@atomic-ui/ui 0.1.0 → 0.1.2
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/dist/{chunk-WC5KO6KZ.js → chunk-4YAA7EML.js} +5 -6
- package/dist/{chunk-WC5KO6KZ.js.map → chunk-4YAA7EML.js.map} +1 -1
- package/dist/{chunk-5NBYZ5UC.js → chunk-6HZA6A3L.js} +11 -13
- package/dist/{chunk-5NBYZ5UC.js.map → chunk-6HZA6A3L.js.map} +1 -1
- package/dist/{chunk-4P3FLJZG.js → chunk-7T34CRBF.js} +9 -11
- package/dist/{chunk-4P3FLJZG.js.map → chunk-7T34CRBF.js.map} +1 -1
- package/dist/{chunk-3LFXWUOU.js → chunk-AC6G7X3G.js} +11 -13
- package/dist/{chunk-3LFXWUOU.js.map → chunk-AC6G7X3G.js.map} +1 -1
- package/dist/{chunk-SHGQMQXS.js → chunk-BOLZMDAS.js} +10 -12
- package/dist/{chunk-SHGQMQXS.js.map → chunk-BOLZMDAS.js.map} +1 -1
- package/dist/{chunk-BM73FVQ4.js → chunk-BUWE6XGX.js} +11 -12
- package/dist/{chunk-BM73FVQ4.js.map → chunk-BUWE6XGX.js.map} +1 -1
- package/dist/{chunk-M3WQZDWU.js → chunk-GEBLDC2J.js} +14 -16
- package/dist/{chunk-M3WQZDWU.js.map → chunk-GEBLDC2J.js.map} +1 -1
- package/dist/{chunk-26CSJMXY.js → chunk-GU4UQKJP.js} +8 -10
- package/dist/{chunk-26CSJMXY.js.map → chunk-GU4UQKJP.js.map} +1 -1
- package/dist/{chunk-PV4GMCP6.js → chunk-HJ2V635J.js} +10 -12
- package/dist/{chunk-PV4GMCP6.js.map → chunk-HJ2V635J.js.map} +1 -1
- package/dist/{chunk-VF6PNIPS.js → chunk-IHEEUM3M.js} +14 -16
- package/dist/{chunk-VF6PNIPS.js.map → chunk-IHEEUM3M.js.map} +1 -1
- package/dist/chunk-J5KAMJ2N.js +138 -0
- package/dist/chunk-J5KAMJ2N.js.map +1 -0
- package/dist/{chunk-CNFIYRPA.js → chunk-KAU3V65B.js} +9 -11
- package/dist/{chunk-CNFIYRPA.js.map → chunk-KAU3V65B.js.map} +1 -1
- package/dist/{chunk-TWCXYY4Z.js → chunk-KC6RKWO6.js} +6 -8
- package/dist/{chunk-TWCXYY4Z.js.map → chunk-KC6RKWO6.js.map} +1 -1
- package/dist/{chunk-OZNQ4GAR.js → chunk-MNCM7YOY.js} +8 -10
- package/dist/chunk-MNCM7YOY.js.map +1 -0
- package/dist/{chunk-43V4RFK4.js → chunk-NEWN44LO.js} +12 -14
- package/dist/{chunk-43V4RFK4.js.map → chunk-NEWN44LO.js.map} +1 -1
- package/dist/{chunk-UTL446G6.js → chunk-SSNCGJ5W.js} +8 -10
- package/dist/{chunk-UTL446G6.js.map → chunk-SSNCGJ5W.js.map} +1 -1
- package/dist/{chunk-VKQGLSDT.js → chunk-T4HSPWA7.js} +7 -9
- package/dist/{chunk-VKQGLSDT.js.map → chunk-T4HSPWA7.js.map} +1 -1
- package/dist/{chunk-WAB4TRB2.js → chunk-T63FI4ET.js} +20 -22
- package/dist/{chunk-WAB4TRB2.js.map → chunk-T63FI4ET.js.map} +1 -1
- package/dist/{chunk-O72RTRIJ.js → chunk-TOTVL3YH.js} +9 -11
- package/dist/{chunk-O72RTRIJ.js.map → chunk-TOTVL3YH.js.map} +1 -1
- package/dist/{chunk-QAKFGIOO.js → chunk-TRLEYGGH.js} +10 -12
- package/dist/{chunk-QAKFGIOO.js.map → chunk-TRLEYGGH.js.map} +1 -1
- package/dist/{chunk-YXHT3ZJU.js → chunk-XEN5NV55.js} +9 -11
- package/dist/{chunk-YXHT3ZJU.js.map → chunk-XEN5NV55.js.map} +1 -1
- package/dist/{chunk-RYJQKKJ4.js → chunk-Z4KZG2E3.js} +18 -20
- package/dist/{chunk-RYJQKKJ4.js.map → chunk-Z4KZG2E3.js.map} +1 -1
- package/dist/components/accordion.js +2 -2
- package/dist/components/alert.js +2 -2
- package/dist/components/button.d.ts +1 -0
- package/dist/components/button.js +2 -2
- package/dist/components/checkbox-group.js +3 -3
- package/dist/components/checkbox.js +3 -3
- package/dist/components/date-input.js +3 -3
- package/dist/components/dialog.js +2 -2
- package/dist/components/grid.js +2 -2
- package/dist/components/help.js +2 -2
- package/dist/components/layout.js +2 -2
- package/dist/components/link.js +2 -2
- package/dist/components/media.js +2 -2
- package/dist/components/price.js +2 -2
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-group.js +3 -3
- package/dist/components/select.js +3 -3
- package/dist/components/summary-list.js +2 -2
- package/dist/components/table.js +2 -2
- package/dist/components/text-input.js +3 -3
- package/dist/components/textarea.js +3 -3
- package/dist/index.js +22 -22
- package/package.json +2 -2
- package/dist/chunk-G6X62CFC.js +0 -713
- package/dist/chunk-G6X62CFC.js.map +0 -1
- package/dist/chunk-OZNQ4GAR.js.map +0 -1
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FieldElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6HZA6A3L.js";
|
|
4
4
|
import {
|
|
5
|
-
A,
|
|
6
|
-
b,
|
|
7
5
|
fontSize,
|
|
8
|
-
i,
|
|
9
6
|
space,
|
|
10
7
|
t
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
12
9
|
|
|
13
10
|
// packages/ui/src/components/date-input.ts
|
|
11
|
+
import { html, css, nothing } from "lit";
|
|
14
12
|
var ImpktDateInput = class extends FieldElement {
|
|
15
13
|
static {
|
|
16
14
|
this.properties = {
|
|
@@ -31,7 +29,7 @@ var ImpktDateInput = class extends FieldElement {
|
|
|
31
29
|
static {
|
|
32
30
|
this.styles = [
|
|
33
31
|
...FieldElement.styles,
|
|
34
|
-
|
|
32
|
+
css`
|
|
35
33
|
fieldset {
|
|
36
34
|
border: 0;
|
|
37
35
|
margin: 0;
|
|
@@ -76,13 +74,13 @@ var ImpktDateInput = class extends FieldElement {
|
|
|
76
74
|
];
|
|
77
75
|
}
|
|
78
76
|
renderLabel() {
|
|
79
|
-
return
|
|
80
|
-
${this.label}${this.required ?
|
|
77
|
+
return html`<legend class="label" part="label">
|
|
78
|
+
${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
|
|
81
79
|
</legend>`;
|
|
82
80
|
}
|
|
83
81
|
datePart(name, label, length, autocomplete) {
|
|
84
82
|
const id = this.id_(name);
|
|
85
|
-
return
|
|
83
|
+
return html`
|
|
86
84
|
<div class="part ${name}">
|
|
87
85
|
<label for=${id}>${label}</label>
|
|
88
86
|
<input
|
|
@@ -91,7 +89,7 @@ var ImpktDateInput = class extends FieldElement {
|
|
|
91
89
|
inputmode="numeric"
|
|
92
90
|
maxlength=${length}
|
|
93
91
|
.value=${this[name]}
|
|
94
|
-
autocomplete=${this.autocompleteSection ? `${this.autocompleteSection}-${autocomplete}` :
|
|
92
|
+
autocomplete=${this.autocompleteSection ? `${this.autocompleteSection}-${autocomplete}` : nothing}
|
|
95
93
|
?disabled=${this.disabled}
|
|
96
94
|
@input=${(e) => {
|
|
97
95
|
this[name] = e.target.value;
|
|
@@ -108,7 +106,7 @@ var ImpktDateInput = class extends FieldElement {
|
|
|
108
106
|
this.setFormValue(iso);
|
|
109
107
|
}
|
|
110
108
|
renderControl() {
|
|
111
|
-
return
|
|
109
|
+
return html`
|
|
112
110
|
<div class="parts" part="parts">
|
|
113
111
|
${this.datePart("day", "Day", 2, "day")}
|
|
114
112
|
${this.datePart("month", "Month", 2, "month")}
|
|
@@ -117,12 +115,12 @@ var ImpktDateInput = class extends FieldElement {
|
|
|
117
115
|
`;
|
|
118
116
|
}
|
|
119
117
|
render() {
|
|
120
|
-
return
|
|
121
|
-
<fieldset part="fieldset" aria-describedby=${this.describedBy} aria-invalid=${this.error ? "true" :
|
|
118
|
+
return html`
|
|
119
|
+
<fieldset part="fieldset" aria-describedby=${this.describedBy} aria-invalid=${this.error ? "true" : nothing}>
|
|
122
120
|
${this.renderLabel()}
|
|
123
|
-
${this.description ?
|
|
121
|
+
${this.description ? html`<div class="description" id=${this.id_("description")} part="description">${this.description}</div>` : nothing}
|
|
124
122
|
${this.renderControl()}
|
|
125
|
-
<div class="error" id=${this.id_("error")} part="error" aria-live="polite">${this.error ||
|
|
123
|
+
<div class="error" id=${this.id_("error")} part="error" aria-live="polite">${this.error || nothing}</div>
|
|
126
124
|
</fieldset>
|
|
127
125
|
`;
|
|
128
126
|
}
|
|
@@ -135,4 +133,4 @@ customElements.define("impkt-date-input", ImpktDateInput);
|
|
|
135
133
|
export {
|
|
136
134
|
ImpktDateInput
|
|
137
135
|
};
|
|
138
|
-
//# sourceMappingURL=chunk-
|
|
136
|
+
//# sourceMappingURL=chunk-GEBLDC2J.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/date-input.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\n/**\n * A date, as three fields.\n *\n * **Why not `<input type=\"date\">`.** The native control is excellent for\n * picking a date near today — an appointment, a start date — and poor for a\n * date of birth, which is the date this product asks for most. Its picker\n * opens on the current month and makes a user born in 1958 navigate eight\n * hundred steps back, its text entry expects a locale-specific format the\n * field does not state, and its rendering differs enough between browsers that\n * no single hint is correct everywhere.\n *\n * Three fields is the pattern government services converged on after testing\n * it on exactly this problem. Each part is typed directly, in any order, with\n * no picker to fight.\n *\n * **The accessibility shape.** A `<fieldset>` and `<legend>` ask the question\n * once; each part has its own visible label, so \"Month\" is announced rather\n * than \"second field\"; `inputmode=\"numeric\"` brings up a number pad without\n * `type=\"number\"`, which on a date part gives spinners, scroll-wheel surprises\n * and silent stripping of a leading zero. The parts carry `autocomplete`\n * tokens so autofill still works, which is 1.3.5.\n\n *\n * @category form\n * @icon calendar\n */\nexport class ImpktDateInput extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n day: { type: String },\n month: { type: String },\n year: { type: String },\n autocompleteSection: { type: String, attribute: 'autocomplete-section' },\n };\n\n declare day: string;\n declare month: string;\n declare year: string;\n /** \"bday\" fills a date of birth. Empty disables autofill for this field. */\n declare autocompleteSection: string;\n\n constructor() {\n super();\n this.day = '';\n this.month = '';\n this.year = '';\n this.autocompleteSection = 'bday';\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 .parts {\n display: flex;\n gap: ${space(3)};\n }\n .part {\n display: flex;\n flex-direction: column;\n gap: ${space(1)};\n }\n .part label {\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n }\n input {\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 inline-size: 4ch;\n }\n .year input {\n inline-size: 6ch;\n }\n :host([invalid]) input {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\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 private datePart(\n name: 'day' | 'month' | 'year',\n label: string,\n length: number,\n autocomplete: string,\n ): TemplateResult {\n const id = this.id_(name);\n return html`\n <div class=\"part ${name}\">\n <label for=${id}>${label}</label>\n <input\n id=${id}\n type=\"text\"\n inputmode=\"numeric\"\n maxlength=${length}\n .value=${this[name]}\n autocomplete=${this.autocompleteSection ? `${this.autocompleteSection}-${autocomplete}` : nothing}\n ?disabled=${this.disabled}\n @input=${(e: Event) => {\n this[name] = (e.target as HTMLInputElement).value;\n this.emit();\n }}\n />\n </div>\n `;\n }\n\n /** ISO, or empty while incomplete. Partial dates are not half-valid. */\n private emit(): void {\n const complete = this.day && this.month && this.year.length === 4;\n const iso = complete\n ? `${this.year}-${this.month.padStart(2, '0')}-${this.day.padStart(2, '0')}`\n : '';\n this.setFormValue(iso);\n }\n\n protected renderControl(): TemplateResult {\n return html`\n <div class=\"parts\" part=\"parts\">\n ${this.datePart('day', 'Day', 2, 'day')}\n ${this.datePart('month', 'Month', 2, 'month')}\n ${this.datePart('year', 'Year', 4, 'year')}\n </div>\n `;\n }\n\n render(): TemplateResult {\n return html`\n <fieldset part=\"fieldset\" aria-describedby=${this.describedBy} aria-invalid=${this.error ? 'true' : nothing}>\n ${this.renderLabel()}\n ${this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">${this.description}</div>`\n : nothing}\n ${this.renderControl()}\n <div class=\"error\" id=${this.id_('error')} part=\"error\" aria-live=\"polite\">${this.error || nothing}</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-date-input', ImpktDateInput);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-date-input': ImpktDateInput }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/date-input.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\n/**\n * A date, as three fields.\n *\n * **Why not `<input type=\"date\">`.** The native control is excellent for\n * picking a date near today — an appointment, a start date — and poor for a\n * date of birth, which is the date this product asks for most. Its picker\n * opens on the current month and makes a user born in 1958 navigate eight\n * hundred steps back, its text entry expects a locale-specific format the\n * field does not state, and its rendering differs enough between browsers that\n * no single hint is correct everywhere.\n *\n * Three fields is the pattern government services converged on after testing\n * it on exactly this problem. Each part is typed directly, in any order, with\n * no picker to fight.\n *\n * **The accessibility shape.** A `<fieldset>` and `<legend>` ask the question\n * once; each part has its own visible label, so \"Month\" is announced rather\n * than \"second field\"; `inputmode=\"numeric\"` brings up a number pad without\n * `type=\"number\"`, which on a date part gives spinners, scroll-wheel surprises\n * and silent stripping of a leading zero. The parts carry `autocomplete`\n * tokens so autofill still works, which is 1.3.5.\n\n *\n * @category form\n * @icon calendar\n */\nexport class ImpktDateInput extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n day: { type: String },\n month: { type: String },\n year: { type: String },\n autocompleteSection: { type: String, attribute: 'autocomplete-section' },\n };\n\n declare day: string;\n declare month: string;\n declare year: string;\n /** \"bday\" fills a date of birth. Empty disables autofill for this field. */\n declare autocompleteSection: string;\n\n constructor() {\n super();\n this.day = '';\n this.month = '';\n this.year = '';\n this.autocompleteSection = 'bday';\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 .parts {\n display: flex;\n gap: ${space(3)};\n }\n .part {\n display: flex;\n flex-direction: column;\n gap: ${space(1)};\n }\n .part label {\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n }\n input {\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 inline-size: 4ch;\n }\n .year input {\n inline-size: 6ch;\n }\n :host([invalid]) input {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\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 private datePart(\n name: 'day' | 'month' | 'year',\n label: string,\n length: number,\n autocomplete: string,\n ): TemplateResult {\n const id = this.id_(name);\n return html`\n <div class=\"part ${name}\">\n <label for=${id}>${label}</label>\n <input\n id=${id}\n type=\"text\"\n inputmode=\"numeric\"\n maxlength=${length}\n .value=${this[name]}\n autocomplete=${this.autocompleteSection ? `${this.autocompleteSection}-${autocomplete}` : nothing}\n ?disabled=${this.disabled}\n @input=${(e: Event) => {\n this[name] = (e.target as HTMLInputElement).value;\n this.emit();\n }}\n />\n </div>\n `;\n }\n\n /** ISO, or empty while incomplete. Partial dates are not half-valid. */\n private emit(): void {\n const complete = this.day && this.month && this.year.length === 4;\n const iso = complete\n ? `${this.year}-${this.month.padStart(2, '0')}-${this.day.padStart(2, '0')}`\n : '';\n this.setFormValue(iso);\n }\n\n protected renderControl(): TemplateResult {\n return html`\n <div class=\"parts\" part=\"parts\">\n ${this.datePart('day', 'Day', 2, 'day')}\n ${this.datePart('month', 'Month', 2, 'month')}\n ${this.datePart('year', 'Year', 4, 'year')}\n </div>\n `;\n }\n\n render(): TemplateResult {\n return html`\n <fieldset part=\"fieldset\" aria-describedby=${this.describedBy} aria-invalid=${this.error ? 'true' : nothing}>\n ${this.renderLabel()}\n ${this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">${this.description}</div>`\n : nothing}\n ${this.renderControl()}\n <div class=\"error\" id=${this.id_('error')} part=\"error\" aria-live=\"polite\">${this.error || nothing}</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-date-input', ImpktDateInput);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-date-input': ImpktDateInput }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA8BjD,IAAM,iBAAN,cAA6B,aAAa;AAAA,EAC/C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,KAAK,EAAE,MAAM,OAAO;AAAA,MACpB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,qBAAqB,EAAE,MAAM,QAAQ,WAAW,uBAAuB;AAAA,IACzE;AAAA;AAAA,EAQA,cAAc;AACZ,UAAM;AACN,SAAK,MAAM;A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-J5KAMJ2N.js";
|
|
12
9
|
|
|
13
10
|
// packages/ui/src/components/summary-list.ts
|
|
11
|
+
import { html, css, nothing } from "lit";
|
|
14
12
|
var ImpktSummaryList = class extends ImpktElement {
|
|
15
13
|
static {
|
|
16
14
|
this.properties = {
|
|
@@ -27,7 +25,7 @@ var ImpktSummaryList = class extends ImpktElement {
|
|
|
27
25
|
this.styles = [
|
|
28
26
|
...ImpktElement.styles,
|
|
29
27
|
focusRing,
|
|
30
|
-
|
|
28
|
+
css`
|
|
31
29
|
:host {
|
|
32
30
|
display: block;
|
|
33
31
|
}
|
|
@@ -95,17 +93,17 @@ var ImpktSummaryList = class extends ImpktElement {
|
|
|
95
93
|
];
|
|
96
94
|
}
|
|
97
95
|
render() {
|
|
98
|
-
return
|
|
96
|
+
return html`
|
|
99
97
|
<dl part="list">
|
|
100
98
|
${this.rows.map(
|
|
101
|
-
(row) =>
|
|
99
|
+
(row) => html`
|
|
102
100
|
<div class="row" part="row">
|
|
103
101
|
<dt part="key">${row.key}</dt>
|
|
104
102
|
<dd part="value">
|
|
105
103
|
<span>${row.value}</span>
|
|
106
|
-
${row.changeHref ?
|
|
104
|
+
${row.changeHref ? html`<a href=${row.changeHref} part="action"
|
|
107
105
|
>${this.changeText}<span class="sr-only"> ${row.key}</span></a
|
|
108
|
-
>` :
|
|
106
|
+
>` : nothing}
|
|
109
107
|
</dd>
|
|
110
108
|
</div>
|
|
111
109
|
`
|
|
@@ -119,4 +117,4 @@ customElements.define("impkt-summary-list", ImpktSummaryList);
|
|
|
119
117
|
export {
|
|
120
118
|
ImpktSummaryList
|
|
121
119
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-GU4UQKJP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/summary-list.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface SummaryRow {\n key: string;\n value: string;\n /** Where \"Change\" goes. Omitted rows show no action. */\n changeHref?: string;\n}\n\n/**\n * Key and value pairs — an order summary, a confirmation, a check-your-answers\n * screen.\n *\n * **It is a description list.** `<dl>` with `<dt>` and `<dd>` says these are\n * pairs; a stack of divs says nothing, and a table claims a grid that a\n * two-column list does not have.\n *\n * **Every \"Change\" names what it changes.** The visible text stays short, and\n * the accessible name is completed with visually hidden words, so a reader\n * tabbing through hears \"Change date of birth\" rather than six links all called\n * \"Change\". This is 2.4.4 Link Purpose, and it is the single most common\n * failure on a check-your-answers page.\n\n *\n * @category content\n * @icon list\n */\nexport class ImpktSummaryList extends ImpktElement {\n static properties = {\n rows: { type: Array },\n changeText: { type: String, attribute: 'change-text' },\n };\n\n declare rows: SummaryRow[];\n declare changeText: string;\n\n constructor() {\n super();\n this.rows = [];\n this.changeText = 'Change';\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n }\n dl {\n margin: 0;\n display: grid;\n grid-template-columns: minmax(8rem, 1fr) 2fr;\n }\n /* A <dl> group may hold only dt and dd — not a third sibling — so the\n action lives inside the value it changes, which is also where it\n belongs semantically. The row uses display:contents so both cells stay\n in the parent grid. */\n .row {\n display: contents;\n }\n dt,\n dd {\n padding: ${space(3)} 0;\n border-block-end: ${t.borderThin} solid ${t.border};\n }\n dt {\n font-weight: ${fontWeight('semibold')};\n font-size: ${fontSize('sm')};\n }\n dd {\n margin: 0;\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: ${space(3)};\n }\n dd a {\n flex: none;\n color: ${t.link};\n text-decoration: underline;\n text-underline-offset: 0.2em;\n display: inline-block;\n min-block-size: ${t.targetMin};\n }\n .sr-only {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n /* One column on a narrow screen. 1.4.10 Reflow: two columns at 320px\n forces horizontal scrolling, and a summary is read, not scanned\n across. */\n @media (max-width: 30rem) {\n dl {\n grid-template-columns: 1fr;\n }\n dt {\n border-block-end: 0;\n padding-block-end: 0;\n }\n dd {\n padding-block-start: 0;\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <dl part=\"list\">\n ${this.rows.map(\n (row) => html`\n <div class=\"row\" part=\"row\">\n <dt part=\"key\">${row.key}</dt>\n <dd part=\"value\">\n <span>${row.value}</span>\n ${row.changeHref\n ? html`<a href=${row.changeHref} part=\"action\"\n >${this.changeText}<span class=\"sr-only\"> ${row.key}</span></a\n >`\n : nothing}\n </dd>\n </div>\n `,\n )}\n </dl>\n `;\n }\n}\n\ncustomElements.define('impkt-summary-list', ImpktSummaryList);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-summary-list': ImpktSummaryList }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/summary-list.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface SummaryRow {\n key: string;\n value: string;\n /** Where \"Change\" goes. Omitted rows show no action. */\n changeHref?: string;\n}\n\n/**\n * Key and value pairs — an order summary, a confirmation, a check-your-answers\n * screen.\n *\n * **It is a description list.** `<dl>` with `<dt>` and `<dd>` says these are\n * pairs; a stack of divs says nothing, and a table claims a grid that a\n * two-column list does not have.\n *\n * **Every \"Change\" names what it changes.** The visible text stays short, and\n * the accessible name is completed with visually hidden words, so a reader\n * tabbing through hears \"Change date of birth\" rather than six links all called\n * \"Change\". This is 2.4.4 Link Purpose, and it is the single most common\n * failure on a check-your-answers page.\n\n *\n * @category content\n * @icon list\n */\nexport class ImpktSummaryList extends ImpktElement {\n static properties = {\n rows: { type: Array },\n changeText: { type: String, attribute: 'change-text' },\n };\n\n declare rows: SummaryRow[];\n declare changeText: string;\n\n constructor() {\n super();\n this.rows = [];\n this.changeText = 'Change';\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n }\n dl {\n margin: 0;\n display: grid;\n grid-template-columns: minmax(8rem, 1fr) 2fr;\n }\n /* A <dl> group may hold only dt and dd — not a third sibling — so the\n action lives inside the value it changes, which is also where it\n belongs semantically. The row uses display:contents so both cells stay\n in the parent grid. */\n .row {\n display: contents;\n }\n dt,\n dd {\n padding: ${space(3)} 0;\n border-block-end: ${t.borderThin} solid ${t.border};\n }\n dt {\n font-weight: ${fontWeight('semibold')};\n font-size: ${fontSize('sm')};\n }\n dd {\n margin: 0;\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: ${space(3)};\n }\n dd a {\n flex: none;\n color: ${t.link};\n text-decoration: underline;\n text-underline-offset: 0.2em;\n display: inline-block;\n min-block-size: ${t.targetMin};\n }\n .sr-only {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n /* One column on a narrow screen. 1.4.10 Reflow: two columns at 320px\n forces horizontal scrolling, and a summary is read, not scanned\n across. */\n @media (max-width: 30rem) {\n dl {\n grid-template-columns: 1fr;\n }\n dt {\n border-block-end: 0;\n padding-block-end: 0;\n }\n dd {\n padding-block-start: 0;\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <dl part=\"list\">\n ${this.rows.map(\n (row) => html`\n <div class=\"row\" part=\"row\">\n <dt part=\"key\">${row.key}</dt>\n <dd part=\"value\">\n <span>${row.value}</span>\n ${row.changeHref\n ? html`<a href=${row.changeHref} part=\"action\"\n >${this.changeText}<span class=\"sr-only\"> ${row.key}</span></a\n >`\n : nothing}\n </dd>\n </div>\n `,\n )}\n </dl>\n `;\n }\n}\n\ncustomElements.define('impkt-summary-list', ImpktSummaryList);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-summary-list': ImpktSummaryList }\n}\n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AAAA,IAInB,CAAC;AAAA;AAAA;AAAA,EAGP;AACF;AAEA,eAAe,OAAO,sBAAsB,gBAAgB;","names":[]}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FieldElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6HZA6A3L.js";
|
|
4
4
|
import {
|
|
5
|
-
A,
|
|
6
|
-
b,
|
|
7
5
|
fontSize,
|
|
8
|
-
i,
|
|
9
6
|
space,
|
|
10
7
|
t,
|
|
11
8
|
targetSize
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
13
10
|
|
|
14
11
|
// packages/ui/src/components/checkbox.ts
|
|
12
|
+
import { html, css, nothing } from "lit";
|
|
15
13
|
var ImpktCheckbox = class extends FieldElement {
|
|
16
14
|
static {
|
|
17
15
|
this.properties = {
|
|
@@ -26,7 +24,7 @@ var ImpktCheckbox = class extends FieldElement {
|
|
|
26
24
|
static {
|
|
27
25
|
this.styles = [
|
|
28
26
|
...FieldElement.styles,
|
|
29
|
-
|
|
27
|
+
css`
|
|
30
28
|
.row {
|
|
31
29
|
display: flex;
|
|
32
30
|
align-items: flex-start;
|
|
@@ -51,32 +49,32 @@ var ImpktCheckbox = class extends FieldElement {
|
|
|
51
49
|
];
|
|
52
50
|
}
|
|
53
51
|
renderControl() {
|
|
54
|
-
return
|
|
52
|
+
return html`
|
|
55
53
|
<label class="row" part="row" for=${this.controlId}>
|
|
56
54
|
<input
|
|
57
55
|
type="checkbox"
|
|
58
56
|
id=${this.controlId}
|
|
59
57
|
part="input"
|
|
60
|
-
name=${this.name ||
|
|
58
|
+
name=${this.name || nothing}
|
|
61
59
|
.checked=${this.checked}
|
|
62
60
|
?disabled=${this.disabled}
|
|
63
61
|
?required=${this.required}
|
|
64
62
|
aria-describedby=${this.describedBy}
|
|
65
|
-
aria-invalid=${this.error ? "true" :
|
|
63
|
+
aria-invalid=${this.error ? "true" : nothing}
|
|
66
64
|
@change=${(e) => {
|
|
67
65
|
this.checked = e.target.checked;
|
|
68
66
|
this.setFormValue(this.checked ? "on" : "");
|
|
69
67
|
}}
|
|
70
68
|
/>
|
|
71
69
|
<span class="text">
|
|
72
|
-
${this.label}${this.required ?
|
|
70
|
+
${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
|
|
73
71
|
</span>
|
|
74
72
|
</label>
|
|
75
73
|
`;
|
|
76
74
|
}
|
|
77
75
|
/** The label is inside the control here, so the base class's is suppressed. */
|
|
78
76
|
renderLabel() {
|
|
79
|
-
return
|
|
77
|
+
return html`${nothing}`;
|
|
80
78
|
}
|
|
81
79
|
updated(changed) {
|
|
82
80
|
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
@@ -87,4 +85,4 @@ customElements.define("impkt-checkbox", ImpktCheckbox);
|
|
|
87
85
|
export {
|
|
88
86
|
ImpktCheckbox
|
|
89
87
|
};
|
|
90
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-HJ2V635J.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/checkbox.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\n/**\n * A single checkbox — a consent, an opt-in, a confirmation.\n *\n * The label sits beside the box rather than above it, so this overrides the\n * base layout. The whole `<label>` is the hit area: a 20px box is legal under\n * 2.5.8 and still unkind, and the row costs nothing.\n\n *\n * @category form\n * @icon checkbox\n */\nexport class ImpktCheckbox extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n checked: { type: Boolean, reflect: true },\n };\n\n declare checked: boolean;\n\n constructor() {\n super();\n this.checked = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n .row {\n display: flex;\n align-items: flex-start;\n gap: ${space(3)};\n cursor: pointer;\n }\n input {\n ${targetSize}\n inline-size: 20px;\n block-size: 20px;\n margin: 0;\n flex: none;\n accent-color: ${t.brand};\n }\n .text {\n font-size: ${fontSize('md')};\n }\n :host([invalid]) .row {\n color: ${t.dangerText};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <label class=\"row\" part=\"row\" for=${this.controlId}>\n <input\n type=\"checkbox\"\n id=${this.controlId}\n part=\"input\"\n name=${this.name || nothing}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => {\n this.checked = (e.target as HTMLInputElement).checked;\n this.setFormValue(this.checked ? 'on' : '');\n }}\n />\n <span class=\"text\">\n ${this.label}${this.required\n ? html`<span class=\"required\"> (${this.requiredText})</span>`\n : nothing}\n </span>\n </label>\n `;\n }\n\n /** The label is inside the control here, so the base class's is suppressed. */\n protected renderLabel(): TemplateResult {\n return html`${nothing}`;\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-checkbox', ImpktCheckbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-checkbox': ImpktCheckbox;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/checkbox.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\n/**\n * A single checkbox — a consent, an opt-in, a confirmation.\n *\n * The label sits beside the box rather than above it, so this overrides the\n * base layout. The whole `<label>` is the hit area: a 20px box is legal under\n * 2.5.8 and still unkind, and the row costs nothing.\n\n *\n * @category form\n * @icon checkbox\n */\nexport class ImpktCheckbox extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n checked: { type: Boolean, reflect: true },\n };\n\n declare checked: boolean;\n\n constructor() {\n super();\n this.checked = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n .row {\n display: flex;\n align-items: flex-start;\n gap: ${space(3)};\n cursor: pointer;\n }\n input {\n ${targetSize}\n inline-size: 20px;\n block-size: 20px;\n margin: 0;\n flex: none;\n accent-color: ${t.brand};\n }\n .text {\n font-size: ${fontSize('md')};\n }\n :host([invalid]) .row {\n color: ${t.dangerText};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <label class=\"row\" part=\"row\" for=${this.controlId}>\n <input\n type=\"checkbox\"\n id=${this.controlId}\n part=\"input\"\n name=${this.name || nothing}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => {\n this.checked = (e.target as HTMLInputElement).checked;\n this.setFormValue(this.checked ? 'on' : '');\n }}\n />\n <span class=\"text\">\n ${this.label}${this.required\n ? html`<span class=\"required\"> (${this.requiredText})</span>`\n : nothing}\n </span>\n </label>\n `;\n }\n\n /** The label is inside the control here, so the base class's is suppressed. */\n protected renderLabel(): TemplateResult {\n return html`${nothing}`;\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-checkbox', ImpktCheckbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-checkbox': ImpktCheckbox;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAgBjD,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,IAC1C;AAAA;AAAA,EAIA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MA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import { html, css, nothing } from "lit";
|
|
10
8
|
var ImpktImage = class extends ImpktElement {
|
|
11
9
|
static {
|
|
12
10
|
this.properties = {
|
|
@@ -34,7 +32,7 @@ var ImpktImage = class extends ImpktElement {
|
|
|
34
32
|
static {
|
|
35
33
|
this.styles = [
|
|
36
34
|
...ImpktElement.styles,
|
|
37
|
-
|
|
35
|
+
css`
|
|
38
36
|
:host {
|
|
39
37
|
display: block;
|
|
40
38
|
}
|
|
@@ -48,14 +46,14 @@ var ImpktImage = class extends ImpktElement {
|
|
|
48
46
|
];
|
|
49
47
|
}
|
|
50
48
|
render() {
|
|
51
|
-
return
|
|
49
|
+
return html`
|
|
52
50
|
<img
|
|
53
51
|
part="image"
|
|
54
52
|
src=${this.src}
|
|
55
53
|
alt=${this.decorative ? "" : this.alt}
|
|
56
|
-
role=${this.decorative ? "presentation" :
|
|
57
|
-
width=${this.width ??
|
|
58
|
-
height=${this.height ??
|
|
54
|
+
role=${this.decorative ? "presentation" : nothing}
|
|
55
|
+
width=${this.width ?? nothing}
|
|
56
|
+
height=${this.height ?? nothing}
|
|
59
57
|
loading=${this.loading}
|
|
60
58
|
style="object-position: ${this.focalX * 100}% ${this.focalY * 100}%"
|
|
61
59
|
/>
|
|
@@ -83,7 +81,7 @@ var ImpktLogo = class extends ImpktElement {
|
|
|
83
81
|
static {
|
|
84
82
|
this.styles = [
|
|
85
83
|
...ImpktElement.styles,
|
|
86
|
-
|
|
84
|
+
css`
|
|
87
85
|
:host {
|
|
88
86
|
display: inline-block;
|
|
89
87
|
}
|
|
@@ -96,7 +94,7 @@ var ImpktLogo = class extends ImpktElement {
|
|
|
96
94
|
}
|
|
97
95
|
render() {
|
|
98
96
|
const src = this.onDark && this.srcDark ? this.srcDark : this.src;
|
|
99
|
-
return
|
|
97
|
+
return html`<img part="logo" src=${src} alt=${this.alt} style="height: ${this.height}px" />`;
|
|
100
98
|
}
|
|
101
99
|
};
|
|
102
100
|
var ImpktDocumentLink = class extends ImpktElement {
|
|
@@ -118,7 +116,7 @@ var ImpktDocumentLink = class extends ImpktElement {
|
|
|
118
116
|
static {
|
|
119
117
|
this.styles = [
|
|
120
118
|
...ImpktElement.styles,
|
|
121
|
-
|
|
119
|
+
css`
|
|
122
120
|
:host {
|
|
123
121
|
display: block;
|
|
124
122
|
}
|
|
@@ -145,9 +143,9 @@ var ImpktDocumentLink = class extends ImpktElement {
|
|
|
145
143
|
}
|
|
146
144
|
render() {
|
|
147
145
|
const meta = [this.fileType, this.size].filter(Boolean).join(", ");
|
|
148
|
-
return
|
|
149
|
-
<a part="link" href=${this.href ||
|
|
150
|
-
<span>${this.label}</span>${meta ?
|
|
146
|
+
return html`
|
|
147
|
+
<a part="link" href=${this.href || nothing} download>
|
|
148
|
+
<span>${this.label}</span>${meta ? html`<span class="meta">(${meta})</span>` : nothing}
|
|
151
149
|
</a>
|
|
152
150
|
`;
|
|
153
151
|
}
|
|
@@ -161,4 +159,4 @@ export {
|
|
|
161
159
|
ImpktLogo,
|
|
162
160
|
ImpktDocumentLink
|
|
163
161
|
};
|
|
164
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-IHEEUM3M.js.map
|
|
@@ -1 +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":"
|
|
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":";;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAuBjD,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,M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AAK,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AACjE,WAAO;AAAA,4BACiB,KAAK,QAAQ,OAAO;AAAA,gBAChC,KAAK,KAAK,UAAU,OAAO,2BAA2B,IAAI,aAAa,OAAO;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,138 @@
|
|
|
1
|
+
// packages/ui/src/base/tokens.ts
|
|
2
|
+
import { unsafeCSS } from "lit";
|
|
3
|
+
var token = (path, fallback) => unsafeCSS(`var(--impkt-${path.replace(/\./g, "-")}, ${fallback})`);
|
|
4
|
+
var t = {
|
|
5
|
+
brand: token("color.brand.default", "#1f4ed8"),
|
|
6
|
+
brandHover: token("color.brand.hover", "#1b45be"),
|
|
7
|
+
brandActive: token("color.brand.active", "#183ba4"),
|
|
8
|
+
brandSubtle: token("color.brand.subtle", "#e4eafa"),
|
|
9
|
+
onBrand: token("color.text.on-brand", "#ffffff"),
|
|
10
|
+
surfaceCard: token("color.surface.card", "#ffffff"),
|
|
11
|
+
surfaceInset: token("color.surface.inset", "#f4f4f4"),
|
|
12
|
+
surfaceSubtle: token("color.surface.subtle", "#e4eafa"),
|
|
13
|
+
text: token("color.text.default", "#1a1a1a"),
|
|
14
|
+
textMuted: token("color.text.muted", "#717171"),
|
|
15
|
+
textPlaceholder: token("color.text.placeholder", "#767676"),
|
|
16
|
+
textHeading: token("color.text.heading", "#1f4ed8"),
|
|
17
|
+
link: token("color.text.link", "#1f4ed8"),
|
|
18
|
+
linkHover: token("color.text.link-hover", "#193ead"),
|
|
19
|
+
border: token("color.border.default", "#929292"),
|
|
20
|
+
borderStrong: token("color.border.strong", "#818181"),
|
|
21
|
+
danger: token("color.status.danger.default", "#c8102e"),
|
|
22
|
+
dangerText: token("color.status.danger.text", "#c8102e"),
|
|
23
|
+
dangerSubtle: token("color.status.danger.subtle", "#f8e2e6"),
|
|
24
|
+
warning: token("color.status.warning.default", "#b45309"),
|
|
25
|
+
warningText: token("color.status.warning.text", "#b45309"),
|
|
26
|
+
warningSubtle: token("color.status.warning.subtle", "#f6eae1"),
|
|
27
|
+
success: token("color.status.success.default", "#047857"),
|
|
28
|
+
successText: token("color.status.success.text", "#047857"),
|
|
29
|
+
successSubtle: token("color.status.success.subtle", "#e0f0ea"),
|
|
30
|
+
info: token("color.status.info.default", "#1f4ed8"),
|
|
31
|
+
infoText: token("color.status.info.text", "#1f4ed8"),
|
|
32
|
+
infoSubtle: token("color.status.info.subtle", "#e4eafa"),
|
|
33
|
+
fontBody: token("font.family.body", "system-ui, sans-serif"),
|
|
34
|
+
fontHeading: token("font.family.heading", "system-ui, sans-serif"),
|
|
35
|
+
focusShadow: token("focus.ring.shadow", "0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a"),
|
|
36
|
+
focusOffset: token("focus.ring.offset", "2px"),
|
|
37
|
+
targetMin: token("target.min", "24px"),
|
|
38
|
+
radiusSm: token("radius.sm", "2px"),
|
|
39
|
+
radius: token("radius.md", "4px"),
|
|
40
|
+
radiusLg: token("radius.lg", "8px"),
|
|
41
|
+
borderThin: token("border.width.thin", "1px"),
|
|
42
|
+
borderThick: token("border.width.thick", "2px")
|
|
43
|
+
};
|
|
44
|
+
var space = (step) => token(`space.${step}`, `${step * 4}px`);
|
|
45
|
+
var fontSize = (name) => token(`font.size.${name}`, "1rem");
|
|
46
|
+
var lineHeight = (name) => token(`font.line-height.${name}`, "1.5");
|
|
47
|
+
var fontWeight = (name) => token(`font.weight.${name}`, "400");
|
|
48
|
+
|
|
49
|
+
// packages/ui/src/base/styles.ts
|
|
50
|
+
import { css } from "lit";
|
|
51
|
+
var focusRing = css`
|
|
52
|
+
:host(:focus-visible),
|
|
53
|
+
:host(:not([disabled])) :focus-visible {
|
|
54
|
+
outline: 2px solid transparent;
|
|
55
|
+
outline-offset: ${t.focusOffset};
|
|
56
|
+
box-shadow: ${t.focusShadow};
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
var targetSize = css`
|
|
60
|
+
min-block-size: ${t.targetMin};
|
|
61
|
+
min-inline-size: ${t.targetMin};
|
|
62
|
+
`;
|
|
63
|
+
var visuallyHidden = css`
|
|
64
|
+
position: absolute;
|
|
65
|
+
inline-size: 1px;
|
|
66
|
+
block-size: 1px;
|
|
67
|
+
margin: -1px;
|
|
68
|
+
padding: 0;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
clip-path: inset(50%);
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
border: 0;
|
|
73
|
+
`;
|
|
74
|
+
var reducedMotion = css`
|
|
75
|
+
@media (prefers-reduced-motion: reduce) {
|
|
76
|
+
:host,
|
|
77
|
+
:host *,
|
|
78
|
+
:host *::before,
|
|
79
|
+
:host *::after {
|
|
80
|
+
animation-duration: 0.01ms !important;
|
|
81
|
+
animation-iteration-count: 1 !important;
|
|
82
|
+
transition-duration: 0.01ms !important;
|
|
83
|
+
scroll-behavior: auto !important;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
var base = css`
|
|
88
|
+
:host {
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
font-family: ${t.fontBody};
|
|
91
|
+
color: ${t.text};
|
|
92
|
+
}
|
|
93
|
+
:host([hidden]) {
|
|
94
|
+
display: none !important;
|
|
95
|
+
}
|
|
96
|
+
*,
|
|
97
|
+
*::before,
|
|
98
|
+
*::after {
|
|
99
|
+
box-sizing: inherit;
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
// packages/ui/src/base/ImpktElement.ts
|
|
104
|
+
import { LitElement, css as css2 } from "lit";
|
|
105
|
+
var counter = 0;
|
|
106
|
+
var ImpktElement = class extends LitElement {
|
|
107
|
+
constructor() {
|
|
108
|
+
super(...arguments);
|
|
109
|
+
/**
|
|
110
|
+
* A unique id for this instance, for `aria-describedby` and friends.
|
|
111
|
+
*
|
|
112
|
+
* Generated once in the constructor rather than in `render`, because an id
|
|
113
|
+
* that changes between renders breaks the relationship it exists to express
|
|
114
|
+
* — and it breaks it silently, since the markup still looks correct.
|
|
115
|
+
*/
|
|
116
|
+
this.uid = `impkt-${counter += 1}`;
|
|
117
|
+
}
|
|
118
|
+
static {
|
|
119
|
+
this.styles = [base, reducedMotion, css2``];
|
|
120
|
+
}
|
|
121
|
+
id_(part) {
|
|
122
|
+
return `${this.uid}-${part}`;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
token,
|
|
128
|
+
t,
|
|
129
|
+
space,
|
|
130
|
+
fontSize,
|
|
131
|
+
lineHeight,
|
|
132
|
+
fontWeight,
|
|
133
|
+
focusRing,
|
|
134
|
+
targetSize,
|
|
135
|
+
visuallyHidden,
|
|
136
|
+
ImpktElement
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=chunk-J5KAMJ2N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/base/tokens.ts","../src/base/styles.ts","../src/base/ImpktElement.ts"],"sourcesContent":["/**\n * Token helpers.\n *\n * Components never name a colour, a size or a radius. They name a token, and a\n * brand decides what it holds — which is what makes a rebrand a content\n * publish rather than a rebuild\n * ([ADR 0005](../../../../docs/decisions/0005-design-tokens.md)).\n *\n * Every reference carries a fallback so that a component dropped onto a page\n * with no token stylesheet still renders something legible. An unstyled\n * component is indistinguishable from a broken one, and the fallback is what\n * keeps a missing stylesheet a visible annoyance rather than a blank screen.\n *\n * These return `CSSResult` rather than strings. Lit's `css` tag refuses plain\n * interpolated strings, which is a deliberate guard against injecting\n * attacker-controlled text into a stylesheet; `unsafeCSS` is the documented\n * way past it and is safe here because every value is a literal in this file,\n * never anything authored or fetched.\n */\nimport { unsafeCSS, type CSSResult } from 'lit';\n\n/** `color.brand.default` → `var(--impkt-color-brand-default, <fallback>)`. */\nexport const token = (path: string, fallback: string): CSSResult =>\n unsafeCSS(`var(--impkt-${path.replace(/\\./g, '-')}, ${fallback})`);\n\nexport const t = {\n brand: token('color.brand.default', '#1f4ed8'),\n brandHover: token('color.brand.hover', '#1b45be'),\n brandActive: token('color.brand.active', '#183ba4'),\n brandSubtle: token('color.brand.subtle', '#e4eafa'),\n onBrand: token('color.text.on-brand', '#ffffff'),\n\n surfaceCard: token('color.surface.card', '#ffffff'),\n surfaceInset: token('color.surface.inset', '#f4f4f4'),\n surfaceSubtle: token('color.surface.subtle', '#e4eafa'),\n\n text: token('color.text.default', '#1a1a1a'),\n textMuted: token('color.text.muted', '#717171'),\n textPlaceholder: token('color.text.placeholder', '#767676'),\n textHeading: token('color.text.heading', '#1f4ed8'),\n link: token('color.text.link', '#1f4ed8'),\n linkHover: token('color.text.link-hover', '#193ead'),\n\n border: token('color.border.default', '#929292'),\n borderStrong: token('color.border.strong', '#818181'),\n\n danger: token('color.status.danger.default', '#c8102e'),\n dangerText: token('color.status.danger.text', '#c8102e'),\n dangerSubtle: token('color.status.danger.subtle', '#f8e2e6'),\n warning: token('color.status.warning.default', '#b45309'),\n warningText: token('color.status.warning.text', '#b45309'),\n warningSubtle: token('color.status.warning.subtle', '#f6eae1'),\n success: token('color.status.success.default', '#047857'),\n successText: token('color.status.success.text', '#047857'),\n successSubtle: token('color.status.success.subtle', '#e0f0ea'),\n info: token('color.status.info.default', '#1f4ed8'),\n infoText: token('color.status.info.text', '#1f4ed8'),\n infoSubtle: token('color.status.info.subtle', '#e4eafa'),\n\n fontBody: token('font.family.body', 'system-ui, sans-serif'),\n fontHeading: token('font.family.heading', 'system-ui, sans-serif'),\n\n focusShadow: token('focus.ring.shadow', '0 0 0 2px #ffffff, 0 0 0 4px #1a1a1a'),\n focusOffset: token('focus.ring.offset', '2px'),\n\n targetMin: token('target.min', '24px'),\n\n radiusSm: token('radius.sm', '2px'),\n radius: token('radius.md', '4px'),\n radiusLg: token('radius.lg', '8px'),\n\n borderThin: token('border.width.thin', '1px'),\n borderThick: token('border.width.thick', '2px'),\n} as const;\n\n/** `space.3` → the custom property. Spacing is always a token, never a number. */\nexport const space = (step: number): CSSResult => token(`space.${step}`, `${step * 4}px`);\n/** `font.size.lg` → the custom property. */\nexport const fontSize = (name: string): CSSResult => token(`font.size.${name}`, '1rem');\nexport const lineHeight = (name: string): CSSResult => token(`font.line-height.${name}`, '1.5');\nexport const fontWeight = (name: string): CSSResult => token(`font.weight.${name}`, '400');\n","/**\n * Shared style fragments.\n *\n * Three of these carry an accessibility guarantee and are therefore not\n * negotiable per component: the focus ring, the minimum target size and the\n * reduced-motion rule. A component that wants its own focus treatment is a\n * component that will get it subtly wrong on one brand, so there is one.\n */\nimport { css } from 'lit';\nimport { t } from './tokens';\n\n/**\n * The focus ring.\n *\n * `:focus-visible` rather than `:focus`, so a mouse click on a button does not\n * draw a ring the user did not ask for while keyboard focus still does.\n *\n * The ring is two-tone — a light inner band inside a dark outer one — drawn\n * with `box-shadow` and a transparent `outline` behind it. The outline is not\n * decoration: it is what survives Windows High Contrast Mode, where box-shadow\n * is dropped entirely and a shadow-only ring disappears for exactly the users\n * who most need it.\n *\n * The colours come from locked tokens a brand cannot reach\n * ([ADR 0010](../../../../docs/decisions/0010-what-a-brand-may-set.md)).\n */\nexport const focusRing = css`\n :host(:focus-visible),\n :host(:not([disabled])) :focus-visible {\n outline: 2px solid transparent;\n outline-offset: ${t.focusOffset};\n box-shadow: ${t.focusShadow};\n }\n`;\n\n/**\n * WCAG 2.2, 2.5.8 Target Size (Minimum): 24 by 24 CSS pixels.\n *\n * Applied as a minimum rather than a fixed size so a control grows with its\n * content and never shrinks below the floor. It reads the locked token, which\n * is deliberately outside the spacing scale — otherwise a brand tightening its\n * spacing unit would shrink every tap target with it.\n */\nexport const targetSize = css`\n min-block-size: ${t.targetMin};\n min-inline-size: ${t.targetMin};\n`;\n\n/**\n * Visible to a screen reader, invisible on screen.\n *\n * `clip-path` with a 1px box rather than `display: none` or `visibility:\n * hidden`, both of which remove the text from the accessibility tree — which\n * is the one thing this must not do.\n */\nexport const visuallyHidden = css`\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n`;\n\n/**\n * 2.3.3 Animation from Interactions, and plain decency.\n *\n * `0.01ms` rather than `0` because a zero-duration transition does not fire a\n * `transitionend` event in every engine, and components that wait for one hang.\n */\nexport const reducedMotion = css`\n @media (prefers-reduced-motion: reduce) {\n :host,\n :host *,\n :host *::before,\n :host *::after {\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n scroll-behavior: auto !important;\n }\n }\n`;\n\n/** The base every component starts from. */\nexport const base = css`\n :host {\n box-sizing: border-box;\n font-family: ${t.fontBody};\n color: ${t.text};\n }\n :host([hidden]) {\n display: none !important;\n }\n *,\n *::before,\n *::after {\n box-sizing: inherit;\n }\n`;\n","import { LitElement, css } from 'lit';\nimport { base, reducedMotion } from './styles';\n\nlet counter = 0;\n\n/**\n * The base every Impkt component extends.\n *\n * It carries the two style fragments that are not a per-component choice — the\n * reset and the reduced-motion rule — and a stable id generator for the ARIA\n * wiring. It deliberately carries nothing else: a base class that grows\n * behaviour becomes the place every component's exceptions are negotiated.\n */\nexport class ImpktElement extends LitElement {\n static styles = [base, reducedMotion, css``];\n\n /**\n * A unique id for this instance, for `aria-describedby` and friends.\n *\n * Generated once in the constructor rather than in `render`, because an id\n * that changes between renders breaks the relationship it exists to express\n * — and it breaks it silently, since the markup still looks correct.\n */\n protected readonly uid = `impkt-${(counter += 1)}`;\n\n protected id_(part: string): string {\n return `${this.uid}-${part}`;\n }\n}\n"],"mappings":";AAmBA,SAAS,iBAAiC;AAGnC,IAAM,QAAQ,CAAC,MAAc,aAClC,UAAU,eAAe,KAAK,QAAQ,OAAO,GAAG,CAAC,KAAK,QAAQ,GAAG;AAE5D,IAAM,IAAI;AAAA,EACf,OAAO,MAAM,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