@syware/jlib 0.6.0 → 0.8.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/dist/all.js +10 -5
- package/dist/atoms/jl-app-icon.d.ts +5 -0
- package/dist/atoms/jl-app-icon.js +26 -4
- package/dist/atoms/jl-badge.js +1 -1
- package/dist/atoms/jl-button.d.ts +5 -0
- package/dist/atoms/jl-button.js +4 -1
- package/dist/atoms/jl-chip.js +3 -2
- package/dist/atoms/jl-input.js +4 -3
- package/dist/atoms/jl-link.js +1 -1
- package/dist/atoms/jl-rating.js +4 -5
- package/dist/atoms/jl-select.css_raw.js +1 -1
- package/dist/atoms/jl-select.d.ts +10 -8
- package/dist/atoms/jl-select.js +15 -9
- package/dist/atoms/jl-spinner.js +2 -2
- package/dist/base/jl-form-control.js +2 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -4
- package/dist/lib/app-icon.d.ts +8 -0
- package/dist/lib/app-icon.js +37 -0
- package/dist/lib/attributes.d.ts +9 -0
- package/dist/lib/attributes.js +10 -1
- package/dist/lib/dom.d.ts +2 -0
- package/dist/lib/dom.js +3 -1
- package/dist/lib/download.d.ts +10 -0
- package/dist/lib/download.js +62 -0
- package/dist/lib/icons.d.ts +4 -0
- package/dist/lib/icons.js +7 -4
- package/dist/lib/input-list.d.ts +12 -0
- package/dist/lib/input-list.js +14 -0
- package/dist/lib/internals.d.ts +5 -0
- package/dist/lib/internals.js +18 -0
- package/dist/lib/nav-tree.d.ts +2 -2
- package/dist/lib/palette.d.ts +2 -2
- package/dist/lib/palette.js +6 -0
- package/dist/lib/resize.d.ts +2 -0
- package/dist/lib/resize.js +10 -0
- package/dist/lib/table.d.ts +22 -4
- package/dist/lib/table.js +55 -5
- package/dist/lib/text.d.ts +2 -0
- package/dist/lib/text.js +4 -1
- package/dist/lib/texts.d.ts +99 -0
- package/dist/lib/texts.js +104 -0
- package/dist/lib/tree.d.ts +10 -1
- package/dist/lib/tree.js +37 -3
- package/dist/molecules/jl-account-button.js +1 -1
- package/dist/molecules/jl-alert.js +2 -1
- package/dist/molecules/jl-breadcrumb.js +3 -3
- package/dist/molecules/jl-calendar.js +4 -4
- package/dist/molecules/jl-chip-group.d.ts +7 -6
- package/dist/molecules/jl-chip-group.js +8 -6
- package/dist/molecules/jl-code-block.css_raw.js +1 -1
- package/dist/molecules/jl-code-block.d.ts +5 -0
- package/dist/molecules/jl-code-block.js +5 -2
- package/dist/molecules/jl-combobox.js +5 -6
- package/dist/molecules/jl-copy-button.js +5 -4
- package/dist/molecules/jl-date-picker.js +6 -7
- package/dist/molecules/jl-empty.js +1 -1
- package/dist/molecules/jl-facts.css_raw.js +3 -0
- package/dist/molecules/jl-facts.d.ts +35 -0
- package/dist/molecules/jl-facts.js +64 -0
- package/dist/molecules/jl-file-drop.d.ts +5 -0
- package/dist/molecules/jl-file-drop.js +17 -14
- package/dist/molecules/jl-input-list.css_raw.js +3 -0
- package/dist/molecules/jl-input-list.d.ts +79 -0
- package/dist/molecules/jl-input-list.js +177 -0
- package/dist/molecules/jl-load-more.css_raw.js +3 -0
- package/dist/molecules/jl-load-more.d.ts +41 -0
- package/dist/molecules/jl-load-more.js +62 -0
- package/dist/molecules/jl-load-state.js +6 -7
- package/dist/molecules/jl-menu.d.ts +8 -4
- package/dist/molecules/jl-menu.js +8 -1
- package/dist/molecules/jl-number-input.js +4 -4
- package/dist/molecules/jl-pagination.js +5 -5
- package/dist/molecules/jl-radio-group.d.ts +8 -7
- package/dist/molecules/jl-radio-group.js +12 -8
- package/dist/molecules/jl-search-button.js +4 -4
- package/dist/molecules/jl-search.js +4 -4
- package/dist/molecules/jl-segmented.d.ts +8 -7
- package/dist/molecules/jl-segmented.js +12 -6
- package/dist/molecules/jl-steps.css_raw.js +1 -1
- package/dist/molecules/jl-steps.d.ts +2 -0
- package/dist/molecules/jl-steps.js +30 -14
- package/dist/molecules/jl-tabs.js +2 -1
- package/dist/molecules/jl-tag-input.js +2 -2
- package/dist/molecules/jl-toast.css_raw.js +1 -1
- package/dist/molecules/jl-toast.d.ts +13 -1
- package/dist/molecules/jl-toast.js +23 -3
- package/dist/organisms/jl-command-palette.css_raw.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +20 -4
- package/dist/organisms/jl-command-palette.js +41 -9
- package/dist/organisms/jl-confirm.js +5 -7
- package/dist/organisms/jl-dialog.js +2 -1
- package/dist/organisms/jl-drawer.js +2 -1
- package/dist/organisms/jl-flow.js +12 -12
- package/dist/organisms/jl-navbar.js +6 -6
- package/dist/organisms/jl-side-nav.css_raw.js +1 -1
- package/dist/organisms/jl-side-nav.d.ts +40 -7
- package/dist/organisms/jl-side-nav.js +78 -16
- package/dist/organisms/jl-tab-bar.d.ts +8 -7
- package/dist/organisms/jl-tab-bar.js +12 -6
- package/dist/organisms/jl-table.css_raw.js +1 -1
- package/dist/organisms/jl-table.d.ts +62 -15
- package/dist/organisms/jl-table.js +246 -35
- package/dist/organisms/jl-toaster.d.ts +9 -1
- package/dist/organisms/jl-toaster.js +148 -7
- package/dist/organisms/jl-tree.css_raw.js +1 -1
- package/dist/organisms/jl-tree.d.ts +71 -4
- package/dist/organisms/jl-tree.js +303 -40
- package/dist/templates/jl-app-shell.css_raw.js +1 -1
- package/dist/templates/jl-app-shell.d.ts +10 -0
- package/dist/templates/jl-app-shell.js +16 -2
- package/dist/templates/jl-auth-layout.js +1 -1
- package/dist/templates/jl-page.js +3 -3
- package/dist/templates/jl-split-view.js +5 -4
- package/dist/types/jl-app-icon.types.d.ts +5 -0
- package/dist/types/jl-chip-group.types.d.ts +3 -3
- package/dist/types/jl-command-palette.types.d.ts +17 -6
- package/dist/types/jl-facts.types.d.ts +17 -0
- package/dist/types/jl-menu.types.d.ts +4 -4
- package/dist/types/jl-radio-group.types.d.ts +6 -3
- package/dist/types/jl-segmented.types.d.ts +6 -3
- package/dist/types/jl-select.types.d.ts +6 -3
- package/dist/types/jl-side-nav.types.d.ts +11 -6
- package/dist/types/jl-steps.types.d.ts +2 -0
- package/dist/types/jl-tab-bar.types.d.ts +6 -3
- package/dist/types/jl-table.types.d.ts +42 -9
- package/dist/types/jl-toaster.types.d.ts +42 -1
- package/dist/types/jl-tree.types.d.ts +26 -0
- package/dist/types/texts.types.d.ts +5 -0
- package/package.json +3 -3
|
@@ -4,22 +4,23 @@ import type { TabBarItem } from '../types/jl-tab-bar.types';
|
|
|
4
4
|
* The bar along the bottom of a phone, under the thumb: the three to five main places of an app, an icon over a
|
|
5
5
|
* label, one tap away. `value` is the current item. Items with an `href` are links; the others are buttons; both
|
|
6
6
|
* fire `select`. `more` adds a last button for everything else, which fires `more`: in a `jl-app-shell`, it opens
|
|
7
|
-
* the navigation drawer.
|
|
7
|
+
* the navigation drawer. Typed by its ids, `JlTabBar<'home' | 'jobs'>` takes items of those ids and gives `select`
|
|
8
|
+
* one of them.
|
|
8
9
|
*/
|
|
9
|
-
export declare class JlTabBar extends JlElement {
|
|
10
|
+
export declare class JlTabBar<Id extends string = string> extends JlElement {
|
|
10
11
|
static readonly selector = "jl-tab-bar";
|
|
11
12
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
12
|
-
select:
|
|
13
|
+
select: Id;
|
|
13
14
|
more: undefined;
|
|
14
15
|
}>>;
|
|
15
16
|
readonly items: Readonly<Readonly<{
|
|
16
|
-
get(): TabBarItem[];
|
|
17
|
-
set(setter: TabBarItem[] | ((prevState: TabBarItem[]) => TabBarItem[])): void;
|
|
17
|
+
get(): TabBarItem<Id>[];
|
|
18
|
+
set(setter: TabBarItem<Id>[] | ((prevState: TabBarItem<Id>[]) => TabBarItem<Id>[])): void;
|
|
18
19
|
}>>;
|
|
19
20
|
/** The id of the current item. */
|
|
20
21
|
readonly value: Readonly<Readonly<{
|
|
21
|
-
get():
|
|
22
|
-
set(setter:
|
|
22
|
+
get(): "" | Id;
|
|
23
|
+
set(setter: "" | Id | ((prevState: "" | Id) => "" | Id)): void;
|
|
23
24
|
}>>;
|
|
24
25
|
/** The label of a last button for the other places (`More`); empty shows none. */
|
|
25
26
|
readonly more: Readonly<Readonly<{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
2
|
import { JlElement } from "../base/jl-element.js";
|
|
3
|
-
import { jsonOf } from "../lib/attributes.js";
|
|
3
|
+
import { jsonOf, textOf } from "../lib/attributes.js";
|
|
4
4
|
import { registerIcons } from "../lib/icons.js";
|
|
5
|
+
import { jlText } from "../lib/texts.js";
|
|
5
6
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
6
7
|
import { setOrRemove } from "../lib/dom.js";
|
|
7
8
|
import jl_tab_bar_default from "./jl-tab-bar.css_raw.js";
|
|
@@ -11,9 +12,9 @@ import { Fragment, jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
|
11
12
|
// src/organisms/jl-tab-bar.tsx
|
|
12
13
|
registerIcons({ ellipsis: Ellipsis });
|
|
13
14
|
var ICON_SIZE = 22;
|
|
14
|
-
var DEFAULT_LABEL = "Shortcuts";
|
|
15
15
|
var MAX_COUNT = 99;
|
|
16
16
|
var ITEM_SELECTOR = ".item";
|
|
17
|
+
var NO_ITEM = "";
|
|
17
18
|
/** A JSON attribute that should hold a list of items; anything else gives none. */
|
|
18
19
|
var parseItems = (value) => {
|
|
19
20
|
const parsed = jsonOf([])(value);
|
|
@@ -28,7 +29,8 @@ var badgeText = (badge) => {
|
|
|
28
29
|
* The bar along the bottom of a phone, under the thumb: the three to five main places of an app, an icon over a
|
|
29
30
|
* label, one tap away. `value` is the current item. Items with an `href` are links; the others are buttons; both
|
|
30
31
|
* fire `select`. `more` adds a last button for everything else, which fires `more`: in a `jl-app-shell`, it opens
|
|
31
|
-
* the navigation drawer.
|
|
32
|
+
* the navigation drawer. Typed by its ids, `JlTabBar<'home' | 'jobs'>` takes items of those ids and gives `select`
|
|
33
|
+
* one of them.
|
|
32
34
|
*/
|
|
33
35
|
var JlTabBar = class extends JlElement {
|
|
34
36
|
static selector = "jl-tab-bar";
|
|
@@ -38,14 +40,17 @@ var JlTabBar = class extends JlElement {
|
|
|
38
40
|
parse: parseItems
|
|
39
41
|
});
|
|
40
42
|
/** The id of the current item. */
|
|
41
|
-
value = this.useChange(
|
|
43
|
+
value = this.useChange(NO_ITEM, (value) => this.renderCurrent(value), {
|
|
44
|
+
attribute: "value",
|
|
45
|
+
parse: textOf(NO_ITEM)
|
|
46
|
+
});
|
|
42
47
|
/** The label of a last button for the other places (`More`); empty shows none. */
|
|
43
48
|
more = this.useChange("", (value) => {
|
|
44
49
|
this._refs.moreLabel.textContent = value;
|
|
45
50
|
this._refs.more.hidden = value === "";
|
|
46
51
|
}, { attribute: "more" });
|
|
47
52
|
/** The name of the navigation for screen readers. */
|
|
48
|
-
label = this.useChange(
|
|
53
|
+
label = this.useChange(jlText("shortcuts"), (value) => this._refs.nav.setAttribute("aria-label", value === "" ? jlText("shortcuts") : value), { attribute: "label" });
|
|
49
54
|
_refs = this.useRefs((ref) => ({
|
|
50
55
|
items: ref(".items"),
|
|
51
56
|
more: ref(".more"),
|
|
@@ -77,7 +82,8 @@ var JlTabBar = class extends JlElement {
|
|
|
77
82
|
this.on(this._refs.more, "click", () => this.events.emit("more"));
|
|
78
83
|
}
|
|
79
84
|
onClick(event) {
|
|
80
|
-
const
|
|
85
|
+
const pressed = event.target.closest(ITEM_SELECTOR)?.dataset.id;
|
|
86
|
+
const id = this.items.get().find((item) => item.id === pressed)?.id;
|
|
81
87
|
if (id === void 0) return;
|
|
82
88
|
this.value.set(id);
|
|
83
89
|
this.events.emit("select", id);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/organisms/jl-table.css?raw
|
|
2
|
-
var jl_table_default = ":host {\n display: block;\n /* The table scrolls sideways inside its frame: its width never pushes the page, or a grid around it, wider. */\n contain: inline-size;\n --max-height: none;\n --cell-y: 10px;\n --cell-x: 14px;\n}\n\n:host([dense]) {\n --cell-y: 6px;\n --cell-x: 12px;\n}\n\n.scroll {\n max-height: var(--max-height);\n overflow: auto;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius);\n background: var(--jl-surface);\n overscroll-behavior-x: contain;\n}\n\ntable {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n line-height: 20px;\n}\n\nth,\ntd {\n padding: var(--cell-y) var(--cell-x);\n white-space: nowrap;\n vertical-align: middle;\n}\n\nth {\n position: sticky;\n top: 0;\n z-index: 1;\n border-bottom: 1px solid var(--jl-line);\n background: var(--jl-surface-2);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n font-weight: 600;\n letter-spacing: 0.01em;\n text-align: left;\n}\n\ntd {\n border-top: 1px solid var(--jl-line-soft);\n}\n\ntbody tr:first-child td {\n border-top: none;\n}\n\ntbody tr.empty td {\n padding: 40px var(--cell-x);\n color: var(--jl-muted);\n text-align: center;\n}\n\n.align-left {\n text-align: left;\n}\n\n.align-center {\n text-align: center;\n}\n\n.align-right {\n text-align: right;\n}\n\n.sort {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin: -2px -4px;\n padding: 2px 4px;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n color: inherit;\n font-weight: inherit;\n letter-spacing: inherit;\n cursor: pointer;\n}\n\n.sort:hover {\n color: var(--jl-text);\n}\n\n.sort-icon {\n color: var(--jl-faint);\n}\n\nth[data-sorted] {\n color: var(--jl-text);\n}\n\nth[data-sorted] .sort-icon {\n color: var(--jl-accent);\n}\n\n/* Selected rows keep their shade: the hover and the stripes leave them alone. */\ntbody tr[data-selected] td {\n background: var(--jl-accent-soft);\n}\n\ntbody tr:not(.empty, .skeleton, [data-selected]):hover td {\n background: var(--jl-surface-2);\n}\n\n:host([striped]) tbody tr:nth-child(even):not(.empty, [data-selected]) td {\n background: var(--jl-surface-2);\n}\n\n:host([striped]) tbody tr:not(.empty, .skeleton, [data-selected]):hover td {\n background: var(--jl-surface-3);\n}\n\n.format-number {\n font-variant-numeric: tabular-nums;\n}\n\n.format-date {\n color: var(--jl-text-2);\n font-variant-numeric: tabular-nums;\n}\n\ncode {\n padding: 2px 6px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-code-bg);\n font-size: var(--jl-font-xs);\n}\n\n.select-cell {\n width:
|
|
2
|
+
var jl_table_default = ":host {\n display: block;\n /* The table scrolls sideways inside its frame: its width never pushes the page, or a grid around it, wider. */\n contain: inline-size;\n --max-height: none;\n --cell-y: 10px;\n --cell-x: 14px;\n --select-width: 44px;\n --expand-width: 36px;\n /* The width of the checkbox and chevron cells, after which the details of open rows start. */\n --lead: 0px;\n}\n\n:host([expandable]) {\n --lead: var(--expand-width);\n}\n\n:host([expandable][selectable]) {\n --expand-width: 28px;\n --lead: calc(var(--select-width) + var(--expand-width));\n}\n\n:host([dense]) {\n --cell-y: 6px;\n --cell-x: 12px;\n}\n\n.scroll {\n max-height: var(--max-height);\n overflow: auto;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius);\n background: var(--jl-surface);\n overscroll-behavior-x: contain;\n}\n\n/* The details of open rows take the width of the frame, not of the table. */\n:host([expandable]) .scroll {\n container-type: inline-size;\n}\n\ntable {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n line-height: 20px;\n}\n\nth,\ntd {\n padding: var(--cell-y) var(--cell-x);\n white-space: nowrap;\n vertical-align: middle;\n}\n\nth {\n position: sticky;\n top: 0;\n z-index: 1;\n border-bottom: 1px solid var(--jl-line);\n background: var(--jl-surface-2);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n font-weight: 600;\n letter-spacing: 0.01em;\n text-align: left;\n}\n\ntd {\n border-top: 1px solid var(--jl-line-soft);\n}\n\ntbody tr:first-child td {\n border-top: none;\n}\n\ntbody tr.empty td {\n padding: 40px var(--cell-x);\n color: var(--jl-muted);\n text-align: center;\n}\n\n/* An open row's detail: joined to its row, no line between them, in line with its first column. */\ntbody tr.detail td {\n padding: 0 var(--cell-x) calc(var(--cell-y) + 6px) calc(var(--lead) + var(--cell-x));\n border-top: none;\n white-space: normal;\n cursor: auto;\n}\n\n/* It stays in the frame while the table scrolls sideways. */\n.detail-body {\n position: sticky;\n left: calc(var(--lead) + var(--cell-x));\n max-width: calc(100cqi - var(--lead) - 2 * var(--cell-x));\n}\n\n.align-left {\n text-align: left;\n}\n\n.align-center {\n text-align: center;\n}\n\n.align-right {\n text-align: right;\n}\n\n.sort {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin: -2px -4px;\n padding: 2px 4px;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n color: inherit;\n font-weight: inherit;\n letter-spacing: inherit;\n cursor: pointer;\n}\n\n.sort:hover {\n color: var(--jl-text);\n}\n\n.sort-icon {\n color: var(--jl-faint);\n}\n\nth[data-sorted] {\n color: var(--jl-text);\n}\n\nth[data-sorted] .sort-icon {\n color: var(--jl-accent);\n}\n\n/* Selected rows keep their shade: the hover and the stripes leave them alone. */\ntbody tr[data-selected] td {\n background: var(--jl-accent-soft);\n}\n\n/* Marked rows (a search's matches) carry a bar at their start and a shade, which selection and hover take over. */\ntbody tr[data-marked] td {\n background: var(--jl-accent-soft);\n}\n\ntbody tr[data-marked] td:first-child {\n box-shadow: inset 3px 0 0 var(--jl-accent);\n}\n\ntbody tr:not(.empty, .skeleton, .detail, [data-selected]):hover td {\n background: var(--jl-surface-2);\n}\n\n/* The stripes count the rows of data, not the details of open rows. */\n:host([striped]) tbody tr:nth-child(even of :where(:not(.detail))):not(.empty, [data-selected], [data-marked]) td {\n background: var(--jl-surface-2);\n}\n\n:host([striped]) tbody tr:not(.empty, .skeleton, .detail, [data-selected]):hover td {\n background: var(--jl-surface-3);\n}\n\n/* An open row's detail takes the shade of its row. */\n:host([striped])\n tbody\n tr:nth-child(even of :where(:not(.detail))):not([data-selected], [data-marked])\n + .detail\n td {\n background: var(--jl-surface-2);\n}\n\n.format-number {\n font-variant-numeric: tabular-nums;\n}\n\n/* Broken anywhere, so a long address wraps too; never so narrow that a word stands alone on each line. */\ntd.wrap {\n min-width: 160px;\n white-space: normal;\n overflow-wrap: anywhere;\n}\n\n.format-date {\n color: var(--jl-text-2);\n font-variant-numeric: tabular-nums;\n}\n\ncode {\n padding: 2px 6px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-code-bg);\n font-size: var(--jl-font-xs);\n}\n\n.select-cell {\n width: var(--select-width);\n padding-right: 0;\n line-height: 0;\n}\n\n/* The chevron's icon starts where the cells' text does, its button around it; after a checkbox, close to it. */\n.expand-cell {\n width: var(--expand-width);\n padding-right: 0;\n padding-left: calc(var(--cell-x) - 4px);\n line-height: 0;\n}\n\n.select-cell + .expand-cell {\n padding-left: 0;\n}\n\n:host([expandable]) tbody tr[data-index] {\n cursor: pointer;\n}\n\n/* Taller than a line of text, the button reaches into the cell's padding rather than heighten the row. */\n.expand {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n margin: -2px 0;\n padding: 0;\n border: none;\n border-radius: var(--jl-radius-xs);\n background: none;\n color: var(--jl-muted);\n cursor: pointer;\n}\n\n.expand:hover {\n color: var(--jl-text);\n}\n\n.chevron {\n transition: rotate var(--jl-fast) var(--jl-ease);\n}\n\n.expand[aria-expanded=\"true\"] .chevron {\n rotate: 90deg;\n}\n\n/* The checkbox: the native input keeps the keyboard and the states, the mark beside it draws the tick. */\n.check {\n position: relative;\n display: inline-flex;\n}\n\n.checkbox {\n width: 16px;\n height: 16px;\n margin: 0;\n border: 1.5px solid var(--jl-line-strong);\n border-radius: 4px;\n background: var(--jl-surface);\n cursor: pointer;\n appearance: none;\n transition:\n background var(--jl-fast) var(--jl-ease),\n border-color var(--jl-fast) var(--jl-ease);\n}\n\n.checkbox:hover {\n border-color: var(--jl-muted);\n}\n\n.checkbox:checked,\n.checkbox:indeterminate {\n border-color: var(--jl-accent);\n background: var(--jl-accent);\n}\n\n.checkbox:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.mark {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n.checkbox:checked + .mark::after {\n position: absolute;\n top: 2.5px;\n left: 5.5px;\n width: 5px;\n height: 9px;\n border: solid var(--jl-on-accent);\n border-width: 0 2px 2px 0;\n rotate: 45deg;\n content: \"\";\n}\n\n.checkbox:indeterminate + .mark::after {\n position: absolute;\n top: 7px;\n right: 4px;\n left: 4px;\n height: 2px;\n border-radius: 1px;\n background: var(--jl-on-accent);\n content: \"\";\n}\n\n.empty-content {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n\n.empty jl-icon {\n color: var(--jl-faint);\n}\n\n.bone {\n display: inline-block;\n width: 70%;\n max-width: 160px;\n height: 10px;\n border-radius: var(--jl-radius-pill);\n background:\n linear-gradient(90deg, var(--jl-surface-3) 30%, var(--jl-surface-2) 50%, var(--jl-surface-3) 70%) 0 0 / 300%\n 100%;\n vertical-align: middle;\n animation: shimmer 1.4s linear infinite;\n}\n\n.bone.box {\n width: 16px;\n height: 16px;\n border-radius: 4px;\n}\n\ntbody tr.skeleton:nth-child(3n + 2) .bone:not(.box) {\n width: 50%;\n}\n\ntbody tr.skeleton:nth-child(3n) .bone:not(.box) {\n width: 85%;\n}\n\n/* Shortened to a millisecond by the base styles, an endless shimmer would flicker: it stands still instead. */\n@media (prefers-reduced-motion: reduce) {\n .bone {\n animation: none;\n }\n}\n\n@keyframes shimmer {\n from {\n background-position: 100% 0;\n }\n\n to {\n background-position: 0 0;\n }\n}\n\n/* A column's description: a quieter line under the cell's value. */\n.cell-description {\n margin-top: 2px;\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n";
|
|
3
3
|
export { jl_table_default as default };
|
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import { JlElement } from '../base/jl-element';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TableColumn, TableColumnKey, TableDetailRenderer, TableExpansion, TableField, TableRenderers, TableRow, TableRowKey, TableSort, TableSortDirection, TableToggle } from '../types/jl-table.types';
|
|
3
3
|
export declare const TABLE_SORT_DIRECTIONS: readonly TableSortDirection[];
|
|
4
|
+
export declare const TABLE_EXPANSIONS: readonly TableExpansion[];
|
|
4
5
|
/**
|
|
5
6
|
* Rows of data under column headings. `columns` say what each column shows and how (`format`: text, number, date,
|
|
6
7
|
* badge, code); `rows` are plain objects. Sortable headings cycle ascending, descending and unsorted, and sort the
|
|
7
8
|
* rows in place; `selectable` adds a checkbox column. The header stays on top while the rows scroll within
|
|
8
9
|
* `max-height`, and the table scrolls sideways on narrow screens. Cells of a column can be drawn by code with
|
|
9
|
-
* `renderers`.
|
|
10
|
+
* `renderers`. `expandable` rows open on a press to show their `detail` under them, the row staying as it is: one at
|
|
11
|
+
* a time (`single`) or any number (`multiple`).
|
|
12
|
+
*
|
|
13
|
+
* Typed by its rows, `JlTable<Order>` checks and completes the fields its columns name, and hands its renderers and
|
|
14
|
+
* `detail` an order; `JlTable<Order, 'actions'>` adds a column that is not a field, which a renderer draws.
|
|
10
15
|
*/
|
|
11
|
-
export declare class JlTable extends JlElement {
|
|
16
|
+
export declare class JlTable<Row extends object = TableRow, Extra extends string = never> extends JlElement {
|
|
12
17
|
static readonly selector = "jl-table";
|
|
13
18
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
14
|
-
sort: TableSort
|
|
19
|
+
sort: TableSort<Row, Extra>;
|
|
15
20
|
selection: TableRowKey[];
|
|
21
|
+
toggle: TableToggle;
|
|
16
22
|
}>>;
|
|
17
23
|
readonly columns: Readonly<Readonly<{
|
|
18
|
-
get(): TableColumn[];
|
|
19
|
-
set(setter: TableColumn[] | ((prevState: TableColumn[]) => TableColumn[])): void;
|
|
24
|
+
get(): TableColumn<Row, Extra>[];
|
|
25
|
+
set(setter: TableColumn<Row, Extra>[] | ((prevState: TableColumn<Row, Extra>[]) => TableColumn<Row, Extra>[])): void;
|
|
20
26
|
}>>;
|
|
21
27
|
readonly rows: Readonly<Readonly<{
|
|
22
|
-
get():
|
|
23
|
-
set(setter:
|
|
28
|
+
get(): Row[];
|
|
29
|
+
set(setter: Row[] | ((prevState: Row[]) => Row[])): void;
|
|
24
30
|
}>>;
|
|
25
31
|
/** The field that tells rows apart, for the selection. */
|
|
26
32
|
readonly rowKey: Readonly<Readonly<{
|
|
27
|
-
get(): string
|
|
28
|
-
set(setter:
|
|
33
|
+
get(): "id" | Extract<keyof Row, string>;
|
|
34
|
+
set(setter: "id" | ((prevState: "id" | TableField<Row>) => "id" | Extract<keyof Row, string>) | TableField<Row>): void;
|
|
29
35
|
}>>;
|
|
30
36
|
/** The column the rows are sorted by. */
|
|
31
37
|
readonly sortKey: Readonly<Readonly<{
|
|
32
|
-
get():
|
|
33
|
-
set(setter:
|
|
38
|
+
get(): "" | TableColumnKey<Row, Extra>;
|
|
39
|
+
set(setter: "" | ((prevState: "" | TableColumnKey<Row, Extra>) => "" | TableColumnKey<Row, Extra>) | TableColumnKey<Row, Extra>): void;
|
|
34
40
|
}>>;
|
|
35
41
|
readonly sortDirection: Readonly<Readonly<{
|
|
36
42
|
get(): TableSortDirection;
|
|
@@ -46,6 +52,21 @@ export declare class JlTable extends JlElement {
|
|
|
46
52
|
get(): TableRowKey[];
|
|
47
53
|
set(setter: TableRowKey[] | ((prevState: TableRowKey[]) => TableRowKey[])): void;
|
|
48
54
|
}>>;
|
|
55
|
+
/** Rows open on a press to show their `detail` under them: one at a time (`single`), any number (`multiple`). */
|
|
56
|
+
readonly expandable: Readonly<Readonly<{
|
|
57
|
+
get(): TableExpansion;
|
|
58
|
+
set(setter: ((prevState: TableExpansion) => TableExpansion) | TableExpansion): void;
|
|
59
|
+
}>>;
|
|
60
|
+
/** The keys of the open rows. */
|
|
61
|
+
readonly expanded: Readonly<Readonly<{
|
|
62
|
+
get(): TableRowKey[];
|
|
63
|
+
set(setter: TableRowKey[] | ((prevState: TableRowKey[]) => TableRowKey[])): void;
|
|
64
|
+
}>>;
|
|
65
|
+
/** The keys of rows to draw attention to, such as a search's matches: a mark, not a selection. */
|
|
66
|
+
readonly marked: Readonly<Readonly<{
|
|
67
|
+
get(): TableRowKey[];
|
|
68
|
+
set(setter: TableRowKey[] | ((prevState: TableRowKey[]) => TableRowKey[])): void;
|
|
69
|
+
}>>;
|
|
49
70
|
/** Shorter rows, for long lists. */
|
|
50
71
|
readonly dense: Readonly<Readonly<{
|
|
51
72
|
get(): boolean;
|
|
@@ -78,13 +99,19 @@ export declare class JlTable extends JlElement {
|
|
|
78
99
|
}>>;
|
|
79
100
|
/** Draws the cells of some columns by code, by column key: `{ name: (row) => <strong>{row.name}</strong> }`. */
|
|
80
101
|
readonly renderers: Readonly<Readonly<{
|
|
81
|
-
get():
|
|
82
|
-
set(setter:
|
|
102
|
+
get(): TableRenderers<Row, Extra>;
|
|
103
|
+
set(setter: TableRenderers<Row, Extra> | ((prevState: TableRenderers<Row, Extra>) => TableRenderers<Row, Extra>)): void;
|
|
83
104
|
}>>;
|
|
105
|
+
private readonly _source;
|
|
84
106
|
private readonly _pending;
|
|
85
|
-
/** The
|
|
107
|
+
/** The rows as drawn and their keys, by their place: the rows and their checkboxes carry the place. */
|
|
86
108
|
private readonly _view;
|
|
87
109
|
private readonly _refs;
|
|
110
|
+
/** Draws what an open row shows under it, from the row: `(row) => <JlFacts items={…} />`. */
|
|
111
|
+
get detail(): TableDetailRenderer<Row> | null;
|
|
112
|
+
set detail(draw: TableDetailRenderer<Row> | null);
|
|
113
|
+
/** Opens or closes a row, as a press on it would; one at a time, opening a row closes the one that was open. */
|
|
114
|
+
toggle(key: TableRowKey, open: boolean): void;
|
|
88
115
|
templateHtml(): Node;
|
|
89
116
|
templateCss(): string;
|
|
90
117
|
onConnect(): void;
|
|
@@ -93,17 +120,37 @@ export declare class JlTable extends JlElement {
|
|
|
93
120
|
private flush;
|
|
94
121
|
private sortBy;
|
|
95
122
|
private changeSelection;
|
|
123
|
+
/** A press on a row's chevron, or on the row anywhere but its controls and its checkbox, opens or closes it. */
|
|
124
|
+
private pressRow;
|
|
125
|
+
/** The row of data a press is on: one of the table's, not a row in the content of a detail. */
|
|
126
|
+
private dataRowOf;
|
|
127
|
+
private opensOnPress;
|
|
96
128
|
private renderMaxHeight;
|
|
129
|
+
private isExpandable;
|
|
130
|
+
/** The number of cells in a row: the columns, after the checkbox and the chevron when there are. */
|
|
131
|
+
private span;
|
|
97
132
|
private renderHead;
|
|
98
133
|
private headerCell;
|
|
99
134
|
/** The arrows and `aria-sort` of the headings, changed in place so a pressed heading keeps the focus. */
|
|
100
135
|
private renderSortState;
|
|
101
136
|
private sortedRows;
|
|
102
137
|
private renderBody;
|
|
138
|
+
private setView;
|
|
103
139
|
private bodyRow;
|
|
140
|
+
/** A cell's value, drawn by its renderer or in its format, with the row's description under it when it has one. */
|
|
104
141
|
private cell;
|
|
142
|
+
private cellValue;
|
|
105
143
|
private skeletonRows;
|
|
106
144
|
private emptyRow;
|
|
145
|
+
/** The rows of data, without the details under the open ones. */
|
|
146
|
+
private dataRows;
|
|
147
|
+
private keyOf;
|
|
148
|
+
/** The bar and the shade of marked rows, changed in place. */
|
|
149
|
+
private renderMarks;
|
|
150
|
+
/** The details of the open rows, added under them and taken away in place: one that stays open keeps its content. */
|
|
151
|
+
private renderExpansion;
|
|
152
|
+
private renderRowOpen;
|
|
153
|
+
private detailRow;
|
|
107
154
|
/** The checkboxes and the shading of selected rows, changed in place. */
|
|
108
155
|
private renderSelection;
|
|
109
156
|
}
|