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,137 @@
|
|
|
1
|
+
# Controller
|
|
2
|
+
|
|
3
|
+
The shared `TableController` methods and their argument and result types from `ui-sdk-table-core`.
|
|
4
|
+
|
|
5
|
+
Get the controller through your adapter, then call its methods. An agent calls the same methods. For instance, the Vue guide shows how to pass `createTableController()` to the table in [Controller and view](./controller-and-view.md).
|
|
6
|
+
|
|
7
|
+
## TableController
|
|
8
|
+
|
|
9
|
+
- `sortBy` (`(columnId: string, direction?: SortDirection | null, options?: { append?: boolean }) => void`): Sorts by a column in a direction, `'asc'` by default. Without `append: true`, the column replaces the sort, whatever the `multiSort` mode. With `append`, `null` takes the column out of the sort; without it, `null` empties the sort.
|
|
10
|
+
- `toggleSort` (`(columnId: string, options?: { append?: boolean; event?: Event }) => void`): Sorts by a column as a press on its header does: ascending, descending, not sorted. Without `append`, the `multiSort` option of the table and the keys of the event decide whether the column joins the sort or replaces it. With `alwaysSorted`, the last column of the sort turns back to ascending and the sort is never empty.
|
|
11
|
+
- `setSearch` (`(text: string) => void`): Gives the table a search text at once. A text that waits from `inputSearch` is dropped.
|
|
12
|
+
- `inputSearch` (`(text: string, event?: Event) => void`): Takes the text of a search field while a person types. `getView().search` holds the text at once, and the table filters when the typing pauses for `searchDebounce` milliseconds. Pass the event of the field for the details of the change.
|
|
13
|
+
- `flushSearch` (`() => void`): Filters now by the text that waits from `inputSearch`, for example on Enter. Without one, nothing happens.
|
|
14
|
+
- `setColumnFilter` (`(columnId: string, value: unknown) => void`): Sets the filter of one column. A value that asks for nothing (see `isEmptyFilter`) takes the filter of the column away.
|
|
15
|
+
- `clearFilters` (`() => void`): Takes the search and the filter of every column away, in one change. A search text that waits from `inputSearch` goes too.
|
|
16
|
+
- `clearColumnFilters` (`() => void`): Takes the filter of every column away, in one change. The search stays.
|
|
17
|
+
- `setGroupBy` (`(columnIds: readonly string[]) => void`): Groups the rows by these columns, in this order. An empty list takes the groups away.
|
|
18
|
+
- `setPage` (`(page: number) => void`): Goes to a page, from 1. A page past the last goes to the last. It throws when the table has no pages or the page is not a whole number.
|
|
19
|
+
- `setPageSize` (`(pageSize: number | null) => void`): Gives the table pages of a size, from its first page. `null` takes the pages away: every row shows.
|
|
20
|
+
- `nextPage` (`() => void`): Goes to the next page. On the last page, nothing changes.
|
|
21
|
+
- `previousPage` (`() => void`): Goes to the page before. On the first page, nothing changes.
|
|
22
|
+
- `firstPage` (`() => void`): Goes to the first page.
|
|
23
|
+
- `lastPage` (`() => void`): Goes to the last page. It throws with `manualPage` and no `rowCount`: the table does not know its last page.
|
|
24
|
+
- `expand` (`(rowId: string) => void`): Opens a tree row, a group or a row with a detail row. It throws for a row that cannot open.
|
|
25
|
+
- `collapse` (`(rowId: string) => void`): Closes a tree row, a group or a row with a detail row. It throws for a row that cannot open.
|
|
26
|
+
- `toggleExpanded` (`(rowId: string, event?: Event) => void`): Opens a row that is closed and closes one that is open. Pass the event of a press for the details of the change.
|
|
27
|
+
- `expandAll` (`() => void`): Opens every tree row and group, in one change. A detail row stays as it is.
|
|
28
|
+
- `collapseAll` (`() => void`): Closes every row and group, detail rows too, in one change.
|
|
29
|
+
- `select` (`(rowId: string) => void`): Selects one row in place of the selection. It throws without the `selection` option, and for a row that `canSelect` refuses.
|
|
30
|
+
- `toggleSelected` (`(rowId: string, event?: Event) => void`): Adds a row to the selection, or takes a selected row away. Pass the event of a press for the details of the change.
|
|
31
|
+
- `selectAll` (`() => void`): Selects every row of the list that can be selected, in one change. It needs `selection: 'multiple'`. A selected row that the filter hides stays selected.
|
|
32
|
+
- `clearSelection` (`() => void`): Takes every row out of the selection.
|
|
33
|
+
- `setColumnVisibility` (`(columnId: string, visible: boolean) => void`): Shows or hides a column, or every column of a header group.
|
|
34
|
+
- `toggleColumnVisibility` (`(columnId: string) => void`): Hides a column that shows and shows one that is hidden.
|
|
35
|
+
- `showAllColumns` (`() => void`): Shows every column, in one change.
|
|
36
|
+
- `hideAllColumns` (`() => void`): Hides every column that can be hidden, in one change. A column with `hideable: false` and a column that leads the table stay. A table needs one column: when no other column would be left, the first one in view stays.
|
|
37
|
+
- `resetColumnVisibility` (`() => void`): Brings the hidden columns back to what the table started with: `defaultColumnVisibility`, or every column in view.
|
|
38
|
+
- `resetColumnOrder` (`() => void`): Brings the column order back to what the table started with: `defaultColumnOrder`, or the order of the definitions.
|
|
39
|
+
- `resetColumnPinning` (`() => void`): Brings the pinned columns back to what the table started with: `defaultColumnPinning`, or no pinned column.
|
|
40
|
+
- `moveColumn` (`(columnId: string, index: number) => void`): Moves a column to a place among the columns that can move, from 0.
|
|
41
|
+
- `setColumnOrder` (`(columnIds: readonly string[]) => void`): Puts the columns in this order. Columns that are not listed come after, in the order of the definitions. It throws for an id that is listed twice.
|
|
42
|
+
- `setColumnWidth` (`(columnId: string, width: number | null) => void`): Gives a column a width in pixels. `null` takes the width away again.
|
|
43
|
+
- `resetColumnWidths` (`() => void`): Takes every width that a resize or `setColumnWidth` gave away, so each column has the width of its definition again.
|
|
44
|
+
- `pinColumn` (`(columnId: string, side: ColumnPin | null) => void`): Pins a column to the start or the end of the table. `null` frees it.
|
|
45
|
+
- `pinRow` (`(rowId: string, edge: RowPin | null) => void`): Pins a row to the top or the bottom of the rows. `null` frees it.
|
|
46
|
+
- `scrollToRow` (`(rowId: string, align?: RowAlign) => void`): Scrolls a row into view, in one step, also when the row is not rendered yet.
|
|
47
|
+
- `editCell` (`(rowId: string, columnId: string, value: unknown) => void | Promise<void>`): Gives a cell a new value, with the check of its column, and reports it through `onCellEdit`. A text is read as the editor reads it. It throws with the reason when the value is refused; when the schema of the column answers with a promise, the result is a promise that rejects.
|
|
48
|
+
- `startEdit` (`(rowId: string, columnId: string) => void`): Opens the editor of a cell that is in view.
|
|
49
|
+
- `cancelEdit` (`() => void`): Closes the editor without a save.
|
|
50
|
+
- `selectCells` (`(from: CellRef, to?: CellRef) => void`): Selects the cells from one cell to another, or one cell. Needs the `cellSelection` option.
|
|
51
|
+
- `clearCellSelection` (`() => void`): Takes the range of cells away.
|
|
52
|
+
- `copyCells` (`() => string`): The text of the selected cells, with tabs between cells and line breaks between rows.
|
|
53
|
+
- `pasteCells` (`(text: string) => void | Promise<void>`): Puts tab-separated text into the cells from the first selected cell on, as a paste does. It throws with the reason when a value is refused, and then no cell changes.
|
|
54
|
+
- `clearCells` (`() => void | Promise<void>`): Empties the selected cells, as Delete does in a sheet: each gets the empty value of its column (`emptyValue`), with the check of the column. It throws with the reason when a column refuses an empty value, and then no cell changes. Cells that cannot be edited are left as they are.
|
|
55
|
+
- `cutCells` (`() => string | Promise<string>`): Empties the selected cells and returns their text, as `copyCells` gives it. A caller puts the text on the clipboard. It throws as `clearCells` does.
|
|
56
|
+
- `fillCells` (`(direction: FillWay, source?: number) => void | Promise<void>`): Fills the selected cells from their first line: `'down'` from the first row, `'up'` from the last row, `'forward'` from the first column, `'back'` from the last column. `source` is how many lines the fill starts from, 1 without it; with two or more, numbers and days with one step go on, and everything else repeats. Each value passes the check of its column, and one refusal stops the fill before any cell changes. It throws when the selected cells are one line in that direction.
|
|
57
|
+
- `selectAllCells` (`() => void`): Selects every cell of the body. Needs the `cellSelection` option.
|
|
58
|
+
- `selectCellRows` (`(fromRowId: string, toRowId?: string) => void`): Selects every cell of a row, or of the rows from one to another as the list shows them.
|
|
59
|
+
- `selectCellColumns` (`(fromColumnId: string, toColumnId?: string) => void`): Selects every cell of a column, or of the columns from one to another as the table shows them.
|
|
60
|
+
- `undo` (`() => void`): Takes the last change of cell values back: it reports the old values through `onCellEdit` with the reason `undo`, and the owner of the rows puts them in, as for an edit. Needs the `history` option. It throws when there is nothing to undo, when a listener refuses the report, and while the check of a value runs.
|
|
61
|
+
- `redo` (`() => void`): Puts the change on again that `undo` took back last, with the reason `redo`.
|
|
62
|
+
- `clearHistory` (`() => void`): Forgets every step. Call it when the rows become other data, such as another document.
|
|
63
|
+
- `getHistory` (`() => { entries: readonly HistoryEntry<TableStepReason>[]; position: number }`): The steps of the history, oldest first, and how many of them are applied: `undo` takes back the last of those.
|
|
64
|
+
- `setColumnAggregate` (`(columnId: string, aggregate: AggregateName | null | undefined) => void`): Chooses the function of the total of a column, in the footer, in the group rows and in an export: `sum`, `mean`, `min`, `max`, `count`, `uniqueCount` or `first`. `null` takes the total of the column away, and `undefined` gives the column the `aggregate` of its definition back.
|
|
65
|
+
- `getColumnFormula` (`(columnId: string) => { formula: string; text: string; error: string | null } | null`): The formula of a computed column, as a person reads it (the headers of the columns, the signs of the locale) and in the stored form, or `null` for a column without one. `error` says why the formula gives an error in every row. Needs the `formulas` option.
|
|
66
|
+
- `setColumnFormula` (`(columnId: string, formula: string | null) => void`): Sets the formula of a column, as a person types it or in the stored form, or takes it away with `null`: one change of `cellFormulas` and one step of the history. It throws when the formula cannot be read, reads another row, or reads its own column through other formulas. Needs the `formulas` option.
|
|
67
|
+
- `getAddress` (`(rowId: string, columnId: string) => string | null`): The address of a cell, such as `D7`: the letter of its column among the columns of the owner and the number of its row in the document. `null` for a column without a letter. Needs the `formulas` option.
|
|
68
|
+
- `cellAt` (`(address: string) => CellRef`): The cell of an address such as `D7`. It throws for an address that the table does not have. Needs the `formulas` option.
|
|
69
|
+
- `getCellFormula` (`(rowId: string, columnId: string) => FormulaView | null`): The formula of a cell: the stored form, the text as a person reads it, the address, the value and the words of its error. `null` for a cell without a formula of its own. Needs the `formulas` option.
|
|
70
|
+
- `setCellFormula` (`(rowId: string, columnId: string, formula: string | null) => void`): Gives a cell a formula, as a person types it or in the stored form, or takes it away with `null` (the cell keeps its value). One report with every cell that follows, and one step. It throws when the cell cannot hold a formula, the formula cannot be read, or it reads its own cell.
|
|
71
|
+
- `recalculate` (`() => number`): Computes every formula of a cell and reports each cell whose value is not the one its formula gives, with the reason `recalculate`. Returns how many cells it reported. The table does this by itself after new rows, for the cells that they change; this is for a check after a load.
|
|
72
|
+
- `getFormulaSummary` (`(limit?: number) => { lines: FormulaSummaryLine[]; more: number }`): The formulas as a short list: each text of a column once, with how many cells hold it. `limit` is 1 to 500, 100 by default.
|
|
73
|
+
- `evaluateFormula` (`(formula: string, at?: CellRef) => unknown`): The value that a formula would give at a cell, the active cell by default. Nothing is written.
|
|
74
|
+
- `getFormulaFunctions` (`() => readonly FormulaFunctionInfo[]`): The functions of the formulas: name, arguments as a text and as a list, one line of help, and group.
|
|
75
|
+
- `getRangeAddress` (`(cells?: CellPick | null) => string | null`): The text that a person types for cells: `B2`, `B2:C5`, or `B:C` for whole columns. It reads a pick of `pickedCells`, else the selected cells (the selected range, or the active cell); selected cells are whole columns when they hold every row of the document, and more than one. The corners are the first and the last cell that hold values. `null` without cells, for a column without a letter, and with `manualPage`, where no address names a row. Needs the `formulas` option.
|
|
76
|
+
- `movePick` (`(key: PickKey, options?: PickMoveOptions) => CellPick | null`): Moves the pick of the pick mode with an arrow key, as a field that writes a formula does it while a person points with the keys. The first move, and a move with `start`, picks the cell next to the cell of the field (the cell that is edited, else the active cell) in the direction of the key; a later move takes the pick one cell further. `extend` (Shift) keeps the first cell and grows a range, and `edge` (Control) goes to the edge of the body. The keys follow the direction of the table, as for the active cell: in a right-to-left table `ArrowLeft` goes to the next column, so a field passes the key that it got. It changes `pickedCells` with the reason `list-navigation`, scrolls the cell into view, and leaves focus, the caret, the active cell and the selected cells where they are. A first move with no cell in its direction (Up from the first row) picks nothing and returns `null`; a later move at the edge keeps the pick. Returns the pick. Needs `pickCells`; the text field of the table's own editor calls it itself.
|
|
77
|
+
- `getFormulaReferences` (`(text: string, at?: CellRef) => FormulaReference[]`): The references of a formula text as a person types it at a cell, the active cell by default: the place of each in the text, from `start` up to `end`, and the cells that it names by ids, from the first to the last. It reads a text that is not a whole formula yet. A field colours a reference and its cells with one colour. Needs the `formulas` option.
|
|
78
|
+
- `getReferenceMarks` (`(references: readonly FormulaReference[]) => (rowId: string, columnId: string) => FormulaReferenceMark | undefined`): Which of these references holds a cell, and at which edges of its block, for `cellAttrs`: give it the references of `getFormulaReferences`, then ask the function by row id and column id. It gives `undefined` for a cell that no reference holds, and for a column that leads. It reads the places in the document once, so each question is cheap, also for whole columns of 50,000 rows. Ask again when the references or the rows change. Needs the `formulas` option.
|
|
79
|
+
- `formatCells` (`(patch: CellFormatPatch, target?: FormatTarget) => void`): Changes the format of cells: how their values become text (`format`, `decimals`, `currency`, `dateStyle`) and how they look (`align`, `bold`, `italic`, `color`, `fill`). A key with `null` takes that property away. Without a target, the selected cells get it; when those are every row that the table has, the format goes to the whole columns and holds for rows that come later. It throws for a property, a format name or a colour that the table does not know, and lists the valid ones.
|
|
80
|
+
- `clearCellFormats` (`(target?: FormatTarget) => void`): Takes every format of cells away: of the target, or of the selected cells.
|
|
81
|
+
- `toggleCellFormat` (`(property: 'bold' | 'italic') => void`): Makes the selected cells bold or italic, for a button of a toolbar, as the keys of a sheet do: on, unless every selected cell has it, and then off.
|
|
82
|
+
- `getCellFormat` (`(rowId: string, columnId: string) => CellFormat`): The format that a cell has of its own: the format of its column in `cellFormats` with the format of the cell over it. An empty object when neither says anything, and for the number of a row. The `format` of the column definition is not in it.
|
|
83
|
+
- `getSelectionSummary` (`() => RangeSummary | null`): What the selected cells add up to: how many hold a value and a number, and the sum, the mean, the smallest and the largest of the numbers, each also as text. Counted when it is asked for, and kept for the same selection and the same rows. `null` when no cell of a data row is selected. Group rows and the numbers of the rows are left out.
|
|
84
|
+
- `exportData` (`(options?: ExportOptions) => ExportData`): The cells of the table as plain data, for a file: every row that passes the filters and the visible columns, or what the options ask for. The writers are in the `export` entry of the package (`toCsv`, `toXlsx`).
|
|
85
|
+
- `selectRows` (`(rowIds: readonly string[]) => void`): Selects rows in one change, beside the rows that are selected. It throws for a row that cannot be selected.
|
|
86
|
+
- `deselectRows` (`(rowIds: readonly string[]) => void`): Takes rows out of the selection in one change.
|
|
87
|
+
- `getView` (`() => TableView`): What the table shows now, for a control beside it: a search field, a list of columns, the pages. It answers at the time of the call; `subscribe` says when to ask again.
|
|
88
|
+
- `getFacets` (`(columnId: string, options?: FacetOptions) => ColumnFacets`): What a filter control of a column offers: its kind, and the values, the numbers or the dates that the column holds. They follow the search and the filters of the other columns, and never the filter of the column itself, so a filter does not take away its own choices. `rows: 'all'` gives the facets of every row of the table. A column that the `facets` option names has the facets of the owner, for both.
|
|
89
|
+
- `getTotals` (`(groupId?: string) => Readonly<Record<string, ColumnTotal>>`): The total of each column that has an `aggregate`, with its text in the format of the column: of the rows that pass the filters, as the footer shows them, or of one group by its id.
|
|
90
|
+
- `subscribe` (`(listener: (changed: readonly string[]) => void) => () => void`): Runs the listener after each change of the state, of the rows or of the columns, with the keys of the state that changed. Returns the function that stops it. A table that is destroyed stops every listener itself.
|
|
91
|
+
|
|
92
|
+
## FacetOptions
|
|
93
|
+
|
|
94
|
+
- `rows?` (`'filtered' | 'all'`): `'filtered'` (the default): the rows that pass the search and the filters of the other columns. `'all'`: every row of the table.
|
|
95
|
+
|
|
96
|
+
## ColumnFacets
|
|
97
|
+
|
|
98
|
+
- `kind` (`FilterKind`): The filter of the column: its `filter` option, or what its format says. A column of dates filters by a range of dates, a column of numbers by a range, any other column by text.
|
|
99
|
+
- `values` (`readonly ColumnFacetValue[]`): Each different value, sorted. Filled for the kind `select`.
|
|
100
|
+
- `range` (`{ min: number; max: number; step: number } | null`): The lowest and the highest number, and the step of a slider between them: the smallest change that the format of the column shows. Filled for the kind `range`. `sliderBounds` gives ends that are whole steps.
|
|
101
|
+
- `dates` (`{ from: Date; to: Date } | null`): The earliest and the latest date. Filled for the kind `dateRange`.
|
|
102
|
+
- `days` (`{ from: string; to: string } | null`): The days of `dates` as `YYYY-MM-DD`, in the zone of the column (the `timeZone` of its format options) or in local time: the days that a range of dates on this column is matched by.
|
|
103
|
+
|
|
104
|
+
## ColumnFacetValue
|
|
105
|
+
|
|
106
|
+
- `value` (`unknown`): The value as the rows hold it.
|
|
107
|
+
- `text` (`string`): The value as text, as a cell of the column shows it.
|
|
108
|
+
- `count?` (`number`): How many rows hold the value.
|
|
109
|
+
|
|
110
|
+
## ColumnTotal
|
|
111
|
+
|
|
112
|
+
- `value` (`unknown`): The total as a value.
|
|
113
|
+
- `text` (`string`): The total as text, with the format of the column.
|
|
114
|
+
|
|
115
|
+
## CellEdit
|
|
116
|
+
|
|
117
|
+
- `rowId` (`string`): The id of the row of the cell.
|
|
118
|
+
- `columnId` (`string`): The id of the column of the cell.
|
|
119
|
+
- `row` (`Row`): The caller's own row object, as it is before the edit.
|
|
120
|
+
- `column` (`ColumnDef<Row>`): The definition of the column.
|
|
121
|
+
- `value` (`unknown`): The new value, after `parse` and the schema of the column.
|
|
122
|
+
- `previous` (`unknown`): The value of the cell before the edit.
|
|
123
|
+
- `formula?` (`string | null`): With formulas: the formula that the cell holds now (a text in the stored form), or `null` when its formula went. Not set for a value and for a result that followed from other cells.
|
|
124
|
+
|
|
125
|
+
## CellRef
|
|
126
|
+
|
|
127
|
+
- `rowId` (`string`): The id of the row.
|
|
128
|
+
- `columnId` (`string`): The id of the column.
|
|
129
|
+
|
|
130
|
+
## HistoryEntry
|
|
131
|
+
|
|
132
|
+
- `id` (`number`): The number of the step: the steps of a table count up from 1.
|
|
133
|
+
- `reason` (`Reason`): What made the step: the reason of its edit, `shortcut` or `formula`.
|
|
134
|
+
- `source` (`ChangeSource`): Who made it: a person with a key or a pointer, code, or an agent.
|
|
135
|
+
- `cells` (`number`): How many cells got a new value. 0 for a step of formats.
|
|
136
|
+
- `formats` (`boolean`): Whether the step changed formats and no value.
|
|
137
|
+
- `formulas` (`boolean`): Whether the step changed formulas.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Export
|
|
2
|
+
|
|
3
|
+
The shared types of `controller.exportData()` and the file writers from `ui-sdk-table-core/export`.
|
|
4
|
+
|
|
5
|
+
See [Export](./export.md) for how they work together.
|
|
6
|
+
|
|
7
|
+
## ExportOptions
|
|
8
|
+
|
|
9
|
+
What `controller.exportData(options)` takes.
|
|
10
|
+
|
|
11
|
+
- `rows?` (`'filtered' | 'page' | 'all' | 'selected'`): Which rows to take. `'filtered'` (the default) is every row that passes the filters, on all pages, in the order of the screen. `'page'` is the rows of the page in view. `'all'` is every row of the data, in the order of the data. `'selected'` is the selected rows, in sort order. A table with `manualPage` has one page of a server, so each set is of that page.
|
|
12
|
+
- `columns?` (`'visible' | 'all' | readonly string[]`): Which columns to take. `'visible'` (the default) is the columns on the screen in their order. `'all'` adds the hidden columns after them. A list of ids gives those columns in that order. A column with `exportable: false` is in none of them.
|
|
13
|
+
- `children?` (`boolean`): Whether the child rows of a tree row come with it, open or not. Defaults to true.
|
|
14
|
+
- `groups?` (`boolean`): Whether each group gets a row of its own before its rows, for `'filtered'` and `'page'`. Defaults to false. `'all'` and `'selected'` have no groups.
|
|
15
|
+
- `totals?` (`boolean`): Whether a last row holds totals. Defaults to false. For `'filtered'` and `'page'` they are the totals of the footer on the screen. For `'all'` and `'selected'` they are the totals of the rows in the file.
|
|
16
|
+
|
|
17
|
+
## ExportData
|
|
18
|
+
|
|
19
|
+
- `columns` (`ExportColumn<Row>[]`): The columns of the export, in the order of the screen.
|
|
20
|
+
- `rows` (`ExportRow<Row>[]`): The rows of the export: rows of the data, group rows and the row of totals.
|
|
21
|
+
- `locale` (`string | undefined`): The `locale` of the table, which a writer uses for its numbers and dates.
|
|
22
|
+
- `document?` (`readonly string[]`): With formulas: the id of every row in the order of the document, for the ranges of the formulas.
|
|
23
|
+
|
|
24
|
+
## ExportColumn
|
|
25
|
+
|
|
26
|
+
- `id` (`string`): The id of the column.
|
|
27
|
+
- `header` (`string`): The header text of the column.
|
|
28
|
+
- `column` (`ColumnDef<Row>`): The definition of the column.
|
|
29
|
+
|
|
30
|
+
## ExportRow
|
|
31
|
+
|
|
32
|
+
- `kind` (`'row' | 'group' | 'total'`): `'row'`: a row of the data. `'group'`: a group row. `'total'`: the row of totals, with the `totals` option of the export.
|
|
33
|
+
- `row?` (`Row`): The row of the data, for a row of kind `'row'`.
|
|
34
|
+
- `level` (`number`): Tree and group levels above this row, from 0.
|
|
35
|
+
- `label?` (`string`): The name of a group, for a row of kind `'group'`. It is also in a cell: the first one without a total, or the first one before its total when every column has a total.
|
|
36
|
+
- `cells` (`ExportCell[]`): One cell for each column of the export.
|
|
37
|
+
- `id?` (`string`): With formulas: the id of a row of kind `'row'`, for the formulas that name it.
|
|
38
|
+
|
|
39
|
+
## ExportCell
|
|
40
|
+
|
|
41
|
+
- `value` (`unknown`): The value of the cell, as the row has it.
|
|
42
|
+
- `text` (`string`): The text of the cell, as a person sees it on the screen.
|
|
43
|
+
- `format?` (`CellFormat`): The format that the cell has of its own, from the `cellFormats` of the table.
|
|
44
|
+
- `formula?` (`string`): With formulas: the formula of the cell, or of its column, in the stored form.
|
|
45
|
+
|
|
46
|
+
## CsvOptions
|
|
47
|
+
|
|
48
|
+
- `separator?` (`string`): The text between two cells. Defaults to a comma.
|
|
49
|
+
- `lineEnd?` (`string`): The text between two rows. Defaults to `\r\n`, as RFC 4180 says.
|
|
50
|
+
- `header?` (`boolean`): Whether the first row holds the header texts. Defaults to true.
|
|
51
|
+
- `bom?` (`boolean`): Whether the text starts with a byte order mark. Defaults to true: without it, Excel reads a UTF-8 file in the code page of the computer.
|
|
52
|
+
- `escapeFormulas?` (`boolean`): Whether a text that a spreadsheet would read as a formula gets a `'` before it. Defaults to true. A cell that a person typed can otherwise run a formula on the computer of the person who opens the file.
|
|
53
|
+
|
|
54
|
+
## XlsxOptions
|
|
55
|
+
|
|
56
|
+
- `sheetName?` (`string`): The name of the sheet. Defaults to `Sheet1`.
|
|
57
|
+
- `freezeHeader?` (`boolean`): Whether the header row stays in view while the rows scroll. Defaults to true.
|
|
58
|
+
- `compress?` (`boolean`): Whether the file is compressed, where the environment can do that. Defaults to true.
|
|
59
|
+
- `formula?` (`XlsxFormulas`): Writes the formulas of the cells as formulas of the file, with the result beside each: `excelFormulas()` of the entry `ui-sdk-table-core/formulas`. Without it, a cell holds its result.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Formulas
|
|
2
|
+
|
|
3
|
+
The shared types of `ui-sdk-table-core/formulas` and the separate Vue formula bar helper.
|
|
4
|
+
|
|
5
|
+
See [Formulas](./sheet-formulas.md) for how they work together.
|
|
6
|
+
|
|
7
|
+
## FormulaEngineOptions
|
|
8
|
+
|
|
9
|
+
What `createFormulaEngine(options)` takes.
|
|
10
|
+
|
|
11
|
+
- `timeZone?` (`string`): The zone of a date that is no reference to a column with a zone of its own (`formatOptions.timeZone`), such as a date that a function gives. Without it, local time: a result that is saved should not depend on the computer that made it, so pass one when a formula reads a moment.
|
|
12
|
+
- `now?` (`() => number`): The clock of `TODAY` and `NOW`, in milliseconds since 1970: `Date.now` by default. A test passes a clock of its own.
|
|
13
|
+
- `maxReads?` (`number`): The most cells that one change may read, 5,000,000 by default. A formula in each row that sums from the first row to its own reads the square of the rows; past the limit the change is refused with words.
|
|
14
|
+
|
|
15
|
+
## CellFormulas
|
|
16
|
+
|
|
17
|
+
The value of `cellFormulas`.
|
|
18
|
+
|
|
19
|
+
- `columns?` (`Readonly<Record<string, string>>`): The formula of each computed column, by column id, in the stored form.
|
|
20
|
+
- `cells?` (`Readonly<Record<string, Readonly<Record<string, string>>>>`): The formula of each cell, by row id and column id, in the stored form.
|
|
21
|
+
|
|
22
|
+
## FormulaBar
|
|
23
|
+
|
|
24
|
+
Vue only: the result of `useFormulaBar(controller)` from `ui-sdk-table-vue/formulas`. The shared engine has no Vue dependency.
|
|
25
|
+
|
|
26
|
+
- `address` (`ComputedRef<string>`): The address of the cell, such as `D7`, or `''` without an active cell.
|
|
27
|
+
- `cell` (`ComputedRef<CellRef | null>`): The cell of the field by ids: the cell of the draft, else the active cell, or `null`. A formula writer reads the references of the text at it.
|
|
28
|
+
- `text` (`ComputedRef<string>`): The text of the field: the draft while a person types, else the formula or the value of the cell.
|
|
29
|
+
- `error` (`ComputedRef<string>`): Why the last commit was refused, in the words for a person, or `''`.
|
|
30
|
+
- `dirty` (`ComputedRef<boolean>`): Whether the text is a draft that is not saved.
|
|
31
|
+
- `ready` (`ComputedRef<boolean>`): Whether a cell is active, so the field can be used.
|
|
32
|
+
- `input` (`(text: string) => void`): The new text of the field.
|
|
33
|
+
- `commit` (`() => boolean`): Saves the draft into its cell, as the editor of the cell does. Returns whether it was saved.
|
|
34
|
+
- `cancel` (`() => void`): Drops the draft and the error.
|
|
35
|
+
|
|
36
|
+
## FormulaFunctionInfo
|
|
37
|
+
|
|
38
|
+
- `name` (`string`): The name of the function, such as `SUM`.
|
|
39
|
+
- `args` (`string`): Its arguments as a person writes them, such as `number, ...`.
|
|
40
|
+
- `help` (`string`): One line that says what it gives.
|
|
41
|
+
- `group` (`FormulaFunctionGroup`): What it works with: `math`, `condition`, `lookup`, `logic`, `text` or `date`.
|
|
42
|
+
- `arguments` (`readonly FormulaArgument[]`): Its arguments as a list, read from `args`.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Reference implementation
|
|
2
|
+
|
|
3
|
+
Use the complete table to study how the parts work together, not as the default component for your app.
|
|
4
|
+
|
|
5
|
+
## Start with parts
|
|
6
|
+
|
|
7
|
+
The framework package gives you the root, head, row, cell and editor parts. Compose the parts you need and keep markup, cell content, controls and styling in your app. The framework guides show a first table built this way: [React](https://ui-sdk-table.fdts.dev/docs/react.md), [Vue](https://ui-sdk-table.fdts.dev/docs/vue.md), [Svelte](https://ui-sdk-table.fdts.dev/docs/svelte.md), [Solid](https://ui-sdk-table.fdts.dev/docs/solid.md) and [Web Components](./web-components.md).
|
|
8
|
+
|
|
9
|
+
## Inspect a complete table
|
|
10
|
+
|
|
11
|
+
Each adapter also has an explicit `/reference` entry. The reference renders the table structure for you, including grouped headers, body rows and footers. It shows how features such as sorting, editing and the row window fit together. It is a working example you can run, read and adapt. It is not a finished product, a design system, or the recommended default.
|
|
12
|
+
|
|
13
|
+
| Framework | Opt-in entry | Export |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| React | `ui-sdk-table-react/reference` | `Table` |
|
|
16
|
+
| Vue | `ui-sdk-table-vue/reference` | `Table` |
|
|
17
|
+
| Svelte | `ui-sdk-table-svelte/reference` | `Table` |
|
|
18
|
+
| Solid | `ui-sdk-table-solid/reference` | `Table` |
|
|
19
|
+
| Web Components | `ui-sdk-table-web/reference` | `defineReferenceTable()` registers `<ui-reference-table>` |
|
|
20
|
+
|
|
21
|
+
Vue also retains its original `Table` export for existing applications. Its [first table example](./first-table.md) demonstrates the reference in action. Import from the explicit entry in new examples so readers can see which approach you chose.
|
|
22
|
+
|
|
23
|
+
## Source code
|
|
24
|
+
|
|
25
|
+
**Framework source** shows the implementation behind the selected adapter’s `/reference` entry. Use the framework selector in the header to compare adapters without leaving this page. Select a file to read or copy its complete contents.
|
|
26
|
+
|
|
27
|
+
**Shared composition** shows how `ui-sdk-table-core` builds the header, body, editor and footer from the same parts. Start there to see which decisions all five adapters share.
|
|
28
|
+
|
|
29
|
+
To read the source offline, follow the `./reference` export in the installed adapter’s `package.json`. For the shared composition, open `node_modules/ui-sdk-table-core/src/reference.ts`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Messages
|
|
2
|
+
|
|
3
|
+
Every text that the table writes itself, for the `messages` prop.
|
|
4
|
+
|
|
5
|
+
Pass the texts that you change; the others keep the English words of `defaultMessages`. Each text is a function, so a language can put the parts in its own order.
|
|
6
|
+
|
|
7
|
+
## TableMessages
|
|
8
|
+
|
|
9
|
+
- `formulaIssue?` (`(issue: FormulaIssue) => string`): The words for an issue of a formula. Without it, the words of the engine: a table without formulas carries none.
|
|
10
|
+
- `formulaError?` (`(code: FormulaError) => string`): Why a formula gives an error value, for the description of its cell. Without it, the words of the engine.
|
|
11
|
+
- `recalculated?` (`(details: { cells: number }) => string`): What the table says after `recalculate()`: how many cells got new values. Without it, the words of the engine.
|
|
12
|
+
- `noRows` (`() => string`): What the body says when no row passes the filters.
|
|
13
|
+
- `loading` (`() => string`): What the body says while the first rows are on their way.
|
|
14
|
+
- `expandRow` (`() => string`): The name of the button that opens a row with child rows or a detail row.
|
|
15
|
+
- `collapseRow` (`() => string`): The name of the button that closes such a row.
|
|
16
|
+
- `expandSign` (`() => string`): The sign on the button of a closed row.
|
|
17
|
+
- `collapseSign` (`() => string`): The sign on the button of an open row.
|
|
18
|
+
- `groupRow` (`(details: { text: string; count: number }) => string`): The text of a group row: the value of the group and how many rows it holds.
|
|
19
|
+
- `resizeColumn` (`(column: string) => string`): The name of the resize handle of a column.
|
|
20
|
+
- `columnResized` (`(details: { column: string; width: number }) => string`): What a screen reader says after a column gets a new width.
|
|
21
|
+
- `columnMoved` (`(details: ColumnReorderMessage) => string`): What a screen reader says while a column moves.
|
|
22
|
+
- `editCell` (`(details: { column: string }) => string`): The name of the text field that edits a cell.
|
|
23
|
+
- `notNumber` (`(text: string) => string`): Why a text is refused in a column of numbers.
|
|
24
|
+
- `notDate` (`(text: string) => string`): Why a text is refused in a cell that holds a date.
|
|
25
|
+
- `notBoolean` (`(text: string) => string`): Why a text is refused in a cell that holds true or false.
|
|
26
|
+
- `invalidValue` (`() => string`): Why a value is refused when its schema gives no message.
|
|
27
|
+
- `editRefused` (`() => string`): Why an edit is refused when a listener of `onCellEdit` cancels it.
|
|
28
|
+
- `cellsSelected` (`(details: { rows: number; columns: number }) => string`): What a screen reader says after the range of cells changed from the keyboard.
|
|
29
|
+
- `cellsCopied` (`(details: { cells: number }) => string`): What a screen reader says after a copy.
|
|
30
|
+
- `cellsPasted` (`(details: { cells: number }) => string`): What a screen reader says after a paste.
|
|
31
|
+
- `pasteRefused` (`(details: { column: string; text: string; message: string }) => string`): Why a paste did nothing: one of its values was refused.
|
|
32
|
+
- `pasteNowhere` (`() => string`): Why a paste did nothing: no cell under it can be edited.
|
|
33
|
+
- `pasteTooLarge` (`(details: { rows: number; columns: number }) => string`): Why a paste did nothing: the text has more rows or columns than the table has from the first cell on.
|
|
34
|
+
- `pasteOverRow` (`() => string`): Why a paste did nothing: a row under it is a group row or a detail row, which holds no values.
|
|
35
|
+
- `editRowGone` (`() => string`): Why an edit was not saved: its row left the table while the value was checked.
|
|
36
|
+
- `cellsCleared` (`(details: { cells: number }) => string`): What a screen reader says after Delete or `clearCells` emptied cells.
|
|
37
|
+
- `cellsCut` (`(details: { cells: number }) => string`): What a screen reader says after a cut.
|
|
38
|
+
- `clearRefused` (`(details: { column: string; message: string }) => string`): Why a clear or a cut did nothing: a column refuses an empty value.
|
|
39
|
+
- `clearNowhere` (`() => string`): Why a clear or a cut did nothing: no cell under it can be edited.
|
|
40
|
+
- `undone` (`(details: { cells: number; gone: number; hidden: number }) => string`): What a screen reader says after an undo. `cells` got their old value back, `gone` of the step are not in the table any more, and `hidden` of the cells that changed are not in view: a filter, a page or a closed row hides them.
|
|
41
|
+
- `redone` (`(details: { cells: number; gone: number; hidden: number }) => string`): What a screen reader says after a redo.
|
|
42
|
+
- `undoRefused` (`() => string`): Why an undo or a redo did nothing: a listener of `onCellEdit` refused it.
|
|
43
|
+
- `nothingToUndo` (`() => string`): Why an undo did nothing: the history has no step to take back.
|
|
44
|
+
- `nothingToRedo` (`() => string`): Why a redo did nothing: the history has no step to bring back.
|
|
45
|
+
- `historyBusy` (`() => string`): Why an undo or a redo must wait: the check of a new value runs.
|
|
46
|
+
- `historyTooLarge` (`(details: { cells: number }) => string`): What a screen reader says when one change holds more cells than the history keeps, so it cannot be undone.
|
|
47
|
+
- `rowNumber` (`(details: { number: number }) => string`): The name of the header of a row: its number, from 1. A screen reader says it with each cell of the row.
|
|
48
|
+
- `cornerCell` (`() => string`): The name of the corner cell of the row of letters, which selects every cell.
|
|
49
|
+
- `cellsFilled` (`(details: { cells: number }) => string`): What a screen reader says after a fill.
|
|
50
|
+
- `fillRefused` (`(details: { column: string; text: string; message: string }) => string`): Why a fill did nothing: a column refuses one of its values.
|
|
51
|
+
- `fillNowhere` (`() => string`): Why a fill did nothing: no cell under it can be edited.
|
|
52
|
+
- `fillOverPinned` (`() => string`): Why a fill did nothing: it would go from pinned rows to rows of the list, which are no neighbours in the data.
|
|
53
|
+
- `cellsFormatted` (`(details: { cells: number }) => string`): What a screen reader says after the formats of cells changed from a key or from code.
|
|
54
|
+
- `aggregateLabel` (`(name: string) => string`): The name of a function of the sum row, for a picker and for the name of a footer cell: `sum`, `mean`, `min`, `max`, `count`, `uniqueCount`, `first`, or `custom` for a function of the column.
|
|
55
|
+
- `totalLabel` (`(details: { label: string; text: string }) => string`): The name of a footer cell whose function a person chose: the function and the total.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# View
|
|
2
|
+
|
|
3
|
+
The shared `getView()` result and row types, plus the Vue helpers for search and edit drafts.
|
|
4
|
+
|
|
5
|
+
Read the view again in `subscribe`. Vue also provides `useTableView(controller)`; see [Controller and view](./controller-and-view.md).
|
|
6
|
+
|
|
7
|
+
## TableView
|
|
8
|
+
|
|
9
|
+
- `sort` (`readonly SortRule[]`): The sort: the columns in the order in which they sort.
|
|
10
|
+
- `filter` (`FilterState`): The filter: the search and the filter of each column.
|
|
11
|
+
- `search` (`string`): The text that a search field shows: the text that waits from `inputSearch`, else the search of the filter.
|
|
12
|
+
- `searchPending` (`boolean`): Whether a text from `inputSearch` waits for its pause, so the rows do not follow `search` yet.
|
|
13
|
+
- `groupBy` (`readonly string[]`): The ids of the columns that group the rows, in order.
|
|
14
|
+
- `expanded` (`readonly string[]`): The ids of the open tree rows, groups and rows with a detail row.
|
|
15
|
+
- `selected` (`readonly string[]`): The ids of the selected rows.
|
|
16
|
+
- `page` (`number`): The page in view, from 1. A table without pages has one page.
|
|
17
|
+
- `pageSize` (`number | undefined`): How many rows a page holds, or `undefined` for a table without pages.
|
|
18
|
+
- `pageCount` (`number`): How many pages there are. A table without pages has one.
|
|
19
|
+
- `rowCount` (`number`): How many entries the pages divide: what `pageUnit` names. With pages from a server, its `rowCount`.
|
|
20
|
+
- `pageUnit` (`PageUnit`): What the pages count. `rows`: each row. `groups`: each group, with its rows on the page of the group. `parents`: each top-level row, with its child rows on the same page. `mixed`: groups, and rows outside every group.
|
|
21
|
+
- `dataRowCount` (`number`): How many data rows pass the filters, child rows too. With `rows`, it is `rowCount`.
|
|
22
|
+
- `lastPageKnown` (`boolean`): Whether the last page is known. It is not for pages from a server that gave no count.
|
|
23
|
+
- `columns` (`readonly ColumnDef[]`): Every column that holds cells, hidden ones too, in definition order.
|
|
24
|
+
- `visibleColumns` (`readonly ColumnDef[]`): The columns in view, in display order.
|
|
25
|
+
- `selectable` (`readonly string[]`): The ids of the rows that `selectAll` selects: the rows that pass the filters and can be selected.
|
|
26
|
+
- `hasExpandable` (`boolean`): Whether the table has a group or a row with child rows: what `expandAll` opens.
|
|
27
|
+
- `hasExpanded` (`boolean`): Whether one of them is open now. An id in `expanded` that no group or row has any more does not count.
|
|
28
|
+
- `loading` (`boolean`): The `loading` option: whether new rows are on their way.
|
|
29
|
+
- `columnAggregates` (`ColumnAggregates`): The functions of the totals that were chosen at run time, by column id.
|
|
30
|
+
- `cellFormats` (`CellFormats`): The formats of cells and columns that were set at run time.
|
|
31
|
+
- `formulas` (`boolean`): Whether the table has the `formulas` option.
|
|
32
|
+
- `cellFormulas` (`CellFormulas`): The formulas of the table.
|
|
33
|
+
- `formula` (`FormulaView | null`): The formula of the active cell or of its column, for a formula bar. `null` without formulas and without an active cell.
|
|
34
|
+
- `canUndo` (`boolean`): Whether `undo` has a step to take back. Always false without the `history` option.
|
|
35
|
+
- `canRedo` (`boolean`): Whether `redo` has a step to bring back. Always false without the `history` option.
|
|
36
|
+
- `activeCell` (`CellRef | null`): The cell that has the tab stop, when it is a cell of a data row.
|
|
37
|
+
- `cellSelection` (`CellSelectionView | null`): The selected cells of a table with `cellSelection`: the range, or the active cell alone. `null` when no cell of a data row is selected.
|
|
38
|
+
|
|
39
|
+
## CellSelectionView
|
|
40
|
+
|
|
41
|
+
- `from` (`CellRef`): The first selected cell that holds a value, at the top and the start.
|
|
42
|
+
- `to` (`CellRef`): The last selected cell that holds a value, at the bottom and the end.
|
|
43
|
+
- `rows` (`number`): How many data rows the selection covers.
|
|
44
|
+
- `columns` (`number`): How many columns the selection covers.
|
|
45
|
+
|
|
46
|
+
## RangeSummary
|
|
47
|
+
|
|
48
|
+
- `cells` (`number`): How many cells of data rows the selection holds.
|
|
49
|
+
- `count` (`number`): How many of them hold a value.
|
|
50
|
+
- `numbers` (`number`): How many hold a number. The four values after it are of these cells.
|
|
51
|
+
- `sum` (`number`): The sum of the numbers. 0 without a number.
|
|
52
|
+
- `mean` (`number | undefined`): The mean of the numbers, or `undefined` without a number.
|
|
53
|
+
- `min` (`number | undefined`): The smallest number, or `undefined` without a number.
|
|
54
|
+
- `max` (`number | undefined`): The largest number, or `undefined` without a number.
|
|
55
|
+
- `texts` (`{ sum: string; mean: string; min: string; max: string }`): Each value as text: in the format of the column when the selection is inside one column that shows numbers, else as a plain number of the locale, where the mean has the decimals of `meanDecimals`. An empty text for a value that does not exist.
|
|
56
|
+
|
|
57
|
+
## TableSearch
|
|
58
|
+
|
|
59
|
+
Vue only: the result of `useTableSearch(controller)` from `ui-sdk-table-vue`.
|
|
60
|
+
|
|
61
|
+
- `text` (`WritableComputedRef<string>`): The text of the search field, for `v-model`. A new text shows at once, and the table filters when the typing pauses (`searchDebounce` of the table). A search text that the table gets from elsewhere shows here too.
|
|
62
|
+
- `pending` (`Readonly<ShallowRef<boolean>>`): Whether a text waits for its pause, so the rows do not follow the field yet.
|
|
63
|
+
- `clear` (`() => void`): Empties the search at once, for a clear button and for Escape.
|
|
64
|
+
- `flush` (`() => void`): Filters now by the text that waits, for Enter.
|
|
65
|
+
|
|
66
|
+
## EditDraft
|
|
67
|
+
|
|
68
|
+
Vue only: the result of `useEditDraft` from `ui-sdk-table-vue`.
|
|
69
|
+
|
|
70
|
+
- `rows` (`ComputedRef<Row[]>`): The rows to pass to the table: the rows of the owner with the values of the draft in them.
|
|
71
|
+
- `formulas` (`ComputedRef<CellFormulas>`): The formulas to pass to the table as `cell-formulas`: the formulas of the owner with those of the draft over them. Without the `formulas` option, those of the draft alone.
|
|
72
|
+
- `count` (`ComputedRef<number>`): How many cells hold another value or another formula than the owner, each cell once, and how many columns another formula.
|
|
73
|
+
- `changed` (`(rowId: string, columnId: string) => boolean`): Whether a cell holds another value or another formula of its own than the owner, by the row id and the column id.
|
|
74
|
+
- `changedColumn` (`(columnId: string) => boolean`): Whether the formula of a column (the `columns` layer) differs from the formula of the owner.
|
|
75
|
+
- `onCellFormulasChange` (`(value: CellFormulas) => void`): Pass it as the `cell-formulas-change` listener of the table.
|
|
76
|
+
- `onCellEdit` (`(edits: readonly CellEdit<Row>[]) => void`): Pass it as the `cell-edit` listener of the table. It takes every report: an edit, a paste, a fill, a clear and an undo. It throws for an edit of a row that is not in the rows of the owner, such as a child row.
|
|
77
|
+
- `save` (`() => EditDraftSave<Row>`): The edits against the rows of the owner, one for each cell that differs, and the formulas to keep; the draft is empty after it.
|
|
78
|
+
- `cancel` (`() => void`): Empties the draft: the values and the formulas together.
|
|
79
|
+
|
|
80
|
+
## EditDraftOptions
|
|
81
|
+
|
|
82
|
+
Vue only: the options for `useEditDraft`.
|
|
83
|
+
|
|
84
|
+
- `getRowId?` (`(row: Row, index: number, parent: null) => string | number`): The `getRowId` of the table, when it has one. Without it, a row is found by its `id`, else by its place.
|
|
85
|
+
- `formulas?` (`MaybeRefOrGetter<CellFormulas | undefined>`): The formulas of the owner, for a table with `formulas`. The draft then holds the formulas that a person types as it holds the values: pass `formulas` of the draft as the `cell-formulas` of the table and its `onCellFormulasChange` as the listener, and the formulas of the owner stay as they are until Save.
|
|
86
|
+
|
|
87
|
+
## Rows
|
|
88
|
+
|
|
89
|
+
### DataRow
|
|
90
|
+
|
|
91
|
+
- `kind` (`'row'`): Always `'row'`: a row of the data.
|
|
92
|
+
- `id` (`string`): The id of the row, from `getRowId`.
|
|
93
|
+
- `row` (`Row`): The row object of the data, as the owner passed it.
|
|
94
|
+
- `index` (`number`): Position among its siblings in the source data.
|
|
95
|
+
- `depth` (`number`): Tree depth in the source data, 0 for a top-level row.
|
|
96
|
+
- `parentId` (`string | null`): The id of the tree row above this row, or `null`.
|
|
97
|
+
- `children?` (`readonly DataRow<Row>[]`): The child rows, for a tree row.
|
|
98
|
+
|
|
99
|
+
### GroupRow
|
|
100
|
+
|
|
101
|
+
- `kind` (`'group'`): Always `'group'`: a group of rows.
|
|
102
|
+
- `id` (`string`): The id of the group, such as `group/team=Design`. `expanded` holds it.
|
|
103
|
+
- `columnId` (`string`): The id of the column that makes the group.
|
|
104
|
+
- `value` (`unknown`): The value of that column that the rows of the group share.
|
|
105
|
+
- `depth` (`number`): Grouping level, 0 for the first `groupBy` column.
|
|
106
|
+
- `parentId` (`string | null`): The id of the group above this one, or `null`.
|
|
107
|
+
- `parent` (`GroupRow<Row> | null`): The group that holds this group, or `null` for a group of the first `groupBy` column.
|
|
108
|
+
- `children` (`readonly TableRow<Row>[]`): The groups or the rows right under this group.
|
|
109
|
+
- `leaves` (`readonly DataRow<Row>[]`): Every data row under the group, in order, without their tree children.
|
|
110
|
+
|
|
111
|
+
### GroupPathEntry
|
|
112
|
+
|
|
113
|
+
- `group` (`GroupRow<Row>`): The group.
|
|
114
|
+
- `column` (`ColumnDef<Row> | undefined`): The column that the group is made from. `undefined` when the table has no such column any more.
|
|
115
|
+
- `value` (`unknown`): The value that the rows of the group share.
|
|
116
|
+
- `text` (`string`): The value as text, with the format of its column.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Row numbers and letters
|
|
2
|
+
|
|
3
|
+
Give a sheet a column of row numbers and a row of column letters, where a person selects whole rows and columns.
|
|
4
|
+
|
|
5
|
+
Use them together with `cellSelection`, and always with formulas, so a person sees the addresses that a formula names.
|
|
6
|
+
|
|
7
|
+
```ts title="letters.ts"
|
|
8
|
+
import { type ColumnDef, rowNumberColumn } from 'ui-sdk-table-core'
|
|
9
|
+
|
|
10
|
+
import { defineReferenceTable, type ReferenceTableElement } from 'ui-sdk-table-web/reference'
|
|
11
|
+
|
|
12
|
+
type City = { id: string; city: string; country: string; people: number }
|
|
13
|
+
|
|
14
|
+
const cities: City[] = [
|
|
15
|
+
{ id: 'c1', city: 'Porto', country: 'Portugal', people: 232000 },
|
|
16
|
+
{ id: 'c2', city: 'Ghent', country: 'Belgium', people: 265000 },
|
|
17
|
+
{ id: 'c3', city: 'Tartu', country: 'Estonia', people: 97000 },
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
const columns: ColumnDef<City>[] = [
|
|
21
|
+
// A column of row numbers: it stays first, and no range, copy or export holds it.
|
|
22
|
+
rowNumberColumn<City>(),
|
|
23
|
+
{ id: 'city', header: 'City' },
|
|
24
|
+
{ id: 'country', header: 'Country' },
|
|
25
|
+
{ id: 'people', header: 'People', format: 'integer' },
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
export default function mount(host: HTMLElement) {
|
|
29
|
+
defineReferenceTable()
|
|
30
|
+
const table = document.createElement('ui-reference-table') as ReferenceTableElement<City>
|
|
31
|
+
table.setAttribute('aria-label', 'Cities')
|
|
32
|
+
table.rows = cities
|
|
33
|
+
table.columns = columns
|
|
34
|
+
table.columnLetters = true
|
|
35
|
+
table.cellSelection = true
|
|
36
|
+
|
|
37
|
+
host.append(table)
|
|
38
|
+
const status = document.createElement('p')
|
|
39
|
+
status.setAttribute('role', 'status')
|
|
40
|
+
host.append(status)
|
|
41
|
+
const api = table.api
|
|
42
|
+
if (!api) return
|
|
43
|
+
function update() {
|
|
44
|
+
const view = table.api?.getView()
|
|
45
|
+
if (!view) return
|
|
46
|
+
const cells = view.cellSelection
|
|
47
|
+
status.textContent = cells ? `${cells.rows} by ${cells.columns} cells` : 'Nothing selected'
|
|
48
|
+
}
|
|
49
|
+
update()
|
|
50
|
+
return api.subscribe(update)
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Press the letter A: the cells of City are selected and the line says 3 by 1 cells. Press the row number 2, then the row number 3 with Shift: two whole rows. The corner above the numbers selects every cell, without the numbers.
|
|
55
|
+
|
|
56
|
+
## Row numbers
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const columns = [rowNumberColumn<Row>(), { id: 'name' }, { id: 'price' }]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `rowNumberColumn(options?)` is a column with `lead: true` and `rowHeader: true`. It stays first, sticks with the start pins, and is outside every range, copy, paste, fill, format and export.
|
|
63
|
+
- Its cells are `th` elements with the role `rowheader` and `data-row-header`, with the name "Row 3" (message `rowNumber`). A screen reader says the number with each cell of the row.
|
|
64
|
+
- The number is the place of the row among the data rows, counted over the pages. Group rows have none. With formulas, it is the place of the row in `rows`: see [Formulas](./sheet-formulas.md).
|
|
65
|
+
- A press on a number selects the cells of its row, with Shift the rows from the active cell on. A drag over numbers selects those rows.
|
|
66
|
+
- Custom `row-header` content in the reference table receives `{ row, node, column, number, selectRow }`.
|
|
67
|
+
- Give the cell `position: sticky; inset-inline-start: 0` and an opaque background to keep it in view without a pinned column.
|
|
68
|
+
|
|
69
|
+
## Column letters
|
|
70
|
+
|
|
71
|
+
`columnLetters` adds a row of letters above the header rows: A, B, C, then AA. It is not part of `sheet`; turn it on as you add `rowNumberColumn()`. A press on a header still sorts, moves and resizes.
|
|
72
|
+
|
|
73
|
+
- **Pointer:** a press on a letter selects the cells of its column, with Shift the columns from the active cell to it. A drag over letters selects those columns, and it stays whole columns when the pointer goes down into the rows.
|
|
74
|
+
- **The corner** is the letter cell above a first column that leads. It selects every column with a letter, so a column of row numbers or of checkboxes stays out. The letter cell of another column that leads is empty and selects nothing.
|
|
75
|
+
- **The letter** is the place of the column among the columns in view: a moved column, and the columns after a hidden one, take the letter of their new place. `lettersByColumn(layout)` gives the letters by column id. With formulas a letter stays with its column: see [Formulas](./sheet-formulas.md).
|
|
76
|
+
- **The grid:** the row of letters is grid row 0, so the header rows start at row 1 and `aria-rowcount` is one more. It sticks with `stickyHeader`, pinned columns pin their letter, and an export does not hold it.
|
|
77
|
+
- **Custom content:** `letter` receives `{ column, letter, corner, selectColumn }`. `letter` is `undefined` for a column that leads. `selectColumn(event?)` selects what a press selects, and throws for a column that leads and is no corner. Without custom content, the cell shows the letter.
|
|
78
|
+
|
|
79
|
+
## Keys
|
|
80
|
+
|
|
81
|
+
| Key | On a letter |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| An arrow | Reaches the letters from the header rows |
|
|
84
|
+
| Space, Control+Space, Shift+Space, Enter | Selects the column of the letter; every column from the corner |
|
|
85
|
+
| Shift with Left or Right | Grows the selection by a column, also from right to left |
|
|
86
|
+
| Control or Command with A | Selects what the corner does |
|
|
87
|
+
| Escape | Drops the range |
|
|
88
|
+
| Delete, a cut, a copy, a fill, the format keys | Act on the selected cells, as from a row number |
|
|
89
|
+
| Tab | Leaves the table |
|
|
90
|
+
|
|
91
|
+
## Attributes
|
|
92
|
+
|
|
93
|
+
- The row of letters has `data-kind="letters"`. `rowAttrs` gets `{ kind: 'letters' }`.
|
|
94
|
+
- A letter cell is a `th` with the role `columnheader`, `data-kind="letter"`, `data-column`, and `data-selected` when every row of its column is selected. `cellAttrs` gets `{ kind: 'letter', column, letter, corner }`.
|
|
95
|
+
- The corner has `data-corner` and the name "All cells" (message `cornerCell`). The cells of leading columns have `data-lead`.
|
|
96
|
+
- A row number has `data-row-header`.
|
|
97
|
+
|
|
98
|
+
The row of letters needs no style to work. A styled table gives the letters a small centred text, a look for `[data-selected]`, and an opaque background where the row sticks (`tr[data-sticky]`) or a cell is pinned (`[data-pinned]`). Add `position: sticky; inset-inline-start: 0` on `[data-corner]` when the row numbers stick that way.
|
|
99
|
+
|
|
100
|
+
See the [Sheet tiles of the sink](https://ui-sdk-table.fdts.dev/?page=sink&only=sheet).
|
|
101
|
+
|
|
102
|
+
## Names
|
|
103
|
+
|
|
104
|
+
- **Attributes:** `data-row-header`, `data-corner`, `data-kind="letters"` on a row and `data-kind="letter"` on a cell.
|
|
105
|
+
- **Exports:** `rowNumberColumn`, `columnLetter`, `lettersByColumn`.
|
|
106
|
+
|
|
107
|
+
For shared methods and result types, see [Controller](./reference-controller.md) and [View](./reference-view.md).
|
|
108
|
+
|
|
109
|
+
For custom elements, properties and DOM events, see the [Web Components API reference](./api-web-components.md).
|