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,219 @@
|
|
|
1
|
+
# Pages and server mode
|
|
2
|
+
|
|
3
|
+
Show the rows a page at a time, and take the rows, the pages, the sort and the filters from a server.
|
|
4
|
+
|
|
5
|
+
## Pages
|
|
6
|
+
|
|
7
|
+
A `page` state of `{ page, pageSize }` shows one page of the rows. Without it, the table shows every row. The page counts from 1.
|
|
8
|
+
|
|
9
|
+
```ts title="pages.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 Invoice = { id: string; number: string; client: string; amount: number }
|
|
15
|
+
|
|
16
|
+
const CLIENTS = ['Northway', 'Sola', 'Arc', 'Brightline', 'Kestrel']
|
|
17
|
+
const invoices: Invoice[] = Array.from({ length: 23 }, (_, index) => ({
|
|
18
|
+
id: `i${index + 1}`,
|
|
19
|
+
number: `INV-${String(1001 + index)}`,
|
|
20
|
+
client: CLIENTS[index % CLIENTS.length] ?? '',
|
|
21
|
+
amount: 400 + ((index * 137) % 900),
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
const columns: ColumnDef<Invoice>[] = [
|
|
25
|
+
{ id: 'number', header: 'Invoice' },
|
|
26
|
+
{ id: 'client', header: 'Client', sortable: true },
|
|
27
|
+
{ id: 'amount', header: 'Amount', sortable: true, format: 'integer' },
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
function button(label: string, action: () => void) {
|
|
31
|
+
const el = document.createElement('button')
|
|
32
|
+
el.type = 'button'
|
|
33
|
+
el.textContent = label
|
|
34
|
+
el.addEventListener('click', action)
|
|
35
|
+
return el
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function mount(host: HTMLElement) {
|
|
39
|
+
defineReferenceTable()
|
|
40
|
+
const table = document.createElement('ui-reference-table') as ReferenceTableElement<Invoice>
|
|
41
|
+
table.setAttribute('aria-label', 'Invoices')
|
|
42
|
+
table.rows = invoices
|
|
43
|
+
table.columns = columns
|
|
44
|
+
table.page = { page: 1, pageSize: 5 }
|
|
45
|
+
table.addEventListener('pagechange', ({ detail }) => {
|
|
46
|
+
table.page = detail.value
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
host.append(table)
|
|
50
|
+
const nav = document.createElement('nav')
|
|
51
|
+
nav.setAttribute('aria-label', 'Pages of the invoices')
|
|
52
|
+
const previous = button('Previous', () => table.api?.previousPage())
|
|
53
|
+
const next = button('Next', () => table.api?.nextPage())
|
|
54
|
+
const links = Array.from({ length: table.api?.getView().pageCount ?? 1 }, (_, i) =>
|
|
55
|
+
button(String(i + 1), () => table.api?.setPage(i + 1)),
|
|
56
|
+
)
|
|
57
|
+
nav.append(previous, ...links, next)
|
|
58
|
+
host.append(nav)
|
|
59
|
+
const status = document.createElement('p')
|
|
60
|
+
status.setAttribute('role', 'status')
|
|
61
|
+
host.append(status)
|
|
62
|
+
const api = table.api
|
|
63
|
+
if (!api) return
|
|
64
|
+
function update() {
|
|
65
|
+
const view = table.api?.getView()
|
|
66
|
+
if (!view) return
|
|
67
|
+
previous.disabled = view.page <= 1
|
|
68
|
+
next.disabled = view.page >= view.pageCount
|
|
69
|
+
links.forEach((link, i) => {
|
|
70
|
+
if (i + 1 === view.page) link.setAttribute('aria-current', 'page')
|
|
71
|
+
else link.removeAttribute('aria-current')
|
|
72
|
+
})
|
|
73
|
+
status.textContent = `Page ${view.page} of ${view.pageCount}, ${view.rowCount} invoices`
|
|
74
|
+
}
|
|
75
|
+
update()
|
|
76
|
+
return api.subscribe(update)
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Press 3 or Next to go to another page. The line under the pages says where you are: page 3 of 5, 23 invoices.
|
|
81
|
+
|
|
82
|
+
- The controls of the pages read the view: `page`, `pageCount`, `rowCount` and `pageSize`. The `Pagination` component of UI SDK draws them.
|
|
83
|
+
- `setPage`, `nextPage`, `previousPage`, `firstPage` and `lastPage` move. `setPageSize(size)` starts again from the first page, and `setPageSize(null)` shows every row.
|
|
84
|
+
- A new search starts on the first page.
|
|
85
|
+
- What the pages count is `pageUnit` of the view: `rows`, `groups` (each group, with its rows on the page of the group), `parents` (each top-level row, with its child rows on its page) or `mixed`.
|
|
86
|
+
|
|
87
|
+
## Rows from a server
|
|
88
|
+
|
|
89
|
+
```ts title="server.ts"
|
|
90
|
+
import { type ColumnDef, type PageState, type SortRule } from 'ui-sdk-table-core'
|
|
91
|
+
|
|
92
|
+
import { defineReferenceTable, type ReferenceTableElement } from 'ui-sdk-table-web/reference'
|
|
93
|
+
|
|
94
|
+
type Person = { id: string; name: string; score: number }
|
|
95
|
+
|
|
96
|
+
// A server in this file: 40 people, sorted and cut into pages after a short wait.
|
|
97
|
+
const PEOPLE: Person[] = Array.from({ length: 40 }, (_, index) => ({
|
|
98
|
+
id: `p${index + 1}`,
|
|
99
|
+
name: `Person ${index + 1}`,
|
|
100
|
+
score: (index * 37) % 100,
|
|
101
|
+
}))
|
|
102
|
+
|
|
103
|
+
function requestPeople(
|
|
104
|
+
sort: readonly SortRule[],
|
|
105
|
+
page: PageState,
|
|
106
|
+
receive: (rows: Person[], total: number) => void,
|
|
107
|
+
) {
|
|
108
|
+
const [rule] = sort
|
|
109
|
+
const sorted = rule
|
|
110
|
+
? PEOPLE.toSorted((a, b) => {
|
|
111
|
+
const order = rule.id === 'score' ? a.score - b.score : a.name.localeCompare(b.name)
|
|
112
|
+
return rule.desc ? -order : order
|
|
113
|
+
})
|
|
114
|
+
: PEOPLE
|
|
115
|
+
const start = (page.page - 1) * page.pageSize
|
|
116
|
+
const timer = setTimeout(
|
|
117
|
+
() => receive(sorted.slice(start, start + page.pageSize), PEOPLE.length),
|
|
118
|
+
200,
|
|
119
|
+
)
|
|
120
|
+
return () => clearTimeout(timer)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const columns: ColumnDef<Person>[] = [
|
|
124
|
+
{ id: 'name', header: 'Name', sortable: true },
|
|
125
|
+
{ id: 'score', header: 'Score', sortable: true, format: 'integer' },
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
function button(label: string, action: () => void) {
|
|
129
|
+
const el = document.createElement('button')
|
|
130
|
+
el.type = 'button'
|
|
131
|
+
el.textContent = label
|
|
132
|
+
el.addEventListener('click', action)
|
|
133
|
+
return el
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export default function mount(host: HTMLElement) {
|
|
137
|
+
defineReferenceTable()
|
|
138
|
+
const table = document.createElement('ui-reference-table') as ReferenceTableElement<Person>
|
|
139
|
+
table.setAttribute('aria-label', 'People from a server')
|
|
140
|
+
table.rows = []
|
|
141
|
+
table.columns = columns
|
|
142
|
+
table.manualSort = true
|
|
143
|
+
table.manualPage = true
|
|
144
|
+
table.sort = []
|
|
145
|
+
table.page = { page: 1, pageSize: 5 }
|
|
146
|
+
let cancel: (() => void) | undefined
|
|
147
|
+
function load() {
|
|
148
|
+
cancel?.()
|
|
149
|
+
table.loading = true
|
|
150
|
+
cancel = requestPeople(
|
|
151
|
+
table.sort ?? [],
|
|
152
|
+
table.page ?? { page: 1, pageSize: 5 },
|
|
153
|
+
(rows, total) => {
|
|
154
|
+
table.rows = rows
|
|
155
|
+
table.rowCount = total
|
|
156
|
+
table.loading = false
|
|
157
|
+
},
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
table.addEventListener('sortchange', ({ detail }) => {
|
|
161
|
+
table.sort = detail.value
|
|
162
|
+
load()
|
|
163
|
+
})
|
|
164
|
+
table.addEventListener('pagechange', ({ detail }) => {
|
|
165
|
+
table.page = detail.value
|
|
166
|
+
load()
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
host.append(table)
|
|
170
|
+
const previous = button('Previous', () => table.api?.previousPage())
|
|
171
|
+
const next = button('Next', () => table.api?.nextPage())
|
|
172
|
+
host.append(previous, next)
|
|
173
|
+
const status = document.createElement('p')
|
|
174
|
+
status.setAttribute('role', 'status')
|
|
175
|
+
host.append(status)
|
|
176
|
+
const api = table.api
|
|
177
|
+
if (!api) return
|
|
178
|
+
function update() {
|
|
179
|
+
const view = table.api?.getView()
|
|
180
|
+
if (!view) return
|
|
181
|
+
previous.disabled = view.page <= 1
|
|
182
|
+
next.disabled = view.lastPageKnown && view.page >= view.pageCount
|
|
183
|
+
status.textContent = view.loading ? 'Loading' : `Page ${view.page} of ${view.pageCount}`
|
|
184
|
+
}
|
|
185
|
+
update()
|
|
186
|
+
const stop = api.subscribe(update)
|
|
187
|
+
load()
|
|
188
|
+
return () => {
|
|
189
|
+
cancel?.()
|
|
190
|
+
stop()
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Press Score to sort, or Next for the next page. The table asks for nothing itself: the app watches the sort and the page, asks its server, and passes the rows that come back.
|
|
196
|
+
|
|
197
|
+
Three options tell the table that a server did the work:
|
|
198
|
+
|
|
199
|
+
- `manualSort`: the rows come in sort order. The table does not sort them. The `sort` state still changes, so the app knows what to ask for.
|
|
200
|
+
- `manualFilter`: the rows come with the search and the filters applied. The table does not filter them.
|
|
201
|
+
- `manualPage`: the rows are one page. The table shows them all, and the pages come from `rowCount`, the number of rows the server has after its filter.
|
|
202
|
+
|
|
203
|
+
A manual stage keeps the state: the sort, the filter and the page are requests to the owner.
|
|
204
|
+
|
|
205
|
+
- Without `rowCount`, a full page has a next page and a page that is not full is the last. An empty page after the first then sends the table one page back, so keep the rows of the page before, or set `loading`, while a page loads. `lastPage` needs the count.
|
|
206
|
+
- A step to the page that the table is on reports no change, so a listener that loads rows does not load them twice.
|
|
207
|
+
- `loading` tells assistive technology that rows are on their way (`aria-busy`), and the table keeps its rows. Without rows, the reference table shows its `loading` content.
|
|
208
|
+
- Every other feature works on the rows that the table has: an export, the totals and "select all" are of the page. Give `totals` for the totals of the server, and `facets` for the choices of every row of a filter control.
|
|
209
|
+
- With `manualPage`, a change of the page, the sort or the filter empties the history of a sheet.
|
|
210
|
+
|
|
211
|
+
## Names
|
|
212
|
+
|
|
213
|
+
- **Types:** `PageUnit`, `ColumnFacetsSource`, `TableTotalsSource`.
|
|
214
|
+
|
|
215
|
+
For shared methods and result types, see [Controller](./reference-controller.md) and [View](./reference-view.md).
|
|
216
|
+
|
|
217
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
218
|
+
|
|
219
|
+
See the [Rows tiles](https://ui-sdk-table.fdts.dev/?page=sink&only=rows) and the [Server tiles](https://ui-sdk-table.fdts.dev/?page=sink&only=server) of the sink.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Range, copy and paste
|
|
2
|
+
|
|
3
|
+
Let a person select a block of cells, copy it, paste into it and read its sum.
|
|
4
|
+
|
|
5
|
+
Use it with `cellSelection` for any table whose cells a person compares or moves to a spreadsheet, and with `editable` too for a table that takes a paste.
|
|
6
|
+
|
|
7
|
+
```ts title="range.ts"
|
|
8
|
+
import { type ColumnDef, applyEdits } from 'ui-sdk-table-core'
|
|
9
|
+
|
|
10
|
+
import { defineReferenceTable, type ReferenceTableElement } from 'ui-sdk-table-web/reference'
|
|
11
|
+
|
|
12
|
+
type Week = { id: string; name: string; mon: number; tue: number; wed: number }
|
|
13
|
+
|
|
14
|
+
const columns: ColumnDef<Week>[] = [
|
|
15
|
+
{ id: 'name', header: 'Name', editable: false },
|
|
16
|
+
{ id: 'mon', header: 'Mon', format: 'decimal' },
|
|
17
|
+
{ id: 'tue', header: 'Tue', format: 'decimal' },
|
|
18
|
+
{ id: 'wed', header: 'Wed', format: 'decimal' },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const rows: Week[] = [
|
|
22
|
+
{ id: 'w1', name: 'Ada', mon: 7.5, tue: 8, wed: 6 },
|
|
23
|
+
{ id: 'w2', name: 'Ben', mon: 8, tue: 7.5, wed: 8 },
|
|
24
|
+
{ id: 'w3', name: 'Cleo', mon: 6, tue: 6, wed: 7.5 },
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
export default function mount(host: HTMLElement) {
|
|
28
|
+
defineReferenceTable()
|
|
29
|
+
const table = document.createElement('ui-reference-table') as ReferenceTableElement<Week>
|
|
30
|
+
table.setAttribute('aria-label', 'Hours of the week')
|
|
31
|
+
table.rows = rows
|
|
32
|
+
table.columns = columns
|
|
33
|
+
table.cellSelection = true
|
|
34
|
+
table.editable = true
|
|
35
|
+
table.addEventListener('celledit', ({ detail }) => {
|
|
36
|
+
table.rows = applyEdits(table.rows ?? [], detail.value)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
host.append(table)
|
|
40
|
+
const status = document.createElement('p')
|
|
41
|
+
status.setAttribute('role', 'status')
|
|
42
|
+
host.append(status)
|
|
43
|
+
status.dataset.testid = 'summary'
|
|
44
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
45
|
+
const update = () => {
|
|
46
|
+
const summary = table.api?.getSelectionSummary()
|
|
47
|
+
status.textContent =
|
|
48
|
+
summary && summary.numbers > 1
|
|
49
|
+
? `${summary.numbers} cells, sum ${summary.texts.sum}, average ${summary.texts.mean}`
|
|
50
|
+
: 'Select two cells or more.'
|
|
51
|
+
}
|
|
52
|
+
update()
|
|
53
|
+
const stop = table.api?.subscribe(() => {
|
|
54
|
+
clearTimeout(timer)
|
|
55
|
+
timer = setTimeout(update, 100)
|
|
56
|
+
})
|
|
57
|
+
return () => {
|
|
58
|
+
clearTimeout(timer)
|
|
59
|
+
stop?.()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Press 7.50 under Mon and press Shift with the right arrow twice: three cells are selected, and the line under the table gives their sum and average. Copy with Control or Command with C, press a cell of Cleo, and paste.
|
|
65
|
+
|
|
66
|
+
## Select a range
|
|
67
|
+
|
|
68
|
+
- A drag over cells, or Shift with an arrow, selects a range.
|
|
69
|
+
- The cells of a range have `data-selected` and `data-range-edge` (`top`, `right`, `bottom`, `left`), so a line around a range is one rule for each side.
|
|
70
|
+
- The state is `cellRange`. The view gives `cellSelection` (`{ from, to, rows, columns }`), by id, data rows only.
|
|
71
|
+
- `controller.selectCells(from, to?)` selects from code; `selectAllCells`, `selectCellRows` and `selectCellColumns` select whole rows or columns, and move the active cell into the range.
|
|
72
|
+
- Escape drops the range.
|
|
73
|
+
- A group row holds no values: its cells are never marked as part of a range.
|
|
74
|
+
|
|
75
|
+
## Copy, cut and paste
|
|
76
|
+
|
|
77
|
+
- Control or Command with C copies the range as text, with tabs between cells and line breaks between rows. A group row gives an empty line. `controller.copyCells()` does the same.
|
|
78
|
+
- A copy holds the plain value of a cell, as the editor shows it, so a paste into the same columns gives the same values.
|
|
79
|
+
- Control or Command with V pastes. A block repeats over a range that it fits a whole number of times: copy two cells, select six, paste, and there are three copies.
|
|
80
|
+
- A paste is all or nothing. Each value passes the `parse` and the schema of its column; one refusal stops the paste before any cell changes.
|
|
81
|
+
- A paste is one report to the cell edit listener with the reason `paste`, and one step of the history.
|
|
82
|
+
- Control or Command with X cuts: the text of a copy, then a clear (reason `cut`). A cut and a paste in another place move the block.
|
|
83
|
+
- A cell that cannot be edited keeps its value.
|
|
84
|
+
|
|
85
|
+
## A summary of the selected cells
|
|
86
|
+
|
|
87
|
+
`getSelectionSummary()` returns `{ cells, count, numbers, sum, mean, min, max, texts }` or `null`.
|
|
88
|
+
|
|
89
|
+
- `cells` is how many cells of data rows are selected, `count` how many hold a value, `numbers` how many hold a number. The rest is of the numbers.
|
|
90
|
+
- Request the summary after the selection rests rather than on every step of a drag. Refresh it after an edit inside the selection.
|
|
91
|
+
- `texts` are in the format of the column when the selection is inside one column of numbers. Else they are plain numbers of the locale, where the average has two decimals more than the values have (`35,391.67` for whole amounts) and six at most.
|
|
92
|
+
- Show it in a plain element and not in a live region.
|
|
93
|
+
- The table keeps the answer for the same selection and rows.
|
|
94
|
+
|
|
95
|
+
## Attributes
|
|
96
|
+
|
|
97
|
+
- `data-cell-selection` on the table, `data-active` on the active cell.
|
|
98
|
+
- `data-selected` and `data-range-edge` on the cells of a range.
|
|
99
|
+
|
|
100
|
+
See the [Sheet tiles of the sink](https://ui-sdk-table.fdts.dev/?page=sink&only=sheet).
|
|
101
|
+
|
|
102
|
+
## Names
|
|
103
|
+
|
|
104
|
+
- **Exports:** `summarize`.
|
|
105
|
+
|
|
106
|
+
For shared methods and result types, see [Controller](./reference-controller.md) and [View](./reference-view.md).
|
|
107
|
+
|
|
108
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# ColumnDef
|
|
2
|
+
|
|
3
|
+
Every key of a column definition, and the shapes of the state that names columns.
|
|
4
|
+
|
|
5
|
+
See [Columns](https://ui-sdk-table.fdts.dev/docs/column-definitions.md) for how they work together.
|
|
6
|
+
|
|
7
|
+
## ColumnDef
|
|
8
|
+
|
|
9
|
+
- `id` (`string`): The id of the column: a key of the state (sort, filter, widths) and of the slots `col-{id}`. Give each column an id of its own.
|
|
10
|
+
- `header?` (`string`): The text of the header. Defaults to the id.
|
|
11
|
+
- `key?` (`string`): The property that holds the cell value. Defaults to `id`.
|
|
12
|
+
- `value?` (`(row: Row) => unknown`): Computes the cell value. Wins over `key`.
|
|
13
|
+
- `columns?` (`readonly ColumnDef<Row>[]`): Child columns. A column with children is a header group and holds no cells.
|
|
14
|
+
- `sortable?` (`boolean`): Whether a press on the header sorts by the column: the header renders a button and gets `aria-sort`. Code can sort by any column with `sortBy`.
|
|
15
|
+
- `compare?` (`(a: unknown, b: unknown, rowA: Row, rowB: Row) => number`): Compares two values for the sort, ascending: a negative number puts `a` first. An empty value goes last in both directions and never reaches it. Without it, numbers, dates and texts of the locale.
|
|
16
|
+
- `filter?` (`FilterKind | FilterMatcher<Row>`): How a column filter matches. Without it, the shape of the filter value decides.
|
|
17
|
+
- `searchable?` (`boolean`): Whether the search reads this column. Defaults to true.
|
|
18
|
+
- `groupable?` (`boolean`): A mark for the controls of the app: whether a person may group by the column. The table groups by any column that `groupBy` names.
|
|
19
|
+
- `aggregate?` (`AggregateName | AggregateFn<Row>`): The total of the column in the footer and in the group rows: a built-in name, or a function of the values and the rows.
|
|
20
|
+
- `format?` (`FormatName`): How the cell value becomes text. Without it, the value is shown as it is.
|
|
21
|
+
- `formatOptions?` (`FormatOptions`): The options of the `format`, such as the decimals, the currency or the time zone.
|
|
22
|
+
- `width?` (`number`): The width in pixels that the column asks for. A resize by a person wins over it.
|
|
23
|
+
- `minWidth?` (`number`): The smallest width in pixels that a resize gives. Without it, the `columnMinWidth` option of the table.
|
|
24
|
+
- `maxWidth?` (`number`): The largest width in pixels that a resize gives. Without it, the `columnMaxWidth` option of the table.
|
|
25
|
+
- `resizable?` (`boolean`): Whether a person can resize the column. Without it, the `resizable` option of the table decides.
|
|
26
|
+
- `reorderable?` (`boolean`): Whether a person can move the column. Without it, the `reorderable` option of the table decides.
|
|
27
|
+
- `lead?` (`boolean`): The column leads the table: it stays before every other column, whatever the column order says, and it sticks to the start as soon as another column is pinned there. A column order and the pins do not hold it. For a top-level column that holds a control of its row, such as a checkbox.
|
|
28
|
+
- `rowHeader?` (`boolean`): The column holds the number of each row, and its cells are the row headers of the table: a screen reader says the number with each cell of the row. Such a column leads the table, as with `lead`, and it is outside every range of cells: a number is never copied, emptied or filled. A press on a number selects the cells of its row. See `rowNumberColumn`.
|
|
29
|
+
- `hideable?` (`boolean`): Whether the column can be hidden. Defaults to true.
|
|
30
|
+
- `editable?` (`boolean | ((row: Row) => boolean)`): Whether a person can edit the cells of the column, or which rows have a cell that can be edited. Without it, the `editable` option of the table decides.
|
|
31
|
+
- `numberKeyboard?` (`boolean`): Whether the editor of a cell asks a phone for its number keyboard (`inputmode="decimal"`): the cells of the column hold numbers. Off by default. The table holds it back where the field can hold a formula, and for a cell whose format is no number format.
|
|
32
|
+
- `allowFormula?` (`boolean`): With formulas: whether a cell of the column takes a text that starts with `=` as a formula. True by default for a cell that can be edited; a column that must keep such a text as its value sets false.
|
|
33
|
+
- `schema?` (`StandardSchemaV1`): Checks a new value before the table reports the edit. Any Standard Schema works: Zod, Valibot, ArkType. A value that the schema refuses keeps the editor open, with the message of the schema.
|
|
34
|
+
- `parse?` (`(text: string, row: Row) => unknown`): Makes the value of a cell from the text of the editor or of a paste. Without it, see `parseText`.
|
|
35
|
+
- `exportable?` (`boolean`): Whether an export holds the column. Defaults to true.
|
|
36
|
+
- `exportValue?` (`(row: Row) => unknown`): The value of a cell in an export, in place of the cell value and its format: for a column whose cell is a slot, or whose file value differs from the screen.
|
|
37
|
+
- `meta?` (`unknown`): Data of the app for the column. The table does not read it.
|
|
38
|
+
|
|
39
|
+
## FormatOptions
|
|
40
|
+
|
|
41
|
+
`formatOptions` of a column takes the options of its `format`. Every format takes the options of `CommonFormatOptions`; the formats below take their own too.
|
|
42
|
+
|
|
43
|
+
### CommonFormatOptions
|
|
44
|
+
|
|
45
|
+
- `nullValue?` (`string`): The text for `null`. Defaults to an empty text.
|
|
46
|
+
- `undefinedValue?` (`string`): The text for `undefined`. Defaults to an empty text.
|
|
47
|
+
- `emptyValue?` (`string`): The text for an empty text. Defaults to an empty text.
|
|
48
|
+
- `invalidValue?` (`string`): The text for a value that the format cannot read. Defaults to an empty text.
|
|
49
|
+
- `prefix?` (`string`): Text before the formatted value.
|
|
50
|
+
- `suffix?` (`string`): Text after the formatted value.
|
|
51
|
+
- `locale?` (`string`): Overrides `FormatContext.locale` for this column.
|
|
52
|
+
|
|
53
|
+
### NumberFormatOptions
|
|
54
|
+
|
|
55
|
+
For `integer`, `decimal` and `number`, and with the options of `currency` and `percentage`.
|
|
56
|
+
|
|
57
|
+
- `roundingMode?` (`RoundingMode`): How a number rounds: `round` (half away from zero), `ceil`, `floor` or `trunc`.
|
|
58
|
+
- `multiplier?` (`number`): A factor that the value is multiplied by before it is shown. 0 changes nothing.
|
|
59
|
+
- `style?` (`'decimal' | 'percent' | 'currency' | 'unit'`): The `style` of `Intl.NumberFormat` for `integer`, `decimal` and `number`. Defaults to `decimal`.
|
|
60
|
+
- `notation?` (`'standard' | 'scientific' | 'engineering' | 'compact'`): The `notation` of `Intl.NumberFormat`, such as `compact` for 1.2K.
|
|
61
|
+
- `compactDisplay?` (`'short' | 'long'`): With `notation: 'compact'`: `short` (1.2K) or `long` (1.2 thousand).
|
|
62
|
+
- `useGrouping?` (`boolean`): Whether thousands are grouped, as in 1,000. Defaults to true.
|
|
63
|
+
- `minimumIntegerDigits?` (`number`): The fewest digits before the decimal sign, filled with zeros.
|
|
64
|
+
- `minimumFractionDigits?` (`number`): The fewest decimals. Defaults to 2 for `decimal`, `number` and `currency`, and 0 for `percentage`. `integer` shows none.
|
|
65
|
+
- `maximumFractionDigits?` (`number`): The most decimals. Defaults to 2 for `decimal`, `number` and `currency`, and 0 for `percentage`, or the minimum when it is larger.
|
|
66
|
+
- `minimumSignificantDigits?` (`number`): The fewest significant digits, as in `Intl.NumberFormat`.
|
|
67
|
+
- `maximumSignificantDigits?` (`number`): The most significant digits, as in `Intl.NumberFormat`.
|
|
68
|
+
|
|
69
|
+
### CurrencyFormatOptions
|
|
70
|
+
|
|
71
|
+
For `currency`, with every option of `NumberFormatOptions`.
|
|
72
|
+
|
|
73
|
+
- `currency?` (`string`): The currency as an ISO 4217 code, such as `USD`. Defaults to `EUR` with `showUnit`.
|
|
74
|
+
- `currencyDisplay?` (`'symbol' | 'code' | 'name' | 'narrowSymbol'`): How the currency shows with `showUnit`: `symbol` (the default), `code`, `name` or `narrowSymbol`.
|
|
75
|
+
- `currencySign?` (`'standard' | 'accounting'`): `accounting` writes a negative amount in parentheses where the locale does so.
|
|
76
|
+
- `showUnit?` (`boolean`): Without it the value is formatted as a plain decimal.
|
|
77
|
+
|
|
78
|
+
### PercentageFormatOptions
|
|
79
|
+
|
|
80
|
+
For `percentage`, with every option of `NumberFormatOptions`.
|
|
81
|
+
|
|
82
|
+
- `scale?` (`'fraction' | 'percent'`): `'fraction'` (default) reads 0.25 as 25 %; `'percent'` reads 25 as 25 %.
|
|
83
|
+
- `showUnit?` (`boolean`): Without it the value is formatted without the % sign.
|
|
84
|
+
|
|
85
|
+
### DateFormatOptions
|
|
86
|
+
|
|
87
|
+
For `date`, `time` and `datetime`.
|
|
88
|
+
|
|
89
|
+
- `dateStyle?` (`'full' | 'long' | 'medium' | 'short'`): The length of the date, as in `Intl.DateTimeFormat`. Defaults to `medium` when no field of the date is set.
|
|
90
|
+
- `timeStyle?` (`'full' | 'long' | 'medium' | 'short'`): The length of the time, as in `Intl.DateTimeFormat`. Defaults to `short` when no field of the time is set.
|
|
91
|
+
- `weekday?` (`'long' | 'short' | 'narrow'`): The weekday, as in `Intl.DateTimeFormat`. A field wins over `dateStyle`.
|
|
92
|
+
- `year?` (`'numeric' | '2-digit'`): The year, as in `Intl.DateTimeFormat`. A field wins over `dateStyle`.
|
|
93
|
+
- `month?` (`'numeric' | '2-digit' | 'long' | 'short' | 'narrow'`): The month, as in `Intl.DateTimeFormat`. A field wins over `dateStyle`.
|
|
94
|
+
- `day?` (`'numeric' | '2-digit'`): The day, as in `Intl.DateTimeFormat`. A field wins over `dateStyle`.
|
|
95
|
+
- `hour?` (`'numeric' | '2-digit'`): The hour, as in `Intl.DateTimeFormat`. A field wins over `timeStyle`.
|
|
96
|
+
- `minute?` (`'numeric' | '2-digit'`): The minute, as in `Intl.DateTimeFormat`. A field wins over `timeStyle`.
|
|
97
|
+
- `second?` (`'numeric' | '2-digit'`): The second, as in `Intl.DateTimeFormat`. A field wins over `timeStyle`.
|
|
98
|
+
- `hour12?` (`boolean`): Whether the clock has 12 hours. Without it, the locale decides.
|
|
99
|
+
- `timeZone?` (`string`): The zone of the clock that a moment shows in, such as `Europe/Paris`. A `YYYY-MM-DD` value is a day and shows that day in every zone. Without it, local time.
|
|
100
|
+
- `timeZoneName?` (`'long' | 'short'`): Writes the name of the zone after the time.
|
|
101
|
+
|
|
102
|
+
### RelativeTimeFormatOptions
|
|
103
|
+
|
|
104
|
+
For `relativeTime`.
|
|
105
|
+
|
|
106
|
+
- `localeMatcher?` (`'best fit' | 'lookup'`): As in `Intl.RelativeTimeFormat`. Defaults to `best fit`.
|
|
107
|
+
- `numeric?` (`'always' | 'auto'`): `auto` writes "yesterday" for -1 day; `always` (the default) writes "1 day ago".
|
|
108
|
+
- `style?` (`'long' | 'short' | 'narrow'`): The length of the words: `long` (the default), `short` or `narrow`.
|
|
109
|
+
- `unit?` (`RelativeTimeUnit`): The unit of the difference. Defaults to `day`.
|
|
110
|
+
- `calculateDifference?` (`boolean`): When false the value is already a difference in `unit`, not a point in time.
|
|
111
|
+
- `capitalize?` (`boolean`): Writes the first letter as a capital.
|
|
112
|
+
- `now?` (`number | Date`): The moment differences are measured from. Defaults to the current time.
|
|
113
|
+
|
|
114
|
+
### PeriodFormatOptions
|
|
115
|
+
|
|
116
|
+
For `period`.
|
|
117
|
+
|
|
118
|
+
- `unit?` (`PeriodUnit`): Which period the value is: the first day of a day, week, month, quarter or year, the moment of an hour, or a number of a day of the week. Defaults to `day`.
|
|
119
|
+
- `weekdays?` (`number`): With `unit: 'weekday'`: the type of `WEEKDAY` that gave the number, 1 (Sunday is 1, the default), 2 (Monday is 1), 3 (Monday is 0) or 11 to 17.
|
|
120
|
+
- `timeZone?` (`string`): With `unit: 'hour'`: the zone of the clock that the hour is shown in.
|
|
121
|
+
|
|
122
|
+
### UrlFormatOptions
|
|
123
|
+
|
|
124
|
+
For `url`.
|
|
125
|
+
|
|
126
|
+
- `url?` (`string`): One address for every cell, in place of the value.
|
|
127
|
+
- `text?` (`string`): One text for every cell, in place of the value.
|
|
128
|
+
- `openInNewTab?` (`boolean`): Whether the link opens in a new tab. Defaults to false.
|
|
129
|
+
- `download?` (`boolean | string`): `true` adds a bare `download` attribute; a string names the file.
|
|
130
|
+
- `urlSelector?` (`(row: unknown) => string`): The address of the cell, from its row.
|
|
131
|
+
- `textSelector?` (`(row: unknown) => string`): The text of the cell, from its row.
|
|
132
|
+
- `attributes?` (`Record<string, string>`): More attributes of the link. A name that is no valid attribute name is left out.
|
|
133
|
+
|
|
134
|
+
### EmailFormatOptions
|
|
135
|
+
|
|
136
|
+
For `email`.
|
|
137
|
+
|
|
138
|
+
- `asLink?` (`boolean`): Whether `linkOf` gives a `mailto:` link for the cell.
|
|
139
|
+
- `maskDomain?` (`boolean`): Shows the address without its domain, as `ada@...`.
|
|
140
|
+
- `textSelector?` (`(row: unknown) => string`): The text of the cell, from its row.
|
|
141
|
+
|
|
142
|
+
### BooleanFormatOptions
|
|
143
|
+
|
|
144
|
+
For `boolean`.
|
|
145
|
+
|
|
146
|
+
- `trueValue?` (`string`): The text for a true value. Defaults to `Yes`.
|
|
147
|
+
- `falseValue?` (`string`): The text for a false value. Defaults to `No`.
|
|
148
|
+
|
|
149
|
+
### TruncateFormatOptions
|
|
150
|
+
|
|
151
|
+
For `truncate`.
|
|
152
|
+
|
|
153
|
+
- `truncate?` (`number`): Maximum number of characters kept; unset or 0 keeps the whole text.
|
|
154
|
+
- `truncateSuffix?` (`string`): The text after a cut text. Defaults to `...`.
|
|
155
|
+
|
|
156
|
+
## SortRule
|
|
157
|
+
|
|
158
|
+
- `id` (`string`): The id of the column.
|
|
159
|
+
- `desc?` (`boolean`): Whether the column sorts descending. Without it, ascending.
|
|
160
|
+
|
|
161
|
+
## FilterState
|
|
162
|
+
|
|
163
|
+
- `search?` (`string`): The search text, which every column with `searchable` reads.
|
|
164
|
+
- `columns?` (`Readonly<Record<string, unknown>>`): The filter of each column, by column id. The shape of a value, or `filter` of the column, decides how it matches.
|
|
165
|
+
|
|
166
|
+
## PageState
|
|
167
|
+
|
|
168
|
+
- `page` (`number`): The page in view, from 1.
|
|
169
|
+
- `pageSize` (`number`): How many rows a page holds.
|
|
170
|
+
|
|
171
|
+
## ColumnPinning
|
|
172
|
+
|
|
173
|
+
- `start?` (`readonly string[]`): The ids of the columns that stay at the start edge, in order.
|
|
174
|
+
- `end?` (`readonly string[]`): The ids of the columns that stay at the end edge, in order.
|
|
175
|
+
|
|
176
|
+
## RowPinning
|
|
177
|
+
|
|
178
|
+
- `top?` (`readonly string[]`): The ids of the rows that stay above the others, in order.
|
|
179
|
+
- `bottom?` (`readonly string[]`): The ids of the rows that stay below the others, in order.
|