@atomic-ui/ui 0.3.0 → 0.6.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.
Files changed (213) hide show
  1. package/README.md +31 -33
  2. package/custom-elements.json +5986 -15880
  3. package/dist/base/FieldElement.d.ts +4 -4
  4. package/dist/base/{ImpktElement.d.ts → ImpaktElement.d.ts} +2 -2
  5. package/dist/base/styles.d.ts +7 -0
  6. package/dist/base/tokens.d.ts +1 -1
  7. package/dist/base/tone.d.ts +20 -0
  8. package/dist/{chunk-3RE4H2XO.js → chunk-3EF4T242.js} +7 -7
  9. package/dist/chunk-3EF4T242.js.map +1 -0
  10. package/dist/chunk-4ZQTXTPA.js +76 -0
  11. package/dist/chunk-4ZQTXTPA.js.map +1 -0
  12. package/dist/{chunk-NKMVICB5.js → chunk-5Y3HYRCU.js} +7 -7
  13. package/dist/chunk-5Y3HYRCU.js.map +1 -0
  14. package/dist/{chunk-ZOTAAYO5.js → chunk-5ZQVL3V2.js} +19 -12
  15. package/dist/chunk-5ZQVL3V2.js.map +1 -0
  16. package/dist/{chunk-4OYHT4BN.js → chunk-A7YBFS4H.js} +15 -15
  17. package/dist/chunk-A7YBFS4H.js.map +1 -0
  18. package/dist/{chunk-DAH7RLW3.js → chunk-DE3INTHZ.js} +6 -6
  19. package/dist/chunk-DE3INTHZ.js.map +1 -0
  20. package/dist/{chunk-HXINWP3V.js → chunk-EJD6LT7E.js} +20 -83
  21. package/dist/chunk-EJD6LT7E.js.map +1 -0
  22. package/dist/{chunk-P6GDMZK4.js → chunk-EJSX4WCD.js} +9 -9
  23. package/dist/chunk-EJSX4WCD.js.map +1 -0
  24. package/dist/{chunk-46BYUQ5A.js → chunk-FWR6SEIA.js} +33 -33
  25. package/dist/chunk-FWR6SEIA.js.map +1 -0
  26. package/dist/{chunk-CUUBAETM.js → chunk-GJPHQLLN.js} +8 -8
  27. package/dist/chunk-GJPHQLLN.js.map +1 -0
  28. package/dist/{chunk-R7FKGFW6.js → chunk-HNBG2POR.js} +7 -7
  29. package/dist/chunk-HNBG2POR.js.map +1 -0
  30. package/dist/{chunk-DKZ425AM.js → chunk-HNZQ7LM4.js} +11 -11
  31. package/dist/chunk-HNZQ7LM4.js.map +1 -0
  32. package/dist/{chunk-55DK75QF.js → chunk-I54DOEZB.js} +6 -6
  33. package/dist/chunk-I54DOEZB.js.map +1 -0
  34. package/dist/{chunk-WGPB3QQU.js → chunk-KFAGXPIK.js} +10 -10
  35. package/dist/chunk-KFAGXPIK.js.map +1 -0
  36. package/dist/{chunk-J2FACXYI.js → chunk-PANH23MF.js} +12 -12
  37. package/dist/chunk-PANH23MF.js.map +1 -0
  38. package/dist/{chunk-KKJEEKL2.js → chunk-PYVUQNFQ.js} +8 -8
  39. package/dist/chunk-PYVUQNFQ.js.map +1 -0
  40. package/dist/{chunk-RWWRTURA.js → chunk-Q54FX3SY.js} +8 -8
  41. package/dist/chunk-Q54FX3SY.js.map +1 -0
  42. package/dist/{chunk-AUVIOU5G.js → chunk-QBORJTS4.js} +36 -36
  43. package/dist/chunk-QBORJTS4.js.map +1 -0
  44. package/dist/{chunk-5QSTXIPG.js → chunk-RXX4CN5J.js} +7 -7
  45. package/dist/chunk-RXX4CN5J.js.map +1 -0
  46. package/dist/{chunk-XPCU4KUY.js → chunk-SV77SN6P.js} +7 -7
  47. package/dist/chunk-SV77SN6P.js.map +1 -0
  48. package/dist/{chunk-FVCM4WHD.js → chunk-TAZZLOUY.js} +10 -10
  49. package/dist/chunk-TAZZLOUY.js.map +1 -0
  50. package/dist/{chunk-KMCGX76Y.js → chunk-TRZO5CHU.js} +7 -7
  51. package/dist/chunk-TRZO5CHU.js.map +1 -0
  52. package/dist/{chunk-F4YQWKK2.js → chunk-UPOTBKKK.js} +7 -7
  53. package/dist/chunk-UPOTBKKK.js.map +1 -0
  54. package/dist/{chunk-APJ5JGRW.js → chunk-WP5WJ4V5.js} +6 -6
  55. package/dist/chunk-WP5WJ4V5.js.map +1 -0
  56. package/dist/{chunk-TCXKZDMR.js → chunk-WS5AUJ35.js} +7 -7
  57. package/dist/chunk-WS5AUJ35.js.map +1 -0
  58. package/dist/{chunk-7P4Z4CLK.js → chunk-WWYYNR3Z.js} +50 -49
  59. package/dist/chunk-WWYYNR3Z.js.map +1 -0
  60. package/dist/{chunk-RYBY35QE.js → chunk-XU2XODVH.js} +6 -6
  61. package/dist/chunk-XU2XODVH.js.map +1 -0
  62. package/dist/{chunk-3KO55PZK.js → chunk-YR6T73GY.js} +18 -11
  63. package/dist/chunk-YR6T73GY.js.map +1 -0
  64. package/dist/{chunk-IOBSIAHB.js → chunk-YYYQPKQ7.js} +24 -24
  65. package/dist/chunk-YYYQPKQ7.js.map +1 -0
  66. package/dist/{chunk-PO6FCAIS.js → chunk-Z45LY6BT.js} +9 -9
  67. package/dist/chunk-Z45LY6BT.js.map +1 -0
  68. package/dist/{chunk-DJEZW7AC.js → chunk-ZQBEFP2O.js} +7 -7
  69. package/dist/chunk-ZQBEFP2O.js.map +1 -0
  70. package/dist/chunk-ZS7RPXCT.js +47 -0
  71. package/dist/chunk-ZS7RPXCT.js.map +1 -0
  72. package/dist/components/accordion.d.ts +3 -3
  73. package/dist/components/accordion.js +4 -4
  74. package/dist/components/alert.d.ts +3 -3
  75. package/dist/components/alert.js +4 -4
  76. package/dist/components/app-ui.d.ts +25 -25
  77. package/dist/components/app-ui.js +21 -21
  78. package/dist/components/badge.d.ts +37 -0
  79. package/dist/components/badge.js +9 -0
  80. package/dist/components/blocks.d.ts +10 -73
  81. package/dist/components/blocks.js +10 -13
  82. package/dist/components/button.d.ts +3 -3
  83. package/dist/components/button.js +5 -5
  84. package/dist/components/checkbox-group.d.ts +2 -2
  85. package/dist/components/checkbox-group.js +5 -5
  86. package/dist/components/checkbox.d.ts +2 -2
  87. package/dist/components/checkbox.js +5 -5
  88. package/dist/components/chip.d.ts +58 -0
  89. package/dist/components/chip.js +8 -0
  90. package/dist/components/date-input.d.ts +2 -2
  91. package/dist/components/date-input.js +5 -5
  92. package/dist/components/dialog.d.ts +4 -4
  93. package/dist/components/dialog.js +4 -4
  94. package/dist/components/fieldset.d.ts +3 -3
  95. package/dist/components/fieldset.js +4 -4
  96. package/dist/components/grid.d.ts +3 -3
  97. package/dist/components/grid.js +4 -4
  98. package/dist/components/help.d.ts +3 -3
  99. package/dist/components/help.js +4 -4
  100. package/dist/components/icon.d.ts +3 -3
  101. package/dist/components/icon.js +4 -4
  102. package/dist/components/journey.d.ts +18 -18
  103. package/dist/components/journey.js +15 -15
  104. package/dist/components/layout.d.ts +9 -9
  105. package/dist/components/layout.js +10 -10
  106. package/dist/components/link.d.ts +3 -3
  107. package/dist/components/link.js +5 -5
  108. package/dist/components/list.d.ts +3 -3
  109. package/dist/components/list.js +4 -4
  110. package/dist/components/media.d.ts +8 -8
  111. package/dist/components/media.js +8 -8
  112. package/dist/components/navigation.d.ts +5 -5
  113. package/dist/components/navigation.js +7 -7
  114. package/dist/components/page.d.ts +5 -5
  115. package/dist/components/page.js +6 -6
  116. package/dist/components/price.d.ts +3 -3
  117. package/dist/components/price.js +4 -4
  118. package/dist/components/progress.d.ts +3 -3
  119. package/dist/components/progress.js +4 -4
  120. package/dist/components/radio-group.d.ts +2 -2
  121. package/dist/components/radio-group.js +5 -5
  122. package/dist/components/select.d.ts +2 -2
  123. package/dist/components/select.js +5 -5
  124. package/dist/components/summary-list.d.ts +3 -3
  125. package/dist/components/summary-list.js +4 -4
  126. package/dist/components/table.d.ts +6 -6
  127. package/dist/components/table.js +5 -5
  128. package/dist/components/text-input.d.ts +2 -2
  129. package/dist/components/text-input.js +5 -5
  130. package/dist/components/textarea.d.ts +2 -2
  131. package/dist/components/textarea.js +5 -5
  132. package/dist/index.d.ts +47 -40
  133. package/dist/index.js +206 -270
  134. package/dist/standalone/atomic-ui.js +796 -2002
  135. package/dist/standalone/atomic-ui.js.map +4 -4
  136. package/dist/standalone/index.html +51 -52
  137. package/package.json +4 -4
  138. package/specimen/index.html +51 -52
  139. package/dist/chunk-37PA72FC.js +0 -725
  140. package/dist/chunk-37PA72FC.js.map +0 -1
  141. package/dist/chunk-3KO55PZK.js.map +0 -1
  142. package/dist/chunk-3RE4H2XO.js.map +0 -1
  143. package/dist/chunk-46BYUQ5A.js.map +0 -1
  144. package/dist/chunk-4OYHT4BN.js.map +0 -1
  145. package/dist/chunk-55DK75QF.js.map +0 -1
  146. package/dist/chunk-5QSTXIPG.js.map +0 -1
  147. package/dist/chunk-7P4Z4CLK.js.map +0 -1
  148. package/dist/chunk-APJ5JGRW.js.map +0 -1
  149. package/dist/chunk-AUVIOU5G.js.map +0 -1
  150. package/dist/chunk-CUUBAETM.js.map +0 -1
  151. package/dist/chunk-DAH7RLW3.js.map +0 -1
  152. package/dist/chunk-DJEZW7AC.js.map +0 -1
  153. package/dist/chunk-DKZ425AM.js.map +0 -1
  154. package/dist/chunk-F4YQWKK2.js.map +0 -1
  155. package/dist/chunk-FVCM4WHD.js.map +0 -1
  156. package/dist/chunk-GBRML4RF.js +0 -264
  157. package/dist/chunk-GBRML4RF.js.map +0 -1
  158. package/dist/chunk-HXINWP3V.js.map +0 -1
  159. package/dist/chunk-IOBSIAHB.js.map +0 -1
  160. package/dist/chunk-IZOTGWWI.js +0 -361
  161. package/dist/chunk-IZOTGWWI.js.map +0 -1
  162. package/dist/chunk-J2FACXYI.js.map +0 -1
  163. package/dist/chunk-KKJEEKL2.js.map +0 -1
  164. package/dist/chunk-KMCGX76Y.js.map +0 -1
  165. package/dist/chunk-NKMVICB5.js.map +0 -1
  166. package/dist/chunk-OFLMG6RN.js +0 -428
  167. package/dist/chunk-OFLMG6RN.js.map +0 -1
  168. package/dist/chunk-P6GDMZK4.js.map +0 -1
  169. package/dist/chunk-PO6FCAIS.js.map +0 -1
  170. package/dist/chunk-PWLZFGS3.js +0 -494
  171. package/dist/chunk-PWLZFGS3.js.map +0 -1
  172. package/dist/chunk-QJIB36DM.js +0 -249
  173. package/dist/chunk-QJIB36DM.js.map +0 -1
  174. package/dist/chunk-R7FKGFW6.js.map +0 -1
  175. package/dist/chunk-RWWRTURA.js.map +0 -1
  176. package/dist/chunk-RYBY35QE.js.map +0 -1
  177. package/dist/chunk-S7F5VKWU.js +0 -453
  178. package/dist/chunk-S7F5VKWU.js.map +0 -1
  179. package/dist/chunk-T5W3FDSF.js +0 -396
  180. package/dist/chunk-T5W3FDSF.js.map +0 -1
  181. package/dist/chunk-TCXKZDMR.js.map +0 -1
  182. package/dist/chunk-WGPB3QQU.js.map +0 -1
  183. package/dist/chunk-XPCU4KUY.js.map +0 -1
  184. package/dist/chunk-YRYZUYY7.js +0 -236
  185. package/dist/chunk-YRYZUYY7.js.map +0 -1
  186. package/dist/chunk-ZOTAAYO5.js.map +0 -1
  187. package/dist/components/changelog.d.ts +0 -386
  188. package/dist/components/changelog.js +0 -25
  189. package/dist/components/estimator.d.ts +0 -246
  190. package/dist/components/estimator.js +0 -16
  191. package/dist/components/marketing.d.ts +0 -370
  192. package/dist/components/marketing.js +0 -21
  193. package/dist/components/marketing.js.map +0 -1
  194. package/dist/components/organisms.d.ts +0 -559
  195. package/dist/components/organisms.js +0 -25
  196. package/dist/components/organisms.js.map +0 -1
  197. package/dist/components/property.d.ts +0 -389
  198. package/dist/components/property.js +0 -20
  199. package/dist/components/property.js.map +0 -1
  200. package/dist/components/scene.d.ts +0 -138
  201. package/dist/components/scene.js +0 -8
  202. package/dist/components/scene.js.map +0 -1
  203. package/dist/components/scrubber.d.ts +0 -86
  204. package/dist/components/scrubber.js +0 -8
  205. package/dist/components/scrubber.js.map +0 -1
  206. package/dist/components/selling.d.ts +0 -409
  207. package/dist/components/selling.js +0 -25
  208. package/dist/components/selling.js.map +0 -1
  209. package/dist/components/site.d.ts +0 -283
  210. package/dist/components/site.js +0 -20
  211. package/dist/components/site.js.map +0 -1
  212. /package/dist/components/{changelog.js.map → badge.js.map} +0 -0
  213. /package/dist/components/{estimator.js.map → chip.js.map} +0 -0
@@ -1,236 +0,0 @@
1
- import {
2
- ImpktElement,
3
- fontSize,
4
- fontWeight,
5
- say,
6
- space,
7
- t,
8
- token,
9
- visuallyHidden
10
- } from "./chunk-3KO55PZK.js";
11
-
12
- // packages/ui/src/components/scrubber.ts
13
- import { html, css } from "lit";
14
- var TONES = {
15
- brand: "var(--impkt-color-brand-default, #1f4ed8)",
16
- accent: "var(--impkt-color-accent-default, #c8a15a)",
17
- info: "var(--impkt-color-status-info-default, #1f4ed8)",
18
- success: "var(--impkt-color-status-success-default, #047857)",
19
- warning: "var(--impkt-color-status-warning-default, #b45309)",
20
- danger: "var(--impkt-color-status-danger-default, #c8102e)"
21
- };
22
- var ImpktScrubber = class extends ImpktElement {
23
- constructor() {
24
- super();
25
- this.scene = null;
26
- this.onProgress = (e) => {
27
- this.value = e.detail.progress;
28
- };
29
- this.onInput = (e) => {
30
- const v = Number(e.target.value) / 1e3;
31
- this.value = v;
32
- this.scene?.seek(v);
33
- };
34
- this.label = "Scene progress";
35
- this.stops = [];
36
- this.look = "buttons";
37
- this.hint = "";
38
- this.value = 0;
39
- }
40
- static {
41
- this.properties = {
42
- label: { type: String },
43
- stops: { type: Array },
44
- look: { type: String, reflect: true },
45
- hint: { type: String },
46
- value: { type: Number, state: true }
47
- };
48
- }
49
- static {
50
- this.styles = [
51
- ...ImpktElement.styles,
52
- css`
53
- :host {
54
- display: block;
55
- width: 100%;
56
- max-width: 48rem;
57
- margin-inline: auto;
58
- }
59
- .wrap {
60
- display: grid;
61
- gap: ${space(2)};
62
- padding: ${space(3)} ${space(4)};
63
- border-radius: ${token("radius.xl", "16px")};
64
- background: ${t.surfaceCard};
65
- box-shadow: ${token("shadow.lg", "0 10px 15px -3px rgba(0,0,0,.1)")};
66
- border: 1px solid ${t.border};
67
- }
68
- input {
69
- width: 100%;
70
- min-height: ${token("target.min", "24px")};
71
- accent-color: ${t.brand};
72
- margin: 0;
73
- }
74
- .stops {
75
- position: relative;
76
- display: flex;
77
- flex-wrap: wrap;
78
- gap: ${space(2)};
79
- list-style: none;
80
- margin: 0;
81
- padding: 0;
82
- }
83
- button {
84
- min-height: ${token("target.min", "24px")};
85
- padding: ${space(1)} ${space(3)};
86
- border-radius: ${token("radius.full", "9999px")};
87
- border: 1px solid ${t.border};
88
- background: transparent;
89
- color: ${t.textMuted};
90
- font-size: ${fontSize("xs")};
91
- font-weight: ${fontWeight("medium")};
92
- cursor: pointer;
93
- }
94
- button[aria-current='true'] {
95
- color: ${t.text};
96
- border-color: ${t.text};
97
- }
98
- .sr-only {
99
- ${visuallyHidden}
100
- }
101
- /* The graph look: the code of where you are, the line of stops, where you are. */
102
- :host([look='graph']) { max-width: none; }
103
- .graph { display: grid; grid-template-columns: minmax(8rem, auto) minmax(0, 1fr) auto; gap: ${space(6)}; align-items: center; padding: ${space(4)} ${space(6)}; border-radius: ${token("radius.xl", "16px")}; background: ${t.surfaceCard}; box-shadow: ${token("shadow.lg", "0 10px 15px -3px rgba(0,0,0,.1)")}; border: 1px solid ${t.border}; }
104
- .mono { font-family: ${t.fontMono}; font-size: ${fontSize("xs")}; letter-spacing: 0.04em; }
105
- .head { display: grid; gap: 2px; }
106
- .head .k { color: ${t.textMuted}; text-transform: uppercase; }
107
- .head .code { font-size: ${fontSize("md")}; color: ${t.text}; }
108
- .head .note { color: ${t.textMuted}; }
109
- .line { position: relative; block-size: 48px; }
110
- .track, .fill { position: absolute; inset-inline: 0; inset-block-start: 14px; block-size: 3px; border-radius: 3px; background: ${t.border}; opacity: 0.5; }
111
- .fill { opacity: 1; background: none; display: flex; overflow: hidden; }
112
- .fill span { block-size: 100%; }
113
- .dot { position: absolute; inset-block-start: 15px; inline-size: 14px; block-size: 14px; translate: -50% -50%; border-radius: 50%; border: 2px solid var(--c); background: ${t.surfaceCard}; padding: 0; min-height: 0; cursor: pointer; }
114
- .dot[data-passed] { background: var(--c); }
115
- .dot[aria-current='true'] { inline-size: 24px; block-size: 24px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 25%, transparent); }
116
- .dot-label { position: absolute; inset-block-start: 30px; translate: -50% 0; white-space: nowrap; color: ${t.textMuted}; text-transform: uppercase; pointer-events: none; }
117
- .dot-label[data-current] { color: ${t.text}; font-weight: ${fontWeight("bold")}; }
118
- .line input { position: absolute; inset: 0 0 auto; block-size: 30px; opacity: 0; cursor: grab; }
119
- .line input:focus-visible { opacity: 1; }
120
- .where { display: grid; gap: ${space(2)}; justify-items: end; }
121
- .chip { display: inline-flex; align-items: center; gap: ${space(2)}; padding: ${space(1)} ${space(3)}; border-radius: ${token("radius.full", "9999px")}; border: 1px solid ${t.border}; color: ${t.text}; text-transform: uppercase; }
122
- .chip::before { content: ''; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--c); }
123
- .hint { color: ${t.textMuted}; text-transform: uppercase; }
124
- @media (max-width: 48rem) {
125
- .graph { grid-template-columns: minmax(0, 1fr); }
126
- .where { justify-items: start; }
127
- .dot-label:not([data-current]) { display: none; }
128
- }
129
- button:focus-visible,
130
- input:focus-visible {
131
- outline: none;
132
- box-shadow: ${token("focus.ring.shadow", "0 0 0 2px #fff, 0 0 0 4px #1a1a1a")};
133
- }
134
- `
135
- ];
136
- }
137
- /** @ignore */
138
- connectedCallback() {
139
- super.connectedCallback();
140
- this.scene = this.closest("impkt-scene");
141
- this.scene?.addEventListener("impkt-scene-progress", this.onProgress);
142
- if (this.scene) this.value = this.scene.progress;
143
- }
144
- /** @ignore */
145
- disconnectedCallback() {
146
- super.disconnectedCallback();
147
- this.scene?.removeEventListener("impkt-scene-progress", this.onProgress);
148
- this.scene = null;
149
- }
150
- goTo(stop) {
151
- this.scene?.seek(stop.at, 600);
152
- }
153
- /** The stop nearest the current position, which the stop list marks as current. */
154
- nearest() {
155
- let best = -1;
156
- let gap = Infinity;
157
- this.stops.forEach((s, i) => {
158
- const d = Math.abs(s.at - this.value);
159
- if (d < gap) {
160
- gap = d;
161
- best = i;
162
- }
163
- });
164
- return best;
165
- }
166
- renderGraph(nearestIndex, valueText) {
167
- let current = nearestIndex;
168
- const stops = [...this.stops ?? []].sort((a, b) => a.at - b.at);
169
- current = stops.indexOf(this.stops[current]);
170
- const colour = (s) => {
171
- const tone = s?.tone ?? "brand";
172
- return typeof tone === "number" ? `var(--impkt-color-chart-${tone}, ${TONES.brand})` : TONES[tone] ?? TONES.brand;
173
- };
174
- const now = stops[current] ?? stops[0];
175
- const segments = stops.map((s, i) => {
176
- const from = i === 0 ? 0 : stops[i - 1].at;
177
- const to = Math.min(s.at, this.value);
178
- return { width: Math.round(Math.max(0, to - from) * 1e4) / 100, c: colour(s) };
179
- });
180
- return html`<div class="graph" part="wrap">
181
- <div class="head mono" aria-hidden="true">
182
- <span class="k">HEAD</span>
183
- <span class="code">${now?.meta ?? now?.label ?? ""}</span>
184
- ${now?.note ? html`<span class="note">${now.note}</span>` : null}
185
- </div>
186
- <div class="line">
187
- <div class="track"></div>
188
- <div class="fill" aria-hidden="true">${segments.map((g) => html`<span style=${`width:${g.width}%;background:${g.c}`}></span>`)}</div>
189
- ${stops.map((s, i) => html`
190
- <button type="button" class="dot" style=${`left:${s.at * 100}%;--c:${colour(s)}`} ?data-passed=${s.at <= this.value + 1e-4} aria-current=${i === current ? "true" : "false"} @click=${() => this.goTo(s)}>
191
- <span class="sr-only">${say("Go to {name}", { name: s.label })}</span>
192
- </button>
193
- <span class="dot-label mono" style=${`left:${s.at * 100}%`} ?data-current=${i === current} aria-hidden="true">${s.label}</span>`)}
194
- <input type="range" min="0" max="1000" step="1" .value=${String(Math.round(this.value * 1e3))} aria-label=${this.label} aria-valuetext=${valueText} @input=${this.onInput} />
195
- </div>
196
- <div class="where" aria-hidden="true">
197
- ${now ? html`<span class="chip mono" style=${`--c:${colour(now)}`}>${now.label}${now.meta ? html`&nbsp;<span style="opacity:.6">${now.meta}</span>` : null}</span>` : null}
198
- ${this.hint ? html`<span class="hint mono">${this.hint}</span>` : null}
199
- </div>
200
- </div>`;
201
- }
202
- render() {
203
- const current = this.nearest();
204
- const valueText = current >= 0 ? this.stops[current].label : `${Math.round(this.value * 100)}%`;
205
- if (this.look === "graph") return this.renderGraph(current, valueText);
206
- return html`
207
- <div class="wrap" part="wrap">
208
- <input
209
- type="range"
210
- min="0"
211
- max="1000"
212
- step="1"
213
- .value=${String(Math.round(this.value * 1e3))}
214
- aria-label=${this.label}
215
- aria-valuetext=${valueText}
216
- @input=${this.onInput}
217
- />
218
- ${this.stops.length ? html`<ul class="stops" part="stops">
219
- ${this.stops.map(
220
- (s, i) => html`<li>
221
- <button type="button" aria-current=${i === current ? "true" : "false"} @click=${() => this.goTo(s)}>
222
- <span aria-hidden="true">${s.label}</span><span class="sr-only">${say("Go to {name}", { name: s.label })}</span>
223
- </button>
224
- </li>`
225
- )}
226
- </ul>` : null}
227
- </div>
228
- `;
229
- }
230
- };
231
- customElements.define("impkt-scrubber", ImpktScrubber);
232
-
233
- export {
234
- ImpktScrubber
235
- };
236
- //# sourceMappingURL=chunk-YRYZUYY7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/scrubber.ts"],"sourcesContent":["import { html, css, type TemplateResult } from 'lit';\nimport { say } from '../base/say';\nimport { ImpktElement } from '../base/ImpktElement';\nimport { visuallyHidden } from '../base/styles';\nimport { fontSize, fontWeight, space, t, token } from '../base/tokens';\nimport type { ImpktScene } from './scene';\n\nexport interface ScrubberStop {\n /** Where the stop sits on the scene's progress, from 0 to 1. */\n at: number;\n label: string;\n /** A short code beside it in the graph look, such as a commit hash. */\n meta?: string;\n /** A line under the code in the graph look, such as a commit message. */\n note?: string;\n /**\n * The colour of the line up to this stop, in the graph look: a named tone,\n * or 1 to 5 for the brand's chart colours, as a project's phases are drawn.\n */\n tone?: 'brand' | 'accent' | 'info' | 'success' | 'warning' | 'danger' | 1 | 2 | 3 | 4 | 5;\n}\n\nconst TONES = {\n brand: 'var(--impkt-color-brand-default, #1f4ed8)',\n accent: 'var(--impkt-color-accent-default, #c8a15a)',\n info: 'var(--impkt-color-status-info-default, #1f4ed8)',\n success: 'var(--impkt-color-status-success-default, #047857)',\n warning: 'var(--impkt-color-status-warning-default, #b45309)',\n danger: 'var(--impkt-color-status-danger-default, #c8102e)',\n} as const;\n\n/**\n * Drives the scene it sits in, by hand.\n *\n * Place it in an `impkt-scene`'s `controls` slot and set that scene's `drive`\n * to `scrubber`. Dragging moves through the scene; a named stop seeks to it\n * with an eased move rather than a cut, which is what makes the Commit-style\n * \"time travel\" read as travel.\n *\n * **It is a native range input.** A slider built from divs has to recreate\n * arrow keys, Page Up and Down, Home and End, the value announcement and touch\n * handling, and every one of those is a place to get it wrong. The input\n * already does all of it. The stops are buttons beside it, so a keyboard or\n * switch user reaches each named moment in one action instead of nudging a\n * thumb to find it (2.5.7, dragging movements).\n *\n * @category action\n * @icon adjustments-horizontal\n */\nexport class ImpktScrubber extends ImpktElement {\n static properties = {\n label: { type: String },\n stops: { type: Array },\n look: { type: String, reflect: true },\n hint: { type: String },\n value: { type: Number, state: true },\n };\n\n /** The slider's accessible name. */\n declare label: string;\n declare stops: ScrubberStop[];\n /**\n * `buttons` lists the stops as buttons under the slider. `graph` draws them\n * as commits on a line that fills in each stop's colour as it is dragged,\n * with the current one's code and note beside it.\n */\n declare look: 'buttons' | 'graph';\n /** A word of help in the graph look, such as \"drag to time-travel\". */\n declare hint: string;\n declare value: number;\n\n private scene: ImpktScene | null = null;\n\n constructor() {\n super();\n this.label = 'Scene progress';\n this.stops = [];\n this.look = 'buttons';\n this.hint = '';\n this.value = 0;\n }\n\n static styles = [\n ...ImpktElement.styles,\n css`\n :host {\n display: block;\n width: 100%;\n max-width: 48rem;\n margin-inline: auto;\n }\n .wrap {\n display: grid;\n gap: ${space(2)};\n padding: ${space(3)} ${space(4)};\n border-radius: ${token('radius.xl', '16px')};\n background: ${t.surfaceCard};\n box-shadow: ${token('shadow.lg', '0 10px 15px -3px rgba(0,0,0,.1)')};\n border: 1px solid ${t.border};\n }\n input {\n width: 100%;\n min-height: ${token('target.min', '24px')};\n accent-color: ${t.brand};\n margin: 0;\n }\n .stops {\n position: relative;\n display: flex;\n flex-wrap: wrap;\n gap: ${space(2)};\n list-style: none;\n margin: 0;\n padding: 0;\n }\n button {\n min-height: ${token('target.min', '24px')};\n padding: ${space(1)} ${space(3)};\n border-radius: ${token('radius.full', '9999px')};\n border: 1px solid ${t.border};\n background: transparent;\n color: ${t.textMuted};\n font-size: ${fontSize('xs')};\n font-weight: ${fontWeight('medium')};\n cursor: pointer;\n }\n button[aria-current='true'] {\n color: ${t.text};\n border-color: ${t.text};\n }\n .sr-only {\n ${visuallyHidden}\n }\n /* The graph look: the code of where you are, the line of stops, where you are. */\n :host([look='graph']) { max-width: none; }\n .graph { display: grid; grid-template-columns: minmax(8rem, auto) minmax(0, 1fr) auto; gap: ${space(6)}; align-items: center; padding: ${space(4)} ${space(6)}; border-radius: ${token('radius.xl', '16px')}; background: ${t.surfaceCard}; box-shadow: ${token('shadow.lg', '0 10px 15px -3px rgba(0,0,0,.1)')}; border: 1px solid ${t.border}; }\n .mono { font-family: ${t.fontMono}; font-size: ${fontSize('xs')}; letter-spacing: 0.04em; }\n .head { display: grid; gap: 2px; }\n .head .k { color: ${t.textMuted}; text-transform: uppercase; }\n .head .code { font-size: ${fontSize('md')}; color: ${t.text}; }\n .head .note { color: ${t.textMuted}; }\n .line { position: relative; block-size: 48px; }\n .track, .fill { position: absolute; inset-inline: 0; inset-block-start: 14px; block-size: 3px; border-radius: 3px; background: ${t.border}; opacity: 0.5; }\n .fill { opacity: 1; background: none; display: flex; overflow: hidden; }\n .fill span { block-size: 100%; }\n .dot { position: absolute; inset-block-start: 15px; inline-size: 14px; block-size: 14px; translate: -50% -50%; border-radius: 50%; border: 2px solid var(--c); background: ${t.surfaceCard}; padding: 0; min-height: 0; cursor: pointer; }\n .dot[data-passed] { background: var(--c); }\n .dot[aria-current='true'] { inline-size: 24px; block-size: 24px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 25%, transparent); }\n .dot-label { position: absolute; inset-block-start: 30px; translate: -50% 0; white-space: nowrap; color: ${t.textMuted}; text-transform: uppercase; pointer-events: none; }\n .dot-label[data-current] { color: ${t.text}; font-weight: ${fontWeight('bold')}; }\n .line input { position: absolute; inset: 0 0 auto; block-size: 30px; opacity: 0; cursor: grab; }\n .line input:focus-visible { opacity: 1; }\n .where { display: grid; gap: ${space(2)}; justify-items: end; }\n .chip { display: inline-flex; align-items: center; gap: ${space(2)}; padding: ${space(1)} ${space(3)}; border-radius: ${token('radius.full', '9999px')}; border: 1px solid ${t.border}; color: ${t.text}; text-transform: uppercase; }\n .chip::before { content: ''; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--c); }\n .hint { color: ${t.textMuted}; text-transform: uppercase; }\n @media (max-width: 48rem) {\n .graph { grid-template-columns: minmax(0, 1fr); }\n .where { justify-items: start; }\n .dot-label:not([data-current]) { display: none; }\n }\n button:focus-visible,\n input:focus-visible {\n outline: none;\n box-shadow: ${token('focus.ring.shadow', '0 0 0 2px #fff, 0 0 0 4px #1a1a1a')};\n }\n `,\n ];\n\n /** @ignore */\n connectedCallback(): void {\n super.connectedCallback();\n this.scene = this.closest('impkt-scene');\n this.scene?.addEventListener('impkt-scene-progress', this.onProgress);\n if (this.scene) this.value = this.scene.progress;\n }\n\n /** @ignore */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.scene?.removeEventListener('impkt-scene-progress', this.onProgress);\n this.scene = null;\n }\n\n private onProgress = (e: Event) => {\n this.value = (e as CustomEvent<{ progress: number }>).detail.progress;\n };\n\n private onInput = (e: Event) => {\n const v = Number((e.target as HTMLInputElement).value) / 1000;\n this.value = v;\n this.scene?.seek(v);\n };\n\n private goTo(stop: ScrubberStop) {\n this.scene?.seek(stop.at, 600);\n }\n\n /** The stop nearest the current position, which the stop list marks as current. */\n private nearest(): number {\n let best = -1;\n let gap = Infinity;\n this.stops.forEach((s, i) => {\n const d = Math.abs(s.at - this.value);\n if (d < gap) {\n gap = d;\n best = i;\n }\n });\n return best;\n }\n\n private renderGraph(nearestIndex: number, valueText: string): TemplateResult {\n let current = nearestIndex;\n const stops = [...(this.stops ?? [])].sort((a, b) => a.at - b.at);\n // Where you are, among the stops in the order they are drawn.\n current = stops.indexOf(this.stops[current]!);\n const colour = (s: ScrubberStop | undefined) => {\n const tone = s?.tone ?? 'brand';\n return typeof tone === 'number' ? `var(--impkt-color-chart-${tone}, ${TONES.brand})` : TONES[tone] ?? TONES.brand;\n };\n const now = stops[current] ?? stops[0];\n // The line fills in each stop's colour, from the stop before it to it, as far as the playhead.\n const segments = stops.map((s, i) => {\n const from = i === 0 ? 0 : stops[i - 1]!.at;\n const to = Math.min(s.at, this.value);\n return { width: Math.round(Math.max(0, to - from) * 10000) / 100, c: colour(s) };\n });\n return html`<div class=\"graph\" part=\"wrap\">\n <div class=\"head mono\" aria-hidden=\"true\">\n <span class=\"k\">HEAD</span>\n <span class=\"code\">${now?.meta ?? now?.label ?? ''}</span>\n ${now?.note ? html`<span class=\"note\">${now.note}</span>` : null}\n </div>\n <div class=\"line\">\n <div class=\"track\"></div>\n <div class=\"fill\" aria-hidden=\"true\">${segments.map((g) => html`<span style=${`width:${g.width}%;background:${g.c}`}></span>`)}</div>\n ${stops.map((s, i) => html`\n <button type=\"button\" class=\"dot\" style=${`left:${s.at * 100}%;--c:${colour(s)}`} ?data-passed=${s.at <= this.value + 0.0001} aria-current=${i === current ? 'true' : 'false'} @click=${() => this.goTo(s)}>\n <span class=\"sr-only\">${say('Go to {name}', { name: s.label })}</span>\n </button>\n <span class=\"dot-label mono\" style=${`left:${s.at * 100}%`} ?data-current=${i === current} aria-hidden=\"true\">${s.label}</span>`)}\n <input type=\"range\" min=\"0\" max=\"1000\" step=\"1\" .value=${String(Math.round(this.value * 1000))} aria-label=${this.label} aria-valuetext=${valueText} @input=${this.onInput} />\n </div>\n <div class=\"where\" aria-hidden=\"true\">\n ${now ? html`<span class=\"chip mono\" style=${`--c:${colour(now)}`}>${now.label}${now.meta ? html`&nbsp;<span style=\"opacity:.6\">${now.meta}</span>` : null}</span>` : null}\n ${this.hint ? html`<span class=\"hint mono\">${this.hint}</span>` : null}\n </div>\n </div>`;\n }\n\n render(): TemplateResult {\n const current = this.nearest();\n const valueText = current >= 0 ? this.stops[current].label : `${Math.round(this.value * 100)}%`;\n if (this.look === 'graph') return this.renderGraph(current, valueText);\n return html`\n <div class=\"wrap\" part=\"wrap\">\n <input\n type=\"range\"\n min=\"0\"\n max=\"1000\"\n step=\"1\"\n .value=${String(Math.round(this.value * 1000))}\n aria-label=${this.label}\n aria-valuetext=${valueText}\n @input=${this.onInput}\n />\n ${this.stops.length\n ? html`<ul class=\"stops\" part=\"stops\">\n ${this.stops.map(\n (s, i) => html`<li>\n <button type=\"button\" aria-current=${i === current ? 'true' : 'false'} @click=${() => this.goTo(s)}>\n <span aria-hidden=\"true\">${s.label}</span><span class=\"sr-only\">${say('Go to {name}', { name: s.label })}</span>\n </button>\n </li>`,\n )}\n </ul>`\n : null}\n </div>\n `;\n }\n}\n\ncustomElements.define('impkt-scrubber', ImpktScrubber);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impkt-scrubber': ImpktScrubber }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,MAAM,WAAgC;AAsB/C,IAAM,QAAQ;AAAA,EACZ,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AACV;AAoBO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAwB9C,cAAc;AACZ,UAAM;AAHR,SAAQ,QAA2B;AAiHnC,SAAQ,aAAa,CAAC,MAAa;AACjC,WAAK,QAAS,EAAwC,OAAO;AAAA,IAC/D;AAEA,SAAQ,UAAU,CAAC,MAAa;AAC9B,YAAM,IAAI,OAAQ,EAAE,OAA4B,KAAK,IAAI;AACzD,WAAK,QAAQ;AACb,WAAK,OAAO,KAAK,CAAC;AAAA,IACpB;AArHE,SAAK,QAAQ;AACb,SAAK,QAAQ,CAAC;AACd,SAAK,OAAO;AACZ,SAAK,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,KAAK,KAAK,CAAC,CAAC;AAAA,+CACrE,EAAE,KAAK,gCAAgC,IAAI,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAAA;AAAA;AAAA,IAG9G,CAAC;AAAA,qBAEH,IAAI;AAAA;AAAA;AAAA,EAGd;AACF;AAEA,eAAe,OAAO,kBAAkB,aAAa;","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\n/**\n * The base of every form control.\n *\n * @fires {CustomEvent<{ value: string }>} impkt-change - When the answer changes. The answer is in detail.value.\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 /**\n * Focusing the element focuses its control, so `el.focus()` from an app, a\n * React ref or the error summary's link lands where someone can type, rather\n * than on a host that cannot take focus and so silently does nothing.\n */\n focus(options?: FocusOptions): void {\n const control = this.renderRoot?.querySelector<HTMLElement>(`#${this.controlId}`)\n ?? this.renderRoot?.querySelector<HTMLElement>('input, select, textarea, button');\n if (control) control.focus(options);\n else super.focus(options);\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,eAAo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