@syware/jlib 0.12.0 → 0.13.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 +1 -1
- package/dist/atoms/jl-avatar.css.js +1 -1
- package/dist/atoms/jl-avatar.js +1 -8
- package/dist/atoms/jl-button.css.js +1 -1
- package/dist/atoms/jl-button.js +4 -6
- package/dist/atoms/jl-checkbox.css.js +1 -1
- package/dist/atoms/jl-checkbox.js +8 -10
- package/dist/atoms/jl-chip.css.js +1 -1
- package/dist/atoms/jl-chip.js +3 -11
- package/dist/atoms/jl-divider.css.js +1 -1
- package/dist/atoms/jl-divider.js +1 -5
- package/dist/atoms/jl-icon.css.js +1 -1
- package/dist/atoms/jl-icon.d.ts +2 -0
- package/dist/atoms/jl-icon.js +5 -1
- package/dist/atoms/jl-input.d.ts +7 -2
- package/dist/atoms/jl-input.js +36 -31
- package/dist/atoms/jl-link.css.js +1 -1
- package/dist/atoms/jl-link.js +3 -6
- package/dist/atoms/jl-rating.css.js +1 -1
- package/dist/atoms/jl-rating.d.ts +2 -2
- package/dist/atoms/jl-rating.js +17 -35
- package/dist/atoms/jl-select.d.ts +8 -3
- package/dist/atoms/jl-select.js +26 -13
- package/dist/atoms/jl-skeleton.d.ts +1 -0
- package/dist/atoms/jl-skeleton.js +4 -1
- package/dist/atoms/jl-slider.d.ts +4 -0
- package/dist/atoms/jl-slider.js +29 -15
- package/dist/atoms/jl-switch.css.js +1 -1
- package/dist/atoms/jl-switch.js +2 -8
- package/dist/atoms/jl-textarea.css.js +1 -1
- package/dist/atoms/jl-textarea.d.ts +4 -5
- package/dist/atoms/jl-textarea.js +15 -30
- package/dist/lib/calendar.js +3 -2
- package/dist/lib/floating.d.ts +10 -0
- package/dist/lib/floating.js +27 -8
- package/dist/lib/flow.d.ts +7 -3
- package/dist/lib/flow.js +19 -8
- package/dist/lib/indicator.d.ts +16 -0
- package/dist/lib/indicator.js +32 -6
- package/dist/lib/intl.d.ts +6 -0
- package/dist/lib/intl.js +19 -0
- package/dist/lib/palette.js +1 -6
- package/dist/lib/table.d.ts +14 -2
- package/dist/lib/table.js +50 -39
- package/dist/molecules/jl-accordion-item.css.js +1 -1
- package/dist/molecules/jl-accordion-item.js +1 -5
- package/dist/molecules/jl-account-button.css.js +1 -1
- package/dist/molecules/jl-account-button.js +1 -5
- package/dist/molecules/jl-alert.css.js +1 -1
- package/dist/molecules/jl-alert.d.ts +5 -5
- package/dist/molecules/jl-alert.js +4 -13
- package/dist/molecules/jl-avatar-group.d.ts +7 -5
- package/dist/molecules/jl-avatar-group.js +15 -5
- package/dist/molecules/jl-breadcrumb.d.ts +7 -4
- package/dist/molecules/jl-breadcrumb.js +32 -8
- package/dist/molecules/jl-calendar.d.ts +12 -3
- package/dist/molecules/jl-calendar.js +79 -48
- package/dist/molecules/jl-card.css.js +1 -1
- package/dist/molecules/jl-card.js +2 -8
- package/dist/molecules/jl-chip-group.css.js +1 -1
- package/dist/molecules/jl-chip-group.d.ts +6 -2
- package/dist/molecules/jl-chip-group.js +13 -18
- package/dist/molecules/jl-code-block.css.js +1 -1
- package/dist/molecules/jl-code-block.d.ts +7 -5
- package/dist/molecules/jl-code-block.js +19 -22
- package/dist/molecules/jl-combobox.css.js +1 -1
- package/dist/molecules/jl-combobox.d.ts +4 -0
- package/dist/molecules/jl-combobox.js +33 -19
- package/dist/molecules/jl-date-picker.d.ts +6 -0
- package/dist/molecules/jl-date-picker.js +29 -9
- package/dist/molecules/jl-empty.css.js +1 -1
- package/dist/molecules/jl-empty.js +4 -19
- package/dist/molecules/jl-field.css.js +1 -1
- package/dist/molecules/jl-field.d.ts +7 -1
- package/dist/molecules/jl-field.js +35 -23
- package/dist/molecules/jl-file-drop.css.js +1 -1
- package/dist/molecules/jl-file-drop.js +1 -3
- package/dist/molecules/jl-input-list.css.js +1 -1
- package/dist/molecules/jl-input-list.d.ts +12 -1
- package/dist/molecules/jl-input-list.js +81 -51
- package/dist/molecules/jl-list-item.css.js +1 -1
- package/dist/molecules/jl-list-item.d.ts +3 -1
- package/dist/molecules/jl-list-item.js +26 -27
- package/dist/molecules/jl-load-state.css.js +1 -1
- package/dist/molecules/jl-load-state.d.ts +6 -1
- package/dist/molecules/jl-load-state.js +15 -18
- package/dist/molecules/jl-menu.d.ts +1 -0
- package/dist/molecules/jl-menu.js +9 -2
- package/dist/molecules/jl-pagination.css.js +1 -1
- package/dist/molecules/jl-pagination.d.ts +7 -1
- package/dist/molecules/jl-pagination.js +43 -35
- package/dist/molecules/jl-search.css.js +1 -1
- package/dist/molecules/jl-search.js +4 -12
- package/dist/molecules/jl-segmented.css.js +1 -1
- package/dist/molecules/jl-segmented.d.ts +4 -2
- package/dist/molecules/jl-segmented.js +19 -26
- package/dist/molecules/jl-stat.css.js +1 -1
- package/dist/molecules/jl-stat.js +2 -8
- package/dist/molecules/jl-steps.d.ts +10 -3
- package/dist/molecules/jl-steps.js +82 -49
- package/dist/molecules/jl-tabs.d.ts +5 -2
- package/dist/molecules/jl-tabs.js +31 -25
- package/dist/molecules/jl-tag-input.css.js +1 -1
- package/dist/molecules/jl-tag-input.d.ts +13 -1
- package/dist/molecules/jl-tag-input.js +57 -30
- package/dist/molecules/jl-timeline.css.js +1 -1
- package/dist/molecules/jl-timeline.d.ts +3 -1
- package/dist/molecules/jl-timeline.js +9 -14
- package/dist/molecules/jl-toast.css.js +1 -1
- package/dist/molecules/jl-toast.js +2 -10
- package/dist/molecules/jl-tooltip.d.ts +2 -1
- package/dist/molecules/jl-tooltip.js +11 -15
- package/dist/organisms/jl-command-palette.css.js +1 -1
- package/dist/organisms/jl-command-palette.d.ts +8 -1
- package/dist/organisms/jl-command-palette.js +73 -42
- package/dist/organisms/jl-confirm.css.js +1 -1
- package/dist/organisms/jl-confirm.js +1 -5
- package/dist/organisms/jl-dialog.css.js +1 -1
- package/dist/organisms/jl-dialog.js +1 -5
- package/dist/organisms/jl-drawer.css.js +1 -1
- package/dist/organisms/jl-drawer.js +1 -3
- package/dist/organisms/jl-flow.d.ts +18 -2
- package/dist/organisms/jl-flow.js +128 -44
- package/dist/organisms/jl-navbar.css.js +1 -1
- package/dist/organisms/jl-navbar.d.ts +1 -1
- package/dist/organisms/jl-navbar.js +3 -5
- package/dist/organisms/jl-page-header.css.js +1 -1
- package/dist/organisms/jl-page-header.js +1 -5
- package/dist/organisms/jl-page-outlet.d.ts +4 -3
- package/dist/organisms/jl-page-outlet.js +7 -8
- package/dist/organisms/jl-side-nav.css.js +1 -1
- package/dist/organisms/jl-side-nav.d.ts +9 -2
- package/dist/organisms/jl-side-nav.js +44 -16
- package/dist/organisms/jl-tab-bar.css.js +1 -1
- package/dist/organisms/jl-tab-bar.js +0 -2
- package/dist/organisms/jl-table.css.js +1 -1
- package/dist/organisms/jl-table.d.ts +18 -6
- package/dist/organisms/jl-table.js +91 -57
- package/dist/organisms/jl-tree.css.js +1 -1
- package/dist/organisms/jl-tree.d.ts +22 -2
- package/dist/organisms/jl-tree.js +101 -41
- package/package.json +1 -1
|
@@ -49,8 +49,6 @@ var JlSearch = class extends JlFormControl {
|
|
|
49
49
|
});
|
|
50
50
|
/** Shows a spinner in place of the search icon, while results are on their way. */
|
|
51
51
|
loading = this.useChange(false, (value) => {
|
|
52
|
-
this._refs.icon.hidden = value;
|
|
53
|
-
this._refs.spinner.hidden = !value;
|
|
54
52
|
this._refs.native.toggleAttribute("aria-busy", value);
|
|
55
53
|
this.reflect("loading", value);
|
|
56
54
|
}, { attribute: "loading" });
|
|
@@ -65,10 +63,8 @@ var JlSearch = class extends JlFormControl {
|
|
|
65
63
|
};
|
|
66
64
|
_refs = this.useRefs((ref) => ({
|
|
67
65
|
clear: ref(".clear"),
|
|
68
|
-
icon: ref(".icon"),
|
|
69
66
|
keys: ref(".keys"),
|
|
70
|
-
native: ref("input")
|
|
71
|
-
spinner: ref(JlSpinner)
|
|
67
|
+
native: ref("input")
|
|
72
68
|
}));
|
|
73
69
|
focus(options) {
|
|
74
70
|
this._refs.native.focus(options);
|
|
@@ -95,10 +91,7 @@ var JlSearch = class extends JlFormControl {
|
|
|
95
91
|
class: "icon",
|
|
96
92
|
name: "search",
|
|
97
93
|
size: ICON_SIZE
|
|
98
|
-
}), /* @__PURE__ */ jsx(JlSpinner, {
|
|
99
|
-
size: ICON_SIZE,
|
|
100
|
-
hidden: true
|
|
101
|
-
})]
|
|
94
|
+
}), /* @__PURE__ */ jsx(JlSpinner, { size: ICON_SIZE })]
|
|
102
95
|
}),
|
|
103
96
|
/* @__PURE__ */ jsx("input", {
|
|
104
97
|
class: "native",
|
|
@@ -118,8 +111,7 @@ var JlSearch = class extends JlFormControl {
|
|
|
118
111
|
}),
|
|
119
112
|
/* @__PURE__ */ jsx("span", {
|
|
120
113
|
class: "keys",
|
|
121
|
-
"aria-hidden": "true"
|
|
122
|
-
hidden: true
|
|
114
|
+
"aria-hidden": "true"
|
|
123
115
|
})
|
|
124
116
|
]
|
|
125
117
|
});
|
|
@@ -203,7 +195,7 @@ var JlSearch = class extends JlFormControl {
|
|
|
203
195
|
renderActions() {
|
|
204
196
|
const hasText = this.value.get() !== "";
|
|
205
197
|
this._refs.clear.hidden = !hasText || this._refs.native.disabled;
|
|
206
|
-
this._refs.keys.hidden = hasText
|
|
198
|
+
this._refs.keys.hidden = hasText;
|
|
207
199
|
}
|
|
208
200
|
renderShortcut() {
|
|
209
201
|
const shortcut = parseShortcut(this.shortcut.get());
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-segmented.css?inline
|
|
2
|
-
var jl_segmented_default = ":host{vertical-align:middle;--height:var(--jl-control-md);--pad:12px;--font-size:var(--jl-font-sm);justify-self:start;max-width:100%;display:inline-flex}:host([size=sm]){--height:var(--jl-control-sm);--pad:10px;--font-size:var(--jl-font-xs)}:host([size=lg]){--height:var(--jl-control-lg);--pad:16px;--font-size:var(--jl-font-md)}:host([block]){justify-self:stretch;display:flex}.group{scrollbar-width:none;min-width:0;height:var(--height);border:1px solid var(--jl-line);border-radius:var(--jl-radius-sm);background:var(--jl-surface-2);flex:1;padding:2px;display:flex;position:relative;overflow-x:auto}.segment{z-index:1;min-width:calc(var(--height) - 6px);padding:0 var(--pad);border-radius:calc(var(--jl-radius-sm) - 3px);color:var(--jl-muted);font-size:var(--font-size);white-space:nowrap;cursor:pointer;transition:color var(--jl-fast) var(--jl-ease);background:0 0;border:none;flex:none;justify-content:center;align-items:center;gap:6px;font-weight:600;display:inline-flex;position:relative}.segment:hover:not(:disabled),.segment[aria-checked=true]{color:var(--jl-text)}.badge{border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);min-width:18px;color:var(--jl-muted);font-size:var(--jl-font-xs);text-align:center;padding:0 6px;font-weight:650;line-height:18px}.segment[aria-checked=true] .badge{background:var(--jl-accent-soft);color:var(--jl-accent)}.segment:disabled{cursor:not-allowed;opacity:.45}:host([block]) .segment{flex:1 1 0}.thumb{width:var(--w);height:var(--h);border:1px solid var(--jl-line-strong);border-radius:calc(var(--jl-radius-sm) - 3px);background:var(--lightningcss-light,var(--jl-surface))var(--lightningcss-dark,var(--jl-surface-3));box-shadow:var(--jl-shadow-sm);transform:translate(var(--x), var(--y));pointer-events:none;position:absolute;top:0;left:0}.thumb[data-placed]{transition:transform var(--jl-slow) var(--jl-ease), width var(--jl-slow) var(--jl-ease)}.group[aria-disabled]{opacity:.55}.group[aria-disabled] .segment{opacity:1}.segment:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--jl-brand) 60%, transparent)}";
|
|
2
|
+
var jl_segmented_default = ":host{vertical-align:middle;--height:var(--jl-control-md);--pad:12px;--font-size:var(--jl-font-sm);justify-self:start;max-width:100%;display:inline-flex}:host([size=sm]){--height:var(--jl-control-sm);--pad:10px;--font-size:var(--jl-font-xs)}:host([size=lg]){--height:var(--jl-control-lg);--pad:16px;--font-size:var(--jl-font-md)}:host([block]){justify-self:stretch;display:flex}.group{scrollbar-width:none;min-width:0;height:var(--height);border:1px solid var(--jl-line);border-radius:var(--jl-radius-sm);background:var(--jl-surface-2);flex:1;padding:2px;display:flex;position:relative;overflow-x:auto}.segment{z-index:1;min-width:calc(var(--height) - 6px);padding:0 var(--pad);border-radius:calc(var(--jl-radius-sm) - 3px);color:var(--jl-muted);font-size:var(--font-size);white-space:nowrap;cursor:pointer;transition:color var(--jl-fast) var(--jl-ease);background:0 0;border:none;flex:none;justify-content:center;align-items:center;gap:6px;font-weight:600;display:inline-flex;position:relative}.segment:hover:not(:disabled),.segment[aria-checked=true]{color:var(--jl-text)}.badge{border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);min-width:18px;color:var(--jl-muted);font-size:var(--jl-font-xs);text-align:center;padding:0 6px;font-weight:650;line-height:18px}.segment[aria-checked=true] .badge{background:var(--jl-accent-soft);color:var(--jl-accent)}.segment:disabled{cursor:not-allowed;opacity:.45}:host([block]) .segment{flex:1 1 0}.thumb{width:var(--w);height:var(--h);border:1px solid var(--jl-line-strong);border-radius:calc(var(--jl-radius-sm) - 3px);background:var(--lightningcss-light,var(--jl-surface))var(--lightningcss-dark,var(--jl-surface-3));box-shadow:var(--jl-shadow-sm);transform:translate(var(--x), var(--y));pointer-events:none;position:absolute;top:0;left:0}.thumb[data-placed]{transition:transform var(--jl-slow) var(--jl-ease), width var(--jl-slow) var(--jl-ease)}.group[aria-disabled]{opacity:.55}.group[aria-disabled] .segment{opacity:1}.segment:focus-visible{box-shadow:inset 0 0 0 2px color-mix(in srgb, var(--jl-brand) 60%, transparent)}jl-icon{--icon-size:16px}:host([size=sm]) jl-icon{--icon-size:14px}:host([size=lg]) jl-icon{--icon-size:18px}";
|
|
3
3
|
export { jl_segmented_default as default };
|
|
@@ -39,7 +39,8 @@ export declare class JlSegmented<Value extends string = string> extends JlFormCo
|
|
|
39
39
|
set(setter: string | ((prevState: string) => string)): void;
|
|
40
40
|
}>>;
|
|
41
41
|
private readonly _state;
|
|
42
|
-
private readonly
|
|
42
|
+
private readonly _drawn;
|
|
43
|
+
private readonly _thumb;
|
|
43
44
|
private readonly _refs;
|
|
44
45
|
focus(options?: FocusOptions): void;
|
|
45
46
|
templateHtml(): Node;
|
|
@@ -53,13 +54,14 @@ export declare class JlSegmented<Value extends string = string> extends JlFormCo
|
|
|
53
54
|
private selectedSegment;
|
|
54
55
|
private isDisabled;
|
|
55
56
|
private renderOptions;
|
|
57
|
+
/** The CSS sizes the icons by the control's size (--icon-size): the thumb follows the segments' new widths. */
|
|
58
|
+
private renderIconSize;
|
|
56
59
|
/** A segment; with only an icon, its value names it. */
|
|
57
60
|
private segment;
|
|
58
61
|
/** The chosen option's index: the one `value` names, or else the first that can be chosen. */
|
|
59
62
|
private selectedIndex;
|
|
60
63
|
private renderValue;
|
|
61
64
|
private renderDisabled;
|
|
62
|
-
private placeThumb;
|
|
63
65
|
private onKeydown;
|
|
64
66
|
/** Chooses an option people picked, and says so. */
|
|
65
67
|
private choose;
|
|
@@ -5,17 +5,11 @@ import { CONTROL_SIZES } from "../lib/options.js";
|
|
|
5
5
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
6
6
|
import { setOrRemove } from "../lib/dom.js";
|
|
7
7
|
import { firstIndex, lastIndex, stepIndex } from "../lib/roving.js";
|
|
8
|
-
import {
|
|
9
|
-
import { watchSizes } from "../lib/resize.js";
|
|
8
|
+
import { followTarget } from "../lib/indicator.js";
|
|
10
9
|
import jl_segmented_default from "./jl-segmented.css.js";
|
|
11
10
|
import { css } from "@jadis/core";
|
|
12
11
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
13
12
|
// src/molecules/jl-segmented.tsx
|
|
14
|
-
var ICON_SIZES = {
|
|
15
|
-
lg: 18,
|
|
16
|
-
md: 16,
|
|
17
|
-
sm: 14
|
|
18
|
-
};
|
|
19
13
|
var NO_VALUE = "";
|
|
20
14
|
var KEY_MOVES = /* @__PURE__ */ new Map([
|
|
21
15
|
["ArrowDown", (enabled, from) => stepIndex(enabled, from, 1)],
|
|
@@ -33,7 +27,7 @@ var KEY_MOVES = /* @__PURE__ */ new Map([
|
|
|
33
27
|
var JlSegmented = class extends JlFormControl {
|
|
34
28
|
static selector = "jl-segmented";
|
|
35
29
|
events = this.useEvents();
|
|
36
|
-
options = this.useChange([], () => this.renderOptions(), {
|
|
30
|
+
options = this.useChange([], (value) => this.renderOptions(value), {
|
|
37
31
|
attribute: "options",
|
|
38
32
|
parse: jsonOf([])
|
|
39
33
|
});
|
|
@@ -44,7 +38,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
44
38
|
});
|
|
45
39
|
size = this.useChange("md", (value) => {
|
|
46
40
|
this.reflect("size", value);
|
|
47
|
-
this.
|
|
41
|
+
this.renderIconSize();
|
|
48
42
|
}, {
|
|
49
43
|
attribute: "size",
|
|
50
44
|
parse: oneOf(CONTROL_SIZES, "md")
|
|
@@ -52,7 +46,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
52
46
|
/** Takes the whole width, the options sharing it. */
|
|
53
47
|
block = this.useChange(false, (value) => {
|
|
54
48
|
this.reflect("block", value);
|
|
55
|
-
this.
|
|
49
|
+
this._thumb.place();
|
|
56
50
|
}, { attribute: "block" });
|
|
57
51
|
disabled = this.useChange(false, (value) => {
|
|
58
52
|
this.reflect("disabled", value);
|
|
@@ -61,7 +55,8 @@ var JlSegmented = class extends JlFormControl {
|
|
|
61
55
|
/** The group's name for screen readers, when no visible label names it. */
|
|
62
56
|
label = this.useChange("", (value) => setOrRemove(this._refs.group, "aria-label", value), { attribute: "label" });
|
|
63
57
|
_state = { disabledByForm: false };
|
|
64
|
-
|
|
58
|
+
_drawn = {};
|
|
59
|
+
_thumb = followTarget(() => this._refs.thumb, () => this.selectedSegment());
|
|
65
60
|
_refs = this.useRefs((ref) => ({
|
|
66
61
|
group: ref(".group"),
|
|
67
62
|
thumb: ref(".thumb")
|
|
@@ -85,7 +80,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
85
80
|
return css`${BASE_STYLES}${jl_segmented_default}`;
|
|
86
81
|
}
|
|
87
82
|
onConnect() {
|
|
88
|
-
this.
|
|
83
|
+
this._thumb.watch(this._refs.group);
|
|
89
84
|
this.on(this._refs.group, "click", (event) => {
|
|
90
85
|
const segment = event.target.closest(".segment");
|
|
91
86
|
if (segment !== null) this.choose(this.segments().indexOf(segment), false);
|
|
@@ -93,7 +88,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
93
88
|
this.on(this._refs.group, "keydown", (event) => this.onKeydown(event));
|
|
94
89
|
}
|
|
95
90
|
onDisconnect() {
|
|
96
|
-
this.
|
|
91
|
+
this._thumb.stop();
|
|
97
92
|
}
|
|
98
93
|
resetValue() {
|
|
99
94
|
this.value.set(textOf(NO_VALUE)(this.getAttribute("value")));
|
|
@@ -112,15 +107,19 @@ var JlSegmented = class extends JlFormControl {
|
|
|
112
107
|
isDisabled() {
|
|
113
108
|
return this.disabled.get() || this._state.disabledByForm;
|
|
114
109
|
}
|
|
115
|
-
renderOptions() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this._refs.group.replaceChildren(this._refs.thumb, ...
|
|
110
|
+
renderOptions(options) {
|
|
111
|
+
if (options === this._drawn.options) return;
|
|
112
|
+
this._drawn.options = options;
|
|
113
|
+
this._refs.group.replaceChildren(this._refs.thumb, ...options.map((option) => this.segment(option)));
|
|
119
114
|
this.renderValue();
|
|
120
115
|
this.renderDisabled();
|
|
121
116
|
}
|
|
117
|
+
/** The CSS sizes the icons by the control's size (--icon-size): the thumb follows the segments' new widths. */
|
|
118
|
+
renderIconSize() {
|
|
119
|
+
this._thumb.place();
|
|
120
|
+
}
|
|
122
121
|
/** A segment; with only an icon, its value names it. */
|
|
123
|
-
segment(option
|
|
122
|
+
segment(option) {
|
|
124
123
|
const label = option.label ?? "";
|
|
125
124
|
const name = label === "" ? option.value : void 0;
|
|
126
125
|
return /* @__PURE__ */ jsxs("button", {
|
|
@@ -133,10 +132,7 @@ var JlSegmented = class extends JlFormControl {
|
|
|
133
132
|
"data-value": option.value,
|
|
134
133
|
"data-disabled": option.disabled === true ? "" : void 0,
|
|
135
134
|
children: [
|
|
136
|
-
option.icon === void 0 ? "" : /* @__PURE__ */ jsx(JlIcon, {
|
|
137
|
-
name: option.icon,
|
|
138
|
-
size: iconSize
|
|
139
|
-
}),
|
|
135
|
+
option.icon === void 0 ? "" : /* @__PURE__ */ jsx(JlIcon, { name: option.icon }),
|
|
140
136
|
label === "" ? "" : /* @__PURE__ */ jsx("span", {
|
|
141
137
|
class: "label",
|
|
142
138
|
children: label
|
|
@@ -167,16 +163,13 @@ var JlSegmented = class extends JlFormControl {
|
|
|
167
163
|
segment.tabIndex = checked ? 0 : -1;
|
|
168
164
|
});
|
|
169
165
|
this.internals.setFormValue(value);
|
|
170
|
-
this.
|
|
166
|
+
this._thumb.place();
|
|
171
167
|
}
|
|
172
168
|
renderDisabled() {
|
|
173
169
|
const disabled = this.isDisabled();
|
|
174
170
|
this._refs.group.toggleAttribute("aria-disabled", disabled);
|
|
175
171
|
for (const segment of this.segments()) segment.disabled = disabled || segment.hasAttribute("data-disabled");
|
|
176
172
|
}
|
|
177
|
-
placeThumb() {
|
|
178
|
-
moveIndicator(this._refs.thumb, this.selectedSegment());
|
|
179
|
-
}
|
|
180
173
|
onKeydown(event) {
|
|
181
174
|
const move = KEY_MOVES.get(event.key);
|
|
182
175
|
const segments = this.segments();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-stat.css?inline
|
|
2
|
-
var jl_stat_default = ":host{--mood:var(--jl-muted);display:block}:host([mood=good]){--mood:var(--jl-ok)}:host([mood=bad]){--mood:var(--jl-danger)}.stat{gap:4px;min-width:0;display:grid}.top{align-items:center;gap:8px;display:flex}.label{min-width:0;color:var(--jl-muted);font-size:var(--jl-font-sm);flex:1;font-weight:600;line-height:1.4}.icon{color:var(--jl-faint)}:host([tone=accent]) .icon{color:var(--jl-accent)}:host([tone=ok]) .icon{color:var(--jl-ok)}:host([tone=warn]) .icon{color:var(--jl-warn)}:host([tone=danger]) .icon{color:var(--jl-danger)}:host([tone=info]) .icon{color:var(--jl-info)}.figure{flex-wrap:wrap;align-items:baseline;column-gap:10px;display:flex}.value{color:var(--jl-text);font-size:var(--jl-font-2xl);font-variant-numeric:tabular-nums;letter-spacing:-.02em;font-weight:700;line-height:1.2}.delta{color:var(--mood);font-size:var(--jl-font-sm);font-variant-numeric:tabular-nums;white-space:nowrap;align-items:center;gap:4px;font-weight:650;display:inline-flex}.caption{color:var(--jl-muted);font-size:var(--jl-font-xs);line-height:1.4}.spark{height:36px;margin-top:8px}.spark svg{width:100%;height:100%;display:block;overflow:visible}.line{fill:none;stroke:var(--jl-accent);stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;vector-effect:non-scaling-stroke}.area{fill:color-mix(in srgb, var(--jl-accent) 10%, transparent);stroke:none}";
|
|
2
|
+
var jl_stat_default = ":host{--mood:var(--jl-muted);display:block}:host([mood=good]){--mood:var(--jl-ok)}:host([mood=bad]){--mood:var(--jl-danger)}.stat{gap:4px;min-width:0;display:grid}.top{align-items:center;gap:8px;display:flex}.label{min-width:0;color:var(--jl-muted);font-size:var(--jl-font-sm);flex:1;font-weight:600;line-height:1.4}.icon{color:var(--jl-faint)}:host([tone=accent]) .icon{color:var(--jl-accent)}:host([tone=ok]) .icon{color:var(--jl-ok)}:host([tone=warn]) .icon{color:var(--jl-warn)}:host([tone=danger]) .icon{color:var(--jl-danger)}:host([tone=info]) .icon{color:var(--jl-info)}.figure{flex-wrap:wrap;align-items:baseline;column-gap:10px;display:flex}.value{color:var(--jl-text);font-size:var(--jl-font-2xl);font-variant-numeric:tabular-nums;letter-spacing:-.02em;font-weight:700;line-height:1.2}.delta{color:var(--mood);font-size:var(--jl-font-sm);font-variant-numeric:tabular-nums;white-space:nowrap;align-items:center;gap:4px;font-weight:650;display:inline-flex}.caption:empty,.spark:empty{display:none}.caption{color:var(--jl-muted);font-size:var(--jl-font-xs);line-height:1.4}.spark{height:36px;margin-top:8px}.spark svg{width:100%;height:100%;display:block;overflow:visible}.line{fill:none;stroke:var(--jl-accent);stroke-linecap:round;stroke-linejoin:round;stroke-width:2px;vector-effect:non-scaling-stroke}.area{fill:color-mix(in srgb, var(--jl-accent) 10%, transparent);stroke:none}";
|
|
3
3
|
export { jl_stat_default as default };
|
|
@@ -80,7 +80,6 @@ var JlStat = class extends JlElement {
|
|
|
80
80
|
/** A note under the figure: "vs. last month". */
|
|
81
81
|
caption = this.useChange("", (value) => {
|
|
82
82
|
this._refs.caption.textContent = value;
|
|
83
|
-
this._refs.caption.hidden = value === "";
|
|
84
83
|
}, { attribute: "caption" });
|
|
85
84
|
/** Recent values, oldest first, drawn as a sparkline: `[4, 6, 5, 9, 12]`. */
|
|
86
85
|
points = this.useChange([], () => this.renderSparkline(), {
|
|
@@ -121,14 +120,10 @@ var JlStat = class extends JlElement {
|
|
|
121
120
|
}), /* @__PURE__ */ jsx("span", { class: "delta-text" })]
|
|
122
121
|
})]
|
|
123
122
|
}),
|
|
124
|
-
/* @__PURE__ */ jsx("p", {
|
|
125
|
-
class: "caption",
|
|
126
|
-
hidden: true
|
|
127
|
-
}),
|
|
123
|
+
/* @__PURE__ */ jsx("p", { class: "caption" }),
|
|
128
124
|
/* @__PURE__ */ jsx("div", {
|
|
129
125
|
class: "spark",
|
|
130
|
-
"aria-hidden": "true"
|
|
131
|
-
hidden: true
|
|
126
|
+
"aria-hidden": "true"
|
|
132
127
|
})
|
|
133
128
|
]
|
|
134
129
|
});
|
|
@@ -153,7 +148,6 @@ var JlStat = class extends JlElement {
|
|
|
153
148
|
const values = this.points.get();
|
|
154
149
|
const points = sparklinePoints(isNumberList(values) ? values : [], SPARK_BOX);
|
|
155
150
|
const spark = this._refs.spark;
|
|
156
|
-
spark.hidden = points.length === 0;
|
|
157
151
|
if (points.length === 0) {
|
|
158
152
|
spark.replaceChildren();
|
|
159
153
|
return;
|
|
@@ -33,16 +33,23 @@ export declare class JlSteps extends JlElement {
|
|
|
33
33
|
get(): string;
|
|
34
34
|
set(setter: string | ((prevState: string) => string)): void;
|
|
35
35
|
}>>;
|
|
36
|
+
private readonly _drawn;
|
|
36
37
|
private readonly _refs;
|
|
37
38
|
templateHtml(): Node;
|
|
38
39
|
templateCss(): string;
|
|
39
40
|
onConnect(): void;
|
|
40
41
|
protected drawTexts(): void;
|
|
41
42
|
private renderLabel;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
private markerOf;
|
|
43
|
+
/** Makes a step for each item; where people are in them is drawn on them after. */
|
|
44
|
+
private renderItems;
|
|
45
45
|
private step;
|
|
46
|
+
/** Where each step stands against the current one, drawn on the steps there are. */
|
|
47
|
+
private renderStatuses;
|
|
48
|
+
private renderStatus;
|
|
49
|
+
/** A done step that people can go back to is a button; any other step a plain block, its content moved over. */
|
|
50
|
+
private renderHead;
|
|
51
|
+
/** A failed step's ×, a done one's check, or the step's number: an icon is made only for the steps that show one. */
|
|
52
|
+
private renderMarker;
|
|
46
53
|
/** Goes back to a done step people picked, and says so. */
|
|
47
54
|
private goBackTo;
|
|
48
55
|
}
|
|
@@ -4,6 +4,7 @@ import { JlElement } from "../base/jl-element.js";
|
|
|
4
4
|
import { clampedNumber, jsonOf, oneOf } from "../lib/attributes.js";
|
|
5
5
|
import { registerIcons } from "../lib/icons.js";
|
|
6
6
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
7
|
+
import { setOrRemove } from "../lib/dom.js";
|
|
7
8
|
import jl_steps_default from "./jl-steps.css.js";
|
|
8
9
|
import { css } from "@jadis/core";
|
|
9
10
|
import { Check, X } from "lucide";
|
|
@@ -25,6 +26,11 @@ var statusText = (status) => {
|
|
|
25
26
|
const key = STATUS_TEXTS[status];
|
|
26
27
|
return key === null ? "" : jlText(key);
|
|
27
28
|
};
|
|
29
|
+
/** The icon a step's marker shows: none for its number. */
|
|
30
|
+
var markerIcon = (item, status) => {
|
|
31
|
+
if (item.failed) return "x";
|
|
32
|
+
return status === "done" ? "check" : "";
|
|
33
|
+
};
|
|
28
34
|
var statusOf = (index, current) => {
|
|
29
35
|
if (index < current) return "done";
|
|
30
36
|
return index === current ? "current" : "upcoming";
|
|
@@ -36,12 +42,12 @@ var statusOf = (index, current) => {
|
|
|
36
42
|
var JlSteps = class extends JlElement {
|
|
37
43
|
static selector = "jl-steps";
|
|
38
44
|
events = this.useEvents();
|
|
39
|
-
items = this.useChange([], () => this.
|
|
45
|
+
items = this.useChange([], (value) => this.renderItems(value), {
|
|
40
46
|
attribute: "items",
|
|
41
47
|
parse: jsonOf([])
|
|
42
48
|
});
|
|
43
49
|
/** The index of the current step, from 0; the number of steps when all are done. */
|
|
44
|
-
current = this.useChange(0, () => this.
|
|
50
|
+
current = this.useChange(0, () => this.renderStatuses(), {
|
|
45
51
|
attribute: "current",
|
|
46
52
|
parse: clampedNumber(0, 0, MAX_STEPS)
|
|
47
53
|
});
|
|
@@ -50,9 +56,10 @@ var JlSteps = class extends JlElement {
|
|
|
50
56
|
parse: oneOf(STEPS_ORIENTATIONS, "horizontal")
|
|
51
57
|
});
|
|
52
58
|
/** Done steps become buttons that go back to them. */
|
|
53
|
-
clickable = this.useChange(false, () => this.
|
|
59
|
+
clickable = this.useChange(false, () => this.renderStatuses(), { attribute: "clickable" });
|
|
54
60
|
/** The list's name for screen readers. */
|
|
55
61
|
label = this.useChange("", () => this.renderLabel(), { attribute: "label" });
|
|
62
|
+
_drawn = {};
|
|
56
63
|
_refs = this.useRefs((ref) => ({ list: ref("ol") }));
|
|
57
64
|
templateHtml() {
|
|
58
65
|
return /* @__PURE__ */ jsx("ol", { attrs: { part: "base" } });
|
|
@@ -62,71 +69,97 @@ var JlSteps = class extends JlElement {
|
|
|
62
69
|
}
|
|
63
70
|
onConnect() {
|
|
64
71
|
this.on(this._refs.list, "click", (event) => {
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
72
|
+
const step = event.target.closest("button.head")?.parentElement;
|
|
73
|
+
if (step instanceof HTMLElement) this.goBackTo([...this._refs.list.children].indexOf(step));
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
76
|
drawTexts() {
|
|
70
77
|
this.renderLabel();
|
|
71
|
-
this.
|
|
78
|
+
this.renderStatuses();
|
|
72
79
|
}
|
|
73
80
|
renderLabel() {
|
|
74
81
|
this._refs.list.setAttribute("aria-label", this.label.get() || jlText("progress"));
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
/** Makes a step for each item; where people are in them is drawn on them after. */
|
|
84
|
+
renderItems(items) {
|
|
85
|
+
if (items === this._drawn.items) return;
|
|
86
|
+
this._drawn.items = items;
|
|
87
|
+
this._refs.list.replaceChildren(...items.map((item) => this.step(item)));
|
|
88
|
+
this.renderStatuses();
|
|
79
89
|
}
|
|
80
|
-
|
|
81
|
-
markerOf(item, index, status) {
|
|
82
|
-
if (item.failed) return /* @__PURE__ */ jsx(JlIcon, {
|
|
83
|
-
name: "x",
|
|
84
|
-
size: CHECK_SIZE
|
|
85
|
-
});
|
|
86
|
-
return status === "done" ? /* @__PURE__ */ jsx(JlIcon, {
|
|
87
|
-
name: "check",
|
|
88
|
-
size: CHECK_SIZE
|
|
89
|
-
}) : String(index + 1);
|
|
90
|
-
}
|
|
91
|
-
step(item, index, status) {
|
|
92
|
-
const content = [/* @__PURE__ */ jsx("span", {
|
|
93
|
-
class: "marker",
|
|
94
|
-
"aria-hidden": "true",
|
|
95
|
-
children: this.markerOf(item, index, status)
|
|
96
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
97
|
-
class: "text",
|
|
98
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
99
|
-
class: "label",
|
|
100
|
-
children: [item.label, /* @__PURE__ */ jsx("span", {
|
|
101
|
-
class: "sr-only",
|
|
102
|
-
children: item.failed ? jlText("failedStep") : statusText(status)
|
|
103
|
-
})]
|
|
104
|
-
}), item.description === void 0 ? "" : /* @__PURE__ */ jsx("span", {
|
|
105
|
-
class: "description",
|
|
106
|
-
children: item.description
|
|
107
|
-
})]
|
|
108
|
-
})];
|
|
109
|
-
const canGoBack = status === "done" && this.clickable.get();
|
|
90
|
+
step(item) {
|
|
110
91
|
return /* @__PURE__ */ jsxs("li", {
|
|
111
92
|
class: "step",
|
|
112
|
-
"data-status": status,
|
|
113
93
|
"data-failed": item.failed ? "" : void 0,
|
|
114
|
-
|
|
115
|
-
children: [canGoBack ? /* @__PURE__ */ jsx("button", {
|
|
116
|
-
type: "button",
|
|
117
|
-
class: "head",
|
|
118
|
-
"data-index": index,
|
|
119
|
-
children: content
|
|
120
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
94
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
121
95
|
class: "head",
|
|
122
|
-
|
|
123
|
-
|
|
96
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
97
|
+
class: "marker",
|
|
98
|
+
"aria-hidden": "true"
|
|
99
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
100
|
+
class: "text",
|
|
101
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
102
|
+
class: "label",
|
|
103
|
+
children: [item.label, /* @__PURE__ */ jsx("span", { class: "status sr-only" })]
|
|
104
|
+
}), item.description === void 0 ? "" : /* @__PURE__ */ jsx("span", {
|
|
105
|
+
class: "description",
|
|
106
|
+
children: item.description
|
|
107
|
+
})]
|
|
108
|
+
})]
|
|
124
109
|
}), /* @__PURE__ */ jsx("span", {
|
|
125
110
|
class: "line",
|
|
126
111
|
"aria-hidden": "true"
|
|
127
112
|
})]
|
|
128
113
|
});
|
|
129
114
|
}
|
|
115
|
+
/** Where each step stands against the current one, drawn on the steps there are. */
|
|
116
|
+
renderStatuses() {
|
|
117
|
+
const current = this.current.get();
|
|
118
|
+
const items = this.items.get();
|
|
119
|
+
this._refs.list.querySelectorAll(".step").forEach((step, index) => {
|
|
120
|
+
const item = items[index];
|
|
121
|
+
if (item !== void 0) this.renderStatus(step, item, index, statusOf(index, current));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
renderStatus(step, item, index, status) {
|
|
125
|
+
step.dataset.status = status;
|
|
126
|
+
setOrRemove(step, "aria-current", status === "current" ? "step" : "");
|
|
127
|
+
const head = this.renderHead(step, status === "done" && this.clickable.get());
|
|
128
|
+
setOrRemove(head, "tabindex", status === "current" ? "-1" : "");
|
|
129
|
+
this.renderMarker(head.querySelector(".marker"), item, index, status);
|
|
130
|
+
const said = head.querySelector(".status");
|
|
131
|
+
said.textContent = item.failed ? jlText("failedStep") : statusText(status);
|
|
132
|
+
}
|
|
133
|
+
/** A done step that people can go back to is a button; any other step a plain block, its content moved over. */
|
|
134
|
+
renderHead(step, canGoBack) {
|
|
135
|
+
const head = step.querySelector(".head");
|
|
136
|
+
const tag = canGoBack ? "button" : "div";
|
|
137
|
+
if (head.localName === tag) return head;
|
|
138
|
+
const swapped = canGoBack ? /* @__PURE__ */ jsx("button", {
|
|
139
|
+
type: "button",
|
|
140
|
+
class: "head"
|
|
141
|
+
}) : /* @__PURE__ */ jsx("div", { class: "head" });
|
|
142
|
+
swapped.append(...head.childNodes);
|
|
143
|
+
head.replaceWith(swapped);
|
|
144
|
+
return swapped;
|
|
145
|
+
}
|
|
146
|
+
/** A failed step's ×, a done one's check, or the step's number: an icon is made only for the steps that show one. */
|
|
147
|
+
renderMarker(marker, item, index, status) {
|
|
148
|
+
const name = markerIcon(item, status);
|
|
149
|
+
if (name === "") {
|
|
150
|
+
marker.textContent = String(index + 1);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const icon = marker.querySelector(JlIcon.selector);
|
|
154
|
+
if (icon !== null) {
|
|
155
|
+
icon.name.set(name);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
marker.replaceChildren(/* @__PURE__ */ jsx(JlIcon, {
|
|
159
|
+
name,
|
|
160
|
+
size: CHECK_SIZE
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
130
163
|
/** Goes back to a done step people picked, and says so. */
|
|
131
164
|
goBackTo(index) {
|
|
132
165
|
if (index >= this.current.get()) return;
|
|
@@ -28,7 +28,9 @@ export declare class JlTabs extends JlElement {
|
|
|
28
28
|
get(): string;
|
|
29
29
|
set(setter: string | ((prevState: string) => string)): void;
|
|
30
30
|
}>>;
|
|
31
|
-
private readonly
|
|
31
|
+
private readonly _mutations;
|
|
32
|
+
private readonly _indicator;
|
|
33
|
+
private readonly _shown;
|
|
32
34
|
private readonly _refs;
|
|
33
35
|
templateHtml(): Node;
|
|
34
36
|
templateCss(): string;
|
|
@@ -44,7 +46,8 @@ export declare class JlTabs extends JlElement {
|
|
|
44
46
|
/** Adds or removes tab buttons to match the panels; the buttons left keep their focus. */
|
|
45
47
|
private syncTabCount;
|
|
46
48
|
private renderTab;
|
|
47
|
-
|
|
49
|
+
/** The panel's icon, label and badge on its tab, made again only when one of them changed. */
|
|
50
|
+
private renderTabContent;
|
|
48
51
|
private onKeydown;
|
|
49
52
|
/** Opens the panel of a tab people picked, and says so. */
|
|
50
53
|
private choose;
|
|
@@ -5,8 +5,7 @@ import { define } from "../lib/define.js";
|
|
|
5
5
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
6
6
|
import { setOrRemove, uniqueId } from "../lib/dom.js";
|
|
7
7
|
import { firstIndex, lastIndex, stepIndex } from "../lib/roving.js";
|
|
8
|
-
import {
|
|
9
|
-
import { watchSizes } from "../lib/resize.js";
|
|
8
|
+
import { followTarget } from "../lib/indicator.js";
|
|
10
9
|
import { JlTabPanel } from "./jl-tab-panel.js";
|
|
11
10
|
import jl_tabs_default from "./jl-tabs.css.js";
|
|
12
11
|
import { css } from "@jadis/core";
|
|
@@ -42,7 +41,7 @@ var JlTabs = class extends JlElement {
|
|
|
42
41
|
value = this.useChange("", () => this.render(), { attribute: "value" });
|
|
43
42
|
variant = this.useChange("line", (value) => {
|
|
44
43
|
this.reflect("variant", value);
|
|
45
|
-
this.
|
|
44
|
+
this._indicator.place();
|
|
46
45
|
}, {
|
|
47
46
|
attribute: "variant",
|
|
48
47
|
parse: oneOf(TAB_VARIANTS, "line")
|
|
@@ -50,14 +49,13 @@ var JlTabs = class extends JlElement {
|
|
|
50
49
|
/** The tabs share the whole width. */
|
|
51
50
|
block = this.useChange(false, (value) => {
|
|
52
51
|
this.reflect("block", value);
|
|
53
|
-
this.
|
|
52
|
+
this._indicator.place();
|
|
54
53
|
}, { attribute: "block" });
|
|
55
54
|
/** The tab list's name for screen readers, when the page has no heading that says it. */
|
|
56
55
|
label = this.useChange("", (value) => setOrRemove(this._refs.list, "aria-label", value), { attribute: "label" });
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
56
|
+
_mutations = new MutationObserver((records) => this.onMutations(records));
|
|
57
|
+
_indicator = followTarget(() => this._refs.indicator, () => this.tabs().find((tab) => tab.getAttribute("aria-selected") === "true") ?? null);
|
|
58
|
+
_shown = /* @__PURE__ */ new WeakMap();
|
|
61
59
|
_refs = this.useRefs((ref) => ({
|
|
62
60
|
indicator: ref(".indicator"),
|
|
63
61
|
list: ref(".list")
|
|
@@ -87,13 +85,13 @@ var JlTabs = class extends JlElement {
|
|
|
87
85
|
}
|
|
88
86
|
onConnect() {
|
|
89
87
|
this.render();
|
|
90
|
-
this.
|
|
88
|
+
this._mutations.observe(this, {
|
|
91
89
|
attributeFilter: PANEL_ATTRIBUTES,
|
|
92
90
|
attributes: true,
|
|
93
91
|
childList: true,
|
|
94
92
|
subtree: true
|
|
95
93
|
});
|
|
96
|
-
this.
|
|
94
|
+
this._indicator.watch(this._refs.list);
|
|
97
95
|
this.on(this._refs.list, "click", (event) => {
|
|
98
96
|
const tab = event.target.closest("[role=\"tab\"]");
|
|
99
97
|
if (tab !== null) this.choose(this.tabs().indexOf(tab), false);
|
|
@@ -101,8 +99,8 @@ var JlTabs = class extends JlElement {
|
|
|
101
99
|
this.on(this._refs.list, "keydown", (event) => this.onKeydown(event));
|
|
102
100
|
}
|
|
103
101
|
onDisconnect() {
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
102
|
+
this._mutations.disconnect();
|
|
103
|
+
this._indicator.stop();
|
|
106
104
|
}
|
|
107
105
|
panels() {
|
|
108
106
|
return [...this.children].filter(isPanel);
|
|
@@ -129,7 +127,7 @@ var JlTabs = class extends JlElement {
|
|
|
129
127
|
const tab = tabs[index];
|
|
130
128
|
if (tab !== void 0) this.renderTab(tab, panel, index === selected);
|
|
131
129
|
});
|
|
132
|
-
this.
|
|
130
|
+
this._indicator.place();
|
|
133
131
|
}
|
|
134
132
|
/** Adds or removes tab buttons to match the panels; the buttons left keep their focus. */
|
|
135
133
|
syncTabCount(count) {
|
|
@@ -143,29 +141,37 @@ var JlTabs = class extends JlElement {
|
|
|
143
141
|
}));
|
|
144
142
|
}
|
|
145
143
|
renderTab(tab, panel, selected) {
|
|
144
|
+
this.renderTabContent(tab, panel);
|
|
145
|
+
tab.setAttribute("aria-selected", String(selected));
|
|
146
|
+
tab.tabIndex = selected ? 0 : -1;
|
|
147
|
+
tab.toggleAttribute("aria-disabled", isDisabled(panel));
|
|
148
|
+
if (panel.id === "") panel.id = uniqueId("jl-tab-panel");
|
|
149
|
+
tab.ariaControlsElements = [panel];
|
|
150
|
+
panel.toggleAttribute("selected", selected);
|
|
151
|
+
panel.tabIndex = 0;
|
|
152
|
+
}
|
|
153
|
+
/** The panel's icon, label and badge on its tab, made again only when one of them changed. */
|
|
154
|
+
renderTabContent(tab, panel) {
|
|
146
155
|
const icon = panel.getAttribute("icon") ?? "";
|
|
156
|
+
const label = panel.getAttribute("label") ?? "";
|
|
147
157
|
const badge = panel.getAttribute("badge") ?? "";
|
|
158
|
+
const shown = JSON.stringify([
|
|
159
|
+
icon,
|
|
160
|
+
label,
|
|
161
|
+
badge
|
|
162
|
+
]);
|
|
163
|
+
if (this._shown.get(tab) === shown) return;
|
|
164
|
+
this._shown.set(tab, shown);
|
|
148
165
|
tab.replaceChildren(icon === "" ? "" : /* @__PURE__ */ jsx(JlIcon, {
|
|
149
166
|
name: icon,
|
|
150
167
|
size: ICON_SIZE
|
|
151
168
|
}), /* @__PURE__ */ jsx("span", {
|
|
152
169
|
class: "label",
|
|
153
|
-
children:
|
|
170
|
+
children: label
|
|
154
171
|
}), badge === "" ? "" : /* @__PURE__ */ jsx("span", {
|
|
155
172
|
class: "badge",
|
|
156
173
|
children: badge
|
|
157
174
|
}));
|
|
158
|
-
tab.setAttribute("aria-selected", String(selected));
|
|
159
|
-
tab.tabIndex = selected ? 0 : -1;
|
|
160
|
-
tab.toggleAttribute("aria-disabled", isDisabled(panel));
|
|
161
|
-
if (panel.id === "") panel.id = uniqueId("jl-tab-panel");
|
|
162
|
-
tab.ariaControlsElements = [panel];
|
|
163
|
-
panel.toggleAttribute("selected", selected);
|
|
164
|
-
panel.tabIndex = 0;
|
|
165
|
-
}
|
|
166
|
-
placeIndicator() {
|
|
167
|
-
const selected = this.tabs().find((tab) => tab.getAttribute("aria-selected") === "true") ?? null;
|
|
168
|
-
moveIndicator(this._refs.indicator, selected);
|
|
169
175
|
}
|
|
170
176
|
onKeydown(event) {
|
|
171
177
|
const move = KEY_MOVES.get(event.key);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-tag-input.css?inline
|
|
2
|
-
var jl_tag_input_default = ":host{--chip-height:calc(var(--height,var(--jl-control-md)) - 12px);min-width:0;display:block}.control{cursor:text;flex-wrap:wrap;gap:4px;padding:4px 6px}.tags{margin:0;padding:0;list-style:none;display:contents}.tag{max-width:100%;height:var(--chip-height);border:1px solid var(--jl-line);border-radius:var(--jl-radius-xs);background:var(--jl-surface-2);color:var(--jl-text);font-size:var(--jl-font-sm);cursor:default;align-items:center;gap:2px;padding:0 3px 0 8px;line-height:1;display:inline-flex}:host([size=sm]) .tag{font-size:var(--jl-font-xs);padding-left:6px}.tag.flash{animation:flash .6s var(--jl-ease)}.tag-text{text-overflow:ellipsis;white-space:nowrap;line-height:1.4;overflow:hidden}.tag-remove{width:18px;height:18px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.tag-remove:hover,.tag-remove:focus-visible{background:var(--jl-surface-3);color:var(--jl-text)}.native{height:calc(var(--height,var(--jl-control-md)) - 10px);flex:1 0 80px;padding-left:6px}:host([disabled]) .tag{color:var(--jl-muted);padding-right:8px}.popup{min-width:180px;padding:4px}.listbox{max-height:240px;margin:0;padding:0;list-style:none;position:relative;overflow-y:auto}.option{border-radius:var(--jl-radius-xs);color:var(--jl-text);font-size:var(--jl-font-md);white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;padding:6px 10px;line-height:1.4}.option
|
|
2
|
+
var jl_tag_input_default = ":host{--chip-height:calc(var(--height,var(--jl-control-md)) - 12px);min-width:0;display:block}.control{cursor:text;flex-wrap:wrap;gap:4px;padding:4px 6px}.tags{margin:0;padding:0;list-style:none;display:contents}.tag{max-width:100%;height:var(--chip-height);border:1px solid var(--jl-line);border-radius:var(--jl-radius-xs);background:var(--jl-surface-2);color:var(--jl-text);font-size:var(--jl-font-sm);cursor:default;align-items:center;gap:2px;padding:0 3px 0 8px;line-height:1;display:inline-flex}:host([size=sm]) .tag{font-size:var(--jl-font-xs);padding-left:6px}.tag.flash{animation:flash .6s var(--jl-ease)}.tag-text{text-overflow:ellipsis;white-space:nowrap;line-height:1.4;overflow:hidden}.tag-remove{width:18px;height:18px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.tag-remove:hover,.tag-remove:focus-visible{background:var(--jl-surface-3);color:var(--jl-text)}.native{height:calc(var(--height,var(--jl-control-md)) - 10px);flex:1 0 80px;padding-left:6px}:host([disabled]) .tag{color:var(--jl-muted);padding-right:8px}:host([disabled]) .tag-remove{display:none}.popup{min-width:180px;padding:4px}.listbox{max-height:240px;margin:0;padding:0;list-style:none;position:relative;overflow-y:auto}.option{border-radius:var(--jl-radius-xs);color:var(--jl-text);font-size:var(--jl-font-md);white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;padding:6px 10px;line-height:1.4}.option[aria-selected=true],.option:hover{background:var(--jl-surface-3)}mark{color:var(--jl-accent);background:0 0;font-weight:700}@keyframes flash{30%{border-color:var(--jl-accent-line);background:var(--jl-accent-soft);color:var(--jl-accent-strong)}}";
|
|
3
3
|
export { jl_tag_input_default as default };
|
|
@@ -94,7 +94,19 @@ export declare class JlTagInput extends JlFormControl {
|
|
|
94
94
|
private pick;
|
|
95
95
|
/** The field is a combobox only when it offers suggestions. */
|
|
96
96
|
private renderSuggestionRole;
|
|
97
|
-
private
|
|
97
|
+
private renderValue;
|
|
98
|
+
/**
|
|
99
|
+
* Makes the chips match the tags: those of tags taken out go, a chip is made for each tag added, and the others stay
|
|
100
|
+
* as they are, so adding or removing a tag makes or removes one chip.
|
|
101
|
+
*/
|
|
102
|
+
private renderChips;
|
|
103
|
+
/** A chip, its remove button hidden by the CSS while the field is disabled. */
|
|
104
|
+
private chip;
|
|
105
|
+
private nameRemoveButton;
|
|
106
|
+
private chips;
|
|
107
|
+
/** The place of the chip an element is in. */
|
|
108
|
+
private chipIndex;
|
|
109
|
+
private renderFull;
|
|
98
110
|
/** The placeholder shows while there is no tag; chips take its place. */
|
|
99
111
|
private renderPlaceholder;
|
|
100
112
|
/** Each tag is its own entry under the field's name, as several checked boxes of one name would be. */
|