@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
|
@@ -4,17 +4,19 @@ import type { MenuItem } from '../types/jl-menu.types';
|
|
|
4
4
|
/**
|
|
5
5
|
* A list of actions that opens from its trigger (`slot="trigger"`, any button): on a press or with ArrowDown. Arrows,
|
|
6
6
|
* Home, End and the first letter move through it; Enter chooses, Escape closes. `select` fires with the value.
|
|
7
|
+
* Typed by its values, `JlMenu<'edit' | 'delete'>` takes actions of those values and gives `select` one of them:
|
|
8
|
+
* a page handles them with a `Record<'edit' | 'delete', () => void>`, which misses none.
|
|
7
9
|
*/
|
|
8
|
-
export declare class JlMenu extends JlElement {
|
|
10
|
+
export declare class JlMenu<Value extends string = string> extends JlElement {
|
|
9
11
|
static readonly selector = "jl-menu";
|
|
10
12
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
11
|
-
select:
|
|
13
|
+
select: Value;
|
|
12
14
|
open: undefined;
|
|
13
15
|
close: undefined;
|
|
14
16
|
}>>;
|
|
15
17
|
readonly items: Readonly<Readonly<{
|
|
16
|
-
get(): MenuItem[];
|
|
17
|
-
set(setter: MenuItem[] | ((prevState: MenuItem[]) => MenuItem[])): void;
|
|
18
|
+
get(): MenuItem<Value>[];
|
|
19
|
+
set(setter: MenuItem<Value>[] | ((prevState: MenuItem<Value>[]) => MenuItem<Value>[])): void;
|
|
18
20
|
}>>;
|
|
19
21
|
/** Where the menu goes; it flips to the other side when there is no room. */
|
|
20
22
|
readonly placement: Readonly<Readonly<{
|
|
@@ -50,6 +52,8 @@ export declare class JlMenu extends JlElement {
|
|
|
50
52
|
private focusItem;
|
|
51
53
|
/** Chooses an item people picked: the menu closes, the focus goes back to the trigger, and `select` fires. */
|
|
52
54
|
private chooseItem;
|
|
55
|
+
/** The action an item of the list draws. */
|
|
56
|
+
private actionOf;
|
|
53
57
|
private onToggle;
|
|
54
58
|
private focusIsInMenu;
|
|
55
59
|
/** Keeps the menu by the trigger while it is open. */
|
|
@@ -44,6 +44,8 @@ var isTypeahead = (event) => event.key.length === 1 && event.key !== " " && !eve
|
|
|
44
44
|
/**
|
|
45
45
|
* A list of actions that opens from its trigger (`slot="trigger"`, any button): on a press or with ArrowDown. Arrows,
|
|
46
46
|
* Home, End and the first letter move through it; Enter chooses, Escape closes. `select` fires with the value.
|
|
47
|
+
* Typed by its values, `JlMenu<'edit' | 'delete'>` takes actions of those values and gives `select` one of them:
|
|
48
|
+
* a page handles them with a `Record<'edit' | 'delete', () => void>`, which misses none.
|
|
47
49
|
*/
|
|
48
50
|
var JlMenu = class extends JlElement {
|
|
49
51
|
static selector = "jl-menu";
|
|
@@ -192,9 +194,14 @@ var JlMenu = class extends JlElement {
|
|
|
192
194
|
/** Chooses an item people picked: the menu closes, the focus goes back to the trigger, and `select` fires. */
|
|
193
195
|
chooseItem(item) {
|
|
194
196
|
if (!(item instanceof HTMLElement) || item.hasAttribute("aria-disabled")) return;
|
|
197
|
+
const action = this.actionOf(item);
|
|
195
198
|
this.close();
|
|
196
199
|
this.triggerElement()?.focus();
|
|
197
|
-
this.events.emit("select",
|
|
200
|
+
if (action !== void 0) this.events.emit("select", action.value);
|
|
201
|
+
}
|
|
202
|
+
/** The action an item of the list draws. */
|
|
203
|
+
actionOf(item) {
|
|
204
|
+
return this.items.get().find((entry) => "value" in entry && entry.value === item.dataset.value);
|
|
198
205
|
}
|
|
199
206
|
onToggle(open) {
|
|
200
207
|
this.renderTrigger();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES, CONTROL_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlFormControl } from "../base/jl-form-control.js";
|
|
3
4
|
import { oneOf } from "../lib/attributes.js";
|
|
4
5
|
import { registerIcons } from "../lib/icons.js";
|
|
5
6
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
6
|
-
import { jlText } from "../lib/texts.js";
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
8
|
import { setOrRemove } from "../lib/dom.js";
|
|
9
9
|
import { clamp, parseNumber, stepValue } from "../lib/numeric.js";
|
|
@@ -89,7 +89,6 @@ var JlNumberInput = class extends JlFormControl {
|
|
|
89
89
|
class: "action step down",
|
|
90
90
|
type: "button",
|
|
91
91
|
tabIndex: -1,
|
|
92
|
-
"aria-label": jlText("decrease"),
|
|
93
92
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
94
93
|
name: "minus",
|
|
95
94
|
size: ICON_SIZE
|
|
@@ -106,7 +105,6 @@ var JlNumberInput = class extends JlFormControl {
|
|
|
106
105
|
class: "action step up",
|
|
107
106
|
type: "button",
|
|
108
107
|
tabIndex: -1,
|
|
109
|
-
"aria-label": jlText("increase"),
|
|
110
108
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
111
109
|
name: "plus",
|
|
112
110
|
size: ICON_SIZE
|
|
@@ -208,6 +206,11 @@ var JlNumberInput = class extends JlFormControl {
|
|
|
208
206
|
this._refs.down.disabled = off || value !== null && min !== null && value <= min;
|
|
209
207
|
this._refs.up.disabled = off || value !== null && max !== null && value >= max;
|
|
210
208
|
}
|
|
209
|
+
drawTexts() {
|
|
210
|
+
this._refs.down.setAttribute("aria-label", jlText("decrease"));
|
|
211
|
+
this._refs.up.setAttribute("aria-label", jlText("increase"));
|
|
212
|
+
this.renderValidity();
|
|
213
|
+
}
|
|
211
214
|
renderValidity() {
|
|
212
215
|
if (!(this.required.get() && this.value.get() === null)) {
|
|
213
216
|
this.internals.setValidity({});
|
|
@@ -46,6 +46,8 @@ export declare class JlPagination extends JlElement {
|
|
|
46
46
|
private readonly _refs;
|
|
47
47
|
templateHtml(): Node;
|
|
48
48
|
templateCss(): string;
|
|
49
|
+
protected drawTexts(): void;
|
|
50
|
+
private renderLabel;
|
|
49
51
|
onConnect(): void;
|
|
50
52
|
/** The current page, kept within the pages there are. */
|
|
51
53
|
private currentPage;
|
|
@@ -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 { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
4
5
|
import { registerIcons } from "../lib/icons.js";
|
|
5
6
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
6
|
-
import { jlText } from "../lib/texts.js";
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
8
|
import { clampPage, pageItems } from "../lib/pagination.js";
|
|
9
9
|
import jl_pagination_default from "./jl-pagination.css_raw.js";
|
|
@@ -61,9 +61,7 @@ var JlPagination = class extends JlElement {
|
|
|
61
61
|
parse: oneOf(CONTROL_SIZES, "md")
|
|
62
62
|
});
|
|
63
63
|
/** The navigation's name for screen readers, when a page has more than one. */
|
|
64
|
-
label = this.useChange(
|
|
65
|
-
this._refs.nav.setAttribute("aria-label", value || jlText("pagination"));
|
|
66
|
-
}, { attribute: "label" });
|
|
64
|
+
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
67
65
|
_refs = this.useRefs((ref) => ({
|
|
68
66
|
list: ref(".pages"),
|
|
69
67
|
nav: ref("nav"),
|
|
@@ -80,7 +78,6 @@ var JlPagination = class extends JlElement {
|
|
|
80
78
|
/* @__PURE__ */ jsx("button", {
|
|
81
79
|
type: "button",
|
|
82
80
|
class: "button previous",
|
|
83
|
-
"aria-label": jlText("previousPage"),
|
|
84
81
|
children: /* @__PURE__ */ jsx(JlIcon, { name: "chevron-left" })
|
|
85
82
|
}),
|
|
86
83
|
/* @__PURE__ */ jsx("ol", { class: "pages" }),
|
|
@@ -91,7 +88,6 @@ var JlPagination = class extends JlElement {
|
|
|
91
88
|
/* @__PURE__ */ jsx("button", {
|
|
92
89
|
type: "button",
|
|
93
90
|
class: "button next",
|
|
94
|
-
"aria-label": jlText("nextPage"),
|
|
95
91
|
children: /* @__PURE__ */ jsx(JlIcon, { name: "chevron-right" })
|
|
96
92
|
})
|
|
97
93
|
]
|
|
@@ -100,6 +96,15 @@ var JlPagination = class extends JlElement {
|
|
|
100
96
|
templateCss() {
|
|
101
97
|
return css`${BASE_STYLES}${jl_pagination_default}`;
|
|
102
98
|
}
|
|
99
|
+
drawTexts() {
|
|
100
|
+
this._refs.previous.setAttribute("aria-label", jlText("previousPage"));
|
|
101
|
+
this._refs.next.setAttribute("aria-label", jlText("nextPage"));
|
|
102
|
+
this.renderLabel();
|
|
103
|
+
this.render();
|
|
104
|
+
}
|
|
105
|
+
renderLabel() {
|
|
106
|
+
this._refs.nav.setAttribute("aria-label", this.label.get() || jlText("pagination"));
|
|
107
|
+
}
|
|
103
108
|
onConnect() {
|
|
104
109
|
this.on(this._refs.previous, "click", () => this.step(STEP_BACK));
|
|
105
110
|
this.on(this._refs.next, "click", () => this.step(STEP_FORWARD));
|
|
@@ -125,8 +130,11 @@ var JlPagination = class extends JlElement {
|
|
|
125
130
|
this._refs.status.hidden = !compact;
|
|
126
131
|
this._refs.status.replaceChildren(/* @__PURE__ */ jsx("span", {
|
|
127
132
|
class: "sr-only",
|
|
128
|
-
children: "
|
|
129
|
-
}),
|
|
133
|
+
children: `${jlText("page")} `
|
|
134
|
+
}), jlText("pageOfTotal", {
|
|
135
|
+
page,
|
|
136
|
+
total: Math.max(pages, 1)
|
|
137
|
+
}));
|
|
130
138
|
if (!compact) {
|
|
131
139
|
const items = pageItems(page, pages, this.siblings.get(), this.boundaries.get());
|
|
132
140
|
this._refs.list.replaceChildren(...items.map((item) => this.entry(item, page)));
|
|
@@ -143,7 +151,7 @@ var JlPagination = class extends JlElement {
|
|
|
143
151
|
type: "button",
|
|
144
152
|
class: "button page",
|
|
145
153
|
"data-page": item.page,
|
|
146
|
-
"aria-label":
|
|
154
|
+
"aria-label": jlText("pageNumber", { page: item.page }),
|
|
147
155
|
"aria-current": isCurrent ? "page" : void 0,
|
|
148
156
|
children: String(item.page)
|
|
149
157
|
}) });
|
|
@@ -4,20 +4,21 @@ export declare const RADIO_GROUP_ORIENTATIONS: readonly RadioGroupOrientation[];
|
|
|
4
4
|
export declare const RADIO_GROUP_VARIANTS: readonly RadioGroupVariant[];
|
|
5
5
|
/**
|
|
6
6
|
* One choice among a few, all in view. It behaves as native radios: Tab reaches the chosen option, the arrow keys
|
|
7
|
-
* move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card.
|
|
7
|
+
* move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card. Typed by its
|
|
8
|
+
* values, `JlRadioGroup<'card' | 'invoice'>` takes options of those values and gives `change` one of them.
|
|
8
9
|
*/
|
|
9
|
-
export declare class JlRadioGroup extends JlFormControl {
|
|
10
|
+
export declare class JlRadioGroup<Value extends string = string> extends JlFormControl {
|
|
10
11
|
static readonly selector = "jl-radio-group";
|
|
11
12
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
12
|
-
change:
|
|
13
|
+
change: Value;
|
|
13
14
|
}>>;
|
|
14
15
|
readonly options: Readonly<Readonly<{
|
|
15
|
-
get(): RadioOption[];
|
|
16
|
-
set(setter: RadioOption[] | ((prevState: RadioOption[]) => RadioOption[])): void;
|
|
16
|
+
get(): RadioOption<Value>[];
|
|
17
|
+
set(setter: RadioOption<Value>[] | ((prevState: RadioOption<Value>[]) => RadioOption<Value>[])): void;
|
|
17
18
|
}>>;
|
|
18
19
|
readonly value: Readonly<Readonly<{
|
|
19
|
-
get():
|
|
20
|
-
set(setter:
|
|
20
|
+
get(): "" | Value;
|
|
21
|
+
set(setter: "" | Value | ((prevState: "" | Value) => "" | Value)): void;
|
|
21
22
|
}>>;
|
|
22
23
|
readonly orientation: Readonly<Readonly<{
|
|
23
24
|
get(): RadioGroupOrientation;
|
|
@@ -67,5 +68,6 @@ export declare class JlRadioGroup extends JlFormControl {
|
|
|
67
68
|
/** Checks the option with the value, and gives the Tab stop to it, or else to the first option enabled. */
|
|
68
69
|
private renderValue;
|
|
69
70
|
private tabStop;
|
|
71
|
+
protected drawTexts(): void;
|
|
70
72
|
private renderValidity;
|
|
71
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlFormControl } from "../base/jl-form-control.js";
|
|
3
|
-
import { jsonOf, oneOf } from "../lib/attributes.js";
|
|
4
|
-
import { jlText } from "../lib/texts.js";
|
|
4
|
+
import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
|
|
5
5
|
import { rovingIndex } from "../lib/roving-index.js";
|
|
6
6
|
import jl_radio_group_default from "./jl-radio-group.css_raw.js";
|
|
7
7
|
import { css } from "@jadis/core";
|
|
@@ -23,7 +23,8 @@ var MOVES = /* @__PURE__ */ new Map([
|
|
|
23
23
|
var SPACE = " ";
|
|
24
24
|
/**
|
|
25
25
|
* One choice among a few, all in view. It behaves as native radios: Tab reaches the chosen option, the arrow keys
|
|
26
|
-
* move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card.
|
|
26
|
+
* move the choice, Space chooses the focused option. `variant="cards"` draws each option as a card. Typed by its
|
|
27
|
+
* values, `JlRadioGroup<'card' | 'invoice'>` takes options of those values and gives `change` one of them.
|
|
27
28
|
*/
|
|
28
29
|
var JlRadioGroup = class extends JlFormControl {
|
|
29
30
|
static selector = "jl-radio-group";
|
|
@@ -32,7 +33,10 @@ var JlRadioGroup = class extends JlFormControl {
|
|
|
32
33
|
attribute: "options",
|
|
33
34
|
parse: jsonOf([])
|
|
34
35
|
});
|
|
35
|
-
value = this.useChange(NO_VALUE, () => this.renderValue(), {
|
|
36
|
+
value = this.useChange(NO_VALUE, () => this.renderValue(), {
|
|
37
|
+
attribute: "value",
|
|
38
|
+
parse: textOf(NO_VALUE)
|
|
39
|
+
});
|
|
36
40
|
orientation = this.useChange("vertical", (value) => {
|
|
37
41
|
this.reflect("orientation", value);
|
|
38
42
|
this._refs.group.setAttribute("aria-orientation", value);
|
|
@@ -95,7 +99,7 @@ var JlRadioGroup = class extends JlFormControl {
|
|
|
95
99
|
this.on(list, "keydown", (event) => this.onKey(event));
|
|
96
100
|
}
|
|
97
101
|
resetValue() {
|
|
98
|
-
this.value.set(this.getAttribute("value")
|
|
102
|
+
this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
|
|
99
103
|
}
|
|
100
104
|
/** The browser calls it for a disabled fieldset and for the element's own disabled attribute, even before render. */
|
|
101
105
|
setDisabledByForm(disabled) {
|
|
@@ -124,8 +128,8 @@ var JlRadioGroup = class extends JlFormControl {
|
|
|
124
128
|
}
|
|
125
129
|
choose(radio) {
|
|
126
130
|
radio.focus();
|
|
127
|
-
const value = radio.dataset.value
|
|
128
|
-
if (value === this.value.get()) return;
|
|
131
|
+
const value = this.options.get().find((option) => option.value === radio.dataset.value)?.value;
|
|
132
|
+
if (value === void 0 || value === this.value.get()) return;
|
|
129
133
|
this.value.set(value);
|
|
130
134
|
this.events.emit("change", value);
|
|
131
135
|
}
|
|
@@ -190,6 +194,9 @@ var JlRadioGroup = class extends JlFormControl {
|
|
|
190
194
|
const enabled = radios.filter((radio) => this.isEnabled(radio));
|
|
191
195
|
return enabled.find((radio) => radio.dataset.value === value) ?? enabled[0];
|
|
192
196
|
}
|
|
197
|
+
drawTexts() {
|
|
198
|
+
this.renderValidity();
|
|
199
|
+
}
|
|
193
200
|
renderValidity() {
|
|
194
201
|
if (!(this.required.get() && this.value.get() === NO_VALUE)) {
|
|
195
202
|
this.internals.setValidity({});
|
|
@@ -9,7 +9,7 @@ export declare class JlSearchButton extends JlElement {
|
|
|
9
9
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
10
10
|
press: undefined;
|
|
11
11
|
}>>;
|
|
12
|
-
/** The text, and the button's name
|
|
12
|
+
/** The text, and the button's name; jlib's own when empty. */
|
|
13
13
|
readonly label: Readonly<Readonly<{
|
|
14
14
|
get(): string;
|
|
15
15
|
set(setter: string | ((prevState: string) => string)): void;
|
|
@@ -28,6 +28,7 @@ export declare class JlSearchButton extends JlElement {
|
|
|
28
28
|
focus(options?: FocusOptions): void;
|
|
29
29
|
templateHtml(): Node;
|
|
30
30
|
templateCss(): string;
|
|
31
|
+
protected drawTexts(): void;
|
|
31
32
|
onConnect(): void;
|
|
32
33
|
private renderLabel;
|
|
33
34
|
private renderHotkey;
|
|
@@ -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 { setOrRemove } from "../lib/dom.js";
|
|
7
7
|
import { JlKbd } from "../atoms/jl-kbd.js";
|
|
@@ -25,8 +25,8 @@ var isMac = () => MAC_PATTERN.test(navigator.userAgent);
|
|
|
25
25
|
var JlSearchButton = class extends JlElement {
|
|
26
26
|
static selector = "jl-search-button";
|
|
27
27
|
events = this.useEvents();
|
|
28
|
-
/** The text, and the button's name
|
|
29
|
-
label = this.useChange(
|
|
28
|
+
/** The text, and the button's name; jlib's own when empty. */
|
|
29
|
+
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
30
30
|
/** The keys that open the palette, as `jl-kbd` writes them: `mod+k`; `none` for no keys. */
|
|
31
31
|
hotkey = this.useChange(DEFAULT_HOTKEY, () => this.renderHotkey(), { attribute: "hotkey" });
|
|
32
32
|
/** The icon alone, the label as its tooltip. */
|
|
@@ -57,8 +57,10 @@ var JlSearchButton = class extends JlElement {
|
|
|
57
57
|
templateCss() {
|
|
58
58
|
return css`${BASE_STYLES}${jl_search_button_default}`;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
drawTexts() {
|
|
61
61
|
this.renderLabel();
|
|
62
|
+
}
|
|
63
|
+
onConnect() {
|
|
62
64
|
this.renderHotkey();
|
|
63
65
|
this.on(this._refs.button, "click", () => this.events.emit("press"));
|
|
64
66
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES, CONTROL_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlFormControl } from "../base/jl-form-control.js";
|
|
3
4
|
import { oneOf } from "../lib/attributes.js";
|
|
4
5
|
import { registerIcons } from "../lib/icons.js";
|
|
5
6
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
6
|
-
import { jlText } from "../lib/texts.js";
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
8
|
import { setOrRemove } from "../lib/dom.js";
|
|
9
9
|
import { JlSpinner } from "../atoms/jl-spinner.js";
|
|
@@ -38,7 +38,7 @@ var JlSearch = class extends JlFormControl {
|
|
|
38
38
|
value = this.useChange("", (value) => this.renderValue(value), { attribute: "value" });
|
|
39
39
|
placeholder = this.useChange("", (value) => setOrRemove(this._refs.native, "placeholder", value), { attribute: "placeholder" });
|
|
40
40
|
/** The field's name for screen readers; "Search" when nothing else names it. */
|
|
41
|
-
label = this.useChange("", (
|
|
41
|
+
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
42
42
|
/** How long typing must pause, in milliseconds, before `search` fires. */
|
|
43
43
|
debounce = this.useChange(DEFAULT_DEBOUNCE_MS, () => void 0, { attribute: "debounce" });
|
|
44
44
|
/** Keys that focus the field from anywhere: "/" or "mod+k" (⌘ on a Mac, Ctrl elsewhere). */
|
|
@@ -108,7 +108,6 @@ var JlSearch = class extends JlFormControl {
|
|
|
108
108
|
/* @__PURE__ */ jsx("button", {
|
|
109
109
|
class: "action clear",
|
|
110
110
|
type: "button",
|
|
111
|
-
"aria-label": jlText("clearSearch"),
|
|
112
111
|
tabIndex: -1,
|
|
113
112
|
hidden: true,
|
|
114
113
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
@@ -127,6 +126,13 @@ var JlSearch = class extends JlFormControl {
|
|
|
127
126
|
templateCss() {
|
|
128
127
|
return css`${BASE_STYLES}${CONTROL_STYLES}${jl_search_default}`;
|
|
129
128
|
}
|
|
129
|
+
drawTexts() {
|
|
130
|
+
this._refs.clear.setAttribute("aria-label", jlText("clearSearch"));
|
|
131
|
+
this.renderLabel();
|
|
132
|
+
}
|
|
133
|
+
renderLabel() {
|
|
134
|
+
this._refs.native.setAttribute("aria-label", this.label.get() || jlText("search"));
|
|
135
|
+
}
|
|
130
136
|
onConnect() {
|
|
131
137
|
const native = this._refs.native;
|
|
132
138
|
this.on(native, "input", (event) => {
|
|
@@ -3,21 +3,22 @@ import type { SegmentedOption } from '../types/jl-segmented.types';
|
|
|
3
3
|
import type { ControlSize } from '../types/options.types';
|
|
4
4
|
/**
|
|
5
5
|
* A row of a few exclusive choices with a thumb that slides to the chosen one: a view switch, a period, a
|
|
6
|
-
* density. It takes part in forms like a radio group; `change` fires with the value people pick.
|
|
6
|
+
* density. It takes part in forms like a radio group; `change` fires with the value people pick. Typed by its values,
|
|
7
|
+
* `JlSegmented<'list' | 'grid'>` takes options of those values and gives `change` one of them.
|
|
7
8
|
*/
|
|
8
|
-
export declare class JlSegmented extends JlFormControl {
|
|
9
|
+
export declare class JlSegmented<Value extends string = string> extends JlFormControl {
|
|
9
10
|
static readonly selector = "jl-segmented";
|
|
10
11
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
11
|
-
change:
|
|
12
|
+
change: Value;
|
|
12
13
|
}>>;
|
|
13
14
|
readonly options: Readonly<Readonly<{
|
|
14
|
-
get(): SegmentedOption[];
|
|
15
|
-
set(setter: SegmentedOption[] | ((prevState: SegmentedOption[]) => SegmentedOption[])): void;
|
|
15
|
+
get(): SegmentedOption<Value>[];
|
|
16
|
+
set(setter: SegmentedOption<Value>[] | ((prevState: SegmentedOption<Value>[]) => SegmentedOption<Value>[])): void;
|
|
16
17
|
}>>;
|
|
17
18
|
/** The chosen option's value; the first option that can be chosen when it names none. */
|
|
18
19
|
readonly value: Readonly<Readonly<{
|
|
19
|
-
get():
|
|
20
|
-
set(setter:
|
|
20
|
+
get(): "" | Value;
|
|
21
|
+
set(setter: "" | Value | ((prevState: "" | Value) => "" | Value)): void;
|
|
21
22
|
}>>;
|
|
22
23
|
readonly size: Readonly<Readonly<{
|
|
23
24
|
get(): ControlSize;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
2
|
import { JlFormControl } from "../base/jl-form-control.js";
|
|
3
|
-
import { jsonOf, oneOf } from "../lib/attributes.js";
|
|
3
|
+
import { jsonOf, oneOf, textOf } from "../lib/attributes.js";
|
|
4
4
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
5
5
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
6
6
|
import { setOrRemove } from "../lib/dom.js";
|
|
@@ -16,6 +16,7 @@ var ICON_SIZES = {
|
|
|
16
16
|
md: 16,
|
|
17
17
|
sm: 14
|
|
18
18
|
};
|
|
19
|
+
var NO_VALUE = "";
|
|
19
20
|
var KEY_MOVES = /* @__PURE__ */ new Map([
|
|
20
21
|
["ArrowDown", (enabled, from) => stepIndex(enabled, from, 1)],
|
|
21
22
|
["ArrowLeft", (enabled, from) => stepIndex(enabled, from, -1)],
|
|
@@ -26,7 +27,8 @@ var KEY_MOVES = /* @__PURE__ */ new Map([
|
|
|
26
27
|
]);
|
|
27
28
|
/**
|
|
28
29
|
* A row of a few exclusive choices with a thumb that slides to the chosen one: a view switch, a period, a
|
|
29
|
-
* density. It takes part in forms like a radio group; `change` fires with the value people pick.
|
|
30
|
+
* density. It takes part in forms like a radio group; `change` fires with the value people pick. Typed by its values,
|
|
31
|
+
* `JlSegmented<'list' | 'grid'>` takes options of those values and gives `change` one of them.
|
|
30
32
|
*/
|
|
31
33
|
var JlSegmented = class extends JlFormControl {
|
|
32
34
|
static selector = "jl-segmented";
|
|
@@ -36,7 +38,10 @@ var JlSegmented = class extends JlFormControl {
|
|
|
36
38
|
parse: jsonOf([])
|
|
37
39
|
});
|
|
38
40
|
/** The chosen option's value; the first option that can be chosen when it names none. */
|
|
39
|
-
value = this.useChange(
|
|
41
|
+
value = this.useChange(NO_VALUE, () => this.renderValue(), {
|
|
42
|
+
attribute: "value",
|
|
43
|
+
parse: textOf(NO_VALUE)
|
|
44
|
+
});
|
|
40
45
|
size = this.useChange("md", (value) => {
|
|
41
46
|
this.reflect("size", value);
|
|
42
47
|
this.renderOptions();
|
|
@@ -91,7 +96,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
91
96
|
this._resize.disconnect();
|
|
92
97
|
}
|
|
93
98
|
resetValue() {
|
|
94
|
-
this.value.set(this.getAttribute("value")
|
|
99
|
+
this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
|
|
95
100
|
}
|
|
96
101
|
/** The browser calls it for a disabled fieldset and for the element's own `disabled`, even before it renders. */
|
|
97
102
|
setDisabledByForm(disabled) {
|
|
@@ -155,7 +160,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
155
160
|
this.value.set(option.value);
|
|
156
161
|
return;
|
|
157
162
|
}
|
|
158
|
-
const value = option?.value ??
|
|
163
|
+
const value = option?.value ?? NO_VALUE;
|
|
159
164
|
this.segments().forEach((segment) => {
|
|
160
165
|
const checked = segment.dataset.value === value;
|
|
161
166
|
segment.setAttribute("aria-checked", String(checked));
|
|
@@ -37,6 +37,8 @@ export declare class JlSteps extends JlElement {
|
|
|
37
37
|
templateHtml(): Node;
|
|
38
38
|
templateCss(): string;
|
|
39
39
|
onConnect(): void;
|
|
40
|
+
protected drawTexts(): void;
|
|
41
|
+
private renderLabel;
|
|
40
42
|
private render;
|
|
41
43
|
/** A failed step's ×, a done one's check, or the step's number. */
|
|
42
44
|
private markerOf;
|
|
@@ -1,8 +1,8 @@
|
|
|
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, jsonOf, oneOf } from "../lib/attributes.js";
|
|
4
5
|
import { registerIcons } from "../lib/icons.js";
|
|
5
|
-
import { jlText } from "../lib/texts.js";
|
|
6
6
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
7
7
|
import jl_steps_default from "./jl-steps.css_raw.js";
|
|
8
8
|
import { css } from "@jadis/core";
|
|
@@ -52,9 +52,7 @@ var JlSteps = class extends JlElement {
|
|
|
52
52
|
/** Done steps become buttons that go back to them. */
|
|
53
53
|
clickable = this.useChange(false, () => this.render(), { attribute: "clickable" });
|
|
54
54
|
/** The list's name for screen readers. */
|
|
55
|
-
label = this.useChange(
|
|
56
|
-
this._refs.list.setAttribute("aria-label", value || jlText("progress"));
|
|
57
|
-
}, { attribute: "label" });
|
|
55
|
+
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
58
56
|
_refs = this.useRefs((ref) => ({ list: ref("ol") }));
|
|
59
57
|
templateHtml() {
|
|
60
58
|
return /* @__PURE__ */ jsx("ol", { attrs: { part: "base" } });
|
|
@@ -68,6 +66,13 @@ var JlSteps = class extends JlElement {
|
|
|
68
66
|
if (target !== null) this.goBackTo(Number(target.dataset.index));
|
|
69
67
|
});
|
|
70
68
|
}
|
|
69
|
+
drawTexts() {
|
|
70
|
+
this.renderLabel();
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
renderLabel() {
|
|
74
|
+
this._refs.list.setAttribute("aria-label", this.label.get() || jlText("progress"));
|
|
75
|
+
}
|
|
71
76
|
render() {
|
|
72
77
|
const current = this.current.get();
|
|
73
78
|
this._refs.list.replaceChildren(...this.items.get().map((item, index) => this.step(item, index, statusOf(index, current))));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { jlText } from "../lib/texts.js";
|
|
1
2
|
import { BASE_STYLES, CONTROL_STYLES, FLOATING_STYLES } from "../styles/shared.js";
|
|
2
3
|
import { JlFormControl } from "../base/jl-form-control.js";
|
|
3
4
|
import { clampedNumber, jsonOf, oneOf } from "../lib/attributes.js";
|
|
4
5
|
import { followAnchor } from "../lib/floating.js";
|
|
5
6
|
import { registerIcons } from "../lib/icons.js";
|
|
6
7
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
7
|
-
import { jlText } from "../lib/texts.js";
|
|
8
8
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
9
9
|
import { setOrRemove, uniqueId } from "../lib/dom.js";
|
|
10
10
|
import { keepInView } from "../lib/keep-in-view.js";
|
|
@@ -118,6 +118,10 @@ var JlTagInput = class extends JlFormControl {
|
|
|
118
118
|
templateCss() {
|
|
119
119
|
return css`${BASE_STYLES}${CONTROL_STYLES}${FLOATING_STYLES}${jl_tag_input_default}`;
|
|
120
120
|
}
|
|
121
|
+
drawTexts() {
|
|
122
|
+
this.renderTags();
|
|
123
|
+
this.renderValidity();
|
|
124
|
+
}
|
|
121
125
|
onConnect() {
|
|
122
126
|
const native = this._refs.native;
|
|
123
127
|
this._nameWatch.observe(this, {
|
|
@@ -232,7 +236,7 @@ var JlTagInput = class extends JlFormControl {
|
|
|
232
236
|
this.closeList();
|
|
233
237
|
if (added.length > 0) {
|
|
234
238
|
this.value.set(result.tags);
|
|
235
|
-
this.announce(
|
|
239
|
+
this.announce(jlText("addedNamed", { names: added.join(", ") }));
|
|
236
240
|
this.events.emit("change", result.tags);
|
|
237
241
|
}
|
|
238
242
|
this.flash(result.duplicates);
|
|
@@ -243,7 +247,7 @@ var JlTagInput = class extends JlFormControl {
|
|
|
243
247
|
if (removed === void 0 || this.disabled.get()) return;
|
|
244
248
|
const next = tags.filter((_, position) => position !== index);
|
|
245
249
|
this.value.set(next);
|
|
246
|
-
this.announce(
|
|
250
|
+
this.announce(jlText("removedNamed", { name: removed }));
|
|
247
251
|
this.events.emit("change", next);
|
|
248
252
|
}
|
|
249
253
|
removeAndFocus(index) {
|
|
@@ -381,7 +385,7 @@ var JlTagInput = class extends JlFormControl {
|
|
|
381
385
|
class: "tag-remove",
|
|
382
386
|
type: "button",
|
|
383
387
|
tabIndex: -1,
|
|
384
|
-
"aria-label":
|
|
388
|
+
"aria-label": jlText("removeNamed", { name: tag }),
|
|
385
389
|
"data-index": String(index),
|
|
386
390
|
children: /* @__PURE__ */ jsx(JlIcon, {
|
|
387
391
|
name: "x",
|
|
@@ -65,6 +65,7 @@ export declare class JlToast extends JlElement {
|
|
|
65
65
|
show(): void;
|
|
66
66
|
templateHtml(): Node;
|
|
67
67
|
templateCss(): string;
|
|
68
|
+
protected drawTexts(): void;
|
|
68
69
|
onConnect(): void;
|
|
69
70
|
onDisconnect(): void;
|
|
70
71
|
/** The way in, once per showing; WAAPI so that the toaster moving in the top layer does not replay it. */
|
|
@@ -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 { registerIcons } from "../lib/icons.js";
|
|
5
6
|
import { TONE_ICONS, TONE_ICON_FILLED } from "../lib/options.js";
|
|
6
|
-
import { jlText } from "../lib/texts.js";
|
|
7
7
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
8
8
|
import { JlButton } from "../atoms/jl-button.js";
|
|
9
9
|
import { optionalNumber } from "../lib/progress.js";
|
|
@@ -181,7 +181,6 @@ var JlToast = class extends JlElement {
|
|
|
181
181
|
variant: "ghost",
|
|
182
182
|
size: "sm",
|
|
183
183
|
icon: "x",
|
|
184
|
-
hint: jlText("close"),
|
|
185
184
|
hidden: true
|
|
186
185
|
})]
|
|
187
186
|
}),
|
|
@@ -197,6 +196,9 @@ var JlToast = class extends JlElement {
|
|
|
197
196
|
templateCss() {
|
|
198
197
|
return css`${BASE_STYLES}${jl_toast_default}`;
|
|
199
198
|
}
|
|
199
|
+
drawTexts() {
|
|
200
|
+
this._refs.close.hint.set(jlText("close"));
|
|
201
|
+
}
|
|
200
202
|
onConnect() {
|
|
201
203
|
this._refs.close.events.register("press", () => this.dismiss());
|
|
202
204
|
this._refs.action.events.register("press", () => {
|