@tanstack/vue-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,17 +11,17 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "4039-152"
14
+ "uid": "1937-156"
15
15
  },
16
16
  {
17
17
  "name": "vue-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "4039-154",
20
+ "uid": "1937-158",
21
21
  "name": "merge-proxy.ts"
22
22
  },
23
23
  {
24
- "uid": "4039-156",
24
+ "uid": "1937-160",
25
25
  "name": "index.ts"
26
26
  }
27
27
  ]
@@ -34,83 +34,83 @@
34
34
  "isRoot": true
35
35
  },
36
36
  "nodeParts": {
37
- "4039-152": {
38
- "renderedLength": 135108,
39
- "gzipLength": 23292,
37
+ "1937-156": {
38
+ "renderedLength": 136655,
39
+ "gzipLength": 23722,
40
40
  "brotliLength": 0,
41
- "mainUid": "4039-151"
41
+ "mainUid": "1937-155"
42
42
  },
43
- "4039-154": {
43
+ "1937-158": {
44
44
  "renderedLength": 1622,
45
45
  "gzipLength": 660,
46
46
  "brotliLength": 0,
47
- "mainUid": "4039-153"
47
+ "mainUid": "1937-157"
48
48
  },
49
- "4039-156": {
49
+ "1937-160": {
50
50
  "renderedLength": 1683,
51
51
  "gzipLength": 677,
52
52
  "brotliLength": 0,
53
- "mainUid": "4039-155"
53
+ "mainUid": "1937-159"
54
54
  }
55
55
  },
56
56
  "nodeMetas": {
57
- "4039-151": {
57
+ "1937-155": {
58
58
  "id": "/packages/table-core/build/esm/index.js",
59
59
  "moduleParts": {
60
- "index.production.js": "4039-152"
60
+ "index.production.js": "1937-156"
61
61
  },
62
62
  "imported": [],
63
63
  "importedBy": [
64
64
  {
65
- "uid": "4039-155"
65
+ "uid": "1937-159"
66
66
  }
67
67
  ]
68
68
  },
69
- "4039-153": {
69
+ "1937-157": {
70
70
  "id": "/packages/vue-table/src/merge-proxy.ts",
71
71
  "moduleParts": {
72
- "index.production.js": "4039-154"
72
+ "index.production.js": "1937-158"
73
73
  },
74
74
  "imported": [],
75
75
  "importedBy": [
76
76
  {
77
- "uid": "4039-155"
77
+ "uid": "1937-159"
78
78
  }
79
79
  ]
80
80
  },
81
- "4039-155": {
81
+ "1937-159": {
82
82
  "id": "/packages/vue-table/src/index.ts",
83
83
  "moduleParts": {
84
- "index.production.js": "4039-156"
84
+ "index.production.js": "1937-160"
85
85
  },
86
86
  "imported": [
87
87
  {
88
- "uid": "4039-151"
88
+ "uid": "1937-155"
89
89
  },
90
90
  {
91
- "uid": "4039-157"
91
+ "uid": "1937-161"
92
92
  },
93
93
  {
94
- "uid": "4039-153"
94
+ "uid": "1937-157"
95
95
  }
96
96
  ],
97
97
  "importedBy": [],
98
98
  "isEntry": true
99
99
  },
100
- "4039-157": {
100
+ "1937-161": {
101
101
  "id": "vue",
102
102
  "moduleParts": {},
103
103
  "imported": [],
104
104
  "importedBy": [
105
105
  {
106
- "uid": "4039-155"
106
+ "uid": "1937-159"
107
107
  }
108
108
  ],
109
109
  "isExternal": true
110
110
  }
111
111
  },
112
112
  "env": {
113
- "rollup": "2.76.0"
113
+ "rollup": "2.77.0"
114
114
  },
115
115
  "options": {
116
116
  "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 = {
@@ -3942,6 +4005,7 @@
3942
4005
  exports.aggregationFns = aggregationFns;
3943
4006
  exports.buildHeaderGroups = buildHeaderGroups;
3944
4007
  exports.createColumn = createColumn;
4008
+ exports.createColumnHelper = createColumnHelper;
3945
4009
  exports.createRow = createRow;
3946
4010
  exports.createTable = createTable;
3947
4011
  exports.defaultColumnSizing = defaultColumnSizing;