@atomic-ui/ui 0.5.0 → 0.7.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 +7 -7
- package/custom-elements.json +2641 -256
- package/dist/base/tone.d.ts +1 -1
- package/dist/{chunk-TAZZLOUY.js → chunk-2HWO5TFV.js} +2 -2
- package/dist/{chunk-FMSC7J7J.js → chunk-4ZQTXTPA.js} +1 -1
- package/dist/{chunk-FMSC7J7J.js.map → chunk-4ZQTXTPA.js.map} +1 -1
- package/dist/chunk-AMDTBUUL.js +299 -0
- package/dist/chunk-AMDTBUUL.js.map +1 -0
- package/dist/{chunk-EJD6LT7E.js → chunk-BNYILASW.js} +36 -4
- package/dist/chunk-BNYILASW.js.map +1 -0
- package/dist/{chunk-Q54FX3SY.js → chunk-INA53XXW.js} +2 -2
- package/dist/chunk-INA53XXW.js.map +1 -0
- package/dist/{chunk-ACQ4KYPR.js → chunk-KFAGXPIK.js} +2 -2
- package/dist/{chunk-ACQ4KYPR.js.map → chunk-KFAGXPIK.js.map} +1 -1
- package/dist/{chunk-SV77SN6P.js → chunk-MLRTPQQO.js} +39 -2
- package/dist/chunk-MLRTPQQO.js.map +1 -0
- package/dist/{chunk-ZS7RPXCT.js → chunk-NU34ZQFR.js} +4 -2
- package/dist/chunk-NU34ZQFR.js.map +1 -0
- package/dist/chunk-NUUX2SSN.js +263 -0
- package/dist/chunk-NUUX2SSN.js.map +1 -0
- package/dist/{chunk-HNZQ7LM4.js → chunk-OE6O3XQB.js} +78 -3
- package/dist/chunk-OE6O3XQB.js.map +1 -0
- package/dist/{chunk-WWYYNR3Z.js → chunk-RZWRAJCD.js} +7 -2
- package/dist/chunk-RZWRAJCD.js.map +1 -0
- package/dist/chunk-UF6KCRNT.js +316 -0
- package/dist/chunk-UF6KCRNT.js.map +1 -0
- package/dist/{chunk-Z45LY6BT.js → chunk-WH43U4IY.js} +37 -2
- package/dist/chunk-WH43U4IY.js.map +1 -0
- package/dist/{chunk-5Y3HYRCU.js → chunk-WS4AYRSL.js} +20 -2
- package/dist/chunk-WS4AYRSL.js.map +1 -0
- package/dist/{chunk-PANH23MF.js → chunk-XZQH2M5I.js} +2 -2
- package/dist/components/app-ui.d.ts +6 -1
- package/dist/components/app-ui.js +2 -2
- package/dist/components/badge.d.ts +7 -2
- package/dist/components/badge.js +2 -2
- package/dist/components/blocks.d.ts +27 -1
- package/dist/components/blocks.js +3 -1
- package/dist/components/button.d.ts +24 -3
- package/dist/components/button.js +2 -2
- package/dist/components/chip.js +1 -1
- package/dist/components/icon.d.ts +19 -1
- package/dist/components/icon.js +1 -1
- package/dist/components/link.d.ts +1 -1
- package/dist/components/link.js +2 -2
- package/dist/components/navigation.js +2 -2
- package/dist/components/progress.d.ts +11 -0
- package/dist/components/progress.js +1 -1
- package/dist/components/rows.d.ts +196 -0
- package/dist/components/rows.js +16 -0
- package/dist/components/rows.js.map +1 -0
- package/dist/components/shell.d.ts +166 -0
- package/dist/components/shell.js +17 -0
- package/dist/components/shell.js.map +1 -0
- package/dist/components/switch.d.ts +147 -0
- package/dist/components/switch.js +11 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +2 -2
- package/dist/components/text-input.d.ts +14 -1
- package/dist/components/text-input.js +2 -1
- package/dist/components/textarea.js +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +44 -16
- package/dist/standalone/atomic-ui.js +929 -285
- package/dist/standalone/atomic-ui.js.map +4 -4
- package/dist/standalone/index.html +1 -1
- package/package.json +2 -2
- package/specimen/index.html +1 -1
- package/dist/chunk-5Y3HYRCU.js.map +0 -1
- package/dist/chunk-EJD6LT7E.js.map +0 -1
- package/dist/chunk-HNZQ7LM4.js.map +0 -1
- package/dist/chunk-Q54FX3SY.js.map +0 -1
- package/dist/chunk-SV77SN6P.js.map +0 -1
- package/dist/chunk-WWYYNR3Z.js.map +0 -1
- package/dist/chunk-Z45LY6BT.js.map +0 -1
- package/dist/chunk-ZS7RPXCT.js.map +0 -1
- /package/dist/{chunk-TAZZLOUY.js.map → chunk-2HWO5TFV.js.map} +0 -0
- /package/dist/{chunk-PANH23MF.js.map → chunk-XZQH2M5I.js.map} +0 -0
package/dist/base/tone.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* restyles everything drawn with one.
|
|
5
5
|
*
|
|
6
6
|
* It is shared: `impakt-chip` here and the changelog, site and estimator blocks
|
|
7
|
-
* in `@atomic-ui/
|
|
7
|
+
* in `@atomic-ui/blocks` all colour themselves with it.
|
|
8
8
|
*/
|
|
9
9
|
/** A colour for a line or a lane, named by what it is in the brand. */
|
|
10
10
|
export type NamedTone = 'brand' | 'accent' | 'info' | 'success' | 'warning' | 'danger';
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-3IGNZTJU.js";
|
|
4
4
|
import {
|
|
5
5
|
iconSvg
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WS4AYRSL.js";
|
|
7
7
|
import {
|
|
8
8
|
ImpaktElement,
|
|
9
9
|
focusRing,
|
|
@@ -325,4 +325,4 @@ customElements.define("impakt-table", ImpaktTable);
|
|
|
325
325
|
export {
|
|
326
326
|
ImpaktTable
|
|
327
327
|
};
|
|
328
|
-
//# sourceMappingURL=chunk-
|
|
328
|
+
//# sourceMappingURL=chunk-2HWO5TFV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chip.ts","../src/base/tone.ts"],"sourcesContent":["/**\n * A short label: a branch, a status with its dot, or a code such as a commit\n * hash.\n */\nimport { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { hideOn } from '../base/styles';\nimport { fontSize, space, t } from '../base/tokens';\nimport { toneOf, type Tone } from '../base/tone';\n\n/** Code-like labels: a branch, a hash, a commit message. */\nconst MONO = t.fontMono;\n\n/**\n * A short label: a branch name with its icon, a status with its dot, or a\n * code such as a commit hash. It says something; it does nothing.\n *\n * @category content\n * @icon badge\n */\nexport class ImpaktChip extends ImpaktElement {\n static properties = {\n label: { type: String },\n meta: { type: String },\n icon: { type: String, reflect: true },\n tone: { type: String },\n look: { type: String, reflect: true },\n hideOn: { type: String, reflect: true, attribute: 'hide-on' },\n };\n declare label: string;\n /** A code after the label, quieter, such as a hash. */\n declare meta: string;\n /** A coloured dot, a branch, or nothing before the label. */\n declare icon: 'none' | 'dot' | 'branch';\n /** The dot's colour: a named tone, or 1 to 5 for the brand's chart colours. */\n declare tone: Tone;\n /** `outlined` on the card colour, `filled` with a faint wash, or `plain` words in the code face. */\n declare look: 'outlined' | 'filled' | 'plain';\n declare hideOn: 'never' | 'phone' | 'wide';\n\n constructor() {\n super();\n this.label = '';\n this.meta = '';\n this.icon = 'none';\n this.tone = 'success';\n this.look = 'filled';\n this.hideOn = 'never';\n }\n\n static styles = [...ImpaktElement.styles, hideOn, css`\n :host { display: inline-flex; flex: none; }\n span.chip { display: inline-flex; align-items: center; gap: ${space(1.5)}; padding: 3px ${space(2.5)}; border-radius: 999px; font-family: ${MONO}; font-size: ${fontSize('xs')}; line-height: 1.2; white-space: nowrap; }\n :host([look='filled']) span.chip { border-radius: ${t.radius}; background: color-mix(in srgb, currentColor 7%, transparent); }\n :host([look='outlined']) span.chip { border: ${t.borderThin} solid ${t.border}; background: ${t.surfaceCard}; text-transform: uppercase; letter-spacing: 0.04em; }\n :host([look='plain']) span.chip { padding: 0; }\n .dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--tone); }\n svg { inline-size: 12px; block-size: 12px; }\n .meta { opacity: 0.72; text-transform: none; }\n :host([look='plain']) .label { opacity: 0.72; }\n `];\n\n render(): TemplateResult {\n const icon = this.icon === 'dot'\n ? html`<span class=\"dot\" aria-hidden=\"true\"></span>`\n : this.icon === 'branch'\n ? html`<svg viewBox=\"0 0 14 14\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"><circle cx=\"3.5\" cy=\"3\" r=\"1.5\"/><circle cx=\"3.5\" cy=\"11\" r=\"1.5\"/><circle cx=\"10.5\" cy=\"4.5\" r=\"1.5\"/><path d=\"M3.5 4.5v5M10.5 6c0 2.5-3 2.5-6 4\"/></svg>`\n : nothing;\n return html`<span class=\"chip\" part=\"chip\" style=${`--tone:${toneOf(this.tone, 0)}`}>${icon}<span class=\"label\">${this.label}</span>${this.meta ? html` <span class=\"meta\">${this.meta}</span>` : nothing}</span>`;\n }\n}\n\ncustomElements.define('impakt-chip', ImpaktChip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-chip': ImpaktChip;\n }\n}\n","/**\n * Colours named by what they are in the brand, for a line, a lane, a dot or a\n * stripe. A tone is a brand token, never a hex value, so a partner's brand\n * restyles everything drawn with one.\n *\n * It is shared: `impakt-chip` here and the changelog, site and estimator blocks\n * in `@atomic-ui/
|
|
1
|
+
{"version":3,"sources":["../src/components/chip.ts","../src/base/tone.ts"],"sourcesContent":["/**\n * A short label: a branch, a status with its dot, or a code such as a commit\n * hash.\n */\nimport { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { hideOn } from '../base/styles';\nimport { fontSize, space, t } from '../base/tokens';\nimport { toneOf, type Tone } from '../base/tone';\n\n/** Code-like labels: a branch, a hash, a commit message. */\nconst MONO = t.fontMono;\n\n/**\n * A short label: a branch name with its icon, a status with its dot, or a\n * code such as a commit hash. It says something; it does nothing.\n *\n * @category content\n * @icon badge\n */\nexport class ImpaktChip extends ImpaktElement {\n static properties = {\n label: { type: String },\n meta: { type: String },\n icon: { type: String, reflect: true },\n tone: { type: String },\n look: { type: String, reflect: true },\n hideOn: { type: String, reflect: true, attribute: 'hide-on' },\n };\n declare label: string;\n /** A code after the label, quieter, such as a hash. */\n declare meta: string;\n /** A coloured dot, a branch, or nothing before the label. */\n declare icon: 'none' | 'dot' | 'branch';\n /** The dot's colour: a named tone, or 1 to 5 for the brand's chart colours. */\n declare tone: Tone;\n /** `outlined` on the card colour, `filled` with a faint wash, or `plain` words in the code face. */\n declare look: 'outlined' | 'filled' | 'plain';\n declare hideOn: 'never' | 'phone' | 'wide';\n\n constructor() {\n super();\n this.label = '';\n this.meta = '';\n this.icon = 'none';\n this.tone = 'success';\n this.look = 'filled';\n this.hideOn = 'never';\n }\n\n static styles = [...ImpaktElement.styles, hideOn, css`\n :host { display: inline-flex; flex: none; }\n span.chip { display: inline-flex; align-items: center; gap: ${space(1.5)}; padding: 3px ${space(2.5)}; border-radius: 999px; font-family: ${MONO}; font-size: ${fontSize('xs')}; line-height: 1.2; white-space: nowrap; }\n :host([look='filled']) span.chip { border-radius: ${t.radius}; background: color-mix(in srgb, currentColor 7%, transparent); }\n :host([look='outlined']) span.chip { border: ${t.borderThin} solid ${t.border}; background: ${t.surfaceCard}; text-transform: uppercase; letter-spacing: 0.04em; }\n :host([look='plain']) span.chip { padding: 0; }\n .dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--tone); }\n svg { inline-size: 12px; block-size: 12px; }\n .meta { opacity: 0.72; text-transform: none; }\n :host([look='plain']) .label { opacity: 0.72; }\n `];\n\n render(): TemplateResult {\n const icon = this.icon === 'dot'\n ? html`<span class=\"dot\" aria-hidden=\"true\"></span>`\n : this.icon === 'branch'\n ? html`<svg viewBox=\"0 0 14 14\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"><circle cx=\"3.5\" cy=\"3\" r=\"1.5\"/><circle cx=\"3.5\" cy=\"11\" r=\"1.5\"/><circle cx=\"10.5\" cy=\"4.5\" r=\"1.5\"/><path d=\"M3.5 4.5v5M10.5 6c0 2.5-3 2.5-6 4\"/></svg>`\n : nothing;\n return html`<span class=\"chip\" part=\"chip\" style=${`--tone:${toneOf(this.tone, 0)}`}>${icon}<span class=\"label\">${this.label}</span>${this.meta ? html` <span class=\"meta\">${this.meta}</span>` : nothing}</span>`;\n }\n}\n\ncustomElements.define('impakt-chip', ImpaktChip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-chip': ImpaktChip;\n }\n}\n","/**\n * Colours named by what they are in the brand, for a line, a lane, a dot or a\n * stripe. A tone is a brand token, never a hex value, so a partner's brand\n * restyles everything drawn with one.\n *\n * It is shared: `impakt-chip` here and the changelog, site and estimator blocks\n * in `@atomic-ui/blocks` all colour themselves with it.\n */\n\n/** A colour for a line or a lane, named by what it is in the brand. */\nexport type NamedTone = 'brand' | 'accent' | 'info' | 'success' | 'warning' | 'danger';\n/** A named tone, or 1 to 5 for the brand's chart colours in order. */\nexport type Tone = NamedTone | 1 | 2 | 3 | 4 | 5;\nexport const TONE: Record<NamedTone, string> = {\n brand: 'var(--impakt-color-brand-default, #1f4ed8)',\n accent: 'var(--impakt-color-accent-default, #c8a15a)',\n info: 'var(--impakt-color-status-info-default, #1f4ed8)',\n success: 'var(--impakt-color-status-success-default, #047857)',\n warning: 'var(--impakt-color-status-warning-default, #b45309)',\n danger: 'var(--impakt-color-status-danger-default, #c8102e)',\n};\n/** When an item names no tone, lanes take these in turn. */\nexport const CYCLE: NamedTone[] = ['success', 'info', 'warning', 'accent', 'danger', 'brand'];\n/**\n * A named tone, or for an item that names none, the brand's chart colour for its\n * place (color.chart.1 to 5), falling back to the status colours in turn.\n */\nexport const toneOf = (tone: Tone | undefined, i: number): string => {\n if (typeof tone === 'number') return `var(--impakt-color-chart-${tone}, ${TONE[CYCLE[(tone - 1) % CYCLE.length]!]})`;\n if (tone && tone in TONE) return TONE[tone];\n return `var(--impakt-color-chart-${(i % 5) + 1}, ${TONE[CYCLE[i % CYCLE.length]!]})`;\n};\n"],"mappings":";;;;;;;;;AAIA,SAAS,KAAK,MAAM,eAAoC;;;ACSjD,IAAM,OAAkC;AAAA,EAC7C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;AAEO,IAAM,QAAqB,CAAC,WAAW,QAAQ,WAAW,UA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4CAA4C,UAAU,OAAO,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,IAAI,uBAAuB,KAAK,KAAK,UAAU,KAAK,OAAO,2BAA2B,KAAK,IAAI,YAAY,OAAO;AAAA,EAC3M;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FieldElement
|
|
3
|
+
} from "./chunk-5ZQVL3V2.js";
|
|
4
|
+
import {
|
|
5
|
+
fontSize,
|
|
6
|
+
fontWeight,
|
|
7
|
+
space,
|
|
8
|
+
t,
|
|
9
|
+
targetSize,
|
|
10
|
+
touchTarget,
|
|
11
|
+
visuallyHidden
|
|
12
|
+
} from "./chunk-YR6T73GY.js";
|
|
13
|
+
|
|
14
|
+
// packages/ui/src/components/switch.ts
|
|
15
|
+
import { html, css, nothing } from "lit";
|
|
16
|
+
var ImpaktSwitch = class extends FieldElement {
|
|
17
|
+
static {
|
|
18
|
+
this.properties = {
|
|
19
|
+
...FieldElement.properties,
|
|
20
|
+
checked: { type: Boolean, reflect: true }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.checked = false;
|
|
26
|
+
}
|
|
27
|
+
static {
|
|
28
|
+
this.styles = [
|
|
29
|
+
...FieldElement.styles,
|
|
30
|
+
touchTarget(".row"),
|
|
31
|
+
css`
|
|
32
|
+
.row {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
gap: ${space(3)};
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
}
|
|
39
|
+
.text {
|
|
40
|
+
font-size: ${fontSize("md")};
|
|
41
|
+
}
|
|
42
|
+
.control {
|
|
43
|
+
position: relative;
|
|
44
|
+
flex: none;
|
|
45
|
+
inline-size: 46px;
|
|
46
|
+
block-size: 28px;
|
|
47
|
+
}
|
|
48
|
+
input {
|
|
49
|
+
${targetSize}
|
|
50
|
+
position: absolute;
|
|
51
|
+
inset: 0;
|
|
52
|
+
inline-size: 100%;
|
|
53
|
+
block-size: 100%;
|
|
54
|
+
margin: 0;
|
|
55
|
+
opacity: 0;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
.track {
|
|
59
|
+
position: absolute;
|
|
60
|
+
inset: 0;
|
|
61
|
+
border-radius: 999px;
|
|
62
|
+
background: ${t.borderStrong};
|
|
63
|
+
transition: background-color 120ms ease-in-out;
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
}
|
|
66
|
+
.knob {
|
|
67
|
+
position: absolute;
|
|
68
|
+
inset-block-start: 3px;
|
|
69
|
+
inset-inline-start: 3px;
|
|
70
|
+
inline-size: 22px;
|
|
71
|
+
block-size: 22px;
|
|
72
|
+
border-radius: 999px;
|
|
73
|
+
background: ${t.surfaceCard};
|
|
74
|
+
box-shadow: ${t.shadowXs};
|
|
75
|
+
transition: transform 120ms ease-in-out;
|
|
76
|
+
}
|
|
77
|
+
:host([checked]) .track {
|
|
78
|
+
background: ${t.brand};
|
|
79
|
+
}
|
|
80
|
+
:host([checked]) .knob {
|
|
81
|
+
transform: translateX(18px);
|
|
82
|
+
}
|
|
83
|
+
:host(:dir(rtl)[checked]) .knob {
|
|
84
|
+
transform: translateX(-18px);
|
|
85
|
+
}
|
|
86
|
+
input:focus-visible + .track {
|
|
87
|
+
box-shadow: ${t.focusShadow};
|
|
88
|
+
}
|
|
89
|
+
input:disabled {
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
}
|
|
92
|
+
:host([disabled]) .track {
|
|
93
|
+
opacity: 0.5;
|
|
94
|
+
}
|
|
95
|
+
@media (prefers-reduced-motion: reduce) {
|
|
96
|
+
.track, .knob { transition: none; }
|
|
97
|
+
}
|
|
98
|
+
@media (forced-colors: active) {
|
|
99
|
+
.track { border: 1px solid CanvasText; }
|
|
100
|
+
.knob { background: CanvasText; }
|
|
101
|
+
:host([checked]) .track { background: Highlight; }
|
|
102
|
+
}
|
|
103
|
+
`
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
renderControl() {
|
|
107
|
+
return html`
|
|
108
|
+
<label class="row" part="row" for=${this.controlId}>
|
|
109
|
+
<span class="text">
|
|
110
|
+
${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
|
|
111
|
+
</span>
|
|
112
|
+
<span class="control">
|
|
113
|
+
<input
|
|
114
|
+
type="checkbox"
|
|
115
|
+
role="switch"
|
|
116
|
+
id=${this.controlId}
|
|
117
|
+
part="input"
|
|
118
|
+
name=${this.name || nothing}
|
|
119
|
+
.checked=${this.checked}
|
|
120
|
+
aria-checked=${this.checked ? "true" : "false"}
|
|
121
|
+
?disabled=${this.disabled}
|
|
122
|
+
?required=${this.required}
|
|
123
|
+
aria-describedby=${this.describedBy}
|
|
124
|
+
aria-invalid=${this.error ? "true" : nothing}
|
|
125
|
+
@change=${(e) => {
|
|
126
|
+
this.checked = e.target.checked;
|
|
127
|
+
this.setFormValue(this.checked ? "on" : "");
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
<span class="track" part="track"><span class="knob" part="knob"></span></span>
|
|
131
|
+
</span>
|
|
132
|
+
</label>
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
/** The label is inside the control here, so the base class's is suppressed. */
|
|
136
|
+
renderLabel() {
|
|
137
|
+
return html`${nothing}`;
|
|
138
|
+
}
|
|
139
|
+
updated(changed) {
|
|
140
|
+
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var ImpaktSegmentedControl = class extends FieldElement {
|
|
144
|
+
static {
|
|
145
|
+
this.properties = {
|
|
146
|
+
...FieldElement.properties,
|
|
147
|
+
options: { type: Array },
|
|
148
|
+
hideLabel: { type: Boolean, attribute: "hide-label", reflect: true },
|
|
149
|
+
full: { type: Boolean, reflect: true }
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
constructor() {
|
|
153
|
+
super();
|
|
154
|
+
this.options = [];
|
|
155
|
+
this.hideLabel = false;
|
|
156
|
+
this.full = false;
|
|
157
|
+
}
|
|
158
|
+
static {
|
|
159
|
+
this.styles = [
|
|
160
|
+
...FieldElement.styles,
|
|
161
|
+
css`
|
|
162
|
+
fieldset {
|
|
163
|
+
border: 0;
|
|
164
|
+
margin: 0;
|
|
165
|
+
padding: 0;
|
|
166
|
+
min-inline-size: 0;
|
|
167
|
+
}
|
|
168
|
+
legend {
|
|
169
|
+
padding: 0;
|
|
170
|
+
}
|
|
171
|
+
:host([hide-label]) legend {
|
|
172
|
+
${visuallyHidden}
|
|
173
|
+
}
|
|
174
|
+
.segments {
|
|
175
|
+
display: inline-flex;
|
|
176
|
+
gap: ${space(1)};
|
|
177
|
+
padding: ${space(1)};
|
|
178
|
+
border-radius: 999px;
|
|
179
|
+
background: ${t.surfaceInset};
|
|
180
|
+
}
|
|
181
|
+
:host([full]) .segments {
|
|
182
|
+
display: flex;
|
|
183
|
+
}
|
|
184
|
+
:host([full]) .segment {
|
|
185
|
+
flex: 1;
|
|
186
|
+
}
|
|
187
|
+
.segment {
|
|
188
|
+
position: relative;
|
|
189
|
+
display: inline-flex;
|
|
190
|
+
}
|
|
191
|
+
input {
|
|
192
|
+
${targetSize}
|
|
193
|
+
position: absolute;
|
|
194
|
+
inset: 0;
|
|
195
|
+
inline-size: 100%;
|
|
196
|
+
block-size: 100%;
|
|
197
|
+
margin: 0;
|
|
198
|
+
opacity: 0;
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
}
|
|
201
|
+
.face {
|
|
202
|
+
display: inline-flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
justify-content: center;
|
|
205
|
+
inline-size: 100%;
|
|
206
|
+
min-block-size: 32px;
|
|
207
|
+
padding: ${space(1.5)} ${space(4)};
|
|
208
|
+
border-radius: 999px;
|
|
209
|
+
font-size: ${fontSize("sm")};
|
|
210
|
+
font-weight: ${fontWeight("medium")};
|
|
211
|
+
color: ${t.textMuted};
|
|
212
|
+
pointer-events: none;
|
|
213
|
+
transition: background-color 120ms ease-in-out, color 120ms ease-in-out;
|
|
214
|
+
}
|
|
215
|
+
.segment:hover .face {
|
|
216
|
+
color: ${t.text};
|
|
217
|
+
}
|
|
218
|
+
input:checked + .face {
|
|
219
|
+
background: ${t.surfaceCard};
|
|
220
|
+
color: ${t.text};
|
|
221
|
+
box-shadow: ${t.shadowXs};
|
|
222
|
+
}
|
|
223
|
+
input:focus-visible + .face {
|
|
224
|
+
box-shadow: ${t.focusShadow};
|
|
225
|
+
}
|
|
226
|
+
input:disabled {
|
|
227
|
+
cursor: not-allowed;
|
|
228
|
+
}
|
|
229
|
+
:host([disabled]) .segments {
|
|
230
|
+
opacity: 0.5;
|
|
231
|
+
}
|
|
232
|
+
@media (prefers-reduced-motion: reduce) {
|
|
233
|
+
.face { transition: none; }
|
|
234
|
+
}
|
|
235
|
+
@media (forced-colors: active) {
|
|
236
|
+
.segments { border: 1px solid CanvasText; }
|
|
237
|
+
input:checked + .face { border: 2px solid Highlight; }
|
|
238
|
+
}
|
|
239
|
+
`
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
renderLabel() {
|
|
243
|
+
return html`<legend class="label" part="label">
|
|
244
|
+
${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
|
|
245
|
+
</legend>`;
|
|
246
|
+
}
|
|
247
|
+
renderControl() {
|
|
248
|
+
return html`
|
|
249
|
+
<div class="segments" part="segments">
|
|
250
|
+
${this.options.map((option, i) => {
|
|
251
|
+
const id = this.id_(`seg-${i}`);
|
|
252
|
+
return html`
|
|
253
|
+
<label class="segment" part="segment" for=${id}>
|
|
254
|
+
<input
|
|
255
|
+
type="radio"
|
|
256
|
+
id=${id}
|
|
257
|
+
name=${this.uid}
|
|
258
|
+
value=${option.value}
|
|
259
|
+
.checked=${this.value === option.value}
|
|
260
|
+
?disabled=${this.disabled}
|
|
261
|
+
?required=${this.required && i === 0}
|
|
262
|
+
@change=${() => {
|
|
263
|
+
this.value = option.value;
|
|
264
|
+
this.setFormValue(option.value);
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
<span class="face">${option.label}</span>
|
|
268
|
+
</label>
|
|
269
|
+
`;
|
|
270
|
+
})}
|
|
271
|
+
</div>
|
|
272
|
+
`;
|
|
273
|
+
}
|
|
274
|
+
render() {
|
|
275
|
+
return html`
|
|
276
|
+
<fieldset
|
|
277
|
+
part="fieldset"
|
|
278
|
+
aria-describedby=${this.describedBy}
|
|
279
|
+
aria-invalid=${this.error ? "true" : nothing}
|
|
280
|
+
>
|
|
281
|
+
${this.renderLabel()}
|
|
282
|
+
${this.description ? html`<div class="description" id=${this.id_("description")} part="description">${this.description}</div>` : nothing}
|
|
283
|
+
${this.renderControl()}
|
|
284
|
+
<div class="error" id=${this.id_("error")} part="error" aria-live="polite">${this.error || nothing}</div>
|
|
285
|
+
</fieldset>
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
updated(changed) {
|
|
289
|
+
if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
customElements.define("impakt-switch", ImpaktSwitch);
|
|
293
|
+
customElements.define("impakt-segmented-control", ImpaktSegmentedControl);
|
|
294
|
+
|
|
295
|
+
export {
|
|
296
|
+
ImpaktSwitch,
|
|
297
|
+
ImpaktSegmentedControl
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=chunk-AMDTBUUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/switch.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { targetSize, touchTarget, visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * An on and off setting that takes effect at once: \"Show to customer\",\n * \"Visible to customer\".\n *\n * **It is a checkbox with the switch role.** A native\n * `<input type=\"checkbox\" role=\"switch\">` keeps Space to toggle, form\n * submission and the label's hit area, and the role makes a screen reader say\n * \"on\" and \"off\" rather than \"checked\". A switch is for a setting that applies\n * straight away. When the choice is only sent with a form, use\n * `impakt-checkbox` instead.\n *\n * **The state is not carried by colour alone.** The knob moves from one end of\n * the track to the other, so the position says on or off without the fill\n * (1.4.1).\n *\n * @category form\n * @icon checkbox\n */\nexport class ImpaktSwitch extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n checked: { type: Boolean, reflect: true },\n };\n\n declare checked: boolean;\n\n constructor() {\n super();\n this.checked = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n touchTarget('.row'),\n css`\n .row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: ${space(3)};\n cursor: pointer;\n }\n .text {\n font-size: ${fontSize('md')};\n }\n .control {\n position: relative;\n flex: none;\n inline-size: 46px;\n block-size: 28px;\n }\n input {\n ${targetSize}\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n .track {\n position: absolute;\n inset: 0;\n border-radius: 999px;\n background: ${t.borderStrong};\n transition: background-color 120ms ease-in-out;\n pointer-events: none;\n }\n .knob {\n position: absolute;\n inset-block-start: 3px;\n inset-inline-start: 3px;\n inline-size: 22px;\n block-size: 22px;\n border-radius: 999px;\n background: ${t.surfaceCard};\n box-shadow: ${t.shadowXs};\n transition: transform 120ms ease-in-out;\n }\n :host([checked]) .track {\n background: ${t.brand};\n }\n :host([checked]) .knob {\n transform: translateX(18px);\n }\n :host(:dir(rtl)[checked]) .knob {\n transform: translateX(-18px);\n }\n input:focus-visible + .track {\n box-shadow: ${t.focusShadow};\n }\n input:disabled {\n cursor: not-allowed;\n }\n :host([disabled]) .track {\n opacity: 0.5;\n }\n @media (prefers-reduced-motion: reduce) {\n .track, .knob { transition: none; }\n }\n @media (forced-colors: active) {\n .track { border: 1px solid CanvasText; }\n .knob { background: CanvasText; }\n :host([checked]) .track { background: Highlight; }\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <label class=\"row\" part=\"row\" for=${this.controlId}>\n <span class=\"text\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </span>\n <span class=\"control\">\n <input\n type=\"checkbox\"\n role=\"switch\"\n id=${this.controlId}\n part=\"input\"\n name=${this.name || nothing}\n .checked=${this.checked}\n aria-checked=${this.checked ? 'true' : 'false'}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => {\n this.checked = (e.target as HTMLInputElement).checked;\n this.setFormValue(this.checked ? 'on' : '');\n }}\n />\n <span class=\"track\" part=\"track\"><span class=\"knob\" part=\"knob\"></span></span>\n </span>\n </label>\n `;\n }\n\n /** The label is inside the control here, so the base class's is suppressed. */\n protected renderLabel(): TemplateResult {\n return html`${nothing}`;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\nexport interface SegmentOption {\n value: string;\n label: string;\n}\n\n/**\n * Two to four choices drawn as one joined control: \"Internal\" or \"Visible to\n * customer\", \"Cost\" or \"Charge\".\n *\n * **It is a radio group underneath.** Native radios sharing a name give arrow\n * keys, one tab stop and the right announcement with no script, exactly as in\n * `impakt-radio-group`. Only the drawing differs. The label is a `<legend>`, so\n * the question is asked of the set; set `hide-label` when the words around it\n * already ask it, and the legend stays for screen readers.\n *\n * @category form\n * @icon radio\n */\nexport class ImpaktSegmentedControl extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n hideLabel: { type: Boolean, attribute: 'hide-label', reflect: true },\n full: { type: Boolean, reflect: true },\n };\n\n declare options: SegmentOption[];\n /** Keep the question for screen readers only, when the words around it already ask it. */\n declare hideLabel: boolean;\n /** As wide as its space, with the segments sharing it equally. */\n declare full: boolean;\n\n constructor() {\n super();\n this.options = [];\n this.hideLabel = false;\n this.full = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n fieldset {\n border: 0;\n margin: 0;\n padding: 0;\n min-inline-size: 0;\n }\n legend {\n padding: 0;\n }\n :host([hide-label]) legend {\n ${visuallyHidden}\n }\n .segments {\n display: inline-flex;\n gap: ${space(1)};\n padding: ${space(1)};\n border-radius: 999px;\n background: ${t.surfaceInset};\n }\n :host([full]) .segments {\n display: flex;\n }\n :host([full]) .segment {\n flex: 1;\n }\n .segment {\n position: relative;\n display: inline-flex;\n }\n input {\n ${targetSize}\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n .face {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: 100%;\n min-block-size: 32px;\n padding: ${space(1.5)} ${space(4)};\n border-radius: 999px;\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('medium')};\n color: ${t.textMuted};\n pointer-events: none;\n transition: background-color 120ms ease-in-out, color 120ms ease-in-out;\n }\n .segment:hover .face {\n color: ${t.text};\n }\n input:checked + .face {\n background: ${t.surfaceCard};\n color: ${t.text};\n box-shadow: ${t.shadowXs};\n }\n input:focus-visible + .face {\n box-shadow: ${t.focusShadow};\n }\n input:disabled {\n cursor: not-allowed;\n }\n :host([disabled]) .segments {\n opacity: 0.5;\n }\n @media (prefers-reduced-motion: reduce) {\n .face { transition: none; }\n }\n @media (forced-colors: active) {\n .segments { border: 1px solid CanvasText; }\n input:checked + .face { border: 2px solid Highlight; }\n }\n `,\n ];\n\n protected renderLabel(): TemplateResult {\n return html`<legend class=\"label\" part=\"label\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </legend>`;\n }\n\n protected renderControl(): TemplateResult {\n return html`\n <div class=\"segments\" part=\"segments\">\n ${this.options.map((option, i) => {\n const id = this.id_(`seg-${i}`);\n return html`\n <label class=\"segment\" part=\"segment\" for=${id}>\n <input\n type=\"radio\"\n id=${id}\n name=${this.uid}\n value=${option.value}\n .checked=${this.value === option.value}\n ?disabled=${this.disabled}\n ?required=${this.required && i === 0}\n @change=${() => {\n this.value = option.value;\n this.setFormValue(option.value);\n }}\n />\n <span class=\"face\">${option.label}</span>\n </label>\n `;\n })}\n </div>\n `;\n }\n\n render(): TemplateResult {\n return html`\n <fieldset\n part=\"fieldset\"\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n >\n ${this.renderLabel()}\n ${this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">${this.description}</div>`\n : nothing}\n ${this.renderControl()}\n <div class=\"error\" id=${this.id_('error')} part=\"error\" aria-live=\"polite\">${this.error || nothing}</div>\n </fieldset>\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impakt-switch', ImpaktSwitch);\ncustomElements.define('impakt-segmented-control', ImpaktSegmentedControl);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-switch': ImpaktSwitch;\n 'impakt-segmented-control': ImpaktSegmentedControl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAuBjD,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,IAC1C;AAAA;AAAA,EAIA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB,YAAY,MAAM;AAAA,MAClB;AAAA;AAAA;AAAA;AAAA;AAAA,eAKW,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,qBAIF,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAA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,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
announceNavigate
|
|
3
|
+
} from "./chunk-UF6KCRNT.js";
|
|
1
4
|
import {
|
|
2
5
|
ImpaktElement,
|
|
3
6
|
focusRing,
|
|
@@ -73,7 +76,8 @@ var ImpaktTabs = class extends ImpaktElement {
|
|
|
73
76
|
items: { type: Array },
|
|
74
77
|
selected: { type: String, reflect: true },
|
|
75
78
|
label: { type: String },
|
|
76
|
-
twoRows: { type: Boolean, reflect: true, attribute: "two-rows" }
|
|
79
|
+
twoRows: { type: Boolean, reflect: true, attribute: "two-rows" },
|
|
80
|
+
look: { type: String, reflect: true }
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
constructor() {
|
|
@@ -82,6 +86,7 @@ var ImpaktTabs = class extends ImpaktElement {
|
|
|
82
86
|
this.selected = "";
|
|
83
87
|
this.label = "";
|
|
84
88
|
this.twoRows = false;
|
|
89
|
+
this.look = "line";
|
|
85
90
|
}
|
|
86
91
|
static {
|
|
87
92
|
this.styles = [...ImpaktElement.styles, focusRing, touchTarget("[role='tab']"), css`
|
|
@@ -100,8 +105,30 @@ var ImpaktTabs = class extends ImpaktElement {
|
|
|
100
105
|
:host([two-rows]) .many [role='tab'][aria-selected='true'] { border-block-end-color: currentColor; background: ${t.brandSubtle}; }
|
|
101
106
|
}
|
|
102
107
|
@media (forced-colors: active) { [role='tab'][aria-selected='true'] { border-block-end-color: Highlight; } }
|
|
108
|
+
.count { display: inline-flex; align-items: center; justify-content: center; min-inline-size: 20px; block-size: 20px; margin-inline-start: ${space(2)}; padding: 0 ${space(1.5)}; border-radius: 999px; font-size: 12px; font-weight: ${fontWeight("semibold")}; background: ${t.brand}; color: ${t.onBrand}; font-variant-numeric: tabular-nums; }
|
|
109
|
+
.sr-only { ${visuallyHidden} }
|
|
110
|
+
/* Links drawn as tabs. */
|
|
111
|
+
nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: ${space(1)}; overflow-x: auto; scrollbar-width: thin; border-block-end: ${t.borderThin} solid ${t.border}; }
|
|
112
|
+
nav a { ${targetSize} display: inline-flex; align-items: center; flex: none; padding: ${space(3)} ${space(4)}; font-weight: ${fontWeight("semibold")}; white-space: nowrap; color: ${t.textMuted}; text-decoration: none; border-block-end: 3px solid transparent; margin-block-end: -1px; border-radius: ${t.radius} ${t.radius} 0 0; }
|
|
113
|
+
nav a:hover { color: ${t.text}; background: ${t.surfaceInset}; }
|
|
114
|
+
nav a[aria-current='page'] { color: ${t.link}; border-block-end-color: currentColor; }
|
|
115
|
+
nav a:focus-visible { box-shadow: inset 0 0 0 2px ${t.text}, inset 0 0 0 4px ${t.surfaceCard}; outline: none; }
|
|
116
|
+
/* The pill look, for either kind. */
|
|
117
|
+
:host([look='pill']) :is([role='tablist'], nav ul) { padding: ${space(1)}; border: 0; border-radius: 999px; background: ${t.surfaceCard}; gap: ${space(0.5)}; }
|
|
118
|
+
:host([look='pill']) :is([role='tab'], nav a) { padding: ${space(2)} ${space(4)}; margin: 0; border: 0; border-radius: 999px; font-weight: ${fontWeight("medium")}; color: ${t.text}; }
|
|
119
|
+
:host([look='pill']) :is([role='tab'], nav a):hover { background: ${t.surfaceInset}; }
|
|
120
|
+
:host([look='pill']) :is([role='tab'][aria-selected='true'], nav a[aria-current='page']) { background: ${t.text}; color: ${t.surfaceCard}; }
|
|
121
|
+
@media (forced-colors: active) { :host([look='pill']) :is([role='tab'][aria-selected='true'], nav a[aria-current='page']) { border: 2px solid Highlight; } }
|
|
103
122
|
`];
|
|
104
123
|
}
|
|
124
|
+
countOf(item) {
|
|
125
|
+
if (typeof item.count !== "number") return nothing;
|
|
126
|
+
return item.countLabel ? html`<span class="count" aria-hidden="true">${item.count}</span><span class="sr-only">, ${item.countLabel}</span>` : html`<span class="count">${item.count}</span>`;
|
|
127
|
+
}
|
|
128
|
+
get linked() {
|
|
129
|
+
const items = this.items ?? [];
|
|
130
|
+
return items.length > 0 && items.every((i) => Boolean(i.href));
|
|
131
|
+
}
|
|
105
132
|
current() {
|
|
106
133
|
const items = this.items ?? [];
|
|
107
134
|
return items.some((i) => i.id === this.selected) ? this.selected : items[0]?.id ?? "";
|
|
@@ -140,11 +167,16 @@ var ImpaktTabs = class extends ImpaktElement {
|
|
|
140
167
|
render() {
|
|
141
168
|
const items = this.items ?? [];
|
|
142
169
|
const current = this.current();
|
|
170
|
+
if (this.linked) {
|
|
171
|
+
return html`<nav aria-label=${this.label || nothing} part="tabs"><ul>
|
|
172
|
+
${items.map((item) => html`<li><a href=${item.href} part="tab" aria-current=${item.id === current ? "page" : nothing} @click=${(e) => announceNavigate(this, e, { href: item.href, id: item.id })}>${item.label}${this.countOf(item)}</a></li>`)}
|
|
173
|
+
</ul></nav>`;
|
|
174
|
+
}
|
|
143
175
|
const many = items.length > 4;
|
|
144
176
|
return html`<div role="tablist" aria-label=${this.label || nothing} part="tabs" class=${many ? "many" : ""} style=${many ? `--columns:${Math.ceil(items.length / 2)}` : nothing} @keydown=${this.onKey}>
|
|
145
|
-
${items.map((item) => html`<button role="tab" type="button" id=${this.id_(`tab-${item.id}`)} aria-selected=${item.id === current ? "true" : "false"} aria-controls=${this.id_(`panel-${item.id}`)} tabindex=${item.id === current ? "0" : "-1"} @click=${() => this.choose(item.id, false)}>${item.label}</button>`)}
|
|
177
|
+
${items.map((item) => html`<button role="tab" type="button" id=${this.id_(`tab-${item.id}`)} aria-selected=${item.id === current ? "true" : "false"} aria-controls=${this.id_(`panel-${item.id}`)} tabindex=${item.id === current ? "0" : "-1"} @click=${() => this.choose(item.id, false)}>${item.label}${this.countOf(item)}</button>`)}
|
|
146
178
|
</div>
|
|
147
|
-
${items.map((item) => html`<div role="tabpanel" id=${this.id_(`panel-${item.id}`)} aria-labelledby=${this.id_(`tab-${item.id}`)} tabindex="0" ?hidden=${item.id !== current} part="panel"><slot name=${item.id}><span class="body">${item.body}</span></slot></div>`)}`;
|
|
179
|
+
${items.map((item) => html`<div role="tabpanel" id=${this.id_(`panel-${item.id}`)} aria-labelledby=${this.id_(`tab-${item.id}`)} tabindex="0" ?hidden=${item.id !== current} part="panel"><slot name=${item.id}><span class="body">${item.body ?? ""}</span></slot></div>`)}`;
|
|
148
180
|
}
|
|
149
181
|
};
|
|
150
182
|
customElements.define("impakt-divider", ImpaktDivider);
|
|
@@ -158,4 +190,4 @@ export {
|
|
|
158
190
|
ImpaktVisuallyHidden,
|
|
159
191
|
ImpaktTabs
|
|
160
192
|
};
|
|
161
|
-
//# sourceMappingURL=chunk-
|
|
193
|
+
//# sourceMappingURL=chunk-BNYILASW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/blocks.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { focusRing, targetSize, touchTarget, visuallyHidden } from '../base/styles';\nimport { fontWeight, lineHeight, space, t } from '../base/tokens';\nimport { announceNavigate } from './shell';\n\n/**\n * A line between two parts of a page.\n *\n * It is decoration, so a screen reader passes over it. Where the change of\n * subject matters, a heading says so better.\n *\n * @category layout\n * @icon divider\n */\nexport class ImpaktDivider extends ImpaktElement {\n static properties = {\n spacing: { type: String, reflect: true },\n tone: { type: String, reflect: true },\n };\n /** Space above and below the line. */\n declare spacing: 'sm' | 'md' | 'lg' | 'xl';\n declare tone: 'subtle' | 'strong';\n\n constructor() {\n super();\n this.spacing = 'md';\n this.tone = 'subtle';\n }\n\n static styles = [...ImpaktElement.styles, css`\n :host { display: block; }\n hr { margin: ${space(4)} 0; border: 0; border-block-start: ${t.borderThin} solid ${t.border}; opacity: 0.5; }\n :host([tone='strong']) hr { opacity: 1; border-block-start-width: ${t.borderThick}; }\n :host([spacing='sm']) hr { margin-block: ${space(2)}; }\n :host([spacing='lg']) hr { margin-block: ${space(8)}; }\n :host([spacing='xl']) hr { margin-block: ${space(12)}; }\n `];\n\n render(): TemplateResult {\n return html`<hr aria-hidden=\"true\" part=\"line\" />`;\n }\n}\n\n/**\n * Empty space, from the spacing scale, for the rare place where the gaps of the\n * containers around it are not enough.\n *\n * @category layout\n * @icon spacer\n */\nexport class ImpaktSpacer extends ImpaktElement {\n static properties = { size: { type: String, reflect: true } };\n declare size: 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\n constructor() {\n super();\n this.size = 'md';\n }\n\n static styles = [...ImpaktElement.styles, css`\n :host { display: block; block-size: ${space(4)}; }\n :host([size='sm']) { block-size: ${space(2)}; }\n :host([size='lg']) { block-size: ${space(8)}; }\n :host([size='xl']) { block-size: ${space(12)}; }\n :host([size='2xl']) { block-size: ${space(16)}; }\n `];\n\n render(): TemplateResult {\n return html``;\n }\n}\n\n/**\n * Words a screen reader says that are not shown: \"(opens a map)\" after a link\n * whose purpose is clear on screen from where it sits.\n *\n * @category typography\n * @icon hidden\n * @slot - The words to say.\n */\nexport class ImpaktVisuallyHidden extends ImpaktElement {\n static styles = [...ImpaktElement.styles, css`:host { ${visuallyHidden} }`];\n render(): TemplateResult {\n return html`<slot></slot>`;\n }\n}\n\n/** One tab and what it shows. */\nexport interface TabItem {\n id: string;\n label: string;\n /** The panel's words. A child with `slot` set to the tab's id is shown instead, for anything richer. */\n body?: string;\n /** A number shown on the tab, such as the open tasks behind it. */\n count?: number;\n /** The count in words for a screen reader, such as \"2 overdue tasks\". The number alone when empty. */\n countLabel?: string;\n /** Where the tab goes. When every tab has one, the tabs are links to pages, not panels. */\n href?: string;\n}\n\n/**\n * Panels of content behind a row of tabs, one shown at a time: the floor plans\n * of three house types, or a case's summary, tasks and files.\n *\n * It follows the ARIA tabs pattern. The tabs are one stop in the tab order,\n * the arrow keys, Home and End move between them, and each panel is labelled\n * by its tab. Use an accordion instead when someone may want to compare panels.\n *\n * **The tabs stay on one row** and scroll sideways when they do not fit, as the\n * design guide sets, and the chosen tab is scrolled into view, so on a phone it\n * is never hidden off the edge. With `two-rows`, a set of more than four tabs is\n * laid out in two rows on a narrow screen instead, so every tab can be seen.\n *\n * **The chosen tab is kept** when the tabs are given again, as a React or Vue app\n * does on every render, so long as a tab with that id is still there.\n *\n * A panel shows its item's `body`, or a child whose `slot` is the item's id.\n *\n * **Tabs that go to pages are links.** When every item has an `href`, such as\n * a job's Overview, Money and Notes, each of which has its own address, the\n * tabs are drawn the same but are a `nav` of links, the current one marked\n * `aria-current=\"page\"`, with no panels. A row of links is not the ARIA tabs\n * pattern, and announcing it as one would promise arrow keys and panels that\n * are not there. They send `impakt-navigate` like the side navigation, so an\n * app can route without a reload.\n *\n * `look=\"pill\"` draws the tabs as pills in a rounded bar, with the chosen one\n * filled, as a product's workspace tabs are.\n *\n * @category content\n * @icon tabs\n * @slot - A child with `slot` set to a tab's id is that tab's panel.\n * @fires {CustomEvent<{ value: string }>} impakt-change - When another tab is chosen.\n * @fires {CustomEvent<{ href: string; id: string }>} impakt-navigate - When a tab that is a link is followed. Cancel it to route in the app.\n */\nexport class ImpaktTabs extends ImpaktElement {\n static properties = {\n items: { type: Array },\n selected: { type: String, reflect: true },\n label: { type: String },\n twoRows: { type: Boolean, reflect: true, attribute: 'two-rows' },\n look: { type: String, reflect: true },\n };\n declare items: TabItem[];\n /** The id of the tab shown first. The first tab when it is empty. */\n declare selected: string;\n /** What the set of tabs is about, for a screen reader. */\n declare label: string;\n /** On a narrow screen, lay more than four tabs out in two rows rather than scroll them. */\n declare twoRows: boolean;\n /** `line` underlines the chosen tab; `pill` fills it, in a rounded bar. */\n declare look: 'line' | 'pill';\n\n constructor() {\n super();\n this.items = [];\n this.selected = '';\n this.label = '';\n this.twoRows = false;\n this.look = 'line';\n }\n\n static styles = [...ImpaktElement.styles, focusRing, touchTarget(\"[role='tab']\"), css`\n :host { display: block; container-type: inline-size; }\n [role='tablist'] { display: flex; gap: ${space(1)}; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; border-block-end: ${t.borderThin} solid ${t.border}; }\n [role='tab'] { ${targetSize} flex: none; padding: ${space(3)} ${space(4)}; font: inherit; font-weight: ${fontWeight('semibold')}; white-space: nowrap; color: ${t.textMuted}; background: transparent; border: 0; border-block-end: 3px solid transparent; margin-block-end: -1px; cursor: pointer; border-radius: ${t.radius} ${t.radius} 0 0; }\n /* Inside a box that scrolls the ring would be clipped, so it is drawn inside the tab. */\n [role='tab']:focus-visible { box-shadow: inset 0 0 0 2px ${t.text}, inset 0 0 0 4px ${t.surfaceCard}; }\n [role='tab']:hover { color: ${t.text}; background: ${t.surfaceInset}; }\n [role='tab'][aria-selected='true'] { color: ${t.link}; border-block-end-color: currentColor; }\n [role='tabpanel'] { padding-block: ${space(5)}; line-height: ${lineHeight('normal')}; }\n .body { white-space: pre-line; }\n @container (max-width: 40rem) {\n :host([two-rows]) [role='tablist'].many { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); overflow: visible; border-block-end: 0; gap: ${space(1)}; }\n :host([two-rows]) .many [role='tab'] { white-space: normal; padding-inline: ${space(2)}; margin: 0; border-block-end-width: 3px; border-block-end-color: ${t.rule}; border-radius: ${t.radius}; }\n :host([two-rows]) .many [role='tab'][aria-selected='true'] { border-block-end-color: currentColor; background: ${t.brandSubtle}; }\n }\n @media (forced-colors: active) { [role='tab'][aria-selected='true'] { border-block-end-color: Highlight; } }\n .count { display: inline-flex; align-items: center; justify-content: center; min-inline-size: 20px; block-size: 20px; margin-inline-start: ${space(2)}; padding: 0 ${space(1.5)}; border-radius: 999px; font-size: 12px; font-weight: ${fontWeight('semibold')}; background: ${t.brand}; color: ${t.onBrand}; font-variant-numeric: tabular-nums; }\n .sr-only { ${visuallyHidden} }\n /* Links drawn as tabs. */\n nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: ${space(1)}; overflow-x: auto; scrollbar-width: thin; border-block-end: ${t.borderThin} solid ${t.border}; }\n nav a { ${targetSize} display: inline-flex; align-items: center; flex: none; padding: ${space(3)} ${space(4)}; font-weight: ${fontWeight('semibold')}; white-space: nowrap; color: ${t.textMuted}; text-decoration: none; border-block-end: 3px solid transparent; margin-block-end: -1px; border-radius: ${t.radius} ${t.radius} 0 0; }\n nav a:hover { color: ${t.text}; background: ${t.surfaceInset}; }\n nav a[aria-current='page'] { color: ${t.link}; border-block-end-color: currentColor; }\n nav a:focus-visible { box-shadow: inset 0 0 0 2px ${t.text}, inset 0 0 0 4px ${t.surfaceCard}; outline: none; }\n /* The pill look, for either kind. */\n :host([look='pill']) :is([role='tablist'], nav ul) { padding: ${space(1)}; border: 0; border-radius: 999px; background: ${t.surfaceCard}; gap: ${space(0.5)}; }\n :host([look='pill']) :is([role='tab'], nav a) { padding: ${space(2)} ${space(4)}; margin: 0; border: 0; border-radius: 999px; font-weight: ${fontWeight('medium')}; color: ${t.text}; }\n :host([look='pill']) :is([role='tab'], nav a):hover { background: ${t.surfaceInset}; }\n :host([look='pill']) :is([role='tab'][aria-selected='true'], nav a[aria-current='page']) { background: ${t.text}; color: ${t.surfaceCard}; }\n @media (forced-colors: active) { :host([look='pill']) :is([role='tab'][aria-selected='true'], nav a[aria-current='page']) { border: 2px solid Highlight; } }\n `];\n\n private countOf(item: TabItem): TemplateResult | typeof nothing {\n if (typeof item.count !== 'number') return nothing;\n return item.countLabel\n ? html`<span class=\"count\" aria-hidden=\"true\">${item.count}</span><span class=\"sr-only\">, ${item.countLabel}</span>`\n : html`<span class=\"count\">${item.count}</span>`;\n }\n\n private get linked(): boolean {\n const items = this.items ?? [];\n return items.length > 0 && items.every((i) => Boolean(i.href));\n }\n\n private current(): string {\n const items = this.items ?? [];\n return items.some((i) => i.id === this.selected) ? this.selected : items[0]?.id ?? '';\n }\n\n private choose(id: string, focus: boolean): void {\n if (id === this.current()) return;\n this.selected = id;\n this.dispatchEvent(new CustomEvent('impakt-change', { detail: { value: id }, bubbles: true, composed: true }));\n if (focus) void this.updateComplete.then(() => this.renderRoot.querySelector<HTMLElement>(`#${this.id_(`tab-${id}`)}`)?.focus({ preventScroll: true }));\n }\n\n private onKey(event: KeyboardEvent): void {\n const items = this.items ?? [];\n const at = items.findIndex((i) => i.id === this.current());\n const to = { ArrowRight: at + 1, ArrowLeft: at - 1, Home: 0, End: items.length - 1 }[event.key];\n if (to === undefined || !items.length) return;\n event.preventDefault();\n this.choose(items[(to + items.length) % items.length]!.id, true);\n }\n\n /**\n * Bring the chosen tab into view inside the row of tabs. Only the row scrolls:\n * `scrollIntoView` would scroll the page too, and move someone who is reading\n * further down.\n */\n private reveal(): void {\n const list = this.renderRoot.querySelector<HTMLElement>(\"[role='tablist']\");\n const tab = this.renderRoot.querySelector<HTMLElement>(\"[role='tab'][aria-selected='true']\");\n if (!list || !tab || list.scrollWidth <= list.clientWidth) return;\n const start = tab.offsetLeft - list.offsetLeft;\n const end = start + tab.offsetWidth;\n if (start < list.scrollLeft) list.scrollLeft = start - 16;\n else if (end > list.scrollLeft + list.clientWidth) list.scrollLeft = end - list.clientWidth + 16;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('selected') || changed.has('items')) this.reveal();\n }\n\n render(): TemplateResult {\n const items = this.items ?? [];\n const current = this.current();\n if (this.linked) {\n return html`<nav aria-label=${this.label || nothing} part=\"tabs\"><ul>\n ${items.map((item) => html`<li><a href=${item.href!} part=\"tab\" aria-current=${item.id === current ? 'page' : nothing} @click=${(e: MouseEvent) => announceNavigate(this, e, { href: item.href!, id: item.id })}>${item.label}${this.countOf(item)}</a></li>`)}\n </ul></nav>`;\n }\n const many = items.length > 4;\n return html`<div role=\"tablist\" aria-label=${this.label || nothing} part=\"tabs\" class=${many ? 'many' : ''} style=${many ? `--columns:${Math.ceil(items.length / 2)}` : nothing} @keydown=${this.onKey}>\n ${items.map((item) => html`<button role=\"tab\" type=\"button\" id=${this.id_(`tab-${item.id}`)} aria-selected=${item.id === current ? 'true' : 'false'} aria-controls=${this.id_(`panel-${item.id}`)} tabindex=${item.id === current ? '0' : '-1'} @click=${() => this.choose(item.id, false)}>${item.label}${this.countOf(item)}</button>`)}\n </div>\n ${items.map((item) => html`<div role=\"tabpanel\" id=${this.id_(`panel-${item.id}`)} aria-labelledby=${this.id_(`tab-${item.id}`)} tabindex=\"0\" ?hidden=${item.id !== current} part=\"panel\"><slot name=${item.id}><span class=\"body\">${item.body ?? ''}</span></slot></div>`)}`;\n }\n}\n\ncustomElements.define('impakt-divider', ImpaktDivider);\ncustomElements.define('impakt-spacer', ImpaktSpacer);\ncustomElements.define('impakt-visually-hidden', ImpaktVisuallyHidden);\ncustomElements.define('impakt-tabs', ImpaktTabs);\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-divider': ImpaktDivider; 'impakt-spacer': ImpaktSpacer; 'impakt-visually-hidden': ImpaktVisuallyHidden; 'impakt-tabs': ImpaktTabs;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,KAAK,MAAM,eAAoC;AAejD,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C;AAAA,SAAO,aAAa;AAAA,MAClB,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACvC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IACtC;AAAA;AAAA,EAKA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AAAA,EAEA;AAAA,SAAO,SAAS,CAAC,GAAG,cAAc,QAAQ;AAAA;AAAA,mBAEzB,MAAM,CAAC,CAAC,sCAAsC,EAAE,UAAU,UAAU,EAAE,MAAM;AAAA,wEACvB,EAAE,WAAW;AAAA,+CACtC,MAAM,CAAC,CAAC;AAAA,+CACR,MAAM,CAAC,CAAC;AAAA,+CACR,MAAM,EAAE,CAAC;AAAA,GACrD;AAAA;AAAA,EAED,SAAyB;AACvB,WAAO;AAAA,EACT;AACF;AASO,IAAM,eAAN,cAA2B,cAAc;AAAA,EAC9C;AAAA,SAAO,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK,EAAE;AAAA;AAAA,EAG5D,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AAAA,EACd;AAAA,EAEA;AAAA,SAAO,SAAS,CAAC,GAAG,cAAc,QAAQ;A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,GAAG,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC;AAAA;AAAA,MAEzU,MAAM,IAAI,CAAC,SAAS,+BAA+B,KAAK,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC,oBAAoB,KAAK,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC,yBAAyB,KAAK,OAAO,OAAO,4BAA4B,KAAK,EAAE,uBAAuB,KAAK,QAAQ,EAAE,sBAAsB,CAAC;AAAA,EAC7Q;AACF;AAEA,eAAe,OAAO,kBAAkB,aAAa;AACrD,eAAe,OAAO,iBAAiB,YAAY;AACnD,eAAe,OAAO,0BAA0B,oBAAoB;AACpE,eAAe,OAAO,eAAe,UAAU;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
iconSvg
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WS4AYRSL.js";
|
|
4
4
|
import {
|
|
5
5
|
ImpaktElement,
|
|
6
6
|
focusRing,
|
|
@@ -75,4 +75,4 @@ customElements.define("impakt-link", ImpaktLink);
|
|
|
75
75
|
export {
|
|
76
76
|
ImpaktLink
|
|
77
77
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-INA53XXW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/link.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { focusRing, visuallyHidden } from '../base/styles';\nimport { fontWeight, space, t } from '../base/tokens';\nimport { iconSvg } from './icon';\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 ImpaktLink extends ImpaktElement {\n static properties = {\n href: { type: String },\n external: { type: Boolean, reflect: true },\n externalText: { type: String, attribute: 'external-text' },\n variant: { type: String, reflect: true },\n icon: { type: String },\n };\n\n declare href: string;\n declare external: boolean;\n declare externalText: string;\n /** In a sentence, or on its own line as a call to action, bolder and with an arrow. */\n declare variant: 'inline' | 'standalone';\n /** An icon after the words. A standalone link has an arrow unless it says otherwise. */\n declare icon: 'none' | 'arrow-right' | 'arrow-left' | 'chevron-right' | 'chevron-down' | 'check' | 'close' | 'menu' | 'plus' | 'minus' | 'search' | 'external' | 'download' | 'home' | 'phone' | 'mail' | 'map-pin' | 'calendar' | 'clock' | 'user' | 'star' | 'heart' | 'shield' | 'leaf' | 'sun' | 'bolt' | 'key' | 'info' | 'warning' | 'document' | 'pound' | 'chat' | 'grid' | 'clipboard' | 'map-pinned' | 'users' | 'radio' | 'settings' | 'log-out' | 'arrow-up-right' | 'more' | 'upload' | 'image' | 'lock' | 'eye' | 'trash' | 'pencil' | 'qr-code' | 'battery';\n\n constructor() {\n super();\n this.href = '';\n this.external = false;\n this.externalText = 'opens in a new tab';\n this.variant = 'inline';\n this.icon = 'none';\n }\n\n static styles = [\n ...ImpaktElement.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 :host([variant='standalone']) { display: inline-block; }\n :host([variant='standalone']) a { display: inline-flex; align-items: center; gap: ${space(1)}; font-weight: ${fontWeight('semibold')}; text-decoration-thickness: 1px; }\n :host([variant='standalone']) a:hover .icon { transform: translateX(2px); }\n .icon { flex: none; transition: transform 120ms ease-in-out; }\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>${iconSvg(this.icon !== 'none' ? this.icon : this.variant === 'standalone' ? (this.external ? 'external' : 'arrow-right') : undefined, '1em')}${this.external ? html`<span class=\"sr-only\"> (${this.externalText})</span>` : nothing}\n </a>\n `;\n }\n}\n\ncustomElements.define('impakt-link', ImpaktLink);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-link': ImpaktLink }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAwBjD,IAAM,aAAN,cAAyB,cAAc;AAAA,EAC5C;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,MACzD,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACvC,MAAM,EAAE,MAAM,OAAO;AAAA,IACvB;AAAA;AAAA,EAUA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,WAAW;AAChB,SAAK,eAAe;AACpB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,cAAc;AAAA,MACjB;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,0FAG8D,MAAM,CAAC,CAAC,kBAAkB,WAAW,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA,UAIhI,cAAc;AAAA;AAAA;AAAA,IAGtB;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA;AAAA,eAGI,KAAK,QAAQ,OAAO;AAAA,iBAClB,KAAK,WAAW,WAAW,OAAO;AAAA,cACrC,KAAK,WAAW,wBAAwB,OAAO;AAAA;AAAA,uBAEtC,QAAQ,KAAK,SAAS,SAAS,KAAK,OAAO,KAAK,YAAY,eAAgB,KAAK,WAAW,aAAa,gBAAiB,QAAW,KAAK,CAAC,GAAG,KAAK,WAAW,+BAA+B,KAAK,YAAY,aAAa,OAAO;AAAA;AAAA;AAAA,EAGvP;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
|
|
@@ -76,7 +76,7 @@ var ImpaktTextarea = class extends FieldElement {
|
|
|
76
76
|
if (this.value) return;
|
|
77
77
|
let saved = null;
|
|
78
78
|
try {
|
|
79
|
-
saved = sessionStorage.getItem("
|
|
79
|
+
saved = sessionStorage.getItem("impakt.estimate");
|
|
80
80
|
} catch {
|
|
81
81
|
saved = null;
|
|
82
82
|
}
|
|
@@ -115,4 +115,4 @@ customElements.define("impakt-textarea", ImpaktTextarea);
|
|
|
115
115
|
export {
|
|
116
116
|
ImpaktTextarea
|
|
117
117
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-KFAGXPIK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/textarea.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement, fieldWidths } 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 ImpaktTextarea extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n width: { type: String, reflect: true },\n rows: { type: Number },\n maxlength: { type: Number },\n fillFrom: { type: String, attribute: 'fill-from' },\n };\n\n declare rows: number;\n declare maxlength: number | undefined;\n /** `estimate` starts an empty box with the estimate a cost estimator sent on, so the visitor can edit it. */\n declare fillFrom: 'none' | 'estimate';\n\n /** How wide the box is, to suit the answer. Full width on a phone whatever this says. */\n declare width: 'full' | 'lg' | 'md' | 'sm' | 'xs';\n\n constructor() {\n super();\n this.width = 'full';\n this.rows = 4;\n this.maxlength = undefined;\n this.fillFrom = 'none';\n }\n\n static styles = [\n ...FieldElement.styles,\n fieldWidths,\n css`\n textarea {\n inline-size: min(100%, var(--impakt-field-width));\n padding: ${space(2.5)} ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: var(--impakt-color-field-surface, ${t.surfaceCard});\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n box-shadow: var(--impakt-shadow-field, ${t.shadowXs});\n transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;\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 textarea:hover:not(:disabled) {\n border-color: ${t.borderStrong};\n }\n textarea:focus-visible {\n border-color: ${t.brand};\n box-shadow: ${t.focusShadow}, 0 0 0 6px ${t.brandHalo};\n }\n :host([invalid]) textarea {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n private filled = false;\n /** The estimate it was filled with, kept until the visitor edits it, so a binding that has not caught up yet cannot empty the box. */\n private filledText = '';\n\n /** @ignore */\n protected willUpdate(changed: Map<string, unknown>): void {\n super.willUpdate?.(changed as never);\n if (this.filledText && changed.has('value') && !this.value) this.value = this.filledText;\n }\n\n /** Fills the box once, when it is first asked to and is still empty. Props can arrive after the element joins the page. */\n private fill(): void {\n if (this.filled || this.fillFrom !== 'estimate') return;\n this.filled = true;\n if (this.value) return;\n let saved: string | null = null;\n try { saved = sessionStorage.getItem('
|
|
1
|
+
{"version":3,"sources":["../src/components/textarea.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement, fieldWidths } 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 ImpaktTextarea extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n width: { type: String, reflect: true },\n rows: { type: Number },\n maxlength: { type: Number },\n fillFrom: { type: String, attribute: 'fill-from' },\n };\n\n declare rows: number;\n declare maxlength: number | undefined;\n /** `estimate` starts an empty box with the estimate a cost estimator sent on, so the visitor can edit it. */\n declare fillFrom: 'none' | 'estimate';\n\n /** How wide the box is, to suit the answer. Full width on a phone whatever this says. */\n declare width: 'full' | 'lg' | 'md' | 'sm' | 'xs';\n\n constructor() {\n super();\n this.width = 'full';\n this.rows = 4;\n this.maxlength = undefined;\n this.fillFrom = 'none';\n }\n\n static styles = [\n ...FieldElement.styles,\n fieldWidths,\n css`\n textarea {\n inline-size: min(100%, var(--impakt-field-width));\n padding: ${space(2.5)} ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: var(--impakt-color-field-surface, ${t.surfaceCard});\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n box-shadow: var(--impakt-shadow-field, ${t.shadowXs});\n transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;\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 textarea:hover:not(:disabled) {\n border-color: ${t.borderStrong};\n }\n textarea:focus-visible {\n border-color: ${t.brand};\n box-shadow: ${t.focusShadow}, 0 0 0 6px ${t.brandHalo};\n }\n :host([invalid]) textarea {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n private filled = false;\n /** The estimate it was filled with, kept until the visitor edits it, so a binding that has not caught up yet cannot empty the box. */\n private filledText = '';\n\n /** @ignore */\n protected willUpdate(changed: Map<string, unknown>): void {\n super.willUpdate?.(changed as never);\n if (this.filledText && changed.has('value') && !this.value) this.value = this.filledText;\n }\n\n /** Fills the box once, when it is first asked to and is still empty. Props can arrive after the element joins the page. */\n private fill(): void {\n if (this.filled || this.fillFrom !== 'estimate') return;\n this.filled = true;\n if (this.value) return;\n let saved: string | null = null;\n try { saved = sessionStorage.getItem('impakt.estimate'); } catch { saved = null; }\n if (saved) { this.filledText = saved; this.setFormValue(saved); }\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.filledText = ''; 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 this.fill();\n }\n}\n\ncustomElements.define('impakt-textarea', ImpaktTextarea);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-textarea': ImpaktTextarea }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AASjD,IAAM,iBAAN,cAA6B,aAAa;AAAA,EAiB/C,cAAc;AACZ,UAAM;AAwCR,SAAQ,SAAS;AAEjB;AAAA,SAAQ,aAAa;AAzCnB,SAAK,QAAQ;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AAAA,EAtBA;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,WAAW,EAAE,MAAM,OAAO;AAAA,MAC1B,UAAU,EAAE,MAAM,QAAQ,WAAW,YAAY;AAAA,IACnD;AAAA;AAAA,EAkBA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA,MACA;AAAA;AAAA;AAAA,mBAGe,MAAM,GAAG,CAAC,IAAI,MAAM,CA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