soma-kit 0.1.15 → 0.1.16

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 (470) hide show
  1. package/README.md +1 -1
  2. package/package.json +8 -5
  3. package/packs/ai/model-card.ts +3 -3
  4. package/packs/ops/error-budget-card.ts +3 -3
  5. package/packs/ops/release-readiness-card.ts +3 -3
  6. package/packs/security/control-evidence-card.ts +3 -3
  7. package/packs/security/finding-card.ts +3 -2
  8. package/packs/shared/card-util.ts +17 -0
  9. package/spec/generated/kit-app.schema.json +2148 -340
  10. package/spec/generated/kit-page.schema.json +1134 -139
  11. package/spec/kit-grammar.json +934 -92
  12. package/spec/kit-grammar.schema.json +167 -2
  13. package/src/app/app-config.ts +219 -186
  14. package/src/app/define-kit-actions.ts +126 -20
  15. package/src/app/define-kit-app.ts +49 -4
  16. package/src/app/index.ts +5 -0
  17. package/src/app/kit-view-context.ts +39 -1
  18. package/src/app/list-page-defaults.ts +14 -0
  19. package/src/app/server-pages.ts +239 -7
  20. package/src/app/server.ts +466 -25
  21. package/src/app/theme-endpoint.ts +67 -23
  22. package/src/app/theme-runtime.ts +414 -85
  23. package/src/app/theme-shards.ts +69 -0
  24. package/src/app/tier-compat.ts +107 -0
  25. package/src/base/action-busy.ts +215 -38
  26. package/src/base/affix.ts +137 -0
  27. package/src/base/alert.ts +104 -59
  28. package/src/base/anchored-layer.ts +7 -6
  29. package/src/base/avatar.ts +147 -61
  30. package/src/base/badge.ts +186 -0
  31. package/src/base/button-group.ts +227 -0
  32. package/src/base/button.ts +347 -50
  33. package/src/base/card.ts +233 -0
  34. package/src/base/cascader.ts +143 -32
  35. package/src/base/check-core.ts +193 -33
  36. package/src/base/checkbox.ts +67 -2
  37. package/src/base/choice.ts +132 -31
  38. package/src/base/collapse.ts +249 -0
  39. package/src/base/color-picker.ts +399 -27
  40. package/src/base/combobox.ts +6 -2
  41. package/src/base/command-palette.ts +148 -36
  42. package/src/base/context-menu.ts +23 -6
  43. package/src/base/countdown.ts +37 -15
  44. package/src/base/date-range.ts +114 -96
  45. package/src/base/date.ts +481 -74
  46. package/src/base/delta.ts +16 -9
  47. package/src/base/divider.ts +51 -33
  48. package/src/base/end-edge.ts +10 -4
  49. package/src/base/fab.ts +57 -21
  50. package/src/base/gap-value.ts +34 -15
  51. package/src/base/hint-tips.ts +99 -29
  52. package/src/base/identity-cells.ts +839 -0
  53. package/src/base/illustrations.ts +6 -4
  54. package/src/base/image.ts +40 -19
  55. package/src/base/index.ts +79 -22
  56. package/src/base/inline-error.ts +13 -7
  57. package/src/base/input.ts +135 -35
  58. package/src/base/kbd.ts +30 -17
  59. package/src/base/kit-contract.ts +400 -0
  60. package/src/base/link.ts +41 -20
  61. package/src/base/listbox-core.ts +282 -101
  62. package/src/base/loading-gate.ts +3 -0
  63. package/src/base/look.ts +197 -0
  64. package/src/base/mentions.ts +55 -22
  65. package/src/base/menu-button.ts +73 -22
  66. package/src/base/menu-core.ts +201 -24
  67. package/src/base/month-grid.ts +60 -3
  68. package/src/base/motion/aura.ts +52 -10
  69. package/src/base/motion/hover-3d.ts +7 -5
  70. package/src/base/motion/hover-gallery.ts +16 -12
  71. package/src/base/motion/limits.ts +10 -0
  72. package/src/base/motion/marquee.ts +18 -11
  73. package/src/base/motion/text-rotate.ts +34 -16
  74. package/src/base/notification.ts +292 -0
  75. package/src/base/number.ts +93 -12
  76. package/src/base/otp.ts +139 -27
  77. package/src/base/overlay-runtime.ts +30 -23
  78. package/src/base/overlay-shell.ts +59 -14
  79. package/src/base/period-picker.ts +868 -0
  80. package/src/base/popover.ts +624 -73
  81. package/src/base/popup.ts +187 -52
  82. package/src/base/portal-core.ts +99 -2
  83. package/src/base/price-text.ts +51 -17
  84. package/src/base/progress.ts +100 -18
  85. package/src/base/qr-code.ts +64 -17
  86. package/src/base/qty-stepper.ts +141 -22
  87. package/src/base/radio.ts +43 -2
  88. package/src/base/range.ts +194 -39
  89. package/src/base/rating.ts +117 -31
  90. package/src/base/reason-tip.ts +58 -16
  91. package/src/base/relation-cells.ts +541 -0
  92. package/src/base/resize-handle.ts +5 -3
  93. package/src/base/row-fresh.ts +84 -0
  94. package/src/base/section-spy.ts +79 -0
  95. package/src/base/segmented.ts +70 -26
  96. package/src/base/select.ts +8 -3
  97. package/src/base/shared.ts +482 -71
  98. package/src/base/spinner.ts +107 -0
  99. package/src/base/state-panel.ts +77 -22
  100. package/src/base/sticky-edge.ts +96 -29
  101. package/src/base/swap.ts +39 -21
  102. package/src/base/switch.ts +158 -38
  103. package/src/base/tabs.ts +292 -0
  104. package/src/base/tag-input.ts +123 -54
  105. package/src/base/tag.ts +184 -66
  106. package/src/base/text.ts +461 -71
  107. package/src/base/textarea.ts +88 -39
  108. package/src/base/time-picker.ts +335 -55
  109. package/src/base/time-range.ts +846 -0
  110. package/src/base/tree-select.ts +342 -88
  111. package/src/base/upload.ts +604 -158
  112. package/src/base/view-transition.ts +7 -3
  113. package/src/base/virtual-list.ts +49 -14
  114. package/src/biz/approval-desk/compile.ts +70 -5
  115. package/src/biz/approval-desk/index.ts +2 -0
  116. package/src/biz/approval-desk/shell.ts +52 -12
  117. package/src/biz/auth-panel/compile.ts +13 -3
  118. package/src/biz/auth-panel/shell.ts +27 -7
  119. package/src/biz/category-crud/compile.ts +51 -13
  120. package/src/biz/category-crud/index.ts +2 -0
  121. package/src/biz/category-crud/shell.ts +29 -9
  122. package/src/biz/checkout-page/compile.ts +37 -3
  123. package/src/biz/checkout-page/index.ts +1 -0
  124. package/src/biz/checkout-page/shell.ts +26 -9
  125. package/src/biz/compose.ts +6 -1
  126. package/src/biz/data-components.ts +2 -0
  127. package/src/biz/import-wizard/compile.ts +4 -1
  128. package/src/biz/import-wizard/index.ts +1 -0
  129. package/src/biz/import-wizard/shell.ts +32 -18
  130. package/src/biz/index.ts +1 -1
  131. package/src/biz/landing-page/compile.ts +3 -2
  132. package/src/biz/landing-page/shell.ts +22 -3
  133. package/src/biz/layout-contracts.ts +918 -0
  134. package/src/biz/link/hub.ts +199 -8
  135. package/src/biz/link/shared.ts +54 -15
  136. package/src/biz/master-sub/compile.ts +194 -57
  137. package/src/biz/master-sub/detail-head.ts +141 -18
  138. package/src/biz/master-sub/index.ts +3 -0
  139. package/src/biz/master-sub/shell.ts +186 -57
  140. package/src/biz/multi-board/compile.ts +87 -36
  141. package/src/biz/multi-board/composition.ts +7 -20
  142. package/src/biz/multi-board/index.ts +3 -2
  143. package/src/biz/multi-board/prose-fold.ts +15 -11
  144. package/src/biz/multi-board/shell.ts +148 -37
  145. package/src/biz/notification-center/compile.ts +20 -6
  146. package/src/biz/notification-center/index.ts +2 -0
  147. package/src/biz/notification-center/shell.ts +43 -10
  148. package/src/biz/page-templates/domain-templates.ts +145 -22
  149. package/src/biz/page-templates/result-page/compile.ts +4 -1
  150. package/src/biz/page-templates/result-page/index.ts +1 -0
  151. package/src/biz/page-templates/result-page/shell.ts +17 -4
  152. package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
  153. package/src/biz/page-templates/sign-in-page/index.ts +1 -0
  154. package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
  155. package/src/biz/record-detail/compile.ts +39 -11
  156. package/src/biz/record-detail/index.ts +1 -0
  157. package/src/biz/record-detail/shell.ts +41 -10
  158. package/src/biz/settings-center/compile.ts +4 -1
  159. package/src/biz/settings-center/index.ts +1 -0
  160. package/src/biz/settings-center/shell.ts +30 -9
  161. package/src/biz/shared/action-host.ts +137 -46
  162. package/src/biz/shared/compile-helpers.ts +130 -28
  163. package/src/biz/shared/coordinator.ts +628 -147
  164. package/src/biz/shared/focus-return.ts +180 -0
  165. package/src/biz/shared/object-aliases.ts +7 -1
  166. package/src/biz/shared/overlay-compile.ts +58 -10
  167. package/src/biz/shared/overlay-shell.ts +40 -10
  168. package/src/biz/shared/page-form-actions.ts +151 -0
  169. package/src/biz/shared/page-form.ts +255 -0
  170. package/src/biz/shared/pipeline.ts +74 -0
  171. package/src/biz/shared/runtime-hub.ts +101 -8
  172. package/src/biz/shared/verbs.ts +129 -0
  173. package/src/biz/single-form/compile.ts +4 -2
  174. package/src/biz/single-form/index.ts +2 -0
  175. package/src/biz/single-form/shell.ts +21 -11
  176. package/src/biz/standard-crud/compile.ts +206 -38
  177. package/src/biz/standard-crud/index.ts +2 -1
  178. package/src/biz/standard-crud/shell.ts +82 -22
  179. package/src/biz/standard-crud/summary.ts +2 -37
  180. package/src/biz/step-form/compile.ts +12 -3
  181. package/src/biz/step-form/hub.ts +165 -50
  182. package/src/biz/step-form/index.ts +1 -0
  183. package/src/biz/step-form/shell.ts +31 -15
  184. package/src/biz/types.ts +40 -4
  185. package/src/cli/kit-cli.ts +145 -26
  186. package/src/cli/kit-init.ts +3 -3
  187. package/src/cli/migrate/theme-map.ts +35 -28
  188. package/src/cli/migrate/ts-rules.ts +2 -2
  189. package/src/cli/migrate/types.ts +3 -3
  190. package/src/cli/migrate/yaml-rules.ts +11 -9
  191. package/src/cli/view-writes.ts +13 -0
  192. package/src/compile/closed-set.ts +102 -6
  193. package/src/compile/compile-page.ts +446 -53
  194. package/src/compile/component-candidates.ts +56 -4
  195. package/src/compile/danger-tier.ts +65 -0
  196. package/src/compile/hints.ts +1 -1
  197. package/src/compile/info-structure.ts +155 -0
  198. package/src/compile/layout-lint/rules-composition.ts +2 -1
  199. package/src/compile/layout-lint/rules-table.ts +4 -19
  200. package/src/compile/look-page.ts +551 -0
  201. package/src/compile/look.ts +376 -0
  202. package/src/compile/page-composition.ts +382 -46
  203. package/src/compile/page-hierarchy.ts +131 -0
  204. package/src/compile/page-pipeline-look.ts +156 -0
  205. package/src/compile/page-pipeline.ts +200 -0
  206. package/src/compile/parse.ts +12 -11
  207. package/src/compile/relation-render.ts +120 -0
  208. package/src/compile/remove-guard.ts +115 -41
  209. package/src/compile/stages.ts +645 -28
  210. package/src/compile/styles.ts +226 -26
  211. package/src/compile/types.ts +62 -5
  212. package/src/compile/view-check.ts +190 -1
  213. package/src/data/access-gate.ts +17 -9
  214. package/src/data/amount-breakdown.ts +49 -22
  215. package/src/data/anchor-nav.ts +73 -15
  216. package/src/data/approval-flow.ts +210 -124
  217. package/src/data/assignment-picker.ts +163 -85
  218. package/src/data/async-result-panel.ts +110 -46
  219. package/src/data/audit-log.ts +461 -0
  220. package/src/data/breadcrumbs.ts +141 -19
  221. package/src/data/calendar.ts +434 -96
  222. package/src/data/card-grid.ts +319 -0
  223. package/src/data/carousel.ts +72 -38
  224. package/src/data/cell-value.ts +253 -0
  225. package/src/data/chart.ts +904 -77
  226. package/src/data/checklist.ts +78 -35
  227. package/src/data/code-view.ts +106 -48
  228. package/src/data/comment-thread.ts +607 -87
  229. package/src/data/compare-view.ts +227 -0
  230. package/src/data/confirm-dialog.ts +198 -30
  231. package/src/data/context-menu.ts +95 -21
  232. package/src/data/d9-limits.ts +2 -0
  233. package/src/data/d9-util.ts +13 -5
  234. package/src/data/diff.ts +107 -50
  235. package/src/data/display-util.ts +9 -4
  236. package/src/data/dock.ts +33 -17
  237. package/src/data/embed.ts +142 -7
  238. package/src/data/engine-ports.ts +13 -4
  239. package/src/data/field-mapper.ts +104 -48
  240. package/src/data/file-list.ts +522 -0
  241. package/src/data/flow-editor.ts +603 -142
  242. package/src/data/flow-node-options.ts +24 -5
  243. package/src/data/flow-remote-options.ts +94 -19
  244. package/src/data/footer.ts +85 -27
  245. package/src/data/form-draft-registry.ts +183 -12
  246. package/src/data/gantt.ts +637 -117
  247. package/src/data/graph-view.ts +51 -0
  248. package/src/data/heat-calendar.ts +412 -0
  249. package/src/data/hero.ts +38 -15
  250. package/src/data/image-viewer.ts +261 -62
  251. package/src/data/index.ts +63 -1
  252. package/src/data/item-list.ts +217 -57
  253. package/src/data/json-view.ts +165 -100
  254. package/src/data/kanban.ts +339 -87
  255. package/src/data/kit-contract.ts +230 -0
  256. package/src/data/leaderboard.ts +343 -0
  257. package/src/data/level-class.ts +21 -0
  258. package/src/data/log-stream.ts +347 -0
  259. package/src/data/markdown-view.ts +155 -45
  260. package/src/data/matrix.ts +217 -112
  261. package/src/data/media-grid.ts +162 -38
  262. package/src/data/mega-menu.ts +39 -23
  263. package/src/data/menu-bar.ts +254 -0
  264. package/src/data/menu-dom.ts +50 -15
  265. package/src/data/menu.ts +131 -47
  266. package/src/data/mockup.ts +30 -22
  267. package/src/data/modal-dialog.ts +90 -13
  268. package/src/data/navbar.ts +143 -61
  269. package/src/data/notice-list.ts +100 -48
  270. package/src/data/notify-renderer.ts +61 -7
  271. package/src/data/object-form.ts +1389 -130
  272. package/src/data/org-chart.ts +544 -0
  273. package/src/data/outcome-watch.ts +90 -21
  274. package/src/data/pager.ts +122 -42
  275. package/src/data/panel-head.ts +237 -75
  276. package/src/data/permission-matrix.ts +371 -119
  277. package/src/data/permission-tree.ts +135 -80
  278. package/src/data/pricing-table.ts +106 -42
  279. package/src/data/prompt-dialog.ts +49 -21
  280. package/src/data/reaction-bar.ts +63 -31
  281. package/src/data/record-card.ts +239 -70
  282. package/src/data/record-picker.ts +56 -27
  283. package/src/data/redirect.ts +39 -15
  284. package/src/data/request-console.ts +131 -41
  285. package/src/data/resident.ts +11 -1
  286. package/src/data/result-panel.ts +65 -27
  287. package/src/data/rich-text.ts +206 -35
  288. package/src/data/row-confirm.ts +47 -0
  289. package/src/data/row-editor.ts +376 -102
  290. package/src/data/rule-builder.ts +129 -80
  291. package/src/data/schedule-grid.ts +238 -0
  292. package/src/data/segment-bar.ts +221 -0
  293. package/src/data/shape-util.ts +86 -43
  294. package/src/data/stage-flow.ts +244 -0
  295. package/src/data/staged-rows.ts +207 -24
  296. package/src/data/stat-group.ts +438 -86
  297. package/src/data/static-lazy.ts +18 -0
  298. package/src/data/static-registry.ts +38 -2
  299. package/src/data/status-strip.ts +171 -0
  300. package/src/data/steps.ts +63 -34
  301. package/src/data/summary-strip.ts +136 -0
  302. package/src/data/summary-util.ts +116 -0
  303. package/src/data/survey.ts +128 -47
  304. package/src/data/system-switcher.ts +40 -20
  305. package/src/data/target-progress.ts +208 -0
  306. package/src/data/text-action-button.ts +28 -7
  307. package/src/data/text-diff.ts +99 -31
  308. package/src/data/tile-grid.ts +343 -0
  309. package/src/data/timeline.ts +205 -36
  310. package/src/data/tour-guide.ts +110 -47
  311. package/src/data/transfer.ts +195 -47
  312. package/src/data/tree-table.ts +194 -112
  313. package/src/data/tree.ts +191 -70
  314. package/src/data/trend-line.ts +68 -12
  315. package/src/data/virtual-rows.ts +242 -102
  316. package/src/data/waterfall.ts +171 -0
  317. package/src/data/watermark.ts +35 -6
  318. package/src/data/wrap.ts +26 -4
  319. package/src/frames/blank-frame.ts +6 -4
  320. package/src/frames/index.ts +1 -2
  321. package/src/frames/inherited-shell.ts +54 -13
  322. package/src/frames/page-bar.ts +205 -27
  323. package/src/frames/page-status.ts +3 -2
  324. package/src/frames/resident-components.ts +0 -2
  325. package/src/frames/shared.ts +64 -21
  326. package/src/frames/single-frame.ts +20 -4
  327. package/src/frames/split-frame/shell.ts +11 -7
  328. package/src/frames/split-frame/wiring.ts +14 -10
  329. package/src/frames/tabs-frame/shell.ts +3 -2
  330. package/src/frames/tabs-frame/wiring.ts +2 -1
  331. package/src/frames/top-main-frame.ts +55 -3
  332. package/src/frames/types.ts +2 -0
  333. package/src/frames/workspace-frame/extras.ts +5 -3
  334. package/src/frames/workspace-frame/index.ts +1 -1
  335. package/src/frames/workspace-frame/pipeline-key.ts +6 -0
  336. package/src/frames/workspace-frame/shell.ts +22 -2
  337. package/src/frames/workspace-frame/state.ts +42 -14
  338. package/src/frames/workspace-frame/view.ts +697 -167
  339. package/src/generated/kit-grammar-runtime.ts +1015 -53
  340. package/src/generated/kit-page.ts +272 -0
  341. package/src/i18n/index.ts +2 -0
  342. package/src/i18n/kit-text.ts +96 -3
  343. package/src/object-renderer/action-group.ts +175 -23
  344. package/src/object-renderer/action-more.ts +48 -17
  345. package/src/object-renderer/arrange.ts +241 -29
  346. package/src/object-renderer/category-tone.ts +96 -0
  347. package/src/object-renderer/collapse-wiring.ts +19 -9
  348. package/src/object-renderer/collection-expand.ts +3 -3
  349. package/src/object-renderer/collection-parts.ts +432 -107
  350. package/src/object-renderer/collection-table.ts +347 -45
  351. package/src/object-renderer/collection.ts +291 -62
  352. package/src/object-renderer/compile-data.ts +12 -2
  353. package/src/object-renderer/defaults.ts +6 -5
  354. package/src/object-renderer/emit-events.ts +45 -19
  355. package/src/object-renderer/emit-object.ts +35 -9
  356. package/src/object-renderer/emit-static.ts +734 -159
  357. package/src/object-renderer/filter-plan.ts +3 -3
  358. package/src/object-renderer/filter-toolbar.ts +105 -18
  359. package/src/object-renderer/form-detail.ts +87 -2
  360. package/src/object-renderer/key-field.ts +21 -0
  361. package/src/object-renderer/layout-facts.ts +18 -2
  362. package/src/object-renderer/layout-plan.ts +6 -3
  363. package/src/object-renderer/overlay-decide.ts +44 -2
  364. package/src/object-renderer/pick-component.ts +8 -2
  365. package/src/object-renderer/pipeline-mode.ts +6 -0
  366. package/src/object-renderer/relation-field.ts +79 -0
  367. package/src/object-renderer/render-object.ts +71 -26
  368. package/src/object-renderer/request-actions.ts +119 -21
  369. package/src/object-renderer/table-actions.ts +424 -103
  370. package/src/object-renderer/table-gap.ts +2 -1
  371. package/src/object-renderer/table-reorder.ts +237 -0
  372. package/src/object-renderer/table-summary.ts +26 -12
  373. package/src/object-renderer/table-tools.ts +428 -128
  374. package/src/object-renderer/types.ts +91 -2
  375. package/src/object-renderer/value-present.ts +49 -0
  376. package/src/page-target/ai-surface.ts +15 -22
  377. package/src/page-target/compile.ts +5 -6
  378. package/src/page-target/drift.ts +0 -7
  379. package/src/page-target/intent-schema.ts +46 -43
  380. package/src/page-target/target.ts +4 -5
  381. package/src/page-target/writer-policy.ts +4 -5
  382. package/src/recipes/chrome-surface.ts +20 -0
  383. package/src/recipes/code-view.ts +15 -14
  384. package/src/recipes/color-role.ts +442 -0
  385. package/src/recipes/compact-group.ts +3 -2
  386. package/src/recipes/composition-projector.ts +321 -0
  387. package/src/recipes/container.ts +76 -19
  388. package/src/recipes/control.ts +64 -5
  389. package/src/recipes/desc-list.ts +101 -7
  390. package/src/recipes/divider.ts +30 -9
  391. package/src/recipes/emphasis.ts +90 -5
  392. package/src/recipes/field-text.ts +72 -0
  393. package/src/recipes/form-section.ts +177 -0
  394. package/src/recipes/frame-bleed.ts +3 -2
  395. package/src/recipes/index.ts +28 -4
  396. package/src/recipes/inherited-shell.ts +21 -15
  397. package/src/recipes/json-view.ts +6 -5
  398. package/src/recipes/look.ts +56 -0
  399. package/src/recipes/mark.ts +138 -0
  400. package/src/recipes/markdown.ts +16 -6
  401. package/src/recipes/overlay.ts +47 -19
  402. package/src/recipes/page-width.ts +31 -0
  403. package/src/recipes/pipeline-runtime.ts +366 -0
  404. package/src/recipes/placeholder.ts +37 -19
  405. package/src/recipes/rail-grid.ts +6 -3
  406. package/src/recipes/self-owned.ts +59 -0
  407. package/src/recipes/slot-align.ts +5 -3
  408. package/src/recipes/stat-state.ts +5 -5
  409. package/src/recipes/state.ts +54 -3
  410. package/src/recipes/status.ts +14 -14
  411. package/src/recipes/strip.ts +47 -5
  412. package/src/recipes/surface-edge.ts +3 -1
  413. package/src/recipes/surface.ts +33 -4
  414. package/src/recipes/table-gap.ts +3 -2
  415. package/src/recipes/table-native-edit.ts +22 -9
  416. package/src/recipes/table-row.ts +45 -12
  417. package/src/recipes/tabs.ts +54 -22
  418. package/src/recipes/text-diff.ts +15 -8
  419. package/src/recipes/text-fit.ts +132 -0
  420. package/src/recipes/title-row.ts +68 -3
  421. package/src/shared/action-func.ts +106 -0
  422. package/src/shared/color-scheme.ts +127 -0
  423. package/src/shared/confirm-decl.ts +5 -2
  424. package/src/shared/danger-facts.ts +55 -0
  425. package/src/shared/dom-attrs-registry.ts +1009 -0
  426. package/src/shared/dom-attrs.ts +743 -0
  427. package/src/shared/field-kind.ts +49 -0
  428. package/src/shared/field-value-format.ts +58 -12
  429. package/src/shared/glyphs.ts +127 -0
  430. package/src/shared/icons.ts +28 -1
  431. package/src/shared/identifier-field.ts +66 -0
  432. package/src/shared/list-pager.ts +23 -0
  433. package/src/shared/list-title.ts +29 -0
  434. package/src/shared/order-value.ts +15 -0
  435. package/src/shared/page-attrs-runtime.ts +327 -0
  436. package/src/shared/page-attrs.ts +262 -0
  437. package/src/shared/pipeline-mode.ts +64 -0
  438. package/src/shared/row-key.ts +15 -0
  439. package/src/shared/theme-runtime-shared.ts +165 -24
  440. package/src/shared/theme-usage.ts +16 -0
  441. package/src/shared/value-table-contract.ts +68 -0
  442. package/src/spatial/action-func.ts +4 -0
  443. package/src/spatial/declared-actions.ts +116 -0
  444. package/src/spatial/emit.ts +660 -0
  445. package/src/spatial/expand.ts +1482 -0
  446. package/src/spatial/field-types.ts +48 -0
  447. package/src/spatial/index.ts +82 -0
  448. package/src/spatial/layout.ts +697 -0
  449. package/src/spatial/look-apply.ts +206 -0
  450. package/src/spatial/page-decl.ts +44 -0
  451. package/src/spatial/page-object.ts +349 -0
  452. package/src/spatial/recognize.ts +491 -0
  453. package/src/spatial/self-report.ts +571 -0
  454. package/src/spatial/shape.ts +205 -0
  455. package/src/spatial/spatial-map.ts +136 -0
  456. package/src/spatial/tone.ts +145 -0
  457. package/src/theme/index.ts +11 -2
  458. package/src/theme/kit-theme-text.ts +1 -1
  459. package/src/theme/kit-theme.css +527 -16
  460. package/src/theme/kit-theme.tpl +491 -16
  461. package/src/theme/look-carrier.ts +65 -0
  462. package/src/theme/nine-dim-structure.ts +522 -185
  463. package/src/theme/private-vars.ts +153 -0
  464. package/src/theme/surface-layers.ts +3 -2
  465. package/src/theme/theme-tokens.ts +1601 -93
  466. package/src/theme/theme-types.ts +38 -59
  467. package/src/theme/value-table.ts +2379 -0
  468. package/src/frames/list-summary.ts +0 -123
  469. package/src/recipes/nowrap.ts +0 -16
  470. package/src/theme/block-theme.ts +0 -202
@@ -10,16 +10,21 @@
10
10
 
11
11
  import type { SomaComponentDefinition } from 'soma-core';
12
12
  import { kitText } from '../i18n/kit-text';
13
+ import { kitIcon } from '../shared/icons';
14
+ import { kitMonoValueRecipe } from '../recipes/field-text';
13
15
  import { createKeyboardWiring } from 'soma-core/keyboard';
14
16
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
15
17
  import { part, wirePopLayer } from './popover';
16
- import { KIT_DROPDOWN_CLASS_CANDIDATES } from './popup';
18
+ import { KIT_DROPDOWN_CLASS_CANDIDATES, popPlaceClass } from './popup';
17
19
  import { mergeClass } from '../shared/merge-class';
20
+ import { KIT_ATTR_CHIP_CHECK, KIT_ATTR_CLEAR, KIT_ATTR_FACE, KIT_ATTR_PLANE_SURFACE, KIT_ATTR_VALUE } from '../shared/dom-attrs';
21
+ import { KIT_STATIC_BLACK_TEXT_CLASS, KIT_STATIC_WHITE_TEXT_CLASS } from '../recipes/color-role';
18
22
  import { kitSurfaceRecipe } from '../recipes/surface';
23
+ import { KIT_FOCUS_RING } from '../recipes/state';
19
24
  import { kitControlEdgeRecipe, kitControlRecipe } from '../recipes/control';
20
25
  import {
21
- CLASS_PROP, ID_PROPS, INVALID_PROPS, SIZE_PROP,
22
- applyCommon, applyCompositeField, bool, classCandidates, createKitController, joinClass, nextUid, setAttr, sizeOf, str,
26
+ CLASS_PROP, FIELD_INVALID_CLASS, ID_PROPS, INVALID_PROPS, SIZE_PROP,
27
+ applyCommon, applyCompositeField, bool, classCandidates, createKitController, joinClass, kitControlSizeOf, kitMarkDataState, kitMarkInteract, kitOuterRoot, kitSid, nextUid, setAttr, str, withInvalid,
23
28
  type KitSize,
24
29
  } from './shared';
25
30
 
@@ -44,6 +49,55 @@ function hslToHex(h: number, s: number, l: number): string {
44
49
  return `#${hex(f(0))}${hex(f(8))}${hex(f(4))}`;
45
50
  }
46
51
 
52
+ export interface Hsv { h: number; s: number; v: number }
53
+
54
+ /** HSV(h 0..360,s / v 0..1)→ 小写 #rrggbb */
55
+ export function hsvToHex(c: Hsv): string {
56
+ const f = (n: number): number => {
57
+ const k = (n + c.h / 60) % 6;
58
+ return c.v - c.v * c.s * Math.max(0, Math.min(k, 4 - k, 1));
59
+ };
60
+ const hex = (x: number): string => Math.round(Math.max(0, Math.min(1, x)) * 255).toString(16).padStart(2, '0');
61
+ return `#${hex(f(5))}${hex(f(3))}${hex(f(1))}`;
62
+ }
63
+
64
+ /** #rrggbb → HSV;灰色(s = 0)时色相给 0,调用方需要保留旧色相时自己判 */
65
+ export function hexToHsv(hex: string): Hsv {
66
+ const n = normalizeHex(hex);
67
+ if (n === null) return { h: 0, s: 0, v: 0 };
68
+ const r = parseInt(n.slice(1, 3), 16) / 255;
69
+ const g = parseInt(n.slice(3, 5), 16) / 255;
70
+ const b = parseInt(n.slice(5, 7), 16) / 255;
71
+ const max = Math.max(r, g, b);
72
+ const d = max - Math.min(r, g, b);
73
+ let h = 0;
74
+ if (d !== 0) {
75
+ if (max === r) h = ((g - b) / d + 6) % 6;
76
+ else if (max === g) h = (b - r) / d + 2;
77
+ else h = (r - g) / d + 4;
78
+ h *= 60;
79
+ }
80
+ return { h, s: max === 0 ? 0 : d / max, v: max };
81
+ }
82
+
83
+ /** 色块上的勾与圆环要用深色还是浅色字(OKLab 感知明度 L > 0.62 用物理静态黑,否则物理静态白) */
84
+ export function inkOnSwatchIsDark(hex: string): boolean {
85
+ const n = normalizeHex(hex);
86
+ if (n === null) return false;
87
+ const ch = (i: number): number => {
88
+ const c = parseInt(n.slice(i, i + 2), 16) / 255;
89
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
90
+ };
91
+ const r = ch(1);
92
+ const g = ch(3);
93
+ const b = ch(5);
94
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
95
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
96
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
97
+ const okL = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s;
98
+ return okL > 0.62;
99
+ }
100
+
47
101
  /** 内置色板:十一档色相 + 一档灰;运行时换算,源码里不放裸色值 */
48
102
  export function defaultPresets(): string[] {
49
103
  const hues = [0, 25, 45, 85, 140, 175, 195, 215, 245, 270, 330];
@@ -68,29 +122,71 @@ const ROOT = 'relative block w-full';
68
122
  // 触发钮 / 色块 / 自定义输入的边 = 控件轮廓出口(KT-B1 / §4 C6)
69
123
  const EDGE = kitControlEdgeRecipe();
70
124
  const CHIP_EDGE = kitControlEdgeRecipe({ wrapper: true });
125
+ const CLEAR_PAD = 'pe-8';
126
+ const TRIGGER_BASE = mergeClass(mergeClass('inline-flex w-full cursor-pointer items-center gap-2 rounded-control bg-surface text-fg transition-colors disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled', EDGE), KIT_FOCUS_RING.control);
71
127
  const TRIGGER: Record<KitSize, string> = {
72
- sm: `inline-flex h-6 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-2.5 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60`,
73
- md: `inline-flex h-8 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-3 text-sm text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60`,
74
- lg: `inline-flex h-10 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-4 text-base text-fg transition-colors focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60`,
128
+ sm: `${TRIGGER_BASE} h-control-sm px-2.5 text-xs`,
129
+ md: `${TRIGGER_BASE} h-8 px-3 text-sm`,
130
+ lg: `${TRIGGER_BASE} h-10 px-4 text-base`,
75
131
  };
132
+ const TRIGGER_CLEAR: Record<KitSize, string> = {
133
+ sm: mergeClass(TRIGGER.sm, CLEAR_PAD),
134
+ md: mergeClass(TRIGGER.md, CLEAR_PAD),
135
+ lg: mergeClass(TRIGGER.lg, CLEAR_PAD),
136
+ };
137
+ const CLEAR_BTN = mergeClass(
138
+ 'absolute end-1.5 top-0 flex h-full w-6 cursor-pointer items-center justify-center rounded-item border-0 bg-transparent p-0 text-fg-subtle transition-colors hover:text-fg',
139
+ KIT_FOCUS_RING.item,
140
+ );
141
+ // 隐藏的清除钮也带焦点环出口(集合项宿主),G121 ⑥
142
+ const CLEAR_HIDDEN = mergeClass('hidden', KIT_FOCUS_RING.item);
76
143
  const TRIGGER_TEXT = 'min-w-0 flex-1 truncate text-start';
77
144
  const TRIGGER_TEXT_EMPTY = 'min-w-0 flex-1 truncate text-start text-fg-subtle';
78
145
  const SWATCH_SVG = 'h-4 w-4 shrink-0';
79
146
  const SWATCH_RECT = 'stroke-border stroke-1';
80
- const PANEL = mergeClass('absolute z-10 w-64 p-3 focus-visible:outline-none', kitSurfaceRecipe('raised'));
147
+ // 面板宽 240、内边距 12(组件卡 ColorPicker §5;Ant 面板内容宽 234)
148
+ const PANEL = mergeClass('absolute z-10 w-60 p-3 focus-visible:outline-none', kitSurfaceRecipe('raised'));
81
149
  const HIDDEN = 'hidden';
82
- const PRESETS = 'flex flex-wrap gap-2';
83
- const CHIP_IDLE = `inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md ${CHIP_EDGE} transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;
84
- const CHIP_ON = 'inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md border-2 border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
85
- const CHIP_SVG = 'h-4 w-4';
150
+ // 预设块间距 4(组件卡:Ant 3 → kit 4)
151
+ const PRESETS = 'mt-3 flex flex-wrap gap-1';
152
+ // 面板自上而下:饱和度 × 明度平面 → 色相滑块 + 预览块 → HEX 输入 → 预设(组件卡 ColorPicker §2 / §7;抄 Ant color-picker 的版式)
153
+ // 平面外层 relative overflow-visible 承载取色圆环防四角削切,内层 overflow-hidden rounded-item 承载渐变面;把手是 SVG 圆(属性画,不写内联样式)
154
+ const PLANE = mergeClass('relative block h-40 w-full cursor-crosshair touch-none overflow-visible rounded-item', KIT_FOCUS_RING.item);
155
+ const PLANE_SURFACE = 'pointer-events-none block h-full w-full overflow-hidden rounded-item';
156
+ const PLANE_HANDLE_SVG = 'pointer-events-none absolute inset-0 block h-full w-full overflow-visible';
157
+ const SLIDER_ROW = 'mt-3 flex items-center gap-3';
158
+ const HUE = mergeClass('relative block h-2 min-w-0 flex-1 cursor-pointer touch-none rounded-full', KIT_FOCUS_RING.item);
159
+ const PLANE_SVG = 'block h-full w-full';
160
+ const HUE_SVG = 'block h-full w-full overflow-visible';
161
+ const HANDLE_RING_LIGHT = mergeClass('fill-none stroke-current stroke-2', KIT_STATIC_WHITE_TEXT_CLASS);
162
+ const HANDLE_RING_DARK = mergeClass('fill-none stroke-current stroke-2', KIT_STATIC_BLACK_TEXT_CLASS);
163
+ const HANDLE_EDGE_DARK = mergeClass('fill-none stroke-current stroke-1', KIT_STATIC_BLACK_TEXT_CLASS);
164
+ const HANDLE_EDGE_LIGHT = mergeClass('fill-none stroke-current stroke-1', KIT_STATIC_WHITE_TEXT_CLASS);
165
+ const PREVIEW = 'size-7 shrink-0';
166
+ const CLEAR_SLASH = 'stroke-danger stroke-2';
167
+ const CHECK_DARK = mergeClass('pointer-events-none absolute', KIT_STATIC_BLACK_TEXT_CLASS);
168
+ const CHECK_LIGHT = mergeClass('pointer-events-none absolute', KIT_STATIC_WHITE_TEXT_CLASS);
169
+ // 预设色块:单层干净圆角色块(size-6 满铺无内嵌双层框),选中 = 主色 2px 外环 + 对比度对勾
170
+ const CHIP_BASE = mergeClass(
171
+ 'relative inline-flex size-6 cursor-pointer items-center justify-center overflow-hidden rounded-item transition-transform hover:scale-105',
172
+ KIT_FOCUS_RING.button,
173
+ );
174
+ const CHIP_IDLE = mergeClass(CHIP_BASE, CHIP_EDGE);
175
+ const CHIP_ON = mergeClass(CHIP_BASE, 'border-2 border-primary');
176
+ const CHIP_SVG = 'block size-full';
86
177
  const CUSTOM = 'mt-3 flex flex-col gap-1';
87
- const CUSTOM_INPUT = kitControlRecipe();
88
- const CUSTOM_INPUT_BAD = 'block h-8 w-full rounded-md border border-danger-on-soft bg-surface px-2.5 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
178
+ // HEX 输入的值是等宽自由值:字取等宽自由值出口(kitMonoValueRecipe),不加底
179
+ const CUSTOM_INPUT = mergeClass(kitControlRecipe(), kitMonoValueRecipe());
180
+ const CUSTOM_INPUT_BAD = mergeClass(CUSTOM_INPUT, 'border-danger-on-soft');
89
181
  const ERROR = 'text-xs text-danger-on-soft';
90
182
 
91
183
  export const KIT_COLOR_PICKER_CLASS_CANDIDATES: readonly string[] = classCandidates(
92
- ROOT, Object.values(TRIGGER), TRIGGER_TEXT, TRIGGER_TEXT_EMPTY, SWATCH_SVG, SWATCH_RECT, PANEL, HIDDEN, PRESETS,
93
- CHIP_IDLE, CHIP_ON, CHIP_SVG, CUSTOM, CUSTOM_INPUT, CUSTOM_INPUT_BAD, ERROR, KIT_DROPDOWN_CLASS_CANDIDATES,
184
+ ROOT, Object.values(TRIGGER), Object.values(TRIGGER_CLEAR), CLEAR_PAD, CLEAR_BTN, CLEAR_HIDDEN,
185
+ TRIGGER_TEXT, TRIGGER_TEXT_EMPTY, SWATCH_SVG, SWATCH_RECT, PANEL, HIDDEN, PRESETS,
186
+ PLANE, PLANE_SURFACE, PLANE_HANDLE_SVG, SLIDER_ROW, HUE, PLANE_SVG, HUE_SVG,
187
+ HANDLE_RING_LIGHT, HANDLE_RING_DARK, HANDLE_EDGE_DARK, HANDLE_EDGE_LIGHT,
188
+ PREVIEW, CLEAR_SLASH, CHECK_DARK, CHECK_LIGHT,
189
+ CHIP_IDLE, CHIP_ON, CHIP_SVG, CUSTOM, CUSTOM_INPUT, CUSTOM_INPUT_BAD, ERROR, FIELD_INVALID_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES,
94
190
  );
95
191
 
96
192
  function swatch(svgClass: string, hex: string | null): SVGSVGElement {
@@ -105,9 +201,155 @@ function swatch(svgClass: string, hex: string | null): SVGSVGElement {
105
201
  rect.setAttribute('fill', hex ?? 'none');
106
202
  rect.setAttribute('class', SWATCH_RECT);
107
203
  svg.appendChild(rect);
204
+ // 清除态(无值):色块画一道斜线(组件卡 ColorPicker §2 清除态)
205
+ if (hex === null) {
206
+ const slash = document.createElementNS(SVG_NS, 'line');
207
+ for (const [k, v] of [['x1', '3'], ['y1', '13'], ['x2', '13'], ['y2', '3']] as const) slash.setAttribute(k, v);
208
+ slash.setAttribute('class', CLEAR_SLASH);
209
+ svg.appendChild(slash);
210
+ }
211
+ return svg;
212
+ }
213
+
214
+ function presetSwatch(hex: string): SVGSVGElement {
215
+ const svg = document.createElementNS(SVG_NS, 'svg');
216
+ svg.setAttribute('viewBox', '0 0 16 16');
217
+ svg.setAttribute('aria-hidden', 'true');
218
+ svg.setAttribute('class', CHIP_SVG);
219
+ const rect = document.createElementNS(SVG_NS, 'rect');
220
+ rect.setAttribute('width', '16');
221
+ rect.setAttribute('height', '16');
222
+ rect.setAttribute('fill', hex);
223
+ svg.appendChild(rect);
108
224
  return svg;
109
225
  }
110
226
 
227
+ function svgNode<K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string> = {}): SVGElementTagNameMap[K] {
228
+ const el = document.createElementNS(SVG_NS, tag);
229
+ for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
230
+ return el;
231
+ }
232
+
233
+ /** 平面 / 色相条里用到的固定色:由 HSV 换算,源码里不放裸色值 */
234
+ const WHITE = hsvToHex({ h: 0, s: 0, v: 1 });
235
+ const BLACK = hsvToHex({ h: 0, s: 0, v: 0 });
236
+ const HUE_STOPS = [0, 60, 120, 180, 240, 300, 360];
237
+
238
+ interface PanelUi {
239
+ plane: HTMLElement;
240
+ planeBase: SVGRectElement;
241
+ hue: HTMLElement;
242
+ preview: HTMLElement;
243
+ hueFill: SVGRectElement;
244
+ planeHandle: SVGGElement;
245
+ hueHandle: SVGGElement;
246
+ }
247
+
248
+ /** 在平面 / 色相条里建 SVG(渐变底 + 独立外溢把手层);每个选择器实例只建一次 */
249
+ function buildPanelUi(root: HTMLElement): PanelUi {
250
+ const plane = part(root, 'plane');
251
+ const hue = part(root, 'hue');
252
+ const preview = part(root, 'preview');
253
+ const gid = nextUid('kit-color-g');
254
+ const planeSurface = document.createElement('span');
255
+ planeSurface.className = PLANE_SURFACE;
256
+ planeSurface.setAttribute('aria-hidden', 'true');
257
+ planeSurface.setAttribute(KIT_ATTR_PLANE_SURFACE, '');
258
+ const psvg = svgNode('svg', { class: PLANE_SVG, preserveAspectRatio: 'none', 'aria-hidden': 'true' });
259
+ const defs = svgNode('defs');
260
+ const gw = svgNode('linearGradient', { id: `${gid}-w`, x1: '0', y1: '0', x2: '1', y2: '0' });
261
+ gw.append(svgNode('stop', { offset: '0', 'stop-color': WHITE }), svgNode('stop', { offset: '1', 'stop-color': WHITE, 'stop-opacity': '0' }));
262
+ const gb = svgNode('linearGradient', { id: `${gid}-b`, x1: '0', y1: '0', x2: '0', y2: '1' });
263
+ gb.append(svgNode('stop', { offset: '0', 'stop-color': BLACK, 'stop-opacity': '0' }), svgNode('stop', { offset: '1', 'stop-color': BLACK }));
264
+ defs.append(gw, gb);
265
+ const planeBase = svgNode('rect', { width: '100%', height: '100%' });
266
+ const white = svgNode('rect', { width: '100%', height: '100%', fill: `url(#${gid}-w)` });
267
+ const black = svgNode('rect', { width: '100%', height: '100%', fill: `url(#${gid}-b)` });
268
+ psvg.append(defs, planeBase, white, black);
269
+ planeSurface.appendChild(psvg);
270
+
271
+ const planeHandleSvg = svgNode('svg', { class: PLANE_HANDLE_SVG, 'aria-hidden': 'true' });
272
+ const planeHandle = svgNode('g');
273
+ planeHandle.append(svgNode('circle', { r: '8', class: HANDLE_EDGE_DARK }), svgNode('circle', { r: '7', class: HANDLE_RING_LIGHT }));
274
+ planeHandleSvg.appendChild(planeHandle);
275
+ plane.replaceChildren(planeSurface, planeHandleSvg);
276
+
277
+ const hsvg = svgNode('svg', { class: HUE_SVG, preserveAspectRatio: 'none', 'aria-hidden': 'true' });
278
+ const hg = svgNode('linearGradient', { id: `${gid}-h`, x1: '0', y1: '0', x2: '1', y2: '0' });
279
+ HUE_STOPS.forEach((h, i) => hg.appendChild(svgNode('stop', { offset: String(i / (HUE_STOPS.length - 1)), 'stop-color': hsvToHex({ h, s: 1, v: 1 }) })));
280
+ const hdefs = svgNode('defs');
281
+ hdefs.appendChild(hg);
282
+ const hueFill = svgNode('rect', { width: '100%', height: '100%', rx: '4', fill: `url(#${gid}-h)` });
283
+ const hueHandle = svgNode('g');
284
+ hueHandle.append(svgNode('circle', { cy: '4', r: '7', class: HANDLE_EDGE_DARK }), svgNode('circle', { cy: '4', r: '6', class: HANDLE_RING_LIGHT }));
285
+ hsvg.append(hdefs, hueFill, hueHandle);
286
+ hue.replaceChildren(hsvg);
287
+ return { plane, planeBase, hue, preview, hueFill, planeHandle, hueHandle };
288
+ }
289
+
290
+ /** 按 HSV 重画平面底色 / 把手位置 / 色相把手 / 预览块与滑块语义值(value 为当前确认值,无值时预览画清除斜线) */
291
+ function paintPanel(ui: PanelUi, c: Hsv, value: string | null): void {
292
+ ui.planeBase.setAttribute('fill', hsvToHex({ h: c.h, s: 1, v: 1 }));
293
+ const place = (g: SVGGElement, cx: string, cy?: string): void => {
294
+ for (const circle of Array.from(g.querySelectorAll('circle'))) {
295
+ circle.setAttribute('cx', cx);
296
+ if (cy !== undefined) circle.setAttribute('cy', cy);
297
+ }
298
+ };
299
+ const syncHandleIcon = (g: SVGGElement, darkInk: boolean): void => {
300
+ const [edgeNode, innerNode] = Array.from(g.querySelectorAll('circle'));
301
+ edgeNode?.setAttribute('class', darkInk ? HANDLE_EDGE_LIGHT : HANDLE_EDGE_DARK);
302
+ innerNode?.setAttribute('class', darkInk ? HANDLE_RING_DARK : HANDLE_RING_LIGHT);
303
+ };
304
+ const curHex = hsvToHex(c);
305
+ place(ui.planeHandle, `${c.s * 100}%`, `${(1 - c.v) * 100}%`);
306
+ syncHandleIcon(ui.planeHandle, inkOnSwatchIsDark(curHex));
307
+ place(ui.hueHandle, `${(c.h / 360) * 100}%`);
308
+ syncHandleIcon(ui.hueHandle, inkOnSwatchIsDark(hsvToHex({ h: c.h, s: 1, v: 1 })));
309
+ const sPct = Math.round(c.s * 100);
310
+ const vPct = Math.round(c.v * 100);
311
+ ui.plane.setAttribute('aria-valuenow', String(sPct));
312
+ ui.plane.setAttribute('aria-valuetext', value !== null ? `${value} (${sPct}% / ${vPct}%)` : `${sPct}% / ${vPct}%`);
313
+ ui.hue.setAttribute('aria-valuenow', String(Math.round(c.h)));
314
+ ui.hue.setAttribute('aria-valuetext', `${Math.round(c.h)}°`);
315
+ ui.preview.replaceChildren(swatch(PREVIEW, value));
316
+ }
317
+
318
+ /** 指针位置 → 元素内 0..1 的比例(量不到布局时回 0) */
319
+ function fractionIn(el: Element, event: PointerEvent): { x: number; y: number } {
320
+ const r = el.getBoundingClientRect();
321
+ const x = r.width > 0 ? (event.clientX - r.left) / r.width : 0;
322
+ const y = r.height > 0 ? (event.clientY - r.top) / r.height : 0;
323
+ return { x: Math.min(1, Math.max(0, x)), y: Math.min(1, Math.max(0, y)) };
324
+ }
325
+
326
+ /** 在 el 上接指针拖动(按下即取点,按住移动持续取点);返回解绑函数 */
327
+ function wireDrag(el: HTMLElement, onPoint: (event: PointerEvent) => void): () => void {
328
+ let active = false;
329
+ const down = (event: PointerEvent): void => {
330
+ active = true;
331
+ try { el.setPointerCapture(event.pointerId); } catch { /* 无指针捕获的环境:靠 move 事件继续 */ }
332
+ el.focus();
333
+ onPoint(event);
334
+ };
335
+ const move = (event: PointerEvent): void => {
336
+ if (active) onPoint(event);
337
+ };
338
+ const up = (): void => {
339
+ active = false;
340
+ };
341
+ el.addEventListener('pointerdown', down);
342
+ el.addEventListener('pointermove', move);
343
+ el.addEventListener('pointerup', up);
344
+ el.addEventListener('pointercancel', up);
345
+ return () => {
346
+ el.removeEventListener('pointerdown', down);
347
+ el.removeEventListener('pointermove', move);
348
+ el.removeEventListener('pointerup', up);
349
+ el.removeEventListener('pointercancel', up);
350
+ };
351
+ }
352
+
111
353
  export function createColorPicker(): SomaComponentDefinition {
112
354
  return {
113
355
  contract: {
@@ -117,6 +359,7 @@ export function createColorPicker(): SomaComponentDefinition {
117
359
  value: { type: 'string', default: '', desc: '当前颜色,小写 #rrggbb(空串 = 未选)' },
118
360
  presets: { type: 'array', default: [], desc: '预设色板 [HEX];空则用内置一排色相' },
119
361
  allow_custom: { type: 'boolean', default: true, desc: '显示 HEX 输入框;假则只能点色板' },
362
+ clearable: { type: 'boolean', default: false, desc: '有值时显示清除钮,点击清空为空串(allow_custom 为假时同样可用)' },
120
363
  placeholder: { type: 'string', default: '', desc: '未选时触发钮文字;缺省取内置文案(按页面语言)' },
121
364
  invalid_text: { type: 'string', default: '', desc: 'HEX 不合法的提示;缺省取内置文案(按页面语言)' },
122
365
  disabled: { type: 'boolean', default: false },
@@ -132,28 +375,43 @@ export function createColorPicker(): SomaComponentDefinition {
132
375
  },
133
376
  templateHtml:
134
377
  `<div data-soma-id="root" class="${ROOT}">` +
135
- `<button data-soma-id="trigger" type="button" data-kit-face="field" class="${TRIGGER.md}"><span data-soma-id="chip"></span><span data-soma-id="text" class="${TRIGGER_TEXT}"></span></button>` +
378
+ `<button data-soma-id="trigger" type="button" ${KIT_ATTR_FACE}="field" class="${TRIGGER.md}"><span data-soma-id="chip"></span><span data-soma-id="text" class="${TRIGGER_TEXT}"></span></button>` +
379
+ `<button data-soma-id="clear" ${KIT_ATTR_CLEAR}="" type="button" tabindex="-1" class="${CLEAR_HIDDEN}"></button>` +
380
+ // 取色面板是挂起来的下拉面板:自报层级角色「浮起」(绘制时由骨架的 selfParts 写;浮层端口挂到页面最外层后仍随节点带着)
136
381
  `<div data-soma-id="panel" class="${HIDDEN}">` +
137
- `<div data-soma-id="presets" role="listbox" aria-orientation="horizontal" class="${PRESETS}"></div>` +
382
+ `<div data-soma-id="plane" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100" class="${PLANE}"></div>` +
383
+ `<div data-soma-id="sliders" class="${SLIDER_ROW}"><div data-soma-id="hue" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="360" class="${HUE}"></div><span data-soma-id="preview" aria-hidden="true" class="${PREVIEW}"></span></div>` +
138
384
  `<div data-soma-id="custom" class="${HIDDEN}">` +
139
- `<input data-soma-id="hex" type="text" autocomplete="off" spellcheck="false" maxlength="7" data-kit-face="field" class="${CUSTOM_INPUT}" />` +
140
- `<div data-soma-id="error" class="${HIDDEN}"></div></div></div></div>`,
141
- controllerFactory: createKitController((api) => {
385
+ `<input data-soma-id="hex" type="text" autocomplete="off" spellcheck="false" maxlength="7" ${KIT_ATTR_FACE}="field" class="${CUSTOM_INPUT}" />` +
386
+ `<div data-soma-id="error" class="${HIDDEN}"></div></div>` +
387
+ `<div data-soma-id="presets" role="listbox" aria-orientation="horizontal" class="${PRESETS}"></div></div></div>`,
388
+ controllerFactory: createKitController(() => {
142
389
  let builtKey = '';
143
390
  let chipKey: string | null = null;
144
391
  let layer: ReturnType<typeof wirePopLayer> | null = null;
145
392
  let lastEmit: string | null = null;
393
+ // 面板的 HSV 状态:以 HSV 为准(灰色 / 纯黑时色相在 hex 里丢失,需保留);外部 value 变了才从 hex 重算
394
+ let hsv: Hsv = { h: 0, s: 1, v: 1 };
395
+ let panelUi: PanelUi | null = null;
396
+ let hiddenEl: HTMLInputElement | null = null;
146
397
  return {
147
398
  attach(root, api) {
148
399
  const trigger = part(root, 'trigger');
400
+ const clearBtn = part(root, 'clear') as HTMLButtonElement;
149
401
  const panel = part(root, 'panel');
150
402
  const list = part(root, 'presets');
151
403
  const hexInput = part(root, 'hex') as HTMLInputElement;
152
404
  const errorEl = part(root, 'error');
153
405
  const errId = nextUid('kit-color-err');
154
406
  errorEl.id = errId;
407
+ clearBtn.replaceChildren(kitIcon('close', 'sm'));
155
408
  const locked = (): boolean => bool(api.props().disabled) || bool(api.props().readonly);
156
409
  const chips = (): HTMLElement[] => Array.from(list.querySelectorAll<HTMLElement>('[role="option"]'));
410
+ panelUi = buildPanelUi(root);
411
+ const ui = panelUi;
412
+ const initial = normalizeHex(api.props().value);
413
+ if (initial !== null) hsv = hexToHsv(initial);
414
+ paintPanel(ui, hsv, initial);
157
415
 
158
416
  const commit = (hex: string): void => {
159
417
  if (locked()) return;
@@ -179,6 +437,18 @@ export function createColorPicker(): SomaComponentDefinition {
179
437
  errorEl.className = HIDDEN;
180
438
  }
181
439
  };
440
+ const onClearMouseDown = (event: Event): void => {
441
+ event.preventDefault();
442
+ };
443
+ const onClearClick = (event: Event): void => {
444
+ event.stopPropagation();
445
+ if (locked() || !bool(api.props().clearable)) return;
446
+ showError(false);
447
+ hexInput.value = '';
448
+ paintPanel(ui, hsv, null);
449
+ commit('');
450
+ trigger.focus();
451
+ };
182
452
  const commitHex = (): void => {
183
453
  const raw = hexInput.value.trim();
184
454
  if (raw === '') {
@@ -240,6 +510,50 @@ export function createColorPicker(): SomaComponentDefinition {
240
510
  if (!chip || !list.contains(chip)) return;
241
511
  select(chip.dataset.key ?? '');
242
512
  };
513
+ // 平面(饱和度 × 明度)与色相条:指针拖动 + 键盘微调(平面 ±1%,色相 ±1°;Shift ×10),每次变化抛 change,面板保持展开
514
+ const commitHsv = (next: Hsv): void => {
515
+ hsv = next;
516
+ const nextHex = hsvToHex(hsv);
517
+ paintPanel(ui, hsv, nextHex);
518
+ commit(nextHex);
519
+ };
520
+ const unPlane = wireDrag(ui.plane, (event) => {
521
+ if (locked()) return;
522
+ const f = fractionIn(ui.plane, event);
523
+ commitHsv({ h: hsv.h, s: f.x, v: 1 - f.y });
524
+ });
525
+ const unHue = wireDrag(ui.hue, (event) => {
526
+ if (locked()) return;
527
+ commitHsv({ h: fractionIn(ui.hue, event).x * 360, s: hsv.s, v: hsv.v });
528
+ });
529
+ const onPlaneKey = (event: KeyboardEvent): void => {
530
+ if (locked() || event.altKey || event.ctrlKey || event.metaKey) return;
531
+ const d = event.shiftKey ? 0.1 : 0.01;
532
+ const stepPct = (x: number, delta: number): number => Math.min(1, Math.max(0, Math.round((x + delta) * 100) / 100));
533
+ if (event.key === 'ArrowLeft') commitHsv({ ...hsv, s: stepPct(hsv.s, -d) });
534
+ else if (event.key === 'ArrowRight') commitHsv({ ...hsv, s: stepPct(hsv.s, d) });
535
+ else if (event.key === 'ArrowUp') commitHsv({ ...hsv, v: stepPct(hsv.v, d) });
536
+ else if (event.key === 'ArrowDown') commitHsv({ ...hsv, v: stepPct(hsv.v, -d) });
537
+ else if (event.key === 'Home') commitHsv({ ...hsv, s: 0 });
538
+ else if (event.key === 'End') commitHsv({ ...hsv, s: 1 });
539
+ else return;
540
+ event.preventDefault();
541
+ };
542
+ const onHueKey = (event: KeyboardEvent): void => {
543
+ if (locked() || event.altKey || event.ctrlKey || event.metaKey) return;
544
+ const d = event.shiftKey ? 10 : 1;
545
+ const clamp = (x: number): number => Math.min(360, Math.max(0, x));
546
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowDown') commitHsv({ ...hsv, h: clamp(hsv.h - d) });
547
+ else if (event.key === 'ArrowRight' || event.key === 'ArrowUp') commitHsv({ ...hsv, h: clamp(hsv.h + d) });
548
+ else if (event.key === 'Home') commitHsv({ ...hsv, h: 0 });
549
+ else if (event.key === 'End') commitHsv({ ...hsv, h: 360 });
550
+ else return;
551
+ event.preventDefault();
552
+ };
553
+ clearBtn.addEventListener('mousedown', onClearMouseDown);
554
+ clearBtn.addEventListener('click', onClearClick);
555
+ ui.plane.addEventListener('keydown', onPlaneKey);
556
+ ui.hue.addEventListener('keydown', onHueKey);
243
557
  list.addEventListener('keydown', onListKey);
244
558
  list.addEventListener('click', onListClick);
245
559
  hexInput.addEventListener('keydown', onHexKey);
@@ -252,10 +566,19 @@ export function createColorPicker(): SomaComponentDefinition {
252
566
  panel,
253
567
  focusTarget: () => chips().find((c) => c.tabIndex === 0) ?? chips()[0] ?? panel,
254
568
  locked,
255
- shownClass: () => `${PANEL} start-0 top-full mt-1`,
569
+ shownClass: () => mergeClass(PANEL, popPlaceClass({ side: 'bottom', align: 'start' })),
256
570
  dropdown: { base: PANEL },
257
571
  });
258
572
  return () => {
573
+ unPlane();
574
+ unHue();
575
+ clearBtn.removeEventListener('mousedown', onClearMouseDown);
576
+ clearBtn.removeEventListener('click', onClearClick);
577
+ ui.plane.removeEventListener('keydown', onPlaneKey);
578
+ ui.hue.removeEventListener('keydown', onHueKey);
579
+ panelUi = null;
580
+ hiddenEl?.remove();
581
+ hiddenEl = null;
259
582
  list.removeEventListener('keydown', onListKey);
260
583
  list.removeEventListener('click', onListClick);
261
584
  hexInput.removeEventListener('keydown', onHexKey);
@@ -267,8 +590,9 @@ export function createColorPicker(): SomaComponentDefinition {
267
590
  chipKey = null;
268
591
  };
269
592
  },
270
- render(root, p) {
593
+ render(root, p, api) {
271
594
  const trigger = part(root, 'trigger') as HTMLButtonElement;
595
+ const clearBtn = part(root, 'clear') as HTMLButtonElement;
272
596
  const chipHost = part(root, 'chip');
273
597
  const text = part(root, 'text');
274
598
  const list = part(root, 'presets');
@@ -278,13 +602,35 @@ export function createColorPicker(): SomaComponentDefinition {
278
602
  lastEmit = null;
279
603
  const presets = presetsOf(p.presets);
280
604
  const disabled = bool(p.disabled);
605
+ const readonly = bool(p.readonly);
606
+ // 触发框高度档:自己的非缺省 size 优先,否则取页面线的 kit.controlSize(没有 kit 时与 sizeOf 相同)
607
+ const size = kitControlSizeOf(p);
608
+ kitMarkDataState(kitOuterRoot(api.host, root), readonly ? 'readonly' : 'normal');
609
+ const showClear = bool(p.clearable) && value !== null && !disabled && !readonly;
281
610
  list.setAttribute('aria-label', kitText('soma.kit.color_presets', undefined, root));
282
611
 
283
- trigger.className = TRIGGER[sizeOf(p.size)];
612
+ trigger.className = withInvalid((showClear ? TRIGGER_CLEAR : TRIGGER)[size], bool(p.invalid));
284
613
  trigger.disabled = disabled;
285
614
  applyCommon(trigger, { id: p.id, aria_label: p.aria_label });
286
- // 作表单字段:根承载字段名 / 说明 / 错误关联与无效标记(触发钮是 button,不写校验属性)
615
+ // 作表单字段:根承载字段名 / 说明 / 错误关联与无效标记;name 非空时同步维护原生 hidden input 表单载体
287
616
  applyCompositeField(root, p);
617
+ const fieldName = str(p.name);
618
+ if (fieldName !== '') {
619
+ if (hiddenEl === null) {
620
+ hiddenEl = document.createElement('input');
621
+ hiddenEl.type = 'hidden';
622
+ hiddenEl.setAttribute(KIT_ATTR_VALUE, '');
623
+ root.appendChild(hiddenEl);
624
+ }
625
+ setAttr(hiddenEl, 'name', fieldName);
626
+ hiddenEl.value = value ?? '';
627
+ hiddenEl.disabled = disabled;
628
+ } else if (hiddenEl !== null) {
629
+ hiddenEl.remove();
630
+ hiddenEl = null;
631
+ }
632
+ clearBtn.className = showClear ? CLEAR_BTN : CLEAR_HIDDEN;
633
+ clearBtn.setAttribute('aria-label', kitText('soma.kit.clear', undefined, root));
288
634
  chipHost.textContent = '';
289
635
  chipHost.appendChild(swatch(SWATCH_SVG, value));
290
636
  text.textContent = value ?? str(p.placeholder, kitText('soma.kit.pick_color', undefined, text));
@@ -299,7 +645,11 @@ export function createColorPicker(): SomaComponentDefinition {
299
645
  chip.setAttribute('role', 'option');
300
646
  chip.dataset.key = hex;
301
647
  chip.setAttribute('aria-label', hex);
302
- chip.appendChild(swatch(CHIP_SVG, hex));
648
+ chip.appendChild(presetSwatch(hex));
649
+ // 选中勾:单层色块内一枚对勾,深底白勾 / 浅底黑勾(只在选中项显示,见下方按 value 画)
650
+ const tick = kitIcon('check', 'sm', inkOnSwatchIsDark(hex) ? CHECK_DARK : CHECK_LIGHT);
651
+ tick.setAttribute(KIT_ATTR_CHIP_CHECK, '');
652
+ chip.appendChild(tick);
303
653
  list.appendChild(chip);
304
654
  }
305
655
  }
@@ -307,19 +657,41 @@ export function createColorPicker(): SomaComponentDefinition {
307
657
  for (const chip of Array.from(list.querySelectorAll<HTMLElement>('[role="option"]'))) {
308
658
  const on = chip.dataset.key === value;
309
659
  chip.className = on ? CHIP_ON : CHIP_IDLE;
660
+ const tick = chip.querySelector(`[${KIT_ATTR_CHIP_CHECK}]`);
661
+ if (tick) tick.setAttribute('class', on ? (inkOnSwatchIsDark(chip.dataset.key ?? '') ? CHECK_DARK : CHECK_LIGHT) : HIDDEN);
310
662
  chip.setAttribute('aria-selected', on ? 'true' : 'false');
663
+ // 选中的预设色块:结构性选中态自报(aria-selected 仍是读屏语义)
664
+ kitMarkInteract(chip, 'selected', on);
311
665
  chip.tabIndex = chip.dataset.key === stop ? 0 : -1;
312
666
  }
313
667
  const allowCustom = p.allow_custom !== false && p.allow_custom !== 'false';
314
668
  custom.className = allowCustom ? CUSTOM : HIDDEN;
669
+ // 平面 / 色相 / 预览只在可自定义时出现(allow_custom 假 = 只能点色板)
670
+ const ui = panelUi;
671
+ if (ui) {
672
+ // 外部 value 变了才从 hex 重算 HSV(灰色 / 纯黑保留旧色相);无值保留当前 HSV
673
+ if (value !== null && value !== hsvToHex(hsv)) {
674
+ const next = hexToHsv(value);
675
+ hsv = next.s === 0 || next.v === 0 ? { h: hsv.h, s: next.s, v: next.v } : next;
676
+ }
677
+ const sliders = part(root, 'sliders');
678
+ ui.plane.className = allowCustom ? PLANE : HIDDEN;
679
+ sliders.className = allowCustom ? SLIDER_ROW : HIDDEN;
680
+ ui.plane.setAttribute('aria-label', kitText('soma.kit.color_plane', undefined, root));
681
+ ui.hue.setAttribute('aria-label', kitText('soma.kit.color_hue', undefined, root));
682
+ const off = disabled || readonly;
683
+ ui.plane.tabIndex = off ? -1 : 0;
684
+ ui.hue.tabIndex = off ? -1 : 0;
685
+ paintPanel(ui, hsv, value);
686
+ }
315
687
  if (document.activeElement !== hexInput && hexInput.getAttribute('aria-invalid') !== 'true') hexInput.value = value ?? '';
316
688
  setAttr(hexInput, 'aria-label', 'HEX');
317
689
  hexInput.disabled = disabled;
318
- hexInput.readOnly = bool(p.readonly);
690
+ hexInput.readOnly = readonly;
319
691
  root.className = joinClass(ROOT, p.class);
320
692
  layer?.sync();
321
693
  },
322
694
  };
323
- }),
695
+ }, { self: { level: 'control' }, selfParts: [[kitSid('text'), { part: 'value' }], [kitSid('panel'), { level: 'float' }]] }), // 取色器整体(触发框)是一个输入控件
324
696
  };
325
697
  }
@@ -32,10 +32,14 @@ export function createCombobox(): SomaComponentDefinition {
32
32
  display: { type: 'string', default: '', desc: '值不在 options 里时输入框显示的文字(异步搜索后选项被换掉时用)' },
33
33
  options: { ...OPTIONS_PROP, desc: '选项 [{ value, label, disabled?, desc?, icon? }]' },
34
34
  placeholder: { type: 'string', default: '', desc: '占位文字' },
35
+ variant: { type: 'enum', values: ['outline', 'filled'], default: 'outline', desc: 'outline = 描边;filled = 浅底' },
36
+ clearable: { type: 'boolean', default: false, desc: '有值时显示清除钮;单选清为空串,多选清为 []' },
35
37
  filter: { type: 'enum', values: ['local', 'none'], default: 'local', desc: 'local = 本地按 label 过滤;none = 不过滤(服务端已过滤)' },
36
38
  allow_free: { type: 'boolean', default: false, desc: '允许自由输入:Enter / 失焦把键入文字当作值' },
37
39
  multiple: { type: 'boolean', default: false, desc: '多选:value 是数组,已选显示为标签,点选项切换、面板保持展开;输入框空时 Backspace 删最后一个标签' },
38
40
  limit_tags: { type: 'number', default: 0, desc: 'multiple 时最多显示几个标签,超出折成「+N」;0 = 全部显示' },
41
+ max_selected: { type: 'number', default: 0, desc: 'multiple 时最多可选几项:到达后未选项置灰(aria-disabled)且不可再选,面板尾显示 max_text;0 = 不限' },
42
+ max_text: { type: 'string', default: '', desc: '到达 max_selected 时面板尾的提示文字;缺省显示「已选/上限」' },
39
43
  group: { type: 'string', default: '', desc: '选项里承载分组标题的字段名(如 region);同标题归一组,组标题粘顶' },
40
44
  loading: { type: 'boolean', default: false, desc: '加载中:面板显示加载行' },
41
45
  loading_text: { type: 'string', default: '', desc: '加载行文字' },
@@ -57,7 +61,7 @@ export function createCombobox(): SomaComponentDefinition {
57
61
  },
58
62
  },
59
63
  services: ['engines'],
60
- templateHtml: '<div data-soma-id="root" class="relative block w-full"></div>',
61
- controllerFactory: createKitController(createListboxView('combobox')),
64
+ templateHtml: '<div data-soma-id="root" class="relative block w-full min-w-0"></div>',
65
+ controllerFactory: createKitController(createListboxView('combobox'), { self: { level: 'control' } }),
62
66
  };
63
67
  }