@substrat-run/elements 0.0.0-stage → 0.1.0
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 +202 -0
- package/README.md +58 -2
- package/dist/avatar.d.ts +56 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +107 -0
- package/dist/avatar.js.map +1 -0
- package/dist/controls.d.ts +21 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +21 -0
- package/dist/controls.js.map +1 -0
- package/dist/entity-table-model.d.ts +269 -0
- package/dist/entity-table-model.d.ts.map +1 -0
- package/dist/entity-table-model.js +490 -0
- package/dist/entity-table-model.js.map +1 -0
- package/dist/entity-table.d.ts +187 -0
- package/dist/entity-table.d.ts.map +1 -0
- package/dist/entity-table.js +1004 -0
- package/dist/entity-table.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/session-controller.d.ts +25 -0
- package/dist/internal/session-controller.d.ts.map +1 -0
- package/dist/internal/session-controller.js +46 -0
- package/dist/internal/session-controller.js.map +1 -0
- package/dist/internal/substrat-element.d.ts +36 -0
- package/dist/internal/substrat-element.d.ts.map +1 -0
- package/dist/internal/substrat-element.js +195 -0
- package/dist/internal/substrat-element.js.map +1 -0
- package/dist/jsx.d.ts +8 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +2 -0
- package/dist/jsx.js.map +1 -0
- package/dist/session.d.ts +84 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +158 -0
- package/dist/session.js.map +1 -0
- package/dist/themes/atelier.css +59 -0
- package/dist/themes/base.css +7 -0
- package/dist/themes/ledger.css +59 -0
- package/dist/themes/native.css +11 -0
- package/dist/user-menu.d.ts +95 -0
- package/dist/user-menu.d.ts.map +1 -0
- package/dist/user-menu.js +212 -0
- package/dist/user-menu.js.map +1 -0
- package/package.json +47 -3
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<sub-entity-table>` — the rows of one paged read: its views, its sort, its filters and
|
|
3
|
+
* search, a selection, and the actions a row allows.
|
|
4
|
+
*
|
|
5
|
+
* A renderer over `EntityTableModel`: it draws the state and forwards clicks, and decides
|
|
6
|
+
* nothing the model does not. Styled only through Web Awesome's `--wa-*` tokens, so it
|
|
7
|
+
* follows whatever theme the page sets — Web Awesome's own, or a Substrat one — with no
|
|
8
|
+
* theme code in here. Uses Web Awesome's free controls inside.
|
|
9
|
+
*
|
|
10
|
+
* Properties (not attributes — they are objects and functions):
|
|
11
|
+
* `source` — `{ read, follow, search? }`: `read(query)` is the generated client's read
|
|
12
|
+
* given the query's `sort`, `order`, filters and view
|
|
13
|
+
* `columns` — `Column[]`; `sort` makes a header a sort button, `kind` draws the value
|
|
14
|
+
* (`badge`, `money`, `relative`, …), and `render` / `mount` replace it
|
|
15
|
+
* `actions` — `RowAction[]`, run through the model (403 / 409 / 404 handled there);
|
|
16
|
+
* `views` scopes one to some views, `bulk` offers it for a selection
|
|
17
|
+
* `views` — `{ id, label }[]`, drawn as a switch above the rows; the first is the default
|
|
18
|
+
* `filters` — `{ key, label, options }[]`, equality filters on declared filterable columns
|
|
19
|
+
* `query` — the first read's query, for a screen restoring one from its URL
|
|
20
|
+
* `layout` — `{ order, hidden }` by column key: which columns show, in what order
|
|
21
|
+
* Attributes: `label` (the table's accessible name), `empty`, `forbidden-text`,
|
|
22
|
+
* `search-label`, `selectable`, `density="compact"`, `paging` (`pages`, the default —
|
|
23
|
+
* Previous / Next with "21–40 of 132" — or `more`, one "Load more" that appends), and
|
|
24
|
+
* `page-size` (25). `pageSizes` is the property behind the rows-per-page picker.
|
|
25
|
+
* `column-picker` adds a "Columns" button: show, hide and reorder the columns. Opt-in;
|
|
26
|
+
* without it the columns are exactly the ones given. `layout-key` keeps the chosen layout
|
|
27
|
+
* in this browser under that key; a screen that would rather keep it on the account
|
|
28
|
+
* listens for `sub-layout-change` and hands it back through `layout`.
|
|
29
|
+
* Slot: `empty` — what an empty view says, in place of `empty` (a "Create" button, say).
|
|
30
|
+
* Events: `sub-action-done` `{ action, rows }` after an action succeeded on some rows;
|
|
31
|
+
* `sub-query-change` `{ query }` whenever the person changes the view, sort, filters or search;
|
|
32
|
+
* `sub-layout-change` `{ layout }` whenever they show, hide or move a column.
|
|
33
|
+
*
|
|
34
|
+
* ## Cells a vertical draws itself
|
|
35
|
+
*
|
|
36
|
+
* `render(row)` returns a Lit template or a string, drawn in the table's shadow root. A
|
|
37
|
+
* framework that is not Lit uses `mount(cell, row)` instead: `cell` is an element in the
|
|
38
|
+
* LIGHT DOM, slotted into its place, so React or Vue can render into it and the page's own
|
|
39
|
+
* stylesheet applies to whatever it draws. `mount` may return `{ update(row), unmount() }`;
|
|
40
|
+
* without `update`, a changed row is unmounted and mounted again.
|
|
41
|
+
*
|
|
42
|
+
* ## Styling, outside in
|
|
43
|
+
*
|
|
44
|
+
* The theme's `--wa-*` tokens; then `--sub-table-*` (row height, header and selected
|
|
45
|
+
* backgrounds, cell padding, `--sub-table-max-height` — set it and the header sticks);
|
|
46
|
+
* then `::part()` — `frame`, `toolbar`, `bulk-bar`, `table`, `header-cell`, `row`
|
|
47
|
+
* (plus `selected`), `cell`, `footer`, `empty`.
|
|
48
|
+
*/
|
|
49
|
+
import '@awesome.me/webawesome/dist/components/badge/badge.js';
|
|
50
|
+
import '@awesome.me/webawesome/dist/components/button/button.js';
|
|
51
|
+
import '@awesome.me/webawesome/dist/components/callout/callout.js';
|
|
52
|
+
import '@awesome.me/webawesome/dist/components/checkbox/checkbox.js';
|
|
53
|
+
import '@awesome.me/webawesome/dist/components/dropdown/dropdown.js';
|
|
54
|
+
import '@awesome.me/webawesome/dist/components/dropdown-item/dropdown-item.js';
|
|
55
|
+
import '@awesome.me/webawesome/dist/components/input/input.js';
|
|
56
|
+
import '@awesome.me/webawesome/dist/components/option/option.js';
|
|
57
|
+
import '@awesome.me/webawesome/dist/components/popover/popover.js';
|
|
58
|
+
import '@awesome.me/webawesome/dist/components/radio/radio.js';
|
|
59
|
+
import '@awesome.me/webawesome/dist/components/radio-group/radio-group.js';
|
|
60
|
+
import '@awesome.me/webawesome/dist/components/select/select.js';
|
|
61
|
+
import '@awesome.me/webawesome/dist/components/skeleton/skeleton.js';
|
|
62
|
+
import '@awesome.me/webawesome/dist/components/spinner/spinner.js';
|
|
63
|
+
import { nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
64
|
+
import SubstratElement from './internal/substrat-element.js';
|
|
65
|
+
import { type ColumnSpec, type RowAction, type TableLayout, type TableQuery, type TableSource, type TableState } from './entity-table-model.js';
|
|
66
|
+
/** What `mount` may hand back, so the table can keep a framework's cell up to date. */
|
|
67
|
+
export interface CellHandle<T> {
|
|
68
|
+
update?(row: T): void;
|
|
69
|
+
unmount?(): void;
|
|
70
|
+
}
|
|
71
|
+
export interface Column<T, S extends string = string> extends ColumnSpec<T, S> {
|
|
72
|
+
/** Draw the cell yourself, in the table's shadow root. */
|
|
73
|
+
render?(row: T): TemplateResult | string;
|
|
74
|
+
/** Draw the cell yourself, into a light-DOM element — for React, Vue, or plain DOM. */
|
|
75
|
+
mount?(cell: HTMLElement, row: T): CellHandle<T> | void;
|
|
76
|
+
}
|
|
77
|
+
export interface TableView {
|
|
78
|
+
id: string;
|
|
79
|
+
label: string;
|
|
80
|
+
}
|
|
81
|
+
export interface TableFilter {
|
|
82
|
+
/** A declared filterable column — the read's own input field. */
|
|
83
|
+
key: string;
|
|
84
|
+
label: string;
|
|
85
|
+
options: readonly {
|
|
86
|
+
value: string;
|
|
87
|
+
label: string;
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
90
|
+
export declare class SubEntityTable<T = unknown, S extends string = string> extends SubstratElement {
|
|
91
|
+
#private;
|
|
92
|
+
static properties: {
|
|
93
|
+
source: {
|
|
94
|
+
attribute: boolean;
|
|
95
|
+
};
|
|
96
|
+
columns: {
|
|
97
|
+
attribute: boolean;
|
|
98
|
+
};
|
|
99
|
+
actions: {
|
|
100
|
+
attribute: boolean;
|
|
101
|
+
};
|
|
102
|
+
views: {
|
|
103
|
+
attribute: boolean;
|
|
104
|
+
};
|
|
105
|
+
filters: {
|
|
106
|
+
attribute: boolean;
|
|
107
|
+
};
|
|
108
|
+
query: {
|
|
109
|
+
attribute: boolean;
|
|
110
|
+
};
|
|
111
|
+
layout: {
|
|
112
|
+
attribute: boolean;
|
|
113
|
+
};
|
|
114
|
+
columnPicker: {
|
|
115
|
+
type: BooleanConstructor;
|
|
116
|
+
attribute: string;
|
|
117
|
+
reflect: boolean;
|
|
118
|
+
};
|
|
119
|
+
layoutKey: {
|
|
120
|
+
attribute: string;
|
|
121
|
+
};
|
|
122
|
+
label: {};
|
|
123
|
+
empty: {};
|
|
124
|
+
forbiddenText: {
|
|
125
|
+
attribute: string;
|
|
126
|
+
};
|
|
127
|
+
searchLabel: {
|
|
128
|
+
attribute: string;
|
|
129
|
+
};
|
|
130
|
+
selectable: {
|
|
131
|
+
type: BooleanConstructor;
|
|
132
|
+
reflect: boolean;
|
|
133
|
+
};
|
|
134
|
+
density: {
|
|
135
|
+
reflect: boolean;
|
|
136
|
+
};
|
|
137
|
+
paging: {
|
|
138
|
+
reflect: boolean;
|
|
139
|
+
};
|
|
140
|
+
pageSize: {
|
|
141
|
+
type: NumberConstructor;
|
|
142
|
+
attribute: string;
|
|
143
|
+
};
|
|
144
|
+
pageSizes: {
|
|
145
|
+
attribute: boolean;
|
|
146
|
+
};
|
|
147
|
+
view: {
|
|
148
|
+
state: boolean;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
source: TableSource<T, S> | undefined;
|
|
152
|
+
columns: Column<T, S>[];
|
|
153
|
+
actions: RowAction<T>[];
|
|
154
|
+
views: TableView[];
|
|
155
|
+
filters: TableFilter[];
|
|
156
|
+
query: Partial<TableQuery<S>> | undefined;
|
|
157
|
+
layout: TableLayout | undefined;
|
|
158
|
+
columnPicker: boolean;
|
|
159
|
+
layoutKey: string | undefined;
|
|
160
|
+
label: string;
|
|
161
|
+
empty: string;
|
|
162
|
+
forbiddenText: string;
|
|
163
|
+
searchLabel: string;
|
|
164
|
+
selectable: boolean;
|
|
165
|
+
density: 'comfortable' | 'compact';
|
|
166
|
+
paging: 'pages' | 'more';
|
|
167
|
+
pageSize: number;
|
|
168
|
+
pageSizes: number[];
|
|
169
|
+
view: TableState<T, S> | undefined;
|
|
170
|
+
constructor();
|
|
171
|
+
connectedCallback(): void;
|
|
172
|
+
disconnectedCallback(): void;
|
|
173
|
+
/** Read again with the current query — after the host created a row, say. */
|
|
174
|
+
reload(): Promise<void>;
|
|
175
|
+
/** The query the rows on screen answer, for a screen that keeps it in its URL. */
|
|
176
|
+
get currentQuery(): TableQuery<S> | undefined;
|
|
177
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
178
|
+
protected updated(changed: PropertyValues): void;
|
|
179
|
+
static css: import("lit").CSSResult;
|
|
180
|
+
render(): typeof nothing | TemplateResult<1>;
|
|
181
|
+
}
|
|
182
|
+
declare global {
|
|
183
|
+
interface HTMLElementTagNameMap {
|
|
184
|
+
'sub-entity-table': SubEntityTable;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=entity-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-table.d.ts","sourceRoot":"","sources":["../src/entity-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,OAAO,uDAAuD,CAAC;AAC/D,OAAO,yDAAyD,CAAC;AACjE,OAAO,2DAA2D,CAAC;AACnE,OAAO,6DAA6D,CAAC;AACrE,OAAO,6DAA6D,CAAC;AACrE,OAAO,uEAAuE,CAAC;AAC/E,OAAO,uDAAuD,CAAC;AAC/D,OAAO,yDAAyD,CAAC;AACjE,OAAO,2DAA2D,CAAC;AACnE,OAAO,uDAA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