@syware/jlib 0.12.1 → 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/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 +16 -13
- package/dist/organisms/jl-tree.js +72 -70
- package/package.json +1 -1
|
@@ -64,6 +64,7 @@ export declare class JlCombobox extends JlFormControl {
|
|
|
64
64
|
}>>;
|
|
65
65
|
private readonly _listId;
|
|
66
66
|
private readonly _state;
|
|
67
|
+
private readonly _items;
|
|
67
68
|
private readonly _refs;
|
|
68
69
|
focus(options?: FocusOptions): void;
|
|
69
70
|
templateHtml(): Node;
|
|
@@ -108,7 +109,10 @@ export declare class JlCombobox extends JlFormControl {
|
|
|
108
109
|
private clearValue;
|
|
109
110
|
/** New options: the field may now show the value's label, and an open list (or one being typed in) refreshes. */
|
|
110
111
|
private renderOptionsChange;
|
|
112
|
+
/** The options that match what was typed, in their order: elements already made are moved, not made again. */
|
|
111
113
|
private renderOptions;
|
|
114
|
+
/** The option's element, made once, with where it now sits, whether it is chosen, and the typed text marked. */
|
|
115
|
+
private drawOption;
|
|
112
116
|
private optionNode;
|
|
113
117
|
/** The active option is the one the arrows reached: aria-selected and aria-activedescendant follow it. */
|
|
114
118
|
private renderActive;
|
|
@@ -75,11 +75,14 @@ var JlCombobox = class extends JlFormControl {
|
|
|
75
75
|
_listId = uniqueId("jl-combobox-list");
|
|
76
76
|
_state = {
|
|
77
77
|
active: NONE,
|
|
78
|
+
/** The option element the arrows reached: it alone is marked, wherever the filter put it. */
|
|
79
|
+
activeItem: null,
|
|
78
80
|
matches: [],
|
|
79
81
|
opening: new AbortController(),
|
|
80
82
|
/** What people typed since the last choice; empty shows every option. */
|
|
81
83
|
query: ""
|
|
82
84
|
};
|
|
85
|
+
_items = /* @__PURE__ */ new WeakMap();
|
|
83
86
|
_refs = this.useRefs((ref) => ({
|
|
84
87
|
clear: ref(".clear"),
|
|
85
88
|
control: ref(".control"),
|
|
@@ -379,28 +382,40 @@ var JlCombobox = class extends JlFormControl {
|
|
|
379
382
|
const typing = this._state.query !== "";
|
|
380
383
|
if (this.isOpen() || typing && this.matches(":focus-within")) this.openList(typing);
|
|
381
384
|
}
|
|
385
|
+
/** The options that match what was typed, in their order: elements already made are moved, not made again. */
|
|
382
386
|
renderOptions() {
|
|
383
387
|
const matches = filterOptions(this.options.get(), this._state.query);
|
|
384
388
|
const value = this.value.get();
|
|
389
|
+
const listbox = this._refs.listbox;
|
|
385
390
|
this._state.matches = matches;
|
|
386
|
-
|
|
387
|
-
|
|
391
|
+
matches.forEach((option, index) => {
|
|
392
|
+
const item = this.drawOption(option, index, value);
|
|
393
|
+
const current = listbox.children.item(index);
|
|
394
|
+
if (current !== item) listbox.insertBefore(item, current);
|
|
395
|
+
});
|
|
396
|
+
while (listbox.children.length > matches.length) listbox.lastElementChild?.remove();
|
|
397
|
+
listbox.hidden = matches.length === 0;
|
|
388
398
|
this._refs.empty.hidden = matches.length > 0;
|
|
389
399
|
}
|
|
390
|
-
|
|
400
|
+
/** The option's element, made once, with where it now sits, whether it is chosen, and the typed text marked. */
|
|
401
|
+
drawOption(option, index, value) {
|
|
402
|
+
const item = this._items.get(option) ?? this.optionNode(option);
|
|
403
|
+
this._items.set(option, item);
|
|
404
|
+
item.id = `${this._listId}-${index}`;
|
|
405
|
+
item.dataset.index = String(index);
|
|
406
|
+
item.classList.toggle("chosen", option.value === value);
|
|
407
|
+
item.querySelector(".option-label")?.replaceChildren(...highlighted(option.label, this._state.query));
|
|
408
|
+
return item;
|
|
409
|
+
}
|
|
410
|
+
optionNode(option) {
|
|
391
411
|
return /* @__PURE__ */ jsxs("div", {
|
|
392
|
-
class:
|
|
412
|
+
class: "option",
|
|
393
413
|
role: "option",
|
|
394
|
-
id: `${this._listId}-${index}`,
|
|
395
|
-
"data-index": String(index),
|
|
396
414
|
"aria-selected": "false",
|
|
397
415
|
"aria-disabled": option.disabled === true ? "true" : void 0,
|
|
398
416
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
399
417
|
class: "text",
|
|
400
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
401
|
-
class: "option-label",
|
|
402
|
-
children: highlighted(option.label, this._state.query)
|
|
403
|
-
}), option.description === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
418
|
+
children: [/* @__PURE__ */ jsx("span", { class: "option-label" }), option.description === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
404
419
|
class: "description",
|
|
405
420
|
children: option.description
|
|
406
421
|
})]
|
|
@@ -413,17 +428,16 @@ var JlCombobox = class extends JlFormControl {
|
|
|
413
428
|
}
|
|
414
429
|
/** The active option is the one the arrows reached: aria-selected and aria-activedescendant follow it. */
|
|
415
430
|
renderActive() {
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
setOrRemove(this._refs.native, "aria-activedescendant", active === NONE ? "" : `${this._listId}-${active}`);
|
|
431
|
+
const option = this._state.matches[this._state.active];
|
|
432
|
+
const item = option === void 0 ? null : this._items.get(option) ?? null;
|
|
433
|
+
this._state.activeItem?.setAttribute("aria-selected", "false");
|
|
434
|
+
item?.setAttribute("aria-selected", "true");
|
|
435
|
+
this._state.activeItem = item;
|
|
436
|
+
setOrRemove(this._refs.native, "aria-activedescendant", item?.id ?? "");
|
|
423
437
|
}
|
|
424
438
|
revealActive() {
|
|
425
|
-
const item = this.
|
|
426
|
-
if (item
|
|
439
|
+
const item = this._state.activeItem;
|
|
440
|
+
if (item !== null) keepInView(this._refs.listbox, item);
|
|
427
441
|
}
|
|
428
442
|
/** The label of the value's option (or the value itself, as free text), unless people are typing. */
|
|
429
443
|
renderValue() {
|
|
@@ -92,6 +92,12 @@ export declare class JlDatePicker extends JlFormControl {
|
|
|
92
92
|
/** Escape closes the calendar and brings the focus back to the field, where it came from. */
|
|
93
93
|
private onPopupKey;
|
|
94
94
|
private onPick;
|
|
95
|
+
/**
|
|
96
|
+
* The calendar, made the first time the popup opens with the field's language, week, bounds and value: a closed
|
|
97
|
+
* picker draws no month, and a form may hold many pickers.
|
|
98
|
+
*/
|
|
99
|
+
private calendar;
|
|
100
|
+
private shownCalendar;
|
|
95
101
|
private openPopup;
|
|
96
102
|
private closePopup;
|
|
97
103
|
/**
|
|
@@ -47,12 +47,12 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
47
47
|
max = this.useChange("", (value) => this.renderBound("max", value), { attribute: "max" });
|
|
48
48
|
/** The language the date and the calendar are written in: `fr-CH`. The page's by default. */
|
|
49
49
|
locale = this.useChange("", (value) => {
|
|
50
|
-
this.
|
|
50
|
+
this.shownCalendar()?.locale.set(value);
|
|
51
51
|
this.renderPlaceholder();
|
|
52
52
|
this.renderValue();
|
|
53
53
|
}, { attribute: "locale" });
|
|
54
54
|
/** The day the calendar's weeks start on: 0 for Sunday, 1 for Monday. */
|
|
55
|
-
firstDay = this.useChange(MONDAY, (value) => this.
|
|
55
|
+
firstDay = this.useChange(MONDAY, (value) => this.shownCalendar()?.firstDay.set(value), {
|
|
56
56
|
attribute: "first-day",
|
|
57
57
|
parse: parseWeekday
|
|
58
58
|
});
|
|
@@ -80,7 +80,6 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
80
80
|
openOnPress: null
|
|
81
81
|
};
|
|
82
82
|
_refs = this.useRefs((ref) => ({
|
|
83
|
-
calendar: ref(JlCalendar),
|
|
84
83
|
clear: ref(".clear"),
|
|
85
84
|
control: ref(".control"),
|
|
86
85
|
native: ref("input"),
|
|
@@ -141,8 +140,7 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
141
140
|
id: this._popupId,
|
|
142
141
|
popover: "auto",
|
|
143
142
|
role: "dialog",
|
|
144
|
-
attrs: { part: "popup" }
|
|
145
|
-
children: /* @__PURE__ */ jsx(JlCalendar, { class: "calendar" })
|
|
143
|
+
attrs: { part: "popup" }
|
|
146
144
|
})] });
|
|
147
145
|
}
|
|
148
146
|
templateCss() {
|
|
@@ -174,7 +172,7 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
174
172
|
this.on(this._refs.clear, "click", () => this.clearValue());
|
|
175
173
|
this.on(this._refs.popup, "toggle", (event) => this.onToggle(event));
|
|
176
174
|
this.on(this._refs.popup, "keydown", (event) => this.onPopupKey(event));
|
|
177
|
-
this.
|
|
175
|
+
this.shownCalendar()?.events.register("pick", (iso) => this.onPick(iso));
|
|
178
176
|
}
|
|
179
177
|
onDisconnect() {
|
|
180
178
|
this._state.opening.abort();
|
|
@@ -232,10 +230,32 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
232
230
|
this.commit(iso);
|
|
233
231
|
this.focus();
|
|
234
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* The calendar, made the first time the popup opens with the field's language, week, bounds and value: a closed
|
|
235
|
+
* picker draws no month, and a form may hold many pickers.
|
|
236
|
+
*/
|
|
237
|
+
calendar() {
|
|
238
|
+
const shown = this.shownCalendar();
|
|
239
|
+
if (shown !== null) return shown;
|
|
240
|
+
const calendar = /* @__PURE__ */ jsx(JlCalendar, {
|
|
241
|
+
class: "calendar",
|
|
242
|
+
locale: this.locale.get(),
|
|
243
|
+
firstDay: this.firstDay.get(),
|
|
244
|
+
min: this.min.get(),
|
|
245
|
+
max: this.max.get(),
|
|
246
|
+
value: this.validIso()
|
|
247
|
+
});
|
|
248
|
+
calendar.events.register("pick", (iso) => this.onPick(iso));
|
|
249
|
+
this._refs.popup.append(calendar);
|
|
250
|
+
return calendar;
|
|
251
|
+
}
|
|
252
|
+
shownCalendar() {
|
|
253
|
+
return this._refs.popup.querySelector(JlCalendar.selector);
|
|
254
|
+
}
|
|
235
255
|
openPopup() {
|
|
236
256
|
if (this.isOpen() || this.disabled.get() || this._refs.native.disabled) return;
|
|
237
257
|
this.commitText();
|
|
238
|
-
const calendar = this.
|
|
258
|
+
const calendar = this.calendar();
|
|
239
259
|
calendar.value.set(this.validIso());
|
|
240
260
|
const popup = this._refs.popup;
|
|
241
261
|
popup.showPopover();
|
|
@@ -290,13 +310,13 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
290
310
|
renderValue() {
|
|
291
311
|
const value = this.validIso();
|
|
292
312
|
this._refs.native.value = this.display(value);
|
|
293
|
-
this.
|
|
313
|
+
this.shownCalendar()?.value.set(value);
|
|
294
314
|
this.internals.setFormValue(value);
|
|
295
315
|
this.renderValidity();
|
|
296
316
|
this.renderClear();
|
|
297
317
|
}
|
|
298
318
|
renderBound(bound, value) {
|
|
299
|
-
this.
|
|
319
|
+
this.shownCalendar()?.[bound].set(value);
|
|
300
320
|
this.renderValidity();
|
|
301
321
|
}
|
|
302
322
|
/** Required, and within min and max, as a native date field checks it. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-empty.css?inline
|
|
2
|
-
var jl_empty_default = ":host{--pad:40px 24px;--medallion:48px;--heading:var(--jl-font-lg);display:block}:host([size=sm]){--pad:24px 16px;--medallion:40px;--heading:var(--jl-font-md)}.empty{padding:var(--pad);text-align:center;flex-direction:column;align-items:center;display:flex}.medallion{width:var(--medallion);height:var(--medallion);border:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);border-radius:50%;justify-content:center;align-items:center;margin-bottom:14px;display:inline-flex}:host([size=sm]) .medallion{margin-bottom:10px}.heading{color:var(--jl-text);font-size:var(--heading);letter-spacing:-.01em;font-weight:650;line-height:1.35}.description{max-width:44ch;color:var(--jl-muted);font-size:var(--jl-font-sm);margin-top:4px;line-height:1.55}.actions{flex-wrap:wrap;justify-content:center;gap:8px;margin-top:18px;display:flex}:host([size=sm]) .actions{margin-top:14px}";
|
|
2
|
+
var jl_empty_default = ":host{--pad:40px 24px;--medallion:48px;--heading:var(--jl-font-lg);display:block}:host([size=sm]){--pad:24px 16px;--medallion:40px;--heading:var(--jl-font-md)}.empty{padding:var(--pad);text-align:center;flex-direction:column;align-items:center;display:flex}.medallion{width:var(--medallion);height:var(--medallion);border:1px solid var(--jl-line);background:var(--jl-surface-2);color:var(--jl-muted);border-radius:50%;justify-content:center;align-items:center;margin-bottom:14px;display:inline-flex}:host([size=sm]) .medallion{margin-bottom:10px}.heading{color:var(--jl-text);font-size:var(--heading);letter-spacing:-.01em;font-weight:650;line-height:1.35}.heading:empty,.description:empty{display:none}.description{max-width:44ch;color:var(--jl-muted);font-size:var(--jl-font-sm);margin-top:4px;line-height:1.55}.actions{flex-wrap:wrap;justify-content:center;gap:8px;margin-top:18px;display:flex}:host([size=sm]) .actions{margin-top:14px}jl-icon{--icon-size:22px}:host([size=sm]) jl-icon{--icon-size:18px}";
|
|
3
3
|
export { jl_empty_default as default };
|
|
@@ -13,28 +13,21 @@ registerIcons({ inbox: Inbox });
|
|
|
13
13
|
var EMPTY_SIZES = ["md", "sm"];
|
|
14
14
|
var DEFAULT_ICON = "inbox";
|
|
15
15
|
var NO_ICON = "none";
|
|
16
|
-
var ICON_SIZES = {
|
|
17
|
-
md: 22,
|
|
18
|
-
sm: 18
|
|
19
|
-
};
|
|
20
16
|
/**
|
|
21
17
|
* What a list, a table or a page shows when it has nothing yet: an icon, a heading, a sentence that says what to
|
|
22
18
|
* do, and the buttons to do it in the default slot.
|
|
23
19
|
*/
|
|
24
20
|
var JlEmpty = class extends JlElement {
|
|
25
21
|
static selector = "jl-empty";
|
|
26
|
-
icon = this.useChange(DEFAULT_ICON, () => this.renderIcon(), { attribute: "icon" });
|
|
22
|
+
icon = this.useChange(DEFAULT_ICON, (value) => this.renderIcon(value), { attribute: "icon" });
|
|
27
23
|
heading = this.useChange("", (value) => {
|
|
28
24
|
this._refs.heading.textContent = value;
|
|
29
|
-
this._refs.heading.hidden = value === "";
|
|
30
25
|
}, { attribute: "heading" });
|
|
31
26
|
description = this.useChange("", (value) => {
|
|
32
27
|
this._refs.description.textContent = value;
|
|
33
|
-
this._refs.description.hidden = value === "";
|
|
34
28
|
}, { attribute: "description" });
|
|
35
29
|
size = this.useChange("md", (value) => {
|
|
36
30
|
this.reflect("size", value);
|
|
37
|
-
this.renderIcon();
|
|
38
31
|
}, {
|
|
39
32
|
attribute: "size",
|
|
40
33
|
parse: oneOf(EMPTY_SIZES, "md")
|
|
@@ -56,14 +49,8 @@ var JlEmpty = class extends JlElement {
|
|
|
56
49
|
class: "medallion",
|
|
57
50
|
children: /* @__PURE__ */ jsx(JlIcon, {})
|
|
58
51
|
}),
|
|
59
|
-
/* @__PURE__ */ jsx("p", {
|
|
60
|
-
|
|
61
|
-
hidden: true
|
|
62
|
-
}),
|
|
63
|
-
/* @__PURE__ */ jsx("p", {
|
|
64
|
-
class: "description",
|
|
65
|
-
hidden: true
|
|
66
|
-
}),
|
|
52
|
+
/* @__PURE__ */ jsx("p", { class: "heading" }),
|
|
53
|
+
/* @__PURE__ */ jsx("p", { class: "description" }),
|
|
67
54
|
/* @__PURE__ */ jsx("div", {
|
|
68
55
|
class: "actions",
|
|
69
56
|
hidden: true,
|
|
@@ -82,11 +69,9 @@ var JlEmpty = class extends JlElement {
|
|
|
82
69
|
renderActions() {
|
|
83
70
|
this._refs.actions.hidden = !hasSlotted(this._refs.slot);
|
|
84
71
|
}
|
|
85
|
-
renderIcon() {
|
|
86
|
-
const name = this.icon.get();
|
|
72
|
+
renderIcon(name) {
|
|
87
73
|
const hidden = name === "" || name === NO_ICON;
|
|
88
74
|
this._refs.icon.name.set(hidden ? "" : name);
|
|
89
|
-
this._refs.icon.size.set(ICON_SIZES[this.size.get()]);
|
|
90
75
|
this._refs.medallion.hidden = hidden;
|
|
91
76
|
}
|
|
92
77
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-field.css?inline
|
|
2
|
-
var jl_field_default = ":host{--label-width:160px;display:block;container-type:inline-size}.field{gap:6px;display:grid}.label-row{color:var(--jl-text);font-size:var(--jl-font-sm);gap:3px;font-weight:600;line-height:20px;display:flex}.asterisk{color:var(--jl-danger)}.body{grid-template-columns:minmax(0,1fr);gap:6px;min-width:0;display:grid}.hint{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:18px}.error
|
|
2
|
+
var jl_field_default = ":host{--label-width:160px;display:block;container-type:inline-size}.field{gap:6px;display:grid}.label-row{color:var(--jl-text);font-size:var(--jl-font-sm);gap:3px;font-weight:600;line-height:20px;display:flex}.asterisk{color:var(--jl-danger)}.body{grid-template-columns:minmax(0,1fr);gap:6px;min-width:0;display:grid}.hint{color:var(--jl-muted);font-size:var(--jl-font-sm);line-height:18px}.error{color:var(--jl-danger);font-size:var(--jl-font-sm);align-items:flex-start;gap:6px;line-height:18px;display:flex}.error jl-icon{flex:none;margin-top:2px}.label-row:has(>.label:empty),.hint:empty,:host([has-error]) .hint{display:none}:host(:not([has-error])) .error-region{display:contents}:host(:not([has-error])) .error{display:none}:host([orientation=horizontal]) .field{grid-template-columns:var(--label-width) minmax(0, 1fr);align-items:baseline;gap:6px 16px}@container (width<=420px){:host([orientation=horizontal]) .field{grid-template-columns:minmax(0,1fr)}}";
|
|
3
3
|
export { jl_field_default as default };
|
|
@@ -38,8 +38,14 @@ export declare class JlField extends JlElement {
|
|
|
38
38
|
/** The control in the slot: the first element the page put there. */
|
|
39
39
|
private control;
|
|
40
40
|
private focusControl;
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Shows the error, which the CSS hides with the field's `has-error`: its paragraph is made at the first error, then
|
|
43
|
+
* only its text changes. A field that never has one makes no icon.
|
|
44
|
+
*/
|
|
45
|
+
private renderError;
|
|
42
46
|
private syncControl;
|
|
47
|
+
/** Runs `sync` on the control in the slot, when there is one. */
|
|
48
|
+
private withControl;
|
|
43
49
|
/** Names the control for screen readers with the field's label, unless it has a label of its own. */
|
|
44
50
|
private syncLabel;
|
|
45
51
|
/** Marks the control invalid, remembering it unless the page had marked it already. */
|
|
@@ -24,15 +24,16 @@ var JlField = class extends JlElement {
|
|
|
24
24
|
static selector = "jl-field";
|
|
25
25
|
label = this.useChange("", (value) => {
|
|
26
26
|
this._refs.label.textContent = value;
|
|
27
|
-
this.
|
|
28
|
-
this.syncControl();
|
|
27
|
+
this.withControl((control) => this.syncLabel(control));
|
|
29
28
|
}, { attribute: "label" });
|
|
30
29
|
/** Help under the control, hidden while there is an error. */
|
|
31
|
-
hint = this.useChange("", () =>
|
|
30
|
+
hint = this.useChange("", (value) => {
|
|
31
|
+
this._refs.hint.textContent = value;
|
|
32
|
+
}, { attribute: "hint" });
|
|
32
33
|
/** What is wrong with the value, in the danger colour; the control is drawn as invalid meanwhile. */
|
|
33
|
-
error = this.useChange("", () => {
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
34
|
+
error = this.useChange("", (value) => {
|
|
35
|
+
this.renderError(value);
|
|
36
|
+
this.withControl((control) => this.syncInvalid(control));
|
|
36
37
|
}, { attribute: "error" });
|
|
37
38
|
/** Adds an asterisk to the label. Set `required` on the control too, for the form to check it. */
|
|
38
39
|
required = this.useChange(false, (value) => {
|
|
@@ -57,7 +58,6 @@ var JlField = class extends JlElement {
|
|
|
57
58
|
attrs: { part: "base" },
|
|
58
59
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
59
60
|
class: "label-row",
|
|
60
|
-
hidden: true,
|
|
61
61
|
children: [/* @__PURE__ */ jsx("span", { class: "label" }), /* @__PURE__ */ jsx("span", {
|
|
62
62
|
class: "asterisk",
|
|
63
63
|
"aria-hidden": "true",
|
|
@@ -68,10 +68,7 @@ var JlField = class extends JlElement {
|
|
|
68
68
|
class: "body",
|
|
69
69
|
children: [
|
|
70
70
|
/* @__PURE__ */ jsx("slot", {}),
|
|
71
|
-
/* @__PURE__ */ jsx("p", {
|
|
72
|
-
class: "hint",
|
|
73
|
-
hidden: true
|
|
74
|
-
}),
|
|
71
|
+
/* @__PURE__ */ jsx("p", { class: "hint" }),
|
|
75
72
|
/* @__PURE__ */ jsx("div", {
|
|
76
73
|
class: "error-region",
|
|
77
74
|
"aria-live": "polite"
|
|
@@ -96,31 +93,46 @@ var JlField = class extends JlElement {
|
|
|
96
93
|
focusControl() {
|
|
97
94
|
this.control()?.focus();
|
|
98
95
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Shows the error, which the CSS hides with the field's `has-error`: its paragraph is made at the first error, then
|
|
98
|
+
* only its text changes. A field that never has one makes no icon.
|
|
99
|
+
*/
|
|
100
|
+
renderError(error) {
|
|
104
101
|
this.reflect("has-error", error !== "");
|
|
105
|
-
this._refs.errorRegion
|
|
102
|
+
const region = this._refs.errorRegion;
|
|
103
|
+
const text = region.querySelector(".error-text");
|
|
104
|
+
if (text !== null) {
|
|
105
|
+
text.textContent = error;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (error === "") return;
|
|
109
|
+
region.append(/* @__PURE__ */ jsxs("p", {
|
|
106
110
|
class: "error",
|
|
107
111
|
children: [/* @__PURE__ */ jsx(JlIcon, {
|
|
108
112
|
name: "circle-alert",
|
|
109
113
|
size: ERROR_ICON_SIZE
|
|
110
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
111
|
-
|
|
114
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
115
|
+
class: "error-text",
|
|
116
|
+
children: error
|
|
117
|
+
})]
|
|
118
|
+
}));
|
|
112
119
|
}
|
|
113
120
|
syncControl() {
|
|
121
|
+
this.withControl((control) => {
|
|
122
|
+
this.syncLabel(control);
|
|
123
|
+
this.syncInvalid(control);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** Runs `sync` on the control in the slot, when there is one. */
|
|
127
|
+
withControl(sync) {
|
|
114
128
|
const control = this.control();
|
|
115
|
-
if (control
|
|
116
|
-
this.syncLabel(control);
|
|
117
|
-
this.syncInvalid(control);
|
|
129
|
+
if (control !== null) sync(control);
|
|
118
130
|
}
|
|
119
131
|
/** Names the control for screen readers with the field's label, unless it has a label of its own. */
|
|
120
132
|
syncLabel(control) {
|
|
121
133
|
const input = inputOf(control, "label");
|
|
122
134
|
const ownLabel = control.hasAttribute("label") || VISIBLE_LABEL_TAGS.includes(control.localName);
|
|
123
|
-
if (input === null || ownLabel) return;
|
|
135
|
+
if (input === null || ownLabel || input.get() === this.label.get()) return;
|
|
124
136
|
input.set(this.label.get());
|
|
125
137
|
}
|
|
126
138
|
/** Marks the control invalid, remembering it unless the page had marked it already. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-file-drop.css?inline
|
|
2
|
-
var jl_file_drop_default = ":host{--pad:24px;--badge:44px;min-width:0;display:block}:host([size=sm]){--pad:14px;--badge:34px}:host([size=lg]){--pad:36px;--badge:52px}.zone{padding:var(--pad);border:1.5px dashed var(--jl-line-strong);border-radius:var(--jl-radius);background:var(--jl-surface);color:var(--jl-text);text-align:center;cursor:pointer;transition:border-color var(--jl-fast) var(--jl-ease), background var(--jl-fast) var(--jl-ease);flex-direction:column;align-items:center;gap:4px;display:flex}.zone:hover{border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%);background:var(--jl-surface-2)}:host([dragging]) .zone{border-color:var(--jl-accent);background:var(--jl-accent-soft)}:host([invalid]) .zone{border-color:var(--jl-danger)}:host([disabled]) .zone{border-color:var(--jl-line-strong);background:var(--jl-surface-2);color:var(--jl-muted);cursor:not-allowed}.zone-icon{width:var(--badge);height:var(--badge);border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);color:var(--jl-muted);transition:background var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);justify-content:center;align-items:center;margin-bottom:6px}:host([dragging]) .zone-icon{background:var(--jl-surface);color:var(--jl-accent)}.text{font-size:var(--jl-font-md);font-weight:600;line-height:1.4}:host([size=sm]) .text{font-size:var(--jl-font-sm)}.hint{color:var(--jl-muted);font-size:var(--jl-font-xs);line-height:1.4}.browse{height:var(--jl-control-sm);border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-sm);background:var(--jl-surface);font-size:var(--jl-font-xs);cursor:pointer;transition:background var(--jl-fast) var(--jl-ease);align-items:center;margin-top:8px;padding:0 12px;font-weight:600;display:inline-flex}.browse:hover{background:var(--jl-surface-3)}.browse:disabled{cursor:not-allowed;opacity:.5}.refused,.files{margin:8px 0 0;padding:0;list-style:none}.refused{color:var(--jl-danger);font-size:var(--jl-font-sm);gap:4px;line-height:1.45;display:grid}.refusal{align-items:flex-start;gap:6px;display:flex}.refusal jl-icon{margin-top:3px}.refused-name{overflow-wrap:anywhere;font-weight:600}.files{border:1px solid var(--jl-line);border-radius:var(--jl-radius)}.file{align-items:center;gap:10px;min-height:40px;padding:6px 8px 6px 12px;display:flex}.file+.file{border-top:1px solid var(--jl-line)}.file-icon{color:var(--jl-faint)}.file-name{min-width:0;font-size:var(--jl-font-sm);text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.file-size{color:var(--jl-muted);font-family:var(--jl-font-mono);font-size:var(--jl-font-xs);white-space:nowrap}.file-remove{border-radius:var(--jl-radius-xs);width:26px;height:26px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.file-remove:hover{background:var(--jl-surface-3);color:var(--jl-text)}.hint:first-letter{text-transform:uppercase}";
|
|
2
|
+
var jl_file_drop_default = ":host{--pad:24px;--badge:44px;min-width:0;display:block}:host([size=sm]){--pad:14px;--badge:34px}:host([size=lg]){--pad:36px;--badge:52px}.zone{padding:var(--pad);border:1.5px dashed var(--jl-line-strong);border-radius:var(--jl-radius);background:var(--jl-surface);color:var(--jl-text);text-align:center;cursor:pointer;transition:border-color var(--jl-fast) var(--jl-ease), background var(--jl-fast) var(--jl-ease);flex-direction:column;align-items:center;gap:4px;display:flex}.zone:hover{border-color:color-mix(in srgb, var(--jl-line-strong) 60%, var(--jl-text) 18%);background:var(--jl-surface-2)}:host([dragging]) .zone{border-color:var(--jl-accent);background:var(--jl-accent-soft)}:host([invalid]) .zone{border-color:var(--jl-danger)}:host([disabled]) .zone{border-color:var(--jl-line-strong);background:var(--jl-surface-2);color:var(--jl-muted);cursor:not-allowed}.zone-icon{width:var(--badge);height:var(--badge);border-radius:var(--jl-radius-pill);background:var(--jl-surface-3);color:var(--jl-muted);transition:background var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);justify-content:center;align-items:center;margin-bottom:6px}:host([dragging]) .zone-icon{background:var(--jl-surface);color:var(--jl-accent)}.text{font-size:var(--jl-font-md);font-weight:600;line-height:1.4}:host([size=sm]) .text{font-size:var(--jl-font-sm)}.hint{color:var(--jl-muted);font-size:var(--jl-font-xs);line-height:1.4}.hint:empty{display:none}.browse{height:var(--jl-control-sm);border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-sm);background:var(--jl-surface);font-size:var(--jl-font-xs);cursor:pointer;transition:background var(--jl-fast) var(--jl-ease);align-items:center;margin-top:8px;padding:0 12px;font-weight:600;display:inline-flex}.browse:hover{background:var(--jl-surface-3)}.browse:disabled{cursor:not-allowed;opacity:.5}.refused,.files{margin:8px 0 0;padding:0;list-style:none}.refused{color:var(--jl-danger);font-size:var(--jl-font-sm);gap:4px;line-height:1.45;display:grid}.refusal{align-items:flex-start;gap:6px;display:flex}.refusal jl-icon{margin-top:3px}.refused-name{overflow-wrap:anywhere;font-weight:600}.files{border:1px solid var(--jl-line);border-radius:var(--jl-radius)}.file{align-items:center;gap:10px;min-height:40px;padding:6px 8px 6px 12px;display:flex}.file+.file{border-top:1px solid var(--jl-line)}.file-icon{color:var(--jl-faint)}.file-name{min-width:0;font-size:var(--jl-font-sm);text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.file-size{color:var(--jl-muted);font-family:var(--jl-font-mono);font-size:var(--jl-font-xs);white-space:nowrap}.file-remove{border-radius:var(--jl-radius-xs);width:26px;height:26px;color:var(--jl-faint);cursor:pointer;background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.file-remove:hover{background:var(--jl-surface-3);color:var(--jl-text)}.hint:first-letter{text-transform:uppercase}";
|
|
3
3
|
export { jl_file_drop_default as default };
|
|
@@ -145,8 +145,7 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
145
145
|
}),
|
|
146
146
|
/* @__PURE__ */ jsx("p", {
|
|
147
147
|
class: "hint",
|
|
148
|
-
id: this._ids.hint
|
|
149
|
-
hidden: true
|
|
148
|
+
id: this._ids.hint
|
|
150
149
|
}),
|
|
151
150
|
/* @__PURE__ */ jsx("button", {
|
|
152
151
|
class: "browse",
|
|
@@ -349,7 +348,6 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
349
348
|
const maxSize = this.maxSize.get();
|
|
350
349
|
const hint = [types, maxSize === NO_LIMIT ? "" : jlText("fileUpTo", { size: formatFileSize(maxSize, pageLocale()) })].filter((part) => part !== "").join(" · ");
|
|
351
350
|
this._refs.hint.textContent = hint;
|
|
352
|
-
this._refs.hint.hidden = hint === "";
|
|
353
351
|
}
|
|
354
352
|
/** Each file is its own entry under the field's name, as from a native file input. */
|
|
355
353
|
renderFormValue() {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-input-list.css?inline
|
|
2
|
-
var jl_input_list_default = ":host{display:block}.list,.rows{gap:var(--jl-space-2);display:grid}.row{align-items:start;gap:var(--jl-space-1);display:flex}.row>:first-child{flex:1;min-width:0}[hidden]{display:none}";
|
|
2
|
+
var jl_input_list_default = ":host{display:block}.list,.rows{gap:var(--jl-space-2);display:grid}.row{align-items:start;gap:var(--jl-space-1);display:flex}.row>:first-child{flex:1;min-width:0}.row:only-child>.remove,:host([disabled]) .remove,:host([disabled]) .add,[hidden]{display:none}";
|
|
3
3
|
export { jl_input_list_default as default };
|
|
@@ -60,6 +60,7 @@ export declare class JlInputList extends JlElement {
|
|
|
60
60
|
set(setter: string | ((prevState: string) => string)): void;
|
|
61
61
|
}>>;
|
|
62
62
|
private readonly _state;
|
|
63
|
+
private readonly _drawn;
|
|
63
64
|
private readonly _refs;
|
|
64
65
|
templateHtml(): Node;
|
|
65
66
|
templateCss(): string;
|
|
@@ -67,11 +68,21 @@ export declare class JlInputList extends JlElement {
|
|
|
67
68
|
/** Values set from outside start the rows again; those the rows themselves gave change nothing. */
|
|
68
69
|
private follow;
|
|
69
70
|
protected drawTexts(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Draws the rows as the inputs say: in place, or built again for another kind of control. Every input's callback
|
|
73
|
+
* runs as the list appears: a build in each made about ten per list.
|
|
74
|
+
*/
|
|
75
|
+
private drawRows;
|
|
76
|
+
/** Builds every row again, from the values in `_state`. */
|
|
70
77
|
private renderRows;
|
|
78
|
+
/** The add button: its text, and hidden at `max`; the CSS hides it in a disabled list. */
|
|
71
79
|
private renderAdd;
|
|
72
80
|
private renderDisabled;
|
|
73
81
|
private row;
|
|
74
|
-
/**
|
|
82
|
+
/** Gives a row the list's label, placeholder, type, options and state; the CSS shows or hides its remove button. */
|
|
83
|
+
private drawRow;
|
|
84
|
+
private rowKind;
|
|
85
|
+
/** A row's control, of the list's kind, holding `value`; `onInput` hears it. drawRow gives it the rest. */
|
|
75
86
|
private control;
|
|
76
87
|
private change;
|
|
77
88
|
private addRow;
|