@syware/jlib 0.7.0 → 0.9.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/README.md +2 -1
- package/dist/all.js +3 -3
- package/dist/atoms/jl-chip.d.ts +1 -0
- package/dist/atoms/jl-chip.js +4 -2
- package/dist/atoms/jl-input.d.ts +2 -0
- package/dist/atoms/jl-input.js +9 -3
- package/dist/atoms/jl-rating.d.ts +2 -0
- package/dist/atoms/jl-rating.js +13 -5
- package/dist/atoms/jl-select.d.ts +8 -7
- package/dist/atoms/jl-select.js +11 -6
- package/dist/atoms/jl-spinner.d.ts +2 -0
- package/dist/atoms/jl-spinner.js +6 -2
- package/dist/base/jl-element.d.ts +6 -0
- package/dist/base/jl-element.js +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/lib/attributes.d.ts +9 -0
- package/dist/lib/attributes.js +10 -1
- package/dist/lib/nav-tree.d.ts +2 -2
- package/dist/lib/palette.d.ts +2 -2
- package/dist/lib/table.d.ts +19 -6
- package/dist/lib/table.js +42 -7
- package/dist/lib/texts-de.d.ts +108 -0
- package/dist/lib/texts-de.js +111 -0
- package/dist/lib/texts-fr.d.ts +108 -0
- package/dist/lib/texts-fr.js +111 -0
- package/dist/lib/texts.d.ts +177 -89
- package/dist/lib/texts.js +176 -9
- package/dist/molecules/jl-alert.d.ts +1 -0
- package/dist/molecules/jl-alert.js +4 -2
- package/dist/molecules/jl-breadcrumb.d.ts +2 -0
- package/dist/molecules/jl-breadcrumb.js +12 -6
- package/dist/molecules/jl-calendar.d.ts +1 -0
- package/dist/molecules/jl-calendar.js +7 -4
- package/dist/molecules/jl-chip-group.d.ts +8 -6
- package/dist/molecules/jl-chip-group.js +10 -5
- package/dist/molecules/jl-code-block.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +3 -1
- package/dist/molecules/jl-combobox.js +12 -7
- package/dist/molecules/jl-copy-button.d.ts +1 -0
- package/dist/molecules/jl-copy-button.js +7 -5
- package/dist/molecules/jl-date-picker.d.ts +1 -0
- package/dist/molecules/jl-date-picker.js +10 -7
- package/dist/molecules/jl-file-drop.d.ts +1 -0
- package/dist/molecules/jl-file-drop.js +15 -6
- package/dist/molecules/jl-input-list.d.ts +3 -2
- package/dist/molecules/jl-input-list.js +10 -7
- package/dist/molecules/jl-load-more.d.ts +4 -2
- package/dist/molecules/jl-load-more.js +15 -8
- package/dist/molecules/jl-load-state.d.ts +4 -0
- package/dist/molecules/jl-load-state.js +13 -9
- package/dist/molecules/jl-menu.d.ts +8 -4
- package/dist/molecules/jl-menu.js +8 -1
- package/dist/molecules/jl-number-input.d.ts +1 -0
- package/dist/molecules/jl-number-input.js +6 -3
- package/dist/molecules/jl-pagination.d.ts +2 -0
- package/dist/molecules/jl-pagination.js +17 -9
- package/dist/molecules/jl-radio-group.d.ts +9 -7
- package/dist/molecules/jl-radio-group.js +14 -7
- package/dist/molecules/jl-search-button.d.ts +2 -1
- package/dist/molecules/jl-search-button.js +6 -4
- package/dist/molecules/jl-search.d.ts +2 -0
- package/dist/molecules/jl-search.js +9 -3
- package/dist/molecules/jl-segmented.d.ts +8 -7
- package/dist/molecules/jl-segmented.js +10 -5
- package/dist/molecules/jl-steps.d.ts +2 -0
- package/dist/molecules/jl-steps.js +9 -4
- package/dist/molecules/jl-tag-input.d.ts +1 -0
- package/dist/molecules/jl-tag-input.js +8 -4
- package/dist/molecules/jl-toast.d.ts +1 -0
- package/dist/molecules/jl-toast.js +4 -2
- package/dist/organisms/jl-command-palette.d.ts +9 -5
- package/dist/organisms/jl-command-palette.js +15 -11
- package/dist/organisms/jl-confirm.d.ts +3 -0
- package/dist/organisms/jl-confirm.js +12 -11
- package/dist/organisms/jl-dialog.d.ts +1 -0
- package/dist/organisms/jl-dialog.js +4 -2
- package/dist/organisms/jl-drawer.d.ts +1 -0
- package/dist/organisms/jl-drawer.js +4 -2
- package/dist/organisms/jl-flow.d.ts +2 -0
- package/dist/organisms/jl-flow.js +25 -16
- package/dist/organisms/jl-navbar.d.ts +3 -0
- package/dist/organisms/jl-navbar.js +16 -7
- package/dist/organisms/jl-side-nav.d.ts +12 -9
- package/dist/organisms/jl-side-nav.js +26 -15
- package/dist/organisms/jl-tab-bar.d.ts +9 -7
- package/dist/organisms/jl-tab-bar.js +15 -6
- package/dist/organisms/jl-table.css_raw.js +1 -1
- package/dist/organisms/jl-table.d.ts +56 -17
- package/dist/organisms/jl-table.js +227 -43
- package/dist/organisms/jl-toaster.d.ts +2 -1
- package/dist/organisms/jl-toaster.js +12 -9
- package/dist/organisms/jl-tree.d.ts +6 -4
- package/dist/organisms/jl-tree.js +21 -15
- package/dist/templates/jl-app-shell.d.ts +1 -0
- package/dist/templates/jl-app-shell.js +4 -2
- package/dist/templates/jl-auth-layout.d.ts +4 -3
- package/dist/templates/jl-auth-layout.js +13 -11
- package/dist/templates/jl-page.d.ts +1 -0
- package/dist/templates/jl-page.js +4 -1
- package/dist/templates/jl-split-view.d.ts +1 -0
- package/dist/templates/jl-split-view.js +5 -4
- package/dist/types/jl-chip-group.types.d.ts +3 -3
- package/dist/types/jl-command-palette.types.d.ts +10 -6
- 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 +9 -6
- package/dist/types/jl-tab-bar.types.d.ts +6 -3
- package/dist/types/jl-table.types.d.ts +34 -8
- package/dist/types/texts.types.d.ts +29 -4
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlElement } from "../base/jl-element.js";
|
|
3
4
|
import { registerIcons } from "../lib/icons.js";
|
|
4
|
-
import { jlText } from "../lib/texts.js";
|
|
5
5
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
6
6
|
import { watchSizes } from "../lib/resize.js";
|
|
7
7
|
import jl_app_shell_default from "./jl-app-shell.css_raw.js";
|
|
@@ -71,7 +71,6 @@ var JlAppShell = class extends JlElement {
|
|
|
71
71
|
children: [/* @__PURE__ */ jsx("button", {
|
|
72
72
|
class: "menu",
|
|
73
73
|
type: "button",
|
|
74
|
-
"aria-label": jlText("navigation"),
|
|
75
74
|
"aria-expanded": "false",
|
|
76
75
|
"aria-controls": "nav",
|
|
77
76
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
@@ -109,6 +108,9 @@ var JlAppShell = class extends JlElement {
|
|
|
109
108
|
templateCss() {
|
|
110
109
|
return css`${BASE_STYLES}${jl_app_shell_default}`;
|
|
111
110
|
}
|
|
111
|
+
drawTexts() {
|
|
112
|
+
this._refs.menu.setAttribute("aria-label", jlText("navigation"));
|
|
113
|
+
}
|
|
112
114
|
onConnect() {
|
|
113
115
|
this._resize.observe(this);
|
|
114
116
|
this._resize.observe(this._refs.tabs);
|
|
@@ -22,12 +22,13 @@ export declare class JlAuthLayout extends JlElement {
|
|
|
22
22
|
get(): string[];
|
|
23
23
|
set(setter: string[] | ((prevState: string[]) => string[])): void;
|
|
24
24
|
}>>;
|
|
25
|
-
/** Where the app comes from, at the foot of the panel. */
|
|
25
|
+
/** Where the app comes from, at the foot of the panel: jlib's own text when not set, nothing when empty. */
|
|
26
26
|
readonly origin: Readonly<Readonly<{
|
|
27
|
-
get(): string;
|
|
28
|
-
set(setter: string | ((prevState: string) => string)): void;
|
|
27
|
+
get(): string | null;
|
|
28
|
+
set(setter: string | ((prevState: string | null) => string | null) | null): void;
|
|
29
29
|
}>>;
|
|
30
30
|
private readonly _refs;
|
|
31
|
+
protected drawTexts(): void;
|
|
31
32
|
templateHtml(): Node;
|
|
32
33
|
templateCss(): string;
|
|
33
34
|
private renderPitch;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { starredParts } from "../lib/text.js";
|
|
2
|
+
import { jlText } from "../lib/texts.js";
|
|
1
3
|
import { BASE_STYLES, TOKEN_STYLES } from "../styles/shared.js";
|
|
2
4
|
import { JlElement } from "../base/jl-element.js";
|
|
3
5
|
import { jsonOf } from "../lib/attributes.js";
|
|
4
6
|
import { registerIcons } from "../lib/icons.js";
|
|
5
|
-
import { starredParts } from "../lib/text.js";
|
|
6
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
7
8
|
import jl_auth_layout_default from "./jl-auth-layout.css_raw.js";
|
|
8
9
|
import { css } from "@jadis/core";
|
|
@@ -10,7 +11,6 @@ import { Check } from "lucide";
|
|
|
10
11
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
11
12
|
// src/templates/jl-auth-layout.tsx
|
|
12
13
|
registerIcons({ check: Check });
|
|
13
|
-
var DEFAULT_ORIGIN = "Made in Switzerland by SyWare";
|
|
14
14
|
var POINT_ICON_SIZE = 12;
|
|
15
15
|
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
16
16
|
var MARK_VIEW_BOX = "429 1092 2155 2358";
|
|
@@ -62,17 +62,22 @@ var JlAuthLayout = class extends JlElement {
|
|
|
62
62
|
attribute: "points",
|
|
63
63
|
parse: jsonOf([])
|
|
64
64
|
});
|
|
65
|
-
/** Where the app comes from, at the foot of the panel. */
|
|
66
|
-
origin = this.useChange(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
65
|
+
/** Where the app comes from, at the foot of the panel: jlib's own text when not set, nothing when empty. */
|
|
66
|
+
origin = this.useChange(null, () => this.drawTexts(), {
|
|
67
|
+
attribute: "origin",
|
|
68
|
+
parse: (value) => value
|
|
69
|
+
});
|
|
70
70
|
_refs = this.useRefs((ref) => ({
|
|
71
71
|
headline: ref(".headline"),
|
|
72
72
|
origin: ref(".origin"),
|
|
73
73
|
points: ref(".points"),
|
|
74
74
|
text: ref(".text")
|
|
75
75
|
}));
|
|
76
|
+
drawTexts() {
|
|
77
|
+
const origin = this.origin.get() ?? jlText("authOrigin");
|
|
78
|
+
this._refs.origin.textContent = origin;
|
|
79
|
+
this._refs.origin.hidden = origin === "";
|
|
80
|
+
}
|
|
76
81
|
templateHtml() {
|
|
77
82
|
return /* @__PURE__ */ jsxs("div", {
|
|
78
83
|
class: "screen",
|
|
@@ -100,10 +105,7 @@ var JlAuthLayout = class extends JlElement {
|
|
|
100
105
|
class: "points",
|
|
101
106
|
hidden: true
|
|
102
107
|
}),
|
|
103
|
-
/* @__PURE__ */ jsx("p", {
|
|
104
|
-
class: "origin",
|
|
105
|
-
children: DEFAULT_ORIGIN
|
|
106
|
-
}),
|
|
108
|
+
/* @__PURE__ */ jsx("p", { class: "origin" }),
|
|
107
109
|
backdrop()
|
|
108
110
|
]
|
|
109
111
|
}), /* @__PURE__ */ jsx("main", {
|
|
@@ -43,6 +43,7 @@ export declare class JlPage extends JlElement {
|
|
|
43
43
|
templateHtml(): Node;
|
|
44
44
|
templateCss(): string;
|
|
45
45
|
onConnect(): void;
|
|
46
|
+
protected drawTexts(): void;
|
|
46
47
|
/** The back link stays out of the header's breadcrumb slot without an address, so the header takes no room for it. */
|
|
47
48
|
private renderBack;
|
|
48
49
|
private renderTitle;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlElement } from "../base/jl-element.js";
|
|
3
4
|
import { oneOf } from "../lib/attributes.js";
|
|
4
5
|
import { define } from "../lib/define.js";
|
|
5
6
|
import { registerIcons } from "../lib/icons.js";
|
|
6
|
-
import { jlText } from "../lib/texts.js";
|
|
7
7
|
import { setOrRemove } from "../lib/dom.js";
|
|
8
8
|
import { JlButton } from "../atoms/jl-button.js";
|
|
9
9
|
import { JlPageHeader } from "../organisms/jl-page-header.js";
|
|
@@ -83,6 +83,9 @@ var JlPage = class extends JlElement {
|
|
|
83
83
|
this.renderTitle();
|
|
84
84
|
this._refs.back.events.register("press", () => this.events.emit("back"));
|
|
85
85
|
}
|
|
86
|
+
drawTexts() {
|
|
87
|
+
this.renderBack();
|
|
88
|
+
}
|
|
86
89
|
/** The back link stays out of the header's breadcrumb slot without an address, so the header takes no room for it. */
|
|
87
90
|
renderBack() {
|
|
88
91
|
const back = this._refs.back;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlElement } from "../base/jl-element.js";
|
|
3
4
|
import { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
4
|
-
import { jlText } from "../lib/texts.js";
|
|
5
5
|
import { watchSizes } from "../lib/resize.js";
|
|
6
6
|
import { clampMin, clampSplit, positionAfterKey, positionAt } from "../lib/split.js";
|
|
7
7
|
import jl_split_view_default from "./jl-split-view.css_raw.js";
|
|
@@ -62,9 +62,7 @@ var JlSplitView = class extends JlElement {
|
|
|
62
62
|
parse: oneOf(SPLIT_PANES, "start")
|
|
63
63
|
});
|
|
64
64
|
/** The divider's name for screen readers. */
|
|
65
|
-
label = this.useChange(
|
|
66
|
-
this._refs.divider.setAttribute("aria-label", value === "" ? jlText("resizePanes") : value);
|
|
67
|
-
}, { attribute: "label" });
|
|
65
|
+
label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
|
|
68
66
|
_drag = { from: DEFAULT_POSITION };
|
|
69
67
|
_resize = watchSizes(() => this.renderStacked());
|
|
70
68
|
/** Whether it shows one pane at a time now. */
|
|
@@ -112,6 +110,9 @@ var JlSplitView = class extends JlElement {
|
|
|
112
110
|
templateCss() {
|
|
113
111
|
return css`${BASE_STYLES}${jl_split_view_default}`;
|
|
114
112
|
}
|
|
113
|
+
drawTexts() {
|
|
114
|
+
this._refs.divider.setAttribute("aria-label", this.label.get() || jlText("resizePanes"));
|
|
115
|
+
}
|
|
115
116
|
onConnect() {
|
|
116
117
|
this._resize.observe(this);
|
|
117
118
|
const divider = this._refs.divider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** One choice of a chip group. */
|
|
2
|
-
export type ChipGroupOption = {
|
|
3
|
-
value:
|
|
1
|
+
/** One choice of a chip group. Typed by its values (`ChipGroupOption<'open' | 'done'>`), `value` is one of them. */
|
|
2
|
+
export type ChipGroupOption<Value extends string = string> = {
|
|
3
|
+
value: Value;
|
|
4
4
|
label: string;
|
|
5
5
|
/** An icon name before the label; a chosen chip without one shows a check. */
|
|
6
6
|
icon?: string;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A command of the palette: `select` fires with its id. Typed by its ids (`PaletteCommand<'theme' | 'logout'>`, or
|
|
3
|
+
* `` `open:${string}` `` for the records a search finds), `id` is one of them.
|
|
4
|
+
*/
|
|
5
|
+
export type PaletteCommand<Id extends string = string> = {
|
|
6
|
+
id: Id;
|
|
3
7
|
label: string;
|
|
4
8
|
/** The heading the command is listed under. */
|
|
5
9
|
group?: string;
|
|
@@ -17,13 +21,13 @@ export type PaletteCommand = {
|
|
|
17
21
|
result?: boolean;
|
|
18
22
|
};
|
|
19
23
|
/** A command that matches the search, with the places of the matched letters in its label. */
|
|
20
|
-
export type PaletteMatch = {
|
|
21
|
-
command: PaletteCommand
|
|
24
|
+
export type PaletteMatch<Id extends string = string> = {
|
|
25
|
+
command: PaletteCommand<Id>;
|
|
22
26
|
score: number;
|
|
23
27
|
positions: number[];
|
|
24
28
|
};
|
|
25
29
|
/** Commands under one heading, in the order they are listed. */
|
|
26
|
-
export type PaletteGroup = {
|
|
30
|
+
export type PaletteGroup<Id extends string = string> = {
|
|
27
31
|
label: string;
|
|
28
|
-
matches: PaletteMatch[];
|
|
32
|
+
matches: PaletteMatch<Id>[];
|
|
29
33
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** A choice of a menu: `select` fires with its value. */
|
|
2
|
-
export type MenuAction = {
|
|
3
|
-
value:
|
|
1
|
+
/** A choice of a menu: `select` fires with its value. Typed (`MenuAction<'edit' | 'delete'>`), it is one of those. */
|
|
2
|
+
export type MenuAction<Value extends string = string> = {
|
|
3
|
+
value: Value;
|
|
4
4
|
label: string;
|
|
5
5
|
icon?: string;
|
|
6
6
|
/** The keys that do the same, shown at the end: "⌘D". */
|
|
@@ -19,4 +19,4 @@ export type MenuDivider = {
|
|
|
19
19
|
export type MenuHeading = {
|
|
20
20
|
heading: string;
|
|
21
21
|
};
|
|
22
|
-
export type MenuItem = MenuAction | MenuDivider | MenuHeading;
|
|
22
|
+
export type MenuItem<Value extends string = string> = MenuAction<Value> | MenuDivider | MenuHeading;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One choice of a radio group, with an optional line that explains it. Typed by its values
|
|
3
|
+
* (`RadioOption<'card' | 'invoice'>`), `value` is one of them.
|
|
4
|
+
*/
|
|
5
|
+
export type RadioOption<Value extends string = string> = {
|
|
6
|
+
value: Value;
|
|
4
7
|
label: string;
|
|
5
8
|
description?: string;
|
|
6
9
|
disabled?: boolean;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One choice of a segmented control; without a label it shows its icon, and its value names it. Typed by its values
|
|
3
|
+
* (`SegmentedOption<'list' | 'grid'>`), `value` is one of them.
|
|
4
|
+
*/
|
|
5
|
+
export type SegmentedOption<Value extends string = string> = {
|
|
6
|
+
value: Value;
|
|
4
7
|
label?: string;
|
|
5
8
|
icon?: string;
|
|
6
9
|
/** A count or a short word after the label: what waits behind the choice. */
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One choice of a select: `group` gathers it with the others of the same group under that heading. Typed by its
|
|
3
|
+
* values (`SelectOption<'eur' | 'chf'>`), `value` is one of them.
|
|
4
|
+
*/
|
|
5
|
+
export type SelectOption<Value extends string = string> = {
|
|
6
|
+
value: Value;
|
|
4
7
|
label: string;
|
|
5
8
|
disabled?: boolean;
|
|
6
9
|
group?: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One entry of a side navigation; with `children`, it opens and closes to show them. Typed by its ids
|
|
3
|
+
* (`SideNavItem<'jobs' | 'people'>`), `id` is one of them.
|
|
4
|
+
*/
|
|
5
|
+
export type SideNavItem<Id extends string = string> = {
|
|
6
|
+
id: Id;
|
|
4
7
|
label: string;
|
|
5
8
|
/** An icon name; the collapsed rail shows only the icons. */
|
|
6
9
|
icon?: string;
|
|
@@ -10,10 +13,10 @@ export type SideNavItem = {
|
|
|
10
13
|
target?: string;
|
|
11
14
|
/** A count or a short word beside the label: `3`, `New`. */
|
|
12
15
|
badge?: string | number;
|
|
13
|
-
children?: SideNavItem[];
|
|
16
|
+
children?: SideNavItem<Id>[];
|
|
14
17
|
};
|
|
15
18
|
/** A group of items under an optional heading. */
|
|
16
|
-
export type SideNavSection = {
|
|
19
|
+
export type SideNavSection<Id extends string = string> = {
|
|
17
20
|
label?: string;
|
|
18
|
-
items: SideNavItem[];
|
|
21
|
+
items: SideNavItem<Id>[];
|
|
19
22
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* One place in a bottom tab bar: an icon over a short label. Typed by its ids (`TabBarItem<'home' | 'jobs'>`), `id`
|
|
3
|
+
* is one of them.
|
|
4
|
+
*/
|
|
5
|
+
export type TabBarItem<Id extends string = string> = {
|
|
6
|
+
id: Id;
|
|
4
7
|
label: string;
|
|
5
8
|
/** An icon name: the tab bar draws one over every label. */
|
|
6
9
|
icon: string;
|
|
@@ -4,9 +4,23 @@ export type TableCellFormat = 'text' | 'number' | 'date' | 'datetime' | 'badge'
|
|
|
4
4
|
export type TableAlign = 'left' | 'center' | 'right';
|
|
5
5
|
/** The order of a sorted column; `none` keeps the rows as they came. */
|
|
6
6
|
export type TableSortDirection = 'asc' | 'desc' | 'none';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/** A row of a table that does not say its type: any field, of any value. */
|
|
8
|
+
export type TableRow = Record<string, unknown>;
|
|
9
|
+
/** The names of a type of row's fields: what a column shows, sorts by, or shows under its value. */
|
|
10
|
+
export type TableField<Row> = Extract<keyof Row, string>;
|
|
11
|
+
/**
|
|
12
|
+
* What a column's `key` names: a field of the row, or one of the `Extra` columns a renderer draws from the whole
|
|
13
|
+
* row, such as a column of actions. The extra columns are named, never guessed from the keys: a misspelt field is
|
|
14
|
+
* an error, not a new column.
|
|
15
|
+
*/
|
|
16
|
+
export type TableColumnKey<Row, Extra extends string = never> = TableField<Row> | NoInfer<Extra>;
|
|
17
|
+
/**
|
|
18
|
+
* A column of a table. Typed by its rows (`TableColumn<Order>`), its `key` and `description` are fields of an
|
|
19
|
+
* order, checked and completed by the editor.
|
|
20
|
+
*/
|
|
21
|
+
export type TableColumn<Row extends object = TableRow, Extra extends string = never> = {
|
|
22
|
+
/** The row's field shown in this column, or one of the `Extra` columns a renderer draws. */
|
|
23
|
+
key: TableColumnKey<Row, Extra>;
|
|
10
24
|
label: string;
|
|
11
25
|
/** Numbers are right-aligned when absent; the rest left. */
|
|
12
26
|
align?: TableAlign;
|
|
@@ -17,21 +31,33 @@ export type TableColumn = {
|
|
|
17
31
|
/** For badges: the tone of each value (`{ "Active": "ok" }`); neutral otherwise. */
|
|
18
32
|
tones?: Record<string, Tone>;
|
|
19
33
|
/** The row's field shown as a quieter line under the value: a package's format under its name. */
|
|
20
|
-
description?:
|
|
34
|
+
description?: TableField<Row>;
|
|
21
35
|
/**
|
|
22
36
|
* Long text, a description or a note, breaks over lines instead of widening the table; cells stay on one line
|
|
23
37
|
* otherwise.
|
|
24
38
|
*/
|
|
25
39
|
wrap?: boolean;
|
|
26
40
|
};
|
|
27
|
-
export type TableRow = Record<string, unknown>;
|
|
28
41
|
/** A row's identity, the value of its `row-key` field. */
|
|
29
42
|
export type TableRowKey = string | number;
|
|
30
|
-
export type TableSort = {
|
|
31
|
-
key:
|
|
43
|
+
export type TableSort<Row extends object = TableRow, Extra extends string = never> = {
|
|
44
|
+
key: TableColumnKey<Row, Extra>;
|
|
32
45
|
direction: TableSortDirection;
|
|
33
46
|
};
|
|
34
47
|
/** Draws a cell of a column in place of its formatted value. */
|
|
35
|
-
export type TableCellRenderer = (row:
|
|
48
|
+
export type TableCellRenderer<Row extends object = TableRow> = (row: Row) => Node;
|
|
49
|
+
/** The renderers of a table, by the key of the column whose cells they draw. */
|
|
50
|
+
export type TableRenderers<Row extends object = TableRow, Extra extends string = never> = {
|
|
51
|
+
[Key in TableColumnKey<Row, Extra>]?: TableCellRenderer<Row>;
|
|
52
|
+
};
|
|
36
53
|
/** What the select-all box shows: no row selected, some, or all of them. */
|
|
37
54
|
export type TableSelectionState = 'none' | 'some' | 'all';
|
|
55
|
+
/** Whether rows open to show more under them: never, one at a time, or any number at once. */
|
|
56
|
+
export type TableExpansion = 'none' | 'single' | 'multiple';
|
|
57
|
+
/** Draws what an open row shows under it. */
|
|
58
|
+
export type TableDetailRenderer<Row extends object = TableRow> = (row: Row) => Node;
|
|
59
|
+
/** A row opened or closed: its key, and whether it is open now. */
|
|
60
|
+
export type TableToggle = {
|
|
61
|
+
key: TableRowKey;
|
|
62
|
+
open: boolean;
|
|
63
|
+
};
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Bus, TranslationLoader, Translations } from '@jadis/core';
|
|
2
|
+
import type { DEFAULT_TEXTS, JL_LANGUAGES } from '../lib/texts';
|
|
3
|
+
/** jlib's texts in English: the source every language translates. */
|
|
4
|
+
export type JlSourceTexts = typeof DEFAULT_TEXTS;
|
|
2
5
|
/** The name of one of the texts jlib's components show on their own. */
|
|
3
|
-
export type JlTextKey = keyof
|
|
4
|
-
/**
|
|
5
|
-
export type
|
|
6
|
+
export type JlTextKey = keyof JlSourceTexts;
|
|
7
|
+
/** A language jlib translates itself. */
|
|
8
|
+
export type JlLanguage = (typeof JL_LANGUAGES)[number];
|
|
9
|
+
/** All of jlib's texts in one language, each with the placeholders of its English text. */
|
|
10
|
+
export type JlLanguageTexts = Translations<JlSourceTexts>;
|
|
11
|
+
/** Some of jlib's texts in one language, each with the placeholders of its English text. */
|
|
12
|
+
export type JlFixes = Partial<JlLanguageTexts>;
|
|
13
|
+
/** What a language added to jlib shows: its texts, their loader, or one of jlib's own languages. */
|
|
14
|
+
export type JlLanguageEntry = JlLanguageTexts | TranslationLoader<JlLanguageTexts> | JlLanguage;
|
|
15
|
+
/** A translator jlib's texts can follow, such as a Jadis `Translator`. */
|
|
16
|
+
export interface FollowedTranslator<Locale extends string> {
|
|
17
|
+
readonly locale: Locale;
|
|
18
|
+
readonly locales: readonly Locale[];
|
|
19
|
+
readonly bus: Bus<{
|
|
20
|
+
change: Locale;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/** A locale a page can add: one jlib does not translate itself, whose texts are fixed instead. */
|
|
24
|
+
export type AddedLocale<Locale extends string> = Locale extends JlLanguage ? `jlib translates ${Locale} itself: fix its texts with jlTexts.fix` : Locale;
|
|
25
|
+
/** The texts shown, in the locale they are shown for, with that locale's number format. */
|
|
26
|
+
export interface ShownTexts {
|
|
27
|
+
locale: string;
|
|
28
|
+
numbers: Intl.NumberFormat;
|
|
29
|
+
texts: Readonly<Record<JlTextKey, string>>;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syware/jlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A tree-shakeable component library on Jadis and native Web Components, organised in atomic design",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"prepublishOnly": "npm run check"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@jadis/core": "^1.
|
|
88
|
+
"@jadis/core": "^1.5.1"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"lucide": "^1.61.0"
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@biomejs/biome": "^2.6.3",
|
|
95
95
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
96
96
|
"@fontsource-variable/manrope": "^5.3.0",
|
|
97
|
-
"@jadis/core": "^1.
|
|
97
|
+
"@jadis/core": "^1.5.1",
|
|
98
98
|
"@types/node": "^24.13.3",
|
|
99
99
|
"playwright-core": "^1.64.1",
|
|
100
100
|
"typescript": "^7.0.2",
|