@atomic-ui/ui 0.0.0-stage → 0.1.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 (113) hide show
  1. package/README.md +134 -2
  2. package/dist/base/FieldElement.d.ts +95 -0
  3. package/dist/base/ImpktElement.d.ts +21 -0
  4. package/dist/base/styles.d.ts +42 -0
  5. package/dist/base/tokens.d.ts +68 -0
  6. package/dist/chunk-4YAA7EML.js +43 -0
  7. package/dist/chunk-4YAA7EML.js.map +1 -0
  8. package/dist/chunk-6HZA6A3L.js +162 -0
  9. package/dist/chunk-6HZA6A3L.js.map +1 -0
  10. package/dist/chunk-7T34CRBF.js +75 -0
  11. package/dist/chunk-7T34CRBF.js.map +1 -0
  12. package/dist/chunk-AC6G7X3G.js +84 -0
  13. package/dist/chunk-AC6G7X3G.js.map +1 -0
  14. package/dist/chunk-BBWMRF5N.js +157 -0
  15. package/dist/chunk-BBWMRF5N.js.map +1 -0
  16. package/dist/chunk-BOLZMDAS.js +95 -0
  17. package/dist/chunk-BOLZMDAS.js.map +1 -0
  18. package/dist/chunk-BUWE6XGX.js +152 -0
  19. package/dist/chunk-BUWE6XGX.js.map +1 -0
  20. package/dist/chunk-GEBLDC2J.js +136 -0
  21. package/dist/chunk-GEBLDC2J.js.map +1 -0
  22. package/dist/chunk-GU4UQKJP.js +120 -0
  23. package/dist/chunk-GU4UQKJP.js.map +1 -0
  24. package/dist/chunk-HJ2V635J.js +88 -0
  25. package/dist/chunk-HJ2V635J.js.map +1 -0
  26. package/dist/chunk-IHEEUM3M.js +162 -0
  27. package/dist/chunk-IHEEUM3M.js.map +1 -0
  28. package/dist/chunk-J5KAMJ2N.js +138 -0
  29. package/dist/chunk-J5KAMJ2N.js.map +1 -0
  30. package/dist/chunk-KAU3V65B.js +65 -0
  31. package/dist/chunk-KAU3V65B.js.map +1 -0
  32. package/dist/chunk-KC6RKWO6.js +81 -0
  33. package/dist/chunk-KC6RKWO6.js.map +1 -0
  34. package/dist/chunk-NEWN44LO.js +92 -0
  35. package/dist/chunk-NEWN44LO.js.map +1 -0
  36. package/dist/chunk-SSNCGJ5W.js +105 -0
  37. package/dist/chunk-SSNCGJ5W.js.map +1 -0
  38. package/dist/chunk-T4HSPWA7.js +122 -0
  39. package/dist/chunk-T4HSPWA7.js.map +1 -0
  40. package/dist/chunk-T63FI4ET.js +139 -0
  41. package/dist/chunk-T63FI4ET.js.map +1 -0
  42. package/dist/chunk-TOTVL3YH.js +130 -0
  43. package/dist/chunk-TOTVL3YH.js.map +1 -0
  44. package/dist/chunk-TRLEYGGH.js +102 -0
  45. package/dist/chunk-TRLEYGGH.js.map +1 -0
  46. package/dist/chunk-XEN5NV55.js +79 -0
  47. package/dist/chunk-XEN5NV55.js.map +1 -0
  48. package/dist/chunk-Z4KZG2E3.js +131 -0
  49. package/dist/chunk-Z4KZG2E3.js.map +1 -0
  50. package/dist/components/accordion.d.ts +66 -0
  51. package/dist/components/accordion.js +8 -0
  52. package/dist/components/accordion.js.map +1 -0
  53. package/dist/components/alert.d.ts +49 -0
  54. package/dist/components/alert.js +8 -0
  55. package/dist/components/alert.js.map +1 -0
  56. package/dist/components/button.d.ts +70 -0
  57. package/dist/components/button.js +8 -0
  58. package/dist/components/button.js.map +1 -0
  59. package/dist/components/checkbox-group.d.ts +79 -0
  60. package/dist/components/checkbox-group.js +9 -0
  61. package/dist/components/checkbox-group.js.map +1 -0
  62. package/dist/components/checkbox.d.ts +64 -0
  63. package/dist/components/checkbox.js +9 -0
  64. package/dist/components/checkbox.js.map +1 -0
  65. package/dist/components/date-input.d.ts +95 -0
  66. package/dist/components/date-input.js +9 -0
  67. package/dist/components/date-input.js.map +1 -0
  68. package/dist/components/dialog.d.ts +61 -0
  69. package/dist/components/dialog.js +8 -0
  70. package/dist/components/dialog.js.map +1 -0
  71. package/dist/components/grid.d.ts +34 -0
  72. package/dist/components/grid.js +8 -0
  73. package/dist/components/grid.js.map +1 -0
  74. package/dist/components/help.d.ts +103 -0
  75. package/dist/components/help.js +8 -0
  76. package/dist/components/help.js.map +1 -0
  77. package/dist/components/layout.d.ts +100 -0
  78. package/dist/components/layout.js +14 -0
  79. package/dist/components/layout.js.map +1 -0
  80. package/dist/components/link.d.ts +46 -0
  81. package/dist/components/link.js +8 -0
  82. package/dist/components/link.js.map +1 -0
  83. package/dist/components/media.d.ts +164 -0
  84. package/dist/components/media.js +12 -0
  85. package/dist/components/media.js.map +1 -0
  86. package/dist/components/price.d.ts +67 -0
  87. package/dist/components/price.js +8 -0
  88. package/dist/components/price.js.map +1 -0
  89. package/dist/components/progress.d.ts +50 -0
  90. package/dist/components/progress.js +8 -0
  91. package/dist/components/progress.js.map +1 -0
  92. package/dist/components/radio-group.d.ts +82 -0
  93. package/dist/components/radio-group.js +9 -0
  94. package/dist/components/radio-group.js.map +1 -0
  95. package/dist/components/select.d.ts +74 -0
  96. package/dist/components/select.js +9 -0
  97. package/dist/components/select.js.map +1 -0
  98. package/dist/components/summary-list.d.ts +47 -0
  99. package/dist/components/summary-list.js +8 -0
  100. package/dist/components/summary-list.js.map +1 -0
  101. package/dist/components/table.d.ts +49 -0
  102. package/dist/components/table.js +8 -0
  103. package/dist/components/table.js.map +1 -0
  104. package/dist/components/text-input.d.ts +80 -0
  105. package/dist/components/text-input.js +9 -0
  106. package/dist/components/text-input.js.map +1 -0
  107. package/dist/components/textarea.d.ts +59 -0
  108. package/dist/components/textarea.js +9 -0
  109. package/dist/components/textarea.js.map +1 -0
  110. package/dist/index.d.ts +31 -0
  111. package/dist/index.js +113 -0
  112. package/dist/index.js.map +1 -0
  113. package/package.json +45 -4
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/accordion.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, targetSize } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface AccordionItem {\n id: string;\n heading: string;\n body: string;\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 * @category content\n * @icon accordion\n */\nexport class ImpktAccordion extends ImpktElement {\n static properties = {\n items: { type: Array },\n headingLevel: { type: Number, attribute: 'heading-level' },\n open: { type: Array },\n multiple: { type: Boolean },\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 constructor() {\n super();\n this.items = [];\n this.headingLevel = 3;\n this.open = [];\n this.multiple = true;\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n }\n .item {\n border-block-end: ${t.borderThin} solid ${t.border};\n }\n button {\n ${targetSize}\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: ${space(3)};\n inline-size: 100%;\n padding: ${space(3)} 0;\n background: none;\n border: 0;\n font: inherit;\n font-size: ${fontSize('md')};\n font-weight: ${fontWeight('semibold')};\n color: ${t.text};\n text-align: start;\n cursor: pointer;\n }\n button:hover {\n color: ${t.link};\n }\n .marker {\n flex: none;\n transition: transform 120ms ease-in-out;\n }\n button[aria-expanded='true'] .marker {\n transform: rotate(90deg);\n }\n .panel {\n padding-block-end: ${space(4)};\n font-size: ${fontSize('md')};\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 return html`\n ${this.items.map((item) => {\n const expanded = 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\" part=\"item\">\n <div 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 <span>${item.heading}</span>\n <span class=\"marker\" aria-hidden=\"true\">›</span>\n </button>\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 ${this.items.length === 0 ? nothing : nothing}\n `;\n }\n}\n\ncustomElements.define('impkt-accordion', ImpktAccordion);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-accordion': ImpktAccordion }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAsCjD,IAAM,iBAAN,cAA6B,aAAa;AAAA,EAC/C;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,IAC5B;AAAA;AAAA,EASA,cAAc;AACZ,UAAM;AACN,SAAK,QAAQ,CAAC;AACd,SAAK,eAAe;AACpB,SAAK,OAAO,CAAC;AACb,SAAK,WAAW;AAAA,EAClB;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AA,wBAE3B,KAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKjB,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,QACA,KAAK,MAAM,WAAW,IAAI,UAAU,OAAO;AAAA;AAAA,EAEjD;AACF;AAEA,eAAe,OAAO,mBAAmB,cAAc;","names":[]}
@@ -0,0 +1,139 @@
1
+ import {
2
+ FieldElement
3
+ } from "./chunk-6HZA6A3L.js";
4
+ import {
5
+ fontSize,
6
+ space,
7
+ t,
8
+ targetSize
9
+ } from "./chunk-J5KAMJ2N.js";
10
+
11
+ // packages/ui/src/components/radio-group.ts
12
+ import { html, css, nothing } from "lit";
13
+ var ImpktRadioGroup = class extends FieldElement {
14
+ static {
15
+ this.properties = {
16
+ ...FieldElement.properties,
17
+ options: { type: Array }
18
+ };
19
+ }
20
+ constructor() {
21
+ super();
22
+ this.options = [];
23
+ }
24
+ static {
25
+ this.styles = [
26
+ ...FieldElement.styles,
27
+ css`
28
+ fieldset {
29
+ border: 0;
30
+ margin: 0;
31
+ padding: 0;
32
+ min-inline-size: 0;
33
+ }
34
+ legend {
35
+ padding: 0;
36
+ }
37
+ .option {
38
+ display: flex;
39
+ align-items: flex-start;
40
+ gap: ${space(3)};
41
+ padding: ${space(3)};
42
+ border: ${t.borderThin} solid ${t.border};
43
+ border-radius: ${t.radius};
44
+ margin-block-end: ${space(2)};
45
+ cursor: pointer;
46
+ }
47
+ .option:hover {
48
+ background: ${t.surfaceSubtle};
49
+ }
50
+ /* The whole row is the target, not the 20px dot — 2.5.8 is a floor and
51
+ a comfortable target is the actual goal. */
52
+ .option input {
53
+ ${targetSize}
54
+ inline-size: 20px;
55
+ block-size: 20px;
56
+ margin: 0;
57
+ flex: none;
58
+ accent-color: ${t.brand};
59
+ }
60
+ .option-text {
61
+ display: block;
62
+ font-size: ${fontSize("md")};
63
+ }
64
+ .option-description {
65
+ display: block;
66
+ font-size: ${fontSize("sm")};
67
+ color: ${t.textMuted};
68
+ margin-block-start: ${space(1)};
69
+ }
70
+ :host([invalid]) .option {
71
+ border-color: ${t.danger};
72
+ }
73
+ `
74
+ ];
75
+ }
76
+ renderLabel() {
77
+ return html`<legend class="label" part="label">
78
+ ${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
79
+ </legend>`;
80
+ }
81
+ renderControl() {
82
+ return html`
83
+ ${this.options.map((option, i) => {
84
+ const id = this.id_(`opt-${i}`);
85
+ const descId = option.description ? this.id_(`opt-${i}-desc`) : void 0;
86
+ return html`
87
+ <label class="option" part="option" for=${id}>
88
+ <input
89
+ type="radio"
90
+ id=${id}
91
+ name=${this.uid}
92
+ value=${option.value}
93
+ .checked=${this.value === option.value}
94
+ ?disabled=${this.disabled}
95
+ ?required=${this.required && i === 0}
96
+ aria-describedby=${descId ?? nothing}
97
+ @change=${() => this.setFormValue(option.value)}
98
+ />
99
+ <span>
100
+ <span class="option-text">${option.label}</span>
101
+ ${option.description ? html`<span class="option-description" id=${descId}>${option.description}</span>` : nothing}
102
+ </span>
103
+ </label>
104
+ `;
105
+ })}
106
+ `;
107
+ }
108
+ /**
109
+ * The fieldset wraps everything, so the whole field is rebuilt here rather
110
+ * than relying on the base class's flat order.
111
+ */
112
+ render() {
113
+ return html`
114
+ <fieldset
115
+ part="fieldset"
116
+ aria-describedby=${this.describedBy}
117
+ aria-invalid=${this.error ? "true" : nothing}
118
+ >
119
+ ${this.renderLabel()}
120
+ ${this.description ? html`<div class="description" id=${this.id_("description")} part="description">
121
+ ${this.description}
122
+ </div>` : nothing}
123
+ ${this.renderControl()}
124
+ <div class="error" id=${this.id_("error")} part="error" aria-live="polite">
125
+ ${this.error || nothing}
126
+ </div>
127
+ </fieldset>
128
+ `;
129
+ }
130
+ updated(changed) {
131
+ if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
132
+ }
133
+ };
134
+ customElements.define("impkt-radio-group", ImpktRadioGroup);
135
+
136
+ export {
137
+ ImpktRadioGroup
138
+ };
139
+ //# sourceMappingURL=chunk-T63FI4ET.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/radio-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 RadioOption {\n value: string;\n label: string;\n description?: string;\n}\n\n/**\n * A choose-one group.\n *\n * **It renders native radios, and that is the whole design.** A group of\n * `<input type=\"radio\">` sharing a name already has roving tabindex, arrow-key\n * navigation that wraps, Home and End, selection-follows-focus, and the right\n * announcement in every screen reader — all of it, correctly, with no\n * JavaScript. Hand-rolling that is the single most commonly attempted and most\n * commonly botched widget in any design system, and every version of it is a\n * worse version of what the platform ships.\n *\n * Because the radios share one shadow root, their `name` scopes to this\n * component and cannot collide with another group on the page.\n *\n * The label is a `<legend>` inside a `<fieldset>`, not a `<label for>`:\n * `for` names one control, and the question here is asked of the set.\n\n *\n * @category form\n * @icon radio\n */\nexport class ImpktRadioGroup extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n };\n\n declare options: RadioOption[];\n\n constructor() {\n super();\n this.options = [];\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 /* The whole row is the target, not the 20px dot — 2.5.8 is a floor and\n a comfortable target is the actual goal. */\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 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=\"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 aria-describedby=${descId ?? nothing}\n @change=${() => this.setFormValue(option.value)}\n />\n <span>\n <span class=\"option-text\">${option.label}</span>\n ${option.description\n ? html`<span class=\"option-description\" id=${descId!}>${option.description}</span>`\n : nothing}\n </span>\n </label>\n `;\n })}\n `;\n }\n\n /**\n * The fieldset wraps everything, so the whole field is rebuilt here rather\n * than relying on the base class's flat order.\n */\n render(): TemplateResult {\n return html`\n <fieldset\n part=\"fieldset\"\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n >\n ${this.renderLabel()}\n ${this.description\n ? html`<div class=\"description\" id=${this.id_('description')} part=\"description\">\n ${this.description}\n </div>`\n : nothing}\n ${this.renderControl()}\n <div class=\"error\" id=${this.id_('error')} part=\"error\" aria-live=\"polite\">\n ${this.error || nothing}\n </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('impkt-radio-group', ImpktRadioGroup);\n\ndeclare global {\n interface HTMLElementTag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ts
12
+ import { html, css, nothing } from "lit";
13
+ var ImpktDialog = class extends ImpktElement {
14
+ static {
15
+ this.properties = {
16
+ open: { type: Boolean, reflect: true },
17
+ heading: { type: String },
18
+ closeLabel: { type: String, attribute: "close-label" },
19
+ dismissible: { type: Boolean }
20
+ };
21
+ }
22
+ constructor() {
23
+ super();
24
+ this.open = false;
25
+ this.heading = "";
26
+ this.closeLabel = "Close";
27
+ this.dismissible = true;
28
+ }
29
+ static {
30
+ this.styles = [
31
+ ...ImpktElement.styles,
32
+ focusRing,
33
+ css`
34
+ dialog {
35
+ padding: 0;
36
+ border: 0;
37
+ border-radius: ${t.radiusLg};
38
+ background: ${t.surfaceCard};
39
+ color: ${t.text};
40
+ max-inline-size: min(32rem, calc(100vw - 2rem));
41
+ /* 1.4.10 Reflow: a dialog taller than the viewport must scroll inside
42
+ itself rather than clipping, at 320px and at 400% zoom alike. */
43
+ max-block-size: calc(100vh - 2rem);
44
+ overflow: auto;
45
+ }
46
+ dialog::backdrop {
47
+ background: rgb(0 0 0 / 0.5);
48
+ }
49
+ .head {
50
+ display: flex;
51
+ align-items: flex-start;
52
+ justify-content: space-between;
53
+ gap: ${space(3)};
54
+ padding: ${space(5)} ${space(5)} 0;
55
+ }
56
+ .heading {
57
+ margin: 0;
58
+ font-family: ${t.fontHeading};
59
+ font-size: ${fontSize("xl")};
60
+ font-weight: ${fontWeight("bold")};
61
+ color: ${t.textHeading};
62
+ }
63
+ .body {
64
+ padding: ${space(4)} ${space(5)} ${space(5)};
65
+ }
66
+ .close {
67
+ ${targetSize}
68
+ flex: none;
69
+ background: none;
70
+ border: 0;
71
+ border-radius: ${t.radius};
72
+ font: inherit;
73
+ font-size: ${fontSize("lg")};
74
+ color: ${t.text};
75
+ cursor: pointer;
76
+ }
77
+ `
78
+ ];
79
+ }
80
+ get dialog() {
81
+ return this.renderRoot.querySelector("dialog");
82
+ }
83
+ updated(changed) {
84
+ if (!changed.has("open")) return;
85
+ const dialog = this.dialog;
86
+ if (!dialog) return;
87
+ if (this.open) {
88
+ if (typeof dialog.showModal === "function") dialog.showModal();
89
+ else dialog.setAttribute("open", "");
90
+ } else if (typeof dialog.close === "function" && dialog.open) {
91
+ dialog.close();
92
+ } else {
93
+ dialog.removeAttribute("open");
94
+ }
95
+ }
96
+ close() {
97
+ this.open = false;
98
+ this.dispatchEvent(new CustomEvent("impkt-close", { bubbles: true, composed: true }));
99
+ }
100
+ render() {
101
+ return html`
102
+ <dialog
103
+ part="dialog"
104
+ aria-labelledby=${this.heading ? this.id_("heading") : nothing}
105
+ @cancel=${(e) => {
106
+ if (!this.dismissible) e.preventDefault();
107
+ else this.close();
108
+ }}
109
+ @close=${() => {
110
+ if (this.open) this.close();
111
+ }}
112
+ >
113
+ <div class="head">
114
+ ${this.heading ? html`<h2 class="heading" id=${this.id_("heading")} part="heading">${this.heading}</h2>` : nothing}
115
+ ${this.dismissible ? html`<button class="close" part="close" type="button" @click=${this.close}>
116
+ <span aria-hidden="true">×</span>
117
+ <span class="sr-only" style="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)">${this.closeLabel}</span>
118
+ </button>` : nothing}
119
+ </div>
120
+ <div class="body" part="body"><slot></slot></div>
121
+ </dialog>
122
+ `;
123
+ }
124
+ };
125
+ customElements.define("impkt-dialog", ImpktDialog);
126
+
127
+ export {
128
+ ImpktDialog
129
+ };
130
+ //# sourceMappingURL=chunk-TOTVL3YH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/dialog.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing, targetSize } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\n/**\n * A modal dialog — \"are you sure you want to leave this order?\".\n *\n * **It is a native `<dialog>` opened with `showModal()`, and that is the whole\n * design.** The platform then provides, correctly and in every browser: a\n * focus trap, Escape to close, the rest of the page made inert so a screen\n * reader cannot wander out of the dialog, rendering in the top layer so no\n * `z-index` can cover it, and focus returned to whatever opened it when it\n * closes.\n *\n * Every one of those is a thing hand-rolled modals get wrong. The focus trap\n * is the famous one, but inertness is the worse failure: a dialog that traps\n * the Tab key but leaves the background in the accessibility tree lets a\n * screen-reader user read straight past it into a page they cannot interact\n * with, and nothing on screen tells them that is what happened.\n *\n * What is left to get right is the labelling. `aria-labelledby` points at the\n * dialog's own heading, so it is announced by name on open rather than as\n * \"dialog\".\n\n *\n * @category feedback\n * @icon dialog\n * @slot - The body of the dialog.\n */\nexport class ImpktDialog extends ImpktElement {\n static properties = {\n open: { type: Boolean, reflect: true },\n heading: { type: String },\n closeLabel: { type: String, attribute: 'close-label' },\n dismissible: { type: Boolean },\n };\n\n declare open: boolean;\n declare heading: string;\n declare closeLabel: string;\n /** When false, Escape and the backdrop do not close it — a decision must be made. */\n declare dismissible: boolean;\n\n constructor() {\n super();\n this.open = false;\n this.heading = '';\n this.closeLabel = 'Close';\n this.dismissible = true;\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n dialog {\n padding: 0;\n border: 0;\n border-radius: ${t.radiusLg};\n background: ${t.surfaceCard};\n color: ${t.text};\n max-inline-size: min(32rem, calc(100vw - 2rem));\n /* 1.4.10 Reflow: a dialog taller than the viewport must scroll inside\n itself rather than clipping, at 320px and at 400% zoom alike. */\n max-block-size: calc(100vh - 2rem);\n overflow: auto;\n }\n dialog::backdrop {\n background: rgb(0 0 0 / 0.5);\n }\n .head {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: ${space(3)};\n padding: ${space(5)} ${space(5)} 0;\n }\n .heading {\n margin: 0;\n font-family: ${t.fontHeading};\n font-size: ${fontSize('xl')};\n font-weight: ${fontWeight('bold')};\n color: ${t.textHeading};\n }\n .body {\n padding: ${space(4)} ${space(5)} ${space(5)};\n }\n .close {\n ${targetSize}\n flex: none;\n background: none;\n border: 0;\n border-radius: ${t.radius};\n font: inherit;\n font-size: ${fontSize('lg')};\n color: ${t.text};\n cursor: pointer;\n }\n `,\n ];\n\n private get dialog(): HTMLDialogElement | null {\n return this.renderRoot.querySelector('dialog');\n }\n\n updated(changed: Map<string, unknown>): void {\n if (!changed.has('open')) return;\n const dialog = this.dialog;\n if (!dialog) return;\n // happy-dom and older engines do not implement showModal. Falling back to\n // the `open` attribute renders a NON-modal dialog — no focus trap, no\n // inert background — so it is used only to keep tests and ancient browsers\n // from throwing, never as an equivalent.\n if (this.open) {\n if (typeof dialog.showModal === 'function') dialog.showModal();\n else dialog.setAttribute('open', '');\n } else if (typeof dialog.close === 'function' && dialog.open) {\n dialog.close();\n } else {\n dialog.removeAttribute('open');\n }\n }\n\n private close(): void {\n this.open = false;\n this.dispatchEvent(new CustomEvent('impkt-close', { bubbles: true, composed: true }));\n }\n\n render(): TemplateResult {\n return html`\n <dialog\n part=\"dialog\"\n aria-labelledby=${this.heading ? this.id_('heading') : nothing}\n @cancel=${(e: Event) => {\n // `cancel` fires on Escape. Blocking it is what makes a dialog\n // non-dismissible, and it is why `dismissible` exists rather than\n // leaving a caller to re-open on close.\n if (!this.dismissible) e.preventDefault();\n else this.close();\n }}\n @close=${() => { if (this.open) this.close(); }}\n >\n <div class=\"head\">\n ${this.heading\n ? html`<h2 class=\"heading\" id=${this.id_('heading')} part=\"heading\">${this.heading}</h2>`\n : nothing}\n ${this.dismissible\n ? html`<button class=\"close\" part=\"close\" type=\"button\" @click=${this.close}>\n <span aria-hidden=\"true\">×</span>\n <span class=\"sr-only\" style=\"position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)\">${this.closeLabel}</span>\n </button>`\n : nothing}\n </div>\n <div class=\"body\" part=\"body\"><slot></slot></div>\n </dialog>\n `;\n }\n}\n\ncustomElements.define('impkt-dialog', ImpktDialog);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-dialog': ImpktDialog }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA8BjD,IAAM,cAAN,cAA0B,aAAa;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,KAAK;AACpB,QAAI,CAAC,OAAQ;AAKb,QAAI,KAAK,MAAM;AACb,UAAI,OAAO,OAAO,cAAc,WAAY,QAAO,UAAU;AAAA,UACxD,QAAO,aAAa,QAAQ,EAAE;AAAA,IACrC,WAAW,OAAO,OAAO,UAAU,cAAc,OAAO,MAAM;AAC5D,aAAO,MAAM;AAAA,IACf,OAAO;AACL,aAAO,gBAAgB,MAAM;AAAA,IAC/B;AAAA,EACF;AAAA,EAEQ,QAAc;AACpB,SAAK,OAAO;AACZ,SAAK,cAAc,IAAI,YAAY,eAAe,EAAE,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,EACtF;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA;AAAA,0BAGe,KAAK,UAAU,KAAK,IAAI,SAAS,IAAI,OAAO;AAAA,kBACpD,CAAC,MAAa;AAItB,UAAI,CAAC,KAAK,YAAa,GAAE,eAAe;AAAA,UACnC,MAAK,MAAM;AAAA,IAClB,CAAC;AAAA,iBACQ,MAAM;AAAE,UAAI,KAAK,KAAM,MAAK,MAAM;AAAA,IAAG,CAAC;AAAA;AAAA;AAAA,YAG3C,KAAK,UACH,8BAA8B,KAAK,IAAI,SAAS,CAAC,mBAAmB,KAAK,OAAO,UAChF,OAAO;AAAA,YACT,KAAK,cACH,+DAA+D,KAAK,KAAK;AAAA;AAAA,4HAEqC,KAAK,UAAU;AAAA,2BAE7H,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
@@ -0,0 +1,102 @@
1
+ import {
2
+ ImpktElement,
3
+ focusRing,
4
+ fontSize,
5
+ fontWeight,
6
+ space,
7
+ t
8
+ } from "./chunk-J5KAMJ2N.js";
9
+
10
+ // packages/ui/src/components/table.ts
11
+ import { html, css, nothing } from "lit";
12
+ var ImpktTable = class extends ImpktElement {
13
+ static {
14
+ this.properties = {
15
+ caption: { type: String },
16
+ columns: { type: Array },
17
+ rows: { type: Array }
18
+ };
19
+ }
20
+ constructor() {
21
+ super();
22
+ this.caption = "";
23
+ this.columns = [];
24
+ this.rows = [];
25
+ }
26
+ static {
27
+ this.styles = [
28
+ ...ImpktElement.styles,
29
+ focusRing,
30
+ css`
31
+ :host {
32
+ display: block;
33
+ }
34
+ .scroller {
35
+ overflow-x: auto;
36
+ }
37
+ table {
38
+ inline-size: 100%;
39
+ border-collapse: collapse;
40
+ font-size: ${fontSize("md")};
41
+ }
42
+ caption {
43
+ text-align: start;
44
+ font-weight: ${fontWeight("semibold")};
45
+ padding-block-end: ${space(2)};
46
+ }
47
+ th,
48
+ td {
49
+ text-align: start;
50
+ padding: ${space(3)};
51
+ border-block-end: ${t.borderThin} solid ${t.border};
52
+ }
53
+ th {
54
+ font-weight: ${fontWeight("semibold")};
55
+ background: ${t.surfaceInset};
56
+ }
57
+ .numeric {
58
+ text-align: end;
59
+ font-variant-numeric: tabular-nums;
60
+ }
61
+ `
62
+ ];
63
+ }
64
+ render() {
65
+ return html`
66
+ <div class="scroller" part="scroller" tabindex="0" role="region" aria-label=${this.caption || nothing}>
67
+ <table part="table">
68
+ ${this.caption ? html`<caption part="caption">${this.caption}</caption>` : nothing}
69
+ <thead>
70
+ <tr>
71
+ ${this.columns.map(
72
+ (c) => html`<th scope="col" class=${c.numeric ? "numeric" : ""}>${c.label}</th>`
73
+ )}
74
+ </tr>
75
+ </thead>
76
+ <tbody>
77
+ ${this.rows.map(
78
+ (row, i) => html`
79
+ <tr>
80
+ ${this.columns.map(
81
+ (c, j) => (
82
+ // The first cell of each row is a row header, so a screen
83
+ // reader announces "Delivery charge, £250" rather than
84
+ // reading a bare number with no idea what it belongs to.
85
+ j === 0 ? html`<th scope="row" id=${`${this.uid}-r${i}`}>${row[c.key] ?? ""}</th>` : html`<td class=${c.numeric ? "numeric" : ""}>${row[c.key] ?? ""}</td>`
86
+ )
87
+ )}
88
+ </tr>
89
+ `
90
+ )}
91
+ </tbody>
92
+ </table>
93
+ </div>
94
+ `;
95
+ }
96
+ };
97
+ customElements.define("impkt-table", ImpktTable);
98
+
99
+ export {
100
+ ImpktTable
101
+ };
102
+ //# sourceMappingURL=chunk-TRLEYGGH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/table.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { focusRing } from '../base/styles';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport interface TableColumn {\n key: string;\n label: string;\n numeric?: boolean;\n}\n\n/**\n * A data table — a plan comparison, a payment schedule.\n *\n * **The caption is required.** It is the table's name, and a page with three\n * unnamed tables is a page a screen-reader user has to read in full to tell\n * apart. Visually it can be the heading they would have written anyway.\n *\n * **It scrolls, and the scroller is focusable.** A wide table cannot reflow to\n * 320px without becoming unreadable, so it scrolls horizontally — and a region\n * that scrolls must be reachable by keyboard, or a keyboard user simply cannot\n * see the right-hand columns. `tabindex=\"0\"` with a role and a name is the\n * established fix, and the name is why the role is there: a bare focusable div\n * announces nothing.\n\n *\n * @category content\n * @icon table\n */\nexport class ImpktTable extends ImpktElement {\n static properties = {\n caption: { type: String },\n columns: { type: Array },\n rows: { type: Array },\n };\n\n declare caption: string;\n declare columns: TableColumn[];\n declare rows: Array<Record<string, string>>;\n\n constructor() {\n super();\n this.caption = '';\n this.columns = [];\n this.rows = [];\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n }\n .scroller {\n overflow-x: auto;\n }\n table {\n inline-size: 100%;\n border-collapse: collapse;\n font-size: ${fontSize('md')};\n }\n caption {\n text-align: start;\n font-weight: ${fontWeight('semibold')};\n padding-block-end: ${space(2)};\n }\n th,\n td {\n text-align: start;\n padding: ${space(3)};\n border-block-end: ${t.borderThin} solid ${t.border};\n }\n th {\n font-weight: ${fontWeight('semibold')};\n background: ${t.surfaceInset};\n }\n .numeric {\n text-align: end;\n font-variant-numeric: tabular-nums;\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <div class=\"scroller\" part=\"scroller\" tabindex=\"0\" role=\"region\" aria-label=${this.caption || nothing}>\n <table part=\"table\">\n ${this.caption ? html`<caption part=\"caption\">${this.caption}</caption>` : nothing}\n <thead>\n <tr>\n ${this.columns.map(\n (c) => html`<th scope=\"col\" class=${c.numeric ? 'numeric' : ''}>${c.label}</th>`,\n )}\n </tr>\n </thead>\n <tbody>\n ${this.rows.map(\n (row, i) => html`\n <tr>\n ${this.columns.map((c, j) =>\n // The first cell of each row is a row header, so a screen\n // reader announces \"Delivery charge, £250\" rather than\n // reading a bare number with no idea what it belongs to.\n j === 0\n ? html`<th scope=\"row\" id=${`${this.uid}-r${i}`}>${row[c.key] ?? ''}</th>`\n : html`<td class=${c.numeric ? 'numeric' : ''}>${row[c.key] ?? ''}</td>`,\n )}\n </tr>\n `,\n )}\n </tbody>\n </table>\n </div>\n `;\n }\n}\n\ncustomElements.define('impkt-table', ImpktTable);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-table': ImpktTable }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA6BjD,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C;AAAA,SAAO,aAAa;AAAA,MAClB,SAAS,EAAE,MAAM,OAAO;AAAA,MACxB,SAAS,EAAE,MAAM,MAAM;AAAA,MACvB,MAAM,EAAE,MAAM,MAAM;AAAA,IACtB;AAAA;AAAA,EAMA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AACf,SAAK,UAAU,CAAC;AAChB,SAAK,OAAO,CAAC;AAAA,EACf;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAUiB,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,uBAIZ,WAAW,UAAU,CAAC;AAAA,6BAChB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKlB,MAAM,CAAC,CAAC;AAAA,4BACC,EAAE,UAAU,UAAU,EAAE,MAAM;AAAA;AAAA;AAAA,uBAGnC,WAAW,UAAU,CAAC;AAAA,sBACvB,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOlC;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA,oFACyE,KAAK,WAAW,OAAO;AAAA;AAAA,YAE/F,KAAK,UAAU,+BAA+B,KAAK,OAAO,eAAe,OAAO;AAAA;AAAA;AAAA,gBAG5E,KAAK,QAAQ;AAAA,MACb,CAAC,MAAM,6BAA6B,EAAE,UAAU,YAAY,EAAE,IAAI,EAAE,KAAK;AAAA,IAC3E,CAAC;AAAA;AAAA;AAAA;AAAA,cAID,KAAK,KAAK;AAAA,MACV,CAAC,KAAK,MAAM;AAAA;AAAA,oBAEN,KAAK,QAAQ;AAAA,QAAI,CAAC,GAAG;AAAA;AAAA;AAAA;AAAA,UAIrB,MAAM,IACF,0BAA0B,GAAG,KAAK,GAAG,KAAK,CAAC,EAAE,IAAI,IAAI,EAAE,GAAG,KAAK,EAAE,UACjE,iBAAiB,EAAE,UAAU,YAAY,EAAE,IAAI,IAAI,EAAE,GAAG,KAAK,EAAE;AAAA;AAAA,MACrE,CAAC;AAAA;AAAA;AAAA,IAGP,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKX;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
@@ -0,0 +1,79 @@
1
+ import {
2
+ FieldElement
3
+ } from "./chunk-6HZA6A3L.js";
4
+ import {
5
+ fontSize,
6
+ space,
7
+ t
8
+ } from "./chunk-J5KAMJ2N.js";
9
+
10
+ // packages/ui/src/components/select.ts
11
+ import { html, css, nothing } from "lit";
12
+ var ImpktSelect = class extends FieldElement {
13
+ static {
14
+ this.properties = {
15
+ ...FieldElement.properties,
16
+ options: { type: Array },
17
+ placeholder: { type: String }
18
+ };
19
+ }
20
+ constructor() {
21
+ super();
22
+ this.options = [];
23
+ this.placeholder = "Choose an option";
24
+ }
25
+ static {
26
+ this.styles = [
27
+ ...FieldElement.styles,
28
+ css`
29
+ select {
30
+ inline-size: 100%;
31
+ min-block-size: 44px;
32
+ padding: ${space(3)};
33
+ font-family: inherit;
34
+ font-size: ${fontSize("md")};
35
+ color: ${t.text};
36
+ background: ${t.surfaceCard};
37
+ border: ${t.borderThin} solid ${t.border};
38
+ border-radius: ${t.radius};
39
+ }
40
+ select:disabled {
41
+ background: ${t.surfaceInset};
42
+ cursor: not-allowed;
43
+ }
44
+ :host([invalid]) select {
45
+ border-color: ${t.danger};
46
+ border-width: ${t.borderThick};
47
+ }
48
+ `
49
+ ];
50
+ }
51
+ renderControl() {
52
+ return html`
53
+ <select
54
+ id=${this.controlId}
55
+ part="select"
56
+ name=${this.name || nothing}
57
+ ?disabled=${this.disabled}
58
+ ?required=${this.required}
59
+ aria-describedby=${this.describedBy}
60
+ aria-invalid=${this.error ? "true" : nothing}
61
+ @change=${(e) => this.setFormValue(e.target.value)}
62
+ >
63
+ <option value="" ?selected=${!this.value}>${this.placeholder}</option>
64
+ ${this.options.map(
65
+ (o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`
66
+ )}
67
+ </select>
68
+ `;
69
+ }
70
+ updated(changed) {
71
+ if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
72
+ }
73
+ };
74
+ customElements.define("impkt-select", ImpktSelect);
75
+
76
+ export {
77
+ ImpktSelect
78
+ };
79
+ //# sourceMappingURL=chunk-XEN5NV55.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/select.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { FieldElement } from '../base/FieldElement';\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 ImpktSelect extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n options: { type: Array },\n placeholder: { type: String },\n };\n\n declare options: SelectOption[];\n declare placeholder: string;\n\n constructor() {\n super();\n this.options = [];\n this.placeholder = 'Choose an option';\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n select {\n inline-size: 100%;\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 }\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(\n (o) => html`<option value=${o.value} ?selected=${this.value === o.value}>${o.label}</option>`,\n )}\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('impkt-select', ImpktSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-select': ImpktSelect;\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAyBjD,IAAM,cAAN,cAA0B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AK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
@@ -0,0 +1,131 @@
1
+ import {
2
+ FieldElement
3
+ } from "./chunk-6HZA6A3L.js";
4
+ import {
5
+ fontSize,
6
+ space,
7
+ t,
8
+ targetSize
9
+ } from "./chunk-J5KAMJ2N.js";
10
+
11
+ // packages/ui/src/components/checkbox-group.ts
12
+ import { html, css, nothing } from "lit";
13
+ var ImpktCheckboxGroup = class extends FieldElement {
14
+ static {
15
+ this.properties = {
16
+ ...FieldElement.properties,
17
+ options: { type: Array },
18
+ values: { type: Array }
19
+ };
20
+ }
21
+ constructor() {
22
+ super();
23
+ this.options = [];
24
+ this.values = [];
25
+ }
26
+ static {
27
+ this.styles = [
28
+ ...FieldElement.styles,
29
+ css`
30
+ fieldset {
31
+ border: 0;
32
+ margin: 0;
33
+ padding: 0;
34
+ min-inline-size: 0;
35
+ }
36
+ legend {
37
+ padding: 0;
38
+ }
39
+ .option {
40
+ display: flex;
41
+ align-items: flex-start;
42
+ gap: ${space(3)};
43
+ padding: ${space(3)};
44
+ border: ${t.borderThin} solid ${t.border};
45
+ border-radius: ${t.radius};
46
+ margin-block-end: ${space(2)};
47
+ cursor: pointer;
48
+ }
49
+ .option:hover {
50
+ background: ${t.surfaceSubtle};
51
+ }
52
+ .option input {
53
+ ${targetSize}
54
+ inline-size: 20px;
55
+ block-size: 20px;
56
+ margin: 0;
57
+ flex: none;
58
+ accent-color: ${t.brand};
59
+ }
60
+ .option-text {
61
+ display: block;
62
+ font-size: ${fontSize("md")};
63
+ }
64
+ .option-description {
65
+ display: block;
66
+ font-size: ${fontSize("sm")};
67
+ color: ${t.textMuted};
68
+ margin-block-start: ${space(1)};
69
+ }
70
+ :host([invalid]) .option {
71
+ border-color: ${t.danger};
72
+ }
73
+ `
74
+ ];
75
+ }
76
+ renderLabel() {
77
+ return html`<legend class="label" part="label">
78
+ ${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
79
+ </legend>`;
80
+ }
81
+ onToggle(value, checked) {
82
+ this.values = checked ? [...this.values, value] : this.values.filter((v) => v !== value);
83
+ this.setFormValue(
84
+ this.options.filter((o) => this.values.includes(o.value)).map((o) => o.value).join(",")
85
+ );
86
+ }
87
+ renderControl() {
88
+ return html`
89
+ ${this.options.map((option, i) => {
90
+ const id = this.id_(`opt-${i}`);
91
+ const descId = option.description ? this.id_(`opt-${i}-desc`) : void 0;
92
+ return html`
93
+ <label class="option" part="option" for=${id}>
94
+ <input
95
+ type="checkbox"
96
+ id=${id}
97
+ value=${option.value}
98
+ .checked=${this.values.includes(option.value)}
99
+ ?disabled=${this.disabled}
100
+ aria-describedby=${descId ?? nothing}
101
+ @change=${(e) => this.onToggle(option.value, e.target.checked)}
102
+ />
103
+ <span>
104
+ <span class="option-text">${option.label}</span>
105
+ ${option.description ? html`<span class="option-description" id=${descId}>${option.description}</span>` : nothing}
106
+ </span>
107
+ </label>
108
+ `;
109
+ })}
110
+ `;
111
+ }
112
+ render() {
113
+ return html`
114
+ <fieldset part="fieldset" aria-describedby=${this.describedBy} aria-invalid=${this.error ? "true" : nothing}>
115
+ ${this.renderLabel()}
116
+ ${this.description ? html`<div class="description" id=${this.id_("description")} part="description">${this.description}</div>` : nothing}
117
+ ${this.renderControl()}
118
+ <div class="error" id=${this.id_("error")} part="error" aria-live="polite">${this.error || nothing}</div>
119
+ </fieldset>
120
+ `;
121
+ }
122
+ updated(changed) {
123
+ if (changed.has("error")) this.toggleAttribute("invalid", Boolean(this.error));
124
+ }
125
+ };
126
+ customElements.define("impkt-checkbox-group", ImpktCheckboxGroup);
127
+
128
+ export {
129
+ ImpktCheckboxGroup
130
+ };
131
+ //# sourceMappingURL=chunk-Z4KZG2E3.js.map