@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
package/README.md CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
1
+ # @atomic-ui/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Standard custom elements, styled only from design tokens, built to WCAG 2.2 AA.
4
+
5
+ One implementation in Lit; React, Vue and Angular get thin wrappers rather than their
6
+ own components, because an accessible component is mostly behaviour — focus management,
7
+ roving tabindex, live-region timing — and behaviour written three times is wrong in
8
+ three different ways ([ADR 0004](../../docs/decisions/0004-lit-plus-wrappers.md)).
9
+
10
+ ```html
11
+ <link rel="stylesheet" href="@atomic-ui/design-tokens/dist/tokens.css" />
12
+ <script type="module">import '@atomic-ui/ui';</script>
13
+
14
+ <impkt-text-input label="Postcode" description="As on your statement" autocomplete="postal-code"></impkt-text-input>
15
+ <impkt-button variant="primary">Get my price</impkt-button>
16
+ ```
17
+
18
+ In React, from `@atomic-ui/ui-react`:
19
+
20
+ ```tsx
21
+ <TextInput label="Postcode" autocomplete="postal-code" onChange={(e) => set(e.detail.value)} />
22
+ <RadioGroup label="Any returns?" options={[{ value: 'yes', label: 'Yes' }]} />
23
+ ```
24
+
25
+ ## What is here
26
+
27
+ Twenty-four elements.
28
+
29
+ | Group | Elements |
30
+ | --- | --- |
31
+ | Layout and type | `impkt-grid`, `impkt-stack`, `impkt-card`, `impkt-heading`, `impkt-text` |
32
+ | Actions | `impkt-button`, `impkt-link` |
33
+ | Form controls | `impkt-text-input`, `impkt-textarea`, `impkt-select`, `impkt-checkbox`, `impkt-checkbox-group`, `impkt-radio-group`, `impkt-date-input` |
34
+ | Feedback | `impkt-alert`, `impkt-dialog` |
35
+ | Content | `impkt-summary-list`, `impkt-table`, `impkt-accordion`, `impkt-progress`, `impkt-price` |
36
+ | Media | `impkt-image`, `impkt-logo`, `impkt-document-link` |
37
+
38
+ Bindings: [`@atomic-ui/ui-react`](../ui-react), [`@atomic-ui/ui-vue`](../ui-vue),
39
+ [`@atomic-ui/ui-angular`](../ui-angular). Each is thin and each exists for a different
40
+ reason — React needs property binding and typed events, Vue needs the `.` prefix hidden
41
+ and prop types, and Angular needs `ControlValueAccessor` directives, without which a
42
+ reactive form containing one of these controls silently never receives a value.
43
+
44
+ ## The decisions worth knowing
45
+
46
+ **Nothing names a colour.** Components read `var(--impkt-*)` with a fallback, so a brand
47
+ is a content publish rather than a rebuild, and a missing token stylesheet is an
48
+ annoyance rather than a blank page.
49
+
50
+ **The focus ring and the minimum target size are locked tokens.** A brand cannot reach
51
+ them. The ring is two-tone — light inside dark — so it stays visible on any surface a
52
+ partner can produce, and it carries a transparent `outline` behind the `box-shadow`
53
+ because Windows High Contrast Mode drops shadows entirely.
54
+
55
+ **A busy button is not a disabled button.** `disabled` removes an element from the tab
56
+ order, so a keyboard user who just pressed it is thrown to the top of the document at
57
+ the moment something starts happening. Busy keeps focus, reports `aria-disabled` and
58
+ `aria-busy`, and blocks activation in the handler.
59
+
60
+ **The error live region exists before there is an error.** A region inserted together
61
+ with its content is announced inconsistently, and the inconsistency is per screen
62
+ reader — so it passes local testing and fails for users.
63
+
64
+ **`aria-describedby` never crosses a shadow boundary**, which is why a field renders its
65
+ own label, description, control and error in one shadow root rather than slotting the
66
+ input from outside.
67
+
68
+ **Native elements wherever one exists.** The radio group is the clearest case: a set of
69
+ `<input type="radio">` sharing a name already has roving tabindex, arrow keys that wrap,
70
+ Home and End, and the right announcement everywhere. Reimplementing that is the most
71
+ commonly attempted and most commonly botched widget in any design system.
72
+
73
+ ## What the tests actually check
74
+
75
+ Two suites, split by what each can honestly measure.
76
+
77
+ **`pnpm --filter @atomic-ui/ui test`** runs in happy-dom, which has no layout engine. It
78
+ checks what breaks in practice — roles, accessible names, the `describedby`
79
+ relationships resolved to the text a screen reader would read, keyboard behaviour, form
80
+ association — and axe is restricted to the rules that mean anything without layout.
81
+ Running the full rule set here would report passes for colour-contrast and target-size
82
+ that axe never evaluated.
83
+
84
+ **`pnpm --filter @atomic-ui/ui test:browser`** runs the real library in Chromium, bundled
85
+ with esbuild and styled by the real token stylesheet. It answers everything the first
86
+ suite cannot:
87
+
88
+ - the **full** axe rule set, colour contrast and target size included
89
+ - every interactive element at 24×24 (2.5.8), with the criterion's inline-link
90
+ exemption applied narrowly and a second test keeping it narrow
91
+ - no sideways scrolling at 320px (1.4.10 — which is also 1280px at 400% zoom)
92
+ - nothing clipped under the text-spacing overrides (1.4.12)
93
+ - a focus ring that renders, and a boundary that survives forced-colours mode
94
+ - the dialog actually being modal: `:modal` matches, Escape closes it, focus returns
95
+ to the opener, and a non-dismissible dialog refuses Escape
96
+
97
+ Between the two, no criterion is reported as passing without being evaluated.
98
+
99
+ ## The manifest
100
+
101
+ `pnpm --filter @atomic-ui/ui manifest` emits `custom-elements.json` — the intermediate
102
+ the CMS palette is ultimately generated from. It is checked in so the conversion is
103
+ runnable from a fresh clone; the artefact actually *reviewed* is
104
+ [@atomic-ui/ui-manifest](../ui-manifest/README.md)'s `manifest.json`, which is small
105
+ enough to read as a diff.
106
+
107
+ Two tags the Custom Elements Manifest spec has no place for — `@category` and `@icon` —
108
+ are captured by a plugin in `custom-elements-manifest.config.mjs`, so they live on the
109
+ component rather than in a lookup table somewhere else.
110
+
111
+ ## Not here yet
112
+
113
+ Stated plainly, because a component library that looks finished is how gaps ship.
114
+
115
+ - **No manual audit.** Automated checking catches perhaps a third of real issues and
116
+ judges none of them — whether alt text is useful, whether an error message makes
117
+ sense, whether the reading order tells a story. A screen-reader pass happens before
118
+ any brand launches, and nothing here substitutes for it.
119
+ - **One browser.** The browser suite runs Chromium. Firefox and WebKit differ most in
120
+ exactly the places this library leans on the platform — `showModal`, `:focus-visible`,
121
+ forced colours — so they are worth adding before launch.
122
+ - **Server rendering is untested.** Declarative Shadow DOM works, the framework
123
+ integrations are uneven, and an SSR'd page can show unstyled content until hydration.
124
+ Behind a form this is tolerable; a marketing page would feel it.
125
+ - **Composition-level criteria are deliberately elsewhere.** Consistent help (3.2.6),
126
+ redundant entry (3.3.7) and heading order across a page are properties of a page or a
127
+ journey, not of a component — they are checked in Strata at publish
128
+ ([ADR 0009](../../docs/decisions/0009-wcag-is-an-authoring-gate.md)). The browser
129
+ suite found a heading-order failure in its own gallery, which is a fair illustration:
130
+ every component was correct and the page was still wrong.
131
+
132
+ The Grid component supplies one to four columns or either sidebar arrangement. Each
133
+ column has a named slot. It stacks below 40rem of available container width, preserving
134
+ column order. The designer offers these as draggable layout presets and prevents
135
+ removing an occupied column.
@@ -0,0 +1,95 @@
1
+ import { nothing, type TemplateResult } from 'lit';
2
+ import { ImpktElement } from './ImpktElement';
3
+ /**
4
+ * The shared anatomy of a form control: a label, an optional description, a
5
+ * control, and an error.
6
+ *
7
+ * This exists because the ARIA wiring between those four is where accessible
8
+ * forms actually fail, and it fails the same way every time — a description
9
+ * that is never announced, an error that appears silently, a label that points
10
+ * at nothing. Written once, it is right once.
11
+ *
12
+ * Everything is rendered inside this component's own shadow root, including
13
+ * the native control. That is not an implementation detail: `aria-describedby`
14
+ * cannot cross a shadow boundary, so a component that slotted the input from
15
+ * outside could not describe it. Keeping the whole relationship in one tree is
16
+ * what makes the wiring work at all.
17
+ */
18
+ export declare abstract class FieldElement extends ImpktElement {
19
+ /** Form controls participate in a `<form>` like native ones. */
20
+ static formAssociated: boolean;
21
+ static properties: {
22
+ label: {
23
+ type: StringConstructor;
24
+ };
25
+ name: {
26
+ type: StringConstructor;
27
+ };
28
+ value: {
29
+ type: StringConstructor;
30
+ };
31
+ description: {
32
+ type: StringConstructor;
33
+ };
34
+ error: {
35
+ type: StringConstructor;
36
+ };
37
+ required: {
38
+ type: BooleanConstructor;
39
+ reflect: boolean;
40
+ };
41
+ disabled: {
42
+ type: BooleanConstructor;
43
+ reflect: boolean;
44
+ };
45
+ readonly: {
46
+ type: BooleanConstructor;
47
+ reflect: boolean;
48
+ };
49
+ requiredText: {
50
+ type: StringConstructor;
51
+ attribute: string;
52
+ };
53
+ };
54
+ label: string;
55
+ name: string;
56
+ value: string;
57
+ description: string;
58
+ error: string;
59
+ required: boolean;
60
+ disabled: boolean;
61
+ readonly: boolean;
62
+ /**
63
+ * How "you must answer this" is said.
64
+ *
65
+ * Words, not an asterisk. 3.3.2 asks for labels or instructions, and an
66
+ * asterisk is neither until a legend explains it — which puts the
67
+ * explanation somewhere other than the field it explains. It is a property
68
+ * so a partner can reword it, not so they can empty it.
69
+ */
70
+ requiredText: string;
71
+ protected internals: ElementInternals | null;
72
+ constructor();
73
+ static styles: import("lit").CSSResult[];
74
+ protected get controlId(): string;
75
+ /**
76
+ * What the control points `aria-describedby` at.
77
+ *
78
+ * The error id is included only while there is an error. A describedby that
79
+ * always names an empty element trains a screen-reader user to expect
80
+ * nothing after the description, and then the one time it matters they have
81
+ * already learned to ignore it.
82
+ */
83
+ protected get describedBy(): string | typeof nothing;
84
+ /** Subclasses render the control itself; everything round it is here. */
85
+ protected abstract renderControl(): TemplateResult;
86
+ /**
87
+ * `<label for>` by default. A group of controls — radios, checkboxes —
88
+ * cannot use one, because `for` names a single control, so those override
89
+ * this and render a `<fieldset>` and `<legend>` instead.
90
+ */
91
+ protected renderLabel(): TemplateResult;
92
+ render(): TemplateResult;
93
+ /** Keep the form value in step with the control. */
94
+ protected setFormValue(value: string): void;
95
+ }
@@ -0,0 +1,21 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * The base every Impkt component extends.
4
+ *
5
+ * It carries the two style fragments that are not a per-component choice — the
6
+ * reset and the reduced-motion rule — and a stable id generator for the ARIA
7
+ * wiring. It deliberately carries nothing else: a base class that grows
8
+ * behaviour becomes the place every component's exceptions are negotiated.
9
+ */
10
+ export declare class ImpktElement extends LitElement {
11
+ static styles: import("lit").CSSResult[];
12
+ /**
13
+ * A unique id for this instance, for `aria-describedby` and friends.
14
+ *
15
+ * Generated once in the constructor rather than in `render`, because an id
16
+ * that changes between renders breaks the relationship it exists to express
17
+ * — and it breaks it silently, since the markup still looks correct.
18
+ */
19
+ protected readonly uid: string;
20
+ protected id_(part: string): string;
21
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The focus ring.
3
+ *
4
+ * `:focus-visible` rather than `:focus`, so a mouse click on a button does not
5
+ * draw a ring the user did not ask for while keyboard focus still does.
6
+ *
7
+ * The ring is two-tone — a light inner band inside a dark outer one — drawn
8
+ * with `box-shadow` and a transparent `outline` behind it. The outline is not
9
+ * decoration: it is what survives Windows High Contrast Mode, where box-shadow
10
+ * is dropped entirely and a shadow-only ring disappears for exactly the users
11
+ * who most need it.
12
+ *
13
+ * The colours come from locked tokens a brand cannot reach
14
+ * ([ADR 0010](../../../../docs/decisions/0010-what-a-brand-may-set.md)).
15
+ */
16
+ export declare const focusRing: import("lit").CSSResult;
17
+ /**
18
+ * WCAG 2.2, 2.5.8 Target Size (Minimum): 24 by 24 CSS pixels.
19
+ *
20
+ * Applied as a minimum rather than a fixed size so a control grows with its
21
+ * content and never shrinks below the floor. It reads the locked token, which
22
+ * is deliberately outside the spacing scale — otherwise a brand tightening its
23
+ * spacing unit would shrink every tap target with it.
24
+ */
25
+ export declare const targetSize: import("lit").CSSResult;
26
+ /**
27
+ * Visible to a screen reader, invisible on screen.
28
+ *
29
+ * `clip-path` with a 1px box rather than `display: none` or `visibility:
30
+ * hidden`, both of which remove the text from the accessibility tree — which
31
+ * is the one thing this must not do.
32
+ */
33
+ export declare const visuallyHidden: import("lit").CSSResult;
34
+ /**
35
+ * 2.3.3 Animation from Interactions, and plain decency.
36
+ *
37
+ * `0.01ms` rather than `0` because a zero-duration transition does not fire a
38
+ * `transitionend` event in every engine, and components that wait for one hang.
39
+ */
40
+ export declare const reducedMotion: import("lit").CSSResult;
41
+ /** The base every component starts from. */
42
+ export declare const base: import("lit").CSSResult;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Token helpers.
3
+ *
4
+ * Components never name a colour, a size or a radius. They name a token, and a
5
+ * brand decides what it holds — which is what makes a rebrand a content
6
+ * publish rather than a rebuild
7
+ * ([ADR 0005](../../../../docs/decisions/0005-design-tokens.md)).
8
+ *
9
+ * Every reference carries a fallback so that a component dropped onto a page
10
+ * with no token stylesheet still renders something legible. An unstyled
11
+ * component is indistinguishable from a broken one, and the fallback is what
12
+ * keeps a missing stylesheet a visible annoyance rather than a blank screen.
13
+ *
14
+ * These return `CSSResult` rather than strings. Lit's `css` tag refuses plain
15
+ * interpolated strings, which is a deliberate guard against injecting
16
+ * attacker-controlled text into a stylesheet; `unsafeCSS` is the documented
17
+ * way past it and is safe here because every value is a literal in this file,
18
+ * never anything authored or fetched.
19
+ */
20
+ import { type CSSResult } from 'lit';
21
+ /** `color.brand.default` → `var(--impkt-color-brand-default, <fallback>)`. */
22
+ export declare const token: (path: string, fallback: string) => CSSResult;
23
+ export declare const t: {
24
+ readonly brand: CSSResult;
25
+ readonly brandHover: CSSResult;
26
+ readonly brandActive: CSSResult;
27
+ readonly brandSubtle: CSSResult;
28
+ readonly onBrand: CSSResult;
29
+ readonly surfaceCard: CSSResult;
30
+ readonly surfaceInset: CSSResult;
31
+ readonly surfaceSubtle: CSSResult;
32
+ readonly text: CSSResult;
33
+ readonly textMuted: CSSResult;
34
+ readonly textPlaceholder: CSSResult;
35
+ readonly textHeading: CSSResult;
36
+ readonly link: CSSResult;
37
+ readonly linkHover: CSSResult;
38
+ readonly border: CSSResult;
39
+ readonly borderStrong: CSSResult;
40
+ readonly danger: CSSResult;
41
+ readonly dangerText: CSSResult;
42
+ readonly dangerSubtle: CSSResult;
43
+ readonly warning: CSSResult;
44
+ readonly warningText: CSSResult;
45
+ readonly warningSubtle: CSSResult;
46
+ readonly success: CSSResult;
47
+ readonly successText: CSSResult;
48
+ readonly successSubtle: CSSResult;
49
+ readonly info: CSSResult;
50
+ readonly infoText: CSSResult;
51
+ readonly infoSubtle: CSSResult;
52
+ readonly fontBody: CSSResult;
53
+ readonly fontHeading: CSSResult;
54
+ readonly focusShadow: CSSResult;
55
+ readonly focusOffset: CSSResult;
56
+ readonly targetMin: CSSResult;
57
+ readonly radiusSm: CSSResult;
58
+ readonly radius: CSSResult;
59
+ readonly radiusLg: CSSResult;
60
+ readonly borderThin: CSSResult;
61
+ readonly borderThick: CSSResult;
62
+ };
63
+ /** `space.3` → the custom property. Spacing is always a token, never a number. */
64
+ export declare const space: (step: number) => CSSResult;
65
+ /** `font.size.lg` → the custom property. */
66
+ export declare const fontSize: (name: string) => CSSResult;
67
+ export declare const lineHeight: (name: string) => CSSResult;
68
+ export declare const fontWeight: (name: string) => CSSResult;
@@ -0,0 +1,43 @@
1
+ import {
2
+ ImpktElement,
3
+ space
4
+ } from "./chunk-J5KAMJ2N.js";
5
+
6
+ // packages/ui/src/components/grid.ts
7
+ import { css, html } from "lit";
8
+ var ImpktGrid = class extends ImpktElement {
9
+ static {
10
+ this.properties = { columns: { type: String, reflect: true }, gap: { type: String, reflect: true } };
11
+ }
12
+ constructor() {
13
+ super();
14
+ this.columns = "two";
15
+ this.gap = "md";
16
+ }
17
+ static {
18
+ this.styles = [...ImpktElement.styles, css`
19
+ :host { display: block; min-inline-size: 0; container-type: inline-size; }
20
+ .columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${space(4)}; }
21
+ :host([gap='sm']) .columns { gap: ${space(2)}; }
22
+ :host([gap='lg']) .columns { gap: ${space(6)}; }
23
+ :host([columns='one']) .columns { grid-template-columns: minmax(0, 1fr); }
24
+ :host([columns='three']) .columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
25
+ :host([columns='four']) .columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
26
+ :host([columns='sidebar-left']) .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
27
+ :host([columns='sidebar-right']) .columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
28
+ .column { min-inline-size: 0; overflow-wrap: anywhere; }
29
+ ::slotted(*) { max-inline-size: 100%; }
30
+ @container (max-width: 40rem) { .columns { grid-template-columns: minmax(0, 1fr) !important; } }
31
+ `];
32
+ }
33
+ render() {
34
+ const count = this.columns === "one" ? 1 : this.columns === "three" ? 3 : this.columns === "four" ? 4 : 2;
35
+ return html`<div class="columns" part="row">${Array.from({ length: count }, (_, i) => html`<div class="column" part="column"><slot name=${`column-${i + 1}`}></slot></div>`)}</div>`;
36
+ }
37
+ };
38
+ customElements.define("impkt-grid", ImpktGrid);
39
+
40
+ export {
41
+ ImpktGrid
42
+ };
43
+ //# sourceMappingURL=chunk-4YAA7EML.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/grid.ts"],"sourcesContent":["import { css, html } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { space } from '../base/tokens';\n\n/**\n * A responsive row with named column slots. Child order stays inside each\n * column; changing a page's visual grid never reorders its reading sequence.\n *\n * @category layout\n * @icon columns\n * @slot column-1 - First column.\n * @slot column-2 - Second column.\n * @slot column-3 - Third column.\n * @slot column-4 - Fourth column.\n */\nexport class ImpktGrid extends ImpktElement {\n static properties = { columns: { type: String, reflect: true }, gap: { type: String, reflect: true } };\n declare columns: 'one' | 'two' | 'three' | 'four' | 'sidebar-left' | 'sidebar-right';\n declare gap: 'sm' | 'md' | 'lg';\n constructor() { super(); this.columns = 'two'; this.gap = 'md'; }\n static styles = [...ImpktElement.styles, css`\n :host { display: block; min-inline-size: 0; container-type: inline-size; }\n .columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${space(4)}; }\n :host([gap='sm']) .columns { gap: ${space(2)}; }\n :host([gap='lg']) .columns { gap: ${space(6)}; }\n :host([columns='one']) .columns { grid-template-columns: minmax(0, 1fr); }\n :host([columns='three']) .columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }\n :host([columns='four']) .columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }\n :host([columns='sidebar-left']) .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }\n :host([columns='sidebar-right']) .columns { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }\n .column { min-inline-size: 0; overflow-wrap: anywhere; }\n ::slotted(*) { max-inline-size: 100%; }\n @container (max-width: 40rem) { .columns { grid-template-columns: minmax(0, 1fr) !important; } }\n `];\n render() {\n const count = this.columns === 'one' ? 1 : this.columns === 'three' ? 3 : this.columns === 'four' ? 4 : 2;\n return html`<div class=\"columns\" part=\"row\">${Array.from({ length: count }, (_, i) => html`<div class=\"column\" part=\"column\"><slot name=${`column-${i+1}`}></slot></div>`)}</div>`;\n }\n}\ncustomElements.define('impkt-grid', ImpktGrid);\ndeclare global { interface HTMLElementTagNameMap { 'impkt-grid': ImpktGrid } }\n"],"mappings":";;;;;;AAAA,SAAS,KAAK,YAAY;AAenB,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;AAAA,SAAO,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,QAAQ,SAAS,KAAK,EAAE;AAAA;AAAA,EAGrG,cAAc;AAAE,UAAM;AAAG,SAAK,UAAU;AAAO,SAAK,MAAM;AAAA,EAAM;AAAA,EAChE;AAAA,SAAO,SAAS,CAAC,GAAG,aAAa,QAAQ;AAAA;AAAA,uFAE4C,MAAM,CAAC,CAAC;AAAA,wCACvD,MAAM,CAAC,CAAC;AAAA,wCACR,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAS7C;AAAA;AAAA,EACD,SAAS;AACP,UAAM,QAAQ,KAAK,YAAY,QAAQ,IAAI,KAAK,YAAY,UAAU,IAAI,KAAK,YAAY,SAAS,IAAI;AACxG,WAAO,uCAAuC,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,CAAC,GAAG,MAAM,oDAAoD,UAAU,IAAE,CAAC,EAAE,gBAAgB,CAAC;AAAA,EAC5K;AACF;AACA,eAAe,OAAO,cAAc,SAAS;","names":[]}
@@ -0,0 +1,162 @@
1
+ import {
2
+ ImpktElement,
3
+ focusRing,
4
+ fontSize,
5
+ fontWeight,
6
+ lineHeight,
7
+ space,
8
+ t,
9
+ visuallyHidden
10
+ } from "./chunk-J5KAMJ2N.js";
11
+
12
+ // packages/ui/src/base/FieldElement.ts
13
+ import { html, css, nothing } from "lit";
14
+ var FieldElement = class extends ImpktElement {
15
+ constructor() {
16
+ super();
17
+ this.internals = null;
18
+ this.label = "";
19
+ this.name = "";
20
+ this.value = "";
21
+ this.description = "";
22
+ this.error = "";
23
+ this.required = false;
24
+ this.disabled = false;
25
+ this.readonly = false;
26
+ this.requiredText = "required";
27
+ try {
28
+ this.internals = this.attachInternals();
29
+ } catch {
30
+ this.internals = null;
31
+ }
32
+ }
33
+ static {
34
+ /** Form controls participate in a `<form>` like native ones. */
35
+ this.formAssociated = true;
36
+ }
37
+ static {
38
+ this.properties = {
39
+ label: { type: String },
40
+ name: { type: String },
41
+ value: { type: String },
42
+ description: { type: String },
43
+ error: { type: String },
44
+ required: { type: Boolean, reflect: true },
45
+ disabled: { type: Boolean, reflect: true },
46
+ readonly: { type: Boolean, reflect: true },
47
+ requiredText: { type: String, attribute: "required-text" }
48
+ };
49
+ }
50
+ static {
51
+ this.styles = [
52
+ ...ImpktElement.styles,
53
+ focusRing,
54
+ css`
55
+ :host {
56
+ display: block;
57
+ margin-block-end: ${space(4)};
58
+ }
59
+ .label {
60
+ display: block;
61
+ font-size: ${fontSize("sm")};
62
+ font-weight: ${fontWeight("semibold")};
63
+ line-height: ${lineHeight("normal")};
64
+ margin-block-end: ${space(1)};
65
+ color: ${t.text};
66
+ }
67
+ .required {
68
+ font-weight: ${fontWeight("regular")};
69
+ color: ${t.textMuted};
70
+ }
71
+ .description {
72
+ font-size: ${fontSize("sm")};
73
+ line-height: ${lineHeight("normal")};
74
+ color: ${t.textMuted};
75
+ margin-block-end: ${space(2)};
76
+ }
77
+ .error {
78
+ font-size: ${fontSize("sm")};
79
+ line-height: ${lineHeight("normal")};
80
+ color: ${t.dangerText};
81
+ margin-block-start: ${space(1)};
82
+ display: flex;
83
+ gap: ${space(1)};
84
+ }
85
+ .error:empty {
86
+ display: none;
87
+ }
88
+ .visually-hidden {
89
+ ${visuallyHidden}
90
+ }
91
+ :host([disabled]) {
92
+ opacity: 0.6;
93
+ }
94
+ `
95
+ ];
96
+ }
97
+ get controlId() {
98
+ return this.id_("control");
99
+ }
100
+ /**
101
+ * What the control points `aria-describedby` at.
102
+ *
103
+ * The error id is included only while there is an error. A describedby that
104
+ * always names an empty element trains a screen-reader user to expect
105
+ * nothing after the description, and then the one time it matters they have
106
+ * already learned to ignore it.
107
+ */
108
+ get describedBy() {
109
+ const ids = [
110
+ this.description ? this.id_("description") : "",
111
+ this.error ? this.id_("error") : ""
112
+ ].filter(Boolean);
113
+ return ids.length ? ids.join(" ") : nothing;
114
+ }
115
+ /**
116
+ * `<label for>` by default. A group of controls — radios, checkboxes —
117
+ * cannot use one, because `for` names a single control, so those override
118
+ * this and render a `<fieldset>` and `<legend>` instead.
119
+ */
120
+ renderLabel() {
121
+ return html`
122
+ <label class="label" for=${this.controlId} part="label">
123
+ ${this.label}${this.required ? html`<span class="required"> (${this.requiredText})</span>` : nothing}
124
+ </label>
125
+ `;
126
+ }
127
+ render() {
128
+ return html`
129
+ ${this.renderLabel()}
130
+ ${this.description ? html`<div class="description" id=${this.id_("description")} part="description">
131
+ ${this.description}
132
+ </div>` : nothing}
133
+ ${this.renderControl()}
134
+ <!--
135
+ The error region is always present, even when empty. A live region
136
+ inserted at the same moment as its content is announced unreliably
137
+ across screen readers; one that already exists and is then filled is
138
+ announced consistently. "polite" rather than "assertive" because a
139
+ validation message should not interrupt what is being read.
140
+ -->
141
+ <div
142
+ class="error"
143
+ id=${this.id_("error")}
144
+ part="error"
145
+ aria-live="polite"
146
+ >
147
+ ${this.error || nothing}
148
+ </div>
149
+ `;
150
+ }
151
+ /** Keep the form value in step with the control. */
152
+ setFormValue(value) {
153
+ this.value = value;
154
+ this.internals?.setFormValue(value);
155
+ this.dispatchEvent(new CustomEvent("impkt-change", { detail: { value }, bubbles: true, composed: true }));
156
+ }
157
+ };
158
+
159
+ export {
160
+ FieldElement
161
+ };
162
+ //# sourceMappingURL=chunk-6HZA6A3L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/base/FieldElement.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from './ImpktElement';\nimport { focusRing, visuallyHidden } from './styles';\nimport { fontSize, fontWeight, lineHeight, space, t } from './tokens';\n\n/**\n * The shared anatomy of a form control: a label, an optional description, a\n * control, and an error.\n *\n * This exists because the ARIA wiring between those four is where accessible\n * forms actually fail, and it fails the same way every time — a description\n * that is never announced, an error that appears silently, a label that points\n * at nothing. Written once, it is right once.\n *\n * Everything is rendered inside this component's own shadow root, including\n * the native control. That is not an implementation detail: `aria-describedby`\n * cannot cross a shadow boundary, so a component that slotted the input from\n * outside could not describe it. Keeping the whole relationship in one tree is\n * what makes the wiring work at all.\n */\nexport abstract class FieldElement extends ImpktElement {\n /** Form controls participate in a `<form>` like native ones. */\n static formAssociated = true;\n\n static properties = {\n label: { type: String },\n name: { type: String },\n value: { type: String },\n description: { type: String },\n error: { type: String },\n required: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n readonly: { type: Boolean, reflect: true },\n requiredText: { type: String, attribute: 'required-text' },\n };\n\n declare label: string;\n declare name: string;\n declare value: string;\n declare description: string;\n declare error: string;\n declare required: boolean;\n declare disabled: boolean;\n declare readonly: boolean;\n /**\n * How \"you must answer this\" is said.\n *\n * Words, not an asterisk. 3.3.2 asks for labels or instructions, and an\n * asterisk is neither until a legend explains it — which puts the\n * explanation somewhere other than the field it explains. It is a property\n * so a partner can reword it, not so they can empty it.\n */\n declare requiredText: string;\n\n protected internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this.label = '';\n this.name = '';\n this.value = '';\n this.description = '';\n this.error = '';\n this.required = false;\n this.disabled = false;\n this.readonly = false;\n this.requiredText = 'required';\n // happy-dom and older engines do not implement attachInternals. A control\n // that cannot associate with a form is still a usable control, so this\n // degrades rather than throwing on construction.\n try {\n this.internals = this.attachInternals();\n } catch {\n this.internals = null;\n }\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n margin-block-end: ${space(4)};\n }\n .label {\n display: block;\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('semibold')};\n line-height: ${lineHeight('normal')};\n margin-block-end: ${space(1)};\n color: ${t.text};\n }\n .required {\n font-weight: ${fontWeight('regular')};\n color: ${t.textMuted};\n }\n .description {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.textMuted};\n margin-block-end: ${space(2)};\n }\n .error {\n font-size: ${fontSize('sm')};\n line-height: ${lineHeight('normal')};\n color: ${t.dangerText};\n margin-block-start: ${space(1)};\n display: flex;\n gap: ${space(1)};\n }\n .error:empty {\n display: none;\n }\n .visually-hidden {\n ${visuallyHidden}\n }\n :host([disabled]) {\n opacity: 0.6;\n }\n `,\n ];\n\n protected get controlId(): string {\n return this.id_('control');\n }\n\n /**\n * What the control points `aria-describedby` at.\n *\n * The error id is included only while there is an error. A describedby that\n * always names an empty element trains a screen-reader user to expect\n * nothing after the description, and then the one time it matters they have\n * already learned to ignore it.\n */\n protected get describedBy(): string | typeof nothing {\n const ids = [\n this.description ? this.id_('description') : '',\n this.error ? this.id_('error') : '',\n ].filter(Boolean);\n return ids.length ? ids.join(' ') : nothing;\n }\n\n /** Subclasses render the control itself; everything round it is here. */\n protected abstract renderControl(): TemplateResult;\n\n /**\n * `<label for>` by default. A group of controls — radios, checkboxes —\n * cannot use one, because `for` names a single control, so those override\n * this and render a `<fieldset>` and `<legend>` instead.\n */\n protected renderLabel(): TemplateResult {\n return html`\n <label class=\"label\" for=${this.controlId} part=\"label\">\n ${this.label}${this.required\n ? html`<span class=\"required\"> (${this.requiredText})</span>`\n : nothing}\n </label>\n `;\n }\n\n render(): TemplateResult {\n return html`\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 <!--\n The error region is always present, even when empty. A live region\n inserted at the same moment as its content is announced unreliably\n across screen readers; one that already exists and is then filled is\n announced consistently. \"polite\" rather than \"assertive\" because a\n validation message should not interrupt what is being read.\n -->\n <div\n class=\"error\"\n id=${this.id_('error')}\n part=\"error\"\n aria-live=\"polite\"\n >\n ${this.error || nothing}\n </div>\n `;\n }\n\n /** Keep the form value in step with the control. */\n protected setFormValue(value: string): void {\n this.value = value;\n this.internals?.setFormValue(value);\n this.dispatchEvent(new CustomEvent('impkt-change', { detail: { value }, bubbles: true, composed: true }));\n }\n}\n"],"mappings":"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","names":[]}