@atomic-ui/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -2
- package/dist/base/FieldElement.d.ts +95 -0
- package/dist/base/ImpktElement.d.ts +21 -0
- package/dist/base/styles.d.ts +42 -0
- package/dist/base/tokens.d.ts +68 -0
- package/dist/chunk-26CSJMXY.js +122 -0
- package/dist/chunk-26CSJMXY.js.map +1 -0
- package/dist/chunk-3LFXWUOU.js +86 -0
- package/dist/chunk-3LFXWUOU.js.map +1 -0
- package/dist/chunk-43V4RFK4.js +94 -0
- package/dist/chunk-43V4RFK4.js.map +1 -0
- package/dist/chunk-4P3FLJZG.js +77 -0
- package/dist/chunk-4P3FLJZG.js.map +1 -0
- package/dist/chunk-5NBYZ5UC.js +164 -0
- package/dist/chunk-5NBYZ5UC.js.map +1 -0
- package/dist/chunk-BM73FVQ4.js +153 -0
- package/dist/chunk-BM73FVQ4.js.map +1 -0
- package/dist/chunk-CNFIYRPA.js +67 -0
- package/dist/chunk-CNFIYRPA.js.map +1 -0
- package/dist/chunk-G6X62CFC.js +713 -0
- package/dist/chunk-G6X62CFC.js.map +1 -0
- package/dist/chunk-M3WQZDWU.js +138 -0
- package/dist/chunk-M3WQZDWU.js.map +1 -0
- package/dist/chunk-O72RTRIJ.js +132 -0
- package/dist/chunk-O72RTRIJ.js.map +1 -0
- package/dist/chunk-OZNQ4GAR.js +159 -0
- package/dist/chunk-OZNQ4GAR.js.map +1 -0
- package/dist/chunk-PV4GMCP6.js +90 -0
- package/dist/chunk-PV4GMCP6.js.map +1 -0
- package/dist/chunk-QAKFGIOO.js +104 -0
- package/dist/chunk-QAKFGIOO.js.map +1 -0
- package/dist/chunk-RYJQKKJ4.js +133 -0
- package/dist/chunk-RYJQKKJ4.js.map +1 -0
- package/dist/chunk-SHGQMQXS.js +97 -0
- package/dist/chunk-SHGQMQXS.js.map +1 -0
- package/dist/chunk-TWCXYY4Z.js +83 -0
- package/dist/chunk-TWCXYY4Z.js.map +1 -0
- package/dist/chunk-UTL446G6.js +107 -0
- package/dist/chunk-UTL446G6.js.map +1 -0
- package/dist/chunk-VF6PNIPS.js +164 -0
- package/dist/chunk-VF6PNIPS.js.map +1 -0
- package/dist/chunk-VKQGLSDT.js +124 -0
- package/dist/chunk-VKQGLSDT.js.map +1 -0
- package/dist/chunk-WAB4TRB2.js +141 -0
- package/dist/chunk-WAB4TRB2.js.map +1 -0
- package/dist/chunk-WC5KO6KZ.js +44 -0
- package/dist/chunk-WC5KO6KZ.js.map +1 -0
- package/dist/chunk-YXHT3ZJU.js +81 -0
- package/dist/chunk-YXHT3ZJU.js.map +1 -0
- package/dist/components/accordion.d.ts +66 -0
- package/dist/components/accordion.js +8 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +49 -0
- package/dist/components/alert.js +8 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/button.d.ts +70 -0
- package/dist/components/button.js +8 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox-group.d.ts +79 -0
- package/dist/components/checkbox-group.js +9 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +64 -0
- package/dist/components/checkbox.js +9 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/date-input.d.ts +95 -0
- package/dist/components/date-input.js +9 -0
- package/dist/components/date-input.js.map +1 -0
- package/dist/components/dialog.d.ts +61 -0
- package/dist/components/dialog.js +8 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/grid.d.ts +34 -0
- package/dist/components/grid.js +8 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/help.d.ts +103 -0
- package/dist/components/help.js +8 -0
- package/dist/components/help.js.map +1 -0
- package/dist/components/layout.d.ts +100 -0
- package/dist/components/layout.js +14 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/link.d.ts +46 -0
- package/dist/components/link.js +8 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/media.d.ts +164 -0
- package/dist/components/media.js +12 -0
- package/dist/components/media.js.map +1 -0
- package/dist/components/price.d.ts +67 -0
- package/dist/components/price.js +8 -0
- package/dist/components/price.js.map +1 -0
- package/dist/components/progress.d.ts +50 -0
- package/dist/components/progress.js +8 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +82 -0
- package/dist/components/radio-group.js +9 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/select.d.ts +74 -0
- package/dist/components/select.js +9 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/summary-list.d.ts +47 -0
- package/dist/components/summary-list.js +8 -0
- package/dist/components/summary-list.js.map +1 -0
- package/dist/components/table.d.ts +49 -0
- package/dist/components/table.js +8 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/text-input.d.ts +80 -0
- package/dist/components/text-input.js +9 -0
- package/dist/components/text-input.js.map +1 -0
- package/dist/components/textarea.d.ts +59 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldElement
|
|
3
|
+
} from "./chunk-5NBYZ5UC.js";
|
|
4
|
+
import {
|
|
5
|
+
A,
|
|
6
|
+
b,
|
|
7
|
+
fontSize,
|
|
8
|
+
i,
|
|
9
|
+
space,
|
|
10
|
+
t
|
|
11
|
+
} from "./chunk-G6X62CFC.js";
|
|
12
|
+
|
|
13
|
+
// packages/ui/src/components/text-input.ts
|
|
14
|
+
var ImpktTextInput = class extends FieldElement {
|
|
15
|
+
static {
|
|
16
|
+
this.properties = {
|
|
17
|
+
...FieldElement.properties,
|
|
18
|
+
type: { type: String },
|
|
19
|
+
placeholder: { type: String },
|
|
20
|
+
autocomplete: { type: String },
|
|
21
|
+
inputmode: { type: String },
|
|
22
|
+
maxlength: { type: Number }
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.type = "text";
|
|
28
|
+
this.placeholder = "";
|
|
29
|
+
this.autocomplete = "";
|
|
30
|
+
this.inputmode = "";
|
|
31
|
+
this.maxlength = void 0;
|
|
32
|
+
}
|
|
33
|
+
static {
|
|
34
|
+
this.styles = [
|
|
35
|
+
...FieldElement.styles,
|
|
36
|
+
i`
|
|
37
|
+
input {
|
|
38
|
+
inline-size: 100%;
|
|
39
|
+
min-block-size: 44px;
|
|
40
|
+
padding: ${space(3)};
|
|
41
|
+
font-family: inherit;
|
|
42
|
+
font-size: ${fontSize("md")};
|
|
43
|
+
color: ${t.text};
|
|
44
|
+
background: ${t.surfaceCard};
|
|
45
|
+
border: ${t.borderThin} solid ${t.border};
|
|
46
|
+
border-radius: ${t.radius};
|
|
47
|
+
}
|
|
48
|
+
input::placeholder {
|
|
49
|
+
color: ${t.textPlaceholder};
|
|
50
|
+
}
|
|
51
|
+
input:disabled {
|
|
52
|
+
background: ${t.surfaceInset};
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
}
|
|
55
|
+
/* The border thickens as well as reddening. Colour alone would carry the
|
|
56
|
+
error, which 1.4.1 forbids — and the message below says it in words. */
|
|
57
|
+
:host([invalid]) input {
|
|
58
|
+
border-color: ${t.danger};
|
|
59
|
+
border-width: ${t.borderThick};
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
renderControl() {
|
|
65
|
+
return b`
|
|
66
|
+
<input
|
|
67
|
+
id=${this.controlId}
|
|
68
|
+
part="input"
|
|
69
|
+
type=${this.type}
|
|
70
|
+
name=${this.name || A}
|
|
71
|
+
.value=${this.value}
|
|
72
|
+
placeholder=${this.placeholder || A}
|
|
73
|
+
autocomplete=${this.autocomplete || A}
|
|
74
|
+
inputmode=${this.inputmode || A}
|
|
75
|
+
maxlength=${this.maxlength ?? A}
|
|
76
|
+
?disabled=${this.disabled}
|
|
77
|
+
?readonly=${this.readonly}
|
|
78
|
+
?required=${this.required}
|
|
79
|
+
aria-describedby=${this.describedBy}
|
|
80
|
+
aria-invalid=${this.error ? "true" : A}
|
|
81
|
+
@input=${(e) => this.setFormValue(e.target.value)}
|
|
82
|
+
/>
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
updated(changed) {
|
|
86
|
+
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
customElements.define("impkt-text-input", ImpktTextInput);
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
ImpktTextInput
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-43V4RFK4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/text-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 single-line text field.\n *\n * `inputmode` and `autocomplete` are first-class properties rather than\n * afterthoughts. 1.3.5 Identify Input Purpose is a Level AA criterion that\n * autofill satisfies directly, and it is the single cheapest accessibility win\n * in a checkout journey — a form that fills itself is a form that someone with a\n * motor impairment can actually finish.\n\n *\n * @category form\n * @icon field\n */\nexport class ImpktTextInput extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n type: { type: String },\n placeholder: { type: String },\n autocomplete: { type: String },\n inputmode: { type: String },\n maxlength: { type: Number },\n };\n\n declare type: 'text' | 'email' | 'tel' | 'number' | 'password' | 'date';\n declare placeholder: string;\n /** A token from the HTML autofill list — `given-name`, `postal-code`, `tel`. */\n declare autocomplete: string;\n declare inputmode: string;\n declare maxlength: number | undefined;\n\n constructor() {\n super();\n this.type = 'text';\n this.placeholder = '';\n this.autocomplete = '';\n this.inputmode = '';\n this.maxlength = undefined;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n input {\n inline-size: 100%;\n min-block-size: 44px;\n padding: ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: ${t.surfaceCard};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radius};\n }\n input::placeholder {\n color: ${t.textPlaceholder};\n }\n input:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n /* The border thickens as well as reddening. Colour alone would carry the\n error, which 1.4.1 forbids — and the message below says it in words. */\n :host([invalid]) input {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <input\n id=${this.controlId}\n part=\"input\"\n type=${this.type}\n name=${this.name || nothing}\n .value=${this.value}\n placeholder=${this.placeholder || nothing}\n autocomplete=${this.autocomplete || nothing}\n inputmode=${this.inputmode || nothing}\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 HTMLInputElement).value)}\n />\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-text-input', ImpktTextInput);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-text-input': ImpktTextInput;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAiBO,IAAM,iBAAN,cAA6B,aAAa;AAAA,EAC/C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,aAAa,EAAE,MAAM,OAAO;AAAA,MAC5B,cAAc,EAAE,MAAM,OAAO;AAAA,MAC7B,WAAW,EAAE,MAAM,OAAO;AAAA,MAC1B,WAAW,EAAE,MAAM,OAAO;AAAA,IAC5B;AAAA;AAAA,EASA,cAAc;AACZ,UAAM;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}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldElement
|
|
3
|
+
} from "./chunk-5NBYZ5UC.js";
|
|
4
|
+
import {
|
|
5
|
+
A,
|
|
6
|
+
b,
|
|
7
|
+
fontSize,
|
|
8
|
+
i,
|
|
9
|
+
space,
|
|
10
|
+
t
|
|
11
|
+
} from "./chunk-G6X62CFC.js";
|
|
12
|
+
|
|
13
|
+
// packages/ui/src/components/textarea.ts
|
|
14
|
+
var ImpktTextarea = class extends FieldElement {
|
|
15
|
+
static {
|
|
16
|
+
this.properties = {
|
|
17
|
+
...FieldElement.properties,
|
|
18
|
+
rows: { type: Number },
|
|
19
|
+
maxlength: { type: Number }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.rows = 4;
|
|
25
|
+
this.maxlength = void 0;
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
this.styles = [
|
|
29
|
+
...FieldElement.styles,
|
|
30
|
+
i`
|
|
31
|
+
textarea {
|
|
32
|
+
inline-size: 100%;
|
|
33
|
+
padding: ${space(3)};
|
|
34
|
+
font-family: inherit;
|
|
35
|
+
font-size: ${fontSize("md")};
|
|
36
|
+
color: ${t.text};
|
|
37
|
+
background: ${t.surfaceCard};
|
|
38
|
+
border: ${t.borderThin} solid ${t.border};
|
|
39
|
+
border-radius: ${t.radius};
|
|
40
|
+
/* Resizing is left on deliberately. 1.4.4 and 1.4.12 both assume text
|
|
41
|
+
can be made bigger, and a fixed box is where that stops working. */
|
|
42
|
+
resize: vertical;
|
|
43
|
+
}
|
|
44
|
+
:host([invalid]) textarea {
|
|
45
|
+
border-color: ${t.danger};
|
|
46
|
+
border-width: ${t.borderThick};
|
|
47
|
+
}
|
|
48
|
+
`
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
renderControl() {
|
|
52
|
+
return b`
|
|
53
|
+
<textarea
|
|
54
|
+
id=${this.controlId}
|
|
55
|
+
part="textarea"
|
|
56
|
+
name=${this.name || A}
|
|
57
|
+
rows=${this.rows}
|
|
58
|
+
maxlength=${this.maxlength ?? A}
|
|
59
|
+
?disabled=${this.disabled}
|
|
60
|
+
?readonly=${this.readonly}
|
|
61
|
+
?required=${this.required}
|
|
62
|
+
aria-describedby=${this.describedBy}
|
|
63
|
+
aria-invalid=${this.error ? "true" : A}
|
|
64
|
+
@input=${(e) => this.setFormValue(e.target.value)}
|
|
65
|
+
>${this.value}</textarea>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
updated(changed) {
|
|
69
|
+
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
customElements.define("impkt-textarea", ImpktTextarea);
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
ImpktTextarea
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=chunk-4P3FLJZG.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;AASO,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,CAAO;AAAA,eACpB,KAAK,IAAI;AAAA,oBACJ,KAAK,aAAa,CAAO;AAAA,oBACzB,KAAK,QAAQ;AAAA,oBACb,KAAK,QAAQ;AAAA,oBACb,KAAK,QAAQ;AAAA,2BACN,KAAK,WAAW;AAAA,uBACpB,KAAK,QAAQ,SAAS,CAAO;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":[]}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
ImpktElement,
|
|
4
|
+
b,
|
|
5
|
+
focusRing,
|
|
6
|
+
fontSize,
|
|
7
|
+
fontWeight,
|
|
8
|
+
i,
|
|
9
|
+
lineHeight,
|
|
10
|
+
space,
|
|
11
|
+
t,
|
|
12
|
+
visuallyHidden
|
|
13
|
+
} from "./chunk-G6X62CFC.js";
|
|
14
|
+
|
|
15
|
+
// packages/ui/src/base/FieldElement.ts
|
|
16
|
+
var FieldElement = class extends ImpktElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.internals = null;
|
|
20
|
+
this.label = "";
|
|
21
|
+
this.name = "";
|
|
22
|
+
this.value = "";
|
|
23
|
+
this.description = "";
|
|
24
|
+
this.error = "";
|
|
25
|
+
this.required = false;
|
|
26
|
+
this.disabled = false;
|
|
27
|
+
this.readonly = false;
|
|
28
|
+
this.requiredText = "required";
|
|
29
|
+
try {
|
|
30
|
+
this.internals = this.attachInternals();
|
|
31
|
+
} catch {
|
|
32
|
+
this.internals = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static {
|
|
36
|
+
/** Form controls participate in a `<form>` like native ones. */
|
|
37
|
+
this.formAssociated = true;
|
|
38
|
+
}
|
|
39
|
+
static {
|
|
40
|
+
this.properties = {
|
|
41
|
+
label: { type: String },
|
|
42
|
+
name: { type: String },
|
|
43
|
+
value: { type: String },
|
|
44
|
+
description: { type: String },
|
|
45
|
+
error: { type: String },
|
|
46
|
+
required: { type: Boolean, reflect: true },
|
|
47
|
+
disabled: { type: Boolean, reflect: true },
|
|
48
|
+
readonly: { type: Boolean, reflect: true },
|
|
49
|
+
requiredText: { type: String, attribute: "required-text" }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static {
|
|
53
|
+
this.styles = [
|
|
54
|
+
...ImpktElement.styles,
|
|
55
|
+
focusRing,
|
|
56
|
+
i`
|
|
57
|
+
:host {
|
|
58
|
+
display: block;
|
|
59
|
+
margin-block-end: ${space(4)};
|
|
60
|
+
}
|
|
61
|
+
.label {
|
|
62
|
+
display: block;
|
|
63
|
+
font-size: ${fontSize("sm")};
|
|
64
|
+
font-weight: ${fontWeight("semibold")};
|
|
65
|
+
line-height: ${lineHeight("normal")};
|
|
66
|
+
margin-block-end: ${space(1)};
|
|
67
|
+
color: ${t.text};
|
|
68
|
+
}
|
|
69
|
+
.required {
|
|
70
|
+
font-weight: ${fontWeight("regular")};
|
|
71
|
+
color: ${t.textMuted};
|
|
72
|
+
}
|
|
73
|
+
.description {
|
|
74
|
+
font-size: ${fontSize("sm")};
|
|
75
|
+
line-height: ${lineHeight("normal")};
|
|
76
|
+
color: ${t.textMuted};
|
|
77
|
+
margin-block-end: ${space(2)};
|
|
78
|
+
}
|
|
79
|
+
.error {
|
|
80
|
+
font-size: ${fontSize("sm")};
|
|
81
|
+
line-height: ${lineHeight("normal")};
|
|
82
|
+
color: ${t.dangerText};
|
|
83
|
+
margin-block-start: ${space(1)};
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: ${space(1)};
|
|
86
|
+
}
|
|
87
|
+
.error:empty {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
.visually-hidden {
|
|
91
|
+
${visuallyHidden}
|
|
92
|
+
}
|
|
93
|
+
:host([disabled]) {
|
|
94
|
+
opacity: 0.6;
|
|
95
|
+
}
|
|
96
|
+
`
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
get controlId() {
|
|
100
|
+
return this.id_("control");
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What the control points `aria-describedby` at.
|
|
104
|
+
*
|
|
105
|
+
* The error id is included only while there is an error. A describedby that
|
|
106
|
+
* always names an empty element trains a screen-reader user to expect
|
|
107
|
+
* nothing after the description, and then the one time it matters they have
|
|
108
|
+
* already learned to ignore it.
|
|
109
|
+
*/
|
|
110
|
+
get describedBy() {
|
|
111
|
+
const ids = [
|
|
112
|
+
this.description ? this.id_("description") : "",
|
|
113
|
+
this.error ? this.id_("error") : ""
|
|
114
|
+
].filter(Boolean);
|
|
115
|
+
return ids.length ? ids.join(" ") : A;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* `<label for>` by default. A group of controls — radios, checkboxes —
|
|
119
|
+
* cannot use one, because `for` names a single control, so those override
|
|
120
|
+
* this and render a `<fieldset>` and `<legend>` instead.
|
|
121
|
+
*/
|
|
122
|
+
renderLabel() {
|
|
123
|
+
return b`
|
|
124
|
+
<label class="label" for=${this.controlId} part="label">
|
|
125
|
+
${this.label}${this.required ? b`<span class="required"> (${this.requiredText})</span>` : A}
|
|
126
|
+
</label>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
render() {
|
|
130
|
+
return b`
|
|
131
|
+
${this.renderLabel()}
|
|
132
|
+
${this.description ? b`<div class="description" id=${this.id_("description")} part="description">
|
|
133
|
+
${this.description}
|
|
134
|
+
</div>` : A}
|
|
135
|
+
${this.renderControl()}
|
|
136
|
+
<!--
|
|
137
|
+
The error region is always present, even when empty. A live region
|
|
138
|
+
inserted at the same moment as its content is announced unreliably
|
|
139
|
+
across screen readers; one that already exists and is then filled is
|
|
140
|
+
announced consistently. "polite" rather than "assertive" because a
|
|
141
|
+
validation message should not interrupt what is being read.
|
|
142
|
+
-->
|
|
143
|
+
<div
|
|
144
|
+
class="error"
|
|
145
|
+
id=${this.id_("error")}
|
|
146
|
+
part="error"
|
|
147
|
+
aria-live="polite"
|
|
148
|
+
>
|
|
149
|
+
${this.error || A}
|
|
150
|
+
</div>
|
|
151
|
+
`;
|
|
152
|
+
}
|
|
153
|
+
/** Keep the form value in step with the control. */
|
|
154
|
+
setFormValue(value) {
|
|
155
|
+
this.value = value;
|
|
156
|
+
this.internals?.setFormValue(value);
|
|
157
|
+
this.dispatchEvent(new CustomEvent("impkt-change", { detail: { value }, bubbles: true, composed: true }));
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
FieldElement
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=chunk-5NBYZ5UC.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;AAoBO,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;A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
1
|
+
import {
|
|
2
|
+
ImpktElement,
|
|
3
|
+
b,
|
|
4
|
+
fontSize,
|
|
5
|
+
fontWeight,
|
|
6
|
+
i,
|
|
7
|
+
lineHeight,
|
|
8
|
+
space,
|
|
9
|
+
t
|
|
10
|
+
} from "./chunk-G6X62CFC.js";
|
|
11
|
+
|
|
12
|
+
// packages/ui/src/components/layout.ts
|
|
13
|
+
var ImpktStack = class extends ImpktElement {
|
|
14
|
+
static {
|
|
15
|
+
this.properties = { gap: { type: String, reflect: true } };
|
|
16
|
+
}
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.gap = "md";
|
|
20
|
+
}
|
|
21
|
+
static {
|
|
22
|
+
this.styles = [
|
|
23
|
+
...ImpktElement.styles,
|
|
24
|
+
i`
|
|
25
|
+
:host {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
}
|
|
29
|
+
:host([gap='xs']) { gap: ${space(1)}; }
|
|
30
|
+
:host([gap='sm']) { gap: ${space(2)}; }
|
|
31
|
+
:host([gap='md']) { gap: ${space(4)}; }
|
|
32
|
+
:host([gap='lg']) { gap: ${space(6)}; }
|
|
33
|
+
:host([gap='xl']) { gap: ${space(8)}; }
|
|
34
|
+
`
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
return b`<slot></slot>`;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var ImpktCard = class extends ImpktElement {
|
|
42
|
+
static {
|
|
43
|
+
this.styles = [
|
|
44
|
+
...ImpktElement.styles,
|
|
45
|
+
i`
|
|
46
|
+
:host {
|
|
47
|
+
display: block;
|
|
48
|
+
background: ${t.surfaceCard};
|
|
49
|
+
border: ${t.borderThin} solid ${t.border};
|
|
50
|
+
border-radius: ${t.radiusLg};
|
|
51
|
+
padding: ${space(6)};
|
|
52
|
+
}
|
|
53
|
+
`
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
return b`<slot></slot>`;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var ImpktHeading = class extends ImpktElement {
|
|
61
|
+
static {
|
|
62
|
+
this.properties = {
|
|
63
|
+
level: { type: Number, reflect: true },
|
|
64
|
+
size: { type: String, reflect: true }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
constructor() {
|
|
68
|
+
super();
|
|
69
|
+
this.level = 2;
|
|
70
|
+
this.size = "xl";
|
|
71
|
+
}
|
|
72
|
+
static {
|
|
73
|
+
this.styles = [
|
|
74
|
+
...ImpktElement.styles,
|
|
75
|
+
i`
|
|
76
|
+
:host {
|
|
77
|
+
display: block;
|
|
78
|
+
color: ${t.textHeading};
|
|
79
|
+
font-family: ${t.fontHeading};
|
|
80
|
+
font-weight: ${fontWeight("bold")};
|
|
81
|
+
line-height: ${lineHeight("tight")};
|
|
82
|
+
}
|
|
83
|
+
:host([size='3xl']) { font-size: ${fontSize("3xl")}; }
|
|
84
|
+
:host([size='2xl']) { font-size: ${fontSize("2xl")}; }
|
|
85
|
+
:host([size='xl']) { font-size: ${fontSize("xl")}; }
|
|
86
|
+
:host([size='lg']) { font-size: ${fontSize("lg")}; }
|
|
87
|
+
:host([size='md']) { font-size: ${fontSize("md")}; }
|
|
88
|
+
.h {
|
|
89
|
+
margin: 0;
|
|
90
|
+
font: inherit;
|
|
91
|
+
color: inherit;
|
|
92
|
+
}
|
|
93
|
+
`
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
return b`<div class="h" role="heading" aria-level=${this.level} part="heading">
|
|
98
|
+
<slot></slot>
|
|
99
|
+
</div>`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var ImpktText = class extends ImpktElement {
|
|
103
|
+
static {
|
|
104
|
+
this.properties = {
|
|
105
|
+
size: { type: String, reflect: true },
|
|
106
|
+
tone: { type: String, reflect: true }
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
constructor() {
|
|
110
|
+
super();
|
|
111
|
+
this.size = "md";
|
|
112
|
+
this.tone = "default";
|
|
113
|
+
}
|
|
114
|
+
static {
|
|
115
|
+
this.styles = [
|
|
116
|
+
...ImpktElement.styles,
|
|
117
|
+
i`
|
|
118
|
+
:host {
|
|
119
|
+
display: block;
|
|
120
|
+
/* 1.4.8 asks for 1.5 within a paragraph, and it is the default here
|
|
121
|
+
rather than an option, because body text is what it is about. */
|
|
122
|
+
line-height: ${lineHeight("normal")};
|
|
123
|
+
/* 1.4.12 Text Spacing: a user stylesheet must be able to widen this
|
|
124
|
+
without clipping, which a max-width in ch units survives and a
|
|
125
|
+
fixed pixel height does not. */
|
|
126
|
+
max-inline-size: 70ch;
|
|
127
|
+
}
|
|
128
|
+
:host([size='sm']) { font-size: ${fontSize("sm")}; }
|
|
129
|
+
:host([size='md']) { font-size: ${fontSize("md")}; }
|
|
130
|
+
:host([size='lg']) { font-size: ${fontSize("lg")}; }
|
|
131
|
+
:host([tone='muted']) { color: ${t.textMuted}; }
|
|
132
|
+
p {
|
|
133
|
+
margin: 0;
|
|
134
|
+
}
|
|
135
|
+
`
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
render() {
|
|
139
|
+
return b`<p part="text"><slot></slot></p>`;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
customElements.define("impkt-stack", ImpktStack);
|
|
143
|
+
customElements.define("impkt-card", ImpktCard);
|
|
144
|
+
customElements.define("impkt-heading", ImpktHeading);
|
|
145
|
+
customElements.define("impkt-text", ImpktText);
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
ImpktStack,
|
|
149
|
+
ImpktCard,
|
|
150
|
+
ImpktHeading,
|
|
151
|
+
ImpktText
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=chunk-BM73FVQ4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/layout.ts"],"sourcesContent":["import { html, css, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { fontSize, fontWeight, lineHeight, space, t } from '../base/tokens';\n\n/**\n * Layout and typography primitives.\n *\n * These are the components a composition is mostly made of, and they are\n * deliberately dull. Their one job is that spacing, type and colour come from\n * tokens, so that a page built in the CMS cannot contain a hard-coded 13px.\n */\n\n/** Vertical rhythm. Every gap is a spacing token, never a number.\n *\n * @category layout\n * @icon stack\n * @slot - The things being stacked.\n */\nexport class ImpktStack extends ImpktElement {\n static properties = { gap: { type: String, reflect: true } };\n declare gap: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n constructor() {\n super();\n this.gap = 'md';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n }\n :host([gap='xs']) { gap: ${space(1)}; }\n :host([gap='sm']) { gap: ${space(2)}; }\n :host([gap='md']) { gap: ${space(4)}; }\n :host([gap='lg']) { gap: ${space(6)}; }\n :host([gap='xl']) { gap: ${space(8)}; }\n `,\n ];\n\n render(): TemplateResult {\n return html`<slot></slot>`;\n }\n}\n\n/** A surface. What text is read against, and what contrast is measured from.\n *\n * @category layout\n * @icon card\n * @slot - What sits on the card.\n */\nexport class ImpktCard extends ImpktElement {\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n background: ${t.surfaceCard};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n padding: ${space(6)};\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`<slot></slot>`;\n }\n}\n\n/**\n * A heading.\n *\n * `level` is required and renders the matching `<h1>`–`<h6>`, because heading\n * level is document structure rather than appearance: a screen-reader user\n * navigates by it, and a page whose levels skip is a page they cannot skim.\n * Size is a separate property, so a visually small `<h2>` needs no lie about\n * its level — which is the usual reason levels end up wrong.\n\n *\n * @category typography\n * @icon heading\n * @role heading\n * @slot - The heading text.\n */\nexport class ImpktHeading extends ImpktElement {\n static properties = {\n level: { type: Number, reflect: true },\n size: { type: String, reflect: true },\n };\n\n declare level: 1 | 2 | 3 | 4 | 5 | 6;\n declare size: '3xl' | '2xl' | 'xl' | 'lg' | 'md';\n\n constructor() {\n super();\n this.level = 2;\n this.size = 'xl';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n color: ${t.textHeading};\n font-family: ${t.fontHeading};\n font-weight: ${fontWeight('bold')};\n line-height: ${lineHeight('tight')};\n }\n :host([size='3xl']) { font-size: ${fontSize('3xl')}; }\n :host([size='2xl']) { font-size: ${fontSize('2xl')}; }\n :host([size='xl']) { font-size: ${fontSize('xl')}; }\n :host([size='lg']) { font-size: ${fontSize('lg')}; }\n :host([size='md']) { font-size: ${fontSize('md')}; }\n .h {\n margin: 0;\n font: inherit;\n color: inherit;\n }\n `,\n ];\n\n render(): TemplateResult {\n // A `role=\"heading\"` with `aria-level` rather than six branches of\n // template. The native element would be marginally better; this is the one\n // place where Lit's lack of a dynamic tag makes the explicit role the\n // honest trade, and the role is fully supported.\n return html`<div class=\"h\" role=\"heading\" aria-level=${this.level} part=\"heading\">\n <slot></slot>\n </div>`;\n }\n}\n\n/** A paragraph.\n *\n * @category typography\n * @icon text\n * @slot - The paragraph text.\n */\nexport class ImpktText extends ImpktElement {\n static properties = {\n size: { type: String, reflect: true },\n tone: { type: String, reflect: true },\n };\n\n declare size: 'sm' | 'md' | 'lg';\n declare tone: 'default' | 'muted';\n\n constructor() {\n super();\n this.size = 'md';\n this.tone = 'default';\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n /* 1.4.8 asks for 1.5 within a paragraph, and it is the default here\n rather than an option, because body text is what it is about. */\n line-height: ${lineHeight('normal')};\n /* 1.4.12 Text Spacing: a user stylesheet must be able to widen this\n without clipping, which a max-width in ch units survives and a\n fixed pixel height does not. */\n max-inline-size: 70ch;\n }\n :host([size='sm']) { font-size: ${fontSize('sm')}; }\n :host([size='md']) { font-size: ${fontSize('md')}; }\n :host([size='lg']) { font-size: ${fontSize('lg')}; }\n :host([tone='muted']) { color: ${t.textMuted}; }\n p {\n margin: 0;\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`<p part=\"text\"><slot></slot></p>`;\n }\n}\n\ncustomElements.define('impkt-stack', ImpktStack);\ncustomElements.define('impkt-card', ImpktCard);\ncustomElements.define('impkt-heading', ImpktHeading);\ncustomElements.define('impkt-text', ImpktText);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-stack': ImpktStack;\n 'impkt-card': ImpktCard;\n 'impkt-heading': ImpktHeading;\n 'impkt-text': ImpktText;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBO,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C;AAAA,SAAO,aAAa,EAAE,KAAK,EAAE,MAAM,QAAQ,SAAS,KAAK,EAAE;AAAA;AAAA,EAG3D,cAAc;AACZ,UAAM;AACN,SAAK,MAAM;AAAA,EACb;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA;AAAA,iCAK6B,MAAM,CAAC,CAAC;AAAA,iCACR,MAAM,CAAC,CAAC;AAAA,iCACR,MAAM,CAAC,CAAC;AAAA,iCACR,MAAM,CAAC,CAAC;AAAA,iCACR,MAAM,CAAC,CAAC;AAAA;AAAA,IAEvC;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,EACT;AACF;AAQO,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA,sBAGkB,EAAE,WAAW;AAAA,kBACjB,EAAE,UAAU,UAAU,EAAE,MAAM;AAAA,yBACvB,EAAE,QAAQ;AAAA,mBAChB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA,IAGzB;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,EACT;AACF;AAiBO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C;AAAA,SAA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AAA,IAKhD;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,EACT;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;AAC/C,eAAe,OAAO,cAAc,SAAS;AAC7C,eAAe,OAAO,iBAAiB,YAAY;AACnD,eAAe,OAAO,cAAc,SAAS;","names":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
ImpktElement,
|
|
4
|
+
b,
|
|
5
|
+
focusRing,
|
|
6
|
+
i,
|
|
7
|
+
t,
|
|
8
|
+
visuallyHidden
|
|
9
|
+
} from "./chunk-G6X62CFC.js";
|
|
10
|
+
|
|
11
|
+
// packages/ui/src/components/link.ts
|
|
12
|
+
var ImpktLink = class extends ImpktElement {
|
|
13
|
+
static {
|
|
14
|
+
this.properties = {
|
|
15
|
+
href: { type: String },
|
|
16
|
+
external: { type: Boolean, reflect: true },
|
|
17
|
+
externalText: { type: String, attribute: "external-text" }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this.href = "";
|
|
23
|
+
this.external = false;
|
|
24
|
+
this.externalText = "opens in a new tab";
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.styles = [
|
|
28
|
+
...ImpktElement.styles,
|
|
29
|
+
focusRing,
|
|
30
|
+
i`
|
|
31
|
+
:host {
|
|
32
|
+
display: inline;
|
|
33
|
+
}
|
|
34
|
+
a {
|
|
35
|
+
color: ${t.link};
|
|
36
|
+
text-decoration: underline;
|
|
37
|
+
text-underline-offset: 0.2em;
|
|
38
|
+
border-radius: ${t.radiusSm};
|
|
39
|
+
}
|
|
40
|
+
a:hover {
|
|
41
|
+
color: ${t.linkHover};
|
|
42
|
+
}
|
|
43
|
+
.sr-only {
|
|
44
|
+
${visuallyHidden}
|
|
45
|
+
}
|
|
46
|
+
`
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
return b`
|
|
51
|
+
<a
|
|
52
|
+
part="link"
|
|
53
|
+
href=${this.href || A}
|
|
54
|
+
target=${this.external ? "_blank" : A}
|
|
55
|
+
rel=${this.external ? "noopener noreferrer" : A}
|
|
56
|
+
>
|
|
57
|
+
<slot></slot>${this.external ? b`<span class="sr-only"> (${this.externalText})</span>` : A}
|
|
58
|
+
</a>
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
customElements.define("impkt-link", ImpktLink);
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
ImpktLink
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=chunk-CNFIYRPA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/link.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, visuallyHidden } from '../base/styles';\nimport { t } from '../base/tokens';\n\n/**\n * A link.\n *\n * **A new tab is always announced.** When `external` is set, the accessible\n * name gains \"opens in a new tab\" — not as a tooltip, which no screen reader\n * reads, and not as an icon alone, which carries no text. An unannounced new\n * tab breaks the back button for someone who cannot see that the window\n * changed, and that is what 3.2.5 is about.\n *\n * **It is underlined.** 1.4.1 Use of Colour: a link distinguished from body\n * text only by being a different colour is not distinguished at all for a\n * reader who cannot tell the two colours apart.\n\n *\n * @category action\n * @icon link\n * @slot - The link text.\n */\nexport class ImpktLink extends ImpktElement {\n static properties = {\n href: { type: String },\n external: { type: Boolean, reflect: true },\n externalText: { type: String, attribute: 'external-text' },\n };\n\n declare href: string;\n declare external: boolean;\n declare externalText: string;\n\n constructor() {\n super();\n this.href = '';\n this.external = false;\n this.externalText = 'opens in a new tab';\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: inline;\n }\n a {\n color: ${t.link};\n text-decoration: underline;\n text-underline-offset: 0.2em;\n border-radius: ${t.radiusSm};\n }\n a:hover {\n color: ${t.linkHover};\n }\n .sr-only {\n ${visuallyHidden}\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <a\n part=\"link\"\n href=${this.href || nothing}\n target=${this.external ? '_blank' : nothing}\n rel=${this.external ? 'noopener noreferrer' : nothing}\n >\n <slot></slot>${this.external ? html`<span class=\"sr-only\"> (${this.externalText})</span>` : nothing}\n </a>\n `;\n }\n}\n\ncustomElements.define('impkt-link', ImpktLink);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-link': ImpktLink }\n}\n"],"mappings":";;;;;;;;;;;AAuBO,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;AAAA,SAAO,aAAa;AAAA,MAClB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACzC,cAAc,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,IAC3D;AAAA;AAAA,EAMA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAKa,EAAE,IAAI;AAAA;AAAA;AAAA,yBAGE,EAAE,QAAQ;AAAA;AAAA;AAAA,iBAGlB,EAAE,SAAS;AAAA;AAAA;AAAA,UAGlB,cAAc;AAAA;AAAA;AAAA,IAGtB;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA;AAAA,eAGI,KAAK,QAAQ,CAAO;AAAA,iBAClB,KAAK,WAAW,WAAW,CAAO;AAAA,cACrC,KAAK,WAAW,wBAAwB,CAAO;AAAA;AAAA,uBAEtC,KAAK,WAAW,4BAA+B,KAAK,YAAY,aAAa,CAAO;AAAA;AAAA;AAAA,EAGzG;AACF;AAEA,eAAe,OAAO,cAAc,SAAS;","names":[]}
|