@atomic-ui/ui 0.10.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/custom-elements.json +9631 -6026
  2. package/dist/base/FieldElement.d.ts +10 -3
  3. package/dist/{chunk-YWP2Z3JN.js → chunk-2TNF7O43.js} +7 -5
  4. package/dist/{chunk-YWP2Z3JN.js.map → chunk-2TNF7O43.js.map} +1 -1
  5. package/dist/{chunk-FKUBEVCU.js → chunk-2WHOBIOY.js} +11 -9
  6. package/dist/{chunk-FKUBEVCU.js.map → chunk-2WHOBIOY.js.map} +1 -1
  7. package/dist/{chunk-26BO3W56.js → chunk-3BWCD5U5.js} +5 -3
  8. package/dist/{chunk-26BO3W56.js.map → chunk-3BWCD5U5.js.map} +1 -1
  9. package/dist/chunk-3GPGDERO.js +201 -0
  10. package/dist/chunk-3GPGDERO.js.map +1 -0
  11. package/dist/{chunk-3T7J66Z2.js → chunk-3KAFK24X.js} +13 -11
  12. package/dist/chunk-3KAFK24X.js.map +1 -0
  13. package/dist/chunk-4MMRBNW7.js +104 -0
  14. package/dist/chunk-4MMRBNW7.js.map +1 -0
  15. package/dist/{chunk-5OJAJA3U.js → chunk-5HCWL2YD.js} +6 -4
  16. package/dist/{chunk-5OJAJA3U.js.map → chunk-5HCWL2YD.js.map} +1 -1
  17. package/dist/{chunk-AG4EP3OY.js → chunk-5IGBH4GL.js} +8 -6
  18. package/dist/{chunk-AG4EP3OY.js.map → chunk-5IGBH4GL.js.map} +1 -1
  19. package/dist/{chunk-AL4IUSML.js → chunk-5OYQZWP2.js} +5 -3
  20. package/dist/{chunk-AL4IUSML.js.map → chunk-5OYQZWP2.js.map} +1 -1
  21. package/dist/chunk-5PRB7P7N.js +167 -0
  22. package/dist/chunk-5PRB7P7N.js.map +1 -0
  23. package/dist/chunk-6CDQSHVW.js +21 -0
  24. package/dist/chunk-6CDQSHVW.js.map +1 -0
  25. package/dist/{chunk-MLKNZL5J.js → chunk-6J22I7F6.js} +14 -12
  26. package/dist/chunk-6J22I7F6.js.map +1 -0
  27. package/dist/chunk-72WNCCDC.js +136 -0
  28. package/dist/chunk-72WNCCDC.js.map +1 -0
  29. package/dist/chunk-7UI3OBXL.js +104 -0
  30. package/dist/chunk-7UI3OBXL.js.map +1 -0
  31. package/dist/{chunk-D6NET2VB.js → chunk-ALFE35FS.js} +30 -3
  32. package/dist/chunk-ALFE35FS.js.map +1 -0
  33. package/dist/chunk-AYINRYNC.js +184 -0
  34. package/dist/chunk-AYINRYNC.js.map +1 -0
  35. package/dist/{chunk-2D2IMQII.js → chunk-BAYSDP44.js} +52 -30
  36. package/dist/chunk-BAYSDP44.js.map +1 -0
  37. package/dist/{chunk-2EP3IV3G.js → chunk-BGHAANTP.js} +22 -8
  38. package/dist/chunk-BGHAANTP.js.map +1 -0
  39. package/dist/{chunk-OJO62KRX.js → chunk-CFCFKLTN.js} +85 -10
  40. package/dist/chunk-CFCFKLTN.js.map +1 -0
  41. package/dist/{chunk-UFPI4I2Y.js → chunk-CQT3VPYK.js} +8 -29
  42. package/dist/chunk-CQT3VPYK.js.map +1 -0
  43. package/dist/{chunk-AURT72IC.js → chunk-DXLEYNID.js} +13 -7
  44. package/dist/chunk-DXLEYNID.js.map +1 -0
  45. package/dist/{chunk-L4CIBOGK.js → chunk-EKPTMRBG.js} +5 -3
  46. package/dist/{chunk-L4CIBOGK.js.map → chunk-EKPTMRBG.js.map} +1 -1
  47. package/dist/{chunk-Z2EWQMTR.js → chunk-F4IXELLK.js} +5 -3
  48. package/dist/{chunk-Z2EWQMTR.js.map → chunk-F4IXELLK.js.map} +1 -1
  49. package/dist/{chunk-APQEXM4I.js → chunk-FJHPGOGS.js} +5 -3
  50. package/dist/{chunk-APQEXM4I.js.map → chunk-FJHPGOGS.js.map} +1 -1
  51. package/dist/chunk-FLAUZU7Y.js +345 -0
  52. package/dist/chunk-FLAUZU7Y.js.map +1 -0
  53. package/dist/{chunk-3NEWOO2P.js → chunk-FZWUQC42.js} +7 -5
  54. package/dist/{chunk-3NEWOO2P.js.map → chunk-FZWUQC42.js.map} +1 -1
  55. package/dist/{chunk-ONED3PUB.js → chunk-HSXLSJVG.js} +54 -8
  56. package/dist/chunk-HSXLSJVG.js.map +1 -0
  57. package/dist/{chunk-V7EB7Q2M.js → chunk-JTCTQBAX.js} +2 -131
  58. package/dist/chunk-JTCTQBAX.js.map +1 -0
  59. package/dist/{chunk-ZL3JFUIE.js → chunk-K5QFVLCI.js} +7 -5
  60. package/dist/{chunk-ZL3JFUIE.js.map → chunk-K5QFVLCI.js.map} +1 -1
  61. package/dist/{chunk-DN5YZFSG.js → chunk-KE6WCXQP.js} +55 -9
  62. package/dist/chunk-KE6WCXQP.js.map +1 -0
  63. package/dist/chunk-LBHTXY7K.js +75 -0
  64. package/dist/chunk-LBHTXY7K.js.map +1 -0
  65. package/dist/{chunk-OZGKK3N5.js → chunk-LP4RTYTL.js} +88 -9
  66. package/dist/chunk-LP4RTYTL.js.map +1 -0
  67. package/dist/{chunk-MOO63SHZ.js → chunk-LXVPWTSY.js} +80 -23
  68. package/dist/chunk-LXVPWTSY.js.map +1 -0
  69. package/dist/{chunk-JNLKM3JT.js → chunk-N6EEW2GF.js} +6 -4
  70. package/dist/{chunk-JNLKM3JT.js.map → chunk-N6EEW2GF.js.map} +1 -1
  71. package/dist/chunk-NHEU5FT6.js +115 -0
  72. package/dist/chunk-NHEU5FT6.js.map +1 -0
  73. package/dist/chunk-QPOM7W3D.js +104 -0
  74. package/dist/chunk-QPOM7W3D.js.map +1 -0
  75. package/dist/{chunk-FU3CEHBS.js → chunk-R6PBY3YN.js} +6 -4
  76. package/dist/{chunk-FU3CEHBS.js.map → chunk-R6PBY3YN.js.map} +1 -1
  77. package/dist/{chunk-TJOYBDKS.js → chunk-R6YMSJR7.js} +65 -36
  78. package/dist/chunk-R6YMSJR7.js.map +1 -0
  79. package/dist/{chunk-ZEIV5X3U.js → chunk-SOYKSPPX.js} +73 -23
  80. package/dist/chunk-SOYKSPPX.js.map +1 -0
  81. package/dist/{chunk-NKMJMVZP.js → chunk-T52CUOCJ.js} +5 -3
  82. package/dist/{chunk-NKMJMVZP.js.map → chunk-T52CUOCJ.js.map} +1 -1
  83. package/dist/chunk-UBNCJROR.js +294 -0
  84. package/dist/chunk-UBNCJROR.js.map +1 -0
  85. package/dist/chunk-UFENSIWD.js +135 -0
  86. package/dist/chunk-UFENSIWD.js.map +1 -0
  87. package/dist/{chunk-A4M3A4SZ.js → chunk-UYTIJCCW.js} +10 -42
  88. package/dist/chunk-UYTIJCCW.js.map +1 -0
  89. package/dist/chunk-XX6JZW5N.js +36 -0
  90. package/dist/chunk-XX6JZW5N.js.map +1 -0
  91. package/dist/{chunk-2ZF3J7OO.js → chunk-XXSZL5CY.js} +17 -5
  92. package/dist/chunk-XXSZL5CY.js.map +1 -0
  93. package/dist/{chunk-6PMA6NHE.js → chunk-Y55FNQHS.js} +5 -3
  94. package/dist/{chunk-6PMA6NHE.js.map → chunk-Y55FNQHS.js.map} +1 -1
  95. package/dist/chunk-ZAWGJC4I.js +176 -0
  96. package/dist/chunk-ZAWGJC4I.js.map +1 -0
  97. package/dist/chunk-ZUQ3DOG2.js +110 -0
  98. package/dist/chunk-ZUQ3DOG2.js.map +1 -0
  99. package/dist/components/accordion.d.ts +22 -0
  100. package/dist/components/accordion.js +6 -2
  101. package/dist/components/alert.d.ts +22 -1
  102. package/dist/components/alert.js +3 -2
  103. package/dist/components/app-bar.d.ts +153 -0
  104. package/dist/components/app-bar.js +15 -0
  105. package/dist/components/app-bar.js.map +1 -0
  106. package/dist/components/app-ui.d.ts +29 -2
  107. package/dist/components/app-ui.js +5 -4
  108. package/dist/components/badge.d.ts +17 -1
  109. package/dist/components/badge.js +4 -3
  110. package/dist/components/blocks.js +5 -4
  111. package/dist/components/button.d.ts +18 -2
  112. package/dist/components/button.js +4 -3
  113. package/dist/components/checkbox-group.js +4 -3
  114. package/dist/components/checkbox.js +4 -3
  115. package/dist/components/checked.d.ts +77 -0
  116. package/dist/components/checked.js +10 -0
  117. package/dist/components/checked.js.map +1 -0
  118. package/dist/components/chip-group.d.ts +113 -0
  119. package/dist/components/chip-group.js +11 -0
  120. package/dist/components/chip-group.js.map +1 -0
  121. package/dist/components/chip.d.ts +11 -0
  122. package/dist/components/chip.js +3 -2
  123. package/dist/components/code-diff.d.ts +77 -0
  124. package/dist/components/code-diff.js +10 -0
  125. package/dist/components/code-diff.js.map +1 -0
  126. package/dist/components/date-input.js +4 -3
  127. package/dist/components/dialog.d.ts +15 -0
  128. package/dist/components/dialog.js +3 -2
  129. package/dist/components/fieldset.js +3 -2
  130. package/dist/components/grid.js +3 -2
  131. package/dist/components/help.js +3 -2
  132. package/dist/components/icon.js +3 -2
  133. package/dist/components/journey.js +4 -3
  134. package/dist/components/language-switch.d.ts +59 -0
  135. package/dist/components/language-switch.js +10 -0
  136. package/dist/components/language-switch.js.map +1 -0
  137. package/dist/components/layout.d.ts +8 -2
  138. package/dist/components/layout.js +3 -2
  139. package/dist/components/link.js +4 -3
  140. package/dist/components/list.js +3 -2
  141. package/dist/components/media.js +3 -2
  142. package/dist/components/meter.d.ts +112 -0
  143. package/dist/components/meter.js +13 -0
  144. package/dist/components/meter.js.map +1 -0
  145. package/dist/components/navigation.d.ts +52 -0
  146. package/dist/components/navigation.js +4 -3
  147. package/dist/components/page.d.ts +13 -8
  148. package/dist/components/page.js +3 -2
  149. package/dist/components/price.js +3 -2
  150. package/dist/components/progress.d.ts +16 -2
  151. package/dist/components/progress.js +3 -2
  152. package/dist/components/radio-group.js +4 -3
  153. package/dist/components/redaction.d.ts +51 -0
  154. package/dist/components/redaction.js +10 -0
  155. package/dist/components/redaction.js.map +1 -0
  156. package/dist/components/rows.d.ts +28 -0
  157. package/dist/components/rows.js +7 -3
  158. package/dist/components/select.d.ts +6 -0
  159. package/dist/components/select.js +4 -3
  160. package/dist/components/shell.js +4 -3
  161. package/dist/components/source.d.ts +68 -0
  162. package/dist/components/source.js +10 -0
  163. package/dist/components/source.js.map +1 -0
  164. package/dist/components/status-pill-style.d.ts +16 -0
  165. package/dist/components/status-pill-style.js +15 -0
  166. package/dist/components/status-pill-style.js.map +1 -0
  167. package/dist/components/status.d.ts +66 -0
  168. package/dist/components/status.js +10 -0
  169. package/dist/components/status.js.map +1 -0
  170. package/dist/components/summary-list.js +3 -2
  171. package/dist/components/switch.js +4 -3
  172. package/dist/components/table.d.ts +19 -0
  173. package/dist/components/table.js +4 -3
  174. package/dist/components/text-input.js +5 -4
  175. package/dist/components/textarea.d.ts +5 -0
  176. package/dist/components/textarea.js +4 -3
  177. package/dist/components/tool-card.d.ts +107 -0
  178. package/dist/components/tool-card.js +11 -0
  179. package/dist/components/tool-card.js.map +1 -0
  180. package/dist/components/tool-kit-tokens.d.ts +25 -0
  181. package/dist/components/tool-kit-tokens.js +8 -0
  182. package/dist/components/tool-kit-tokens.js.map +1 -0
  183. package/dist/index.d.ts +11 -0
  184. package/dist/index.js +116 -70
  185. package/dist/standalone/atomic-ui.js +2030 -692
  186. package/dist/standalone/atomic-ui.js.map +4 -4
  187. package/package.json +2 -2
  188. package/dist/chunk-2D2IMQII.js.map +0 -1
  189. package/dist/chunk-2EP3IV3G.js.map +0 -1
  190. package/dist/chunk-2ZF3J7OO.js.map +0 -1
  191. package/dist/chunk-3T7J66Z2.js.map +0 -1
  192. package/dist/chunk-7UWJXPR3.js +0 -97
  193. package/dist/chunk-7UWJXPR3.js.map +0 -1
  194. package/dist/chunk-A4M3A4SZ.js.map +0 -1
  195. package/dist/chunk-AURT72IC.js.map +0 -1
  196. package/dist/chunk-AYKYHZGQ.js +0 -108
  197. package/dist/chunk-AYKYHZGQ.js.map +0 -1
  198. package/dist/chunk-D6NET2VB.js.map +0 -1
  199. package/dist/chunk-DN5YZFSG.js.map +0 -1
  200. package/dist/chunk-MLKNZL5J.js.map +0 -1
  201. package/dist/chunk-MOO63SHZ.js.map +0 -1
  202. package/dist/chunk-OJO62KRX.js.map +0 -1
  203. package/dist/chunk-ONED3PUB.js.map +0 -1
  204. package/dist/chunk-OZGKK3N5.js.map +0 -1
  205. package/dist/chunk-QU3U2CS2.js +0 -144
  206. package/dist/chunk-QU3U2CS2.js.map +0 -1
  207. package/dist/chunk-TJOYBDKS.js.map +0 -1
  208. package/dist/chunk-UFPI4I2Y.js.map +0 -1
  209. package/dist/chunk-V7EB7Q2M.js.map +0 -1
  210. package/dist/chunk-ZEIV5X3U.js.map +0 -1
@@ -0,0 +1,345 @@
1
+ import {
2
+ statusPill,
3
+ statusPillStyles
4
+ } from "./chunk-6CDQSHVW.js";
5
+ import {
6
+ onServer
7
+ } from "./chunk-6WVL3HOC.js";
8
+ import {
9
+ ImpaktElement,
10
+ focusRing,
11
+ targetSize
12
+ } from "./chunk-72WNCCDC.js";
13
+ import {
14
+ fontSize,
15
+ fontWeight,
16
+ space,
17
+ t
18
+ } from "./chunk-JTCTQBAX.js";
19
+
20
+ // packages/ui/src/components/accordion.ts
21
+ import { html, css, nothing, unsafeCSS } from "lit";
22
+ var LINE_SOFT = unsafeCSS("var(--impakt-color-line-soft, #dcdcd8)");
23
+ var ImpaktAccordion = class extends ImpaktElement {
24
+ static {
25
+ this.properties = {
26
+ items: { type: Array },
27
+ headingLevel: { type: Number, attribute: "heading-level" },
28
+ open: { type: Array },
29
+ multiple: { type: Boolean },
30
+ look: { type: String, reflect: true },
31
+ enhanced: { state: true }
32
+ };
33
+ }
34
+ constructor() {
35
+ super();
36
+ this.items = [];
37
+ this.headingLevel = 3;
38
+ this.open = [];
39
+ this.multiple = true;
40
+ this.look = "plain";
41
+ this.enhanced = false;
42
+ }
43
+ connectedCallback() {
44
+ if (!onServer && !this.shadowRoot) this.enhanced = true;
45
+ super.connectedCallback();
46
+ }
47
+ firstUpdated() {
48
+ this.enhanced = true;
49
+ }
50
+ static {
51
+ this.styles = [
52
+ ...ImpaktElement.styles,
53
+ focusRing,
54
+ statusPillStyles,
55
+ css`
56
+ :host {
57
+ display: block;
58
+ border-block-start: ${t.borderThin} solid ${t.text};
59
+ }
60
+ .item {
61
+ border-block-end: ${t.borderThin} solid ${t.text};
62
+ }
63
+ /* The heading row. The button is stretched over it, so the whole row opens the panel, the status included. */
64
+ .head {
65
+ position: relative;
66
+ display: flex;
67
+ align-items: center;
68
+ gap: ${space(4)};
69
+ }
70
+ .h {
71
+ flex: 1;
72
+ min-inline-size: 0;
73
+ margin: 0;
74
+ }
75
+ button {
76
+ ${targetSize}
77
+ display: flex;
78
+ align-items: baseline;
79
+ flex-wrap: wrap;
80
+ column-gap: ${space(4)};
81
+ row-gap: ${space(1)};
82
+ inline-size: 100%;
83
+ padding: ${space(8)} 0;
84
+ background: none;
85
+ border: 0;
86
+ font: inherit;
87
+ /* G2 heading S: 24/1.15, -2.5%, semibold. */
88
+ font-size: var(--impakt-type-heading-s-size, 1.5rem);
89
+ line-height: 1.15;
90
+ letter-spacing: -0.025em;
91
+ font-weight: ${fontWeight("semibold")};
92
+ color: ${t.text};
93
+ text-align: start;
94
+ cursor: pointer;
95
+ }
96
+ button::after {
97
+ content: '';
98
+ position: absolute;
99
+ inset: 0;
100
+ }
101
+ button:focus-visible {
102
+ box-shadow: none;
103
+ }
104
+ button:focus-visible::after {
105
+ box-shadow: ${t.focusShadow};
106
+ }
107
+ button:hover .q {
108
+ text-decoration: underline;
109
+ text-decoration-thickness: 1px;
110
+ text-underline-offset: 0.15em;
111
+ }
112
+ .meta {
113
+ font-family: ${t.fontMono};
114
+ font-size: ${fontSize("sm")};
115
+ font-weight: 400;
116
+ letter-spacing: normal;
117
+ color: ${t.textMuted};
118
+ }
119
+ .status-pill {
120
+ flex: none;
121
+ }
122
+ .pills {
123
+ display: flex;
124
+ flex-wrap: wrap;
125
+ justify-content: flex-end;
126
+ gap: ${space(2)};
127
+ max-inline-size: 50%;
128
+ }
129
+ /* A plus that turns to a minus: two bars, the upright one hidden when open. Drawn, not typed, so it is the same in every face. */
130
+ .marker {
131
+ position: relative;
132
+ flex: none;
133
+ inline-size: 18px;
134
+ block-size: 18px;
135
+ /* Centred on the question's first line, not sat on its baseline. */
136
+ align-self: flex-start;
137
+ margin-block-start: calc((1lh - 18px) / 2);
138
+ }
139
+ .marker::before,
140
+ .marker::after {
141
+ content: '';
142
+ position: absolute;
143
+ background: ${t.text};
144
+ }
145
+ .marker::before {
146
+ inset-inline: 0;
147
+ inset-block-start: calc(50% - 1px);
148
+ block-size: 2px;
149
+ }
150
+ .marker::after {
151
+ inset-block: 0;
152
+ inset-inline-start: calc(50% - 1px);
153
+ inline-size: 2px;
154
+ transition: transform 120ms ease-in-out;
155
+ }
156
+ .item.open .marker::after {
157
+ transform: scaleY(0);
158
+ }
159
+ @media (forced-colors: active) {
160
+ .marker::before,
161
+ .marker::after {
162
+ background: CanvasText;
163
+ }
164
+ }
165
+ /* With no script the element is never defined: the buttons cannot work, so they do not look as if they do. */
166
+ :host(:not(:defined)) button {
167
+ cursor: default;
168
+ pointer-events: none;
169
+ }
170
+ :host(:not(:defined)) .marker {
171
+ display: none;
172
+ }
173
+ .panel {
174
+ max-inline-size: 48rem;
175
+ margin-block-start: calc(-1 * ${space(4)});
176
+ padding-block-end: ${space(8)};
177
+ font-size: ${fontSize("md")};
178
+ line-height: 1.6;
179
+ color: ${t.textMuted};
180
+ }
181
+ /*
182
+ * Issues (frames 36:716, 36:430): rows divided by soft rules, each a code, a small "+" and the finding in
183
+ * body type. An open finding becomes an inset soft box with an ink edge: the code above the heading, the
184
+ * heading in heading S, the status at the top right, and the panel under them, with no marker.
185
+ */
186
+ :host([look='issues']) {
187
+ border-block-start: 0;
188
+ }
189
+ :host([look='issues']) .item {
190
+ border-block-end: ${t.borderThin} solid ${LINE_SOFT};
191
+ }
192
+ /* The finding keeps at least 16rem; on a narrow screen the status wraps under it, at the end, rather than squeezing it. */
193
+ :host([look='issues']) .head {
194
+ flex-wrap: wrap;
195
+ gap: ${space(2)} ${space(4)};
196
+ }
197
+ :host([look='issues']) .h {
198
+ flex: 1 1 16rem;
199
+ }
200
+ :host([look='issues']) .head > :is(.status-pill, .pills) {
201
+ margin-inline-start: auto;
202
+ }
203
+ :host([look='issues']) button {
204
+ align-items: center;
205
+ column-gap: ${space(3)};
206
+ padding-block: ${space(5)};
207
+ font-size: 1.25rem;
208
+ line-height: 1.2;
209
+ letter-spacing: -0.01em;
210
+ font-weight: ${fontWeight("regular")};
211
+ }
212
+ :host([look='issues']) .meta {
213
+ margin-inline-end: ${space(1)};
214
+ }
215
+ :host([look='issues']) .marker {
216
+ inline-size: 12px;
217
+ block-size: 12px;
218
+ }
219
+ :host([look='issues']) .marker::before {
220
+ inset-block-start: calc(50% - 0.75px);
221
+ block-size: 1.5px;
222
+ }
223
+ :host([look='issues']) .marker::after {
224
+ inset-inline-start: calc(50% - 0.75px);
225
+ inline-size: 1.5px;
226
+ }
227
+ :host([look='issues']) .item.open {
228
+ margin-block: ${space(4)};
229
+ padding: ${space(6)};
230
+ background: ${t.surfaceSubtle};
231
+ border: ${t.borderThin} solid ${t.text};
232
+ }
233
+ :host([look='issues']) .item.open .head {
234
+ align-items: flex-start;
235
+ }
236
+ :host([look='issues']) .item.open button {
237
+ flex-direction: column;
238
+ align-items: flex-start;
239
+ row-gap: ${space(2)};
240
+ padding-block: 0;
241
+ font-size: var(--impakt-type-heading-s-size, 1.5rem);
242
+ line-height: 1.15;
243
+ letter-spacing: -0.025em;
244
+ font-weight: ${fontWeight("semibold")};
245
+ }
246
+ :host([look='issues']) .item.open .meta {
247
+ letter-spacing: normal;
248
+ font-weight: 400;
249
+ }
250
+ :host([look='issues']) .item.open .marker {
251
+ display: none;
252
+ }
253
+ :host([look='issues']) .panel {
254
+ max-inline-size: none;
255
+ margin: ${space(4)} 0 0;
256
+ padding: 0;
257
+ color: ${t.text};
258
+ }
259
+ :host([look='issues']) .panel[hidden] {
260
+ display: none;
261
+ }
262
+ /* Without script every finding is open and has no marker; it reads as a list, not as boxes. */
263
+ :host([look='issues']:not(:defined)) .item.open {
264
+ margin: 0;
265
+ padding: ${space(5)} 0;
266
+ background: none;
267
+ border: 0;
268
+ border-block-end: ${t.borderThin} solid ${LINE_SOFT};
269
+ }
270
+ @media (max-width: 40rem) {
271
+ button {
272
+ padding-block: ${space(6)};
273
+ font-size: 1.25rem;
274
+ }
275
+ :host([look='issues']) button {
276
+ padding-block: ${space(4)};
277
+ font-size: 1.125rem;
278
+ }
279
+ :host([look='issues']) .item.open {
280
+ padding: ${space(4)};
281
+ }
282
+ :host([look='issues']) .item.open button {
283
+ padding-block: 0;
284
+ font-size: 1.25rem;
285
+ }
286
+ }
287
+ `
288
+ ];
289
+ }
290
+ toggle(id) {
291
+ const isOpen = this.open.includes(id);
292
+ if (isOpen) this.open = this.open.filter((o) => o !== id);
293
+ else this.open = this.multiple ? [...this.open, id] : [id];
294
+ }
295
+ render() {
296
+ const issues = this.look === "issues";
297
+ return html`
298
+ ${this.items.map((item) => {
299
+ const expanded = !this.enhanced || this.open.includes(item.id);
300
+ const panelId = this.id_(`panel-${item.id}`);
301
+ const buttonId = this.id_(`button-${item.id}`);
302
+ return html`
303
+ <div class="item ${expanded ? "open" : ""}" part="item">
304
+ <div class="head" part="head">
305
+ <div class="h" role="heading" aria-level=${this.headingLevel}>
306
+ <button
307
+ id=${buttonId}
308
+ part="header"
309
+ type="button"
310
+ aria-expanded=${expanded ? "true" : "false"}
311
+ aria-controls=${panelId}
312
+ @click=${() => this.toggle(item.id)}
313
+ >
314
+ ${item.meta ? html`<span class="meta" part="meta">${item.meta}</span>` : nothing}
315
+ ${issues ? html`<span class="marker" aria-hidden="true"></span>` : nothing}
316
+ <span class="q">${item.heading}</span>
317
+ </button>
318
+ </div>
319
+ ${item.tags?.length ? html`<span class="pills" part="pills">
320
+ ${statusPill(item.status, item.statusTone)}${item.tags.map((tag) => statusPill(tag.label, tag.tone ?? "neutral", "tag"))}
321
+ </span>` : statusPill(item.status, item.statusTone)}
322
+ ${issues ? nothing : html`<span class="marker" aria-hidden="true"></span>`}
323
+ </div>
324
+ <div
325
+ id=${panelId}
326
+ class="panel"
327
+ part="panel"
328
+ role="region"
329
+ aria-labelledby=${buttonId}
330
+ ?hidden=${!expanded}
331
+ >
332
+ <slot name=${`panel-${item.id}`}>${item.body}</slot>
333
+ </div>
334
+ </div>
335
+ `;
336
+ })}
337
+ `;
338
+ }
339
+ };
340
+ customElements.define("impakt-accordion", ImpaktAccordion);
341
+
342
+ export {
343
+ ImpaktAccordion
344
+ };
345
+ //# sourceMappingURL=chunk-FLAUZU7Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/accordion.ts"],"sourcesContent":["import { html, css, nothing, unsafeCSS, type TemplateResult } from 'lit';\nimport { onServer } from '../base/server';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { focusRing, targetSize } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\nimport { statusPill, statusPillStyles, type StatusTone } from './status-pill-style';\n\n/** The G2 soft rule between findings, until the theme carries it. */\nconst LINE_SOFT = unsafeCSS('var(--impakt-color-line-soft, #dcdcd8)');\n\nexport interface AccordionItem {\n id: string;\n heading: string;\n body: string;\n /** A short code before the heading, in the code face, such as \"01\" or \"WCAG 1.4.3\". It is part of the button's name. */\n meta?: string;\n /** A status after the heading, drawn as a pill, such as \"Fixed\". It is outside the button, so its name stays the question. */\n status?: string;\n /** The status's tone. */\n statusTone?: StatusTone;\n /** More pills after the status, such as \"Found by the model\" or \"WCAG 1.1.1\". Each one is words, so none rests on its dot. */\n tags?: Array<{ label: string; tone?: StatusTone }>;\n}\n\n/**\n * Disclosure sections — frequently asked questions, \"what does this mean?\".\n *\n * **Each header is a button inside a heading.** The heading is what lets a\n * screen-reader user jump between sections without tabbing through every\n * paragraph; the button is what makes the section openable. One without the\n * other is a common half-implementation: all-headings cannot be operated,\n * all-buttons cannot be navigated.\n *\n * `headingLevel` is a property because the right level depends on what is\n * above the accordion on the page, and guessing produces exactly the skipped\n * levels that 1.3.1 is about.\n *\n * **Panels are hidden, not unmounted.** `hidden` keeps the content in the\n * accessibility tree's structure and lets in-page search find it when opened,\n * and it means `aria-controls` always points at an element that exists.\n *\n * **A panel can hold more than words.** `body` is plain text, which is what a\n * composition can author safely. Content rendered elsewhere, such as an FAQ\n * answer with links and a list, is slotted instead: a child with\n * `slot=\"panel-<item id>\"` replaces that item's body. The slot sits inside the\n * panel, so the region, its label and its `hidden` state are unchanged, and a\n * panel with nothing slotted still shows its body.\n *\n * **Without script every panel is open.** A page built to finished HTML may load\n * no script at all, and a closed panel there could never be opened. So an\n * accordion drawn on the server has every panel open and its markers hidden: the\n * questions and answers read as a plain list. When the script loads it closes\n * the panels that `open` does not name, and the buttons work.\n *\n * @category content\n * @icon accordion\n */\nexport class ImpaktAccordion extends ImpaktElement {\n static properties = {\n items: { type: Array },\n headingLevel: { type: Number, attribute: 'heading-level' },\n open: { type: Array },\n multiple: { type: Boolean },\n look: { type: String, reflect: true },\n enhanced: { state: true },\n };\n\n declare items: AccordionItem[];\n declare headingLevel: number;\n /** Ids currently expanded. */\n declare open: string[];\n /** When false, opening one closes the others. */\n declare multiple: boolean;\n /**\n * `plain` is the site's questions: a \"+\" at the end that turns to \"−\" when\n * open. `issues` is a list of findings in a tool: the \"+\" at the start and an\n * open panel drawn as an inset soft panel with an ink border.\n */\n declare look: 'plain' | 'issues';\n /** Whether the script is running here, so the panels can be closed and opened. */\n declare private enhanced: boolean;\n\n constructor() {\n super();\n this.items = [];\n this.headingLevel = 3;\n this.open = [];\n this.multiple = true;\n this.look = 'plain';\n this.enhanced = false;\n }\n\n connectedCallback(): void {\n // Drawn here from nothing, the panels start as `open` says. Drawn on the server first, the\n // first draw here must match what the server sent, with every panel open, and firstUpdated\n // then closes them.\n if (!onServer && !this.shadowRoot) this.enhanced = true;\n super.connectedCallback();\n }\n\n protected firstUpdated(): void {\n this.enhanced = true;\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n statusPillStyles,\n css`\n :host {\n display: block;\n border-block-start: ${t.borderThin} solid ${t.text};\n }\n .item {\n border-block-end: ${t.borderThin} solid ${t.text};\n }\n /* The heading row. The button is stretched over it, so the whole row opens the panel, the status included. */\n .head {\n position: relative;\n display: flex;\n align-items: center;\n gap: ${space(4)};\n }\n .h {\n flex: 1;\n min-inline-size: 0;\n margin: 0;\n }\n button {\n ${targetSize}\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n column-gap: ${space(4)};\n row-gap: ${space(1)};\n inline-size: 100%;\n padding: ${space(8)} 0;\n background: none;\n border: 0;\n font: inherit;\n /* G2 heading S: 24/1.15, -2.5%, semibold. */\n font-size: var(--impakt-type-heading-s-size, 1.5rem);\n line-height: 1.15;\n letter-spacing: -0.025em;\n font-weight: ${fontWeight('semibold')};\n color: ${t.text};\n text-align: start;\n cursor: pointer;\n }\n button::after {\n content: '';\n position: absolute;\n inset: 0;\n }\n button:focus-visible {\n box-shadow: none;\n }\n button:focus-visible::after {\n box-shadow: ${t.focusShadow};\n }\n button:hover .q {\n text-decoration: underline;\n text-decoration-thickness: 1px;\n text-underline-offset: 0.15em;\n }\n .meta {\n font-family: ${t.fontMono};\n font-size: ${fontSize('sm')};\n font-weight: 400;\n letter-spacing: normal;\n color: ${t.textMuted};\n }\n .status-pill {\n flex: none;\n }\n .pills {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: ${space(2)};\n max-inline-size: 50%;\n }\n /* A plus that turns to a minus: two bars, the upright one hidden when open. Drawn, not typed, so it is the same in every face. */\n .marker {\n position: relative;\n flex: none;\n inline-size: 18px;\n block-size: 18px;\n /* Centred on the question's first line, not sat on its baseline. */\n align-self: flex-start;\n margin-block-start: calc((1lh - 18px) / 2);\n }\n .marker::before,\n .marker::after {\n content: '';\n position: absolute;\n background: ${t.text};\n }\n .marker::before {\n inset-inline: 0;\n inset-block-start: calc(50% - 1px);\n block-size: 2px;\n }\n .marker::after {\n inset-block: 0;\n inset-inline-start: calc(50% - 1px);\n inline-size: 2px;\n transition: transform 120ms ease-in-out;\n }\n .item.open .marker::after {\n transform: scaleY(0);\n }\n @media (forced-colors: active) {\n .marker::before,\n .marker::after {\n background: CanvasText;\n }\n }\n /* With no script the element is never defined: the buttons cannot work, so they do not look as if they do. */\n :host(:not(:defined)) button {\n cursor: default;\n pointer-events: none;\n }\n :host(:not(:defined)) .marker {\n display: none;\n }\n .panel {\n max-inline-size: 48rem;\n margin-block-start: calc(-1 * ${space(4)});\n padding-block-end: ${space(8)};\n font-size: ${fontSize('md')};\n line-height: 1.6;\n color: ${t.textMuted};\n }\n /*\n * Issues (frames 36:716, 36:430): rows divided by soft rules, each a code, a small \"+\" and the finding in\n * body type. An open finding becomes an inset soft box with an ink edge: the code above the heading, the\n * heading in heading S, the status at the top right, and the panel under them, with no marker.\n */\n :host([look='issues']) {\n border-block-start: 0;\n }\n :host([look='issues']) .item {\n border-block-end: ${t.borderThin} solid ${LINE_SOFT};\n }\n /* The finding keeps at least 16rem; on a narrow screen the status wraps under it, at the end, rather than squeezing it. */\n :host([look='issues']) .head {\n flex-wrap: wrap;\n gap: ${space(2)} ${space(4)};\n }\n :host([look='issues']) .h {\n flex: 1 1 16rem;\n }\n :host([look='issues']) .head > :is(.status-pill, .pills) {\n margin-inline-start: auto;\n }\n :host([look='issues']) button {\n align-items: center;\n column-gap: ${space(3)};\n padding-block: ${space(5)};\n font-size: 1.25rem;\n line-height: 1.2;\n letter-spacing: -0.01em;\n font-weight: ${fontWeight('regular')};\n }\n :host([look='issues']) .meta {\n margin-inline-end: ${space(1)};\n }\n :host([look='issues']) .marker {\n inline-size: 12px;\n block-size: 12px;\n }\n :host([look='issues']) .marker::before {\n inset-block-start: calc(50% - 0.75px);\n block-size: 1.5px;\n }\n :host([look='issues']) .marker::after {\n inset-inline-start: calc(50% - 0.75px);\n inline-size: 1.5px;\n }\n :host([look='issues']) .item.open {\n margin-block: ${space(4)};\n padding: ${space(6)};\n background: ${t.surfaceSubtle};\n border: ${t.borderThin} solid ${t.text};\n }\n :host([look='issues']) .item.open .head {\n align-items: flex-start;\n }\n :host([look='issues']) .item.open button {\n flex-direction: column;\n align-items: flex-start;\n row-gap: ${space(2)};\n padding-block: 0;\n font-size: var(--impakt-type-heading-s-size, 1.5rem);\n line-height: 1.15;\n letter-spacing: -0.025em;\n font-weight: ${fontWeight('semibold')};\n }\n :host([look='issues']) .item.open .meta {\n letter-spacing: normal;\n font-weight: 400;\n }\n :host([look='issues']) .item.open .marker {\n display: none;\n }\n :host([look='issues']) .panel {\n max-inline-size: none;\n margin: ${space(4)} 0 0;\n padding: 0;\n color: ${t.text};\n }\n :host([look='issues']) .panel[hidden] {\n display: none;\n }\n /* Without script every finding is open and has no marker; it reads as a list, not as boxes. */\n :host([look='issues']:not(:defined)) .item.open {\n margin: 0;\n padding: ${space(5)} 0;\n background: none;\n border: 0;\n border-block-end: ${t.borderThin} solid ${LINE_SOFT};\n }\n @media (max-width: 40rem) {\n button {\n padding-block: ${space(6)};\n font-size: 1.25rem;\n }\n :host([look='issues']) button {\n padding-block: ${space(4)};\n font-size: 1.125rem;\n }\n :host([look='issues']) .item.open {\n padding: ${space(4)};\n }\n :host([look='issues']) .item.open button {\n padding-block: 0;\n font-size: 1.25rem;\n }\n }\n `,\n ];\n\n private toggle(id: string): void {\n const isOpen = this.open.includes(id);\n if (isOpen) this.open = this.open.filter((o) => o !== id);\n else this.open = this.multiple ? [...this.open, id] : [id];\n }\n\n render(): TemplateResult {\n // In the issues look the \"+\" sits between the code and the finding, so it is inside the button.\n const issues = this.look === 'issues';\n return html`\n ${this.items.map((item) => {\n const expanded = !this.enhanced || this.open.includes(item.id);\n const panelId = this.id_(`panel-${item.id}`);\n const buttonId = this.id_(`button-${item.id}`);\n return html`\n <div class=\"item ${expanded ? 'open' : ''}\" part=\"item\">\n <div class=\"head\" part=\"head\">\n <div class=\"h\" role=\"heading\" aria-level=${this.headingLevel}>\n <button\n id=${buttonId}\n part=\"header\"\n type=\"button\"\n aria-expanded=${expanded ? 'true' : 'false'}\n aria-controls=${panelId}\n @click=${() => this.toggle(item.id)}\n >\n ${item.meta ? html`<span class=\"meta\" part=\"meta\">${item.meta}</span>` : nothing}\n ${issues ? html`<span class=\"marker\" aria-hidden=\"true\"></span>` : nothing}\n <span class=\"q\">${item.heading}</span>\n </button>\n </div>\n ${\n item.tags?.length\n ? html`<span class=\"pills\" part=\"pills\">\n ${statusPill(item.status, item.statusTone)}${item.tags.map((tag) => statusPill(tag.label, tag.tone ?? 'neutral', 'tag'))}\n </span>`\n : statusPill(item.status, item.statusTone)\n }\n ${issues ? nothing : html`<span class=\"marker\" aria-hidden=\"true\"></span>`}\n </div>\n <div\n id=${panelId}\n class=\"panel\"\n part=\"panel\"\n role=\"region\"\n aria-labelledby=${buttonId}\n ?hidden=${!expanded}\n >\n <slot name=${`panel-${item.id}`}>${item.body}</slot>\n </div>\n </div>\n `;\n })}\n `;\n }\n}\n\ncustomElements.define('impakt-accordion', ImpaktAccordion);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-accordion': ImpaktAccordion;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,SAAS,iBAAsC;AAQnE,IAAM,YAAY,UAAU,wCAAwC;AAiD7D,IAAM,kBAAN,cAA8B,cAAc;AAAA,EACjD;AAAA,SAAO,aAAa;AAAA,MAClB,OAAO,EAAE,MAAM,MAAM;AAAA,MACrB,cAAc,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,MACzD,MAAM,EAAE,MAAM,MAAM;AAAA,MACpB,UAAU,EAAE,MAAM,QAAQ;AAAA,MAC1B,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,UAAU,EAAE,OAAO,KAAK;AAAA,IAC1B;AAAA;AAAA,EAiBA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ,CAAC;AACd,SAAK,eAAe;AACpB,SAAK,OAAO,CAAC;AACb,SAAK,WAAW;AAChB,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA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KAAK,QAAQ,KAAK,UAAU,CAC7C;AAAA,gBACE,SAAS,UAAU,qDAAqD;AAAA;AAAA;AAAA,mBAGrE,OAAO;AAAA;AAAA;AAAA;AAAA,gCAIM,QAAQ;AAAA,wBAChB,CAAC,QAAQ;AAAA;AAAA,2BAEN,SAAS,KAAK,EAAE,EAAE,IAAI,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,IAIpD,CAAC,CAAC;AAAA;AAAA,EAEN;AACF;AAEA,eAAe,OAAO,oBAAoB,eAAe;","names":[]}
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  FieldElement
3
- } from "./chunk-ONED3PUB.js";
3
+ } from "./chunk-HSXLSJVG.js";
4
+ import {
5
+ targetSize
6
+ } from "./chunk-72WNCCDC.js";
4
7
  import {
5
8
  fontSize,
6
9
  space,
7
- t,
8
- targetSize
9
- } from "./chunk-V7EB7Q2M.js";
10
+ t
11
+ } from "./chunk-JTCTQBAX.js";
10
12
 
11
13
  // packages/ui/src/components/checkbox-group.ts
12
14
  import { html, css, nothing } from "lit";
@@ -128,4 +130,4 @@ customElements.define("impakt-checkbox-group", ImpaktCheckboxGroup);
128
130
  export {
129
131
  ImpaktCheckboxGroup
130
132
  };
131
- //# sourceMappingURL=chunk-3NEWOO2P.js.map
133
+ //# sourceMappingURL=chunk-FZWUQC42.js.map
@@ -1 +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\n .filter((o) => this.values.includes(o.value))\n .map((o) => o.value)\n .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 ? html`<span class=\"option-description\" id=${descId!}>${option.description}</span>` : 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 ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">${this.description}</div>` : 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 {\n 'impakt-checkbox-group': ImpaktCheckboxGroup;\n }\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,CAA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A,iCACN,UAAU,OAAO;AAAA,wBAC1B,CAAC,MAAa,KAAK,SAAS,OAAO,OAAQ,EAAE,OAA4B,OAAO,CAAC;AAAA;AAAA;AAAA,0CAG/D,OAAO,KAAK;AAAA,gBACtC,OAAO,cAAc,2CAA2C,MAAO,IAAI,OAAO,WAAW,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA,IAI1H,CAAC,CAAC;AAAA;AAAA,EAEN;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,mDACwC,KAAK,WAAW,iBAAiB,KAAK,QAAQ,SAAS,OAAO;AAAA,UACvG,KAAK,YAAY,CAAC;AAAA,UAClB,KAAK,cAAc,mCAAmC,KAAK,IAAI,aAAa,CAAC,uBAAuB,KAAK,WAAW,WAAW,OAAO;AAAA,UACtI,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
+ {"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\n .filter((o) => this.values.includes(o.value))\n .map((o) => o.value)\n .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 ? html`<span class=\"option-description\" id=${descId!}>${option.description}</span>` : 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 ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">${this.description}</div>` : 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 {\n 'impakt-checkbox-group': ImpaktCheckboxGroup;\n }\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;A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,EAAE,OAA4B,OAAO,CAAC;AAAA;AAAA;AAAA,0CAG/D,OAAO,KAAK;AAAA,gBACtC,OAAO,cAAc,2CAA2C,MAAO,IAAI,OAAO,WAAW,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA,IAI1H,CAAC,CAAC;AAAA;AAAA,EAEN;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,mDACwC,KAAK,WAAW,iBAAiB,KAAK,QAAQ,SAAS,OAAO;AAAA,UACvG,KAAK,YAAY,CAAC;AAAA,UAClB,KAAK,cAAc,mCAAmC,KAAK,IAAI,aAAa,CAAC,uBAAuB,KAAK,WAAW,WAAW,OAAO;AAAA,UACtI,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,16 +1,18 @@
1
1
  import {
2
2
  ImpaktElement,
3
3
  focusRing,
4
+ visuallyHidden
5
+ } from "./chunk-72WNCCDC.js";
6
+ import {
4
7
  fontSize,
5
8
  fontWeight,
6
9
  lineHeight,
7
10
  space,
8
- t,
9
- visuallyHidden
10
- } from "./chunk-V7EB7Q2M.js";
11
+ t
12
+ } from "./chunk-JTCTQBAX.js";
11
13
 
12
14
  // packages/ui/src/base/FieldElement.ts
13
- import { html, css, nothing } from "lit";
15
+ import { html, css, nothing, unsafeCSS } from "lit";
14
16
  var fieldWidths = css`
15
17
  :host { --impakt-field-width: 100%; }
16
18
  :host([width='xs']) { --impakt-field-width: 8ch; }
@@ -18,6 +20,41 @@ var fieldWidths = css`
18
20
  :host([width='md']) { --impakt-field-width: 24ch; }
19
21
  :host([width='lg']) { --impakt-field-width: 40ch; }
20
22
  `;
23
+ var fieldControl = (selector) => {
24
+ const s = unsafeCSS(selector);
25
+ return css`
26
+ ${s} {
27
+ inline-size: min(100%, var(--impakt-field-width));
28
+ min-block-size: 50px;
29
+ padding: 13px ${space(3.5)};
30
+ font-family: inherit;
31
+ font-size: ${fontSize("md")};
32
+ line-height: 1.5;
33
+ color: ${t.text};
34
+ background: var(--impakt-color-field-surface, ${t.surfaceCard});
35
+ border: ${t.borderThin} solid var(--impakt-color-field-border, ${t.text});
36
+ border-radius: ${t.radius};
37
+ box-shadow: var(--impakt-shadow-field, none);
38
+ transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;
39
+ }
40
+ ${s}:focus-visible {
41
+ border-color: ${t.text};
42
+ box-shadow: ${t.focusShadow};
43
+ }
44
+ ${s}::placeholder {
45
+ color: ${t.textPlaceholder};
46
+ }
47
+ ${s}:disabled {
48
+ background: ${t.surfaceInset};
49
+ cursor: not-allowed;
50
+ }
51
+ /* The border thickens as well as reddening, and the message below says it in words (1.4.1). */
52
+ :host([invalid]) ${s} {
53
+ border-color: ${t.danger};
54
+ border-width: ${t.borderThick};
55
+ }
56
+ `;
57
+ };
21
58
  var FieldElement = class extends ImpaktElement {
22
59
  constructor() {
23
60
  super();
@@ -63,12 +100,20 @@ var FieldElement = class extends ImpaktElement {
63
100
  display: block;
64
101
  margin-block-end: ${space(4)};
65
102
  }
103
+ /*
104
+ * The question, in the code face at 14px in the ink (G2). A page can set it
105
+ * another way through these properties, such as the site's contact form,
106
+ * which sets its labels in capitals at 11px (frame 20:1157).
107
+ */
66
108
  .label {
67
109
  display: block;
68
- font-size: ${fontSize("sm")};
69
- font-weight: ${fontWeight("semibold")};
110
+ font-family: var(--impakt-field-label-font, ${t.fontMono});
111
+ font-size: var(--impakt-field-label-size, ${fontSize("sm")});
112
+ font-weight: var(--impakt-field-label-weight, ${fontWeight("regular")});
113
+ letter-spacing: var(--impakt-field-label-tracking, normal);
114
+ text-transform: var(--impakt-field-label-transform, none);
70
115
  line-height: ${lineHeight("normal")};
71
- margin-block-end: ${space(1)};
116
+ margin-block-end: ${space(2)};
72
117
  color: ${t.text};
73
118
  }
74
119
  .required {
@@ -183,6 +228,7 @@ var FieldElement = class extends ImpaktElement {
183
228
 
184
229
  export {
185
230
  fieldWidths,
231
+ fieldControl,
186
232
  FieldElement
187
233
  };
188
- //# sourceMappingURL=chunk-ONED3PUB.js.map
234
+ //# sourceMappingURL=chunk-HSXLSJVG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/base/FieldElement.ts"],"sourcesContent":["import { html, css, nothing, unsafeCSS, type CSSResult, type TemplateResult } from 'lit';\nimport { ImpaktElement } from './ImpaktElement';\nimport { focusRing, visuallyHidden } from './styles';\nimport { fontSize, fontWeight, lineHeight, space, t } from './tokens';\n\n/**\n * The shared anatomy of a form control: a label, an optional description, a\n * control, and an error.\n *\n * This exists because the ARIA wiring between those four is where accessible\n * forms actually fail, and it fails the same way every time — a description\n * that is never announced, an error that appears silently, a label that points\n * at nothing. Written once, it is right once.\n *\n * Everything is rendered inside this component's own shadow root, including\n * the native control. That is not an implementation detail: `aria-describedby`\n * cannot cross a shadow boundary, so a component that slotted the input from\n * outside could not describe it. Keeping the whole relationship in one tree is\n * what makes the wiring work at all.\n */\n/**\n * How wide a single-line control is, from what it holds: a postcode is short,\n * an email address is long. A width that matches the answer is a hint about\n * what to type (1.3.5 is about the purpose, this is about the size). Applied by\n * the controls that take a `width`, through `--impakt-field-width`.\n */\nexport const fieldWidths = css`\n :host { --impakt-field-width: 100%; }\n :host([width='xs']) { --impakt-field-width: 8ch; }\n :host([width='sm']) { --impakt-field-width: 14ch; }\n :host([width='md']) { --impakt-field-width: 24ch; }\n :host([width='lg']) { --impakt-field-width: 40ch; }\n`;\n\n/**\n * The box a single control is drawn in, shared by the text input, the select and\n * the textarea so they match: a 1px ink border, no shadow, and on focus the\n * locked two-band ring rather than a wide halo (G2 Noire, frames 33:492 and 36:398).\n * A product can still set `--impakt-shadow-field` or `--impakt-color-field-border`.\n */\nexport const fieldControl = (selector: string): CSSResult => {\n const s = unsafeCSS(selector);\n return css`\n ${s} {\n inline-size: min(100%, var(--impakt-field-width));\n min-block-size: 50px;\n padding: 13px ${space(3.5)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n line-height: 1.5;\n color: ${t.text};\n background: var(--impakt-color-field-surface, ${t.surfaceCard});\n border: ${t.borderThin} solid var(--impakt-color-field-border, ${t.text});\n border-radius: ${t.radius};\n box-shadow: var(--impakt-shadow-field, none);\n transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;\n }\n ${s}:focus-visible {\n border-color: ${t.text};\n box-shadow: ${t.focusShadow};\n }\n ${s}::placeholder {\n color: ${t.textPlaceholder};\n }\n ${s}:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n /* The border thickens as well as reddening, and the message below says it in words (1.4.1). */\n :host([invalid]) ${s} {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `;\n};\n\n/**\n * The base of every form control.\n *\n * @fires {CustomEvent<{ value: string }>} impakt-change - When the answer changes. The answer is in detail.value.\n */\nexport abstract class FieldElement extends ImpaktElement {\n /** Form controls participate in a `<form>` like native ones. */\n static formAssociated = true;\n\n static properties = {\n label: { type: String },\n name: { type: String },\n value: { type: String },\n description: { type: String },\n error: { type: String },\n required: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n readonly: { type: Boolean, reflect: true },\n requiredText: { type: String, attribute: 'required-text' },\n };\n\n declare label: string;\n declare name: string;\n declare value: string;\n declare description: string;\n declare error: string;\n declare required: boolean;\n declare disabled: boolean;\n declare readonly: boolean;\n /**\n * How \"you must answer this\" is said.\n *\n * Words, not an asterisk. 3.3.2 asks for labels or instructions, and an\n * asterisk is neither until a legend explains it — which puts the\n * explanation somewhere other than the field it explains. It is a property\n * so a partner can reword it, not so they can empty it.\n */\n declare requiredText: string;\n\n protected internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this.label = '';\n this.name = '';\n this.value = '';\n this.description = '';\n this.error = '';\n this.required = false;\n this.disabled = false;\n this.readonly = false;\n this.requiredText = 'required';\n // happy-dom and older engines do not implement attachInternals. A control\n // that cannot associate with a form is still a usable control, so this\n // degrades rather than throwing on construction.\n try {\n this.internals = this.attachInternals();\n } catch {\n this.internals = null;\n }\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n margin-block-end: ${space(4)};\n }\n /*\n * The question, in the code face at 14px in the ink (G2). A page can set it\n * another way through these properties, such as the site's contact form,\n * which sets its labels in capitals at 11px (frame 20:1157).\n */\n .label {\n display: block;\n font-family: var(--impakt-field-label-font, ${t.fontMono});\n font-size: var(--impakt-field-label-size, ${fontSize('sm')});\n font-weight: var(--impakt-field-label-weight, ${fontWeight('regular')});\n letter-spacing: var(--impakt-field-label-tracking, normal);\n text-transform: var(--impakt-field-label-transform, none);\n line-height: ${lineHeight('normal')};\n margin-block-end: ${space(2)};\n color: ${t.text};\n }\n .required {\n font-weight: ${fontWeight('regular')};\n color: ${t.textMuted};\n }\n .description {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.textMuted};\n margin-block-end: ${space(2)};\n }\n .error {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.dangerText};\n margin-block-start: ${space(1)};\n display: flex;\n gap: ${space(1)};\n }\n .error:empty {\n display: none;\n }\n .visually-hidden {\n ${visuallyHidden}\n }\n /*\n * Only the control is dimmed. Dimming the whole host took the question,\n * the hint and the error below 4.5:1, and a disabled field still has to\n * say what it is and why it cannot be changed. The native disabled\n * control itself is exempt from the contrast criterion.\n */\n :host([disabled]) :is(input, select, textarea, button) {\n opacity: 0.6;\n cursor: not-allowed;\n }\n `,\n ];\n\n protected get controlId(): string {\n return this.id_('control');\n }\n\n /**\n * What the control points `aria-describedby` at.\n *\n * The error id is included only while there is an error. A describedby that\n * always names an empty element trains a screen-reader user to expect\n * nothing after the description, and then the one time it matters they have\n * already learned to ignore it.\n */\n protected get describedBy(): string | typeof nothing {\n const ids = [this.description ? this.id_('description') : '', this.error ? this.id_('error') : ''].filter(Boolean);\n return ids.length ? ids.join(' ') : nothing;\n }\n\n /**\n * Focusing the element focuses its control, so `el.focus()` from an app, a\n * React ref or the error summary's link lands where someone can type, rather\n * than on a host that cannot take focus and so silently does nothing.\n */\n focus(options?: FocusOptions): void {\n const control =\n this.renderRoot?.querySelector<HTMLElement>(`#${this.controlId}`) ?? this.renderRoot?.querySelector<HTMLElement>('input, select, textarea, button');\n if (control) control.focus(options);\n else super.focus(options);\n }\n\n /** Subclasses render the control itself; everything round it is here. */\n protected abstract renderControl(): TemplateResult;\n\n /**\n * `<label for>` by default. A group of controls — radios, checkboxes —\n * cannot use one, because `for` names a single control, so those override\n * this and render a `<fieldset>` and `<legend>` instead.\n */\n protected renderLabel(): TemplateResult {\n return html`\n <label class=\"label\" for=${this.controlId} part=\"label\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </label>\n `;\n }\n\n render(): TemplateResult {\n return html`\n ${this.renderLabel()}\n ${\n this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">\n ${this.description}\n </div>`\n : nothing\n }\n ${this.renderControl()}\n <!--\n The error region is always present, even when empty. A live region\n inserted at the same moment as its content is announced unreliably\n across screen readers; one that already exists and is then filled is\n announced consistently. \"polite\" rather than \"assertive\" because a\n validation message should not interrupt what is being read.\n -->\n <div\n class=\"error\"\n id=${this.id_('error')}\n part=\"error\"\n aria-live=\"polite\"\n >\n ${this.error || nothing}\n </div>\n `;\n }\n\n /** Keep the form value in step with the control. */\n protected setFormValue(value: string): void {\n this.value = value;\n this.internals?.setFormValue(value);\n this.dispatchEvent(new CustomEvent('impakt-change', { detail: this.changeDetail(value), bubbles: true, composed: true }));\n }\n\n /** What `impakt-change` carries. A control with more to say than its value adds it here. */\n protected changeDetail(value: string): { value: string } {\n return { value };\n }\n}\n"],"mappings":";;;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