@atomic-ui/ui 0.7.0 → 0.7.2

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 (139) hide show
  1. package/README.md +8 -8
  2. package/custom-elements.json +460 -28
  3. package/dist/base/FieldElement.d.ts +4 -0
  4. package/dist/{chunk-TRZO5CHU.js → chunk-26BO3W56.js} +8 -4
  5. package/dist/chunk-26BO3W56.js.map +1 -0
  6. package/dist/{chunk-4ZQTXTPA.js → chunk-2EP3IV3G.js} +8 -4
  7. package/dist/chunk-2EP3IV3G.js.map +1 -0
  8. package/dist/{chunk-NU34ZQFR.js → chunk-2ZF3J7OO.js} +8 -5
  9. package/dist/chunk-2ZF3J7OO.js.map +1 -0
  10. package/dist/{chunk-WP5WJ4V5.js → chunk-3NEWOO2P.js} +3 -3
  11. package/dist/chunk-3NEWOO2P.js.map +1 -0
  12. package/dist/{chunk-AMDTBUUL.js → chunk-3T7J66Z2.js} +16 -4
  13. package/dist/chunk-3T7J66Z2.js.map +1 -0
  14. package/dist/{chunk-XU2XODVH.js → chunk-5OJAJA3U.js} +3 -3
  15. package/dist/chunk-5OJAJA3U.js.map +1 -0
  16. package/dist/{chunk-3EF4T242.js → chunk-6PMA6NHE.js} +8 -4
  17. package/dist/chunk-6PMA6NHE.js.map +1 -0
  18. package/dist/{chunk-HNBG2POR.js → chunk-7C56LPNJ.js} +2 -2
  19. package/dist/{chunk-HNBG2POR.js.map → chunk-7C56LPNJ.js.map} +1 -1
  20. package/dist/{chunk-EJSX4WCD.js → chunk-7UWJXPR3.js} +12 -8
  21. package/dist/chunk-7UWJXPR3.js.map +1 -0
  22. package/dist/{chunk-WH43U4IY.js → chunk-A4M3A4SZ.js} +4 -4
  23. package/dist/{chunk-WH43U4IY.js.map → chunk-A4M3A4SZ.js.map} +1 -1
  24. package/dist/{chunk-I54DOEZB.js → chunk-AG4EP3OY.js} +3 -3
  25. package/dist/{chunk-I54DOEZB.js.map → chunk-AG4EP3OY.js.map} +1 -1
  26. package/dist/{chunk-WS4AYRSL.js → chunk-AL4IUSML.js} +7 -4
  27. package/dist/{chunk-WS4AYRSL.js.map → chunk-AL4IUSML.js.map} +1 -1
  28. package/dist/{chunk-ZQBEFP2O.js → chunk-APQEXM4I.js} +8 -4
  29. package/dist/chunk-APQEXM4I.js.map +1 -0
  30. package/dist/{chunk-YYYQPKQ7.js → chunk-AURT72IC.js} +2 -2
  31. package/dist/{chunk-KFAGXPIK.js → chunk-AVDSYLOY.js} +3 -3
  32. package/dist/{chunk-KFAGXPIK.js.map → chunk-AVDSYLOY.js.map} +1 -1
  33. package/dist/{chunk-GJPHQLLN.js → chunk-AYKYHZGQ.js} +2 -2
  34. package/dist/{chunk-GJPHQLLN.js.map → chunk-AYKYHZGQ.js.map} +1 -1
  35. package/dist/{chunk-QBORJTS4.js → chunk-D3JWVMJE.js} +55 -19
  36. package/dist/chunk-D3JWVMJE.js.map +1 -0
  37. package/dist/{chunk-RXX4CN5J.js → chunk-EGJZDKMW.js} +2 -2
  38. package/dist/{chunk-RXX4CN5J.js.map → chunk-EGJZDKMW.js.map} +1 -1
  39. package/dist/{chunk-UPOTBKKK.js → chunk-FU3CEHBS.js} +2 -2
  40. package/dist/{chunk-UPOTBKKK.js.map → chunk-FU3CEHBS.js.map} +1 -1
  41. package/dist/{chunk-FWR6SEIA.js → chunk-HA6OJRVI.js} +17 -6
  42. package/dist/chunk-HA6OJRVI.js.map +1 -0
  43. package/dist/{chunk-XZQH2M5I.js → chunk-HURHKQTJ.js} +18 -8
  44. package/dist/chunk-HURHKQTJ.js.map +1 -0
  45. package/dist/{chunk-UF6KCRNT.js → chunk-JNLKM3JT.js} +29 -13
  46. package/dist/chunk-JNLKM3JT.js.map +1 -0
  47. package/dist/{chunk-2HWO5TFV.js → chunk-KAQJVGYW.js} +14 -9
  48. package/dist/{chunk-2HWO5TFV.js.map → chunk-KAQJVGYW.js.map} +1 -1
  49. package/dist/{chunk-BNYILASW.js → chunk-MLKNZL5J.js} +28 -12
  50. package/dist/chunk-MLKNZL5J.js.map +1 -0
  51. package/dist/{chunk-PYVUQNFQ.js → chunk-MOO63SHZ.js} +2 -2
  52. package/dist/{chunk-PYVUQNFQ.js.map → chunk-MOO63SHZ.js.map} +1 -1
  53. package/dist/{chunk-A7YBFS4H.js → chunk-NKMJMVZP.js} +2 -2
  54. package/dist/{chunk-5ZQVL3V2.js → chunk-ONED3PUB.js} +8 -7
  55. package/dist/{chunk-5ZQVL3V2.js.map → chunk-ONED3PUB.js.map} +1 -1
  56. package/dist/{chunk-MLRTPQQO.js → chunk-OZGKK3N5.js} +11 -6
  57. package/dist/chunk-OZGKK3N5.js.map +1 -0
  58. package/dist/{chunk-RZWRAJCD.js → chunk-P6HG5RB2.js} +71 -29
  59. package/dist/chunk-P6HG5RB2.js.map +1 -0
  60. package/dist/{chunk-NUUX2SSN.js → chunk-TE3CBEJQ.js} +34 -12
  61. package/dist/chunk-TE3CBEJQ.js.map +1 -0
  62. package/dist/{chunk-YR6T73GY.js → chunk-V7EB7Q2M.js} +1 -1
  63. package/dist/chunk-V7EB7Q2M.js.map +1 -0
  64. package/dist/{chunk-OE6O3XQB.js → chunk-VYYY5DDZ.js} +3 -3
  65. package/dist/chunk-VYYY5DDZ.js.map +1 -0
  66. package/dist/{chunk-DE3INTHZ.js → chunk-YWP2Z3JN.js} +3 -3
  67. package/dist/{chunk-DE3INTHZ.js.map → chunk-YWP2Z3JN.js.map} +1 -1
  68. package/dist/{chunk-WS5AUJ35.js → chunk-Z2EWQMTR.js} +7 -4
  69. package/dist/chunk-Z2EWQMTR.js.map +1 -0
  70. package/dist/{chunk-INA53XXW.js → chunk-ZL3JFUIE.js} +3 -3
  71. package/dist/chunk-ZL3JFUIE.js.map +1 -0
  72. package/dist/components/accordion.js +2 -2
  73. package/dist/components/alert.js +2 -2
  74. package/dist/components/app-ui.d.ts +13 -0
  75. package/dist/components/app-ui.js +4 -4
  76. package/dist/components/badge.js +3 -3
  77. package/dist/components/blocks.js +4 -4
  78. package/dist/components/button.js +3 -3
  79. package/dist/components/checkbox-group.js +3 -3
  80. package/dist/components/checkbox.js +3 -3
  81. package/dist/components/chip.js +2 -2
  82. package/dist/components/date-input.js +3 -3
  83. package/dist/components/dialog.js +2 -2
  84. package/dist/components/fieldset.js +2 -2
  85. package/dist/components/grid.js +2 -2
  86. package/dist/components/help.js +2 -2
  87. package/dist/components/icon.js +2 -2
  88. package/dist/components/journey.js +3 -3
  89. package/dist/components/layout.js +2 -2
  90. package/dist/components/link.js +3 -3
  91. package/dist/components/list.js +2 -2
  92. package/dist/components/media.js +2 -2
  93. package/dist/components/navigation.js +3 -3
  94. package/dist/components/page.js +2 -2
  95. package/dist/components/price.js +2 -2
  96. package/dist/components/progress.d.ts +12 -0
  97. package/dist/components/progress.js +2 -2
  98. package/dist/components/radio-group.js +3 -3
  99. package/dist/components/rows.js +3 -3
  100. package/dist/components/select.d.ts +11 -0
  101. package/dist/components/select.js +3 -3
  102. package/dist/components/shell.js +3 -3
  103. package/dist/components/summary-list.js +2 -2
  104. package/dist/components/switch.d.ts +17 -0
  105. package/dist/components/switch.js +3 -3
  106. package/dist/components/table.js +3 -3
  107. package/dist/components/text-input.js +4 -4
  108. package/dist/components/textarea.js +3 -3
  109. package/dist/index.d.ts +2 -2
  110. package/dist/index.js +35 -35
  111. package/dist/standalone/atomic-ui.js +95 -73
  112. package/dist/standalone/atomic-ui.js.map +3 -3
  113. package/dist/standalone/index.html +189 -150
  114. package/package.json +2 -2
  115. package/scripts/copy-to-product.mjs +8 -7
  116. package/specimen/index.html +189 -150
  117. package/dist/chunk-3EF4T242.js.map +0 -1
  118. package/dist/chunk-4ZQTXTPA.js.map +0 -1
  119. package/dist/chunk-AMDTBUUL.js.map +0 -1
  120. package/dist/chunk-BNYILASW.js.map +0 -1
  121. package/dist/chunk-EJSX4WCD.js.map +0 -1
  122. package/dist/chunk-FWR6SEIA.js.map +0 -1
  123. package/dist/chunk-INA53XXW.js.map +0 -1
  124. package/dist/chunk-MLRTPQQO.js.map +0 -1
  125. package/dist/chunk-NU34ZQFR.js.map +0 -1
  126. package/dist/chunk-NUUX2SSN.js.map +0 -1
  127. package/dist/chunk-OE6O3XQB.js.map +0 -1
  128. package/dist/chunk-QBORJTS4.js.map +0 -1
  129. package/dist/chunk-RZWRAJCD.js.map +0 -1
  130. package/dist/chunk-TRZO5CHU.js.map +0 -1
  131. package/dist/chunk-UF6KCRNT.js.map +0 -1
  132. package/dist/chunk-WP5WJ4V5.js.map +0 -1
  133. package/dist/chunk-WS5AUJ35.js.map +0 -1
  134. package/dist/chunk-XU2XODVH.js.map +0 -1
  135. package/dist/chunk-XZQH2M5I.js.map +0 -1
  136. package/dist/chunk-YR6T73GY.js.map +0 -1
  137. package/dist/chunk-ZQBEFP2O.js.map +0 -1
  138. /package/dist/{chunk-YYYQPKQ7.js.map → chunk-AURT72IC.js.map} +0 -0
  139. /package/dist/{chunk-A7YBFS4H.js.map → chunk-NKMJMVZP.js.map} +0 -0
@@ -110,4 +110,8 @@ export declare abstract class FieldElement extends ImpaktElement {
110
110
  render(): TemplateResult;
111
111
  /** Keep the form value in step with the control. */
112
112
  protected setFormValue(value: string): void;
113
+ /** What `impakt-change` carries. A control with more to say than its value adds it here. */
114
+ protected changeDetail(value: string): {
115
+ value: string;
116
+ };
113
117
  }
@@ -3,7 +3,7 @@ import {
3
3
  focusRing,
4
4
  fontWeight,
5
5
  t
6
- } from "./chunk-YR6T73GY.js";
6
+ } from "./chunk-V7EB7Q2M.js";
7
7
 
8
8
  // packages/ui/src/components/help.ts
9
9
  import { html, css, nothing } from "lit";
@@ -25,7 +25,10 @@ var ImpaktHelp = class extends ImpaktElement {
25
25
  this.detail = "";
26
26
  }
27
27
  static {
28
- this.styles = [...ImpaktElement.styles, focusRing, css`
28
+ this.styles = [
29
+ ...ImpaktElement.styles,
30
+ focusRing,
31
+ css`
29
32
  :host { display: block; }
30
33
  a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};
31
34
  color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }
@@ -35,7 +38,8 @@ var ImpaktHelp = class extends ImpaktElement {
35
38
  /* An address is written one line at a time, and opening hours are often one
36
39
  day to a line. Long unbroken values still wrap at 320px (1.4.10). */
37
40
  .detail { white-space: pre-line; overflow-wrap: anywhere; }
38
- `];
41
+ `
42
+ ];
39
43
  }
40
44
  render() {
41
45
  switch (this.kind) {
@@ -81,4 +85,4 @@ customElements.define("impakt-help", ImpaktHelp);
81
85
  export {
82
86
  ImpaktHelp
83
87
  };
84
- //# sourceMappingURL=chunk-TRZO5CHU.js.map
88
+ //# sourceMappingURL=chunk-26BO3W56.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 = [\n ...ImpaktElement.styles,\n focusRing,\n 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\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 ? html`<span class=\"caption\" part=\"label\" id=${captionId}>${caption}</span>` : 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\n .replace(/\\(0\\)/g, '')\n .replace(/[^\\d+]/g, '')\n .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 {\n 'impakt-help': ImpaktHelp;\n }\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,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,cAAc;AAAA,MACjB;AAAA,MACA;AAAA;AAAA,iEAE6D,EAAE,SAAS,gBAAgB,EAAE,SAAS;AAAA,eACxF,EAAE,IAAI;AAAA,uBACE,EAAE,SAAS;AAAA;AAAA,8CAEY,WAAW,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,IAKlE;AAAA;AAAA,EAEA,SAA0C;AACxC,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAA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73GY.js";
7
+ } from "./chunk-V7EB7Q2M.js";
8
8
 
9
9
  // packages/ui/src/components/chip.ts
10
10
  import { css, html, nothing } from "lit";
@@ -48,7 +48,10 @@ var ImpaktChip = class extends ImpaktElement {
48
48
  this.hideOn = "never";
49
49
  }
50
50
  static {
51
- this.styles = [...ImpaktElement.styles, hideOn, css`
51
+ this.styles = [
52
+ ...ImpaktElement.styles,
53
+ hideOn,
54
+ css`
52
55
  :host { display: inline-flex; flex: none; }
53
56
  span.chip { display: inline-flex; align-items: center; gap: ${space(1.5)}; padding: 3px ${space(2.5)}; border-radius: 999px; font-family: ${MONO}; font-size: ${fontSize("xs")}; line-height: 1.2; white-space: nowrap; }
54
57
  :host([look='filled']) span.chip { border-radius: ${t.radius}; background: color-mix(in srgb, currentColor 7%, transparent); }
@@ -58,7 +61,8 @@ var ImpaktChip = class extends ImpaktElement {
58
61
  svg { inline-size: 12px; block-size: 12px; }
59
62
  .meta { opacity: 0.72; text-transform: none; }
60
63
  :host([look='plain']) .label { opacity: 0.72; }
61
- `];
64
+ `
65
+ ];
62
66
  }
63
67
  render() {
64
68
  const icon = this.icon === "dot" ? html`<span class="dot" aria-hidden="true"></span>` : this.icon === "branch" ? html`<svg viewBox="0 0 14 14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="3.5" cy="3" r="1.5"/><circle cx="3.5" cy="11" r="1.5"/><circle cx="10.5" cy="4.5" r="1.5"/><path d="M3.5 4.5v5M10.5 6c0 2.5-3 2.5-6 4"/></svg>` : nothing;
@@ -73,4 +77,4 @@ export {
73
77
  toneOf,
74
78
  ImpaktChip
75
79
  };
76
- //# sourceMappingURL=chunk-4ZQTXTPA.js.map
80
+ //# sourceMappingURL=chunk-2EP3IV3G.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chip.ts","../src/base/tone.ts"],"sourcesContent":["/**\n * A short label: a branch, a status with its dot, or a code such as a commit\n * hash.\n */\nimport { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { hideOn } from '../base/styles';\nimport { fontSize, space, t } from '../base/tokens';\nimport { toneOf, type Tone } from '../base/tone';\n\n/** Code-like labels: a branch, a hash, a commit message. */\nconst MONO = t.fontMono;\n\n/**\n * A short label: a branch name with its icon, a status with its dot, or a\n * code such as a commit hash. It says something; it does nothing.\n *\n * @category content\n * @icon badge\n */\nexport class ImpaktChip extends ImpaktElement {\n static properties = {\n label: { type: String },\n meta: { type: String },\n icon: { type: String, reflect: true },\n tone: { type: String },\n look: { type: String, reflect: true },\n hideOn: { type: String, reflect: true, attribute: 'hide-on' },\n };\n declare label: string;\n /** A code after the label, quieter, such as a hash. */\n declare meta: string;\n /** A coloured dot, a branch, or nothing before the label. */\n declare icon: 'none' | 'dot' | 'branch';\n /** The dot's colour: a named tone, or 1 to 5 for the brand's chart colours. */\n declare tone: Tone;\n /** `outlined` on the card colour, `filled` with a faint wash, or `plain` words in the code face. */\n declare look: 'outlined' | 'filled' | 'plain';\n declare hideOn: 'never' | 'phone' | 'wide';\n\n constructor() {\n super();\n this.label = '';\n this.meta = '';\n this.icon = 'none';\n this.tone = 'success';\n this.look = 'filled';\n this.hideOn = 'never';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n hideOn,\n css`\n :host { display: inline-flex; flex: none; }\n span.chip { display: inline-flex; align-items: center; gap: ${space(1.5)}; padding: 3px ${space(2.5)}; border-radius: 999px; font-family: ${MONO}; font-size: ${fontSize('xs')}; line-height: 1.2; white-space: nowrap; }\n :host([look='filled']) span.chip { border-radius: ${t.radius}; background: color-mix(in srgb, currentColor 7%, transparent); }\n :host([look='outlined']) span.chip { border: ${t.borderThin} solid ${t.border}; background: ${t.surfaceCard}; text-transform: uppercase; letter-spacing: 0.04em; }\n :host([look='plain']) span.chip { padding: 0; }\n .dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--tone); }\n svg { inline-size: 12px; block-size: 12px; }\n .meta { opacity: 0.72; text-transform: none; }\n :host([look='plain']) .label { opacity: 0.72; }\n `,\n ];\n\n render(): TemplateResult {\n const icon =\n this.icon === 'dot'\n ? html`<span class=\"dot\" aria-hidden=\"true\"></span>`\n : this.icon === 'branch'\n ? html`<svg viewBox=\"0 0 14 14\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"><circle cx=\"3.5\" cy=\"3\" r=\"1.5\"/><circle cx=\"3.5\" cy=\"11\" r=\"1.5\"/><circle cx=\"10.5\" cy=\"4.5\" r=\"1.5\"/><path d=\"M3.5 4.5v5M10.5 6c0 2.5-3 2.5-6 4\"/></svg>`\n : nothing;\n return html`<span class=\"chip\" part=\"chip\" style=${`--tone:${toneOf(this.tone, 0)}`}>${icon}<span class=\"label\">${this.label}</span>${this.meta ? html` <span class=\"meta\">${this.meta}</span>` : nothing}</span>`;\n }\n}\n\ncustomElements.define('impakt-chip', ImpaktChip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-chip': ImpaktChip;\n }\n}\n","/**\n * Colours named by what they are in the brand, for a line, a lane, a dot or a\n * stripe. A tone is a brand token, never a hex value, so a partner's brand\n * restyles everything drawn with one.\n *\n * It is shared: `impakt-chip` here and the changelog, site and estimator blocks\n * in `@atomic-ui/blocks` all colour themselves with it.\n */\n\n/** A colour for a line or a lane, named by what it is in the brand. */\nexport type NamedTone = 'brand' | 'accent' | 'info' | 'success' | 'warning' | 'danger';\n/** A named tone, or 1 to 5 for the brand's chart colours in order. */\nexport type Tone = NamedTone | 1 | 2 | 3 | 4 | 5;\nexport const TONE: Record<NamedTone, string> = {\n brand: 'var(--impakt-color-brand-default, #1f4ed8)',\n accent: 'var(--impakt-color-accent-default, #c8a15a)',\n info: 'var(--impakt-color-status-info-default, #1f4ed8)',\n success: 'var(--impakt-color-status-success-default, #047857)',\n warning: 'var(--impakt-color-status-warning-default, #b45309)',\n danger: 'var(--impakt-color-status-danger-default, #c8102e)',\n};\n/** When an item names no tone, lanes take these in turn. */\nexport const CYCLE: NamedTone[] = ['success', 'info', 'warning', 'accent', 'danger', 'brand'];\n/**\n * A named tone, or for an item that names none, the brand's chart colour for its\n * place (color.chart.1 to 5), falling back to the status colours in turn.\n */\nexport const toneOf = (tone: Tone | undefined, i: number): string => {\n if (typeof tone === 'number') return `var(--impakt-color-chart-${tone}, ${TONE[CYCLE[(tone - 1) % CYCLE.length]!]})`;\n if (tone && tone in TONE) return TONE[tone];\n return `var(--impakt-color-chart-${(i % 5) + 1}, ${TONE[CYCLE[i % CYCLE.length]!]})`;\n};\n"],"mappings":";;;;;;;;;AAIA,SAAS,KAAK,MAAM,eAAoC;;;ACSjD,IAAM,OAAkC;AAAA,EAC7C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;AAEO,IAAM,QAAqB,CAAC,WAAW,QAAQ,WAAW,UAAU,UAAU,OAAO;AAKrF,IAAM,SAAS,CAAC,MAAwB,MAAsB;AACnE,MAAI,OAAO,SAAS,SAAU,QAAO,4BAA4B,IAAI,KAAK,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM,CAAE,CAAC;AACjH,MAAI,QAAQ,QAAQ,KAAM,QAAO,KAAK,IAAI;AAC1C,SAAO,4BAA6B,IAAI,IAAK,CAAC,KAAK,KAAK,MAAM,IAAI,MAAM,MAAM,CAAE,CAAC;AACnF;;;ADpBA,IAAM,OAAO,EAAE;AASR,IAAM,aAAN,cAAyB,cAAc;AAAA,EAC5C;AAAA,SAAO,aAAa;AAAA,MAClB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,QAAQ,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,UAAU;AAAA,IAC9D;AAAA;AAAA,EAYA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,cAAc;AAAA,MACjB;AAAA,MACA;AAAA;AAAA,kEAE8D,MAAM,GAAG,CAAC,kBAAkB,MAAM,GAAG,CAAC,wCAAwC,IAAI,gBAAgB,SAAS,IAAI,CAAC;AAAA,wDAC1H,EAAE,MAAM;AAAA,mDACb,EAAE,UAAU,UAAU,EAAE,MAAM,iBAAiB,EAAE,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO7G;AAAA;AAAA,EAEA,SAAyB;AACvB,UAAM,OACJ,KAAK,SAAS,QACV,qDACA,KAAK,SAAS,WACZ,oQACA;AACR,WAAO,4CAA4C,UAAU,OAAO,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,IAAI,uBAAuB,KAAK,KAAK,UAAU,KAAK,OAAO,2BAA2B,KAAK,IAAI,YAAY,OAAO;AAAA,EAC3M;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  iconSvg
3
- } from "./chunk-WS4AYRSL.js";
3
+ } from "./chunk-AL4IUSML.js";
4
4
  import {
5
5
  ImpaktElement,
6
6
  fontWeight,
7
7
  space,
8
8
  t,
9
9
  type
10
- } from "./chunk-YR6T73GY.js";
10
+ } from "./chunk-V7EB7Q2M.js";
11
11
 
12
12
  // packages/ui/src/components/badge.ts
13
13
  import { css, html } from "lit";
@@ -24,7 +24,9 @@ var ImpaktBadge = class extends ImpaktElement {
24
24
  this.icon = "none";
25
25
  }
26
26
  static {
27
- this.styles = [...ImpaktElement.styles, css`
27
+ this.styles = [
28
+ ...ImpaktElement.styles,
29
+ css`
28
30
  :host { display: inline-flex; }
29
31
  span { display: inline-flex; align-items: center; gap: ${space(1)}; padding: ${space(0.5)} ${space(2)}; border-radius: ${t.radius}; ${type("sm")} font-weight: ${fontWeight("medium")}; background: ${t.surfaceInset}; color: ${t.text}; box-shadow: inset 0 0 0 1px ${t.hairline}; }
30
32
  :host([tone='brand']) span { background: ${t.brandSubtle}; color: ${t.brand}; }
@@ -35,7 +37,8 @@ var ImpaktBadge = class extends ImpaktElement {
35
37
  :host([tone='inverse']) span { background: ${t.text}; color: ${t.surfaceCard}; box-shadow: none; }
36
38
  :host([tone='solid']) span { background: ${t.brand}; color: ${t.onBrand}; box-shadow: none; }
37
39
  @media (forced-colors: active) { span { border-color: CanvasText; } }
38
- `];
40
+ `
41
+ ];
39
42
  }
40
43
  render() {
41
44
  return html`<span part="badge">${iconSvg(this.icon, "1em")}<slot></slot></span>`;
@@ -46,4 +49,4 @@ customElements.define("impakt-badge", ImpaktBadge);
46
49
  export {
47
50
  ImpaktBadge
48
51
  };
49
- //# sourceMappingURL=chunk-NU34ZQFR.js.map
52
+ //# sourceMappingURL=chunk-2ZF3J7OO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/badge.ts"],"sourcesContent":["/**\n * A short label on something, coloured by its tone.\n */\nimport { css, html, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { fontWeight, space, t, type } from '../base/tokens';\nimport { iconSvg } from './icon';\n\n/**\n * A short label on something: \"New\", \"Selling fast\", \"2 left\".\n *\n * The tone colours it, and the words carry the meaning, so it reads the same\n * without the colour (1.4.1).\n *\n * @category feedback\n * @icon badge\n * @slot - The badge's words.\n */\nexport class ImpaktBadge extends ImpaktElement {\n static properties = {\n tone: { type: String, reflect: true },\n icon: { type: String },\n };\n /**\n * Its colour. `inverse` is the text colour as a fill, for a label that has to\n * stand out on a photo or a light card. `solid` is the brand as a fill, for\n * the one label on a screen that matters most.\n */\n declare tone: 'neutral' | 'brand' | 'success' | 'warning' | 'danger' | 'info' | 'inverse' | 'solid';\n /** An icon before the words. */\n declare icon:\n | 'none'\n | 'arrow-right'\n | 'arrow-left'\n | 'chevron-right'\n | 'chevron-down'\n | 'check'\n | 'close'\n | 'menu'\n | 'plus'\n | 'minus'\n | 'search'\n | 'external'\n | 'download'\n | 'home'\n | 'phone'\n | 'mail'\n | 'map-pin'\n | 'calendar'\n | 'clock'\n | 'user'\n | 'star'\n | 'heart'\n | 'shield'\n | 'leaf'\n | 'sun'\n | 'bolt'\n | 'key'\n | 'info'\n | 'warning'\n | 'document'\n | 'pound'\n | 'chat'\n | 'grid'\n | 'clipboard'\n | 'map-pinned'\n | 'users'\n | 'radio'\n | 'settings'\n | 'log-out'\n | 'arrow-up-right'\n | 'more'\n | 'upload'\n | 'image'\n | 'lock'\n | 'eye'\n | 'trash'\n | 'pencil'\n | 'qr-code'\n | 'battery';\n\n constructor() {\n super();\n this.tone = 'neutral';\n this.icon = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host { display: inline-flex; }\n span { display: inline-flex; align-items: center; gap: ${space(1)}; padding: ${space(0.5)} ${space(2)}; border-radius: ${t.radius}; ${type('sm')} font-weight: ${fontWeight('medium')}; background: ${t.surfaceInset}; color: ${t.text}; box-shadow: inset 0 0 0 1px ${t.hairline}; }\n :host([tone='brand']) span { background: ${t.brandSubtle}; color: ${t.brand}; }\n :host([tone='success']) span { background: ${t.successSubtle}; color: ${t.successText}; }\n :host([tone='warning']) span { background: ${t.warningSubtle}; color: ${t.warningText}; }\n :host([tone='danger']) span { background: ${t.dangerSubtle}; color: ${t.dangerText}; }\n :host([tone='info']) span { background: ${t.infoSubtle}; color: ${t.infoText}; }\n :host([tone='inverse']) span { background: ${t.text}; color: ${t.surfaceCard}; box-shadow: none; }\n :host([tone='solid']) span { background: ${t.brand}; color: ${t.onBrand}; box-shadow: none; }\n @media (forced-colors: active) { span { border-color: CanvasText; } }\n `,\n ];\n\n render(): TemplateResult {\n return html`<span part=\"badge\">${iconSvg(this.icon, '1em')}<slot></slot></span>`;\n }\n}\n\ncustomElements.define('impakt-badge', ImpaktBadge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-badge': ImpaktBadge;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,KAAK,YAAiC;AAexC,IAAM,cAAN,cAA0B,cAAc;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,MAAM,EAAE,MAAM,OAAO;AAAA,IACvB;AAAA;AAAA,EA2DA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,cAAc;AAAA,MACjB;AAAA;AAAA,6DAEyD,MAAM,CAAC,CAAC,cAAc,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,oBAAoB,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,iBAAiB,WAAW,QAAQ,CAAC,iBAAiB,EAAE,YAAY,YAAY,EAAE,IAAI,iCAAiC,EAAE,QAAQ;AAAA,+CACtO,EAAE,WAAW,YAAY,EAAE,KAAK;AAAA,iDAC9B,EAAE,aAAa,YAAY,EAAE,WAAW;AAAA,iDACxC,EAAE,aAAa,YAAY,EAAE,WAAW;AAAA,gDACzC,EAAE,YAAY,YAAY,EAAE,UAAU;AAAA,8CACxC,EAAE,UAAU,YAAY,EAAE,QAAQ;AAAA,iDAC/B,EAAE,IAAI,YAAY,EAAE,WAAW;AAAA,+CACjC,EAAE,KAAK,YAAY,EAAE,OAAO;AAAA;AAAA;AAAA,IAGzE;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO,0BAA0B,QAAQ,KAAK,MAAM,KAAK,CAAC;AAAA,EAC5D;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  FieldElement
3
- } from "./chunk-5ZQVL3V2.js";
3
+ } from "./chunk-ONED3PUB.js";
4
4
  import {
5
5
  fontSize,
6
6
  space,
7
7
  t,
8
8
  targetSize
9
- } from "./chunk-YR6T73GY.js";
9
+ } from "./chunk-V7EB7Q2M.js";
10
10
 
11
11
  // packages/ui/src/components/checkbox-group.ts
12
12
  import { html, css, nothing } from "lit";
@@ -128,4 +128,4 @@ customElements.define("impakt-checkbox-group", ImpaktCheckboxGroup);
128
128
  export {
129
129
  ImpaktCheckboxGroup
130
130
  };
131
- //# sourceMappingURL=chunk-WP5WJ4V5.js.map
131
+ //# sourceMappingURL=chunk-3NEWOO2P.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\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;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;AAAA,IAG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Aa,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,6 +1,6 @@
1
1
  import {
2
2
  FieldElement
3
- } from "./chunk-5ZQVL3V2.js";
3
+ } from "./chunk-ONED3PUB.js";
4
4
  import {
5
5
  fontSize,
6
6
  fontWeight,
@@ -9,7 +9,7 @@ import {
9
9
  targetSize,
10
10
  touchTarget,
11
11
  visuallyHidden
12
- } from "./chunk-YR6T73GY.js";
12
+ } from "./chunk-V7EB7Q2M.js";
13
13
 
14
14
  // packages/ui/src/components/switch.ts
15
15
  import { html, css, nothing } from "lit";
@@ -17,12 +17,14 @@ var ImpaktSwitch = class extends FieldElement {
17
17
  static {
18
18
  this.properties = {
19
19
  ...FieldElement.properties,
20
- checked: { type: Boolean, reflect: true }
20
+ checked: { type: Boolean, reflect: true },
21
+ hideLabel: { type: Boolean, attribute: "hide-label", reflect: true }
21
22
  };
22
23
  }
23
24
  constructor() {
24
25
  super();
25
26
  this.checked = false;
27
+ this.hideLabel = false;
26
28
  }
27
29
  static {
28
30
  this.styles = [
@@ -39,6 +41,12 @@ var ImpaktSwitch = class extends FieldElement {
39
41
  .text {
40
42
  font-size: ${fontSize("md")};
41
43
  }
44
+ :host([hide-label]) .row {
45
+ justify-content: flex-start;
46
+ }
47
+ :host([hide-label]) .text {
48
+ ${visuallyHidden}
49
+ }
42
50
  .control {
43
51
  position: relative;
44
52
  flex: none;
@@ -132,6 +140,10 @@ var ImpaktSwitch = class extends FieldElement {
132
140
  </label>
133
141
  `;
134
142
  }
143
+ /** Whether it is on, so a handler need not read "on" or an empty string. */
144
+ changeDetail(value) {
145
+ return { value, checked: this.checked };
146
+ }
135
147
  /** The label is inside the control here, so the base class's is suppressed. */
136
148
  renderLabel() {
137
149
  return html`${nothing}`;
@@ -296,4 +308,4 @@ export {
296
308
  ImpaktSwitch,
297
309
  ImpaktSegmentedControl
298
310
  };
299
- //# sourceMappingURL=chunk-AMDTBUUL.js.map
311
+ //# sourceMappingURL=chunk-3T7J66Z2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/switch.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\nimport { targetSize, touchTarget, visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * An on and off setting that takes effect at once: \"Show to customer\",\n * \"Visible to customer\".\n *\n * **It is a checkbox with the switch role.** A native\n * `<input type=\"checkbox\" role=\"switch\">` keeps Space to toggle, form\n * submission and the label's hit area, and the role makes a screen reader say\n * \"on\" and \"off\" rather than \"checked\". A switch is for a setting that applies\n * straight away. When the choice is only sent with a form, use\n * `impakt-checkbox` instead.\n *\n * **The state is not carried by colour alone.** The knob moves from one end of\n * the track to the other, so the position says on or off without the fill\n * (1.4.1).\n *\n * **Set `hide-label` in a row that already names the setting**, such as a\n * table row whose first cell says what is being switched. The label stays the\n * switch's accessible name.\n *\n * @category form\n * @icon checkbox\n * @fires {CustomEvent<{ value: string; checked: boolean }>} impakt-change - When it is switched. detail.checked says whether it is now on, and detail.value is the form value, \"on\" or empty.\n */\nexport class ImpaktSwitch extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n checked: { type: Boolean, reflect: true },\n hideLabel: { type: Boolean, attribute: 'hide-label', reflect: true },\n };\n\n declare checked: boolean;\n /** Keep the label for screen readers only, when the row around it already names the setting. */\n declare hideLabel: boolean;\n\n constructor() {\n super();\n this.checked = false;\n this.hideLabel = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n touchTarget('.row'),\n css`\n .row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: ${space(3)};\n cursor: pointer;\n }\n .text {\n font-size: ${fontSize('md')};\n }\n :host([hide-label]) .row {\n justify-content: flex-start;\n }\n :host([hide-label]) .text {\n ${visuallyHidden}\n }\n .control {\n position: relative;\n flex: none;\n inline-size: 46px;\n block-size: 28px;\n }\n input {\n ${targetSize}\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n .track {\n position: absolute;\n inset: 0;\n border-radius: 999px;\n background: ${t.borderStrong};\n transition: background-color 120ms ease-in-out;\n pointer-events: none;\n }\n .knob {\n position: absolute;\n inset-block-start: 3px;\n inset-inline-start: 3px;\n inline-size: 22px;\n block-size: 22px;\n border-radius: 999px;\n background: ${t.surfaceCard};\n box-shadow: ${t.shadowXs};\n transition: transform 120ms ease-in-out;\n }\n :host([checked]) .track {\n background: ${t.brand};\n }\n :host([checked]) .knob {\n transform: translateX(18px);\n }\n :host(:dir(rtl)[checked]) .knob {\n transform: translateX(-18px);\n }\n input:focus-visible + .track {\n box-shadow: ${t.focusShadow};\n }\n input:disabled {\n cursor: not-allowed;\n }\n :host([disabled]) .track {\n opacity: 0.5;\n }\n @media (prefers-reduced-motion: reduce) {\n .track, .knob { transition: none; }\n }\n @media (forced-colors: active) {\n .track { border: 1px solid CanvasText; }\n .knob { background: CanvasText; }\n :host([checked]) .track { background: Highlight; }\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <label class=\"row\" part=\"row\" for=${this.controlId}>\n <span class=\"text\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </span>\n <span class=\"control\">\n <input\n type=\"checkbox\"\n role=\"switch\"\n id=${this.controlId}\n part=\"input\"\n name=${this.name || nothing}\n .checked=${this.checked}\n aria-checked=${this.checked ? 'true' : 'false'}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => {\n this.checked = (e.target as HTMLInputElement).checked;\n this.setFormValue(this.checked ? 'on' : '');\n }}\n />\n <span class=\"track\" part=\"track\"><span class=\"knob\" part=\"knob\"></span></span>\n </span>\n </label>\n `;\n }\n\n /** Whether it is on, so a handler need not read \"on\" or an empty string. */\n protected changeDetail(value: string): { value: string; checked: boolean } {\n return { value, checked: this.checked };\n }\n\n /** The label is inside the control here, so the base class's is suppressed. */\n protected renderLabel(): TemplateResult {\n return html`${nothing}`;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\nexport interface SegmentOption {\n value: string;\n label: string;\n}\n\n/**\n * Two to four choices drawn as one joined control: \"Internal\" or \"Visible to\n * customer\", \"Cost\" or \"Charge\".\n *\n * **It is a radio group underneath.** Native radios sharing a name give arrow\n * keys, one tab stop and the right announcement with no script, exactly as in\n * `impakt-radio-group`. Only the drawing differs. The label is a `<legend>`, so\n * the question is asked of the set; set `hide-label` when the words around it\n * already ask it, and the legend stays for screen readers.\n *\n * @category form\n * @icon radio\n */\nexport class ImpaktSegmentedControl extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n hideLabel: { type: Boolean, attribute: 'hide-label', reflect: true },\n full: { type: Boolean, reflect: true },\n };\n\n declare options: SegmentOption[];\n /** Keep the question for screen readers only, when the words around it already ask it. */\n declare hideLabel: boolean;\n /** As wide as its space, with the segments sharing it equally. */\n declare full: boolean;\n\n constructor() {\n super();\n this.options = [];\n this.hideLabel = false;\n this.full = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n fieldset {\n border: 0;\n margin: 0;\n padding: 0;\n min-inline-size: 0;\n }\n legend {\n padding: 0;\n }\n :host([hide-label]) legend {\n ${visuallyHidden}\n }\n .segments {\n display: inline-flex;\n gap: ${space(1)};\n padding: ${space(1)};\n border-radius: 999px;\n background: ${t.surfaceInset};\n }\n :host([full]) .segments {\n display: flex;\n }\n :host([full]) .segment {\n flex: 1;\n }\n .segment {\n position: relative;\n display: inline-flex;\n }\n input {\n ${targetSize}\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n .face {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n inline-size: 100%;\n min-block-size: 32px;\n padding: ${space(1.5)} ${space(4)};\n border-radius: 999px;\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('medium')};\n color: ${t.textMuted};\n pointer-events: none;\n transition: background-color 120ms ease-in-out, color 120ms ease-in-out;\n }\n .segment:hover .face {\n color: ${t.text};\n }\n input:checked + .face {\n background: ${t.surfaceCard};\n color: ${t.text};\n box-shadow: ${t.shadowXs};\n }\n input:focus-visible + .face {\n box-shadow: ${t.focusShadow};\n }\n input:disabled {\n cursor: not-allowed;\n }\n :host([disabled]) .segments {\n opacity: 0.5;\n }\n @media (prefers-reduced-motion: reduce) {\n .face { transition: none; }\n }\n @media (forced-colors: active) {\n .segments { border: 1px solid CanvasText; }\n input:checked + .face { border: 2px solid Highlight; }\n }\n `,\n ];\n\n protected renderLabel(): TemplateResult {\n return html`<legend class=\"label\" part=\"label\">\n ${this.label}${this.required ? html`<span class=\"required\"> (${this.requiredText})</span>` : nothing}\n </legend>`;\n }\n\n protected renderControl(): TemplateResult {\n return html`\n <div class=\"segments\" part=\"segments\">\n ${this.options.map((option, i) => {\n const id = this.id_(`seg-${i}`);\n return html`\n <label class=\"segment\" part=\"segment\" for=${id}>\n <input\n type=\"radio\"\n id=${id}\n name=${this.uid}\n value=${option.value}\n .checked=${this.value === option.value}\n ?disabled=${this.disabled}\n ?required=${this.required && i === 0}\n @change=${() => {\n this.value = option.value;\n this.setFormValue(option.value);\n }}\n />\n <span class=\"face\">${option.label}</span>\n </label>\n `;\n })}\n </div>\n `;\n }\n\n render(): TemplateResult {\n return html`\n <fieldset\n part=\"fieldset\"\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n >\n ${this.renderLabel()}\n ${this.description ? 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-switch', ImpaktSwitch);\ncustomElements.define('impakt-segmented-control', ImpaktSegmentedControl);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-switch': ImpaktSwitch;\n 'impakt-segmented-control': ImpaktSegmentedControl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA4BjD,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,MACxC,WAAW,EAAE,MAAM,SAAS,WAAW,cAAc,SAAS,KAAK;AAAA,IACrE;AAAA;AAAA,EAMA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AACf,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB,YAAY,MAAM;AAAA,MAClB;AAAA;AAAA;AAAA;AAAA;AAAA,eAKW,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,qBAIF,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAMzB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UASd,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAaE,EAAE,Y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2.js";
3
+ } from "./chunk-ONED3PUB.js";
4
4
  import {
5
5
  fontSize,
6
6
  say,
7
7
  space,
8
8
  t
9
- } from "./chunk-YR6T73GY.js";
9
+ } from "./chunk-V7EB7Q2M.js";
10
10
 
11
11
  // packages/ui/src/components/date-input.ts
12
12
  import { html, css, nothing } from "lit";
@@ -135,4 +135,4 @@ customElements.define("impakt-date-input", ImpaktDateInput);
135
135
  export {
136
136
  ImpaktDateInput
137
137
  };
138
- //# sourceMappingURL=chunk-XU2XODVH.js.map
138
+ //# sourceMappingURL=chunk-5OJAJA3U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/date-input.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { say } from '../base/say';\nimport { FieldElement } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\n\n/**\n * A date, as three fields.\n *\n * **Why not `<input type=\"date\">`.** The native control is excellent for\n * picking a date near today — an appointment, a start date — and poor for a\n * date of birth, which is the date this product asks for most. Its picker\n * opens on the current month and makes a user born in 1958 navigate eight\n * hundred steps back, its text entry expects a locale-specific format the\n * field does not state, and its rendering differs enough between browsers that\n * no single hint is correct everywhere.\n *\n * Three fields is the pattern government services converged on after testing\n * it on exactly this problem. Each part is typed directly, in any order, with\n * no picker to fight.\n *\n * **The accessibility shape.** A `<fieldset>` and `<legend>` ask the question\n * once; each part has its own visible label, so \"Month\" is announced rather\n * than \"second field\"; `inputmode=\"numeric\"` brings up a number pad without\n * `type=\"number\"`, which on a date part gives spinners, scroll-wheel surprises\n * and silent stripping of a leading zero. The parts carry `autocomplete`\n * tokens so autofill still works, which is 1.3.5.\n\n *\n * @category form\n * @icon calendar\n */\nexport class ImpaktDateInput extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n day: { type: String },\n month: { type: String },\n year: { type: String },\n autocompleteSection: { type: String, attribute: 'autocomplete-section' },\n };\n\n declare day: string;\n declare month: string;\n declare year: string;\n /** \"bday\" fills a date of birth. Empty disables autofill for this field. */\n declare autocompleteSection: string;\n\n constructor() {\n super();\n this.day = '';\n this.month = '';\n this.year = '';\n this.autocompleteSection = 'bday';\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 .parts {\n display: flex;\n gap: ${space(3)};\n }\n .part {\n display: flex;\n flex-direction: column;\n gap: ${space(1)};\n }\n .part label {\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n }\n input {\n min-block-size: 44px;\n padding: ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: ${t.surfaceCard};\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radius};\n /* Room for the digits plus the padding and border, so the box is never narrower than a finger. */\n inline-size: calc(3ch + ${space(6)} + 2px);\n }\n .year input {\n inline-size: calc(5ch + ${space(6)} + 2px);\n }\n :host([invalid]) input {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\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 datePart(name: 'day' | 'month' | 'year', label: string, length: number, autocomplete: string): TemplateResult {\n const id = this.id_(name);\n return html`\n <div class=\"part ${name}\">\n <label for=${id}>${label}</label>\n <input\n id=${id}\n type=\"text\"\n inputmode=\"numeric\"\n maxlength=${length}\n .value=${this[name]}\n autocomplete=${this.autocompleteSection ? `${this.autocompleteSection}-${autocomplete}` : nothing}\n ?disabled=${this.disabled}\n @input=${(e: Event) => {\n this[name] = (e.target as HTMLInputElement).value;\n this.emit();\n }}\n />\n </div>\n `;\n }\n\n /** ISO, or empty while incomplete. Partial dates are not half-valid. */\n private emit(): void {\n const complete = this.day && this.month && this.year.length === 4;\n const iso = complete ? `${this.year}-${this.month.padStart(2, '0')}-${this.day.padStart(2, '0')}` : '';\n this.setFormValue(iso);\n }\n\n protected renderControl(): TemplateResult {\n return html`\n <div class=\"parts\" part=\"parts\">\n ${this.datePart('day', say('Day'), 2, 'day')}\n ${this.datePart('month', say('Month'), 2, 'month')}\n ${this.datePart('year', say('Year'), 4, 'year')}\n </div>\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-date-input', ImpaktDateInput);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-date-input': ImpaktDateInput;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA+BjD,IAAM,kBAAN,cAA8B,aAAa;AAAA,EAChD;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,KAAK,EAAE,MAAM,OAAO;AAAA,MACpB,OAAO,EAAE,MAAM,OAAO;AAAA,MACtB,MAAM,EAAE,MAAM,OAAO;AAAA,MACrB,qBAAqB,EAAE,MAAM,QAAQ,WAAW,uBAAuB;AAAA,IACzE;AAAA;AAAA,EAQA,cAAc;AACZ,UAAM;AACN,SAAK,MAAM;AACX,SAAK,QAAQ;AACb,SAAK,OAAO;AACZ,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAYW,MAAM,CAAC,CAAC;AAAA;AAAA;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G,CAAC,IAAI,KAAK,IAAI,SAAS,GAAG,GAAG,CAAC,KAAK;AACpG,SAAK,aAAa,GAAG;AAAA,EACvB;AAAA,EAEU,gBAAgC;AACxC,WAAO;AAAA;AAAA,UAED,KAAK,SAAS,OAAO,IAAI,KAAK,GAAG,GAAG,KAAK,CAAC;AAAA,UAC1C,KAAK,SAAS,SAAS,IAAI,OAAO,GAAG,GAAG,OAAO,CAAC;AAAA,UAChD,KAAK,SAAS,QAAQ,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC;AAAA;AAAA;AAAA,EAGrD;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,qBAAqB,eAAe;","names":[]}
@@ -5,7 +5,7 @@ import {
5
5
  spaceAround,
6
6
  t,
7
7
  type
8
- } from "./chunk-YR6T73GY.js";
8
+ } from "./chunk-V7EB7Q2M.js";
9
9
 
10
10
  // packages/ui/src/components/list.ts
11
11
  import { css, html } from "lit";
@@ -28,7 +28,10 @@ var ImpaktList = class extends ImpaktElement {
28
28
  this.spaceBelow = "none";
29
29
  }
30
30
  static {
31
- this.styles = [...ImpaktElement.styles, spaceAround, css`
31
+ this.styles = [
32
+ ...ImpaktElement.styles,
33
+ spaceAround,
34
+ css`
32
35
  :host { display: block; }
33
36
  ul, ol { list-style: none; margin: 0; padding: 0; display: grid; gap: ${space(3)}; counter-reset: point; }
34
37
  li { position: relative; padding-inline-start: ${space(7)}; ${type("md")} text-wrap: pretty; counter-increment: point; }
@@ -38,7 +41,8 @@ var ImpaktList = class extends ImpaktElement {
38
41
  :host([look='check']) li::before { content: '✓'; inset-inline-start: 0; inset-block-start: 0; inline-size: auto; block-size: auto; background: none; color: ${t.success}; font-weight: ${fontWeight("bold")}; }
39
42
  :host([look='number']) li::before { content: counter(point, decimal-leading-zero); inset-inline-start: 0; inset-block-start: 0.2em; inline-size: auto; block-size: auto; background: none; font-family: ${t.fontMono}; font-size: 0.75em; color: ${t.textMuted}; }
40
43
  @media (forced-colors: active) { li::before { background: CanvasText; } :host([look='check']) li::before, :host([look='number']) li::before { background: none; color: CanvasText; } }
41
- `];
44
+ `
45
+ ];
42
46
  }
43
47
  render() {
44
48
  const items = (this.items ?? []).map((item) => html`<li part="item">${item}</li>`);
@@ -50,4 +54,4 @@ customElements.define("impakt-list", ImpaktList);
50
54
  export {
51
55
  ImpaktList
52
56
  };
53
- //# sourceMappingURL=chunk-3EF4T242.js.map
57
+ //# sourceMappingURL=chunk-6PMA6NHE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/list.ts"],"sourcesContent":["import { css, html, type TemplateResult } from 'lit';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { fontWeight, space, spaceAround, t, type } from '../base/tokens';\n\n/**\n * A list of short points: what a phase delivers, what a plan includes, the\n * steps of an argument in an article. A bullet, a tick or a number marks each\n * one; the marks are drawn, so a screen reader hears a plain list.\n *\n * @category content\n * @icon list\n */\nexport class ImpaktList extends ImpaktElement {\n static properties = {\n items: { type: Array },\n look: { type: String, reflect: true },\n size: { type: String, reflect: true },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n\n /** The points, in order. */\n declare items: string[];\n /** `bullet` for points, `check` for what is included, `number` when the order matters. */\n declare look: 'bullet' | 'check' | 'number';\n declare size: 'sm' | 'md' | 'lg';\n declare spaceAbove: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n declare spaceBelow: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\n constructor() {\n super();\n this.items = [];\n this.look = 'bullet';\n this.size = 'md';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n spaceAround,\n css`\n :host { display: block; }\n ul, ol { list-style: none; margin: 0; padding: 0; display: grid; gap: ${space(3)}; counter-reset: point; }\n li { position: relative; padding-inline-start: ${space(7)}; ${type('md')} text-wrap: pretty; counter-increment: point; }\n :host([size='sm']) li { ${type('sm')} }\n :host([size='lg']) li { ${type('lg')} }\n li::before { content: ''; position: absolute; inset-inline-start: 4px; inset-block-start: 0.6em; inline-size: 7px; block-size: 7px; border-radius: 2px; background: ${t.brand}; }\n :host([look='check']) li::before { content: '✓'; inset-inline-start: 0; inset-block-start: 0; inline-size: auto; block-size: auto; background: none; color: ${t.success}; font-weight: ${fontWeight('bold')}; }\n :host([look='number']) li::before { content: counter(point, decimal-leading-zero); inset-inline-start: 0; inset-block-start: 0.2em; inline-size: auto; block-size: auto; background: none; font-family: ${t.fontMono}; font-size: 0.75em; color: ${t.textMuted}; }\n @media (forced-colors: active) { li::before { background: CanvasText; } :host([look='check']) li::before, :host([look='number']) li::before { background: none; color: CanvasText; } }\n `,\n ];\n\n render(): TemplateResult {\n const items = (this.items ?? []).map((item) => html`<li part=\"item\">${item}</li>`);\n return this.look === 'number' ? html`<ol part=\"list\">${items}</ol>` : html`<ul part=\"list\" role=\"list\">${items}</ul>`;\n }\n}\n\ncustomElements.define('impakt-list', ImpaktList);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-list': ImpaktList;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,KAAK,YAAiC;AAYxC,IAAM,aAAN,cAAyB,cAAc;AAAA,EAC5C;AAAA,SAAO,aAAa;AAAA,MAClB,OAAO,EAAE,MAAM,MAAM;AAAA,MACrB,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACpC,YAAY,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,cAAc;AAAA,MACpE,YAAY,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,cAAc;AAAA,IACtE;AAAA;AAAA,EAUA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ,CAAC;AACd,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,cAAc;AAAA,MACjB;AAAA,MACA;AAAA;AAAA,4EAEwE,MAAM,CAAC,CAAC;AAAA,qDAC/B,MAAM,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC;AAAA,8BAC9C,KAAK,IAAI,CAAC;AAAA,8BACV,KAAK,IAAI,CAAC;AAAA,0KACkI,EAAE,KAAK;AAAA,kKACf,EAAE,OAAO,kBAAkB,WAAW,MAAM,CAAC;AAAA,8MACD,EAAE,QAAQ,+BAA+B,EAAE,SAAS;AAAA;AAAA;AAAA,IAGhQ;AAAA;AAAA,EAEA,SAAyB;AACvB,UAAM,SAAS,KAAK,SAAS,CAAC,GAAG,IAAI,CAAC,SAAS,uBAAuB,IAAI,OAAO;AACjF,WAAO,KAAK,SAAS,WAAW,uBAAuB,KAAK,UAAU,mCAAmC,KAAK;AAAA,EAChH;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
@@ -7,7 +7,7 @@ import {
7
7
  fontWeight,
8
8
  space,
9
9
  t
10
- } from "./chunk-YR6T73GY.js";
10
+ } from "./chunk-V7EB7Q2M.js";
11
11
 
12
12
  // packages/ui/src/components/price.ts
13
13
  import { html, css, nothing } from "lit";
@@ -86,4 +86,4 @@ customElements.define("impakt-price", ImpaktPrice);
86
86
  export {
87
87
  ImpaktPrice
88
88
  };
89
- //# sourceMappingURL=chunk-HNBG2POR.js.map
89
+ //# sourceMappingURL=chunk-7C56LPNJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/price.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { pageLocale } from '../base/locale';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * A money amount.\n *\n * This component exists because of a decision taken in the content model: a\n * binding names a source and cannot compute\n * ([ADR 0003](https://github.com/matthill8286/strata/blob/main/docs/decisions/0003-binding-expressions.md)). The\n * consequence is that formatting lives here, where the locale and the currency\n * are known, rather than in authored content — so there is one place that\n * decides what \"£24.99\" looks like, and nobody writes a format string into a\n * CMS field.\n *\n * **The amount is one text node.** Splitting the pounds and the pence into\n * separate elements for typographic effect makes some screen readers read them\n * as two numbers, and \"twenty-four ninety-nine\" becomes \"twenty four, ninety\n * nine\". The visual emphasis is done with CSS over one node instead.\n *\n * **Minor units in, major units out.** `amount` is in pence, because a price\n * that arrives from a pricing API as a float has already lost money to binary\n * rounding before it reaches the screen.\n\n *\n * @category content\n * @icon price\n */\nexport class ImpaktPrice extends ImpaktElement {\n static properties = {\n amount: { type: Number },\n currency: { type: String },\n locale: { type: String },\n prefix: { type: String },\n period: { type: String },\n size: { type: String, reflect: true },\n pending: { type: String },\n };\n\n /** In minor units — pence, cents. */\n declare amount: number | undefined;\n declare currency: string;\n declare locale: string;\n /** \"From\", \"Guide\". Read before the amount. */\n declare prefix: string;\n /** \"a month\", \"a year\". Read after the amount. */\n declare period: string;\n declare size: 'md' | 'lg' | 'xl';\n /** Shown while there is no amount yet. A price takes seconds to arrive. */\n declare pending: string;\n\n constructor() {\n super();\n this.amount = undefined;\n this.currency = 'GBP';\n this.locale = '';\n this.prefix = '';\n this.period = '';\n this.size = 'xl';\n this.pending = '—';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host {\n display: inline-flex;\n align-items: baseline;\n gap: ${space(1)};\n color: ${t.text};\n }\n .amount {\n font-family: ${t.fontHeading};\n font-weight: ${fontWeight('bold')};\n /* Tabular figures so a price does not reflow as the digits change,\n which otherwise makes a recalculating price jitter. */\n font-variant-numeric: tabular-nums;\n }\n :host([size='md']) .amount { font-size: ${fontSize('lg')}; }\n :host([size='lg']) .amount { font-size: ${fontSize('2xl')}; }\n :host([size='xl']) .amount { font-size: ${fontSize('3xl')}; }\n .period {\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n }\n `,\n ];\n\n private get formatted(): string {\n if (this.amount === undefined || Number.isNaN(this.amount)) return this.pending;\n try {\n return new Intl.NumberFormat(this.locale || pageLocale(this), {\n style: 'currency',\n currency: this.currency,\n // A house price reads as £385,000. Pence only mean something on small amounts.\n ...(this.amount >= 100000 && this.amount % 100 === 0 ? { minimumFractionDigits: 0, maximumFractionDigits: 0 } : {}),\n }).format(this.amount / 100);\n } catch {\n // An unknown currency or locale must not take the page down. The number\n // is still the most useful thing on the screen.\n return (this.amount / 100).toFixed(2);\n }\n }\n\n render(): TemplateResult {\n return html`\n ${this.prefix ? html`<span class=\"period\" part=\"prefix\">${this.prefix}</span>` : nothing}\n <span class=\"amount\" part=\"amount\">${this.formatted}</span>\n ${this.period ? html`<span class=\"period\" part=\"period\">${this.period}</span>` : nothing}\n `;\n }\n}\n\ncustomElements.define('impakt-price', ImpaktPrice);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-price': ImpaktPrice }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA6BjD,IAAM,cAAN,cAA0B,cAAc;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,QAAQ,EAAE,MAAM,OAAO;AAAA,MACvB,UAAU,EAAE,MAAM,OAAO;AAAA,MACzB,QAAQ,EAAE,MAAM,OAAO;AAAA,MACvB,QAAQ,EAAE,MAAM,OAA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SAAS,0CAA0C,KAAK,MAAM,YAAY,OAAO;AAAA,2CACnD,KAAK,SAAS;AAAA,QACjD,KAAK,SAAS,0CAA0C,KAAK,MAAM,YAAY,OAAO;AAAA;AAAA,EAE5F;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
1
+ {"version":3,"sources":["../src/components/price.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { pageLocale } from '../base/locale';\nimport { ImpaktElement } from '../base/ImpaktElement';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * A money amount.\n *\n * This component exists because of a decision taken in the content model: a\n * binding names a source and cannot compute\n * ([ADR 0003](https://github.com/matthill8286/strata/blob/main/docs/decisions/0003-binding-expressions.md)). The\n * consequence is that formatting lives here, where the locale and the currency\n * are known, rather than in authored content — so there is one place that\n * decides what \"£24.99\" looks like, and nobody writes a format string into a\n * CMS field.\n *\n * **The amount is one text node.** Splitting the pounds and the pence into\n * separate elements for typographic effect makes some screen readers read them\n * as two numbers, and \"twenty-four ninety-nine\" becomes \"twenty four, ninety\n * nine\". The visual emphasis is done with CSS over one node instead.\n *\n * **Minor units in, major units out.** `amount` is in pence, because a price\n * that arrives from a pricing API as a float has already lost money to binary\n * rounding before it reaches the screen.\n\n *\n * @category content\n * @icon price\n */\nexport class ImpaktPrice extends ImpaktElement {\n static properties = {\n amount: { type: Number },\n currency: { type: String },\n locale: { type: String },\n prefix: { type: String },\n period: { type: String },\n size: { type: String, reflect: true },\n pending: { type: String },\n };\n\n /** In minor units — pence, cents. */\n declare amount: number | undefined;\n declare currency: string;\n declare locale: string;\n /** \"From\", \"Guide\". Read before the amount. */\n declare prefix: string;\n /** \"a month\", \"a year\". Read after the amount. */\n declare period: string;\n declare size: 'md' | 'lg' | 'xl';\n /** Shown while there is no amount yet. A price takes seconds to arrive. */\n declare pending: string;\n\n constructor() {\n super();\n this.amount = undefined;\n this.currency = 'GBP';\n this.locale = '';\n this.prefix = '';\n this.period = '';\n this.size = 'xl';\n this.pending = '—';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host {\n display: inline-flex;\n align-items: baseline;\n gap: ${space(1)};\n color: ${t.text};\n }\n .amount {\n font-family: ${t.fontHeading};\n font-weight: ${fontWeight('bold')};\n /* Tabular figures so a price does not reflow as the digits change,\n which otherwise makes a recalculating price jitter. */\n font-variant-numeric: tabular-nums;\n }\n :host([size='md']) .amount { font-size: ${fontSize('lg')}; }\n :host([size='lg']) .amount { font-size: ${fontSize('2xl')}; }\n :host([size='xl']) .amount { font-size: ${fontSize('3xl')}; }\n .period {\n font-size: ${fontSize('sm')};\n color: ${t.textMuted};\n }\n `,\n ];\n\n private get formatted(): string {\n if (this.amount === undefined || Number.isNaN(this.amount)) return this.pending;\n try {\n return new Intl.NumberFormat(this.locale || pageLocale(this), {\n style: 'currency',\n currency: this.currency,\n // A house price reads as £385,000. Pence only mean something on small amounts.\n ...(this.amount >= 100000 && this.amount % 100 === 0 ? { minimumFractionDigits: 0, maximumFractionDigits: 0 } : {}),\n }).format(this.amount / 100);\n } catch {\n // An unknown currency or locale must not take the page down. The number\n // is still the most useful thing on the screen.\n return (this.amount / 100).toFixed(2);\n }\n }\n\n render(): TemplateResult {\n return html`\n ${this.prefix ? html`<span class=\"period\" part=\"prefix\">${this.prefix}</span>` : nothing}\n <span class=\"amount\" part=\"amount\">${this.formatted}</span>\n ${this.period ? html`<span class=\"period\" part=\"period\">${this.period}</span>` : nothing}\n `;\n }\n}\n\ncustomElements.define('impakt-price', ImpaktPrice);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-price': ImpaktPrice;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA6BjD,IAAM,cAAN,cAA0B,cAAc;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,QAAQ,EAAE,MAAM,OAAO;AAAA,MACvB,UAAU,EAAE,MAAM,OAAO;AAAA,MACzB,QAAQ,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EACF;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,QACH,KAAK,SAAS,0CAA0C,KAAK,MAAM,YAAY,OAAO;AAAA,2CACnD,KAAK,SAAS;AAAA,QACjD,KAAK,SAAS,0CAA0C,KAAK,MAAM,YAAY,OAAO;AAAA;AAAA,EAE5F;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  FieldElement,
3
3
  fieldWidths
4
- } from "./chunk-5ZQVL3V2.js";
4
+ } from "./chunk-ONED3PUB.js";
5
5
  import {
6
6
  fontSize,
7
7
  space,
8
- t
9
- } from "./chunk-YR6T73GY.js";
8
+ t,
9
+ visuallyHidden
10
+ } from "./chunk-V7EB7Q2M.js";
10
11
 
11
12
  // packages/ui/src/components/select.ts
12
13
  import { html, css, nothing } from "lit";
@@ -16,7 +17,8 @@ var ImpaktSelect = class extends FieldElement {
16
17
  ...FieldElement.properties,
17
18
  width: { type: String, reflect: true },
18
19
  options: { type: Array },
19
- placeholder: { type: String }
20
+ placeholder: { type: String },
21
+ hideLabel: { type: Boolean, attribute: "hide-label", reflect: true }
20
22
  };
21
23
  }
22
24
  constructor() {
@@ -24,12 +26,16 @@ var ImpaktSelect = class extends FieldElement {
24
26
  this.width = "full";
25
27
  this.options = [];
26
28
  this.placeholder = "Choose an option";
29
+ this.hideLabel = false;
27
30
  }
28
31
  static {
29
32
  this.styles = [
30
33
  ...FieldElement.styles,
31
34
  fieldWidths,
32
35
  css`
36
+ :host([hide-label]) .label {
37
+ ${visuallyHidden}
38
+ }
33
39
  select {
34
40
  inline-size: min(100%, var(--impakt-field-width));
35
41
  min-block-size: 44px;
@@ -75,9 +81,7 @@ var ImpaktSelect = class extends FieldElement {
75
81
  @change=${(e) => this.setFormValue(e.target.value)}
76
82
  >
77
83
  <option value="" ?selected=${!this.value}>${this.placeholder}</option>
78
- ${this.options.map(
79
- (o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`
80
- )}
84
+ ${this.options.map((o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`)}
81
85
  </select>
82
86
  `;
83
87
  }
@@ -90,4 +94,4 @@ customElements.define("impakt-select", ImpaktSelect);
90
94
  export {
91
95
  ImpaktSelect
92
96
  };
93
- //# sourceMappingURL=chunk-EJSX4WCD.js.map
97
+ //# sourceMappingURL=chunk-7UWJXPR3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/select.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement, fieldWidths } from '../base/FieldElement';\nimport { visuallyHidden } from '../base/styles';\nimport { fontSize, space, t } from '../base/tokens';\n\nexport interface SelectOption {\n value: string;\n label: string;\n}\n\n/**\n * A dropdown.\n *\n * A native `<select>`, because the alternative is a listbox widget that has to\n * reimplement type-ahead, keyboard selection, and the platform's own picker on\n * touch — and whose main advantage is that the arrow can be restyled. On a\n * phone, native wins outright: it opens the system control that the user\n * already knows how to drive.\n *\n * The empty first option carries a real label rather than being blank, so a\n * screen reader announces a choice to make rather than silence.\n\n *\n * @category form\n * @icon select\n */\nexport class ImpaktSelect extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n width: { type: String, reflect: true },\n options: { type: Array },\n placeholder: { type: String },\n hideLabel: { type: Boolean, attribute: 'hide-label', reflect: true },\n };\n\n declare options: SelectOption[];\n /**\n * Keep the label for screen readers only, for a picker whose purpose is\n * plain from where it sits, such as a filter above a table or a role in a\n * team row. The label stays its accessible name.\n */\n declare hideLabel: boolean;\n declare placeholder: string;\n\n /** How wide the box is, to suit the answer. Full width on a phone whatever this says. */\n declare width: 'full' | 'lg' | 'md' | 'sm' | 'xs';\n\n constructor() {\n super();\n this.width = 'full';\n this.options = [];\n this.placeholder = 'Choose an option';\n this.hideLabel = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n fieldWidths,\n css`\n :host([hide-label]) .label {\n ${visuallyHidden}\n }\n select {\n inline-size: min(100%, var(--impakt-field-width));\n min-block-size: 44px;\n padding: ${space(2.5)} ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: var(--impakt-color-field-surface, ${t.surfaceCard});\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n box-shadow: var(--impakt-shadow-field, ${t.shadowXs});\n transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;\n }\n select:hover:not(:disabled) {\n border-color: ${t.borderStrong};\n }\n /* A brand halo as well as the focus ring, so the field being typed in is plain at a glance. */\n select:focus-visible {\n border-color: ${t.brand};\n box-shadow: ${t.focusShadow}, 0 0 0 6px ${t.brandHalo};\n }\n select:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n :host([invalid]) select {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <select\n id=${this.controlId}\n part=\"select\"\n name=${this.name || nothing}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => this.setFormValue((e.target as HTMLSelectElement).value)}\n >\n <option value=\"\" ?selected=${!this.value}>${this.placeholder}</option>\n ${this.options.map((o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`)}\n </select>\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-select', ImpaktSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-select': ImpaktSelect;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA0BjD,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC,SAAS,EAAE,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Q,IAAI,CAAC,MAAM,qBAAqB,EAAE,KAAK,cAAc,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,KAAK,WAAW,CAAC;AAAA;AAAA;AAAA,EAGvH;AAAA,EAEA,QAAQ,SAAqC;AAC3C,QAAI,QAAQ,IAAI,OAAO,EAAG,MAAK,gBAAgB,WAAW,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,iBAAiB,YAAY;","names":[]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  iconSvg
3
- } from "./chunk-WS4AYRSL.js";
3
+ } from "./chunk-AL4IUSML.js";
4
4
  import {
5
5
  FieldElement,
6
6
  fieldWidths
7
- } from "./chunk-5ZQVL3V2.js";
7
+ } from "./chunk-ONED3PUB.js";
8
8
  import {
9
9
  fontSize,
10
10
  space,
11
11
  t
12
- } from "./chunk-YR6T73GY.js";
12
+ } from "./chunk-V7EB7Q2M.js";
13
13
 
14
14
  // packages/ui/src/components/text-input.ts
15
15
  import { html, css, nothing } from "lit";
@@ -138,4 +138,4 @@ customElements.define("impakt-text-input", ImpaktTextInput);
138
138
  export {
139
139
  ImpaktTextInput
140
140
  };
141
- //# sourceMappingURL=chunk-WH43U4IY.js.map
141
+ //# sourceMappingURL=chunk-A4M3A4SZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/text-input.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement, fieldWidths } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\nimport { iconSvg } from './icon';\n\n/**\n * A single-line text field.\n *\n * `inputmode` and `autocomplete` are first-class properties rather than\n * afterthoughts. 1.3.5 Identify Input Purpose is a Level AA criterion that\n * autofill satisfies directly, and it is the single cheapest accessibility win\n * in a checkout journey — a form that fills itself is a form that someone with a\n * motor impairment can actually finish.\n\n *\n * @category form\n * @icon field\n */\nexport class ImpaktTextInput extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n width: { type: String, reflect: true },\n type: { type: String },\n placeholder: { type: String },\n autocomplete: { type: String },\n inputmode: { type: String },\n maxlength: { type: Number },\n hideLabel: { type: Boolean, attribute: 'hide-label', reflect: true },\n };\n\n /** `search` draws a search icon at the start and rounds the field, as a search box. */\n declare type: 'text' | 'email' | 'tel' | 'number' | 'password' | 'date' | 'search';\n /**\n * Keep the label for screen readers only, for a field whose purpose is plain\n * from where it sits, such as the search in a top bar. The label stays its\n * accessible name; a placeholder is never a substitute for it.\n */\n declare hideLabel: boolean;\n declare placeholder: string;\n /** A token from the HTML autofill list — `given-name`, `postal-code`, `tel`. */\n declare autocomplete: string;\n declare inputmode: string;\n declare maxlength: number | undefined;\n\n /** How wide the box is, to suit the answer. Full width on a phone whatever this says. */\n declare width: 'full' | 'lg' | 'md' | 'sm' | 'xs';\n\n constructor() {\n super();\n this.width = 'full';\n this.type = 'text';\n this.placeholder = '';\n this.autocomplete = '';\n this.inputmode = '';\n this.maxlength = undefined;\n this.hideLabel = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n fieldWidths,\n css`\n input {\n inline-size: min(100%, var(--impakt-field-width));\n min-block-size: 44px;\n padding: ${space(2.5)} ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: var(--impakt-color-field-surface, ${t.surfaceCard});\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n box-shadow: var(--impakt-shadow-field, ${t.shadowXs});\n transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;\n }\n input:hover:not(:disabled) {\n border-color: ${t.borderStrong};\n }\n /* A brand halo as well as the focus ring, so the field being typed in is plain at a glance. */\n input:focus-visible {\n border-color: ${t.brand};\n box-shadow: ${t.focusShadow}, 0 0 0 6px ${t.brandHalo};\n }\n input::placeholder {\n color: ${t.textPlaceholder};\n }\n input:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n /* The border thickens as well as reddening. Colour alone would carry the\n error, which 1.4.1 forbids — and the message below says it in words. */\n :host([hide-label]) .label {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n .search {\n position: relative;\n display: block;\n inline-size: min(100%, var(--impakt-field-width));\n }\n .search input {\n inline-size: 100%;\n padding-inline-start: ${space(10)};\n border-radius: 999px;\n }\n .search .icon {\n position: absolute;\n inset-inline-start: ${space(3.5)};\n inset-block-start: 50%;\n transform: translateY(-50%);\n color: ${t.textMuted};\n pointer-events: none;\n }\n :host([invalid]) input {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n const input = this.renderInput();\n return this.type === 'search'\n ? html`<span class=\"search\" part=\"search\">${iconSvg('search', '20px')}${input}</span>`\n : input;\n }\n\n private renderInput(): TemplateResult {\n return html`\n <input\n id=${this.controlId}\n part=\"input\"\n type=${this.type}\n name=${this.name || nothing}\n .value=${this.value}\n placeholder=${this.placeholder || nothing}\n autocomplete=${this.autocomplete || nothing}\n inputmode=${this.inputmode || nothing}\n maxlength=${this.maxlength ?? nothing}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @input=${(e: Event) => this.setFormValue((e.target as HTMLInputElement).value)}\n />\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impakt-text-input', ImpaktTextInput);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-text-input': ImpaktTextInput;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAkBjD,IAAM,kBAAN,cAA8B,aAAa;AAAA,EAChD;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,MACrC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,EAAE,MAAM;AAAA,wBACR,EAAE,WAAW;AAAA;AAAA;AAAA,IAGnC;AAAA;AAAA,EAEU,gBAAgC;AACxC,UAAM,QAAQ,KAAK,YAAY;AAC/B,WAAO,KAAK,SAAS,WACjB,0CAA0C,QAAQ,UAAU,MAAM,CAAC,GAAG,KAAK,YAC3E;AAAA,EACN;AAAA,EAEQ,cAA8B;AACpC,WAAO;AAAA;AAAA,aAEE,KAAK,SAAS;AAAA;AAAA,eAEZ,KAAK,IAAI;AAAA,eACT,KAAK,QAAQ,OAAO;AAAA,iBAClB,KAAK,KAAK;AAAA,sBACL,KAAK,eAAe,OAAO;AAAA,uBAC1B,KAAK,gBAAgB,OAAO;AAAA,oBAC/B,KAAK,aAAa,OAAO;AAAA,oBACzB,KAAK,aAAa,OAAO;AAAA,oBACzB,KAAK,QAAQ;AAAA,oBACb,KAAK,QAAQ;AAAA,oBACb,KAAK,QAAQ;AAAA,2BACN,KAAK,WAAW;AAAA,uBACpB,KAAK,QAAQ,SAAS,OAAO;AAAA,iBACnC,CAAC,MAAa,KAAK,aAAc,EAAE,OAA4B,KAAK,CAAC;AAAA;AAAA;AAAA,EAGpF;AAAA,EAEA,QAAQ,SAAqC;AAC3C,QAAI,QAAQ,IAAI,OAAO,EAAG,MAAK,gBAAgB,WAAW,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,qBAAqB,eAAe;","names":[]}
1
+ {"version":3,"sources":["../src/components/text-input.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement, fieldWidths } from '../base/FieldElement';\nimport { fontSize, space, t } from '../base/tokens';\nimport { iconSvg } from './icon';\n\n/**\n * A single-line text field.\n *\n * `inputmode` and `autocomplete` are first-class properties rather than\n * afterthoughts. 1.3.5 Identify Input Purpose is a Level AA criterion that\n * autofill satisfies directly, and it is the single cheapest accessibility win\n * in a checkout journey — a form that fills itself is a form that someone with a\n * motor impairment can actually finish.\n\n *\n * @category form\n * @icon field\n */\nexport class ImpaktTextInput extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n width: { type: String, reflect: true },\n type: { type: String },\n placeholder: { type: String },\n autocomplete: { type: String },\n inputmode: { type: String },\n maxlength: { type: Number },\n hideLabel: { type: Boolean, attribute: 'hide-label', reflect: true },\n };\n\n /** `search` draws a search icon at the start and rounds the field, as a search box. */\n declare type: 'text' | 'email' | 'tel' | 'number' | 'password' | 'date' | 'search';\n /**\n * Keep the label for screen readers only, for a field whose purpose is plain\n * from where it sits, such as the search in a top bar. The label stays its\n * accessible name; a placeholder is never a substitute for it.\n */\n declare hideLabel: boolean;\n declare placeholder: string;\n /** A token from the HTML autofill list — `given-name`, `postal-code`, `tel`. */\n declare autocomplete: string;\n declare inputmode: string;\n declare maxlength: number | undefined;\n\n /** How wide the box is, to suit the answer. Full width on a phone whatever this says. */\n declare width: 'full' | 'lg' | 'md' | 'sm' | 'xs';\n\n constructor() {\n super();\n this.width = 'full';\n this.type = 'text';\n this.placeholder = '';\n this.autocomplete = '';\n this.inputmode = '';\n this.maxlength = undefined;\n this.hideLabel = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n fieldWidths,\n css`\n input {\n inline-size: min(100%, var(--impakt-field-width));\n min-block-size: 44px;\n padding: ${space(2.5)} ${space(3)};\n font-family: inherit;\n font-size: ${fontSize('md')};\n color: ${t.text};\n background: var(--impakt-color-field-surface, ${t.surfaceCard});\n border: ${t.borderThin} solid ${t.border};\n border-radius: ${t.radiusLg};\n box-shadow: var(--impakt-shadow-field, ${t.shadowXs});\n transition: border-color 120ms ease-in-out, box-shadow 120ms ease-in-out;\n }\n input:hover:not(:disabled) {\n border-color: ${t.borderStrong};\n }\n /* A brand halo as well as the focus ring, so the field being typed in is plain at a glance. */\n input:focus-visible {\n border-color: ${t.brand};\n box-shadow: ${t.focusShadow}, 0 0 0 6px ${t.brandHalo};\n }\n input::placeholder {\n color: ${t.textPlaceholder};\n }\n input:disabled {\n background: ${t.surfaceInset};\n cursor: not-allowed;\n }\n /* The border thickens as well as reddening. Colour alone would carry the\n error, which 1.4.1 forbids — and the message below says it in words. */\n :host([hide-label]) .label {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n .search {\n position: relative;\n display: block;\n inline-size: min(100%, var(--impakt-field-width));\n }\n .search input {\n inline-size: 100%;\n padding-inline-start: ${space(10)};\n border-radius: 999px;\n }\n .search .icon {\n position: absolute;\n inset-inline-start: ${space(3.5)};\n inset-block-start: 50%;\n transform: translateY(-50%);\n color: ${t.textMuted};\n pointer-events: none;\n }\n :host([invalid]) input {\n border-color: ${t.danger};\n border-width: ${t.borderThick};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n const input = this.renderInput();\n return this.type === 'search' ? html`<span class=\"search\" part=\"search\">${iconSvg('search', '20px')}${input}</span>` : input;\n }\n\n private renderInput(): TemplateResult {\n return html`\n <input\n id=${this.controlId}\n part=\"input\"\n type=${this.type}\n name=${this.name || nothing}\n .value=${this.value}\n placeholder=${this.placeholder || nothing}\n autocomplete=${this.autocomplete || nothing}\n inputmode=${this.inputmode || nothing}\n maxlength=${this.maxlength ?? nothing}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @input=${(e: Event) => this.setFormValue((e.target as HTMLInputElement).value)}\n />\n `;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impakt-text-input', ImpaktTextInput);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-text-input': ImpaktTextInput;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAkBjD,IAAM,kBAAN,cAA8B,aAAa;AAAA,EAChD;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aA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