@newtone-dev/ui-react-web 0.2.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 (304) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +83 -0
  3. package/dist/accordion/accordion.css +239 -0
  4. package/dist/accordion/accordion.d.ts +106 -0
  5. package/dist/accordion/accordion.d.ts.map +1 -0
  6. package/dist/accordion/accordion.js +15 -0
  7. package/dist/accordion/accordion.js.map +1 -0
  8. package/dist/accordion/index.d.ts +4 -0
  9. package/dist/accordion/index.d.ts.map +1 -0
  10. package/dist/accordion/index.js +3 -0
  11. package/dist/accordion/index.js.map +1 -0
  12. package/dist/action/action.css +86 -0
  13. package/dist/action/action.d.ts +62 -0
  14. package/dist/action/action.d.ts.map +1 -0
  15. package/dist/action/action.js +59 -0
  16. package/dist/action/action.js.map +1 -0
  17. package/dist/action/index.d.ts +4 -0
  18. package/dist/action/index.d.ts.map +1 -0
  19. package/dist/action/index.js +3 -0
  20. package/dist/action/index.js.map +1 -0
  21. package/dist/avatar/avatar.css +39 -0
  22. package/dist/avatar/avatar.d.ts +43 -0
  23. package/dist/avatar/avatar.d.ts.map +1 -0
  24. package/dist/avatar/avatar.js +38 -0
  25. package/dist/avatar/avatar.js.map +1 -0
  26. package/dist/avatar/index.d.ts +4 -0
  27. package/dist/avatar/index.d.ts.map +1 -0
  28. package/dist/avatar/index.js +3 -0
  29. package/dist/avatar/index.js.map +1 -0
  30. package/dist/button/button.css +112 -0
  31. package/dist/button/button.d.ts +36 -0
  32. package/dist/button/button.d.ts.map +1 -0
  33. package/dist/button/button.js +24 -0
  34. package/dist/button/button.js.map +1 -0
  35. package/dist/button/index.d.ts +3 -0
  36. package/dist/button/index.d.ts.map +1 -0
  37. package/dist/button/index.js +2 -0
  38. package/dist/button/index.js.map +1 -0
  39. package/dist/card-box/card-box.css +75 -0
  40. package/dist/card-box/card-box.d.ts +114 -0
  41. package/dist/card-box/card-box.d.ts.map +1 -0
  42. package/dist/card-box/card-box.js +9 -0
  43. package/dist/card-box/card-box.js.map +1 -0
  44. package/dist/card-box/index.d.ts +4 -0
  45. package/dist/card-box/index.d.ts.map +1 -0
  46. package/dist/card-box/index.js +3 -0
  47. package/dist/card-box/index.js.map +1 -0
  48. package/dist/card-grid/card-grid.css +97 -0
  49. package/dist/card-grid/card-grid.d.ts +63 -0
  50. package/dist/card-grid/card-grid.d.ts.map +1 -0
  51. package/dist/card-grid/card-grid.js +27 -0
  52. package/dist/card-grid/card-grid.js.map +1 -0
  53. package/dist/card-grid/index.d.ts +4 -0
  54. package/dist/card-grid/index.d.ts.map +1 -0
  55. package/dist/card-grid/index.js +3 -0
  56. package/dist/card-grid/index.js.map +1 -0
  57. package/dist/color/gamut.d.ts +20 -0
  58. package/dist/color/gamut.d.ts.map +1 -0
  59. package/dist/color/gamut.js +72 -0
  60. package/dist/color/gamut.js.map +1 -0
  61. package/dist/color/index.d.ts +8 -0
  62. package/dist/color/index.d.ts.map +1 -0
  63. package/dist/color/index.js +21 -0
  64. package/dist/color/index.js.map +1 -0
  65. package/dist/color/oklch.d.ts +35 -0
  66. package/dist/color/oklch.d.ts.map +1 -0
  67. package/dist/color/oklch.js +103 -0
  68. package/dist/color/oklch.js.map +1 -0
  69. package/dist/color/scale.d.ts +20 -0
  70. package/dist/color/scale.d.ts.map +1 -0
  71. package/dist/color/scale.js +75 -0
  72. package/dist/color/scale.js.map +1 -0
  73. package/dist/color/seeds.d.ts +33 -0
  74. package/dist/color/seeds.d.ts.map +1 -0
  75. package/dist/color/seeds.js +148 -0
  76. package/dist/color/seeds.js.map +1 -0
  77. package/dist/control/control.css +203 -0
  78. package/dist/control/control.d.ts +112 -0
  79. package/dist/control/control.d.ts.map +1 -0
  80. package/dist/control/control.js +107 -0
  81. package/dist/control/control.js.map +1 -0
  82. package/dist/control/index.d.ts +4 -0
  83. package/dist/control/index.d.ts.map +1 -0
  84. package/dist/control/index.js +3 -0
  85. package/dist/control/index.js.map +1 -0
  86. package/dist/data-list/data-list.css +52 -0
  87. package/dist/data-list/data-list.d.ts +55 -0
  88. package/dist/data-list/data-list.d.ts.map +1 -0
  89. package/dist/data-list/data-list.js +51 -0
  90. package/dist/data-list/data-list.js.map +1 -0
  91. package/dist/data-list/index.d.ts +5 -0
  92. package/dist/data-list/index.d.ts.map +1 -0
  93. package/dist/data-list/index.js +3 -0
  94. package/dist/data-list/index.js.map +1 -0
  95. package/dist/data-list/row/row.d.ts +16 -0
  96. package/dist/data-list/row/row.d.ts.map +1 -0
  97. package/dist/data-list/row/row.js +15 -0
  98. package/dist/data-list/row/row.js.map +1 -0
  99. package/dist/feature-card/feature-card.css +93 -0
  100. package/dist/feature-card/feature-card.d.ts +68 -0
  101. package/dist/feature-card/feature-card.d.ts.map +1 -0
  102. package/dist/feature-card/feature-card.js +11 -0
  103. package/dist/feature-card/feature-card.js.map +1 -0
  104. package/dist/feature-card/index.d.ts +4 -0
  105. package/dist/feature-card/index.d.ts.map +1 -0
  106. package/dist/feature-card/index.js +3 -0
  107. package/dist/feature-card/index.js.map +1 -0
  108. package/dist/framed-icon/framed-icon.css +77 -0
  109. package/dist/framed-icon/framed-icon.d.ts +61 -0
  110. package/dist/framed-icon/framed-icon.d.ts.map +1 -0
  111. package/dist/framed-icon/framed-icon.js +14 -0
  112. package/dist/framed-icon/framed-icon.js.map +1 -0
  113. package/dist/framed-icon/index.d.ts +4 -0
  114. package/dist/framed-icon/index.d.ts.map +1 -0
  115. package/dist/framed-icon/index.js +3 -0
  116. package/dist/framed-icon/index.js.map +1 -0
  117. package/dist/gallery/gallery.css +165 -0
  118. package/dist/gallery/gallery.d.ts +85 -0
  119. package/dist/gallery/gallery.d.ts.map +1 -0
  120. package/dist/gallery/gallery.js +75 -0
  121. package/dist/gallery/gallery.js.map +1 -0
  122. package/dist/gallery/index.d.ts +4 -0
  123. package/dist/gallery/index.d.ts.map +1 -0
  124. package/dist/gallery/index.js +3 -0
  125. package/dist/gallery/index.js.map +1 -0
  126. package/dist/icon/icon.css +83 -0
  127. package/dist/icon/icon.d.ts +69 -0
  128. package/dist/icon/icon.d.ts.map +1 -0
  129. package/dist/icon/icon.js +18 -0
  130. package/dist/icon/icon.js.map +1 -0
  131. package/dist/icon/index.d.ts +4 -0
  132. package/dist/icon/index.d.ts.map +1 -0
  133. package/dist/icon/index.js +3 -0
  134. package/dist/icon/index.js.map +1 -0
  135. package/dist/icon-link/icon-link.css +57 -0
  136. package/dist/icon-link/icon-link.d.ts +47 -0
  137. package/dist/icon-link/icon-link.d.ts.map +1 -0
  138. package/dist/icon-link/icon-link.js +35 -0
  139. package/dist/icon-link/icon-link.js.map +1 -0
  140. package/dist/icon-link/index.d.ts +4 -0
  141. package/dist/icon-link/index.d.ts.map +1 -0
  142. package/dist/icon-link/index.js +3 -0
  143. package/dist/icon-link/index.js.map +1 -0
  144. package/dist/identity/identity.d.ts +25 -0
  145. package/dist/identity/identity.d.ts.map +1 -0
  146. package/dist/identity/identity.js +25 -0
  147. package/dist/identity/identity.js.map +1 -0
  148. package/dist/identity/index.d.ts +3 -0
  149. package/dist/identity/index.d.ts.map +1 -0
  150. package/dist/identity/index.js +2 -0
  151. package/dist/identity/index.js.map +1 -0
  152. package/dist/index.d.ts +57 -0
  153. package/dist/index.d.ts.map +1 -0
  154. package/dist/index.js +29 -0
  155. package/dist/index.js.map +1 -0
  156. package/dist/link/index.d.ts +3 -0
  157. package/dist/link/index.d.ts.map +1 -0
  158. package/dist/link/index.js +2 -0
  159. package/dist/link/index.js.map +1 -0
  160. package/dist/link/link.css +65 -0
  161. package/dist/link/link.d.ts +38 -0
  162. package/dist/link/link.d.ts.map +1 -0
  163. package/dist/link/link.js +22 -0
  164. package/dist/link/link.js.map +1 -0
  165. package/dist/logo-marquee/index.d.ts +4 -0
  166. package/dist/logo-marquee/index.d.ts.map +1 -0
  167. package/dist/logo-marquee/index.js +3 -0
  168. package/dist/logo-marquee/index.js.map +1 -0
  169. package/dist/logo-marquee/logo-marquee.css +227 -0
  170. package/dist/logo-marquee/logo-marquee.d.ts +69 -0
  171. package/dist/logo-marquee/logo-marquee.d.ts.map +1 -0
  172. package/dist/logo-marquee/logo-marquee.js +11 -0
  173. package/dist/logo-marquee/logo-marquee.js.map +1 -0
  174. package/dist/media-plate/index.d.ts +4 -0
  175. package/dist/media-plate/index.d.ts.map +1 -0
  176. package/dist/media-plate/index.js +3 -0
  177. package/dist/media-plate/index.js.map +1 -0
  178. package/dist/media-plate/media-plate.css +41 -0
  179. package/dist/media-plate/media-plate.d.ts +45 -0
  180. package/dist/media-plate/media-plate.d.ts.map +1 -0
  181. package/dist/media-plate/media-plate.js +5 -0
  182. package/dist/media-plate/media-plate.js.map +1 -0
  183. package/dist/media-window/media-window.css +82 -0
  184. package/dist/navbar/actions/actions.d.ts +14 -0
  185. package/dist/navbar/actions/actions.d.ts.map +1 -0
  186. package/dist/navbar/actions/actions.js +12 -0
  187. package/dist/navbar/actions/actions.js.map +1 -0
  188. package/dist/navbar/brand/brand.d.ts +12 -0
  189. package/dist/navbar/brand/brand.d.ts.map +1 -0
  190. package/dist/navbar/brand/brand.js +10 -0
  191. package/dist/navbar/brand/brand.js.map +1 -0
  192. package/dist/navbar/context.d.ts +12 -0
  193. package/dist/navbar/context.d.ts.map +1 -0
  194. package/dist/navbar/context.js +13 -0
  195. package/dist/navbar/context.js.map +1 -0
  196. package/dist/navbar/index.d.ts +8 -0
  197. package/dist/navbar/index.d.ts.map +1 -0
  198. package/dist/navbar/index.js +8 -0
  199. package/dist/navbar/index.js.map +1 -0
  200. package/dist/navbar/link/drawer/drawer.css +50 -0
  201. package/dist/navbar/link/drawer/drawer.d.ts +20 -0
  202. package/dist/navbar/link/drawer/drawer.d.ts.map +1 -0
  203. package/dist/navbar/link/drawer/drawer.js +44 -0
  204. package/dist/navbar/link/drawer/drawer.js.map +1 -0
  205. package/dist/navbar/link/link.css +54 -0
  206. package/dist/navbar/link/link.d.ts +30 -0
  207. package/dist/navbar/link/link.d.ts.map +1 -0
  208. package/dist/navbar/link/link.js +29 -0
  209. package/dist/navbar/link/link.js.map +1 -0
  210. package/dist/navbar/links/links.d.ts +14 -0
  211. package/dist/navbar/links/links.d.ts.map +1 -0
  212. package/dist/navbar/links/links.js +14 -0
  213. package/dist/navbar/links/links.js.map +1 -0
  214. package/dist/navbar/menu-button/menu-button.css +20 -0
  215. package/dist/navbar/menu-button/menu-button.d.ts +13 -0
  216. package/dist/navbar/menu-button/menu-button.d.ts.map +1 -0
  217. package/dist/navbar/menu-button/menu-button.js +20 -0
  218. package/dist/navbar/menu-button/menu-button.js.map +1 -0
  219. package/dist/navbar/navbar.css +179 -0
  220. package/dist/navbar/navbar.d.ts +58 -0
  221. package/dist/navbar/navbar.d.ts.map +1 -0
  222. package/dist/navbar/navbar.js +96 -0
  223. package/dist/navbar/navbar.js.map +1 -0
  224. package/dist/numbered-list/index.d.ts +4 -0
  225. package/dist/numbered-list/index.d.ts.map +1 -0
  226. package/dist/numbered-list/index.js +3 -0
  227. package/dist/numbered-list/index.js.map +1 -0
  228. package/dist/numbered-list/numbered-list.css +46 -0
  229. package/dist/numbered-list/numbered-list.d.ts +31 -0
  230. package/dist/numbered-list/numbered-list.d.ts.map +1 -0
  231. package/dist/numbered-list/numbered-list.js +26 -0
  232. package/dist/numbered-list/numbered-list.js.map +1 -0
  233. package/dist/on-media/on-media.css +198 -0
  234. package/dist/quick-action/index.d.ts +4 -0
  235. package/dist/quick-action/index.d.ts.map +1 -0
  236. package/dist/quick-action/index.js +3 -0
  237. package/dist/quick-action/index.js.map +1 -0
  238. package/dist/quick-action/quick-action.css +70 -0
  239. package/dist/quick-action/quick-action.d.ts +68 -0
  240. package/dist/quick-action/quick-action.d.ts.map +1 -0
  241. package/dist/quick-action/quick-action.js +54 -0
  242. package/dist/quick-action/quick-action.js.map +1 -0
  243. package/dist/segmented-control/index.d.ts +4 -0
  244. package/dist/segmented-control/index.d.ts.map +1 -0
  245. package/dist/segmented-control/index.js +3 -0
  246. package/dist/segmented-control/index.js.map +1 -0
  247. package/dist/segmented-control/segmented-control.css +206 -0
  248. package/dist/segmented-control/segmented-control.d.ts +91 -0
  249. package/dist/segmented-control/segmented-control.d.ts.map +1 -0
  250. package/dist/segmented-control/segmented-control.js +9 -0
  251. package/dist/segmented-control/segmented-control.js.map +1 -0
  252. package/dist/stat-card/index.d.ts +4 -0
  253. package/dist/stat-card/index.d.ts.map +1 -0
  254. package/dist/stat-card/index.js +3 -0
  255. package/dist/stat-card/index.js.map +1 -0
  256. package/dist/stat-card/stat-card.css +56 -0
  257. package/dist/stat-card/stat-card.d.ts +48 -0
  258. package/dist/stat-card/stat-card.d.ts.map +1 -0
  259. package/dist/stat-card/stat-card.js +11 -0
  260. package/dist/stat-card/stat-card.js.map +1 -0
  261. package/dist/surface/index.d.ts +3 -0
  262. package/dist/surface/index.d.ts.map +1 -0
  263. package/dist/surface/index.js +2 -0
  264. package/dist/surface/index.js.map +1 -0
  265. package/dist/surface/surface.d.ts +40 -0
  266. package/dist/surface/surface.d.ts.map +1 -0
  267. package/dist/surface/surface.js +22 -0
  268. package/dist/surface/surface.js.map +1 -0
  269. package/dist/tag/index.d.ts +4 -0
  270. package/dist/tag/index.d.ts.map +1 -0
  271. package/dist/tag/index.js +3 -0
  272. package/dist/tag/index.js.map +1 -0
  273. package/dist/tag/tag.css +77 -0
  274. package/dist/tag/tag.d.ts +80 -0
  275. package/dist/tag/tag.d.ts.map +1 -0
  276. package/dist/tag/tag.js +16 -0
  277. package/dist/tag/tag.js.map +1 -0
  278. package/dist/text/index.d.ts +3 -0
  279. package/dist/text/index.d.ts.map +1 -0
  280. package/dist/text/index.js +2 -0
  281. package/dist/text/index.js.map +1 -0
  282. package/dist/text/text.css +232 -0
  283. package/dist/text/text.d.ts +64 -0
  284. package/dist/text/text.d.ts.map +1 -0
  285. package/dist/text/text.js +37 -0
  286. package/dist/text/text.js.map +1 -0
  287. package/dist/video-lightbox/index.d.ts +4 -0
  288. package/dist/video-lightbox/index.d.ts.map +1 -0
  289. package/dist/video-lightbox/index.js +3 -0
  290. package/dist/video-lightbox/index.js.map +1 -0
  291. package/dist/video-lightbox/video-lightbox.css +167 -0
  292. package/dist/video-lightbox/video-lightbox.d.ts +92 -0
  293. package/dist/video-lightbox/video-lightbox.d.ts.map +1 -0
  294. package/dist/video-lightbox/video-lightbox.js +31 -0
  295. package/dist/video-lightbox/video-lightbox.js.map +1 -0
  296. package/dist/wrapper/index.d.ts +3 -0
  297. package/dist/wrapper/index.d.ts.map +1 -0
  298. package/dist/wrapper/index.js +2 -0
  299. package/dist/wrapper/index.js.map +1 -0
  300. package/dist/wrapper/wrapper.d.ts +113 -0
  301. package/dist/wrapper/wrapper.d.ts.map +1 -0
  302. package/dist/wrapper/wrapper.js +83 -0
  303. package/dist/wrapper/wrapper.js.map +1 -0
  304. package/package.json +184 -0
@@ -0,0 +1,75 @@
1
+ // CIE L*, the lightness search, and the fifty-one steps.
2
+ //
3
+ // Contract sections 6.5 and 3. The shape is `L* = 100 - 2 x step`, computed rather than
4
+ // tabulated -- see the blueprint's section 5: "the derivation is computed, never tabulated".
5
+ //
6
+ // Private to `color/`. What leaves the folder is decided by index.ts.
7
+ import { clamp01, oklchToLinearSrgb, oklchToHex } from './oklch.js';
8
+ import { colorAt } from './gamut.js';
9
+ // ---------------------------------------------------------------------------
10
+ // Section 6.5 -- CIE L*, and the lightness search
11
+ // ---------------------------------------------------------------------------
12
+ const DELTA = 6 / 29;
13
+ const DELTA_SQ = DELTA * DELTA;
14
+ const DELTA_CU = DELTA * DELTA * DELTA;
15
+ function cieLstar({ l, c, h }) {
16
+ const [r, g, b] = oklchToLinearSrgb(l, c, h);
17
+ const y = 0.2126 * clamp01(r) + 0.7152 * clamp01(g) + 0.0722 * clamp01(b);
18
+ // The linear branch is not decoration: without it the curve has infinite slope at zero
19
+ // and the search below cannot converge on the last step.
20
+ const f = y > DELTA_CU ? Math.cbrt(y) : y / (3 * DELTA_SQ) + 4 / 29;
21
+ return 116 * f - 16;
22
+ }
23
+ /**
24
+ * The colour whose CIE L* is `target`, found by bisection on OKLCH lightness.
25
+ *
26
+ * The colour is rebuilt at every probe, CHROMA INCLUDED: chroma depends on lightness
27
+ * through the ceiling, and luminance depends on chroma. Searching on lightness while
28
+ * holding chroma fixed converges on the wrong L.
29
+ */
30
+ function atLstar(hue, chroma, gamut, target) {
31
+ let lo = 0;
32
+ let hi = 1;
33
+ for (let i = 0; i < 30; i++) {
34
+ const mid = (lo + hi) / 2;
35
+ if (cieLstar(colorAt(hue, chroma, gamut, mid)) < target)
36
+ lo = mid;
37
+ else
38
+ hi = mid;
39
+ }
40
+ return colorAt(hue, chroma, gamut, (lo + hi) / 2);
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // Section 3 -- the palette
44
+ // ---------------------------------------------------------------------------
45
+ /** Fifty-one steps, index 0 to 50. Fixed by section 5.1, not by the colour maths. */
46
+ export const STEPS = 51;
47
+ /**
48
+ * One palette's fifty-one steps, from a hue and a saturation ratio.
49
+ *
50
+ * Derived TWICE, not encoded twice: the hex comes off a vector clamped to the sRGB
51
+ * ceiling and the OKLCH channels off one at the P3 ceiling. Where a colour fits inside
52
+ * sRGB the two agree; where it does not they do not round-trip, and that is section 6.7
53
+ * rather than a rounding artefact.
54
+ *
55
+ * Quantised at 6 places for `l` and `c` -- which is what makes the L* = 0 endpoint round
56
+ * to exactly 0 rather than to 4.66e-10 -- and 2 for `h`, a seed input never searched for.
57
+ */
58
+ export function deriveScale(hue, chroma) {
59
+ const out = [];
60
+ for (let step = 0; step < STEPS; step++) {
61
+ const target = Math.max(0, 100 - step * 2);
62
+ const p3 = atLstar(hue, chroma, 'p3', target);
63
+ const srgb = atLstar(hue, chroma, 'srgb', target);
64
+ out.push({
65
+ oklch: {
66
+ l: Number(p3.l.toFixed(6)),
67
+ c: Number(p3.c.toFixed(6)),
68
+ h: Number(p3.h.toFixed(2)),
69
+ },
70
+ srgb: oklchToHex(srgb),
71
+ });
72
+ }
73
+ return out;
74
+ }
75
+ //#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AC,CAAC;gBAC1B,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC1B,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aAC7B;YACD,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC;SACzB,CAAC,CAAA;IACN,CAAC;IACD,OAAO,GAAG,CAAA;AACd,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * One palette's seed: a hue and a saturation. Shaped exactly like `seed.json`.
3
+ *
4
+ * `c` is a RATIO, 0 to 1, of the most colourful thing that exists at this lightness and
5
+ * hue -- not an amount of chroma. It is therefore comparable across palettes, and `c = 1`
6
+ * is the gamut boundary rather than an error. See contracts/seeds.md section 1.
7
+ *
8
+ * There is no lightness, because lightness is a property of the job a colour is doing and
9
+ * the job is not known until a role asks for it. There is no `key` either: a key selects
10
+ * which step a role reads, and roles are references resolved at build time.
11
+ */
12
+ export interface Seed {
13
+ h: number;
14
+ c: number;
15
+ }
16
+ export type SeedGroup = 'system' | 'custom';
17
+ /** Group, then palette, then the seed. Any subset; what is absent is inherited. */
18
+ export type Seeds = Partial<Record<SeedGroup, Record<string, Seed>>>;
19
+ /**
20
+ * Every way this seed set breaks the contract, as the build's own message strings.
21
+ *
22
+ * **Every violation, not the first.** Somebody who has just edited six numbers should not have
23
+ * to run six times to find six mistakes -- contracts/seeds.md section 7.
24
+ *
25
+ * Two differences from the build, both deliberate. A palette may be ABSENT here: a runtime seed
26
+ * is a partial override and what it does not name inherits, where seed.json must name
27
+ * everything. And a `custom` saturation is REJECTED here: section 7 delegates that one rule to
28
+ * whatever accepts runtime seeds, because seed.json is the authored default where the
29
+ * saturation is ours and belongs.
30
+ */
31
+ export declare function validateSeeds(seeds: Seeds): string[];
32
+ export declare function seedProperties(seeds: Seeds, wide?: boolean): Record<string, string>;
33
+ //# sourceMappingURL=seeds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seeds.d.ts","sourceRoot":"","sources":["../../src/color/seeds.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,IAAI;IACjB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE3C,mFAAmF;AACnF,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAkFpE;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CAiCpD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,UAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuB1F"}
@@ -0,0 +1,148 @@
1
+ // A seed set in, the custom properties that re-derive those palettes out.
2
+ //
3
+ // This is the boundary the rest of the library meets: `Identity` writes what
4
+ // `seedProperties` returns onto an element, and CSS inherits it down.
5
+ //
6
+ // Private to `color/`. What leaves the folder is decided by index.ts.
7
+ import { cssNumber } from './oklch.js';
8
+ import { deriveScale, STEPS } from './scale.js';
9
+ /**
10
+ * Whether to write `oklch()` or a hex.
11
+ *
12
+ * The stylesheet expresses this as an `@supports` block overriding `:root`. An inline
13
+ * style has no such mechanism, so the runtime asks directly. The two coordinates are
14
+ * different colours by design where P3 is wider than sRGB, so this is a visible choice
15
+ * rather than a rounding one.
16
+ */
17
+ function prefersOklch() {
18
+ return typeof CSS !== 'undefined' && CSS.supports?.('color', 'oklch(0% 0 0)') === true;
19
+ }
20
+ /**
21
+ * Turn a set of seeds into the custom properties that re-derive those palettes.
22
+ *
23
+ * Derivation is atomic: a palette named here has all fifty-one steps recomputed, and one
24
+ * not named is untouched, so it inherits from the enclosing scope. That inheritance is
25
+ * CSS's, not ours -- which is why nesting works to any depth for free.
26
+ */
27
+ // ---------------------------------------------------------------------------
28
+ // The clamps -- contracts/seeds.md sections 3 and 4
29
+ // ---------------------------------------------------------------------------
30
+ // The same tables the tokens build carries, for the same reason it carries them: the clamps
31
+ // are the only thing between "a person picks their colours" and "a person picks a dull blue
32
+ // for error". The derivation has no opinion and will faithfully produce fifty-one steps of
33
+ // dull blue.
34
+ //
35
+ // Duplicated from build.mjs rather than shared, and that is a real cost stated plainly: two
36
+ // copies of fourteen ranges can drift. They cannot be shared without this repo importing from
37
+ // the tokens repo, which section 2's "must never import" exists to prevent, or without a third
38
+ // package nobody has asked for.
39
+ //
40
+ // ~~**Trigger to unify:** the two disagree once.~~ **THAT TRIGGER FIRED ON 2026-09-13 AND THE
41
+ // ANSWER WAS NO, WHICH IS WHY IT IS REWORDED RATHER THAN DELETED.** The neutral ceiling was raised
42
+ // from 0.2 to 0.24 in contracts/seeds.md section 3 and in build.mjs, and this copy was not touched
43
+ // -- so the two disagreed. They disagreed for about a minute, because
44
+ // tools/check-conformance.mjs reads the range out of the CONTRACT and executes it against BOTH
45
+ // implementations, and it failed by name: `react-web "seed color.neutral.c 0.25 outside [0.000,
46
+ // 0.240]" not in [...0.200...]`.
47
+ //
48
+ // SO THE DUPLICATION IS GUARDED AND THE TRIGGER WAS NAMING THE WRONG EVENT. What makes two copies
49
+ // dangerous is drifting UNNOTICED; these cannot, because neither copy is the source -- the contract
50
+ // is, and a checker executes it against both. A third package to hold fourteen ranges would remove
51
+ // a duplication that costs nothing and add a dependency to a repo whose section 2 forbids importing
52
+ // from the other one. governance/deferrals/a-trigger-is-a-signal-to-decide-again.md: the trigger
53
+ // fires the question, and the question was answered rather than inherited.
54
+ //
55
+ // **Trigger to unify, reworded:** the two disagree once AND NOTHING REPORTS IT -- a range reaches a
56
+ // release with check-conformance passing, or a range is added here that contracts/seeds.md section 3
57
+ // does not carry, which is the same defect with nothing to execute.
58
+ const C_MAX = 1.0;
59
+ const SYSTEM = {
60
+ // 0.2 until 2026-09-13. contracts/seeds.md section 3.1 has the argument; the number is the
61
+ // contract's and this line is checked against it rather than trusted.
62
+ neutral: { h: [0, 360], c: [0.0, 0.24] },
63
+ accent: { h: [0, 360], c: [0.0, C_MAX] },
64
+ support: { h: [0, 360], c: [0.0, C_MAX] },
65
+ success: { h: [130, 170], c: [0.5, C_MAX] },
66
+ warning: { h: [50, 85], c: [0.5, C_MAX] },
67
+ error: { h: [10, 42], c: [0.5, C_MAX] },
68
+ };
69
+ const CUSTOM = {
70
+ red: [14, 40],
71
+ orange: [48, 78],
72
+ yellow: [86, 112],
73
+ green: [130, 168],
74
+ teal: [178, 212],
75
+ blue: [240, 284],
76
+ purple: [294, 320],
77
+ pink: [328, 352],
78
+ };
79
+ const inRange = (v, [lo, hi]) => typeof v === 'number' && v >= lo && v <= hi;
80
+ // Echoed as the person typed it. Re-rendering someone's input in a different shape makes a
81
+ // message harder to match against the file it came from -- 0.21, never 0.2100.
82
+ const fmt = (v) => (typeof v === 'number' ? String(v) : JSON.stringify(v));
83
+ /**
84
+ * Every way this seed set breaks the contract, as the build's own message strings.
85
+ *
86
+ * **Every violation, not the first.** Somebody who has just edited six numbers should not have
87
+ * to run six times to find six mistakes -- contracts/seeds.md section 7.
88
+ *
89
+ * Two differences from the build, both deliberate. A palette may be ABSENT here: a runtime seed
90
+ * is a partial override and what it does not name inherits, where seed.json must name
91
+ * everything. And a `custom` saturation is REJECTED here: section 7 delegates that one rule to
92
+ * whatever accepts runtime seeds, because seed.json is the authored default where the
93
+ * saturation is ours and belongs.
94
+ */
95
+ export function validateSeeds(seeds) {
96
+ const errs = [];
97
+ for (const [name, seed] of Object.entries(seeds.system ?? {})) {
98
+ const rule = SYSTEM[name];
99
+ if (!rule) {
100
+ errs.push(`unknown system palette "${name}"`);
101
+ continue;
102
+ }
103
+ if (!inRange(seed?.h, rule.h))
104
+ errs.push(`seed color.${name}.h ${fmt(seed?.h)} outside [${rule.h[0]}, ${rule.h[1]}]`);
105
+ if (!inRange(seed?.c, rule.c))
106
+ errs.push(`seed color.${name}.c ${fmt(seed?.c)} outside [${rule.c[0].toFixed(3)}, ${rule.c[1].toFixed(3)}]`);
107
+ }
108
+ for (const [name, seed] of Object.entries(seeds.custom ?? {})) {
109
+ const range = CUSTOM[name];
110
+ if (!range) {
111
+ errs.push(`unknown custom palette "${name}"`);
112
+ continue;
113
+ }
114
+ if (!inRange(seed?.h, range))
115
+ errs.push(`seed color.custom.${name}.h ${fmt(seed?.h)} outside [${range[0]}, ${range[1]}]`);
116
+ // The rule section 7 could not put in the build's list, and said so: a custom palette is
117
+ // "the group you customise" along ONE axis. Hue is the person's; saturation and key are ours.
118
+ if (seed?.c !== undefined)
119
+ errs.push(`seed color.custom.${name}.c may not be seeded`);
120
+ }
121
+ return errs;
122
+ }
123
+ export function seedProperties(seeds, wide = prefersOklch()) {
124
+ // Throwing is heavier than the build's exit code and is the deliberate choice: a seed is
125
+ // authored by a developer and is never user input, and the alternative -- derive anyway and
126
+ // warn -- is a screen that is subtly wrong beside a console nobody has open. See the repo
127
+ // blueprint, section 7.
128
+ const errs = validateSeeds(seeds);
129
+ if (errs.length)
130
+ throw new Error(`invalid seed:\n${errs.join('\n')}`);
131
+ const props = {};
132
+ for (const group of ['system', 'custom']) {
133
+ const palettes = seeds[group];
134
+ if (!palettes)
135
+ continue;
136
+ for (const [name, seed] of Object.entries(palettes)) {
137
+ const scale = deriveScale(seed.h, seed.c);
138
+ for (let step = 0; step < STEPS; step++) {
139
+ const { oklch, srgb } = scale[step];
140
+ props[`--newtone-color-${group}-${name}-${step}`] = wide
141
+ ? `oklch(${cssNumber(oklch.l * 100)}% ${cssNumber(oklch.c)} ${cssNumber(oklch.h)})`
142
+ : srgb;
143
+ }
144
+ }
145
+ }
146
+ return props;
147
+ }
148
+ //# sourceMappingURL=seeds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seeds.js","sourceRoot":"","sources":["../../src/color/seeds.ts"],"names":[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,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;gBACtC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;gBACnC,KAAK,CAAC,mBAAmB,KAAK,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI;oBACpD,CAAC,CAAC,SAAS,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG;oBACnF,CAAC,CAAC,IAAI,CAAA;YACd,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAA;AAChB,CAAC"}
@@ -0,0 +1,203 @@
1
+ /* Control -- a glyph you press to move around a page. See the repo blueprint, section 3, and
2
+ * blueprints/newtone/repos/newtone_ui_react-web/components/control.md.
3
+ *
4
+ * ---- the box is square when it is bare, and a row when it is labelled -----
5
+ *
6
+ * `--newtone-control-padding-md` is 12px around a 24px glyph and `-lg` is 16px around a 32px one,
7
+ * so a bare control is a 48px or a 64px SQUARE. That is the whole of why the padding is one value
8
+ * per size rather than an x/y pair: equal padding around one glyph is what makes it square, and a
9
+ * pair is two numbers that can stop agreeing.
10
+ *
11
+ * **Both clear 44px, and that is a floor rather than a taste** -- see `icon-link.css`, which draws
12
+ * the same floor for the same reason. There is no `sm` size here; the reference this component came
13
+ * from has one at 28px and this library had already written down that 44 is the minimum a finger
14
+ * reliably hits.
15
+ *
16
+ * A labelled control keeps the same block padding and gains the label plus a gap, so it grows along
17
+ * the inline axis only -- the height is the size, whether or not there is a word in it.
18
+ *
19
+ * ---- the word gets one gap more room than the glyph, and the glyph side holds ----
20
+ *
21
+ * **A glyph carries bearing inside its own box and a word does not.** A 20px `arrow_back` puts its
22
+ * ink somewhere inside a 20px square; the left edge of a cap IS the left edge of its box. So equal
23
+ * padding gives unequal CLEARANCE, and it errs in the direction that makes the word look like it is
24
+ * falling off the control. Stated by Joshua on 2026-09-17 with the arithmetic in the sentence, and
25
+ * this component is the surface it was found failing on -- see
26
+ * governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md and the component
27
+ * blueprint.
28
+ *
29
+ * **The extra room is one GAP and never a fourth number.** 20 - 12 = 8, and 8 is
30
+ * `--newtone-control-gap`. Writing `20px` here would be a value that can drift away from the three
31
+ * it was derived from; reading the gap means the two cannot disagree at any size.
32
+ *
33
+ * **The glyph side is the one that holds, and that is an argument rather than a coin toss.** The
34
+ * padding above is the SQUARE's -- equal padding around one glyph is the whole of why it is one
35
+ * value -- so it is a number about a glyph and moving it would make a bare control and a labelled
36
+ * one disagree about where a glyph sits. `action.css` anchors the OTHER side for the mirror reason:
37
+ * its `padding-x` was set for a pill that held only a label. Same rule, two anchors.
38
+ *
39
+ * ---- and it is a margin on the label, not a padding pair on the box ------
40
+ *
41
+ * Two reasons, and neither is visible from the declaration itself.
42
+ *
43
+ * **A pair would have to know the size**, because the value it adds to is per size -- which is
44
+ * `.newtone-control--md.newtone-control--labelled`, `0,2,0`, landing on the element a caller's
45
+ * `className` reaches. That is the exact mistake the note further down this file records this sheet
46
+ * being corrected for once already.
47
+ *
48
+ * **And a pair would stay on when the word goes.** `adenario_website` clips the three desk labels
49
+ * under 40rem with `position: absolute` rather than `display: none`, because removing the word takes
50
+ * the control's only accessible name with it. AN OUT-OF-FLOW FLEX ITEM TAKES ITS MARGINS WITH IT, so
51
+ * a narrow control returns to `12 + 20 + 12` -- a 44px square -- with no media query in this library,
52
+ * no cooperation from the call site, and no new `--newtone-*` hook on a prefix issue 123 is already
53
+ * counting fifteen unsortable names under. A padding pair would have left a visually bare control
54
+ * 8px lopsided on every phone.
55
+ *
56
+ * ---- no transition -------------------------------------------------------
57
+ *
58
+ * Every state in the reference carries a duration and an easing. Newtone has no motion vocabulary,
59
+ * so these are instant: writing `120ms` here would hard-code a value the shared layer cannot
60
+ * express and would make this component web-only, which is `icon-link.css`'s concession arriving a
61
+ * second time. `logo-marquee.css` is still the only sheet in this library that declares a duration.
62
+ *
63
+ * ---- the border is present on every variant ------------------------------
64
+ *
65
+ * `secondary` paints it `transparent` rather than leaving it out, so the two variants occupy the
66
+ * same box and a control does not move when a caller changes tier. A border with no colour falls
67
+ * back to `currentColor`, which here is the glyph -- the loudest rim available -- so the colour is
68
+ * always stated. Same arrangement, same reason, as `on-media.css`. */
69
+
70
+ .newtone-control {
71
+ display: inline-flex;
72
+ align-items: center;
73
+ justify-content: center;
74
+ gap: var(--newtone-control-gap);
75
+ font-family: var(--newtone-control-label-family);
76
+ font-weight: var(--newtone-control-label-weight);
77
+ /* SIZE AND LEADING ARE NOT HERE. They are per size class below, because each one takes a whole
78
+ * step -- 14/20 at md, 16/24 at lg -- and a step is the pair that matches the glyph beside it.
79
+ * Declaring either one here would be the half-a-pair this component already shipped once. */
80
+ border: 1px solid;
81
+ border-radius: var(--newtone-control-radius);
82
+ cursor: pointer;
83
+ text-decoration: none;
84
+ /* The box is content-driven, so equal padding around one glyph reads as a square. A flex parent
85
+ * stretching it on the cross axis is exactly what would break that. */
86
+ block-size: fit-content;
87
+ }
88
+
89
+ /* The border is subtracted once here so each size class states only its padding VALUE, and the
90
+ * classes describe the OUTER box: md is 20 + 2x12 = 44, lg is 24 + 2x16 = 56.
91
+ *
92
+ * THOSE WERE 48 AND 64 UNTIL 2026-09-16, when the glyphs became 20 and 24 to pair with their
93
+ * labels' leading. The box is equal padding around one glyph, so it moved with them. 44 is the
94
+ * floor icon-link.css argues for, landed on exactly rather than cleared by four pixels.
95
+ *
96
+ * EACH CLASS ALSO CARRIES ITS STEP, both halves from the same one. */
97
+ .newtone-control--md {
98
+ padding: calc(var(--newtone-control-padding-md) - 1px);
99
+ font-size: var(--newtone-control-label-md-size);
100
+ line-height: var(--newtone-control-label-md-line-height);
101
+ }
102
+
103
+ .newtone-control--lg {
104
+ padding: calc(var(--newtone-control-padding-lg) - 1px);
105
+ font-size: var(--newtone-control-label-lg-size);
106
+ line-height: var(--newtone-control-label-lg-line-height);
107
+ }
108
+
109
+ /* A bare control needs NO rule of its own to be square, and the first draft of this sheet wrote two.
110
+ *
111
+ * `icon.css` gives the glyph an explicit `width` and `height` off `--newtone-icon-px`, so the
112
+ * content box of a control with one child is already 24px or 32px square; equal padding around it
113
+ * is a square with nothing stated. **The two rules that stated it anyway were `0,2,0`** --
114
+ * `.newtone-control--md.newtone-control--bare` -- landing on the element a caller's `className`
115
+ * reaches, which is exactly the trigger section 8 names for a specificity check over this library:
116
+ * a consumer's single class would have silently lost to them. */
117
+
118
+ /* THE WORD'S OWN CLEARANCE, on the side away from the glyph. The box's padding is untouched and
119
+ * stays equal on all four sides; what this adds is the one gap that makes the word's clearance 20
120
+ * where the glyph's is 12. See the docblock for why it is here and not on `.newtone-control`.
121
+ *
122
+ * `--icon-end` FLIPS IT BECAUSE THE COMPONENT OWNS THE ORDER FROM 2026-09-17. `margin-inline-end` is
123
+ * a writing-mode direction and not a flex one, so a consumer reversing the row -- which
124
+ * `adenario_website`'s `.desk-next` did -- would point this at the glyph and make the gap 16 while
125
+ * leaving the rim at 12. The rule inverted, on one control, silently. That is what turned the
126
+ * ordering from a convenience into a prop:
127
+ * governance/code/a-consumer-that-reorders-a-components-children-disables-the-rules-it-cannot-see.md */
128
+ .newtone-control-label {
129
+ margin-inline-end: var(--newtone-control-gap);
130
+ }
131
+
132
+ .newtone-control--icon-end .newtone-control-label {
133
+ margin-inline-end: 0;
134
+ margin-inline-start: var(--newtone-control-gap);
135
+ }
136
+
137
+ .newtone-control:focus-visible {
138
+ outline: 2px solid;
139
+ outline-offset: 2px;
140
+ }
141
+
142
+ .newtone-control--primary:focus-visible {
143
+ outline-color: var(--newtone-control-primary-focus-ring);
144
+ }
145
+
146
+ .newtone-control--secondary:focus-visible {
147
+ outline-color: var(--newtone-control-secondary-focus-ring);
148
+ }
149
+
150
+ /* No `pointer-events: none`. This only ever matches a native `<button disabled>` -- the anchor arm
151
+ * takes no `disabled` -- which cannot fire a click or take focus on its own, so suppressing hit
152
+ * testing would change nothing about inertness and would make `cursor: not-allowed` unreachable. */
153
+ .newtone-control:disabled {
154
+ cursor: not-allowed;
155
+ }
156
+
157
+ .newtone-control--primary {
158
+ background: var(--newtone-control-primary-rest-fill);
159
+ color: var(--newtone-control-primary-rest-text);
160
+ border-color: var(--newtone-control-primary-rest-border);
161
+ }
162
+
163
+ .newtone-control--primary:hover {
164
+ background: var(--newtone-control-primary-hover-fill);
165
+ color: var(--newtone-control-primary-hover-text);
166
+ border-color: var(--newtone-control-primary-hover-border);
167
+ }
168
+
169
+ .newtone-control--primary:active {
170
+ background: var(--newtone-control-primary-pressed-fill);
171
+ color: var(--newtone-control-primary-pressed-text);
172
+ border-color: var(--newtone-control-primary-pressed-border);
173
+ }
174
+
175
+ .newtone-control--primary:disabled {
176
+ background: var(--newtone-control-primary-disabled-fill);
177
+ color: var(--newtone-control-primary-disabled-text);
178
+ border-color: var(--newtone-control-primary-disabled-border);
179
+ }
180
+
181
+ .newtone-control--secondary {
182
+ background: var(--newtone-control-secondary-rest-fill);
183
+ color: var(--newtone-control-secondary-rest-text);
184
+ border-color: var(--newtone-control-secondary-rest-border);
185
+ }
186
+
187
+ .newtone-control--secondary:hover {
188
+ background: var(--newtone-control-secondary-hover-fill);
189
+ color: var(--newtone-control-secondary-hover-text);
190
+ border-color: var(--newtone-control-secondary-hover-border);
191
+ }
192
+
193
+ .newtone-control--secondary:active {
194
+ background: var(--newtone-control-secondary-pressed-fill);
195
+ color: var(--newtone-control-secondary-pressed-text);
196
+ border-color: var(--newtone-control-secondary-pressed-border);
197
+ }
198
+
199
+ .newtone-control--secondary:disabled {
200
+ background: var(--newtone-control-secondary-disabled-fill);
201
+ color: var(--newtone-control-secondary-disabled-text);
202
+ border-color: var(--newtone-control-secondary-disabled-border);
203
+ }
@@ -0,0 +1,112 @@
1
+ import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react';
2
+ export type ControlVariant = 'primary' | 'secondary';
3
+ export type ControlSize = 'md' | 'lg';
4
+ interface ControlCommon {
5
+ /** A Material Symbols ligature -- `arrow_back`, `chevron_right`, `close`. */
6
+ icon: string;
7
+ /** `primary` is the soft outline, `secondary` the ghost. Neither is ever the accent. */
8
+ variant?: ControlVariant;
9
+ /**
10
+ * 48px or 64px. There is no `sm`, and the absence is the design -- see the docblock and
11
+ * `components/control.md`.
12
+ */
13
+ size?: ControlSize;
14
+ /** Fill the glyph (the family's `FILL` axis). Defaults to outlined. */
15
+ fill?: boolean;
16
+ /**
17
+ * The glyph trails the label instead of leading it. **No effect on a control with no label.**
18
+ *
19
+ * IT EXISTS BECAUSE THE BOX IS NO LONGER SYMMETRIC. From 2026-09-17 the word carries one extra
20
+ * gap of clearance on the side away from the glyph -- `control.css`, and
21
+ * `governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md` -- and that
22
+ * clearance is a `margin-inline`, which is a WRITING-MODE direction rather than a flex one. So a
23
+ * consumer reversing the row puts the word's extra room against the glyph instead of the rim and
24
+ * the rule inverts, silently, on that one control.
25
+ *
26
+ * `adenario_website`'s `.desk-next` was doing exactly that, with a comment arguing that a
27
+ * reversal is cheaper than an ordering prop sized from a single consumer. That was right on what
28
+ * was then known; a component that puts something on *the word's side* has to know which side
29
+ * that is. The three lines came out in the same sitting -- and they had never been allowed by
30
+ * that repo's own §5 row, which says no control in the desk bar is drawn there.
31
+ */
32
+ iconEnd?: boolean;
33
+ }
34
+ /**
35
+ * The name, as a union, so a control with no visible word cannot compile without one.
36
+ *
37
+ * A control whose whole content is a decorative glyph is a control with **no text** -- it reaches a
38
+ * screen reader as *button, button, button*, which is what a row of carousel arrows does by
39
+ * default. `Icon` is already `aria-hidden`, so there is nothing for the name to compete with.
40
+ *
41
+ * The reference this came from requires the name unconditionally and renders no visible label at
42
+ * all, so a caller there can satisfy it with an empty string and a caller here cannot omit it.
43
+ */
44
+ type ControlName = {
45
+ /** Rendered beside the glyph. Its text is the accessible name unless `ariaLabel` overrides. */
46
+ label: string;
47
+ ariaLabel?: string;
48
+ } | {
49
+ label?: undefined;
50
+ /** Required when there is no visible label: the control would otherwise have no name. */
51
+ ariaLabel: string;
52
+ };
53
+ /**
54
+ * `href` present renders an `<a>`, absent renders a `<button type="button">`.
55
+ *
56
+ * Exactly one of the two arms at a time, which is `Button`'s shape and arrived for `Button`'s
57
+ * reason -- see `contracts/button.md`, *Destination*.
58
+ */
59
+ type ControlElement = (Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label'> & {
60
+ /** Absent on this arm. A control with no destination acts in place. */
61
+ href?: undefined;
62
+ }) | (Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'children' | 'href' | 'aria-label'> & {
63
+ /** Where pressing it goes. Its presence turns the rendered element into an `<a>`. */
64
+ href: string;
65
+ });
66
+ export type ControlProps = ControlCommon & ControlName & ControlElement;
67
+ /**
68
+ * A glyph you press to move around a page rather than to act on it: a deck's previous and next, a
69
+ * step back, a panel opened.
70
+ *
71
+ * ---- it is neutral, and that is the whole hierarchy argument ---------------
72
+ *
73
+ * `primary` is a soft outline and `secondary` is a ghost. **There is deliberately no filled tier**,
74
+ * because a filled control competing with a `Button` on the same screen is the confusion this
75
+ * component exists to stay out of -- a row of these should read as one family on any surface, and
76
+ * the thing a page is actually asking for should be the only loud control on it.
77
+ *
78
+ * ---- where it came from, and the two rules it breaks -----------------------
79
+ *
80
+ * **Ported 2026-09-16 from `~/Projects/Harbour Space/-harbour-space-design-system`**, where it is
81
+ * called `Key`. It is the first component in this library that came from outside the house, and
82
+ * what crossed is what `governance/evidence/read-a-reference-for-values-not-for-its-model.md`
83
+ * permits: the values it renders and the interface it presents. Its colour engine did not cross --
84
+ * two hooks per render, a theme slice out of React context, thirteen resolved strings written into
85
+ * inline custom properties. Here the cascade does that and this file is told nothing.
86
+ *
87
+ * **It breaks two of that reference's own rules, both because its first consumer asked.** The
88
+ * reference says a control *never* takes an `href` -- and the first bar to hold one has a back
89
+ * control that navigates, where a `<button>` costs middle-click, the new tab, the status bar and
90
+ * *link* in the accessibility tree. The reference is also icon-only by contract, and the same bar
91
+ * draws *Previous* and *Next* beside the glyphs. Both breaks are argued in
92
+ * `components/control.md`; neither is a rule that was copied past without being read.
93
+ *
94
+ * ---- there is no `sm`, and 44 is why -------------------------------------
95
+ *
96
+ * The reference ships `sm` at **28px**. `icon-link.tsx` in this library already argues that 44px is
97
+ * a floor rather than a taste -- the smallest target a finger reliably hits, the same number on
98
+ * every platform -- and draws a 2.75rem box for it. **A library cannot hold both sentences.** `md`
99
+ * is 48 and `lg` is 64, and a control smaller than the floor needs a call site that can say why the
100
+ * floor does not apply to it.
101
+ *
102
+ * ---- no transition, and that is a vocabulary this library does not have ----
103
+ *
104
+ * Every state in the reference carries `--motion-fast` and `--motion-ease-out`. Newtone has no
105
+ * motion vocabulary at all, so the states here are instant. Writing a duration would hard-code a
106
+ * value the shared layer cannot express -- `a-component-stops-at-a-vocabulary-it-cannot-speak.md`,
107
+ * third refusal -- which is the tempting one in a port, because the number is sitting in the file
108
+ * being read from.
109
+ */
110
+ export declare function Control({ icon, variant, size, label, ariaLabel, fill, iconEnd, className, ...rest }: ControlProps): import("react").JSX.Element;
111
+ export {};
112
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/control/control.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAGvE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,CAAA;AACpD,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAA;AA0BrC,UAAU,aAAa;IACnB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAA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