@atomic-ui/ui 0.0.0-stage → 0.1.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 +134 -2
- package/dist/base/FieldElement.d.ts +95 -0
- package/dist/base/ImpktElement.d.ts +21 -0
- package/dist/base/styles.d.ts +42 -0
- package/dist/base/tokens.d.ts +68 -0
- package/dist/chunk-26CSJMXY.js +122 -0
- package/dist/chunk-26CSJMXY.js.map +1 -0
- package/dist/chunk-3LFXWUOU.js +86 -0
- package/dist/chunk-3LFXWUOU.js.map +1 -0
- package/dist/chunk-43V4RFK4.js +94 -0
- package/dist/chunk-43V4RFK4.js.map +1 -0
- package/dist/chunk-4P3FLJZG.js +77 -0
- package/dist/chunk-4P3FLJZG.js.map +1 -0
- package/dist/chunk-5NBYZ5UC.js +164 -0
- package/dist/chunk-5NBYZ5UC.js.map +1 -0
- package/dist/chunk-BM73FVQ4.js +153 -0
- package/dist/chunk-BM73FVQ4.js.map +1 -0
- package/dist/chunk-CNFIYRPA.js +67 -0
- package/dist/chunk-CNFIYRPA.js.map +1 -0
- package/dist/chunk-G6X62CFC.js +713 -0
- package/dist/chunk-G6X62CFC.js.map +1 -0
- package/dist/chunk-M3WQZDWU.js +138 -0
- package/dist/chunk-M3WQZDWU.js.map +1 -0
- package/dist/chunk-O72RTRIJ.js +132 -0
- package/dist/chunk-O72RTRIJ.js.map +1 -0
- package/dist/chunk-OZNQ4GAR.js +159 -0
- package/dist/chunk-OZNQ4GAR.js.map +1 -0
- package/dist/chunk-PV4GMCP6.js +90 -0
- package/dist/chunk-PV4GMCP6.js.map +1 -0
- package/dist/chunk-QAKFGIOO.js +104 -0
- package/dist/chunk-QAKFGIOO.js.map +1 -0
- package/dist/chunk-RYJQKKJ4.js +133 -0
- package/dist/chunk-RYJQKKJ4.js.map +1 -0
- package/dist/chunk-SHGQMQXS.js +97 -0
- package/dist/chunk-SHGQMQXS.js.map +1 -0
- package/dist/chunk-TWCXYY4Z.js +83 -0
- package/dist/chunk-TWCXYY4Z.js.map +1 -0
- package/dist/chunk-UTL446G6.js +107 -0
- package/dist/chunk-UTL446G6.js.map +1 -0
- package/dist/chunk-VF6PNIPS.js +164 -0
- package/dist/chunk-VF6PNIPS.js.map +1 -0
- package/dist/chunk-VKQGLSDT.js +124 -0
- package/dist/chunk-VKQGLSDT.js.map +1 -0
- package/dist/chunk-WAB4TRB2.js +141 -0
- package/dist/chunk-WAB4TRB2.js.map +1 -0
- package/dist/chunk-WC5KO6KZ.js +44 -0
- package/dist/chunk-WC5KO6KZ.js.map +1 -0
- package/dist/chunk-YXHT3ZJU.js +81 -0
- package/dist/chunk-YXHT3ZJU.js.map +1 -0
- package/dist/components/accordion.d.ts +66 -0
- package/dist/components/accordion.js +8 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +49 -0
- package/dist/components/alert.js +8 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/button.d.ts +70 -0
- package/dist/components/button.js +8 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox-group.d.ts +79 -0
- package/dist/components/checkbox-group.js +9 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +64 -0
- package/dist/components/checkbox.js +9 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/date-input.d.ts +95 -0
- package/dist/components/date-input.js +9 -0
- package/dist/components/date-input.js.map +1 -0
- package/dist/components/dialog.d.ts +61 -0
- package/dist/components/dialog.js +8 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/grid.d.ts +34 -0
- package/dist/components/grid.js +8 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/help.d.ts +103 -0
- package/dist/components/help.js +8 -0
- package/dist/components/help.js.map +1 -0
- package/dist/components/layout.d.ts +100 -0
- package/dist/components/layout.js +14 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/link.d.ts +46 -0
- package/dist/components/link.js +8 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/media.d.ts +164 -0
- package/dist/components/media.js +12 -0
- package/dist/components/media.js.map +1 -0
- package/dist/components/price.d.ts +67 -0
- package/dist/components/price.js +8 -0
- package/dist/components/price.js.map +1 -0
- package/dist/components/progress.d.ts +50 -0
- package/dist/components/progress.js +8 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +82 -0
- package/dist/components/radio-group.js +9 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/select.d.ts +74 -0
- package/dist/components/select.js +9 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/summary-list.d.ts +47 -0
- package/dist/components/summary-list.js +8 -0
- package/dist/components/summary-list.js.map +1 -0
- package/dist/components/table.d.ts +49 -0
- package/dist/components/table.js +8 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/text-input.d.ts +80 -0
- package/dist/components/text-input.js +9 -0
- package/dist/components/text-input.js.map +1 -0
- package/dist/components/textarea.d.ts +59 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
ImpktElement,
|
|
4
|
+
b,
|
|
5
|
+
i,
|
|
6
|
+
t
|
|
7
|
+
} from "./chunk-G6X62CFC.js";
|
|
8
|
+
|
|
9
|
+
// packages/ui/src/components/media.ts
|
|
10
|
+
var ImpktImage = class extends ImpktElement {
|
|
11
|
+
static {
|
|
12
|
+
this.properties = {
|
|
13
|
+
src: { type: String },
|
|
14
|
+
alt: { type: String },
|
|
15
|
+
decorative: { type: Boolean, reflect: true },
|
|
16
|
+
width: { type: Number },
|
|
17
|
+
height: { type: Number },
|
|
18
|
+
focalX: { type: Number, attribute: "focal-x" },
|
|
19
|
+
focalY: { type: Number, attribute: "focal-y" },
|
|
20
|
+
loading: { type: String }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.src = "";
|
|
26
|
+
this.alt = "";
|
|
27
|
+
this.decorative = false;
|
|
28
|
+
this.width = void 0;
|
|
29
|
+
this.height = void 0;
|
|
30
|
+
this.focalX = 0.5;
|
|
31
|
+
this.focalY = 0.5;
|
|
32
|
+
this.loading = "lazy";
|
|
33
|
+
}
|
|
34
|
+
static {
|
|
35
|
+
this.styles = [
|
|
36
|
+
...ImpktElement.styles,
|
|
37
|
+
i`
|
|
38
|
+
:host {
|
|
39
|
+
display: block;
|
|
40
|
+
}
|
|
41
|
+
img {
|
|
42
|
+
display: block;
|
|
43
|
+
max-inline-size: 100%;
|
|
44
|
+
block-size: auto;
|
|
45
|
+
object-fit: cover;
|
|
46
|
+
}
|
|
47
|
+
`
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
return b`
|
|
52
|
+
<img
|
|
53
|
+
part="image"
|
|
54
|
+
src=${this.src}
|
|
55
|
+
alt=${this.decorative ? "" : this.alt}
|
|
56
|
+
role=${this.decorative ? "presentation" : A}
|
|
57
|
+
width=${this.width ?? A}
|
|
58
|
+
height=${this.height ?? A}
|
|
59
|
+
loading=${this.loading}
|
|
60
|
+
style="object-position: ${this.focalX * 100}% ${this.focalY * 100}%"
|
|
61
|
+
/>
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var ImpktLogo = class extends ImpktElement {
|
|
66
|
+
static {
|
|
67
|
+
this.properties = {
|
|
68
|
+
src: { type: String },
|
|
69
|
+
srcDark: { type: String, attribute: "src-dark" },
|
|
70
|
+
alt: { type: String },
|
|
71
|
+
onDark: { type: Boolean, attribute: "on-dark", reflect: true },
|
|
72
|
+
height: { type: Number }
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
constructor() {
|
|
76
|
+
super();
|
|
77
|
+
this.src = "";
|
|
78
|
+
this.srcDark = "";
|
|
79
|
+
this.alt = "";
|
|
80
|
+
this.onDark = false;
|
|
81
|
+
this.height = 32;
|
|
82
|
+
}
|
|
83
|
+
static {
|
|
84
|
+
this.styles = [
|
|
85
|
+
...ImpktElement.styles,
|
|
86
|
+
i`
|
|
87
|
+
:host {
|
|
88
|
+
display: inline-block;
|
|
89
|
+
}
|
|
90
|
+
img {
|
|
91
|
+
display: block;
|
|
92
|
+
inline-size: auto;
|
|
93
|
+
}
|
|
94
|
+
`
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
const src = this.onDark && this.srcDark ? this.srcDark : this.src;
|
|
99
|
+
return b`<img part="logo" src=${src} alt=${this.alt} style="height: ${this.height}px" />`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var ImpktDocumentLink = class extends ImpktElement {
|
|
103
|
+
static {
|
|
104
|
+
this.properties = {
|
|
105
|
+
href: { type: String },
|
|
106
|
+
label: { type: String },
|
|
107
|
+
fileType: { type: String, attribute: "file-type" },
|
|
108
|
+
byteSize: { type: Number, attribute: "byte-size" }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
constructor() {
|
|
112
|
+
super();
|
|
113
|
+
this.href = "";
|
|
114
|
+
this.label = "";
|
|
115
|
+
this.fileType = "";
|
|
116
|
+
this.byteSize = void 0;
|
|
117
|
+
}
|
|
118
|
+
static {
|
|
119
|
+
this.styles = [
|
|
120
|
+
...ImpktElement.styles,
|
|
121
|
+
i`
|
|
122
|
+
:host {
|
|
123
|
+
display: block;
|
|
124
|
+
}
|
|
125
|
+
a {
|
|
126
|
+
color: ${t.link};
|
|
127
|
+
text-decoration: underline;
|
|
128
|
+
text-underline-offset: 0.2em;
|
|
129
|
+
display: inline-flex;
|
|
130
|
+
gap: 0.5ch;
|
|
131
|
+
align-items: baseline;
|
|
132
|
+
min-block-size: ${t.targetMin};
|
|
133
|
+
}
|
|
134
|
+
.meta {
|
|
135
|
+
color: ${t.textMuted};
|
|
136
|
+
}
|
|
137
|
+
`
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
/** "240 KB". Rounded, because the exact byte count helps nobody. */
|
|
141
|
+
get size() {
|
|
142
|
+
if (!this.byteSize) return "";
|
|
143
|
+
const kb = this.byteSize / 1024;
|
|
144
|
+
return kb >= 1024 ? `${(kb / 1024).toFixed(1)} MB` : `${Math.round(kb)} KB`;
|
|
145
|
+
}
|
|
146
|
+
render() {
|
|
147
|
+
const meta = [this.fileType, this.size].filter(Boolean).join(", ");
|
|
148
|
+
return b`
|
|
149
|
+
<a part="link" href=${this.href || A} download>
|
|
150
|
+
<span>${this.label}</span>${meta ? b`<span class="meta">(${meta})</span>` : A}
|
|
151
|
+
</a>
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
customElements.define("impkt-image", ImpktImage);
|
|
156
|
+
customElements.define("impkt-logo", ImpktLogo);
|
|
157
|
+
customElements.define("impkt-document-link", ImpktDocumentLink);
|
|
158
|
+
|
|
159
|
+
export {
|
|
160
|
+
ImpktImage,
|
|
161
|
+
ImpktLogo,
|
|
162
|
+
ImpktDocumentLink
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=chunk-VF6PNIPS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/media.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { t } from '../base/tokens';\n\n/**\n * An image.\n *\n * `alt` is required and may be the empty string, which is a decision rather\n * than laxity: an empty alt is the correct and only way to mark an image as\n * decorative, and a missing alt is a different thing entirely — it leaves a\n * screen reader to read the file name. Making the property required forces the\n * author to say which they meant.\n *\n * `width` and `height` are the intrinsic pixel size. Without them the browser\n * cannot reserve space and the page jumps as each image loads, which is a\n * usability problem for everyone and a serious one for anyone using a screen\n * magnifier, who loses their place entirely.\n\n *\n * @category media\n * @icon image\n * @role image\n */\nexport class ImpktImage extends ImpktElement {\n static properties = {\n src: { type: String },\n alt: { type: String },\n decorative: { type: Boolean, reflect: true },\n width: { type: Number },\n height: { type: Number },\n focalX: { type: Number, attribute: 'focal-x' },\n focalY: { type: Number, attribute: 'focal-y' },\n loading: { type: String },\n };\n\n declare src: string;\n declare alt: string;\n /**\n * This image says nothing a reader needs.\n *\n * An empty `alt` is the correct way to mark a decorative image AND what a\n * missing one looks like, so the two are indistinguishable to anything\n * downstream — which is why the commonest accessibility failure on the web\n * survives every automated check. Only the author knows which they meant,\n * so this is where they say it, and the publish gate holds them to it.\n */\n declare decorative: boolean;\n declare width: number | undefined;\n declare height: number | undefined;\n /** The fraction of the image that must survive a crop. */\n declare focalX: number;\n declare focalY: number;\n declare loading: 'lazy' | 'eager';\n\n constructor() {\n super();\n this.src = '';\n this.alt = '';\n this.decorative = false;\n this.width = undefined;\n this.height = undefined;\n this.focalX = 0.5;\n this.focalY = 0.5;\n this.loading = 'lazy';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n }\n img {\n display: block;\n max-inline-size: 100%;\n block-size: auto;\n object-fit: cover;\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <img\n part=\"image\"\n src=${this.src}\n alt=${this.decorative ? '' : this.alt}\n role=${this.decorative ? 'presentation' : nothing}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n loading=${this.loading}\n style=\"object-position: ${this.focalX * 100}% ${this.focalY * 100}%\"\n />\n `;\n }\n}\n\n/**\n * The partner's logo.\n *\n * Separate from `impkt-image` for one reason: it is the most prominent image on\n * every page and its alt text is the brand name, so it should not be possible\n * to ship it with an empty alt by copying a decorative image. `src` and `alt`\n * come from the brand's assets.\n *\n * `on-dark` picks the dark-surface variant where the brand supplies one. A\n * logo that disappears into a dark footer is not a styling problem, it is a\n * missing piece of information.\n\n *\n * @category media\n * @icon logo\n */\nexport class ImpktLogo extends ImpktElement {\n static properties = {\n src: { type: String },\n srcDark: { type: String, attribute: 'src-dark' },\n alt: { type: String },\n onDark: { type: Boolean, attribute: 'on-dark', reflect: true },\n height: { type: Number },\n };\n\n declare src: string;\n declare srcDark: string;\n declare alt: string;\n declare onDark: boolean;\n declare height: number;\n\n constructor() {\n super();\n this.src = '';\n this.srcDark = '';\n this.alt = '';\n this.onDark = false;\n this.height = 32;\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: inline-block;\n }\n img {\n display: block;\n inline-size: auto;\n }\n `,\n ];\n\n render(): TemplateResult {\n const src = this.onDark && this.srcDark ? this.srcDark : this.src;\n return html`<img part=\"logo\" src=${src} alt=${this.alt} style=\"height: ${this.height}px\" />`;\n }\n}\n\n/**\n * A downloadable document — terms of service, a product sheet, a price list.\n *\n * The file type and size are part of the accessible name, not decoration\n * beside it. A list of links all named \"Download\" fails 2.4.4 Link Purpose,\n * and a reader tabbing between them cannot tell which document they are on.\n\n *\n * @category media\n * @icon document\n */\nexport class ImpktDocumentLink extends ImpktElement {\n static properties = {\n href: { type: String },\n label: { type: String },\n fileType: { type: String, attribute: 'file-type' },\n byteSize: { type: Number, attribute: 'byte-size' },\n };\n\n declare href: string;\n declare label: string;\n declare fileType: string;\n declare byteSize: number | undefined;\n\n constructor() {\n super();\n this.href = '';\n this.label = '';\n this.fileType = '';\n this.byteSize = undefined;\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n }\n a {\n color: ${t.link};\n text-decoration: underline;\n text-underline-offset: 0.2em;\n display: inline-flex;\n gap: 0.5ch;\n align-items: baseline;\n min-block-size: ${t.targetMin};\n }\n .meta {\n color: ${t.textMuted};\n }\n `,\n ];\n\n /** \"240 KB\". Rounded, because the exact byte count helps nobody. */\n private get size(): string {\n if (!this.byteSize) return '';\n const kb = this.byteSize / 1024;\n return kb >= 1024 ? `${(kb / 1024).toFixed(1)} MB` : `${Math.round(kb)} KB`;\n }\n\n render(): TemplateResult {\n const meta = [this.fileType, this.size].filter(Boolean).join(', ');\n return html`\n <a part=\"link\" href=${this.href || nothing} download>\n <span>${this.label}</span>${meta ? html`<span class=\"meta\">(${meta})</span>` : nothing}\n </a>\n `;\n }\n}\n\ncustomElements.define('impkt-image', ImpktImage);\ncustomElements.define('impkt-logo', ImpktLogo);\ncustomElements.define('impkt-document-link', ImpktDocumentLink);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-image': ImpktImage;\n 'impkt-logo': ImpktLogo;\n 'impkt-document-link': ImpktDocumentLink;\n }\n}\n"],"mappings":";;;;;;;;;AAuBO,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C;AAAA,SAAO,aAAa;AAAA,MAClB,KAAK,EAAE,MAAM,OAAO;AAAA,MACpB,KAAK,EAAE,MAAM,OAAO;AAAA,MACpB,YAAY,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MAC3C,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,QAAQ,EAAE,MAAM,OAAO;AAAA,MACvB,QAAQ,EAAE,MAAM,QAAQ,WAAW,UAAU;AAAA,MAC7C,QAAQ,EAAE,MAAM,QAAQ,WAAW,UAAU;AAAA,MAC7C,SAAS,EAAE,MAAM,OAAO;AAAA,IAC1B;AAAA;AAAA,EAqBA,cAAc;AACZ,UAAM;AACN,SAAK,MAAM;AACX,SAAK,MAAM;AACX,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,SAAS;AACd,SAAK,SAAS;AACd,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWF;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA;AAAA,cAGG,KAAK,GAAG;AAAA,cACR,KAAK,aAAa,KAAK,KAAK,GAAG;AAAA,eAC9B,KAAK,aAAa,iBAAiB,CAAO;AAAA,gBACzC,KAAK,SAAS,CAA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AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKa,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAMG,EAAE,SAAS;AAAA;AAAA;AAAA,iBAGpB,EAAE,SAAS;AAAA;AAAA;AAAA,IAG1B;AAAA;AAAA;AAAA,EAGA,IAAY,OAAe;AACzB,QAAI,CAAC,KAAK,SAAU,QAAO;AAC3B,UAAM,KAAK,KAAK,WAAW;AAC3B,WAAO,MAAM,OAAO,IAAI,KAAK,MAAM,QAAQ,CAAC,CAAC,QAAQ,GAAG,KAAK,MAAM,EAAE,CAAC;AAAA,EACxE;AAAA,EAEA,SAAyB;AACvB,UAAM,OAAO,CAAC,KAAK,UAAU,KAAK,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AACjE,WAAO;AAAA,4BACiB,KAAK,QAAQ,CAAO;AAAA,gBAChC,KAAK,KAAK,UAAU,OAAO,wBAA2B,IAAI,aAAa,CAAO;AAAA;AAAA;AAAA,EAG5F;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;AAC/C,eAAe,OAAO,cAAc,SAAS;AAC7C,eAAe,OAAO,uBAAuB,iBAAiB;","names":[]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
ImpktElement,
|
|
4
|
+
b,
|
|
5
|
+
focusRing,
|
|
6
|
+
fontSize,
|
|
7
|
+
fontWeight,
|
|
8
|
+
i,
|
|
9
|
+
space,
|
|
10
|
+
t,
|
|
11
|
+
targetSize
|
|
12
|
+
} from "./chunk-G6X62CFC.js";
|
|
13
|
+
|
|
14
|
+
// packages/ui/src/components/accordion.ts
|
|
15
|
+
var ImpktAccordion = class extends ImpktElement {
|
|
16
|
+
static {
|
|
17
|
+
this.properties = {
|
|
18
|
+
items: { type: Array },
|
|
19
|
+
headingLevel: { type: Number, attribute: "heading-level" },
|
|
20
|
+
open: { type: Array },
|
|
21
|
+
multiple: { type: Boolean }
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.items = [];
|
|
27
|
+
this.headingLevel = 3;
|
|
28
|
+
this.open = [];
|
|
29
|
+
this.multiple = true;
|
|
30
|
+
}
|
|
31
|
+
static {
|
|
32
|
+
this.styles = [
|
|
33
|
+
...ImpktElement.styles,
|
|
34
|
+
focusRing,
|
|
35
|
+
i`
|
|
36
|
+
:host {
|
|
37
|
+
display: block;
|
|
38
|
+
}
|
|
39
|
+
.item {
|
|
40
|
+
border-block-end: ${t.borderThin} solid ${t.border};
|
|
41
|
+
}
|
|
42
|
+
button {
|
|
43
|
+
${targetSize}
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
gap: ${space(3)};
|
|
48
|
+
inline-size: 100%;
|
|
49
|
+
padding: ${space(3)} 0;
|
|
50
|
+
background: none;
|
|
51
|
+
border: 0;
|
|
52
|
+
font: inherit;
|
|
53
|
+
font-size: ${fontSize("md")};
|
|
54
|
+
font-weight: ${fontWeight("semibold")};
|
|
55
|
+
color: ${t.text};
|
|
56
|
+
text-align: start;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
button:hover {
|
|
60
|
+
color: ${t.link};
|
|
61
|
+
}
|
|
62
|
+
.marker {
|
|
63
|
+
flex: none;
|
|
64
|
+
transition: transform 120ms ease-in-out;
|
|
65
|
+
}
|
|
66
|
+
button[aria-expanded='true'] .marker {
|
|
67
|
+
transform: rotate(90deg);
|
|
68
|
+
}
|
|
69
|
+
.panel {
|
|
70
|
+
padding-block-end: ${space(4)};
|
|
71
|
+
font-size: ${fontSize("md")};
|
|
72
|
+
}
|
|
73
|
+
`
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
toggle(id) {
|
|
77
|
+
const isOpen = this.open.includes(id);
|
|
78
|
+
if (isOpen) this.open = this.open.filter((o) => o !== id);
|
|
79
|
+
else this.open = this.multiple ? [...this.open, id] : [id];
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
return b`
|
|
83
|
+
${this.items.map((item) => {
|
|
84
|
+
const expanded = this.open.includes(item.id);
|
|
85
|
+
const panelId = this.id_(`panel-${item.id}`);
|
|
86
|
+
const buttonId = this.id_(`button-${item.id}`);
|
|
87
|
+
return b`
|
|
88
|
+
<div class="item" part="item">
|
|
89
|
+
<div role="heading" aria-level=${this.headingLevel}>
|
|
90
|
+
<button
|
|
91
|
+
id=${buttonId}
|
|
92
|
+
part="header"
|
|
93
|
+
type="button"
|
|
94
|
+
aria-expanded=${expanded ? "true" : "false"}
|
|
95
|
+
aria-controls=${panelId}
|
|
96
|
+
@click=${() => this.toggle(item.id)}
|
|
97
|
+
>
|
|
98
|
+
<span>${item.heading}</span>
|
|
99
|
+
<span class="marker" aria-hidden="true">›</span>
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
<div
|
|
103
|
+
id=${panelId}
|
|
104
|
+
class="panel"
|
|
105
|
+
part="panel"
|
|
106
|
+
role="region"
|
|
107
|
+
aria-labelledby=${buttonId}
|
|
108
|
+
?hidden=${!expanded}
|
|
109
|
+
>
|
|
110
|
+
<slot name=${`panel-${item.id}`}>${item.body}</slot>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
`;
|
|
114
|
+
})}
|
|
115
|
+
${this.items.length === 0 ? A : A}
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
customElements.define("impkt-accordion", ImpktAccordion);
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
ImpktAccordion
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=chunk-VKQGLSDT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/accordion.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, targetSize } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface AccordionItem {\n id: string;\n heading: string;\n body: string;\n}\n\n/**\n * Disclosure sections — frequently asked questions, \"what does this mean?\".\n *\n * **Each header is a button inside a heading.** The heading is what lets a\n * screen-reader user jump between sections without tabbing through every\n * paragraph; the button is what makes the section openable. One without the\n * other is a common half-implementation: all-headings cannot be operated,\n * all-buttons cannot be navigated.\n *\n * `headingLevel` is a property because the right level depends on what is\n * above the accordion on the page, and guessing produces exactly the skipped\n * levels that 1.3.1 is about.\n *\n * **Panels are hidden, not unmounted.** `hidden` keeps the content in the\n * accessibility tree's structure and lets in-page search find it when opened,\n * and it means `aria-controls` always points at an element that exists.\n *\n * **A panel can hold more than words.** `body` is plain text, which is what a\n * composition can author safely. Content rendered elsewhere, such as an FAQ\n * answer with links and a list, is slotted instead: a child with\n * `slot=\"panel-<item id>\"` replaces that item's body. The slot sits inside the\n * panel, so the region, its label and its `hidden` state are unchanged, and a\n * panel with nothing slotted still shows its body.\n *\n * @category content\n * @icon accordion\n */\nexport class ImpktAccordion extends ImpktElement {\n static properties = {\n items: { type: Array },\n headingLevel: { type: Number, attribute: 'heading-level' },\n open: { type: Array },\n multiple: { type: Boolean },\n };\n\n declare items: AccordionItem[];\n declare headingLevel: number;\n /** Ids currently expanded. */\n declare open: string[];\n /** When false, opening one closes the others. */\n declare multiple: boolean;\n\n constructor() {\n super();\n this.items = [];\n this.headingLevel = 3;\n this.open = [];\n this.multiple = true;\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n }\n .item {\n border-block-end: ${t.borderThin} solid ${t.border};\n }\n button {\n ${targetSize}\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: ${space(3)};\n inline-size: 100%;\n padding: ${space(3)} 0;\n background: none;\n border: 0;\n font: inherit;\n font-size: ${fontSize('md')};\n font-weight: ${fontWeight('semibold')};\n color: ${t.text};\n text-align: start;\n cursor: pointer;\n }\n button:hover {\n color: ${t.link};\n }\n .marker {\n flex: none;\n transition: transform 120ms ease-in-out;\n }\n button[aria-expanded='true'] .marker {\n transform: rotate(90deg);\n }\n .panel {\n padding-block-end: ${space(4)};\n font-size: ${fontSize('md')};\n }\n `,\n ];\n\n private toggle(id: string): void {\n const isOpen = this.open.includes(id);\n if (isOpen) this.open = this.open.filter((o) => o !== id);\n else this.open = this.multiple ? [...this.open, id] : [id];\n }\n\n render(): TemplateResult {\n return html`\n ${this.items.map((item) => {\n const expanded = this.open.includes(item.id);\n const panelId = this.id_(`panel-${item.id}`);\n const buttonId = this.id_(`button-${item.id}`);\n return html`\n <div class=\"item\" part=\"item\">\n <div role=\"heading\" aria-level=${this.headingLevel}>\n <button\n id=${buttonId}\n part=\"header\"\n type=\"button\"\n aria-expanded=${expanded ? 'true' : 'false'}\n aria-controls=${panelId}\n @click=${() => this.toggle(item.id)}\n >\n <span>${item.heading}</span>\n <span class=\"marker\" aria-hidden=\"true\">›</span>\n </button>\n </div>\n <div\n id=${panelId}\n class=\"panel\"\n part=\"panel\"\n role=\"region\"\n aria-labelledby=${buttonId}\n ?hidden=${!expanded}\n >\n <slot name=${`panel-${item.id}`}>${item.body}</slot>\n </div>\n </div>\n `;\n })}\n ${this.items.length === 0 ? nothing : nothing}\n `;\n }\n}\n\ncustomElements.define('impkt-accordion', ImpktAccordion);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-accordion': ImpktAccordion }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCO,IAAM,iBAAN,cAA6B,aAAa;AAAA,EAC/C;AAAA,SAAO,aAAa;AAAA,MAClB,OAAO,EAAE,MAAM,MAAM;AAAA,MACrB,cAAc,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,MACzD,MAAM,EAAE,MAAM,MAAM;AAAA,MACpB,UAAU,EAAE,MAAM,QAAQ;AAAA,IAC5B;AAAA;AAAA,E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;AAAA;AAAA,gCAGG,WAAW,SAAS,OAAO;AAAA,gCAC3B,OAAO;AAAA,yBACd,MAAM,KAAK,OAAO,KAAK,EAAE,CAAC;AAAA;AAAA,wBAE3B,KAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKjB,OAAO;AAAA;AAAA;AAAA;AAAA,gCAIM,QAAQ;AAAA,wBAChB,CAAC,QAAQ;AAAA;AAAA,2BAEN,SAAS,KAAK,EAAE,EAAE,IAAI,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,IAIpD,CAAC,CAAC;AAAA,QACA,KAAK,MAAM,WAAW,IAAI,IAAU,CAAO;AAAA;AAAA,EAEjD;AACF;AAEA,eAAe,OAAO,mBAAmB,cAAc;","names":[]}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldElement
|
|
3
|
+
} from "./chunk-5NBYZ5UC.js";
|
|
4
|
+
import {
|
|
5
|
+
A,
|
|
6
|
+
b,
|
|
7
|
+
fontSize,
|
|
8
|
+
i,
|
|
9
|
+
space,
|
|
10
|
+
t,
|
|
11
|
+
targetSize
|
|
12
|
+
} from "./chunk-G6X62CFC.js";
|
|
13
|
+
|
|
14
|
+
// packages/ui/src/components/radio-group.ts
|
|
15
|
+
var ImpktRadioGroup = class extends FieldElement {
|
|
16
|
+
static {
|
|
17
|
+
this.properties = {
|
|
18
|
+
...FieldElement.properties,
|
|
19
|
+
options: { type: Array }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.options = [];
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.styles = [
|
|
28
|
+
...FieldElement.styles,
|
|
29
|
+
i`
|
|
30
|
+
fieldset {
|
|
31
|
+
border: 0;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
min-inline-size: 0;
|
|
35
|
+
}
|
|
36
|
+
legend {
|
|
37
|
+
padding: 0;
|
|
38
|
+
}
|
|
39
|
+
.option {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: flex-start;
|
|
42
|
+
gap: ${space(3)};
|
|
43
|
+
padding: ${space(3)};
|
|
44
|
+
border: ${t.borderThin} solid ${t.border};
|
|
45
|
+
border-radius: ${t.radius};
|
|
46
|
+
margin-block-end: ${space(2)};
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
}
|
|
49
|
+
.option:hover {
|
|
50
|
+
background: ${t.surfaceSubtle};
|
|
51
|
+
}
|
|
52
|
+
/* The whole row is the target, not the 20px dot — 2.5.8 is a floor and
|
|
53
|
+
a comfortable target is the actual goal. */
|
|
54
|
+
.option input {
|
|
55
|
+
${targetSize}
|
|
56
|
+
inline-size: 20px;
|
|
57
|
+
block-size: 20px;
|
|
58
|
+
margin: 0;
|
|
59
|
+
flex: none;
|
|
60
|
+
accent-color: ${t.brand};
|
|
61
|
+
}
|
|
62
|
+
.option-text {
|
|
63
|
+
display: block;
|
|
64
|
+
font-size: ${fontSize("md")};
|
|
65
|
+
}
|
|
66
|
+
.option-description {
|
|
67
|
+
display: block;
|
|
68
|
+
font-size: ${fontSize("sm")};
|
|
69
|
+
color: ${t.textMuted};
|
|
70
|
+
margin-block-start: ${space(1)};
|
|
71
|
+
}
|
|
72
|
+
:host([invalid]) .option {
|
|
73
|
+
border-color: ${t.danger};
|
|
74
|
+
}
|
|
75
|
+
`
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
renderLabel() {
|
|
79
|
+
return b`<legend class="label" part="label">
|
|
80
|
+
${this.label}${this.required ? b`<span class="required"> (${this.requiredText})</span>` : A}
|
|
81
|
+
</legend>`;
|
|
82
|
+
}
|
|
83
|
+
renderControl() {
|
|
84
|
+
return b`
|
|
85
|
+
${this.options.map((option, i2) => {
|
|
86
|
+
const id = this.id_(`opt-${i2}`);
|
|
87
|
+
const descId = option.description ? this.id_(`opt-${i2}-desc`) : void 0;
|
|
88
|
+
return b`
|
|
89
|
+
<label class="option" part="option" for=${id}>
|
|
90
|
+
<input
|
|
91
|
+
type="radio"
|
|
92
|
+
id=${id}
|
|
93
|
+
name=${this.uid}
|
|
94
|
+
value=${option.value}
|
|
95
|
+
.checked=${this.value === option.value}
|
|
96
|
+
?disabled=${this.disabled}
|
|
97
|
+
?required=${this.required && i2 === 0}
|
|
98
|
+
aria-describedby=${descId ?? A}
|
|
99
|
+
@change=${() => this.setFormValue(option.value)}
|
|
100
|
+
/>
|
|
101
|
+
<span>
|
|
102
|
+
<span class="option-text">${option.label}</span>
|
|
103
|
+
${option.description ? b`<span class="option-description" id=${descId}>${option.description}</span>` : A}
|
|
104
|
+
</span>
|
|
105
|
+
</label>
|
|
106
|
+
`;
|
|
107
|
+
})}
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The fieldset wraps everything, so the whole field is rebuilt here rather
|
|
112
|
+
* than relying on the base class's flat order.
|
|
113
|
+
*/
|
|
114
|
+
render() {
|
|
115
|
+
return b`
|
|
116
|
+
<fieldset
|
|
117
|
+
part="fieldset"
|
|
118
|
+
aria-describedby=${this.describedBy}
|
|
119
|
+
aria-invalid=${this.error ? "true" : A}
|
|
120
|
+
>
|
|
121
|
+
${this.renderLabel()}
|
|
122
|
+
${this.description ? b`<div class="description" id=${this.id_("description")} part="description">
|
|
123
|
+
${this.description}
|
|
124
|
+
</div>` : A}
|
|
125
|
+
${this.renderControl()}
|
|
126
|
+
<div class="error" id=${this.id_("error")} part="error" aria-live="polite">
|
|
127
|
+
${this.error || A}
|
|
128
|
+
</div>
|
|
129
|
+
</fieldset>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
updated(changed) {
|
|
133
|
+
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
customElements.define("impkt-radio-group", ImpktRadioGroup);
|
|
137
|
+
|
|
138
|
+
export {
|
|
139
|
+
ImpktRadioGroup
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=chunk-WAB4TRB2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/radio-group.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { targetSize } from '../base/styles';\nimport { fontSize, space, t } from '../base/tokens';\n\nexport interface RadioOption {\n value: string;\n label: string;\n description?: string;\n}\n\n/**\n * A choose-one group.\n *\n * **It renders native radios, and that is the whole design.** A group of\n * `<input type=\"radio\">` sharing a name already has roving tabindex, arrow-key\n * navigation that wraps, Home and End, selection-follows-focus, and the right\n * announcement in every screen reader — all of it, correctly, with no\n * JavaScript. Hand-rolling that is the single most commonly attempted and most\n * commonly botched widget in any design system, and every version of it is a\n * worse version of what the platform ships.\n *\n * Because the radios share one shadow root, their `name` scopes to this\n * component and cannot collide with another group on the page.\n *\n * The label is a `<legend>` inside a `<fieldset>`, not a `<label for>`:\n * `for` names one control, and the question here is asked of the set.\n\n *\n * @category form\n * @icon radio\n */\nexport class ImpktRadioGroup extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n };\n\n declare options: RadioOption[];\n\n constructor() {\n super();\n this.options = [];\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n fieldset {\n border: 0;\n margin: 0;\n padding: 0;\n min-inline-size: 0;\n }\n legend {\n padding: 0;\n }\n .option {\n display: flex;\n align-items: flex-start;\n gap: ${space(3)};\n padding: ${space(3)};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radius};\n margin-block-end: ${space(2)};\n cursor: pointer;\n }\n .option:hover {\n background: ${t.surfaceSubtle};\n }\n /* The whole row is the target, not the 20px dot — 2.5.8 is a floor and\n a comfortable target is the actual goal. */\n .option input {\n ${targetSize}\n inline-size: 20px;\n block-size: 20px;\n margin: 0;\n flex: none;\n accent-color: ${t.brand};\n }\n .option-text {\n display: block;\n font-size: ${fontSize('md')};\n }\n .option-description {\n display: block;\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n margin-block-start: ${space(1)};\n }\n :host([invalid]) .option {\n border-color: ${t.danger};\n }\n `,\n ];\n\n protected renderLabel(): TemplateResult {\n return html`<legend class=\"label\" part=\"label\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </legend>`;\n }\n\n protected renderControl(): TemplateResult {\n return html`\n ${this.options.map((option, i) => {\n const id = this.id_(`opt-${i}`);\n const descId = option.description ? this.id_(`opt-${i}-desc`) : undefined;\n return html`\n <label class=\"option\" part=\"option\" for=${id}>\n <input\n type=\"radio\"\n id=${id}\n name=${this.uid}\n value=${option.value}\n .checked=${this.value === option.value}\n ?disabled=${this.disabled}\n ?required=${this.required && i === 0}\n aria-describedby=${descId ?? nothing}\n @change=${() => this.setFormValue(option.value)}\n />\n <span>\n <span class=\"option-text\">${option.label}</span>\n ${option.description\n ? html`<span class=\"option-description\" id=${descId!}>${option.description}</span>`\n : nothing}\n </span>\n </label>\n `;\n })}\n `;\n }\n\n /**\n * The fieldset wraps everything, so the whole field is rebuilt here rather\n * than relying on the base class's flat order.\n */\n render(): TemplateResult {\n return html`\n <fieldset\n part=\"fieldset\"\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n >\n ${this.renderLabel()}\n ${this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">\n ${this.description}\n </div>`\n : nothing}\n ${this.renderControl()}\n <div class=\"error\" id=${this.id_('error')} part=\"error\" aria-live=\"polite\">\n ${this.error || nothing}\n </div>\n </fieldset>\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impkt-radio-group', ImpktRadioGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-radio-group': ImpktRadioGroup;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCO,IAAM,kBAAN,cAA8B,a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K,GAAG;AAAA,sBACP,OAAO,KAAK;AAAA,yBACT,KAAK,UAAU,OAAO,KAAK;AAAA,0BAC1B,KAAK,QAAQ;AAAA,0BACb,KAAK,YAAYA,OAAM,CAAC;AAAA,iCACjB,UAAU,CAAO;AAAA,wBAC1B,MAAM,KAAK,aAAa,OAAO,KAAK,CAAC;AAAA;AAAA;AAAA,0CAGnB,OAAO,KAAK;AAAA,gBACtC,OAAO,cACL,wCAA2C,MAAO,IAAI,OAAO,WAAW,YACxE,CAAO;AAAA;AAAA;AAAA;AAAA,IAInB,CAAC,CAAC;AAAA;AAAA,EAEN;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAyB;AACvB,WAAO;AAAA;AAAA;AAAA,2BAGgB,KAAK,WAAW;AAAA,uBACpB,KAAK,QAAQ,SAAS,CAAO;AAAA;AAAA,UAE1C,KAAK,YAAY,CAAC;AAAA,UAClB,KAAK,cACH,gCAAmC,KAAK,IAAI,aAAa,CAAC;AAAA,gBACtD,KAAK,WAAW;AAAA,sBAEpB,CAAO;AAAA,UACT,KAAK,cAAc,CAAC;AAAA,gCACE,KAAK,IAAI,OAAO,CAAC;AAAA,YACrC,KAAK,SAAS,CAAO;AAAA;AAAA;AAAA;AAAA,EAI/B;AAAA,EAEA,QAAQ,SAAqC;AAC3C,QAAI,QAAQ,IAAI,OAAO,EAAG,MAAK,gBAAgB,WAAW,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,qBAAqB,eAAe;","names":["i"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ImpktElement,
|
|
3
|
+
b,
|
|
4
|
+
i,
|
|
5
|
+
space
|
|
6
|
+
} from "./chunk-G6X62CFC.js";
|
|
7
|
+
|
|
8
|
+
// packages/ui/src/components/grid.ts
|
|
9
|
+
var ImpktGrid = class extends ImpktElement {
|
|
10
|
+
static {
|
|
11
|
+
this.properties = { columns: { type: String, reflect: true }, gap: { type: String, reflect: true } };
|
|
12
|
+
}
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.columns = "two";
|
|
16
|
+
this.gap = "md";
|
|
17
|
+
}
|
|
18
|
+
static {
|
|
19
|
+
this.styles = [...ImpktElement.styles, i`
|
|
20
|
+
:host { display: block; min-inline-size: 0; container-type: inline-size; }
|
|
21
|
+
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${space(4)}; }
|
|
22
|
+
:host([gap='sm']) .columns { gap: ${space(2)}; }
|
|
23
|
+
:host([gap='lg']) .columns { gap: ${space(6)}; }
|
|
24
|
+
:host([columns='one']) .columns { grid-template-columns: minmax(0, 1fr); }
|
|
25
|
+
:host([columns='three']) .columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
26
|
+
:host([columns='four']) .columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
27
|
+
:host([columns='sidebar-left']) .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
|
|
28
|
+
:host([columns='sidebar-right']) .columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
|
|
29
|
+
.column { min-inline-size: 0; overflow-wrap: anywhere; }
|
|
30
|
+
::slotted(*) { max-inline-size: 100%; }
|
|
31
|
+
@container (max-width: 40rem) { .columns { grid-template-columns: minmax(0, 1fr) !important; } }
|
|
32
|
+
`];
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
const count = this.columns === "one" ? 1 : this.columns === "three" ? 3 : this.columns === "four" ? 4 : 2;
|
|
36
|
+
return b`<div class="columns" part="row">${Array.from({ length: count }, (_, i2) => b`<div class="column" part="column"><slot name=${`column-${i2 + 1}`}></slot></div>`)}</div>`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
customElements.define("impkt-grid", ImpktGrid);
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
ImpktGrid
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=chunk-WC5KO6KZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/grid.ts"],"sourcesContent":["import { css, html } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { space } from '../base/tokens';\n\n/**\n * A responsive row with named column slots. Child order stays inside each\n * column; changing a page's visual grid never reorders its reading sequence.\n *\n * @category layout\n * @icon columns\n * @slot column-1 - First column.\n * @slot column-2 - Second column.\n * @slot column-3 - Third column.\n * @slot column-4 - Fourth column.\n */\nexport class ImpktGrid extends ImpktElement {\n static properties = { columns: { type: String, reflect: true }, gap: { type: String, reflect: true } };\n declare columns: 'one' | 'two' | 'three' | 'four' | 'sidebar-left' | 'sidebar-right';\n declare gap: 'sm' | 'md' | 'lg';\n constructor() { super(); this.columns = 'two'; this.gap = 'md'; }\n static styles = [...ImpktElement.styles, css`\n :host { display: block; min-inline-size: 0; container-type: inline-size; }\n .columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${space(4)}; }\n :host([gap='sm']) .columns { gap: ${space(2)}; }\n :host([gap='lg']) .columns { gap: ${space(6)}; }\n :host([columns='one']) .columns { grid-template-columns: minmax(0, 1fr); }\n :host([columns='three']) .columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }\n :host([columns='four']) .columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }\n :host([columns='sidebar-left']) .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }\n :host([columns='sidebar-right']) .columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }\n .column { min-inline-size: 0; overflow-wrap: anywhere; }\n ::slotted(*) { max-inline-size: 100%; }\n @container (max-width: 40rem) { .columns { grid-template-columns: minmax(0, 1fr) !important; } }\n `];\n render() {\n const count = this.columns === 'one' ? 1 : this.columns === 'three' ? 3 : this.columns === 'four' ? 4 : 2;\n return html`<div class=\"columns\" part=\"row\">${Array.from({ length: count }, (_, i) => html`<div class=\"column\" part=\"column\"><slot name=${`column-${i+1}`}></slot></div>`)}</div>`;\n }\n}\ncustomElements.define('impkt-grid', ImpktGrid);\ndeclare global { interface HTMLElementTagNameMap { 'impkt-grid': ImpktGrid } }\n"],"mappings":";;;;;;;;AAeO,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;AAAA,SAAO,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,QAAQ,SAAS,KAAK,EAAE;AAAA;AAAA,EAGrG,cAAc;AAAE,UAAM;AAAG,SAAK,UAAU;AAAO,SAAK,MAAM;AAAA,EAAM;AAAA,EAChE;AAAA,SAAO,SAAS,CAAC,GAAG,aAAa,QAAQ;AAAA;AAAA,uFAE4C,MAAM,CAAC,CAAC;AAAA,wCACvD,MAAM,CAAC,CAAC;AAAA,wCACR,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAS7C;AAAA;AAAA,EACD,SAAS;AACP,UAAM,QAAQ,KAAK,YAAY,QAAQ,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,SAAS,IAAI;AACxG,WAAO,oCAAuC,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,CAAC,GAAGA,OAAM,iDAAoD,UAAUA,KAAE,CAAC,EAAE,gBAAgB,CAAC;AAAA,EAC5K;AACF;AACA,eAAe,OAAO,cAAc,SAAS;","names":["i"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldElement
|
|
3
|
+
} from "./chunk-5NBYZ5UC.js";
|
|
4
|
+
import {
|
|
5
|
+
A,
|
|
6
|
+
b,
|
|
7
|
+
fontSize,
|
|
8
|
+
i,
|
|
9
|
+
space,
|
|
10
|
+
t
|
|
11
|
+
} from "./chunk-G6X62CFC.js";
|
|
12
|
+
|
|
13
|
+
// packages/ui/src/components/select.ts
|
|
14
|
+
var ImpktSelect = class extends FieldElement {
|
|
15
|
+
static {
|
|
16
|
+
this.properties = {
|
|
17
|
+
...FieldElement.properties,
|
|
18
|
+
options: { type: Array },
|
|
19
|
+
placeholder: { type: String }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.options = [];
|
|
25
|
+
this.placeholder = "Choose an option";
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
this.styles = [
|
|
29
|
+
...FieldElement.styles,
|
|
30
|
+
i`
|
|
31
|
+
select {
|
|
32
|
+
inline-size: 100%;
|
|
33
|
+
min-block-size: 44px;
|
|
34
|
+
padding: ${space(3)};
|
|
35
|
+
font-family: inherit;
|
|
36
|
+
font-size: ${fontSize("md")};
|
|
37
|
+
color: ${t.text};
|
|
38
|
+
background: ${t.surfaceCard};
|
|
39
|
+
border: ${t.borderThin} solid ${t.border};
|
|
40
|
+
border-radius: ${t.radius};
|
|
41
|
+
}
|
|
42
|
+
select:disabled {
|
|
43
|
+
background: ${t.surfaceInset};
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
}
|
|
46
|
+
:host([invalid]) select {
|
|
47
|
+
border-color: ${t.danger};
|
|
48
|
+
border-width: ${t.borderThick};
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
renderControl() {
|
|
54
|
+
return b`
|
|
55
|
+
<select
|
|
56
|
+
id=${this.controlId}
|
|
57
|
+
part="select"
|
|
58
|
+
name=${this.name || A}
|
|
59
|
+
?disabled=${this.disabled}
|
|
60
|
+
?required=${this.required}
|
|
61
|
+
aria-describedby=${this.describedBy}
|
|
62
|
+
aria-invalid=${this.error ? "true" : A}
|
|
63
|
+
@change=${(e) => this.setFormValue(e.target.value)}
|
|
64
|
+
>
|
|
65
|
+
<option value="" ?selected=${!this.value}>${this.placeholder}</option>
|
|
66
|
+
${this.options.map(
|
|
67
|
+
(o) => b`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`
|
|
68
|
+
)}
|
|
69
|
+
</select>
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
updated(changed) {
|
|
73
|
+
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
customElements.define("impkt-select", ImpktSelect);
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
ImpktSelect
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=chunk-YXHT3ZJU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/select.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\nexport interface SelectOption {\n value: string;\n label: string;\n}\n\n/**\n * A dropdown.\n *\n * A native `<select>`, because the alternative is a listbox widget that has to\n * reimplement type-ahead, keyboard selection, and the platform's own picker on\n * touch — and whose main advantage is that the arrow can be restyled. On a\n * phone, native wins outright: it opens the system control that the user\n * already knows how to drive.\n *\n * The empty first option carries a real label rather than being blank, so a\n * screen reader announces a choice to make rather than silence.\n\n *\n * @category form\n * @icon select\n */\nexport class ImpktSelect extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n placeholder: { type: String },\n };\n\n declare options: SelectOption[];\n declare placeholder: string;\n\n constructor() {\n super();\n this.options = [];\n this.placeholder = 'Choose an option';\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n select {\n inline-size: 100%;\n min-block-size: 44px;\n padding: ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: ${t.surfaceCard};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radius};\n }\n select:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n :host([invalid]) select {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <select\n id=${this.controlId}\n part=\"select\"\n name=${this.name || nothing}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => this.setFormValue((e.target as HTMLSelectElement).value)}\n >\n <option value=\"\" ?selected=${!this.value}>${this.placeholder}</option>\n ${this.options.map(\n (o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`,\n )}\n </select>\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impkt-select', ImpktSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-select': ImpktSelect;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAyBO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,SAAS,EAAE,MAAM,MAAM;AAAA,MACvB,aAAa,EAAE,MAAM,OAAO;AAAA,IAC9B;AAAA;AAAA,EAKA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU,CAAC;AAChB,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA,mBAIe,MAAM,CAAC,CAAC;AAAA;AAAA,qBAEN,SAAS,IAAI,CAAC;AAAA,iBAClB,EAAE,IAAI;AAAA,sBACD,EAAE,WAAW;AAAA,kBACjB,EAAE,UAAU,UAAU,EAAE,MAAM;AAAA,yBACvB,EAAE,MAAM;AAAA;AAAA;AAAA,sBAGX,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA,wBAIZ,EAAE,MAAM;AAAA,wBACR,EAAE,WAAW;AAAA;AAAA;AAAA,IAGnC;AAAA;AAAA,EAEU,gBAAgC;AACxC,WAAO;AAAA;AAAA,aAEE,KAAK,SAAS;AAAA;AAAA,eAEZ,KAAK,QAAQ,CAAO;AAAA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