@c2n/table 0.0.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 +20 -0
- package/dist/table-column-Dsv4HKrd.js +92 -0
- package/dist/table-column.js +2 -0
- package/dist/table-types.js +18 -0
- package/dist/table.js +1029 -0
- package/package.json +88 -0
- package/react.d.ts +26 -0
- package/react.js +3 -0
- package/types/src/table-column.d.ts +72 -0
- package/types/src/table-column.d.ts.map +1 -0
- package/types/src/table-types.d.ts +112 -0
- package/types/src/table-types.d.ts.map +1 -0
- package/types/src/table.d.ts +272 -0
- package/types/src/table.d.ts.map +1 -0
- package/vue.d.ts +57 -0
- package/vue.js +3 -0
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@c2n/table",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/table.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./types/src/table.d.ts",
|
|
9
|
+
"default": "./dist/table.js"
|
|
10
|
+
},
|
|
11
|
+
"./table-column.js": {
|
|
12
|
+
"types": "./types/src/table-column.d.ts",
|
|
13
|
+
"default": "./dist/table-column.js"
|
|
14
|
+
},
|
|
15
|
+
"./table-types.js": {
|
|
16
|
+
"types": "./types/src/table-types.d.ts",
|
|
17
|
+
"default": "./dist/table-types.js"
|
|
18
|
+
},
|
|
19
|
+
"./react": {
|
|
20
|
+
"types": "./react.d.ts",
|
|
21
|
+
"default": "./react.js"
|
|
22
|
+
},
|
|
23
|
+
"./vue": {
|
|
24
|
+
"types": "./vue.d.ts",
|
|
25
|
+
"default": "./vue.js"
|
|
26
|
+
},
|
|
27
|
+
"./custom-elements.json": "./custom-elements.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"types",
|
|
32
|
+
"react.d.ts",
|
|
33
|
+
"react.js",
|
|
34
|
+
"vue.d.ts",
|
|
35
|
+
"vue.js"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"table",
|
|
39
|
+
"data grid",
|
|
40
|
+
"virtual scroll",
|
|
41
|
+
"web component",
|
|
42
|
+
"lit"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"author": "code2nguyen@gmail.com",
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"registry": "https://registry.npmjs.org",
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/code2nguyen/web-components.git"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "vite",
|
|
56
|
+
"build": "wireit",
|
|
57
|
+
"build:only": "vite build",
|
|
58
|
+
"type-check": "wireit"
|
|
59
|
+
},
|
|
60
|
+
"wireit": {
|
|
61
|
+
"type-check": {
|
|
62
|
+
"dependencies": [
|
|
63
|
+
"../../core:build",
|
|
64
|
+
"../checkbox:build",
|
|
65
|
+
"../spinner:build"
|
|
66
|
+
],
|
|
67
|
+
"command": "tsc -p tsconfig.lib.json --composite false"
|
|
68
|
+
},
|
|
69
|
+
"build": {
|
|
70
|
+
"dependencies": [
|
|
71
|
+
"type-check"
|
|
72
|
+
],
|
|
73
|
+
"command": "vite build"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"@c2n/checkbox": "0.0.7",
|
|
78
|
+
"@c2n/core": "0.0.7",
|
|
79
|
+
"@c2n/spinner": "0.0.7",
|
|
80
|
+
"@lit/context": "1.1.6",
|
|
81
|
+
"lit": "3.3.3"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@c2n/config": "*"
|
|
85
|
+
},
|
|
86
|
+
"customElements": "custom-elements.json",
|
|
87
|
+
"gitHead": "c8db398a27f7cd417d665fdf5da455fee2d4e910"
|
|
88
|
+
}
|
package/react.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// GENERATED by @c2n/framework-types. Do not edit by hand.
|
|
2
|
+
//
|
|
3
|
+
// JSX types for the custom elements of @c2n/table. Import once, anywhere in the program:
|
|
4
|
+
//
|
|
5
|
+
// import '@c2n/table/react'
|
|
6
|
+
//
|
|
7
|
+
// Register the elements at module scope before React renders, or React writes an object prop as an
|
|
8
|
+
// attribute and it stringifies.
|
|
9
|
+
|
|
10
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react'
|
|
11
|
+
import type { Table } from '@c2n/table'
|
|
12
|
+
import type { TableColumn } from '@c2n/table/table-column.js'
|
|
13
|
+
|
|
14
|
+
/** Standard React host-element attributes plus the element's own public properties. */
|
|
15
|
+
type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
|
|
16
|
+
|
|
17
|
+
declare module 'react' {
|
|
18
|
+
namespace JSX {
|
|
19
|
+
interface IntrinsicElements {
|
|
20
|
+
'c2-table': C2Props<Table>
|
|
21
|
+
'c2-table-column': C2Props<TableColumn>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {}
|
package/react.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import type { ColumnAlign, ColumnFormat, ColumnPin, TableCellRenderer, TableColumnConfig, TableHeaderRenderer } from './table-types.js';
|
|
3
|
+
/** Fired at the parent table whenever a column definition changes. */
|
|
4
|
+
export declare const COLUMN_CHANGE_EVENT = "c2-table-column-change";
|
|
5
|
+
/**
|
|
6
|
+
* One column of a `c2-table`, declared as a light-DOM child. The element renders nothing: it is a definition the
|
|
7
|
+
* table reads, the same way `c2-select` reads its `c2-list-item` children. Everything it exposes as an attribute can
|
|
8
|
+
* also be set as a property, and the function-valued properties (`renderCell`, `renderHeader`, `comparator`) are
|
|
9
|
+
* property-only.
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* <c2-table rows='[{ "name": "Ada", "score": 12 }]'>
|
|
13
|
+
* <c2-table-column field="name" header="Name" width="2fr" sortable pinned="start"></c2-table-column>
|
|
14
|
+
* <c2-table-column field="score" header="Score" width="120px" align="end" format="number" sortable></c2-table-column>
|
|
15
|
+
* </c2-table>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @tag c2-table-column
|
|
19
|
+
*/
|
|
20
|
+
export declare class TableColumn extends LitElement implements TableColumnConfig {
|
|
21
|
+
#private;
|
|
22
|
+
static styles: import("lit").CSSResult;
|
|
23
|
+
/** Key of the value in the row object; may be a dotted path such as `user.name`. */
|
|
24
|
+
field: string;
|
|
25
|
+
/** Header label. Falls back to the field name. */
|
|
26
|
+
header?: string;
|
|
27
|
+
/** Grid track for the column: `1fr`, `160px`, `minmax(120px, 1fr)`… */
|
|
28
|
+
width: string;
|
|
29
|
+
/** Lower bound in pixels while the column is resized. */
|
|
30
|
+
minWidth: number;
|
|
31
|
+
/** Horizontal alignment of the header and the cells. */
|
|
32
|
+
align: ColumnAlign;
|
|
33
|
+
/** Lets the user sort by this column. Defaults to the table's `sortable`. */
|
|
34
|
+
sortable?: boolean;
|
|
35
|
+
/** Lets the user drag the column's trailing edge. Defaults to the table's `resizable`. */
|
|
36
|
+
resizable?: boolean;
|
|
37
|
+
/** Freezes the column against the leading or trailing edge while scrolling horizontally. */
|
|
38
|
+
pinned?: ColumnPin;
|
|
39
|
+
/** Leaves the column out of the table without removing the definition. */
|
|
40
|
+
hidden: boolean;
|
|
41
|
+
/** Built-in `Intl` formatting applied when no `renderCell` is set. */
|
|
42
|
+
format: ColumnFormat;
|
|
43
|
+
/** Options handed to the `Intl` formatter of `format`, as JSON in the attribute. */
|
|
44
|
+
formatOptions?: Record<string, unknown>;
|
|
45
|
+
/** Currency code used by `format="currency"`. */
|
|
46
|
+
currency?: string;
|
|
47
|
+
/** BCP 47 locale used by `format`. Defaults to the browser locale. */
|
|
48
|
+
locale?: string;
|
|
49
|
+
/** Class set on every cell of this column, so light-DOM CSS can target it through `::part(cell)`. */
|
|
50
|
+
cellClass?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Renders each cell from a light-DOM child of the table rather than from `renderCell`: the cell holds a
|
|
53
|
+
* `<slot name="cell:<row key>:<field>">`, so a framework can build the body with its own template language.
|
|
54
|
+
* Requires the table's `row-key`.
|
|
55
|
+
*/
|
|
56
|
+
cellSlot: boolean;
|
|
57
|
+
/** Renders the cell body. Property only. */
|
|
58
|
+
renderCell?: TableCellRenderer;
|
|
59
|
+
/** Renders the header body. Property only. */
|
|
60
|
+
renderHeader?: TableHeaderRenderer;
|
|
61
|
+
/** Client-side sort comparator for this column's values. Property only. */
|
|
62
|
+
comparator?: (a: unknown, b: unknown) => number;
|
|
63
|
+
connectedCallback(): void;
|
|
64
|
+
disconnectedCallback(): void;
|
|
65
|
+
protected updated(_changed: PropertyValues): void;
|
|
66
|
+
}
|
|
67
|
+
declare global {
|
|
68
|
+
interface HTMLElementTagNameMap {
|
|
69
|
+
'c2-table-column': TableColumn;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=table-column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-column.d.ts","sourceRoot":"","sources":["../../src/table-column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAKhE,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEvI,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAE3D;;;;;;;;;;;;;;GAcG;AACH,qBACa,WAAY,SAAQ,UAAW,YAAW,iBAAiB;;IACtE,OA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
3
|
+
export interface SortModel {
|
|
4
|
+
field: string;
|
|
5
|
+
direction: SortDirection;
|
|
6
|
+
}
|
|
7
|
+
export type ColumnAlign = 'start' | 'center' | 'end';
|
|
8
|
+
export type ColumnPin = 'start' | 'end';
|
|
9
|
+
export type ColumnFormat = 'text' | 'number' | 'percent' | 'currency' | 'date' | 'datetime' | 'time';
|
|
10
|
+
/** A row is any plain object; values are read by `field`, which may be a dotted path (`user.name`). */
|
|
11
|
+
export type TableRow = Record<string, unknown>;
|
|
12
|
+
export interface TableCellContext {
|
|
13
|
+
value: unknown;
|
|
14
|
+
row: TableRow;
|
|
15
|
+
rowIndex: number;
|
|
16
|
+
column: TableColumnConfig;
|
|
17
|
+
}
|
|
18
|
+
export interface TableHeaderContext {
|
|
19
|
+
column: TableColumnConfig;
|
|
20
|
+
}
|
|
21
|
+
/** Returns anything Lit can render: a `TemplateResult`, a string, a number, a node. */
|
|
22
|
+
export type TableCellRenderer = (context: TableCellContext) => unknown;
|
|
23
|
+
export type TableHeaderRenderer = (context: TableHeaderContext) => unknown;
|
|
24
|
+
export interface TableColumnConfig {
|
|
25
|
+
/** Key of the value in the row object; may be a dotted path. */
|
|
26
|
+
field: string;
|
|
27
|
+
/** Header label. Defaults to the field. */
|
|
28
|
+
header?: string;
|
|
29
|
+
/** Grid track for the column: `1fr`, `160px`, `minmax(120px, 1fr)`… Defaults to `1fr`. */
|
|
30
|
+
width?: string;
|
|
31
|
+
/** Lower bound in pixels while resizing. Defaults to 64. */
|
|
32
|
+
minWidth?: number;
|
|
33
|
+
align?: ColumnAlign;
|
|
34
|
+
sortable?: boolean;
|
|
35
|
+
resizable?: boolean;
|
|
36
|
+
/** Freezes the column against the left (`start`) or right (`end`) edge while scrolling horizontally. */
|
|
37
|
+
pinned?: ColumnPin;
|
|
38
|
+
hidden?: boolean;
|
|
39
|
+
/** Built-in `Intl` formatting applied when no `renderCell` is given. */
|
|
40
|
+
format?: ColumnFormat;
|
|
41
|
+
/** Options passed to the `Intl` formatter of `format`. */
|
|
42
|
+
formatOptions?: Record<string, unknown>;
|
|
43
|
+
/** Currency code for `format="currency"`. Defaults to `USD`. */
|
|
44
|
+
currency?: string;
|
|
45
|
+
/** BCP 47 locale for `format`. Defaults to the browser locale. */
|
|
46
|
+
locale?: string;
|
|
47
|
+
/** Class set on every cell of the column, for `::part(cell)`-free styling from the light DOM. */
|
|
48
|
+
cellClass?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Renders each cell of the column from a light-DOM child instead of a function, so a framework can build the
|
|
51
|
+
* body with its own template language. The table puts a `<slot name="cell:<row key>:<field>">` in the cell;
|
|
52
|
+
* `renderCell` (or the formatted value) stays as the fallback while nothing is slotted into it.
|
|
53
|
+
*
|
|
54
|
+
* Requires `rowKey`. Only the rows the virtualizer has rendered have a slot, so children for the rest simply
|
|
55
|
+
* wait — write one child per row and let the table pick.
|
|
56
|
+
*/
|
|
57
|
+
cellSlot?: boolean;
|
|
58
|
+
renderCell?: TableCellRenderer;
|
|
59
|
+
renderHeader?: TableHeaderRenderer;
|
|
60
|
+
/** Client-side sort comparator for the column's values. */
|
|
61
|
+
comparator?: (a: unknown, b: unknown) => number;
|
|
62
|
+
}
|
|
63
|
+
export interface TableRowsRequest {
|
|
64
|
+
/** Index of the first row requested. */
|
|
65
|
+
start: number;
|
|
66
|
+
/** Number of rows requested. */
|
|
67
|
+
count: number;
|
|
68
|
+
/** Sort the server should apply, in priority order. */
|
|
69
|
+
sort: SortModel[];
|
|
70
|
+
}
|
|
71
|
+
export interface TableRowsResult {
|
|
72
|
+
rows: TableRow[];
|
|
73
|
+
/** Total number of rows on the server. Required on the first response so the scrollbar can be sized. */
|
|
74
|
+
total?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Lazy row source: the table asks for one block of rows at a time as they scroll into view, instead of holding the
|
|
78
|
+
* whole dataset in `rows`. Sorting is delegated to the source.
|
|
79
|
+
*/
|
|
80
|
+
export interface TableDataSource {
|
|
81
|
+
getRows(request: TableRowsRequest): Promise<TableRowsResult>;
|
|
82
|
+
}
|
|
83
|
+
export interface TableSelectionChangeEventDetail {
|
|
84
|
+
/** Keys of the selected rows (`row-key` field, or the row index when no `row-key` is set). */
|
|
85
|
+
value: string[];
|
|
86
|
+
/** The selected rows themselves; only the loaded ones when a `dataSource` is used. */
|
|
87
|
+
rows: TableRow[];
|
|
88
|
+
}
|
|
89
|
+
export interface TableSortChangeEventDetail {
|
|
90
|
+
sort: SortModel[];
|
|
91
|
+
}
|
|
92
|
+
export interface TableRowEventDetail {
|
|
93
|
+
row: TableRow;
|
|
94
|
+
rowIndex: number;
|
|
95
|
+
key: string;
|
|
96
|
+
}
|
|
97
|
+
export interface TableCellEventDetail extends TableRowEventDetail {
|
|
98
|
+
column: TableColumnConfig;
|
|
99
|
+
value: unknown;
|
|
100
|
+
}
|
|
101
|
+
export interface TableColumnResizeEventDetail {
|
|
102
|
+
field: string;
|
|
103
|
+
width: number;
|
|
104
|
+
}
|
|
105
|
+
/** Reads a possibly dotted `field` path out of a row. Re-exported from `@c2n/core` so the table keeps its own subpath. */
|
|
106
|
+
export { getFieldValue } from '@c2n/core/data-helper.js';
|
|
107
|
+
/** `name:asc;age:desc` ⇄ `SortModel[]`, so the sort can be set from markup. */
|
|
108
|
+
export declare const sortModelConverter: {
|
|
109
|
+
toAttribute: (value: SortModel[]) => string | null;
|
|
110
|
+
fromAttribute: (value: string | null) => SortModel[];
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=table-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-types.d.ts","sourceRoot":"","sources":["../../src/table-types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,aAAa,CAAA;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BAAiB,CAAA;IACzB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,0HAA0H;AAC1H,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB;yBACR,SAAS,EAAE;2BACT,MAAM,GAAG,IAAI,KAAG,SAAS,EAAE;CAWnD,CAAA"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
|
|
3
|
+
import { type SortModel, type TableCellEventDetail, type TableColumnConfig, type TableColumnResizeEventDetail, type TableDataSource, type TableRow, type TableRowEventDetail, type TableSelectionChangeEventDetail, type TableSortChangeEventDetail } from './table-types.js';
|
|
4
|
+
import '@c2n/checkbox';
|
|
5
|
+
import '@c2n/spinner';
|
|
6
|
+
export type TableSelectionMode = 'none' | 'single' | 'multiple';
|
|
7
|
+
export type TableVirtualMode = 'auto' | 'always' | 'never';
|
|
8
|
+
export interface TablePageChangeEventDetail {
|
|
9
|
+
/** The page now shown, 1-based. */
|
|
10
|
+
page: number;
|
|
11
|
+
/** The page shown before. */
|
|
12
|
+
previousPage: number;
|
|
13
|
+
/** Rows per page. */
|
|
14
|
+
pageSize: number;
|
|
15
|
+
/** Total number of pages. */
|
|
16
|
+
pageCount: number;
|
|
17
|
+
/** Index of the first row of the page, and how many were asked for — the `getRows` request that follows. */
|
|
18
|
+
start: number;
|
|
19
|
+
count: number;
|
|
20
|
+
/** Total rows the data source reports. */
|
|
21
|
+
totalRows: number;
|
|
22
|
+
}
|
|
23
|
+
/** Events fired by {@link Table}, keyed for `addEventListener`. */
|
|
24
|
+
export interface TableEventMap {
|
|
25
|
+
'selection-change': CustomEvent<TableSelectionChangeEventDetail>;
|
|
26
|
+
'sort-change': CustomEvent<TableSortChangeEventDetail>;
|
|
27
|
+
'row-click': CustomEvent<TableRowEventDetail>;
|
|
28
|
+
'cell-click': CustomEvent<TableCellEventDetail>;
|
|
29
|
+
'column-resize': CustomEvent<TableColumnResizeEventDetail>;
|
|
30
|
+
'page-change': CustomEvent<TablePageChangeEventDetail>;
|
|
31
|
+
}
|
|
32
|
+
export interface Table {
|
|
33
|
+
addEventListener: TypedAddEventListener<Table, TableEventMap>;
|
|
34
|
+
removeEventListener: TypedRemoveEventListener<Table, TableEventMap>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A data grid: a scrolling, virtualized table built from a `rows` array (or an async `dataSource`) and a set of
|
|
38
|
+
* `c2-table-column` definitions given as light-DOM children. Sorting, row selection, column pinning, column resizing
|
|
39
|
+
* and keyboard navigation are built in; every cell can be rendered by a function, so a cell body can be any markup —
|
|
40
|
+
* including other c2 components.
|
|
41
|
+
*
|
|
42
|
+
* Rows and columns are readable from markup as JSON attributes as well as from script as properties, so a table can be
|
|
43
|
+
* authored without a build step:
|
|
44
|
+
*
|
|
45
|
+
* ```html
|
|
46
|
+
* <c2-table row-key="id" selection="multiple" checkbox-selection sortable stripe style="height: 320px">
|
|
47
|
+
* <c2-table-column field="name" header="Name" width="2fr" pinned="start"></c2-table-column>
|
|
48
|
+
* <c2-table-column field="score" header="Score" width="120px" align="end" format="number"></c2-table-column>
|
|
49
|
+
* </c2-table>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* **Layout.** The table is one CSS grid: the header row and every body row are grid items using `grid-template-columns:
|
|
53
|
+
* subgrid`, so columns stay aligned without any scroll syncing, and pinned columns are `position: sticky` cells rather
|
|
54
|
+
* than separate containers. Give the host a height (or `--c2-table--max-height`) — the body scrolls inside it.
|
|
55
|
+
*
|
|
56
|
+
* **Styling one column.** Every cell carries two parts named after its column — `cell-<field>` on the cell box and
|
|
57
|
+
* `cell-content-<field>` on the text inside it — so a single column can be given its own colour, alignment or pill
|
|
58
|
+
* shape from outside: `::part(cell-content-status) { border-radius: 999px; background: #f4f4f5 }`. Rows are
|
|
59
|
+
* `::part(row)` and `::part(row-selected)`.
|
|
60
|
+
*
|
|
61
|
+
* **Virtualization** windows the rows to the visible range plus an overscan margin. It needs a uniform row height, which
|
|
62
|
+
* it measures from the first rendered row, so theme the height with `--c2-table__row--height` (`row-height` is only the
|
|
63
|
+
* estimate used for the first paint). It turns on automatically past `virtual-threshold` rows; `virtual="always"` and
|
|
64
|
+
* `virtual="never"` force it.
|
|
65
|
+
*
|
|
66
|
+
* @tag c2-table
|
|
67
|
+
*
|
|
68
|
+
* @slot default - The column definitions: `c2-table-column` elements. They render nothing themselves.
|
|
69
|
+
* @slot toolbar - Bar above the header, for a title, filters or a column menu. Hidden when empty.
|
|
70
|
+
* @slot footer - Bar below the rows, for a row count or a `c2-pagination`. Hidden when empty.
|
|
71
|
+
* @slot empty - Replaces the built-in "no rows" message.
|
|
72
|
+
* @slot loading - Replaces the built-in spinner shown while the first rows load.
|
|
73
|
+
* @slot error - Replaces the built-in message shown when `error` is set.
|
|
74
|
+
* @slot cell:{rowKey}:{field} - Body of one cell of a column marked `cell-slot`, e.g. `slot="cell:AAPL:change"`. Lets a framework render a cell with its own template language instead of a `renderCell` function; the column's `renderCell` or formatted value stays as the fallback.
|
|
75
|
+
*
|
|
76
|
+
* @slotcomponent c2-table-column
|
|
77
|
+
* @slotcomponent c2-pagination
|
|
78
|
+
*
|
|
79
|
+
* @event {CustomEvent<TableSelectionChangeEventDetail>} selection-change - Fired after the user changes the selection. `detail.value` is the array of selected row keys, `detail.rows` the matching rows. Does not bubble: several components fire `selection-change`, so a listener belongs on the element itself rather than on an ancestor.
|
|
80
|
+
* @event {CustomEvent<TableSortChangeEventDetail>} sort-change - Fired after the user clicks a sortable header. `detail.sort` is the new sort model, in priority order.
|
|
81
|
+
* @event {CustomEvent<TableRowEventDetail>} row-click - Fired when a row is clicked, before the selection is applied.
|
|
82
|
+
* @event {CustomEvent<TableCellEventDetail>} cell-click - Fired when a cell is clicked; adds `detail.column` and `detail.value`.
|
|
83
|
+
* @event {CustomEvent<TableColumnResizeEventDetail>} column-resize - Fired when the user releases a column's resize handle.
|
|
84
|
+
* @event {CustomEvent<TablePageChangeEventDetail>} page-change - Fired after the shown page changes, while `paginated`. `detail.start` and `detail.count` are the slice of the whole dataset now shown — with a `dataSource`, the `getRows` request that follows. A pager slotted in the footer does not fire its own: the table speaks for it.
|
|
85
|
+
*
|
|
86
|
+
* @cssproperty {color} [--c2-table--background=#ffffff]
|
|
87
|
+
* @cssproperty {color} [--c2-table--color=#18181b]
|
|
88
|
+
* @cssproperty {font-size} [--c2-table--font-size=14px]
|
|
89
|
+
* @cssproperty {pixel} [--c2-table--max-height=none] - Caps the height when the host is not sized itself; the body scrolls.
|
|
90
|
+
*
|
|
91
|
+
* @cssproperty {border} [--c2-table--border-top=1px solid #e4e4e7]
|
|
92
|
+
* @cssproperty {border} [--c2-table--border-right=1px solid #e4e4e7]
|
|
93
|
+
* @cssproperty {border} [--c2-table--border-bottom=1px solid #e4e4e7]
|
|
94
|
+
* @cssproperty {border} [--c2-table--border-left=1px solid #e4e4e7]
|
|
95
|
+
*
|
|
96
|
+
* @cssproperty {border-radius} [--c2-table--border-top-left-radius=8px]
|
|
97
|
+
* @cssproperty {border-radius} [--c2-table--border-top-right-radius=8px]
|
|
98
|
+
* @cssproperty {border-radius} [--c2-table--border-bottom-left-radius=8px]
|
|
99
|
+
* @cssproperty {border-radius} [--c2-table--border-bottom-right-radius=8px]
|
|
100
|
+
*
|
|
101
|
+
* @cssproperty {box-shadow} [--c2-table--box-shadow=none]
|
|
102
|
+
*
|
|
103
|
+
* @cssproperty {color} [--c2-table__header--background=#fafafa]
|
|
104
|
+
* @cssproperty {color} [--c2-table__header--color=#71717a]
|
|
105
|
+
* @cssproperty {pixel} [--c2-table__header--height=36px]
|
|
106
|
+
* @cssproperty {font-size} [--c2-table__header--font-size=12px]
|
|
107
|
+
* @cssproperty {font-weight} [--c2-table__header--font-weight=600]
|
|
108
|
+
* @cssproperty {letter-spacing} [--c2-table__header--letter-spacing=0.02em]
|
|
109
|
+
* @cssproperty {border} [--c2-table__header--border-bottom=1px solid #e4e4e7]
|
|
110
|
+
*
|
|
111
|
+
* @cssproperty {padding} [--c2-table__header-cell--padding=0 12px]
|
|
112
|
+
* @cssproperty {pixel} [--c2-table__header-cell--gap=6px]
|
|
113
|
+
* @cssproperty {color} [--c2-table__header-cell__hover--background=#f4f4f5]
|
|
114
|
+
* @cssproperty {color} [--c2-table__header-cell__sorted--color=#18181b]
|
|
115
|
+
*
|
|
116
|
+
* @cssproperty {pixel} [--c2-table__sort-icon--width=14px]
|
|
117
|
+
* @cssproperty {pixel} [--c2-table__sort-icon--height=14px]
|
|
118
|
+
* @cssproperty {color} [--c2-table__sort-icon--color=#a1a1aa]
|
|
119
|
+
* @cssproperty {color} [--c2-table__sort-icon__active--color=rgb(2, 101, 220)]
|
|
120
|
+
*
|
|
121
|
+
* @cssproperty {pixel} [--c2-table__resizer--width=9px] - Width of the grab area, not of the visible line.
|
|
122
|
+
* @cssproperty {pixel} [--c2-table__resizer--height=56%] - Height of the resting divider, as a share of the header.
|
|
123
|
+
* @cssproperty {pixel} [--c2-table__resizer--line-width=1px]
|
|
124
|
+
* @cssproperty {color} [--c2-table__resizer--color=#e4e4e7] - The divider drawn at a resizable column's edge.
|
|
125
|
+
* @cssproperty {pixel} [--c2-table__resizer__hover--height=100%]
|
|
126
|
+
* @cssproperty {pixel} [--c2-table__resizer__hover--line-width=2px]
|
|
127
|
+
* @cssproperty {color} [--c2-table__resizer__hover--color=rgb(2, 101, 220)]
|
|
128
|
+
*
|
|
129
|
+
* @cssproperty {pixel} [--c2-table__row--height=36px] - Row height; virtualization measures it, so keep it uniform.
|
|
130
|
+
* @cssproperty {border} [--c2-table__row--border-bottom=1px solid #e4e4e7]
|
|
131
|
+
* @cssproperty {color} [--c2-table__row__hover--background=#fafafa]
|
|
132
|
+
* @cssproperty {color} [--c2-table__row__odd--background=#fafafa] - Applies with the `stripe` attribute.
|
|
133
|
+
* @cssproperty {color} [--c2-table__row__selected--background=#edf1fe]
|
|
134
|
+
* @cssproperty {color} [--c2-table__row__selected--color=#18181b]
|
|
135
|
+
*
|
|
136
|
+
* @cssproperty {padding} [--c2-table__cell--padding=0 12px]
|
|
137
|
+
* @cssproperty {pixel} [--c2-table__cell--gap=8px]
|
|
138
|
+
* @cssproperty {font-size} [--c2-table__cell--font-size=14px]
|
|
139
|
+
* @cssproperty {color} [--c2-table__cell--color=#18181b]
|
|
140
|
+
* @cssproperty {border} [--c2-table__cell--border-right=none] - Vertical grid lines; applies to header cells too.
|
|
141
|
+
* @cssproperty {outline} [--c2-table__cell__focus--outline=2px solid rgba(2, 101, 220, 0.4)]
|
|
142
|
+
* @cssproperty {pixel} [--c2-table__cell__focus--outline-offset=-2px]
|
|
143
|
+
*
|
|
144
|
+
* @cssproperty {box-shadow} [--c2-table__pinned-start--box-shadow=1px 0 0 0 #e4e4e7] - Separator on the last column pinned to the start.
|
|
145
|
+
* @cssproperty {box-shadow} [--c2-table__pinned-end--box-shadow=-1px 0 0 0 #e4e4e7] - Separator on the first column pinned to the end.
|
|
146
|
+
*
|
|
147
|
+
* @cssproperty {pixel} [--c2-table__selection-cell--width=44px] - Width of the `checkbox-selection` column.
|
|
148
|
+
*
|
|
149
|
+
* @cssproperty {color} [--c2-table__skeleton--background=#f4f4f5] - Placeholder shown in cells whose `dataSource` block is still loading.
|
|
150
|
+
* @cssproperty {border-radius} [--c2-table__skeleton--border-radius=4px]
|
|
151
|
+
*
|
|
152
|
+
* @cssproperty {color} [--c2-table__state--color=#71717a] - Colour of the empty and loading messages.
|
|
153
|
+
* @cssproperty {padding} [--c2-table__state--padding=32px 12px]
|
|
154
|
+
* @cssproperty {font-size} [--c2-table__state--font-size=14px]
|
|
155
|
+
* @cssproperty {color} [--c2-table__state__error--color=rgb(211, 21, 16)]
|
|
156
|
+
*
|
|
157
|
+
* @cssproperty {color} [--c2-table__toolbar--background=transparent]
|
|
158
|
+
* @cssproperty {padding} [--c2-table__toolbar--padding=8px 12px]
|
|
159
|
+
* @cssproperty {border} [--c2-table__toolbar--border-bottom=1px solid #e4e4e7]
|
|
160
|
+
*
|
|
161
|
+
* @cssproperty {color} [--c2-table__footer--background=transparent]
|
|
162
|
+
* @cssproperty {padding} [--c2-table__footer--padding=8px 12px]
|
|
163
|
+
* @cssproperty {border} [--c2-table__footer--border-top=1px solid #e4e4e7]
|
|
164
|
+
*/
|
|
165
|
+
export declare class Table extends LitElement {
|
|
166
|
+
#private;
|
|
167
|
+
static styles: import("lit").CSSResult;
|
|
168
|
+
private viewport;
|
|
169
|
+
/** The rows to display. An array in the property, JSON in the attribute. */
|
|
170
|
+
rows: TableRow[];
|
|
171
|
+
/** Column definitions, as an alternative to `c2-table-column` children. Children win when both are present. */
|
|
172
|
+
columns?: TableColumnConfig[];
|
|
173
|
+
/** Field used as the identity of a row, for selection and DOM reuse. Falls back to the row index. */
|
|
174
|
+
rowKey: string;
|
|
175
|
+
/** `single` selects one row at a time, `multiple` supports ⌘/ctrl-click and shift-click ranges. */
|
|
176
|
+
selection: TableSelectionMode;
|
|
177
|
+
/** Adds a leading checkbox column, pinned to the start. */
|
|
178
|
+
checkboxSelection: boolean;
|
|
179
|
+
/** Keys of the selected rows: an array in the property, `;`-separated in the attribute. */
|
|
180
|
+
value: string[];
|
|
181
|
+
/** The sort, in priority order: `SortModel[]` in the property, `field:asc;other:desc` in the `sort` attribute. */
|
|
182
|
+
sortModel: SortModel[];
|
|
183
|
+
/** Lets shift-click add a column to the sort instead of replacing it. */
|
|
184
|
+
multiSort: boolean;
|
|
185
|
+
/** Makes every column sortable; a column's own `sortable` still wins. */
|
|
186
|
+
sortable: boolean;
|
|
187
|
+
/** Makes every column resizable; a column's own `resizable` still wins. */
|
|
188
|
+
resizable: boolean;
|
|
189
|
+
/** Tints odd rows with `--c2-table__row__odd--background`. */
|
|
190
|
+
stripe: boolean;
|
|
191
|
+
/** `auto` virtualizes past `virtual-threshold` rows; `always` and `never` force it. */
|
|
192
|
+
virtual: TableVirtualMode;
|
|
193
|
+
/** Row height in pixels used before the first row has been measured. */
|
|
194
|
+
rowHeight: number;
|
|
195
|
+
/** Rows rendered above and below the viewport while virtualizing. */
|
|
196
|
+
overscan: number;
|
|
197
|
+
/** Row count past which `virtual="auto"` starts windowing. */
|
|
198
|
+
virtualThreshold: number;
|
|
199
|
+
/** Lazy row source used instead of `rows`; the table requests one block at a time as rows scroll into view. */
|
|
200
|
+
dataSource?: TableDataSource;
|
|
201
|
+
/** Number of rows the table asks a `dataSource` for at a time. */
|
|
202
|
+
blockSize: number;
|
|
203
|
+
/** Shows the loading state; implied while a `dataSource` resolves its first block. */
|
|
204
|
+
loading: boolean;
|
|
205
|
+
/** Shows the error state with this message. */
|
|
206
|
+
error: string;
|
|
207
|
+
/** Message shown when there are no rows. */
|
|
208
|
+
emptyMessage: string;
|
|
209
|
+
/** The page on show, 1-based. Only meaningful while the table is `paginated`; clamped to `pageCount`. */
|
|
210
|
+
page: number;
|
|
211
|
+
/**
|
|
212
|
+
* Rows per page. `0` leaves paging off; a `c2-pagination` slotted into the `footer` sets it from its own
|
|
213
|
+
* `page-size` when the table has none, which is what makes the nested form work with no configuration.
|
|
214
|
+
* With `rows` the page is sliced in place; with a `dataSource` each page is one request.
|
|
215
|
+
*/
|
|
216
|
+
pageSize: number;
|
|
217
|
+
private columnElements;
|
|
218
|
+
private widthOverrides;
|
|
219
|
+
private focusedCell;
|
|
220
|
+
private hasToolbar;
|
|
221
|
+
private hasFooter;
|
|
222
|
+
private remoteTotal;
|
|
223
|
+
/**
|
|
224
|
+
* Shared with a `c2-pagination` slotted into the `footer`. Rebuilt rather than mutated whenever the paging state
|
|
225
|
+
* moves: `@lit/context` consumers only re-render on a new object identity.
|
|
226
|
+
*/
|
|
227
|
+
private pager;
|
|
228
|
+
/** Total number of rows the table knows about: `rows.length`, or the `dataSource` total. */
|
|
229
|
+
get totalRows(): number;
|
|
230
|
+
/**
|
|
231
|
+
* Number of rows on screen right now: the whole dataset, or one page of it while `paginated`. This is what the
|
|
232
|
+
* virtualizer windows and what `virtual="auto"` measures, so a 25-row page is never virtualized against a
|
|
233
|
+
* million-row total.
|
|
234
|
+
*/
|
|
235
|
+
get rowCount(): number;
|
|
236
|
+
/**
|
|
237
|
+
* Whether the table is paging its rows. `rows` are sliced in place; a `dataSource` is asked for one page per
|
|
238
|
+
* request. Either way `page-size` is the switch, and a pager slotted into the `footer` sets it.
|
|
239
|
+
*/
|
|
240
|
+
get paginated(): boolean;
|
|
241
|
+
/** Number of pages, at least 1. */
|
|
242
|
+
get pageCount(): number;
|
|
243
|
+
/** Whether the rows are currently windowed. */
|
|
244
|
+
get isVirtualized(): boolean;
|
|
245
|
+
/** The resolved, ordered, visible columns — children first, then the `columns` property, then one per key of the first row. */
|
|
246
|
+
get resolvedColumns(): TableColumnConfig[];
|
|
247
|
+
/** The rows currently selected. Only the loaded ones when a `dataSource` is used. */
|
|
248
|
+
getSelectedRows(): TableRow[];
|
|
249
|
+
/** Selects every loaded row. No-op unless `selection="multiple"`. */
|
|
250
|
+
selectAll(): void;
|
|
251
|
+
/** Clears the selection. */
|
|
252
|
+
clearSelection(): void;
|
|
253
|
+
/** Scrolls the row at `index` into view. */
|
|
254
|
+
scrollToIndex(index: number): void;
|
|
255
|
+
/** Drops the `dataSource` cache and reloads the visible rows. */
|
|
256
|
+
refresh(): void;
|
|
257
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
258
|
+
/** Shows `page`, clamped to the available range, and loads it. Fires `page-change` when the page actually moves. */
|
|
259
|
+
goToPage(page: number): void;
|
|
260
|
+
/** Changes the rows per page, keeping the first row of the current page on screen. */
|
|
261
|
+
setPageSize(pageSize: number): void;
|
|
262
|
+
protected updated(changed: PropertyValues): void;
|
|
263
|
+
render(): TemplateResult<1>;
|
|
264
|
+
connectedCallback(): void;
|
|
265
|
+
disconnectedCallback(): void;
|
|
266
|
+
}
|
|
267
|
+
declare global {
|
|
268
|
+
interface HTMLElementTagNameMap {
|
|
269
|
+
'c2-table': Table;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAGpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAWhG,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAChC,MAAM,kBAAkB,CAAA;AAEzB,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAGrB,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAA;AAC/D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAa1D,MAAM,WAAW,0BAA0B;IACzC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,4GAA4G;IAC5G,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAA;CAClB;AAgBD,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B,kBAAkB,EAAE,WA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,EAAE,MAAM;cAQT,OAAO,CAAC,OAAO,EAAE,cAAc;IAgBzC,MAAM;IAsZN,iBAAiB;IASjB,oBAAoB;CAqR9B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,KAAK,CAAA;KAClB;CACF"}
|
package/vue.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// GENERATED by @c2n/framework-types. Do not edit by hand.
|
|
2
|
+
//
|
|
3
|
+
// Vue template types for the custom elements of @c2n/table. Import once, anywhere in the program:
|
|
4
|
+
//
|
|
5
|
+
// import '@c2n/table/vue'
|
|
6
|
+
//
|
|
7
|
+
// Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
|
|
8
|
+
// nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
|
|
9
|
+
|
|
10
|
+
import type { DefineComponent, HTMLAttributes } from 'vue'
|
|
11
|
+
import type { Table, TableEventMap } from '@c2n/table'
|
|
12
|
+
import type { TableColumn, TableColumnEventMap } from '@c2n/table/table-column.js'
|
|
13
|
+
|
|
14
|
+
/** The element's own public properties, plus every attribute Vue understands on a host element. */
|
|
15
|
+
type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
|
|
16
|
+
|
|
17
|
+
declare module 'vue' {
|
|
18
|
+
interface GlobalComponents {
|
|
19
|
+
'c2-table': DefineComponent<
|
|
20
|
+
C2Props<Table> & {
|
|
21
|
+
'row-key'?: unknown
|
|
22
|
+
'checkbox-selection'?: unknown
|
|
23
|
+
sort?: unknown
|
|
24
|
+
'multi-sort'?: unknown
|
|
25
|
+
'row-height'?: unknown
|
|
26
|
+
'virtual-threshold'?: unknown
|
|
27
|
+
'block-size'?: unknown
|
|
28
|
+
'empty-message'?: unknown
|
|
29
|
+
'page-size'?: unknown
|
|
30
|
+
onPageChange?: (event: TableEventMap['page-change']) => void
|
|
31
|
+
onSortChange?: (event: TableEventMap['sort-change']) => void
|
|
32
|
+
onRowClick?: (event: TableEventMap['row-click']) => void
|
|
33
|
+
onCellClick?: (event: TableEventMap['cell-click']) => void
|
|
34
|
+
onSelectionChange?: (event: TableEventMap['selection-change']) => void
|
|
35
|
+
onColumnResize?: (event: TableEventMap['column-resize']) => void
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
'c2-table-column': DefineComponent<
|
|
39
|
+
C2Props<TableColumn> & {
|
|
40
|
+
'min-width'?: unknown
|
|
41
|
+
'format-options'?: unknown
|
|
42
|
+
'cell-class'?: unknown
|
|
43
|
+
'cell-slot'?: unknown
|
|
44
|
+
onCOLUMN_CHANGE_EVENT?: (event: TableColumnEventMap['COLUMN_CHANGE_EVENT']) => void
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare module '@vue/runtime-dom' {
|
|
51
|
+
interface HTMLAttributes {
|
|
52
|
+
/** Vue's own definition omits it, and slotting a plain element into a component needs it. */
|
|
53
|
+
slot?: string
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {}
|
package/vue.js
ADDED