@syware/jlib 0.10.0 → 0.11.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.
@@ -1,5 +1,6 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
+ import { elementInternals } from "../lib/internals.js";
3
4
  import { oneOf } from "../lib/attributes.js";
4
5
  import { CONTROL_SIZES } from "../lib/options.js";
5
6
  import { JlIcon } from "./jl-icon.js";
@@ -75,7 +76,7 @@ var JlButton = class extends JlElement {
75
76
  target = this.useChange("", () => this.renderLink(), { attribute: "target" });
76
77
  /** With an `href`, saves what it points to as a file of this name instead of opening it. */
77
78
  download = this.useChange("", () => this.renderLink(), { attribute: "download" });
78
- _internals = this.attachInternals();
79
+ _internals = elementInternals(this);
79
80
  _refs = this.useRefs((ref) => ({
80
81
  button: ref("button"),
81
82
  content: ref(".content"),
@@ -27,5 +27,6 @@ export declare class JlIcon extends JlElement {
27
27
  templateHtml(): Node;
28
28
  templateCss(): string;
29
29
  private draw;
30
+ private drawNow;
30
31
  private setAccessibleName;
31
32
  }
@@ -1,6 +1,6 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
- import { iconElement } from "../lib/icons.js";
3
+ import { hasIcon, iconElement } from "../lib/icons.js";
4
4
  import jl_icon_default from "./jl-icon.css.js";
5
5
  import { css } from "@jadis/core";
6
6
  import { jsx } from "@jadis/core/jsx-runtime";
@@ -26,6 +26,15 @@ var JlIcon = class extends JlElement {
26
26
  return css`${BASE_STYLES}${jl_icon_default}`;
27
27
  }
28
28
  draw() {
29
+ const name = this.name.get();
30
+ if (name !== "" && !hasIcon(name)) {
31
+ this._refs.icon.replaceChildren();
32
+ queueMicrotask(() => this.drawNow());
33
+ return;
34
+ }
35
+ this.drawNow();
36
+ }
37
+ drawNow() {
29
38
  const name = this.name.get();
30
39
  this._refs.icon.replaceChildren(...name === "" ? [] : [iconElement(name, this.size.get())]);
31
40
  }
@@ -1,3 +1,5 @@
1
+ /** The internals of an element, or inert ones where the DOM has no `attachInternals` (happy-dom on a server). */
2
+ export declare function elementInternals(element: HTMLElement): ElementInternals;
1
3
  /**
2
4
  * The internals of a form-associated element. Where the DOM gives them no form methods (jsdom), they get ones that
3
5
  * keep nothing and find every value valid; a browser's are left as they are.
@@ -7,12 +7,26 @@ var FORM_METHODS = {
7
7
  setValidity: () => void 0
8
8
  };
9
9
  /**
10
+ * Internals for a DOM that gives none (happy-dom, which renders pages on a server): they belong to no form and keep
11
+ * the role and ARIA values written on them, which the server's markup has no place for anyway.
12
+ */
13
+ var inertInternals = () => {
14
+ return {
15
+ form: null,
16
+ validationMessage: ""
17
+ };
18
+ };
19
+ /** The internals of an element, or inert ones where the DOM has no `attachInternals` (happy-dom on a server). */
20
+ function elementInternals(element) {
21
+ return typeof element.attachInternals === "function" ? element.attachInternals() : inertInternals();
22
+ }
23
+ /**
10
24
  * The internals of a form-associated element. Where the DOM gives them no form methods (jsdom), they get ones that
11
25
  * keep nothing and find every value valid; a browser's are left as they are.
12
26
  */
13
27
  function formInternals(element) {
14
- const internals = element.attachInternals();
28
+ const internals = elementInternals(element);
15
29
  if (typeof internals.setFormValue === "function") return internals;
16
30
  return Object.assign(internals, FORM_METHODS);
17
31
  }
18
- export { formInternals };
32
+ export { elementInternals, formInternals };
@@ -1,5 +1,6 @@
1
1
  import { BASE_STYLES } from "../styles/shared.js";
2
2
  import { JlElement } from "../base/jl-element.js";
3
+ import { elementInternals } from "../lib/internals.js";
3
4
  import jl_tab_panel_default from "./jl-tab-panel.css.js";
4
5
  import { css } from "@jadis/core";
5
6
  import { jsx } from "@jadis/core/jsx-runtime";
@@ -23,7 +24,7 @@ var JlTabPanel = class extends JlElement {
23
24
  /** A short count or word after the tab's text: "3", "New". */
24
25
  badge = this.useChange("", (value) => this.reflect("badge", value), { attribute: "badge" });
25
26
  disabled = this.useChange(false, (value) => this.reflect("disabled", value), { attribute: "disabled" });
26
- _internals = Object.assign(this.attachInternals(), { role: ROLE });
27
+ _internals = Object.assign(elementInternals(this), { role: ROLE });
27
28
  templateHtml() {
28
29
  return /* @__PURE__ */ jsx("slot", {});
29
30
  }
@@ -1,3 +1,3 @@
1
1
  // src/organisms/jl-page-outlet.css?inline
2
- var jl_page_outlet_default = ":host{grid-template:1fr/minmax(0,1fr);min-height:100%;display:grid;position:relative}::slotted(*){grid-area:1/1}.line{z-index:1;grid-area:1/1;align-self:start;position:sticky;top:0}.next{visibility:hidden;height:0;position:absolute;inset:0 0 auto;overflow:hidden}";
2
+ var jl_page_outlet_default = ":host{--line-top:0px;grid-template:1fr/minmax(0,1fr);min-height:100%;display:grid;position:relative}::slotted(*){grid-area:1/1}.line{top:var(--line-top);z-index:1;grid-area:1/1;align-self:start;position:sticky}.next{visibility:hidden;height:0;position:absolute;inset:0 0 auto;overflow:hidden}";
3
3
  export { jl_page_outlet_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syware/jlib",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "A tree-shakeable component library on Jadis and native Web Components, organised in atomic design",
5
5
  "keywords": [
6
6
  "web-components",
@@ -95,7 +95,7 @@
95
95
  "@biomejs/biome": "^2.6.3",
96
96
  "@fontsource-variable/jetbrains-mono": "^5.3.0",
97
97
  "@fontsource-variable/manrope": "^5.3.0",
98
- "@jadis/core": "^1.6.0",
98
+ "@jadis/core": "^1.8.0",
99
99
  "@types/node": "^24.13.3",
100
100
  "playwright-core": "^1.64.1",
101
101
  "typescript": "^7.0.2",