@atomic-ui/ui 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-OZNQ4GAR.js → chunk-BBWMRF5N.js} +8 -10
- package/dist/{chunk-OZNQ4GAR.js.map → chunk-BBWMRF5N.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-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.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
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ImpktElement,
|
|
3
|
-
b,
|
|
4
|
-
i,
|
|
5
3
|
space
|
|
6
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
7
5
|
|
|
8
6
|
// packages/ui/src/components/grid.ts
|
|
7
|
+
import { css, html } from "lit";
|
|
9
8
|
var ImpktGrid = class extends ImpktElement {
|
|
10
9
|
static {
|
|
11
10
|
this.properties = { columns: { type: String, reflect: true }, gap: { type: String, reflect: true } };
|
|
@@ -16,7 +15,7 @@ var ImpktGrid = class extends ImpktElement {
|
|
|
16
15
|
this.gap = "md";
|
|
17
16
|
}
|
|
18
17
|
static {
|
|
19
|
-
this.styles = [...ImpktElement.styles,
|
|
18
|
+
this.styles = [...ImpktElement.styles, css`
|
|
20
19
|
:host { display: block; min-inline-size: 0; container-type: inline-size; }
|
|
21
20
|
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${space(4)}; }
|
|
22
21
|
:host([gap='sm']) .columns { gap: ${space(2)}; }
|
|
@@ -33,7 +32,7 @@ var ImpktGrid = class extends ImpktElement {
|
|
|
33
32
|
}
|
|
34
33
|
render() {
|
|
35
34
|
const count = this.columns === "one" ? 1 : this.columns === "three" ? 3 : this.columns === "four" ? 4 : 2;
|
|
36
|
-
return
|
|
35
|
+
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>`;
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
customElements.define("impkt-grid", ImpktGrid);
|
|
@@ -41,4 +40,4 @@ customElements.define("impkt-grid", ImpktGrid);
|
|
|
41
40
|
export {
|
|
42
41
|
ImpktGrid
|
|
43
42
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-4YAA7EML.js.map
|
|
@@ -1 +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":"
|
|
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":";;;;;;AAAA,SAAS,KAAK,YAAY;AAenB,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,uCAAuC,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,CAAC,GAAG,MAAM,oDAAoD,UAAU,IAAE,CAAC,EAAE,gBAAgB,CAAC;AAAA,EAC5K;AACF;AACA,eAAe,OAAO,cAAc,SAAS;","names":[]}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
A,
|
|
3
2
|
ImpktElement,
|
|
4
|
-
b,
|
|
5
3
|
focusRing,
|
|
6
4
|
fontSize,
|
|
7
5
|
fontWeight,
|
|
8
|
-
i,
|
|
9
6
|
lineHeight,
|
|
10
7
|
space,
|
|
11
8
|
t,
|
|
12
9
|
visuallyHidden
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
14
11
|
|
|
15
12
|
// packages/ui/src/base/FieldElement.ts
|
|
13
|
+
import { html, css, nothing } from "lit";
|
|
16
14
|
var FieldElement = class extends ImpktElement {
|
|
17
15
|
constructor() {
|
|
18
16
|
super();
|
|
@@ -53,7 +51,7 @@ var FieldElement = class extends ImpktElement {
|
|
|
53
51
|
this.styles = [
|
|
54
52
|
...ImpktElement.styles,
|
|
55
53
|
focusRing,
|
|
56
|
-
|
|
54
|
+
css`
|
|
57
55
|
:host {
|
|
58
56
|
display: block;
|
|
59
57
|
margin-block-end: ${space(4)};
|
|
@@ -112,7 +110,7 @@ var FieldElement = class extends ImpktElement {
|
|
|
112
110
|
this.description ? this.id_("description") : "",
|
|
113
111
|
this.error ? this.id_("error") : ""
|
|
114
112
|
].filter(Boolean);
|
|
115
|
-
return ids.length ? ids.join(" ") :
|
|
113
|
+
return ids.length ? ids.join(" ") : nothing;
|
|
116
114
|
}
|
|
117
115
|
/**
|
|
118
116
|
* `<label for>` by default. A group of controls — radios, checkboxes —
|
|
@@ -120,18 +118,18 @@ var FieldElement = class extends ImpktElement {
|
|
|
120
118
|
* this and render a `<fieldset>` and `<legend>` instead.
|
|
121
119
|
*/
|
|
122
120
|
renderLabel() {
|
|
123
|
-
return
|
|
121
|
+
return html`
|
|
124
122
|
<label class="label" for=${this.controlId} part="label">
|
|
125
|
-
${this.label}${this.required ?
|
|
123
|
+
${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
|
|
126
124
|
</label>
|
|
127
125
|
`;
|
|
128
126
|
}
|
|
129
127
|
render() {
|
|
130
|
-
return
|
|
128
|
+
return html`
|
|
131
129
|
${this.renderLabel()}
|
|
132
|
-
${this.description ?
|
|
130
|
+
${this.description ? html`<div class="description" id=${this.id_("description")} part="description">
|
|
133
131
|
${this.description}
|
|
134
|
-
</div>` :
|
|
132
|
+
</div>` : nothing}
|
|
135
133
|
${this.renderControl()}
|
|
136
134
|
<!--
|
|
137
135
|
The error region is always present, even when empty. A live region
|
|
@@ -146,7 +144,7 @@ var FieldElement = class extends ImpktElement {
|
|
|
146
144
|
part="error"
|
|
147
145
|
aria-live="polite"
|
|
148
146
|
>
|
|
149
|
-
${this.error ||
|
|
147
|
+
${this.error || nothing}
|
|
150
148
|
</div>
|
|
151
149
|
`;
|
|
152
150
|
}
|
|
@@ -161,4 +159,4 @@ var FieldElement = class extends ImpktElement {
|
|
|
161
159
|
export {
|
|
162
160
|
FieldElement
|
|
163
161
|
};
|
|
164
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-6HZA6A3L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base/FieldElement.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from './ImpktElement';\nimport { focusRing, visuallyHidden } from './styles';\nimport { fontSize, fontWeight, lineHeight, space, t } from './tokens';\n\n/**\n * The shared anatomy of a form control: a label, an optional description, a\n * control, and an error.\n *\n * This exists because the ARIA wiring between those four is where accessible\n * forms actually fail, and it fails the same way every time — a description\n * that is never announced, an error that appears silently, a label that points\n * at nothing. Written once, it is right once.\n *\n * Everything is rendered inside this component's own shadow root, including\n * the native control. That is not an implementation detail: `aria-describedby`\n * cannot cross a shadow boundary, so a component that slotted the input from\n * outside could not describe it. Keeping the whole relationship in one tree is\n * what makes the wiring work at all.\n */\nexport abstract class FieldElement extends ImpktElement {\n /** Form controls participate in a `<form>` like native ones. */\n static formAssociated = true;\n\n static properties = {\n label: { type: String },\n name: { type: String },\n value: { type: String },\n description: { type: String },\n error: { type: String },\n required: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n readonly: { type: Boolean, reflect: true },\n requiredText: { type: String, attribute: 'required-text' },\n };\n\n declare label: string;\n declare name: string;\n declare value: string;\n declare description: string;\n declare error: string;\n declare required: boolean;\n declare disabled: boolean;\n declare readonly: boolean;\n /**\n * How \"you must answer this\" is said.\n *\n * Words, not an asterisk. 3.3.2 asks for labels or instructions, and an\n * asterisk is neither until a legend explains it — which puts the\n * explanation somewhere other than the field it explains. It is a property\n * so a partner can reword it, not so they can empty it.\n */\n declare requiredText: string;\n\n protected internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this.label = '';\n this.name = '';\n this.value = '';\n this.description = '';\n this.error = '';\n this.required = false;\n this.disabled = false;\n this.readonly = false;\n this.requiredText = 'required';\n // happy-dom and older engines do not implement attachInternals. A control\n // that cannot associate with a form is still a usable control, so this\n // degrades rather than throwing on construction.\n try {\n this.internals = this.attachInternals();\n } catch {\n this.internals = null;\n }\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n margin-block-end: ${space(4)};\n }\n .label {\n display: block;\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('semibold')};\n line-height: ${lineHeight('normal')};\n margin-block-end: ${space(1)};\n color: ${t.text};\n }\n .required {\n font-weight: ${fontWeight('regular')};\n color: ${t.textMuted};\n }\n .description {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.textMuted};\n margin-block-end: ${space(2)};\n }\n .error {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.dangerText};\n margin-block-start: ${space(1)};\n display: flex;\n gap: ${space(1)};\n }\n .error:empty {\n display: none;\n }\n .visually-hidden {\n ${visuallyHidden}\n }\n :host([disabled]) {\n opacity: 0.6;\n }\n `,\n ];\n\n protected get controlId(): string {\n return this.id_('control');\n }\n\n /**\n * What the control points `aria-describedby` at.\n *\n * The error id is included only while there is an error. A describedby that\n * always names an empty element trains a screen-reader user to expect\n * nothing after the description, and then the one time it matters they have\n * already learned to ignore it.\n */\n protected get describedBy(): string | typeof nothing {\n const ids = [\n this.description ? this.id_('description') : '',\n this.error ? this.id_('error') : '',\n ].filter(Boolean);\n return ids.length ? ids.join(' ') : nothing;\n }\n\n /** Subclasses render the control itself; everything round it is here. */\n protected abstract renderControl(): TemplateResult;\n\n /**\n * `<label for>` by default. A group of controls — radios, checkboxes —\n * cannot use one, because `for` names a single control, so those override\n * this and render a `<fieldset>` and `<legend>` instead.\n */\n protected renderLabel(): TemplateResult {\n return html`\n <label class=\"label\" for=${this.controlId} part=\"label\">\n ${this.label}${this.required\n ? html`<span class=\"required\"> (${this.requiredText})</span>`\n : nothing}\n </label>\n `;\n }\n\n render(): TemplateResult {\n return html`\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 <!--\n The error region is always present, even when empty. A live region\n inserted at the same moment as its content is announced unreliably\n across screen readers; one that already exists and is then filled is\n announced consistently. \"polite\" rather than \"assertive\" because a\n validation message should not interrupt what is being read.\n -->\n <div\n class=\"error\"\n id=${this.id_('error')}\n part=\"error\"\n aria-live=\"polite\"\n >\n ${this.error || nothing}\n </div>\n `;\n }\n\n /** Keep the form value in step with the control. */\n protected setFormValue(value: string): void {\n this.value = value;\n this.internals?.setFormValue(value);\n this.dispatchEvent(new CustomEvent('impkt-change', { detail: { value }, bubbles: true, composed: true }));\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/base/FieldElement.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from './ImpktElement';\nimport { focusRing, visuallyHidden } from './styles';\nimport { fontSize, fontWeight, lineHeight, space, t } from './tokens';\n\n/**\n * The shared anatomy of a form control: a label, an optional description, a\n * control, and an error.\n *\n * This exists because the ARIA wiring between those four is where accessible\n * forms actually fail, and it fails the same way every time — a description\n * that is never announced, an error that appears silently, a label that points\n * at nothing. Written once, it is right once.\n *\n * Everything is rendered inside this component's own shadow root, including\n * the native control. That is not an implementation detail: `aria-describedby`\n * cannot cross a shadow boundary, so a component that slotted the input from\n * outside could not describe it. Keeping the whole relationship in one tree is\n * what makes the wiring work at all.\n */\nexport abstract class FieldElement extends ImpktElement {\n /** Form controls participate in a `<form>` like native ones. */\n static formAssociated = true;\n\n static properties = {\n label: { type: String },\n name: { type: String },\n value: { type: String },\n description: { type: String },\n error: { type: String },\n required: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n readonly: { type: Boolean, reflect: true },\n requiredText: { type: String, attribute: 'required-text' },\n };\n\n declare label: string;\n declare name: string;\n declare value: string;\n declare description: string;\n declare error: string;\n declare required: boolean;\n declare disabled: boolean;\n declare readonly: boolean;\n /**\n * How \"you must answer this\" is said.\n *\n * Words, not an asterisk. 3.3.2 asks for labels or instructions, and an\n * asterisk is neither until a legend explains it — which puts the\n * explanation somewhere other than the field it explains. It is a property\n * so a partner can reword it, not so they can empty it.\n */\n declare requiredText: string;\n\n protected internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this.label = '';\n this.name = '';\n this.value = '';\n this.description = '';\n this.error = '';\n this.required = false;\n this.disabled = false;\n this.readonly = false;\n this.requiredText = 'required';\n // happy-dom and older engines do not implement attachInternals. A control\n // that cannot associate with a form is still a usable control, so this\n // degrades rather than throwing on construction.\n try {\n this.internals = this.attachInternals();\n } catch {\n this.internals = null;\n }\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n margin-block-end: ${space(4)};\n }\n .label {\n display: block;\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('semibold')};\n line-height: ${lineHeight('normal')};\n margin-block-end: ${space(1)};\n color: ${t.text};\n }\n .required {\n font-weight: ${fontWeight('regular')};\n color: ${t.textMuted};\n }\n .description {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.textMuted};\n margin-block-end: ${space(2)};\n }\n .error {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.dangerText};\n margin-block-start: ${space(1)};\n display: flex;\n gap: ${space(1)};\n }\n .error:empty {\n display: none;\n }\n .visually-hidden {\n ${visuallyHidden}\n }\n :host([disabled]) {\n opacity: 0.6;\n }\n `,\n ];\n\n protected get controlId(): string {\n return this.id_('control');\n }\n\n /**\n * What the control points `aria-describedby` at.\n *\n * The error id is included only while there is an error. A describedby that\n * always names an empty element trains a screen-reader user to expect\n * nothing after the description, and then the one time it matters they have\n * already learned to ignore it.\n */\n protected get describedBy(): string | typeof nothing {\n const ids = [\n this.description ? this.id_('description') : '',\n this.error ? this.id_('error') : '',\n ].filter(Boolean);\n return ids.length ? ids.join(' ') : nothing;\n }\n\n /** Subclasses render the control itself; everything round it is here. */\n protected abstract renderControl(): TemplateResult;\n\n /**\n * `<label for>` by default. A group of controls — radios, checkboxes —\n * cannot use one, because `for` names a single control, so those override\n * this and render a `<fieldset>` and `<legend>` instead.\n */\n protected renderLabel(): TemplateResult {\n return html`\n <label class=\"label\" for=${this.controlId} part=\"label\">\n ${this.label}${this.required\n ? html`<span class=\"required\"> (${this.requiredText})</span>`\n : nothing}\n </label>\n `;\n }\n\n render(): TemplateResult {\n return html`\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 <!--\n The error region is always present, even when empty. A live region\n inserted at the same moment as its content is announced unreliably\n across screen readers; one that already exists and is then filled is\n announced consistently. \"polite\" rather than \"assertive\" because a\n validation message should not interrupt what is being read.\n -->\n <div\n class=\"error\"\n id=${this.id_('error')}\n part=\"error\"\n aria-live=\"polite\"\n >\n ${this.error || nothing}\n </div>\n `;\n }\n\n /** Keep the form value in step with the control. */\n protected setFormValue(value: string): void {\n this.value = value;\n this.internals?.setFormValue(value);\n this.dispatchEvent(new CustomEvent('impkt-change', { detail: { value }, bubbles: true, composed: true }));\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAoBjD,IAAe,eAAf,cAAoC,aAAa;AAAA,EAoCtD,cAAc;AACZ,UAAM;AAHR,SAAU,YAAqC;AAI7C,SAAK,QAAQ;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,cAAc;AACnB,SAAK,QAAQ;AACb,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,eAAe;AAIpB,QAAI;AACF,WAAK,YAAY,KAAK,gBAAgB;AAAA,IACxC,QAAQ;AACN,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA,EArDA;AAAA;AAAA,SAAO,iBAAiB;AAAA;AAAA,EAExB;AAAA,SAAO,aAAa;AAAA,MAClB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,aAAa,EAAE,MAAM,OAAO;AAAA,MAC5B,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACzC,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACzC,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACzC,cAAc,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,IAC3D;AAAA;AAAA,EA2CA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA,MACA;AAAA;AAAA;AAAA,4BAGwB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,qBAIf,SAAS,IAAI,CAAC;AAAA,uBACZ,WAAW,UAAU,CAAC;AAAA,uBACtB,WAAW,QAAQ,CAAC;AAAA,4BACf,MAAM,CAAC,CAAC;AAAA,iBACnB,EAAE,IAAI;AAAA;AAAA;AAAA,uBAGA,WAAW,SAAS,CAAC;AAAA,iBAC3B,EAAE,SAAS;AAAA;AAAA;AAAA,qBAGP,SAAS,IAAI,CAAC;AAAA,uBACZ,WAAW,QAAQ,CAAC;AAAA,iBAC1B,EAAE,SAAS;AAAA,4BACA,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA,qBAGf,SAAS,IAAI,CAAC;AAAA,uBACZ,WAAW,QAAQ,CAAC;AAAA,iBAC1B,EAAE,UAAU;AAAA,8BACC,MAAM,CAAC,CAAC;AAAA;AAAA,eAEvB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAMb,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMtB;AAAA;AAAA,EAEA,IAAc,YAAoB;AAChC,WAAO,KAAK,IAAI,SAAS;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,IAAc,cAAuC;AACnD,UAAM,MAAM;AAAA,MACV,KAAK,cAAc,KAAK,IAAI,aAAa,IAAI;AAAA,MAC7C,KAAK,QAAQ,KAAK,IAAI,OAAO,IAAI;AAAA,IACnC,EAAE,OAAO,OAAO;AAChB,WAAO,IAAI,SAAS,IAAI,KAAK,GAAG,IAAI;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUU,cAA8B;AACtC,WAAO;AAAA,iCACsB,KAAK,SAAS;AAAA,UACrC,KAAK,KAAK,GAAG,KAAK,WAChB,gCAAgC,KAAK,YAAY,aACjD,OAAO;AAAA;AAAA;AAAA,EAGjB;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,QACH,KAAK,YAAY,CAAC;AAAA,QAClB,KAAK,cACH,mCAAmC,KAAK,IAAI,aAAa,CAAC;AAAA,cACtD,KAAK,WAAW;AAAA,oBAEpB,OAAO;AAAA,QACT,KAAK,cAAc,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAUf,KAAK,IAAI,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA,UAIpB,KAAK,SAAS,OAAO;AAAA;AAAA;AAAA,EAG7B;AAAA;AAAA,EAGU,aAAa,OAAqB;AAC1C,SAAK,QAAQ;AACb,SAAK,WAAW,aAAa,KAAK;AAClC,SAAK,cAAc,IAAI,YAAY,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,EAC1G;AACF;","names":[]}
|
|
@@ -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/textarea.ts
|
|
11
|
+
import { html, css, nothing } from "lit";
|
|
14
12
|
var ImpktTextarea = class extends FieldElement {
|
|
15
13
|
static {
|
|
16
14
|
this.properties = {
|
|
@@ -27,7 +25,7 @@ var ImpktTextarea = class extends FieldElement {
|
|
|
27
25
|
static {
|
|
28
26
|
this.styles = [
|
|
29
27
|
...FieldElement.styles,
|
|
30
|
-
|
|
28
|
+
css`
|
|
31
29
|
textarea {
|
|
32
30
|
inline-size: 100%;
|
|
33
31
|
padding: ${space(3)};
|
|
@@ -49,18 +47,18 @@ var ImpktTextarea = class extends FieldElement {
|
|
|
49
47
|
];
|
|
50
48
|
}
|
|
51
49
|
renderControl() {
|
|
52
|
-
return
|
|
50
|
+
return html`
|
|
53
51
|
<textarea
|
|
54
52
|
id=${this.controlId}
|
|
55
53
|
part="textarea"
|
|
56
|
-
name=${this.name ||
|
|
54
|
+
name=${this.name || nothing}
|
|
57
55
|
rows=${this.rows}
|
|
58
|
-
maxlength=${this.maxlength ??
|
|
56
|
+
maxlength=${this.maxlength ?? nothing}
|
|
59
57
|
?disabled=${this.disabled}
|
|
60
58
|
?readonly=${this.readonly}
|
|
61
59
|
?required=${this.required}
|
|
62
60
|
aria-describedby=${this.describedBy}
|
|
63
|
-
aria-invalid=${this.error ? "true" :
|
|
61
|
+
aria-invalid=${this.error ? "true" : nothing}
|
|
64
62
|
@input=${(e) => this.setFormValue(e.target.value)}
|
|
65
63
|
>${this.value}</textarea>
|
|
66
64
|
`;
|
|
@@ -74,4 +72,4 @@ customElements.define("impkt-textarea", ImpktTextarea);
|
|
|
74
72
|
export {
|
|
75
73
|
ImpktTextarea
|
|
76
74
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
75
|
+
//# sourceMappingURL=chunk-7T34CRBF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/textarea.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\n/** Several lines of text — a delivery instruction, an additional note.\n *\n * @category form\n * @icon field\n */\nexport class ImpktTextarea extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n rows: { type: Number },\n maxlength: { type: Number },\n };\n\n declare rows: number;\n declare maxlength: number | undefined;\n\n constructor() {\n super();\n this.rows = 4;\n this.maxlength = undefined;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n textarea {\n inline-size: 100%;\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 /* Resizing is left on deliberately. 1.4.4 and 1.4.12 both assume text\n can be made bigger, and a fixed box is where that stops working. */\n resize: vertical;\n }\n :host([invalid]) textarea {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <textarea\n id=${this.controlId}\n part=\"textarea\"\n name=${this.name || nothing}\n rows=${this.rows}\n maxlength=${this.maxlength ?? nothing}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @input=${(e: Event) => this.setFormValue((e.target as HTMLTextAreaElement).value)}\n >${this.value}</textarea>\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-textarea', ImpktTextarea);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-textarea': ImpktTextarea }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/textarea.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\n/** Several lines of text — a delivery instruction, an additional note.\n *\n * @category form\n * @icon field\n */\nexport class ImpktTextarea extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n rows: { type: Number },\n maxlength: { type: Number },\n };\n\n declare rows: number;\n declare maxlength: number | undefined;\n\n constructor() {\n super();\n this.rows = 4;\n this.maxlength = undefined;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n textarea {\n inline-size: 100%;\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 /* Resizing is left on deliberately. 1.4.4 and 1.4.12 both assume text\n can be made bigger, and a fixed box is where that stops working. */\n resize: vertical;\n }\n :host([invalid]) textarea {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <textarea\n id=${this.controlId}\n part=\"textarea\"\n name=${this.name || nothing}\n rows=${this.rows}\n maxlength=${this.maxlength ?? nothing}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @input=${(e: Event) => this.setFormValue((e.target as HTMLTextAreaElement).value)}\n >${this.value}</textarea>\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-textarea', ImpktTextarea);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-textarea': ImpktTextarea }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AASjD,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,WAAW,EAAE,MAAM,OAAO;AAAA,IAC5B;AAAA;AAAA,EAKA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA,mBAGe,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;AAAA;AAAA;AAAA,wBAMT,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,OAAO;AAAA,eACpB,KAAK,IAAI;AAAA,oBACJ,KAAK,aAAa,OAAO;AAAA,oBACzB,KAAK,QAAQ;AAAA,oBACb,KAAK,QAAQ;AAAA,oBACb,KAAK,QAAQ;AAAA,2BACN,KAAK,WAAW;AAAA,uBACpB,KAAK,QAAQ,SAAS,OAAO;AAAA,iBACnC,CAAC,MAAa,KAAK,aAAc,EAAE,OAA+B,KAAK,CAAC;AAAA,SAChF,KAAK,KAAK;AAAA;AAAA,EAEjB;AAAA,EAEA,QAAQ,SAAqC;AAC3C,QAAI,QAAQ,IAAI,OAAO,EAAG,MAAK,gBAAgB,WAAW,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,kBAAkB,aAAa;","names":[]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
A,
|
|
3
2
|
ImpktElement,
|
|
4
|
-
b,
|
|
5
3
|
focusRing,
|
|
6
4
|
fontWeight,
|
|
7
|
-
i,
|
|
8
5
|
t
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
10
7
|
|
|
11
8
|
// packages/ui/src/components/help.ts
|
|
9
|
+
import { html, css, nothing } from "lit";
|
|
12
10
|
var ImpktHelp = class extends ImpktElement {
|
|
13
11
|
static {
|
|
14
12
|
this.properties = {
|
|
@@ -27,7 +25,7 @@ var ImpktHelp = class extends ImpktElement {
|
|
|
27
25
|
this.detail = "";
|
|
28
26
|
}
|
|
29
27
|
static {
|
|
30
|
-
this.styles = [...ImpktElement.styles, focusRing,
|
|
28
|
+
this.styles = [...ImpktElement.styles, focusRing, css`
|
|
31
29
|
:host { display: block; }
|
|
32
30
|
a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};
|
|
33
31
|
color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }
|
|
@@ -51,20 +49,20 @@ var ImpktHelp = class extends ImpktElement {
|
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
renderLink() {
|
|
54
|
-
if (!text(this.label)) return
|
|
55
|
-
return
|
|
52
|
+
if (!text(this.label)) return nothing;
|
|
53
|
+
return html`<a part="link" href=${this.href}>${this.label}</a>`;
|
|
56
54
|
}
|
|
57
55
|
renderContact() {
|
|
58
56
|
const detail = text(this.detail);
|
|
59
|
-
if (!detail) return
|
|
57
|
+
if (!detail) return nothing;
|
|
60
58
|
const caption = text(this.label);
|
|
61
59
|
const target = contactHref(this.kind, detail);
|
|
62
60
|
const captionId = this.id_("caption");
|
|
63
61
|
const detailId = this.id_("detail");
|
|
64
|
-
const captionPart = caption ?
|
|
65
|
-
const detailPart = target ?
|
|
66
|
-
><span class="detail" part="detail" id=${detailId}>${detail}</span></a>` :
|
|
67
|
-
return
|
|
62
|
+
const captionPart = caption ? html`<span class="caption" part="label" id=${captionId}>${caption}</span>` : nothing;
|
|
63
|
+
const detailPart = target ? html`<a part="link" href=${target} aria-labelledby=${caption ? `${captionId} ${detailId}` : nothing}
|
|
64
|
+
><span class="detail" part="detail" id=${detailId}>${detail}</span></a>` : html`<span class="detail" part="detail">${detail}</span>`;
|
|
65
|
+
return html`<p class="contact" part="contact">${captionPart}${detailPart}</p>`;
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
function text(value) {
|
|
@@ -83,4 +81,4 @@ customElements.define("impkt-help", ImpktHelp);
|
|
|
83
81
|
export {
|
|
84
82
|
ImpktHelp
|
|
85
83
|
};
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-AC6G7X3G.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/help.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing } from '../base/styles';\nimport { fontWeight, t } from '../base/tokens';\n\n/**\n * What form a help mechanism takes.\n *\n * `link` goes somewhere: a help page, a contact form, a chat. The other four\n * are the \"human contact details\" that 3.2.6 Consistent Help names, shown as\n * text so a reader can see them without following anything.\n */\nexport type HelpKind = 'link' | 'phone' | 'email' | 'address' | 'hours';\n\n/**\n * A help link, or contact details shown as text.\n *\n * **Its identity is `mechanismId`, not its wording or destination.** 3.2.6\n * Consistent Help asks that help offered on several pages appears in the same\n * relative order on each. Strata checks that at publish by comparing these ids\n * across pages, so the label can be reworded and the number can change\n * without the check treating it as a different mechanism. It is literal and\n * cannot be bound, because an id that a data response could change is one the\n * check cannot compare.\n *\n * **Contact details are text, not a link to a page that has them.** The\n * criterion lists a phone number, an email address and a postal address as\n * help in their own right, and a reader who has to follow a link to find the\n * number has been given a link rather than the number. A phone number renders\n * as a `tel:` link and an email address as a `mailto:` link, each with the\n * detail itself as the visible text. The link target is derived from the\n * visible detail rather than authored separately, so the number a reader sees\n * and the number their phone dials cannot drift apart. An address or opening\n * hours render as plain text and keep the line breaks they were written with.\n *\n * **Contact links are named by their caption and their detail.** A phone\n * link's accessible name is \"Call us 0800 123 456\" rather than the bare\n * number, because a reader moving through a list of links hears each one out\n * of context (2.4.4 Link Purpose). The visible text stays inside the name, so\n * 2.5.3 Label in Name holds for a reader who speaks it.\n *\n * **Nothing unnamed or empty is ever rendered.** Runtime bindings may be\n * absent while data loads, or resolve to blank text. A link with no label, or\n * contact details with no detail, render nothing rather than a focusable link\n * with no name or a caption with nothing under it. Contact details whose\n * caption is blank still show the detail, because a phone number or an\n * address names itself. For that reason the caption is optional for contact\n * details, and publishing requires a label only on a link. Publishing does\n * require what each kind cannot do without: a link's label and address, and\n * contact details' detail, so the empty states are only reached at runtime.\n *\n * **Every link meets the minimum target size.** Links here are at least the\n * locked `target.min` token in both directions (2.5.8 Target Size), because a\n * help link usually stands on its own line, where the criterion's inline\n * exemption does not apply.\n *\n * @category action\n * @icon help\n * @role help\n */\nexport class ImpktHelp extends ImpktElement {\n static properties = {\n mechanismId: { type: String, attribute: 'mechanism-id' },\n kind: { type: String, reflect: true },\n href: { type: String },\n label: { type: String },\n detail: { type: String },\n };\n\n /** Stable identity across pages, independent of wording and destination. */\n declare mechanismId: string;\n // Written out as a union rather than as `HelpKind` so the manifest offers it\n // as a fixed choice: which form help takes is a design decision, not data.\n /** Whether this is a link to help, or contact details shown as text. */\n declare kind: 'link' | 'phone' | 'email' | 'address' | 'hours';\n /** Where a link goes. Phone and email links are built from the detail instead. */\n declare href: string;\n /**\n * The visible name. For a link it is the link text. For contact details it\n * is the caption shown above them, such as \"Call us\".\n */\n declare label: string;\n /**\n * The contact detail itself: a phone number, an email address, a postal\n * address or opening hours. Line breaks are kept. Unused by a link.\n */\n declare detail: string;\n\n constructor() {\n super();\n this.kind = 'link';\n this.href = '';\n // Defaulted, so the manifest does not mark it required: contact details\n // may leave the caption out. A link without one is refused at publish.\n this.label = '';\n this.detail = '';\n }\n\n static styles = [...ImpktElement.styles, focusRing, css`\n :host { display: block; }\n a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};\n color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }\n a:hover { color: ${t.linkHover}; }\n .contact { margin: 0; }\n .caption { display: block; font-weight: ${fontWeight('semibold')}; }\n /* An address is written one line at a time, and opening hours are often one\n day to a line. Long unbroken values still wrap at 320px (1.4.10). */\n .detail { white-space: pre-line; overflow-wrap: anywhere; }\n `];\n\n render(): TemplateResult | typeof nothing {\n switch (this.kind) {\n case 'phone':\n case 'email':\n case 'address':\n case 'hours':\n return this.renderContact();\n default:\n // An absent or unrecognised kind keeps the original link behaviour, so\n // a page published before contact details existed renders unchanged.\n return this.renderLink();\n }\n }\n\n private renderLink(): TemplateResult | typeof nothing {\n // Runtime bindings may be absent while data loads, or resolve to blank text.\n // Do not expose an unnamed focusable link in those states.\n if (!text(this.label)) return nothing;\n return html`<a part=\"link\" href=${this.href}>${this.label}</a>`;\n }\n\n private renderContact(): TemplateResult | typeof nothing {\n const detail = text(this.detail);\n // A caption with nothing under it is not help, so neither is drawn.\n if (!detail) return nothing;\n const caption = text(this.label);\n const target = contactHref(this.kind, detail);\n const captionId = this.id_('caption');\n const detailId = this.id_('detail');\n const captionPart = caption\n ? html`<span class=\"caption\" part=\"label\" id=${captionId}>${caption}</span>`\n : nothing;\n const detailPart = target\n ? html`<a part=\"link\" href=${target} aria-labelledby=${caption ? `${captionId} ${detailId}` : nothing}\n ><span class=\"detail\" part=\"detail\" id=${detailId}>${detail}</span></a>`\n : html`<span class=\"detail\" part=\"detail\">${detail}</span>`;\n return html`<p class=\"contact\" part=\"contact\">${captionPart}${detailPart}</p>`;\n }\n}\n\n/** Trimmed text, or empty for anything that is not a string. */\nfunction text(value: unknown): string {\n return typeof value === 'string' ? value.trim() : '';\n}\n\n/**\n * The link a contact detail opens, or empty when it should stay as text.\n *\n * A phone number is reduced to its digits and one leading `+`, and the \"(0)\"\n * that UK numbers print after the country code is dropped, because the\n * separators a reader expects are not dialled. A value with no digits, or an\n * email address without an `@`, stays as plain text. The reader still sees\n * it, and nothing offers to dial or mail something that cannot work.\n */\nfunction contactHref(kind: string, detail: string): string {\n if (kind === 'phone') {\n const digits = detail.replace(/\\(0\\)/g, '').replace(/[^\\d+]/g, '').replace(/(?!^)\\+/g, '');\n return /\\d/.test(digits) ? `tel:${digits}` : '';\n }\n if (kind === 'email') return /^[^\\s@]+@[^\\s@]+$/.test(detail) ? `mailto:${detail}` : '';\n return '';\n}\n\ncustomElements.define('impkt-help', ImpktHelp);\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-help': ImpktHelp }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/help.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing } from '../base/styles';\nimport { fontWeight, t } from '../base/tokens';\n\n/**\n * What form a help mechanism takes.\n *\n * `link` goes somewhere: a help page, a contact form, a chat. The other four\n * are the \"human contact details\" that 3.2.6 Consistent Help names, shown as\n * text so a reader can see them without following anything.\n */\nexport type HelpKind = 'link' | 'phone' | 'email' | 'address' | 'hours';\n\n/**\n * A help link, or contact details shown as text.\n *\n * **Its identity is `mechanismId`, not its wording or destination.** 3.2.6\n * Consistent Help asks that help offered on several pages appears in the same\n * relative order on each. Strata checks that at publish by comparing these ids\n * across pages, so the label can be reworded and the number can change\n * without the check treating it as a different mechanism. It is literal and\n * cannot be bound, because an id that a data response could change is one the\n * check cannot compare.\n *\n * **Contact details are text, not a link to a page that has them.** The\n * criterion lists a phone number, an email address and a postal address as\n * help in their own right, and a reader who has to follow a link to find the\n * number has been given a link rather than the number. A phone number renders\n * as a `tel:` link and an email address as a `mailto:` link, each with the\n * detail itself as the visible text. The link target is derived from the\n * visible detail rather than authored separately, so the number a reader sees\n * and the number their phone dials cannot drift apart. An address or opening\n * hours render as plain text and keep the line breaks they were written with.\n *\n * **Contact links are named by their caption and their detail.** A phone\n * link's accessible name is \"Call us 0800 123 456\" rather than the bare\n * number, because a reader moving through a list of links hears each one out\n * of context (2.4.4 Link Purpose). The visible text stays inside the name, so\n * 2.5.3 Label in Name holds for a reader who speaks it.\n *\n * **Nothing unnamed or empty is ever rendered.** Runtime bindings may be\n * absent while data loads, or resolve to blank text. A link with no label, or\n * contact details with no detail, render nothing rather than a focusable link\n * with no name or a caption with nothing under it. Contact details whose\n * caption is blank still show the detail, because a phone number or an\n * address names itself. For that reason the caption is optional for contact\n * details, and publishing requires a label only on a link. Publishing does\n * require what each kind cannot do without: a link's label and address, and\n * contact details' detail, so the empty states are only reached at runtime.\n *\n * **Every link meets the minimum target size.** Links here are at least the\n * locked `target.min` token in both directions (2.5.8 Target Size), because a\n * help link usually stands on its own line, where the criterion's inline\n * exemption does not apply.\n *\n * @category action\n * @icon help\n * @role help\n */\nexport class ImpktHelp extends ImpktElement {\n static properties = {\n mechanismId: { type: String, attribute: 'mechanism-id' },\n kind: { type: String, reflect: true },\n href: { type: String },\n label: { type: String },\n detail: { type: String },\n };\n\n /** Stable identity across pages, independent of wording and destination. */\n declare mechanismId: string;\n // Written out as a union rather than as `HelpKind` so the manifest offers it\n // as a fixed choice: which form help takes is a design decision, not data.\n /** Whether this is a link to help, or contact details shown as text. */\n declare kind: 'link' | 'phone' | 'email' | 'address' | 'hours';\n /** Where a link goes. Phone and email links are built from the detail instead. */\n declare href: string;\n /**\n * The visible name. For a link it is the link text. For contact details it\n * is the caption shown above them, such as \"Call us\".\n */\n declare label: string;\n /**\n * The contact detail itself: a phone number, an email address, a postal\n * address or opening hours. Line breaks are kept. Unused by a link.\n */\n declare detail: string;\n\n constructor() {\n super();\n this.kind = 'link';\n this.href = '';\n // Defaulted, so the manifest does not mark it required: contact details\n // may leave the caption out. A link without one is refused at publish.\n this.label = '';\n this.detail = '';\n }\n\n static styles = [...ImpktElement.styles, focusRing, css`\n :host { display: block; }\n a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};\n color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }\n a:hover { color: ${t.linkHover}; }\n .contact { margin: 0; }\n .caption { display: block; font-weight: ${fontWeight('semibold')}; }\n /* An address is written one line at a time, and opening hours are often one\n day to a line. Long unbroken values still wrap at 320px (1.4.10). */\n .detail { white-space: pre-line; overflow-wrap: anywhere; }\n `];\n\n render(): TemplateResult | typeof nothing {\n switch (this.kind) {\n case 'phone':\n case 'email':\n case 'address':\n case 'hours':\n return this.renderContact();\n default:\n // An absent or unrecognised kind keeps the original link behaviour, so\n // a page published before contact details existed renders unchanged.\n return this.renderLink();\n }\n }\n\n private renderLink(): TemplateResult | typeof nothing {\n // Runtime bindings may be absent while data loads, or resolve to blank text.\n // Do not expose an unnamed focusable link in those states.\n if (!text(this.label)) return nothing;\n return html`<a part=\"link\" href=${this.href}>${this.label}</a>`;\n }\n\n private renderContact(): TemplateResult | typeof nothing {\n const detail = text(this.detail);\n // A caption with nothing under it is not help, so neither is drawn.\n if (!detail) return nothing;\n const caption = text(this.label);\n const target = contactHref(this.kind, detail);\n const captionId = this.id_('caption');\n const detailId = this.id_('detail');\n const captionPart = caption\n ? html`<span class=\"caption\" part=\"label\" id=${captionId}>${caption}</span>`\n : nothing;\n const detailPart = target\n ? html`<a part=\"link\" href=${target} aria-labelledby=${caption ? `${captionId} ${detailId}` : nothing}\n ><span class=\"detail\" part=\"detail\" id=${detailId}>${detail}</span></a>`\n : html`<span class=\"detail\" part=\"detail\">${detail}</span>`;\n return html`<p class=\"contact\" part=\"contact\">${captionPart}${detailPart}</p>`;\n }\n}\n\n/** Trimmed text, or empty for anything that is not a string. */\nfunction text(value: unknown): string {\n return typeof value === 'string' ? value.trim() : '';\n}\n\n/**\n * The link a contact detail opens, or empty when it should stay as text.\n *\n * A phone number is reduced to its digits and one leading `+`, and the \"(0)\"\n * that UK numbers print after the country code is dropped, because the\n * separators a reader expects are not dialled. A value with no digits, or an\n * email address without an `@`, stays as plain text. The reader still sees\n * it, and nothing offers to dial or mail something that cannot work.\n */\nfunction contactHref(kind: string, detail: string): string {\n if (kind === 'phone') {\n const digits = detail.replace(/\\(0\\)/g, '').replace(/[^\\d+]/g, '').replace(/(?!^)\\+/g, '');\n return /\\d/.test(digits) ? `tel:${digits}` : '';\n }\n if (kind === 'email') return /^[^\\s@]+@[^\\s@]+$/.test(detail) ? `mailto:${detail}` : '';\n return '';\n}\n\ncustomElements.define('impkt-help', ImpktHelp);\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-help': ImpktHelp }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA4DjD,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;AAAA,SAAO,aAAa;AAAA,MAClB,aAAa,EAAE,MAAM,QAAQ,WAAW,eAAe;AAAA,MACvD,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,QAAQ,EAAE,MAAM,OAAO;AAAA,IACzB;AAAA;AAAA,EAqBA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,OAAO;AAGZ,SAAK,QAAQ;AACb,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA;AAAA,SAAO,SAAS,CAAC,GAAG,aAAa,QAAQ,WAAW;AAAA;AAAA,iEAEW,EAAE,SAAS,gBAAgB,EAAE,SAAS;AAAA,eACxF,EAAE,IAAI;AAAA,uBACE,EAAE,SAAS;AAAA;AAAA,8CAEY,WAAW,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA,GAIjE;AAAA;AAAA,EAED,SAA0C;AACxC,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACH,eAAO,KAAK,cAAc;AAAA,MAC5B;AAGE,eAAO,KAAK,WAAW;AAAA,IAC3B;AAAA,EACF;AAAA,EAEQ,aAA8C;AAGpD,QAAI,CAAC,KAAK,KAAK,KAAK,EAAG,QAAO;AAC9B,WAAO,2BAA2B,KAAK,IAAI,IAAI,KAAK,KAAK;AAAA,EAC3D;AAAA,EAEQ,gBAAiD;AACvD,UAAM,SAAS,KAAK,KAAK,MAAM;AAE/B,QAAI,CAAC,OAAQ,QAAO;AACpB,UAAM,UAAU,KAAK,KAAK,KAAK;AAC/B,UAAM,SAAS,YAAY,KAAK,MAAM,MAAM;AAC5C,UAAM,YAAY,KAAK,IAAI,SAAS;AACpC,UAAM,WAAW,KAAK,IAAI,QAAQ;AAClC,UAAM,cAAc,UAChB,6CAA6C,SAAS,IAAI,OAAO,YACjE;AACJ,UAAM,aAAa,SACf,2BAA2B,MAAM,oBAAoB,UAAU,GAAG,SAAS,IAAI,QAAQ,KAAK,OAAO;AAAA,mDACxD,QAAQ,IAAI,MAAM,gBAC7D,0CAA0C,MAAM;AACpD,WAAO,yCAAyC,WAAW,GAAG,UAAU;AAAA,EAC1E;AACF;AAGA,SAAS,KAAK,OAAwB;AACpC,SAAO,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;AACpD;AAWA,SAAS,YAAY,MAAc,QAAwB;AACzD,MAAI,SAAS,SAAS;AACpB,UAAM,SAAS,OAAO,QAAQ,UAAU,EAAE,EAAE,QAAQ,WAAW,EAAE,EAAE,QAAQ,YAAY,EAAE;AACzF,WAAO,KAAK,KAAK,MAAM,IAAI,OAAO,MAAM,KAAK;AAAA,EAC/C;AACA,MAAI,SAAS,QAAS,QAAO,oBAAoB,KAAK,MAAM,IAAI,UAAU,MAAM,KAAK;AACrF,SAAO;AACT;AAEA,eAAe,OAAO,cAAc,SAAS;","names":[]}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
A,
|
|
3
2
|
ImpktElement,
|
|
4
|
-
b,
|
|
5
3
|
focusRing,
|
|
6
4
|
fontSize,
|
|
7
5
|
fontWeight,
|
|
8
|
-
i,
|
|
9
6
|
space,
|
|
10
7
|
t,
|
|
11
8
|
targetSize,
|
|
12
9
|
visuallyHidden
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
14
11
|
|
|
15
12
|
// packages/ui/src/components/button.ts
|
|
13
|
+
import { html, css, nothing } from "lit";
|
|
16
14
|
var ImpktButton = class extends ImpktElement {
|
|
17
15
|
constructor() {
|
|
18
16
|
super();
|
|
@@ -46,7 +44,7 @@ var ImpktButton = class extends ImpktElement {
|
|
|
46
44
|
this.styles = [
|
|
47
45
|
...ImpktElement.styles,
|
|
48
46
|
focusRing,
|
|
49
|
-
|
|
47
|
+
css`
|
|
50
48
|
:host {
|
|
51
49
|
display: inline-block;
|
|
52
50
|
}
|
|
@@ -135,18 +133,18 @@ var ImpktButton = class extends ImpktElement {
|
|
|
135
133
|
if (this.type === "reset") this.internals?.form?.reset();
|
|
136
134
|
}
|
|
137
135
|
render() {
|
|
138
|
-
return
|
|
136
|
+
return html`
|
|
139
137
|
<button
|
|
140
138
|
class=${this.variant}
|
|
141
139
|
type="button"
|
|
142
140
|
part="button"
|
|
143
141
|
?disabled=${this.disabled}
|
|
144
|
-
aria-disabled=${this.busy ? "true" :
|
|
145
|
-
aria-busy=${this.busy ? "true" :
|
|
142
|
+
aria-disabled=${this.busy ? "true" : nothing}
|
|
143
|
+
aria-busy=${this.busy ? "true" : nothing}
|
|
146
144
|
@click=${this.onClick}
|
|
147
145
|
>
|
|
148
146
|
<slot></slot>
|
|
149
|
-
${this.busy ?
|
|
147
|
+
${this.busy ? html`<span class="sr-only">${this.busyLabel}</span>` : nothing}
|
|
150
148
|
</button>
|
|
151
149
|
`;
|
|
152
150
|
}
|
|
@@ -156,4 +154,4 @@ customElements.define("impkt-button", ImpktButton);
|
|
|
156
154
|
export {
|
|
157
155
|
ImpktButton
|
|
158
156
|
};
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
157
|
+
//# sourceMappingURL=chunk-BBWMRF5N.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/button.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, targetSize, visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * A button.\n *\n * Two decisions carry the accessibility weight here.\n *\n * **A busy button is not a disabled button.** While an action is in flight the\n * control keeps its place in the tab order and reports `aria-disabled`, rather\n * than taking the native `disabled` attribute. A natively disabled element is\n * removed from the tab order, so a keyboard user who had just activated it\n * loses their focus position to the top of the document — at precisely the\n * moment something is happening that they need to be told about. Activation is\n * blocked in the handler instead.\n *\n * **It renders a real `<button>`.** A `<div role=\"button\">` needs Enter and\n * Space handling, a tabindex, and a disabled story, and it will still not\n * submit a form. The native element already has all of that, correctly, in\n * every browser and every assistive technology.\n\n *\n * @category action\n * @icon button\n * @slot - The button label.\n */\nexport class ImpktButton extends ImpktElement {\n static formAssociated = true;\n\n static properties = {\n variant: { type: String, reflect: true },\n type: { type: String },\n disabled: { type: Boolean, reflect: true },\n busy: { type: Boolean, reflect: true },\n busyLabel: { type: String, attribute: 'busy-label' },\n full: { type: Boolean, reflect: true },\n };\n\n declare variant: 'primary' | 'secondary' | 'ghost';\n declare type: 'button' | 'submit' | 'reset';\n declare disabled: boolean;\n declare busy: boolean;\n /** Announced when the button becomes busy. Says what is happening, not that something is. */\n declare busyLabel: string;\n declare full: boolean;\n\n private internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this.variant = 'primary';\n this.type = 'button';\n this.disabled = false;\n this.busy = false;\n this.busyLabel = 'Working';\n this.full = false;\n try {\n this.internals = this.attachInternals();\n } catch {\n this.internals = null;\n }\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: inline-block;\n }\n :host([full]) {\n display: block;\n }\n button {\n ${targetSize}\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: ${space(2)};\n inline-size: 100%;\n padding: ${space(3)} ${space(5)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n font-weight: ${fontWeight('semibold')};\n line-height: 1.2;\n border-radius: ${t.radius};\n border: ${t.borderThick} solid transparent;\n cursor: pointer;\n transition: background-color 120ms ease-in-out, border-color 120ms ease-in-out;\n }\n /* The cursor is the only thing that changes while busy. Moving or\n recolouring a control the moment it is pressed is how a user loses it. */\n button[aria-disabled='true'] {\n cursor: progress;\n }\n :host([disabled]) button {\n cursor: not-allowed;\n opacity: 0.55;\n }\n\n button.primary {\n background: ${t.brand};\n color: ${t.onBrand};\n }\n button.primary:hover:not([aria-disabled='true']) {\n background: ${t.brandHover};\n }\n button.primary:active:not([aria-disabled='true']) {\n background: ${t.brandActive};\n }\n\n button.secondary {\n background: transparent;\n color: ${t.link};\n border-color: currentColor;\n }\n button.secondary:hover:not([aria-disabled='true']) {\n background: ${t.brandSubtle};\n }\n\n button.ghost {\n background: transparent;\n color: ${t.link};\n border-color: transparent;\n text-decoration: underline;\n }\n button.ghost:hover:not([aria-disabled='true']) {\n background: ${t.brandSubtle};\n }\n\n .sr-only {\n ${visuallyHidden}\n }\n\n /* Windows High Contrast Mode drops background and border colours, so a\n button styled only by background becomes invisible. A forced-colors\n border puts the boundary back. */\n @media (forced-colors: active) {\n button {\n border-color: ButtonBorder;\n }\n }\n `,\n ];\n\n private onClick(event: MouseEvent): void {\n if (this.disabled || this.busy) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n // A shadow-rooted button does not submit the outer form by itself, because\n // the click never reaches it. `requestSubmit` rather than `submit` so that\n // native validation and the submit event both still run.\n if (this.type === 'submit') this.internals?.form?.requestSubmit();\n if (this.type === 'reset') this.internals?.form?.reset();\n }\n\n render(): TemplateResult {\n return html`\n <button\n class=${this.variant}\n type=\"button\"\n part=\"button\"\n ?disabled=${this.disabled}\n aria-disabled=${this.busy ? 'true' : nothing}\n aria-busy=${this.busy ? 'true' : nothing}\n @click=${this.onClick}\n >\n <slot></slot>\n ${this.busy ? html`<span class=\"sr-only\">${this.busyLabel}</span>` : nothing}\n </button>\n `;\n }\n}\n\ncustomElements.define('impkt-button', ImpktButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-button': ImpktButton;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/button.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, targetSize, visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * A button.\n *\n * Two decisions carry the accessibility weight here.\n *\n * **A busy button is not a disabled button.** While an action is in flight the\n * control keeps its place in the tab order and reports `aria-disabled`, rather\n * than taking the native `disabled` attribute. A natively disabled element is\n * removed from the tab order, so a keyboard user who had just activated it\n * loses their focus position to the top of the document — at precisely the\n * moment something is happening that they need to be told about. Activation is\n * blocked in the handler instead.\n *\n * **It renders a real `<button>`.** A `<div role=\"button\">` needs Enter and\n * Space handling, a tabindex, and a disabled story, and it will still not\n * submit a form. The native element already has all of that, correctly, in\n * every browser and every assistive technology.\n\n *\n * @category action\n * @icon button\n * @slot - The button label.\n */\nexport class ImpktButton extends ImpktElement {\n static formAssociated = true;\n\n static properties = {\n variant: { type: String, reflect: true },\n type: { type: String },\n disabled: { type: Boolean, reflect: true },\n busy: { type: Boolean, reflect: true },\n busyLabel: { type: String, attribute: 'busy-label' },\n full: { type: Boolean, reflect: true },\n };\n\n declare variant: 'primary' | 'secondary' | 'ghost';\n declare type: 'button' | 'submit' | 'reset';\n declare disabled: boolean;\n declare busy: boolean;\n /** Announced when the button becomes busy. Says what is happening, not that something is. */\n declare busyLabel: string;\n declare full: boolean;\n\n private internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this.variant = 'primary';\n this.type = 'button';\n this.disabled = false;\n this.busy = false;\n this.busyLabel = 'Working';\n this.full = false;\n try {\n this.internals = this.attachInternals();\n } catch {\n this.internals = null;\n }\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: inline-block;\n }\n :host([full]) {\n display: block;\n }\n button {\n ${targetSize}\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: ${space(2)};\n inline-size: 100%;\n padding: ${space(3)} ${space(5)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n font-weight: ${fontWeight('semibold')};\n line-height: 1.2;\n border-radius: ${t.radius};\n border: ${t.borderThick} solid transparent;\n cursor: pointer;\n transition: background-color 120ms ease-in-out, border-color 120ms ease-in-out;\n }\n /* The cursor is the only thing that changes while busy. Moving or\n recolouring a control the moment it is pressed is how a user loses it. */\n button[aria-disabled='true'] {\n cursor: progress;\n }\n :host([disabled]) button {\n cursor: not-allowed;\n opacity: 0.55;\n }\n\n button.primary {\n background: ${t.brand};\n color: ${t.onBrand};\n }\n button.primary:hover:not([aria-disabled='true']) {\n background: ${t.brandHover};\n }\n button.primary:active:not([aria-disabled='true']) {\n background: ${t.brandActive};\n }\n\n button.secondary {\n background: transparent;\n color: ${t.link};\n border-color: currentColor;\n }\n button.secondary:hover:not([aria-disabled='true']) {\n background: ${t.brandSubtle};\n }\n\n button.ghost {\n background: transparent;\n color: ${t.link};\n border-color: transparent;\n text-decoration: underline;\n }\n button.ghost:hover:not([aria-disabled='true']) {\n background: ${t.brandSubtle};\n }\n\n .sr-only {\n ${visuallyHidden}\n }\n\n /* Windows High Contrast Mode drops background and border colours, so a\n button styled only by background becomes invisible. A forced-colors\n border puts the boundary back. */\n @media (forced-colors: active) {\n button {\n border-color: ButtonBorder;\n }\n }\n `,\n ];\n\n private onClick(event: MouseEvent): void {\n if (this.disabled || this.busy) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n // A shadow-rooted button does not submit the outer form by itself, because\n // the click never reaches it. `requestSubmit` rather than `submit` so that\n // native validation and the submit event both still run.\n if (this.type === 'submit') this.internals?.form?.requestSubmit();\n if (this.type === 'reset') this.internals?.form?.reset();\n }\n\n render(): TemplateResult {\n return html`\n <button\n class=${this.variant}\n type=\"button\"\n part=\"button\"\n ?disabled=${this.disabled}\n aria-disabled=${this.busy ? 'true' : nothing}\n aria-busy=${this.busy ? 'true' : nothing}\n @click=${this.onClick}\n >\n <slot></slot>\n ${this.busy ? html`<span class=\"sr-only\">${this.busyLabel}</span>` : nothing}\n </button>\n `;\n }\n}\n\ncustomElements.define('impkt-button', ImpktButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-button': ImpktButton;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA4BjD,IAAM,cAAN,cAA0B,aAAa;AAAA,EAsB5C,cAAc;AACZ,UAAM;AAHR,SAAQ,YAAqC;AAI3C,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,OAAO;AACZ,QAAI;AACF,WAAK,YAAY,KAAK,gBAAgB;AAAA,IACxC,QAAQ;AACN,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA,EAlCA;AAAA,SAAO,iBAAiB;AAAA;AAAA,EAExB;AAAA,SAAO,aAAa;AAAA,MAClB,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACvC,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACzC,MAAM,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACrC,WAAW,EAAE,MAAM,QAAQ,WAAW,aAAa;AAAA,MACnD,MAAM,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,IACvC;AAAA;AAAA,EA2BA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAQM,UAAU;AAAA;AAAA;AAAA;AAAA,eAIL,MAAM,CAAC,CAAC;AAAA;AAAA,mBAEJ,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAAA;AAAA,qBAElB,SAAS,IAAI,CAAC;AAAA,uBACZ,WAAW,UAAU,CAAC;AAAA;AAAA,yBAEpB,EAAE,MAAM;AAAA,kBACf,EAAE,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAeT,EAAE,KAAK;AAAA,iBACZ,EAAE,OAAO;AAAA;AAAA;AAAA,sBAGJ,EAAE,UAAU;AAAA;AAAA;AAAA,sBAGZ,EAAE,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKlB,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA,sBAID,EAAE,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKlB,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKD,EAAE,WAAW;AAAA;AAAA;AAAA;AAAA,UAIzB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYtB;AAAA;AAAA,EAEQ,QAAQ,OAAyB;AACvC,QAAI,KAAK,YAAY,KAAK,MAAM;AAC9B,YAAM,eAAe;AACrB,YAAM,yBAAyB;AAC/B;AAAA,IACF;AAIA,QAAI,KAAK,SAAS,SAAU,MAAK,WAAW,MAAM,cAAc;AAChE,QAAI,KAAK,SAAS,QAAS,MAAK,WAAW,MAAM,MAAM;AAAA,EACzD;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA,gBAEK,KAAK,OAAO;AAAA;AAAA;AAAA,oBAGR,KAAK,QAAQ;AAAA,wBACT,KAAK,OAAO,SAAS,OAAO;AAAA,oBAChC,KAAK,OAAO,SAAS,OAAO;AAAA,iBAC/B,KAAK,OAAO;AAAA;AAAA;AAAA,UAGnB,KAAK,OAAO,6BAA6B,KAAK,SAAS,YAAY,OAAO;AAAA;AAAA;AAAA,EAGlF;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
A,
|
|
3
2
|
ImpktElement,
|
|
4
|
-
b,
|
|
5
3
|
fontSize,
|
|
6
4
|
fontWeight,
|
|
7
|
-
i,
|
|
8
5
|
space,
|
|
9
6
|
t,
|
|
10
7
|
visuallyHidden
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-J5KAMJ2N.js";
|
|
12
9
|
|
|
13
10
|
// packages/ui/src/components/progress.ts
|
|
11
|
+
import { html, css, nothing } from "lit";
|
|
14
12
|
var ImpktProgress = class extends ImpktElement {
|
|
15
13
|
static {
|
|
16
14
|
this.properties = {
|
|
@@ -28,7 +26,7 @@ var ImpktProgress = class extends ImpktElement {
|
|
|
28
26
|
static {
|
|
29
27
|
this.styles = [
|
|
30
28
|
...ImpktElement.styles,
|
|
31
|
-
|
|
29
|
+
css`
|
|
32
30
|
:host {
|
|
33
31
|
display: block;
|
|
34
32
|
margin-block-end: ${space(5)};
|
|
@@ -72,14 +70,14 @@ var ImpktProgress = class extends ImpktElement {
|
|
|
72
70
|
}
|
|
73
71
|
render() {
|
|
74
72
|
const index = this.steps.findIndex((s) => s.id === this.current);
|
|
75
|
-
return
|
|
73
|
+
return html`
|
|
76
74
|
<nav part="nav" aria-label=${this.label}>
|
|
77
75
|
<ol part="list">
|
|
78
|
-
${this.steps.map((step,
|
|
79
|
-
const state =
|
|
80
|
-
return
|
|
81
|
-
<li data-state=${state} aria-current=${state === "current" ? "step" :
|
|
82
|
-
${state === "current" ?
|
|
76
|
+
${this.steps.map((step, i) => {
|
|
77
|
+
const state = i < index ? "done" : i === index ? "current" : "todo";
|
|
78
|
+
return html`
|
|
79
|
+
<li data-state=${state} aria-current=${state === "current" ? "step" : nothing}>
|
|
80
|
+
${state === "current" ? html`<span class="sr-only">Step ${i + 1} of ${this.steps.length}: </span>` : nothing}
|
|
83
81
|
<span>${step.label}</span>
|
|
84
82
|
</li>
|
|
85
83
|
`;
|
|
@@ -94,4 +92,4 @@ customElements.define("impkt-progress", ImpktProgress);
|
|
|
94
92
|
export {
|
|
95
93
|
ImpktProgress
|
|
96
94
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-BOLZMDAS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/progress.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface ProgressStep {\n id: string;\n label: string;\n}\n\n/**\n * Where the customer is in a journey.\n *\n * **It is not a `progressbar`.** That role is for a task completing — a file\n * uploading, a price calculating — and it carries `aria-valuenow`. A journey\n * indicator is navigation: an ordered list of named steps with\n * `aria-current=\"step\"` on the one you are on. Using `progressbar` here\n * announces a percentage and loses the step names, which are the only useful\n * part.\n *\n * **The position is said in words.** \"Step 2 of 5\" is visually hidden and read\n * aloud, because the visual design communicates position through colour and a\n * filled bar, and neither is available to a screen-reader user — nor to anyone\n * who cannot distinguish the filled colour from the empty one, which is 1.4.1.\n\n *\n * @category content\n * @icon progress\n */\nexport class ImpktProgress extends ImpktElement {\n static properties = {\n steps: { type: Array },\n current: { type: String },\n label: { type: String },\n };\n\n declare steps: ProgressStep[];\n /** The id of the step being shown. */\n declare current: string;\n declare label: string;\n\n constructor() {\n super();\n this.steps = [];\n this.current = '';\n this.label = 'Progress';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n margin-block-end: ${space(5)};\n }\n ol {\n display: flex;\n gap: ${space(2)};\n list-style: none;\n margin: 0;\n padding: 0;\n }\n li {\n flex: 1;\n font-size: ${fontSize('xs')};\n color: ${t.textMuted};\n padding-block-start: ${space(2)};\n border-block-start: 4px solid ${t.border};\n }\n li[data-state='done'] {\n color: ${t.text};\n border-block-start-color: ${t.brand};\n }\n li[data-state='current'] {\n color: ${t.text};\n font-weight: ${fontWeight('semibold')};\n border-block-start-color: ${t.brand};\n }\n .sr-only {\n ${visuallyHidden}\n }\n /* Below 30rem the labels stop fitting; the position in words is the part\n that has to survive, so the list collapses to bars and the current\n step's name. */\n @media (max-width: 30rem) {\n li:not([data-state='current']) span:not(.sr-only) {\n ${visuallyHidden}\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n const index = this.steps.findIndex((s) => s.id === this.current);\n return html`\n <nav part=\"nav\" aria-label=${this.label}>\n <ol part=\"list\">\n ${this.steps.map((step, i) => {\n const state = i < index ? 'done' : i === index ? 'current' : 'todo';\n return html`\n <li data-state=${state} aria-current=${state === 'current' ? 'step' : nothing}>\n ${state === 'current'\n ? html`<span class=\"sr-only\">Step ${i + 1} of ${this.steps.length}: </span>`\n : nothing}\n <span>${step.label}</span>\n </li>\n `;\n })}\n </ol>\n </nav>\n `;\n }\n}\n\ncustomElements.define('impkt-progress', ImpktProgress);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-progress': ImpktProgress }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/progress.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface ProgressStep {\n id: string;\n label: string;\n}\n\n/**\n * Where the customer is in a journey.\n *\n * **It is not a `progressbar`.** That role is for a task completing — a file\n * uploading, a price calculating — and it carries `aria-valuenow`. A journey\n * indicator is navigation: an ordered list of named steps with\n * `aria-current=\"step\"` on the one you are on. Using `progressbar` here\n * announces a percentage and loses the step names, which are the only useful\n * part.\n *\n * **The position is said in words.** \"Step 2 of 5\" is visually hidden and read\n * aloud, because the visual design communicates position through colour and a\n * filled bar, and neither is available to a screen-reader user — nor to anyone\n * who cannot distinguish the filled colour from the empty one, which is 1.4.1.\n\n *\n * @category content\n * @icon progress\n */\nexport class ImpktProgress extends ImpktElement {\n static properties = {\n steps: { type: Array },\n current: { type: String },\n label: { type: String },\n };\n\n declare steps: ProgressStep[];\n /** The id of the step being shown. */\n declare current: string;\n declare label: string;\n\n constructor() {\n super();\n this.steps = [];\n this.current = '';\n this.label = 'Progress';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n margin-block-end: ${space(5)};\n }\n ol {\n display: flex;\n gap: ${space(2)};\n list-style: none;\n margin: 0;\n padding: 0;\n }\n li {\n flex: 1;\n font-size: ${fontSize('xs')};\n color: ${t.textMuted};\n padding-block-start: ${space(2)};\n border-block-start: 4px solid ${t.border};\n }\n li[data-state='done'] {\n color: ${t.text};\n border-block-start-color: ${t.brand};\n }\n li[data-state='current'] {\n color: ${t.text};\n font-weight: ${fontWeight('semibold')};\n border-block-start-color: ${t.brand};\n }\n .sr-only {\n ${visuallyHidden}\n }\n /* Below 30rem the labels stop fitting; the position in words is the part\n that has to survive, so the list collapses to bars and the current\n step's name. */\n @media (max-width: 30rem) {\n li:not([data-state='current']) span:not(.sr-only) {\n ${visuallyHidden}\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n const index = this.steps.findIndex((s) => s.id === this.current);\n return html`\n <nav part=\"nav\" aria-label=${this.label}>\n <ol part=\"list\">\n ${this.steps.map((step, i) => {\n const state = i < index ? 'done' : i === index ? 'current' : 'todo';\n return html`\n <li data-state=${state} aria-current=${state === 'current' ? 'step' : nothing}>\n ${state === 'current'\n ? html`<span class=\"sr-only\">Step ${i + 1} of ${this.steps.length}: </span>`\n : nothing}\n <span>${step.label}</span>\n </li>\n `;\n })}\n </ol>\n </nav>\n `;\n }\n}\n\ncustomElements.define('impkt-progress', ImpktProgress);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-progress': ImpktProgress }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA6BjD,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C;AAAA,SAAO,aAAa;AAAA,MAClB,OAAO,EAAE,MAAM,MAAM;AAAA,MACrB,SAAS,EAAE,MAAM,OAAO;AAAA,MACxB,OAAO,EAAE,MAAM,OAAO;AAAA,IACxB;AAAA;AAAA,EAOA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ,CAAC;AACd,SAAK,UAAU;AACf,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA,4BAGwB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,eAIrB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOF,SAAS,IAAI,CAAC;AAAA,iBAClB,EAAE,SAAS;AAAA,+BACG,MAAM,CAAC,CAAC;AAAA,wCACC,EAAE,MAAM;AAAA;AAAA;AAAA,iBAG/B,EAAE,IAAI;AAAA,oCACa,EAAE,KAAK;AAAA;AAAA;AAAA,iBAG1B,EAAE,IAAI;AAAA,uBACA,WAAW,UAAU,CAAC;AAAA,oCACT,EAAE,KAAK;AAAA;AAAA;AAAA,UAGjC,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAOZ,cAAc;AAAA;AAAA;AAAA;AAAA,IAIxB;AAAA;AAAA,EAEA,SAAyB;AACvB,UAAM,QAAQ,KAAK,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO;AAC/D,WAAO;AAAA,mCACwB,KAAK,KAAK;AAAA;AAAA,YAEjC,KAAK,MAAM,IAAI,CAAC,MAAM,MAAM;AAC5B,YAAM,QAAQ,IAAI,QAAQ,SAAS,MAAM,QAAQ,YAAY;AAC7D,aAAO;AAAA,+BACY,KAAK,iBAAiB,UAAU,YAAY,SAAS,OAAO;AAAA,kBACzE,UAAU,YACR,kCAAkC,IAAI,CAAC,OAAO,KAAK,MAAM,MAAM,cAC/D,OAAO;AAAA,wBACH,KAAK,KAAK;AAAA;AAAA;AAAA,IAGxB,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAIV;AACF;AAEA,eAAe,OAAO,kBAAkB,aAAa;","names":[]}
|