@atomic-ui/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -2
- package/dist/base/FieldElement.d.ts +95 -0
- package/dist/base/ImpktElement.d.ts +21 -0
- package/dist/base/styles.d.ts +42 -0
- package/dist/base/tokens.d.ts +68 -0
- package/dist/chunk-26CSJMXY.js +122 -0
- package/dist/chunk-26CSJMXY.js.map +1 -0
- package/dist/chunk-3LFXWUOU.js +86 -0
- package/dist/chunk-3LFXWUOU.js.map +1 -0
- package/dist/chunk-43V4RFK4.js +94 -0
- package/dist/chunk-43V4RFK4.js.map +1 -0
- package/dist/chunk-4P3FLJZG.js +77 -0
- package/dist/chunk-4P3FLJZG.js.map +1 -0
- package/dist/chunk-5NBYZ5UC.js +164 -0
- package/dist/chunk-5NBYZ5UC.js.map +1 -0
- package/dist/chunk-BM73FVQ4.js +153 -0
- package/dist/chunk-BM73FVQ4.js.map +1 -0
- package/dist/chunk-CNFIYRPA.js +67 -0
- package/dist/chunk-CNFIYRPA.js.map +1 -0
- package/dist/chunk-G6X62CFC.js +713 -0
- package/dist/chunk-G6X62CFC.js.map +1 -0
- package/dist/chunk-M3WQZDWU.js +138 -0
- package/dist/chunk-M3WQZDWU.js.map +1 -0
- package/dist/chunk-O72RTRIJ.js +132 -0
- package/dist/chunk-O72RTRIJ.js.map +1 -0
- package/dist/chunk-OZNQ4GAR.js +159 -0
- package/dist/chunk-OZNQ4GAR.js.map +1 -0
- package/dist/chunk-PV4GMCP6.js +90 -0
- package/dist/chunk-PV4GMCP6.js.map +1 -0
- package/dist/chunk-QAKFGIOO.js +104 -0
- package/dist/chunk-QAKFGIOO.js.map +1 -0
- package/dist/chunk-RYJQKKJ4.js +133 -0
- package/dist/chunk-RYJQKKJ4.js.map +1 -0
- package/dist/chunk-SHGQMQXS.js +97 -0
- package/dist/chunk-SHGQMQXS.js.map +1 -0
- package/dist/chunk-TWCXYY4Z.js +83 -0
- package/dist/chunk-TWCXYY4Z.js.map +1 -0
- package/dist/chunk-UTL446G6.js +107 -0
- package/dist/chunk-UTL446G6.js.map +1 -0
- package/dist/chunk-VF6PNIPS.js +164 -0
- package/dist/chunk-VF6PNIPS.js.map +1 -0
- package/dist/chunk-VKQGLSDT.js +124 -0
- package/dist/chunk-VKQGLSDT.js.map +1 -0
- package/dist/chunk-WAB4TRB2.js +141 -0
- package/dist/chunk-WAB4TRB2.js.map +1 -0
- package/dist/chunk-WC5KO6KZ.js +44 -0
- package/dist/chunk-WC5KO6KZ.js.map +1 -0
- package/dist/chunk-YXHT3ZJU.js +81 -0
- package/dist/chunk-YXHT3ZJU.js.map +1 -0
- package/dist/components/accordion.d.ts +66 -0
- package/dist/components/accordion.js +8 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +49 -0
- package/dist/components/alert.js +8 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/button.d.ts +70 -0
- package/dist/components/button.js +8 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/checkbox-group.d.ts +79 -0
- package/dist/components/checkbox-group.js +9 -0
- package/dist/components/checkbox-group.js.map +1 -0
- package/dist/components/checkbox.d.ts +64 -0
- package/dist/components/checkbox.js +9 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/date-input.d.ts +95 -0
- package/dist/components/date-input.js +9 -0
- package/dist/components/date-input.js.map +1 -0
- package/dist/components/dialog.d.ts +61 -0
- package/dist/components/dialog.js +8 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/grid.d.ts +34 -0
- package/dist/components/grid.js +8 -0
- package/dist/components/grid.js.map +1 -0
- package/dist/components/help.d.ts +103 -0
- package/dist/components/help.js +8 -0
- package/dist/components/help.js.map +1 -0
- package/dist/components/layout.d.ts +100 -0
- package/dist/components/layout.js +14 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/link.d.ts +46 -0
- package/dist/components/link.js +8 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/media.d.ts +164 -0
- package/dist/components/media.js +12 -0
- package/dist/components/media.js.map +1 -0
- package/dist/components/price.d.ts +67 -0
- package/dist/components/price.js +8 -0
- package/dist/components/price.js.map +1 -0
- package/dist/components/progress.d.ts +50 -0
- package/dist/components/progress.js +8 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +82 -0
- package/dist/components/radio-group.js +9 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/select.d.ts +74 -0
- package/dist/components/select.js +9 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/summary-list.d.ts +47 -0
- package/dist/components/summary-list.js +8 -0
- package/dist/components/summary-list.js.map +1 -0
- package/dist/components/table.d.ts +49 -0
- package/dist/components/table.js +8 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/text-input.d.ts +80 -0
- package/dist/components/text-input.js +9 -0
- package/dist/components/text-input.js.map +1 -0
- package/dist/components/textarea.d.ts +59 -0
- package/dist/components/textarea.js +9 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
package/README.md
CHANGED
|
@@ -1,3 +1,135 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @atomic-ui/ui
|
|
2
2
|
|
|
3
|
-
|
|
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,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
ImpktElement,
|
|
4
|
+
b,
|
|
5
|
+
focusRing,
|
|
6
|
+
fontSize,
|
|
7
|
+
fontWeight,
|
|
8
|
+
i,
|
|
9
|
+
space,
|
|
10
|
+
t
|
|
11
|
+
} from "./chunk-G6X62CFC.js";
|
|
12
|
+
|
|
13
|
+
// packages/ui/src/components/summary-list.ts
|
|
14
|
+
var ImpktSummaryList = class extends ImpktElement {
|
|
15
|
+
static {
|
|
16
|
+
this.properties = {
|
|
17
|
+
rows: { type: Array },
|
|
18
|
+
changeText: { type: String, attribute: "change-text" }
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.rows = [];
|
|
24
|
+
this.changeText = "Change";
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.styles = [
|
|
28
|
+
...ImpktElement.styles,
|
|
29
|
+
focusRing,
|
|
30
|
+
i`
|
|
31
|
+
:host {
|
|
32
|
+
display: block;
|
|
33
|
+
}
|
|
34
|
+
dl {
|
|
35
|
+
margin: 0;
|
|
36
|
+
display: grid;
|
|
37
|
+
grid-template-columns: minmax(8rem, 1fr) 2fr;
|
|
38
|
+
}
|
|
39
|
+
/* A <dl> group may hold only dt and dd — not a third sibling — so the
|
|
40
|
+
action lives inside the value it changes, which is also where it
|
|
41
|
+
belongs semantically. The row uses display:contents so both cells stay
|
|
42
|
+
in the parent grid. */
|
|
43
|
+
.row {
|
|
44
|
+
display: contents;
|
|
45
|
+
}
|
|
46
|
+
dt,
|
|
47
|
+
dd {
|
|
48
|
+
padding: ${space(3)} 0;
|
|
49
|
+
border-block-end: ${t.borderThin} solid ${t.border};
|
|
50
|
+
}
|
|
51
|
+
dt {
|
|
52
|
+
font-weight: ${fontWeight("semibold")};
|
|
53
|
+
font-size: ${fontSize("sm")};
|
|
54
|
+
}
|
|
55
|
+
dd {
|
|
56
|
+
margin: 0;
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: baseline;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
gap: ${space(3)};
|
|
61
|
+
}
|
|
62
|
+
dd a {
|
|
63
|
+
flex: none;
|
|
64
|
+
color: ${t.link};
|
|
65
|
+
text-decoration: underline;
|
|
66
|
+
text-underline-offset: 0.2em;
|
|
67
|
+
display: inline-block;
|
|
68
|
+
min-block-size: ${t.targetMin};
|
|
69
|
+
}
|
|
70
|
+
.sr-only {
|
|
71
|
+
position: absolute;
|
|
72
|
+
inline-size: 1px;
|
|
73
|
+
block-size: 1px;
|
|
74
|
+
margin: -1px;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
clip-path: inset(50%);
|
|
77
|
+
white-space: nowrap;
|
|
78
|
+
}
|
|
79
|
+
/* One column on a narrow screen. 1.4.10 Reflow: two columns at 320px
|
|
80
|
+
forces horizontal scrolling, and a summary is read, not scanned
|
|
81
|
+
across. */
|
|
82
|
+
@media (max-width: 30rem) {
|
|
83
|
+
dl {
|
|
84
|
+
grid-template-columns: 1fr;
|
|
85
|
+
}
|
|
86
|
+
dt {
|
|
87
|
+
border-block-end: 0;
|
|
88
|
+
padding-block-end: 0;
|
|
89
|
+
}
|
|
90
|
+
dd {
|
|
91
|
+
padding-block-start: 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
return b`
|
|
99
|
+
<dl part="list">
|
|
100
|
+
${this.rows.map(
|
|
101
|
+
(row) => b`
|
|
102
|
+
<div class="row" part="row">
|
|
103
|
+
<dt part="key">${row.key}</dt>
|
|
104
|
+
<dd part="value">
|
|
105
|
+
<span>${row.value}</span>
|
|
106
|
+
${row.changeHref ? b`<a href=${row.changeHref} part="action"
|
|
107
|
+
>${this.changeText}<span class="sr-only"> ${row.key}</span></a
|
|
108
|
+
>` : A}
|
|
109
|
+
</dd>
|
|
110
|
+
</div>
|
|
111
|
+
`
|
|
112
|
+
)}
|
|
113
|
+
</dl>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
customElements.define("impkt-summary-list", ImpktSummaryList);
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
ImpktSummaryList
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=chunk-26CSJMXY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/summary-list.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 SummaryRow {\n key: string;\n value: string;\n /** Where \"Change\" goes. Omitted rows show no action. */\n changeHref?: string;\n}\n\n/**\n * Key and value pairs — an order summary, a confirmation, a check-your-answers\n * screen.\n *\n * **It is a description list.** `<dl>` with `<dt>` and `<dd>` says these are\n * pairs; a stack of divs says nothing, and a table claims a grid that a\n * two-column list does not have.\n *\n * **Every \"Change\" names what it changes.** The visible text stays short, and\n * the accessible name is completed with visually hidden words, so a reader\n * tabbing through hears \"Change date of birth\" rather than six links all called\n * \"Change\". This is 2.4.4 Link Purpose, and it is the single most common\n * failure on a check-your-answers page.\n\n *\n * @category content\n * @icon list\n */\nexport class ImpktSummaryList extends ImpktElement {\n static properties = {\n rows: { type: Array },\n changeText: { type: String, attribute: 'change-text' },\n };\n\n declare rows: SummaryRow[];\n declare changeText: string;\n\n constructor() {\n super();\n this.rows = [];\n this.changeText = 'Change';\n }\n\n static styles = [\n ...ImpktElement.styles,\n focusRing,\n css`\n :host {\n display: block;\n }\n dl {\n margin: 0;\n display: grid;\n grid-template-columns: minmax(8rem, 1fr) 2fr;\n }\n /* A <dl> group may hold only dt and dd — not a third sibling — so the\n action lives inside the value it changes, which is also where it\n belongs semantically. The row uses display:contents so both cells stay\n in the parent grid. */\n .row {\n display: contents;\n }\n dt,\n dd {\n padding: ${space(3)} 0;\n border-block-end: ${t.borderThin} solid ${t.border};\n }\n dt {\n font-weight: ${fontWeight('semibold')};\n font-size: ${fontSize('sm')};\n }\n dd {\n margin: 0;\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: ${space(3)};\n }\n dd a {\n flex: none;\n color: ${t.link};\n text-decoration: underline;\n text-underline-offset: 0.2em;\n display: inline-block;\n min-block-size: ${t.targetMin};\n }\n .sr-only {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n /* One column on a narrow screen. 1.4.10 Reflow: two columns at 320px\n forces horizontal scrolling, and a summary is read, not scanned\n across. */\n @media (max-width: 30rem) {\n dl {\n grid-template-columns: 1fr;\n }\n dt {\n border-block-end: 0;\n padding-block-end: 0;\n }\n dd {\n padding-block-start: 0;\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n return html`\n <dl part=\"list\">\n ${this.rows.map(\n (row) => html`\n <div class=\"row\" part=\"row\">\n <dt part=\"key\">${row.key}</dt>\n <dd part=\"value\">\n <span>${row.value}</span>\n ${row.changeHref\n ? html`<a href=${row.changeHref} part=\"action\"\n >${this.changeText}<span class=\"sr-only\"> ${row.key}</span></a\n >`\n : nothing}\n </dd>\n </div>\n `,\n )}\n </dl>\n `;\n }\n}\n\ncustomElements.define('impkt-summary-list', ImpktSummaryList);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-summary-list': ImpktSummaryList }\n}\n"],"mappings":";;;;;;;;;;;;;AA8BO,IAAM,mBAAN,cAA+B,aAAa;AAAA,EACjD;AAAA,SAAO,aAAa;AAAA,MAClB,MAAM,EAAE,MAAM,MAAM;AAAA,MACpB,YAAY,EAAE,MAAM,QAAQ,WAAW,cAAc;AAAA,IACvD;AAAA;AAAA,EAKA,cAAc;AACZ,UAAM;AACN,SAAK,OAAO,CAAC;AACb,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA,MACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAkBe,MAAM,CAAC,CAAC;AAAA,4BACC,EAAE,UAAU,UAAU,EAAE,MAAM;AAAA;AAAA;AAAA,uBAGnC,WAAW,UAAU,CAAC;AAAA,qBACxB,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOpB,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,iBAIN,EAAE,IAAI;AAAA;AAAA;AAAA;AAAA,0BAIG,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA2BnC;AAAA;AAAA,EAEA,SAAyB;AACvB,WAAO;AAAA;AAAA,UAED,KAAK,KAAK;AAAA,MACV,CAAC,QAAQ;AAAA;AAAA,+BAEY,IAAI,GAAG;AAAA;AAAA,wBAEd,IAAI,KAAK;AAAA,kBACf,IAAI,aACF,YAAe,IAAI,UAAU;AAAA,yBACxB,KAAK,UAAU,0BAA0B,IAAI,GAAG;AAAA,yBAErD,CAAO;AAAA;AAAA;AAAA;AAAA,IAInB,CAAC;AAAA;AAAA;AAAA,EAGP;AACF;AAEA,eAAe,OAAO,sBAAsB,gBAAgB;","names":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A,
|
|
3
|
+
ImpktElement,
|
|
4
|
+
b,
|
|
5
|
+
focusRing,
|
|
6
|
+
fontWeight,
|
|
7
|
+
i,
|
|
8
|
+
t
|
|
9
|
+
} from "./chunk-G6X62CFC.js";
|
|
10
|
+
|
|
11
|
+
// packages/ui/src/components/help.ts
|
|
12
|
+
var ImpktHelp = class extends ImpktElement {
|
|
13
|
+
static {
|
|
14
|
+
this.properties = {
|
|
15
|
+
mechanismId: { type: String, attribute: "mechanism-id" },
|
|
16
|
+
kind: { type: String, reflect: true },
|
|
17
|
+
href: { type: String },
|
|
18
|
+
label: { type: String },
|
|
19
|
+
detail: { type: String }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.kind = "link";
|
|
25
|
+
this.href = "";
|
|
26
|
+
this.label = "";
|
|
27
|
+
this.detail = "";
|
|
28
|
+
}
|
|
29
|
+
static {
|
|
30
|
+
this.styles = [...ImpktElement.styles, focusRing, i`
|
|
31
|
+
:host { display: block; }
|
|
32
|
+
a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};
|
|
33
|
+
color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }
|
|
34
|
+
a:hover { color: ${t.linkHover}; }
|
|
35
|
+
.contact { margin: 0; }
|
|
36
|
+
.caption { display: block; font-weight: ${fontWeight("semibold")}; }
|
|
37
|
+
/* An address is written one line at a time, and opening hours are often one
|
|
38
|
+
day to a line. Long unbroken values still wrap at 320px (1.4.10). */
|
|
39
|
+
.detail { white-space: pre-line; overflow-wrap: anywhere; }
|
|
40
|
+
`];
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
switch (this.kind) {
|
|
44
|
+
case "phone":
|
|
45
|
+
case "email":
|
|
46
|
+
case "address":
|
|
47
|
+
case "hours":
|
|
48
|
+
return this.renderContact();
|
|
49
|
+
default:
|
|
50
|
+
return this.renderLink();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
renderLink() {
|
|
54
|
+
if (!text(this.label)) return A;
|
|
55
|
+
return b`<a part="link" href=${this.href}>${this.label}</a>`;
|
|
56
|
+
}
|
|
57
|
+
renderContact() {
|
|
58
|
+
const detail = text(this.detail);
|
|
59
|
+
if (!detail) return A;
|
|
60
|
+
const caption = text(this.label);
|
|
61
|
+
const target = contactHref(this.kind, detail);
|
|
62
|
+
const captionId = this.id_("caption");
|
|
63
|
+
const detailId = this.id_("detail");
|
|
64
|
+
const captionPart = caption ? b`<span class="caption" part="label" id=${captionId}>${caption}</span>` : A;
|
|
65
|
+
const detailPart = target ? b`<a part="link" href=${target} aria-labelledby=${caption ? `${captionId} ${detailId}` : A}
|
|
66
|
+
><span class="detail" part="detail" id=${detailId}>${detail}</span></a>` : b`<span class="detail" part="detail">${detail}</span>`;
|
|
67
|
+
return b`<p class="contact" part="contact">${captionPart}${detailPart}</p>`;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function text(value) {
|
|
71
|
+
return typeof value === "string" ? value.trim() : "";
|
|
72
|
+
}
|
|
73
|
+
function contactHref(kind, detail) {
|
|
74
|
+
if (kind === "phone") {
|
|
75
|
+
const digits = detail.replace(/\(0\)/g, "").replace(/[^\d+]/g, "").replace(/(?!^)\+/g, "");
|
|
76
|
+
return /\d/.test(digits) ? `tel:${digits}` : "";
|
|
77
|
+
}
|
|
78
|
+
if (kind === "email") return /^[^\s@]+@[^\s@]+$/.test(detail) ? `mailto:${detail}` : "";
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
customElements.define("impkt-help", ImpktHelp);
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
ImpktHelp
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=chunk-3LFXWUOU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/help.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\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 ImpktHelp extends ImpktElement {\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 = [...ImpktElement.styles, focusRing, css`\n :host { display: block; }\n a { display: inline-flex; align-items: center; min-height: ${t.targetMin}; min-width: ${t.targetMin};\n color: ${t.link}; text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }\n a:hover { color: ${t.linkHover}; }\n .contact { margin: 0; }\n .caption { display: block; font-weight: ${fontWeight('semibold')}; }\n /* An address is written one line at a time, and opening hours are often one\n day to a line. Long unbroken values still wrap at 320px (1.4.10). */\n .detail { white-space: pre-line; overflow-wrap: anywhere; }\n `];\n\n render(): TemplateResult | typeof nothing {\n switch (this.kind) {\n case 'phone':\n case 'email':\n case 'address':\n case 'hours':\n return this.renderContact();\n default:\n // An absent or unrecognised kind keeps the original link behaviour, so\n // a page published before contact details existed renders unchanged.\n return this.renderLink();\n }\n }\n\n private renderLink(): TemplateResult | typeof nothing {\n // Runtime bindings may be absent while data loads, or resolve to blank text.\n // Do not expose an unnamed focusable link in those states.\n if (!text(this.label)) return nothing;\n return html`<a part=\"link\" href=${this.href}>${this.label}</a>`;\n }\n\n private renderContact(): TemplateResult | typeof nothing {\n const detail = text(this.detail);\n // A caption with nothing under it is not help, so neither is drawn.\n if (!detail) return nothing;\n const caption = text(this.label);\n const target = contactHref(this.kind, detail);\n const captionId = this.id_('caption');\n const detailId = this.id_('detail');\n const captionPart = caption\n ? html`<span class=\"caption\" part=\"label\" id=${captionId}>${caption}</span>`\n : nothing;\n const detailPart = target\n ? html`<a part=\"link\" href=${target} aria-labelledby=${caption ? `${captionId} ${detailId}` : nothing}\n ><span class=\"detail\" part=\"detail\" id=${detailId}>${detail}</span></a>`\n : html`<span class=\"detail\" part=\"detail\">${detail}</span>`;\n return html`<p class=\"contact\" part=\"contact\">${captionPart}${detailPart}</p>`;\n }\n}\n\n/** Trimmed text, or empty for anything that is not a string. */\nfunction text(value: unknown): string {\n return typeof value === 'string' ? value.trim() : '';\n}\n\n/**\n * The link a contact detail opens, or empty when it should stay as text.\n *\n * A phone number is reduced to its digits and one leading `+`, and the \"(0)\"\n * that UK numbers print after the country code is dropped, because the\n * separators a reader expects are not dialled. A value with no digits, or an\n * email address without an `@`, stays as plain text. The reader still sees\n * it, and nothing offers to dial or mail something that cannot work.\n */\nfunction contactHref(kind: string, detail: string): string {\n if (kind === 'phone') {\n const digits = detail.replace(/\\(0\\)/g, '').replace(/[^\\d+]/g, '').replace(/(?!^)\\+/g, '');\n return /\\d/.test(digits) ? `tel:${digits}` : '';\n }\n if (kind === 'email') return /^[^\\s@]+@[^\\s@]+$/.test(detail) ? `mailto:${detail}` : '';\n return '';\n}\n\ncustomElements.define('impkt-help', ImpktHelp);\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-help': ImpktHelp }\n}\n"],"mappings":";;;;;;;;;;;AA4DO,IAAM,YAAN,cAAwB,aAAa;AAAA,EAC1C;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,CAAC,GAAG,aAAa,QAAQ,WAAW;AAAA;AAAA,iEAEW,EAAE,SAAS,gBAAgB,EAAE,SAAS;AAAA,eACxF,EAAE,IAAI;AAAA,uBACE,EAAE,SAAS;AAAA;AAAA,8CAEY,WAAW,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA,GAIjE;AAAA;AAAA,EAED,SAA0C;AACxC,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACH,eAAO,KAAK,cAAc;AAAA,MAC5B;AAGE,eAAO,KAAK,WAAW;AAAA,IAC3B;AAAA,EACF;AAAA,EAEQ,aAA8C;AAGpD,QAAI,CAAC,KAAK,KAAK,KAAK,EAAG,QAAO;AAC9B,WAAO,wBAA2B,KAAK,IAAI,IAAI,KAAK,KAAK;AAAA,EAC3D;AAAA,EAEQ,gBAAiD;AACvD,UAAM,SAAS,KAAK,KAAK,MAAM;AAE/B,QAAI,CAAC,OAAQ,QAAO;AACpB,UAAM,UAAU,KAAK,KAAK,KAAK;AAC/B,UAAM,SAAS,YAAY,KAAK,MAAM,MAAM;AAC5C,UAAM,YAAY,KAAK,IAAI,SAAS;AACpC,UAAM,WAAW,KAAK,IAAI,QAAQ;AAClC,UAAM,cAAc,UAChB,0CAA6C,SAAS,IAAI,OAAO,YACjE;AACJ,UAAM,aAAa,SACf,wBAA2B,MAAM,oBAAoB,UAAU,GAAG,SAAS,IAAI,QAAQ,KAAK,CAAO;AAAA,mDACxD,QAAQ,IAAI,MAAM,gBAC7D,uCAA0C,MAAM;AACpD,WAAO,sCAAyC,WAAW,GAAG,UAAU;AAAA,EAC1E;AACF;AAGA,SAAS,KAAK,OAAwB;AACpC,SAAO,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;AACpD;AAWA,SAAS,YAAY,MAAc,QAAwB;AACzD,MAAI,SAAS,SAAS;AACpB,UAAM,SAAS,OAAO,QAAQ,UAAU,EAAE,EAAE,QAAQ,WAAW,EAAE,EAAE,QAAQ,YAAY,EAAE;AACzF,WAAO,KAAK,KAAK,MAAM,IAAI,OAAO,MAAM,KAAK;AAAA,EAC/C;AACA,MAAI,SAAS,QAAS,QAAO,oBAAoB,KAAK,MAAM,IAAI,UAAU,MAAM,KAAK;AACrF,SAAO;AACT;AAEA,eAAe,OAAO,cAAc,SAAS;","names":[]}
|