ui-sdk-table-vue 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # ui-sdk-table-vue
2
2
 
3
- The headless table for Vue: `Table`, its parts, slots, a `v-model` for each state, and `createTableController`. It renders a real `<table>` without any looks. A styled table is the work of the consumer, and is built on it. The docs of the package are in `docs`: start with `docs/llms.txt`.
3
+ The headless table for Vue: `Table`, its parts, slots, a `v-model` for each state, and `createTableController`. It renders a real `<table>` without any looks. A styled table is the work of the consumer, and is built on it.
4
4
 
5
5
  ```vue
6
6
  <script setup lang="ts">
@@ -18,86 +18,9 @@ const columns: ColumnDef<Person>[] = [
18
18
  </template>
19
19
  ```
20
20
 
21
- - `ui-sdk-table-vue/export` holds the CSV and Excel writers. Load it with `import()` where a person asks for a file, so a page without an export does not carry it.
22
- - The package ships TypeScript source (`exports` points at `src`), so an app compiles it with its own compiler options.
23
- - The export is named `Table`. An app that registers a component of its own with that name (for example by file name) imports this one under another name: `import { Table as HeadlessTable } from 'ui-sdk-table-vue'`.
24
- - `rowAttrs` and `cellAttrs` give attributes to rows and cells. The table spreads them first and its own attributes after them, so a caller cannot replace a part prop (`value`, `index`, `row`, `col`, `colspan`) or a state attribute (`aria-*`, `data-*` of the table).
25
- - `createTableController()` can be used before the table mounts: `subscribe` waits for the table and runs once when it is there. `useTableSearch` and `useTableView` can be called before the table too.
21
+ ## Docs
26
22
 
27
- ## What a styled table builds on
28
-
29
- | Need | What the table gives |
30
- | --- | --- |
31
- | Looks | `data-slot` on every part (`table`, `table-row`, `table-cell`, ...), state as `aria-*` and `data-*` attributes (`data-kind`, `data-pinned`, `data-sticky`, `data-selected`, `data-active`, `data-format` with the format of the column on each of its cells, `data-sort-index` with the place of a column in the sort on its header cell), and `rowAttrs`, `cellAttrs`, `sectionAttrs` for classes |
32
- | Widths and offsets | A table whose columns can be resized is as wide as its columns (`inline-size: var(--table-width)`) and must not stretch to its frame: a drag starts from the width that a column has on the screen. `--table-width`, `--table-column-width`, `--table-pin-offset`, `--table-sticky-offset`, `--table-row-height`, `--table-spacer-size`. A page with a fixed header or footer sets `--table-sticky-top` and `--table-sticky-bottom` on the table or a parent, and the sticky rows stop there |
33
- | A checkbox or an expand column | A column with `lead: true`: always first, never in the column order or the pins, and it sticks with the first column that is pinned to the start. Its cells carry `data-lead`, for a width of their own |
34
- | Controls beside the table | `createTableController()`, then `getView()` for the state and the pages, `subscribe()` for when to read again, and one method for each action. In Vue, `useTableView(controller)` is a ref of the view that follows the table, and is `undefined` until the table is there |
35
- | A search field | `useTableSearch(controller)`: see below |
36
- | Filter controls | `getFacets(columnId)`: see below. `sliderBounds(range, { steps: 100 })` gives a slider its ends and a step that a thumb can use: 1, 2 or 5 times a power of ten of the step of a cell, and about a hundred stops |
37
- | A data sheet | The `sheet` option: see below |
38
- | Formulas | The `formulas` option and the entry `ui-sdk-table-vue/formulas`: see "Formulas" below |
39
- | Totals | The footer row, the cells of a group row, `getTotals()`, and the `totals` option for totals that only a server knows |
40
-
41
- ## Group rows
42
-
43
- A group row has a label cell and, from the first column with an `aggregate` on, one cell for each column: the total of the group stands under its header and over the total of the footer. The label covers the columns before that. It ends where pinned columns end, so it sticks or scrolls as one cell.
44
-
45
- - `#group` fills the label cell. It gets `group`, `text`, `expanded`, `level`, `totals`, `totalTexts`, `toggleExpanded`, the `path` of the group (the groups above it and itself, each with `column`, `value` and `text`, for a label such as "Europe / Finland") and `covered`, the columns under the label. A total of a covered column has no cell of its own.
46
- - `#group-total-{column id}` and `#group-total` fill a cell under a column, in the way of `#foot-{column id}` and `#foot`. They get `group`, `column`, `value`, `text`, `totals`, `expanded`, `level` and `path`. A column without an `aggregate` has an empty cell, with an empty `text`.
47
- - `cellAttrs` gets the kind `group` for the label cell and `group-total` for the cells under a column. The cells carry `data-kind`: `group-label`, `group-total` or `group-blank`.
48
- - `:group-totals="false"` gives one cell as wide as the table, as a table without any `aggregate` has.
49
- - Enter on any cell of a group row opens or closes the group, and Space selects its rows. A group row holds no values: its cells are never marked as part of a cell range, and a copy gives an empty line for it.
50
-
51
- The footer, the group rows, `getTotals` and the totals of an export read one function. A total counts the rows that pass the filters, on every page, with their child rows; a pinned row that the filter refuses is in view and not in a total. With rows from a server (`manualFilter`, `manualPage`) the table has one page of rows and its totals are of that page: pass `:totals="{ table: { amount: 1234 }, groups: { 'group/team=Design': { amount: 800 } } }"` for the totals of the server.
52
-
53
- ## Filter controls
54
-
55
- `controller.getFacets(columnId)` answers with what a control offers. The facets follow the search and the filters of the other columns, and never the filter of the column itself. `getFacets(columnId, { rows: 'all' })` gives the facets of every row.
56
-
57
- | Control | Read |
58
- | --- | --- |
59
- | A list of values | `values`: each with `value`, `text` in the format of the column, and `count`. A value that the filter names stays in the list with the count 0 when no row holds it any more. A combobox of the design system can search the list by `text`; `fuzzyScore` of `@ui-sdk/core/text-match` is the search of the table |
60
- | A slider | `range`: `min`, `max` and `step`, the smallest change that the format of the column shows. `sliderBounds(range)` gives ends that are whole steps |
61
- | A date picker | `days`: the first and the last day as `YYYY-MM-DD`, in the time zone of the column; `dates` holds the two moments |
62
-
63
- A facet is counted when it is asked for, and kept until the search or another filter changes. With `manualFilter`, the rows are what the server sent; the `facets` option gives the choices of every row.
64
-
65
- ## A search field with a pause
66
-
67
- ```vue
68
- <script setup lang="ts">
69
- import { createTableController, Table, useTableSearch } from 'ui-sdk-table-vue'
70
-
71
- const controller = createTableController()
72
- const search = useTableSearch(controller)
73
- </script>
74
-
75
- <template>
76
- <input
77
- v-model="search.text.value"
78
- type="search"
79
- @keydown.escape="search.clear()"
80
- @keydown.enter="search.flush()"
81
- />
82
- <Table :rows="people" :columns="columns" :controller="controller" :search-debounce="200" />
83
- </template>
84
- ```
85
-
86
- The field shows each letter at once. The table filters when the typing pauses for `searchDebounce` milliseconds (200 without the prop), with one change of `filter` and the reason `input-change`. `clear` and `setSearch` act at once and drop a text that waits, and so do `clearFilters` and a new search text from the owner of `v-model:filter`. `search.pending` says that a text waits. The table itself says nothing to a screen reader about a search: announce the rows found when `filter` changes, which is one time after the pause.
87
-
88
- Without Vue, the same is `controller.inputSearch(text, event)`, `controller.flushSearch()`, and `search` and `searchPending` of `getView()`. `createDebounce(run, { debounce })` is the utility under it, with `call`, `cancel`, `flush` and `pending`.
89
-
90
- ## Sort modes
91
-
92
- - `multi-sort="modifier"` (the default): a press on a header replaces the sort, and a press with Shift, Control or Command adds the column. `"none"`: one column at a time, whatever key is held. `"always"`: each press adds the column. Enter on a header follows the same rule.
93
- - `always-sorted`: a press on the only column of the sort turns the order and never clears it. Off by default.
94
- - `sortIndex` of the `#header` slot and `data-sort-index` of the header cell hold the place of the column in the sort, from 1, and are absent for a column that is not sorted.
95
- - `toggleSort(event)` of the `#header` slot passes the event, and the table reads the keys. `controller.toggleSort(id, { append: true })` and `sortBy(id, direction, { append: true })` throw in the mode `none`.
96
- - A `sort` of the owner with more columns than the mode allows is left as it is. With `manualSort`, the rules are the same: the state is the request.
97
-
98
- ## Columns back to their start
99
-
100
- `controller.hideAllColumns()` hides every column that can be hidden, in one change; a column with `hideable: false` and a `lead` column stay, and the first column in view stays when no other would. `resetColumnVisibility()`, `resetColumnOrder()` and `resetColumnPinning()` bring a state back to what the table started with (its `default…` prop, else the empty state), with the reason `reset`. `resetColumnWidths()` takes every width away. A `v-model:column-visibility` that hides every column gives a table without columns; the table does not correct the state of its owner.
23
+ The docs are at https://falldownthesystem.github.io/ui-sdk-table/. The same pages ship in this package as Markdown in `docs`: start with `docs/llms.txt`, and `docs/README.md` lists every page.
101
24
 
102
25
  ## A data sheet
103
26
 
package/docs/README.md CHANGED
@@ -10,6 +10,22 @@ Start with [llms.txt](./llms.txt): what the library is and the conventions every
10
10
  - [Installation](./installation.md): Add the packages to your Vue app.
11
11
  - [First table](./first-table.md): Put a table on a page and give it looks.
12
12
 
13
+ ## Using the table
14
+
15
+ - [Columns](./column-definitions.md): Say what each column shows, how its value becomes text, and how a person can change its place and width.
16
+ - [Cells and slots](./cells-and-slots.md): Put your own content in a header, a cell, a footer or the empty table, and give rows and cells your own attributes.
17
+ - [State and events](./state-and-events.md): Start a state where you want it, hold it in your app, and hear each change with its reason.
18
+ - [Styling](./styling.md): Give the table the looks of your app with CSS that reads its parts and its state.
19
+ - [Controller and view](./controller-and-view.md): Change the table from a control beside it, and read what it shows now.
20
+ - [Sort, filter and search](./sort-filter-and-search.md): Sort by one or more columns, filter each column, and search every column with a pause in the typing.
21
+ - [Groups and totals](./groups-and-totals.md): Group the rows by the values of a column, and show a total of a column under it, for each group and for the table.
22
+ - [Pages and server mode](./pages-and-server-mode.md): Show the rows a page at a time, and take the rows, the pages, the sort and the filters from a server.
23
+ - [Rows](./rows.md): Show rows with child rows, a detail row under a row, rows pinned to an edge, and many thousand rows in a window.
24
+ - [Selection and keyboard](./selection-and-keyboard.md): Let a person select rows, and move through the table with the keys of a grid.
25
+ - [Editing](./cell-editing.md): Let a person change the value of a cell, check it first, and put it into your rows.
26
+ - [Export](./export.md): Write the rows of the table to a CSV or an Excel file, with the text that the screen shows.
27
+ - [Agents](./agents.md): Let an agent find a table on the page, read it and act on it, with the same actions that a person has.
28
+
13
29
  ## Source and licence
14
30
 
15
31
  The format of these pages, the layout of `llms.txt` and parts of the text of Introduction, Installation and First table follow the docs of UI SDK (`@ui-sdk/vue/docs`, https://ui-sdk.dev), which are licensed under the Apache License 2.0.
package/docs/agents.md ADDED
@@ -0,0 +1,71 @@
1
+ # Agents
2
+
3
+ Let an agent find a table on the page, read it and act on it, with the same actions that a person has.
4
+
5
+ The table is a UI SDK primitive with an agent part. The agent of UI SDK (`createAgent` of `@ui-sdk/vue/agent`) sees every component of the page that has an accessible name, with its state and its actions. A table is found by its `aria-label`.
6
+
7
+ ```vue title="agent.vue"
8
+ <script setup lang="ts">
9
+ import { Button } from '@ui-sdk/vue/button'
10
+ import { createAgent } from '@ui-sdk/vue/agent'
11
+ import { Table, type ColumnDef } from 'ui-sdk-table-vue'
12
+ import { shallowRef } from 'vue'
13
+
14
+ type Ship = { id: string; name: string; port: string; tons: number }
15
+
16
+ const ships: Ship[] = [
17
+ { id: 's1', name: 'Northern Star', port: 'Bergen', tons: 3200 },
18
+ { id: 's2', name: 'Blue Heron', port: 'Rotterdam', tons: 5100 },
19
+ { id: 's3', name: 'Sea Lark', port: 'Bergen', tons: 1800 },
20
+ ]
21
+
22
+ const columns: ColumnDef<Ship>[] = [
23
+ { id: 'name', header: 'Ship', sortable: true },
24
+ { id: 'port', header: 'Port', sortable: true },
25
+ { id: 'tons', header: 'Tons', sortable: true, format: 'integer' },
26
+ ]
27
+
28
+ // The agent of UI SDK sees every component of the page that has a name, and its actions.
29
+ const agent = createAgent()
30
+ const answer = shallowRef('')
31
+
32
+ async function act(action: string, args: unknown[]) {
33
+ const result = await agent.act({ steps: [{ ref: 'Ships in port', action, args }] })
34
+ answer.value = result.ok ? `${action} done.` : `Refused: ${result.error?.message ?? ''}`
35
+ }
36
+ </script>
37
+
38
+ <template>
39
+ <div>
40
+ <Button @click="act('sortBy', ['tons', 'desc'])">Heaviest first</Button>
41
+ <Button @click="act('sortBy', ['weight', 'desc'])">Sort by weight</Button>
42
+ </div>
43
+ <p role="status">{{ answer }}</p>
44
+ <Table :rows="ships" :columns="columns" aria-label="Ships in port" />
45
+ </template>
46
+ ```
47
+
48
+ Press Heaviest first: the agent sorts by tons. Press Sort by weight: no column has that id, and the table refuses with a message that lists the columns.
49
+
50
+ ## What an agent sees
51
+
52
+ - `agent.snapshot()` lists the table with its name, its state and its actions.
53
+ - The snapshot holds the controlled state of the table, such as `sort`, `filter` and `selected`. It holds no cell format and no formula: an agent reads those with `getCellFormat` and `getFormulaSummary`, so a snapshot of 50,000 rows stays small.
54
+ - `agent.act({ steps: [{ ref: 'Ships in port', action: 'sortBy', args: ['tons', 'desc'] }] })` calls an action. Its answer has `ok`, and `error.message` when the table refused.
55
+
56
+ ## The actions
57
+
58
+ The actions are the methods of the controller: sort, search and filter, groups and pages, rows, selection, columns, cells, the sheet, formulas, `exportData`, and the reads `getFacets`, `getTotals` and `getSelectionSummary`.
59
+
60
+ An action checks its arguments. A wrong one throws a message that lists the valid values, such as `No column "weight" to sort by. Columns: name, port, tons.` The agent reads it and tries again.
61
+
62
+ ## A change from an agent
63
+
64
+ A change that an agent made reaches the events as any change does, with `details.source` set to `agent`. Listen to it for analytics; never give an agent other rules than a person.
65
+
66
+ ## Keep going
67
+
68
+ - The UI SDK docs for agents are at `node_modules/@ui-sdk/vue/docs/agents.md`: the bridge, the WebMCP tools and the rules of what an agent may do.
69
+ - [Controller and view](./controller-and-view.md) lists every method.
70
+
71
+ See the [More tiles of the sink](https://falldownthesystem.github.io/ui-sdk-table/?page=sink&only=more).
@@ -0,0 +1,132 @@
1
+ # Editing
2
+
3
+ Let a person change the value of a cell, check it first, and put it into your rows.
4
+
5
+ The table never writes a row. It reports each edit through `@cell-edit`, and the app puts the value into its rows. `applyEdits` does that for plain rows.
6
+
7
+ ```vue title="prices.vue"
8
+ <script setup lang="ts">
9
+ import {
10
+ applyEdits,
11
+ Table,
12
+ type CellEdit,
13
+ type ColumnDef,
14
+ type StandardSchemaV1,
15
+ type TableEditDetails,
16
+ } from 'ui-sdk-table-vue'
17
+ import { shallowRef } from 'vue'
18
+
19
+ type Product = { id: string; name: string; price: number; stock: number }
20
+
21
+ // Any Standard Schema works: Zod, Valibot, ArkType. This one is written by hand.
22
+ function check(test: (value: unknown) => string | undefined): StandardSchemaV1 {
23
+ return {
24
+ '~standard': {
25
+ version: 1,
26
+ vendor: 'example',
27
+ validate: (value) => {
28
+ const message = test(value)
29
+ return message === undefined ? { value } : { issues: [{ message }] }
30
+ },
31
+ },
32
+ }
33
+ }
34
+
35
+ const columns: ColumnDef<Product>[] = [
36
+ { id: 'name', header: 'Product', editable: false },
37
+ {
38
+ id: 'price',
39
+ header: 'Price',
40
+ format: 'decimal',
41
+ numberKeyboard: true,
42
+ schema: check((value) =>
43
+ typeof value === 'number' && value >= 0 ? undefined : 'A price is a number, zero or more.',
44
+ ),
45
+ },
46
+ {
47
+ id: 'stock',
48
+ header: 'In stock',
49
+ format: 'integer',
50
+ numberKeyboard: true,
51
+ schema: check((value) =>
52
+ Number.isInteger(value) && Number(value) >= 0 ? undefined : 'Stock is a whole number.',
53
+ ),
54
+ },
55
+ ]
56
+
57
+ // The rows are yours. The table reports an edit and never writes a row.
58
+ const rows = shallowRef<Product[]>([
59
+ { id: 'p1', name: 'Green tea', price: 6.5, stock: 40 },
60
+ { id: 'p2', name: 'Dark coffee', price: 9.9, stock: 12 },
61
+ { id: 'p3', name: 'Oat cookies', price: 3.2, stock: 75 },
62
+ ])
63
+ const last = shallowRef('Nothing edited yet.')
64
+
65
+ function onCellEdit(edits: readonly CellEdit<Product>[], details: TableEditDetails) {
66
+ rows.value = applyEdits(rows.value, edits)
67
+ const [edit] = edits
68
+ if (edit)
69
+ last.value = `${edit.row.name}: ${edit.column.header} ${edit.previous} to ${edit.value}, by ${details.reason}`
70
+ }
71
+ </script>
72
+
73
+ <template>
74
+ <Table :rows="rows" :columns="columns" editable aria-label="Prices" @cell-edit="onCellEdit" />
75
+ <p role="status">{{ last }}</p>
76
+ </template>
77
+ ```
78
+
79
+ Double-press a price, type 7, and press Enter. The line under the table says what changed. Type -1 and the editor stays open with the reason. Product names cannot be edited.
80
+
81
+ ## Turn it on
82
+
83
+ - `editable` on the table lets a person edit every cell. `editable` on a column says otherwise for its cells: `false`, or a function `(row) => boolean` for some rows.
84
+ - `@cell-edit` gets `(edits, details)`. Each edit has `rowId`, `columnId`, `row` (your object, as it was before), `column`, `value` and `previous`. `details.reason` says how it came: `enter-key`, `tab-key`, `focus-out`, `paste` or `imperative`. `details.cancel()` refuses the edit.
85
+ - `applyEdits(rows, edits, getRowId?)` returns a new array with a new object for each row that changed. The other rows stay the same objects. It finds the row of an edit by its object, and by its id when the object was replaced already. Pass the `getRowId` of the table when it has one. It reads the top level only: the child rows of a tree need your own code.
86
+
87
+ ## Keys
88
+
89
+ | Key | On a cell that can be edited |
90
+ | --- | --- |
91
+ | Enter, F2 or a double press | Opens the editor with the value |
92
+ | A character | Opens the editor with that character |
93
+ | Enter in the editor | Saves, and focus goes back to the cell |
94
+ | Tab, Shift+Tab in the editor | Saves and goes to the next or the cell before |
95
+ | Escape in the editor | Closes it and puts the value back |
96
+ | A press elsewhere | Saves |
97
+
98
+ The arrows in the editor move the caret. Without an editor, Tab leaves the table.
99
+
100
+ ## Check a value
101
+
102
+ A text becomes a value in two steps:
103
+
104
+ 1. `parse(text, row)` of the column makes the value. Without it, the value that the cell holds now decides: a number stays a number, a boolean a boolean, a date a date, and anything else gets the text. An empty text empties a number or a date.
105
+ 2. `schema` of the column checks the value. Any Standard Schema works: Zod, Valibot, ArkType. A refusal keeps the editor open with the message of the schema.
106
+
107
+ A check can answer with a promise. The editor then waits (`data-checking`), and Escape takes the edit back.
108
+
109
+ `numberKeyboard: true` on a column gives the field of its editor `inputmode="decimal"`, so a phone shows its number keyboard. The field stays a text field and never `type="number"`.
110
+
111
+ ## Your own editor
112
+
113
+ `#editor` and `#edit-{column id}` fill the editor of a cell. They get `row`, `column`, `value`, `text`, `error`, `checking`, `mode`, `typed`, `inputMode`, `save(value, event)` and `cancel()`. The control must take focus itself. A `save` goes through the same check as the field of the table.
114
+
115
+ ## From code
116
+
117
+ `controller.editCell(rowId, columnId, value)` gives a cell a value with the check of its column, and reports it with the reason `imperative`. It throws with the reason when the value is refused. `startEdit` opens the editor of a cell in view, and `cancelEdit` closes it.
118
+
119
+ ## Attributes
120
+
121
+ - `data-editable` on a cell that can be edited, `data-editing` while its editor is open, `data-checking` while a check runs.
122
+ - The editor is `[data-slot='table-editor']`, with `aria-invalid` and `data-invalid` after a refusal. Its name is "Edit Price" (message `editCell`).
123
+ - The reason of a refusal is `[data-slot='table-edit-error']`, which the editor names with `aria-errormessage`.
124
+
125
+ ## Names
126
+
127
+ - **Options:** `editable`, `onCellEdit` (`@cell-edit`); column keys `editable`, `parse`, `schema`, `numberKeyboard`.
128
+ - **Controller:** `editCell`, `startEdit`, `cancelEdit`.
129
+ - **Slots:** `#editor`, `#edit-{column id}`.
130
+ - **Exports:** `applyEdits`, `cellValue`, `emptyValue`, and the types `CellEdit`, `TableEditDetails`, `TableEditReason`, `StandardSchemaV1`, `EditorSlotProps`.
131
+
132
+ See the [Edit tiles of the sink](https://falldownthesystem.github.io/ui-sdk-table/?page=sink&only=edit).
@@ -0,0 +1,124 @@
1
+ # Cells and slots
2
+
3
+ Put your own content in a header, a cell, a footer or the empty table, and give rows and cells your own attributes.
4
+
5
+ Every cell of the table is a Vue slot. A slot gets the row, the column, the value and its text, and the functions that act on its row. Without a slot, a cell shows the text of its value.
6
+
7
+ ```vue title="slots.vue"
8
+ <script setup lang="ts">
9
+ import { Table, type ColumnDef } from 'ui-sdk-table-vue'
10
+
11
+ type Task = {
12
+ id: string
13
+ title: string
14
+ owner: string
15
+ state: 'todo' | 'doing' | 'done'
16
+ hours: number
17
+ }
18
+
19
+ const tasks: Task[] = [
20
+ { id: 't1', title: 'Write the release notes', owner: 'Ada', state: 'doing', hours: 3 },
21
+ { id: 't2', title: 'Fix the login page', owner: 'Tomas', state: 'done', hours: 5 },
22
+ { id: 't3', title: 'Plan the next sprint', owner: 'Maya', state: 'todo', hours: 2 },
23
+ ]
24
+
25
+ const STATES = { todo: 'To do', doing: 'Doing', done: 'Done' }
26
+
27
+ const columns: ColumnDef<Task>[] = [
28
+ { id: 'title', header: 'Task' },
29
+ { id: 'owner', header: 'Owner' },
30
+ { id: 'state', header: 'State' },
31
+ { id: 'hours', header: 'Hours', format: 'integer', aggregate: 'sum' },
32
+ ]
33
+ </script>
34
+
35
+ <template>
36
+ <Table
37
+ :rows="tasks"
38
+ :columns="columns"
39
+ :cell-attrs="
40
+ (cell) =>
41
+ cell.kind === 'cell' && cell.column.id === 'state' ? { class: 'state' } : undefined
42
+ "
43
+ aria-label="Tasks of the week"
44
+ >
45
+ <!-- A slot for one column wins over the slot for every cell. -->
46
+ <template #col-state="{ row }">
47
+ <mark :data-state="row.state">{{ STATES[row.state] }}</mark>
48
+ </template>
49
+ <template #header-hours="{ label }">{{ label }} (sum below)</template>
50
+ <template #foot-title>All tasks</template>
51
+ <template #empty>No task this week.</template>
52
+ </Table>
53
+ </template>
54
+
55
+ <style scoped>
56
+ mark {
57
+ padding: 2px 8px;
58
+ border-radius: 999px;
59
+ background: #e4e4e7;
60
+ color: #18181b;
61
+ font-size: 13px;
62
+ }
63
+
64
+ mark[data-state='done'] {
65
+ background: #dcfce7;
66
+ color: #14532d;
67
+ }
68
+
69
+ mark[data-state='doing'] {
70
+ background: #e0e7ff;
71
+ color: #1e3a8a;
72
+ }
73
+ </style>
74
+
75
+ <style scoped>
76
+ /* `cellAttrs` gives the cells of the state column a class. The table renders them, so the rule reaches them through :deep(). */
77
+ :deep(.state) {
78
+ text-align: center;
79
+ }
80
+ </style>
81
+ ```
82
+
83
+ The State column shows a badge from its own slot. The Hours header has its own text, and the footer shows the sum under it.
84
+
85
+ ## The slots
86
+
87
+ | Slot | Fills | Gets |
88
+ | --- | --- | --- |
89
+ | `#cell`, `#col-{column id}` | A body cell | `row`, `node`, `column`, `value`, `text`, `format`, `selected`, `expanded`, `expandable`, `level`, `pinned`, `toggleSelected`, `toggleExpanded`, `formula` |
90
+ | `#header`, `#header-{column id}` | A header cell | `column`, `label`, `leaf`, `sort`, `sortIndex`, `toggleSort`, `pin`, `selectColumn`, `formula` |
91
+ | `#foot`, `#foot-{column id}` | A footer cell | `column`, `value`, `text`, `totals`, `aggregate`, `setAggregate` |
92
+ | `#group` | The label cell of a group row | See [Groups and totals](./groups-and-totals.md) |
93
+ | `#group-total`, `#group-total-{column id}` | A cell of a group row under a column | See [Groups and totals](./groups-and-totals.md) |
94
+ | `#detail` | The detail row of a row | `row`, `node`, `toggleExpanded` |
95
+ | `#editor`, `#edit-{column id}` | The editor of a cell | See [Editing](./cell-editing.md) |
96
+ | `#empty` | The body, when no row passes the filters | Nothing |
97
+ | `#loading` | The body, while `loading` is set and the table has no rows | Nothing |
98
+
99
+ A slot for one column wins over the slot for every column: `#col-state` wins over `#cell`.
100
+
101
+ - `text` is the value with the format of the cell, else of its column. Show `text` unless the cell needs more.
102
+ - `row` is your own row object. `node` is the place of the row in the table: its `id`, its `depth` and its `parentId`.
103
+ - A header slot of a sortable column replaces the sort button too. Call `toggleSort(event)` from your own button, and pass the event: the table reads the Shift key from it.
104
+
105
+ ## Attributes of rows and cells
106
+
107
+ `rowAttrs`, `cellAttrs` and `sectionAttrs` give attributes to the elements that the table renders, such as a class or a `data-*` attribute of your own.
108
+
109
+ - `rowAttrs(context)` gets the kind of the row: `header`, `letters`, `row`, `group`, `detail`, `foot` or `empty`, with the row or the group.
110
+ - `cellAttrs(context)` gets the kind of the cell: `header`, `letter`, `cell`, `group`, `group-total`, `detail`, `foot` or `empty`, with the column and the row.
111
+ - `sectionAttrs` is an object with `head`, `body` and `foot`.
112
+
113
+ The table spreads these first and its own attributes after them. A caller cannot replace a part prop (`value`, `index`, `row`, `col`, `colspan`), a role, a `tabindex` or a state attribute of the table (`aria-*` and the `data-*` attributes of the table). Such a name in the answer is left out.
114
+
115
+ The table calls `rowAttrs` when it renders its rows, not for a new selection or a new active cell. Show such state with the attributes of the table, such as `aria-selected`. Pass the same function while its answers stay the same: a new function renders every row again.
116
+
117
+ A scoped style of your component does not reach the elements that the table renders. Use `:deep()`, or a style that is not scoped.
118
+
119
+ ## Names
120
+
121
+ - **Slot props types:** `CellSlotProps`, `HeaderSlotProps`, `FootSlotProps`, `GroupSlotProps`, `GroupTotalSlotProps`, `DetailSlotProps`, `EditorSlotProps`, `RowHeaderSlotProps`, `LetterSlotProps`, `TableSlots`.
122
+ - **Attribute types:** `TableAttrsProps`, `RowAttrsContext`, `CellAttrsContext`, `PartAttrs`.
123
+
124
+ See the [More tiles of the sink](https://falldownthesystem.github.io/ui-sdk-table/?page=sink&only=more).