@syware/jlib 0.14.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 +6 -2
- package/dist/atoms/jl-progress.d.ts +1 -0
- package/dist/atoms/jl-progress.js +5 -2
- 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 +1 -0
- 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/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/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 +3 -3
- 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 +3 -2
- 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 +8 -4
- 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 +9 -3
- 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 +14 -3
- package/dist/organisms/jl-table.js +34 -15
- 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 +6 -4
|
@@ -6,7 +6,7 @@ import { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
|
6
6
|
import { registerIcons } from "../lib/icons.js";
|
|
7
7
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
8
8
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
9
|
-
import { setOrRemove, uniqueId } from "../lib/dom.js";
|
|
9
|
+
import { setAriaFlag, setOrRemove, uniqueId } from "../lib/dom.js";
|
|
10
10
|
import { addMonths, calendarDateOf, clampDate, dateAfterKey, dateFormatter, formatMonthTitle, isSameDate, isSameMonth, isWithin, monthGrid, monthHasDaysWithin, parseIsoDate, toIsoDate, weekdayNames } from "../lib/calendar.js";
|
|
11
11
|
import jl_calendar_default from "./jl-calendar.css.js";
|
|
12
12
|
import { css } from "@jadis/core";
|
|
@@ -23,6 +23,7 @@ var SUNDAY = 0;
|
|
|
23
23
|
var SATURDAY = 6;
|
|
24
24
|
var DAYS_PER_WEEK = 7;
|
|
25
25
|
var SELECT_KEYS = ["Enter", " "];
|
|
26
|
+
var TAB_STOP = "[tabindex=\"0\"]";
|
|
26
27
|
var FULL_DATE = { dateStyle: "full" };
|
|
27
28
|
/** The first day of the week from its attribute: 0 (Sunday) to 6 (Saturday), Monday when absent. */
|
|
28
29
|
var parseWeekday = (value) => Math.round(clampedNumber(MONDAY, SUNDAY, SATURDAY)(value));
|
|
@@ -90,7 +91,7 @@ var JlCalendar = class extends JlFormControl {
|
|
|
90
91
|
}));
|
|
91
92
|
/** Focuses the day the arrows move from: the chosen one, or today, or the first of the month. */
|
|
92
93
|
focus(options) {
|
|
93
|
-
this.
|
|
94
|
+
this.tabStop()?.focus(options);
|
|
94
95
|
}
|
|
95
96
|
/** Shows the month of a date (ISO), without choosing it. */
|
|
96
97
|
showMonth(iso) {
|
|
@@ -154,7 +155,7 @@ var JlCalendar = class extends JlFormControl {
|
|
|
154
155
|
}
|
|
155
156
|
setDisabledByForm(disabled) {
|
|
156
157
|
this._state.formDisabled = disabled;
|
|
157
|
-
this.whenRendered(() => this.
|
|
158
|
+
this.whenRendered(() => this.drawDisabled());
|
|
158
159
|
}
|
|
159
160
|
bounds() {
|
|
160
161
|
return {
|
|
@@ -247,6 +248,11 @@ var JlCalendar = class extends JlFormControl {
|
|
|
247
248
|
this.renderDays(locale);
|
|
248
249
|
this.renderStates(min, max);
|
|
249
250
|
this.renderNavigation(min, max);
|
|
251
|
+
this.renderValidity();
|
|
252
|
+
}
|
|
253
|
+
/** The day the Tab key reaches: the one the arrows move from. */
|
|
254
|
+
tabStop() {
|
|
255
|
+
return this._refs.days.querySelector(TAB_STOP);
|
|
250
256
|
}
|
|
251
257
|
/** The title is a live region: written only when the month changes, so it is announced once. */
|
|
252
258
|
renderTitle(text) {
|
|
@@ -333,14 +339,19 @@ var JlCalendar = class extends JlFormControl {
|
|
|
333
339
|
}
|
|
334
340
|
renderValidity() {
|
|
335
341
|
if (this.required.get() && parseIsoDate(this.value.get()) === null) {
|
|
336
|
-
this.internals.setValidity({ valueMissing: true }, jlText("chooseDateMissing"));
|
|
342
|
+
this.internals.setValidity({ valueMissing: true }, jlText("chooseDateMissing"), this.tabStop() ?? void 0);
|
|
337
343
|
return;
|
|
338
344
|
}
|
|
339
345
|
this.internals.setValidity({});
|
|
340
346
|
}
|
|
341
347
|
renderDisabled(disabled) {
|
|
342
348
|
this.reflect("disabled", disabled);
|
|
343
|
-
this.
|
|
349
|
+
this.drawDisabled();
|
|
350
|
+
}
|
|
351
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
352
|
+
drawDisabled() {
|
|
353
|
+
setAriaFlag(this._refs.base, "aria-disabled", this.isOff());
|
|
354
|
+
setAriaFlag(this._refs.grid, "aria-disabled", this.isOff());
|
|
344
355
|
this.renderPage();
|
|
345
356
|
}
|
|
346
357
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-chip-group.css?inline
|
|
2
|
-
var jl_chip_group_default = ":host{--height:28px;--pad:10px;--font-size:var(--jl-font-sm);min-width:0;display:block}:host([size=sm]){--height:24px;--pad:8px;--font-size:var(--jl-font-xs)}:host([size=lg]){--height:36px;--pad:14px;--font-size:var(--jl-font-md)}.group{scrollbar-width:none;contain:inline-size;gap:8px;min-width:0;margin:-3px;padding:3px;display:flex;overflow-x:auto}.group::-webkit-scrollbar{display:none}:host([wrap]) .group{contain:none;flex-wrap:wrap;overflow:visible}.chip{max-width:100%;height:var(--height);padding:0 var(--pad);border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface);color:var(--jl-text-2);font-size:var(--font-size);white-space:nowrap;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);flex:none;align-items:center;gap:6px;font-weight:600;line-height:1;display:inline-flex}.chip:hover:not(:disabled){background:var(--jl-surface-2)}.chip:is([aria-checked=true],[aria-pressed=true]),.chip:is([aria-checked=true],[aria-pressed=true]):hover:not(:disabled){border-color:var(--jl-accent-line);background:var(--jl-accent-soft);color:var(--jl-accent)}.chip:not([data-icon],[aria-checked=true],[aria-pressed=true]) .icon{display:none}.chip:disabled{cursor:not-allowed;opacity:.5}.label{text-overflow:ellipsis;line-height:1.4;overflow:hidden}.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);font-variant-numeric:tabular-nums;text-align:center;margin-right:-4px;padding:0 6px;font-weight:650;line-height:18px}.chip:is([aria-checked=true],[aria-pressed=true]) .badge{background:color-mix(in srgb, var(--jl-accent) 14%, transparent);color:var(--jl-accent)}jl-icon{--icon-size:14px}:host([size=sm]) jl-icon{--icon-size:12px}:host([size=lg]) jl-icon{--icon-size:16px}";
|
|
2
|
+
var jl_chip_group_default = ":host{--height:28px;--pad:10px;--font-size:var(--jl-font-sm);min-width:0;display:block}:host([size=sm]){--height:24px;--pad:8px;--font-size:var(--jl-font-xs)}:host([size=lg]){--height:36px;--pad:14px;--font-size:var(--jl-font-md)}.group{scrollbar-width:none;contain:inline-size;gap:8px;min-width:0;margin:-3px;padding:3px;display:flex;overflow-x:auto}.group::-webkit-scrollbar{display:none}:host([wrap]) .group{contain:none;flex-wrap:wrap;overflow:visible}.chip{max-width:100%;height:var(--height);padding:0 var(--pad);border:1px solid var(--jl-line-strong);border-radius:var(--jl-radius-pill);background:var(--jl-surface);color:var(--jl-text-2);font-size:var(--font-size);white-space:nowrap;cursor:pointer;transition:background var(--jl-fast) var(--jl-ease), border-color var(--jl-fast) var(--jl-ease), color var(--jl-fast) var(--jl-ease);flex:none;align-items:center;gap:6px;font-weight:600;line-height:1;display:inline-flex}.chip:hover:not(:disabled){background:var(--jl-surface-2)}.chip:is([aria-checked=true],[aria-pressed=true]),.chip:is([aria-checked=true],[aria-pressed=true]):hover:not(:disabled){border-color:var(--jl-accent-line);background:var(--jl-accent-soft);color:var(--jl-accent)}.chip:not([data-icon],[aria-checked=true],[aria-pressed=true]) .icon{display:none}.chip:disabled{cursor:not-allowed;opacity:.5}.label{text-overflow:ellipsis;line-height:1.4;overflow:hidden}.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);font-variant-numeric:tabular-nums;text-align:center;margin-right:-4px;padding:0 6px;font-weight:650;line-height:18px}.chip:is([aria-checked=true],[aria-pressed=true]) .badge{background:color-mix(in srgb, var(--jl-accent) 14%, transparent);color:var(--jl-accent-strong)}jl-icon{--icon-size:14px}:host([size=sm]) jl-icon{--icon-size:12px}:host([size=lg]) jl-icon{--icon-size:16px}";
|
|
3
3
|
export { jl_chip_group_default as default };
|
|
@@ -5,7 +5,7 @@ import { jsonOf, oneOf, textListOf } 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 "../atoms/jl-icon.js";
|
|
8
|
-
import { setOrRemove } from "../lib/dom.js";
|
|
8
|
+
import { setAriaFlag, setOrRemove } from "../lib/dom.js";
|
|
9
9
|
import { rovingIndex } from "../lib/roving.js";
|
|
10
10
|
import jl_chip_group_default from "./jl-chip-group.css.js";
|
|
11
11
|
import { css } from "@jadis/core";
|
|
@@ -65,7 +65,7 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
65
65
|
/** A form refuses to submit while nothing is chosen. */
|
|
66
66
|
required = this.useChange(false, (value) => {
|
|
67
67
|
this.reflect("required", value);
|
|
68
|
-
this._refs.group
|
|
68
|
+
setAriaFlag(this._refs.group, "aria-required", value);
|
|
69
69
|
this.renderValidity();
|
|
70
70
|
}, { attribute: "required" });
|
|
71
71
|
disabled = this.useChange(false, (value) => {
|
|
@@ -209,7 +209,7 @@ var JlChipGroup = class extends JlFormControl {
|
|
|
209
209
|
const multiple = this.multiple.get();
|
|
210
210
|
const groupDisabled = this.isDisabled();
|
|
211
211
|
this._refs.group.setAttribute("role", multiple ? "group" : "radiogroup");
|
|
212
|
-
this._refs.group
|
|
212
|
+
setAriaFlag(this._refs.group, "aria-disabled", groupDisabled);
|
|
213
213
|
for (const chip of this.chips()) {
|
|
214
214
|
const selected = chosen.has(chip.dataset.value ?? "");
|
|
215
215
|
chip.disabled = groupDisabled || chip.dataset.disabled !== void 0;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-code-block.css?inline
|
|
2
|
-
var jl_code_block_default = ":host{--max-height:none;min-width:0;display:block}figure{border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface-2);position:relative;overflow:hidden}header{border-bottom:1px solid var(--jl-line);height:38px;color:var(--jl-muted);font-size:var(--jl-font-xs);justify-content:space-between;align-items:center;gap:12px;padding:0 52px 0 14px;display:flex}.heading{color:var(--jl-text-2);font-family:var(--jl-font-mono);text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}.language{letter-spacing:.06em;text-transform:uppercase;font-weight:600}.body{min-width:0;max-height:var(--max-height);display:flex;overflow-y:auto}.gutter,pre{font-family:var(--jl-font-mono);font-variant-ligatures:no-contextual;padding:14px 16px;font-size:12.5px;line-height:1.7}.gutter{color:var(--jl-
|
|
2
|
+
var jl_code_block_default = ":host{--max-height:none;min-width:0;display:block}figure{border:1px solid var(--jl-line);border-radius:var(--jl-radius);background:var(--jl-surface-2);position:relative;overflow:hidden}header{border-bottom:1px solid var(--jl-line);height:38px;color:var(--jl-muted);font-size:var(--jl-font-xs);justify-content:space-between;align-items:center;gap:12px;padding:0 52px 0 14px;display:flex}.heading{color:var(--jl-text-2);font-family:var(--jl-font-mono);text-overflow:ellipsis;white-space:nowrap;font-weight:500;overflow:hidden}.language{letter-spacing:.06em;text-transform:uppercase;font-weight:600}.body{min-width:0;max-height:var(--max-height);display:flex;overflow-y:auto}.gutter,pre{font-family:var(--jl-font-mono);font-variant-ligatures:no-contextual;padding:14px 16px;font-size:12.5px;line-height:1.7}.gutter{color:var(--jl-muted);text-align:right;white-space:pre;-webkit-user-select:none;user-select:none;flex:none;padding-right:4px;display:none}pre{min-width:0;color:var(--jl-text);tab-size:2;flex:1;margin:0;padding-right:48px;overflow-x:auto}:host([line-numbers]) .gutter{display:block}:host(:not([has-header])) header{display:none}:host([wrap]) pre{white-space:pre-wrap;overflow-wrap:anywhere}.copy{background:var(--jl-surface-2);border-radius:var(--jl-radius-sm);position:absolute;top:6px;right:6px}:host(:not([has-header])) .copy{opacity:.6;transition:opacity var(--jl-fast) var(--jl-ease)}:host(:not([has-header])) figure:hover .copy,.copy:focus-within{opacity:1}.tok-comment{color:var(--jl-code-comment);font-style:italic}.tok-string{color:var(--jl-code-string)}.tok-number{color:var(--jl-code-number)}.tok-keyword{color:var(--jl-code-keyword)}.tok-tag{color:var(--jl-code-tag)}.tok-attribute{color:var(--jl-code-attribute)}.tok-property{color:var(--jl-code-property)}.tok-function{color:var(--jl-code-function)}.tok-punctuation{color:var(--jl-muted)}";
|
|
3
3
|
export { jl_code_block_default as default };
|
|
@@ -73,6 +73,8 @@ export declare class JlCombobox extends JlFormControl {
|
|
|
73
73
|
onDisconnect(): void;
|
|
74
74
|
protected resetValue(): void;
|
|
75
75
|
protected setDisabledByForm(disabled: boolean): void;
|
|
76
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
77
|
+
private isOff;
|
|
76
78
|
protected drawTexts(): void;
|
|
77
79
|
private renderEmptyText;
|
|
78
80
|
private isOpen;
|
|
@@ -123,4 +125,6 @@ export declare class JlCombobox extends JlFormControl {
|
|
|
123
125
|
private renderValidity;
|
|
124
126
|
private renderClear;
|
|
125
127
|
private renderDisabled;
|
|
128
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
129
|
+
private drawDisabled;
|
|
126
130
|
}
|
|
@@ -6,7 +6,7 @@ import { followAnchor } from "../lib/floating.js";
|
|
|
6
6
|
import { registerIcons } from "../lib/icons.js";
|
|
7
7
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
8
8
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
9
|
-
import { setOrRemove, uniqueId } from "../lib/dom.js";
|
|
9
|
+
import { setAriaFlag, setOrRemove, uniqueId } from "../lib/dom.js";
|
|
10
10
|
import { keepInView } from "../lib/keep-in-view.js";
|
|
11
11
|
import { edgeEnabledIndex, filterOptions, foldText, matchParts, nextEnabledIndex } from "../lib/option-filter.js";
|
|
12
12
|
import jl_combobox_default from "./jl-combobox.css.js";
|
|
@@ -58,7 +58,7 @@ var JlCombobox = class extends JlFormControl {
|
|
|
58
58
|
/** What the list says when no option matches; jlib's own when empty. */
|
|
59
59
|
emptyText = this.useChange("", () => this.renderEmptyText(), { attribute: "empty-text" });
|
|
60
60
|
required = this.useChange(false, (value) => {
|
|
61
|
-
this._refs.native
|
|
61
|
+
setAriaFlag(this._refs.native, "aria-required", value);
|
|
62
62
|
this.reflect("required", value);
|
|
63
63
|
this.renderValidity();
|
|
64
64
|
}, { attribute: "required" });
|
|
@@ -66,7 +66,7 @@ var JlCombobox = class extends JlFormControl {
|
|
|
66
66
|
/** Draws the field in the danger colour, for an error the page found itself. */
|
|
67
67
|
invalid = this.useChange(false, (value) => {
|
|
68
68
|
this.reflect("invalid", value);
|
|
69
|
-
this._refs.native
|
|
69
|
+
setAriaFlag(this._refs.native, "aria-invalid", value);
|
|
70
70
|
}, { attribute: "invalid" });
|
|
71
71
|
size = this.useChange("md", (value) => this.reflect("size", value), {
|
|
72
72
|
attribute: "size",
|
|
@@ -77,6 +77,7 @@ var JlCombobox = class extends JlFormControl {
|
|
|
77
77
|
active: NONE,
|
|
78
78
|
/** The option element the arrows reached: it alone is marked, wherever the filter put it. */
|
|
79
79
|
activeItem: null,
|
|
80
|
+
disabledByForm: false,
|
|
80
81
|
matches: [],
|
|
81
82
|
opening: new AbortController(),
|
|
82
83
|
/** What people typed since the last choice; empty shows every option. */
|
|
@@ -174,9 +175,12 @@ var JlCombobox = class extends JlFormControl {
|
|
|
174
175
|
this.value.set(this.getAttribute("value") ?? "");
|
|
175
176
|
}
|
|
176
177
|
setDisabledByForm(disabled) {
|
|
177
|
-
this.
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
this._state.disabledByForm = disabled;
|
|
179
|
+
this.whenRendered(() => this.drawDisabled());
|
|
180
|
+
}
|
|
181
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
182
|
+
isOff() {
|
|
183
|
+
return this.disabled.get() || this._state.disabledByForm;
|
|
180
184
|
}
|
|
181
185
|
drawTexts() {
|
|
182
186
|
this._refs.clear.setAttribute("aria-label", jlText("clear"));
|
|
@@ -280,7 +284,7 @@ var JlCombobox = class extends JlFormControl {
|
|
|
280
284
|
* it; otherwise the chosen option is. With free text allowed and nothing matching, the list stays closed.
|
|
281
285
|
*/
|
|
282
286
|
openList(typing) {
|
|
283
|
-
if (this.
|
|
287
|
+
if (this.isOff() || this.options.get().length === 0 && this._state.query === "") return;
|
|
284
288
|
this.renderOptions();
|
|
285
289
|
const matches = this._state.matches;
|
|
286
290
|
const autoActive = typing && this._state.query.trim() !== "" && !this.allowCustom.get();
|
|
@@ -348,8 +352,12 @@ var JlCombobox = class extends JlFormControl {
|
|
|
348
352
|
commitText() {
|
|
349
353
|
this.closeList();
|
|
350
354
|
const text = this._refs.native.value.trim();
|
|
351
|
-
const exact = this.optionWithLabel(text);
|
|
352
355
|
this._state.query = "";
|
|
356
|
+
if (text === this.displayOf(this.value.get()).trim()) {
|
|
357
|
+
this.renderValue();
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const exact = this.optionWithLabel(text);
|
|
353
361
|
if (exact !== void 0) {
|
|
354
362
|
this.commit(exact.value);
|
|
355
363
|
return;
|
|
@@ -461,12 +469,16 @@ var JlCombobox = class extends JlFormControl {
|
|
|
461
469
|
}
|
|
462
470
|
renderClear() {
|
|
463
471
|
const native = this._refs.native;
|
|
464
|
-
this._refs.clear.hidden = !(this.clearable.get() && !this.
|
|
472
|
+
this._refs.clear.hidden = !(this.clearable.get() && !this.isOff() && native.value !== "");
|
|
465
473
|
}
|
|
466
474
|
renderDisabled(disabled) {
|
|
467
|
-
this._refs.native.disabled = disabled;
|
|
468
|
-
this._refs.toggle.disabled = disabled;
|
|
469
475
|
this.reflect("disabled", disabled);
|
|
476
|
+
this.drawDisabled();
|
|
477
|
+
}
|
|
478
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
479
|
+
drawDisabled() {
|
|
480
|
+
this._refs.native.disabled = this.isOff();
|
|
481
|
+
this._refs.toggle.disabled = this.isOff();
|
|
470
482
|
this.closeList();
|
|
471
483
|
this.renderClear();
|
|
472
484
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/molecules/jl-copy-button.css?inline
|
|
2
|
-
var jl_copy_button_default = ":host{display:inline-flex}:host([copied]) jl-button{--jl-accent:var(--jl-ok);--jl-accent-soft:var(--jl-ok-soft)}";
|
|
2
|
+
var jl_copy_button_default = ":host{display:inline-flex}:host([copied]) jl-button{--jl-accent:var(--jl-ok);--jl-accent-soft:var(--jl-ok-soft)}:host([failed]) jl-button{--jl-accent:var(--jl-danger);--jl-accent-soft:var(--jl-danger-soft)}";
|
|
3
3
|
export { jl_copy_button_default as default };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { JlElement } from '../base/jl-element';
|
|
2
2
|
import type { ControlSize } from '../types/options.types';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Copies a text to the clipboard, and says so for a moment. Fires `copy` with the text. Where the clipboard refuses
|
|
5
|
+
* (a page served without https has none, a permission denied), the button says that it could not copy.
|
|
6
|
+
*/
|
|
4
7
|
export declare class JlCopyButton extends JlElement {
|
|
5
8
|
static readonly selector = "jl-copy-button";
|
|
6
9
|
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
@@ -19,14 +22,18 @@ export declare class JlCopyButton extends JlElement {
|
|
|
19
22
|
get(): ControlSize;
|
|
20
23
|
set(setter: ((prevState: ControlSize) => ControlSize) | ControlSize): void;
|
|
21
24
|
}>>;
|
|
22
|
-
private readonly
|
|
25
|
+
private readonly _state;
|
|
23
26
|
private readonly _refs;
|
|
24
27
|
templateHtml(): Node;
|
|
25
28
|
templateCss(): string;
|
|
26
29
|
onConnect(): void;
|
|
30
|
+
/** The timer goes, and what it would have taken back with it: the button returns as a copy button. */
|
|
27
31
|
onDisconnect(): void;
|
|
28
|
-
/** Copies the value now; resolves once the clipboard has it. */
|
|
32
|
+
/** Copies the value now; resolves once the clipboard has it, and rejects when the clipboard refuses. */
|
|
29
33
|
copy(): Promise<void>;
|
|
30
34
|
protected drawTexts(): void;
|
|
31
|
-
|
|
35
|
+
/** A press has no caller to tell of a refusal: the button says it, where `copy()` rejects. */
|
|
36
|
+
private copyOnPress;
|
|
37
|
+
/** Shows what the press came to, for a moment when there is something to say. */
|
|
38
|
+
private say;
|
|
32
39
|
}
|
|
@@ -7,17 +7,33 @@ import { CONTROL_SIZES } from "../lib/options.js";
|
|
|
7
7
|
import { JlButton } from "../atoms/jl-button.js";
|
|
8
8
|
import jl_copy_button_default from "./jl-copy-button.css.js";
|
|
9
9
|
import { css } from "@jadis/core";
|
|
10
|
-
import { Check, Copy } from "lucide";
|
|
10
|
+
import { Check, Copy, X } from "lucide";
|
|
11
11
|
import { jsx } from "@jadis/core/jsx-runtime";
|
|
12
12
|
// src/molecules/jl-copy-button.tsx
|
|
13
13
|
registerIcons({
|
|
14
14
|
check: Check,
|
|
15
|
-
copy: Copy
|
|
15
|
+
copy: Copy,
|
|
16
|
+
x: X
|
|
16
17
|
});
|
|
17
18
|
var CONFIRM_MS = 1600;
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
var OUTCOME_LOOKS = {
|
|
20
|
+
copied: {
|
|
21
|
+
icon: "check",
|
|
22
|
+
text: "copied"
|
|
23
|
+
},
|
|
24
|
+
failed: {
|
|
25
|
+
icon: "x",
|
|
26
|
+
text: "copyFailed"
|
|
27
|
+
},
|
|
28
|
+
idle: {
|
|
29
|
+
icon: "copy",
|
|
30
|
+
text: "copy"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Copies a text to the clipboard, and says so for a moment. Fires `copy` with the text. Where the clipboard refuses
|
|
35
|
+
* (a page served without https has none, a permission denied), the button says that it could not copy.
|
|
36
|
+
*/
|
|
21
37
|
var JlCopyButton = class extends JlElement {
|
|
22
38
|
static selector = "jl-copy-button";
|
|
23
39
|
events = this.useEvents();
|
|
@@ -28,44 +44,54 @@ var JlCopyButton = class extends JlElement {
|
|
|
28
44
|
attribute: "size",
|
|
29
45
|
parse: oneOf(CONTROL_SIZES, "sm")
|
|
30
46
|
});
|
|
31
|
-
|
|
47
|
+
_state = {
|
|
48
|
+
outcome: "idle",
|
|
49
|
+
timer: 0
|
|
50
|
+
};
|
|
32
51
|
_refs = this.useRefs((ref) => ({ button: ref(JlButton) }));
|
|
33
52
|
templateHtml() {
|
|
34
53
|
return /* @__PURE__ */ jsx(JlButton, {
|
|
35
54
|
variant: "ghost",
|
|
36
|
-
icon:
|
|
55
|
+
icon: OUTCOME_LOOKS.idle.icon
|
|
37
56
|
});
|
|
38
57
|
}
|
|
39
58
|
templateCss() {
|
|
40
59
|
return css`${BASE_STYLES}${jl_copy_button_default}`;
|
|
41
60
|
}
|
|
42
61
|
onConnect() {
|
|
43
|
-
this._refs.button.events.register("press", () => void this.
|
|
62
|
+
this._refs.button.events.register("press", () => void this.copyOnPress());
|
|
44
63
|
}
|
|
64
|
+
/** The timer goes, and what it would have taken back with it: the button returns as a copy button. */
|
|
45
65
|
onDisconnect() {
|
|
46
|
-
|
|
66
|
+
this.say("idle");
|
|
47
67
|
}
|
|
48
|
-
/** Copies the value now; resolves once the clipboard has it. */
|
|
68
|
+
/** Copies the value now; resolves once the clipboard has it, and rejects when the clipboard refuses. */
|
|
49
69
|
async copy() {
|
|
50
70
|
const text = this.value.get();
|
|
51
71
|
await navigator.clipboard.writeText(text);
|
|
52
72
|
this.events.emit("copy", text);
|
|
53
|
-
this.
|
|
73
|
+
this.say("copied");
|
|
54
74
|
}
|
|
55
75
|
drawTexts() {
|
|
56
|
-
this._refs.button.hint.set(jlText(this.
|
|
76
|
+
this._refs.button.hint.set(jlText(OUTCOME_LOOKS[this._state.outcome].text));
|
|
77
|
+
}
|
|
78
|
+
/** A press has no caller to tell of a refusal: the button says it, where `copy()` rejects. */
|
|
79
|
+
async copyOnPress() {
|
|
80
|
+
try {
|
|
81
|
+
await this.copy();
|
|
82
|
+
} catch {
|
|
83
|
+
this.say("failed");
|
|
84
|
+
}
|
|
57
85
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.
|
|
86
|
+
/** Shows what the press came to, for a moment when there is something to say. */
|
|
87
|
+
say(outcome) {
|
|
88
|
+
this._state.outcome = outcome;
|
|
89
|
+
this._refs.button.icon.set(OUTCOME_LOOKS[outcome].icon);
|
|
90
|
+
this.reflect("copied", outcome === "copied");
|
|
91
|
+
this.reflect("failed", outcome === "failed");
|
|
62
92
|
this.drawTexts();
|
|
63
|
-
window.clearTimeout(this.
|
|
64
|
-
this.
|
|
65
|
-
button.icon.set(COPY_ICON);
|
|
66
|
-
this.reflect("copied", false);
|
|
67
|
-
this.drawTexts();
|
|
68
|
-
}, CONFIRM_MS);
|
|
93
|
+
window.clearTimeout(this._state.timer);
|
|
94
|
+
if (outcome !== "idle") this._state.timer = window.setTimeout(() => this.say("idle"), CONFIRM_MS);
|
|
69
95
|
}
|
|
70
96
|
};
|
|
71
97
|
JlCopyButton.register();
|
|
@@ -84,6 +84,8 @@ export declare class JlDatePicker extends JlFormControl {
|
|
|
84
84
|
onDisconnect(): void;
|
|
85
85
|
protected resetValue(): void;
|
|
86
86
|
protected setDisabledByForm(disabled: boolean): void;
|
|
87
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
88
|
+
private isOff;
|
|
87
89
|
private isOpen;
|
|
88
90
|
/** Down (with or without Alt) opens the calendar. */
|
|
89
91
|
private onKey;
|
|
@@ -119,4 +121,6 @@ export declare class JlDatePicker extends JlFormControl {
|
|
|
119
121
|
private renderMissing;
|
|
120
122
|
private renderClear;
|
|
121
123
|
private renderDisabled;
|
|
124
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
125
|
+
private drawDisabled;
|
|
122
126
|
}
|
|
@@ -7,7 +7,7 @@ import { followAnchor } from "../lib/floating.js";
|
|
|
7
7
|
import { registerIcons } from "../lib/icons.js";
|
|
8
8
|
import { CONTROL_SIZES } from "../lib/options.js";
|
|
9
9
|
import { JlIcon } from "../atoms/jl-icon.js";
|
|
10
|
-
import { setOrRemove, uniqueId } from "../lib/dom.js";
|
|
10
|
+
import { setAriaFlag, setOrRemove, uniqueId } from "../lib/dom.js";
|
|
11
11
|
import { NUMERIC_DATE, compareDates, dateOrder, datePattern, formatDate, isDateText, parseIsoDate, parseTypedDate, toIsoDate } from "../lib/calendar.js";
|
|
12
12
|
import { JlCalendar } from "./jl-calendar.js";
|
|
13
13
|
import jl_date_picker_default from "./jl-date-picker.css.js";
|
|
@@ -59,7 +59,7 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
59
59
|
/** Shows a button that empties the field while it holds a date. */
|
|
60
60
|
clearable = this.useChange(false, () => this.renderClear(), { attribute: "clearable" });
|
|
61
61
|
required = this.useChange(false, (value) => {
|
|
62
|
-
this._refs.native
|
|
62
|
+
setAriaFlag(this._refs.native, "aria-required", value);
|
|
63
63
|
this.reflect("required", value);
|
|
64
64
|
this.renderValidity();
|
|
65
65
|
}, { attribute: "required" });
|
|
@@ -67,7 +67,7 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
67
67
|
/** Draws the field in the danger colour, for an error the page found itself. */
|
|
68
68
|
invalid = this.useChange(false, (value) => {
|
|
69
69
|
this.reflect("invalid", value);
|
|
70
|
-
this._refs.native
|
|
70
|
+
setAriaFlag(this._refs.native, "aria-invalid", value);
|
|
71
71
|
}, { attribute: "invalid" });
|
|
72
72
|
size = this.useChange("md", (value) => this.reflect("size", value), {
|
|
73
73
|
attribute: "size",
|
|
@@ -75,6 +75,7 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
75
75
|
});
|
|
76
76
|
_popupId = uniqueId("jl-date-picker-popup");
|
|
77
77
|
_state = {
|
|
78
|
+
disabledByForm: false,
|
|
78
79
|
opening: new AbortController(),
|
|
79
80
|
/** Whether a press on the button should open: read before the press closes the calendar by light dismiss. */
|
|
80
81
|
openOnPress: null
|
|
@@ -181,11 +182,12 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
181
182
|
this.value.set(this.getAttribute("value") ?? "");
|
|
182
183
|
}
|
|
183
184
|
setDisabledByForm(disabled) {
|
|
184
|
-
|
|
185
|
-
this.whenRendered(() =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
this._state.disabledByForm = disabled;
|
|
186
|
+
this.whenRendered(() => this.drawDisabled());
|
|
187
|
+
}
|
|
188
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
189
|
+
isOff() {
|
|
190
|
+
return this.disabled.get() || this._state.disabledByForm;
|
|
189
191
|
}
|
|
190
192
|
isOpen() {
|
|
191
193
|
return this._refs.popup.matches(":popover-open");
|
|
@@ -253,7 +255,7 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
253
255
|
return this._refs.popup.querySelector(JlCalendar.selector);
|
|
254
256
|
}
|
|
255
257
|
openPopup() {
|
|
256
|
-
if (this.isOpen() || this.
|
|
258
|
+
if (this.isOpen() || this.isOff()) return;
|
|
257
259
|
this.commitText();
|
|
258
260
|
const calendar = this.calendar();
|
|
259
261
|
calendar.value.set(this.validIso());
|
|
@@ -348,13 +350,17 @@ var JlDatePicker = class extends JlFormControl {
|
|
|
348
350
|
this.internals.setValidity({});
|
|
349
351
|
}
|
|
350
352
|
renderClear() {
|
|
351
|
-
const editable = !this.
|
|
353
|
+
const editable = !this.isOff();
|
|
352
354
|
this._refs.clear.hidden = !(this.clearable.get() && editable && this._refs.native.value !== "");
|
|
353
355
|
}
|
|
354
356
|
renderDisabled(disabled) {
|
|
355
|
-
this._refs.native.disabled = disabled;
|
|
356
|
-
this._refs.open.disabled = disabled;
|
|
357
357
|
this.reflect("disabled", disabled);
|
|
358
|
+
this.drawDisabled();
|
|
359
|
+
}
|
|
360
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
361
|
+
drawDisabled() {
|
|
362
|
+
this._refs.native.disabled = this.isOff();
|
|
363
|
+
this._refs.open.disabled = this.isOff();
|
|
358
364
|
this.closePopup();
|
|
359
365
|
this.renderClear();
|
|
360
366
|
}
|
|
@@ -46,8 +46,12 @@ export declare class JlField extends JlElement {
|
|
|
46
46
|
private syncControl;
|
|
47
47
|
/** Runs `sync` on the control in the slot, when there is one. */
|
|
48
48
|
private withControl;
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Names the control for screen readers with the field's label, unless it has a label of its own: one written as
|
|
51
|
+
* an attribute, or given in code (a JSX prop writes no attribute), which is any label this field did not give.
|
|
52
|
+
*/
|
|
50
53
|
private syncLabel;
|
|
54
|
+
private hasOwnLabel;
|
|
51
55
|
/** Marks the control invalid, remembering it unless the page had marked it already. */
|
|
52
56
|
private invalidate;
|
|
53
57
|
/** Marks the control invalid while there is an error, and clears only what the field itself marked. */
|
|
@@ -43,7 +43,14 @@ var JlField = class extends JlElement {
|
|
|
43
43
|
attribute: "orientation",
|
|
44
44
|
parse: oneOf(FIELD_ORIENTATIONS, "vertical")
|
|
45
45
|
});
|
|
46
|
-
_state = {
|
|
46
|
+
_state = {
|
|
47
|
+
invalidated: null,
|
|
48
|
+
/** The control this field named, and with which label: a label of the control's own is told from it. */
|
|
49
|
+
named: {
|
|
50
|
+
control: null,
|
|
51
|
+
label: ""
|
|
52
|
+
}
|
|
53
|
+
};
|
|
47
54
|
_refs = this.useRefs((ref) => ({
|
|
48
55
|
asterisk: ref(".asterisk"),
|
|
49
56
|
errorRegion: ref(".error-region"),
|
|
@@ -128,12 +135,24 @@ var JlField = class extends JlElement {
|
|
|
128
135
|
const control = this.control();
|
|
129
136
|
if (control !== null) sync(control);
|
|
130
137
|
}
|
|
131
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Names the control for screen readers with the field's label, unless it has a label of its own: one written as
|
|
140
|
+
* an attribute, or given in code (a JSX prop writes no attribute), which is any label this field did not give.
|
|
141
|
+
*/
|
|
132
142
|
syncLabel(control) {
|
|
133
143
|
const input = inputOf(control, "label");
|
|
134
|
-
const
|
|
135
|
-
if (input === null ||
|
|
136
|
-
|
|
144
|
+
const shown = control.hasAttribute("label") || VISIBLE_LABEL_TAGS.includes(control.localName);
|
|
145
|
+
if (input === null || shown || this.hasOwnLabel(control, input.get())) return;
|
|
146
|
+
const label = this.label.get();
|
|
147
|
+
this._state.named = {
|
|
148
|
+
control,
|
|
149
|
+
label
|
|
150
|
+
};
|
|
151
|
+
if (input.get() !== label) input.set(label);
|
|
152
|
+
}
|
|
153
|
+
hasOwnLabel(control, label) {
|
|
154
|
+
const { named } = this._state;
|
|
155
|
+
return label !== "" && !(named.control === control && named.label === label);
|
|
137
156
|
}
|
|
138
157
|
/** Marks the control invalid, remembering it unless the page had marked it already. */
|
|
139
158
|
invalidate(control, input) {
|
|
@@ -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(
|
|
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 };
|
|
@@ -74,6 +74,8 @@ export declare class JlFileDrop extends JlFormControl {
|
|
|
74
74
|
onDisconnect(): void;
|
|
75
75
|
protected resetValue(): void;
|
|
76
76
|
protected setDisabledByForm(disabled: boolean): void;
|
|
77
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
78
|
+
private isOff;
|
|
77
79
|
private canDrop;
|
|
78
80
|
private onDragEnter;
|
|
79
81
|
private onDragOver;
|
|
@@ -96,4 +98,6 @@ export declare class JlFileDrop extends JlFormControl {
|
|
|
96
98
|
private renderFormValue;
|
|
97
99
|
private renderValidity;
|
|
98
100
|
private renderDisabled;
|
|
101
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
102
|
+
private drawDisabled;
|
|
99
103
|
}
|
|
@@ -84,6 +84,7 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
84
84
|
};
|
|
85
85
|
_state = {
|
|
86
86
|
depth: 0,
|
|
87
|
+
disabledByForm: false,
|
|
87
88
|
files: [],
|
|
88
89
|
refused: []
|
|
89
90
|
};
|
|
@@ -108,7 +109,7 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
108
109
|
/** Opens the file chooser. */
|
|
109
110
|
browse() {
|
|
110
111
|
this.whenRendered(() => {
|
|
111
|
-
if (!this.
|
|
112
|
+
if (!this.isOff()) this._refs.picker.click();
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
@@ -198,12 +199,15 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
198
199
|
this.setFiles([]);
|
|
199
200
|
}
|
|
200
201
|
setDisabledByForm(disabled) {
|
|
201
|
-
this.
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
this._state.disabledByForm = disabled;
|
|
203
|
+
this.whenRendered(() => this.drawDisabled());
|
|
204
|
+
}
|
|
205
|
+
/** Disabled by its own input, or by a `<fieldset disabled>` around it. */
|
|
206
|
+
isOff() {
|
|
207
|
+
return this.disabled.get() || this._state.disabledByForm;
|
|
204
208
|
}
|
|
205
209
|
canDrop(event) {
|
|
206
|
-
return hasFiles(event) && !this.
|
|
210
|
+
return hasFiles(event) && !this.isOff();
|
|
207
211
|
}
|
|
208
212
|
onDragEnter(event) {
|
|
209
213
|
if (!this.canDrop(event)) return;
|
|
@@ -224,7 +228,7 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
224
228
|
event.preventDefault();
|
|
225
229
|
this._state.depth = 0;
|
|
226
230
|
this.reflect("dragging", false);
|
|
227
|
-
if (this.
|
|
231
|
+
if (this.isOff()) return;
|
|
228
232
|
this.take([...event.dataTransfer?.files ?? []]);
|
|
229
233
|
}
|
|
230
234
|
onPicked() {
|
|
@@ -276,7 +280,7 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
276
280
|
}
|
|
277
281
|
renderFiles() {
|
|
278
282
|
const files = this._state.files;
|
|
279
|
-
const editable = !this.
|
|
283
|
+
const editable = !this.isOff();
|
|
280
284
|
const locale = pageLocale();
|
|
281
285
|
this._refs.files.hidden = files.length === 0;
|
|
282
286
|
this._refs.files.replaceChildren(...files.map((file, index) => /* @__PURE__ */ jsxs("li", {
|
|
@@ -368,8 +372,12 @@ var JlFileDrop = class extends JlFormControl {
|
|
|
368
372
|
this.internals.setValidity({});
|
|
369
373
|
}
|
|
370
374
|
renderDisabled(disabled) {
|
|
371
|
-
this._refs.browse.disabled = disabled;
|
|
372
375
|
this.reflect("disabled", disabled);
|
|
376
|
+
this.drawDisabled();
|
|
377
|
+
}
|
|
378
|
+
/** Without the attribute: the form says its state before the `disabled` input has taken the attribute's change. */
|
|
379
|
+
drawDisabled() {
|
|
380
|
+
this._refs.browse.disabled = this.isOff();
|
|
373
381
|
this.renderFiles();
|
|
374
382
|
}
|
|
375
383
|
};
|