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
package/src/base/text.ts CHANGED
@@ -4,14 +4,68 @@
4
4
  // (不带文本,避免凭据类文本再次上行);文字为空时不出钮。
5
5
 
6
6
  import type { SomaComponentDefinition } from 'soma-core';
7
- import { TAG_CLASS } from './tag';
8
- import { formatDateRangeValue, formatMoneyValue, formatPercentValue } from '../object-renderer/field-value';
7
+ import { DOT_CORE, DOT_ROOT, DOT_TEXT, DOT_WRAP } from './tag';
8
+ import { kitWellRecipe } from '../recipes/surface';
9
+ import { formatDateRangeValue, formatMoneyValue, formatPercentValue } from '../shared/field-value-format';
9
10
  import { kitLocaleAt, kitText } from '../i18n/kit-text';
10
- import { KIT_TIPS_SCOPE_ATTR } from './hint-tips';
11
+ import { KIT_ATTR_ACTION, KIT_ATTR_COPIED, KIT_ATTR_TIP, KIT_ATTR_TIPS } from '../shared/dom-attrs';
12
+ // 仅为副作用保留:hint-tips 模块加载时注册提示委托(原先随常量导入一并加载,加载顺序不变)
13
+ import './hint-tips';
14
+ import { kitFocusRingRecipe } from '../recipes/state';
15
+ import { mergeClass } from '../shared/merge-class';
16
+ import { KIT_ICON_CLASS_CANDIDATES, kitIcon, setKitIconCached } from '../shared/icons';
17
+ import { ROOT_CLASS as AVATAR_ROOT_CLASS, safeSrc } from './avatar';
18
+ import { safeHref } from './link';
19
+ import { kitCategoryToneFor, kitMarkInkRecipe, kitMarkRecipe, kitToneMapHasAuto } from '../recipes/mark';
20
+ import { KIT_LOOK_TONE_ATTR } from '../recipes/look';
21
+ import { applyLook, kitCategoryAutoSequence, kitCategoryTonesByOrder, kitMarkElementPart, type KitLookProp } from './look';
22
+ import { KIT_PROSE_ATTR, kitProseFit, kitProseIsCode, kitProseParagraphs } from '../recipes/text-fit';
11
23
  import {
12
24
  CLASS_PROP, SIZE_PROP, OPTIONS_PROP,
13
- bool, classCandidates, createKitController, displayOf, joinClass, optionsOf, sizeOf, str, type KitSize, type KitTone,
25
+ bool, classCandidates, createKitController, displayOf, formatValue, joinClass, optionsOf, sizeOf, str,
26
+ KIT_ALIGN_CLASS, kitApplyOverflowMark, kitCategoryOn, kitHasOwnAlign, kitHasOwnOverflow, kitMarkDataState, kitOuterRoot, kitOverflowFit, kitReadProps, kitToneOfPipeline,
27
+ type KitApi, type KitSize, type KitTone,
14
28
  } from './shared';
29
+ import type { KitElementPart } from '../shared/page-attrs';
30
+
31
+ /**
32
+ * 把页面线写在 props.kit 里的判定并进 Text 自己的同义入参,后面的画法只认 Text 自己的入参,不再另判新旧模式。
33
+ * 值的呈现形态(present / copyable)不在此并入:它以类型呈现真源按数据类型给的缺省为准(SCON-128 B1;页面线只有 13 种字段类型,
34
+ * 分不清整数与金额、日期与日期时间),页面线只加分类色、溢出与对齐。没有 kit 对象时原样返回 p(渲染与改前逐字一致)。
35
+ * 溢出与对齐是按位置给的缺省,只补空缺:自己的类串(页面写的值类、对象渲染器按集合形态与列声明给的类)里已有溢出取向 / 对齐的,
36
+ * 以自己的为准,不再叠加(kit-contract#kitHasOwnOverflow / kitHasOwnAlign)。
37
+ */
38
+ export function withTextKit(p: Record<string, unknown>, host?: Element | null): Record<string, unknown> {
39
+ const kit = kitReadProps(p);
40
+ if (Object.keys(kit).length === 0) return p;
41
+ const q: Record<string, unknown> = { ...p };
42
+ // 分类色:按选项声明顺序取主题自动序列的色号(超出序列长度整字段退成中性;host = 读 --kit-cat-auto 的宿主);
43
+ // 编译期色表里显式的 cN / neutral 原样保留、不占序号,其余选项接续取色(E→D:next 下自动位已被剥掉,只剩显式条目时其余选项不退中性)
44
+ if (kitCategoryOn(kit)) q.tag_tones = kitCategoryTonesByOrder(optionsOf(p.options), host, p.tag_tones);
45
+ // 溢出策略与逻辑对齐只加类(走 text-fit 出口与文本对齐类),外部 class 仍在最后
46
+ const own = str(p.class);
47
+ const fit = kitHasOwnOverflow(own) ? null : kitOverflowFit(kit.overflow);
48
+ const align = kit.align !== undefined && !kitHasOwnAlign(own) ? KIT_ALIGN_CLASS[kit.align] : '';
49
+ const extra = [fit?.class ?? '', align, own].filter((c) => c !== '').join(' ');
50
+ if (extra !== own) q.class = extra;
51
+ return q;
52
+ }
53
+
54
+ /** 页面线的溢出策略里实际生效的那一份:自己的类串里已有溢出取向时页面线的不生效(与 withTextKit 加类的判据同一条) */
55
+ function textKitOverflowOf(raw: Record<string, unknown>): ReturnType<typeof kitReadProps>['overflow'] {
56
+ return kitHasOwnOverflow(raw.class) ? undefined : kitReadProps(raw).overflow;
57
+ }
58
+
59
+ /** 当轮内容对应的元素部件:带语气 = 状态;画成标签 / 标识块 / 布尔标记 = 标记;其余 = 值 */
60
+ function textPartOf(p: Record<string, unknown>, root: HTMLElement): KitElementPart {
61
+ if (isEmptyValue(p.value)) return 'value';
62
+ const { option } = resolveTextDisplay(p, root);
63
+ if ((option?.tone ?? kitToneOfPipeline(kitReadProps(p).tone) ?? undefined) !== undefined && !bool(p.copyable)) return 'status';
64
+ const present = presentOf(p.present);
65
+ return present === 'tag' || present === 'ref' || present === 'code' || present === 'level' || present === 'flag' || present === 'bool' ? 'mark' : 'value';
66
+ }
67
+
68
+ const isEmptyValue = (raw: unknown): boolean => raw === null || raw === undefined || raw === '' || (Array.isArray(raw) && raw.length === 0);
15
69
 
16
70
  // 每档一整串字面量,不拼接
17
71
  const TEXT_SIZE_CLASS: Record<KitSize, string> = {
@@ -24,43 +78,144 @@ const TEXT_CLASS: Record<KitSize, string> = {
24
78
  md: `${TEXT_SIZE_CLASS.md} text-fg`,
25
79
  lg: `${TEXT_SIZE_CLASS.lg} text-fg`,
26
80
  };
81
+ // 空值占位(「—」)弱化墨:看起来不像一个值(KT-K-desc-2 / KT-K-stat-3 同一占位)
82
+ const TEXT_EMPTY_CLASS: Record<KitSize, string> = {
83
+ sm: `${TEXT_SIZE_CLASS.sm} text-fg-subtle`,
84
+ md: `${TEXT_SIZE_CLASS.md} text-fg-subtle`,
85
+ lg: `${TEXT_SIZE_CLASS.lg} text-fg-subtle`,
86
+ };
27
87
  // 语气纯文字着色(tone_as: text):只换字色,无底无描边;neutral 用次要字色,其余取 -on-soft 配对字色
28
88
  export const TONE_AS_TEXT = 'text' as const;
29
89
  const TONE_TEXT_COLOR: Record<KitTone, string> = {
30
- neutral: 'text-fg-muted',
31
- info: 'text-info-on-soft',
32
- success: 'text-success-on-soft',
33
- warning: 'text-warning-on-soft',
34
- danger: 'text-danger-on-soft',
90
+ neutral: kitMarkInkRecipe('neutral'),
91
+ info: kitMarkInkRecipe('info'),
92
+ success: kitMarkInkRecipe('success'),
93
+ warning: kitMarkInkRecipe('warning'),
94
+ danger: kitMarkInkRecipe('danger'),
35
95
  };
36
96
  // 字阶取 TEXT_SIZE_CLASS 里已有的那一档(不另写一份字阶类,G101 typography 不增)
37
97
  const toneTextClass = (size: KitSize, tone: KitTone): string => `${TEXT_SIZE_CLASS[size]} ${TONE_TEXT_COLOR[tone]}`;
38
- const TONE_TEXT_CLASS: Record<KitSize, Record<KitTone, string>> = {
98
+ export const TONE_TEXT_CLASS: Record<KitSize, Record<KitTone, string>> = {
39
99
  sm: { neutral: toneTextClass('sm', 'neutral'), info: toneTextClass('sm', 'info'), success: toneTextClass('sm', 'success'), warning: toneTextClass('sm', 'warning'), danger: toneTextClass('sm', 'danger') },
40
100
  md: { neutral: toneTextClass('md', 'neutral'), info: toneTextClass('md', 'info'), success: toneTextClass('md', 'success'), warning: toneTextClass('md', 'warning'), danger: toneTextClass('md', 'danger') },
41
101
  lg: { neutral: toneTextClass('lg', 'neutral'), info: toneTextClass('lg', 'info'), success: toneTextClass('lg', 'success'), warning: toneTextClass('lg', 'warning'), danger: toneTextClass('lg', 'danger') },
42
102
  };
43
- // copyable 时根元素变成一行:文字 + 复制钮(whitespace-nowrap:值与复制钮是同一个不折行的行内组,宽松密度 / 窄格里也不会把钮挤到下一行)
103
+ // copyable 时根元素变成一行:文字 + 复制钮(max-w-full min-w-0 配合内层 truncate:长文本省略,复制按钮 shrink-0 永不被裁)
44
104
  const COPY_ROOT_CLASS: Record<KitSize, string> = {
45
- sm: 'inline-flex items-center gap-2 whitespace-nowrap text-sm text-fg',
46
- md: 'inline-flex items-center gap-2 whitespace-nowrap text-base text-fg',
47
- lg: 'inline-flex items-center gap-2 whitespace-nowrap text-lg text-fg',
105
+ sm: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-sm text-fg',
106
+ md: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-base text-fg',
107
+ lg: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-lg text-fg',
108
+ };
109
+ export const COPY_TEXT_CLASS = 'min-w-0 truncate';
110
+ // 复制入口 = 墨色弱化的小图标钮(「重复出现的元素不抢强调」:一列十几行各一个,不用主色文字;一页的蓝只给主动作与链接):
111
+ // 常显、计宽(aa202ca:键盘 / 触屏可达、悬停不位移),静止弱化墨(fg-subtle),悬停 / 聚焦图标转主色 + 中性状态层(CS19 ②,主会话裁决 D-30-1:与安静钮同一取法);
112
+ // 文案(复制 / 已复制)进可访问名与悬停提示(data-kit-tip,base/hint-tips),不占可见文字;复制成功图标换成对勾
113
+ export const COPY_BTN_CLASS = mergeClass(
114
+ 'inline-flex h-6 w-6 min-h-6 min-w-6 shrink-0 cursor-pointer appearance-none items-center justify-center rounded-item border-0 bg-transparent p-0 text-fg-subtle transition-colors hover:bg-state-layer-hover hover:text-primary-on-soft active:bg-state-layer-press focus-visible:text-primary-on-soft',
115
+ kitFocusRingRecipe('button'),
116
+ );
117
+ /** 复制钮的内容:图标(复制 / 对勾)+ 可访问名 + 悬停提示文案;Text 与 TreeTable 的复制格共用这一处 */
118
+ export function setKitCopyButton(btn: HTMLElement, label: string, copied: boolean): void {
119
+ setKitIconCached(btn, copied ? 'check' : 'copy', 'sm');
120
+ btn.setAttribute('aria-label', label);
121
+ btn.setAttribute(KIT_ATTR_TIP, label);
122
+ if (copied) btn.setAttribute(KIT_ATTR_COPIED, '');
123
+ else btn.removeAttribute(KIT_ATTR_COPIED);
124
+ }
125
+
126
+ // ── 只读值按字段类型的呈现形态(present,DC4-1「val 用好看的 label」;映射在编译期 object-renderer/value-present.ts,按 type-presentation#formFields.readonlyPresent)──
127
+ // 形态闭集:text(缺省,正文墨)/ tag(分类:标签)/ ref(引用:中性标签 = 名称 + 弱化等宽编码)/ code(标识符:等宽,配 copyable 出复制钮)/
128
+ // bool(是 / 否:是 = 墨 + 对勾,否 = 弱化墨;不用绿 / 红)/ count(数量:等宽数字,0 弱化)/ time(时间:近期相对 + 提示绝对,等宽数字)/
129
+ // prose(长文本只读、块级位置:按换行分段,段首缩进由成段正文出口 text-fit#kitProseFit 判定,KT-T-prose)。
130
+ // 状态(选项带语气)不在此列:恒为圆点 + 文字(上面的 tone 分支,优先于 present)。分类标签的色只经标记出口 kitMarkRecipe('category') 取(分类色 c1…c8 落地后由该出口切换,不在这里另造色)。
131
+ export const KIT_TEXT_PRESENTS = ['text', 'tag', 'ref', 'code', 'bool', 'count', 'time', 'prose', 'level', 'flag', 'link', 'image'] as const;
132
+ export type KitTextPresent = typeof KIT_TEXT_PRESENTS[number];
133
+ export const PRESENT_TAG_CLASS = kitMarkRecipe('category');
134
+ /** 带分类色的标签(CS20):同一形体,淡底 + 同色字经色调载体(元素另打 data-kit-tone=cN) */
135
+ export const PRESENT_TAG_TONED_CLASS = kitMarkRecipe('category', 'c1');
136
+ /**
137
+ * 标签的分类色(编译期的标签色表 tag_tones { 选项值: cN | '@k' },category-tone.ts 推出):命中就打载体属性并返回色名;没命中(引用值、超上限退化)清掉属性、返回 undefined。
138
+ * 色表里未解析的自动位 '@k'(next 下没有页面线锚点的格,E→D)按主题自动序列解析,与编译期同一规则;legacy 色表没有自动位,不读序列。
139
+ * 调用方按返回值选类。
140
+ */
141
+ function paintTagTone(el: HTMLElement, p: Record<string, unknown>, value: unknown): string | undefined {
142
+ const tone = kitCategoryToneFor(p.tag_tones, value, kitToneMapHasAuto(p.tag_tones) ? kitCategoryAutoSequence(el) : undefined);
143
+ if (tone === undefined) el.removeAttribute(KIT_LOOK_TONE_ATTR);
144
+ else el.setAttribute(KIT_LOOK_TONE_ATTR, tone);
145
+ return tone;
146
+ }
147
+ /** 多值标签 / 引用标签的行:标签之间的簇内间距,可换行 */
148
+ const PRESENT_TAGS_CLASS = 'inline-flex max-w-full min-w-0 flex-wrap items-center gap-1';
149
+ /** 引用标签:名称(标签字色)+ 编码(等宽弱化墨,同一块里) */
150
+ const PRESENT_REF_CLASS = mergeClass(PRESENT_TAG_CLASS, 'gap-1');
151
+ const PRESENT_REF_CODE_CLASS = kitMarkRecipe('code');
152
+ const PRESENT_MONO_CLASS = 'font-mono';
153
+ /** 标识符(present: code)独立成值:标记出口 ident(中性淡底 + 等宽弱化墨小块) */
154
+ const PRESENT_IDENT_CLASS = kitMarkRecipe('ident');
155
+ export const PRESENT_LEVEL_CLASS = kitMarkRecipe('level');
156
+ export const PRESENT_FLAG_CLASS = kitMarkRecipe('flag');
157
+ const PRESENT_NUM_CLASS = 'tabular-nums';
158
+ const PRESENT_BOOL_CLASS = 'inline-flex items-center gap-1';
159
+ // 链接(type: link / url):主色链接字,外链(http / https)带 ↗ 并新窗口打开(Ant Typography.Link);图片(type: image):方形圆角缩略图,边长同头像 md、加载失败回退成图标(Ant Table 图片列 / Arco Image)
160
+ const PRESENT_LINK_CLASS = mergeClass(
161
+ 'inline-flex max-w-full min-w-0 items-center gap-0.5 rounded-item text-base text-primary-on-soft hover:underline',
162
+ kitFocusRingRecipe('item'),
163
+ );
164
+ const PRESENT_IMAGE_CLASS = mergeClass(mergeClass(AVATAR_ROOT_CLASS.md, 'items-center justify-center overflow-hidden rounded-item text-fg-subtle'), kitWellRecipe());
165
+ const PRESENT_IMAGE_IMG_CLASS = 'h-full w-full object-cover';
166
+ const EXTERNAL_URL = /^https?:\/\//i;
167
+ const PRESENT_PROSE_ROOT_CLASS = 'block min-w-0';
168
+ const PRESENT_PROSE_PARA_CLASS = 'block';
169
+ const presentOf = (raw: unknown): KitTextPresent => {
170
+ const s = str(raw);
171
+ return (KIT_TEXT_PRESENTS as readonly string[]).includes(s) ? s as KitTextPresent : 'text';
48
172
  };
49
- const COPY_BTN_CLASS = 'inline-flex shrink-0 cursor-pointer items-center rounded-sm px-1.5 py-0.5 text-xs font-medium text-primary-on-soft transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
173
+ const isTrueLike = (v: unknown): boolean => v === true || v === 1 || v === 'true' || v === '1';
174
+ const isFalseLike = (v: unknown): boolean => v === false || v === 0 || v === 'false' || v === '0';
175
+ const isZero = (v: unknown): boolean => v === 0 || v === '0' || (typeof v === 'string' && v.trim() !== '' && Number(v) === 0);
176
+ const DAY_MS = 86_400_000;
177
+ const RELATIVE_REFRESH_MS = 60_000;
178
+ function timeMsOf(v: unknown): number | null {
179
+ if (v instanceof Date) return Number.isFinite(v.getTime()) ? v.getTime() : null;
180
+ if (typeof v === 'number' && Number.isFinite(v)) return v;
181
+ if (typeof v !== 'string' || v.trim() === '') return null;
182
+ const t = Date.parse(v);
183
+ return Number.isFinite(t) ? t : null;
184
+ }
185
+
186
+ function isRelativeTimeActive(p: Record<string, unknown>): boolean {
187
+ const raw = p.value;
188
+ if (raw === null || raw === undefined || raw === '' || Array.isArray(raw)) return false;
189
+ if (optionsOf(p.options).length > 0) return false;
190
+ const t = timeMsOf(raw);
191
+ if (t === null) return false;
192
+ if (str(p.format).trim() === 'relative') return true;
193
+ if (presentOf(p.present) === 'time') {
194
+ const days = Number(p.relative_within_days);
195
+ return Number.isFinite(days) && days > 0 && Math.abs(Date.now() - t) <= days * DAY_MS;
196
+ }
197
+ return false;
198
+ }
50
199
 
51
- export const KIT_TEXT_CLASS_CANDIDATES: readonly string[] = classCandidates(Object.values(COPY_ROOT_CLASS), COPY_BTN_CLASS, ...Object.values(TONE_TEXT_CLASS).flatMap((m) => Object.values(m)), ...Object.values(TAG_CLASS).flatMap((m) => Object.values(m)));
200
+ export const KIT_TEXT_CLASS_CANDIDATES: readonly string[] = classCandidates(Object.values(TEXT_EMPTY_CLASS), Object.values(COPY_ROOT_CLASS), COPY_TEXT_CLASS, COPY_BTN_CLASS, ...Object.values(TONE_TEXT_CLASS).flatMap((m) => Object.values(m)), ...[Object.values(DOT_ROOT), Object.values(DOT_TEXT), Object.values(DOT_WRAP), Object.values(DOT_CORE)].flat(),
201
+ PRESENT_TAG_CLASS, PRESENT_TAG_TONED_CLASS, PRESENT_TAGS_CLASS, PRESENT_REF_CLASS, PRESENT_REF_CODE_CLASS, PRESENT_IDENT_CLASS, PRESENT_MONO_CLASS, PRESENT_NUM_CLASS, PRESENT_BOOL_CLASS,
202
+ PRESENT_PROSE_ROOT_CLASS, PRESENT_PROSE_PARA_CLASS, PRESENT_LEVEL_CLASS, PRESENT_FLAG_CLASS,
203
+ PRESENT_LINK_CLASS, PRESENT_IMAGE_CLASS, PRESENT_IMAGE_IMG_CLASS, KIT_ICON_CLASS_CANDIDATES, 'min-w-0 truncate');
204
+ // 页面线判定(kit.overflow / kit.align)运行期才加的类不并进这里(旧版候选类与样式要逐字节不变):新模式由 data/kit-contract.ts#KIT_CONTRACT_CLASS_CANDIDATES 统一并入
52
205
 
53
206
  const COPIED_MS = 1500;
54
207
 
55
208
  interface CopyState {
56
209
  timer: ReturnType<typeof setTimeout> | null;
57
210
  copied: boolean;
211
+ valueEl: HTMLSpanElement | null;
212
+ copyBtn: HTMLButtonElement | null;
58
213
  }
59
214
  const states = new WeakMap<HTMLElement, CopyState>();
60
215
  function stateOf(root: HTMLElement): CopyState {
61
216
  let s = states.get(root);
62
217
  if (!s) {
63
- s = { timer: null, copied: false };
218
+ s = { timer: null, copied: false, valueEl: null, copyBtn: null };
64
219
  states.set(root, s);
65
220
  }
66
221
  return s;
@@ -70,8 +225,9 @@ export function resolveTextDisplay(p: Record<string, unknown>, root: HTMLElement
70
225
  const opts = optionsOf(p.options);
71
226
  const raw = p.value;
72
227
  const placeholder = str(p.placeholder);
73
- // 显式空串 '' = 有意留白,渲染为空白;null / undefined / 空数组按占位
74
- if (raw === '') return { text: '', option: null };
228
+ // 显式空串 '' = 有意留白,渲染为空白;null / undefined / 空数组按占位。
229
+ // 例外:描述列表(只读详情的键值对)里空串也是缺失值,按占位「—」显示(KT-K-desc-2,2026-11-26 主会话裁决;empty_as_missing 由描述列表格给出)
230
+ if (raw === '' && !bool(p.empty_as_missing)) return { text: '', option: null };
75
231
  if (raw === null || raw === undefined || raw === '' || (Array.isArray(raw) && raw.length === 0)) {
76
232
  return { text: placeholder, option: null };
77
233
  }
@@ -89,13 +245,181 @@ export function resolveTextDisplay(p: Record<string, unknown>, root: HTMLElement
89
245
  const dr = formatDateRangeValue(raw);
90
246
  return { text: dr !== '' ? dr : placeholder, option: null };
91
247
  }
92
- if (fmt === 'percent') {
93
- return { text: formatPercentValue(raw), option: null };
248
+ const measured = kitFormatMeasureValue(raw, { format: fmt, unit, currency, decimals: kitDecimalsOf(p.decimals) });
249
+ if (measured !== null) return { text: measured, option: null };
250
+ return displayOf(raw, opts, fmt, str(p.locale, kitLocaleAt(root) || 'zh-CN'), placeholder);
251
+ }
252
+
253
+ /** decimals 入参:非负整数才算给了(Text 契约缺省 -1 = 没给;树表 / 虚拟表的列 props、表格合计列同一判据) */
254
+ export function kitDecimalsOf(raw: unknown): number | undefined {
255
+ return typeof raw === 'number' && Number.isInteger(raw) && raw >= 0 ? raw : undefined;
256
+ }
257
+
258
+ /**
259
+ * 百分比 / 金额的显示文字(D-09:Text 正文、树表 / 虚拟表单元格、表格合计行同一出口,同一组 helper):
260
+ * format 为 percent → formatPercentValue(0..100 原值加 %,不乘 100);money / currency / currency:XXX,或没写 format 但给了 unit / currency → formatMoneyValue;
261
+ * decimals 给了按位数补齐。其余格式返回 null,调用方按各自的缺省画(Text 走 displayOf,合计行走 formatValue)。
262
+ */
263
+ export function kitFormatMeasureValue(
264
+ raw: unknown,
265
+ o: { readonly format: string; readonly unit: string; readonly currency: string; readonly decimals: number | undefined },
266
+ ): string | null {
267
+ const fmt = o.format;
268
+ if (fmt === 'percent') return formatPercentValue(raw, o.decimals !== undefined ? { decimals: o.decimals } : undefined);
269
+ if (fmt === 'money' || fmt === 'currency' || fmt.startsWith('currency:') || (fmt === '' && (o.unit !== '' || o.currency !== ''))) {
270
+ return formatMoneyValue(raw, { unit: o.unit, currency: o.currency, format: fmt, ...(o.decimals !== undefined ? { decimals: o.decimals } : {}) });
94
271
  }
95
- if (fmt === 'money' || fmt === 'currency' || fmt.startsWith('currency:') || (fmt === '' && (unit !== '' || currency !== ''))) {
96
- return { text: formatMoneyValue(raw, { unit, currency, format: fmt }), option: null };
272
+ return null;
273
+ }
274
+
275
+ /**
276
+ * 非空值按 present 画(状态与复制分支之后):画了返回 true,text 形态或不认识的形态返回 false(走正文墨的缺省画法)。
277
+ * 只换形体与字色角色,文字内容仍是 resolveTextDisplay 的结果(选项文字 / 格式化值),不另造文案。
278
+ */
279
+ function renderPresent(root: HTMLElement, p: Record<string, unknown>, text: string, size: KitSize): boolean {
280
+ const present = presentOf(p.present);
281
+ const raw = p.value;
282
+ root.removeAttribute(KIT_ATTR_TIP);
283
+ switch (present) {
284
+ case 'tag': {
285
+ const opts = optionsOf(p.options);
286
+ if (Array.isArray(raw) && raw.length > 1) {
287
+ // 多值:每个值一枚标签(同一形体、各取各的分类色),簇内间距
288
+ const chips = raw.map((v) => {
289
+ const span = document.createElement('span');
290
+ span.className = paintTagTone(span, p, v) === undefined ? PRESENT_TAG_CLASS : PRESENT_TAG_TONED_CLASS;
291
+ span.textContent = displayOf(v, opts, str(p.format), str(p.locale, kitLocaleAt(root) || 'zh-CN'), '').text;
292
+ return span;
293
+ });
294
+ root.replaceChildren(...chips);
295
+ root.removeAttribute(KIT_LOOK_TONE_ATTR);
296
+ root.className = joinClass(PRESENT_TAGS_CLASS, p.class);
297
+ return true;
298
+ }
299
+ root.textContent = text;
300
+ const tone = paintTagTone(root, p, Array.isArray(raw) ? raw[0] : raw);
301
+ root.className = joinClass(tone === undefined ? PRESENT_TAG_CLASS : PRESENT_TAG_TONED_CLASS, p.class);
302
+ return true;
303
+ }
304
+ case 'ref': {
305
+ const code = Array.isArray(raw) ? '' : str(raw);
306
+ // 候选文字自带「(编码)」尾巴的(「需求运营 (story_ops)」)去掉尾巴,编码只写一次(弱化等宽)
307
+ const bare = code === '' ? text : text.replace(new RegExp(`\\s*[((]\\s*${code.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*[))]\\s*$`), '');
308
+ if (code === '' || code === text || bare.includes(code) || bare === '') {
309
+ root.textContent = text;
310
+ root.className = joinClass(PRESENT_TAG_CLASS, p.class);
311
+ return true;
312
+ }
313
+ const name = document.createElement('span');
314
+ name.textContent = bare;
315
+ const codeEl = document.createElement('span');
316
+ codeEl.className = PRESENT_REF_CODE_CLASS;
317
+ codeEl.textContent = code;
318
+ root.replaceChildren(name, codeEl);
319
+ root.className = joinClass(PRESENT_REF_CLASS, p.class);
320
+ return true;
321
+ }
322
+ case 'code':
323
+ // 标识符独立成值:中性淡底等宽小块(标记出口 ident;带复制钮的详情 / 摘要条另走复制分支,仍是等宽文字 + 复制钮)
324
+ root.className = joinClass(PRESENT_IDENT_CLASS, p.class);
325
+ return true;
326
+ case 'link': {
327
+ // 只放行相对地址 / 锚点 / http(s) / mailto / tel(safeHref);不安全或没有地址退回正文文字
328
+ const href = safeHref(str(raw));
329
+ if (href === '' || Array.isArray(raw)) return false;
330
+ const a = document.createElement('a');
331
+ a.setAttribute('href', href);
332
+ const label = document.createElement('span');
333
+ label.className = 'min-w-0 truncate';
334
+ label.textContent = text;
335
+ a.appendChild(label);
336
+ if (EXTERNAL_URL.test(href)) {
337
+ a.setAttribute('target', '_blank');
338
+ a.setAttribute('rel', 'noopener noreferrer');
339
+ a.appendChild(kitIcon('external-link', 'xs'));
340
+ }
341
+ root.replaceChildren(a);
342
+ root.className = joinClass('inline-flex max-w-full min-w-0', p.class);
343
+ a.className = PRESENT_LINK_CLASS;
344
+ return true;
345
+ }
346
+ case 'image': {
347
+ // 缩略图:不安全地址或加载失败画成图标占位;图片只作装饰(alt 空),可访问名取字段文字
348
+ const src = safeSrc(str(raw));
349
+ const holder = document.createElement('span');
350
+ holder.className = PRESENT_IMAGE_CLASS;
351
+ holder.setAttribute('role', 'img');
352
+ holder.setAttribute('aria-label', str(p.alt, text));
353
+ const fallback = (): void => holder.replaceChildren(kitIcon('file', 'sm'));
354
+ if (src === '' || Array.isArray(raw)) fallback();
355
+ else {
356
+ const img = document.createElement('img');
357
+ img.className = PRESENT_IMAGE_IMG_CLASS;
358
+ img.setAttribute('src', src);
359
+ img.setAttribute('alt', '');
360
+ img.setAttribute('loading', 'lazy');
361
+ img.addEventListener('error', fallback, { once: true });
362
+ holder.appendChild(img);
363
+ }
364
+ root.replaceChildren(holder);
365
+ root.className = joinClass('inline-flex max-w-full', p.class);
366
+ return true;
367
+ }
368
+ case 'level':
369
+ // 等级(L1–L3、P0–P3):弱化墨等宽纯文字,不成块(标记出口 level)
370
+ root.textContent = text;
371
+ root.className = joinClass(PRESENT_LEVEL_CLASS, p.class);
372
+ return true;
373
+ case 'flag':
374
+ // 标志(内置、锁定、只读):弱化墨纯文字,不成块(标记出口 flag)
375
+ root.textContent = text;
376
+ root.className = joinClass(PRESENT_FLAG_CLASS, p.class);
377
+ return true;
378
+ case 'bool': {
379
+ // 有选项(true_label 一类)时 resolveTextDisplay 已给出选项文字,按正文画;只认原值的真假
380
+ if (optionsOf(p.options).length > 0 || (!isTrueLike(raw) && !isFalseLike(raw))) return false;
381
+ if (isTrueLike(raw)) {
382
+ root.replaceChildren(kitIcon('check', 'sm'), document.createTextNode(kitText('soma.kit.yes', undefined, root)));
383
+ root.className = joinClass(mergeClass(TEXT_CLASS[size], PRESENT_BOOL_CLASS), p.class);
384
+ } else {
385
+ root.textContent = kitText('soma.kit.no', undefined, root);
386
+ root.className = joinClass(TEXT_EMPTY_CLASS[size], p.class);
387
+ }
388
+ return true;
389
+ }
390
+ case 'count':
391
+ root.className = joinClass(mergeClass(isZero(raw) ? TEXT_EMPTY_CLASS[size] : TEXT_CLASS[size], PRESENT_NUM_CLASS), p.class);
392
+ return true;
393
+ case 'prose': {
394
+ // 成段正文:每段一个块级 span(宿主可能是行内元素,不放 <p>),段首缩进 / 行高 / 版心只从成段正文出口取;JSON / 代码样长文本照原样(走缺省画法)
395
+ if (kitProseIsCode(text)) return false;
396
+ const paras = kitProseParagraphs(text);
397
+ const fit = kitProseFit(paras);
398
+ root.replaceChildren(...paras.map((para) => {
399
+ const el = document.createElement('span');
400
+ el.className = mergeClass(PRESENT_PROSE_PARA_CLASS, fit.classOf(para));
401
+ el.setAttribute(KIT_PROSE_ATTR, fit.indent ? 'indent' : 'flat');
402
+ el.textContent = para;
403
+ return el;
404
+ }));
405
+ root.className = joinClass(mergeClass(TEXT_CLASS[size], PRESENT_PROSE_ROOT_CLASS), p.class);
406
+ return true;
407
+ }
408
+ case 'time': {
409
+ const days = Number(p.relative_within_days);
410
+ const t = timeMsOf(raw);
411
+ if (t !== null && Number.isFinite(days) && days > 0 && Math.abs(Date.now() - t) <= days * DAY_MS) {
412
+ const locale = str(p.locale, kitLocaleAt(root) || 'zh-CN');
413
+ // 近期写相对时间,绝对时间进悬停 / 聚焦提示(base/hint-tips)
414
+ root.textContent = formatValue(raw, 'relative', locale);
415
+ root.setAttribute(KIT_ATTR_TIP, text);
416
+ }
417
+ root.className = joinClass(mergeClass(TEXT_CLASS[size], PRESENT_NUM_CLASS), p.class);
418
+ return true;
419
+ }
420
+ default:
421
+ return false;
97
422
  }
98
- return displayOf(raw, opts, fmt, str(p.locale, kitLocaleAt(root) || 'zh-CN'), placeholder);
99
423
  }
100
424
 
101
425
  export function createText(): SomaComponentDefinition {
@@ -109,88 +433,178 @@ export function createText(): SomaComponentDefinition {
109
433
  format: { type: 'string', default: '', desc: 'number / money / percent / currency:CNY / date / datetime / daterange / relative / bytes / duration:s' },
110
434
  unit: { type: 'string', default: '', desc: '金额或数值单位符号(如 $ / € / ¥)' },
111
435
  currency: { type: 'string', default: '', desc: '币种代码(如 USD / EUR / CNY)' },
436
+ decimals: { type: 'number', default: -1, desc: '小数位(format 为 percent / money / currency 时生效,非负整数按位数补齐);负数 = 没给:百分比按数值原样(至多 4 位)、金额按币种(ISO 4217)。与树表 / 虚拟表单元格、表格合计行同一口径(kitFormatMeasureValue)' },
112
437
  locale: { type: 'string', default: '', desc: '格式化语言;缺省取页面语言(page.locale),都没声明为 zh-CN' },
113
438
  placeholder: { type: 'string', default: '', desc: '空值时显示的文字' },
439
+ empty_as_missing: { type: 'boolean', default: false, desc: '显式空串也按缺失显示占位(描述列表的键值格由框架给出,KT-K-desc-2);缺省 false = 显式空串留白' },
114
440
  copyable: { type: 'boolean', default: false, desc: '文字后带「复制」钮,复制显示出来的文字' },
115
441
  copy_label: { type: 'string', default: '', desc: '复制钮文字;缺省取内置文案(按页面语言)' },
116
442
  copied_label: { type: 'string', default: '', desc: '复制成功后短暂显示的文字;缺省取内置文案(按页面语言)' },
117
- tone_as: { type: 'string', default: 'tag', desc: '选项带 tone 时的呈现:tag = 徽标(缺省)/ text = 纯文字着色(无底无描边)' },
443
+ tone_as: { type: 'string', default: 'dot', desc: '选项带 tone 时的呈现(值带语气 = 状态):dot = 6px 圆点 + 语义色文字(缺省,KT-K-status-1)/ text = 纯文字着色(无圆点);旧值 tag 按 dot 画(状态与标签永不同形)' },
444
+ present: { type: 'string', default: '', desc: '只读值的呈现形态(编译期按字段类型推出,DC4-1):text / tag(分类标签)/ ref(引用:名称 + 弱化编码)/ code(标识符等宽)/ bool(是 / 否)/ count(等宽数字,0 弱化)/ time(近期相对时间 + 提示绝对时间)/ prose(长文本成段正文:按换行分段,段首缩进由成段正文出口判定)/ level(等级:弱化墨等宽纯文字)/ flag(标志:弱化墨纯文字);选项带语气时恒为状态(圆点 + 文字)' },
445
+ tag_tones: { type: 'object', default: {}, desc: 'present: tag 时的标签色表 { 选项值: 分类色名 c1…c8 }(编译期按 CS20 分类色缺省分配推出,页面不写):命中的值画成该色的淡底 + 同色字标签,没命中的中性' },
446
+ relative_within_days: { type: 'number', default: 0, desc: 'present: time 时,距今不超过这么多天写相对时间(编译期取真源 readonlyPresent.relativeDays);0 = 一律绝对时间' },
118
447
  size: SIZE_PROP,
119
448
  class: CLASS_PROP,
449
+ look: { type: 'object', default: {}, desc: '界面规则(look)编译出的部件外观表(保留 prop,页面不直接写):{ value: { tone?, ink?, overflow? } };作字段值时部件 value(角色 value)' },
120
450
  },
121
451
  emits: {
122
452
  copy: { payload: { ok: { type: 'boolean' } }, desc: '点复制钮后抛,ok 表示剪贴板写入成功' },
123
453
  },
124
454
  },
125
455
  templateHtml: '<span data-soma-id="root" class="text-base text-fg"></span>',
126
- controllerFactory: createKitController(() => ({
127
- attach(root, api) {
128
- const s = stateOf(root);
129
- const onClick = (event: Event): void => {
130
- const btn = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-action="copy"]');
131
- if (!btn || !root.contains(btn)) return;
132
- const p = api.props();
133
- const { text } = resolveTextDisplay(p, root);
134
- const done = (ok: boolean): void => {
135
- if (ok) {
136
- s.copied = true;
137
- if (s.timer !== null) clearTimeout(s.timer);
138
- s.timer = setTimeout(() => {
139
- s.copied = false;
140
- s.timer = null;
141
- const b = root.querySelector<HTMLElement>('[data-kit-action="copy"]');
142
- if (b) b.textContent = str(api.props().copy_label, kitText('soma.kit.copy', undefined, root));
143
- }, COPIED_MS);
144
- const b = root.querySelector<HTMLElement>('[data-kit-action="copy"]');
145
- if (b) b.textContent = str(api.props().copied_label, kitText('soma.kit.copied', undefined, root));
456
+ controllerFactory: createKitController(() => {
457
+ let mounted = false;
458
+ let activeApi: KitApi | null = null;
459
+ let lastProps: Record<string, unknown> = {};
460
+ let tickTimer: ReturnType<typeof setInterval> | null = null;
461
+ const stopTick = (): void => {
462
+ if (tickTimer !== null) {
463
+ clearInterval(tickTimer);
464
+ tickTimer = null;
465
+ }
466
+ };
467
+ const renderAll = (root: HTMLElement, raw: Record<string, unknown>, host?: HTMLElement): void => {
468
+ const p = withTextKit(raw, root);
469
+ paintText(root, p);
470
+ // 自报:值节点按当轮内容报元素部件;空值占位时组件根报「内容全空」(没有 kit 时只多这两个属性,类与内容不变)
471
+ kitMarkElementPart(root, textPartOf(p, root));
472
+ // 文本角色标记只在页面线的溢出策略生效时写(自己的类串已有溢出取向时不写,免得标记与实际的类对不上)
473
+ kitApplyOverflowMark(root, textKitOverflowOf(raw));
474
+ if (host !== undefined) kitMarkDataState(kitOuterRoot(host, root), isEmptyValue(p.value) ? 'empty' : 'normal');
475
+ // 界面规则(look):字段值部件 value。值画成标签时按标记角色落(淡底 + 同色字,分类色在这里生效),其余按值角色落(墨色;分类色不染纯文字);没写规则时什么都不改
476
+ applyLook(root, p.look as KitLookProp | undefined, 'value', presentOf(p.present) === 'tag' ? 'mark' : 'value');
477
+ };
478
+ const syncRelativeTimer = (root: HTMLElement, p: Record<string, unknown>): void => {
479
+ if (mounted && isRelativeTimeActive(p)) {
480
+ if (tickTimer === null) {
481
+ tickTimer = setInterval(() => {
482
+ const cur = activeApi ? activeApi.props() : lastProps;
483
+ if (!mounted || !isRelativeTimeActive(cur)) {
484
+ stopTick();
485
+ return;
486
+ }
487
+ renderAll(root, cur);
488
+ }, RELATIVE_REFRESH_MS);
489
+ }
490
+ } else {
491
+ stopTick();
492
+ }
493
+ };
494
+ return {
495
+ attach(root, api) {
496
+ mounted = true;
497
+ activeApi = api;
498
+ const s = stateOf(root);
499
+ syncRelativeTimer(root, api.props());
500
+ const onClick = (event: Event): void => {
501
+ const btn = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_ACTION}="copy"]`);
502
+ if (!btn || !root.contains(btn)) return;
503
+ const p = api.props();
504
+ const { text } = resolveTextDisplay(p, root);
505
+ const done = (ok: boolean): void => {
506
+ if (ok) {
507
+ s.copied = true;
508
+ if (s.timer !== null) clearTimeout(s.timer);
509
+ s.timer = setTimeout(() => {
510
+ s.copied = false;
511
+ s.timer = null;
512
+ const b = root.querySelector<HTMLElement>(`[${KIT_ATTR_ACTION}="copy"]`);
513
+ if (b) setKitCopyButton(b, str(api.props().copy_label, kitText('soma.kit.copy', undefined, root)), false);
514
+ }, COPIED_MS);
515
+ const b = root.querySelector<HTMLElement>(`[${KIT_ATTR_ACTION}="copy"]`);
516
+ if (b) setKitCopyButton(b, str(api.props().copied_label, kitText('soma.kit.copied', undefined, root)), true);
517
+ }
518
+ api.emit('copy', { ok });
519
+ };
520
+ const clip = typeof navigator !== 'undefined' ? navigator.clipboard : undefined;
521
+ if (!clip || typeof clip.writeText !== 'function') {
522
+ done(false);
523
+ return;
146
524
  }
147
- api.emit('copy', { ok });
525
+ clip.writeText(text).then(() => done(true), () => done(false));
148
526
  };
149
- const clip = typeof navigator !== 'undefined' ? navigator.clipboard : undefined;
150
- if (!clip || typeof clip.writeText !== 'function') {
151
- done(false);
152
- return;
153
- }
154
- clip.writeText(text).then(() => done(true), () => done(false));
155
- };
156
- root.addEventListener('click', onClick);
157
- return () => {
158
- root.removeEventListener('click', onClick);
159
- if (s.timer !== null) clearTimeout(s.timer);
160
- s.timer = null;
161
- s.copied = false;
162
- };
163
- },
164
- render(root, p) {
527
+ root.addEventListener('click', onClick);
528
+ return () => {
529
+ mounted = false;
530
+ activeApi = null;
531
+ stopTick();
532
+ root.removeEventListener('click', onClick);
533
+ if (s.timer !== null) clearTimeout(s.timer);
534
+ s.timer = null;
535
+ s.copied = false;
536
+ };
537
+ },
538
+ render(root, p, api) {
539
+ lastProps = p;
540
+ renderAll(root, p, api.host);
541
+ syncRelativeTimer(root, p);
542
+ },
543
+ };
544
+ }),
545
+ };
546
+ }
547
+
548
+ /** Text 的画法(各形态分支);界面规则在它之后由 applyLook 统一落 */
549
+ function paintText(root: HTMLElement, p: Record<string, unknown>): void {
165
550
  const { text, option } = resolveTextDisplay(p, root);
166
- const tone = option?.tone;
551
+ // 语气:选项自带的语气优先(组件自己的入参),没有时取页面线判定的语义色调(kit.tone,none 不着色)
552
+ const tone = option?.tone ?? kitToneOfPipeline(kitReadProps(p).tone) ?? undefined;
167
553
  const size = sizeOf(p.size);
168
554
  const raw = p.value;
169
555
  const empty = raw === null || raw === undefined || raw === '' || (Array.isArray(raw) && raw.length === 0);
170
- root.textContent = text;
556
+ // 分类色载体只由本次的标签分支打(上一次渲染留下的清掉);界面规则(applyLook)在其后落,压过它
557
+ root.removeAttribute(KIT_LOOK_TONE_ATTR);
171
558
  // 不再给每个值写原生 title(无论是否被截断都冒气泡,且不可键盘 / 读屏):被截断的文字由 hint-tips 的委托在悬停 / 聚焦时现量、才挂 kitTooltip
172
559
  root.removeAttribute('title');
173
560
  // 自带 truncate 类的值自己标出提示作用范围(独立使用、不在表格 / 摘要格里时也有截断全文提示)
174
- if (/(?:^|\s)(?:[a-z0-9*@-]+:)*truncate(?=\s|$)/.test(str(p.class))) root.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
175
- else root.removeAttribute(KIT_TIPS_SCOPE_ATTR);
561
+ if (/(?:^|\s)(?:[a-z0-9*@-]+:)*truncate(?=\s|$)/.test(str(p.class))) root.setAttribute(KIT_ATTR_TIPS, '');
562
+ else root.removeAttribute(KIT_ATTR_TIPS);
176
563
  if (bool(p.copyable) && !empty) {
177
564
  const s = stateOf(root);
178
- const btn = document.createElement('button');
179
- btn.setAttribute('type', 'button');
180
- btn.setAttribute('data-kit-action', 'copy');
565
+ root.removeAttribute(KIT_ATTR_TIP);
566
+ let valueEl = s.valueEl;
567
+ if (!valueEl) {
568
+ valueEl = document.createElement('span');
569
+ s.valueEl = valueEl;
570
+ }
571
+ // 带复制钮的标识符同样是中性淡底等宽小块(标记出口 ident,C9;此前是等宽文字 + 远处的复制钮),标识不截断
572
+ valueEl.className = presentOf(p.present) === 'code' ? PRESENT_IDENT_CLASS : COPY_TEXT_CLASS;
573
+ valueEl.setAttribute(KIT_ATTR_TIPS, '');
574
+ valueEl.textContent = text;
575
+ let btn = s.copyBtn;
576
+ if (!btn) {
577
+ btn = document.createElement('button');
578
+ btn.setAttribute('type', 'button');
579
+ btn.setAttribute(KIT_ATTR_ACTION, 'copy');
580
+ s.copyBtn = btn;
581
+ }
181
582
  btn.className = COPY_BTN_CLASS;
182
- btn.textContent = s.copied ? str(p.copied_label, kitText('soma.kit.copied', undefined, root)) : str(p.copy_label, kitText('soma.kit.copy', undefined, root));
183
- root.appendChild(btn);
583
+ setKitCopyButton(btn, s.copied ? str(p.copied_label, kitText('soma.kit.copied', undefined, root)) : str(p.copy_label, kitText('soma.kit.copy', undefined, root)), s.copied);
584
+ if (root.childNodes.length !== 2 || root.firstChild !== valueEl || root.lastChild !== btn) {
585
+ root.replaceChildren(valueEl, btn);
586
+ }
184
587
  root.className = joinClass(COPY_ROOT_CLASS[size], p.class);
185
588
  return;
186
589
  }
590
+ root.textContent = text;
187
591
  if (!empty && !bool(p.copyable) && tone !== undefined) {
188
- // tone_as: text = 纯文字着色(text-<tone>-on-soft,无底无描边);缺省 tag = 徽标
189
- root.className = joinClass(str(p.tone_as) === TONE_AS_TEXT ? TONE_TEXT_CLASS[size][tone] : TAG_CLASS[size][tone], p.class);
592
+ // 值带语气 = 状态(knowledge/Kit主题规则与算法.md KT-K-status-1 / 3):缺省呈现为 6px 圆点 + 语义色文字、无底无框(与 Tag dot 同一组类);
593
+ // tone_as: text = 纯文字着色(无圆点)。旧值 tag(浅底徽标)已删:状态与标签永不同形,按圆点画
594
+ if (str(p.tone_as) === TONE_AS_TEXT) {
595
+ root.className = joinClass(TONE_TEXT_CLASS[size][tone], p.class);
596
+ return;
597
+ }
598
+ const dot = document.createElement('span');
599
+ dot.setAttribute('aria-hidden', 'true');
600
+ dot.className = DOT_WRAP[size];
601
+ const core = document.createElement('span');
602
+ core.className = DOT_CORE[tone];
603
+ dot.appendChild(core);
604
+ root.replaceChildren(dot, document.createTextNode(text));
605
+ root.className = joinClass(`${DOT_ROOT[size]} ${DOT_TEXT[tone]}`, p.class);
190
606
  return;
191
607
  }
192
- root.className = joinClass(TEXT_CLASS[size], p.class);
193
- },
194
- })),
195
- };
608
+ if (!empty && renderPresent(root, p, text, size)) return;
609
+ root.className = joinClass(empty && text !== '' ? TEXT_EMPTY_CLASS[size] : TEXT_CLASS[size], p.class);
196
610
  }