@threadlabs/looma 0.45.0 → 0.45.1

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/docs/catalog.json CHANGED
@@ -463,7 +463,7 @@
463
463
  ],
464
464
  "schemaVersion": 1,
465
465
  "package": "@threadlabs/looma",
466
- "version": "0.45.0",
466
+ "version": "0.45.1",
467
467
  "groups": [
468
468
  {
469
469
  "id": "layout",
@@ -16879,7 +16879,7 @@
16879
16879
  "tag": "ui-section",
16880
16880
  "package": "@threadlabs/looma",
16881
16881
  "root": "section",
16882
- "description": "A part of a view: an `h2` `heading`, an optional `description`, `actions` for the whole section, and its content. `variant=\"card\"` sets it on a bordered surface, for a settings group; `variant=\"divided\"` rules it off from the section before, for a long form; `tone=\"danger\"` marks destructive actions. Space sections with a Stack.",
16882
+ "description": "A part of a view: an `h2` `heading`, an optional `description`, `actions` for the whole section, and its content. `variant=\"fieldset\"` joins the heading to a rounded frame with a native legend, for a named settings group. Its description and actions stay inside the frame; long headings wrap without covering the content. `variant=\"card\"` sets it on a bordered surface; `variant=\"divided\"` rules it off from the section before, for a long form; `tone=\"danger\"` marks destructive actions. A fieldset is announced as a group named by its legend. Use `aria-label` when omitting the heading. Space sections with a Stack.",
16883
16883
  "designTokens": {
16884
16884
  "sources": [
16885
16885
  "packages/looma/src/components/ui-section/ui-section.html"
@@ -16922,6 +16922,9 @@
16922
16922
  {
16923
16923
  "name": "--ui-font-size-lg"
16924
16924
  },
16925
+ {
16926
+ "name": "--ui-font-size-md"
16927
+ },
16925
16928
  {
16926
16929
  "name": "--ui-font-size-sm"
16927
16930
  },
@@ -16971,7 +16974,7 @@
16971
16974
  {
16972
16975
  "name": "tone",
16973
16976
  "property": "tone",
16974
- "description": "danger marks a section of destructive actions (a danger zone): its heading and a card's border take the danger colour.",
16977
+ "description": "danger marks a section of destructive actions (a danger zone): its heading and a framed section's border take the danger colour.",
16975
16978
  "type": "keyword",
16976
16979
  "default": "neutral",
16977
16980
  "options": [
@@ -16982,13 +16985,14 @@
16982
16985
  {
16983
16986
  "name": "variant",
16984
16987
  "property": "variant",
16985
- "description": "How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided rules it off from the section before it, for a long form.",
16988
+ "description": "How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided rules it off from the section before it, for a long form. fieldset joins the heading to a bordered frame using a native legend.",
16986
16989
  "type": "keyword",
16987
16990
  "default": "plain",
16988
16991
  "options": [
16989
16992
  "plain",
16990
16993
  "card",
16991
- "divided"
16994
+ "divided",
16995
+ "fieldset"
16992
16996
  ]
16993
16997
  }
16994
16998
  ],
@@ -17001,7 +17005,7 @@
17001
17005
  },
17002
17006
  {
17003
17007
  "name": "tone",
17004
- "description": "danger marks a section of destructive actions (a danger zone): its heading and a card's border take the danger colour.",
17008
+ "description": "danger marks a section of destructive actions (a danger zone): its heading and a framed section's border take the danger colour.",
17005
17009
  "type": "\"neutral\" | \"danger\"",
17006
17010
  "default": "neutral",
17007
17011
  "options": [
@@ -17011,13 +17015,14 @@
17011
17015
  },
17012
17016
  {
17013
17017
  "name": "variant",
17014
- "description": "How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided rules it off from the section before it, for a long form.",
17015
- "type": "\"plain\" | \"card\" | \"divided\"",
17018
+ "description": "How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided rules it off from the section before it, for a long form. fieldset joins the heading to a bordered frame using a native legend.",
17019
+ "type": "\"plain\" | \"card\" | \"divided\" | \"fieldset\"",
17016
17020
  "default": "plain",
17017
17021
  "options": [
17018
17022
  "plain",
17019
17023
  "card",
17020
- "divided"
17024
+ "divided",
17025
+ "fieldset"
17021
17026
  ]
17022
17027
  }
17023
17028
  ],
@@ -17065,6 +17070,16 @@
17065
17070
  "resizable": false,
17066
17071
  "bindings": "",
17067
17072
  "frameworks": {}
17073
+ },
17074
+ {
17075
+ "id": "@threadlabs/looma/ui-section/03-fieldset",
17076
+ "name": "03-fieldset",
17077
+ "title": "Connected headings",
17078
+ "description": "A native legend joins the heading to the frame. Descriptions, actions and fields stay comfortably inside it, including with long titles on narrow screens.",
17079
+ "markup": "<ui-stack gap=\"l\">\n <ui-section heading=\"Profile and preferences\" variant=\"fieldset\">\n <span slot=\"description\">The details people see when you work together.</span>\n <ui-form-field>\n <label slot=\"label\" for=\"profile-name\">Display name</label>\n <ui-input id=\"profile-name\" value=\"Ada Lovelace\"></ui-input>\n </ui-form-field>\n <ui-button slot=\"actions\" variant=\"outline\" tone=\"accent\" size=\"sm\">Reset</ui-button>\n </ui-section>\n <ui-section heading=\"Notification preferences and shared workspace visibility\" variant=\"fieldset\">\n <ui-text>Choose when you hear about changes and which workspaces appear in your navigation.</ui-text>\n </ui-section>\n <ui-section heading=\"Delete account\" variant=\"fieldset\" tone=\"danger\">\n <span slot=\"description\">Permanently remove this account and its saved preferences.</span>\n <ui-button variant=\"outline\" tone=\"danger\">Delete account</ui-button>\n </ui-section>\n</ui-stack>",
17080
+ "resizable": false,
17081
+ "bindings": "",
17082
+ "frameworks": {}
17068
17083
  }
17069
17084
  ]
17070
17085
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",
@@ -16,7 +16,8 @@
16
16
  min-inline-size: 0;
17
17
  }
18
18
 
19
- :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=card"] {
19
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=card"],
20
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=fieldset"] {
20
21
  --_ui-selection-context-surface: initial;
21
22
  --_ui-selection-context-border: initial;
22
23
  --_ui-selection-context-text: initial;
@@ -26,12 +27,40 @@
26
27
  background: var(--ui-surface-raised);
27
28
  }
28
29
 
30
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=fieldset"] {
31
+ display: block !important;
32
+ box-sizing: border-box !important;
33
+ margin: 0 !important;
34
+ padding-block-start: var(--ui-space-4) !important;
35
+ }
36
+
37
+ .legend {
38
+ max-inline-size: 100%;
39
+ box-sizing: border-box !important;
40
+ padding-inline: var(--ui-space-2) !important;
41
+ margin-inline-start: calc(-1 * var(--ui-space-2)) !important;
42
+ overflow-wrap: anywhere;
43
+ }
44
+
45
+ .legend .heading {
46
+ font-size: var(--ui-font-size-md);
47
+ }
48
+
49
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=fieldset"] .head {
50
+ margin-block-end: var(--ui-space-4) !important;
51
+ }
52
+
53
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=fieldset"] .head:has(.description:empty):has(.actions:empty) {
54
+ display: none !important;
55
+ }
56
+
29
57
  :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=divided"] {
30
58
  padding-block-start: var(--ui-space-6) !important;
31
59
  border-block-start: var(--ui-border-width) solid var(--ui-border-divider);
32
60
  }
33
61
 
34
- :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=card"][data-ui-section-state~="tone=danger"] {
62
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=card"][data-ui-section-state~="tone=danger"],
63
+ :scope:where([data-component~="ui-section"])[data-ui-section-state~="variant=fieldset"][data-ui-section-state~="tone=danger"] {
35
64
  --_ui-selection-context-surface: light-dark(
36
65
  oklch(from var(--ui-danger-soft) calc(l - 0.045) calc(max(c, min(0.045, c * 3))) h),
37
66
  oklch(from var(--ui-danger-soft) calc(l + 0.045) calc(max(c, min(0.045, c * 3))) h)
@@ -12,7 +12,7 @@ export interface UiSectionElement extends HTMLElement {
12
12
  export interface UiSectionProps {
13
13
  heading?: string | null;
14
14
  tone?: "neutral" | "danger" | null;
15
- variant?: "plain" | "card" | "divided" | null;
15
+ variant?: "plain" | "card" | "divided" | "fieldset" | null;
16
16
  attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
17
17
  children?: readonly (string | Node)[];
18
18
  slots?: Readonly<Record<string, readonly (string | Node)[]>>;
@@ -1,26 +1,43 @@
1
1
  // Generated by HTML Next 1.0.0-alpha.69 for Vanilla DOM. Do not edit.
2
- import { attachGeneratedController, buildTemplate, toAttribute, toText, truthy, writeAttribute, dispose, formatOf, keywordFormat, hostState, acceptProps, manageProps, generatedInputs, project, fillSlot, checkFormat, checkString, defineComponent } from "@nextwebwg/html-next/generated-runtime";
2
+ import { attachGeneratedController, buildTemplate, toAttribute, toText, truthy, writeAttribute, dispose, formatOf, keywordFormat, hostState, acceptProps, manageProps, generatedInputs, project, fillSlot, armElement, replaceRoot, checkFormat, checkString, defineComponent } from "@nextwebwg/html-next/generated-runtime";
3
3
  import "../styles/ui-section.css";
4
4
 
5
- const T0 = ["",[],"\n ",["span",["class","head"],"\n ",["span",["class","copy"],"\n ",["h2",["class","heading"],0],"\n ",["span",["class","description"],4],"\n "],"\n ",["span",["class","actions"],4],"\n "],"\n ",["span",["class","body"],4],"\n "];
5
+ const T0 = ["",[],"\n ",["legend",["class","legend"],["h2",["class","heading"],0]],"\n ",["span",["class","head"],"\n ",["span",["class","copy"],["span",["class","description"],4]],"\n ",["span",["class","actions"],4],"\n "],"\n ",["span",["class","body"],4],"\n "];
6
6
  const T1 = ["",[]];
7
7
  const T2 = ["",[]];
8
8
  const T3 = ["",[]];
9
- let P0, P1, P2, P3;
9
+ const T4 = ["",[],"\n ",["span",["class","head"],"\n ",["span",["class","copy"],"\n ",["h2",["class","heading"],0],"\n ",["span",["class","description"],4],"\n "],"\n ",["span",["class","actions"],4],"\n "],"\n ",["span",["class","body"],4],"\n "];
10
+ const T5 = ["",[]];
11
+ const T6 = ["",[]];
12
+ const T7 = ["",[]];
13
+ let P0, P1, P2, P3, P4, P5, P6, P7;
10
14
  const S = { n: [], t: [], f: import.meta.url, g: "ui-section", b: generatedInputs };
11
- const D = { g: "ui-section", props: { "heading": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "tone": { "required":false,"values":["neutral","danger"],"default":"neutral", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat)] }, "variant": { "required":false,"values":["plain","card","divided"],"default":"plain", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat)] } } };
15
+ const A = [["fieldset",{},[],"",[],["data-ui-section-state","data-ui-section-prop-heading","data-ui-section-prop-tone","data-ui-section-prop-variant"]],["section",{},[],"",[],["data-ui-section-state","data-ui-section-prop-heading","data-ui-section-prop-tone","data-ui-section-prop-variant"]]];
16
+ const Q = [[],[]];
17
+ const D = { g: "ui-section", props: { "heading": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "tone": { "required":false,"values":["neutral","danger"],"default":"neutral", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat)] }, "variant": { "required":false,"values":["plain","card","divided","fieldset"],"default":"plain", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat)] } } };
12
18
 
13
19
  export function createUiSection(options = {}, html) {
14
20
  const { attributes = {}, children = [], slots = {}, ...componentProps } = options;
15
- const element = document.createElement("section");
16
- for (const [name, value] of Object.entries(attributes)) {
17
- if (value === null || value === undefined || value === false) continue;
18
- element.setAttribute(name, value === true ? "" : String(value));
19
- }
20
- element.setAttribute("data-component", "ui-section");
21
- element.append((P0 ??= buildTemplate(T0)).cloneNode(true));
22
21
  const v = [null, null, null];
23
- const B = acceptProps(element, D, S.n, v, componentProps, [], html);
22
+ let B = acceptProps(undefined, D, S.n, v, componentProps, [], html);
23
+ let a = ((v[2] === "fieldset") ? 0 : 1);
24
+ let element;
25
+ if (a === 0) {
26
+ element = document.createElement("fieldset");
27
+ for (const [name, value] of Object.entries(attributes)) {
28
+ if (value === null || value === undefined || value === false) continue;
29
+ element.setAttribute(name, value === true ? "" : String(value));
30
+ }
31
+ element.setAttribute("data-component", "ui-section");
32
+ } else {
33
+ element = document.createElement("section");
34
+ for (const [name, value] of Object.entries(attributes)) {
35
+ if (value === null || value === undefined || value === false) continue;
36
+ element.setAttribute(name, value === true ? "" : String(value));
37
+ }
38
+ element.setAttribute("data-component", "ui-section");
39
+ }
40
+ B = acceptProps(element, D, S.n, v, componentProps, Q[a], html);
24
41
  const m1 = (d) => {
25
42
  const n = (P1 ??= buildTemplate(T1)).cloneNode(true);
26
43
  const r = { n };
@@ -45,6 +62,43 @@ export function createUiSection(options = {}, html) {
45
62
  };
46
63
  const p3 = (r, c, d) => {
47
64
  };
65
+ const m5 = (d) => {
66
+ const n = (P5 ??= buildTemplate(T5)).cloneNode(true);
67
+ const r = { n };
68
+ p5(r, -1, d);
69
+ return r;
70
+ };
71
+ const p5 = (r, c, d) => {
72
+ };
73
+ const m6 = (d) => {
74
+ const n = (P6 ??= buildTemplate(T6)).cloneNode(true);
75
+ const r = { n };
76
+ p6(r, -1, d);
77
+ return r;
78
+ };
79
+ const p6 = (r, c, d) => {
80
+ };
81
+ const m7 = (d) => {
82
+ const n = (P7 ??= buildTemplate(T7)).cloneNode(true);
83
+ const r = { n };
84
+ p7(r, -1, d);
85
+ return r;
86
+ };
87
+ const p7 = (r, c, d) => {
88
+ };
89
+ const m0 = (n, d) => {
90
+ n.append((P0 ??= buildTemplate(T0)).cloneNode(true));
91
+ const t0 = n.firstChild.nextSibling;
92
+ const t1 = t0.firstChild.firstChild;
93
+ const t2 = t0.nextSibling.nextSibling;
94
+ const t3 = t2.firstChild.nextSibling;
95
+ const t4 = t3.firstChild.firstChild;
96
+ const t5 = t3.nextSibling.nextSibling.firstChild;
97
+ const t6 = t2.nextSibling.nextSibling.firstChild;
98
+ const r = { n, a0: t0, a1: t1, v0: null, v1: "", v2: undefined, a2: t4, e0: t4.nextSibling, b0: undefined, f0: undefined, a3: t5, e1: t5.nextSibling, b1: undefined, f1: undefined, a4: t6, e2: t6.nextSibling, b2: undefined, f2: undefined };
99
+ p0(r, -1, d);
100
+ return r;
101
+ };
48
102
  const p0 = (r, c, d) => {
49
103
  if (c & 1) {
50
104
  const x0 = !truthy(v[0]);
@@ -69,17 +123,67 @@ export function createUiSection(options = {}, html) {
69
123
  if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b2 = m3(d); at.before(r.b2.n); } }
70
124
  else if (r.b2 !== undefined) p3(r.b2, c, d);
71
125
  };
72
- const t0 = element.firstChild.nextSibling;
73
- const t1 = t0.firstChild.nextSibling;
74
- const t2 = t1.firstChild.nextSibling;
75
- const t3 = t2.firstChild;
76
- const t4 = t2.nextSibling.nextSibling.firstChild;
77
- const t5 = t1.nextSibling.nextSibling.firstChild;
78
- const t6 = t0.nextSibling.nextSibling.firstChild;
79
- const R = { n: element, a0: t2, a1: t3, v0: null, v1: "", v2: undefined, a2: t4, e0: t4.nextSibling, b0: undefined, f0: undefined, a3: t5, e1: t5.nextSibling, b1: undefined, f1: undefined, a4: t6, e2: t6.nextSibling, b2: undefined, f2: undefined };
126
+ const m4 = (n, d) => {
127
+ n.append((P4 ??= buildTemplate(T4)).cloneNode(true));
128
+ const t0 = n.firstChild.nextSibling;
129
+ const t1 = t0.firstChild.nextSibling;
130
+ const t2 = t1.firstChild.nextSibling;
131
+ const t3 = t2.firstChild;
132
+ const t4 = t2.nextSibling.nextSibling.firstChild;
133
+ const t5 = t1.nextSibling.nextSibling.firstChild;
134
+ const t6 = t0.nextSibling.nextSibling.firstChild;
135
+ const r = { n, a0: t2, a1: t3, v0: null, v1: "", v2: undefined, a2: t4, e0: t4.nextSibling, b0: undefined, f0: undefined, a3: t5, e1: t5.nextSibling, b1: undefined, f1: undefined, a4: t6, e2: t6.nextSibling, b2: undefined, f2: undefined };
136
+ p4(r, -1, d);
137
+ return r;
138
+ };
139
+ const p4 = (r, c, d) => {
140
+ if (c & 1) {
141
+ const x0 = !truthy(v[0]);
142
+ const s0 = toAttribute(x0, "hidden");
143
+ if (s0 !== r.v0) writeAttribute(r.a0, "hidden", r.v0 = s0);
144
+ const x1 = v[0];
145
+ const s1 = toText(x1);
146
+ if (s1 !== r.v1) r.a1.data = r.v1 = s1;
147
+ }
148
+ if (c & 6) {
149
+ const x2 = hostState(["variant","tone"], [v[2], v[1]]);
150
+ const s2 = x2;
151
+ if (s2 !== r.v2) writeAttribute(r.n, "data-ui-section-state", (r.v2 = s2) === "" ? null : s2);
152
+ }
153
+ if (r.f0 === undefined) { r.f0 = 1; const at = fillSlot(r.a2, r.e0, "description", J, false, undefined, d);
154
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b0 = m5(d); at.before(r.b0.n); } }
155
+ else if (r.b0 !== undefined) p5(r.b0, c, d);
156
+ if (r.f1 === undefined) { r.f1 = 1; const at = fillSlot(r.a3, r.e1, "actions", J, false, undefined, d);
157
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b1 = m6(d); at.before(r.b1.n); } }
158
+ else if (r.b1 !== undefined) p6(r.b1, c, d);
159
+ if (r.f2 === undefined) { r.f2 = 1; const at = fillSlot(r.a4, r.e2, "", J, false, undefined, d);
160
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b2 = m7(d); at.before(r.b2.n); } }
161
+ else if (r.b2 !== undefined) p7(r.b2, c, d);
162
+ };
163
+ const M = [m0, m4], N = [p0, p4];
164
+ let R;
165
+ const p = (c, d) => {
166
+ if (R === null) return;
167
+ if (R === undefined) { R = M[a](element, d); return; }
168
+ if (c & 4) {
169
+ const t = ((v[2] === "fieldset") ? 0 : 1);
170
+ if (t !== a) {
171
+ dispose(R);
172
+ for (const key in I.r) delete I.r[key];
173
+ const previous = I.e, next = armElement(previous, A[a], A[t]);
174
+ I.B.b = Q[t];
175
+ a = t;
176
+ R = null;
177
+ R = M[t](next, d);
178
+ replaceRoot(I, previous, next);
179
+ return;
180
+ }
181
+ }
182
+ N[a](R, c, d);
183
+ };
80
184
  const I = { B };
81
185
  const J = project(I, children, slots);
82
- attachGeneratedController(element, S, v, ((c, d) => p0(R, c, d)), undefined, undefined, I);
186
+ attachGeneratedController(element, S, v, p, undefined, undefined, I);
83
187
  manageProps(I);
84
188
  return element;
85
189
  }
@@ -1,12 +1,18 @@
1
1
  import type { PropType } from 'vue';
2
2
  import { type InputBindings } from './props.js';
3
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {};
3
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {}, __VLS_9: {}, __VLS_11: {};
4
4
  type __VLS_Slots = {} & {
5
5
  description?: (props: typeof __VLS_1) => any;
6
6
  } & {
7
7
  actions?: (props: typeof __VLS_3) => any;
8
8
  } & {
9
9
  default?: (props: typeof __VLS_5) => any;
10
+ } & {
11
+ description?: (props: typeof __VLS_7) => any;
12
+ } & {
13
+ actions?: (props: typeof __VLS_9) => any;
14
+ } & {
15
+ default?: (props: typeof __VLS_11) => any;
10
16
  };
11
17
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
12
18
  heading: {
@@ -16,7 +22,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
16
22
  type: PropType<"neutral" | "danger" | null>;
17
23
  };
18
24
  variant: {
19
- type: PropType<"plain" | "card" | "divided" | null>;
25
+ type: PropType<"plain" | "card" | "divided" | "fieldset" | null>;
20
26
  };
21
27
  "\0htmlNextInputStatus": {
22
28
  type: PropType<InputBindings>;
@@ -29,7 +35,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
29
35
  type: PropType<"neutral" | "danger" | null>;
30
36
  };
31
37
  variant: {
32
- type: PropType<"plain" | "card" | "divided" | null>;
38
+ type: PropType<"plain" | "card" | "divided" | "fieldset" | null>;
33
39
  };
34
40
  "\0htmlNextInputStatus": {
35
41
  type: PropType<InputBindings>;
package/vue/UiSection.vue CHANGED
@@ -1,8 +1,8 @@
1
1
  <!-- Generated by HTML Next 1.0.0-alpha.69 for Vue 3.5. Do not edit. -->
2
2
  <script setup lang="ts">
3
- import { computed, watchSyncEffect } from 'vue'
3
+ import { computed, useTemplateRef, watchSyncEffect } from 'vue'
4
4
  import type { PropType } from 'vue'
5
- import { checkHydratedRoot, nativeAttrs, useReflectedProp } from './host'
5
+ import { checkHydratedRoot, nativeAttrs, preserveRootFocus, useReflectedProp } from './host'
6
6
  import {
7
7
  BINDING_INPUTS_PROP,
8
8
  checkedProp,
@@ -32,7 +32,7 @@ const propValidityContract = {
32
32
  required: false,
33
33
  target: { attribute: 'tone' },
34
34
  description:
35
- 'danger marks a section of destructive actions (a danger zone): its heading and a card\'s border take the danger colour.',
35
+ 'danger marks a section of destructive actions (a danger zone): its heading and a framed section\'s border take the danger colour.',
36
36
  values: ['neutral', 'danger'],
37
37
  default: 'neutral',
38
38
  },
@@ -41,8 +41,8 @@ const propValidityContract = {
41
41
  required: false,
42
42
  target: { attribute: 'variant' },
43
43
  description:
44
- 'How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided\n rules it off from the section before it, for a long form.',
45
- values: ['plain', 'card', 'divided'],
44
+ 'How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided\n rules it off from the section before it, for a long form. fieldset joins the heading to a bordered frame using a native legend.',
45
+ values: ['plain', 'card', 'divided', 'fieldset'],
46
46
  default: 'plain',
47
47
  },
48
48
  },
@@ -50,7 +50,7 @@ const propValidityContract = {
50
50
  const props = defineProps({
51
51
  heading: { type: null as unknown as PropType<string | null> },
52
52
  tone: { type: null as unknown as PropType<'neutral' | 'danger' | null> },
53
- variant: { type: null as unknown as PropType<'plain' | 'card' | 'divided' | null> },
53
+ variant: { type: null as unknown as PropType<'plain' | 'card' | 'divided' | 'fieldset' | null> },
54
54
  [BINDING_INPUTS_PROP]: { type: null as unknown as PropType<InputBindings> },
55
55
  })
56
56
  const acceptedProps: Record<string, unknown> = { heading: '', tone: 'neutral', variant: 'plain' }
@@ -86,11 +86,11 @@ const checkedProps = computed(() => {
86
86
  props['tone'],
87
87
  props[BINDING_INPUTS_PROP],
88
88
  ) as 'neutral' | 'danger',
89
- variant: propInputs.value<'plain' | 'card' | 'divided' | null>(
89
+ variant: propInputs.value<'plain' | 'card' | 'divided' | 'fieldset' | null>(
90
90
  'variant',
91
91
  props['variant'],
92
92
  props[BINDING_INPUTS_PROP],
93
- ) as 'plain' | 'card' | 'divided',
93
+ ) as 'plain' | 'card' | 'divided' | 'fieldset',
94
94
  })
95
95
  })
96
96
  const inputStatus = (name: string, handlesError: boolean) => {
@@ -104,7 +104,13 @@ watchSyncEffect(() => {
104
104
  })
105
105
  const reflectedProp = useReflectedProp()
106
106
 
107
- checkHydratedRoot('section', 'ui-section')
107
+ const rootArmElement = useTemplateRef<HTMLElement>('@html-next/root')
108
+ const root = rootArmElement
109
+ preserveRootFocus(root)
110
+ checkHydratedRoot(
111
+ (checkedProps.value.variant === 'fieldset') ? 'fieldset' : ('section'),
112
+ 'ui-section',
113
+ )
108
114
 
109
115
  /** The values the styles' :host() and :state() rules test. */
110
116
  const hostState = computed(() =>
@@ -119,7 +125,35 @@ const hostState = computed(() =>
119
125
  </script>
120
126
 
121
127
  <template>
128
+ <fieldset
129
+ v-if="checkedProps.variant === 'fieldset'"
130
+ class="ui-section"
131
+ v-bind="nativeAttrs($attrs)"
132
+ data-hn
133
+ data-hn-ui-section
134
+ v-prop-validity="{ contract: propValidityContract, values: { ...props } }"
135
+ :data-ui-section-prop-heading="reflectedProp('heading', 'heading', checkedProps.heading, undefined, false)"
136
+ :data-ui-section-prop-tone="reflectedProp('tone', 'tone', checkedProps.tone, undefined, false)"
137
+ :data-ui-section-prop-variant="reflectedProp('variant', 'variant', checkedProps.variant, undefined, false)"
138
+ :data-ui-section-state="hostState || undefined"
139
+ ref="@html-next/root"
140
+ >
141
+ <legend class="legend" data-hn-ui-section :hidden="!checkedProps.heading">
142
+ <h2 class="heading" data-hn-ui-section>{{ checkedProps.heading }}</h2>
143
+ </legend>
144
+ <span class="head" data-hn-ui-section><span class="copy" data-hn-ui-section><span
145
+ class="description"
146
+ data-hn-ui-section
147
+ ><slot name="description" /></span></span>{{ ' ' }}<span
148
+ class="actions"
149
+ data-hn-ui-section
150
+ ><slot name="actions" /></span></span>{{ ' ' }}<span
151
+ class="body"
152
+ data-hn-ui-section
153
+ ><slot /></span>
154
+ </fieldset>
122
155
  <section
156
+ v-else
123
157
  class="ui-section"
124
158
  v-bind="nativeAttrs($attrs)"
125
159
  data-hn
@@ -129,6 +163,7 @@ const hostState = computed(() =>
129
163
  :data-ui-section-prop-tone="reflectedProp('tone', 'tone', checkedProps.tone, undefined, false)"
130
164
  :data-ui-section-prop-variant="reflectedProp('variant', 'variant', checkedProps.variant, undefined, false)"
131
165
  :data-ui-section-state="hostState || undefined"
166
+ ref="@html-next/root"
132
167
  >
133
168
  <span class="head" data-hn-ui-section><span class="copy" data-hn-ui-section><h2
134
169
  class="heading"
@@ -160,7 +195,8 @@ const hostState = computed(() =>
160
195
  min-inline-size: 0;
161
196
  }
162
197
 
163
- :global(:scope[data-ui-section-state~="variant=card"]:where([data-hn-ui-section])) {
198
+ :global(:scope[data-ui-section-state~="variant=card"]:where([data-hn-ui-section])),
199
+ :global(:scope[data-ui-section-state~="variant=fieldset"]:where([data-hn-ui-section])) {
164
200
  --_ui-selection-context-surface: initial;
165
201
  --_ui-selection-context-border: initial;
166
202
  --_ui-selection-context-text: initial;
@@ -170,12 +206,41 @@ const hostState = computed(() =>
170
206
  background: var(--ui-surface-raised);
171
207
  }
172
208
 
209
+ :global(:scope[data-ui-section-state~="variant=fieldset"]:where([data-hn-ui-section])) {
210
+ display: block !important;
211
+ box-sizing: border-box !important;
212
+ margin: 0 !important;
213
+ padding-block-start: var(--ui-space-4) !important;
214
+ }
215
+
216
+ :global(.legend:where([data-hn-ui-section])) {
217
+ max-inline-size: 100%;
218
+ box-sizing: border-box !important;
219
+ padding-inline: var(--ui-space-2) !important;
220
+ margin-inline-start: calc(-1 * var(--ui-space-2)) !important;
221
+ overflow-wrap: anywhere;
222
+ }
223
+
224
+ :global(.legend .heading:where([data-hn-ui-section])) {
225
+ font-size: var(--ui-font-size-md);
226
+ }
227
+
228
+ :global(:scope[data-ui-section-state~="variant=fieldset"] .head:where([data-hn-ui-section])) {
229
+ margin-block-end: var(--ui-space-4) !important;
230
+ }
231
+
232
+ :global(:scope[data-ui-section-state~="variant=fieldset"]
233
+ .head:has(.description:empty):has(.actions:empty):where([data-hn-ui-section])) {
234
+ display: none !important;
235
+ }
236
+
173
237
  :global(:scope[data-ui-section-state~="variant=divided"]:where([data-hn-ui-section])) {
174
238
  padding-block-start: var(--ui-space-6) !important;
175
239
  border-block-start: var(--ui-border-width) solid var(--ui-border-divider);
176
240
  }
177
241
 
178
- :global(:scope[data-ui-section-state~="variant=card"][data-ui-section-state~="tone=danger"]:where([data-hn-ui-section])) {
242
+ :global(:scope[data-ui-section-state~="variant=card"][data-ui-section-state~="tone=danger"]:where([data-hn-ui-section])),
243
+ :global(:scope[data-ui-section-state~="variant=fieldset"][data-ui-section-state~="tone=danger"]:where([data-hn-ui-section])) {
179
244
  --_ui-selection-context-surface: light-dark(
180
245
  oklch(from var(--ui-danger-soft) calc(l - 0.045) calc(max(c, min(0.045, c * 3))) h),
181
246
  oklch(from var(--ui-danger-soft) calc(l + 0.045) calc(max(c, min(0.045, c * 3))) h)