@atomic-ui/ui 0.6.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.
Files changed (67) hide show
  1. package/custom-elements.json +2641 -256
  2. package/dist/{chunk-TAZZLOUY.js → chunk-2HWO5TFV.js} +2 -2
  3. package/dist/chunk-AMDTBUUL.js +299 -0
  4. package/dist/chunk-AMDTBUUL.js.map +1 -0
  5. package/dist/{chunk-EJD6LT7E.js → chunk-BNYILASW.js} +36 -4
  6. package/dist/chunk-BNYILASW.js.map +1 -0
  7. package/dist/{chunk-Q54FX3SY.js → chunk-INA53XXW.js} +2 -2
  8. package/dist/chunk-INA53XXW.js.map +1 -0
  9. package/dist/{chunk-SV77SN6P.js → chunk-MLRTPQQO.js} +39 -2
  10. package/dist/chunk-MLRTPQQO.js.map +1 -0
  11. package/dist/{chunk-ZS7RPXCT.js → chunk-NU34ZQFR.js} +4 -2
  12. package/dist/chunk-NU34ZQFR.js.map +1 -0
  13. package/dist/chunk-NUUX2SSN.js +263 -0
  14. package/dist/chunk-NUUX2SSN.js.map +1 -0
  15. package/dist/{chunk-HNZQ7LM4.js → chunk-OE6O3XQB.js} +78 -3
  16. package/dist/chunk-OE6O3XQB.js.map +1 -0
  17. package/dist/{chunk-WWYYNR3Z.js → chunk-RZWRAJCD.js} +7 -2
  18. package/dist/chunk-RZWRAJCD.js.map +1 -0
  19. package/dist/chunk-UF6KCRNT.js +316 -0
  20. package/dist/chunk-UF6KCRNT.js.map +1 -0
  21. package/dist/{chunk-Z45LY6BT.js → chunk-WH43U4IY.js} +37 -2
  22. package/dist/chunk-WH43U4IY.js.map +1 -0
  23. package/dist/{chunk-5Y3HYRCU.js → chunk-WS4AYRSL.js} +20 -2
  24. package/dist/chunk-WS4AYRSL.js.map +1 -0
  25. package/dist/{chunk-PANH23MF.js → chunk-XZQH2M5I.js} +2 -2
  26. package/dist/components/app-ui.d.ts +6 -1
  27. package/dist/components/app-ui.js +2 -2
  28. package/dist/components/badge.d.ts +7 -2
  29. package/dist/components/badge.js +2 -2
  30. package/dist/components/blocks.d.ts +27 -1
  31. package/dist/components/blocks.js +3 -1
  32. package/dist/components/button.d.ts +24 -3
  33. package/dist/components/button.js +2 -2
  34. package/dist/components/icon.d.ts +19 -1
  35. package/dist/components/icon.js +1 -1
  36. package/dist/components/link.d.ts +1 -1
  37. package/dist/components/link.js +2 -2
  38. package/dist/components/navigation.js +2 -2
  39. package/dist/components/progress.d.ts +11 -0
  40. package/dist/components/progress.js +1 -1
  41. package/dist/components/rows.d.ts +196 -0
  42. package/dist/components/rows.js +16 -0
  43. package/dist/components/rows.js.map +1 -0
  44. package/dist/components/shell.d.ts +166 -0
  45. package/dist/components/shell.js +17 -0
  46. package/dist/components/shell.js.map +1 -0
  47. package/dist/components/switch.d.ts +147 -0
  48. package/dist/components/switch.js +11 -0
  49. package/dist/components/switch.js.map +1 -0
  50. package/dist/components/table.js +2 -2
  51. package/dist/components/text-input.d.ts +14 -1
  52. package/dist/components/text-input.js +2 -1
  53. package/dist/index.d.ts +3 -0
  54. package/dist/index.js +43 -15
  55. package/dist/standalone/atomic-ui.js +929 -285
  56. package/dist/standalone/atomic-ui.js.map +4 -4
  57. package/package.json +2 -2
  58. package/dist/chunk-5Y3HYRCU.js.map +0 -1
  59. package/dist/chunk-EJD6LT7E.js.map +0 -1
  60. package/dist/chunk-HNZQ7LM4.js.map +0 -1
  61. package/dist/chunk-Q54FX3SY.js.map +0 -1
  62. package/dist/chunk-SV77SN6P.js.map +0 -1
  63. package/dist/chunk-WWYYNR3Z.js.map +0 -1
  64. package/dist/chunk-Z45LY6BT.js.map +0 -1
  65. package/dist/chunk-ZS7RPXCT.js.map +0 -1
  66. /package/dist/{chunk-TAZZLOUY.js.map → chunk-2HWO5TFV.js.map} +0 -0
  67. /package/dist/{chunk-PANH23MF.js.map → chunk-XZQH2M5I.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-3IGNZTJU.js";
4
4
  import {
5
5
  iconSvg
6
- } from "./chunk-5Y3HYRCU.js";
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-TAZZLOUY.js.map
328
+ //# sourceMappingURL=chunk-2HWO5TFV.js.map
@@ -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;AA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AAK,IAAI,aAAa,CAAC,uBAAuB,KAAK,WAAW,WACjG,OAAO;AAAA,UACT,KAAK,cAAc,CAAC;AAAA,gCACE,KAAK,IAAI,OAAO,CAAC,oCAAoC,KAAK,SAAS,OAAO;AAAA;AAAA;AAAA,EAGxG;AAAA,EAEA,QAAQ,SAAqC;AAC3C,QAAI,QAAQ,IAAI,OAAO,EAAG,MAAK,gBAAgB,WAAW,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,iBAAiB,YAAY;AACnD,eAAe,OAAO,4BAA4B,sBAAsB;","names":[]}
@@ -1,3 +1,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-EJD6LT7E.js.map
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;AAAA,0CACF,MAAM,CAAC,CAAC;AAAA,uCACX,MAAM,CAAC,CAAC;AAAA,uCACR,MAAM,CAAC,CAAC;AAAA,uCACR,MAAM,EAAE,CAAC;AAAA,wCACR,MAAM,EAAE,CAAC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AAK,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-5Y3HYRCU.js";
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-Q54FX3SY.js.map
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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,OAAO;AAAA;AAAA;AAAA,EAGvP;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
@@ -15,7 +15,8 @@ var ImpaktProgress = class extends ImpaktElement {
15
15
  this.properties = {
16
16
  steps: { type: Array },
17
17
  current: { type: String },
18
- label: { type: String }
18
+ label: { type: String },
19
+ look: { type: String, reflect: true }
19
20
  };
20
21
  }
21
22
  constructor() {
@@ -23,6 +24,7 @@ var ImpaktProgress = class extends ImpaktElement {
23
24
  this.steps = [];
24
25
  this.current = "";
25
26
  this.label = "Progress";
27
+ this.look = "steps";
26
28
  }
27
29
  static {
28
30
  this.styles = [
@@ -58,6 +60,41 @@ var ImpaktProgress = class extends ImpaktElement {
58
60
  .sr-only {
59
61
  ${visuallyHidden}
60
62
  }
63
+ :host([look='bars']) {
64
+ margin-block-end: 0;
65
+ }
66
+ :host([look='bars']) ol {
67
+ gap: ${space(1.5)};
68
+ }
69
+ :host([look='bars']) li {
70
+ position: relative;
71
+ padding-block-start: ${space(3)};
72
+ border: 0;
73
+ font-size: 12px;
74
+ min-inline-size: 0;
75
+ overflow: hidden;
76
+ text-overflow: ellipsis;
77
+ white-space: nowrap;
78
+ }
79
+ :host([look='bars']) li::before {
80
+ content: '';
81
+ position: absolute;
82
+ inset-inline: 0;
83
+ inset-block-start: 0;
84
+ block-size: 5px;
85
+ border-radius: 999px;
86
+ background: ${t.border};
87
+ }
88
+ :host([look='bars']) li[data-state='done']::before {
89
+ background: ${t.text};
90
+ }
91
+ :host([look='bars']) li[data-state='current']::before {
92
+ background: ${t.brand};
93
+ }
94
+ @media (forced-colors: active) {
95
+ :host([look='bars']) li::before { background: GrayText; }
96
+ :host([look='bars']) li[data-state='done']::before, :host([look='bars']) li[data-state='current']::before { background: CanvasText; }
97
+ }
61
98
  /* Below 30rem the labels stop fitting; the position in words is the part
62
99
  that has to survive, so the list collapses to bars and the current
63
100
  step's name. */
@@ -93,4 +130,4 @@ customElements.define("impakt-progress", ImpaktProgress);
93
130
  export {
94
131
  ImpaktProgress
95
132
  };
96
- //# sourceMappingURL=chunk-SV77SN6P.js.map
133
+ //# sourceMappingURL=chunk-MLRTPQQO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/progress.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { say } from '../base/say';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface ProgressStep {\n id: string;\n label: string;\n}\n\n/**\n * Where the customer is in a journey.\n *\n * **It is not a `progressbar`.** That role is for a task completing — a file\n * uploading, a price calculating — and it carries `aria-valuenow`. A journey\n * indicator is navigation: an ordered list of named steps with\n * `aria-current=\"step\"` on the one you are on. Using `progressbar` here\n * announces a percentage and loses the step names, which are the only useful\n * part.\n *\n * **The position is said in words.** \"Step 2 of 5\" is visually hidden and read\n * aloud, because the visual design communicates position through colour and a\n * filled bar, and neither is available to a screen-reader user — nor to anyone\n * who cannot distinguish the filled colour from the empty one, which is 1.4.1.\n\n *\n * @category content\n * @icon progress\n */\nexport class ImpaktProgress extends ImpaktElement {\n static properties = {\n steps: { type: Array },\n current: { type: String },\n label: { type: String },\n look: { type: String, reflect: true },\n };\n\n declare steps: ProgressStep[];\n /** The id of the step being shown. */\n declare current: string;\n declare label: string;\n /**\n * `steps` is the full indicator. `bars` is a compact one for a card: short\n * rounded bars, the done steps in the text colour and the current one in the\n * brand, with small names under them. The current step is also set in a\n * heavier weight, so it does not rest on colour alone.\n */\n declare look: 'steps' | 'bars';\n\n constructor() {\n super();\n this.steps = [];\n this.current = '';\n this.label = 'Progress';\n this.look = 'steps';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host {\n display: block;\n margin-block-end: ${space(5)};\n }\n ol {\n display: flex;\n gap: ${space(2)};\n list-style: none;\n margin: 0;\n padding: 0;\n }\n li {\n flex: 1;\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n padding-block-start: ${space(2)};\n border-block-start: 4px solid ${t.border};\n }\n li[data-state='done'] {\n color: ${t.text};\n border-block-start-color: ${t.brand};\n }\n li[data-state='current'] {\n color: ${t.text};\n font-weight: ${fontWeight('semibold')};\n border-block-start-color: ${t.brand};\n }\n .sr-only {\n ${visuallyHidden}\n }\n :host([look='bars']) {\n margin-block-end: 0;\n }\n :host([look='bars']) ol {\n gap: ${space(1.5)};\n }\n :host([look='bars']) li {\n position: relative;\n padding-block-start: ${space(3)};\n border: 0;\n font-size: 12px;\n min-inline-size: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n :host([look='bars']) li::before {\n content: '';\n position: absolute;\n inset-inline: 0;\n inset-block-start: 0;\n block-size: 5px;\n border-radius: 999px;\n background: ${t.border};\n }\n :host([look='bars']) li[data-state='done']::before {\n background: ${t.text};\n }\n :host([look='bars']) li[data-state='current']::before {\n background: ${t.brand};\n }\n @media (forced-colors: active) {\n :host([look='bars']) li::before { background: GrayText; }\n :host([look='bars']) li[data-state='done']::before, :host([look='bars']) li[data-state='current']::before { background: CanvasText; }\n }\n /* Below 30rem the labels stop fitting; the position in words is the part\n that has to survive, so the list collapses to bars and the current\n step's name. */\n @media (max-width: 30rem) {\n li:not([data-state='current']) span:not(.sr-only) {\n ${visuallyHidden}\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n const index = this.steps.findIndex((s) => s.id === this.current);\n return html`\n <nav part=\"nav\" aria-label=${this.label}>\n <ol part=\"list\">\n ${this.steps.map((step, i) => {\n const state = i < index ? 'done' : i === index ? 'current' : 'todo';\n return html`\n <li data-state=${state} aria-current=${state === 'current' ? 'step' : nothing}>\n ${state === 'current'\n ? html`<span class=\"sr-only\">${say('Step {step} of {steps}:', { step: i + 1, steps: this.steps.length })} </span>`\n : nothing}\n <span>${step.label}</span>\n </li>\n `;\n })}\n </ol>\n </nav>\n `;\n }\n}\n\ncustomElements.define('impakt-progress', ImpaktProgress);\n\ndeclare global {\n interface HTML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K;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAWjB,cAAc;AAAA;AAAA;AAAA;AAAA,IAIxB;AAAA;AAAA,EAEA,SAAyB;AACvB,UAAM,QAAQ,KAAK,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO;AAC/D,WAAO;AAAA,mCACwB,KAAK,KAAK;AAAA;AAAA,YAEjC,KAAK,MAAM,IAAI,CAAC,MAAM,MAAM;AAC5B,YAAM,QAAQ,IAAI,QAAQ,SAAS,MAAM,QAAQ,YAAY;AAC7D,aAAO;AAAA,+BACY,KAAK,iBAAiB,UAAU,YAAY,SAAS,OAAO;AAAA,kBACzE,UAAU,YACR,6BAA6B,IAAI,2BAA2B,EAAE,MAAM,IAAI,GAAG,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,aACtG,OAAO;AAAA,wBACH,KAAK,KAAK;AAAA;AAAA;AAAA,IAGxB,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAIV;AACF;AAEA,eAAe,OAAO,mBAAmB,cAAc;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  iconSvg
3
- } from "./chunk-5Y3HYRCU.js";
3
+ } from "./chunk-WS4AYRSL.js";
4
4
  import {
5
5
  ImpaktElement,
6
6
  fontWeight,
@@ -32,6 +32,8 @@ var ImpaktBadge = class extends ImpaktElement {
32
32
  :host([tone='warning']) span { background: ${t.warningSubtle}; color: ${t.warningText}; }
33
33
  :host([tone='danger']) span { background: ${t.dangerSubtle}; color: ${t.dangerText}; }
34
34
  :host([tone='info']) span { background: ${t.infoSubtle}; color: ${t.infoText}; }
35
+ :host([tone='inverse']) span { background: ${t.text}; color: ${t.surfaceCard}; box-shadow: none; }
36
+ :host([tone='solid']) span { background: ${t.brand}; color: ${t.onBrand}; box-shadow: none; }
35
37
  @media (forced-colors: active) { span { border-color: CanvasText; } }
36
38
  `];
37
39
  }
@@ -44,4 +46,4 @@ customElements.define("impakt-badge", ImpaktBadge);
44
46
  export {
45
47
  ImpaktBadge
46
48
  };
47
- //# sourceMappingURL=chunk-ZS7RPXCT.js.map
49
+ //# sourceMappingURL=chunk-NU34ZQFR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/badge.ts"],"sourcesContent":["/**\n * A short label on something, coloured by its tone.\n */\nimport { css, html, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { fontWeight, space, t, type } from '../base/tokens';\nimport { iconSvg } from './icon';\n\n/**\n * A short label on something: \"New\", \"Selling fast\", \"2 left\".\n *\n * The tone colours it, and the words carry the meaning, so it reads the same\n * without the colour (1.4.1).\n *\n * @category feedback\n * @icon badge\n * @slot - The badge's words.\n */\nexport class ImpaktBadge extends ImpaktElement {\n static properties = {\n tone: { type: String, reflect: true },\n icon: { type: String },\n };\n /**\n * Its colour. `inverse` is the text colour as a fill, for a label that has to\n * stand out on a photo or a light card. `solid` is the brand as a fill, for\n * the one label on a screen that matters most.\n */\n declare tone: 'neutral' | 'brand' | 'success' | 'warning' | 'danger' | 'info' | 'inverse' | 'solid';\n /** An icon before the words. */\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.tone = 'neutral';\n this.icon = 'none';\n }\n\n static styles = [...ImpaktElement.styles, css`\n :host { display: inline-flex; }\n span { display: inline-flex; align-items: center; gap: ${space(1)}; padding: ${space(0.5)} ${space(2)}; border-radius: ${t.radius}; ${type('sm')} font-weight: ${fontWeight('medium')}; background: ${t.surfaceInset}; color: ${t.text}; box-shadow: inset 0 0 0 1px ${t.hairline}; }\n :host([tone='brand']) span { background: ${t.brandSubtle}; color: ${t.brand}; }\n :host([tone='success']) span { background: ${t.successSubtle}; color: ${t.successText}; }\n :host([tone='warning']) span { background: ${t.warningSubtle}; color: ${t.warningText}; }\n :host([tone='danger']) span { background: ${t.dangerSubtle}; color: ${t.dangerText}; }\n :host([tone='info']) span { background: ${t.infoSubtle}; color: ${t.infoText}; }\n :host([tone='inverse']) span { background: ${t.text}; color: ${t.surfaceCard}; box-shadow: none; }\n :host([tone='solid']) span { background: ${t.brand}; color: ${t.onBrand}; box-shadow: none; }\n @media (forced-colors: active) { span { border-color: CanvasText; } }\n `];\n\n render(): TemplateResult {\n return html`<span part=\"badge\">${iconSvg(this.icon, '1em')}<slot></slot></span>`;\n }\n}\n\ncustomElements.define('impakt-badge', ImpaktBadge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-badge': ImpaktBadge;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,KAAK,YAAiC;AAexC,IAAM,cAAN,cAA0B,cAAc;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,MAAM,EAAE,MAAM,OAAO;AAAA,IACvB;AAAA;AAAA,EAUA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AAAA,EAEA;AAAA,SAAO,SAAS,CAAC,GAAG,cAAc,QAAQ;AAAA;AAAA,6DAEiB,MAAM,CAAC,CAAC,cAAc,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,oBAAoB,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,iBAAiB,WAAW,QAAQ,CAAC,iBAAiB,EAAE,YAAY,YAAY,EAAE,IAAI,iCAAiC,EAAE,QAAQ;AAAA,+CACtO,EAAE,WAAW,YAAY,EAAE,KAAK;AAAA,iDAC9B,EAAE,aAAa,YAAY,EAAE,WAAW;AAAA,iDACxC,EAAE,aAAa,YAAY,EAAE,WAAW;AAAA,gDACzC,EAAE,YAAY,YAAY,EAAE,UAAU;AAAA,8CACxC,EAAE,UAAU,YAAY,EAAE,QAAQ;AAAA,iDAC/B,EAAE,IAAI,YAAY,EAAE,WAAW;AAAA,+CACjC,EAAE,KAAK,YAAY,EAAE,OAAO;AAAA;AAAA,GAExE;AAAA;AAAA,EAED,SAAyB;AACvB,WAAO,0BAA0B,QAAQ,KAAK,MAAM,KAAK,CAAC;AAAA,EAC5D;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}