@atomic-ui/ui 0.2.0 → 0.5.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 (219) hide show
  1. package/README.md +88 -105
  2. package/custom-elements.json +6370 -15469
  3. package/dist/base/FieldElement.d.ts +14 -3
  4. package/dist/base/{ImpktElement.d.ts → ImpaktElement.d.ts} +2 -2
  5. package/dist/base/scroll-lock.d.ts +2 -0
  6. package/dist/base/styles.d.ts +31 -5
  7. package/dist/base/tokens.d.ts +1 -1
  8. package/dist/base/tone.d.ts +20 -0
  9. package/dist/chunk-2YRTFWW2.js +26 -0
  10. package/dist/chunk-2YRTFWW2.js.map +1 -0
  11. package/dist/{chunk-7BSZPUE3.js → chunk-3EF4T242.js} +7 -7
  12. package/dist/chunk-3EF4T242.js.map +1 -0
  13. package/dist/{chunk-KFD4O7VA.js → chunk-5Y3HYRCU.js} +7 -7
  14. package/dist/chunk-5Y3HYRCU.js.map +1 -0
  15. package/dist/{chunk-7AJN2TIS.js → chunk-5ZQVL3V2.js} +29 -12
  16. package/dist/chunk-5ZQVL3V2.js.map +1 -0
  17. package/dist/{chunk-NCASAXQT.js → chunk-A7YBFS4H.js} +15 -15
  18. package/dist/chunk-A7YBFS4H.js.map +1 -0
  19. package/dist/{chunk-E2VBUWJ4.js → chunk-ACQ4KYPR.js} +9 -9
  20. package/dist/chunk-ACQ4KYPR.js.map +1 -0
  21. package/dist/{chunk-OMJMUFOW.js → chunk-DE3INTHZ.js} +6 -6
  22. package/dist/chunk-DE3INTHZ.js.map +1 -0
  23. package/dist/chunk-EJD6LT7E.js +161 -0
  24. package/dist/chunk-EJD6LT7E.js.map +1 -0
  25. package/dist/{chunk-XJXCTGDR.js → chunk-EJSX4WCD.js} +9 -9
  26. package/dist/chunk-EJSX4WCD.js.map +1 -0
  27. package/dist/chunk-FMSC7J7J.js +76 -0
  28. package/dist/chunk-FMSC7J7J.js.map +1 -0
  29. package/dist/{chunk-R67PDFKE.js → chunk-FWR6SEIA.js} +33 -33
  30. package/dist/chunk-FWR6SEIA.js.map +1 -0
  31. package/dist/{chunk-FFCIY7NM.js → chunk-GJPHQLLN.js} +8 -8
  32. package/dist/chunk-GJPHQLLN.js.map +1 -0
  33. package/dist/{chunk-OLLZFNO6.js → chunk-HNBG2POR.js} +7 -7
  34. package/dist/chunk-HNBG2POR.js.map +1 -0
  35. package/dist/{chunk-E3XJK7MY.js → chunk-HNZQ7LM4.js} +13 -11
  36. package/dist/chunk-HNZQ7LM4.js.map +1 -0
  37. package/dist/{chunk-3IQ73WNW.js → chunk-I54DOEZB.js} +9 -7
  38. package/dist/chunk-I54DOEZB.js.map +1 -0
  39. package/dist/{chunk-QB2KMV6S.js → chunk-PANH23MF.js} +12 -12
  40. package/dist/chunk-PANH23MF.js.map +1 -0
  41. package/dist/{chunk-UCHJCUYI.js → chunk-PYVUQNFQ.js} +39 -13
  42. package/dist/chunk-PYVUQNFQ.js.map +1 -0
  43. package/dist/{chunk-GQDUHZE3.js → chunk-Q54FX3SY.js} +8 -8
  44. package/dist/chunk-Q54FX3SY.js.map +1 -0
  45. package/dist/{chunk-WFKSOM6O.js → chunk-QBORJTS4.js} +68 -44
  46. package/dist/chunk-QBORJTS4.js.map +1 -0
  47. package/dist/{chunk-TGT7J4EG.js → chunk-RXX4CN5J.js} +7 -7
  48. package/dist/chunk-RXX4CN5J.js.map +1 -0
  49. package/dist/{chunk-XEJMFFIM.js → chunk-SV77SN6P.js} +8 -8
  50. package/dist/chunk-SV77SN6P.js.map +1 -0
  51. package/dist/chunk-TAZZLOUY.js +328 -0
  52. package/dist/chunk-TAZZLOUY.js.map +1 -0
  53. package/dist/{chunk-7OXTZJR4.js → chunk-TRZO5CHU.js} +7 -7
  54. package/dist/chunk-TRZO5CHU.js.map +1 -0
  55. package/dist/{chunk-EDSZI227.js → chunk-UPOTBKKK.js} +12 -9
  56. package/dist/chunk-UPOTBKKK.js.map +1 -0
  57. package/dist/{chunk-26O27BQS.js → chunk-WP5WJ4V5.js} +6 -6
  58. package/dist/chunk-WP5WJ4V5.js.map +1 -0
  59. package/dist/{chunk-YD6IZ2C5.js → chunk-WS5AUJ35.js} +7 -7
  60. package/dist/chunk-WS5AUJ35.js.map +1 -0
  61. package/dist/{chunk-HYPPG4NF.js → chunk-WWYYNR3Z.js} +93 -53
  62. package/dist/chunk-WWYYNR3Z.js.map +1 -0
  63. package/dist/{chunk-NKTMMJYD.js → chunk-XU2XODVH.js} +9 -8
  64. package/dist/chunk-XU2XODVH.js.map +1 -0
  65. package/dist/{chunk-D6C7XEY4.js → chunk-YR6T73GY.js} +24 -12
  66. package/dist/chunk-YR6T73GY.js.map +1 -0
  67. package/dist/{chunk-OB7WULFK.js → chunk-YYYQPKQ7.js} +24 -24
  68. package/dist/chunk-YYYQPKQ7.js.map +1 -0
  69. package/dist/{chunk-FJRHZA3C.js → chunk-Z45LY6BT.js} +9 -9
  70. package/dist/chunk-Z45LY6BT.js.map +1 -0
  71. package/dist/{chunk-6YYAOKNI.js → chunk-ZQBEFP2O.js} +7 -7
  72. package/dist/chunk-ZQBEFP2O.js.map +1 -0
  73. package/dist/chunk-ZS7RPXCT.js +47 -0
  74. package/dist/chunk-ZS7RPXCT.js.map +1 -0
  75. package/dist/components/accordion.d.ts +3 -3
  76. package/dist/components/accordion.js +4 -4
  77. package/dist/components/alert.d.ts +3 -3
  78. package/dist/components/alert.js +4 -4
  79. package/dist/components/app-ui.d.ts +47 -31
  80. package/dist/components/app-ui.js +21 -20
  81. package/dist/components/badge.d.ts +37 -0
  82. package/dist/components/badge.js +9 -0
  83. package/dist/components/blocks.d.ts +37 -74
  84. package/dist/components/blocks.js +10 -13
  85. package/dist/components/button.d.ts +3 -3
  86. package/dist/components/button.js +5 -5
  87. package/dist/components/checkbox-group.d.ts +2 -2
  88. package/dist/components/checkbox-group.js +5 -5
  89. package/dist/components/checkbox.d.ts +2 -2
  90. package/dist/components/checkbox.js +5 -5
  91. package/dist/components/chip.d.ts +58 -0
  92. package/dist/components/chip.js +8 -0
  93. package/dist/components/date-input.d.ts +2 -2
  94. package/dist/components/date-input.js +5 -5
  95. package/dist/components/dialog.d.ts +18 -3
  96. package/dist/components/dialog.js +5 -4
  97. package/dist/components/fieldset.d.ts +3 -3
  98. package/dist/components/fieldset.js +4 -4
  99. package/dist/components/grid.d.ts +3 -3
  100. package/dist/components/grid.js +4 -4
  101. package/dist/components/help.d.ts +3 -3
  102. package/dist/components/help.js +4 -4
  103. package/dist/components/icon.d.ts +3 -3
  104. package/dist/components/icon.js +4 -4
  105. package/dist/components/journey.d.ts +30 -16
  106. package/dist/components/journey.js +15 -15
  107. package/dist/components/layout.d.ts +9 -9
  108. package/dist/components/layout.js +10 -10
  109. package/dist/components/link.d.ts +3 -3
  110. package/dist/components/link.js +5 -5
  111. package/dist/components/list.d.ts +3 -3
  112. package/dist/components/list.js +4 -4
  113. package/dist/components/media.d.ts +8 -8
  114. package/dist/components/media.js +8 -8
  115. package/dist/components/navigation.d.ts +5 -5
  116. package/dist/components/navigation.js +7 -7
  117. package/dist/components/page.d.ts +5 -5
  118. package/dist/components/page.js +6 -6
  119. package/dist/components/price.d.ts +3 -3
  120. package/dist/components/price.js +4 -4
  121. package/dist/components/progress.d.ts +3 -3
  122. package/dist/components/progress.js +4 -4
  123. package/dist/components/radio-group.d.ts +2 -2
  124. package/dist/components/radio-group.js +5 -5
  125. package/dist/components/select.d.ts +2 -2
  126. package/dist/components/select.js +5 -5
  127. package/dist/components/summary-list.d.ts +3 -3
  128. package/dist/components/summary-list.js +4 -4
  129. package/dist/components/table.d.ts +97 -5
  130. package/dist/components/table.js +6 -4
  131. package/dist/components/text-input.d.ts +2 -2
  132. package/dist/components/text-input.js +5 -5
  133. package/dist/components/textarea.d.ts +2 -2
  134. package/dist/components/textarea.js +5 -5
  135. package/dist/index.d.ts +47 -40
  136. package/dist/index.js +206 -269
  137. package/dist/standalone/atomic-ui.js +1928 -0
  138. package/dist/standalone/atomic-ui.js.map +7 -0
  139. package/dist/standalone/index.html +173 -0
  140. package/package.json +19 -7
  141. package/scripts/copy-to-product.mjs +52 -0
  142. package/specimen/index.html +173 -0
  143. package/dist/chunk-26O27BQS.js.map +0 -1
  144. package/dist/chunk-2CFVV2NZ.js +0 -494
  145. package/dist/chunk-2CFVV2NZ.js.map +0 -1
  146. package/dist/chunk-3IQ73WNW.js.map +0 -1
  147. package/dist/chunk-4X723QBD.js +0 -361
  148. package/dist/chunk-4X723QBD.js.map +0 -1
  149. package/dist/chunk-6YYAOKNI.js.map +0 -1
  150. package/dist/chunk-7AJN2TIS.js.map +0 -1
  151. package/dist/chunk-7BSZPUE3.js.map +0 -1
  152. package/dist/chunk-7OXTZJR4.js.map +0 -1
  153. package/dist/chunk-7XEPNEVQ.js +0 -264
  154. package/dist/chunk-7XEPNEVQ.js.map +0 -1
  155. package/dist/chunk-D6C7XEY4.js.map +0 -1
  156. package/dist/chunk-E2VBUWJ4.js.map +0 -1
  157. package/dist/chunk-E3XJK7MY.js.map +0 -1
  158. package/dist/chunk-EDSZI227.js.map +0 -1
  159. package/dist/chunk-FFCIY7NM.js.map +0 -1
  160. package/dist/chunk-FJRHZA3C.js.map +0 -1
  161. package/dist/chunk-GQDUHZE3.js.map +0 -1
  162. package/dist/chunk-HYPPG4NF.js.map +0 -1
  163. package/dist/chunk-J4JULXUG.js +0 -249
  164. package/dist/chunk-J4JULXUG.js.map +0 -1
  165. package/dist/chunk-KFD4O7VA.js.map +0 -1
  166. package/dist/chunk-MVEFM5QI.js +0 -195
  167. package/dist/chunk-MVEFM5QI.js.map +0 -1
  168. package/dist/chunk-NCASAXQT.js.map +0 -1
  169. package/dist/chunk-NKTMMJYD.js.map +0 -1
  170. package/dist/chunk-OB7WULFK.js.map +0 -1
  171. package/dist/chunk-OHDPGIJ3.js +0 -428
  172. package/dist/chunk-OHDPGIJ3.js.map +0 -1
  173. package/dist/chunk-OLLZFNO6.js.map +0 -1
  174. package/dist/chunk-OMJMUFOW.js.map +0 -1
  175. package/dist/chunk-QB2KMV6S.js.map +0 -1
  176. package/dist/chunk-R67PDFKE.js.map +0 -1
  177. package/dist/chunk-RZSZQMSE.js +0 -236
  178. package/dist/chunk-RZSZQMSE.js.map +0 -1
  179. package/dist/chunk-TGT7J4EG.js.map +0 -1
  180. package/dist/chunk-UCHJCUYI.js.map +0 -1
  181. package/dist/chunk-UHLRXI6J.js +0 -453
  182. package/dist/chunk-UHLRXI6J.js.map +0 -1
  183. package/dist/chunk-UNVL3CNM.js +0 -725
  184. package/dist/chunk-UNVL3CNM.js.map +0 -1
  185. package/dist/chunk-WDDWWCHN.js +0 -104
  186. package/dist/chunk-WDDWWCHN.js.map +0 -1
  187. package/dist/chunk-WFKSOM6O.js.map +0 -1
  188. package/dist/chunk-XEJMFFIM.js.map +0 -1
  189. package/dist/chunk-XJXCTGDR.js.map +0 -1
  190. package/dist/chunk-YD6IZ2C5.js.map +0 -1
  191. package/dist/chunk-YK5QI57J.js +0 -396
  192. package/dist/chunk-YK5QI57J.js.map +0 -1
  193. package/dist/components/changelog.d.ts +0 -386
  194. package/dist/components/changelog.js +0 -25
  195. package/dist/components/estimator.d.ts +0 -246
  196. package/dist/components/estimator.js +0 -16
  197. package/dist/components/marketing.d.ts +0 -370
  198. package/dist/components/marketing.js +0 -21
  199. package/dist/components/marketing.js.map +0 -1
  200. package/dist/components/organisms.d.ts +0 -559
  201. package/dist/components/organisms.js +0 -25
  202. package/dist/components/organisms.js.map +0 -1
  203. package/dist/components/property.d.ts +0 -389
  204. package/dist/components/property.js +0 -20
  205. package/dist/components/property.js.map +0 -1
  206. package/dist/components/scene.d.ts +0 -138
  207. package/dist/components/scene.js +0 -8
  208. package/dist/components/scene.js.map +0 -1
  209. package/dist/components/scrubber.d.ts +0 -86
  210. package/dist/components/scrubber.js +0 -8
  211. package/dist/components/scrubber.js.map +0 -1
  212. package/dist/components/selling.d.ts +0 -407
  213. package/dist/components/selling.js +0 -25
  214. package/dist/components/selling.js.map +0 -1
  215. package/dist/components/site.d.ts +0 -283
  216. package/dist/components/site.js +0 -20
  217. package/dist/components/site.js.map +0 -1
  218. /package/dist/components/{changelog.js.map → badge.js.map} +0 -0
  219. /package/dist/components/{estimator.js.map → chip.js.map} +0 -0
@@ -0,0 +1,328 @@
1
+ import {
2
+ pageLocale
3
+ } from "./chunk-3IGNZTJU.js";
4
+ import {
5
+ iconSvg
6
+ } from "./chunk-5Y3HYRCU.js";
7
+ import {
8
+ ImpaktElement,
9
+ focusRing,
10
+ fontSize,
11
+ fontWeight,
12
+ space,
13
+ t,
14
+ touchTarget,
15
+ visuallyHidden
16
+ } from "./chunk-YR6T73GY.js";
17
+
18
+ // packages/ui/src/components/table.ts
19
+ import { html, css, nothing } from "lit";
20
+ var ImpaktTable = class extends ImpaktElement {
21
+ static {
22
+ this.properties = {
23
+ caption: { type: String },
24
+ columns: { type: Array },
25
+ rows: { type: Array },
26
+ sortKey: { type: String, attribute: "sort-key", reflect: true },
27
+ sortDirection: { type: String, attribute: "sort-direction", reflect: true },
28
+ manualSort: { type: Boolean, attribute: "manual-sort" },
29
+ selectable: { type: Boolean, reflect: true },
30
+ selected: { type: Array },
31
+ rowKey: { type: String, attribute: "row-key" },
32
+ stack: { type: Boolean, reflect: true },
33
+ emptyText: { type: String, attribute: "empty-text" },
34
+ selectAllText: { type: String, attribute: "select-all-text" },
35
+ selectRowText: { type: String, attribute: "select-row-text" }
36
+ };
37
+ }
38
+ constructor() {
39
+ super();
40
+ this.caption = "";
41
+ this.columns = [];
42
+ this.rows = [];
43
+ this.sortKey = "";
44
+ this.sortDirection = "ascending";
45
+ this.manualSort = false;
46
+ this.selectable = false;
47
+ this.selected = [];
48
+ this.rowKey = "id";
49
+ this.stack = false;
50
+ this.emptyText = "Nothing to show";
51
+ this.selectAllText = "Select all rows";
52
+ this.selectRowText = "Select {row}";
53
+ }
54
+ static {
55
+ this.styles = [
56
+ ...ImpaktElement.styles,
57
+ focusRing,
58
+ touchTarget(".sort, .pick label"),
59
+ css`
60
+ :host {
61
+ display: block;
62
+ }
63
+ :host([stack]) {
64
+ container-type: inline-size;
65
+ }
66
+ .scroller {
67
+ overflow-x: auto;
68
+ }
69
+ table {
70
+ inline-size: 100%;
71
+ border-collapse: collapse;
72
+ font-size: ${fontSize("md")};
73
+ }
74
+ caption {
75
+ text-align: start;
76
+ font-weight: ${fontWeight("semibold")};
77
+ padding-block-end: ${space(2)};
78
+ }
79
+ th,
80
+ td {
81
+ text-align: start;
82
+ padding: ${space(3)};
83
+ border-block-end: ${t.borderThin} solid ${t.rule};
84
+ }
85
+ thead th {
86
+ font-weight: ${fontWeight("semibold")};
87
+ background: ${t.surfaceInset};
88
+ }
89
+ tbody th {
90
+ font-weight: ${fontWeight("semibold")};
91
+ }
92
+ .numeric {
93
+ /* A figure read across a line break is a different figure. */
94
+ white-space: nowrap;
95
+ text-align: end;
96
+ font-variant-numeric: tabular-nums;
97
+ }
98
+ th.sortable {
99
+ padding: ${space(1)};
100
+ }
101
+ .sort {
102
+ display: inline-flex;
103
+ align-items: center;
104
+ gap: ${space(1)};
105
+ min-block-size: ${t.targetMin};
106
+ padding: ${space(2)};
107
+ font: inherit;
108
+ color: inherit;
109
+ background: none;
110
+ border: 0;
111
+ border-radius: ${t.radius};
112
+ cursor: pointer;
113
+ }
114
+ .sort:hover {
115
+ background: ${t.wash};
116
+ }
117
+ .numeric .sort {
118
+ flex-direction: row-reverse;
119
+ }
120
+ .arrow {
121
+ display: inline-flex;
122
+ color: ${t.textMuted};
123
+ transition: transform 140ms ease-in-out;
124
+ }
125
+ [aria-sort] .arrow {
126
+ color: inherit;
127
+ }
128
+ [aria-sort='ascending'] .arrow {
129
+ transform: rotate(180deg);
130
+ }
131
+ :not([aria-sort]) > .sort .arrow {
132
+ opacity: 0.45;
133
+ }
134
+ .pick {
135
+ inline-size: 1%;
136
+ padding-block: 0;
137
+ padding-inline-end: 0;
138
+ }
139
+ .pick label {
140
+ display: inline-flex;
141
+ align-items: center;
142
+ justify-content: center;
143
+ min-block-size: ${t.targetMin};
144
+ min-inline-size: ${t.targetMin};
145
+ cursor: pointer;
146
+ }
147
+ .pick input {
148
+ inline-size: 20px;
149
+ block-size: 20px;
150
+ margin: 0;
151
+ accent-color: ${t.brand};
152
+ cursor: pointer;
153
+ }
154
+ tr.chosen > * {
155
+ background: ${t.brandSubtle};
156
+ }
157
+ .empty {
158
+ padding-block: ${space(6)};
159
+ text-align: center;
160
+ color: ${t.textMuted};
161
+ }
162
+ .label {
163
+ display: none;
164
+ }
165
+ .visually-hidden {
166
+ ${visuallyHidden}
167
+ }
168
+ /* Stacked: each row a card, each value under its column's name. */
169
+ @container (max-width: 36rem) {
170
+ table, tbody, tr, tbody th, tbody td {
171
+ display: block;
172
+ }
173
+ thead tr {
174
+ display: flex;
175
+ flex-wrap: wrap;
176
+ align-items: center;
177
+ gap: ${space(1)};
178
+ margin-block-end: ${space(3)};
179
+ }
180
+ thead th {
181
+ display: none;
182
+ padding: 0;
183
+ border: 0;
184
+ background: none;
185
+ }
186
+ thead th.sortable, thead th.pick {
187
+ display: block;
188
+ inline-size: auto;
189
+ }
190
+ thead .sort {
191
+ border: ${t.borderThin} solid ${t.rule};
192
+ border-radius: 999px;
193
+ padding-inline: ${space(3)};
194
+ background: ${t.surfaceCard};
195
+ }
196
+ tbody tr {
197
+ position: relative;
198
+ margin-block-end: ${space(3)};
199
+ padding: ${space(3)} ${space(4)};
200
+ border: ${t.borderThin} solid ${t.rule};
201
+ border-radius: ${t.radiusXl};
202
+ background: ${t.surfaceCard};
203
+ }
204
+ tbody tr.chosen {
205
+ background: ${t.brandSubtle};
206
+ }
207
+ tr.chosen > * {
208
+ background: none;
209
+ }
210
+ tbody th, tbody td {
211
+ display: grid;
212
+ grid-template-columns: minmax(6rem, 38%) minmax(0, 1fr);
213
+ gap: ${space(3)};
214
+ padding: ${space(1.5)} 0;
215
+ border: 0;
216
+ text-align: start;
217
+ white-space: normal;
218
+ }
219
+ tbody td.numeric {
220
+ text-align: start;
221
+ }
222
+ tbody .pick {
223
+ display: block;
224
+ position: absolute;
225
+ inset-block-start: ${space(1)};
226
+ inset-inline-end: ${space(1)};
227
+ inline-size: auto;
228
+ padding: 0;
229
+ }
230
+ tbody tr:has(.pick) > th {
231
+ padding-inline-end: ${space(10)};
232
+ }
233
+ .label {
234
+ display: block;
235
+ font-size: ${fontSize("sm")};
236
+ font-weight: ${fontWeight("semibold")};
237
+ color: ${t.textMuted};
238
+ }
239
+ .empty {
240
+ display: block;
241
+ border: 0;
242
+ }
243
+ }
244
+ `
245
+ ];
246
+ }
247
+ keyOf(row, index) {
248
+ const key = row?.[this.rowKey];
249
+ return key === void 0 || key === null || key === "" ? String(index) : String(key);
250
+ }
251
+ /** The rows in the order they are drawn: as given, or sorted by the chosen column. */
252
+ ordered() {
253
+ const rows = (this.rows ?? []).map((row, i) => ({ row, key: this.keyOf(row, i) }));
254
+ const column = (this.columns ?? []).find((c) => c.key === this.sortKey && c.sortable);
255
+ if (!column || this.manualSort) return rows;
256
+ const way = this.sortDirection === "descending" ? -1 : 1;
257
+ const locale = pageLocale(this);
258
+ const figure = (v) => Number(String(v ?? "").replace(/[^\d.-]/g, "")) || 0;
259
+ return rows.sort((a, b) => {
260
+ const x = a.row[column.key] ?? "";
261
+ const y = b.row[column.key] ?? "";
262
+ const order = column.numeric ? figure(x) - figure(y) : String(x).localeCompare(String(y), locale, { numeric: true, sensitivity: "base" });
263
+ return order * way;
264
+ });
265
+ }
266
+ sortBy(key) {
267
+ const direction = this.sortKey === key && this.sortDirection === "ascending" ? "descending" : "ascending";
268
+ this.sortKey = key;
269
+ this.sortDirection = direction;
270
+ this.dispatchEvent(new CustomEvent("impakt-sort", { detail: { key, direction }, bubbles: true, composed: true }));
271
+ }
272
+ choose(keys, on) {
273
+ const now = new Set(this.selected ?? []);
274
+ for (const key of keys) {
275
+ if (on) now.add(key);
276
+ else now.delete(key);
277
+ }
278
+ this.selected = [...now];
279
+ this.dispatchEvent(new CustomEvent("impakt-selection", { detail: { selected: this.selected }, bubbles: true, composed: true }));
280
+ }
281
+ heading(c) {
282
+ const sorted = c.sortable && c.key === this.sortKey;
283
+ const classes = [c.numeric ? "numeric" : "", c.sortable ? "sortable" : ""].filter(Boolean).join(" ");
284
+ if (!c.sortable) return html`<th scope="col" role="columnheader" class=${classes}>${c.label}</th>`;
285
+ return html`<th scope="col" role="columnheader" class=${classes} aria-sort=${sorted ? this.sortDirection : nothing}>
286
+ <button class="sort" type="button" part="sort" @click=${() => this.sortBy(c.key)}>${c.label}<span class="arrow" aria-hidden="true">${iconSvg("chevron-down", "16px")}</span></button>
287
+ </th>`;
288
+ }
289
+ render() {
290
+ const columns = this.columns ?? [];
291
+ const rows = this.ordered();
292
+ const chosen = new Set(this.selected ?? []);
293
+ const every = rows.length > 0 && rows.every((r) => chosen.has(r.key));
294
+ const some = !every && rows.some((r) => chosen.has(r.key));
295
+ return html`
296
+ <div class="scroller" part="scroller" tabindex="0" role="region" aria-label=${this.caption || nothing}>
297
+ <table part="table" role="table">
298
+ ${this.caption ? html`<caption part="caption">${this.caption}</caption>` : nothing}
299
+ <thead role="rowgroup">
300
+ <tr role="row">
301
+ ${this.selectable ? html`<th scope="col" role="columnheader" class="pick"><label><input type="checkbox" aria-label=${this.selectAllText} .checked=${every} .indeterminate=${some} ?disabled=${!rows.length}
302
+ @change=${(e) => this.choose(rows.map((r) => r.key), e.target.checked)} /></label></th>` : nothing}
303
+ ${columns.map((c) => this.heading(c))}
304
+ </tr>
305
+ </thead>
306
+ <tbody role="rowgroup">
307
+ ${rows.length ? rows.map(({ row, key }, i) => html`
308
+ <tr role="row" class=${chosen.has(key) ? "chosen" : ""} part="row">
309
+ ${this.selectable ? html`<td role="cell" class="pick"><label><input type="checkbox" aria-label=${this.selectRowText.replace("{row}", String(row[columns[0]?.key ?? ""] ?? key))} .checked=${chosen.has(key)}
310
+ @change=${(e) => this.choose([key], e.target.checked)} /></label></td>` : nothing}
311
+ ${columns.map((c, j) => {
312
+ const value = html`<span class="label" aria-hidden="true">${c.label}</span><span class="value"><slot name=${`cell:${key}:${c.key}`}>${row[c.key] ?? ""}</slot></span>`;
313
+ return j === 0 ? html`<th scope="row" role="rowheader" id=${`${this.uid}-r${i}`}>${value}</th>` : html`<td role="cell" class=${c.numeric ? "numeric" : ""}>${value}</td>`;
314
+ })}
315
+ </tr>
316
+ `) : html`<tr role="row"><td role="cell" class="empty" colspan=${columns.length + (this.selectable ? 1 : 0) || 1}><slot name="empty">${this.emptyText}</slot></td></tr>`}
317
+ </tbody>
318
+ </table>
319
+ </div>
320
+ `;
321
+ }
322
+ };
323
+ customElements.define("impakt-table", ImpaktTable);
324
+
325
+ export {
326
+ ImpaktTable
327
+ };
328
+ //# sourceMappingURL=chunk-TAZZLOUY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/table.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { pageLocale } from '../base/locale';\nimport { focusRing, touchTarget, visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\nimport { iconSvg } from './icon';\n\nexport interface TableColumn {\n key: string;\n label: string;\n numeric?: boolean;\n /** Let the rows be sorted by this column. Its heading becomes a button. */\n sortable?: boolean;\n}\n\n/** Which way a sorted column runs, in the words `aria-sort` uses. */\nexport type SortDirection = 'ascending' | 'descending';\n\n/**\n * A data table — a plan comparison, a payment schedule, a list of cases.\n *\n * **The caption is required.** It is the table's name, and a page with three\n * unnamed tables is a page a screen-reader user has to read in full to tell\n * apart. Visually it can be the heading they would have written anyway.\n *\n * **It scrolls, and the scroller is focusable.** A wide table cannot reflow to\n * 320px without becoming unreadable, so it scrolls horizontally — and a region\n * that scrolls must be reachable by keyboard, or a keyboard user simply cannot\n * see the right-hand columns. `tabindex=\"0\"` with a role and a name is the\n * established fix, and the name is why the role is there: a bare focusable div\n * announces nothing.\n *\n * **Or it stacks.** With `stack`, a narrow table turns each row into a card,\n * with each value under the name of its column, so a phone reads a list of\n * cases rather than scrolling a grid. The table keeps its roles written out,\n * because some browsers drop a table's meaning once it is no longer drawn as one.\n *\n * **Sorting is announced.** A sortable column's heading is a button, and the\n * column the rows are sorted by carries `aria-sort`, so a screen reader says\n * \"Opened, sorted descending\" rather than leaving the order to be guessed. The\n * table sorts its own rows unless `manual-sort` says the app does it, as an app\n * that pages its rows on the server must.\n *\n * **Rows can be chosen.** With `selectable`, each row has a checkbox named by\n * the row's first cell, and the heading has one for every row. A row is known by\n * its `id`, or by the key `row-key` names.\n *\n * A cell can hold more than words: give the table a child with\n * `slot=\"cell:{row id}:{column key}\"`, such as a badge, and it is drawn in that\n * cell. With no rows the table says `empty-text`, or shows a child with\n * `slot=\"empty\"`.\n *\n * @category content\n * @icon table\n * @slot empty - What to show when there are no rows, in place of the empty text.\n * @fires {CustomEvent<{ key: string; direction: SortDirection }>} impakt-sort - When a column heading is pressed to sort the rows.\n * @fires {CustomEvent<{ selected: string[] }>} impakt-selection - When rows are chosen or let go. The ids are in detail.selected.\n */\nexport class ImpaktTable extends ImpaktElement {\n static properties = {\n caption: { type: String },\n columns: { type: Array },\n rows: { type: Array },\n sortKey: { type: String, attribute: 'sort-key', reflect: true },\n sortDirection: { type: String, attribute: 'sort-direction', reflect: true },\n manualSort: { type: Boolean, attribute: 'manual-sort' },\n selectable: { type: Boolean, reflect: true },\n selected: { type: Array },\n rowKey: { type: String, attribute: 'row-key' },\n stack: { type: Boolean, reflect: true },\n emptyText: { type: String, attribute: 'empty-text' },\n selectAllText: { type: String, attribute: 'select-all-text' },\n selectRowText: { type: String, attribute: 'select-row-text' },\n };\n\n declare caption: string;\n declare columns: TableColumn[];\n declare rows: Array<Record<string, string>>;\n /** The key of the column the rows are sorted by. Empty leaves them in the order given. */\n declare sortKey: string;\n declare sortDirection: SortDirection;\n /** The app sorts the rows itself, on `impakt-sort`. The table only shows which column and which way. */\n declare manualSort: boolean;\n /** Each row has a checkbox, and the heading one for every row. */\n declare selectable: boolean;\n /** The ids of the chosen rows. */\n declare selected: string[];\n /** The key in each row that tells rows apart. */\n declare rowKey: string;\n /** On a narrow screen, draw each row as a card rather than scroll the table sideways. */\n declare stack: boolean;\n /** What the table says when it has no rows. */\n declare emptyText: string;\n /** The name of the checkbox that chooses every row. */\n declare selectAllText: string;\n /** The name of each row's checkbox, with `{row}` for the row's first cell. */\n declare selectRowText: string;\n\n constructor() {\n super();\n this.caption = '';\n this.columns = [];\n this.rows = [];\n this.sortKey = '';\n this.sortDirection = 'ascending';\n this.manualSort = false;\n this.selectable = false;\n this.selected = [];\n this.rowKey = 'id';\n this.stack = false;\n this.emptyText = 'Nothing to show';\n this.selectAllText = 'Select all rows';\n this.selectRowText = 'Select {row}';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n touchTarget('.sort, .pick label'),\n css`\n :host {\n display: block;\n }\n :host([stack]) {\n container-type: inline-size;\n }\n .scroller {\n overflow-x: auto;\n }\n table {\n inline-size: 100%;\n border-collapse: collapse;\n font-size: ${fontSize('md')};\n }\n caption {\n text-align: start;\n font-weight: ${fontWeight('semibold')};\n padding-block-end: ${space(2)};\n }\n th,\n td {\n text-align: start;\n padding: ${space(3)};\n border-block-end: ${t.borderThin} solid ${t.rule};\n }\n thead th {\n font-weight: ${fontWeight('semibold')};\n background: ${t.surfaceInset};\n }\n tbody th {\n font-weight: ${fontWeight('semibold')};\n }\n .numeric {\n /* A figure read across a line break is a different figure. */\n white-space: nowrap;\n text-align: end;\n font-variant-numeric: tabular-nums;\n }\n th.sortable {\n padding: ${space(1)};\n }\n .sort {\n display: inline-flex;\n align-items: center;\n gap: ${space(1)};\n min-block-size: ${t.targetMin};\n padding: ${space(2)};\n font: inherit;\n color: inherit;\n background: none;\n border: 0;\n border-radius: ${t.radius};\n cursor: pointer;\n }\n .sort:hover {\n background: ${t.wash};\n }\n .numeric .sort {\n flex-direction: row-reverse;\n }\n .arrow {\n display: inline-flex;\n color: ${t.textMuted};\n transition: transform 140ms ease-in-out;\n }\n [aria-sort] .arrow {\n color: inherit;\n }\n [aria-sort='ascending'] .arrow {\n transform: rotate(180deg);\n }\n :not([aria-sort]) > .sort .arrow {\n opacity: 0.45;\n }\n .pick {\n inline-size: 1%;\n padding-block: 0;\n padding-inline-end: 0;\n }\n .pick label {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-block-size: ${t.targetMin};\n min-inline-size: ${t.targetMin};\n cursor: pointer;\n }\n .pick input {\n inline-size: 20px;\n block-size: 20px;\n margin: 0;\n accent-color: ${t.brand};\n cursor: pointer;\n }\n tr.chosen > * {\n background: ${t.brandSubtle};\n }\n .empty {\n padding-block: ${space(6)};\n text-align: center;\n color: ${t.textMuted};\n }\n .label {\n display: none;\n }\n .visually-hidden {\n ${visuallyHidden}\n }\n /* Stacked: each row a card, each value under its column's name. */\n @container (max-width: 36rem) {\n table, tbody, tr, tbody th, tbody td {\n display: block;\n }\n thead tr {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: ${space(1)};\n margin-block-end: ${space(3)};\n }\n thead th {\n display: none;\n padding: 0;\n border: 0;\n background: none;\n }\n thead th.sortable, thead th.pick {\n display: block;\n inline-size: auto;\n }\n thead .sort {\n border: ${t.borderThin} solid ${t.rule};\n border-radius: 999px;\n padding-inline: ${space(3)};\n background: ${t.surfaceCard};\n }\n tbody tr {\n position: relative;\n margin-block-end: ${space(3)};\n padding: ${space(3)} ${space(4)};\n border: ${t.borderThin} solid ${t.rule};\n border-radius: ${t.radiusXl};\n background: ${t.surfaceCard};\n }\n tbody tr.chosen {\n background: ${t.brandSubtle};\n }\n tr.chosen > * {\n background: none;\n }\n tbody th, tbody td {\n display: grid;\n grid-template-columns: minmax(6rem, 38%) minmax(0, 1fr);\n gap: ${space(3)};\n padding: ${space(1.5)} 0;\n border: 0;\n text-align: start;\n white-space: normal;\n }\n tbody td.numeric {\n text-align: start;\n }\n tbody .pick {\n display: block;\n position: absolute;\n inset-block-start: ${space(1)};\n inset-inline-end: ${space(1)};\n inline-size: auto;\n padding: 0;\n }\n tbody tr:has(.pick) > th {\n padding-inline-end: ${space(10)};\n }\n .label {\n display: block;\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('semibold')};\n color: ${t.textMuted};\n }\n .empty {\n display: block;\n border: 0;\n }\n }\n `,\n ];\n\n private keyOf(row: Record<string, string>, index: number): string {\n const key = row?.[this.rowKey];\n return key === undefined || key === null || key === '' ? String(index) : String(key);\n }\n\n /** The rows in the order they are drawn: as given, or sorted by the chosen column. */\n private ordered(): Array<{ row: Record<string, string>; key: string }> {\n const rows = (this.rows ?? []).map((row, i) => ({ row, key: this.keyOf(row, i) }));\n const column = (this.columns ?? []).find((c) => c.key === this.sortKey && c.sortable);\n if (!column || this.manualSort) return rows;\n const way = this.sortDirection === 'descending' ? -1 : 1;\n const locale = pageLocale(this);\n const figure = (v: unknown) => Number(String(v ?? '').replace(/[^\\d.-]/g, '')) || 0;\n return rows.sort((a, b) => {\n const x = a.row[column.key] ?? '';\n const y = b.row[column.key] ?? '';\n const order = column.numeric ? figure(x) - figure(y) : String(x).localeCompare(String(y), locale, { numeric: true, sensitivity: 'base' });\n return order * way;\n });\n }\n\n private sortBy(key: string): void {\n const direction: SortDirection = this.sortKey === key && this.sortDirection === 'ascending' ? 'descending' : 'ascending';\n this.sortKey = key;\n this.sortDirection = direction;\n this.dispatchEvent(new CustomEvent('impakt-sort', { detail: { key, direction }, bubbles: true, composed: true }));\n }\n\n private choose(keys: string[], on: boolean): void {\n const now = new Set(this.selected ?? []);\n for (const key of keys) {\n if (on) now.add(key);\n else now.delete(key);\n }\n this.selected = [...now];\n this.dispatchEvent(new CustomEvent('impakt-selection', { detail: { selected: this.selected }, bubbles: true, composed: true }));\n }\n\n private heading(c: TableColumn): TemplateResult {\n const sorted = c.sortable && c.key === this.sortKey;\n const classes = [c.numeric ? 'numeric' : '', c.sortable ? 'sortable' : ''].filter(Boolean).join(' ');\n if (!c.sortable) return html`<th scope=\"col\" role=\"columnheader\" class=${classes}>${c.label}</th>`;\n return html`<th scope=\"col\" role=\"columnheader\" class=${classes} aria-sort=${sorted ? this.sortDirection : nothing}>\n <button class=\"sort\" type=\"button\" part=\"sort\" @click=${() => this.sortBy(c.key)}>${c.label}<span class=\"arrow\" aria-hidden=\"true\">${iconSvg('chevron-down', '16px')}</span></button>\n </th>`;\n }\n\n render(): TemplateResult {\n const columns = this.columns ?? [];\n const rows = this.ordered();\n const chosen = new Set(this.selected ?? []);\n const every = rows.length > 0 && rows.every((r) => chosen.has(r.key));\n const some = !every && rows.some((r) => chosen.has(r.key));\n return html`\n <div class=\"scroller\" part=\"scroller\" tabindex=\"0\" role=\"region\" aria-label=${this.caption || nothing}>\n <table part=\"table\" role=\"table\">\n ${this.caption ? html`<caption part=\"caption\">${this.caption}</caption>` : nothing}\n <thead role=\"rowgroup\">\n <tr role=\"row\">\n ${this.selectable\n ? html`<th scope=\"col\" role=\"columnheader\" class=\"pick\"><label><input type=\"checkbox\" aria-label=${this.selectAllText} .checked=${every} .indeterminate=${some} ?disabled=${!rows.length}\n @change=${(e: Event) => this.choose(rows.map((r) => r.key), (e.target as HTMLInputElement).checked)} /></label></th>`\n : nothing}\n ${columns.map((c) => this.heading(c))}\n </tr>\n </thead>\n <tbody role=\"rowgroup\">\n ${rows.length\n ? rows.map(({ row, key }, i) => html`\n <tr role=\"row\" class=${chosen.has(key) ? 'chosen' : ''} part=\"row\">\n ${this.selectable\n ? html`<td role=\"cell\" class=\"pick\"><label><input type=\"checkbox\" aria-label=${this.selectRowText.replace('{row}', String(row[columns[0]?.key ?? ''] ?? key))} .checked=${chosen.has(key)}\n @change=${(e: Event) => this.choose([key], (e.target as HTMLInputElement).checked)} /></label></td>`\n : nothing}\n ${columns.map((c, j) => {\n const value = html`<span class=\"label\" aria-hidden=\"true\">${c.label}</span><span class=\"value\"><slot name=${`cell:${key}:${c.key}`}>${row[c.key] ?? ''}</slot></span>`;\n // The first cell of each row is a row header, so a screen\n // reader announces \"Delivery charge, £250\" rather than\n // reading a bare number with no idea what it belongs to.\n return j === 0\n ? html`<th scope=\"row\" role=\"rowheader\" id=${`${this.uid}-r${i}`}>${value}</th>`\n : html`<td role=\"cell\" class=${c.numeric ? 'numeric' : ''}>${value}</td>`;\n })}\n </tr>\n `)\n : html`<tr role=\"row\"><td role=\"cell\" class=\"empty\" colspan=${columns.length + (this.selectable ? 1 : 0) || 1}><slot name=\"empty\">${this.emptyText}</slot></td></tr>`}\n </tbody>\n </table>\n </div>\n `;\n }\n}\n\ncustomElements.define('impakt-table', ImpaktTable);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-table': ImpaktTable }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA0DjD,IAAM,cAAN,cAA0B,cAAc;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,SAAS,EAAE,MAAM,OAAO;AAAA,MACxB,SAAS,EAAE,MAAM,MAAM;AAAA,MACvB,MAAM,EAAE,MAAM,MAAM;AAAA,MACpB,SAAS,EAAE,MAAM,QAAQ,WAAW,YAAY,SAAS,KAAK;AAAA,MAC9D,eAAe,EAAE,MAAM,QAAQ,WAAW,kBAAkB,SAAS,KAAK;AAAA,MAC1E,YAAY,EAAE,MAAM,SAAS,WAAW,cAAc;AAAA,MACtD,YAAY,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MAC3C,UAAU,EAAE,MAAM,MAAM;AAAA,MACxB,QAAQ,EAAE,MAAM,QAAQ,WAAW,UAAU;AAAA,MAC7C,OAAO,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACtC,WAAW,EAAE,MAAM,QAAQ,WAAW,aAAa;AAAA,MACnD,eAAe,EAAE,MAAM,QAAQ,WAAW,kBAAkB;AAAA,MAC5D,eAAe,EAAE,MAAM,QAAQ,WAAW,kBAAkB;AAAA,IAC9D;AAAA;AAAA,EAyBA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AACf,SAAK,UAAU,CAAC;AA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  fontWeight,
5
5
  t
6
- } from "./chunk-D6C7XEY4.js";
6
+ } from "./chunk-YR6T73GY.js";
7
7
 
8
8
  // packages/ui/src/components/help.ts
9
9
  import { html, css, nothing } from "lit";
10
- var ImpktHelp = class extends ImpktElement {
10
+ var ImpaktHelp = class extends ImpaktElement {
11
11
  static {
12
12
  this.properties = {
13
13
  mechanismId: { type: String, attribute: "mechanism-id" },
@@ -25,7 +25,7 @@ var ImpktHelp = class extends ImpktElement {
25
25
  this.detail = "";
26
26
  }
27
27
  static {
28
- this.styles = [...ImpktElement.styles, focusRing, css`
28
+ this.styles = [...ImpaktElement.styles, focusRing, css`
29
29
  :host { display: block; }
30
30
  a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};
31
31
  color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }
@@ -76,9 +76,9 @@ function contactHref(kind, detail) {
76
76
  if (kind === "email") return /^[^\s@]+@[^\s@]+$/.test(detail) ? `mailto:${detail}` : "";
77
77
  return "";
78
78
  }
79
- customElements.define("impkt-help", ImpktHelp);
79
+ customElements.define("impakt-help", ImpaktHelp);
80
80
 
81
81
  export {
82
- ImpktHelp
82
+ ImpaktHelp
83
83
  };
84
- //# sourceMappingURL=chunk-7OXTZJR4.js.map
84
+ //# sourceMappingURL=chunk-TRZO5CHU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/help.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { focusRing } from '../base/styles';\nimport { fontWeight, t } from '../base/tokens';\n\n/**\n * What form a help mechanism takes.\n *\n * `link` goes somewhere: a help page, a contact form, a chat. The other four\n * are the \"human contact details\" that 3.2.6 Consistent Help names, shown as\n * text so a reader can see them without following anything.\n */\nexport type HelpKind = 'link' | 'phone' | 'email' | 'address' | 'hours';\n\n/**\n * A help link, or contact details shown as text.\n *\n * **Its identity is `mechanismId`, not its wording or destination.** 3.2.6\n * Consistent Help asks that help offered on several pages appears in the same\n * relative order on each. Strata checks that at publish by comparing these ids\n * across pages, so the label can be reworded and the number can change\n * without the check treating it as a different mechanism. It is literal and\n * cannot be bound, because an id that a data response could change is one the\n * check cannot compare.\n *\n * **Contact details are text, not a link to a page that has them.** The\n * criterion lists a phone number, an email address and a postal address as\n * help in their own right, and a reader who has to follow a link to find the\n * number has been given a link rather than the number. A phone number renders\n * as a `tel:` link and an email address as a `mailto:` link, each with the\n * detail itself as the visible text. The link target is derived from the\n * visible detail rather than authored separately, so the number a reader sees\n * and the number their phone dials cannot drift apart. An address or opening\n * hours render as plain text and keep the line breaks they were written with.\n *\n * **Contact links are named by their caption and their detail.** A phone\n * link's accessible name is \"Call us 0800 123 456\" rather than the bare\n * number, because a reader moving through a list of links hears each one out\n * of context (2.4.4 Link Purpose). The visible text stays inside the name, so\n * 2.5.3 Label in Name holds for a reader who speaks it.\n *\n * **Nothing unnamed or empty is ever rendered.** Runtime bindings may be\n * absent while data loads, or resolve to blank text. A link with no label, or\n * contact details with no detail, render nothing rather than a focusable link\n * with no name or a caption with nothing under it. Contact details whose\n * caption is blank still show the detail, because a phone number or an\n * address names itself. For that reason the caption is optional for contact\n * details, and publishing requires a label only on a link. Publishing does\n * require what each kind cannot do without: a link's label and address, and\n * contact details' detail, so the empty states are only reached at runtime.\n *\n * **Every link meets the minimum target size.** Links here are at least the\n * locked `target.min` token in both directions (2.5.8 Target Size), because a\n * help link usually stands on its own line, where the criterion's inline\n * exemption does not apply.\n *\n * @category action\n * @icon help\n * @role help\n */\nexport class ImpaktHelp extends ImpaktElement {\n static properties = {\n mechanismId: { type: String, attribute: 'mechanism-id' },\n kind: { type: String, reflect: true },\n href: { type: String },\n label: { type: String },\n detail: { type: String },\n };\n\n /** Stable identity across pages, independent of wording and destination. */\n declare mechanismId: string;\n // Written out as a union rather than as `HelpKind` so the manifest offers it\n // as a fixed choice: which form help takes is a design decision, not data.\n /** Whether this is a link to help, or contact details shown as text. */\n declare kind: 'link' | 'phone' | 'email' | 'address' | 'hours';\n /** Where a link goes. Phone and email links are built from the detail instead. */\n declare href: string;\n /**\n * The visible name. For a link it is the link text. For contact details it\n * is the caption shown above them, such as \"Call us\".\n */\n declare label: string;\n /**\n * The contact detail itself: a phone number, an email address, a postal\n * address or opening hours. Line breaks are kept. Unused by a link.\n */\n declare detail: string;\n\n constructor() {\n super();\n this.kind = 'link';\n this.href = '';\n // Defaulted, so the manifest does not mark it required: contact details\n // may leave the caption out. A link without one is refused at publish.\n this.label = '';\n this.detail = '';\n }\n\n static styles = [...ImpaktElement.styles, focusRing, css`\n :host { display: block; }\n a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};\n color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }\n a:hover { color: ${t.linkHover}; }\n .contact { margin: 0; }\n .caption { display: block; font-weight: ${fontWeight('semibold')}; }\n /* An address is written one line at a time, and opening hours are often one\n day to a line. Long unbroken values still wrap at 320px (1.4.10). */\n .detail { white-space: pre-line; overflow-wrap: anywhere; }\n `];\n\n render(): TemplateResult | typeof nothing {\n switch (this.kind) {\n case 'phone':\n case 'email':\n case 'address':\n case 'hours':\n return this.renderContact();\n default:\n // An absent or unrecognised kind keeps the original link behaviour, so\n // a page published before contact details existed renders unchanged.\n return this.renderLink();\n }\n }\n\n private renderLink(): TemplateResult | typeof nothing {\n // Runtime bindings may be absent while data loads, or resolve to blank text.\n // Do not expose an unnamed focusable link in those states.\n if (!text(this.label)) return nothing;\n return html`<a part=\"link\" href=${this.href}>${this.label}</a>`;\n }\n\n private renderContact(): TemplateResult | typeof nothing {\n const detail = text(this.detail);\n // A caption with nothing under it is not help, so neither is drawn.\n if (!detail) return nothing;\n const caption = text(this.label);\n const target = contactHref(this.kind, detail);\n const captionId = this.id_('caption');\n const detailId = this.id_('detail');\n const captionPart = caption\n ? html`<span class=\"caption\" part=\"label\" id=${captionId}>${caption}</span>`\n : nothing;\n const detailPart = target\n ? html`<a part=\"link\" href=${target} aria-labelledby=${caption ? `${captionId} ${detailId}` : nothing}\n ><span class=\"detail\" part=\"detail\" id=${detailId}>${detail}</span></a>`\n : html`<span class=\"detail\" part=\"detail\">${detail}</span>`;\n return html`<p class=\"contact\" part=\"contact\">${captionPart}${detailPart}</p>`;\n }\n}\n\n/** Trimmed text, or empty for anything that is not a string. */\nfunction text(value: unknown): string {\n return typeof value === 'string' ? value.trim() : '';\n}\n\n/**\n * The link a contact detail opens, or empty when it should stay as text.\n *\n * A phone number is reduced to its digits and one leading `+`, and the \"(0)\"\n * that UK numbers print after the country code is dropped, because the\n * separators a reader expects are not dialled. A value with no digits, or an\n * email address without an `@`, stays as plain text. The reader still sees\n * it, and nothing offers to dial or mail something that cannot work.\n */\nfunction contactHref(kind: string, detail: string): string {\n if (kind === 'phone') {\n const digits = detail.replace(/\\(0\\)/g, '').replace(/[^\\d+]/g, '').replace(/(?!^)\\+/g, '');\n return /\\d/.test(digits) ? `tel:${digits}` : '';\n }\n if (kind === 'email') return /^[^\\s@]+@[^\\s@]+$/.test(detail) ? `mailto:${detail}` : '';\n return '';\n}\n\ncustomElements.define('impakt-help', ImpaktHelp);\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-help': ImpaktHelp }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA4DjD,IAAM,aAAN,cAAyB,cAAc;AAAA,EAC5C;AAAA,SAAO,aAAa;AAAA,MAClB,aAAa,EAAE,MAAM,QAAQ,WAAW,eAAe;AAAA,MACvD,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,QAAQ,EAAE,MAAM,OAAO;AAAA,IACzB;AAAA;AAAA,EAqBA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,OAAO;AAGZ,SAAK,QAAQ;AACb,SAA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AM,SAAS,OAAO,QAAQ,UAAU,EAAE,EAAE,QAAQ,WAAW,EAAE,EAAE,QAAQ,YAAY,EAAE;AACzF,WAAO,KAAK,KAAK,MAAM,IAAI,OAAO,MAAM,KAAK;AAAA,EAC/C;AACA,MAAI,SAAS,QAAS,QAAO,oBAAoB,KAAK,MAAM,IAAI,UAAU,MAAM,KAAK;AACrF,SAAO;AACT;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
@@ -1,15 +1,16 @@
1
1
  import {
2
- ImpktElement,
2
+ ImpaktElement,
3
3
  focusRing,
4
4
  fontSize,
5
5
  fontWeight,
6
6
  space,
7
- t
8
- } from "./chunk-D6C7XEY4.js";
7
+ t,
8
+ touchTarget
9
+ } from "./chunk-YR6T73GY.js";
9
10
 
10
11
  // packages/ui/src/components/summary-list.ts
11
12
  import { html, css, nothing } from "lit";
12
- var ImpktSummaryList = class extends ImpktElement {
13
+ var ImpaktSummaryList = class extends ImpaktElement {
13
14
  static {
14
15
  this.properties = {
15
16
  rows: { type: Array },
@@ -23,8 +24,9 @@ var ImpktSummaryList = class extends ImpktElement {
23
24
  }
24
25
  static {
25
26
  this.styles = [
26
- ...ImpktElement.styles,
27
+ ...ImpaktElement.styles,
27
28
  focusRing,
29
+ touchTarget("dd a"),
28
30
  css`
29
31
  :host {
30
32
  display: block;
@@ -62,7 +64,8 @@ var ImpktSummaryList = class extends ImpktElement {
62
64
  color: ${t.link};
63
65
  text-decoration: underline;
64
66
  text-underline-offset: 0.2em;
65
- display: inline-block;
67
+ display: inline-flex;
68
+ align-items: center;
66
69
  min-block-size: ${t.targetMin};
67
70
  }
68
71
  .sr-only {
@@ -112,9 +115,9 @@ var ImpktSummaryList = class extends ImpktElement {
112
115
  `;
113
116
  }
114
117
  };
115
- customElements.define("impkt-summary-list", ImpktSummaryList);
118
+ customElements.define("impakt-summary-list", ImpaktSummaryList);
116
119
 
117
120
  export {
118
- ImpktSummaryList
121
+ ImpaktSummaryList
119
122
  };
120
- //# sourceMappingURL=chunk-EDSZI227.js.map
123
+ //# sourceMappingURL=chunk-UPOTBKKK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/summary-list.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { focusRing, touchTarget } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface SummaryRow {\n key: string;\n value: string;\n /** Where \"Change\" goes. Omitted rows show no action. */\n changeHref?: string;\n}\n\n/**\n * Key and value pairs — an order summary, a confirmation, a check-your-answers\n * screen.\n *\n * **It is a description list.** `<dl>` with `<dt>` and `<dd>` says these are\n * pairs; a stack of divs says nothing, and a table claims a grid that a\n * two-column list does not have.\n *\n * **Every \"Change\" names what it changes.** The visible text stays short, and\n * the accessible name is completed with visually hidden words, so a reader\n * tabbing through hears \"Change date of birth\" rather than six links all called\n * \"Change\". This is 2.4.4 Link Purpose, and it is the single most common\n * failure on a check-your-answers page.\n\n *\n * @category content\n * @icon list\n */\nexport class ImpaktSummaryList extends ImpaktElement {\n static properties = {\n rows: { type: Array },\n changeText: { type: String, attribute: 'change-text' },\n };\n\n declare rows: SummaryRow[];\n declare changeText: string;\n\n constructor() {\n super();\n this.rows = [];\n this.changeText = 'Change';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n touchTarget('dd a'),\n css`\n :host {\n display: block;\n }\n dl {\n margin: 0;\n display: grid;\n grid-template-columns: minmax(8rem, 1fr) 2fr;\n }\n /* A <dl> group may hold only dt and dd — not a third sibling — so the\n action lives inside the value it changes, which is also where it\n belongs semantically. The row uses display:contents so both cells stay\n in the parent grid. */\n .row {\n display: contents;\n }\n dt,\n dd {\n padding: ${space(3)} 0;\n border-block-end: ${t.borderThin} solid ${t.rule};\n }\n dt {\n font-weight: ${fontWeight('semibold')};\n font-size: ${fontSize('sm')};\n }\n dd {\n margin: 0;\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: ${space(3)};\n }\n dd a {\n flex: none;\n color: ${t.link};\n text-decoration: underline;\n text-underline-offset: 0.2em;\n display: inline-flex;\n align-items: center;\n min-block-size: ${t.targetMin};\n }\n .sr-only {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n /* One column on a narrow screen. 1.4.10 Reflow: two columns at 320px\n forces horizontal scrolling, and a summary is read, not scanned\n across. */\n @media (max-width: 30rem) {\n dl {\n grid-template-columns: 1fr;\n }\n dt {\n border-block-end: 0;\n padding-block-end: 0;\n }\n dd {\n padding-block-start: 0;\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <dl part=\"list\">\n ${this.rows.map(\n (row) => html`\n <div class=\"row\" part=\"row\">\n <dt part=\"key\">${row.key}</dt>\n <dd part=\"value\">\n <span>${row.value}</span>\n ${row.changeHref\n ? html`<a href=${row.changeHref} part=\"action\"\n >${this.changeText}<span class=\"sr-only\"> ${row.key}</span></a\n >`\n : nothing}\n </dd>\n </div>\n `,\n )}\n </dl>\n `;\n }\n}\n\ncustomElements.define('impakt-summary-list', ImpaktSummaryList);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-summary-list': ImpaktSummaryList }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA8BjD,IAAM,oBAAN,cAAgC,cAAc;AAAA,EACnD;AAAA,SAAO,aAAa;AAAA,MAClB,MAAM,EAAE,MAAM,MAAM;AAAA,MACpB,YAAY,EAAE,MAAM,QAAQ,WAAW,cAAc;AAAA,IACvD;AAAA;AAAA,EAKA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO,CAAC;AACb,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,cAAc;AAAA,MACjB;AAAA,MACA,YAAY,MAAM;AAAA,MAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAkBe,MAAM,CAAC,CAAC;AAAA,4BACC,EAAE,UAAU,UAAU,EAAE,IAAI;AAAA;AAAA;AAAA,uBAGjC,WAAW,UAAU,CAAC;AAAA,qBACxB,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOpB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,iBAIN,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKG,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA2BnC;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA,UAED,KAAK,KAAK;AAAA,MACV,CAAC,QAAQ;AAAA;AAAA,+BAEY,IAAI,GAAG;AAAA;AAAA,wBAEd,IAAI,KAAK;AAAA,kBACf,IAAI,aACF,eAAe,IAAI,UAAU;AAAA,yBACxB,KAAK,UAAU,0BAA0B,IAAI,GAAG;AAAA,yBAErD,OAAO;AAAA;AAAA;AAAA;AAAA,IAInB,CAAC;AAAA;AAAA;AAAA,EAGP;AACF;AAEA,eAAe,OAAO,uBAAuB,iBAAiB;","names":[]}
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  FieldElement
3
- } from "./chunk-7AJN2TIS.js";
3
+ } from "./chunk-5ZQVL3V2.js";
4
4
  import {
5
5
  fontSize,
6
6
  space,
7
7
  t,
8
8
  targetSize
9
- } from "./chunk-D6C7XEY4.js";
9
+ } from "./chunk-YR6T73GY.js";
10
10
 
11
11
  // packages/ui/src/components/checkbox-group.ts
12
12
  import { html, css, nothing } from "lit";
13
- var ImpktCheckboxGroup = class extends FieldElement {
13
+ var ImpaktCheckboxGroup = class extends FieldElement {
14
14
  static {
15
15
  this.properties = {
16
16
  ...FieldElement.properties,
@@ -123,9 +123,9 @@ var ImpktCheckboxGroup = class extends FieldElement {
123
123
  if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
124
124
  }
125
125
  };
126
- customElements.define("impkt-checkbox-group", ImpktCheckboxGroup);
126
+ customElements.define("impakt-checkbox-group", ImpaktCheckboxGroup);
127
127
 
128
128
  export {
129
- ImpktCheckboxGroup
129
+ ImpaktCheckboxGroup
130
130
  };
131
- //# sourceMappingURL=chunk-26O27BQS.js.map
131
+ //# sourceMappingURL=chunk-WP5WJ4V5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/checkbox-group.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { targetSize } from '../base/styles';\nimport { fontSize, space, t } from '../base/tokens';\n\nexport interface CheckboxOption {\n value: string;\n label: string;\n description?: string;\n}\n\n/**\n * A choose-several group — the multi-select question type.\n *\n * Same shape as the radio group and for the same reasons: a `<fieldset>` with\n * a `<legend>`, because the question is asked of the set and `label for` names\n * one control.\n *\n * It differs from radios in one way that matters. Checkboxes have no roving\n * tabindex — every box is its own tab stop, which is correct, because each is\n * an independent yes or no rather than one choice among several. Nothing needs\n * to be implemented for that; it is what the platform does, and it is worth\n * knowing it is deliberate rather than missing.\n\n *\n * @category form\n * @icon checkbox\n */\nexport class ImpaktCheckboxGroup extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n values: { type: Array },\n };\n\n declare options: CheckboxOption[];\n declare values: string[];\n\n constructor() {\n super();\n this.options = [];\n this.values = [];\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 .option {\n display: flex;\n align-items: flex-start;\n gap: ${space(3)};\n padding: ${space(3)};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radius};\n margin-block-end: ${space(2)};\n cursor: pointer;\n }\n .option:hover {\n background: ${t.surfaceSubtle};\n }\n .option input {\n ${targetSize}\n inline-size: 20px;\n block-size: 20px;\n margin: 0;\n flex: none;\n accent-color: ${t.brand};\n }\n .option-text {\n display: block;\n font-size: ${fontSize('md')};\n }\n .option-description {\n display: block;\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n margin-block-start: ${space(1)};\n }\n :host([invalid]) .option {\n border-color: ${t.danger};\n }\n `,\n ];\n\n protected renderLabel(): TemplateResult {\n return html`<legend class=\"label\" part=\"label\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </legend>`;\n }\n\n private onToggle(value: string, checked: boolean): void {\n this.values = checked ? [...this.values, value] : this.values.filter((v) => v !== value);\n // One form value, comma-joined — a multi-select arrives at a pricing API as\n // a list, and the order follows the options rather than the clicks.\n this.setFormValue(\n this.options.filter((o) => this.values.includes(o.value)).map((o) => o.value).join(','),\n );\n }\n\n protected renderControl(): TemplateResult {\n return html`\n ${this.options.map((option, i) => {\n const id = this.id_(`opt-${i}`);\n const descId = option.description ? this.id_(`opt-${i}-desc`) : undefined;\n return html`\n <label class=\"option\" part=\"option\" for=${id}>\n <input\n type=\"checkbox\"\n id=${id}\n value=${option.value}\n .checked=${this.values.includes(option.value)}\n ?disabled=${this.disabled}\n aria-describedby=${descId ?? nothing}\n @change=${(e: Event) => this.onToggle(option.value, (e.target as HTMLInputElement).checked)}\n />\n <span>\n <span class=\"option-text\">${option.label}</span>\n ${option.description\n ? html`<span class=\"option-description\" id=${descId!}>${option.description}</span>`\n : nothing}\n </span>\n </label>\n `;\n })}\n `;\n }\n\n render(): TemplateResult {\n return html`\n <fieldset part=\"fieldset\" aria-describedby=${this.describedBy} aria-invalid=${this.error ? 'true' : nothing}>\n ${this.renderLabel()}\n ${this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">${this.description}</div>`\n : nothing}\n ${this.renderControl()}\n <div class=\"error\" id=${this.id_('error')} part=\"error\" aria-live=\"polite\">${this.error || nothing}</div>\n </fieldset>\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impakt-checkbox-group', ImpaktCheckboxGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-checkbox-group': ImpaktCheckboxGroup }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA4BjD,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,SAAS,EAAE,MAAM,MAAM;AAAA,MACvB,QAAQ,EAAE,MAAM,MAAM;AAAA,IACxB;AAAA;AAAA,EAKA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU,CAAC;AAChB,SAAK,SAAS,CAAC;AAAA,EACjB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAaW,MAAM,CAAC,CAAC;AAAA,mBACJ,MAAM,CAAC,CAAC;AAAA,kBACT,EAAE,UAAU,UAAU,EAAE,MAAM;AAAA,yBACvB,EAAE,MAAM;AAAA,4BACL,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,sBAId,EAAE,aAAa;AAAA;AAAA;AAAA,UAG3B,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKI,EAAE,KAAK;AAAA;AAAA;AAAA;AAAA,qBAIV,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,qBAId,SAAS,IAAI,CAAC;AAAA,iBAClB,EAAE,SAAS;AAAA,8BACE,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA,wBAGd,EAAE,MAAM;AAAA;AAAA;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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,yBAAyB,mBAAmB;","names":[]}
@@ -1,15 +1,15 @@
1
1
  import {
2
- ImpktElement,
2
+ ImpaktElement,
3
3
  fontSize,
4
4
  fontWeight,
5
5
  lineHeight,
6
6
  space,
7
7
  t
8
- } from "./chunk-D6C7XEY4.js";
8
+ } from "./chunk-YR6T73GY.js";
9
9
 
10
10
  // packages/ui/src/components/fieldset.ts
11
11
  import { css, html, nothing } from "lit";
12
- var ImpktFieldset = class extends ImpktElement {
12
+ var ImpaktFieldset = class extends ImpaktElement {
13
13
  static {
14
14
  this.properties = {
15
15
  legend: { type: String },
@@ -26,7 +26,7 @@ var ImpktFieldset = class extends ImpktElement {
26
26
  this.size = "md";
27
27
  }
28
28
  static {
29
- this.styles = [...ImpktElement.styles, css`
29
+ this.styles = [...ImpaktElement.styles, css`
30
30
  :host { display: block; margin-block-end: ${space(6)}; }
31
31
  fieldset { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
32
32
  legend { padding: 0; margin-block-end: ${space(2)}; font-size: ${fontSize("md")}; font-weight: ${fontWeight("bold")}; line-height: ${lineHeight("tight")}; color: ${t.text}; }
@@ -48,9 +48,9 @@ var ImpktFieldset = class extends ImpktElement {
48
48
  </fieldset>`;
49
49
  }
50
50
  };
51
- customElements.define("impkt-fieldset", ImpktFieldset);
51
+ customElements.define("impakt-fieldset", ImpaktFieldset);
52
52
 
53
53
  export {
54
- ImpktFieldset
54
+ ImpaktFieldset
55
55
  };
56
- //# sourceMappingURL=chunk-YD6IZ2C5.js.map
56
+ //# sourceMappingURL=chunk-WS5AUJ35.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/fieldset.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { fontSize, fontWeight, lineHeight, space, t } from '../base/tokens';\n\n/**\n * Fields that belong together under one question: the lines of an address,\n * or a name in two parts.\n *\n * **The question is the group's name.** It is a `fieldset` with a `legend`, so\n * a screen reader says \"Your address, group\" on the way in, and each field\n * inside is heard as part of it (1.3.1, 3.3.2). An error for the group as a\n * whole, such as \"Enter a full address\", is tied to it the same way.\n *\n * @category form\n * @icon fieldset\n * @slot - The fields in the group.\n */\nexport class ImpaktFieldset extends ImpaktElement {\n static properties = {\n legend: { type: String },\n description: { type: String },\n error: { type: String, reflect: true },\n size: { type: String, reflect: true },\n };\n /** The question the fields answer together. */\n declare legend: string;\n /** A hint for the whole group, under the question. */\n declare description: string;\n /** What is wrong with the group as a whole. */\n declare error: string;\n /** How large the question is. A page that asks only this question makes it the page's heading size. */\n declare size: 'md' | 'lg' | 'xl';\n\n constructor() {\n super();\n this.legend = '';\n this.description = '';\n this.error = '';\n this.size = 'md';\n }\n\n static styles = [...ImpaktElement.styles, css`\n :host { display: block; margin-block-end: ${space(6)}; }\n fieldset { margin: 0; padding: 0; border: 0; min-inline-size: 0; }\n legend { padding: 0; margin-block-end: ${space(2)}; font-size: ${fontSize('md')}; font-weight: ${fontWeight('bold')}; line-height: ${lineHeight('tight')}; color: ${t.text}; }\n :host([size='lg']) legend { font-size: ${fontSize('xl')}; font-family: ${t.fontHeading}; color: ${t.textHeading}; }\n :host([size='xl']) legend { font-size: ${fontSize('2xl')}; font-family: ${t.fontHeading}; color: ${t.textHeading}; }\n .description { margin-block-end: ${space(3)}; font-size: ${fontSize('sm')}; color: ${t.textMuted}; line-height: ${lineHeight('normal')}; }\n .error { margin-block-end: ${space(3)}; font-size: ${fontSize('sm')}; color: ${t.dangerText}; font-weight: ${fontWeight('semibold')}; }\n .error:empty { display: none; }\n :host([error]:not([error=''])) .fields { padding-inline-start: ${space(4)}; border-inline-start: 4px solid ${t.danger}; }\n `];\n\n render(): TemplateResult {\n const described = [this.description ? this.id_('description') : '', this.error ? this.id_('error') : ''].filter(Boolean).join(' ');\n return html`<fieldset part=\"fieldset\" aria-describedby=${described || nothing}>\n <legend part=\"legend\">${this.legend}</legend>\n ${this.description ? html`<div class=\"description\" id=${this.id_('description')}>${this.description}</div>` : nothing}\n <div class=\"error\" id=${this.id_('error')} aria-live=\"polite\">${this.error || nothing}</div>\n <div class=\"fields\" part=\"fields\"><slot></slot></div>\n </fieldset>`;\n }\n}\n\ncustomElements.define('impakt-fieldset', ImpaktFieldset);\ndeclare global { interface HTMLElementTagNameMap { 'impakt-fieldset': ImpaktFieldset } }\n"],"mappings":";;;;;;;;;;AAAA,SAAS,KAAK,MAAM,eAAoC;AAiBjD,IAAM,iBAAN,cAA6B,cAAc;AAAA,EAChD;AAAA,SAAO,aAAa;AAAA,MAClB,QAAQ,EAAE,MAAM,OAAO;AAAA,MACvB,aAAa,EAAE,MAAM,OAAO;AAAA,MAC5B,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IACtC;AAAA;AAAA,EAUA,cAAc;AACZ,UAAM;AACN,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,QAAQ;AACb,SAAK,OAAO;AAAA,EACd;AAAA,EAEA;AAAA,SAAO,SAAS,CAAC,GAAG,cAAc,QAAQ;AAAA,gDACI,MAAM,CAAC,CAAC;AAAA;AAAA,6CAEX,MAAM,CAAC,CAAC,gBAAgB,SAAS,IAAI,CAAC,kBAAkB,WAAW,MAAM,CAAC,kBAAkB,WAAW,OAAO,CAAC,YAAY,EAAE,IAAI;AAAA,6CACjI,SAAS,IAAI,CAAC,kBAAkB,EAAE,WAAW,YAAY,EAAE,WA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