@rien7/seji 0.0.0 → 0.6.1

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 (414) hide show
  1. package/bin/design-surface.mjs +6 -0
  2. package/bin/postinstall.mjs +19 -0
  3. package/bin/seji.mjs +585 -0
  4. package/dist/agent/host.d.mts +34 -0
  5. package/dist/agent/host.mjs +387 -0
  6. package/dist/agent/messages.d.mts +9 -0
  7. package/dist/agent/messages.mjs +70 -0
  8. package/dist/agent/runtimes.mjs +157 -0
  9. package/dist/cli/app.mjs +321 -0
  10. package/dist/cli/appScan.mjs +284 -0
  11. package/dist/cli/catalog.mjs +78 -0
  12. package/dist/cli/component.mjs +165 -0
  13. package/dist/cli/consolidate.mjs +159 -0
  14. package/dist/cli/cssImport.mjs +68 -0
  15. package/dist/cli/dev.mjs +339 -0
  16. package/dist/cli/doctor.mjs +311 -0
  17. package/dist/cli/init.mjs +338 -0
  18. package/dist/cli/legacyNames.mjs +266 -0
  19. package/dist/cli/migrate.mjs +163 -0
  20. package/dist/cli/prompt.mjs +34 -0
  21. package/dist/cli/propose.mjs +208 -0
  22. package/dist/cli/providers.mjs +344 -0
  23. package/dist/cli/reviewOps.mjs +110 -0
  24. package/dist/cli/semver.mjs +45 -0
  25. package/dist/cli/setup.mjs +360 -0
  26. package/dist/cli/sketches.mjs +47 -0
  27. package/dist/cli/skills.mjs +150 -0
  28. package/dist/cli/snapshot.mjs +107 -0
  29. package/dist/cli/tokenOps.mjs +120 -0
  30. package/dist/cli/types.mjs +191 -0
  31. package/dist/cli/updater.mjs +274 -0
  32. package/dist/components/astIndex.mjs +992 -0
  33. package/dist/components/ops.mjs +1069 -0
  34. package/dist/editor/AgentProposalCard.d.ts +10 -0
  35. package/dist/editor/AgentProposalCard.d.ts.map +1 -0
  36. package/dist/editor/AgentProposalCard.js +31 -0
  37. package/dist/editor/AgentProposalCard.js.map +1 -0
  38. package/dist/editor/App.d.ts +2 -0
  39. package/dist/editor/App.d.ts.map +1 -0
  40. package/dist/editor/App.js +2834 -0
  41. package/dist/editor/App.js.map +1 -0
  42. package/dist/editor/CanvasHud.d.ts +12 -0
  43. package/dist/editor/CanvasHud.d.ts.map +1 -0
  44. package/dist/editor/CanvasHud.js +13 -0
  45. package/dist/editor/CanvasHud.js.map +1 -0
  46. package/dist/editor/CanvasSurface.d.ts +31 -0
  47. package/dist/editor/CanvasSurface.d.ts.map +1 -0
  48. package/dist/editor/CanvasSurface.js +270 -0
  49. package/dist/editor/CanvasSurface.js.map +1 -0
  50. package/dist/editor/CommentPopover.d.ts +17 -0
  51. package/dist/editor/CommentPopover.d.ts.map +1 -0
  52. package/dist/editor/CommentPopover.js +62 -0
  53. package/dist/editor/CommentPopover.js.map +1 -0
  54. package/dist/editor/Comments.d.ts +13 -0
  55. package/dist/editor/Comments.d.ts.map +1 -0
  56. package/dist/editor/Comments.js +41 -0
  57. package/dist/editor/Comments.js.map +1 -0
  58. package/dist/editor/ComponentPage.d.ts +28 -0
  59. package/dist/editor/ComponentPage.d.ts.map +1 -0
  60. package/dist/editor/ComponentPage.js +55 -0
  61. package/dist/editor/ComponentPage.js.map +1 -0
  62. package/dist/editor/ComponentPanel.d.ts +38 -0
  63. package/dist/editor/ComponentPanel.d.ts.map +1 -0
  64. package/dist/editor/ComponentPanel.js +275 -0
  65. package/dist/editor/ComponentPanel.js.map +1 -0
  66. package/dist/editor/Glyph.d.ts +51 -0
  67. package/dist/editor/Glyph.d.ts.map +1 -0
  68. package/dist/editor/Glyph.js +50 -0
  69. package/dist/editor/Glyph.js.map +1 -0
  70. package/dist/editor/History.d.ts +7 -0
  71. package/dist/editor/History.d.ts.map +1 -0
  72. package/dist/editor/History.js +51 -0
  73. package/dist/editor/History.js.map +1 -0
  74. package/dist/editor/Inspector.d.ts +56 -0
  75. package/dist/editor/Inspector.d.ts.map +1 -0
  76. package/dist/editor/Inspector.js +510 -0
  77. package/dist/editor/Inspector.js.map +1 -0
  78. package/dist/editor/LazyMount.d.ts +10 -0
  79. package/dist/editor/LazyMount.d.ts.map +1 -0
  80. package/dist/editor/LazyMount.js +29 -0
  81. package/dist/editor/LazyMount.js.map +1 -0
  82. package/dist/editor/LocaleSwitch.d.ts +3 -0
  83. package/dist/editor/LocaleSwitch.d.ts.map +1 -0
  84. package/dist/editor/LocaleSwitch.js +9 -0
  85. package/dist/editor/LocaleSwitch.js.map +1 -0
  86. package/dist/editor/PreviewFrame.d.ts +10 -0
  87. package/dist/editor/PreviewFrame.d.ts.map +1 -0
  88. package/dist/editor/PreviewFrame.js +22 -0
  89. package/dist/editor/PreviewFrame.js.map +1 -0
  90. package/dist/editor/ProjectIndex.d.ts +12 -0
  91. package/dist/editor/ProjectIndex.d.ts.map +1 -0
  92. package/dist/editor/ProjectIndex.js +43 -0
  93. package/dist/editor/ProjectIndex.js.map +1 -0
  94. package/dist/editor/PromoteComponent.d.ts +28 -0
  95. package/dist/editor/PromoteComponent.d.ts.map +1 -0
  96. package/dist/editor/PromoteComponent.js +33 -0
  97. package/dist/editor/PromoteComponent.js.map +1 -0
  98. package/dist/editor/PromoteForm.d.ts +18 -0
  99. package/dist/editor/PromoteForm.d.ts.map +1 -0
  100. package/dist/editor/PromoteForm.js +35 -0
  101. package/dist/editor/PromoteForm.js.map +1 -0
  102. package/dist/editor/PromoteToken.d.ts +31 -0
  103. package/dist/editor/PromoteToken.d.ts.map +1 -0
  104. package/dist/editor/PromoteToken.js +94 -0
  105. package/dist/editor/PromoteToken.js.map +1 -0
  106. package/dist/editor/StatePreviews.d.ts +28 -0
  107. package/dist/editor/StatePreviews.d.ts.map +1 -0
  108. package/dist/editor/StatePreviews.js +113 -0
  109. package/dist/editor/StatePreviews.js.map +1 -0
  110. package/dist/editor/ValueCombo.d.ts +51 -0
  111. package/dist/editor/ValueCombo.d.ts.map +1 -0
  112. package/dist/editor/ValueCombo.js +260 -0
  113. package/dist/editor/ValueCombo.js.map +1 -0
  114. package/dist/editor/agent/AgentPanel.d.ts +19 -0
  115. package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
  116. package/dist/editor/agent/AgentPanel.js +271 -0
  117. package/dist/editor/agent/AgentPanel.js.map +1 -0
  118. package/dist/editor/agent/Markdown.d.ts +5 -0
  119. package/dist/editor/agent/Markdown.d.ts.map +1 -0
  120. package/dist/editor/agent/Markdown.js +28 -0
  121. package/dist/editor/agent/Markdown.js.map +1 -0
  122. package/dist/editor/agent/agentApi.d.ts +106 -0
  123. package/dist/editor/agent/agentApi.d.ts.map +1 -0
  124. package/dist/editor/agent/agentApi.js +66 -0
  125. package/dist/editor/agent/agentApi.js.map +1 -0
  126. package/dist/editor/agent/toolLines.d.ts +38 -0
  127. package/dist/editor/agent/toolLines.d.ts.map +1 -0
  128. package/dist/editor/agent/toolLines.js +159 -0
  129. package/dist/editor/agent/toolLines.js.map +1 -0
  130. package/dist/editor/agent/useAgent.d.ts +15 -0
  131. package/dist/editor/agent/useAgent.d.ts.map +1 -0
  132. package/dist/editor/agent/useAgent.js +65 -0
  133. package/dist/editor/agent/useAgent.js.map +1 -0
  134. package/dist/editor/api.d.ts +378 -0
  135. package/dist/editor/api.d.ts.map +1 -0
  136. package/dist/editor/api.js +247 -0
  137. package/dist/editor/api.js.map +1 -0
  138. package/dist/editor/camera.d.ts +18 -0
  139. package/dist/editor/camera.d.ts.map +1 -0
  140. package/dist/editor/camera.js +40 -0
  141. package/dist/editor/camera.js.map +1 -0
  142. package/dist/editor/canvas.d.ts +25 -0
  143. package/dist/editor/canvas.d.ts.map +1 -0
  144. package/dist/editor/canvas.js +35 -0
  145. package/dist/editor/canvas.js.map +1 -0
  146. package/dist/editor/changes/ChangesPage.d.ts +25 -0
  147. package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
  148. package/dist/editor/changes/ChangesPage.js +132 -0
  149. package/dist/editor/changes/ChangesPage.js.map +1 -0
  150. package/dist/editor/changes/changeModel.d.ts +25 -0
  151. package/dist/editor/changes/changeModel.d.ts.map +1 -0
  152. package/dist/editor/changes/changeModel.js +81 -0
  153. package/dist/editor/changes/changeModel.js.map +1 -0
  154. package/dist/editor/changes/changeState.d.mts +29 -0
  155. package/dist/editor/changes/changeState.mjs +187 -0
  156. package/dist/editor/chrome/EditorChrome.d.ts +49 -0
  157. package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
  158. package/dist/editor/chrome/EditorChrome.js +21 -0
  159. package/dist/editor/chrome/EditorChrome.js.map +1 -0
  160. package/dist/editor/drafts.d.ts +46 -0
  161. package/dist/editor/drafts.d.ts.map +1 -0
  162. package/dist/editor/drafts.js +38 -0
  163. package/dist/editor/drafts.js.map +1 -0
  164. package/dist/editor/i18n.d.ts +29 -0
  165. package/dist/editor/i18n.d.ts.map +1 -0
  166. package/dist/editor/i18n.js +2320 -0
  167. package/dist/editor/i18n.js.map +1 -0
  168. package/dist/editor/iconStroke.d.ts +6 -0
  169. package/dist/editor/iconStroke.d.ts.map +1 -0
  170. package/dist/editor/iconStroke.js +6 -0
  171. package/dist/editor/iconStroke.js.map +1 -0
  172. package/dist/editor/main.d.ts +2 -0
  173. package/dist/editor/main.d.ts.map +1 -0
  174. package/dist/editor/main.js +14 -0
  175. package/dist/editor/main.js.map +1 -0
  176. package/dist/editor/model.d.ts +16 -0
  177. package/dist/editor/model.d.ts.map +1 -0
  178. package/dist/editor/model.js +11 -0
  179. package/dist/editor/model.js.map +1 -0
  180. package/dist/editor/reasons.d.ts +44 -0
  181. package/dist/editor/reasons.d.ts.map +1 -0
  182. package/dist/editor/reasons.js +131 -0
  183. package/dist/editor/reasons.js.map +1 -0
  184. package/dist/editor/reviewLifecycle.d.ts +8 -0
  185. package/dist/editor/reviewLifecycle.d.ts.map +1 -0
  186. package/dist/editor/reviewLifecycle.js +21 -0
  187. package/dist/editor/reviewLifecycle.js.map +1 -0
  188. package/dist/editor/styles.css +8737 -0
  189. package/dist/editor/tokenMatch.d.ts +59 -0
  190. package/dist/editor/tokenMatch.d.ts.map +1 -0
  191. package/dist/editor/tokenMatch.js +198 -0
  192. package/dist/editor/tokenMatch.js.map +1 -0
  193. package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
  194. package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
  195. package/dist/editor/tokens/ConsolidatePage.js +244 -0
  196. package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
  197. package/dist/editor/tokens/TokenActivity.d.ts +18 -0
  198. package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
  199. package/dist/editor/tokens/TokenActivity.js +18 -0
  200. package/dist/editor/tokens/TokenActivity.js.map +1 -0
  201. package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
  202. package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
  203. package/dist/editor/tokens/TokenDialogs.js +119 -0
  204. package/dist/editor/tokens/TokenDialogs.js.map +1 -0
  205. package/dist/editor/tokens/TokenList.d.ts +21 -0
  206. package/dist/editor/tokens/TokenList.d.ts.map +1 -0
  207. package/dist/editor/tokens/TokenList.js +98 -0
  208. package/dist/editor/tokens/TokenList.js.map +1 -0
  209. package/dist/editor/tokens/TokenPage.d.ts +25 -0
  210. package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
  211. package/dist/editor/tokens/TokenPage.js +108 -0
  212. package/dist/editor/tokens/TokenPage.js.map +1 -0
  213. package/dist/editor/tokens/tokenModel.d.ts +35 -0
  214. package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
  215. package/dist/editor/tokens/tokenModel.js +72 -0
  216. package/dist/editor/tokens/tokenModel.js.map +1 -0
  217. package/dist/editor/ui/Button.d.ts +3 -0
  218. package/dist/editor/ui/Button.d.ts.map +1 -0
  219. package/dist/editor/ui/Button.js +6 -0
  220. package/dist/editor/ui/Button.js.map +1 -0
  221. package/dist/editor/ui/CommentBox.d.ts +23 -0
  222. package/dist/editor/ui/CommentBox.d.ts.map +1 -0
  223. package/dist/editor/ui/CommentBox.js +41 -0
  224. package/dist/editor/ui/CommentBox.js.map +1 -0
  225. package/dist/editor/ui/Icon.d.ts +8 -0
  226. package/dist/editor/ui/Icon.d.ts.map +1 -0
  227. package/dist/editor/ui/Icon.js +6 -0
  228. package/dist/editor/ui/Icon.js.map +1 -0
  229. package/dist/editor/ui/IconButton.d.ts +11 -0
  230. package/dist/editor/ui/IconButton.d.ts.map +1 -0
  231. package/dist/editor/ui/IconButton.js +6 -0
  232. package/dist/editor/ui/IconButton.js.map +1 -0
  233. package/dist/editor/ui/NumberInput.d.ts +14 -0
  234. package/dist/editor/ui/NumberInput.d.ts.map +1 -0
  235. package/dist/editor/ui/NumberInput.js +6 -0
  236. package/dist/editor/ui/NumberInput.js.map +1 -0
  237. package/dist/editor/ui/PageLine.d.ts +14 -0
  238. package/dist/editor/ui/PageLine.d.ts.map +1 -0
  239. package/dist/editor/ui/PageLine.js +7 -0
  240. package/dist/editor/ui/PageLine.js.map +1 -0
  241. package/dist/editor/ui/SearchPicker.d.ts +41 -0
  242. package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
  243. package/dist/editor/ui/SearchPicker.js +82 -0
  244. package/dist/editor/ui/SearchPicker.js.map +1 -0
  245. package/dist/editor/ui/Select.d.ts +19 -0
  246. package/dist/editor/ui/Select.d.ts.map +1 -0
  247. package/dist/editor/ui/Select.js +12 -0
  248. package/dist/editor/ui/Select.js.map +1 -0
  249. package/dist/editor/ui/TokenField.d.ts +14 -0
  250. package/dist/editor/ui/TokenField.d.ts.map +1 -0
  251. package/dist/editor/ui/TokenField.js +41 -0
  252. package/dist/editor/ui/TokenField.js.map +1 -0
  253. package/dist/editor/ui/TokenPicker.d.ts +31 -0
  254. package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
  255. package/dist/editor/ui/TokenPicker.js +26 -0
  256. package/dist/editor/ui/TokenPicker.js.map +1 -0
  257. package/dist/editor/useBuildError.d.ts +7 -0
  258. package/dist/editor/useBuildError.d.ts.map +1 -0
  259. package/dist/editor/useBuildError.js +30 -0
  260. package/dist/editor/useBuildError.js.map +1 -0
  261. package/dist/editor/useLatestRequest.d.ts +22 -0
  262. package/dist/editor/useLatestRequest.d.ts.map +1 -0
  263. package/dist/editor/useLatestRequest.js +49 -0
  264. package/dist/editor/useLatestRequest.js.map +1 -0
  265. package/dist/editor-bundle/editor.css +2 -0
  266. package/dist/editor-bundle/editor.js +83 -0
  267. package/dist/editor-ui.d.ts +15 -0
  268. package/dist/editor-ui.d.ts.map +1 -0
  269. package/dist/editor-ui.js +14 -0
  270. package/dist/editor-ui.js.map +1 -0
  271. package/dist/inspector/runtime.d.ts +18 -0
  272. package/dist/inspector/runtime.d.ts.map +1 -0
  273. package/dist/inspector/runtime.js +1280 -0
  274. package/dist/inspector/runtime.js.map +1 -0
  275. package/dist/preview/main.d.ts +3 -0
  276. package/dist/preview/main.d.ts.map +1 -0
  277. package/dist/preview/main.js +320 -0
  278. package/dist/preview/main.js.map +1 -0
  279. package/dist/preview/preview.css +40 -0
  280. package/dist/runtime/index.d.ts +3 -0
  281. package/dist/runtime/index.d.ts.map +1 -0
  282. package/dist/runtime/index.js +2 -0
  283. package/dist/runtime/index.js.map +1 -0
  284. package/dist/shared/buildError.d.mts +27 -0
  285. package/dist/shared/buildError.mjs +141 -0
  286. package/dist/shared/cameraFit.d.mts +16 -0
  287. package/dist/shared/cameraFit.mjs +47 -0
  288. package/dist/shared/canvasLayout.d.mts +13 -0
  289. package/dist/shared/canvasLayout.mjs +171 -0
  290. package/dist/shared/commentShots.d.mts +12 -0
  291. package/dist/shared/commentShots.mjs +53 -0
  292. package/dist/shared/componentExtract.d.mts +43 -0
  293. package/dist/shared/componentExtract.mjs +136 -0
  294. package/dist/shared/componentMeta.d.mts +26 -0
  295. package/dist/shared/componentMeta.mjs +87 -0
  296. package/dist/shared/componentOps.d.mts +70 -0
  297. package/dist/shared/componentOps.mjs +407 -0
  298. package/dist/shared/componentTarget.d.mts +15 -0
  299. package/dist/shared/componentTarget.mjs +58 -0
  300. package/dist/shared/components.d.mts +30 -0
  301. package/dist/shared/components.mjs +106 -0
  302. package/dist/shared/consolidateCategories.d.mts +2 -0
  303. package/dist/shared/consolidateCategories.mjs +6 -0
  304. package/dist/shared/env.d.mts +4 -0
  305. package/dist/shared/env.mjs +18 -0
  306. package/dist/shared/gitChanges.d.mts +2 -0
  307. package/dist/shared/gitChanges.mjs +30 -0
  308. package/dist/shared/legacyPaths.d.mts +1 -0
  309. package/dist/shared/legacyPaths.mjs +9 -0
  310. package/dist/shared/oklab.d.mts +6 -0
  311. package/dist/shared/oklab.mjs +56 -0
  312. package/dist/shared/optimizeEntries.d.mts +5 -0
  313. package/dist/shared/optimizeEntries.mjs +24 -0
  314. package/dist/shared/packages.d.mts +11 -0
  315. package/dist/shared/packages.mjs +96 -0
  316. package/dist/shared/projectFiles.d.mts +23 -0
  317. package/dist/shared/projectFiles.mjs +72 -0
  318. package/dist/shared/prompt.d.mts +25 -0
  319. package/dist/shared/prompt.mjs +217 -0
  320. package/dist/shared/proposals.d.mts +11 -0
  321. package/dist/shared/proposals.mjs +42 -0
  322. package/dist/shared/protocol.d.ts +122 -0
  323. package/dist/shared/protocol.d.ts.map +1 -0
  324. package/dist/shared/protocol.js +7 -0
  325. package/dist/shared/protocol.js.map +1 -0
  326. package/dist/shared/reviewArchive.d.mts +4 -0
  327. package/dist/shared/reviewArchive.mjs +19 -0
  328. package/dist/shared/reviewStore.d.mts +30 -0
  329. package/dist/shared/reviewStore.mjs +218 -0
  330. package/dist/shared/reviewVerify.d.mts +21 -0
  331. package/dist/shared/reviewVerify.mjs +158 -0
  332. package/dist/shared/sizeModes.d.mts +15 -0
  333. package/dist/shared/sizeModes.mjs +53 -0
  334. package/dist/shared/sketches.d.mts +10 -0
  335. package/dist/shared/sketches.mjs +64 -0
  336. package/dist/shared/snapshotCheck.d.mts +13 -0
  337. package/dist/shared/snapshotCheck.mjs +81 -0
  338. package/dist/shared/timeout.d.mts +1 -0
  339. package/dist/shared/timeout.mjs +15 -0
  340. package/dist/shared/tokens.d.ts +2 -0
  341. package/dist/shared/tokens.d.ts.map +1 -0
  342. package/dist/shared/tokens.js +2 -0
  343. package/dist/shared/tokens.js.map +1 -0
  344. package/dist/shared/types.d.ts +689 -0
  345. package/dist/shared/types.d.ts.map +1 -0
  346. package/dist/shared/types.js +13 -0
  347. package/dist/shared/types.js.map +1 -0
  348. package/dist/shared/wheelRouting.d.mts +9 -0
  349. package/dist/shared/wheelRouting.mjs +31 -0
  350. package/dist/shared/writeScope.mjs +96 -0
  351. package/dist/snapshots/diff.d.mts +28 -0
  352. package/dist/snapshots/diff.mjs +263 -0
  353. package/dist/snapshots/index.d.mts +110 -0
  354. package/dist/snapshots/index.mjs +638 -0
  355. package/dist/snapshots/render.d.mts +24 -0
  356. package/dist/snapshots/render.mjs +250 -0
  357. package/dist/snapshots/toolOps.d.mts +25 -0
  358. package/dist/snapshots/toolOps.mjs +69 -0
  359. package/dist/tokens/adapters/css.mjs +51 -0
  360. package/dist/tokens/adapters/cssInCode.mjs +314 -0
  361. package/dist/tokens/adapters/oxcShared.mjs +80 -0
  362. package/dist/tokens/adapters/preprocessor.mjs +63 -0
  363. package/dist/tokens/adapters/registry.mjs +53 -0
  364. package/dist/tokens/adapters/tailwindcss.mjs +424 -0
  365. package/dist/tokens/adapters/types.mjs +117 -0
  366. package/dist/tokens/consolidate/index.d.mts +42 -0
  367. package/dist/tokens/consolidate/index.mjs +111 -0
  368. package/dist/tokens/consolidate/normalize.mjs +479 -0
  369. package/dist/tokens/consolidate/plan.mjs +726 -0
  370. package/dist/tokens/consolidate/scan.mjs +928 -0
  371. package/dist/tokens/extract.mjs +441 -0
  372. package/dist/tokens/moduleData.d.mts +14 -0
  373. package/dist/tokens/moduleData.mjs +32 -0
  374. package/dist/tokens/opLock.d.mts +4 -0
  375. package/dist/tokens/opLock.mjs +108 -0
  376. package/dist/tokens/ops.d.mts +71 -0
  377. package/dist/tokens/ops.mjs +1511 -0
  378. package/dist/tokens/pipeline.mjs +813 -0
  379. package/dist/tokens/report.d.mts +47 -0
  380. package/dist/tokens/report.mjs +257 -0
  381. package/dist/tokens/rewrite/code.mjs +172 -0
  382. package/dist/tokens/rewrite/css.mjs +154 -0
  383. package/dist/tokens/rewrite/index.mjs +244 -0
  384. package/dist/tokens/rewrite/tailwind.mjs +288 -0
  385. package/dist/tokens/rewrite/text.mjs +116 -0
  386. package/dist/tokens/rewrite/value.mjs +115 -0
  387. package/dist/tokens/usage.d.mts +97 -0
  388. package/dist/tokens/usage.mjs +680 -0
  389. package/dist/vite/agent.d.ts +21 -0
  390. package/dist/vite/agent.d.ts.map +1 -0
  391. package/dist/vite/agent.js +165 -0
  392. package/dist/vite/agent.js.map +1 -0
  393. package/dist/vite/events.d.ts +27 -0
  394. package/dist/vite/events.d.ts.map +1 -0
  395. package/dist/vite/events.js +156 -0
  396. package/dist/vite/events.js.map +1 -0
  397. package/dist/vite/layout.d.ts +2 -0
  398. package/dist/vite/layout.d.ts.map +1 -0
  399. package/dist/vite/layout.js +4 -0
  400. package/dist/vite/layout.js.map +1 -0
  401. package/dist/vite/plugin.d.ts +40 -0
  402. package/dist/vite/plugin.d.ts.map +1 -0
  403. package/dist/vite/plugin.js +1264 -0
  404. package/dist/vite/plugin.js.map +1 -0
  405. package/dist/vite/requestGuard.d.mts +3 -0
  406. package/dist/vite/requestGuard.mjs +43 -0
  407. package/dist/vite/review.d.ts +11 -0
  408. package/dist/vite/review.d.ts.map +1 -0
  409. package/dist/vite/review.js +283 -0
  410. package/dist/vite/review.js.map +1 -0
  411. package/package.json +106 -1
  412. package/skills/seji/SKILL.md +400 -0
  413. package/skills/seji-authoring/SKILL.md +397 -0
  414. package/skills/seji-tokens/SKILL.md +432 -0
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useI18n } from './i18n';
4
+ const TIERS = ['semantic', 'component', 'primitive'];
5
+ /** Most common `--<prefix>-` among a tier's tokens, used as the naming hint. */
6
+ const namePrefix = (tokens, tier) => {
7
+ const counts = new Map();
8
+ for (const token of tokens) {
9
+ if (tier && token.tier !== tier)
10
+ continue;
11
+ const prefix = /^--[a-z0-9]+-/i.exec(token.name)?.[0];
12
+ if (prefix)
13
+ counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
14
+ }
15
+ return [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0] ?? '--';
16
+ };
17
+ export function PromoteForm({ value, tokens, defaultTier = null, onSubmit, onCancel, }) {
18
+ const { t } = useI18n();
19
+ const [tier, setTier] = useState(defaultTier);
20
+ const [name, setName] = useState('');
21
+ const [description, setDescription] = useState('');
22
+ const normalized = value.trim().toLowerCase();
23
+ // Non-primitive tokens alias an existing primitive with exactly this value, if any.
24
+ const alias = tier && tier !== 'primitive'
25
+ ? tokens.find((token) => token.tier === 'primitive' && token.value?.trim().toLowerCase() === normalized)?.path
26
+ : undefined;
27
+ const taken = tokens.some((token) => token.name === name);
28
+ const valid = /^--[a-zA-Z0-9_-]+$/.test(name) && !taken && Boolean(tier) && Boolean(description.trim());
29
+ return (_jsxs("span", { className: "token-promote-form", children: [_jsx("code", { children: value }), _jsx("span", { className: "token-promote-tiers", title: t('tokenDialog.tier'), children: TIERS.map((option) => (_jsx("button", { className: tier === option ? 'token-scope is-active' : 'token-scope', type: "button", onClick: () => setTier(option), children: t(`tokens.tier.${option}`) }, option))) }), _jsx("input", { "aria-label": t('tokenDialog.name'), placeholder: `${namePrefix(tokens, tier)}…`, value: name, onChange: (event) => setName(event.target.value.trim()) }), _jsx("input", { "aria-label": t('tokenDialog.description'), placeholder: t('tokens.health.promoteDescription'), value: description, onChange: (event) => setDescription(event.target.value) }), alias ? _jsx("em", { children: t('tokens.alias', { target: alias }) }) : null, taken ? _jsx("em", { children: t('tokens.health.promoteTaken') }) : null, _jsx("button", { className: "token-health-action", disabled: !valid, type: "button", onClick: () => {
30
+ if (!tier)
31
+ return;
32
+ onSubmit({ value, name, tier, description: description.trim(), ...(alias ? { alias } : {}) });
33
+ }, children: t('tokens.health.promote') }), _jsx("button", { type: "button", onClick: onCancel, children: t('tokenDialog.cancel') })] }));
34
+ }
35
+ //# sourceMappingURL=PromoteForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromoteForm.js","sourceRoot":"","sources":["../../src/editor/PromoteForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAWhC,MAAM,KAAK,GAAgB,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;AAEjE,gFAAgF;AAChF,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAE,IAAsB,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;YAAE,SAAQ;QACzC,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACrD,IAAI,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AAC1E,CAAC,CAAA;AAED,MAAM,UAAU,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,WAAW,GAAG,IAAI,EAClB,QAAQ,EACR,QAAQ,GAQT;IACC,MAAM,EAAE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,CAAC,uBAAuB,CAAC,GACpB,EACT,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,QAAQ,YACpC,CAAC,CAAC,oBAAoB,CAAC,GACjB,IACJ,CACR,CAAA;AACH,CAAC","sourcesContent":["import { useState } from 'react'\n\nimport type { TokenDef, TokenTier } from '../shared/tokens'\nimport { useI18n } from './i18n'\n\n/** Promote a hard-coded literal to a named token that replaces it where it is used. */\nexport type TokenPromoteDraft = {\n value: string\n name: string\n tier: TokenTier\n description: string\n alias?: string\n}\n\nconst TIERS: TokenTier[] = ['semantic', 'component', 'primitive']\n\n/** Most common `--<prefix>-` among a tier's tokens, used as the naming hint. */\nconst namePrefix = (tokens: TokenDef[], tier: TokenTier | null) => {\n const counts = new Map<string, number>()\n for (const token of tokens) {\n if (tier && token.tier !== tier) continue\n const prefix = /^--[a-z0-9]+-/i.exec(token.name)?.[0]\n if (prefix) counts.set(prefix, (counts.get(prefix) ?? 0) + 1)\n }\n return [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0] ?? '--'\n}\n\nexport function PromoteForm({\n value,\n tokens,\n defaultTier = null,\n onSubmit,\n onCancel,\n}: {\n value: string\n tokens: TokenDef[]\n /** Preselected tier (component pages promote to component tokens). */\n defaultTier?: TokenTier | null\n onSubmit: (draft: TokenPromoteDraft) => void\n onCancel: () => void\n}) {\n const { t } = useI18n()\n const [tier, setTier] = useState<TokenTier | null>(defaultTier)\n const [name, setName] = useState('')\n const [description, setDescription] = useState('')\n const normalized = value.trim().toLowerCase()\n // Non-primitive tokens alias an existing primitive with exactly this value, if any.\n const alias =\n tier && tier !== 'primitive'\n ? tokens.find(\n (token) => token.tier === 'primitive' && token.value?.trim().toLowerCase() === normalized,\n )?.path\n : undefined\n const taken = tokens.some((token) => token.name === name)\n const valid = /^--[a-zA-Z0-9_-]+$/.test(name) && !taken && Boolean(tier) && Boolean(description.trim())\n\n return (\n <span className=\"token-promote-form\">\n <code>{value}</code>\n <span className=\"token-promote-tiers\" title={t('tokenDialog.tier')}>\n {TIERS.map((option) => (\n <button\n className={tier === option ? 'token-scope is-active' : 'token-scope'}\n key={option}\n type=\"button\"\n onClick={() => setTier(option)}\n >\n {t(`tokens.tier.${option}`)}\n </button>\n ))}\n </span>\n <input\n aria-label={t('tokenDialog.name')}\n placeholder={`${namePrefix(tokens, tier)}…`}\n value={name}\n onChange={(event) => setName(event.target.value.trim())}\n />\n <input\n aria-label={t('tokenDialog.description')}\n placeholder={t('tokens.health.promoteDescription')}\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n />\n {alias ? <em>{t('tokens.alias', { target: alias })}</em> : null}\n {taken ? <em>{t('tokens.health.promoteTaken')}</em> : null}\n <button\n className=\"token-health-action\"\n disabled={!valid}\n type=\"button\"\n onClick={() => {\n if (!tier) return\n onSubmit({ value, name, tier, description: description.trim(), ...(alias ? { alias } : {}) })\n }}\n >\n {t('tokens.health.promote')}\n </button>\n <button type=\"button\" onClick={onCancel}>\n {t('tokenDialog.cancel')}\n </button>\n </span>\n )\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { type TokenKind } from './tokenMatch';
2
+ import type { TokenDef, TokenTier } from '../shared/tokens';
3
+ import type { NodeRef } from '../shared/types';
4
+ /** The literal a designer wants to turn into a token. */
5
+ export type PromoteTarget = {
6
+ label: string;
7
+ frame: string;
8
+ node: NodeRef;
9
+ property: string;
10
+ value: string;
11
+ kind: TokenKind;
12
+ };
13
+ export type PromoteDraft = {
14
+ name: string;
15
+ path: string;
16
+ tier: TokenTier;
17
+ alias?: string;
18
+ description: string;
19
+ value: string;
20
+ type: TokenDef['type'];
21
+ };
22
+ type Props = {
23
+ open: boolean;
24
+ target: PromoteTarget | null;
25
+ tokens: TokenDef[];
26
+ onOpenChange: (open: boolean) => void;
27
+ onCreate: (target: PromoteTarget, draft: PromoteDraft) => void;
28
+ };
29
+ export declare function PromoteToken({ open, target, tokens, onOpenChange, onCreate }: Props): import("react").JSX.Element | null;
30
+ export {};
31
+ //# source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0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from 'react';
3
+ import { Dialog } from '@base-ui/react/dialog';
4
+ import { useI18n } from './i18n';
5
+ import { tokenPath, tokensOfKind } from './tokenMatch';
6
+ import { Button } from './ui/Button';
7
+ const TIERS = ['primitive', 'semantic', 'component'];
8
+ const KIND_PREFIX = {
9
+ color: 'color',
10
+ space: 'space',
11
+ radius: 'radius',
12
+ 'font-size': 'font-size',
13
+ 'border-width': 'border-width',
14
+ };
15
+ const slug = (value) => value
16
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
17
+ .toLowerCase()
18
+ .replace(/[^a-z0-9]+/g, '-')
19
+ .replace(/^-|-$/g, '');
20
+ const cssName = (path) => `--${path.replace(/\./g, '-')}`;
21
+ // Follow the project's own naming: reuse the most common path prefix among
22
+ // existing tokens of the same kind and tier.
23
+ const suggestPath = (target, tier, tokens) => {
24
+ const peers = tokensOfKind(tokens, target.kind).filter((token) => token.tier === tier);
25
+ const counts = new Map();
26
+ for (const token of peers) {
27
+ const parts = tokenPath(token).split('.');
28
+ const prefix = parts.slice(0, Math.max(1, parts.length - 1)).join('.');
29
+ counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
30
+ }
31
+ const prefix = [...counts].sort((a, b) => b[1] - a[1])[0]?.[0] ?? KIND_PREFIX[target.kind] ?? slug(target.property);
32
+ const base = slug(target.node.component ?? target.node.name ?? target.property) || 'token';
33
+ const taken = new Set(tokens.map((token) => tokenPath(token)));
34
+ let path = `${prefix}.${base}`;
35
+ for (let index = 2; taken.has(path); index += 1)
36
+ path = `${prefix}.${base}-${index}`;
37
+ return path;
38
+ };
39
+ export function PromoteToken({ open, target, tokens, onOpenChange, onCreate }) {
40
+ const { t } = useI18n();
41
+ const [tier, setTier] = useState(null);
42
+ const [path, setPath] = useState('');
43
+ const [alias, setAlias] = useState('');
44
+ const [description, setDescription] = useState('');
45
+ const [value, setValue] = useState('');
46
+ useEffect(() => {
47
+ if (!open || !target)
48
+ return;
49
+ setTier(null);
50
+ setPath('');
51
+ setAlias('');
52
+ setDescription('');
53
+ setValue(target.value);
54
+ }, [open, target]);
55
+ const aliasCandidates = useMemo(() => {
56
+ if (!target || !tier || tier === 'primitive')
57
+ return [];
58
+ const wanted = tier === 'semantic' ? 'primitive' : 'semantic';
59
+ return tokensOfKind(tokens, target.kind).filter((token) => token.tier === wanted);
60
+ }, [target, tier, tokens]);
61
+ if (!target)
62
+ return null;
63
+ const chooseTier = (next) => {
64
+ setTier(next);
65
+ setAlias('');
66
+ setPath(suggestPath(target, next, tokens));
67
+ };
68
+ const taken = tokens.some((token) => tokenPath(token) === path);
69
+ const needsAlias = tier !== null && tier !== 'primitive' && aliasCandidates.length > 0;
70
+ const ready = tier !== null &&
71
+ /^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(path) &&
72
+ !taken &&
73
+ Boolean(description.trim()) &&
74
+ (needsAlias ? Boolean(alias) : Boolean(value.trim()));
75
+ return (_jsx(Dialog.Root, { open: open, onOpenChange: onOpenChange, children: _jsxs(Dialog.Portal, { children: [_jsx(Dialog.Backdrop, { className: "token-dialog-backdrop" }), _jsxs(Dialog.Popup, { className: "token-dialog promote-dialog", children: [_jsx("div", { className: "token-dialog-head", children: _jsxs("div", { children: [_jsxs("p", { className: "token-dialog-kicker", children: [target.label, " \u00B7 ", _jsx("code", { children: target.value })] }), _jsx("h2", { children: t('promote.title') })] }) }), _jsxs("div", { className: "token-dialog-form", children: [_jsx("label", { children: t('promote.tier') }), _jsx("span", { className: "ins-seg is-text", role: "group", "aria-label": t('promote.tier'), children: TIERS.map((item) => (_jsx("button", { "aria-pressed": tier === item, className: tier === item ? 'is-on' : '', type: "button", onClick: () => chooseTier(item), children: t(`tokens.tier.${item}`) }, item))) }), _jsx("p", { className: "token-dialog-note", children: t(tier ? `promote.tierHint.${tier}` : 'promote.tierPick') }), tier ? (_jsxs(_Fragment, { children: [_jsx("label", { children: t('promote.name') }), _jsx("input", { value: path, onChange: (event) => setPath(event.target.value.trim()) }), _jsx("p", { className: "token-dialog-note", children: taken ? t('promote.taken') : _jsx("code", { children: cssName(path) }) }), needsAlias ? (_jsxs(_Fragment, { children: [_jsx("label", { children: t('promote.alias') }), _jsxs("select", { value: alias, onChange: (event) => {
76
+ setAlias(event.target.value);
77
+ const chosen = aliasCandidates.find((token) => tokenPath(token) === event.target.value);
78
+ if (chosen?.value)
79
+ setValue(chosen.value);
80
+ }, children: [_jsx("option", { value: "", children: t('promote.pickAlias') }), aliasCandidates.map((token) => (_jsxs("option", { value: tokenPath(token), children: [tokenPath(token), " \u00B7 ", token.value] }, token.name)))] })] })) : (_jsxs(_Fragment, { children: [_jsx("label", { children: t('promote.value') }), _jsx("input", { value: value, onChange: (event) => setValue(event.target.value) })] })), _jsx("label", { children: t('promote.description') }), _jsx("input", { placeholder: t('promote.descriptionHint'), value: description, onChange: (event) => setDescription(event.target.value) })] })) : null, _jsxs("div", { className: "token-dialog-actions", children: [_jsx(Button, { className: "primary-button", disabled: !ready, type: "button", onClick: () => {
81
+ if (!tier)
82
+ return;
83
+ onCreate(target, {
84
+ name: cssName(path),
85
+ path,
86
+ tier,
87
+ ...(needsAlias && alias ? { alias } : {}),
88
+ description: description.trim(),
89
+ value: value.trim() || target.value,
90
+ type: target.kind === 'color' ? 'color' : target.kind === 'shadow' || target.kind === 'other' ? 'text' : 'length',
91
+ });
92
+ }, children: t('promote.create') }), _jsx(Button, { className: "button", type: "button", onClick: () => onOpenChange(false), children: t('common.cancel') })] })] })] })] }) }));
93
+ }
94
+ //# sourceMappingURL=PromoteToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromoteToken.js","sourceRoot":"","sources":["../../src/editor/PromoteToken.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEpD,OAAO,EAAE,MAAM,EAAE,MA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;gDACjB,QAAQ,CAAC,MAAM,EAAE;oDACf,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;oDACnB,IAAI;oDACJ,IAAI;oDACJ,GAAG,CAAC,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oDACzC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE;oDAC/B,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,KAAK;oDACnC,IAAI,EAAE,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;iDAClH,CAAC,CAAA;4CACJ,CAAC,YAEA,CAAC,CAAC,gBAAgB,CAAC,GACb,EACT,KAAC,MAAM,IAAC,SAAS,EAAC,QAAQ,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,YAAG,CAAC,CAAC,eAAe,CAAC,GAAU,IACtG,IACF,IACO,IACD,GACJ,CACf,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useMemo, useState } from 'react'\n\nimport { Dialog } from '@base-ui/react/dialog'\n\nimport { useI18n } from './i18n'\nimport { tokenPath, tokensOfKind, type TokenKind } from './tokenMatch'\nimport { Button } from './ui/Button'\nimport type { TokenDef, TokenTier } from '../shared/tokens'\nimport type { NodeRef } from '../shared/types'\n\n/** The literal a designer wants to turn into a token. */\nexport type PromoteTarget = {\n label: string\n frame: string\n node: NodeRef\n property: string\n value: string\n kind: TokenKind\n}\n\nexport type PromoteDraft = {\n name: string\n path: string\n tier: TokenTier\n alias?: string\n description: string\n value: string\n type: TokenDef['type']\n}\n\ntype Props = {\n open: boolean\n target: PromoteTarget | null\n tokens: TokenDef[]\n onOpenChange: (open: boolean) => void\n onCreate: (target: PromoteTarget, draft: PromoteDraft) => void\n}\n\nconst TIERS: TokenTier[] = ['primitive', 'semantic', 'component']\n\nconst KIND_PREFIX: Partial<Record<TokenKind, string>> = {\n color: 'color',\n space: 'space',\n radius: 'radius',\n 'font-size': 'font-size',\n 'border-width': 'border-width',\n}\n\nconst slug = (value: string) =>\n value\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '')\n\nconst cssName = (path: string) => `--${path.replace(/\\./g, '-')}`\n\n// Follow the project's own naming: reuse the most common path prefix among\n// existing tokens of the same kind and tier.\nconst suggestPath = (target: PromoteTarget, tier: TokenTier, tokens: TokenDef[]) => {\n const peers = tokensOfKind(tokens, target.kind).filter((token) => token.tier === tier)\n const counts = new Map<string, number>()\n for (const token of peers) {\n const parts = tokenPath(token).split('.')\n const prefix = parts.slice(0, Math.max(1, parts.length - 1)).join('.')\n counts.set(prefix, (counts.get(prefix) ?? 0) + 1)\n }\n const prefix =\n [...counts].sort((a, b) => b[1] - a[1])[0]?.[0] ?? KIND_PREFIX[target.kind] ?? slug(target.property)\n const base = slug(target.node.component ?? target.node.name ?? target.property) || 'token'\n const taken = new Set(tokens.map((token) => tokenPath(token)))\n let path = `${prefix}.${base}`\n for (let index = 2; taken.has(path); index += 1) path = `${prefix}.${base}-${index}`\n return path\n}\n\nexport function PromoteToken({ open, target, tokens, onOpenChange, onCreate }: Props) {\n const { t } = useI18n()\n const [tier, setTier] = useState<TokenTier | null>(null)\n const [path, setPath] = useState('')\n const [alias, setAlias] = useState('')\n const [description, setDescription] = useState('')\n const [value, setValue] = useState('')\n\n useEffect(() => {\n if (!open || !target) return\n setTier(null)\n setPath('')\n setAlias('')\n setDescription('')\n setValue(target.value)\n }, [open, target])\n\n const aliasCandidates = useMemo(() => {\n if (!target || !tier || tier === 'primitive') return []\n const wanted: TokenTier = tier === 'semantic' ? 'primitive' : 'semantic'\n return tokensOfKind(tokens, target.kind).filter((token) => token.tier === wanted)\n }, [target, tier, tokens])\n\n if (!target) return null\n\n const chooseTier = (next: TokenTier) => {\n setTier(next)\n setAlias('')\n setPath(suggestPath(target, next, tokens))\n }\n const taken = tokens.some((token) => tokenPath(token) === path)\n const needsAlias = tier !== null && tier !== 'primitive' && aliasCandidates.length > 0\n const ready =\n tier !== null &&\n /^[a-z0-9-]+(\\.[a-z0-9-]+)+$/.test(path) &&\n !taken &&\n Boolean(description.trim()) &&\n (needsAlias ? Boolean(alias) : Boolean(value.trim()))\n\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <Dialog.Portal>\n <Dialog.Backdrop className=\"token-dialog-backdrop\" />\n <Dialog.Popup className=\"token-dialog promote-dialog\">\n <div className=\"token-dialog-head\">\n <div>\n <p className=\"token-dialog-kicker\">{target.label} · <code>{target.value}</code></p>\n <h2>{t('promote.title')}</h2>\n </div>\n </div>\n <div className=\"token-dialog-form\">\n <label>{t('promote.tier')}</label>\n <span className=\"ins-seg is-text\" role=\"group\" aria-label={t('promote.tier')}>\n {TIERS.map((item) => (\n <button\n aria-pressed={tier === item}\n className={tier === item ? 'is-on' : ''}\n key={item}\n type=\"button\"\n onClick={() => chooseTier(item)}\n >\n {t(`tokens.tier.${item}`)}\n </button>\n ))}\n </span>\n <p className=\"token-dialog-note\">{t(tier ? `promote.tierHint.${tier}` : 'promote.tierPick')}</p>\n {tier ? (\n <>\n <label>{t('promote.name')}</label>\n <input value={path} onChange={(event) => setPath(event.target.value.trim())} />\n <p className=\"token-dialog-note\">\n {taken ? t('promote.taken') : <code>{cssName(path)}</code>}\n </p>\n {needsAlias ? (\n <>\n <label>{t('promote.alias')}</label>\n <select\n value={alias}\n onChange={(event) => {\n setAlias(event.target.value)\n const chosen = aliasCandidates.find((token) => tokenPath(token) === event.target.value)\n if (chosen?.value) setValue(chosen.value)\n }}\n >\n <option value=\"\">{t('promote.pickAlias')}</option>\n {aliasCandidates.map((token) => (\n <option key={token.name} value={tokenPath(token)}>\n {tokenPath(token)} · {token.value}\n </option>\n ))}\n </select>\n </>\n ) : (\n <>\n <label>{t('promote.value')}</label>\n <input value={value} onChange={(event) => setValue(event.target.value)} />\n </>\n )}\n <label>{t('promote.description')}</label>\n <input\n placeholder={t('promote.descriptionHint')}\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n />\n </>\n ) : null}\n <div className=\"token-dialog-actions\">\n <Button\n className=\"primary-button\"\n disabled={!ready}\n type=\"button\"\n onClick={() => {\n if (!tier) return\n onCreate(target, {\n name: cssName(path),\n path,\n tier,\n ...(needsAlias && alias ? { alias } : {}),\n description: description.trim(),\n value: value.trim() || target.value,\n type: target.kind === 'color' ? 'color' : target.kind === 'shadow' || target.kind === 'other' ? 'text' : 'length',\n })\n }}\n >\n {t('promote.create')}\n </Button>\n <Button className=\"button\" type=\"button\" onClick={() => onOpenChange(false)}>{t('common.cancel')}</Button>\n </div>\n </div>\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n )\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { DraftState } from './drafts';
2
+ import type { InspectorNode } from '../shared/types';
3
+ /** A style the thumbnails must show: saved-but-unapplied changes plus drafts. */
4
+ export type ThumbStyle = {
5
+ anchor: string | null;
6
+ path: string;
7
+ property: string;
8
+ value: string;
9
+ state?: Exclude<DraftState, 'default'>;
10
+ };
11
+ type Props = {
12
+ src: string;
13
+ size: [number, number];
14
+ node: InspectorNode;
15
+ editing: DraftState;
16
+ styles: ThumbStyle[];
17
+ onPick: (state: DraftState) => void;
18
+ };
19
+ /** The five states the selected element is drawn in. */
20
+ export declare const ALL_STATES: DraftState[];
21
+ /**
22
+ * Small live previews of the selected element in each pseudo state. Each one is
23
+ * its own preview iframe with the state forced, so clicking one switches the
24
+ * inspector to editing that state's styles.
25
+ */
26
+ export declare function StatePreviews({ src, size, node, editing, styles, onPick }: Props): import("react").JSX.Element;
27
+ export {};
28
+ //# sourceMappingURL=StatePreviews.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatePreviews.d.ts","sourceRoot":"","sources":["../../src/editor/StatePreviews.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAQ,MAAM,iBAAiB,CAAA;AAE1D,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;CACvC,CAAA;AAED,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtB,IAAI,EAAE,aAAa,CAAA;IACnB,OAAO,EAAE,UAAU,CAAA;IACnB,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACpC,CAAA;AAOD,wDAAwD;AACxD,eAAO,MAAM,UAAU,EAAE,UAAU,EAAwD,CAAA;AAU3F;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,+BAgChF"}
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { useI18n } from './i18n';
4
+ const THUMB_MAX = 134;
5
+ const THUMB_MIN = 96;
6
+ const THUMB_GAP = 8;
7
+ const PADDING = 10;
8
+ /** The five states the selected element is drawn in. */
9
+ export const ALL_STATES = ['default', 'hover', 'active', 'focus', 'disabled'];
10
+ const thumbWidthFor = (frameWidth) => Math.round(Math.max(THUMB_MIN, Math.min(THUMB_MAX, (frameWidth - THUMB_GAP * 4) / ALL_STATES.length)));
11
+ const styleKey = (style) => `${style.path}|${style.state ?? ''}|${style.property}`;
12
+ /**
13
+ * Small live previews of the selected element in each pseudo state. Each one is
14
+ * its own preview iframe with the state forced, so clicking one switches the
15
+ * inspector to editing that state's styles.
16
+ */
17
+ export function StatePreviews({ src, size, node, editing, styles, onPick }) {
18
+ const { t } = useI18n();
19
+ // All five states are always drawn; one without its own rules says so.
20
+ const own = new Set(['default', ...(node.states ?? [])]);
21
+ // Always five across; under a narrow artboard the strip is wider than it and the
22
+ // slot grows, pushing the neighbouring artboards aside.
23
+ const thumbWidth = thumbWidthFor(size[0]);
24
+ const target = { node };
25
+ return (_jsxs("div", { className: "board-states", "data-canvas-drag": true, children: [_jsxs("div", { className: "board-states-head", children: [_jsx("b", { children: t('states.title') }), _jsx("span", { children: t('states.hint') })] }), _jsx("div", { className: "board-states-row", children: ALL_STATES.map((state) => (_jsx(StateThumb, { width: thumbWidth, editing: editing === state, plain: !own.has(state), target: target, size: size, src: src, state: state, styles: styles, onPick: () => onPick(state) }, state))) })] }));
26
+ }
27
+ function StateThumb({ src, size, target, state, editing, plain, width, styles, onPick, }) {
28
+ const { t } = useI18n();
29
+ const frame = useRef(null);
30
+ const applied = useRef(new Map());
31
+ const [ready, setReady] = useState(0);
32
+ // Where a component target is in the frame: the runtime answers `design:target` whenever
33
+ // the element it is bound to changes or moves (a source update remounts it). Kept with the
34
+ // component it answers for, so a renamed component never uses the old name's rect.
35
+ const [answer, setAnswer] = useState(null);
36
+ const node = 'node' in target ? target.node : null;
37
+ const component = 'component' in target ? target.component : null;
38
+ const aliases = 'component' in target ? target.aliases : null;
39
+ useEffect(() => {
40
+ const onMessage = (event) => {
41
+ if (event.source !== frame.current?.contentWindow)
42
+ return;
43
+ const data = event.data;
44
+ if (data?.type === 'design:hello') {
45
+ applied.current = new Map();
46
+ setReady((count) => count + 1);
47
+ }
48
+ else if (data?.type === 'design:target' && data.rect && data.component === component) {
49
+ setAnswer({ component: data.component, rect: data.rect });
50
+ }
51
+ };
52
+ window.addEventListener('message', onMessage);
53
+ return () => window.removeEventListener('message', onMessage);
54
+ }, [component]);
55
+ const signature = JSON.stringify(styles);
56
+ useEffect(() => {
57
+ const target = frame.current?.contentWindow;
58
+ if (!ready || !target)
59
+ return;
60
+ const send = (command) => target.postMessage({ type: 'design:command', ...command }, '*');
61
+ const next = new Map(styles.map((style) => [styleKey(style), style]));
62
+ for (const [key, style] of applied.current) {
63
+ if (next.has(key))
64
+ continue;
65
+ send({
66
+ action: 'reset-style',
67
+ anchor: style.anchor,
68
+ path: style.path,
69
+ property: style.property,
70
+ ...(style.state ? { state: style.state } : {}),
71
+ });
72
+ }
73
+ for (const style of next.values()) {
74
+ send({
75
+ action: 'set-style',
76
+ anchor: style.anchor,
77
+ path: style.path,
78
+ property: style.property,
79
+ value: style.value,
80
+ ...(style.state ? { state: style.state } : {}),
81
+ });
82
+ }
83
+ applied.current = next;
84
+ if (component) {
85
+ send({ action: 'force-state', component, aliases: aliases ?? [], state: state === 'default' ? null : state });
86
+ return;
87
+ }
88
+ if (!node)
89
+ return;
90
+ send({ action: 'isolate', anchor: node.ownAnchor ?? node.anchor, path: node.path });
91
+ send({
92
+ action: 'force-state',
93
+ anchor: node.ownAnchor ?? node.anchor,
94
+ path: node.path,
95
+ state: state === 'default' ? null : state,
96
+ });
97
+ // `signature` stands in for `styles`, whose identity changes every render.
98
+ }, [aliases, component, node?.anchor, node?.ownAnchor, node?.path, ready, signature, state]);
99
+ // Only the element is drawn (the runtime hides the rest), centred and scaled to fit.
100
+ const height = Math.round(width * 0.68);
101
+ const targetRect = component && answer?.component === component ? answer.rect : null;
102
+ const rect = (component ? targetRect : node?.rect) ?? { x: 0, y: 0, width: size[0], height: size[1] };
103
+ const scale = Math.min(2, width / (rect.width + PADDING * 2), height / (rect.height + PADDING * 2));
104
+ const left = (width - rect.width * scale) / 2 - rect.x * scale;
105
+ const top = (height - rect.height * scale) / 2 - rect.y * scale;
106
+ const label = t(`states.${state}`);
107
+ return (_jsxs("button", { "aria-pressed": editing, className: ['board-state', editing ? 'is-editing' : '', plain ? 'is-plain' : ''].filter(Boolean).join(' '), title: t('states.pick', { state: label }), type: "button", onClick: onPick, onPointerDown: (event) => event.stopPropagation(), children: [_jsx("span", { className: "board-state-view", style: { width, height }, children: _jsx("iframe", { "aria-hidden": "true", ref: frame, src: src, style: {
108
+ width: size[0],
109
+ height: size[1],
110
+ transform: `translate(${left}px, ${top}px) scale(${scale})`,
111
+ }, tabIndex: -1, title: label }) }), _jsxs("span", { className: "board-state-label", style: { maxWidth: width }, children: [label, editing ? _jsxs("em", { children: [" \u00B7 ", t('states.editing')] }) : plain ? _jsxs("em", { className: "is-plain", children: [" \u00B7 ", t('states.plain')] }) : null] })] }));
112
+ }
113
+ //# sourceMappingURL=StatePreviews.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatePreviews.js","sourceRoot":"","sources":["../../src/editor/StatePreviews.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAuBhC,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,MAAM,OAAO,GAAG,EAAE,CAAA;AAElB,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;AAE3F,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,EAAE,CAC3C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI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AgB,CAAC,IAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAI,SAAS,EAAC,UAAU,yBAAK,CAAC,CAAC,cAAc,CAAC,IAAM,CAAC,CAAC,CAAC,IAAI,IAC7G,IACA,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useRef, useState } from 'react'\n\nimport { useI18n } from './i18n'\nimport type { DraftState } from './drafts'\nimport type { PreviewCommand } from '../shared/protocol'\nimport type { InspectorNode, Rect } from '../shared/types'\n\n/** A style the thumbnails must show: saved-but-unapplied changes plus drafts. */\nexport type ThumbStyle = {\n anchor: string | null\n path: string\n property: string\n value: string\n state?: Exclude<DraftState, 'default'>\n}\n\ntype Props = {\n src: string\n size: [number, number]\n node: InspectorNode\n editing: DraftState\n styles: ThumbStyle[]\n onPick: (state: DraftState) => void\n}\n\nconst THUMB_MAX = 134\nconst THUMB_MIN = 96\nconst THUMB_GAP = 8\nconst PADDING = 10\n\n/** The five states the selected element is drawn in. */\nexport const ALL_STATES: DraftState[] = ['default', 'hover', 'active', 'focus', 'disabled']\n\nconst thumbWidthFor = (frameWidth: number) =>\n Math.round(Math.max(THUMB_MIN, Math.min(THUMB_MAX, (frameWidth - THUMB_GAP * 4) / ALL_STATES.length)))\n\n/** What a thumbnail shows: the selected node, or the root element a component renders. */\ntype ThumbTarget = { node: InspectorNode } | { component: string; aliases: string[] }\n\nconst styleKey = (style: ThumbStyle) => `${style.path}|${style.state ?? ''}|${style.property}`\n\n/**\n * Small live previews of the selected element in each pseudo state. Each one is\n * its own preview iframe with the state forced, so clicking one switches the\n * inspector to editing that state's styles.\n */\nexport function StatePreviews({ src, size, node, editing, styles, onPick }: Props) {\n const { t } = useI18n()\n // All five states are always drawn; one without its own rules says so.\n const own = new Set<DraftState>(['default', ...(node.states ?? [])])\n // Always five across; under a narrow artboard the strip is wider than it and the\n // slot grows, pushing the neighbouring artboards aside.\n const thumbWidth = thumbWidthFor(size[0])\n const target = { node }\n return (\n <div className=\"board-states\" data-canvas-drag>\n <div className=\"board-states-head\">\n <b>{t('states.title')}</b>\n <span>{t('states.hint')}</span>\n </div>\n <div className=\"board-states-row\">\n {ALL_STATES.map((state) => (\n <StateThumb\n width={thumbWidth}\n editing={editing === state}\n plain={!own.has(state)}\n key={state}\n target={target}\n size={size}\n src={src}\n state={state}\n styles={styles}\n onPick={() => onPick(state)}\n />\n ))}\n </div>\n </div>\n )\n}\n\nfunction StateThumb({\n src,\n size,\n target,\n state,\n editing,\n plain,\n width,\n styles,\n onPick,\n}: {\n plain: boolean\n width: number\n src: string\n size: [number, number]\n target: ThumbTarget\n state: DraftState\n editing: boolean\n styles: ThumbStyle[]\n onPick: () => void\n}) {\n const { t } = useI18n()\n const frame = useRef<HTMLIFrameElement | null>(null)\n const applied = useRef(new Map<string, ThumbStyle>())\n const [ready, setReady] = useState(0)\n // Where a component target is in the frame: the runtime answers `design:target` whenever\n // the element it is bound to changes or moves (a source update remounts it). Kept with the\n // component it answers for, so a renamed component never uses the old name's rect.\n const [answer, setAnswer] = useState<{ component: string; rect: Rect } | null>(null)\n const node = 'node' in target ? target.node : null\n const component = 'component' in target ? target.component : null\n const aliases = 'component' in target ? target.aliases : null\n\n useEffect(() => {\n const onMessage = (event: MessageEvent) => {\n if (event.source !== frame.current?.contentWindow) return\n const data = event.data as { type?: string; rect?: Rect; component?: string } | null\n if (data?.type === 'design:hello') {\n applied.current = new Map()\n setReady((count) => count + 1)\n } else if (data?.type === 'design:target' && data.rect && data.component === component) {\n setAnswer({ component: data.component, rect: data.rect })\n }\n }\n window.addEventListener('message', onMessage)\n return () => window.removeEventListener('message', onMessage)\n }, [component])\n\n const signature = JSON.stringify(styles)\n useEffect(() => {\n const target = frame.current?.contentWindow\n if (!ready || !target) return\n const send = (command: PreviewCommand) =>\n target.postMessage({ type: 'design:command', ...command }, '*')\n const next = new Map(styles.map((style) => [styleKey(style), style]))\n for (const [key, style] of applied.current) {\n if (next.has(key)) continue\n send({\n action: 'reset-style',\n anchor: style.anchor,\n path: style.path,\n property: style.property,\n ...(style.state ? { state: style.state } : {}),\n })\n }\n for (const style of next.values()) {\n send({\n action: 'set-style',\n anchor: style.anchor,\n path: style.path,\n property: style.property,\n value: style.value,\n ...(style.state ? { state: style.state } : {}),\n })\n }\n applied.current = next\n if (component) {\n send({ action: 'force-state', component, aliases: aliases ?? [], state: state === 'default' ? null : state })\n return\n }\n if (!node) return\n send({ action: 'isolate', anchor: node.ownAnchor ?? node.anchor, path: node.path })\n send({\n action: 'force-state',\n anchor: node.ownAnchor ?? node.anchor,\n path: node.path,\n state: state === 'default' ? null : state,\n })\n // `signature` stands in for `styles`, whose identity changes every render.\n }, [aliases, component, node?.anchor, node?.ownAnchor, node?.path, ready, signature, state])\n\n // Only the element is drawn (the runtime hides the rest), centred and scaled to fit.\n const height = Math.round(width * 0.68)\n const targetRect = component && answer?.component === component ? answer.rect : null\n const rect = (component ? targetRect : node?.rect) ?? { x: 0, y: 0, width: size[0], height: size[1] }\n const scale = Math.min(\n 2,\n width / (rect.width + PADDING * 2),\n height / (rect.height + PADDING * 2),\n )\n const left = (width - rect.width * scale) / 2 - rect.x * scale\n const top = (height - rect.height * scale) / 2 - rect.y * scale\n const label = t(`states.${state}`)\n\n return (\n <button\n aria-pressed={editing}\n className={['board-state', editing ? 'is-editing' : '', plain ? 'is-plain' : ''].filter(Boolean).join(' ')}\n title={t('states.pick', { state: label })}\n type=\"button\"\n onClick={onPick}\n onPointerDown={(event) => event.stopPropagation()}\n >\n <span className=\"board-state-view\" style={{ width, height }}>\n <iframe\n aria-hidden=\"true\"\n ref={frame}\n src={src}\n style={{\n width: size[0],\n height: size[1],\n transform: `translate(${left}px, ${top}px) scale(${scale})`,\n }}\n tabIndex={-1}\n title={label}\n />\n </span>\n <span className=\"board-state-label\" style={{ maxWidth: width }}>\n {label}\n {editing ? <em> · {t('states.editing')}</em> : plain ? <em className=\"is-plain\"> · {t('states.plain')}</em> : null}\n </span>\n </button>\n )\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { TokenDef } from '../shared/tokens';
3
+ import { type TokenKind } from './tokenMatch';
4
+ export type ComboCommit = {
5
+ value: string;
6
+ token: TokenDef | null;
7
+ };
8
+ type Props = {
9
+ label: string;
10
+ kind: TokenKind;
11
+ /** Resolved CSS value currently on the element. */
12
+ value: string;
13
+ token: TokenDef | null;
14
+ /** Same-kind tokens the field may bind to. */
15
+ tokens: TokenDef[];
16
+ resolve: (token: TokenDef) => string;
17
+ nearest?: TokenDef | null;
18
+ mixed?: boolean;
19
+ numeric?: boolean;
20
+ unit?: string;
21
+ /** Convert between the displayed number and the CSS value (defaults to px). */
22
+ toNumber?: (value: string) => number | null;
23
+ toCss?: (number: number) => string;
24
+ min?: number;
25
+ /** Read-only: shows the computed value greyed out (e.g. width while hugging). */
26
+ disabled?: boolean;
27
+ warn?: 'cross' | 'deprecated' | null;
28
+ isPrimitive?: (token: TokenDef) => boolean;
29
+ onPreview: (value: string | null) => void;
30
+ onCommit: (next: ComboCommit) => void;
31
+ };
32
+ /**
33
+ * Value field for one style property. A bound token is a single inline chip;
34
+ * typing filters same-kind tokens (hover previews on the canvas), numbers and
35
+ * expressions such as `10*2` commit a custom value, ↑/↓ step by 1 (Shift 10),
36
+ * and Backspace right after the chip unbinds it back to its value.
37
+ */
38
+ export declare function ValueCombo({ label, kind, value, token, tokens, resolve, nearest, mixed, numeric, unit, toNumber, toCss, min, disabled, warn, isPrimitive, onPreview, onCommit, }: Props): import("react").JSX.Element;
39
+ /** Field icon that scrubs a numeric value: drag left/right, live preview, commit on release. */
40
+ export declare function ScrubLabel({ children, title, value, toNumber, toCss, min, onPreview, onCommit, }: {
41
+ children: ReactNode;
42
+ title: string;
43
+ value: string;
44
+ toNumber?: (value: string) => number | null;
45
+ toCss?: (number: number) => string;
46
+ min?: number;
47
+ onPreview: (value: string | null) => void;
48
+ onCommit: (value: string) => void;
49
+ }): import("react").JSX.Element;
50
+ export {};
51
+ //# sourceMappingUR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