ui-sdk-table-web 0.0.0-stage → 0.2.7
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/LICENSE +21 -0
- package/README.md +7 -2
- package/dist/table-licenses.md +411 -0
- package/dist/table-reference-licenses.md +411 -0
- package/dist/table-reference.js +10631 -0
- package/dist/table.js +10147 -0
- package/docs/api-web-components.md +319 -0
- package/docs/cell-editing.md +234 -0
- package/docs/cells-and-slots.md +106 -0
- package/docs/component-body.md +42 -0
- package/docs/component-cell.md +31 -0
- package/docs/component-col.md +31 -0
- package/docs/component-edit-error.md +31 -0
- package/docs/component-editor.md +31 -0
- package/docs/component-fill-handle.md +31 -0
- package/docs/component-foot.md +33 -0
- package/docs/component-head.md +33 -0
- package/docs/component-header-cell.md +31 -0
- package/docs/component-header-row.md +33 -0
- package/docs/component-plain-row.md +33 -0
- package/docs/component-resizer.md +33 -0
- package/docs/component-root.md +40 -0
- package/docs/component-row.md +33 -0
- package/docs/component-spacer.md +31 -0
- package/docs/controller-and-view.md +108 -0
- package/docs/examples-agents.md +62 -0
- package/docs/examples-column-definitions.md +172 -0
- package/docs/examples-formula-writer.md +262 -0
- package/docs/examples-styling.md +180 -0
- package/docs/examples.md +125 -0
- package/docs/excel-formulas.md +119 -0
- package/docs/export.md +107 -0
- package/docs/fill.md +111 -0
- package/docs/first-table.md +111 -0
- package/docs/formats.md +158 -0
- package/docs/groups-and-totals.md +117 -0
- package/docs/history.md +126 -0
- package/docs/installation.md +52 -0
- package/docs/llms.txt +13 -0
- package/docs/pages-and-server-mode.md +219 -0
- package/docs/range-copy-and-paste.md +108 -0
- package/docs/reference-columns.md +179 -0
- package/docs/reference-controller.md +137 -0
- package/docs/reference-export.md +59 -0
- package/docs/reference-formulas.md +42 -0
- package/docs/reference-implementation.md +29 -0
- package/docs/reference-messages.md +55 -0
- package/docs/reference-view.md +116 -0
- package/docs/row-numbers-and-letters.md +109 -0
- package/docs/rows.md +310 -0
- package/docs/selection-and-keyboard.md +134 -0
- package/docs/sheet-formulas.md +322 -0
- package/docs/sheet-options.md +192 -0
- package/docs/skills.md +41 -0
- package/docs/sort-filter-and-search.md +268 -0
- package/docs/state-and-events.md +86 -0
- package/docs/styled-table.md +229 -0
- package/docs/table-components.md +100 -0
- package/docs/web-components.md +113 -0
- package/package.json +49 -3
- package/src/browser.ts +3 -0
- package/src/index.ts +77 -0
- package/src/reference-browser.ts +3 -0
- package/src/reference-dom.ts +206 -0
- package/src/reference.ts +63 -0
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
When composing the parts yourself, put your content inside the cell part. The [reference implementation](./reference-implementation.md) also lets you replace content by name. For example, `col-state` replaces only the cells of the `state` column; all other data cells still show their formatted text.
|
|
6
|
+
|
|
7
|
+
Set `table.renderers` on the reference element. A `'col-state'` renderer can return a `mark` element whose `textContent` is the cell’s `text`.
|
|
8
|
+
|
|
9
|
+
```ts title="slots.ts"
|
|
10
|
+
import { type ColumnDef } from 'ui-sdk-table-core'
|
|
11
|
+
|
|
12
|
+
import { defineReferenceTable, type ReferenceTableElement } from 'ui-sdk-table-web/reference'
|
|
13
|
+
|
|
14
|
+
type Task = {
|
|
15
|
+
id: string
|
|
16
|
+
title: string
|
|
17
|
+
owner: string
|
|
18
|
+
state: 'todo' | 'doing' | 'done'
|
|
19
|
+
hours: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const tasks: Task[] = [
|
|
23
|
+
{ id: 't1', title: 'Write the release notes', owner: 'Ada', state: 'doing', hours: 3 },
|
|
24
|
+
{ id: 't2', title: 'Fix the login page', owner: 'Tomas', state: 'done', hours: 5 },
|
|
25
|
+
{ id: 't3', title: 'Plan the next sprint', owner: 'Maya', state: 'todo', hours: 2 },
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const STATES = { todo: 'To do', doing: 'Doing', done: 'Done' }
|
|
29
|
+
|
|
30
|
+
const columns: ColumnDef<Task>[] = [
|
|
31
|
+
{ id: 'title', header: 'Task' },
|
|
32
|
+
{ id: 'owner', header: 'Owner' },
|
|
33
|
+
{ id: 'state', header: 'State' },
|
|
34
|
+
{ id: 'hours', header: 'Hours', format: 'integer', aggregate: 'sum' },
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
export default function mount(host: HTMLElement) {
|
|
38
|
+
const style = document.createElement('style')
|
|
39
|
+
style.textContent = `.task-state { text-align: center } .task-state mark { padding: 2px 8px; border-radius: 1em } .task-state [data-state='done'] { background: #dcfce7; color: #14532d } .task-state [data-state='doing'] { background: #e0e7ff; color: #1e3a8a }`
|
|
40
|
+
host.append(style)
|
|
41
|
+
defineReferenceTable()
|
|
42
|
+
const table = document.createElement('ui-reference-table') as ReferenceTableElement<Task>
|
|
43
|
+
table.setAttribute('aria-label', 'Tasks of the week')
|
|
44
|
+
table.rows = tasks
|
|
45
|
+
table.columns = columns
|
|
46
|
+
table.cellAttrs = (cell) =>
|
|
47
|
+
cell.kind === 'cell' && cell.column.id === 'state' ? { class: 'task-state' } : undefined
|
|
48
|
+
table.renderers = {
|
|
49
|
+
'col-state': ({ row }) => {
|
|
50
|
+
const mark = document.createElement('mark')
|
|
51
|
+
mark.dataset.state = row.state
|
|
52
|
+
mark.textContent = STATES[row.state]
|
|
53
|
+
return mark
|
|
54
|
+
},
|
|
55
|
+
'header-hours': ({ label }) => `${label} (sum below)`,
|
|
56
|
+
'foot-title': () => 'All tasks',
|
|
57
|
+
empty: () => 'No task this week.',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
host.append(table)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
## The slots
|
|
67
|
+
|
|
68
|
+
| Content name | Fills | Gets |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| `cell`, `col-{column id}` | A body cell | `row`, `node`, `column`, `value`, `text`, `format`, `selected`, `expanded`, `expandable`, `level`, `pinned`, `toggleSelected`, `toggleExpanded`, `formula` |
|
|
71
|
+
| `header`, `header-{column id}` | A header cell | `column`, `label`, `leaf`, `sort`, `sortIndex`, `toggleSort`, `pin`, `selectColumn`, `formula` |
|
|
72
|
+
| `foot`, `foot-{column id}` | A footer cell | `column`, `value`, `text`, `totals`, `aggregate`, `setAggregate` |
|
|
73
|
+
| `group` | The label cell of a group row | See [Groups and totals](./groups-and-totals.md) |
|
|
74
|
+
| `group-total`, `group-total-{column id}` | A cell of a group row under a column | See [Groups and totals](./groups-and-totals.md) |
|
|
75
|
+
| `detail` | The detail row of a row | `row`, `node`, `toggleExpanded` |
|
|
76
|
+
| `editor`, `edit-{column id}` | The editor of a cell | See [Editing](./cell-editing.md) |
|
|
77
|
+
| `empty` | The body, when no row passes the filters | Nothing |
|
|
78
|
+
| `loading` | The body, while `loading` is set and the table has no rows | Nothing |
|
|
79
|
+
|
|
80
|
+
A column-specific name wins over the general name: `col-state` wins over `cell`.
|
|
81
|
+
|
|
82
|
+
- `text` is the value with the format of the cell, else of its column. Show `text` unless the cell needs more.
|
|
83
|
+
- `row` is your own row object. `node` is the place of the row in the table: its `id`, its `depth` and its `parentId`.
|
|
84
|
+
- 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.
|
|
85
|
+
|
|
86
|
+
## Attributes of rows and cells
|
|
87
|
+
|
|
88
|
+
`rowAttrs`, `cellAttrs` and `sectionAttrs` give attributes to the elements that the table renders, such as a class or a `data-*` attribute of your own.
|
|
89
|
+
|
|
90
|
+
- `rowAttrs(context)` gets the kind of the row: `header`, `letters`, `row`, `group`, `detail`, `foot` or `empty`, with the row or the group.
|
|
91
|
+
- `cellAttrs(context)` gets the kind of the cell: `header`, `letter`, `cell`, `group`, `group-total`, `detail`, `foot` or `empty`, with the column and the row.
|
|
92
|
+
- `sectionAttrs` is an object with `head`, `body` and `foot`.
|
|
93
|
+
|
|
94
|
+
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.
|
|
95
|
+
|
|
96
|
+
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.
|
|
97
|
+
|
|
98
|
+
## Names
|
|
99
|
+
|
|
100
|
+
- **Attribute types:** `RowAttrsContext`, `CellAttrsContext`, `PartAttrs`.
|
|
101
|
+
|
|
102
|
+
For shared methods and result types, see [Controller](./reference-controller.md) and [View](./reference-view.md).
|
|
103
|
+
|
|
104
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
105
|
+
|
|
106
|
+
See the [More tiles of the sink](https://ui-sdk-table.fdts.dev/?page=sink&only=more).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# TableBody
|
|
2
|
+
|
|
3
|
+
Render the rows of the current view so the text on screen stays aligned with grid focus after sorting or filtering.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Place the body between the head and the optional foot. Render a [row](./component-row.md) for each ordinary entry in the displayed model; branch for groups or detail rows if you enable them. An empty message belongs in a plain row instead.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-body></ui-table-body>
|
|
13
|
+
<script type="module">
|
|
14
|
+
const grid = document.querySelector('ui-table')
|
|
15
|
+
const body = grid.querySelector('ui-table-body')
|
|
16
|
+
const start = grid.api.headerRowCount()
|
|
17
|
+
body.replaceChildren(...grid.api.rows().map((flat, i) => {
|
|
18
|
+
const row = document.createElement('ui-table-row')
|
|
19
|
+
row.value = flat.id
|
|
20
|
+
row.index = start + i
|
|
21
|
+
return row
|
|
22
|
+
}))
|
|
23
|
+
</script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Inputs
|
|
27
|
+
|
|
28
|
+
No table-specific props. Body part state supplies `rows` (the flattened display entries) and `headerRowCount: number`. A data entry has `node.kind === 'row'` and carries the original object at `node.row`. Start body coordinates at `headerRowCount`, not at zero. A child renderer needs its own row type; it cannot infer that type from an ancestor.
|
|
29
|
+
|
|
30
|
+
## Behavior and changes
|
|
31
|
+
|
|
32
|
+
The body binds pinning, sticky positioning and the row window. It has no selection or sort event of its own: the root changes the model, then you render the new order. When building a windowed body, use the window segments and [spacers](./component-spacer.md), not a loop over every source row.
|
|
33
|
+
|
|
34
|
+
## Try it
|
|
35
|
+
|
|
36
|
+
[Jump to row 5,000 in the row window](./rows.md#the-row-window).
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
41
|
+
|
|
42
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableCell
|
|
2
|
+
|
|
3
|
+
Make one displayed value a focusable grid cell without writing navigation or selection handlers.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Put the cell in a row and supply its text or control as content. The coordinates connect it to the model; passing a number as `value` would not render that number. Render the [editor](./component-editor.md) in place of the value when the cell enters edit mode.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-cell value="order-7:price" row="1" col="0">12</ui-table-cell>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
`value: string` is a stable part key. `row: number` and `col: number` are zero-based grid positions, including header rows. Optional numeric `colspan` and `rowspan` describe a rectangle from that first position and otherwise act as one. Leave `header` unset for a data cell. Cell part state includes `editing`, `checking`, `error` and `fillHandle`.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
The primitive gives the active cell `tabindex="0"` and handles focus, arrow keys and pointer presses. With the corresponding options on, it also handles range selection, clipboard events and starting an edit. Try F2 on an editable cell; an accepted save reports edits at the root rather than mutating the record. Native controls inside a cell keep their own input and clipboard behavior.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Move between planets with the arrow keys](./table-components.md).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableCol
|
|
2
|
+
|
|
3
|
+
Apply the model’s width to a column without rendering another header or data cell.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
In a native table put one column part per visible leaf in a `colgroup` before the head, in display order. Its key follows the column when it moves. The part is not a `ColumnDef`: define the column and its width on the root first.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-col value="price"></ui-table-col>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
`value: string` is the column id from the definitions. There is no width prop on this part. If the model has a width, the part exposes it as `--table-column-width` in pixels; otherwise it leaves the variable unset.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
Use `[data-slot="table-col"] { width: var(--table-column-width); }` in a native table. A resize updates this column’s width; `data-column` identifies it and `data-pinned` identifies its pinned edge, if any. The part has no keyboard or pointer handlers. Put the interactive [resizer](./component-resizer.md) in the header cell instead.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Drag a header edge, then move or pin its column](https://ui-sdk-table.fdts.dev/docs/column-definitions.md#width-order-and-pins).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableEditError
|
|
2
|
+
|
|
3
|
+
Show the validation message where the open editor can name it as its error.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
When the cell reports an `error`, put this part beside its editor inside the cell and render the message as its content. The part provides the association, not the error text or a second validation step.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-edit-error value='["order-7","price"]'>Price must be positive.</ui-table-edit-error>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
`value: string` is the same `cellKey(rowId, columnId)` as the editor. It does not take an error string as `value`. Use the cell’s `error` for content; omit the part when there is no error.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
The primitive generates an id for the message and sets `aria-errormessage` on the invalid editor to that id. Do not generate ids by hand. There is no error-part event to subscribe to: the column’s parser or schema refuses a value, and the cell reflects the refusal.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Edit a price and try a value the column refuses](./cell-editing.md).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableEditor
|
|
2
|
+
|
|
3
|
+
Give the active edit a text field that participates in validation, save, cancel and grid focus.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Render the editor inside its data cell only while that cell is editing. Use its sibling [error part](./component-edit-error.md) to display a refusal. The component part renders an input; for custom elements put a native `input` inside the editor tag.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-editor value='["order-7","price"]'><input></ui-table-editor>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
`value: string` is the editing cell’s identity from `cellKey(rowId, columnId)` in `ui-sdk-table-core`. It is not the draft text. Let the behavior bind the input and initialize its contents. An eligible numeric field gets `inputmode="decimal"`, not `type="number"`.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
The editor handles `keydown` and `focusout`. Enter requests a save; Escape cancels. A pending check makes the field read-only and `aria-busy`; a refusal keeps it open with `aria-invalid` and a link to the error. Handle the root’s cell-edit report to apply accepted changes to your rows.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Edit a price and try a value the column refuses](./cell-editing.md).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableFillHandle
|
|
2
|
+
|
|
3
|
+
Let a person drag from the corner of a selected range to fill neighbouring cells.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Inside the one cell whose `fillHandle` state is true, add the handle beside the displayed value. Give `[data-slot="table-fill-handle"]` a visible size and position in your stylesheet. Do not put a handle in every editable cell.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-fill-handle></ui-table-fill-handle>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
No table-specific props or cell id. The source is the current selection. Configure `fillHandle` on the root: `true`, `false`, `'vertical'` or `'horizontal'`. The `sheet` preset turns it on unless explicitly disabled.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
A pointer press starts the fill, and the root tracks the drag even if the row window removes the original cell. The handle is hidden from assistive technology and adds no tab stop. Fill keys or `fillCells` provide alternatives. A successful multi-cell fill is one edit report and one history step when history is enabled; a refusal changes none of the cells.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Drag the square to extend a series](./fill.md).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# TableFoot
|
|
2
|
+
|
|
3
|
+
Group the footer rows without turning a total into a selectable data record.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Put the foot after the body. Inside it, render a [plain row](./component-plain-row.md) with `footer` set and cells for the totals you want to show. The foot does not calculate totals. Supply the totals from your data, or read them from a table controller with `getTotals`; do not sum just the rows currently mounted in the window.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-foot>
|
|
13
|
+
<ui-table-plain-row footer index="4"></ui-table-plain-row>
|
|
14
|
+
</ui-table-foot>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
|
|
19
|
+
No table-specific props. The root owns aggregate definitions, any supplied totals, and `stickyFooter` (off by default). Footer position belongs on the row, not on this section.
|
|
20
|
+
|
|
21
|
+
## Behavior and changes
|
|
22
|
+
|
|
23
|
+
The foot has role `rowgroup` and binds the pinning and sticky behaviors so footer cells can line up with body columns. The footer row, not the foot itself, is marked `data-sticky="bottom"` when it sticks. There is no footer change event.
|
|
24
|
+
|
|
25
|
+
## Try it
|
|
26
|
+
|
|
27
|
+
[Compare the footer total with a group total](./groups-and-totals.md).
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
32
|
+
|
|
33
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# TableHead
|
|
2
|
+
|
|
3
|
+
Group the header rows so their cells can share the pinned-column offsets and sticky-row measurements.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Put the head before the body. Add one [header row](./component-header-row.md) for each level of headings, and one more above them if you render column letters. Put header cells inside those rows, not directly in the head.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-head>
|
|
13
|
+
<ui-table-header-row value="head" index="0"></ui-table-header-row>
|
|
14
|
+
</ui-table-head>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
|
|
19
|
+
No table-specific props. The head neither takes a list of columns nor generates headings. The root options and column definitions determine the header model; your composition supplies its markup.
|
|
20
|
+
|
|
21
|
+
## Behavior and changes
|
|
22
|
+
|
|
23
|
+
The head binds a `rowgroup` to the pinning and sticky-row behaviors. It does not sort, take focus or emit a header-click event. Enter to sort is handled by a sortable leaf header cell. Style the section with `[data-slot="table-head"]`.
|
|
24
|
+
|
|
25
|
+
## Try it
|
|
26
|
+
|
|
27
|
+
[Scroll a table with sticky headings and totals](https://ui-sdk-table.fdts.dev/docs/styling.md).
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
32
|
+
|
|
33
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableHeaderCell
|
|
2
|
+
|
|
3
|
+
Render a heading that participates in grid focus, sorting and column operations.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Place a header cell inside a header row. It uses the same primitive slot as a [data cell](./component-cell.md). The component adapters render a `th`; the custom element uses the `header` property on the ordinary cell tag. Put the column label here, and a [resizer](./component-resizer.md) if this leaf column can resize.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-cell value="head:price" header row="0" col="0">Price</ui-table-cell>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
`value: string` identifies the part; key a heading by column id, never by visual position. `row: number` and `col: number` locate its first grid position (both start at zero). Set `header` to give the cell the `columnheader` role: choosing a `th` alone does not set that role. Optional numeric `colspan` and `rowspan` default to one. For a row-header column in the body, omit `header`.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
Focus a sortable leaf heading and press Enter: the root requests a sort change, and `aria-sort` reflects the applied sort. The cell binds column reordering and pinning for a leaf, and Alt with a horizontal arrow resizes a resizable column. For pointer sorting, supply a control that calls `toggleSort`; the cell does not turn every click into a sort.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Drag a header edge, then move or pin its column](https://ui-sdk-table.fdts.dev/docs/column-definitions.md#width-order-and-pins).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# TableHeaderRow
|
|
2
|
+
|
|
3
|
+
Give a level of column headings its grid position and its own sticky-row identity.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Nest this row in the head and place [header cells](./component-header-cell.md) inside it. For a grouped header, render one row per level. A row of column letters, when enabled, comes before all other headings.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-header-row value="head" index="0">
|
|
13
|
+
<ui-table-cell value="head:price" header row="0" col="0">Price</ui-table-cell>
|
|
14
|
+
</ui-table-header-row>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
|
|
19
|
+
`index: number` is the zero-based grid row. `value?: string` is the part key: give every header row a distinct, stable value even though the type permits omitting it. Otherwise multiple header rows share a part and only the last can stick.
|
|
20
|
+
|
|
21
|
+
## Behavior and changes
|
|
22
|
+
|
|
23
|
+
The primitive supplies role `row` and `aria-rowindex` equal to `index + 1`. With `stickyHeader` on the root it measures this row and marks it `data-sticky="top"`; without it the row scrolls normally. There is no row selection, change callback or key handler on a header row.
|
|
24
|
+
|
|
25
|
+
## Try it
|
|
26
|
+
|
|
27
|
+
[Scroll a table with sticky headings and totals](https://ui-sdk-table.fdts.dev/docs/styling.md).
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
32
|
+
|
|
33
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# TablePlainRow
|
|
2
|
+
|
|
3
|
+
Place an empty message or a footer in the grid without giving it a data-row id.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Use a plain row in the body when there are no records to show, or inside the foot to hold totals. Add the cells yourself. Use a [data row](./component-row.md) instead when a row should reflect record selection, expansion or pinning.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-plain-row index="1">
|
|
13
|
+
<ui-table-cell value="empty" row="1" col="0">No orders</ui-table-cell>
|
|
14
|
+
</ui-table-plain-row>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
|
|
19
|
+
`index: number` is the zero-based grid position. Set `footer?: boolean` for a footer; leave it unset for an ordinary message row. There is no required `value` or record id.
|
|
20
|
+
|
|
21
|
+
## Behavior and changes
|
|
22
|
+
|
|
23
|
+
The primitive supplies role `row` and sets `aria-rowindex` to `index + 1`. A footer gets `data-kind="footer"` and can stick to the bottom when the root has `stickyFooter`; a message row does not stick. There is no row-selection event or expandable state here.
|
|
24
|
+
|
|
25
|
+
## Try it
|
|
26
|
+
|
|
27
|
+
[Scroll a table with sticky headings and totals](https://ui-sdk-table.fdts.dev/docs/styling.md).
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
32
|
+
|
|
33
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# TableResizer
|
|
2
|
+
|
|
3
|
+
Adjust one column’s width with a drag or the keyboard and report the final width separately from the drag steps.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Put the resizer at the edge of a resizable leaf header cell. Render it only where resizing is allowed by the root and column options. Style the handle’s hit area yourself; the headless part has no visible grip by default.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-cell header value="head:price" row="0" col="0">
|
|
13
|
+
Price <ui-table-resizer value="price"></ui-table-resizer>
|
|
14
|
+
</ui-table-cell>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
|
|
19
|
+
`value: string` is the column id, not a pixel width. The root’s `columnWidths` and the column definition supply the width; minimum and maximum widths constrain it. Inspect `data-column` on the handle and `data-dragging` during a drag.
|
|
20
|
+
|
|
21
|
+
## Behavior and changes
|
|
22
|
+
|
|
23
|
+
The part is a focusable vertical separator with an accessible name and current width. Drag with the primary pointer or focus the handle and press Left or Right; Shift takes a larger step. The handle keeps those arrow keys out of grid navigation. The root reports width changes during the gesture (`onColumnWidthsChange`) and reports its end separately (`onColumnWidthsCommit`), including after a keyboard step. On the custom element, listen for `columnwidthschange` and `columnwidthscommit` instead.
|
|
24
|
+
|
|
25
|
+
## Try it
|
|
26
|
+
|
|
27
|
+
[Drag a header edge, then move or pin its column](https://ui-sdk-table.fdts.dev/docs/column-definitions.md#width-order-and-pins).
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
32
|
+
|
|
33
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# TableRoot
|
|
2
|
+
|
|
3
|
+
Connect rows and columns to one grid and supply the parts that render it.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Start here. Put a head and a body inside the root; add a column group or foot if you render widths or totals. Give the root an accessible name with `aria-label` or `aria-labelledby`. A root with data but no children does not generate a single cell.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table aria-label="Orders" selection="multiple"><ui-table-body></ui-table-body></ui-table>
|
|
13
|
+
<script type="module">
|
|
14
|
+
const grid = document.querySelector('ui-table')
|
|
15
|
+
grid.rows = orders
|
|
16
|
+
grid.columns = columns
|
|
17
|
+
grid.selected = []
|
|
18
|
+
grid.addEventListener('selectedchange', event => { grid.selected = event.detail.value })
|
|
19
|
+
</script>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Assign arrays as properties, not JSON attributes. A typed `TableElement<Order>` accepts `ColumnDef<Order>[]`; the inferred tag type uses `unknown`. Change events do not bubble: listen on the root and use `event.preventDefault()` to refuse a cancelable request.
|
|
23
|
+
|
|
24
|
+
## Inputs
|
|
25
|
+
|
|
26
|
+
`rows?: readonly Row[]` and `columns?: readonly ColumnDef<Row>[]` describe the data. Omit them for an empty model. A row needs a stable `id` or a `getRowId` function. The other parts use these ids, not the source array indices. Options such as `selection` and `editable` belong here, not on each row or cell.
|
|
27
|
+
|
|
28
|
+
## Behavior and changes
|
|
29
|
+
|
|
30
|
+
The root supplies the grid (or treegrid) role and row and column counts. It binds grid focus and tracks fill and pick drags that outlive a single cell. Keyboard navigation starts on the focused cell. Listen for state changes at the root: for example, selection is initially empty; `defaultSelected` sets a starting value, while `selected` is controlled by the owner.
|
|
31
|
+
|
|
32
|
+
## Try it
|
|
33
|
+
|
|
34
|
+
[Move between planets with the arrow keys](./table-components.md).
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
39
|
+
|
|
40
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# TableRow
|
|
2
|
+
|
|
3
|
+
Keep a visible row attached to the same record when the model changes order.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Render a row inside the body, then add one cell per visible column for an ordinary data row. Use a [plain row](./component-plain-row.md) for a footer or empty message; neither represents a record.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-row value="order-7" index="1">
|
|
13
|
+
<ui-table-cell value="order-7:price" row="1" col="0">12</ui-table-cell>
|
|
14
|
+
</ui-table-row>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
|
|
19
|
+
`value: string` is the displayed entry’s stable id, not a DOM `id`. `index: number` is its current zero-based grid position, including header rows. When a row moves, keep `value` and update `index`. Row part state exposes `selected`, `expanded`, `expandable` and the zero-based `level`.
|
|
20
|
+
|
|
21
|
+
## Behavior and changes
|
|
22
|
+
|
|
23
|
+
The row exposes `aria-rowindex`, selection and expansion where applicable, and tree position for tree rows. It binds row measurement and sticky positioning for pinned rows. To select with the keyboard, focus a cell and press Space with selection enabled. The cell handles the key and the root reports the new ids; there is no row-level selection callback.
|
|
24
|
+
|
|
25
|
+
## Try it
|
|
26
|
+
|
|
27
|
+
[Select rows and inspect the selected ids](./selection-and-keyboard.md).
|
|
28
|
+
|
|
29
|
+
## API
|
|
30
|
+
|
|
31
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
32
|
+
|
|
33
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# TableSpacer
|
|
2
|
+
|
|
3
|
+
Reserve the height of rows that a windowed body has not mounted.
|
|
4
|
+
|
|
5
|
+
## Composition
|
|
6
|
+
|
|
7
|
+
Insert a spacer in the body wherever the row window leaves a gap. Keep the leading spacer in place even when its size is zero: it marks where the row list begins for scroll measurements.
|
|
8
|
+
|
|
9
|
+
Register the parts with `defineTableElements()` from `ui-sdk-table-web`, or load the standalone parts module. See the [Web Components guide](./web-components.md) for the complete setup.
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<ui-table-spacer value="gap-0" size="144"></ui-table-spacer>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
`value: string` identifies the gap. Use `gap-0` for the first one: the row-window behavior binds its origin to that key. `size: number` is the gap height in pixels, not a count of rows or a grid index.
|
|
18
|
+
|
|
19
|
+
## Behavior and changes
|
|
20
|
+
|
|
21
|
+
Use `--table-spacer-size` in your CSS to give the gap its measured height. A zero-height gap gets `data-empty`; every spacer is `aria-hidden="true"`. It is not a data row, a focus target or a source of selection events. `rowWindow` is off by default on the root.
|
|
22
|
+
|
|
23
|
+
## Try it
|
|
24
|
+
|
|
25
|
+
[Jump to row 5,000 in the row window](./rows.md#the-row-window).
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
See the [table components overview](./table-components.md) for how the parts fit together. For all imports, types and signatures in your renderer:
|
|
30
|
+
|
|
31
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|