@websublime/line-components 0.2.1 → 0.2.3

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.
@@ -0,0 +1,3 @@
1
+ export { LineSeparator } from './separator.js';
2
+ export type { SeparatorOrientation } from './separator.types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/separator/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { INTERNALS as e, LineElement as t } from "@websublime/line-core";
2
+ import { commonReset as n } from "@websublime/line-core/styles";
3
+ import { css as r } from "lit";
4
+ //#region src/separator/separator.ts
5
+ var i = { fromAttribute: (e) => e === "vertical" ? "vertical" : "horizontal" }, a = class extends t {
6
+ static {
7
+ this.properties = {
8
+ orientation: {
9
+ reflect: !0,
10
+ useDefault: !0,
11
+ converter: i
12
+ },
13
+ decorative: {
14
+ type: Boolean,
15
+ reflect: !0,
16
+ useDefault: !0
17
+ }
18
+ };
19
+ }
20
+ static {
21
+ this.styles = [n, r`
22
+ :host {
23
+ --line-separator-color: var(--line-gray-6, currentColor);
24
+ --line-separator-thickness: var(--line-border-1, 1px);
25
+
26
+ display: block;
27
+ align-self: stretch;
28
+ flex-shrink: 0;
29
+ border-block-start-style: solid;
30
+ border-block-start-width: var(--line-separator-thickness);
31
+ border-block-start-color: var(--line-separator-color);
32
+ }
33
+
34
+ :host([hidden]) {
35
+ display: none;
36
+ }
37
+
38
+ :host([orientation='vertical']) {
39
+ inline-size: 0;
40
+ min-block-size: 1em;
41
+ border-block-start-style: none;
42
+ border-block-start-width: 0;
43
+ border-inline-start-style: solid;
44
+ border-inline-start-width: var(--line-separator-thickness);
45
+ border-inline-start-color: var(--line-separator-color);
46
+ }
47
+ `];
48
+ }
49
+ constructor() {
50
+ super(), this.orientation = "horizontal", this.decorative = !1;
51
+ }
52
+ willUpdate(t) {
53
+ if (super.willUpdate(t), this.hasUpdated && !t.has("orientation") && !t.has("decorative")) return;
54
+ let n = this[e];
55
+ n.role = this.decorative ? "none" : "separator", n.ariaOrientation = !this.decorative && this.orientation === "vertical" ? "vertical" : null;
56
+ }
57
+ };
58
+ customElements.define("line-separator", a);
59
+ //#endregion
60
+ export { a as LineSeparator };
61
+
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["orientationConverter","value","LineSeparator","LineElement","commonReset","changed","internals","INTERNALS"],"sources":["../../src/separator/separator.ts"],"sourcesContent":["import { INTERNALS, LineElement } from '@websublime/line-core';\nimport { commonReset } from '@websublime/line-core/styles';\nimport { type ComplexAttributeConverter, css, type PropertyDeclarations } from 'lit';\nimport type { SeparatorOrientation } from './separator.types.js';\n\n/** An unknown `orientation` behaves as `horizontal`; the attribute keeps what the author wrote (C8). */\nconst orientationConverter: ComplexAttributeConverter<SeparatorOrientation> = {\n fromAttribute: (value) => (value === 'vertical' ? 'vertical' : 'horizontal'),\n};\n\n/**\n * `<line-separator>` draws a thin line between sections of content. The host\n * is the line and the shadow root renders nothing. The host carries the\n * `separator` role and its orientation as `ElementInternals` defaults, so an\n * author `role` or `aria-*` attribute wins, and a host `aria-label` names it.\n * `decorative` sets the role to `none`, so assistive technology skips the\n * line; give a decorative separator no `aria-label`. It adds no spacing.\n *\n * @summary A thin horizontal or vertical line that separates sections of content.\n *\n * @cssprop [--line-separator-color=var(--line-gray-6, currentColor)] - Colour of the line.\n * @cssprop [--line-separator-thickness=var(--line-border-1, 1px)] - Thickness of the line.\n */\nexport class LineSeparator extends LineElement {\n static override properties: PropertyDeclarations = {\n orientation: { reflect: true, useDefault: true, converter: orientationConverter },\n decorative: { type: Boolean, reflect: true, useDefault: true },\n };\n\n // The line is one border side set through longhands: forced-colors mode keeps a border colour visible,\n // and an invalid var() in a shorthand would reset border-style to none (spec 0011-separator.md Drawing).\n static override styles = [\n commonReset,\n css`\n :host {\n --line-separator-color: var(--line-gray-6, currentColor);\n --line-separator-thickness: var(--line-border-1, 1px);\n\n display: block;\n align-self: stretch;\n flex-shrink: 0;\n border-block-start-style: solid;\n border-block-start-width: var(--line-separator-thickness);\n border-block-start-color: var(--line-separator-color);\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([orientation='vertical']) {\n inline-size: 0;\n min-block-size: 1em;\n border-block-start-style: none;\n border-block-start-width: 0;\n border-inline-start-style: solid;\n border-inline-start-width: var(--line-separator-thickness);\n border-inline-start-color: var(--line-separator-color);\n }\n `,\n ];\n\n /** Direction of the line; an unknown value behaves as `horizontal`. */\n declare orientation: SeparatorOrientation;\n /** Removes the separator from the accessibility tree (role `none`); the line still draws. */\n declare decorative: boolean;\n\n constructor() {\n super();\n // `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).\n this.orientation = 'horizontal';\n this.decorative = false;\n }\n\n protected override willUpdate(changed: Map<PropertyKey, unknown>): void {\n super.willUpdate(changed);\n // Lit leaves `useDefault` initial values out of the first `changed` map, so the first update always writes.\n if (this.hasUpdated && !changed.has('orientation') && !changed.has('decorative')) {\n return;\n }\n const internals = this[INTERNALS];\n internals.role = this.decorative ? 'none' : 'separator';\n internals.ariaOrientation = !this.decorative && this.orientation === 'vertical' ? 'vertical' : null;\n }\n}\n\ncustomElements.define('line-separator', LineSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-separator': LineSeparator;\n }\n}\n"],"mappings":";;;;AAMA,IAAMA,IAAwE,EAC5E,gBAAgB,MAAWC,MAAU,aAAa,aAAa,aACjE,GAeaC,IAAb,cAAmCC,EAAY;;EACM,KAAA,aAAA;GACjD,aAAa;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWH;GAAqB;GAChF,YAAY;IAAE,MAAM;IAAS,SAAS;IAAM,YAAY;GAAK;EAC/D;;;EAIyB,KAAA,SAAA,CACvBI,GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BL;;CAOA,cAAc;EAIZ,AAHA,MAAM,GAEN,KAAK,cAAc,cACnB,KAAK,aAAa;CACpB;CAEA,WAA8B,GAA0C;EAGtE,IAFA,MAAM,WAAWC,CAAO,GAEpB,KAAK,cAAc,CAACA,EAAQ,IAAI,aAAa,KAAK,CAACA,EAAQ,IAAI,YAAY,GAC7E;EAEF,IAAMC,IAAY,KAAKC;EAEvB,AADA,EAAU,OAAO,KAAK,aAAa,SAAS,aAC5C,EAAU,kBAAkB,CAAC,KAAK,cAAc,KAAK,gBAAgB,aAAa,aAAa;CACjG;AACF;AAEA,eAAe,OAAO,kBAAkBL,CAAa"}
@@ -0,0 +1,32 @@
1
+ import { LineElement } from '@websublime/line-core';
2
+ import { type PropertyDeclarations } from 'lit';
3
+ import type { SeparatorOrientation } from './separator.types.js';
4
+ /**
5
+ * `<line-separator>` draws a thin line between sections of content. The host
6
+ * is the line and the shadow root renders nothing. The host carries the
7
+ * `separator` role and its orientation as `ElementInternals` defaults, so an
8
+ * author `role` or `aria-*` attribute wins, and a host `aria-label` names it.
9
+ * `decorative` sets the role to `none`, so assistive technology skips the
10
+ * line; give a decorative separator no `aria-label`. It adds no spacing.
11
+ *
12
+ * @summary A thin horizontal or vertical line that separates sections of content.
13
+ *
14
+ * @cssprop [--line-separator-color=var(--line-gray-6, currentColor)] - Colour of the line.
15
+ * @cssprop [--line-separator-thickness=var(--line-border-1, 1px)] - Thickness of the line.
16
+ */
17
+ export declare class LineSeparator extends LineElement {
18
+ static properties: PropertyDeclarations;
19
+ static styles: (import("lit").CSSResult | CSSStyleSheet)[];
20
+ /** Direction of the line; an unknown value behaves as `horizontal`. */
21
+ orientation: SeparatorOrientation;
22
+ /** Removes the separator from the accessibility tree (role `none`); the line still draws. */
23
+ decorative: boolean;
24
+ constructor();
25
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'line-separator': LineSeparator;
30
+ }
31
+ }
32
+ //# sourceMappingURL=separator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separator.d.ts","sourceRoot":"","sources":["../../src/separator/separator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,KAAK,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAOjE;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAgB,UAAU,EAAE,oBAAoB,CAG9C;IAIF,OAAgB,MAAM,8CA6BpB;IAEF,uEAAuE;IAC/D,WAAW,EAAE,oBAAoB,CAAC;IAC1C,6FAA6F;IACrF,UAAU,EAAE,OAAO,CAAC;IAE5B,cAKC;IAED,UAAmB,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAStE;CACF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
@@ -0,0 +1,3 @@
1
+ /** Direction of the line drawn by `<line-separator>`; the A2UI basic v0.9 `Divider.axis` values. */
2
+ export type SeparatorOrientation = 'horizontal' | 'vertical';
3
+ //# sourceMappingURL=separator.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separator.types.d.ts","sourceRoot":"","sources":["../../src/separator/separator.types.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { LineStack } from './stack.js';
2
+ export type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,155 @@
1
+ import { LineElement as e } from "@websublime/line-core";
2
+ import { commonReset as t } from "@websublime/line-core/styles";
3
+ import { css as n, html as r } from "lit";
4
+ //#region src/stack/stack.ts
5
+ var i = ["horizontal", "vertical"], a = [
6
+ "start",
7
+ "center",
8
+ "end",
9
+ "spaceBetween",
10
+ "spaceAround",
11
+ "spaceEvenly",
12
+ "stretch"
13
+ ], o = [
14
+ "start",
15
+ "center",
16
+ "end",
17
+ "stretch"
18
+ ], s = [
19
+ "0",
20
+ "1",
21
+ "2",
22
+ "3",
23
+ "4",
24
+ "5"
25
+ ];
26
+ function c(e, t) {
27
+ return { fromAttribute: (n) => e.find((e) => e === n) ?? t };
28
+ }
29
+ var l = { fromAttribute: (e) => s.find((t) => t === e) }, u = class extends e {
30
+ static {
31
+ this.properties = {
32
+ orientation: {
33
+ reflect: !0,
34
+ useDefault: !0,
35
+ converter: c(i, "vertical")
36
+ },
37
+ justify: {
38
+ reflect: !0,
39
+ useDefault: !0,
40
+ converter: c(a, "start")
41
+ },
42
+ align: {
43
+ reflect: !0,
44
+ useDefault: !0,
45
+ converter: c(o, "stretch")
46
+ },
47
+ gap: {
48
+ reflect: !0,
49
+ converter: l
50
+ },
51
+ wrap: {
52
+ type: Boolean,
53
+ reflect: !0,
54
+ useDefault: !0
55
+ }
56
+ };
57
+ }
58
+ static {
59
+ this.styles = [t, n`
60
+ :host {
61
+ --line-stack-gap: var(--line-layout-gap-2);
62
+
63
+ display: flex;
64
+ flex-direction: column;
65
+ justify-content: flex-start;
66
+ align-items: stretch;
67
+ flex-wrap: nowrap;
68
+ gap: var(--line-stack-gap);
69
+ }
70
+
71
+ :host([hidden]) {
72
+ display: none;
73
+ }
74
+
75
+ :host([orientation='horizontal']) {
76
+ flex-direction: row;
77
+ }
78
+
79
+ :host([justify='center']) {
80
+ justify-content: center;
81
+ }
82
+
83
+ :host([justify='end']) {
84
+ justify-content: flex-end;
85
+ }
86
+
87
+ :host([justify='spaceBetween']) {
88
+ justify-content: space-between;
89
+ }
90
+
91
+ :host([justify='spaceAround']) {
92
+ justify-content: space-around;
93
+ }
94
+
95
+ :host([justify='spaceEvenly']) {
96
+ justify-content: space-evenly;
97
+ }
98
+
99
+ :host([justify='stretch']) ::slotted(*) {
100
+ flex-grow: 1;
101
+ }
102
+
103
+ :host([align='start']) {
104
+ align-items: flex-start;
105
+ }
106
+
107
+ :host([align='center']) {
108
+ align-items: center;
109
+ }
110
+
111
+ :host([align='end']) {
112
+ align-items: flex-end;
113
+ }
114
+
115
+ :host([wrap]) {
116
+ flex-wrap: wrap;
117
+ }
118
+
119
+ :host([gap='0']) {
120
+ --line-stack-gap: 0;
121
+ }
122
+
123
+ :host([gap='1']) {
124
+ --line-stack-gap: var(--line-layout-gap-1);
125
+ }
126
+
127
+ :host([gap='2']) {
128
+ --line-stack-gap: var(--line-layout-gap-2);
129
+ }
130
+
131
+ :host([gap='3']) {
132
+ --line-stack-gap: var(--line-layout-gap-3);
133
+ }
134
+
135
+ :host([gap='4']) {
136
+ --line-stack-gap: var(--line-layout-gap-4);
137
+ }
138
+
139
+ :host([gap='5']) {
140
+ --line-stack-gap: var(--line-layout-gap-5);
141
+ }
142
+ `];
143
+ }
144
+ constructor() {
145
+ super(), this.orientation = "vertical", this.justify = "start", this.align = "stretch", this.wrap = !1;
146
+ }
147
+ render() {
148
+ return r`<slot></slot>`;
149
+ }
150
+ };
151
+ customElements.define("line-stack", u);
152
+ //#endregion
153
+ export { u as LineStack };
154
+
155
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ORIENTATIONS","JUSTIFIES","ALIGNS","GAPS","enumConverter","values","entry","value","fallback","gapConverter","gap","LineStack","LineElement","commonReset"],"sources":["../../src/stack/stack.ts"],"sourcesContent":["import { LineElement } from '@websublime/line-core';\nimport { commonReset } from '@websublime/line-core/styles';\nimport { type ComplexAttributeConverter, css, html, type PropertyDeclarations, type TemplateResult } from 'lit';\nimport type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';\n\nconst ORIENTATIONS: readonly StackOrientation[] = ['horizontal', 'vertical'];\nconst JUSTIFIES: readonly StackJustify[] = [\n 'start',\n 'center',\n 'end',\n 'spaceBetween',\n 'spaceAround',\n 'spaceEvenly',\n 'stretch',\n];\nconst ALIGNS: readonly StackAlign[] = ['start', 'center', 'end', 'stretch'];\nconst GAPS: readonly StackGap[] = ['0', '1', '2', '3', '4', '5'];\n\n/** An unknown value behaves as `fallback`; the attribute keeps what the author wrote. */\nfunction enumConverter<T extends string>(values: readonly T[], fallback: T): ComplexAttributeConverter<T> {\n return { fromAttribute: (value) => values.find((entry) => entry === value) ?? fallback };\n}\n\n/** An unknown `gap` behaves as no attribute, so the default step applies. */\nconst gapConverter: ComplexAttributeConverter<StackGap | undefined> = {\n fromAttribute: (value) => GAPS.find((gap) => gap === value),\n};\n\n/**\n * `<line-stack>` lays out its children in one row or one column with a gap\n * between them. The host is the flex container and the slotted children are\n * its flex items. It adds no role, so it stays `generic`; put `role=\"list\"`\n * on the host and `role=\"listitem\"` on the children to build a list.\n *\n * @summary A layout container that places its children in one row or column with even spacing.\n *\n * @slot - The children; each element becomes a flex item.\n *\n * @cssprop [--line-stack-gap=var(--line-layout-gap-2)] - Space between items; `gap=\"0\"` uses `0` and `gap=\"N\"` uses `var(--line-layout-gap-N)`.\n */\nexport class LineStack extends LineElement {\n static override properties: PropertyDeclarations = {\n orientation: { reflect: true, useDefault: true, converter: enumConverter(ORIENTATIONS, 'vertical') },\n justify: { reflect: true, useDefault: true, converter: enumConverter(JUSTIFIES, 'start') },\n align: { reflect: true, useDefault: true, converter: enumConverter(ALIGNS, 'stretch') },\n gap: { reflect: true, converter: gapConverter },\n wrap: { type: Boolean, reflect: true, useDefault: true },\n };\n\n static override styles = [\n commonReset,\n css`\n :host {\n --line-stack-gap: var(--line-layout-gap-2);\n\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n flex-wrap: nowrap;\n gap: var(--line-stack-gap);\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([orientation='horizontal']) {\n flex-direction: row;\n }\n\n :host([justify='center']) {\n justify-content: center;\n }\n\n :host([justify='end']) {\n justify-content: flex-end;\n }\n\n :host([justify='spaceBetween']) {\n justify-content: space-between;\n }\n\n :host([justify='spaceAround']) {\n justify-content: space-around;\n }\n\n :host([justify='spaceEvenly']) {\n justify-content: space-evenly;\n }\n\n :host([justify='stretch']) ::slotted(*) {\n flex-grow: 1;\n }\n\n :host([align='start']) {\n align-items: flex-start;\n }\n\n :host([align='center']) {\n align-items: center;\n }\n\n :host([align='end']) {\n align-items: flex-end;\n }\n\n :host([wrap]) {\n flex-wrap: wrap;\n }\n\n :host([gap='0']) {\n --line-stack-gap: 0;\n }\n\n :host([gap='1']) {\n --line-stack-gap: var(--line-layout-gap-1);\n }\n\n :host([gap='2']) {\n --line-stack-gap: var(--line-layout-gap-2);\n }\n\n :host([gap='3']) {\n --line-stack-gap: var(--line-layout-gap-3);\n }\n\n :host([gap='4']) {\n --line-stack-gap: var(--line-layout-gap-4);\n }\n\n :host([gap='5']) {\n --line-stack-gap: var(--line-layout-gap-5);\n }\n `,\n ];\n\n /** Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction. */\n declare orientation: StackOrientation;\n /** Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`. */\n declare justify: StackJustify;\n /** Alignment on the cross axis; an unknown value behaves as `stretch`. */\n declare align: StackAlign;\n /** Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`. */\n declare gap: StackGap | undefined;\n /** Lets the items flow onto more lines when they run out of space. */\n declare wrap: boolean;\n\n constructor() {\n super();\n // `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).\n this.orientation = 'vertical';\n this.justify = 'start';\n this.align = 'stretch';\n this.wrap = false;\n }\n\n override render(): TemplateResult {\n return html`<slot></slot>`;\n }\n}\n\ncustomElements.define('line-stack', LineStack);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-stack': LineStack;\n }\n}\n"],"mappings":";;;;AAKA,IAAMA,IAA4C,CAAC,cAAc,UAAU,GACrEC,IAAqC;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GACMC,IAAgC;CAAC;CAAS;CAAU;CAAO;AAAS,GACpEC,IAA4B;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;AAG/D,SAASC,EAAgC,GAAsB,GAA2C;CACxG,OAAO,EAAE,gBAAgB,MAAUC,EAAO,MAAM,MAAUC,MAAUC,CAAK,KAAKC,EAAS;AACzF;AAGA,IAAMC,IAAgE,EACpE,gBAAgB,MAAUN,EAAK,MAAM,MAAQO,MAAQH,CAAK,EAC5D,GAcaI,IAAb,cAA+BC,EAAY;;EACU,KAAA,aAAA;GACjD,aAAa;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWR,EAAcJ,GAAc,UAAU;GAAE;GACnG,SAAS;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWI,EAAcH,GAAW,OAAO;GAAE;GACzF,OAAO;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWG,EAAcF,GAAQ,SAAS;GAAE;GACtF,KAAK;IAAE,SAAS;IAAM,WAAWO;GAAa;GAC9C,MAAM;IAAE,MAAM;IAAS,SAAS;IAAM,YAAY;GAAK;EACzD;;;EAEyB,KAAA,SAAA,CACvBI,GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoFL;;CAaA,cAAc;EAMZ,AALA,MAAM,GAEN,KAAK,cAAc,YACnB,KAAK,UAAU,SACf,KAAK,QAAQ,WACb,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,OAAO,CAAI;CACb;AACF;AAEA,eAAe,OAAO,cAAcF,CAAS"}
@@ -0,0 +1,37 @@
1
+ import { LineElement } from '@websublime/line-core';
2
+ import { type PropertyDeclarations, type TemplateResult } from 'lit';
3
+ import type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
4
+ /**
5
+ * `<line-stack>` lays out its children in one row or one column with a gap
6
+ * between them. The host is the flex container and the slotted children are
7
+ * its flex items. It adds no role, so it stays `generic`; put `role="list"`
8
+ * on the host and `role="listitem"` on the children to build a list.
9
+ *
10
+ * @summary A layout container that places its children in one row or column with even spacing.
11
+ *
12
+ * @slot - The children; each element becomes a flex item.
13
+ *
14
+ * @cssprop [--line-stack-gap=var(--line-layout-gap-2)] - Space between items; `gap="0"` uses `0` and `gap="N"` uses `var(--line-layout-gap-N)`.
15
+ */
16
+ export declare class LineStack extends LineElement {
17
+ static properties: PropertyDeclarations;
18
+ static styles: (import("lit").CSSResult | CSSStyleSheet)[];
19
+ /** Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction. */
20
+ orientation: StackOrientation;
21
+ /** Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`. */
22
+ justify: StackJustify;
23
+ /** Alignment on the cross axis; an unknown value behaves as `stretch`. */
24
+ align: StackAlign;
25
+ /** Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`. */
26
+ gap: StackGap | undefined;
27
+ /** Lets the items flow onto more lines when they run out of space. */
28
+ wrap: boolean;
29
+ constructor();
30
+ render(): TemplateResult;
31
+ }
32
+ declare global {
33
+ interface HTMLElementTagNameMap {
34
+ 'line-stack': LineStack;
35
+ }
36
+ }
37
+ //# sourceMappingURL=stack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/stack/stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAA6C,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAChH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAyB7F;;;;;;;;;;;GAWG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,OAAgB,UAAU,EAAE,oBAAoB,CAM9C;IAEF,OAAgB,MAAM,8CAsFpB;IAEF,2GAA2G;IACnG,WAAW,EAAE,gBAAgB,CAAC;IACtC,sGAAsG;IAC9F,OAAO,EAAE,YAAY,CAAC;IAC9B,0EAA0E;IAClE,KAAK,EAAE,UAAU,CAAC;IAC1B,gFAAgF;IACxE,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;IAClC,sEAAsE;IAC9D,IAAI,EAAE,OAAO,CAAC;IAEtB,cAOC;IAEQ,MAAM,IAAI,cAAc,CAEhC;CACF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
@@ -0,0 +1,9 @@
1
+ /** Main axis of `<line-stack>`; the A2UI basic v0.9 `List.direction` values. */
2
+ export type StackOrientation = 'horizontal' | 'vertical';
3
+ /** Main-axis distribution of `<line-stack>`; the A2UI basic v0.9 `justify` values. */
4
+ export type StackJustify = 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly' | 'stretch';
5
+ /** Cross-axis alignment of `<line-stack>`; the A2UI basic v0.9 `align` values without `baseline`. */
6
+ export type StackAlign = 'start' | 'center' | 'end' | 'stretch';
7
+ /** Gap step of `<line-stack>` on the `--line-layout-gap-*` scale (ARCH §17.2 C6). */
8
+ export type StackGap = '0' | '1' | '2' | '3' | '4' | '5';
9
+ //# sourceMappingURL=stack.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.types.d.ts","sourceRoot":"","sources":["../../src/stack/stack.types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,UAAU,CAAC;AAEzD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,cAAc,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC;AAEnH,qGAAqG;AACrG,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEhE,qFAAqF;AACrF,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websublime/line-components",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -26,6 +26,14 @@
26
26
  "./button": {
27
27
  "types": "./dist/button/index.d.ts",
28
28
  "import": "./dist/button/index.js"
29
+ },
30
+ "./separator": {
31
+ "types": "./dist/separator/index.d.ts",
32
+ "import": "./dist/separator/index.js"
33
+ },
34
+ "./stack": {
35
+ "types": "./dist/stack/index.d.ts",
36
+ "import": "./dist/stack/index.js"
29
37
  }
30
38
  },
31
39
  "dependencies": {
@@ -0,0 +1,3 @@
1
+ // biome-ignore lint/performance/noBarrelFile: the `./separator` subpath entry registers `line-separator` and exposes its class and types (spec 0011-separator.md Bundle).
2
+ export { LineSeparator } from './separator.js';
3
+ export type { SeparatorOrientation } from './separator.types.js';
@@ -0,0 +1,93 @@
1
+ import { INTERNALS, LineElement } from '@websublime/line-core';
2
+ import { commonReset } from '@websublime/line-core/styles';
3
+ import { type ComplexAttributeConverter, css, type PropertyDeclarations } from 'lit';
4
+ import type { SeparatorOrientation } from './separator.types.js';
5
+
6
+ /** An unknown `orientation` behaves as `horizontal`; the attribute keeps what the author wrote (C8). */
7
+ const orientationConverter: ComplexAttributeConverter<SeparatorOrientation> = {
8
+ fromAttribute: (value) => (value === 'vertical' ? 'vertical' : 'horizontal'),
9
+ };
10
+
11
+ /**
12
+ * `<line-separator>` draws a thin line between sections of content. The host
13
+ * is the line and the shadow root renders nothing. The host carries the
14
+ * `separator` role and its orientation as `ElementInternals` defaults, so an
15
+ * author `role` or `aria-*` attribute wins, and a host `aria-label` names it.
16
+ * `decorative` sets the role to `none`, so assistive technology skips the
17
+ * line; give a decorative separator no `aria-label`. It adds no spacing.
18
+ *
19
+ * @summary A thin horizontal or vertical line that separates sections of content.
20
+ *
21
+ * @cssprop [--line-separator-color=var(--line-gray-6, currentColor)] - Colour of the line.
22
+ * @cssprop [--line-separator-thickness=var(--line-border-1, 1px)] - Thickness of the line.
23
+ */
24
+ export class LineSeparator extends LineElement {
25
+ static override properties: PropertyDeclarations = {
26
+ orientation: { reflect: true, useDefault: true, converter: orientationConverter },
27
+ decorative: { type: Boolean, reflect: true, useDefault: true },
28
+ };
29
+
30
+ // The line is one border side set through longhands: forced-colors mode keeps a border colour visible,
31
+ // and an invalid var() in a shorthand would reset border-style to none (spec 0011-separator.md Drawing).
32
+ static override styles = [
33
+ commonReset,
34
+ css`
35
+ :host {
36
+ --line-separator-color: var(--line-gray-6, currentColor);
37
+ --line-separator-thickness: var(--line-border-1, 1px);
38
+
39
+ display: block;
40
+ align-self: stretch;
41
+ flex-shrink: 0;
42
+ border-block-start-style: solid;
43
+ border-block-start-width: var(--line-separator-thickness);
44
+ border-block-start-color: var(--line-separator-color);
45
+ }
46
+
47
+ :host([hidden]) {
48
+ display: none;
49
+ }
50
+
51
+ :host([orientation='vertical']) {
52
+ inline-size: 0;
53
+ min-block-size: 1em;
54
+ border-block-start-style: none;
55
+ border-block-start-width: 0;
56
+ border-inline-start-style: solid;
57
+ border-inline-start-width: var(--line-separator-thickness);
58
+ border-inline-start-color: var(--line-separator-color);
59
+ }
60
+ `,
61
+ ];
62
+
63
+ /** Direction of the line; an unknown value behaves as `horizontal`. */
64
+ declare orientation: SeparatorOrientation;
65
+ /** Removes the separator from the accessibility tree (role `none`); the line still draws. */
66
+ declare decorative: boolean;
67
+
68
+ constructor() {
69
+ super();
70
+ // `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).
71
+ this.orientation = 'horizontal';
72
+ this.decorative = false;
73
+ }
74
+
75
+ protected override willUpdate(changed: Map<PropertyKey, unknown>): void {
76
+ super.willUpdate(changed);
77
+ // Lit leaves `useDefault` initial values out of the first `changed` map, so the first update always writes.
78
+ if (this.hasUpdated && !changed.has('orientation') && !changed.has('decorative')) {
79
+ return;
80
+ }
81
+ const internals = this[INTERNALS];
82
+ internals.role = this.decorative ? 'none' : 'separator';
83
+ internals.ariaOrientation = !this.decorative && this.orientation === 'vertical' ? 'vertical' : null;
84
+ }
85
+ }
86
+
87
+ customElements.define('line-separator', LineSeparator);
88
+
89
+ declare global {
90
+ interface HTMLElementTagNameMap {
91
+ 'line-separator': LineSeparator;
92
+ }
93
+ }
@@ -0,0 +1,2 @@
1
+ /** Direction of the line drawn by `<line-separator>`; the A2UI basic v0.9 `Divider.axis` values. */
2
+ export type SeparatorOrientation = 'horizontal' | 'vertical';
@@ -0,0 +1,3 @@
1
+ // biome-ignore lint/performance/noBarrelFile: the `./stack` subpath entry registers `line-stack` and exposes its class and types (spec 0018-stack.md Bundle).
2
+ export { LineStack } from './stack.js';
3
+ export type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
@@ -0,0 +1,169 @@
1
+ import { LineElement } from '@websublime/line-core';
2
+ import { commonReset } from '@websublime/line-core/styles';
3
+ import { type ComplexAttributeConverter, css, html, type PropertyDeclarations, type TemplateResult } from 'lit';
4
+ import type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
5
+
6
+ const ORIENTATIONS: readonly StackOrientation[] = ['horizontal', 'vertical'];
7
+ const JUSTIFIES: readonly StackJustify[] = [
8
+ 'start',
9
+ 'center',
10
+ 'end',
11
+ 'spaceBetween',
12
+ 'spaceAround',
13
+ 'spaceEvenly',
14
+ 'stretch',
15
+ ];
16
+ const ALIGNS: readonly StackAlign[] = ['start', 'center', 'end', 'stretch'];
17
+ const GAPS: readonly StackGap[] = ['0', '1', '2', '3', '4', '5'];
18
+
19
+ /** An unknown value behaves as `fallback`; the attribute keeps what the author wrote. */
20
+ function enumConverter<T extends string>(values: readonly T[], fallback: T): ComplexAttributeConverter<T> {
21
+ return { fromAttribute: (value) => values.find((entry) => entry === value) ?? fallback };
22
+ }
23
+
24
+ /** An unknown `gap` behaves as no attribute, so the default step applies. */
25
+ const gapConverter: ComplexAttributeConverter<StackGap | undefined> = {
26
+ fromAttribute: (value) => GAPS.find((gap) => gap === value),
27
+ };
28
+
29
+ /**
30
+ * `<line-stack>` lays out its children in one row or one column with a gap
31
+ * between them. The host is the flex container and the slotted children are
32
+ * its flex items. It adds no role, so it stays `generic`; put `role="list"`
33
+ * on the host and `role="listitem"` on the children to build a list.
34
+ *
35
+ * @summary A layout container that places its children in one row or column with even spacing.
36
+ *
37
+ * @slot - The children; each element becomes a flex item.
38
+ *
39
+ * @cssprop [--line-stack-gap=var(--line-layout-gap-2)] - Space between items; `gap="0"` uses `0` and `gap="N"` uses `var(--line-layout-gap-N)`.
40
+ */
41
+ export class LineStack extends LineElement {
42
+ static override properties: PropertyDeclarations = {
43
+ orientation: { reflect: true, useDefault: true, converter: enumConverter(ORIENTATIONS, 'vertical') },
44
+ justify: { reflect: true, useDefault: true, converter: enumConverter(JUSTIFIES, 'start') },
45
+ align: { reflect: true, useDefault: true, converter: enumConverter(ALIGNS, 'stretch') },
46
+ gap: { reflect: true, converter: gapConverter },
47
+ wrap: { type: Boolean, reflect: true, useDefault: true },
48
+ };
49
+
50
+ static override styles = [
51
+ commonReset,
52
+ css`
53
+ :host {
54
+ --line-stack-gap: var(--line-layout-gap-2);
55
+
56
+ display: flex;
57
+ flex-direction: column;
58
+ justify-content: flex-start;
59
+ align-items: stretch;
60
+ flex-wrap: nowrap;
61
+ gap: var(--line-stack-gap);
62
+ }
63
+
64
+ :host([hidden]) {
65
+ display: none;
66
+ }
67
+
68
+ :host([orientation='horizontal']) {
69
+ flex-direction: row;
70
+ }
71
+
72
+ :host([justify='center']) {
73
+ justify-content: center;
74
+ }
75
+
76
+ :host([justify='end']) {
77
+ justify-content: flex-end;
78
+ }
79
+
80
+ :host([justify='spaceBetween']) {
81
+ justify-content: space-between;
82
+ }
83
+
84
+ :host([justify='spaceAround']) {
85
+ justify-content: space-around;
86
+ }
87
+
88
+ :host([justify='spaceEvenly']) {
89
+ justify-content: space-evenly;
90
+ }
91
+
92
+ :host([justify='stretch']) ::slotted(*) {
93
+ flex-grow: 1;
94
+ }
95
+
96
+ :host([align='start']) {
97
+ align-items: flex-start;
98
+ }
99
+
100
+ :host([align='center']) {
101
+ align-items: center;
102
+ }
103
+
104
+ :host([align='end']) {
105
+ align-items: flex-end;
106
+ }
107
+
108
+ :host([wrap]) {
109
+ flex-wrap: wrap;
110
+ }
111
+
112
+ :host([gap='0']) {
113
+ --line-stack-gap: 0;
114
+ }
115
+
116
+ :host([gap='1']) {
117
+ --line-stack-gap: var(--line-layout-gap-1);
118
+ }
119
+
120
+ :host([gap='2']) {
121
+ --line-stack-gap: var(--line-layout-gap-2);
122
+ }
123
+
124
+ :host([gap='3']) {
125
+ --line-stack-gap: var(--line-layout-gap-3);
126
+ }
127
+
128
+ :host([gap='4']) {
129
+ --line-stack-gap: var(--line-layout-gap-4);
130
+ }
131
+
132
+ :host([gap='5']) {
133
+ --line-stack-gap: var(--line-layout-gap-5);
134
+ }
135
+ `,
136
+ ];
137
+
138
+ /** Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction. */
139
+ declare orientation: StackOrientation;
140
+ /** Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`. */
141
+ declare justify: StackJustify;
142
+ /** Alignment on the cross axis; an unknown value behaves as `stretch`. */
143
+ declare align: StackAlign;
144
+ /** Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`. */
145
+ declare gap: StackGap | undefined;
146
+ /** Lets the items flow onto more lines when they run out of space. */
147
+ declare wrap: boolean;
148
+
149
+ constructor() {
150
+ super();
151
+ // `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).
152
+ this.orientation = 'vertical';
153
+ this.justify = 'start';
154
+ this.align = 'stretch';
155
+ this.wrap = false;
156
+ }
157
+
158
+ override render(): TemplateResult {
159
+ return html`<slot></slot>`;
160
+ }
161
+ }
162
+
163
+ customElements.define('line-stack', LineStack);
164
+
165
+ declare global {
166
+ interface HTMLElementTagNameMap {
167
+ 'line-stack': LineStack;
168
+ }
169
+ }