soma-kit 0.1.14 → 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 (505) 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/finance/reconcile-desk/compile.ts +1 -1
  5. package/packs/finance/reconcile-desk/shell.ts +1 -1
  6. package/packs/ops/error-budget-card.ts +3 -3
  7. package/packs/ops/release-readiness-card.ts +3 -3
  8. package/packs/security/control-evidence-card.ts +3 -3
  9. package/packs/security/finding-card.ts +3 -2
  10. package/packs/shared/card-util.ts +17 -0
  11. package/spec/generated/kit-app.schema.json +2148 -338
  12. package/spec/generated/kit-page.schema.json +1152 -87
  13. package/spec/kit-grammar.json +1084 -136
  14. package/spec/kit-grammar.schema.json +167 -26
  15. package/src/app/app-config.ts +220 -187
  16. package/src/app/component-gate.ts +2 -2
  17. package/src/app/compose-apps.ts +5 -2
  18. package/src/app/define-kit-actions.ts +200 -22
  19. package/src/app/define-kit-app.ts +54 -8
  20. package/src/app/define-kit-view.ts +1 -1
  21. package/src/app/index.ts +12 -7
  22. package/src/app/kit-view-context.ts +50 -3
  23. package/src/app/list-page-defaults.ts +14 -0
  24. package/src/app/server-pages.ts +239 -7
  25. package/src/app/server.ts +466 -25
  26. package/src/app/theme-endpoint.ts +68 -24
  27. package/src/app/theme-runtime.ts +421 -87
  28. package/src/app/theme-shards.ts +69 -0
  29. package/src/app/tier-compat.ts +107 -0
  30. package/src/base/action-busy.ts +215 -38
  31. package/src/base/affix.ts +137 -0
  32. package/src/base/alert.ts +107 -59
  33. package/src/base/anchored-layer.ts +8 -7
  34. package/src/base/avatar.ts +147 -61
  35. package/src/base/badge.ts +186 -0
  36. package/src/base/button-group.ts +227 -0
  37. package/src/base/button.ts +365 -53
  38. package/src/base/card.ts +233 -0
  39. package/src/base/cascader.ts +147 -32
  40. package/src/base/check-core.ts +196 -33
  41. package/src/base/checkbox.ts +67 -2
  42. package/src/base/choice.ts +132 -31
  43. package/src/base/collapse.ts +249 -0
  44. package/src/base/color-picker.ts +404 -28
  45. package/src/base/combobox.ts +6 -2
  46. package/src/base/command-palette.ts +155 -37
  47. package/src/base/context-menu.ts +26 -6
  48. package/src/base/countdown.ts +37 -15
  49. package/src/base/date-range.ts +115 -94
  50. package/src/base/date.ts +487 -76
  51. package/src/base/delta.ts +20 -11
  52. package/src/base/divider.ts +64 -97
  53. package/src/base/end-edge.ts +10 -4
  54. package/src/base/fab.ts +64 -23
  55. package/src/base/gap-value.ts +35 -16
  56. package/src/base/hint-tips.ts +100 -30
  57. package/src/base/identity-cells.ts +839 -0
  58. package/src/base/illustrations.ts +6 -4
  59. package/src/base/image.ts +40 -19
  60. package/src/base/index.ts +92 -24
  61. package/src/base/inline-error.ts +90 -0
  62. package/src/base/input.ts +174 -38
  63. package/src/base/kbd.ts +31 -17
  64. package/src/base/kit-contract.ts +400 -0
  65. package/src/base/link.ts +41 -20
  66. package/src/base/listbox-core.ts +324 -95
  67. package/src/base/loading-gate.ts +3 -0
  68. package/src/base/look.ts +197 -0
  69. package/src/base/mentions.ts +58 -22
  70. package/src/base/menu-button.ts +129 -42
  71. package/src/base/menu-core.ts +210 -26
  72. package/src/base/month-grid.ts +60 -3
  73. package/src/base/motion/aura.ts +52 -10
  74. package/src/base/motion/hover-3d.ts +10 -5
  75. package/src/base/motion/hover-gallery.ts +19 -12
  76. package/src/base/motion/limits.ts +10 -0
  77. package/src/base/motion/marquee.ts +18 -11
  78. package/src/base/motion/text-rotate.ts +34 -16
  79. package/src/base/notification.ts +292 -0
  80. package/src/base/number.ts +93 -12
  81. package/src/base/otp.ts +143 -27
  82. package/src/base/overlay-runtime.ts +32 -24
  83. package/src/base/overlay-shell.ts +186 -0
  84. package/src/base/period-picker.ts +868 -0
  85. package/src/base/popover.ts +625 -74
  86. package/src/base/popup.ts +219 -78
  87. package/src/base/portal-core.ts +99 -2
  88. package/src/base/price-text.ts +51 -17
  89. package/src/base/progress.ts +100 -18
  90. package/src/base/qr-code.ts +64 -17
  91. package/src/base/qty-stepper.ts +145 -21
  92. package/src/base/radio.ts +43 -2
  93. package/src/base/range.ts +194 -39
  94. package/src/base/rating.ts +117 -31
  95. package/src/base/reason-tip.ts +60 -18
  96. package/src/base/relation-cells.ts +541 -0
  97. package/src/{frames → base}/resize-handle.ts +6 -4
  98. package/src/base/row-fresh.ts +84 -0
  99. package/src/base/section-spy.ts +79 -0
  100. package/src/base/segmented.ts +99 -56
  101. package/src/base/select.ts +8 -2
  102. package/src/base/shared.ts +520 -73
  103. package/src/base/spinner.ts +107 -0
  104. package/src/base/state-panel.ts +77 -22
  105. package/src/base/status-tone.ts +1 -1
  106. package/src/base/sticky-edge.ts +96 -29
  107. package/src/base/swap.ts +39 -21
  108. package/src/base/switch.ts +158 -38
  109. package/src/base/tabs.ts +292 -0
  110. package/src/base/tag-input.ts +129 -55
  111. package/src/base/tag.ts +203 -91
  112. package/src/base/text.ts +491 -77
  113. package/src/base/textarea.ts +89 -40
  114. package/src/base/time-picker.ts +341 -57
  115. package/src/base/time-range.ts +846 -0
  116. package/src/base/tree-select.ts +346 -89
  117. package/src/base/upload.ts +612 -158
  118. package/src/base/view-transition.ts +7 -3
  119. package/src/base/virtual-list.ts +49 -14
  120. package/src/biz/approval-desk/compile.ts +98 -6
  121. package/src/biz/approval-desk/index.ts +2 -0
  122. package/src/biz/approval-desk/shell.ts +53 -13
  123. package/src/biz/auth-panel/compile.ts +14 -4
  124. package/src/biz/auth-panel/shell.ts +28 -8
  125. package/src/biz/category-crud/compile.ts +64 -13
  126. package/src/biz/category-crud/index.ts +2 -0
  127. package/src/biz/category-crud/shell.ts +30 -8
  128. package/src/biz/checkout-page/compile.ts +38 -4
  129. package/src/biz/checkout-page/index.ts +1 -0
  130. package/src/biz/checkout-page/shell.ts +28 -10
  131. package/src/biz/compose.ts +9 -4
  132. package/src/biz/data-components.ts +2 -0
  133. package/src/biz/define.ts +1 -1
  134. package/src/biz/import-wizard/compile.ts +5 -2
  135. package/src/biz/import-wizard/index.ts +1 -0
  136. package/src/biz/import-wizard/shell.ts +36 -20
  137. package/src/biz/index.ts +5 -4
  138. package/src/biz/landing-page/compile.ts +4 -3
  139. package/src/biz/landing-page/shell.ts +25 -5
  140. package/src/biz/layout-contracts.ts +918 -0
  141. package/src/biz/link/hub.ts +199 -8
  142. package/src/biz/link/shared.ts +62 -16
  143. package/src/biz/master-sub/compile.ts +318 -38
  144. package/src/biz/master-sub/detail-head.ts +145 -21
  145. package/src/biz/master-sub/index.ts +6 -3
  146. package/src/biz/master-sub/shell.ts +232 -66
  147. package/src/biz/multi-board/compile.ts +89 -38
  148. package/src/biz/multi-board/composition.ts +7 -20
  149. package/src/biz/multi-board/index.ts +25 -9
  150. package/src/biz/multi-board/prose-fold.ts +17 -13
  151. package/src/biz/multi-board/shell.ts +153 -38
  152. package/src/biz/names.ts +1 -0
  153. package/src/biz/notification-center/compile.ts +28 -7
  154. package/src/biz/notification-center/index.ts +2 -0
  155. package/src/biz/notification-center/shell.ts +51 -11
  156. package/src/biz/page-templates/domain-templates.ts +147 -20
  157. package/src/biz/page-templates/result-page/compile.ts +5 -2
  158. package/src/biz/page-templates/result-page/index.ts +1 -0
  159. package/src/biz/page-templates/result-page/shell.ts +20 -6
  160. package/src/biz/page-templates/shared.ts +1 -1
  161. package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
  162. package/src/biz/page-templates/sign-in-page/index.ts +1 -0
  163. package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
  164. package/src/biz/record-detail/compile.ts +43 -12
  165. package/src/biz/record-detail/index.ts +1 -0
  166. package/src/biz/record-detail/shell.ts +42 -11
  167. package/src/biz/settings-center/compile.ts +5 -2
  168. package/src/biz/settings-center/index.ts +1 -0
  169. package/src/biz/settings-center/shell.ts +33 -9
  170. package/src/biz/shared/action-host.ts +146 -48
  171. package/src/biz/shared/compile-helpers.ts +134 -32
  172. package/src/biz/shared/coordinator.ts +727 -163
  173. package/src/biz/shared/focus-return.ts +180 -0
  174. package/src/biz/shared/object-aliases.ts +7 -1
  175. package/src/biz/shared/overlay-compile.ts +102 -24
  176. package/src/biz/shared/overlay-shell.ts +97 -116
  177. package/src/biz/shared/page-form-actions.ts +151 -0
  178. package/src/biz/shared/page-form.ts +255 -0
  179. package/src/biz/shared/pipeline.ts +74 -0
  180. package/src/biz/shared/runtime-hub.ts +101 -8
  181. package/src/biz/shared/verbs.ts +129 -0
  182. package/src/biz/single-form/compile.ts +6 -4
  183. package/src/biz/single-form/index.ts +2 -0
  184. package/src/biz/single-form/shell.ts +22 -8
  185. package/src/biz/standard-crud/compile.ts +213 -38
  186. package/src/biz/standard-crud/index.ts +2 -1
  187. package/src/biz/standard-crud/shell.ts +90 -13
  188. package/src/biz/standard-crud/summary.ts +2 -35
  189. package/src/biz/step-form/compile.ts +13 -4
  190. package/src/biz/step-form/hub.ts +168 -49
  191. package/src/biz/step-form/index.ts +1 -0
  192. package/src/biz/step-form/shell.ts +35 -17
  193. package/src/biz/types.ts +49 -6
  194. package/src/cli/app-layer-check.ts +375 -0
  195. package/src/cli/kit-cli.ts +179 -33
  196. package/src/cli/kit-init.ts +152 -3
  197. package/src/cli/migrate/theme-map.ts +35 -28
  198. package/src/cli/migrate/ts-rules.ts +2 -2
  199. package/src/cli/migrate/types.ts +3 -3
  200. package/src/cli/migrate/yaml-rules.ts +11 -9
  201. package/src/cli/view-writes.ts +13 -0
  202. package/src/compile/access-gate-attach.ts +1 -1
  203. package/src/compile/action-host-attach.ts +1 -1
  204. package/src/compile/closed-set.ts +102 -6
  205. package/src/compile/compile-page.ts +461 -273
  206. package/src/compile/component-candidates.ts +58 -5
  207. package/src/compile/danger-tier.ts +65 -0
  208. package/src/compile/hints.ts +6 -59
  209. package/src/compile/index.ts +2 -2
  210. package/src/compile/info-structure.ts +155 -0
  211. package/src/compile/layout-lint/index.ts +4 -1
  212. package/src/compile/layout-lint/rules-composition.ts +44 -13
  213. package/src/compile/layout-lint/rules-table.ts +4 -19
  214. package/src/compile/look-page.ts +551 -0
  215. package/src/compile/look.ts +376 -0
  216. package/src/compile/page-composition.ts +405 -67
  217. package/src/compile/page-hierarchy.ts +131 -0
  218. package/src/compile/page-pipeline-look.ts +156 -0
  219. package/src/compile/page-pipeline.ts +200 -0
  220. package/src/compile/parse.ts +12 -11
  221. package/src/compile/redirect.ts +1 -1
  222. package/src/compile/relation-render.ts +120 -0
  223. package/src/compile/remove-guard.ts +115 -41
  224. package/src/compile/stages.ts +786 -0
  225. package/src/compile/styles.ts +286 -48
  226. package/src/compile/types.ts +63 -6
  227. package/src/compile/view-check.ts +190 -1
  228. package/src/data/access-gate.ts +17 -9
  229. package/src/data/amount-breakdown.ts +52 -23
  230. package/src/data/anchor-nav.ts +77 -16
  231. package/src/data/approval-flow.ts +217 -126
  232. package/src/data/assignment-picker.ts +182 -94
  233. package/src/data/async-result-panel.ts +114 -46
  234. package/src/data/audit-log.ts +461 -0
  235. package/src/data/breadcrumbs.ts +150 -24
  236. package/src/data/calendar.ts +436 -97
  237. package/src/data/card-grid.ts +319 -0
  238. package/src/data/carousel.ts +81 -41
  239. package/src/data/cell-value.ts +253 -0
  240. package/src/data/chart.ts +1053 -96
  241. package/src/data/checklist.ts +82 -38
  242. package/src/data/code-view.ts +296 -44
  243. package/src/data/comment-thread.ts +611 -86
  244. package/src/data/compare-view.ts +227 -0
  245. package/src/data/confirm-dialog.ts +250 -39
  246. package/src/data/context-menu.ts +95 -21
  247. package/src/data/d9-limits.ts +2 -0
  248. package/src/data/d9-util.ts +13 -5
  249. package/src/data/diff.ts +109 -49
  250. package/src/data/display-util.ts +9 -4
  251. package/src/data/dock.ts +38 -18
  252. package/src/data/embed.ts +143 -8
  253. package/src/data/engine-ports.ts +135 -0
  254. package/src/data/field-mapper.ts +116 -54
  255. package/src/data/file-list.ts +522 -0
  256. package/src/data/flow-editor.ts +695 -158
  257. package/src/data/flow-node-options.ts +24 -5
  258. package/src/data/flow-remote-options.ts +94 -19
  259. package/src/data/footer.ts +88 -26
  260. package/src/data/form-draft-registry.ts +183 -12
  261. package/src/data/gantt.ts +640 -117
  262. package/src/data/graph-view.ts +51 -0
  263. package/src/data/heat-calendar.ts +412 -0
  264. package/src/data/hero.ts +40 -13
  265. package/src/data/image-viewer.ts +265 -62
  266. package/src/data/index.ts +75 -6
  267. package/src/data/item-list.ts +219 -58
  268. package/src/data/json-view.ts +909 -0
  269. package/src/data/kanban.ts +346 -91
  270. package/src/data/kit-contract.ts +230 -0
  271. package/src/data/leaderboard.ts +343 -0
  272. package/src/data/level-class.ts +21 -0
  273. package/src/data/log-stream.ts +347 -0
  274. package/src/data/markdown-view.ts +597 -0
  275. package/src/data/matrix.ts +234 -120
  276. package/src/data/media-grid.ts +165 -38
  277. package/src/data/mega-menu.ts +43 -26
  278. package/src/data/menu-bar.ts +254 -0
  279. package/src/data/menu-dom.ts +55 -19
  280. package/src/data/menu.ts +138 -48
  281. package/src/data/mockup.ts +37 -25
  282. package/src/data/modal-dialog.ts +126 -98
  283. package/src/data/navbar.ts +152 -66
  284. package/src/data/notice-list.ts +101 -49
  285. package/src/data/notify-renderer.ts +80 -15
  286. package/src/data/object-form.ts +1504 -164
  287. package/src/data/org-chart.ts +544 -0
  288. package/src/data/outcome-watch.ts +90 -21
  289. package/src/data/pager.ts +129 -45
  290. package/src/data/panel-head.ts +238 -76
  291. package/src/data/permission-matrix.ts +379 -120
  292. package/src/data/permission-tree.ts +146 -78
  293. package/src/data/pricing-table.ts +112 -43
  294. package/src/data/prompt-dialog.ts +49 -21
  295. package/src/data/reaction-bar.ts +67 -32
  296. package/src/data/record-card.ts +245 -72
  297. package/src/data/record-picker.ts +61 -28
  298. package/src/data/redirect.ts +39 -15
  299. package/src/data/request-console.ts +141 -38
  300. package/src/data/resident.ts +11 -13
  301. package/src/data/result-panel.ts +65 -27
  302. package/src/data/rich-text.ts +260 -127
  303. package/src/data/row-confirm.ts +47 -0
  304. package/src/data/row-editor.ts +384 -105
  305. package/src/data/rule-builder.ts +136 -81
  306. package/src/data/schedule-grid.ts +238 -0
  307. package/src/data/segment-bar.ts +221 -0
  308. package/src/data/shape-util.ts +90 -36
  309. package/src/data/stage-flow.ts +244 -0
  310. package/src/data/staged-rows.ts +207 -24
  311. package/src/data/stat-group.ts +493 -100
  312. package/src/data/static-lazy.ts +21 -0
  313. package/src/data/static-registry.ts +46 -4
  314. package/src/data/status-strip.ts +171 -0
  315. package/src/data/steps.ts +69 -36
  316. package/src/data/summary-strip.ts +136 -0
  317. package/src/data/summary-util.ts +116 -0
  318. package/src/data/survey.ts +134 -47
  319. package/src/data/system-switcher.ts +53 -24
  320. package/src/data/target-progress.ts +208 -0
  321. package/src/data/text-action-button.ts +28 -7
  322. package/src/data/text-diff.ts +731 -0
  323. package/src/data/tile-grid.ts +343 -0
  324. package/src/data/timeline.ts +205 -36
  325. package/src/data/tour-guide.ts +113 -47
  326. package/src/data/transfer.ts +204 -47
  327. package/src/data/tree-table.ts +228 -81
  328. package/src/data/tree.ts +193 -69
  329. package/src/data/trend-line.ts +68 -12
  330. package/src/data/virtual-rows.ts +248 -98
  331. package/src/data/waterfall.ts +171 -0
  332. package/src/data/watermark.ts +35 -6
  333. package/src/data/wrap.ts +28 -6
  334. package/src/frames/blank-frame.ts +6 -4
  335. package/src/frames/index.ts +4 -4
  336. package/src/frames/inherited-shell.ts +219 -0
  337. package/src/frames/page-bar.ts +208 -28
  338. package/src/frames/page-status.ts +3 -2
  339. package/src/frames/resident-components.ts +18 -0
  340. package/src/frames/shared.ts +73 -26
  341. package/src/frames/single-frame.ts +20 -4
  342. package/src/frames/split-frame/shell.ts +27 -17
  343. package/src/frames/split-frame/wiring.ts +16 -12
  344. package/src/frames/tabs-frame/shell.ts +14 -7
  345. package/src/frames/tabs-frame/wiring.ts +2 -1
  346. package/src/frames/top-main-frame.ts +55 -3
  347. package/src/frames/types.ts +5 -2
  348. package/src/frames/workspace-frame/extras.ts +23 -7
  349. package/src/frames/workspace-frame/index.ts +1 -1
  350. package/src/frames/workspace-frame/pipeline-key.ts +6 -0
  351. package/src/frames/workspace-frame/shell.ts +24 -3
  352. package/src/frames/workspace-frame/state.ts +42 -8
  353. package/src/frames/workspace-frame/view.ts +773 -194
  354. package/src/generated/kit-grammar-runtime.ts +1061 -77
  355. package/src/generated/kit-page.ts +272 -0
  356. package/src/i18n/index.ts +2 -0
  357. package/src/i18n/kit-text.ts +210 -5
  358. package/src/i18n/resolve-text-refs.ts +1 -1
  359. package/src/object-renderer/action-group.ts +204 -22
  360. package/src/object-renderer/action-more.ts +66 -19
  361. package/src/object-renderer/arrange.ts +270 -28
  362. package/src/object-renderer/category-tone.ts +96 -0
  363. package/src/object-renderer/collapse-wiring.ts +19 -9
  364. package/src/object-renderer/collection-expand.ts +3 -3
  365. package/src/object-renderer/collection-parts.ts +459 -103
  366. package/src/object-renderer/collection-table.ts +406 -59
  367. package/src/object-renderer/collection.ts +333 -71
  368. package/src/object-renderer/compile-data.ts +13 -3
  369. package/src/object-renderer/defaults.ts +14 -5
  370. package/src/object-renderer/emit-events.ts +46 -20
  371. package/src/object-renderer/emit-object.ts +35 -6
  372. package/src/object-renderer/emit-static.ts +831 -153
  373. package/src/object-renderer/field-value.ts +12 -239
  374. package/src/object-renderer/filter-plan.ts +3 -3
  375. package/src/object-renderer/filter-toolbar.ts +190 -0
  376. package/src/object-renderer/form-detail.ts +87 -2
  377. package/src/{compile → object-renderer}/fragment.ts +2 -2
  378. package/src/object-renderer/index.ts +1 -1
  379. package/src/object-renderer/key-field.ts +21 -0
  380. package/src/object-renderer/layout-facts.ts +55 -7
  381. package/src/object-renderer/layout-plan.ts +6 -3
  382. package/src/object-renderer/overlay-decide.ts +124 -0
  383. package/src/object-renderer/pick-component.ts +8 -2
  384. package/src/object-renderer/pipeline-mode.ts +6 -0
  385. package/src/object-renderer/relation-field.ts +79 -0
  386. package/src/object-renderer/render-object.ts +72 -27
  387. package/src/object-renderer/request-actions.ts +119 -21
  388. package/src/object-renderer/table-actions.ts +479 -111
  389. package/src/object-renderer/table-gap.ts +2 -1
  390. package/src/object-renderer/table-reorder.ts +237 -0
  391. package/src/object-renderer/table-summary.ts +26 -12
  392. package/src/object-renderer/table-tools.ts +437 -130
  393. package/src/object-renderer/types.ts +100 -17
  394. package/src/object-renderer/value-present.ts +49 -0
  395. package/src/page-target/ai-surface.ts +15 -22
  396. package/src/page-target/compile.ts +5 -6
  397. package/src/page-target/drift.ts +0 -7
  398. package/src/page-target/intent-schema.ts +46 -43
  399. package/src/page-target/target.ts +4 -5
  400. package/src/page-target/writer-policy.ts +4 -5
  401. package/src/recipes/app-blocks.ts +66 -0
  402. package/src/recipes/chrome-surface.ts +20 -0
  403. package/src/recipes/code-view.ts +57 -0
  404. package/src/recipes/color-role.ts +442 -0
  405. package/src/recipes/compact-group.ts +32 -0
  406. package/src/recipes/composition-projector.ts +321 -0
  407. package/src/recipes/container.ts +93 -26
  408. package/src/recipes/control.ts +85 -8
  409. package/src/recipes/desc-list.ts +108 -0
  410. package/src/recipes/divider.ts +74 -0
  411. package/src/recipes/emphasis.ts +102 -13
  412. package/src/recipes/field-text.ts +72 -0
  413. package/src/recipes/form-section.ts +177 -0
  414. package/src/recipes/frame-bleed.ts +6 -5
  415. package/src/recipes/index.ts +39 -5
  416. package/src/recipes/inherited-shell.ts +43 -0
  417. package/src/recipes/json-view.ts +50 -0
  418. package/src/recipes/look.ts +56 -0
  419. package/src/recipes/mark.ts +138 -0
  420. package/src/recipes/markdown.ts +96 -0
  421. package/src/recipes/overlay.ts +151 -37
  422. package/src/recipes/page-width.ts +51 -0
  423. package/src/recipes/pipeline-runtime.ts +366 -0
  424. package/src/recipes/placeholder.ts +38 -20
  425. package/src/recipes/rail-grid.ts +6 -3
  426. package/src/recipes/self-owned.ts +59 -0
  427. package/src/recipes/slot-align.ts +5 -3
  428. package/src/recipes/stat-state.ts +6 -6
  429. package/src/recipes/state.ts +64 -11
  430. package/src/recipes/status.ts +21 -20
  431. package/src/recipes/strip.ts +114 -0
  432. package/src/recipes/surface-edge.ts +3 -1
  433. package/src/recipes/surface.ts +40 -7
  434. package/src/recipes/table-gap.ts +4 -3
  435. package/src/recipes/table-native-edit.ts +25 -12
  436. package/src/recipes/table-row.ts +56 -20
  437. package/src/recipes/tabs.ts +140 -31
  438. package/src/recipes/text-diff.ts +97 -0
  439. package/src/recipes/text-fit.ts +132 -0
  440. package/src/recipes/title-row.ts +72 -5
  441. package/src/recipes/typography.ts +2 -2
  442. package/src/shared/action-func.ts +106 -0
  443. package/src/shared/color-scheme.ts +127 -0
  444. package/src/shared/confirm-decl.ts +5 -2
  445. package/src/shared/danger-facts.ts +55 -0
  446. package/src/shared/diagnostics.ts +16 -0
  447. package/src/shared/dom-attrs-registry.ts +1009 -0
  448. package/src/shared/dom-attrs.ts +743 -0
  449. package/src/shared/envelope.ts +1 -1
  450. package/src/shared/field-kind.ts +49 -0
  451. package/src/shared/field-value-format.ts +292 -0
  452. package/src/shared/focus-ring.ts +8 -0
  453. package/src/shared/glyphs.ts +127 -0
  454. package/src/shared/hints.ts +56 -0
  455. package/src/{base → shared}/icons.ts +40 -1
  456. package/src/shared/identifier-field.ts +66 -0
  457. package/src/shared/kit-error.ts +1 -1
  458. package/src/shared/list-pager.ts +23 -0
  459. package/src/shared/list-title.ts +29 -0
  460. package/src/{object-renderer → shared}/merge-class.ts +3 -2
  461. package/src/shared/order-value.ts +15 -0
  462. package/src/shared/page-attrs-runtime.ts +327 -0
  463. package/src/shared/page-attrs.ts +262 -0
  464. package/src/shared/path-guard.ts +1 -1
  465. package/src/shared/pipeline-mode.ts +64 -0
  466. package/src/shared/primitives-types.ts +8 -0
  467. package/src/shared/row-key.ts +15 -0
  468. package/src/shared/theme-runtime-shared.ts +181 -21
  469. package/src/shared/theme-usage.ts +16 -0
  470. package/src/shared/value-table-contract.ts +68 -0
  471. package/src/spatial/action-func.ts +4 -0
  472. package/src/spatial/declared-actions.ts +116 -0
  473. package/src/spatial/emit.ts +660 -0
  474. package/src/spatial/expand.ts +1482 -0
  475. package/src/spatial/field-types.ts +48 -0
  476. package/src/spatial/index.ts +82 -0
  477. package/src/spatial/layout.ts +697 -0
  478. package/src/spatial/look-apply.ts +206 -0
  479. package/src/spatial/page-decl.ts +44 -0
  480. package/src/spatial/page-object.ts +349 -0
  481. package/src/spatial/recognize.ts +491 -0
  482. package/src/spatial/self-report.ts +571 -0
  483. package/src/spatial/shape.ts +205 -0
  484. package/src/spatial/spatial-map.ts +136 -0
  485. package/src/spatial/tone.ts +145 -0
  486. package/src/theme/index.ts +11 -2
  487. package/src/theme/kit-theme-text.ts +1 -1
  488. package/src/theme/kit-theme.css +563 -28
  489. package/src/theme/kit-theme.tpl +527 -28
  490. package/src/theme/look-carrier.ts +65 -0
  491. package/src/theme/nine-dim-structure.ts +538 -176
  492. package/src/theme/private-vars.ts +153 -0
  493. package/src/theme/surface-layers.ts +12 -3
  494. package/src/theme/theme-tokens.ts +1602 -90
  495. package/src/theme/theme-types.ts +38 -59
  496. package/src/theme/value-table.ts +2379 -0
  497. package/src/app/envelope.ts +0 -1
  498. package/src/app/notify-renderer.ts +0 -1
  499. package/src/app/paged-list-adapter.ts +0 -1
  500. package/src/app/theme-runtime-shared.ts +0 -1
  501. package/src/compile/kit-error.ts +0 -1
  502. package/src/frames/list-summary.ts +0 -100
  503. package/src/recipes/nowrap.ts +0 -16
  504. package/src/theme/block-theme.ts +0 -202
  505. /package/src/{base → shared}/class-candidates.ts +0 -0
@@ -0,0 +1,51 @@
1
+ // GraphView:拓扑 / 依赖图(layer: data,写死形状,accept: single)。只读:服务依赖、资源拓扑、任务依赖等节点连线图。
2
+ //
3
+ // 不另起一套画布:复用 FlowEditor 的只读渲染内核(节点 HTML + SVG 连线、分层布局 layered、缩放平移、拾取与无障碍邻接摘要表),
4
+ // 但拥有独立的只读契约(仅暴露只读属性与 node_pick / edge_pick / retry 只读事件,不含任何写事件或表单校验属性)。
5
+ // 要编辑请用 FlowEditor。
6
+
7
+ import type { SomaComponentDefinition } from 'soma-core';
8
+ import { createFlowEditor, KIT_FLOW_EDITOR_CLASS_CANDIDATES } from './flow-editor';
9
+
10
+ export const KIT_GRAPH_VIEW_CLASS_CANDIDATES: readonly string[] = KIT_FLOW_EDITOR_CLASS_CANDIDATES;
11
+
12
+ export const GRAPH_VIEW_CONTRACT = {
13
+ name: 'GraphView',
14
+ layer: 'data',
15
+ props: {
16
+ data: { type: 'object', default: {}, desc: '{ nodes: [{ id, type, label, x?, y?, status?, meta? }], edges: [{ id, from, to, label? }], config? }' },
17
+ nodeTypes: { type: 'object', default: {}, desc: '节点类型表 { 类型: { label, icon, tone, numbered?, fields? } }' },
18
+ layout: { type: 'string', default: 'layered', desc: '布局:layered = 自动分层(缺省,页面不给坐标);manual = 按节点自带坐标' },
19
+ direction: { type: 'string', default: 'LR', desc: '分层布局方向:LR(从左到右,缺省)或 TB(从上到下)' },
20
+ numbered: { type: 'boolean', default: false, desc: '按拓扑层序自动为节点编号(1, 2, 3…)' },
21
+ fit: { type: 'boolean', default: true, desc: '挂载或尺寸变化时自动居中适应画布视口' },
22
+ zoomable: { type: 'boolean', default: true, desc: '允许缩放画布' },
23
+ pannable: { type: 'boolean', default: true, desc: '允许平移画布' },
24
+ readonly: { type: 'boolean', default: true, desc: '只读图谱(GraphView 恒为只读)' },
25
+ statusTones: { type: 'object', default: {}, desc: '节点状态值 -> 语气(neutral / info / success / warning / danger / primary)' },
26
+ texts: { type: 'object', default: {}, desc: '文案覆盖' },
27
+ empty_text: { type: 'string', default: '', desc: '无节点时的空态文案' },
28
+ loading: { type: 'boolean', default: false, desc: '加载中' },
29
+ error: { type: 'string', default: '', desc: '出错态文案(同 error_text)' },
30
+ error_text: { type: 'string', default: '', desc: '出错态文案;非空时显示错误提示与重试按钮' },
31
+ retry_text: { type: 'string', default: '', desc: '出错态重试按钮文案' },
32
+ id: { type: 'string', default: '', desc: '根节点 id' },
33
+ labelledby: { type: 'string', default: '', desc: '可见标签元素 id' },
34
+ describedby: { type: 'string', default: '', desc: '关联说明元素 id' },
35
+ aria_describedby: { type: 'string', default: '', desc: '同 describedby' },
36
+ class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
37
+ },
38
+ emits: {
39
+ node_pick: { payload: { id: { type: 'string' }, node: { type: 'object' } }, desc: '点击或回车激活某个节点' },
40
+ edge_pick: { payload: { id: { type: 'string' }, edge: { type: 'object' } }, desc: '点击或回车激活某条连线' },
41
+ retry: { payload: {}, desc: '出错态下点击重试' },
42
+ },
43
+ } as unknown as SomaComponentDefinition['contract'];
44
+
45
+ export function createGraphView(): SomaComponentDefinition {
46
+ const base = createFlowEditor({ graphView: true });
47
+ return {
48
+ ...base,
49
+ contract: GRAPH_VIEW_CONTRACT,
50
+ };
51
+ }
@@ -0,0 +1,412 @@
1
+ // HeatCalendar:热力日历(layer: data,写死形状,accept: list)。年度贡献式:一年 53 列 x 7 行,格子颜色按当日数值分五档。
2
+ //
3
+ // 抄自 GitHub 贡献图的通行写法与 react-activity-calendar(MIT):列 = 周,行 = 星期,顶部月份标、左侧隔行星期标、
4
+ // 底部「少 ▢▢▢▢▢ 多」图例;档位 = 0 为空格,其余按 ceil(值 / 最大值 x 4) 分 1-4 档(最大值可由 `max` 固定,便于多图同标尺)。
5
+ // 数据:`data` 是 [{ date, count }](同一天多条累加),键名可由 `map` 改写;区间:给 `year` 取该自然年,否则取以 `end`(缺省数据里最晚一天)结尾的 53 周。
6
+ // 民用日算术全走 base/month-grid(UTC 零点,不受本地时区影响)。`selectable` 为真时每格是按钮,点击抛 `select { date, count }`。组件只展示。
7
+
8
+ import type { SomaComponentDefinition } from 'soma-core';
9
+ import { kitMarkDataFacts, kitMarkPart } from './kit-contract';
10
+ import { KIT_ATTR_COUNT, KIT_ATTR_DATE, KIT_ATTR_HEAT_LEVEL, KIT_ATTR_POS, kitAttrSel } from '../shared/dom-attrs';
11
+ import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
12
+ import { KIT_FOCUS_RING } from '../recipes/state';
13
+ import { kitWellRecipe } from '../recipes/surface';
14
+ import { mergeClass } from '../shared/merge-class';
15
+ import { isDarkColorScheme, unwrapLightDark } from '../shared/color-scheme';
16
+ import { KIT_THEME_APPLIED_EVENT } from '../shared/theme-runtime-shared';
17
+ import { bool, createKitController, formatValue, joinClass, num, str } from '../base/shared';
18
+ import { KIT_APP_TOOLTIP_CLASS_CANDIDATES, kitTooltip, releaseReasonTipsIn } from '../base/reason-tip';
19
+ import { kitKey, kitText } from '../i18n/kit-text';
20
+ import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
21
+ import { classTokens, emptyNode, keyMap, mk, rowsOf } from './shape-util';
22
+ import { dayNumOf, textOfDayNum, weekStartOf, weekdayName, ymdOfDayNum } from './d9-util';
23
+ import { weekStartProp } from '../base/month-grid';
24
+
25
+ export const KIT_HEAT_CALENDAR_DEFAULT_MAP = Object.freeze({ date: 'date', count: 'count' });
26
+
27
+ // 数字真源:soma-design kit-limits#staticComponents.display.HeatCalendar(生成后经 foundation 投影)
28
+ const { weeks: WEEK_COUNT, weekDays: WEEK_DAYS, levelMax: LEVEL_MAX } = KIT_STATIC_COMPONENT_LIMITS.display.HeatCalendar;
29
+
30
+ const ROOT_CLASS = 'flex w-fit max-w-full flex-col gap-2 overflow-x-auto text-xs text-fg-muted';
31
+ const FRAME_CLASS = 'flex gap-2';
32
+ const WEEKDAYS_CLASS = 'flex flex-col gap-1 pt-4';
33
+ const WEEKDAY_CLASS = 'h-3 whitespace-nowrap leading-none';
34
+ const MAIN_CLASS = 'flex flex-col gap-1';
35
+ const MONTHS_CLASS = 'flex h-3 gap-1';
36
+ const MONTH_SLOT_CLASS = 'w-3 shrink-0 overflow-visible whitespace-nowrap leading-none';
37
+ const WEEKS_CLASS = 'flex gap-1';
38
+ const WEEK_CLASS = 'flex flex-col gap-1';
39
+ const CELL_BASE = 'size-3 shrink-0 rounded-item';
40
+ const CELL_SVG_CLASS = mergeClass(CELL_BASE, 'pointer-events-none block');
41
+ const CELL_BUTTON = 'cursor-pointer transition-colors ' + KIT_FOCUS_RING.item;
42
+ const LEVEL_CLASS: readonly string[] = Object.freeze([kitWellRecipe(), 'bg-chart-1/30', 'bg-chart-1/50', 'bg-chart-1/70', 'bg-chart-1']);
43
+ const LEGEND_CLASS = 'flex items-center justify-end gap-1';
44
+ const FOOT_CLASS = 'flex items-center justify-between gap-4';
45
+ const TOTAL_CLASS = 'whitespace-nowrap tabular-nums';
46
+ const SVG_NS = 'http://www.w3.org/2000/svg';
47
+
48
+ /** 热力等级优先读取的主题顺序色阶令牌(读不到时退回 LEVEL_CLASS) */
49
+ export const KIT_HEAT_SEQ_TOKENS = Object.freeze([
50
+ '--soma-chart-seq-2',
51
+ '--soma-chart-seq-4',
52
+ '--soma-chart-seq-6',
53
+ '--soma-chart-seq-8',
54
+ '--soma-chart-seq-10',
55
+ ] as const);
56
+
57
+ function readHeatSeqPalette(el: HTMLElement): readonly string[] | null {
58
+ const view = el.ownerDocument?.defaultView ?? (typeof window !== 'undefined' ? window : null);
59
+ if (!view || typeof view.getComputedStyle !== 'function') return null;
60
+ const cs = view.getComputedStyle(el);
61
+ const dark = isDarkColorScheme(el);
62
+ const vals = KIT_HEAT_SEQ_TOKENS.map((t) => unwrapLightDark(cs.getPropertyValue(t).trim(), dark));
63
+ return vals.every((v) => v !== '') ? vals : null;
64
+ }
65
+
66
+ function heatSeqColorForLevel(seq: readonly string[] | null, level: number): string {
67
+ if (!seq || level <= 0) return '';
68
+ const idx = Math.round(((Math.min(level, LEVEL_MAX) - 1) / Math.max(1, LEVEL_MAX - 1)) * (seq.length - 1));
69
+ return seq[idx] ?? '';
70
+ }
71
+
72
+ function appendHeatSwatch(host: HTMLElement, fill: string): void {
73
+ const doc = host.ownerDocument;
74
+ const svg = doc.createElementNS(SVG_NS, 'svg');
75
+ svg.setAttribute('aria-hidden', 'true');
76
+ svg.setAttribute('viewBox', '0 0 12 12');
77
+ svg.setAttribute('class', CELL_SVG_CLASS);
78
+ const rect = doc.createElementNS(SVG_NS, 'rect');
79
+ rect.setAttribute('width', '12');
80
+ rect.setAttribute('height', '12');
81
+ rect.setAttribute('fill', fill);
82
+ svg.appendChild(rect);
83
+ host.appendChild(svg);
84
+ }
85
+
86
+ export const KIT_HEAT_CALENDAR_CLASS_CANDIDATES: readonly string[] = classTokens(
87
+ ROOT_CLASS, FRAME_CLASS, WEEKDAYS_CLASS, WEEKDAY_CLASS, MAIN_CLASS, MONTHS_CLASS, MONTH_SLOT_CLASS, WEEKS_CLASS, WEEK_CLASS,
88
+ CELL_BASE, CELL_SVG_CLASS, CELL_BUTTON, LEVEL_CLASS, LEGEND_CLASS, FOOT_CLASS, TOTAL_CLASS, KIT_APP_TOOLTIP_CLASS_CANDIDATES.join(' '),
89
+ );
90
+
91
+ export interface KitHeatCell { day: number; date: string; count: number; level: number }
92
+ export interface KitHeatGrid { weeks: Array<Array<KitHeatCell | null>>; max: number; total: number }
93
+
94
+ /** 档位:0 为空格,其余按 ceil(值 / 最大值 x 4) 分 1-4 档 */
95
+ export function heatLevelOf(count: number, max: number): number {
96
+ if (!(count > 0) || !(max > 0)) return 0;
97
+ return Math.min(LEVEL_MAX, Math.max(1, Math.ceil((count / max) * LEVEL_MAX)));
98
+ }
99
+
100
+ /** 源数据 -> 周列网格(纯函数);周内不在区间的格子为 null */
101
+ export function heatGridOf(data: unknown, mapRaw: unknown, yearRaw: unknown, endRaw: unknown, weekStartRaw: unknown, fixedMax = 0): KitHeatGrid {
102
+ const m = keyMap(KIT_HEAT_CALENDAR_DEFAULT_MAP, mapRaw);
103
+ const byDay = new Map<number, number>();
104
+ for (const r of rowsOf(data)) {
105
+ const day = dayNumOf(r[m.date]);
106
+ if (day === null) continue;
107
+ const c = num(r[m.count]) ?? 1;
108
+ byDay.set(day, (byDay.get(day) ?? 0) + c);
109
+ }
110
+ const weekStart = weekStartProp(weekStartRaw, 0);
111
+ const year = num(yearRaw);
112
+ let first: number;
113
+ let last: number;
114
+ if (year !== null && year > 0) {
115
+ first = dayNumOf(`${String(Math.trunc(year)).padStart(4, '0')}-01-01`) ?? 0;
116
+ last = dayNumOf(`${String(Math.trunc(year)).padStart(4, '0')}-12-31`) ?? first;
117
+ } else {
118
+ const end = dayNumOf(endRaw) ?? (byDay.size > 0 ? Math.max(...byDay.keys()) : null);
119
+ if (end === null) return { weeks: [], max: 0, total: 0 };
120
+ last = end;
121
+ first = weekStartOf(end, weekStart) - (WEEK_COUNT - 1) * WEEK_DAYS;
122
+ }
123
+ let max = 0;
124
+ let total = 0;
125
+ for (const [day, c] of byDay) if (day >= first && day <= last) { max = Math.max(max, c); total += c; }
126
+ if (fixedMax > 0) max = fixedMax;
127
+ const weeks: Array<Array<KitHeatCell | null>> = [];
128
+ for (let start = weekStartOf(first, weekStart); start <= last; start += WEEK_DAYS) {
129
+ const col: Array<KitHeatCell | null> = [];
130
+ for (let i = 0; i < WEEK_DAYS; i++) {
131
+ const day = start + i;
132
+ if (day < first || day > last) { col.push(null); continue; }
133
+ const count = byDay.get(day) ?? 0;
134
+ col.push({ day, date: textOfDayNum(day), count, level: heatLevelOf(count, max) });
135
+ }
136
+ weeks.push(col);
137
+ }
138
+ return { weeks, max, total };
139
+ }
140
+
141
+ export function createHeatCalendar(): SomaComponentDefinition {
142
+ return {
143
+ contract: {
144
+ name: 'HeatCalendar',
145
+ layer: 'data',
146
+ props: {
147
+ data: { type: 'array', default: [], desc: '每日数值 [{ date: YYYY-MM-DD, count }];同一天多条累加;count 缺省按 1 计' },
148
+ map: { type: 'object', default: {}, desc: '键名对照:date / count -> 数据里的键' },
149
+ year: { type: 'number', default: 0, desc: '取该自然年(1 月 1 日至 12 月 31 日);0 则取以 end 结尾的 53 周' },
150
+ end: { type: 'string', default: '', desc: '区间最后一天 YYYY-MM-DD;空则取数据里最晚一天(仅 year 为 0 时有效)' },
151
+ week_start: { type: 'number', default: 0, desc: '周起始日:0 = 周日(GitHub 通行),1 = 周一' },
152
+ max: { type: 'number', default: 0, desc: '固定最大值(多图共用同一标尺);0 则取区间内最大日值' },
153
+ selectable: { type: 'boolean', default: false, desc: '格子可点(按钮),点击抛 select' },
154
+ legend: { type: 'boolean', default: true, desc: '底部「少 - 多」图例' },
155
+ locale: { type: 'string', default: '', desc: '月份与星期名的语言;空则取声明语言' },
156
+ cell_text: { type: 'string', default: '', desc: '格子提示与读屏文案,{date} / {count} 占位;空则「{date}:{count}」' },
157
+ less_text: { type: 'string', default: '', desc: '图例左端文案' },
158
+ more_text: { type: 'string', default: '', desc: '图例右端文案' }, empty_text: { type: 'string', default: '', desc: '无数据时的文案' },
159
+ ...KIT_READ_STATE_PROP_DEFS,
160
+ class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
161
+ },
162
+ emits: {
163
+ select: { payload: { date: { type: 'string' }, count: { type: 'number' } }, desc: '点某一天(selectable 时)' },
164
+ ...KIT_READ_STATE_EMIT_DEFS,
165
+ },
166
+ },
167
+ templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
168
+ controllerFactory: createKitController(() => {
169
+ let cursorDate = '';
170
+ let currentWeeks: Array<Array<KitHeatCell | null>> = [];
171
+
172
+ const focusCell = (root: HTMLElement, date: string): void => {
173
+ if (date === '') return;
174
+ cursorDate = date;
175
+ let target: HTMLButtonElement | null = null;
176
+ for (const btn of Array.from(root.querySelectorAll<HTMLButtonElement>(`button${kitAttrSel(KIT_ATTR_DATE)}`))) {
177
+ const on = btn.getAttribute(KIT_ATTR_DATE) === date;
178
+ btn.tabIndex = on ? 0 : -1;
179
+ if (on) target = btn;
180
+ }
181
+ target?.focus();
182
+ };
183
+
184
+ const nearestInCol = (wi: number, di: number): KitHeatCell | null => {
185
+ const col = currentWeeks[wi];
186
+ if (!col) return null;
187
+ if (col[di] !== null && col[di] !== undefined) return col[di]!;
188
+ for (let step = 1; step < WEEK_DAYS; step++) {
189
+ const up = di - step >= 0 ? col[di - step] : null;
190
+ if (up) return up;
191
+ const down = di + step < WEEK_DAYS ? col[di + step] : null;
192
+ if (down) return down;
193
+ }
194
+ return null;
195
+ };
196
+
197
+ return {
198
+ attach(root, api) {
199
+ const onClick = (event: Event): void => {
200
+ const hit = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_DATE));
201
+ if (!hit || !bool(api.props().selectable)) return;
202
+ const date = hit.getAttribute(KIT_ATTR_DATE) ?? '';
203
+ if (date !== '') {
204
+ cursorDate = date;
205
+ for (const btn of Array.from(root.querySelectorAll<HTMLButtonElement>(`button${kitAttrSel(KIT_ATTR_DATE)}`))) {
206
+ btn.tabIndex = btn === hit ? 0 : -1;
207
+ }
208
+ }
209
+ api.emit('select', { date, count: Number(hit.getAttribute(KIT_ATTR_COUNT) ?? 0) });
210
+ };
211
+ const onKeydown = (event: KeyboardEvent): void => {
212
+ if (!bool(api.props().selectable) || event.altKey || event.ctrlKey || event.metaKey) return;
213
+ const hit = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_DATE));
214
+ if (!hit || currentWeeks.length === 0) return;
215
+ const pos = hit.getAttribute(KIT_ATTR_POS) ?? '';
216
+ const m = /^(\d+):(\d+)$/.exec(pos);
217
+ if (!m) return;
218
+ const wi = Number(m[1]);
219
+ const di = Number(m[2]);
220
+ const k = kitKey(event.key, root);
221
+ let next: KitHeatCell | null = null;
222
+ if (k === 'ArrowUp') {
223
+ if (di > 0) next = currentWeeks[wi]?.[di - 1] ?? null;
224
+ else if (wi > 0) next = currentWeeks[wi - 1]?.[WEEK_DAYS - 1] ?? null;
225
+ } else if (k === 'ArrowDown') {
226
+ if (di + 1 < WEEK_DAYS) next = currentWeeks[wi]?.[di + 1] ?? null;
227
+ else if (wi + 1 < currentWeeks.length) next = currentWeeks[wi + 1]?.[0] ?? null;
228
+ } else if (k === 'ArrowLeft') {
229
+ if (wi > 0) next = nearestInCol(wi - 1, di);
230
+ } else if (k === 'ArrowRight') {
231
+ if (wi + 1 < currentWeeks.length) next = nearestInCol(wi + 1, di);
232
+ } else if (k === 'Home') {
233
+ for (const col of currentWeeks) {
234
+ const c = col.find((x): x is KitHeatCell => x !== null);
235
+ if (c) { next = c; break; }
236
+ }
237
+ } else if (k === 'End') {
238
+ for (let cIdx = currentWeeks.length - 1; cIdx >= 0; cIdx--) {
239
+ const col = currentWeeks[cIdx]!;
240
+ for (let rIdx = col.length - 1; rIdx >= 0; rIdx--) {
241
+ if (col[rIdx]) { next = col[rIdx]!; break; }
242
+ }
243
+ if (next) break;
244
+ }
245
+ } else {
246
+ return;
247
+ }
248
+ event.preventDefault();
249
+ if (next) focusCell(root, next.date);
250
+ };
251
+ root.addEventListener('click', onClick);
252
+ root.addEventListener('keydown', onKeydown as EventListener);
253
+ const offs: Array<() => void> = [];
254
+ const doc = root.ownerDocument;
255
+ const view = doc?.defaultView;
256
+ const schemeKey = (): string => {
257
+ const cl = doc?.documentElement?.classList;
258
+ return `${cl?.contains('soma-scheme-dark') === true}/${cl?.contains('soma-scheme-light') === true}`;
259
+ };
260
+ let lastScheme = schemeKey();
261
+ const repaint = (): void => { api.refresh(); };
262
+ const mm = view && typeof view.matchMedia === 'function'
263
+ ? view.matchMedia.bind(view)
264
+ : (typeof globalThis.matchMedia === 'function' ? globalThis.matchMedia.bind(globalThis) : null);
265
+ if (mm !== null) {
266
+ const mq = mm('(prefers-color-scheme: dark)');
267
+ if (typeof mq?.addEventListener === 'function') {
268
+ mq.addEventListener('change', repaint);
269
+ offs.push(() => mq.removeEventListener('change', repaint));
270
+ } else if (typeof mq?.addListener === 'function') {
271
+ mq.addListener(repaint);
272
+ offs.push(() => mq.removeListener(repaint));
273
+ }
274
+ }
275
+ if (typeof MutationObserver === 'function' && doc?.documentElement) {
276
+ const mo = new MutationObserver(() => {
277
+ const now = schemeKey();
278
+ if (now === lastScheme) return;
279
+ lastScheme = now;
280
+ repaint();
281
+ });
282
+ mo.observe(doc.documentElement, { attributes: true, attributeFilter: ['class'] });
283
+ offs.push(() => mo.disconnect());
284
+ }
285
+ if (doc && typeof doc.addEventListener === 'function') {
286
+ const onApplied = (): void => { lastScheme = schemeKey(); repaint(); };
287
+ doc.addEventListener(KIT_THEME_APPLIED_EVENT, onApplied);
288
+ offs.push(() => doc.removeEventListener(KIT_THEME_APPLIED_EVENT, onApplied));
289
+ }
290
+ return () => {
291
+ for (const off of offs) off();
292
+ root.removeEventListener('click', onClick);
293
+ root.removeEventListener('keydown', onKeydown as EventListener);
294
+ releaseReasonTipsIn(root);
295
+ currentWeeks = [];
296
+ };
297
+ },
298
+ render(root, p, api) {
299
+ root.className = joinClass(ROOT_CLASS, p.class);
300
+ const active = root.ownerDocument.activeElement;
301
+ const hadFocus = active instanceof HTMLElement && root.contains(active) && active.hasAttribute(KIT_ATTR_DATE);
302
+ if (hadFocus && active instanceof HTMLElement) {
303
+ cursorDate = active.getAttribute(KIT_ATTR_DATE) ?? cursorDate;
304
+ }
305
+ releaseReasonTipsIn(root);
306
+ root.textContent = '';
307
+ const grid = heatGridOf(p.data, p.map, p.year, p.end, p.week_start, num(p.max) ?? 0);
308
+ currentWeeks = grid.weeks;
309
+ // 数据状态自报(每次渲染都写):与读状态面板同一判据,出错 > 加载 > 空;data-kit-state 面板标记照旧
310
+ kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: !(grid.weeks.length > 0) });
311
+ if (applyKitReadState(root, p, { hasContent: grid.weeks.length > 0, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) return;
312
+ if (grid.weeks.length === 0) {
313
+ root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.tl_empty', undefined, root))));
314
+ return;
315
+ }
316
+ const locale = str(p.locale);
317
+ const weekStart = weekStartProp(p.week_start, 0);
318
+ const selectable = bool(p.selectable);
319
+ const allDates: string[] = [];
320
+ for (const col of grid.weeks) for (const c of col) if (c !== null) allDates.push(c.date);
321
+ if (cursorDate === '' || !allDates.includes(cursorDate)) cursorDate = allDates[0] ?? '';
322
+ const cellText = str(p.cell_text, kitText('soma.kit.hm_cell', undefined, root));
323
+ const label = (date: string, count: number): string => cellText.replace('{date}', date).replace('{count}', String(count));
324
+ const seqPalette = readHeatSeqPalette(root);
325
+ const frame = mk('div', FRAME_CLASS);
326
+ if (selectable) frame.setAttribute('role', 'grid');
327
+ // 左侧星期标:隔行显示(第 2、4、6 行),与 GitHub 一致
328
+ const weekdays = mk('div', WEEKDAYS_CLASS);
329
+ weekdays.setAttribute('aria-hidden', 'true');
330
+ for (let i = 0; i < WEEK_DAYS; i++) {
331
+ weekdays.appendChild(mk('span', WEEKDAY_CLASS, i % 2 === 1 ? weekdayName((weekStart + i) % WEEK_DAYS, locale, root) : ''));
332
+ }
333
+ const main = mk('div', MAIN_CLASS);
334
+ const months = mk('div', MONTHS_CLASS);
335
+ months.setAttribute('aria-hidden', 'true');
336
+ const weeks = mk('div', WEEKS_CLASS);
337
+ const colMonths = grid.weeks.map((col) => {
338
+ const firstDay = col.find((c) => c !== null) ?? null;
339
+ return firstDay ? ymdOfDayNum(firstDay.day).m : -1;
340
+ });
341
+ let prevMonth = -1;
342
+ grid.weeks.forEach((col, wi) => {
343
+ const firstDay = col.find((c) => c !== null) ?? null;
344
+ const month = colMonths[wi] ?? prevMonth;
345
+ // 月份标挂在「该月第一周」的列顶;若第 0 列残周与第 1 列月份不同则隐藏第 0 列残周月标,防止横向穿字重叠
346
+ let name = '';
347
+ const skipStubMonth = wi === 0 && colMonths.length > 1 && colMonths[1] !== -1 && month !== colMonths[1];
348
+ if (firstDay && month !== prevMonth && !skipStubMonth) {
349
+ const ymd = ymdOfDayNum(firstDay.day);
350
+ name = new Intl.DateTimeFormat(locale || undefined, { month: 'short', timeZone: 'UTC' }).format(new Date(Date.UTC(ymd.y, ymd.m - 1, ymd.d)));
351
+ prevMonth = month;
352
+ }
353
+ months.appendChild(mk('span', MONTH_SLOT_CLASS, name));
354
+ const week = mk('div', WEEK_CLASS);
355
+ col.forEach((c, di) => {
356
+ if (c === null) { week.appendChild(mk('span', 'size-3 shrink-0')); return; }
357
+ const seqFill = heatSeqColorForLevel(seqPalette, c.level);
358
+ const lvlCls = seqFill !== '' ? '' : ` ${LEVEL_CLASS[c.level]}`;
359
+ const cell = selectable ? mk('button', `${CELL_BASE}${lvlCls} ${CELL_BUTTON}`) : mk('span', `${CELL_BASE}${lvlCls}`);
360
+ if (seqFill !== '') appendHeatSwatch(cell, seqFill);
361
+ if (cell instanceof HTMLButtonElement) {
362
+ cell.type = 'button';
363
+ cell.tabIndex = c.date === cursorDate ? 0 : -1;
364
+ cell.setAttribute(KIT_ATTR_DATE, c.date);
365
+ cell.setAttribute(KIT_ATTR_COUNT, String(c.count));
366
+ cell.setAttribute(KIT_ATTR_POS, `${wi}:${di}`);
367
+ }
368
+ const text = label(c.date, c.count);
369
+ // 悬停(selectable 时含聚焦)显 kit 提示气泡,替代原生 title;占位节点放进格内,不打乱周列布局
370
+ cell.setAttribute('aria-label', text);
371
+ if (text !== '') kitTooltip(cell, text, { inside: true });
372
+ // 热度档用专名:data-kit-level 已是层级角色自报的属性名(shared/page-attrs-runtime),同名会让取值表把格子当层级节点
373
+ cell.setAttribute(KIT_ATTR_HEAT_LEVEL, String(c.level));
374
+ // 日期格 = 格(自管布局,只自报到一级结构)
375
+ kitMarkPart(cell, 'cell');
376
+ week.appendChild(cell);
377
+ });
378
+ weeks.appendChild(week);
379
+ });
380
+ main.appendChild(months);
381
+ main.appendChild(weeks);
382
+ frame.appendChild(weekdays);
383
+ frame.appendChild(main);
384
+ root.appendChild(frame);
385
+ // 脚部:左 = 区间总数(等宽千分位),右 = 图例(少 ▢▢▢▢▢ 多)
386
+ const foot = mk('div', FOOT_CLASS);
387
+ const formattedTotal = formatValue(grid.total, 'number', locale);
388
+ foot.appendChild(mk('span', TOTAL_CLASS, `${kitText('soma.kit.summary_total', undefined, root)} ${formattedTotal}`));
389
+ if (p.legend === undefined || bool(p.legend)) {
390
+ const legend = mk('div', LEGEND_CLASS);
391
+ legend.setAttribute('aria-hidden', 'true');
392
+ legend.appendChild(mk('span', '', str(p.less_text, kitText('soma.kit.hm_less', undefined, root))));
393
+ LEVEL_CLASS.forEach((cls, lvl) => {
394
+ const seqFill = heatSeqColorForLevel(seqPalette, lvl);
395
+ const sw = mk('span', seqFill !== '' ? CELL_BASE : `${CELL_BASE} ${cls}`);
396
+ if (seqFill !== '') appendHeatSwatch(sw, seqFill);
397
+ legend.appendChild(sw);
398
+ });
399
+ legend.appendChild(mk('span', '', str(p.more_text, kitText('soma.kit.hm_more', undefined, root))));
400
+ foot.appendChild(legend);
401
+ }
402
+ root.appendChild(foot);
403
+ if (hadFocus && selectable && cursorDate !== '') {
404
+ Array.from(root.querySelectorAll<HTMLButtonElement>(`button${kitAttrSel(KIT_ATTR_DATE)}`))
405
+ .find((b) => b.getAttribute(KIT_ATTR_DATE) === cursorDate)
406
+ ?.focus({ preventScroll: true });
407
+ }
408
+ },
409
+ };
410
+ }),
411
+ };
412
+ }
package/src/data/hero.ts CHANGED
@@ -6,17 +6,25 @@
6
6
  // 动作只经事件抛出,组件不改数据。
7
7
 
8
8
  import type { SomaComponentDefinition } from 'soma-core';
9
- import { createKitController, joinClass, str } from '../base/shared';
9
+ import { bool, createKitController, joinClass, str, toggleKitHidden } from '../base/shared';
10
10
  import { actionButton, BUTTON_CLASS_TOKENS, classTokens, mk, rowsOf, type ShapeAction } from './shape-util';
11
- import { singleOf, urlOf } from './display-util';
11
+ import { imageUrlOf, singleOf } from './display-util';
12
12
  import { markKitEdge } from '../recipes/surface-edge';
13
+ import { KIT_FACE_EDGE_CLASS } from '../recipes/surface';
14
+ import { KIT_SCOPE_ATTR, KIT_SCOPE_INVERT } from '../recipes/color-role';
15
+ import { mergeClass } from '../shared/merge-class';
16
+ import { KIT_ATTR_ACTION, KIT_ATTR_CONTAINER, kitAttrSel } from '../shared/dom-attrs';
17
+ import { kitHasProps, kitMarkPart, kitReadProps } from './kit-contract';
18
+
19
+ /** 外缘 = 对象面外缘出口(容器边,KT-B2)+ 带底色(surface-band,横幅是带不是井) */
20
+ const ROOT_EDGE = `${KIT_FACE_EDGE_CLASS} bg-surface-band`;
13
21
 
14
22
  export const KIT_HERO_LAYOUTS = ['center', 'split'] as const;
15
23
  export type KitHeroLayout = (typeof KIT_HERO_LAYOUTS)[number];
16
24
 
17
25
  const KEYS = ['title', 'subtitle', 'description', 'image', 'image_alt', 'actions'] as const;
18
26
 
19
- const ROOT_CLASS = '@container rounded-lg border border-border-subtle bg-surface-sunken px-6 py-10 text-fg';
27
+ const ROOT_CLASS = `@container ${ROOT_EDGE} px-6 py-10 text-fg`;
20
28
  const CENTER_CLASS = 'mx-auto flex max-w-2xl flex-col items-center gap-4 text-center';
21
29
  const SPLIT_CLASS = 'flex flex-col gap-8 @md:flex-row @md:items-center';
22
30
  const TEXT_CLASS = 'flex flex-1 flex-col gap-3';
@@ -28,11 +36,11 @@ const DESC_CLASS = 'text-base text-fg-muted';
28
36
  const ACTIONS_CLASS = 'flex flex-wrap items-center gap-3 pt-2';
29
37
  const ACTIONS_CENTER_CLASS = 'flex flex-wrap items-center justify-center gap-3 pt-2';
30
38
  const IMAGE_BOX_CLASS = 'flex-1';
31
- const IMAGE_CLASS = 'block aspect-16/9 w-full rounded-lg object-cover shadow-md';
32
- const IMAGE_CENTER_CLASS = 'block aspect-16/9 w-full max-w-xl rounded-lg object-cover shadow-md';
39
+ const IMAGE_CLASS = 'block aspect-16/9 w-full rounded-card object-cover shadow-md';
40
+ const IMAGE_CENTER_CLASS = 'block aspect-16/9 w-full max-w-xl rounded-card object-cover shadow-md';
33
41
 
34
42
  export const KIT_HERO_CLASS_CANDIDATES: readonly string[] = classTokens(
35
- ROOT_CLASS, CENTER_CLASS, SPLIT_CLASS, TEXT_CLASS, TEXT_CENTER_CLASS, TITLE_CLASS, SUBTITLE_CLASS, DESC_CLASS,
43
+ ROOT_CLASS, 'bg-surface-inverse', 'hidden', CENTER_CLASS, SPLIT_CLASS, TEXT_CLASS, TEXT_CENTER_CLASS, TITLE_CLASS, SUBTITLE_CLASS, DESC_CLASS,
36
44
  ACTIONS_CLASS, ACTIONS_CENTER_CLASS, IMAGE_BOX_CLASS, IMAGE_CLASS, IMAGE_CENTER_CLASS, BUTTON_CLASS_TOKENS,
37
45
  );
38
46
 
@@ -73,7 +81,7 @@ export function heroModelOf(data: unknown, props: Record<string, unknown>): KitH
73
81
  title: str(src.title),
74
82
  subtitle: str(src.subtitle),
75
83
  description: str(src.description),
76
- image: urlOf(src.image),
84
+ image: imageUrlOf(src.image),
77
85
  imageAlt: str(src.image_alt),
78
86
  actions,
79
87
  };
@@ -93,20 +101,23 @@ export function createHero(): SomaComponentDefinition {
93
101
  image: { type: 'string', default: '', desc: '图片地址(safeHref 放行的相对 / http(s) 地址)' },
94
102
  image_alt: { type: 'string', default: '', desc: '图片替代文字;空表示装饰图' },
95
103
  actions: { type: 'array', default: [], desc: '动作 [{ key, label, tone?, disabled? }],第一个默认主色' },
104
+ variant: { type: 'string', default: '', desc: '舞台模式:invert 启用反色舞台,默认空' },
105
+ tone: { type: 'string', default: '', desc: '舞台语气:invert 启用反色舞台' },
106
+ dark: { type: 'boolean', default: false, desc: '暗色反色舞台开关' },
96
107
  class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
97
108
  },
98
109
  emits: {
99
110
  action: { payload: { key: { type: 'string' }, item: { type: 'object' } }, desc: '点某个动作按钮;item 是该动作的源对象' },
100
111
  },
101
112
  },
102
- templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
113
+ templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
103
114
  controllerFactory: createKitController(() => ({
104
115
  attach(root, api) {
105
116
  const onClick = (event: Event): void => {
106
- const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-action]');
117
+ const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION));
107
118
  if (!hit || !root.contains(hit) || hit.hasAttribute('disabled')) return;
108
119
  const p = api.props();
109
- const key = hit.getAttribute('data-kit-action') ?? '';
120
+ const key = hit.getAttribute(KIT_ATTR_ACTION) ?? '';
110
121
  const action = heroModelOf(p.data, p).actions.find((a) => a.key === key);
111
122
  if (action) api.emit('action', { key, item: action.raw });
112
123
  };
@@ -114,14 +125,26 @@ export function createHero(): SomaComponentDefinition {
114
125
  return () => root.removeEventListener('click', onClick);
115
126
  },
116
127
  render(root, p) {
117
- root.className = joinClass(ROOT_CLASS, p.class);
118
- markKitEdge(root);
128
+ const dRec = p.data !== null && typeof p.data === 'object' && !Array.isArray(p.data) ? (p.data as Record<string, unknown>) : {};
129
+ const isInvert = p.variant === 'invert' || p.tone === 'invert' || bool(p.dark)
130
+ || dRec.variant === 'invert' || dRec.tone === 'invert' || bool(dRec.dark);
131
+ if (isInvert) root.setAttribute(KIT_SCOPE_ATTR, KIT_SCOPE_INVERT);
132
+ else root.removeAttribute(KIT_SCOPE_ATTR);
133
+ root.className = joinClass(isInvert ? mergeClass(ROOT_CLASS, 'bg-surface-inverse') : ROOT_CLASS, p.class);
134
+ // 外框去留原由祖先样式判断(C 项):新流水线下由页面线写层级角色、取值表按邻接给外框,组件不再标外框
135
+ if (!kitHasProps(p)) markKitEdge(root);
119
136
  root.textContent = '';
120
137
  const model = heroModelOf(p.data, p);
121
138
  const split = heroLayoutOf(p.layout) === 'split';
122
139
  const wrap = mk('div', split ? SPLIT_CLASS : CENTER_CLASS);
123
140
  const text = mk('div', split ? TEXT_CLASS : TEXT_CENTER_CLASS);
124
- if (model.title !== '') text.appendChild(mk('h2', TITLE_CLASS, model.title));
141
+ if (model.title !== '') {
142
+ // 首屏横幅的主标题即本页标题(元素部件页标题)
143
+ // 页面线判定标题与页标题重复时(titleHidden)只在视觉上隐去,标题仍作无障碍名留在原位;没有判定时照常显示
144
+ const t = mk('h2', kitReadProps(p).titleHidden === true ? 'sr-only' : TITLE_CLASS, model.title);
145
+ kitMarkPart(t, 'page-title');
146
+ text.appendChild(t);
147
+ }
125
148
  if (model.subtitle !== '') text.appendChild(mk('p', SUBTITLE_CLASS, model.subtitle));
126
149
  if (model.description !== '') text.appendChild(mk('p', DESC_CLASS, model.description));
127
150
  if (model.actions.length > 0) {
@@ -134,6 +157,10 @@ export function createHero(): SomaComponentDefinition {
134
157
  img.setAttribute('src', model.image);
135
158
  img.setAttribute('alt', model.imageAlt);
136
159
  img.setAttribute('loading', 'lazy');
160
+ img.addEventListener('error', () => {
161
+ const box = img.parentElement;
162
+ toggleKitHidden(box && box.className === IMAGE_BOX_CLASS ? box : img, true);
163
+ }, { once: true });
137
164
  }
138
165
  wrap.appendChild(text);
139
166
  if (img) {