@tanstack/svelte-table 8.2.6 → 8.3.0

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.
@@ -11,25 +11,25 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "4039-171"
14
+ "uid": "1937-175"
15
15
  },
16
16
  {
17
17
  "name": "svelte-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "4039-173",
20
+ "uid": "1937-177",
21
21
  "name": "placeholder.svelte"
22
22
  },
23
23
  {
24
- "uid": "4039-175",
24
+ "uid": "1937-179",
25
25
  "name": "placeholder.ts"
26
26
  },
27
27
  {
28
- "uid": "4039-177",
28
+ "uid": "1937-181",
29
29
  "name": "render-component.ts"
30
30
  },
31
31
  {
32
- "uid": "4039-179",
32
+ "uid": "1937-183",
33
33
  "name": "index.ts"
34
34
  }
35
35
  ]
@@ -42,160 +42,160 @@
42
42
  "isRoot": true
43
43
  },
44
44
  "nodeParts": {
45
- "4039-171": {
46
- "renderedLength": 135108,
47
- "gzipLength": 23292,
45
+ "1937-175": {
46
+ "renderedLength": 136655,
47
+ "gzipLength": 23722,
48
48
  "brotliLength": 0,
49
- "mainUid": "4039-170"
49
+ "mainUid": "1937-174"
50
50
  },
51
- "4039-173": {
51
+ "1937-177": {
52
52
  "renderedLength": 927,
53
53
  "gzipLength": 445,
54
54
  "brotliLength": 0,
55
- "mainUid": "4039-172"
55
+ "mainUid": "1937-176"
56
56
  },
57
- "4039-175": {
57
+ "1937-179": {
58
58
  "renderedLength": 246,
59
59
  "gzipLength": 184,
60
60
  "brotliLength": 0,
61
- "mainUid": "4039-174"
61
+ "mainUid": "1937-178"
62
62
  },
63
- "4039-177": {
63
+ "1937-181": {
64
64
  "renderedLength": 1458,
65
65
  "gzipLength": 539,
66
66
  "brotliLength": 0,
67
- "mainUid": "4039-176"
67
+ "mainUid": "1937-180"
68
68
  },
69
- "4039-179": {
69
+ "1937-183": {
70
70
  "renderedLength": 2915,
71
71
  "gzipLength": 958,
72
72
  "brotliLength": 0,
73
- "mainUid": "4039-178"
73
+ "mainUid": "1937-182"
74
74
  }
75
75
  },
76
76
  "nodeMetas": {
77
- "4039-170": {
77
+ "1937-174": {
78
78
  "id": "/packages/table-core/build/esm/index.js",
79
79
  "moduleParts": {
80
- "index.production.js": "4039-171"
80
+ "index.production.js": "1937-175"
81
81
  },
82
82
  "imported": [],
83
83
  "importedBy": [
84
84
  {
85
- "uid": "4039-178"
85
+ "uid": "1937-182"
86
86
  }
87
87
  ]
88
88
  },
89
- "4039-172": {
89
+ "1937-176": {
90
90
  "id": "/packages/svelte-table/src/placeholder.svelte",
91
91
  "moduleParts": {
92
- "index.production.js": "4039-173"
92
+ "index.production.js": "1937-177"
93
93
  },
94
94
  "imported": [
95
95
  {
96
- "uid": "4039-180"
96
+ "uid": "1937-184"
97
97
  }
98
98
  ],
99
99
  "importedBy": [
100
100
  {
101
- "uid": "4039-174"
101
+ "uid": "1937-178"
102
102
  }
103
103
  ]
104
104
  },
105
- "4039-174": {
105
+ "1937-178": {
106
106
  "id": "/packages/svelte-table/src/placeholder.ts",
107
107
  "moduleParts": {
108
- "index.production.js": "4039-175"
108
+ "index.production.js": "1937-179"
109
109
  },
110
110
  "imported": [
111
111
  {
112
- "uid": "4039-180"
112
+ "uid": "1937-184"
113
113
  },
114
114
  {
115
- "uid": "4039-172"
115
+ "uid": "1937-176"
116
116
  }
117
117
  ],
118
118
  "importedBy": [
119
119
  {
120
- "uid": "4039-178"
120
+ "uid": "1937-182"
121
121
  }
122
122
  ]
123
123
  },
124
- "4039-176": {
124
+ "1937-180": {
125
125
  "id": "/packages/svelte-table/src/render-component.ts",
126
126
  "moduleParts": {
127
- "index.production.js": "4039-177"
127
+ "index.production.js": "1937-181"
128
128
  },
129
129
  "imported": [
130
130
  {
131
- "uid": "4039-180"
131
+ "uid": "1937-184"
132
132
  }
133
133
  ],
134
134
  "importedBy": [
135
135
  {
136
- "uid": "4039-178"
136
+ "uid": "1937-182"
137
137
  }
138
138
  ]
139
139
  },
140
- "4039-178": {
140
+ "1937-182": {
141
141
  "id": "/packages/svelte-table/src/index.ts",
142
142
  "moduleParts": {
143
- "index.production.js": "4039-179"
143
+ "index.production.js": "1937-183"
144
144
  },
145
145
  "imported": [
146
146
  {
147
- "uid": "4039-170"
147
+ "uid": "1937-174"
148
148
  },
149
149
  {
150
- "uid": "4039-174"
150
+ "uid": "1937-178"
151
151
  },
152
152
  {
153
- "uid": "4039-180"
153
+ "uid": "1937-184"
154
154
  },
155
155
  {
156
- "uid": "4039-181"
156
+ "uid": "1937-185"
157
157
  },
158
158
  {
159
- "uid": "4039-176"
159
+ "uid": "1937-180"
160
160
  }
161
161
  ],
162
162
  "importedBy": [],
163
163
  "isEntry": true
164
164
  },
165
- "4039-180": {
165
+ "1937-184": {
166
166
  "id": "svelte/internal",
167
167
  "moduleParts": {},
168
168
  "imported": [],
169
169
  "importedBy": [
170
170
  {
171
- "uid": "4039-178"
171
+ "uid": "1937-182"
172
172
  },
173
173
  {
174
- "uid": "4039-174"
174
+ "uid": "1937-178"
175
175
  },
176
176
  {
177
- "uid": "4039-176"
177
+ "uid": "1937-180"
178
178
  },
179
179
  {
180
- "uid": "4039-172"
180
+ "uid": "1937-176"
181
181
  }
182
182
  ],
183
183
  "isExternal": true
184
184
  },
185
- "4039-181": {
185
+ "1937-185": {
186
186
  "id": "svelte/store",
187
187
  "moduleParts": {},
188
188
  "imported": [],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "4039-178"
191
+ "uid": "1937-182"
192
192
  }
193
193
  ],
194
194
  "isExternal": true
195
195
  }
196
196
  },
197
197
  "env": {
198
- "rollup": "2.76.0"
198
+ "rollup": "2.77.0"
199
199
  },
200
200
  "options": {
201
201
  "gzip": true,
@@ -24,6 +24,9 @@
24
24
  *
25
25
  * @license MIT
26
26
  */
27
+ // Is this type a tuple?
28
+ // If this type is a tuple, what indices are allowed?
29
+ ///
27
30
  function functionalUpdate(updater, input) {
28
31
  return typeof updater === 'function' ? updater(input) : updater;
29
32
  }
@@ -109,13 +112,27 @@
109
112
  const resolvedColumnDef = { ...defaultColumn,
110
113
  ...columnDef
111
114
  };
112
- let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : resolvedColumnDef.accessorKey) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
115
+ const accessorKey = resolvedColumnDef.accessorKey;
116
+ let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.replace('.', '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
113
117
  let accessorFn;
114
118
 
115
119
  if (resolvedColumnDef.accessorFn) {
116
120
  accessorFn = resolvedColumnDef.accessorFn;
117
- } else if (resolvedColumnDef.accessorKey) {
118
- accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
121
+ } else if (accessorKey) {
122
+ // Support deep accessor keys
123
+ if (accessorKey.includes('.')) {
124
+ accessorFn = originalRow => {
125
+ let result = originalRow;
126
+
127
+ for (const key of accessorKey.split('.')) {
128
+ result = result[key];
129
+ }
130
+
131
+ return result;
132
+ };
133
+ } else {
134
+ accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
135
+ }
119
136
  }
120
137
 
121
138
  if (!id) {
@@ -3101,6 +3118,52 @@
3101
3118
  return row;
3102
3119
  };
3103
3120
 
3121
+ // type Person = {
3122
+ // firstName: string
3123
+ // lastName: string
3124
+ // age: number
3125
+ // visits: number
3126
+ // status: string
3127
+ // progress: number
3128
+ // nested: {
3129
+ // foo: [
3130
+ // {
3131
+ // bar: 'bar'
3132
+ // }
3133
+ // ]
3134
+ // bar: { subBar: boolean }[]
3135
+ // baz: {
3136
+ // foo: 'foo'
3137
+ // bar: {
3138
+ // baz: 'baz'
3139
+ // }
3140
+ // }
3141
+ // }
3142
+ // }
3143
+ // const test: DeepKeys<Person> = 'nested.foo.0.bar'
3144
+ // const test2: DeepKeys<Person> = 'nested.bar'
3145
+ // const helper = createColumnHelper<Person>()
3146
+ // helper.accessor('nested.foo', {
3147
+ // cell: info => info.getValue(),
3148
+ // })
3149
+ // helper.accessor('nested.foo.0.bar', {
3150
+ // cell: info => info.getValue(),
3151
+ // })
3152
+ // helper.accessor('nested.bar', {
3153
+ // cell: info => info.getValue(),
3154
+ // })
3155
+ function createColumnHelper() {
3156
+ return {
3157
+ accessor: (accessor, column) => {
3158
+ return typeof accessor === 'function' ? { ...column,
3159
+ accessorFn: accessor
3160
+ } : { ...column,
3161
+ accessorKey: accessor
3162
+ };
3163
+ }
3164
+ };
3165
+ }
3166
+
3104
3167
  function getCoreRowModel() {
3105
3168
  return table => memo(() => [table.options.data], data => {
3106
3169
  const rowModel = {
@@ -4015,6 +4078,7 @@
4015
4078
  exports.aggregationFns = aggregationFns;
4016
4079
  exports.buildHeaderGroups = buildHeaderGroups;
4017
4080
  exports.createColumn = createColumn;
4081
+ exports.createColumnHelper = createColumnHelper;
4018
4082
  exports.createRow = createRow;
4019
4083
  exports.createSvelteTable = createSvelteTable;
4020
4084
  exports.createTable = createTable;