@astryxdesign/cli 0.7.17 → 0.7.18-canary.g170df15

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 (255) hide show
  1. package/README.md +1 -1
  2. package/api/discover/_adapter.d.mts +7 -5
  3. package/api/discover/_adapter.mjs +12 -11
  4. package/api/docs/_adapter.d.mts +19 -2
  5. package/api/docs/_adapter.mjs +66 -5
  6. package/api/doctor/_adapter.d.mts +11 -62
  7. package/api/doctor/_adapter.mjs +242 -472
  8. package/api/doctor/doctor.d.mts +1 -1
  9. package/api/doctor/doctor.mjs +3 -3
  10. package/api/doctor/theme-checks.mjs +37 -45
  11. package/api/error.d.mts +21 -0
  12. package/api/error.mjs +89 -0
  13. package/api/hook/list/list.d.mts +1 -1
  14. package/api/icon/_adapter.d.mts +8 -0
  15. package/api/icon/_adapter.mjs +17 -0
  16. package/api/icon/_authoring.mjs +6 -6
  17. package/api/icon/_default-look.mjs +16 -16
  18. package/api/icon/add/add.mjs +3 -3
  19. package/api/icon/exportIconIndex.doc.mjs +2 -2
  20. package/api/icon/icon.doc.mjs +2 -2
  21. package/api/icon/icon.type.d.mts +4 -0
  22. package/api/icon/icon.type.mjs +2 -1
  23. package/api/icon/search/icon-index.mjs +16 -3
  24. package/api/icon/search/search.d.mts +15 -5
  25. package/api/icon/search/search.mjs +74 -16
  26. package/api/icon/use/use.mjs +4 -4
  27. package/api/render/_adapter.mjs +233 -40
  28. package/api/render/render.type.d.mts +1 -1
  29. package/api/render/render.type.mjs +1 -1
  30. package/api/search/ORDERING.md +2 -2
  31. package/api/search/_adapter.mjs +4 -0
  32. package/api/search/_candidate-score.mjs +32 -8
  33. package/api/search/_cards.json +1 -1
  34. package/api/search/_compound.d.mts +0 -1
  35. package/api/search/_compound.mjs +93 -2
  36. package/api/search/_icons.d.mts +4 -2
  37. package/api/search/_icons.mjs +4 -2
  38. package/api/search/_lexical.mjs +177 -17
  39. package/api/search/_order.d.mts +3 -1
  40. package/api/search/_order.mjs +16 -5
  41. package/api/search/_result.d.mts +9 -0
  42. package/api/search/_result.mjs +10 -0
  43. package/api/search/_score.mjs +21 -3
  44. package/api/swizzle/_moduleGraph.d.mts +8 -0
  45. package/api/swizzle/_moduleGraph.mjs +61 -3
  46. package/api/template/copy/copy.mjs +5 -3
  47. package/api/template/template.type.d.mts +3 -3
  48. package/api/template/template.type.mjs +3 -3
  49. package/api/theme/_adapter.mjs +48 -12
  50. package/api/theme/build/build.d.mts +4 -0
  51. package/api/theme/build/build.mjs +69 -18
  52. package/api/theme/build/style-keys.mjs +4 -5
  53. package/api/theme/build/theme-object.mjs +5 -0
  54. package/api/theme/palette/generate/color.d.mts +47 -0
  55. package/api/theme/palette/generate/color.mjs +58 -1
  56. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  57. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  58. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  59. package/api/theme/palette/generate/editor-look.mjs +550 -0
  60. package/api/theme/palette/generate/mapping.d.mts +94 -9
  61. package/api/theme/palette/generate/mapping.mjs +94 -22
  62. package/api/theme-edit/_adapter.mjs +13 -2
  63. package/api/theme-edit/_catalog.d.mts +13 -13
  64. package/api/theme-edit/_catalog.mjs +66 -28
  65. package/api/theme-edit/_check.d.mts +82 -6
  66. package/api/theme-edit/_check.mjs +1270 -238
  67. package/api/theme-edit/_color.d.mts +74 -0
  68. package/api/theme-edit/_color.mjs +168 -3
  69. package/api/theme-edit/_compiler.d.mts +3 -5
  70. package/api/theme-edit/_compiler.mjs +122 -23
  71. package/api/theme-edit/_context.d.mts +55 -12
  72. package/api/theme-edit/_context.mjs +114 -60
  73. package/api/theme-edit/_css.d.mts +11 -0
  74. package/api/theme-edit/_css.mjs +40 -0
  75. package/api/theme-edit/_edit.d.mts +15 -2
  76. package/api/theme-edit/_edit.mjs +1469 -133
  77. package/api/theme-edit/_how-commands.d.mts +116 -0
  78. package/api/theme-edit/_how-commands.mjs +227 -115
  79. package/api/theme-edit/_how-question.d.mts +74 -29
  80. package/api/theme-edit/_how-question.mjs +8514 -1256
  81. package/api/theme-edit/_how-sides.d.mts +22 -0
  82. package/api/theme-edit/_how-sides.mjs +173 -0
  83. package/api/theme-edit/_how-steps.d.mts +42 -0
  84. package/api/theme-edit/_how-steps.mjs +208 -0
  85. package/api/theme-edit/_how-values.d.mts +29 -0
  86. package/api/theme-edit/_how-values.mjs +111 -0
  87. package/api/theme-edit/_how-words.d.mts +15 -0
  88. package/api/theme-edit/_how-words.mjs +239 -0
  89. package/api/theme-edit/_how.d.mts +1 -1
  90. package/api/theme-edit/_how.mjs +422 -37
  91. package/api/theme-edit/_missed.d.mts +2 -1
  92. package/api/theme-edit/_missed.mjs +125 -13
  93. package/api/theme-edit/_normal.d.mts +5 -3
  94. package/api/theme-edit/_normal.mjs +54 -14
  95. package/api/theme-edit/_palette.d.mts +204 -4
  96. package/api/theme-edit/_palette.mjs +901 -25
  97. package/api/theme-edit/_part-pieces.d.mts +54 -0
  98. package/api/theme-edit/_part-pieces.mjs +179 -0
  99. package/api/theme-edit/_part-words.mjs +33 -5
  100. package/api/theme-edit/_parts.d.mts +133 -0
  101. package/api/theme-edit/_parts.mjs +599 -10
  102. package/api/theme-edit/_picture-traits.d.mts +259 -0
  103. package/api/theme-edit/_picture-traits.mjs +1030 -0
  104. package/api/theme-edit/_preview.d.mts +95 -4
  105. package/api/theme-edit/_preview.mjs +284 -31
  106. package/api/theme-edit/_project.d.mts +14 -4
  107. package/api/theme-edit/_project.mjs +95 -26
  108. package/api/theme-edit/_resolved.d.mts +46 -0
  109. package/api/theme-edit/_resolved.mjs +800 -0
  110. package/api/theme-edit/_set-line.d.mts +29 -0
  111. package/api/theme-edit/_set-line.mjs +100 -0
  112. package/api/theme-edit/_settings.d.mts +625 -28
  113. package/api/theme-edit/_settings.mjs +4867 -888
  114. package/api/theme-edit/_tables.d.mts +25 -1
  115. package/api/theme-edit/_tables.mjs +115 -11
  116. package/api/theme-edit/_text-looks.d.mts +78 -0
  117. package/api/theme-edit/_text-looks.mjs +376 -0
  118. package/api/theme-edit/_vet.d.mts +3 -26
  119. package/api/theme-edit/_vet.mjs +5 -89
  120. package/api/theme-edit/how/how.d.mts +1 -1
  121. package/api/theme-edit/how/how.mjs +1 -1
  122. package/api/theme-edit/show/show.d.mts +4 -3
  123. package/api/theme-edit/show/show.mjs +3 -2
  124. package/api/theme-edit/theme-edit.type.d.mts +117 -1
  125. package/api/theme-edit/theme-edit.type.mjs +46 -3
  126. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  128. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  129. package/api/theme-edit/themeEditShow.doc.mjs +22 -3
  130. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  131. package/assets/component-list.generated.json +1 -1
  132. package/assets/docs/author-a-theme.doc.mjs +7 -4
  133. package/assets/docs/icons.doc.mjs +7 -6
  134. package/assets/docs/theme.doc.dense.mjs +10 -0
  135. package/assets/docs/theme.doc.mjs +10 -0
  136. package/assets/docs/theme.doc.zh.mjs +10 -0
  137. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  138. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  139. package/assets/docs/use-a-theme.doc.mjs +89 -17
  140. package/assets/docs-routes.generated.json +1 -1
  141. package/assets/docs.generated.json +2 -2
  142. package/assets/icons/definitions/article.doc.mjs +9 -0
  143. package/assets/icons/template-icons.json +5 -0
  144. package/assets/search-catalog.generated.json +2 -2
  145. package/assets/self-audit.generated.json +1 -1
  146. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  147. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  148. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  149. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  150. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  151. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  152. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  153. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  154. package/assets/templates/components.generated.json +1 -1
  155. package/assets/templates/pages/ide/page.tsx +5 -10
  156. package/assets/templates/pages/payment-form/page.tsx +16 -60
  157. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  158. package/authoring/config/parse.mjs +1 -1
  159. package/authoring/debug/parse.d.mts +1 -1
  160. package/authoring/doctypes/_schema.d.mts +13 -13
  161. package/authoring/doctypes/icon-definition/parse.mjs +2 -2
  162. package/authoring/doctypes/icon-set/parse.mjs +1 -1
  163. package/authoring/doctypes/template/parse.mjs +1 -4
  164. package/authoring/gap-report/parse.d.mts +1 -1
  165. package/clients/cli/build-id.generated.json +1 -1
  166. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  167. package/clients/cli/commands/experimental/icon.mjs +7 -7
  168. package/clients/cli/commands/experimental/theme.mjs +175 -13
  169. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  170. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  171. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  172. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  173. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
  174. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  175. package/clients/cli/commands/hook.mjs +7 -0
  176. package/clients/cli/commands/template.mjs +1 -1
  177. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  178. package/clients/cli/index.mjs +6 -2
  179. package/clients/cli/lib/hook-format.mjs +41 -1
  180. package/clients/cli/lib/json-shim.mjs +34 -14
  181. package/clients/cli/lib/other-cli-words.mjs +7 -0
  182. package/clients/cli/lib/unknown-command.mjs +345 -46
  183. package/clients/cli/manifest.generated.json +1 -1
  184. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  185. package/foundation/agent-docs/agent-docs.mjs +51 -8
  186. package/foundation/config/project.d.mts +11 -1
  187. package/foundation/config/project.mjs +11 -2
  188. package/foundation/discovery/component-replacement.d.mts +5 -8
  189. package/foundation/discovery/component-replacement.mjs +12 -14
  190. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  191. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  192. package/foundation/discovery/core-elements.d.mts +6 -0
  193. package/foundation/discovery/core-elements.mjs +10 -2
  194. package/foundation/discovery/core-prop-types.d.mts +5 -0
  195. package/foundation/discovery/core-prop-types.mjs +10 -3
  196. package/foundation/discovery/core-props.d.mts +8 -0
  197. package/foundation/discovery/core-props.mjs +29 -13
  198. package/foundation/discovery/icon-ranking.d.mts +5 -2
  199. package/foundation/discovery/icon-ranking.mjs +101 -18
  200. package/foundation/discovery/icon-set-checks.mjs +1 -1
  201. package/foundation/discovery/icon-set-writer.mjs +1 -1
  202. package/foundation/discovery/official-list.d.mts +17 -0
  203. package/foundation/discovery/official-list.mjs +77 -0
  204. package/foundation/discovery/template-icon-notes.mjs +3 -3
  205. package/foundation/discovery/template-icons.mjs +2 -2
  206. package/foundation/discovery/template-placeholders.mjs +1 -1
  207. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  208. package/foundation/discovery/unknown-core-props.mjs +601 -0
  209. package/foundation/discovery/written-prop-values.d.mts +35 -0
  210. package/foundation/discovery/written-prop-values.mjs +258 -0
  211. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  212. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  213. package/foundation/fs/package-name.d.mts +10 -0
  214. package/foundation/fs/package-name.mjs +37 -0
  215. package/foundation/fs/project-source-files.d.mts +27 -0
  216. package/foundation/fs/project-source-files.mjs +115 -0
  217. package/foundation/fs/project-sources.d.mts +25 -0
  218. package/foundation/fs/project-sources.mjs +83 -0
  219. package/foundation/fs/read-record.d.mts +18 -0
  220. package/foundation/fs/read-record.mjs +36 -2
  221. package/foundation/integrations/integration-warnings.d.mts +39 -7
  222. package/foundation/integrations/integration-warnings.mjs +141 -19
  223. package/foundation/integrations/missing-dependency.d.mts +11 -0
  224. package/foundation/integrations/missing-dependency.mjs +20 -5
  225. package/foundation/release/folder-lock.d.mts +5 -2
  226. package/foundation/release/folder-lock.mjs +9 -3
  227. package/foundation/release/notices.mjs +2 -8
  228. package/foundation/render/cut-short.d.mts +8 -2
  229. package/foundation/render/cut-short.mjs +50 -5
  230. package/foundation/render/drawn-contrast.d.mts +40 -0
  231. package/foundation/render/drawn-contrast.mjs +355 -0
  232. package/foundation/render/file-header.mjs +4 -0
  233. package/foundation/render/layers.d.mts +2 -1
  234. package/foundation/render/layers.mjs +22 -1
  235. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  236. package/foundation/render/package-resolve-hooks.mjs +124 -32
  237. package/foundation/render/page-worker.mjs +95 -23
  238. package/foundation/render/part-boxes.d.mts +27 -0
  239. package/foundation/render/part-boxes.mjs +45 -0
  240. package/foundation/render/picture-chrome.mjs +36 -4
  241. package/foundation/render/picture-playwright.mjs +26 -2
  242. package/foundation/render/picture-window.d.mts +29 -2
  243. package/foundation/render/picture-window.mjs +99 -1
  244. package/foundation/render/render-page.d.mts +39 -6
  245. package/foundation/render/render-page.mjs +26 -10
  246. package/foundation/render/ts-paths.mjs +2 -1
  247. package/foundation/response/error-codes.doc.mjs +1 -1
  248. package/foundation/response/error-codes.mjs +1 -1
  249. package/foundation/response/response-types.doc.mjs +9 -5
  250. package/foundation/suggest/other-command.mjs +25 -1
  251. package/foundation/text/icon-set-next.d.mts +1 -1
  252. package/foundation/text/icon-set-next.mjs +2 -2
  253. package/foundation/text/written-string.d.mts +4 -1
  254. package/foundation/text/written-string.mjs +4 -1
  255. package/package.json +8 -7
@@ -10,6 +10,7 @@
10
10
  */
11
11
 
12
12
  import {CUSTOM_PROPERTY} from '../theme/build/written-values.mjs';
13
+ import {readSetLine} from './_set-line.mjs';
13
14
  import {AstryxError} from '../error.mjs';
14
15
  import * as fs from 'node:fs';
15
16
  import * as path from 'node:path';
@@ -37,8 +38,15 @@ import {
37
38
  takesPercentage,
38
39
  sameKindValues,
39
40
  unitsJoined,
41
+ sidesOf,
42
+ BOX_SIDES,
40
43
  } from './_css.mjs';
41
- import {calcVars, coreFallback, multipliedTokens} from './_parts.mjs';
44
+ import {
45
+ calcVars,
46
+ coreFallback,
47
+ multipliedTokens,
48
+ INHERITED_TEXT,
49
+ } from './_parts.mjs';
42
50
  import {
43
51
  AUTO_SPREAD,
44
52
  COMMON_STATES,
@@ -64,13 +72,14 @@ import {
64
72
  THING_HINTS,
65
73
  TYPE_STYLES,
66
74
  familyOf,
75
+ onlyMeans,
67
76
  wordTable,
68
77
  WRAPPED_PARTS,
69
78
  CARD_LIKE,
70
79
  systemFontFamilies,
71
80
  isSystemFamily,
72
81
  fontStack,
73
- onlyMeans,
82
+ STATE_SYNONYMS,
74
83
  } from './_tables.mjs';
75
84
  import {
76
85
  COLOR_NAMES,
@@ -87,12 +96,15 @@ import {
87
96
  ratio,
88
97
  mixSide,
89
98
  splitTop,
99
+ colorSides,
100
+ colorOpacitiesAsCss,
90
101
  } from './_color.mjs';
91
102
  import {
92
103
  PALETTE_DIALS,
93
104
  PALETTE_TOKENS,
105
+ isLookToken,
94
106
  VIBRANCY_DEFAULT,
95
- vibrancyMoves,
107
+ vibrancyMovesAny,
96
108
  paletteToken,
97
109
  seedsInEffect,
98
110
  } from './_palette.mjs';
@@ -116,6 +128,12 @@ import {
116
128
  focusStateOf,
117
129
  valueProblem,
118
130
  partComponentDocs,
131
+ colorPropTokens,
132
+ innerPropTokens,
133
+ columnLineTokens,
134
+ mainTextSizeToken,
135
+ namesToken,
136
+ heldSizeTokenFor,
119
137
  themeFiles,
120
138
  ownSourceTokenValues,
121
139
  baseTopTokens,
@@ -137,6 +155,13 @@ import {
137
155
  propertySpelling,
138
156
  modesOf,
139
157
  dialNumber,
158
+ dialValueFits,
159
+ groupsOf,
160
+ onlyFits,
161
+ growsWithContent,
162
+ notGrowingWhens,
163
+ sharedControlHeight,
164
+ controlHeightValue,
140
165
  } from './_settings.mjs';
141
166
  import {isColorToken} from './_compiler.mjs';
142
167
  import {
@@ -267,43 +292,43 @@ export const setLine = (slug, thing, value, s, unset = false) =>
267
292
  `${P} ${unset ? 'undo' : 'set'} ${slug} ${quoteCommandArgument(thing)}${value ? ` ${quoteCommandArgument(value)}` : ''}${s.on ? ` --on ${s.on}` : ''}${s.when ? ` --when ${s.when}` : ''}${s.state ? ` --state ${s.state}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}${s.only ? ' --only' : ''}`;
268
293
 
269
294
  /**
270
- * The longhand lines that give a box shorthand of two to four lengths side
271
- * by side (`padding '5px 0'`: padding-block 5px, padding-inline 0), each
272
- * with the length typed for it, as CSS gives the sides out; null for any
273
- * other property or value.
274
- * @param {string} slug
295
+ * The sides a box shorthand of two to four values gives out, as CSS does
296
+ * (`5px 0`: block 5px, inline 0), each with the value typed for it, which
297
+ * that side's own check reads; one working length said for every side is
298
+ * that length alone (side ''); null for any other property or value.
275
299
  * @param {string} prop
276
300
  * @param {string} v
277
- * @param {{on?: string, when?: string, state?: string, mode?: string, only?: boolean}} s
278
- * @returns {string[] | null}
301
+ * @returns {Array<[string, string]> | null}
279
302
  */
280
- function boxSideLines(slug, prop, v, s) {
303
+ function boxSides(prop, v) {
281
304
  if (prop !== 'padding' && prop !== 'margin') return null;
282
- const w = splitTop(v.trim(), ' ').filter(Boolean);
283
- if (w.length < 2 || w.length > 4) return null;
284
- if (!w.every(x => oneLength(x) || /^[+-]?0*\.?0+$/.test(x))) return null;
285
- // (One length said again for each side is that one length.)
286
- if (new Set(w).size === 1) return null;
287
- /** @type {Array<[string, string]>} */
288
- const sides =
289
- w.length === 2
305
+ const n = splitTop(v.trim(), ' ').filter(Boolean).length;
306
+ // (The shorthand rules split the value, as every other reader of a box
307
+ // shorthand's sides does.)
308
+ const sides = n >= 2 ? sidesOf(prop, v) : null;
309
+ if (!sides) return null;
310
+ const [top, right, bottom, left] = ['top', 'right', 'bottom', 'left'].map(
311
+ side => sides[`${prop}-${side}`],
312
+ );
313
+ if (top === right && right === bottom && bottom === left && oneLength(top))
314
+ return [['', top]];
315
+ return n === 2
316
+ ? [
317
+ ['block', top],
318
+ ['inline', right],
319
+ ]
320
+ : n === 3
290
321
  ? [
291
- ['block', w[0]],
292
- ['inline', w[1]],
322
+ ['top', top],
323
+ ['inline', right],
324
+ ['bottom', bottom],
293
325
  ]
294
- : w.length === 3
295
- ? [
296
- ['top', w[0]],
297
- ['inline', w[1]],
298
- ['bottom', w[2]],
299
- ]
300
- : [
301
- ['top', w[0]],
302
- ['right', w[1]],
303
- ['bottom', w[2]],
304
- ['left', w[3]],
305
- ];
306
- return sides.map(([side, x]) => setLine(slug, `${prop}-${side}`, x, s));
326
+ : [
327
+ ['top', top],
328
+ ['right', right],
329
+ ['bottom', bottom],
330
+ ['left', left],
331
+ ];
307
332
  }
308
333
 
309
334
  /** @param {string} v */
@@ -836,6 +861,7 @@ const COLOR_DIAL_WORDS = (() => {
836
861
  * @property {string} [state]
837
862
  * @property {string} [mode]
838
863
  * @property {boolean} [only]
864
+ * @property {boolean} [sides] - set's own value: a box shorthand where one length works is written as its sides (never a saved entry, which is checked as written)
839
865
  */
840
866
 
841
867
  /**
@@ -846,7 +872,7 @@ const COLOR_DIAL_WORDS = (() => {
846
872
  * @param {string} slug
847
873
  * @param {import('./_settings.mjs').ThemeData} data
848
874
  * @param {string | {thing: string, on?: string, when?: string, state?: string, mode?: string}} [skip]
849
- * @returns {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean, fix?: string}>} every saved setting the editor no longer accepts (`fix`: the clean value to set, when one reads)
875
+ * @returns {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean, fix?: string, noEffect?: boolean}>} every saved setting the editor no longer accepts (`fix`: the clean value to set, when one reads; `noEffect`: refused as it never shows where it is saved)
850
876
  */
851
877
  export function storedProblems(ctx, slug, data, skip = '') {
852
878
  // The setting the command replaces (its thing in the same scope); a
@@ -861,7 +887,7 @@ export function storedProblems(ctx, slug, data, skip = '') {
861
887
  (s.when ?? '') === (skip.when ?? '') &&
862
888
  (s.state ?? '') === (skip.state ?? '') &&
863
889
  (s.mode ?? '') === (skip.mode ?? '');
864
- /** @type {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean, fix?: string}>} */
890
+ /** @type {Array<{setting: import('./_settings.mjs').Setting, why: string, scope?: boolean, fix?: string, noEffect?: boolean}>} */
865
891
  const found = [];
866
892
  const TOKENS = ctx.project.core.tokenDefaults;
867
893
  // Where each saved setting applies names a real part, group, state and
@@ -869,6 +895,7 @@ export function storedProblems(ctx, slug, data, skip = '') {
869
895
  const WHOLE_ONLY = [
870
896
  'surfaces',
871
897
  'buttons',
898
+ 'badges',
872
899
  'base',
873
900
  'mode',
874
901
  'vibrancy',
@@ -886,7 +913,7 @@ export function storedProblems(ctx, slug, data, skip = '') {
886
913
  if (
887
914
  s.on &&
888
915
  !t &&
889
- !FAMILIES[s.on] &&
916
+ !groupsOf(ctx)[s.on] &&
890
917
  !(s.thing === 'font' && FONT_ROLES.includes(s.on))
891
918
  )
892
919
  return scope(`there is no part or group "${s.on}"`);
@@ -984,7 +1011,15 @@ export function storedProblems(ctx, slug, data, skip = '') {
984
1011
  },
985
1012
  s.thing,
986
1013
  s.value,
987
- {on: s.on, when: s.when, state: s.state, mode: s.mode, only: s.only},
1014
+ {
1015
+ on: s.on,
1016
+ when: s.when,
1017
+ state: s.state,
1018
+ mode: s.mode,
1019
+ only: s.only,
1020
+ },
1021
+ false,
1022
+ {saved: true},
988
1023
  );
989
1024
  } catch (e) {
990
1025
  if (!(e instanceof AstryxError)) throw e;
@@ -994,6 +1029,8 @@ export function storedProblems(ctx, slug, data, skip = '') {
994
1029
  e instanceof Error
995
1030
  ? e.message.replace(/ Nothing was changed\.$/, '')
996
1031
  : String(e),
1032
+ // Refused for having no effect where it is saved: it never shows.
1033
+ ...(e.code === E.ERR_THEME_NO_EFFECT ? {noEffect: true} : {}),
997
1034
  });
998
1035
  }
999
1036
  }
@@ -2366,6 +2403,53 @@ function isShadow(value) {
2366
2403
  });
2367
2404
  }
2368
2405
 
2406
+ /**
2407
+ * The tokens a control height written as a size token reads on its way
2408
+ * back to that token, ending with it; null when it never reads it. A
2409
+ * custom property's var() resolves on the element that sets it, so only
2410
+ * the tokens set where this one is written are followed: on the controls
2411
+ * group, and on the one control for its own height (where its own tokens
2412
+ * win).
2413
+ * @param {import('./_settings.mjs').ThemeData} data
2414
+ * @param {{token: string, own: boolean, setting: import('./_settings.mjs').Setting}} asToken
2415
+ * @param {string} value
2416
+ * @returns {string[] | null}
2417
+ */
2418
+ function heightTokenLoop(data, asToken, value) {
2419
+ const scopes = asToken.own ? ['controls', asToken.setting.on] : ['controls'];
2420
+ /** @type {Map<string, string>} */
2421
+ const held = new Map();
2422
+ for (const on of scopes)
2423
+ for (const x of data.settings)
2424
+ if (
2425
+ x.source === 'token' &&
2426
+ x.on === on &&
2427
+ !x.when &&
2428
+ !x.state &&
2429
+ (x.mode ?? null) === (asToken.setting.mode ?? null)
2430
+ )
2431
+ held.set(x.thing, String(x.value));
2432
+ held.set(asToken.token, value);
2433
+ /** @param {string} v */
2434
+ const refs = v =>
2435
+ [
2436
+ ...v.matchAll(new RegExp(String.raw`var\(\s*(${CUSTOM_PROPERTY})`, 'gi')),
2437
+ ].map(m => m[1]);
2438
+ const seen = new Set();
2439
+ /** @param {string} v @param {string[]} path @returns {string[] | null} */
2440
+ const walk = (v, path) => {
2441
+ for (const t of refs(v)) {
2442
+ if (t === asToken.token) return [...path, t];
2443
+ if (seen.has(t) || !held.has(t)) continue;
2444
+ seen.add(t);
2445
+ const found = walk(/** @type {string} */ (held.get(t)), [...path, t]);
2446
+ if (found) return found;
2447
+ }
2448
+ return null;
2449
+ };
2450
+ return walk(value, []);
2451
+ }
2452
+
2369
2453
  /**
2370
2454
  * Refuse a value that would read the token itself, through other tokens.
2371
2455
  * A token set on a part (`--on`) overrides only inside that part: there
@@ -2707,6 +2791,15 @@ const DIAL_WORDS = wordTable(
2707
2791
  plain: 'flat',
2708
2792
  minimal: 'flat',
2709
2793
  },
2794
+ badges: {
2795
+ tint: 'soft',
2796
+ tinted: 'soft',
2797
+ subtle: 'soft',
2798
+ outlined: 'outline',
2799
+ bordered: 'outline',
2800
+ filled: 'solid',
2801
+ fill: 'solid',
2802
+ },
2710
2803
  buttons: {
2711
2804
  uppercase: 'caps',
2712
2805
  upper: 'caps',
@@ -3030,14 +3123,19 @@ function oneModeOfTheme(data) {
3030
3123
  /**
3031
3124
  * Whether any of the parts draws a line of that kind (a border, one side's
3032
3125
  * border, an outline) with a width, at rest or in the state named: then its
3033
- * color alone can differ by mode.
3126
+ * color alone can differ by mode. A width drawn with a style of none or
3127
+ * hidden in the same rule is no line. A side cleared only on the first or
3128
+ * last child (a list row's divider, a grouped button's join) is still
3129
+ * drawn on the others, so it counts. With a variant (`variant:primary`), a rule for another value of that
3130
+ * prop does not count.
3034
3131
  * @param {any} C the part census
3035
3132
  * @param {string[]} parts
3036
3133
  * @param {string} prop border, border-<side> or outline
3037
3134
  * @param {string | undefined | null} [state]
3135
+ * @param {string | undefined | null} [when] a variant, `prop:value`
3038
3136
  * @returns {boolean}
3039
3137
  */
3040
- export function drawsLine(C, parts, prop, state) {
3138
+ export function drawsLine(C, parts, prop, state, when) {
3041
3139
  // (A side's line is drawn by the side's own width or the shared one.)
3042
3140
  const keys =
3043
3141
  prop === 'border'
@@ -3048,15 +3146,29 @@ export function drawsLine(C, parts, prop, state) {
3048
3146
  : prop.startsWith('border-')
3049
3147
  ? [`${prop}-width`, 'border-width']
3050
3148
  : [`${prop}-width`];
3149
+ const [wp, wv] = String(when ?? '').split(':');
3150
+ const zero = (/** @type {unknown} */ v) =>
3151
+ /^\s*0(?:px|rem|em)?\s*$/.test(String(v));
3152
+ const none = (/** @type {unknown} */ v) =>
3153
+ /^\s*(?:none|hidden)\b/i.test(String(v));
3051
3154
  return parts.some(t => {
3052
3155
  const at = C.MAP[t]?.at ?? {};
3053
- return keys.some(k =>
3054
- Object.entries(at[k] ?? {}).some(
3055
- ([sel, w]) =>
3056
- !/^\s*0(?:px)?\s*$/.test(String(w)) &&
3057
- (state ? sel.includes(state) : !/:/.test(sel)),
3058
- ),
3059
- );
3156
+ return keys.some(k => {
3157
+ const rules = /** @type {Record<string, string>} */ (at[k] ?? {});
3158
+ const styles = /** @type {Record<string, string>} */ (
3159
+ at[k.replace(/-width$/, '-style')] ?? {}
3160
+ );
3161
+ return Object.entries(rules).some(([sel, w]) => {
3162
+ if (zero(w) || none(styles[sel] ?? '')) return false;
3163
+ if (state ? !sel.includes(state) : /:/.test(sel)) return false;
3164
+ const pairs = sel.split(' ')[0].split(',');
3165
+ return !(
3166
+ wp &&
3167
+ pairs.some(pr => pr.startsWith(`${wp}=`)) &&
3168
+ !pairs.includes(`${wp}=${wv}`)
3169
+ );
3170
+ });
3171
+ });
3060
3172
  });
3061
3173
  }
3062
3174
 
@@ -3407,6 +3519,417 @@ function lineRefusal(ctx, slug, s, prop, v) {
3407
3519
  );
3408
3520
  }
3409
3521
 
3522
+ /**
3523
+ * The elements a browser draws a border on by itself (a native button's,
3524
+ * a text field's): a part rendered as one of these with no border rule of
3525
+ * its own is not known to draw none.
3526
+ */
3527
+ const NATIVE_BORDER_TAGS = new Set([
3528
+ 'button',
3529
+ 'input',
3530
+ 'textarea',
3531
+ 'select',
3532
+ 'fieldset',
3533
+ 'hr',
3534
+ 'iframe',
3535
+ ]);
3536
+
3537
+ /**
3538
+ * Whether a part draws a border in the variant and state a setting names
3539
+ * from outside Core's own rules (drawsLine reads those): the base theme's
3540
+ * rules for it, or the theme's own settings for it; or a part Core sets no
3541
+ * border on whose element the browser draws one (a native button), or a
3542
+ * part the part data does not know.
3543
+ * @param {import('./_settings.mjs').Ctx} ctx
3544
+ * @param {any} data
3545
+ * @param {import('./_settings.mjs').Setting} s
3546
+ * @param {string} part
3547
+ */
3548
+ function bordersBeyondCore(ctx, data, s, part) {
3549
+ const rec = ctx.C.MAP[part];
3550
+ if (!rec) return true;
3551
+ const wp = String(s.when ?? '').split(':')[0];
3552
+ const edgeProp =
3553
+ /^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?(?:-(?:width|style))?$/;
3554
+ const blank = (/** @type {unknown} */ v) =>
3555
+ /^\s*(?:none|hidden|0(?:px|rem|em)?)\s*$/i.test(String(v)) ||
3556
+ /^\s*(?:none|hidden)\b/i.test(String(v));
3557
+ // A part Core sets no border on draws none, unless the browser draws one
3558
+ // on its element (a native button).
3559
+ const recorded = Object.keys(rec.at ?? {}).some(p => edgeProp.test(p));
3560
+ if (!recorded && (rec.tags ?? []).some(t => NATIVE_BORDER_TAGS.has(t)))
3561
+ return true;
3562
+ // The base theme's rules for the part (its own block and the variant's).
3563
+ const blocks = ctx.base?.components?.[part] ?? {};
3564
+ /** @param {unknown} b @returns {boolean} */
3565
+ const drawsIn = b =>
3566
+ !!b &&
3567
+ typeof b === 'object' &&
3568
+ Object.entries(b).some(([k, v]) =>
3569
+ v && typeof v === 'object'
3570
+ ? drawsIn(v)
3571
+ : /^border(?:Top|Right|Bottom|Left|Block|Inline)?(?:Start|End)?(?:Width|Style)?$/.test(
3572
+ k,
3573
+ ) && !blank(v),
3574
+ );
3575
+ for (const [k, b] of Object.entries(blocks))
3576
+ if (k === 'base' || !wp || k === s.when) if (drawsIn(b)) return true;
3577
+ // The theme's own settings for it. (A width alone draws no line: Core's
3578
+ // style stays none; a style draws, and a shorthand only with a style word
3579
+ // in it, as borderSidesOff reads it: `border-top 1px` draws nothing.)
3580
+ const STYLE_WORD =
3581
+ /(?:^|\s)(?:solid|dashed|dotted|double|groove|ridge|inset|outset)(?:\s|$)/i;
3582
+ return (data?.settings ?? []).some(
3583
+ (/** @type {any} */ x) =>
3584
+ x.source === 'property' &&
3585
+ edgeProp.test(String(x.thing)) &&
3586
+ !/-width$/.test(String(x.thing)) &&
3587
+ (/-style$/.test(String(x.thing)) || STYLE_WORD.test(String(x.value))) &&
3588
+ !blank(x.value) &&
3589
+ (!x.when || !s.when || x.when === s.when) &&
3590
+ (!x.state || x.state === s.state) &&
3591
+ // (A border written for one mode draws only in that mode.)
3592
+ (!x.mode || x.mode === /** @type {any} */ (s).mode) &&
3593
+ partsOf(ctx, x).includes(part),
3594
+ );
3595
+ }
3596
+
3597
+ /**
3598
+ * The look a part has by default: its documented default variant, as
3599
+ * `variant:<value>`, when the part records that variant.
3600
+ * @param {import('./_settings.mjs').Ctx} ctx
3601
+ * @param {string} part
3602
+ * @returns {string | undefined}
3603
+ */
3604
+ function defaultLook(ctx, part) {
3605
+ const values = ctx.C.variantValues(part)?.variant ?? [];
3606
+ if (!values.length) return undefined;
3607
+ for (const info of Object.values(ctx.project?.components ?? {})) {
3608
+ if (!info?.targets?.some(t => t.className === `astryx-${part}`)) continue;
3609
+ const v = String(info.props?.variant?.default ?? '').replace(/['"]/g, '');
3610
+ if (values.includes(v)) return `variant:${v}`;
3611
+ }
3612
+ return undefined;
3613
+ }
3614
+
3615
+ /**
3616
+ * Whether every border side a part draws at rest in a look is cleared on
3617
+ * its first child: a seam with the sibling before it (a button group's
3618
+ * join), never a line around the part.
3619
+ * @param {any} C
3620
+ * @param {string} part
3621
+ * @param {string | undefined} when
3622
+ */
3623
+ function seamOnly(C, part, when) {
3624
+ const v = String(when ?? '').replace(/^variant:/, '');
3625
+ const blank = (/** @type {unknown} */ x) =>
3626
+ /^\s*(?:0(?:px)?|none)\s*$/.test(String(x));
3627
+ const drawn = Object.entries(C.MAP[part]?.at ?? {})
3628
+ .filter(([prop]) => /^border(?:-[a-z-]+)?-width$/.test(prop))
3629
+ .flatMap(([, rules]) =>
3630
+ Object.entries(/** @type {Record<string, unknown>} */ (rules))
3631
+ .filter(
3632
+ ([sel, val]) =>
3633
+ !/[\s:]/.test(sel) &&
3634
+ !blank(val) &&
3635
+ (!v ||
3636
+ !/(?:^|,)variant=/.test(sel) ||
3637
+ sel.split(',').includes(`variant=${v}`)),
3638
+ )
3639
+ .map(([sel]) => [rules, sel]),
3640
+ );
3641
+ return (
3642
+ drawn.length > 0 &&
3643
+ drawn.every(([rules, sel]) =>
3644
+ blank(/** @type {any} */ (rules)[`${sel} :first-child`]),
3645
+ )
3646
+ );
3647
+ }
3648
+
3649
+ /**
3650
+ * Whether Core draws a line around a part where it is asked: in the look
3651
+ * said, else the part's default look, at rest or in the state said. A side
3652
+ * cleared on the first child, a seam with the sibling before it, is never a
3653
+ * line around the part: a secondary button standing alone draws none.
3654
+ * @param {import('./_settings.mjs').Ctx} ctx
3655
+ * @param {string} part
3656
+ * @param {string | null | undefined} state
3657
+ * @param {string | undefined} when
3658
+ */
3659
+ export function drawsLineAround(ctx, part, state, when) {
3660
+ const look = when ?? defaultLook(ctx, part);
3661
+ const line =
3662
+ drawsLine(ctx.C, [part], 'border', null, look) ||
3663
+ (!!state && drawsLine(ctx.C, [part], 'border', state, look));
3664
+ return line && !seamOnly(ctx.C, part, look);
3665
+ }
3666
+
3667
+ /** A border color: one color, one per side, or one side's. */
3668
+ export const BORDER_COLOR_PROP =
3669
+ /^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?-color$/;
3670
+
3671
+ /** The border a border color brings to a part that draws none. */
3672
+ export const BORDER_TO_COLOR = 'var(--border-width) solid transparent';
3673
+
3674
+ /**
3675
+ * The theme's own setting that turns off every side a border color is on
3676
+ * (`border none`, `border-width 0`, `border-bottom none` for a bottom
3677
+ * color), read in order, or undefined.
3678
+ * @param {import('./_settings.mjs').Ctx} ctx
3679
+ * @param {any} data
3680
+ * @param {{on?: string, when?: string, state?: string}} s
3681
+ * @param {string} part
3682
+ */
3683
+ function borderSetToNone(ctx, data, s, part) {
3684
+ const hidden = borderSidesOff(ctx, data, s, part);
3685
+ const asked = borderSides(String(/** @type {any} */ (s).thing ?? ''));
3686
+ return asked.every(side => hidden.has(side))
3687
+ ? hidden.get(asked[0])
3688
+ : undefined;
3689
+ }
3690
+
3691
+ /**
3692
+ * The sides a border property names: one side, a logical pair, or all four.
3693
+ * @param {string} thing
3694
+ * @returns {string[]}
3695
+ */
3696
+ function borderSides(thing) {
3697
+ const m =
3698
+ /^border-(top|right|bottom|left|block|inline)(?:-(start|end))?/.exec(thing);
3699
+ if (!m) return [...BOX_SIDES];
3700
+ if (m[1] === 'block')
3701
+ return m[2] ? [m[2] === 'start' ? 'top' : 'bottom'] : ['top', 'bottom'];
3702
+ if (m[1] === 'inline')
3703
+ return m[2] ? [m[2] === 'start' ? 'left' : 'right'] : ['left', 'right'];
3704
+ return [m[1]];
3705
+ }
3706
+
3707
+ /**
3708
+ * The sides of a part's border the theme turns off where a color is asked,
3709
+ * each with the setting that does it, read in the order the settings are
3710
+ * written: a none or zero hides a side, and a later width, style or
3711
+ * shorthand on it draws it again (`border none` then `border-top 1px
3712
+ * solid` leaves the top). A width or style of several values names each
3713
+ * side as CSS reads it, a logical pair (`border-block-width '0 1px'`) its
3714
+ * start and end.
3715
+ * @param {import('./_settings.mjs').Ctx} ctx
3716
+ * @param {any} data
3717
+ * @param {{on?: string, when?: string, state?: string}} s
3718
+ * @param {string} part
3719
+ * @returns {Map<string, any>}
3720
+ */
3721
+ function borderSidesOff(ctx, data, s, part) {
3722
+ const edge =
3723
+ /^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?(?:-(width|style))?$/;
3724
+ const blank = (/** @type {string | undefined} */ t) =>
3725
+ /^(?:none|hidden|0(?:px|rem|em)?)$/i.test(t ?? '');
3726
+ /** @type {Map<string, any>} */
3727
+ const widthOff = new Map();
3728
+ /** @type {Map<string, any>} */
3729
+ const styleOff = new Map();
3730
+ for (const x of /** @type {any[]} */ (data?.settings ?? [])) {
3731
+ const m = edge.exec(String(x.thing));
3732
+ if (
3733
+ !m ||
3734
+ x.source !== 'property' ||
3735
+ // (A none set for one look hides only that look.)
3736
+ (x.when && x.when !== s.when) ||
3737
+ (x.state && x.state !== s.state) ||
3738
+ !partsOf(ctx, x).includes(part)
3739
+ )
3740
+ continue;
3741
+ const sides = borderSides(String(x.thing));
3742
+ const tokens = String(x.value).trim().split(/\s+/).filter(Boolean);
3743
+ // (A width or style names each side's value as CSS reads the list,
3744
+ // `calc()` kept whole; a logical pair is its start and its end.)
3745
+ const perSide = m[1] ? sidesOf(String(x.thing), String(x.value)) : null;
3746
+ /** @param {string} side @returns {string | undefined} */
3747
+ const tokenAt = side => {
3748
+ if (!perSide) return tokens[0];
3749
+ const prop = Object.keys(perSide).find(p => borderSides(p)[0] === side);
3750
+ return prop ? perSide[prop] : undefined;
3751
+ };
3752
+ sides.forEach(side => {
3753
+ if (m[1]) {
3754
+ const off = m[1] === 'width' ? widthOff : styleOff;
3755
+ if (blank(tokenAt(side))) off.set(side, x);
3756
+ else off.delete(side);
3757
+ } else {
3758
+ // (A shorthand writes the side's width and style together; with no
3759
+ // style in it, the style is none: `border-top 1px` draws no line.)
3760
+ const none =
3761
+ tokens.some(t => /^(?:none|hidden)$/i.test(t)) ||
3762
+ !tokens.some(t =>
3763
+ /^(?:solid|dashed|dotted|double|groove|ridge|inset|outset)$/i.test(
3764
+ t,
3765
+ ),
3766
+ );
3767
+ const zero = tokens.some(t => /^0(?:px|rem|em)?$/i.test(t));
3768
+ if (none || zero) {
3769
+ if (none) styleOff.set(side, x);
3770
+ else styleOff.delete(side);
3771
+ if (zero) widthOff.set(side, x);
3772
+ else widthOff.delete(side);
3773
+ } else {
3774
+ widthOff.delete(side);
3775
+ styleOff.delete(side);
3776
+ }
3777
+ }
3778
+ });
3779
+ }
3780
+ /** @type {Map<string, any>} */
3781
+ const off = new Map();
3782
+ for (const side of BOX_SIDES) {
3783
+ const by = styleOff.get(side) ?? widthOff.get(side);
3784
+ if (by) off.set(side, by);
3785
+ }
3786
+ return off;
3787
+ }
3788
+
3789
+ /**
3790
+ * The border a border color (one color, a color per side, or one side's)
3791
+ * brings to the part it is set on, when the part draws no border in the
3792
+ * variant and state asked (Core sets a tab's, a primary button's and a
3793
+ * banner's to none): a transparent one at rest, as wide as the theme's
3794
+ * border width, so the part keeps one size in every state and the color
3795
+ * has a line to show on. Null when the setting is no border color, its
3796
+ * parts draw a border there, or the theme itself sets their border to none
3797
+ * (set refuses that conflict, naming the none). Set and how both write it
3798
+ * before the color.
3799
+ * @param {import('./_settings.mjs').Ctx} ctx
3800
+ * @param {string} slug
3801
+ * @param {any} data
3802
+ * @param {import('./_settings.mjs').Setting} s the checked border color
3803
+ * @returns {import('./_settings.mjs').Setting | null}
3804
+ */
3805
+ export function borderFor(ctx, slug, data, s) {
3806
+ if (ctx.unchecked || !s.on || s.source !== 'property') return null;
3807
+ if (!BORDER_COLOR_PROP.test(s.thing)) return null;
3808
+ if (
3809
+ CSS_WIDE.includes(
3810
+ String(s.value ?? '')
3811
+ .trim()
3812
+ .toLowerCase(),
3813
+ )
3814
+ )
3815
+ return null;
3816
+ const parts = partsOf(ctx, s);
3817
+ /**
3818
+ * Whether the part draws a border where the color is asked. With no
3819
+ * --when, that is the look the part has by default, its documented
3820
+ * default variant (a card's default draws one; a button's secondary draws
3821
+ * only the seam with the button before it in a group, cleared on the
3822
+ * first child, which is no line around it).
3823
+ * @param {string} t
3824
+ */
3825
+ const draws = t =>
3826
+ drawsLineAround(ctx, t, s.state, s.when) ||
3827
+ bordersBeyondCore(
3828
+ ctx,
3829
+ data,
3830
+ {...s, when: s.when ?? defaultLook(ctx, t)},
3831
+ t,
3832
+ );
3833
+ if (
3834
+ !parts.length ||
3835
+ parts.some(
3836
+ t =>
3837
+ draws(t) ||
3838
+ // (Every side the color is on turned off: set refuses it.)
3839
+ borderSetToNone(ctx, data, s, t) != null,
3840
+ )
3841
+ )
3842
+ return null;
3843
+ const edge = checkSetting(
3844
+ ctx,
3845
+ slug,
3846
+ structuredClone(data),
3847
+ 'border',
3848
+ BORDER_TO_COLOR,
3849
+ {on: s.on, when: s.when, only: s.only},
3850
+ false,
3851
+ );
3852
+ // (In the color's own mode only where the look draws a line in the other
3853
+ // mode, a button group's seam, which a border for every mode would hide;
3854
+ // elsewhere for every mode, so the part keeps one size when the mode
3855
+ // changes.)
3856
+ const seam = parts.some(t =>
3857
+ drawsLine(ctx.C, [t], 'border', null, s.when ?? defaultLook(ctx, t)),
3858
+ );
3859
+ return s.mode && seam ? {...edge, mode: s.mode} : edge;
3860
+ }
3861
+
3862
+ /**
3863
+ * Whether a setting turns a border side off: a border width, style or side
3864
+ * shorthand (never a radius, spacing or image) whose value holds a none,
3865
+ * hidden or zero.
3866
+ * @param {{thing?: unknown, value?: unknown}} x
3867
+ */
3868
+ export function turnsBorderOff(x) {
3869
+ return (
3870
+ /^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?(?:-(?:width|style))?$/.test(
3871
+ String(x.thing),
3872
+ ) &&
3873
+ String(x.value ?? '')
3874
+ .trim()
3875
+ .split(/\s+/)
3876
+ .some(t => /^(?:none|hidden|0(?:px|rem|em)?)$/i.test(t))
3877
+ );
3878
+ }
3879
+
3880
+ /**
3881
+ * Where a border a color brings goes in the theme's settings: before the
3882
+ * part's own border widths, styles, shorthands and colors, so a side the
3883
+ * theme turns off or sizes itself keeps its own value and a color saved
3884
+ * earlier still draws.
3885
+ * @param {import('./_settings.mjs').Ctx} ctx
3886
+ * @param {any[]} settings
3887
+ * @param {import('./_settings.mjs').Setting} edge
3888
+ * @returns {number}
3889
+ */
3890
+ export function broughtBorderAt(ctx, settings, edge) {
3891
+ const parts = partsOf(ctx, edge);
3892
+ const i = settings.findIndex(
3893
+ x =>
3894
+ x.source === 'property' &&
3895
+ // (A saved border color too: written before the brought border, the
3896
+ // border's shorthand would reset it to see-through.)
3897
+ (/^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?(?:-(?:width|style))?$/.test(
3898
+ String(x.thing),
3899
+ ) ||
3900
+ BORDER_COLOR_PROP.test(String(x.thing))) &&
3901
+ (!x.when || !edge.when || x.when === edge.when) &&
3902
+ partsOf(ctx, x).some(t => parts.includes(t)),
3903
+ );
3904
+ return i < 0 ? settings.length : i;
3905
+ }
3906
+
3907
+ /**
3908
+ * Refuses a border color on a part where the theme itself turns off every
3909
+ * side the color is on (`border none --on tab`): the two say opposite
3910
+ * things, so neither is changed for the other. The refusal names the none
3911
+ * and offers its undo.
3912
+ * @param {import('./_settings.mjs').Ctx} ctx
3913
+ * @param {string} slug
3914
+ * @param {any} data
3915
+ * @param {import('./_settings.mjs').Setting} s
3916
+ * @param {string} prop
3917
+ */
3918
+ function borderNoneRefusal(ctx, slug, data, s, prop) {
3919
+ if (ctx.unchecked || !s.on || !BORDER_COLOR_PROP.test(prop)) return;
3920
+ const parts = partsOf(ctx, s);
3921
+ // (Whether Core draws the border or not: the theme's own none hides it
3922
+ // either way, an input's included.)
3923
+ if (!parts.length) return;
3924
+ const none = parts.map(t => borderSetToNone(ctx, data, s, t)).find(Boolean);
3925
+ if (!none) return;
3926
+ refuse(
3927
+ E.ERR_THEME_NO_EFFECT,
3928
+ `${slug} sets ${none.thing} ${none.value} on ${none.on}${none.when ? ` when ${none.when}` : ''}${none.state ? ` :${none.state}` : ''}, so ${prop} on ${s.on} has no line to color. Undo that first, then set the color: it brings the border it needs.`,
3929
+ {run: [setLine(slug, none.thing, '', none, true)]},
3930
+ );
3931
+ }
3932
+
3410
3933
  /**
3411
3934
  * Refuses an outline's color, width or offset on a part whose outline Core
3412
3935
  * draws as none in every rule (an input, which shows focus with a ring in
@@ -3516,12 +4039,7 @@ function mediaTextRefusal(ctx, slug, s, v) {
3516
4039
  * @returns {string | null}
3517
4040
  */
3518
4041
  export function inheritedReach(ctx, s, prop) {
3519
- if (
3520
- !/^(font-(size|weight|style|family|variant)|text-(transform|align)|letter-spacing|line-height|white-space|word-spacing)$/.test(
3521
- prop,
3522
- )
3523
- )
3524
- return null;
4042
+ if (!INHERITED_TEXT.test(prop)) return null;
3525
4043
  const reached = [
3526
4044
  ...new Set(
3527
4045
  partsOf(ctx, /** @type {any} */ (s)).flatMap(t =>
@@ -3659,24 +4177,6 @@ function sameState(state, states) {
3659
4177
  return states.find(x => flat(x) === flat(state)) ?? null;
3660
4178
  }
3661
4179
 
3662
- /** Other words for a state, each read as the first of these there is. */
3663
- const STATE_SYNONYMS = wordTable(
3664
- /** @type {Record<string, string[]>} */ ({
3665
- pressed: ['isPressed', 'active'],
3666
- press: ['isPressed', 'active'],
3667
- on: ['isPressed', 'checked', 'selected'],
3668
- down: ['active'],
3669
- clicked: ['active'],
3670
- hovered: ['hover'],
3671
- focused: ['focus-visible', 'focus-within', 'focus'],
3672
- checked: ['checked', 'selected'],
3673
- selected: ['selected', 'checked'],
3674
- open: ['open', 'expanded'],
3675
- expanded: ['expanded', 'open'],
3676
- inactive: ['disabled'],
3677
- }),
3678
- );
3679
-
3680
4180
  /**
3681
4181
  * The state a word for one names among those a part has, by the one table
3682
4182
  * of other words for states (expanded: open; pressed: a toggle's isPressed,
@@ -3802,7 +4302,10 @@ export function coveredPaints(ctx, part, prop) {
3802
4302
  ? null
3803
4303
  : t?.states.includes(k) && (v === k || v === 'true')
3804
4304
  ? `--state ${k}`
3805
- : t?.props.includes(k)
4305
+ : // (A prop the part's doc lists, or one the census saw it drawn
4306
+ // with, a toast's `type`.)
4307
+ t?.props.includes(k) ||
4308
+ /** @type {any} */ (C.MAP[part])?.attrs?.[k]?.includes(v)
3806
4309
  ? `--when ${k}:${v}`
3807
4310
  : null;
3808
4311
  covered.push({token: r.token, flags, cond: cond.replace(':', '=')});
@@ -3810,24 +4313,6 @@ export function coveredPaints(ctx, part, prop) {
3810
4313
  return {rest, covered};
3811
4314
  }
3812
4315
 
3813
- /**
3814
- * The colors a part's color prop may show when none is given: its default
3815
- * as its doc gives it; with none (Text's depends on its type), each value
3816
- * of the prop whose text token the part's own color reads, in the order
3817
- * the prop lists them. Empty with no color prop.
3818
- * @param {{type?: string, default?: string | null} | undefined} prop
3819
- * @param {Record<string, unknown> | undefined} reads the tokens the part's color reads (its part data)
3820
- * @returns {string[]}
3821
- */
3822
- function colorPropDefaults(prop, reads) {
3823
- if (!prop) return [];
3824
- const own = /^'([\w-]+)'$/.exec(String(prop.default ?? '').trim())?.[1];
3825
- if (own) return [own];
3826
- return [...String(prop.type ?? '').matchAll(/'([\w-]+)'/g)]
3827
- .map(m => m[1])
3828
- .filter(v => Object.hasOwn(reads ?? {}, `--color-text-${v}`));
3829
- }
3830
-
3831
4316
  /**
3832
4317
  * Check one setting and give it back ready to store, or refuse. What it
3833
4318
  * accepts, the settings loader takes too: the loader's own check runs last,
@@ -3839,11 +4324,13 @@ function colorPropDefaults(prop, reads) {
3839
4324
  * @param {string | undefined} value
3840
4325
  * @param {SetFlags} flags
3841
4326
  * @param {boolean} [unset] an undo of one setting: only the identity of the setting is checked
3842
- * @param {{reads?: ReadonlySet<string>, element?: Record<string, unknown>}} [scope] `reads`: the custom
4327
+ * @param {{reads?: ReadonlySet<string>, element?: Record<string, unknown>, saved?: boolean}} [scope] `reads`: the custom
3843
4328
  * properties the theme itself sets where the value is read, which a var()
3844
4329
  * in it reads as it reads a design token; `element`: the custom properties
3845
4330
  * set on the element the value is set on, when that is not the theme's
3846
- * root (a surface's own tokens), the only ones that can loop back to it
4331
+ * root (a surface's own tokens), the only ones that can loop back to it;
4332
+ * `saved`: the setting is read from the settings file, not typed in, so a
4333
+ * rule about what a new `set` writes does not refuse it
3847
4334
  * @returns {import('./_settings.mjs').Setting}
3848
4335
  */
3849
4336
  export function checkSetting(
@@ -3854,7 +4341,124 @@ export function checkSetting(
3854
4341
  value,
3855
4342
  flags,
3856
4343
  unset = false,
3857
- {reads, element} = {},
4344
+ scope = {},
4345
+ ) {
4346
+ try {
4347
+ return checkTyped(ctx, slug, data, thing, value, flags, unset, scope);
4348
+ } catch (e) {
4349
+ throw keepTypedScope(e, ctx, slug, data, flags);
4350
+ }
4351
+ }
4352
+
4353
+ /** The scope flags a refusal's line keeps from the line typed. */
4354
+ const SCOPE_FLAGS = /** @type {const} */ (['state', 'when', 'mode']);
4355
+
4356
+ /**
4357
+ * Every line a refusal offers for the theme keeps the scope typed: a
4358
+ * `--state` or `--when` on the same part, and a `--mode`, that the line
4359
+ * leaves out and does not give another value for go back into it whenever
4360
+ * the command takes the line with them, so following the line never writes
4361
+ * wider than what was asked (a hovered link's color offered for every
4362
+ * link). A line the command refuses with that flag (a `--mode` on what is
4363
+ * not a color) is the one that works, and is kept as it is.
4364
+ * @param {unknown} e
4365
+ * @param {import('./_settings.mjs').Ctx} ctx
4366
+ * @param {string} slug
4367
+ * @param {import('./_settings.mjs').ThemeData} data
4368
+ * @param {SetFlags} flags
4369
+ */
4370
+ function keepTypedScope(e, ctx, slug, data, flags) {
4371
+ if (!(e instanceof AstryxError) || !e.suggestions?.length || !data) return e;
4372
+ const typed = SCOPE_FLAGS.filter(k => flags?.[k]);
4373
+ if (!typed.length) return e;
4374
+ /** The line as the command reads it, set or undo. @param {string} name */
4375
+ const read = name => {
4376
+ const sub = name.startsWith(`${P} undo ${slug} `)
4377
+ ? 'undo'
4378
+ : name.startsWith(`${P} set ${slug} `)
4379
+ ? 'set'
4380
+ : null;
4381
+ if (!sub) return null;
4382
+ const line = readSetLine(
4383
+ sub === 'undo' ? name.replace(`${P} undo `, `${P} set `) : name,
4384
+ slug,
4385
+ );
4386
+ return line ? {sub, ...line} : null;
4387
+ };
4388
+ /**
4389
+ * Whether the command takes the line with these flags.
4390
+ * @param {NonNullable<ReturnType<typeof read>>} line
4391
+ * @param {SetFlags} withFlags
4392
+ */
4393
+ const takes = (line, withFlags) => {
4394
+ try {
4395
+ checkTyped(
4396
+ ctx,
4397
+ slug,
4398
+ structuredClone(data),
4399
+ line.thing,
4400
+ line.value,
4401
+ withFlags,
4402
+ line.sub === 'undo',
4403
+ );
4404
+ return true;
4405
+ } catch (err) {
4406
+ if (err instanceof AstryxError) return false;
4407
+ throw err;
4408
+ }
4409
+ };
4410
+ e.suggestions = e.suggestions.map(x => {
4411
+ const line = read(x.name);
4412
+ if (!line) return x;
4413
+ const missing = typed.filter(
4414
+ k =>
4415
+ line.flags[k] == null &&
4416
+ (k === 'mode' || (line.flags.on ?? null) === (flags.on ?? null)),
4417
+ );
4418
+ if (!missing.length) return x;
4419
+ /** @type {SetFlags} */
4420
+ const withFlags = {...line.flags};
4421
+ for (const k of missing) /** @type {any} */ (withFlags)[k] = flags[k];
4422
+ // Each flag on its own when the line does not take them together.
4423
+ const kept = takes(line, withFlags)
4424
+ ? withFlags
4425
+ : missing
4426
+ .map(k => ({...line.flags, [k]: flags[k]}))
4427
+ .find(f => takes(line, f));
4428
+ if (!kept) return x;
4429
+ const name = setLine(
4430
+ slug,
4431
+ line.thing,
4432
+ line.value,
4433
+ kept,
4434
+ line.sub === 'undo',
4435
+ );
4436
+ return {...x, name};
4437
+ });
4438
+ return e;
4439
+ }
4440
+
4441
+ /**
4442
+ * {@link checkSetting} without the scope pass on its refusals.
4443
+ * @param {import('./_settings.mjs').Ctx} ctx
4444
+ * @param {string} slug
4445
+ * @param {import('./_settings.mjs').ThemeData} data
4446
+ * @param {string} thing
4447
+ * @param {string | undefined} value
4448
+ * @param {SetFlags} flags
4449
+ * @param {boolean} [unset]
4450
+ * @param {{reads?: ReadonlySet<string>, element?: Record<string, unknown>, saved?: boolean}} [scope]
4451
+ * @returns {import('./_settings.mjs').Setting}
4452
+ */
4453
+ function checkTyped(
4454
+ ctx,
4455
+ slug,
4456
+ data,
4457
+ thing,
4458
+ value,
4459
+ flags,
4460
+ unset = false,
4461
+ {reads, element, saved = false} = {},
3858
4462
  ) {
3859
4463
  // Any other dial's value pasted with its property name (`font-size:
3860
4464
  // 18px;` for text-size, `color: #e11d48` for accent) is the value: one
@@ -3889,6 +4493,27 @@ export function checkSetting(
3889
4493
  },
3890
4494
  );
3891
4495
  }
4496
+ // Tailwind's color/opacity shorthand (`black/5`, `#000/10`) is no CSS
4497
+ // color: the same color at that opacity is, and is the line offered; a
4498
+ // Tailwind stop (`blue-500/20`) is named, since its color is not read
4499
+ // here. The opacity is never dropped.
4500
+ if (!unset && typeof value === 'string') {
4501
+ const read = colorOpacitiesAsCss(value);
4502
+ if (read) {
4503
+ const {css: asCss, found: clear, unread} = read;
4504
+ refuse(
4505
+ E.ERR_THEME_BAD_VALUE,
4506
+ unread.length
4507
+ ? `${unread.map(x => `"${x.typed}"`).join(', ')} ${unread.length > 1 ? 'are colors' : 'is a color'} with an opacity after the slash, as Tailwind writes it; CSS writes a color at an opacity as rgb(r g b / alpha), such as rgb(59 130 246 / 0.2). Give the color written out at that opacity.`
4508
+ : `${clear.map(x => `"${x.typed}"`).join(', ')} ${clear.length > 1 ? 'are colors' : 'is a color'} with an opacity after the slash, as Tailwind writes it; CSS writes ${clear.length > 1 ? 'them' : 'it'} as ${clear.map(x => x.color).join(', ')}.`,
4509
+ {
4510
+ run: unread.length
4511
+ ? [`${HOW} ${thing}`]
4512
+ : [setLine(slug, thing, asCss, flags)],
4513
+ },
4514
+ );
4515
+ }
4516
+ }
3892
4517
  // A value that holds NaN or undefined (a script's empty value pasted)
3893
4518
  // is no CSS value, and Core refuses a theme that resolves to one.
3894
4519
  if (
@@ -4047,6 +4672,61 @@ export function checkSetting(
4047
4672
  );
4048
4673
  }
4049
4674
  }
4675
+ // A part typed in the setting's place, the setting and its value after it
4676
+ // (`set t button background-color '#2563eb'`, `card padding 20px`,
4677
+ // `card 'padding: 20px'`, `buttons background-color red`): the setting
4678
+ // on that part, as --on reads it. (A dial of the same name, `buttons`,
4679
+ // only when what follows is no value of it.)
4680
+ if (!unset && typeof value === 'string' && !flags.on) {
4681
+ const on = partNamed(ctx, thing);
4682
+ const m =
4683
+ /^\s*([a-z-]+|--[a-z0-9-]+)\s*(?::\s*|\s+)(\S[\s\S]*?)\s*;?\s*$/i.exec(
4684
+ value,
4685
+ );
4686
+ const next = m ? m[1].toLowerCase() : '';
4687
+ if (
4688
+ on &&
4689
+ m &&
4690
+ (!DIALS[thing] || !dialValueFits(thing, value)) &&
4691
+ (DIALS[next] || cssProperties().has(next) || next.startsWith('--'))
4692
+ )
4693
+ refuse(
4694
+ E.ERR_THEME_BAD_VALUE,
4695
+ `"${thing}" is a part, typed in the setting's place; the setting is ${next}, and a value for one part is given with --on ${on}.`,
4696
+ {
4697
+ run: [
4698
+ `${P} set ${slug} ${next} ${quoteCommandArgument(m[2])} --on ${on}${flags.when ? ` --when ${flags.when}` : ''}${flags.state ? ` --state ${flags.state}` : ''}${flags.mode ? ` --mode ${flags.mode}` : ''}`,
4699
+ ],
4700
+ },
4701
+ );
4702
+ }
4703
+ // A dial's value that names a part or group, plural included, as a label
4704
+ // (`spacing 'buttons: roomy'`, `corners 'cards: pill'`), after `on`
4705
+ // (`'pill on card'`) or as its first or last word (`'card pill'`): the
4706
+ // part is read first, by the one part-in-value reader the properties
4707
+ // use, so the line keeps the change on that part, never the whole theme
4708
+ // (and never a dial the label also spells, when the rest is this dial's
4709
+ // value). The font takes any words, so its value is never split.
4710
+ if (
4711
+ !unset &&
4712
+ typeof value === 'string' &&
4713
+ DIALS[thing] &&
4714
+ thing !== 'font' &&
4715
+ !flags.on &&
4716
+ !dialValueFits(thing, value)
4717
+ ) {
4718
+ const named = partInValue(ctx, value);
4719
+ if (named && dialValueFits(thing, named.value))
4720
+ refuse(
4721
+ E.ERR_THEME_BAD_VALUE,
4722
+ `${named.on} in "${value}" is a part; a value for one part is given with --on ${named.on}.`,
4723
+ {
4724
+ run: [
4725
+ `${P} set ${slug} ${thing} ${quoteCommandArgument(named.value)} --on ${named.on}${named.state ? ` --state ${named.state}` : ''}${flags.when ? ` --when ${flags.when}` : ''}${flags.mode ? ` --mode ${flags.mode}` : ''}`,
4726
+ ],
4727
+ },
4728
+ );
4729
+ }
4050
4730
  // A value labeled with a word that is not this setting's own name (a
4051
4731
  // mode, a state, a device, a part, or a word the editor does not read) is
4052
4732
  // refused with what that word means here, never set with the word dropped.
@@ -4113,7 +4793,10 @@ export function checkSetting(
4113
4793
  (thing.startsWith('--') && isColorToken(thing)) ||
4114
4794
  (partProperty &&
4115
4795
  /color|^background$|^fill$|^stroke$|shadow/.test(thing));
4116
- const parts = [...ctx.project.target.keys(), ...Object.keys(FAMILIES)];
4796
+ const parts = [
4797
+ ...ctx.project.target.keys(),
4798
+ ...Object.keys(groupsOf(ctx)),
4799
+ ];
4117
4800
  // A theme with one mode: its own mode's label is the value, as the
4118
4801
  // theme has no other; the other mode's label names a mode it lacks.
4119
4802
  const only = oneModeOfTheme(data);
@@ -4424,6 +5107,7 @@ export function checkSetting(
4424
5107
  unset,
4425
5108
  reads,
4426
5109
  element,
5110
+ saved,
4427
5111
  );
4428
5112
  // A var() with a fallback always gives a value; a name one slip from a
4429
5113
  // design token is noted as a likely typo, and the setting stands.
@@ -4467,15 +5151,7 @@ export function checkSetting(
4467
5151
  * @returns {{on: string, value: string, state?: string} | null}
4468
5152
  */
4469
5153
  function partInValue(ctx, text) {
4470
- /** The part a word names, or null. @param {string} w */
4471
- const partOf = w => {
4472
- const word = w.trim().toLowerCase().replace(/\s+/g, '-');
4473
- return (
4474
- [word, word.replace(/e?s$/, ''), word.replace(/s$/, '')].find(
4475
- x => x && (ctx.project.target.has(x) || FAMILIES[x]),
4476
- ) ?? null
4477
- );
4478
- };
5154
+ const partOf = (/** @type {string} */ w) => partNamed(ctx, w);
4479
5155
  const t = text.trim();
4480
5156
  /** @type {Array<[string, string, string?]>} part words, value, state */
4481
5157
  const readings = [];
@@ -4499,6 +5175,23 @@ function partInValue(ctx, text) {
4499
5175
  return null;
4500
5176
  }
4501
5177
 
5178
+ /**
5179
+ * The part or group a word names as --on reads it (a plural is its part:
5180
+ * `cards`, `buttons`), or null. The one reader for a part named inside a
5181
+ * value and a part typed in the setting's place.
5182
+ * @param {any} ctx
5183
+ * @param {string} w
5184
+ * @returns {string | null}
5185
+ */
5186
+ export function partNamed(ctx, w) {
5187
+ const word = String(w).trim().toLowerCase().replace(/\s+/g, '-');
5188
+ return (
5189
+ [word, word.replace(/e?s$/, ''), word.replace(/s$/, '')].find(
5190
+ x => x && (ctx.project.target.has(x) || groupsOf(ctx)[x]),
5191
+ ) ?? null
5192
+ );
5193
+ }
5194
+
4502
5195
  /**
4503
5196
  * A note for a var() with a fallback whose name is a letter or two off a
4504
5197
  * design token (`var(--spacing-xl, 2rem)` when the token is `--spacing-x1`):
@@ -4533,6 +5226,7 @@ function fallbackVarTypo(v, TOKENS) {
4533
5226
  * @param {Record<string, unknown>} [element] the custom properties set on
4534
5227
  * the element the value is set on, when that is not the theme's root (a
4535
5228
  * surface's own tokens): only these can loop back to it
5229
+ * @param {boolean} [saved] read from the settings file, not typed in
4536
5230
  * @returns {import('./_settings.mjs').Setting}
4537
5231
  */
4538
5232
  function checkSettingAsTyped(
@@ -4545,6 +5239,7 @@ function checkSettingAsTyped(
4545
5239
  unset = false,
4546
5240
  reads = undefined,
4547
5241
  element = undefined,
5242
+ saved = false,
4548
5243
  ) {
4549
5244
  const s = checkOne(
4550
5245
  ctx,
@@ -4556,6 +5251,7 @@ function checkSettingAsTyped(
4556
5251
  unset,
4557
5252
  reads,
4558
5253
  element,
5254
+ saved,
4559
5255
  );
4560
5256
  const why = unset ? null : valueProblem(s);
4561
5257
  if (why)
@@ -4586,6 +5282,7 @@ function checkSettingAsTyped(
4586
5282
  * @param {boolean} unset
4587
5283
  * @param {ReadonlySet<string>} [reads] custom properties the theme sets where the value is read
4588
5284
  * @param {Record<string, unknown>} [element] the custom properties set on the element the value is set on, when that is not the theme's root
5285
+ * @param {boolean} [saved] read from the settings file, not typed in
4589
5286
  * @returns {import('./_settings.mjs').Setting}
4590
5287
  */
4591
5288
  function checkOne(
@@ -4598,6 +5295,7 @@ function checkOne(
4598
5295
  unset,
4599
5296
  reads,
4600
5297
  element = undefined,
5298
+ saved = false,
4601
5299
  ) {
4602
5300
  const {C} = ctx;
4603
5301
  const TARGET = ctx.project.target;
@@ -4822,25 +5520,75 @@ function checkOne(
4822
5520
  });
4823
5521
  // --only is checked on a part this Core has; a part in other letters or
4824
5522
  // misspelt gets the part's own refusal first, with --only kept.
4825
- // (What --only means is the one rule the settings reader reads a saved
4826
- // one by: onlyMeans.)
4827
- if (s.only && (!s.on || TARGET.has(s.on) || FAMILIES[s.on])) {
4828
- const means = onlyMeans(s.on);
4829
- if (means === 'group')
5523
+ // --only keeps a change to the part named. On a group itself, or with no
5524
+ // part, it names nothing to keep to, and is refused. On a part that is
5525
+ // styled on its own already (a part in no group that spreads, such as a
5526
+ // sub-part or a member of a group that spreads only when named), it asks
5527
+ // for what the change does anyway: the change is made, without it, and
5528
+ // said, so the escape always works.
5529
+ if (s.only && (!s.on || TARGET.has(s.on) || groupsOf(ctx)[s.on])) {
5530
+ // (One predicate with the settings reader: onlyMeans.)
5531
+ if (onlyMeans(s.on) === 'group')
4830
5532
  refuse(
4831
5533
  E.ERR_INVALID_ARGUMENT,
4832
5534
  '--only is for one member of a group, such as text-input (how --list groups).',
4833
5535
  {run: [`${HOW} --list groups`]},
4834
5536
  );
4835
- if (means === 'own')
5537
+ // (One predicate with the settings reader: a member of a group that
5538
+ // spreads.)
5539
+ if (!onlyFits(s, ctx)) {
5540
+ s.only = undefined;
5541
+ if (!unset)
5542
+ s.note = `${s.on} is styled on its own already (only the ${AUTO_SPREAD.join(' and ')} groups spread), so --only changes nothing: it is saved without it`;
5543
+ }
5544
+ }
5545
+ // A control that grows with its content takes its top and bottom padding
5546
+ // from its size's height, so controls keep one height at each size: a
5547
+ // padding of those sides alone changes nothing on it.
5548
+ if (
5549
+ s.on &&
5550
+ /^padding-(top|bottom|block(-start|-end)?)$/.test(kebab(String(thing)))
5551
+ ) {
5552
+ const reached = partsOf(ctx, /** @type {any} */ (s));
5553
+ if (
5554
+ reached.length &&
5555
+ reached.every(
5556
+ t =>
5557
+ growsWithContent(ctx, t, s.when) &&
5558
+ !notGrowingWhens(ctx, t, s.when).length,
5559
+ )
5560
+ )
4836
5561
  refuse(
4837
- E.ERR_INVALID_ARGUMENT,
4838
- `${s.on} is styled on its own already: only ${AUTO_SPREAD.join(' and ')} spread to their group, so drop --only.`,
4839
- // The same command with only --only dropped: every other scope
4840
- // (a variant, a state, a mode) kept, never a wider write.
4841
- {run: [setLine(slug, thing, v, {...s, only: undefined}, unset)]},
5562
+ E.ERR_THEME_NO_EFFECT,
5563
+ `${s.on} keeps Core's top and bottom padding, so a theme's padding never makes it taller than the other controls at its size; ${thing} changes nothing on it. Set its height instead: ${P} set ${slug} height <length> --on ${s.on} (every control's height at that size; add --only for ${s.on} alone).`,
5564
+ {run: [`${HOW} height`]},
4842
5565
  );
4843
5566
  }
5567
+ // A control's height is a size every control shares, which Core reads
5568
+ // inside its own sums: a word (auto) cannot be one. Only a height set
5569
+ // writes as a size token is refused (one predicate with set): a variant
5570
+ // that is not a size keeps a plain height. (A saved word height was built
5571
+ // as a plain height, and still is.)
5572
+ const asToken =
5573
+ !unset && !saved
5574
+ ? sharedControlHeight(ctx, {...s, source: 'property'})
5575
+ : null;
5576
+ if (asToken && !controlHeightValue(String(value)))
5577
+ refuse(
5578
+ E.ERR_THEME_BAD_VALUE,
5579
+ `${value} is not a size, and a height on ${s.on} ${asToken.own ? `is written as its own size token (${asToken.token})` : 'is the size every control takes (buttons, inputs, selectors, input groups)'}: give a length, as in ${P} set ${slug} height <length> --on ${s.on}${asToken.own ? ' --only' : ''}.`,
5580
+ {run: [`${HOW} height`]},
5581
+ );
5582
+ // (The height is written as that size's token: a value that reads the
5583
+ // token, itself or through the tokens set on the controls, would read
5584
+ // itself.)
5585
+ const loop = asToken ? heightTokenLoop(data, asToken, String(value)) : null;
5586
+ if (asToken && loop)
5587
+ refuse(
5588
+ E.ERR_THEME_BAD_VALUE,
5589
+ `${value} reads ${loop.length > 1 ? `${loop.slice(0, -1).join(', which reads ')}, which reads ` : ''}${asToken.token}, which is the token this height is written as, so it would read itself: give a length, as in ${P} set ${slug} height <length> --on ${s.on}${s.when ? ` --when ${s.when}` : ''}${asToken.own ? ' --only' : ''}.`,
5590
+ {run: [`${HOW} height`]},
5591
+ );
4844
5592
  // A font role in other letters (Body, CODE) is that role.
4845
5593
  if (
4846
5594
  thing === 'font' &&
@@ -4857,8 +5605,8 @@ function checkOne(
4857
5605
  },
4858
5606
  );
4859
5607
  const isRole = thing === 'font' && FONT_ROLES.includes(s.on ?? '');
4860
- if (s.on && !isRole && !FAMILIES[s.on]) {
4861
- const t = TARGET.get(s.on);
5608
+ if (s.on && !isRole && !groupsOf(ctx)[s.on]) {
5609
+ let t = TARGET.get(s.on);
4862
5610
  if (!t) {
4863
5611
  // Another case of a part or group, its class name copied from the
4864
5612
  // page (`.astryx-card`), or its component (`<Card>`, `Card`): that
@@ -4888,16 +5636,16 @@ function checkOne(
4888
5636
  const words = partWords();
4889
5637
  const candidates = [
4890
5638
  ...TARGET.keys(),
4891
- ...Object.keys(FAMILIES),
5639
+ ...Object.keys(groupsOf(ctx)),
4892
5640
  ...[...words]
4893
- .filter(([, on]) => TARGET.has(on) || FAMILIES[on])
5641
+ .filter(([, on]) => TARGET.has(on) || groupsOf(ctx)[on])
4894
5642
  .map(([w]) => w),
4895
5643
  ].filter(n => n !== lower && n !== dashed);
4896
5644
  // The one typo ranker (closestOf). A hit that is a part or group
4897
5645
  // name is that name (`tabel` is table); a word that is no name is
4898
5646
  // read as its part (`sidebr` is side-nav).
4899
5647
  const isName = (/** @type {string} */ n) =>
4900
- TARGET.has(n) || Boolean(FAMILIES[n]);
5648
+ TARGET.has(n) || Boolean(groupsOf(ctx)[n]);
4901
5649
  return [
4902
5650
  ...new Set(
4903
5651
  closestOf(dashed, candidates).map(n =>
@@ -4913,7 +5661,7 @@ function checkOne(
4913
5661
  w.replace(/(ch|sh|x|s)es$/, '$1'),
4914
5662
  w.replace(/s$/, ''),
4915
5663
  ])
4916
- .find(x => x !== lower && (TARGET.has(x) || FAMILIES[x]));
5664
+ .find(x => x !== lower && (TARGET.has(x) || groupsOf(ctx)[x]));
4917
5665
  // Several parts named in one --on (`button, text-input`, `button/
4918
5666
  // text-input`, `button and text-input`, or spaces): one command per
4919
5667
  // part named, each checked, never a group that one word of the list
@@ -4921,16 +5669,19 @@ function checkOne(
4921
5669
  const listed = /,|\/|&|\band\b/.test(lower);
4922
5670
  // (Words with only spaces that name one part, `text inputs`, are
4923
5671
  // that part.)
4924
- if (!(TARGET.has(dashed) || FAMILIES[dashed]) && (listed || !singular)) {
5672
+ if (
5673
+ !(TARGET.has(dashed) || groupsOf(ctx)[dashed]) &&
5674
+ (listed || !singular)
5675
+ ) {
4925
5676
  const pieces = lower
4926
5677
  .split(/\s*(?:,|\/|&|\band\b)\s*|\s+/)
4927
5678
  .map(x => x.trim())
4928
5679
  .filter(Boolean);
4929
5680
  const partOf = (/** @type {string} */ w) =>
4930
- TARGET.has(w) || FAMILIES[w]
5681
+ TARGET.has(w) || groupsOf(ctx)[w]
4931
5682
  ? w
4932
5683
  : ([w.replace(/ies$/, 'y'), w.replace(/s$/, '')].find(
4933
- x => x !== w && (TARGET.has(x) || FAMILIES[x]),
5684
+ x => x !== w && (TARGET.has(x) || groupsOf(ctx)[x]),
4934
5685
  ) ?? null);
4935
5686
  const found = pieces.map(partOf);
4936
5687
  const parts = [...new Set(found.filter(x => x != null))];
@@ -4952,15 +5703,15 @@ function checkOne(
4952
5703
  );
4953
5704
  }
4954
5705
  const named =
4955
- TARGET.has(lower) || FAMILIES[lower]
5706
+ TARGET.has(lower) || groupsOf(ctx)[lower]
4956
5707
  ? lower
4957
- : TARGET.has(dashed) || FAMILIES[dashed]
5708
+ : TARGET.has(dashed) || groupsOf(ctx)[dashed]
4958
5709
  ? dashed
4959
5710
  : singular
4960
5711
  ? singular
4961
5712
  : typoParts.length === 1
4962
5713
  ? typoParts[0]
4963
- : byWord && (TARGET.has(byWord) || FAMILIES[byWord])
5714
+ : byWord && (TARGET.has(byWord) || groupsOf(ctx)[byWord])
4964
5715
  ? byWord
4965
5716
  : null;
4966
5717
  // The page (the body behind every part) is painted by the app shell.
@@ -4986,27 +5737,121 @@ function checkOne(
4986
5737
  run: [setLine(slug, thing, v, {...s, on: named}, unset)],
4987
5738
  },
4988
5739
  );
5740
+ // A name that is a part's name with more after it: the longest part
5741
+ // name it starts with. The rest is a state of that part (`link-hover`,
5742
+ // `tab-selected`), a variant of it (`button-primary`), or a piece it
5743
+ // draws (a top nav heading's title, `top-nav-heading-title`): the
5744
+ // piece's own name among the parts it holds, or, holding none, an
5745
+ // inner element the census saw. A text property those inner elements
5746
+ // read from tokens is offered as those tokens there. Any other rest
5747
+ // (`tab-panel`) is no piece of it.
5748
+ const holder = [...TARGET.keys()]
5749
+ .filter(n => dashed.startsWith(`${n}-`))
5750
+ .sort((a, b) => b.length - a.length)[0];
5751
+ const rest = holder ? dashed.slice(holder.length + 1) : '';
5752
+ const record = holder ? ctx.C.MAP[holder] : null;
5753
+ const variant = Object.entries(record?.attrs ?? {}).find(
5754
+ ([, vals]) => Array.isArray(vals) && vals.includes(rest),
5755
+ )?.[0];
5756
+ if (
5757
+ holder &&
5758
+ (STATE_WORDS.includes(rest) ||
5759
+ TARGET.get(holder)?.states?.includes(rest))
5760
+ )
5761
+ refuse(
5762
+ E.ERR_THEME_UNKNOWN_PART,
5763
+ `"${s.on}" is not a part name; it is ${holder} when ${rest}, set on ${holder} --state ${rest}.`,
5764
+ {
5765
+ didYouMean: [holder],
5766
+ run: [
5767
+ setLine(slug, thing, v, {...s, on: holder, state: rest}, unset),
5768
+ ],
5769
+ },
5770
+ );
5771
+ if (holder && variant)
5772
+ refuse(
5773
+ E.ERR_THEME_UNKNOWN_PART,
5774
+ `"${s.on}" is not a part name; it is ${holder} with ${variant} ${rest}, set on ${holder} --when ${variant}:${rest}.`,
5775
+ {
5776
+ didYouMean: [holder],
5777
+ run: [
5778
+ setLine(
5779
+ slug,
5780
+ thing,
5781
+ v,
5782
+ {...s, on: holder, when: `${variant}:${rest}`},
5783
+ unset,
5784
+ ),
5785
+ ],
5786
+ },
5787
+ );
5788
+ const held = record?.contains ?? [];
5789
+ if (
5790
+ holder &&
5791
+ (held.length
5792
+ ? held.some(k => k.split('-').at(-1) === rest.split('-').at(-1))
5793
+ : Object.keys(record?.innerSets ?? {}).length > 0)
5794
+ ) {
5795
+ const toks = innerPropTokens(ctx.C, holder, kebab(thing));
5796
+ // (A text size said of the main piece's name, "top-nav-heading-title"
5797
+ // or "-heading", where the holder's main text can be told: set on, or
5798
+ // undone from, the holder, as said of it. Another piece's name,
5799
+ // "-subtitle", is refused: which line it is cannot be told apart.)
5800
+ const main =
5801
+ !s.state &&
5802
+ kebab(thing) === 'font-size' &&
5803
+ /^(?:title|heading)$/.test(rest)
5804
+ ? mainTextSizeToken(ctx.C, holder, TOKENS)
5805
+ : null;
5806
+ if (main && (unset || !namesToken(v, main))) {
5807
+ const said = `"${s.on}" is drawn inside ${holder}: ${unset ? 'undone from' : 'set on'} ${holder}`;
5808
+ s.note = s.note ? `${s.note}; ${said}` : said;
5809
+ s.on = holder;
5810
+ // (As --only reads on the holder named directly.)
5811
+ if (s.only && !onlyFits(s)) {
5812
+ s.only = undefined;
5813
+ if (!unset)
5814
+ s.note = `${s.note}; ${holder} is styled on its own already, so --only changes nothing: it is saved without it`;
5815
+ }
5816
+ } else
5817
+ refuse(
5818
+ E.ERR_THEME_UNKNOWN_PART,
5819
+ `"${s.on}" is not a part name; what it names is drawn inside ${holder}, the part to set it on${toks.length ? `, where its ${kebab(thing)} comes from ${toks.join(', ')}` : ''}.`,
5820
+ {
5821
+ didYouMean: [holder],
5822
+ run: toks.length
5823
+ ? toks.map(tok =>
5824
+ setLine(slug, tok, v, {...s, on: holder}, unset),
5825
+ )
5826
+ : [setLine(slug, thing, v, {...s, on: holder}, unset)],
5827
+ },
5828
+ );
5829
+ }
4989
5830
  // A plural or another case names the part it means; a typo of one
4990
5831
  // part leads with the same command on that part.
4991
5832
  const near = nearest(s.on.toLowerCase().replace(/s$/, ''), [
4992
5833
  ...TARGET.keys(),
4993
- ...Object.keys(FAMILIES),
5834
+ ...Object.keys(groupsOf(ctx)),
4994
5835
  ]);
4995
5836
  const typo = near.filter(n => typoOf(lower, n));
4996
- refuse(
4997
- E.ERR_THEME_UNKNOWN_PART,
4998
- `"${s.on}" is not a part you can style.`,
4999
- {
5000
- didYouMean: near,
5001
- run: [
5002
- ...(typo.length === 1
5003
- ? [setLine(slug, thing, v, {...s, on: typo[0]}, unset)]
5004
- : []),
5005
- `${HOW} --list parts ${quoteCommandArgument(lower.replace(/s$/, '').split('-')[0] || 'button')}`,
5006
- `${HOW} ${quoteCommandArgument(s.on)}`,
5007
- ],
5008
- },
5009
- );
5837
+ // (A title piece moved onto its holder above is a part now.)
5838
+ const moved = TARGET.get(s.on);
5839
+ if (moved) t = moved;
5840
+ else
5841
+ refuse(
5842
+ E.ERR_THEME_UNKNOWN_PART,
5843
+ `"${s.on}" is not a part you can style.`,
5844
+ {
5845
+ didYouMean: near,
5846
+ run: [
5847
+ ...(typo.length === 1
5848
+ ? [setLine(slug, thing, v, {...s, on: typo[0]}, unset)]
5849
+ : []),
5850
+ `${HOW} --list parts ${quoteCommandArgument(lower.replace(/s$/, '').split('-')[0] || 'button')}`,
5851
+ `${HOW} ${quoteCommandArgument(s.on)}`,
5852
+ ],
5853
+ },
5854
+ );
5010
5855
  }
5011
5856
  if (s.when) {
5012
5857
  const variants = C.variantValues(s.on);
@@ -5091,6 +5936,19 @@ function checkOne(
5091
5936
  // name or its ARIA attribute (`isPressed`, `aria-pressed` on a button,
5092
5937
  // `isSelected` on a tab) is the state of that name.
5093
5938
  if (s.state) s.state = partState(ctx, s.on, s.state);
5939
+ // Another word for one state the part has (pressed on a part whose
5940
+ // press is active): written as that state, and said. A word for more
5941
+ // than one of its states is not written: the refusal below offers one.
5942
+ if (s.state && !s.state.includes('+') && !statesHold(states, s.state)) {
5943
+ const same = (STATE_SYNONYMS[s.state.toLowerCase()] ?? []).filter(x =>
5944
+ states.includes(x),
5945
+ );
5946
+ if (same.length === 1) {
5947
+ // (Its own note, beside any other the setting carries.)
5948
+ s.stateNote = `read as --state ${same[0]}: ${s.on} marks the ${s.state} moment as ${same[0]}`;
5949
+ s.state = same[0];
5950
+ }
5951
+ }
5094
5952
  // Several states in one --state (`hover,focus-visible`, `hover
5095
5953
  // focus-visible`): one line per state, the value quoted as typed.
5096
5954
  const typedStates = String(flags.state ?? '')
@@ -5145,16 +6003,23 @@ function checkOne(
5145
6003
  );
5146
6004
  if (s.state && !statesHold(states, s.state)) {
5147
6005
  // A part drawn inside this one that has the state (a calendar's day
5148
- // is today; the calendar is not): that part's line, with the state.
6006
+ // is today; the calendar is not; a pagination's page button is the
6007
+ // current one): that part's line, with the state. Its own pieces
6008
+ // first, then the parts the census finds drawn inside it.
5149
6009
  const state = String(s.state);
6010
+ const holds = (/** @type {string} */ k) =>
6011
+ statesHold(partStates(ctx, k), state);
5150
6012
  const inner = meant
5151
6013
  ? []
5152
- : [...ctx.project.target.keys()]
5153
- .filter(
5154
- k =>
5155
- k.startsWith(`${s.on}-`) &&
5156
- statesHold(partStates(ctx, k), state),
5157
- )
6014
+ : [
6015
+ ...new Set([
6016
+ ...[...ctx.project.target.keys()].filter(k =>
6017
+ k.startsWith(`${s.on}-`),
6018
+ ),
6019
+ ...(ctx.C.MAP[String(s.on)]?.contains ?? []),
6020
+ ]),
6021
+ ]
6022
+ .filter(k => ctx.project.target.has(k) && holds(k))
5158
6023
  .slice(0, 3);
5159
6024
  refuse(
5160
6025
  E.ERR_THEME_UNKNOWN_STATE,
@@ -5181,7 +6046,7 @@ function checkOne(
5181
6046
  !unset &&
5182
6047
  s.on &&
5183
6048
  !String(s.thing).startsWith('--') &&
5184
- !FAMILIES[s.on] &&
6049
+ !groupsOf(ctx)[s.on] &&
5185
6050
  /^(background(-color)?|color)$/.test(prop)
5186
6051
  ) {
5187
6052
  const rec = ctx.C.MAP[s.on];
@@ -5429,10 +6294,12 @@ function checkOne(
5429
6294
  );
5430
6295
  }
5431
6296
  // On a group, a variant or state must belong to at least one member.
5432
- if (s.on && FAMILIES[s.on] && (s.when || s.state)) {
6297
+ if (s.on && groupsOf(ctx)[s.on] && (s.when || s.state)) {
5433
6298
  const members =
5434
6299
  /** @type {Array<[string, import('../../foundation/discovery/theming-targets.mjs').ThemingTarget]>} */ (
5435
- FAMILIES[s.on].map(m => [m, TARGET.get(m)]).filter(([, t]) => t)
6300
+ (groupsOf(ctx)[s.on] ?? [])
6301
+ .map(m => [m, TARGET.get(m)])
6302
+ .filter(([, t]) => t)
5436
6303
  );
5437
6304
  // What the members have between them: their props, each prop's values,
5438
6305
  // their states. A typo or another case on the group is read as on one
@@ -5540,7 +6407,7 @@ function checkOne(
5540
6407
  );
5541
6408
  if (DIALS[thing]) {
5542
6409
  s.source = 'dial';
5543
- if (['surfaces', 'buttons', 'type'].includes(thing)) {
6410
+ if (['surfaces', 'buttons', 'badges', 'type'].includes(thing)) {
5544
6411
  if (s.on)
5545
6412
  refuse(
5546
6413
  E.ERR_THEME_BAD_VALUE,
@@ -5603,7 +6470,11 @@ function checkOne(
5603
6470
  CORNERS.find(
5604
6471
  ([n]) => lower.replace(/s$/, '') === n,
5605
6472
  )?.[0] ?? lower,
5606
- thing === 'buttons' ? {on: 'button'} : {},
6473
+ thing === 'buttons'
6474
+ ? {on: 'button'}
6475
+ : thing === 'badges'
6476
+ ? {on: 'badge'}
6477
+ : {},
5607
6478
  ),
5608
6479
  ]
5609
6480
  : [
@@ -5944,7 +6815,7 @@ function checkOne(
5944
6815
  if (thing === 'corners') {
5945
6816
  if (s.on) {
5946
6817
  refuseInvisibleCorners(ctx, slug, s, data);
5947
- refuseRadioCorners(ctx, slug, s);
6818
+ refuseRadioCorners(ctx, slug, s, data);
5948
6819
  }
5949
6820
  // With no corners setting yet, a step starts from the base theme's
5950
6821
  // own radius.
@@ -6237,7 +7108,7 @@ function checkOne(
6237
7108
  const pastSpacing = (/** @type {[string, number]} */ [, k]) => {
6238
7109
  if (!s.on) return null;
6239
7110
  // (A group: its first member that reads a control height.)
6240
- const parts = FAMILIES[s.on] ?? [s.on];
7111
+ const parts = groupsOf(ctx)[s.on] ?? [s.on];
6241
7112
  const token = parts
6242
7113
  .flatMap(p => C.partReads(p, 'size') ?? [])
6243
7114
  .map((/** @type {{token: string}} */ r) => r.token)
@@ -6519,9 +7390,7 @@ function checkOne(
6519
7390
  // counts when vibrancy changes the shades made from it at all (a warm
6520
7391
  // gray has a little hue to take out or add; a pure gray has none).
6521
7392
  const inEffect = seedsInEffect(ctx.project.cwd, slug, data);
6522
- const canApply = inEffect.some(f =>
6523
- vibrancyMoves(f.dial, f.seed, 0, 100),
6524
- );
7393
+ const canApply = vibrancyMovesAny(inEffect);
6525
7394
  // The fills the theme's own source sets win over their settings.
6526
7395
  const fromSource = inEffect.filter(f => f.source);
6527
7396
  if (!step && canApply && (!/^\d{1,3}$/.test(v) || Number(v) > 100)) {
@@ -6948,7 +7817,7 @@ function checkOne(
6948
7817
  // or group, `link`) is no typo of another token's word (`pink`): the
6949
7818
  // name near by spelling is then no reading of it.
6950
7819
  const knownWord = (/** @type {string} */ w) =>
6951
- TARGET.has(w) || Boolean(FAMILIES[w]) || partWords().has(w);
7820
+ TARGET.has(w) || Boolean(groupsOf(ctx)[w]) || partWords().has(w);
6952
7821
  const typedWords = thing.toLowerCase().replace(/^-+/, '').split('-');
6953
7822
  const near = nearest(thing, Object.keys(TOKENS)).filter(n => {
6954
7823
  const nearWords = n.replace(/^-+/, '').split('-');
@@ -7074,6 +7943,15 @@ function checkOne(
7074
7943
  multipliedTokens(ctx.project).has(thing),
7075
7944
  data.settings.some(x => x.thing === thing),
7076
7945
  );
7946
+ // A control's size token takes what a control's height takes (one
7947
+ // predicate with `set height --on <control>`): no percentage. Only a
7948
+ // typed value is refused; a saved one still opens.
7949
+ if (!saved && /^--size-element-/.test(thing) && !controlHeightValue(v))
7950
+ refuse(
7951
+ E.ERR_THEME_BAD_VALUE,
7952
+ `${v} is not a size a control can take: ${thing} is a control's height, which Core reads inside its own sums, so it takes a length and no percentage, as in ${setLine(slug, thing, '40px', s)}.`,
7953
+ {run: [`${HOW} ${thing}`]},
7954
+ );
7077
7955
  checkCycle(thing, v, TOKENS, data, ctx.project.cwd, s, element);
7078
7956
  // With no part data, what reads the token is unknown: save, unchecked.
7079
7957
  if (ctx.unchecked) return s;
@@ -7098,16 +7976,34 @@ function checkOne(
7098
7976
  ),
7099
7977
  ]),
7100
7978
  );
7979
+ // (A text size token said for one part that reads no size token,
7980
+ // whose held parts read one, a tab list's tabs: the value goes into
7981
+ // that token on the part; the build reads it the same way.)
7982
+ if (results.length === 1 && results[0][1] && !results[0][1].soft) {
7983
+ const held = heldSizeTokenFor(
7984
+ C,
7985
+ s,
7986
+ results[0][0],
7987
+ thing,
7988
+ v,
7989
+ results[0][1],
7990
+ );
7991
+ if (held) {
7992
+ results[0][1] = null;
7993
+ const said = `${results[0][0]} never reads ${thing}: its text reads ${held}, so the value goes into ${held} on ${results[0][0]}`;
7994
+ s.note = s.note ? `${s.note}; ${said}` : said;
7995
+ }
7996
+ }
7101
7997
  const recorded = results.filter(([, r]) => !r?.soft);
7102
7998
  const hard = recorded.filter(([, r]) => r);
7103
7999
  const spread = Boolean(
7104
- FAMILIES[s.on ?? ''] || (familyOf(s.on ?? '') && parts.length > 1),
8000
+ groupsOf(ctx)[s.on ?? ''] || (familyOf(s.on ?? '') && parts.length > 1),
7105
8001
  );
7106
8002
  // A part with no record is judged by its group: refused when no
7107
8003
  // member that has a record reads the token, as the group form is.
7108
8004
  const fam = s.on ? familyOf(s.on) : null;
7109
8005
  if (!recorded.length && fam && !spread) {
7110
- const siblings = FAMILIES[fam].filter(t => C.MAP[t]);
8006
+ const siblings = groupsOf(ctx)[fam].filter(t => C.MAP[t]);
7111
8007
  const famResults = siblings.map(
7112
8008
  t =>
7113
8009
  /** @type {[string, import('./_compiler.mjs').CheckFailure | null]} */ ([
@@ -7343,7 +8239,54 @@ function checkOne(
7343
8239
  (d.vars ?? []).some(x => inCalc.has(x.toLowerCase())),
7344
8240
  ),
7345
8241
  );
7346
- if (hit && !oneLength(v)) {
8242
+ // (A radius of two to four corners, each one length, is written as
8243
+ // each corner on the box, and its first corner as the one length the
8244
+ // variable takes: the build's corner radii, so it is taken.)
8245
+ const corners =
8246
+ prop === 'border-radius' &&
8247
+ splitTop(v.trim(), '/').every(half => {
8248
+ const w = splitTop(half.trim(), ' ').filter(Boolean);
8249
+ return (
8250
+ w.length >= 1 &&
8251
+ w.length <= 4 &&
8252
+ w.every(x => oneLength(x) || /^0+(?:\.0+)?$/.test(x))
8253
+ );
8254
+ }) &&
8255
+ (splitTop(v.trim(), ' ').filter(Boolean).length > 1 || v.includes('/'));
8256
+ // A padding of two to four lengths there is its sides, each with the
8257
+ // length typed for it: set writes them in this one change (a side
8258
+ // the part cannot take refuses as that side).
8259
+ const sides = !unset && hit && flags?.sides ? boxSides(prop, v) : null;
8260
+ if (sides?.length === 1) {
8261
+ s.value = sides[0][1];
8262
+ const said = `"${v.trim()}" is ${s.value} on every side, the one length ${hit} takes there`;
8263
+ // The value's own typo note, which the check below gives only to a
8264
+ // setting with no note yet, is kept beside it.
8265
+ const typo = fallbackVarTypo(
8266
+ String(s.value),
8267
+ ctx.project.core.tokenDefaults ?? {},
8268
+ );
8269
+ s.note = [s.note, said, typo].filter(Boolean).join('; ');
8270
+ } else if (sides)
8271
+ return {
8272
+ ...s,
8273
+ sides: sides.map(([side, x]) =>
8274
+ checkSetting(ctx, slug, data, `${prop}-${side}`, x, {
8275
+ on: s.on,
8276
+ when: s.when,
8277
+ state: s.state,
8278
+ mode: s.mode,
8279
+ only: s.only,
8280
+ }),
8281
+ ),
8282
+ };
8283
+ // A bare 0 is a length everywhere in CSS but inside calc(), where it
8284
+ // is a number: it is saved as 0px, the length it means.
8285
+ if (hit && /^[+-]?0*\.?0+$/.test(v.trim())) {
8286
+ s.value = '0px';
8287
+ const said = `${v.trim()} is saved as 0px: ${hit} reads ${prop} inside calc(), where a bare 0 is not a length`;
8288
+ s.note = s.note ? `${s.note}; ${said}` : said;
8289
+ } else if (hit && !oneLength(String(s.value)) && !corners) {
7347
8290
  const first = splitTop(v.trim(), ' ')[0] ?? '';
7348
8291
  const n = cssNumber(first);
7349
8292
  const fix = oneLength(first)
@@ -7354,11 +8297,7 @@ function checkOne(
7354
8297
  refuse(
7355
8298
  E.ERR_THEME_BAD_VALUE,
7356
8299
  `${hit} reads ${prop} inside calc() (its corners and inner rows follow it), where only one length works: a length, a variable, or calc(), min(), max() or clamp() giving one; not "${v.trim()}".`,
7357
- {
7358
- run: boxSideLines(slug, prop, v, s) ?? [
7359
- setLine(slug, prop, fix, s),
7360
- ],
7361
- },
8300
+ {run: [setLine(slug, prop, fix, s)]},
7362
8301
  );
7363
8302
  }
7364
8303
  }
@@ -7490,6 +8429,9 @@ function checkOne(
7490
8429
  // style is set for it.
7491
8430
  if (!unset && /^outline-(color|width|offset)$/.test(prop))
7492
8431
  noOutlineRefusal(ctx, slug, data, s, prop, v);
8432
+ // A border color where the theme itself sets the part's border to none
8433
+ // has no line to color (elsewhere set brings the border it needs).
8434
+ if (!unset) borderNoneRefusal(ctx, slug, data, s, prop);
7493
8435
  // A text property on a part whose text is drawn by elements inside it
7494
8436
  // that set that property themselves from a token (a top nav heading's
7495
8437
  // title span) never reaches that text: the token, on the part, does.
@@ -7508,38 +8450,42 @@ function checkOne(
7508
8450
  ].includes(prop)
7509
8451
  ) {
7510
8452
  const inner = partsOf(ctx, s)
7511
- .map(t => {
7512
- const rec = ctx.C.MAP[t];
7513
- // (A color only through the parts inside it: elements inside a
7514
- // part that read a color token are answered with the tokens on
7515
- // the part by how.)
7516
- let toks =
7517
- prop === 'color'
7518
- ? []
7519
- : Object.entries(rec?.inside ?? {})
7520
- .filter(([, props]) => props.includes(prop))
7521
- .map(([tok]) => tok);
7522
- const held = (rec?.contains ?? []).map(x => ctx.C.MAP[x]);
7523
- if (
7524
- !toks.length &&
7525
- !Object.keys(rec?.inside ?? {}).length &&
7526
- held.length &&
7527
- held.every(x => x?.own?.[prop])
7528
- )
7529
- toks = [
7530
- ...new Set(
7531
- held.flatMap(x => Object.keys(x.own[prop].tokens ?? {})),
7532
- ),
7533
- ]
7534
- .filter(tok => !/disabled|placeholder|accent/.test(tok))
7535
- .slice(0, 4);
7536
- return /** @type {const} */ ([
7537
- t,
7538
- rec && !rec.own?.[prop] ? toks : [],
7539
- ]);
7540
- })
8453
+ .map(t => /** @type {const} */ ([t, innerPropTokens(ctx.C, t, prop)]))
7541
8454
  .filter(([, toks]) => toks.length);
7542
- if (inner.length && inner.length === partsOf(ctx, s).length) {
8455
+ // One token for each part (a banner's text size, --text-label-size):
8456
+ // the value goes into it on the part (compileTheme), and the result
8457
+ // says so. With several (a top nav heading's title and subtitle
8458
+ // sizes), which one is meant is not known: the refusal names each.
8459
+ // A text column's lines (a banner's title and description) each take
8460
+ // it, since it means all of the part's text.
8461
+ const column = (/** @type {string} */ t, /** @type {string[]} */ toks) =>
8462
+ toks.length > 1 &&
8463
+ columnLineTokens(ctx.C, t, prop).join() === toks.join();
8464
+ // (A text size whose pieces each read a text size token, said of one
8465
+ // part, a top nav heading's title and supporting line: the main
8466
+ // text's, the largest.)
8467
+ const main = (/** @type {string} */ t) => {
8468
+ if (prop !== 'font-size' || partsOf(ctx, s).length !== 1) return null;
8469
+ const m = mainTextSizeToken(ctx.C, t, TOKENS);
8470
+ return m && !namesToken(v, m) ? m : null;
8471
+ };
8472
+ const oneEach =
8473
+ prop !== 'color' &&
8474
+ inner.every(
8475
+ ([t, toks]) => toks.length === 1 || column(t, toks) || main(t),
8476
+ );
8477
+ if (inner.length && inner.length === partsOf(ctx, s).length && oneEach) {
8478
+ const said = inner
8479
+ .map(([part, toks]) =>
8480
+ toks.length === 1
8481
+ ? `${part}'s text is drawn by elements inside it that set their own ${prop} from ${toks[0]}, so the value goes into ${toks[0]} on ${part}`
8482
+ : column(part, toks)
8483
+ ? `${part}'s text is in parts inside it that set their own ${prop} from ${toks.join(' and ')}, so the value goes into each: ${toks.map(tok => `${tok} on ${part}`).join(', ')}`
8484
+ : `${part}'s text is drawn by elements inside it that set their own ${prop} from ${toks.join(' and ')}, so the value goes into ${main(part)} on ${part}, the size of its main text`,
8485
+ )
8486
+ .join('; ');
8487
+ s.note = s.note ? `${s.note}; ${said}` : said;
8488
+ } else if (inner.length && inner.length === partsOf(ctx, s).length) {
7543
8489
  const [part, toks] = inner[0];
7544
8490
  refuse(
7545
8491
  E.ERR_THEME_NO_EFFECT,
@@ -7553,23 +8499,59 @@ function checkOne(
7553
8499
  );
7554
8500
  }
7555
8501
  }
8502
+ // A text property CSS inherits that an element inside the part sets
8503
+ // itself, to a value the component's props choose (a code block's lines:
8504
+ // white-space pre, or pre-wrap when wrapped), never reaches the text
8505
+ // that element holds: the prop decides it, never the theme. Refused,
8506
+ // naming the values there.
8507
+ if (!unset && INHERITED_TEXT.test(prop)) {
8508
+ const held = partsOf(ctx, s)
8509
+ .map(t => /** @type {const} */ ([t, ctx.C.MAP[t]?.innerSets?.[prop]]))
8510
+ .filter(
8511
+ ([t, vals]) =>
8512
+ Array.isArray(vals) &&
8513
+ vals.length > 1 &&
8514
+ !ctx.C.MAP[t]?.own?.[prop] &&
8515
+ innerPropTokens(ctx.C, t, prop).length === 0,
8516
+ );
8517
+ if (held.length && held.length === partsOf(ctx, s).length) {
8518
+ const [part, vals] = held[0];
8519
+ refuse(
8520
+ E.ERR_THEME_NO_EFFECT,
8521
+ `${part}'s text is laid out by an element inside it that sets its own ${prop} (${/** @type {string[]} */ (vals).join(' or ')}, as the component's props choose), so ${prop} on ${part} never shows; the app chooses it with that prop, never the theme.`,
8522
+ {run: [`${HOW} ${part}`]},
8523
+ );
8524
+ }
8525
+ }
7556
8526
  // A text property CSS inherits reaches the parts inside the part that
7557
8527
  // do not set it themselves (a side nav section's items): the result
7558
8528
  // says which.
7559
8529
  if (!unset) {
7560
8530
  const reach = inheritedReach(ctx, s, prop);
7561
- if (reach) s.note = reach;
8531
+ if (reach) s.note = s.note ? `${s.note}; ${reach}` : reach;
7562
8532
  }
7563
8533
  // Text, headings and links take their color from the color prop.
7564
8534
  const textParts = COLOR_PROP_PARTS;
7565
- // A heading's color is written as the text color tokens its color prop
7566
- // reads, on the heading alone (compileTheme), so it shows.
7567
- const headingColor =
8535
+ // A text, heading or link color is written as the text color tokens
8536
+ // its color prop reads, on that part alone (compileTheme), so it shows.
8537
+ const propTokens = partsOf(ctx, s).map(t =>
8538
+ colorPropTokens(ctx, t, s.when),
8539
+ );
8540
+ // (A value that is no color is refused below, with the nearest color.)
8541
+ const propColor =
7568
8542
  prop === 'color' &&
7569
- partsOf(ctx, s).length > 0 &&
7570
- partsOf(ctx, s).every(t => t === 'heading');
8543
+ isColorValue(v) &&
8544
+ propTokens.length > 0 &&
8545
+ propTokens.every(k => k.length);
8546
+ if (propColor && partsOf(ctx, s).some(t => t !== 'heading')) {
8547
+ const toks = [...new Set(propTokens.flat())];
8548
+ const said = `the color goes into ${toks.join(' and ')} on ${s.on}, the ${toks.length > 1 ? 'tokens' : 'token'} its color prop reads (Core sets that prop after part styles)`;
8549
+ s.note = s.note ? `${s.note}; ${said}` : said;
8550
+ }
7571
8551
  if (
7572
- !headingColor &&
8552
+ !propColor &&
8553
+ // (A value that is no color, "12px", is refused below as no color.)
8554
+ (unset || !v || isColorValue(v)) &&
7573
8555
  (prop === 'color' || prop === '-webkit-text-fill-color') &&
7574
8556
  partsOf(ctx, s).some(t => textParts.includes(t))
7575
8557
  ) {
@@ -7581,26 +8563,24 @@ function checkOne(
7581
8563
  v && isColorValue(v) && isFixedColor(v) && !/\bvar\(/i.test(v)
7582
8564
  ? v
7583
8565
  : (nearestColorName(v) ?? '#1f2937');
7584
- // The tokens the part's color prop reads: the one named, else the
7585
- // prop's default as its doc gives it (a link's accent), else each
7586
- // color whose token the part reads (Text's depends on its type),
7587
- // set on the part alone.
7588
- const colors = named
7589
- ? [named]
7590
- : colorPropDefaults(
7591
- partComponentDocs(ctx, /** @type {string} */ (s.on))
7592
- .map(d => d.doc.props?.color)
7593
- .find(Boolean),
7594
- ctx.C.MAP[/** @type {string} */ (s.on)]?.own?.color?.tokens,
7595
- );
7596
- const tail = `${s.on ? ` --on ${s.on}` : ''}${s.mode ? ` --mode ${s.mode}` : ''}`;
8566
+ // The tokens the part's color prop reads (colorPropTokens), set on
8567
+ // the part alone.
8568
+ const colors = colorPropTokens(
8569
+ ctx,
8570
+ /** @type {string} */ (s.on),
8571
+ s.when,
8572
+ ).map(t => t.replace(/^--color-text-/, ''));
7597
8573
  refuse(
7598
8574
  E.ERR_THEME_NO_EFFECT,
7599
8575
  `${s.on} takes its color from the color prop, which Core sets after part styles, so a color set on ${s.on} never shows. Set the token its color prop reads (${colors.map(c => `${c}: --color-text-${c}`).join('; ')}) on ${s.on} instead.`,
7600
8576
  {
7601
- run: colors.map(
7602
- c =>
7603
- `${P} set ${slug} --color-text-${c} ${quoteCommandArgument(color)}${tail}`,
8577
+ // The token on the part, in the scope typed: a hovered link's
8578
+ // color is the hovered link's token, never every link's.
8579
+ run: colors.map(c =>
8580
+ setLine(slug, `--color-text-${c}`, color, {
8581
+ ...s,
8582
+ when: named ? undefined : s.when,
8583
+ }),
7604
8584
  ),
7605
8585
  },
7606
8586
  );
@@ -7647,7 +8627,26 @@ function checkOne(
7647
8627
  : [`${HOW} ${prop}`],
7648
8628
  },
7649
8629
  );
8630
+ // A box color shorthand takes a color per side (`#ddd #ddd
8631
+ // transparent`), each one read as a color.
8632
+ const sides = colorSides(prop, v);
8633
+ if (sides?.tooMany)
8634
+ refuse(
8635
+ E.ERR_THEME_BAD_VALUE,
8636
+ `${prop} takes 1 to ${sides.max} colors, one per side; "${v}" has ${sides.colors.length}.`,
8637
+ {run: [`${HOW} ${prop}`]},
8638
+ );
8639
+ const notColor = sides?.colors.find(
8640
+ x => !isColorValue(x.color) || !isFixedColor(x.color),
8641
+ );
8642
+ if (sides && notColor)
8643
+ refuse(
8644
+ E.ERR_THEME_BAD_VALUE,
8645
+ `${prop} takes a color for each side; "${notColor.color}" in "${v}" is not one.`,
8646
+ {run: [`${HOW} ${prop}`]},
8647
+ );
7650
8648
  if (
8649
+ !sides &&
7651
8650
  COLOR_PROPS.test(prop) &&
7652
8651
  !CSS_WIDE.includes(v.trim().toLowerCase()) &&
7653
8652
  (!isColorValue(v) || !isFixedColor(v))
@@ -7693,6 +8692,9 @@ function checkOne(
7693
8692
  s.mode &&
7694
8693
  !COLOR_PROPS.test(prop) &&
7695
8694
  !(prop === 'background' && isColorValue(v)) &&
8695
+ // (The see-through border a border color brings, in that color's
8696
+ // mode: it shows nothing, and the other mode keeps its own line.)
8697
+ !(prop === 'border' && v.trim() === BORDER_TO_COLOR) &&
7696
8698
  // A gradient background (no image file) goes per mode: its colors
7697
8699
  // are each painted in that mode only (compileTheme).
7698
8700
  !(
@@ -7995,21 +8997,39 @@ function checkOne(
7995
8997
  * @param {import('./_settings.mjs').Ctx} ctx
7996
8998
  * @param {string} slug
7997
8999
  * @param {import('./_settings.mjs').Setting} s
9000
+ * @param {import('./_settings.mjs').ThemeData} data
7998
9001
  */
7999
- function refuseRadioCorners(ctx, slug, s) {
9002
+ function refuseRadioCorners(ctx, slug, s, data) {
8000
9003
  if (ctx.unchecked) return;
8001
9004
  const parts = partsOf(ctx, s);
8002
9005
  if (!parts.length || !parts.every(t => radioCircle(ctx.C, t))) return;
8003
9006
  // A radius set on the part itself overrides the circle: a square radio
8004
- // is asked of this component, by name.
9007
+ // is asked of this component, by name. A fully round ask (pill, round)
9008
+ // is the circle it has: with a radius the theme set on it, the undo of
9009
+ // that radius gives the circle back.
8005
9010
  const px = cornerPxOf(String(s.value));
8006
- const own =
8007
- Number.isFinite(px) && px < 9999
8008
- ? setLine(slug, 'border-radius', px === 0 ? '0' : `${px}px`, s)
8009
- : null;
9011
+ const saved = (data?.settings ?? []).find(
9012
+ (/** @type {any} */ x) =>
9013
+ x.thing === 'border-radius' &&
9014
+ x.on === s.on &&
9015
+ !x.when &&
9016
+ !x.state &&
9017
+ !x.mode,
9018
+ );
9019
+ // (A step, "rounder" or "sharper", is no length: only "more" is round,
9020
+ // and "less" gets no line, since a circle has no corner to sharpen.)
9021
+ const step = Number.isFinite(px) ? null : String(s.value);
9022
+ const round = step ? step === 'more' : px >= 9999;
9023
+ const own = round
9024
+ ? saved
9025
+ ? `${P} undo ${slug} border-radius --on ${s.on}`
9026
+ : null
9027
+ : step
9028
+ ? null
9029
+ : setLine(slug, 'border-radius', px === 0 ? '0' : `${px}px`, s);
8010
9030
  refuse(
8011
9031
  E.ERR_THEME_NO_EFFECT,
8012
- `${s.on} is a radio's circle (border-radius 50%), not a corner, so the corners dial leaves it and changes nothing you see.${own ? ` A border-radius on it sets its shape: ${own.replace(`${P} `, '')}.` : ''}`,
9032
+ `${s.on} is a radio's circle (border-radius 50%), not a corner, so the corners dial leaves it and changes nothing you see.${round ? (saved ? ` ${slug} sets border-radius ${saved.value} on it; undoing that gives the circle back: ${String(own).replace(`${P} `, '')}.` : ` It is fully round already.`) : own ? ` A border-radius on it sets its shape: ${own.replace(`${P} `, '')}.` : ''}`,
8013
9033
  {run: own ? [own] : [`${HOW} ${s.on}`]},
8014
9034
  );
8015
9035
  }
@@ -8046,13 +9066,16 @@ function refuseInvisibleCorners(ctx, slug, s, data) {
8046
9066
  .slice(0, 3);
8047
9067
  refuse(
8048
9068
  E.ERR_THEME_NO_EFFECT,
8049
- `${s.on} has no background, border or shadow of its own, so rounding its corners changes nothing you see.${kids.length ? ` Parts inside it that do show an edge: ${kids.join(', ')}.` : ''}`,
9069
+ `${s.on} has no background, border or shadow of its own, so rounding its corners changes nothing you see. To round ${s.on} itself, give it a background or a border first, then set its corners.${kids.length ? ` Parts inside it that do show an edge: ${kids.join(', ')}.` : ''}`,
8050
9070
  {
8051
- run: kids.length
8052
- ? kids.map(k =>
8053
- setLine(slug, 'corners', s.value || 'round', {...s, on: k}),
8054
- )
8055
- : [`${HOW} ${s.on}`],
9071
+ // (How names the fill and border the part takes; the editor offers
9072
+ // no value the person did not type.)
9073
+ run: [
9074
+ `${HOW} ${s.on}`,
9075
+ ...kids.map(k =>
9076
+ setLine(slug, 'corners', s.value || 'round', {...s, on: k}),
9077
+ ),
9078
+ ],
8056
9079
  },
8057
9080
  );
8058
9081
  }
@@ -8100,6 +9123,7 @@ function statusTwin(C, recorded, thing, when) {
8100
9123
  */
8101
9124
  const dialWrites = token =>
8102
9125
  PALETTE_TOKENS.has(token) ||
9126
+ isLookToken(token) ||
8103
9127
  /^--(text-(heading|display)-\d-weight|radius-|spacing-|size-element-|font-size-)/.test(
8104
9128
  token,
8105
9129
  );
@@ -8188,10 +9212,18 @@ export function propertyValueProblem(ctx, prop, value, TOKENS, reads) {
8188
9212
  const mismatch = tokenKindMismatch(ctx, prop, v);
8189
9213
  if (mismatch) return mismatch.message;
8190
9214
  if (CSS_WIDE.includes(v.toLowerCase())) return null;
8191
- if (COLOR_PROPS.test(prop))
8192
- return /\bvar\(/i.test(v) || isColorValue(v)
8193
- ? null
8194
- : `${prop} takes a color; "${v}" is not one.`;
9215
+ if (COLOR_PROPS.test(prop)) {
9216
+ const sides = colorSides(prop, v);
9217
+ const one = (/** @type {string} */ x) =>
9218
+ /\bvar\(/i.test(x) || isColorValue(x);
9219
+ if (sides)
9220
+ return sides.tooMany
9221
+ ? `${prop} takes 1 to ${sides.max} colors, one per side; "${v}" has ${sides.colors.length}.`
9222
+ : sides.colors.every(x => one(x.color))
9223
+ ? null
9224
+ : `${prop} takes a color for each side; "${v}" is not that.`;
9225
+ return one(v) ? null : `${prop} takes a color; "${v}" is not one.`;
9226
+ }
8195
9227
  const grammar = propertyProblem(prop, v);
8196
9228
  return grammar ? `${prop} takes ${grammar.takes}; "${v}" is not one.` : null;
8197
9229
  }