@syware/jlib 0.13.0 → 0.15.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 +12 -8
- package/dist/atoms/jl-avatar.d.ts +2 -0
- package/dist/atoms/jl-avatar.js +11 -6
- package/dist/atoms/jl-button.d.ts +6 -0
- package/dist/atoms/jl-button.js +22 -8
- package/dist/atoms/jl-chip.js +2 -1
- package/dist/atoms/jl-input.js +3 -3
- package/dist/atoms/jl-link.d.ts +1 -0
- package/dist/atoms/jl-link.js +5 -2
- package/dist/atoms/jl-progress-ring.d.ts +2 -0
- package/dist/atoms/jl-progress-ring.js +9 -4
- package/dist/atoms/jl-progress.d.ts +1 -0
- package/dist/atoms/jl-progress.js +8 -4
- package/dist/atoms/jl-rating.d.ts +2 -0
- package/dist/atoms/jl-rating.js +11 -6
- package/dist/atoms/jl-select.css.js +1 -1
- package/dist/atoms/jl-select.d.ts +4 -0
- package/dist/atoms/jl-select.js +18 -2
- package/dist/atoms/jl-switch.css.js +1 -1
- package/dist/atoms/jl-textarea.js +2 -2
- package/dist/base/jl-form-control.d.ts +3 -2
- package/dist/base/jl-form-control.js +14 -4
- package/dist/index.d.ts +2 -1
- package/dist/lib/dom.d.ts +5 -0
- package/dist/lib/dom.js +9 -1
- package/dist/lib/download.js +10 -2
- package/dist/lib/floating.d.ts +5 -0
- package/dist/lib/floating.js +21 -2
- package/dist/lib/fuzzy.d.ts +3 -2
- package/dist/lib/fuzzy.js +15 -4
- package/dist/lib/hotkey.d.ts +13 -0
- package/dist/lib/hotkey.js +2 -1
- package/dist/lib/key-shortcut.js +11 -29
- package/dist/lib/modal.d.ts +24 -0
- package/dist/lib/modal.js +52 -0
- package/dist/lib/numeric.d.ts +5 -0
- package/dist/lib/numeric.js +11 -1
- package/dist/lib/option-filter.d.ts +2 -0
- package/dist/lib/option-filter.js +1 -1
- package/dist/lib/press.d.ts +11 -0
- package/dist/lib/press.js +31 -0
- package/dist/lib/progress.d.ts +0 -5
- package/dist/lib/progress.js +1 -9
- package/dist/lib/roving.d.ts +6 -0
- package/dist/lib/roving.js +14 -1
- package/dist/lib/table.js +12 -4
- package/dist/lib/texts-de.d.ts +12 -0
- package/dist/lib/texts-de.js +12 -0
- package/dist/lib/texts-fr.d.ts +12 -0
- package/dist/lib/texts-fr.js +12 -0
- package/dist/lib/texts.d.ts +12 -0
- package/dist/lib/texts.js +12 -0
- package/dist/molecules/jl-accordion-item.js +2 -1
- package/dist/molecules/jl-calendar.d.ts +4 -0
- package/dist/molecules/jl-calendar.js +16 -5
- package/dist/molecules/jl-chip-group.css.js +1 -1
- package/dist/molecules/jl-chip-group.js +4 -4
- package/dist/molecules/jl-code-block.css.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +4 -0
- package/dist/molecules/jl-combobox.js +23 -11
- package/dist/molecules/jl-copy-button.css.js +1 -1
- package/dist/molecules/jl-copy-button.d.ts +11 -4
- package/dist/molecules/jl-copy-button.js +48 -22
- package/dist/molecules/jl-date-picker.d.ts +4 -0
- package/dist/molecules/jl-date-picker.js +18 -12
- package/dist/molecules/jl-field.d.ts +5 -1
- package/dist/molecules/jl-field.js +24 -5
- package/dist/molecules/jl-file-drop.css.js +1 -1
- package/dist/molecules/jl-file-drop.d.ts +4 -0
- package/dist/molecules/jl-file-drop.js +16 -8
- package/dist/molecules/jl-input-list.js +13 -6
- package/dist/molecules/jl-load-state.d.ts +8 -0
- package/dist/molecules/jl-load-state.js +33 -7
- package/dist/molecules/jl-menu.d.ts +21 -1
- package/dist/molecules/jl-menu.js +58 -6
- package/dist/molecules/jl-number-input.d.ts +2 -0
- package/dist/molecules/jl-number-input.js +12 -8
- package/dist/molecules/jl-radio-group.js +4 -3
- package/dist/molecules/jl-search.js +2 -2
- package/dist/molecules/jl-segmented.js +2 -2
- package/dist/molecules/jl-tabs.js +2 -2
- package/dist/molecules/jl-tag-input.css.js +1 -1
- package/dist/molecules/jl-tag-input.d.ts +4 -0
- package/dist/molecules/jl-tag-input.js +17 -9
- package/dist/molecules/jl-toast.js +10 -6
- package/dist/molecules/jl-tooltip.js +8 -2
- package/dist/organisms/jl-command-palette.css.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +2 -0
- package/dist/organisms/jl-command-palette.js +10 -4
- package/dist/organisms/jl-dialog.d.ts +3 -0
- package/dist/organisms/jl-dialog.js +13 -3
- package/dist/organisms/jl-drawer.d.ts +3 -0
- package/dist/organisms/jl-drawer.js +13 -3
- package/dist/organisms/jl-flow.d.ts +2 -0
- package/dist/organisms/jl-flow.js +29 -9
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +15 -4
- package/dist/organisms/jl-table.js +40 -17
- package/dist/organisms/jl-toaster.d.ts +13 -2
- package/dist/organisms/jl-toaster.js +47 -4
- package/dist/organisms/jl-tree.css.js +1 -1
- package/dist/organisms/jl-tree.d.ts +23 -4
- package/dist/organisms/jl-tree.js +74 -18
- package/dist/styles/base.css.js +1 -1
- package/dist/styles/control.css.js +1 -1
- package/dist/styles/tokens.css.js +1 -1
- package/dist/tokens.css +4 -3
- package/dist/types/jl-load-state.types.d.ts +7 -0
- package/dist/types/jl-table.types.d.ts +12 -0
- package/dist/types/jl-tree.types.d.ts +17 -0
- package/dist/types/press.types.d.ts +6 -0
- package/package.json +7 -3
- package/dist/lib/roving-index.d.ts +0 -10
- package/dist/lib/roving-index.js +0 -32
- /package/dist/types/{roving-index.types.d.ts → roving.types.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -48,18 +48,22 @@ button.events.register('press', () => save());
|
|
|
48
48
|
|
|
49
49
|
## Components
|
|
50
50
|
|
|
51
|
-
- **Atoms**: avatar, badge, button, checkbox, chip, divider, icon, input, kbd, link,
|
|
52
|
-
select, skeleton, slider, spinner, switch, textarea.
|
|
53
|
-
- **Molecules**: accordion, alert, avatar group, breadcrumb, calendar, card,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- **
|
|
51
|
+
- **Atoms**: app icon, avatar, badge, button, checkbox, chip, divider, icon, input, kbd, link, loading bar,
|
|
52
|
+
progress, progress ring, rating, select, skeleton, slider, spinner, switch, textarea.
|
|
53
|
+
- **Molecules**: accordion, accordion item, account button, alert, avatar group, breadcrumb, calendar, card, chip
|
|
54
|
+
group, code block, combobox, copy button, date picker, empty state, facts, field, file drop, input list, list
|
|
55
|
+
item, load more, load state, menu, number input, pagination, popover, radio group, search, search button,
|
|
56
|
+
segmented control, stat, steps, tab panel, tabs, tag input, timeline, toast, tooltip.
|
|
57
|
+
- **Organisms**: command palette, confirm, dialog, drawer, flow, navbar, page header, page outlet, side nav, tab
|
|
58
|
+
bar, table, toaster, tree.
|
|
59
|
+
- **Templates**: app shell, auth layout, page, split view, stack.
|
|
58
60
|
|
|
59
61
|
## Icons
|
|
60
62
|
|
|
61
63
|
Components draw their own icons with no setup. The names a page writes (`<jl-icon name="settings">`,
|
|
62
|
-
`icon="plus"` on a button) are registered once, so a bundle holds only the icons in use:
|
|
64
|
+
`icon="plus"` on a button) are registered once, so a bundle holds only the icons in use: Icons are
|
|
65
|
+
[lucide](https://lucide.dev)'s: an app that imports some by name installs it itself (`npm install lucide`), as a
|
|
66
|
+
strict package manager (pnpm) gives an app only the packages it names.
|
|
63
67
|
|
|
64
68
|
```ts
|
|
65
69
|
import { Coffee } from 'lucide';
|
package/dist/atoms/jl-avatar.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
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";
|
|
@@ -34,11 +35,11 @@ var NAME_TONES = [
|
|
|
34
35
|
"neutral"
|
|
35
36
|
];
|
|
36
37
|
var NO_NAME_TONE = "neutral";
|
|
37
|
-
var
|
|
38
|
-
away: "
|
|
39
|
-
busy: "
|
|
40
|
-
offline: "
|
|
41
|
-
online: "
|
|
38
|
+
var STATUS_TEXTS = {
|
|
39
|
+
away: "statusAway",
|
|
40
|
+
busy: "statusBusy",
|
|
41
|
+
offline: "statusOffline",
|
|
42
|
+
online: "statusOnline"
|
|
42
43
|
};
|
|
43
44
|
var FALLBACK_ICON = "user";
|
|
44
45
|
/**
|
|
@@ -147,10 +148,14 @@ var JlAvatar = class extends JlElement {
|
|
|
147
148
|
this.reflect("status", status);
|
|
148
149
|
this.renderLabel();
|
|
149
150
|
}
|
|
151
|
+
/** The status is said in jlib's language. */
|
|
152
|
+
drawTexts() {
|
|
153
|
+
this.renderLabel();
|
|
154
|
+
}
|
|
150
155
|
renderLabel() {
|
|
151
156
|
const name = this.label.get() || this.name.get().trim();
|
|
152
157
|
const status = this.status.get();
|
|
153
|
-
const spoken = status === "" ?
|
|
158
|
+
const spoken = [name, status === "" ? "" : jlText(STATUS_TEXTS[status])].filter((part) => part !== "").join(", ");
|
|
154
159
|
const avatar = this._refs.avatar;
|
|
155
160
|
setOrRemove(avatar, "aria-label", spoken);
|
|
156
161
|
avatar.setAttribute("role", spoken === "" ? "presentation" : "img");
|
|
@@ -73,12 +73,18 @@ export declare class JlButton extends JlElement {
|
|
|
73
73
|
set(setter: string | ((prevState: string) => string)): void;
|
|
74
74
|
}>>;
|
|
75
75
|
private readonly _internals;
|
|
76
|
+
private readonly _form;
|
|
76
77
|
private readonly _refs;
|
|
77
78
|
focus(options?: FocusOptions): void;
|
|
78
79
|
templateHtml(): Node;
|
|
79
80
|
templateCss(): string;
|
|
81
|
+
/** Called by the browser when a `<fieldset disabled>` around the button changes: it presses and submits no more. */
|
|
82
|
+
formDisabledCallback(disabled: boolean): void;
|
|
80
83
|
onConnect(): void;
|
|
81
84
|
private canPress;
|
|
85
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
86
|
+
private isOff;
|
|
87
|
+
private renderDisabled;
|
|
82
88
|
/** The element that takes focus and clicks: the link with an `href`, the button otherwise. */
|
|
83
89
|
private control;
|
|
84
90
|
/**
|
package/dist/atoms/jl-button.js
CHANGED
|
@@ -4,7 +4,7 @@ import { elementInternals } from "../lib/internals.js";
|
|
|
4
4
|
import { oneOf } from "../lib/attributes.js";
|
|
5
5
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
6
6
|
import { JlIcon } from "./jl-icon.js";
|
|
7
|
-
import { setOrRemove } from "../lib/dom.js";
|
|
7
|
+
import { setAriaFlag, setOrRemove } from "../lib/dom.js";
|
|
8
8
|
import jl_button_default from "./jl-button.css.js";
|
|
9
9
|
import { JlSpinner } from "./jl-spinner.js";
|
|
10
10
|
import { css } from "@jadis/core";
|
|
@@ -54,16 +54,15 @@ var JlButton = class extends JlElement {
|
|
|
54
54
|
parse: oneOf(BUTTON_TYPES, "button")
|
|
55
55
|
});
|
|
56
56
|
disabled = this.useChange(false, (value) => {
|
|
57
|
-
this._refs.button.disabled = value;
|
|
58
|
-
this.renderLink();
|
|
59
57
|
this.reflect("disabled", value);
|
|
58
|
+
this.renderDisabled();
|
|
60
59
|
}, { attribute: "disabled" });
|
|
61
60
|
/** Shows a spinner in place of the icon and ignores presses, while the work it started runs. */
|
|
62
61
|
loading = this.useChange(false, (value) => {
|
|
63
62
|
this._refs.spinner.hidden = !value;
|
|
64
63
|
this._refs.start.hidden = value || this.icon.get() === "";
|
|
65
|
-
this._refs.button
|
|
66
|
-
this._refs.link
|
|
64
|
+
setAriaFlag(this._refs.button, "aria-busy", value);
|
|
65
|
+
setAriaFlag(this._refs.link, "aria-busy", value);
|
|
67
66
|
this.reflect("loading", value);
|
|
68
67
|
}, { attribute: "loading" });
|
|
69
68
|
/** The tooltip; also the button's name for screen readers when it only has an icon. */
|
|
@@ -77,6 +76,7 @@ var JlButton = class extends JlElement {
|
|
|
77
76
|
/** With an `href`, saves what it points to as a file of this name instead of opening it. */
|
|
78
77
|
download = this.useChange("", () => this.renderLink(), { attribute: "download" });
|
|
79
78
|
_internals = elementInternals(this);
|
|
79
|
+
_form = { disabled: false };
|
|
80
80
|
_refs = this.useRefs((ref) => ({
|
|
81
81
|
button: ref("button"),
|
|
82
82
|
content: ref(".content"),
|
|
@@ -120,7 +120,13 @@ var JlButton = class extends JlElement {
|
|
|
120
120
|
templateCss() {
|
|
121
121
|
return css`${BASE_STYLES}${jl_button_default}`;
|
|
122
122
|
}
|
|
123
|
+
/** Called by the browser when a `<fieldset disabled>` around the button changes: it presses and submits no more. */
|
|
124
|
+
formDisabledCallback(disabled) {
|
|
125
|
+
this._form.disabled = disabled;
|
|
126
|
+
this.whenRendered(() => this.renderDisabled());
|
|
127
|
+
}
|
|
123
128
|
onConnect() {
|
|
129
|
+
this.renderLabel();
|
|
124
130
|
this.on(this._refs.slot, "slotchange", () => this.renderLabel());
|
|
125
131
|
this.on(this._refs.button, "click", () => {
|
|
126
132
|
if (!this.canPress()) return;
|
|
@@ -136,7 +142,15 @@ var JlButton = class extends JlElement {
|
|
|
136
142
|
});
|
|
137
143
|
}
|
|
138
144
|
canPress() {
|
|
139
|
-
return !(this.
|
|
145
|
+
return !(this.isOff() || this.loading.get());
|
|
146
|
+
}
|
|
147
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
148
|
+
isOff() {
|
|
149
|
+
return this.disabled.get() || this._form.disabled;
|
|
150
|
+
}
|
|
151
|
+
renderDisabled() {
|
|
152
|
+
this._refs.button.disabled = this.isOff();
|
|
153
|
+
this.renderLink();
|
|
140
154
|
}
|
|
141
155
|
/** The element that takes focus and clicks: the link with an `href`, the button otherwise. */
|
|
142
156
|
control() {
|
|
@@ -151,7 +165,7 @@ var JlButton = class extends JlElement {
|
|
|
151
165
|
const href = this.href.get();
|
|
152
166
|
const isLink = href !== "";
|
|
153
167
|
const target = this.target.get();
|
|
154
|
-
const off = isLink && this.
|
|
168
|
+
const off = isLink && this.isOff();
|
|
155
169
|
const control = this.control();
|
|
156
170
|
if (content.parentNode !== control) control.append(content);
|
|
157
171
|
button.hidden = isLink;
|
|
@@ -188,7 +202,7 @@ var JlButton = class extends JlElement {
|
|
|
188
202
|
const label = this.label.get();
|
|
189
203
|
const hint = this.hint.get();
|
|
190
204
|
const iconOnly = label === "" && !this.hasSlottedContent();
|
|
191
|
-
this._refs.label.textContent = label;
|
|
205
|
+
if (this._refs.label.textContent !== label) this._refs.label.textContent = label;
|
|
192
206
|
this.reflect("icon-only", iconOnly);
|
|
193
207
|
for (const control of [this._refs.button, this._refs.link]) {
|
|
194
208
|
setOrRemove(control, "title", hint);
|
package/dist/atoms/jl-chip.js
CHANGED
|
@@ -4,6 +4,7 @@ import { JlElement } from "../base/jl-element.js";
|
|
|
4
4
|
import { oneOf } from "../lib/attributes.js";
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { JlIcon } from "./jl-icon.js";
|
|
7
|
+
import { setAriaFlag } from "../lib/dom.js";
|
|
7
8
|
import { isActivationKey } from "../lib/surface.js";
|
|
8
9
|
import jl_chip_default from "./jl-chip.css.js";
|
|
9
10
|
import { css } from "@jadis/core";
|
|
@@ -129,7 +130,7 @@ var JlChip = class extends JlElement {
|
|
|
129
130
|
}
|
|
130
131
|
main.setAttribute("role", "button");
|
|
131
132
|
main.setAttribute("aria-pressed", String(this.selected.get()));
|
|
132
|
-
main
|
|
133
|
+
setAriaFlag(main, "aria-disabled", disabled);
|
|
133
134
|
if (disabled) {
|
|
134
135
|
main.removeAttribute("tabindex");
|
|
135
136
|
return;
|
package/dist/atoms/jl-input.js
CHANGED
|
@@ -5,7 +5,7 @@ import { oneOf } from "../lib/attributes.js";
|
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
7
7
|
import { JlIcon } from "./jl-icon.js";
|
|
8
|
-
import { setOrRemove } from "../lib/dom.js";
|
|
8
|
+
import { setAriaFlag, setOrRemove } from "../lib/dom.js";
|
|
9
9
|
import jl_input_default from "./jl-input.css.js";
|
|
10
10
|
import { css } from "@jadis/core";
|
|
11
11
|
import { Eye, EyeOff, X } from "lucide";
|
|
@@ -65,7 +65,7 @@ var JlInput = class extends JlFormControl {
|
|
|
65
65
|
/** Draws the field in the danger colour, for an error the page found itself. */
|
|
66
66
|
invalid = this.useChange(false, (value) => {
|
|
67
67
|
this.reflect("invalid", value);
|
|
68
|
-
this._refs.native
|
|
68
|
+
setAriaFlag(this._refs.native, "aria-invalid", value);
|
|
69
69
|
}, { attribute: "invalid" });
|
|
70
70
|
size = this.useChange("md", (value) => this.reflect("size", value), {
|
|
71
71
|
attribute: "size",
|
|
@@ -193,7 +193,7 @@ var JlInput = class extends JlFormControl {
|
|
|
193
193
|
}
|
|
194
194
|
/** The × shows while an editable field holds text; its SVG is drawn the first time it does. */
|
|
195
195
|
renderClear() {
|
|
196
|
-
const editable = !this.disabled
|
|
196
|
+
const editable = !this._refs.native.disabled && !this.readonly.get();
|
|
197
197
|
const clear = this._refs.clear;
|
|
198
198
|
clear.hidden = !(this.clearable.get() && editable && this.value.get() !== "");
|
|
199
199
|
if (!clear.hidden) this._refs.clearIcon.name.set("x");
|
package/dist/atoms/jl-link.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare class JlLink extends JlElement {
|
|
|
43
43
|
templateHtml(): Node;
|
|
44
44
|
templateCss(): string;
|
|
45
45
|
onConnect(): void;
|
|
46
|
+
protected drawTexts(): void;
|
|
46
47
|
/** An interactive link without an address fires `press`; one with an address leaves it to the browser. */
|
|
47
48
|
private pressable;
|
|
48
49
|
/** Followed by the app, the link is still a link to the keyboard and to screen readers. */
|
package/dist/atoms/jl-link.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
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";
|
|
@@ -66,8 +67,7 @@ var JlLink = class extends JlElement {
|
|
|
66
67
|
}),
|
|
67
68
|
/* @__PURE__ */ jsx("span", {
|
|
68
69
|
class: "new-tab sr-only",
|
|
69
|
-
hidden: true
|
|
70
|
-
children: "(opens in a new tab)"
|
|
70
|
+
hidden: true
|
|
71
71
|
})
|
|
72
72
|
]
|
|
73
73
|
});
|
|
@@ -87,6 +87,9 @@ var JlLink = class extends JlElement {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
drawTexts() {
|
|
91
|
+
this._refs.newTab.textContent = jlText("opensInNewTab");
|
|
92
|
+
}
|
|
90
93
|
/** An interactive link without an address fires `press`; one with an address leaves it to the browser. */
|
|
91
94
|
pressable() {
|
|
92
95
|
return this.interactive.get() && this.href.get() === "";
|
|
@@ -43,6 +43,8 @@ export declare class JlProgressRing extends JlElement {
|
|
|
43
43
|
private readonly _svg;
|
|
44
44
|
templateHtml(): Node;
|
|
45
45
|
templateCss(): string;
|
|
46
|
+
/** The ring's name: its label, or what screen readers call a ring without one, in jlib's language. */
|
|
47
|
+
protected drawTexts(): void;
|
|
46
48
|
private buildSvg;
|
|
47
49
|
private renderGeometry;
|
|
48
50
|
private renderValue;
|
|
@@ -1,8 +1,10 @@
|
|
|
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 { svgElement } from "../lib/dom.js";
|
|
5
|
-
import {
|
|
6
|
+
import { parseNumber } from "../lib/numeric.js";
|
|
7
|
+
import { percentLabel, percentOf, progressRatio, ringGeometry } from "../lib/progress.js";
|
|
6
8
|
import { PROGRESS_TONES } from "./jl-progress.js";
|
|
7
9
|
import jl_progress_ring_default from "./jl-progress-ring.css.js";
|
|
8
10
|
import { css } from "@jadis/core";
|
|
@@ -12,7 +14,6 @@ var DEFAULT_MAX = 100;
|
|
|
12
14
|
var DEFAULT_SIZE = 40;
|
|
13
15
|
var DEFAULT_THICKNESS = 4;
|
|
14
16
|
var PATH_LENGTH = 100;
|
|
15
|
-
var DEFAULT_NAME = "Progress";
|
|
16
17
|
/**
|
|
17
18
|
* How far a task has gone, as a ring: `value` out of `max`, the percentage in its centre with `show-value`.
|
|
18
19
|
* Without a value, the ring turns: the work has no known end. Fits in buttons, cards and table cells.
|
|
@@ -22,7 +23,7 @@ var JlProgressRing = class extends JlElement {
|
|
|
22
23
|
/** How much is done, out of `max`; `null` (no attribute) for work of unknown length. */
|
|
23
24
|
value = this.useChange(null, () => this.renderValue(), {
|
|
24
25
|
attribute: "value",
|
|
25
|
-
parse:
|
|
26
|
+
parse: parseNumber
|
|
26
27
|
});
|
|
27
28
|
max = this.useChange(DEFAULT_MAX, () => this.renderValue(), { attribute: "max" });
|
|
28
29
|
/** The ring's width and height, in pixels. */
|
|
@@ -38,7 +39,7 @@ var JlProgressRing = class extends JlElement {
|
|
|
38
39
|
this._refs.percent.hidden = !value;
|
|
39
40
|
}, { attribute: "show-value" });
|
|
40
41
|
/** The ring's name for screen readers: what is in progress. */
|
|
41
|
-
label = this.useChange("", (
|
|
42
|
+
label = this.useChange("", () => this.drawTexts(), { attribute: "label" });
|
|
42
43
|
_refs = this.useRefs((ref) => ({
|
|
43
44
|
percent: ref(".percent"),
|
|
44
45
|
ring: ref(".ring")
|
|
@@ -66,6 +67,10 @@ var JlProgressRing = class extends JlElement {
|
|
|
66
67
|
templateCss() {
|
|
67
68
|
return css`${BASE_STYLES}${jl_progress_ring_default}`;
|
|
68
69
|
}
|
|
70
|
+
/** The ring's name: its label, or what screen readers call a ring without one, in jlib's language. */
|
|
71
|
+
drawTexts() {
|
|
72
|
+
this._refs.ring.setAttribute("aria-label", this.label.get() || jlText("progress"));
|
|
73
|
+
}
|
|
69
74
|
buildSvg() {
|
|
70
75
|
const root = svgElement("svg", {
|
|
71
76
|
"aria-hidden": "true",
|
|
@@ -1,7 +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
|
-
import {
|
|
5
|
+
import { parseNumber } from "../lib/numeric.js";
|
|
6
|
+
import { percentLabel, percentOf, progressRatio } from "../lib/progress.js";
|
|
5
7
|
import jl_progress_default from "./jl-progress.css.js";
|
|
6
8
|
import { css } from "@jadis/core";
|
|
7
9
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
@@ -14,7 +16,6 @@ var PROGRESS_TONES = [
|
|
|
14
16
|
];
|
|
15
17
|
var PROGRESS_SIZES = ["md", "sm"];
|
|
16
18
|
var DEFAULT_MAX = 100;
|
|
17
|
-
var DEFAULT_NAME = "Progress";
|
|
18
19
|
/**
|
|
19
20
|
* How far a task has gone, as a bar: `value` out of `max`. Without a value, the work has no known end and the bar
|
|
20
21
|
* runs back and forth. A `label` above names it; `show-value` prints the percentage.
|
|
@@ -24,7 +25,7 @@ var JlProgress = class extends JlElement {
|
|
|
24
25
|
/** How much is done, out of `max`; `null` (no attribute) for work of unknown length. */
|
|
25
26
|
value = this.useChange(null, () => this.render(), {
|
|
26
27
|
attribute: "value",
|
|
27
|
-
parse:
|
|
28
|
+
parse: parseNumber
|
|
28
29
|
});
|
|
29
30
|
max = this.useChange(DEFAULT_MAX, () => this.render(), { attribute: "max" });
|
|
30
31
|
tone = this.useChange("accent", (value) => this.reflect("tone", value), {
|
|
@@ -90,6 +91,9 @@ var JlProgress = class extends JlElement {
|
|
|
90
91
|
this._refs.bar.style.width = `${percentOf(ratio)}%`;
|
|
91
92
|
this._refs.percent.textContent = percentLabel(ratio);
|
|
92
93
|
}
|
|
94
|
+
drawTexts() {
|
|
95
|
+
this.renderHeader();
|
|
96
|
+
}
|
|
93
97
|
renderHeader() {
|
|
94
98
|
const label = this.label.get();
|
|
95
99
|
const track = this._refs.track;
|
|
@@ -98,7 +102,7 @@ var JlProgress = class extends JlElement {
|
|
|
98
102
|
this._refs.header.hidden = label === "" && !this.showValue.get();
|
|
99
103
|
if (label === "") {
|
|
100
104
|
track.removeAttribute("aria-labelledby");
|
|
101
|
-
track.setAttribute("aria-label",
|
|
105
|
+
track.setAttribute("aria-label", jlText("progress"));
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
108
|
track.removeAttribute("aria-label");
|
|
@@ -72,4 +72,6 @@ export declare class JlRating extends JlFormControl {
|
|
|
72
72
|
private renderValue;
|
|
73
73
|
private renderValidity;
|
|
74
74
|
private renderDisabled;
|
|
75
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
76
|
+
private drawDisabled;
|
|
75
77
|
}
|
package/dist/atoms/jl-rating.js
CHANGED
|
@@ -4,6 +4,7 @@ import { JlFormControl } from "../base/jl-form-control.js";
|
|
|
4
4
|
import { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
5
5
|
import { iconElement, registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
7
|
+
import { setAriaFlag } from "../lib/dom.js";
|
|
7
8
|
import { ratingAfterChoice, ratingAfterKey } from "../lib/rating.js";
|
|
8
9
|
import jl_rating_default from "./jl-rating.css.js";
|
|
9
10
|
import { css } from "@jadis/core";
|
|
@@ -34,7 +35,7 @@ var JlRating = class extends JlFormControl {
|
|
|
34
35
|
/** Shows a score that cannot be changed: an average, a review. */
|
|
35
36
|
readonly = this.useChange(false, (value) => {
|
|
36
37
|
this.reflect("readonly", value);
|
|
37
|
-
this._refs.slider
|
|
38
|
+
setAriaFlag(this._refs.slider, "aria-readonly", value);
|
|
38
39
|
}, { attribute: "readonly" });
|
|
39
40
|
icon = this.useChange(DEFAULT_ICON, () => this.renderIcons(), { attribute: "icon" });
|
|
40
41
|
size = this.useChange("md", (value) => this.reflect("size", value), {
|
|
@@ -44,14 +45,14 @@ var JlRating = class extends JlFormControl {
|
|
|
44
45
|
/** The name screen readers give the scale. */
|
|
45
46
|
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
46
47
|
required = this.useChange(false, (value) => {
|
|
47
|
-
this._refs.slider
|
|
48
|
+
setAriaFlag(this._refs.slider, "aria-required", value);
|
|
48
49
|
this.renderValidity();
|
|
49
50
|
}, { attribute: "required" });
|
|
50
51
|
disabled = this.useChange(false, (value) => this.renderDisabled(value), { attribute: "disabled" });
|
|
51
52
|
/** Draws the empty icons in the danger colour, for an error the page found itself. */
|
|
52
53
|
invalid = this.useChange(false, (value) => {
|
|
53
54
|
this.reflect("invalid", value);
|
|
54
|
-
this._refs.slider
|
|
55
|
+
setAriaFlag(this._refs.slider, "aria-invalid", value);
|
|
55
56
|
}, { attribute: "invalid" });
|
|
56
57
|
_state = {
|
|
57
58
|
drawnIcon: "",
|
|
@@ -88,7 +89,7 @@ var JlRating = class extends JlFormControl {
|
|
|
88
89
|
}
|
|
89
90
|
setDisabledByForm(disabled) {
|
|
90
91
|
this._state.formDisabled = disabled;
|
|
91
|
-
this.whenRendered(() => this.
|
|
92
|
+
this.whenRendered(() => this.drawDisabled());
|
|
92
93
|
}
|
|
93
94
|
canChange() {
|
|
94
95
|
return !this.readonly.get() && !this.disabled.get() && !this._state.formDisabled;
|
|
@@ -163,10 +164,14 @@ var JlRating = class extends JlFormControl {
|
|
|
163
164
|
this.internals.setValidity({});
|
|
164
165
|
}
|
|
165
166
|
renderDisabled(disabled) {
|
|
166
|
-
const off = disabled || this._state.formDisabled;
|
|
167
167
|
this.reflect("disabled", disabled);
|
|
168
|
+
this.drawDisabled();
|
|
169
|
+
}
|
|
170
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
171
|
+
drawDisabled() {
|
|
172
|
+
const off = this.disabled.get() || this._state.formDisabled;
|
|
168
173
|
this._refs.slider.tabIndex = off ? -1 : 0;
|
|
169
|
-
this._refs.slider
|
|
174
|
+
setAriaFlag(this._refs.slider, "aria-disabled", off);
|
|
170
175
|
}
|
|
171
176
|
};
|
|
172
177
|
JlRating.register();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/atoms/jl-select.css?inline
|
|
2
|
-
var jl_select_default = ":host{display:block}.control{padding:0;position:relative}.native{border-radius:inherit;text-overflow:ellipsis;cursor:pointer;appearance:none;padding:0 36px 0 12px}.native:disabled{cursor:not-allowed}:host([placeholder-shown]) .native{color:var(--jl-
|
|
2
|
+
var jl_select_default = ":host{display:block}.control{padding:0;position:relative}.native{border-radius:inherit;text-overflow:ellipsis;cursor:pointer;appearance:none;padding:0 36px 0 12px}.native:disabled{cursor:not-allowed}:host([placeholder-shown]) .native{color:var(--jl-muted)}option,optgroup{background:var(--jl-surface);color:var(--jl-text)}.chevron{color:var(--jl-muted);pointer-events:none;transition:transform var(--jl-fast) var(--jl-ease);position:absolute;right:12px}.native:open+.chevron{transform:rotate(180deg)}:host([disabled]) .chevron{color:var(--jl-faint)}@media (hover:hover) and (pointer:fine){@supports (appearance:base-select){.control{anchor-name:--frame}.native{appearance:base-select}.native::picker(select){appearance:base-select}.native{-webkit-line-clamp:1;padding-block:calc((var(--height,var(--jl-control-md)) - 2px - 1lh) / 2);overflow-clip-margin:content-box;-webkit-box-orient:vertical;display:-webkit-box;overflow:clip}.native::picker-icon{display:none}.native::picker(select){position-anchor:--frame;position-try-order:normal;box-sizing:border-box;min-inline-size:anchor-size(self-inline);border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface);max-block-size:274px;color:var(--jl-text);box-shadow:var(--jl-shadow-lg);animation:jl-float-in var(--jl-fast) var(--jl-ease);margin-block:6px;padding:4px}optgroup{color:var(--jl-muted);font-size:var(--jl-font-xs);text-indent:calc(10px - .5em);padding-block-start:8px;font-weight:600}optgroup>option:first-of-type{margin-block-start:4px}option{box-sizing:border-box;border-radius:var(--jl-radius-xs);min-block-size:34px;font-size:var(--jl-font-md);text-indent:0;cursor:pointer;gap:10px;padding:6px 10px;font-weight:400;line-height:1.35}option:enabled:is(:hover,:focus-visible){background:var(--jl-surface-3);box-shadow:none}option:checked{font-weight:600}option:disabled{color:var(--jl-faint);cursor:not-allowed}option::checkmark{background:var(--jl-accent);content:\"\";order:1;width:14px;height:14px;margin-inline-start:auto;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E\") 50%/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E\") 50%/contain no-repeat}}}";
|
|
3
3
|
export { jl_select_default as default };
|
|
@@ -52,11 +52,15 @@ export declare class JlSelect<Value extends string = string> extends JlFormContr
|
|
|
52
52
|
private readonly _form;
|
|
53
53
|
private _kept;
|
|
54
54
|
private readonly _drawn;
|
|
55
|
+
private readonly _lightWatch;
|
|
55
56
|
private readonly _refs;
|
|
56
57
|
focus(options?: FocusOptions): void;
|
|
57
58
|
templateHtml(): Node;
|
|
58
59
|
templateCss(): string;
|
|
59
60
|
onConnect(): void;
|
|
61
|
+
onDisconnect(): void;
|
|
62
|
+
/** Draws the page's options again when one came, left or changed. The select's own attributes are its inputs. */
|
|
63
|
+
private onLightChange;
|
|
60
64
|
protected resetValue(): void;
|
|
61
65
|
/** The browser calls it for a disabled fieldset and for the element's own disabled attribute, even before render. */
|
|
62
66
|
protected setDisabledByForm(disabled: boolean): void;
|
package/dist/atoms/jl-select.js
CHANGED
|
@@ -4,7 +4,7 @@ import { asValue, jsonOf, oneOf, textOf } from "../lib/attributes.js";
|
|
|
4
4
|
import { registerIcons } from "../lib/icons.js";
|
|
5
5
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
6
6
|
import { JlIcon } from "./jl-icon.js";
|
|
7
|
-
import { setOrRemove } from "../lib/dom.js";
|
|
7
|
+
import { setAriaFlag, setOrRemove } from "../lib/dom.js";
|
|
8
8
|
import { groupOptions } from "../lib/option-groups.js";
|
|
9
9
|
import jl_select_default from "./jl-select.css.js";
|
|
10
10
|
import { css } from "@jadis/core";
|
|
@@ -68,11 +68,12 @@ var JlSelect = class extends JlFormControl {
|
|
|
68
68
|
/** Draws the field in the danger colour, for an error the page found itself. */
|
|
69
69
|
invalid = this.useChange(false, (value) => {
|
|
70
70
|
this.reflect("invalid", value);
|
|
71
|
-
this._refs.native
|
|
71
|
+
setAriaFlag(this._refs.native, "aria-invalid", value);
|
|
72
72
|
}, { attribute: "invalid" });
|
|
73
73
|
_form = { disabled: false };
|
|
74
74
|
_kept;
|
|
75
75
|
_drawn = { light: [] };
|
|
76
|
+
_lightWatch = new MutationObserver((records) => this.onLightChange(records));
|
|
76
77
|
_refs = this.useRefs((ref) => ({ native: ref("select") }));
|
|
77
78
|
focus(options) {
|
|
78
79
|
this._refs.native.focus(options);
|
|
@@ -102,6 +103,21 @@ var JlSelect = class extends JlFormControl {
|
|
|
102
103
|
this.events.emit("change", value);
|
|
103
104
|
});
|
|
104
105
|
this.renderOptions();
|
|
106
|
+
this._lightWatch.observe(this, {
|
|
107
|
+
attributes: true,
|
|
108
|
+
characterData: true,
|
|
109
|
+
childList: true,
|
|
110
|
+
subtree: true
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
onDisconnect() {
|
|
114
|
+
this._lightWatch.disconnect();
|
|
115
|
+
}
|
|
116
|
+
/** Draws the page's options again when one came, left or changed. The select's own attributes are its inputs. */
|
|
117
|
+
onLightChange(records) {
|
|
118
|
+
if (records.every((record) => record.target === this && record.type === "attributes")) return;
|
|
119
|
+
this._drawn.light = [];
|
|
120
|
+
this.renderOptions();
|
|
105
121
|
}
|
|
106
122
|
resetValue() {
|
|
107
123
|
this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/atoms/jl-switch.css?inline
|
|
2
|
-
var jl_switch_default = ":host{vertical-align:middle;--track-width:36px;--track-height:20px;--thumb:14px;display:inline-flex}:host([size=sm]){--track-width:28px;--track-height:16px;--thumb:10px}.wrap{color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;align-items:flex-start;gap:10px;line-height:20px;display:inline-flex}:host([size=sm]) .wrap{font-size:var(--jl-font-sm)}.track{width:var(--track-width);height:var(--track-height);margin-top:calc((20px - var(--track-height)) / 2);flex:none;display:inline-flex;position:relative}.native{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);width:100%;height:100%;cursor:inherit;appearance:none;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), box-shadow var(--jl-fast) var(--jl-ease);margin:0;position:absolute;inset:0}.wrap:hover .native:not(:disabled){border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%)}.native:checked{border-color:var(--jl-accent);background:var(--jl-accent)}.wrap:hover .native:checked:not(:disabled){border-color:var(--jl-accent-strong);background:var(--jl-accent-strong)}.thumb{top:calc((var(--track-height) - var(--thumb)) / 2);left:calc((var(--track-height) - var(--thumb)) / 2);width:var(--thumb);height:var(--thumb);background:var(--jl-muted);pointer-events:none;transition:transform var(--jl-fast) var(--jl-ease), background var(--jl-fast) var(--jl-ease);border-radius:50%;position:absolute}.native:checked+.thumb{background:var(--jl-on-accent);transform:translateX(calc(var(--track-width) - var(--track-height)))}.text{align-self:baseline;gap:2px;display:grid}.label:empty,.description:empty{display:none}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:18px}:host([disabled]) .wrap,:host(:disabled) .wrap{cursor:not-allowed;opacity:.5}";
|
|
2
|
+
var jl_switch_default = ":host{vertical-align:middle;--track-width:36px;--track-height:20px;--thumb:14px;display:inline-flex}:host([size=sm]){--track-width:28px;--track-height:16px;--thumb:10px}.wrap{color:var(--jl-text);font-size:var(--jl-font-md);cursor:pointer;align-items:flex-start;gap:10px;line-height:20px;display:inline-flex}:host([size=sm]) .wrap{font-size:var(--jl-font-sm)}.track{width:var(--track-width);height:var(--track-height);margin-top:calc((20px - var(--track-height)) / 2);flex:none;display:inline-flex;position:relative}.native{border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);width:100%;height:100%;cursor:inherit;appearance:none;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), box-shadow var(--jl-fast) var(--jl-ease);margin:0;position:absolute;inset:0}.wrap:hover .native:not(:disabled){border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%)}.native:checked{border-color:var(--jl-accent);background:var(--jl-accent)}.wrap:hover .native:checked:not(:disabled){border-color:var(--jl-accent-strong);background:var(--jl-accent-strong)}.thumb{top:calc((var(--track-height) - var(--thumb)) / 2);left:calc((var(--track-height) - var(--thumb)) / 2);width:var(--thumb);height:var(--thumb);background:var(--jl-muted);pointer-events:none;transition:transform var(--jl-fast) var(--jl-ease), background var(--jl-fast) var(--jl-ease);border-radius:50%;position:absolute}.native:checked+.thumb{background:var(--jl-on-accent);transform:translateX(calc(var(--track-width) - var(--track-height)))}@media (forced-colors:active){.native,.thumb{forced-color-adjust:none}.native{background:canvas;border-color:buttontext}.thumb{background:buttontext}.native:checked{background:highlight;border-color:highlight}.native:checked+.thumb{background:highlighttext}}.text{align-self:baseline;gap:2px;display:grid}.label:empty,.description:empty{display:none}.description{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:18px}:host([disabled]) .wrap,:host(:disabled) .wrap{cursor:not-allowed;opacity:.5}";
|
|
3
3
|
export { jl_switch_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BASE_STYLES, CONTROL_STYLES } from "../styles/shared.js";
|
|
2
2
|
import { JlFormControl } from "../base/jl-form-control.js";
|
|
3
|
-
import { setOrRemove } from "../lib/dom.js";
|
|
3
|
+
import { setAriaFlag, setOrRemove } from "../lib/dom.js";
|
|
4
4
|
import jl_textarea_default from "./jl-textarea.css.js";
|
|
5
5
|
import { css } from "@jadis/core";
|
|
6
6
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
@@ -39,7 +39,7 @@ var JlTextarea = class extends JlFormControl {
|
|
|
39
39
|
/** Draws the field in the danger colour, for an error the page found itself. */
|
|
40
40
|
invalid = this.useChange(false, (value) => {
|
|
41
41
|
this.reflect("invalid", value);
|
|
42
|
-
this._refs.native
|
|
42
|
+
setAriaFlag(this._refs.native, "aria-invalid", value);
|
|
43
43
|
}, { attribute: "invalid" });
|
|
44
44
|
_form = { disabled: false };
|
|
45
45
|
_refs = this.useRefs((ref) => ({
|
|
@@ -26,8 +26,9 @@ export declare abstract class JlFormControl extends JlElement {
|
|
|
26
26
|
/**
|
|
27
27
|
* Submits the form the field belongs to, as Enter in a native field of one line does. The native field inside the
|
|
28
28
|
* shadow root belongs to no form, so the browser's own implicit submission never reaches the page's: each field of
|
|
29
|
-
* one line calls this for an Enter it did not use itself. Nothing during a composition (an IME choosing a word),
|
|
30
|
-
* outside a form; `requestSubmit` checks the form's fields
|
|
29
|
+
* one line calls this for an Enter it did not use itself. Nothing during a composition (an IME choosing a word),
|
|
30
|
+
* outside a form, or when the form's submit button cannot be pressed; `requestSubmit` checks the form's fields
|
|
31
|
+
* first, as a submit button does.
|
|
31
32
|
*/
|
|
32
33
|
protected submitImplicitly(event: KeyboardEvent): void;
|
|
33
34
|
/** Copies the native field's validity, so the form sees the same errors the browser would show. */
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { JlElement } from "./jl-element.js";
|
|
2
2
|
import { formInternals } from "../lib/internals.js";
|
|
3
3
|
// src/base/jl-form-control.ts
|
|
4
|
+
var SUBMIT_BUTTONS = "button:not([type]), button[type=\"submit\"], input[type=\"submit\"], input[type=\"image\"], jl-button[type=\"submit\"]";
|
|
5
|
+
var UNPRESSABLE = ":disabled, [loading]";
|
|
6
|
+
/** The button Enter presses in a form: the first of its submit buttons, as the browser chooses it. */
|
|
7
|
+
var submitButtonOf = (form) => [...form.elements].find((element) => element.matches(SUBMIT_BUTTONS));
|
|
8
|
+
/** A button the browser takes as a submission's submitter: `jl-button` is not one, and submits without. */
|
|
9
|
+
var isNativeSubmitter = (button) => button instanceof HTMLButtonElement || button instanceof HTMLInputElement;
|
|
4
10
|
/**
|
|
5
11
|
* The base of the components a form submits: they take part in `<form>` like native fields (their `name`, their
|
|
6
12
|
* value in `FormData`, `required`, reset, a disabled `<fieldset>`), through the element's internals.
|
|
@@ -36,12 +42,16 @@ var JlFormControl = class extends JlElement {
|
|
|
36
42
|
/**
|
|
37
43
|
* Submits the form the field belongs to, as Enter in a native field of one line does. The native field inside the
|
|
38
44
|
* shadow root belongs to no form, so the browser's own implicit submission never reaches the page's: each field of
|
|
39
|
-
* one line calls this for an Enter it did not use itself. Nothing during a composition (an IME choosing a word),
|
|
40
|
-
* outside a form; `requestSubmit` checks the form's fields
|
|
45
|
+
* one line calls this for an Enter it did not use itself. Nothing during a composition (an IME choosing a word),
|
|
46
|
+
* outside a form, or when the form's submit button cannot be pressed; `requestSubmit` checks the form's fields
|
|
47
|
+
* first, as a submit button does.
|
|
41
48
|
*/
|
|
42
49
|
submitImplicitly(event) {
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
const form = this.internals.form;
|
|
51
|
+
if (event.isComposing || form === null) return;
|
|
52
|
+
const button = submitButtonOf(form);
|
|
53
|
+
if (button?.matches(UNPRESSABLE)) return;
|
|
54
|
+
form.requestSubmit(isNativeSubmitter(button) ? button : void 0);
|
|
45
55
|
}
|
|
46
56
|
/** Copies the native field's validity, so the form sees the same errors the browser would show. */
|
|
47
57
|
mirrorValidity(native) {
|
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,8 @@ export type * from './types/keycaps.types';
|
|
|
66
66
|
export type * from './types/option-filter.types';
|
|
67
67
|
export type * from './types/options.types';
|
|
68
68
|
export type * from './types/pagination.types';
|
|
69
|
-
export type * from './types/
|
|
69
|
+
export type * from './types/press.types';
|
|
70
|
+
export type * from './types/roving.types';
|
|
70
71
|
export type * from './types/sparkline.types';
|
|
71
72
|
export type * from './types/texts.types';
|
|
72
73
|
export * from './atoms/jl-app-icon';
|
package/dist/lib/dom.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/** Sets an attribute, or removes it when the value is empty. */
|
|
2
2
|
export declare function setOrRemove(element: Element, name: string, value: string): void;
|
|
3
|
+
/**
|
|
4
|
+
* Says an ARIA state is on, or removes it: `aria-invalid`, `aria-required`, `aria-disabled`, `aria-busy`. A bare
|
|
5
|
+
* attribute, as `toggleAttribute` writes it (`aria-invalid=""`), is one browsers read as false.
|
|
6
|
+
*/
|
|
7
|
+
export declare function setAriaFlag(element: Element, name: `aria-${string}`, on: boolean): void;
|
|
3
8
|
/** A unique id within the page, for wiring `aria-controls`, `aria-labelledby` and the like inside a shadow root. */
|
|
4
9
|
export declare function uniqueId(prefix: string): string;
|
|
5
10
|
/** An SVG element with its attributes: JSX makes HTML elements only. */
|