@colspec/tanstack 0.1.0 → 0.1.1
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/README.md +11 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,11 +15,11 @@ Register the functions contracts may refer to, once:
|
|
|
15
15
|
```ts
|
|
16
16
|
import { createTableRegistry } from "@colspec/tanstack";
|
|
17
17
|
|
|
18
|
-
const registry = createTableRegistry<
|
|
19
|
-
accessorFns: { "
|
|
20
|
-
cells: { "
|
|
18
|
+
const registry = createTableRegistry<Product>({
|
|
19
|
+
accessorFns: { "inventory.brandModel": (row) => `${row.brand} ${row.model}` },
|
|
20
|
+
cells: { "inventory.statusBadge": ({ getValue }) => renderBadge(getValue()) },
|
|
21
21
|
formatters: {
|
|
22
|
-
"
|
|
22
|
+
"inventory.date": (value: string) => new Date(value).toLocaleDateString(),
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
```
|
|
@@ -29,7 +29,7 @@ Then hydrate a validated contract:
|
|
|
29
29
|
```ts
|
|
30
30
|
import { hydrateContract } from "@colspec/tanstack";
|
|
31
31
|
|
|
32
|
-
const result = hydrateContract<typeof features,
|
|
32
|
+
const result = hydrateContract<typeof features, Product>(contract, registry);
|
|
33
33
|
|
|
34
34
|
if (result.ok) {
|
|
35
35
|
const { columns, options } = result.value;
|
|
@@ -40,12 +40,12 @@ if (result.ok) {
|
|
|
40
40
|
|
|
41
41
|
## How names resolve
|
|
42
42
|
|
|
43
|
-
| In the contract
|
|
44
|
-
|
|
|
45
|
-
| `"sortFn": "alphanumeric"`
|
|
46
|
-
| `"sortFn": "auto"`
|
|
47
|
-
| `"cell": { "ref": "
|
|
48
|
-
| `"header": "Name"`
|
|
43
|
+
| In the contract | Resolves to |
|
|
44
|
+
| -------------------------------------------- | ----------------------------------------- |
|
|
45
|
+
| `"sortFn": "alphanumeric"` | TanStack's built-in function of that name |
|
|
46
|
+
| `"sortFn": "auto"` | Passed through; TanStack chooses |
|
|
47
|
+
| `"cell": { "ref": "inventory.statusBadge" }` | Your registered function |
|
|
48
|
+
| `"header": "Name"` | Literal text |
|
|
49
49
|
|
|
50
50
|
A name that can't be found produces a `missing-reference` or `unknown-builtin`
|
|
51
51
|
diagnostic. colspec never substitutes a different function, and never executes
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colspec/tanstack",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@tanstack/table-core": "^9.2.6"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@colspec/core": "0.1.
|
|
8
|
+
"@colspec/core": "0.1.1"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@repo/eslint-config": "0.0.0",
|