@atomic-ui/ui 0.1.7 → 0.3.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 +82 -95
- package/custom-elements.json +25364 -0
- package/dist/base/FieldElement.d.ts +11 -0
- package/dist/base/ImpktElement.d.ts +14 -0
- package/dist/base/locale.d.ts +8 -0
- package/dist/base/say.d.ts +1 -0
- package/dist/base/scroll-lock.d.ts +2 -0
- package/dist/base/styles.d.ts +25 -6
- package/dist/base/tokens.d.ts +5 -1
- package/dist/chunk-2YRTFWW2.js +26 -0
- package/dist/chunk-2YRTFWW2.js.map +1 -0
- package/dist/{chunk-X7IPZPTG.js → chunk-37PA72FC.js} +34 -19
- package/dist/chunk-37PA72FC.js.map +1 -0
- package/dist/chunk-3IGNZTJU.js +14 -0
- package/dist/chunk-3IGNZTJU.js.map +1 -0
- package/dist/{chunk-NTNXHLTM.js → chunk-3KO55PZK.js} +47 -2
- package/dist/chunk-3KO55PZK.js.map +1 -0
- package/dist/chunk-3RE4H2XO.js +53 -0
- package/dist/chunk-3RE4H2XO.js.map +1 -0
- package/dist/{chunk-5EA4IDUD.js → chunk-46BYUQ5A.js} +2 -2
- package/dist/{chunk-WECSVHIM.js → chunk-4OYHT4BN.js} +7 -3
- package/dist/chunk-4OYHT4BN.js.map +1 -0
- package/dist/{chunk-4HU4Y23Q.js → chunk-55DK75QF.js} +6 -4
- package/dist/chunk-55DK75QF.js.map +1 -0
- package/dist/{chunk-XVKEM5JY.js → chunk-5QSTXIPG.js} +2 -2
- package/dist/{chunk-QCNT7D5V.js → chunk-7P4Z4CLK.js} +63 -20
- package/dist/chunk-7P4Z4CLK.js.map +1 -0
- package/dist/{chunk-GSCVG2ER.js → chunk-APJ5JGRW.js} +3 -3
- package/dist/chunk-AUVIOU5G.js +522 -0
- package/dist/chunk-AUVIOU5G.js.map +1 -0
- package/dist/{chunk-6ICOJPMD.js → chunk-CUUBAETM.js} +4 -3
- package/dist/chunk-CUUBAETM.js.map +1 -0
- package/dist/{chunk-NQKYHILD.js → chunk-DAH7RLW3.js} +3 -3
- package/dist/{chunk-OB7LC6NJ.js → chunk-DJEZW7AC.js} +2 -2
- package/dist/{chunk-XJP45LFA.js → chunk-DKZ425AM.js} +15 -5
- package/dist/chunk-DKZ425AM.js.map +1 -0
- package/dist/{chunk-GO2IBRFP.js → chunk-F4YQWKK2.js} +7 -4
- package/dist/chunk-F4YQWKK2.js.map +1 -0
- package/dist/chunk-FVCM4WHD.js +328 -0
- package/dist/chunk-FVCM4WHD.js.map +1 -0
- package/dist/chunk-GBRML4RF.js +264 -0
- package/dist/chunk-GBRML4RF.js.map +1 -0
- package/dist/{chunk-ZQJD4YEJ.js → chunk-HXINWP3V.js} +42 -13
- package/dist/chunk-HXINWP3V.js.map +1 -0
- package/dist/{chunk-T6L3USBZ.js → chunk-IOBSIAHB.js} +23 -11
- package/dist/chunk-IOBSIAHB.js.map +1 -0
- package/dist/{chunk-7Y6UCSUS.js → chunk-IZOTGWWI.js} +5 -5
- package/dist/chunk-IZOTGWWI.js.map +1 -0
- package/dist/{chunk-MLVUMCQ2.js → chunk-J2FACXYI.js} +14 -5
- package/dist/chunk-J2FACXYI.js.map +1 -0
- package/dist/{chunk-VTFCTWSX.js → chunk-KKJEEKL2.js} +33 -7
- package/dist/chunk-KKJEEKL2.js.map +1 -0
- package/dist/{chunk-HWWA27DN.js → chunk-KMCGX76Y.js} +2 -2
- package/dist/{chunk-2YQA3VBY.js → chunk-NKMVICB5.js} +4 -2
- package/dist/chunk-NKMVICB5.js.map +1 -0
- package/dist/{chunk-ZBLTU67D.js → chunk-OFLMG6RN.js} +15 -11
- package/dist/chunk-OFLMG6RN.js.map +1 -0
- package/dist/{chunk-CMAU4DSB.js → chunk-P6GDMZK4.js} +5 -5
- package/dist/chunk-P6GDMZK4.js.map +1 -0
- package/dist/{chunk-MOEMFL4K.js → chunk-PO6FCAIS.js} +5 -5
- package/dist/chunk-PO6FCAIS.js.map +1 -0
- package/dist/chunk-PWLZFGS3.js +494 -0
- package/dist/chunk-PWLZFGS3.js.map +1 -0
- package/dist/chunk-QJIB36DM.js +249 -0
- package/dist/chunk-QJIB36DM.js.map +1 -0
- package/dist/{chunk-TPF4MOMF.js → chunk-R7FKGFW6.js} +7 -4
- package/dist/chunk-R7FKGFW6.js.map +1 -0
- package/dist/{chunk-ZGAOMRYD.js → chunk-RWWRTURA.js} +3 -3
- package/dist/{chunk-QDNI54ON.js → chunk-RYBY35QE.js} +10 -8
- package/dist/chunk-RYBY35QE.js.map +1 -0
- package/dist/chunk-S7F5VKWU.js +453 -0
- package/dist/chunk-S7F5VKWU.js.map +1 -0
- package/dist/chunk-T5W3FDSF.js +396 -0
- package/dist/chunk-T5W3FDSF.js.map +1 -0
- package/dist/{chunk-BTGCUONV.js → chunk-TCXKZDMR.js} +2 -2
- package/dist/{chunk-C36CZRHK.js → chunk-WGPB3QQU.js} +43 -13
- package/dist/chunk-WGPB3QQU.js.map +1 -0
- package/dist/{chunk-G6OVKNL7.js → chunk-XPCU4KUY.js} +5 -4
- package/dist/chunk-XPCU4KUY.js.map +1 -0
- package/dist/chunk-YRYZUYY7.js +236 -0
- package/dist/chunk-YRYZUYY7.js.map +1 -0
- package/dist/{chunk-7BIQ3K6H.js → chunk-ZOTAAYO5.js} +12 -2
- package/dist/chunk-ZOTAAYO5.js.map +1 -0
- package/dist/components/accordion.js +2 -2
- package/dist/components/alert.js +2 -2
- package/dist/components/app-ui.d.ts +28 -12
- package/dist/components/app-ui.js +6 -4
- package/dist/components/blocks.d.ts +28 -2
- package/dist/components/blocks.js +3 -3
- package/dist/components/button.d.ts +7 -0
- package/dist/components/button.js +3 -3
- package/dist/components/changelog.d.ts +386 -0
- package/dist/components/changelog.js +25 -0
- package/dist/components/changelog.js.map +1 -0
- package/dist/components/checkbox-group.js +3 -3
- package/dist/components/checkbox.js +3 -3
- package/dist/components/date-input.js +3 -3
- package/dist/components/dialog.d.ts +15 -0
- package/dist/components/dialog.js +3 -2
- package/dist/components/estimator.d.ts +246 -0
- package/dist/components/estimator.js +16 -0
- package/dist/components/estimator.js.map +1 -0
- package/dist/components/fieldset.js +2 -2
- package/dist/components/grid.js +2 -2
- package/dist/components/help.js +2 -2
- package/dist/components/icon.d.ts +2 -0
- package/dist/components/icon.js +2 -2
- package/dist/components/journey.d.ts +447 -0
- package/dist/components/journey.js +22 -0
- package/dist/components/journey.js.map +1 -0
- package/dist/components/layout.d.ts +24 -0
- package/dist/components/layout.js +2 -2
- package/dist/components/link.js +3 -3
- package/dist/components/list.d.ts +50 -0
- package/dist/components/list.js +8 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/marketing.d.ts +1 -1
- package/dist/components/marketing.js +3 -3
- package/dist/components/media.d.ts +10 -0
- package/dist/components/media.js +2 -2
- package/dist/components/navigation.d.ts +16 -0
- package/dist/components/navigation.js +3 -3
- package/dist/components/organisms.d.ts +13 -1
- package/dist/components/organisms.js +3 -3
- package/dist/components/page.js +2 -2
- package/dist/components/price.d.ts +1 -1
- package/dist/components/price.js +3 -2
- package/dist/components/progress.js +2 -2
- package/dist/components/property.d.ts +1 -1
- package/dist/components/property.js +4 -3
- package/dist/components/radio-group.js +3 -3
- package/dist/components/scene.d.ts +138 -0
- package/dist/components/scene.js +8 -0
- package/dist/components/scene.js.map +1 -0
- package/dist/components/scrubber.d.ts +86 -0
- package/dist/components/scrubber.js +8 -0
- package/dist/components/scrubber.js.map +1 -0
- package/dist/components/select.js +3 -3
- package/dist/components/selling.d.ts +409 -0
- package/dist/components/selling.js +25 -0
- package/dist/components/selling.js.map +1 -0
- package/dist/components/site.d.ts +283 -0
- package/dist/components/site.js +20 -0
- package/dist/components/site.js.map +1 -0
- package/dist/components/summary-list.js +2 -2
- package/dist/components/table.d.ts +94 -2
- package/dist/components/table.js +4 -2
- package/dist/components/text-input.js +3 -3
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +3 -3
- package/dist/index.d.ts +10 -2
- package/dist/index.js +135 -55
- package/dist/standalone/atomic-ui.js +3134 -0
- package/dist/standalone/atomic-ui.js.map +7 -0
- package/dist/standalone/index.html +174 -0
- package/package.json +26 -7
- package/scripts/copy-to-product.mjs +52 -0
- package/specimen/index.html +174 -0
- package/dist/chunk-2YQA3VBY.js.map +0 -1
- package/dist/chunk-4HU4Y23Q.js.map +0 -1
- package/dist/chunk-6ICOJPMD.js.map +0 -1
- package/dist/chunk-7BIQ3K6H.js.map +0 -1
- package/dist/chunk-7Y6UCSUS.js.map +0 -1
- package/dist/chunk-C36CZRHK.js.map +0 -1
- package/dist/chunk-CMAU4DSB.js.map +0 -1
- package/dist/chunk-G6OVKNL7.js.map +0 -1
- package/dist/chunk-GO2IBRFP.js.map +0 -1
- package/dist/chunk-MLVUMCQ2.js.map +0 -1
- package/dist/chunk-MOEMFL4K.js.map +0 -1
- package/dist/chunk-NTNXHLTM.js.map +0 -1
- package/dist/chunk-QCNT7D5V.js.map +0 -1
- package/dist/chunk-QDNI54ON.js.map +0 -1
- package/dist/chunk-T6L3USBZ.js.map +0 -1
- package/dist/chunk-TPF4MOMF.js.map +0 -1
- package/dist/chunk-VTFCTWSX.js.map +0 -1
- package/dist/chunk-VWNBB7FW.js +0 -104
- package/dist/chunk-VWNBB7FW.js.map +0 -1
- package/dist/chunk-WECSVHIM.js.map +0 -1
- package/dist/chunk-X7IPZPTG.js.map +0 -1
- package/dist/chunk-XJP45LFA.js.map +0 -1
- package/dist/chunk-ZBLTU67D.js.map +0 -1
- package/dist/chunk-ZQJD4YEJ.js.map +0 -1
- /package/dist/{chunk-5EA4IDUD.js.map → chunk-46BYUQ5A.js.map} +0 -0
- /package/dist/{chunk-XVKEM5JY.js.map → chunk-5QSTXIPG.js.map} +0 -0
- /package/dist/{chunk-GSCVG2ER.js.map → chunk-APJ5JGRW.js.map} +0 -0
- /package/dist/{chunk-NQKYHILD.js.map → chunk-DAH7RLW3.js.map} +0 -0
- /package/dist/{chunk-OB7LC6NJ.js.map → chunk-DJEZW7AC.js.map} +0 -0
- /package/dist/{chunk-HWWA27DN.js.map → chunk-KMCGX76Y.js.map} +0 -0
- /package/dist/{chunk-ZGAOMRYD.js.map → chunk-RWWRTURA.js.map} +0 -0
- /package/dist/{chunk-BTGCUONV.js.map → chunk-TCXKZDMR.js.map} +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Impkt components in a plain HTML product</title>
|
|
7
|
+
<!--
|
|
8
|
+
A plain HTML product needs two files beside this page: theme.css from
|
|
9
|
+
@atomic-ui/theme (pnpm theme:copy) and atomic-ui.js from @atomic-ui/ui
|
|
10
|
+
(pnpm ui:copy). The theme gives the page the Impkt look and gives the
|
|
11
|
+
components their tokens, in light and in dark. The script defines every
|
|
12
|
+
element when it loads.
|
|
13
|
+
-->
|
|
14
|
+
<link rel="stylesheet" href="theme.css">
|
|
15
|
+
<script type="module" src="atomic-ui.js"></script>
|
|
16
|
+
<style>
|
|
17
|
+
main { max-width: 1040px; margin: 0 auto; padding: var(--ik-space-6) var(--ik-gutter) var(--ik-space-12); }
|
|
18
|
+
section { margin-bottom: var(--ik-space-8); }
|
|
19
|
+
.lede { color: var(--ik-ink-muted); max-width: 60ch; margin: 0 0 var(--ik-space-6); }
|
|
20
|
+
.toolbar { display: flex; flex-wrap: wrap; gap: var(--ik-space-3); align-items: flex-end; margin-bottom: var(--ik-space-4); }
|
|
21
|
+
.toolbar impkt-text-input { flex: 1 1 16rem; margin: 0; }
|
|
22
|
+
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ik-space-4); }
|
|
23
|
+
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
|
|
24
|
+
.row { display: flex; flex-wrap: wrap; gap: var(--ik-space-2); align-items: center; }
|
|
25
|
+
</style>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<a class="ik-skip" href="#main">Skip to the content</a>
|
|
29
|
+
<header class="ik-header">
|
|
30
|
+
<a class="ik-brand" href="./"><span class="ik-mark" aria-hidden="true"></span><span><b>Impkt</b> <span class="ik-product">Components</span></span></a>
|
|
31
|
+
<div class="row">
|
|
32
|
+
<label for="theme" class="ik-sr-only">Theme</label>
|
|
33
|
+
<select id="theme" style="min-height:44px;padding:4px 10px;font-size:16px">
|
|
34
|
+
<option value="">Auto</option>
|
|
35
|
+
<option value="light">Light</option>
|
|
36
|
+
<option value="dark">Dark</option>
|
|
37
|
+
</select>
|
|
38
|
+
<impkt-menu id="account" label="Account" edge="end" items='[{"text":"Profile","href":"#profile","icon":"user"},{"text":"Settings","value":"settings"},{"text":"Sign out","value":"sign-out","tone":"danger"}]'></impkt-menu>
|
|
39
|
+
</div>
|
|
40
|
+
</header>
|
|
41
|
+
|
|
42
|
+
<main id="main">
|
|
43
|
+
<h1>Components for the products</h1>
|
|
44
|
+
<p class="lede">The parts the apps and the AI tools use most, drawn by the Impkt components on a page styled by the product theme. Change the theme at the top to see the dark version, and narrow the window to see the phone layout.</p>
|
|
45
|
+
|
|
46
|
+
<impkt-error-summary id="problems"></impkt-error-summary>
|
|
47
|
+
|
|
48
|
+
<section aria-labelledby="h-cases">
|
|
49
|
+
<h2 id="h-cases">A table with search, sorting, selection and pages</h2>
|
|
50
|
+
<div class="card">
|
|
51
|
+
<div class="toolbar">
|
|
52
|
+
<impkt-text-input id="search" type="search" label="Search cases" description="By name or reference"></impkt-text-input>
|
|
53
|
+
<impkt-menu id="bulk" label="With selected" items='[{"text":"Export","value":"export","icon":"download"},{"text":"Archive","value":"archive"}]'></impkt-menu>
|
|
54
|
+
</div>
|
|
55
|
+
<impkt-table id="cases" caption="Open cases" stack selectable sort-key="opened" sort-direction="descending" empty-text="No cases match your search."
|
|
56
|
+
columns='[{"key":"ref","label":"Reference","sortable":true},{"key":"name","label":"Client","sortable":true},{"key":"status","label":"Status"},{"key":"opened","label":"Opened","sortable":true},{"key":"fee","label":"Fee","numeric":true,"sortable":true}]'
|
|
57
|
+
rows='[{"id":"c1","ref":"HB-1042","name":"Amira Hassan","status":"In progress","opened":"2026-11-02","fee":"£1,250"},{"id":"c2","ref":"HB-1043","name":"Tom Price","status":"Waiting","opened":"2026-11-09","fee":"£480"},{"id":"c3","ref":"HB-1044","name":"Sofia Rossi","status":"Done","opened":"2026-10-21","fee":"£12,400"},{"id":"c4","ref":"HB-1045","name":"Ben Okafor","status":"In progress","opened":"2026-11-15","fee":"£990"}]'>
|
|
58
|
+
<impkt-badge slot="cell:c1:status" tone="info">In progress</impkt-badge>
|
|
59
|
+
<impkt-badge slot="cell:c2:status" tone="warning">Waiting</impkt-badge>
|
|
60
|
+
<impkt-badge slot="cell:c3:status" tone="success">Done</impkt-badge>
|
|
61
|
+
<impkt-badge slot="cell:c4:status" tone="info">In progress</impkt-badge>
|
|
62
|
+
</impkt-table>
|
|
63
|
+
<impkt-pagination id="pages" page="2" pages="9"></impkt-pagination>
|
|
64
|
+
</div>
|
|
65
|
+
<impkt-empty-state framed heading="No documents yet" lead="Documents you upload for this case appear here." heading-level="3" icon="document"><impkt-button slot="actions" variant="secondary" href="#upload">Upload a document</impkt-button></impkt-empty-state>
|
|
66
|
+
</section>
|
|
67
|
+
|
|
68
|
+
<section aria-labelledby="h-tabs">
|
|
69
|
+
<h2 id="h-tabs">Tabs</h2>
|
|
70
|
+
<impkt-tabs id="tabs" label="Case" two-rows selected="files"
|
|
71
|
+
items='[{"id":"summary","label":"Summary","body":"The case at a glance."},{"id":"tasks","label":"Tasks","body":""},{"id":"files","label":"Files","body":""},{"id":"messages","label":"Messages","body":"No messages yet."},{"id":"payments","label":"Payments","body":"Nothing to pay."},{"id":"history","label":"History","body":"Opened on 2 November 2026."}]'>
|
|
72
|
+
<div slot="tasks">
|
|
73
|
+
<impkt-task-list heading="Your import" heading-level="3"
|
|
74
|
+
items='[{"id":"t1","title":"Vehicle details","href":"#vehicle","status":"done"},{"id":"t2","title":"Proof of ownership","href":"#upload","status":"in-progress","hint":"Takes about five minutes"},{"id":"t3","title":"Payment","href":"#pay","status":"not-started"},{"id":"t4","title":"Registration","status":"cannot-start"}]'></impkt-task-list>
|
|
75
|
+
</div>
|
|
76
|
+
<div slot="files">
|
|
77
|
+
<impkt-document-link href="#v5c" label="V5C registration certificate" file-type="PDF" byte-size="245760"></impkt-document-link>
|
|
78
|
+
<impkt-file-upload id="upload" label="Add proof of ownership" description="PDF, JPG or PNG, up to 10 MB each" many-files></impkt-file-upload>
|
|
79
|
+
</div>
|
|
80
|
+
</impkt-tabs>
|
|
81
|
+
</section>
|
|
82
|
+
|
|
83
|
+
<section aria-labelledby="h-summary" class="grid2">
|
|
84
|
+
<div class="card">
|
|
85
|
+
<h2 id="h-summary">Summary list</h2>
|
|
86
|
+
<impkt-summary-list rows='[{"key":"Vehicle","value":"2019 Toyota Land Cruiser","changeHref":"#vehicle"},{"key":"Port","value":"Southampton","changeHref":"#port"},{"key":"Arriving","value":"12 December 2026"}]'></impkt-summary-list>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="card">
|
|
89
|
+
<h2>Badges, steps and progress</h2>
|
|
90
|
+
<div class="row">
|
|
91
|
+
<impkt-badge>Draft</impkt-badge><impkt-badge tone="brand">New</impkt-badge><impkt-badge tone="success" icon="check">Paid</impkt-badge><impkt-badge tone="warning">Due soon</impkt-badge><impkt-badge tone="danger">Overdue</impkt-badge><impkt-badge tone="info">Shipped</impkt-badge>
|
|
92
|
+
</div>
|
|
93
|
+
<impkt-progress steps='[{"id":"a","label":"Details"},{"id":"b","label":"Documents"},{"id":"c","label":"Payment"}]' current="b"></impkt-progress>
|
|
94
|
+
<impkt-steps orientation="vertical" heading-level="3" items='[{"heading":"Shipped","text":"Left Yokohama on 3 November.","meta":"Done"},{"heading":"At sea","text":"About five weeks."},{"heading":"Customs","text":"We clear it for you."}]'></impkt-steps>
|
|
95
|
+
</div>
|
|
96
|
+
</section>
|
|
97
|
+
|
|
98
|
+
<section aria-labelledby="h-form">
|
|
99
|
+
<h2 id="h-form">A form</h2>
|
|
100
|
+
<form class="card" id="form" novalidate>
|
|
101
|
+
<impkt-text-input id="name" name="name" label="Full name" required autocomplete="name"></impkt-text-input>
|
|
102
|
+
<impkt-date-input id="arrival" name="arrival" label="Arrival date" description="For example, 12 12 2026"></impkt-date-input>
|
|
103
|
+
<impkt-money-input id="value" name="value" label="Value of the vehicle" lowest="1000"></impkt-money-input>
|
|
104
|
+
<impkt-select name="port" label="Port" options='[{"value":"sou","label":"Southampton"},{"value":"til","label":"Tilbury"}]'></impkt-select>
|
|
105
|
+
<impkt-textarea name="notes" label="Anything else we should know"></impkt-textarea>
|
|
106
|
+
<impkt-checkbox name="agree" label="I confirm these details are correct"></impkt-checkbox>
|
|
107
|
+
<div class="row">
|
|
108
|
+
<impkt-button id="submit" variant="primary" type="submit">Save and continue</impkt-button>
|
|
109
|
+
<impkt-button id="open-dialog" variant="secondary">Cancel the import</impkt-button>
|
|
110
|
+
<impkt-button id="open-drawer" variant="secondary">Filters</impkt-button>
|
|
111
|
+
<impkt-button id="show-toast" variant="secondary">Save a draft</impkt-button>
|
|
112
|
+
</div>
|
|
113
|
+
</form>
|
|
114
|
+
</section>
|
|
115
|
+
|
|
116
|
+
<section aria-labelledby="h-alerts">
|
|
117
|
+
<h2 id="h-alerts">Alerts</h2>
|
|
118
|
+
<impkt-alert tone="info" heading="Your vehicle has shipped">It left Yokohama on 3 November.</impkt-alert>
|
|
119
|
+
<impkt-alert tone="success" heading="Payment received">Thank you. We have sent a receipt.</impkt-alert>
|
|
120
|
+
<impkt-alert tone="warning" heading="A document is missing">Upload proof of ownership before 1 December.</impkt-alert>
|
|
121
|
+
<impkt-alert tone="danger" heading="Payment failed">Try another card.</impkt-alert>
|
|
122
|
+
</section>
|
|
123
|
+
</main>
|
|
124
|
+
|
|
125
|
+
<impkt-dialog id="dialog" heading="Cancel this import?" phone-full-screen>
|
|
126
|
+
<p>We keep your details for 30 days, so you can start again.</p>
|
|
127
|
+
<div class="row">
|
|
128
|
+
<impkt-button id="dialog-keep" variant="primary">Keep the import</impkt-button>
|
|
129
|
+
<impkt-button id="dialog-cancel" variant="secondary">Cancel it</impkt-button>
|
|
130
|
+
</div>
|
|
131
|
+
</impkt-dialog>
|
|
132
|
+
|
|
133
|
+
<impkt-drawer id="drawer" heading="Filters">
|
|
134
|
+
<impkt-checkbox-group label="Status" options='[{"value":"open","label":"Open"},{"value":"waiting","label":"Waiting"},{"value":"done","label":"Done"}]'></impkt-checkbox-group>
|
|
135
|
+
<impkt-button slot="footer" id="drawer-apply" variant="primary">Show cases</impkt-button>
|
|
136
|
+
</impkt-drawer>
|
|
137
|
+
|
|
138
|
+
<impkt-toast id="toast" tone="success" message="Draft saved" action-text="Undo"></impkt-toast>
|
|
139
|
+
|
|
140
|
+
<script type="module">
|
|
141
|
+
const $ = (id) => document.getElementById(id);
|
|
142
|
+
const sel = $('theme');
|
|
143
|
+
sel.addEventListener('change', () => {
|
|
144
|
+
if (sel.value) document.documentElement.dataset.theme = sel.value;
|
|
145
|
+
else delete document.documentElement.dataset.theme;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Search filters the table. With nothing left, the table says so.
|
|
149
|
+
const table = $('cases');
|
|
150
|
+
const all = table.rows;
|
|
151
|
+
$('search').addEventListener('impkt-change', (e) => {
|
|
152
|
+
const q = e.detail.value.trim().toLowerCase();
|
|
153
|
+
table.rows = all.filter((r) => !q || `${r.ref} ${r.name}`.toLowerCase().includes(q));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
$('open-dialog').addEventListener('click', () => { $('dialog').open = true; });
|
|
157
|
+
$('dialog-keep').addEventListener('click', () => { $('dialog').open = false; });
|
|
158
|
+
$('dialog-cancel').addEventListener('click', () => { $('dialog').open = false; });
|
|
159
|
+
$('open-drawer').addEventListener('click', () => { $('drawer').open = true; });
|
|
160
|
+
$('drawer-apply').addEventListener('click', () => { $('drawer').open = false; });
|
|
161
|
+
$('show-toast').addEventListener('click', () => { $('toast').open = true; });
|
|
162
|
+
|
|
163
|
+
// Saving with a field empty lists the mistakes at the top, each linking to its field.
|
|
164
|
+
$('form').addEventListener('submit', (e) => {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
const items = [];
|
|
167
|
+
const name = $('name');
|
|
168
|
+
name.error = name.value ? '' : 'Enter your full name';
|
|
169
|
+
if (name.error) items.push({ id: 'name', text: name.error, href: '#name' });
|
|
170
|
+
$('problems').items = items;
|
|
171
|
+
});
|
|
172
|
+
</script>
|
|
173
|
+
</body>
|
|
174
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomic-ui/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The Impkt component library: standard custom elements, styled only from design tokens, built to WCAG 2.2 AA.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/matthill8286/impkt-design-system.git",
|
|
8
|
+
"directory": "packages/ui"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"main": "./dist/index.js",
|
|
7
12
|
"types": "./dist/index.d.ts",
|
|
@@ -13,11 +18,20 @@
|
|
|
13
18
|
"./components/*": {
|
|
14
19
|
"types": "./dist/components/*.d.ts",
|
|
15
20
|
"import": "./dist/components/*.js"
|
|
16
|
-
}
|
|
21
|
+
},
|
|
22
|
+
"./standalone": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/standalone/atomic-ui.js"
|
|
25
|
+
},
|
|
26
|
+
"./custom-elements.json": "./custom-elements.json",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"impkt-ui-copy": "./scripts/copy-to-product.mjs"
|
|
17
31
|
},
|
|
18
32
|
"dependencies": {
|
|
19
33
|
"lit": "^3.3.3",
|
|
20
|
-
"@atomic-ui/design-tokens": "0.
|
|
34
|
+
"@atomic-ui/design-tokens": "^0.3.0"
|
|
21
35
|
},
|
|
22
36
|
"devDependencies": {
|
|
23
37
|
"@types/node": "^20.14.0",
|
|
@@ -32,16 +46,21 @@
|
|
|
32
46
|
"customElements": "custom-elements.json",
|
|
33
47
|
"files": [
|
|
34
48
|
"dist",
|
|
35
|
-
"README.md"
|
|
49
|
+
"README.md",
|
|
50
|
+
"custom-elements.json",
|
|
51
|
+
"scripts/copy-to-product.mjs",
|
|
52
|
+
"specimen"
|
|
36
53
|
],
|
|
37
54
|
"publishConfig": {
|
|
55
|
+
"registry": "https://registry.npmjs.org",
|
|
38
56
|
"access": "public"
|
|
39
57
|
},
|
|
40
58
|
"scripts": {
|
|
41
|
-
"build": "tsc -p tsconfig.json",
|
|
59
|
+
"build": "custom-elements-manifest analyze && tsc -p tsconfig.json",
|
|
42
60
|
"typecheck": "tsc -p tsconfig.json",
|
|
43
61
|
"test": "vitest run",
|
|
44
62
|
"test:browser": "playwright test",
|
|
45
|
-
"manifest": "custom-elements-manifest analyze"
|
|
63
|
+
"manifest": "custom-elements-manifest analyze",
|
|
64
|
+
"standalone": "node scripts/standalone.mjs"
|
|
46
65
|
}
|
|
47
|
-
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copy the standalone components file into a plain HTML product.
|
|
4
|
+
*
|
|
5
|
+
* pnpm ui:copy ../impkt-tender
|
|
6
|
+
* node packages/ui/scripts/copy-to-product.mjs /path/to/product [public folder]
|
|
7
|
+
*
|
|
8
|
+
* Copies dist/standalone/atomic-ui.js and its source map into the product's public
|
|
9
|
+
* folder, which is `public` unless a second argument names another. The first line
|
|
10
|
+
* of the copy names the version and the design system's commit, so anyone can see
|
|
11
|
+
* which components a product carries. It replaces the build's own first line rather
|
|
12
|
+
* than adding one, so the source map still lines up. Build first with `pnpm build`.
|
|
13
|
+
*/
|
|
14
|
+
import { execFileSync } from 'node:child_process';
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
|
|
19
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
20
|
+
const [product, folder = 'public'] = process.argv.slice(2);
|
|
21
|
+
if (!product) {
|
|
22
|
+
console.error('Use: copy-to-product.mjs <product folder> [public folder]');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const built = join(root, 'dist', 'standalone', 'atomic-ui.js');
|
|
27
|
+
if (!existsSync(built)) {
|
|
28
|
+
console.error('There is no dist/standalone/atomic-ui.js. Run pnpm build first.');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { version } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
33
|
+
// The commit is the design system's own, so it is read only in a checkout of it, not in an installed package.
|
|
34
|
+
const inRepository = basename(dirname(root)) === 'packages' && existsSync(join(root, '..', '..', 'pnpm-workspace.yaml'));
|
|
35
|
+
let commit = inRepository ? 'uncommitted' : 'as published';
|
|
36
|
+
if (inRepository) try {
|
|
37
|
+
commit = execFileSync('git', ['rev-parse', '--short', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim();
|
|
38
|
+
const dirty = execFileSync('git', ['status', '--porcelain', '--', '.'], { cwd: root, encoding: 'utf8' }).trim();
|
|
39
|
+
if (dirty) commit += ' with uncommitted changes';
|
|
40
|
+
} catch {
|
|
41
|
+
// git is not installed: the version is enough.
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// pnpm runs a root script from the repository root, so a relative path is read from where it was typed.
|
|
45
|
+
const target = resolve(process.env.INIT_CWD ?? process.cwd(), product, folder);
|
|
46
|
+
if (!existsSync(target)) mkdirSync(target, { recursive: true });
|
|
47
|
+
const source = readFileSync(built, 'utf8');
|
|
48
|
+
const rest = source.slice(source.indexOf('\n') + 1);
|
|
49
|
+
const first = `/* Copied from matthill8286/impkt-design-system, @atomic-ui/ui version ${version}, commit ${commit}. To update, build the design system and run pnpm ui:copy again. */\n`;
|
|
50
|
+
writeFileSync(join(target, 'atomic-ui.js'), first + rest);
|
|
51
|
+
writeFileSync(join(target, 'atomic-ui.js.map'), readFileSync(`${built}.map`));
|
|
52
|
+
console.log(`copied @atomic-ui/ui ${version} (${commit}) to ${join(target, 'atomic-ui.js')} and its source map`);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en-GB">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Impkt components in a plain HTML product</title>
|
|
7
|
+
<!--
|
|
8
|
+
A plain HTML product needs two files beside this page: theme.css from
|
|
9
|
+
@atomic-ui/theme (pnpm theme:copy) and atomic-ui.js from @atomic-ui/ui
|
|
10
|
+
(pnpm ui:copy). The theme gives the page the Impkt look and gives the
|
|
11
|
+
components their tokens, in light and in dark. The script defines every
|
|
12
|
+
element when it loads.
|
|
13
|
+
-->
|
|
14
|
+
<link rel="stylesheet" href="theme.css">
|
|
15
|
+
<script type="module" src="atomic-ui.js"></script>
|
|
16
|
+
<style>
|
|
17
|
+
main { max-width: 1040px; margin: 0 auto; padding: var(--ik-space-6) var(--ik-gutter) var(--ik-space-12); }
|
|
18
|
+
section { margin-bottom: var(--ik-space-8); }
|
|
19
|
+
.lede { color: var(--ik-ink-muted); max-width: 60ch; margin: 0 0 var(--ik-space-6); }
|
|
20
|
+
.toolbar { display: flex; flex-wrap: wrap; gap: var(--ik-space-3); align-items: flex-end; margin-bottom: var(--ik-space-4); }
|
|
21
|
+
.toolbar impkt-text-input { flex: 1 1 16rem; margin: 0; }
|
|
22
|
+
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ik-space-4); }
|
|
23
|
+
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
|
|
24
|
+
.row { display: flex; flex-wrap: wrap; gap: var(--ik-space-2); align-items: center; }
|
|
25
|
+
</style>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<a class="ik-skip" href="#main">Skip to the content</a>
|
|
29
|
+
<header class="ik-header">
|
|
30
|
+
<a class="ik-brand" href="./"><span class="ik-mark" aria-hidden="true"></span><span><b>Impkt</b> <span class="ik-product">Components</span></span></a>
|
|
31
|
+
<div class="row">
|
|
32
|
+
<label for="theme" class="ik-sr-only">Theme</label>
|
|
33
|
+
<select id="theme" style="min-height:44px;padding:4px 10px;font-size:16px">
|
|
34
|
+
<option value="">Auto</option>
|
|
35
|
+
<option value="light">Light</option>
|
|
36
|
+
<option value="dark">Dark</option>
|
|
37
|
+
</select>
|
|
38
|
+
<impkt-menu id="account" label="Account" edge="end" items='[{"text":"Profile","href":"#profile","icon":"user"},{"text":"Settings","value":"settings"},{"text":"Sign out","value":"sign-out","tone":"danger"}]'></impkt-menu>
|
|
39
|
+
</div>
|
|
40
|
+
</header>
|
|
41
|
+
|
|
42
|
+
<main id="main">
|
|
43
|
+
<h1>Components for the products</h1>
|
|
44
|
+
<p class="lede">The parts the apps and the AI tools use most, drawn by the Impkt components on a page styled by the product theme. Change the theme at the top to see the dark version, and narrow the window to see the phone layout.</p>
|
|
45
|
+
|
|
46
|
+
<impkt-error-summary id="problems"></impkt-error-summary>
|
|
47
|
+
|
|
48
|
+
<section aria-labelledby="h-cases">
|
|
49
|
+
<h2 id="h-cases">A table with search, sorting, selection and pages</h2>
|
|
50
|
+
<div class="card">
|
|
51
|
+
<div class="toolbar">
|
|
52
|
+
<impkt-text-input id="search" type="search" label="Search cases" description="By name or reference"></impkt-text-input>
|
|
53
|
+
<impkt-menu id="bulk" label="With selected" items='[{"text":"Export","value":"export","icon":"download"},{"text":"Archive","value":"archive"}]'></impkt-menu>
|
|
54
|
+
</div>
|
|
55
|
+
<impkt-table id="cases" caption="Open cases" stack selectable sort-key="opened" sort-direction="descending" empty-text="No cases match your search."
|
|
56
|
+
columns='[{"key":"ref","label":"Reference","sortable":true},{"key":"name","label":"Client","sortable":true},{"key":"status","label":"Status"},{"key":"opened","label":"Opened","sortable":true},{"key":"fee","label":"Fee","numeric":true,"sortable":true}]'
|
|
57
|
+
rows='[{"id":"c1","ref":"HB-1042","name":"Amira Hassan","status":"In progress","opened":"2026-11-02","fee":"£1,250"},{"id":"c2","ref":"HB-1043","name":"Tom Price","status":"Waiting","opened":"2026-11-09","fee":"£480"},{"id":"c3","ref":"HB-1044","name":"Sofia Rossi","status":"Done","opened":"2026-10-21","fee":"£12,400"},{"id":"c4","ref":"HB-1045","name":"Ben Okafor","status":"In progress","opened":"2026-11-15","fee":"£990"}]'>
|
|
58
|
+
<impkt-badge slot="cell:c1:status" tone="info">In progress</impkt-badge>
|
|
59
|
+
<impkt-badge slot="cell:c2:status" tone="warning">Waiting</impkt-badge>
|
|
60
|
+
<impkt-badge slot="cell:c3:status" tone="success">Done</impkt-badge>
|
|
61
|
+
<impkt-badge slot="cell:c4:status" tone="info">In progress</impkt-badge>
|
|
62
|
+
</impkt-table>
|
|
63
|
+
<impkt-pagination id="pages" page="2" pages="9"></impkt-pagination>
|
|
64
|
+
</div>
|
|
65
|
+
<impkt-empty-state framed heading="No documents yet" lead="Documents you upload for this case appear here." heading-level="3" icon="document"><impkt-button slot="actions" variant="secondary" href="#upload">Upload a document</impkt-button></impkt-empty-state>
|
|
66
|
+
</section>
|
|
67
|
+
|
|
68
|
+
<section aria-labelledby="h-tabs">
|
|
69
|
+
<h2 id="h-tabs">Tabs</h2>
|
|
70
|
+
<impkt-tabs id="tabs" label="Case" two-rows selected="files"
|
|
71
|
+
items='[{"id":"summary","label":"Summary","body":"The case at a glance."},{"id":"tasks","label":"Tasks","body":""},{"id":"files","label":"Files","body":""},{"id":"messages","label":"Messages","body":"No messages yet."},{"id":"payments","label":"Payments","body":"Nothing to pay."},{"id":"history","label":"History","body":"Opened on 2 November 2026."}]'>
|
|
72
|
+
<div slot="tasks">
|
|
73
|
+
<impkt-task-list heading="Your import" heading-level="3"
|
|
74
|
+
items='[{"id":"t1","title":"Vehicle details","href":"#vehicle","status":"done"},{"id":"t2","title":"Proof of ownership","href":"#upload","status":"in-progress","hint":"Takes about five minutes"},{"id":"t3","title":"Payment","href":"#pay","status":"not-started"},{"id":"t4","title":"Registration","status":"cannot-start"}]'></impkt-task-list>
|
|
75
|
+
</div>
|
|
76
|
+
<div slot="files">
|
|
77
|
+
<impkt-document-link href="#v5c" label="V5C registration certificate" file-type="PDF" byte-size="245760"></impkt-document-link>
|
|
78
|
+
<impkt-file-upload id="upload" label="Add proof of ownership" description="PDF, JPG or PNG, up to 10 MB each" many-files></impkt-file-upload>
|
|
79
|
+
</div>
|
|
80
|
+
</impkt-tabs>
|
|
81
|
+
</section>
|
|
82
|
+
|
|
83
|
+
<section aria-labelledby="h-summary" class="grid2">
|
|
84
|
+
<div class="card">
|
|
85
|
+
<h2 id="h-summary">Summary list</h2>
|
|
86
|
+
<impkt-summary-list rows='[{"key":"Vehicle","value":"2019 Toyota Land Cruiser","changeHref":"#vehicle"},{"key":"Port","value":"Southampton","changeHref":"#port"},{"key":"Arriving","value":"12 December 2026"}]'></impkt-summary-list>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="card">
|
|
89
|
+
<h2>Badges, steps and progress</h2>
|
|
90
|
+
<div class="row">
|
|
91
|
+
<impkt-badge>Draft</impkt-badge><impkt-badge tone="brand">New</impkt-badge><impkt-badge tone="success" icon="check">Paid</impkt-badge><impkt-badge tone="warning">Due soon</impkt-badge><impkt-badge tone="danger">Overdue</impkt-badge><impkt-badge tone="info">Shipped</impkt-badge>
|
|
92
|
+
</div>
|
|
93
|
+
<impkt-progress steps='[{"id":"a","label":"Details"},{"id":"b","label":"Documents"},{"id":"c","label":"Payment"}]' current="b"></impkt-progress>
|
|
94
|
+
<impkt-steps orientation="vertical" heading-level="3" items='[{"heading":"Shipped","text":"Left Yokohama on 3 November.","meta":"Done"},{"heading":"At sea","text":"About five weeks."},{"heading":"Customs","text":"We clear it for you."}]'></impkt-steps>
|
|
95
|
+
</div>
|
|
96
|
+
</section>
|
|
97
|
+
|
|
98
|
+
<section aria-labelledby="h-form">
|
|
99
|
+
<h2 id="h-form">A form</h2>
|
|
100
|
+
<form class="card" id="form" novalidate>
|
|
101
|
+
<impkt-text-input id="name" name="name" label="Full name" required autocomplete="name"></impkt-text-input>
|
|
102
|
+
<impkt-date-input id="arrival" name="arrival" label="Arrival date" description="For example, 12 12 2026"></impkt-date-input>
|
|
103
|
+
<impkt-money-input id="value" name="value" label="Value of the vehicle" lowest="1000"></impkt-money-input>
|
|
104
|
+
<impkt-select name="port" label="Port" options='[{"value":"sou","label":"Southampton"},{"value":"til","label":"Tilbury"}]'></impkt-select>
|
|
105
|
+
<impkt-textarea name="notes" label="Anything else we should know"></impkt-textarea>
|
|
106
|
+
<impkt-checkbox name="agree" label="I confirm these details are correct"></impkt-checkbox>
|
|
107
|
+
<div class="row">
|
|
108
|
+
<impkt-button id="submit" variant="primary" type="submit">Save and continue</impkt-button>
|
|
109
|
+
<impkt-button id="open-dialog" variant="secondary">Cancel the import</impkt-button>
|
|
110
|
+
<impkt-button id="open-drawer" variant="secondary">Filters</impkt-button>
|
|
111
|
+
<impkt-button id="show-toast" variant="secondary">Save a draft</impkt-button>
|
|
112
|
+
</div>
|
|
113
|
+
</form>
|
|
114
|
+
</section>
|
|
115
|
+
|
|
116
|
+
<section aria-labelledby="h-alerts">
|
|
117
|
+
<h2 id="h-alerts">Alerts</h2>
|
|
118
|
+
<impkt-alert tone="info" heading="Your vehicle has shipped">It left Yokohama on 3 November.</impkt-alert>
|
|
119
|
+
<impkt-alert tone="success" heading="Payment received">Thank you. We have sent a receipt.</impkt-alert>
|
|
120
|
+
<impkt-alert tone="warning" heading="A document is missing">Upload proof of ownership before 1 December.</impkt-alert>
|
|
121
|
+
<impkt-alert tone="danger" heading="Payment failed">Try another card.</impkt-alert>
|
|
122
|
+
</section>
|
|
123
|
+
</main>
|
|
124
|
+
|
|
125
|
+
<impkt-dialog id="dialog" heading="Cancel this import?" phone-full-screen>
|
|
126
|
+
<p>We keep your details for 30 days, so you can start again.</p>
|
|
127
|
+
<div class="row">
|
|
128
|
+
<impkt-button id="dialog-keep" variant="primary">Keep the import</impkt-button>
|
|
129
|
+
<impkt-button id="dialog-cancel" variant="secondary">Cancel it</impkt-button>
|
|
130
|
+
</div>
|
|
131
|
+
</impkt-dialog>
|
|
132
|
+
|
|
133
|
+
<impkt-drawer id="drawer" heading="Filters">
|
|
134
|
+
<impkt-checkbox-group label="Status" options='[{"value":"open","label":"Open"},{"value":"waiting","label":"Waiting"},{"value":"done","label":"Done"}]'></impkt-checkbox-group>
|
|
135
|
+
<impkt-button slot="footer" id="drawer-apply" variant="primary">Show cases</impkt-button>
|
|
136
|
+
</impkt-drawer>
|
|
137
|
+
|
|
138
|
+
<impkt-toast id="toast" tone="success" message="Draft saved" action-text="Undo"></impkt-toast>
|
|
139
|
+
|
|
140
|
+
<script type="module">
|
|
141
|
+
const $ = (id) => document.getElementById(id);
|
|
142
|
+
const sel = $('theme');
|
|
143
|
+
sel.addEventListener('change', () => {
|
|
144
|
+
if (sel.value) document.documentElement.dataset.theme = sel.value;
|
|
145
|
+
else delete document.documentElement.dataset.theme;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Search filters the table. With nothing left, the table says so.
|
|
149
|
+
const table = $('cases');
|
|
150
|
+
const all = table.rows;
|
|
151
|
+
$('search').addEventListener('impkt-change', (e) => {
|
|
152
|
+
const q = e.detail.value.trim().toLowerCase();
|
|
153
|
+
table.rows = all.filter((r) => !q || `${r.ref} ${r.name}`.toLowerCase().includes(q));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
$('open-dialog').addEventListener('click', () => { $('dialog').open = true; });
|
|
157
|
+
$('dialog-keep').addEventListener('click', () => { $('dialog').open = false; });
|
|
158
|
+
$('dialog-cancel').addEventListener('click', () => { $('dialog').open = false; });
|
|
159
|
+
$('open-drawer').addEventListener('click', () => { $('drawer').open = true; });
|
|
160
|
+
$('drawer-apply').addEventListener('click', () => { $('drawer').open = false; });
|
|
161
|
+
$('show-toast').addEventListener('click', () => { $('toast').open = true; });
|
|
162
|
+
|
|
163
|
+
// Saving with a field empty lists the mistakes at the top, each linking to its field.
|
|
164
|
+
$('form').addEventListener('submit', (e) => {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
const items = [];
|
|
167
|
+
const name = $('name');
|
|
168
|
+
name.error = name.value ? '' : 'Enter your full name';
|
|
169
|
+
if (name.error) items.push({ id: 'name', text: name.error, href: '#name' });
|
|
170
|
+
$('problems').items = items;
|
|
171
|
+
});
|
|
172
|
+
</script>
|
|
173
|
+
</body>
|
|
174
|
+
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/icon.ts"],"sourcesContent":["import { css, html, nothing, svg, type SVGTemplateResult, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { t } from '../base/tokens';\n\n/**\n * The icons the library draws, each on a 24 by 24 grid in strokes of the\n * current text colour. Kept to a set the components need and editors reach\n * for, so an icon always matches the line weight of the ones beside it.\n */\nexport const ICONS = {\n 'arrow-right': svg`<path d=\"M5 12h14M13 6l6 6-6 6\"/>`,\n 'arrow-left': svg`<path d=\"M19 12H5M11 6l-6 6 6 6\"/>`,\n 'chevron-right': svg`<path d=\"M9 6l6 6-6 6\"/>`,\n 'chevron-down': svg`<path d=\"M6 9l6 6 6-6\"/>`,\n check: svg`<path d=\"M5 12.5l4.5 4.5L19 7\"/>`,\n close: svg`<path d=\"M6 6l12 12M18 6L6 18\"/>`,\n menu: svg`<path d=\"M4 7h16M4 12h16M4 17h16\"/>`,\n plus: svg`<path d=\"M12 5v14M5 12h14\"/>`,\n minus: svg`<path d=\"M5 12h14\"/>`,\n search: svg`<circle cx=\"11\" cy=\"11\" r=\"6.5\"/><path d=\"M16 16l4 4\"/>`,\n external: svg`<path d=\"M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5\"/>`,\n download: svg`<path d=\"M12 4v11M7 10l5 5 5-5M5 20h14\"/>`,\n home: svg`<path d=\"M4 11l8-7 8 7M6 9.5V20h12V9.5\"/><path d=\"M10 20v-6h4v6\"/>`,\n phone: svg`<path d=\"M7 3.5h3l1.5 4-2 1.5a11 11 0 0 0 5.5 5.5l1.5-2 4 1.5v3a2 2 0 0 1-2 2A16 16 0 0 1 5 5.5a2 2 0 0 1 2-2z\"/>`,\n mail: svg`<rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"1.5\"/><path d=\"M4 7l8 6 8-6\"/>`,\n 'map-pin': svg`<path d=\"M12 21s-6.5-6-6.5-11a6.5 6.5 0 0 1 13 0c0 5-6.5 11-6.5 11z\"/><circle cx=\"12\" cy=\"10\" r=\"2.5\"/>`,\n calendar: svg`<rect x=\"4\" y=\"5.5\" width=\"16\" height=\"14.5\" rx=\"1.5\"/><path d=\"M4 10h16M8.5 3.5v4M15.5 3.5v4\"/>`,\n clock: svg`<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M12 7.5V12l3 2\"/>`,\n user: svg`<circle cx=\"12\" cy=\"8.5\" r=\"3.5\"/><path d=\"M5 20a7 7 0 0 1 14 0\"/>`,\n star: svg`<path d=\"M12 4l2.4 5 5.4.6-4 3.7 1.1 5.4L12 16l-4.9 2.7 1.1-5.4-4-3.7 5.4-.6z\"/>`,\n heart: svg`<path d=\"M12 19.5s-7.5-4.6-7.5-10A4 4 0 0 1 12 7a4 4 0 0 1 7.5 2.5c0 5.4-7.5 10-7.5 10z\"/>`,\n shield: svg`<path d=\"M12 3.5l7 2.5v5.5c0 4.5-3 7.8-7 9-4-1.2-7-4.5-7-9V6z\"/><path d=\"M9 12l2 2 4-4\"/>`,\n leaf: svg`<path d=\"M5 19c0-8 5-13 14-14 0 9-5 14-13 14z\"/><path d=\"M5 19l7-7\"/>`,\n sun: svg`<circle cx=\"12\" cy=\"12\" r=\"3.5\"/><path d=\"M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6L7 7M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4\"/>`,\n bolt: svg`<path d=\"M13 3L5 13.5h6L10 21l8-10.5h-6z\"/>`,\n key: svg`<circle cx=\"8\" cy=\"15\" r=\"3.5\"/><path d=\"M10.5 12.5L19 4M16 7l2.5 2.5M14 9l2 2\"/>`,\n info: svg`<circle cx=\"12\" cy=\"12\" r=\"8.5\"/><path d=\"M12 11v5.5M12 7.5v.5\"/>`,\n warning: svg`<path d=\"M12 4l9 15.5H3z\"/><path d=\"M12 10v4M12 16.5v.5\"/>`,\n document: svg`<path d=\"M6 3.5h8l4 4V20a.5.5 0 0 1-.5.5h-11A.5.5 0 0 1 6 20z\"/><path d=\"M14 3.5V8h4M9 13h6M9 16.5h6\"/>`,\n pound: svg`<path d=\"M16 6.5a3.5 3.5 0 0 0-6.5 1.8V20M7 13h7M7 20h10\"/>`,\n chat: svg`<path d=\"M4.5 5.5h15v10h-9l-4 3.5v-3.5h-2z\"/>`,\n} as const satisfies Record<string, SVGTemplateResult>;\n\nexport type IconName = keyof typeof ICONS;\nexport const ICON_NAMES = Object.keys(ICONS) as IconName[];\n\n/** An icon as markup, for components that draw one beside their own words. Always decorative. */\nexport function iconSvg(name: string | undefined, size = '1.25em'): TemplateResult | typeof nothing {\n const shape = name ? ICONS[name as IconName] : undefined;\n if (!shape) return nothing;\n return html`<svg class=\"icon\" viewBox=\"0 0 24 24\" width=${size} height=${size} fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">${shape}</svg>`;\n}\n\n/**\n * A small picture that stands for something: a phone beside a number, a tick\n * beside a benefit.\n *\n * **An icon is decorative unless it is labelled.** With no `label` it is\n * hidden from screen readers, because the words beside it already say what it\n * means. Give it a label only when it stands alone and carries meaning (1.1.1).\n *\n * @category media\n * @icon star\n */\nexport class ImpktIcon extends ImpktElement {\n static properties = {\n name: { type: String, reflect: true },\n label: { type: String },\n size: { type: String, reflect: true },\n tone: { type: String, reflect: true },\n };\n /** Which icon. */\n declare name: 'arrow-right' | 'arrow-left' | 'chevron-right' | 'chevron-down' | 'check' | 'close' | 'menu' | 'plus' | 'minus' | 'search' | 'external' | 'download' | 'home' | 'phone' | 'mail' | 'map-pin' | 'calendar' | 'clock' | 'user' | 'star' | 'heart' | 'shield' | 'leaf' | 'sun' | 'bolt' | 'key' | 'info' | 'warning' | 'document' | 'pound' | 'chat';\n /** What the icon means, when it stands alone. Leave empty when words beside it say the same. */\n declare label: string;\n declare size: 'sm' | 'md' | 'lg' | 'xl';\n /** The icon's colour. */\n declare tone: 'inherit' | 'brand' | 'muted';\n\n constructor() {\n super();\n this.name = 'star';\n this.label = '';\n this.size = 'md';\n this.tone = 'inherit';\n }\n\n static styles = [...ImpktElement.styles, css`\n :host { display: inline-flex; vertical-align: middle; line-height: 0; }\n :host([tone='brand']) { color: ${t.brand}; }\n :host([tone='muted']) { color: ${t.textMuted}; }\n @media (forced-colors: active) { :host { color: CanvasText; } }\n `];\n\n render(): TemplateResult {\n const size = { sm: '16px', md: '24px', lg: '32px', xl: '48px' }[this.size] ?? '24px';\n const drawn = iconSvg(this.name, size);\n return this.label ? html`<span role=\"img\" aria-label=${this.label}>${drawn}</span>` : html`${drawn}`;\n }\n}\n\ncustomElements.define('impkt-icon', ImpktIcon);\ndeclare global { interface HTMLElementTagNameMap { 'impkt-icon': ImpktIcon } }\n"],"mappings":";;;;;;AAAA,SAAS,KAAK,MAAM,SAAS,WAAwD;AAS9E,IAAM,QAAQ;AAAA,EACnB,eA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,GAE7C;AAAA;AAAA,EAED,SAAyB;AACvB,UAAM,OAAO,EAAE,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,OAAO,EAAE,KAAK,IAAI,KAAK;AAC9E,UAAM,QAAQ,QAAQ,KAAK,MAAM,IAAI;AACrC,WAAO,KAAK,QAAQ,mCAAmC,KAAK,KAAK,IAAI,KAAK,YAAY,OAAO,KAAK;AAAA,EACpG;AACF;AAEA,eAAe,OAAO,cAAc,SAAS;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/checkbox.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\n/**\n * A single checkbox — a consent, an opt-in, a confirmation.\n *\n * The label sits beside the box rather than above it, so this overrides the\n * base layout. The whole `<label>` is the hit area: a 20px box is legal under\n * 2.5.8 and still unkind, and the row costs nothing.\n\n *\n * @category form\n * @icon checkbox\n */\nexport class ImpktCheckbox extends FieldElement {\n static properties = {\n ...FieldElement.properties,\n checked: { type: Boolean, reflect: true },\n };\n\n declare checked: boolean;\n\n constructor() {\n super();\n this.checked = false;\n }\n\n static styles = [\n ...FieldElement.styles,\n css`\n .row {\n display: flex;\n align-items: flex-start;\n gap: ${space(3)};\n cursor: pointer;\n }\n input {\n ${targetSize}\n inline-size: 20px;\n block-size: 20px;\n margin: 0;\n flex: none;\n accent-color: ${t.brand};\n }\n .text {\n font-size: ${fontSize('md')};\n }\n :host([invalid]) .row {\n color: ${t.dangerText};\n }\n `,\n ];\n\n protected renderControl(): TemplateResult {\n return html`\n <label class=\"row\" part=\"row\" for=${this.controlId}>\n <input\n type=\"checkbox\"\n id=${this.controlId}\n part=\"input\"\n name=${this.name || nothing}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${this.describedBy}\n aria-invalid=${this.error ? 'true' : nothing}\n @change=${(e: Event) => {\n this.checked = (e.target as HTMLInputElement).checked;\n this.setFormValue(this.checked ? 'on' : '');\n }}\n />\n <span class=\"text\">\n ${this.label}${this.required\n ? html`<span class=\"required\"> (${this.requiredText})</span>`\n : nothing}\n </span>\n </label>\n `;\n }\n\n /** The label is inside the control here, so the base class's is suppressed. */\n protected renderLabel(): TemplateResult {\n return html`${nothing}`;\n }\n\n updated(changed: Map<string, unknown>): void {\n if (changed.has('error')) this.toggleAttribute('invalid', Boolean(this.error));\n }\n}\n\ncustomElements.define('impkt-checkbox', ImpktCheckbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-checkbox': ImpktCheckbox;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAgBjD,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C;AAAA,SAAO,aAAa;AAAA,MAClB,GAAG,aAAa;AAAA,MAChB,SAAS,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,IAC1C;AAAA;AAAA,EAIA,cAAc;AACZ,UAAM;AACN,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA;AAAA,SAAO,SAAS;AAAA,MACd,GAAG,aAAa;AAAA,MAChB;AAAA;AAAA;AAAA;AAAA,eAIW,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,UAIb,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKI,EAAE,KAAK;AAAA;AAAA;AAAA,qBAGV,SAAS,IAAI,CAAC;AAAA;AAAA;AAAA,iBAGlB,EAAE,UAAU;AAAA;AAAA;AAAA,IAG3B;AAAA;AAAA,EAEU,gBAAgC;AACxC,WAAO;AAAA,0CAC+B,KAAK,SAAS;AAAA;AAAA;AAAA,eAGzC,KAAK,SAAS;AAAA;AAAA,iBAEZ,KAAK,QAAQ,OAAO;AAAA,qBAChB,KAAK,OAAO;AAAA,sBACX,KAAK,QAAQ;AAAA,sBACb,KAAK,QAAQ;AAAA,6BACN,KAAK,WAAW;AAAA,yBACpB,KAAK,QAAQ,SAAS,OAAO;AAAA,oBAClC,CAAC,MAAa;AACtB,WAAK,UAAW,EAAE,OAA4B;AAC9C,WAAK,aAAa,KAAK,UAAU,OAAO,EAAE;AAAA,IAC5C,CAAC;AAAA;AAAA;AAAA,YAGC,KAAK,KAAK,GAAG,KAAK,WAChB,gCAAgC,KAAK,YAAY,aACjD,OAAO;AAAA;AAAA;AAAA;AAAA,EAInB;AAAA;AAAA,EAGU,cAA8B;AACtC,WAAO,OAAO,OAAO;AAAA,EACvB;AAAA,EAEA,QAAQ,SAAqC;AAC3C,QAAI,QAAQ,IAAI,OAAO,EAAG,MAAK,gBAAgB,WAAW,QAAQ,KAAK,KAAK,CAAC;AAAA,EAC/E;AACF;AAEA,eAAe,OAAO,kBAAkB,aAAa;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/alert.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult } from 'lit';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { fontSize, fontWeight, space, t } from '../base/tokens';\n\nexport type AlertTone = 'info' | 'success' | 'warning' | 'danger';\n\n/**\n * A notice.\n *\n * **The role depends on the tone, and that is a real distinction.** `alert`\n * interrupts whatever a screen reader is saying; `status` waits for a pause.\n * A failed payment earns the interruption. \"Your basket has been saved\" does\n * not, and using `alert` for it is how users learn to tune the live region\n * out — at which point the one that mattered is also lost.\n *\n * **The tone is never carried by colour alone.** Each tone ships a word, in\n * the accessible name, because 1.4.1 Use of Colour says a red border is not a\n * message and because a red border is invisible in forced-colours mode.\n\n *\n * @category feedback\n * @icon alert\n * @slot - The body of the notice.\n */\nexport class ImpktAlert extends ImpktElement {\n static properties = {\n tone: { type: String, reflect: true },\n heading: { type: String },\n toneLabel: { type: String, attribute: 'tone-label' },\n };\n\n declare tone: AlertTone;\n declare heading: string;\n /** Overrides the default word for the tone, for translation. */\n declare toneLabel: string;\n\n constructor() {\n super();\n this.tone = 'info';\n this.heading = '';\n this.toneLabel = '';\n }\n\n private static readonly TONE_WORDS: Record<AlertTone, string> = {\n info: 'Information',\n success: 'Success',\n warning: 'Warning',\n danger: 'Error',\n };\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n margin-block-end: ${space(4)};\n }\n .alert {\n padding: ${space(4)} ${space(5)};\n border-radius: ${t.radiusLg};\n border-inline-start: 4px solid;\n box-shadow: inset 0 0 0 1px ${t.hairline};\n font-size: ${fontSize('sm')};\n line-height: 1.5;\n }\n .heading {\n font-weight: ${fontWeight('semibold')};\n margin-block-end: ${space(1)};\n }\n :host([tone='info']) .alert {\n background: ${t.infoSubtle};\n border-color: ${t.info};\n color: ${t.text};\n }\n :host([tone='success']) .alert {\n background: ${t.successSubtle};\n border-color: ${t.success};\n color: ${t.text};\n }\n :host([tone='warning']) .alert {\n background: ${t.warningSubtle};\n border-color: ${t.warning};\n color: ${t.text};\n }\n :host([tone='danger']) .alert {\n background: ${t.dangerSubtle};\n border-color: ${t.danger};\n color: ${t.text};\n }\n /* Colour is the only signal left in forced-colours mode, and it is gone.\n The border keeps the boundary; the tone word in the label carries the\n meaning. */\n @media (forced-colors: active) {\n .alert {\n border: 1px solid CanvasText;\n border-inline-start-width: 4px;\n }\n }\n `,\n ];\n\n render(): TemplateResult {\n const word = this.toneLabel || ImpktAlert.TONE_WORDS[this.tone];\n return html`\n <div\n class=\"alert\"\n part=\"alert\"\n role=${this.tone === 'danger' ? 'alert' : 'status'}\n aria-label=${this.heading ? nothing : word}\n >\n ${this.heading\n ? html`<div class=\"heading\" part=\"heading\">\n <span class=\"tone-word\">${word}:</span> ${this.heading}\n </div>`\n : nothing}\n <slot></slot>\n </div>\n `;\n }\n}\n\ncustomElements.define('impkt-alert', ImpktAlert);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impkt-alert': ImpktAlert;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AAwBj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;AACvB,UAAM,OAAO,KAAK,aAAa,YAAW,WAAW,KAAK,IAAI;AAC9D,WAAO;AAAA;AAAA;AAAA;AAAA,eAII,KAAK,SAAS,WAAW,UAAU,QAAQ;AAAA,qBACrC,KAAK,UAAU,UAAU,IAAI;AAAA;AAAA,UAExC,KAAK,UACH;AAAA,wCAC4B,IAAI,YAAY,KAAK,OAAO;AAAA,sBAExD,OAAO;AAAA;AAAA;AAAA;AAAA,EAIjB;AACF;AAEA,eAAe,OAAO,eAAe,UAAU;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 */\n/**\n * How wide a single-line control is, from what it holds: a postcode is short,\n * an email address is long. A width that matches the answer is a hint about\n * what to type (1.3.5 is about the purpose, this is about the size). Applied by\n * the controls that take a `width`, through `--impkt-field-width`.\n */\nexport const fieldWidths = css`\n :host { --impkt-field-width: 100%; }\n :host([width='xs']) { --impkt-field-width: 8ch; }\n :host([width='sm']) { --impkt-field-width: 14ch; }\n :host([width='md']) { --impkt-field-width: 24ch; }\n :host([width='lg']) { --impkt-field-width: 40ch; }\n`;\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":";;;;;;;;;;;;AAAA,SAAS,MAAM,KAAK,eAAoC;AA0BjD,IAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,IAAe,eAAf,cAAoC,aAAa;AAAA,EAoCtD,cAAc;AACZ,UAAM;AAHR,SAAU,YAAqC;AAI7C,SAAK,QAAQ;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SA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