soma-kit 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (470) hide show
  1. package/README.md +1 -1
  2. package/package.json +8 -5
  3. package/packs/ai/model-card.ts +3 -3
  4. package/packs/ops/error-budget-card.ts +3 -3
  5. package/packs/ops/release-readiness-card.ts +3 -3
  6. package/packs/security/control-evidence-card.ts +3 -3
  7. package/packs/security/finding-card.ts +3 -2
  8. package/packs/shared/card-util.ts +17 -0
  9. package/spec/generated/kit-app.schema.json +2148 -340
  10. package/spec/generated/kit-page.schema.json +1134 -139
  11. package/spec/kit-grammar.json +935 -93
  12. package/spec/kit-grammar.schema.json +167 -2
  13. package/src/app/app-config.ts +219 -186
  14. package/src/app/define-kit-actions.ts +126 -20
  15. package/src/app/define-kit-app.ts +49 -4
  16. package/src/app/index.ts +5 -0
  17. package/src/app/kit-view-context.ts +39 -1
  18. package/src/app/list-page-defaults.ts +14 -0
  19. package/src/app/server-pages.ts +239 -7
  20. package/src/app/server.ts +466 -25
  21. package/src/app/theme-endpoint.ts +67 -23
  22. package/src/app/theme-runtime.ts +414 -85
  23. package/src/app/theme-shards.ts +69 -0
  24. package/src/app/tier-compat.ts +107 -0
  25. package/src/base/action-busy.ts +215 -38
  26. package/src/base/affix.ts +137 -0
  27. package/src/base/alert.ts +104 -59
  28. package/src/base/anchored-layer.ts +7 -6
  29. package/src/base/avatar.ts +147 -61
  30. package/src/base/badge.ts +186 -0
  31. package/src/base/button-group.ts +227 -0
  32. package/src/base/button.ts +347 -50
  33. package/src/base/card.ts +233 -0
  34. package/src/base/cascader.ts +143 -32
  35. package/src/base/check-core.ts +193 -33
  36. package/src/base/checkbox.ts +67 -2
  37. package/src/base/choice.ts +132 -31
  38. package/src/base/collapse.ts +249 -0
  39. package/src/base/color-picker.ts +399 -27
  40. package/src/base/combobox.ts +6 -2
  41. package/src/base/command-palette.ts +148 -36
  42. package/src/base/context-menu.ts +23 -6
  43. package/src/base/countdown.ts +37 -15
  44. package/src/base/date-range.ts +114 -96
  45. package/src/base/date.ts +481 -74
  46. package/src/base/delta.ts +16 -9
  47. package/src/base/divider.ts +51 -33
  48. package/src/base/end-edge.ts +10 -4
  49. package/src/base/fab.ts +57 -21
  50. package/src/base/gap-value.ts +34 -15
  51. package/src/base/hint-tips.ts +99 -29
  52. package/src/base/identity-cells.ts +839 -0
  53. package/src/base/illustrations.ts +6 -4
  54. package/src/base/image.ts +40 -19
  55. package/src/base/index.ts +79 -22
  56. package/src/base/inline-error.ts +13 -7
  57. package/src/base/input.ts +135 -35
  58. package/src/base/kbd.ts +30 -17
  59. package/src/base/kit-contract.ts +400 -0
  60. package/src/base/link.ts +41 -20
  61. package/src/base/listbox-core.ts +282 -101
  62. package/src/base/loading-gate.ts +3 -0
  63. package/src/base/look.ts +197 -0
  64. package/src/base/mentions.ts +55 -22
  65. package/src/base/menu-button.ts +73 -22
  66. package/src/base/menu-core.ts +201 -24
  67. package/src/base/month-grid.ts +60 -3
  68. package/src/base/motion/aura.ts +52 -10
  69. package/src/base/motion/hover-3d.ts +7 -5
  70. package/src/base/motion/hover-gallery.ts +16 -12
  71. package/src/base/motion/limits.ts +10 -0
  72. package/src/base/motion/marquee.ts +18 -11
  73. package/src/base/motion/text-rotate.ts +34 -16
  74. package/src/base/notification.ts +292 -0
  75. package/src/base/number.ts +93 -12
  76. package/src/base/otp.ts +139 -27
  77. package/src/base/overlay-runtime.ts +30 -23
  78. package/src/base/overlay-shell.ts +59 -14
  79. package/src/base/period-picker.ts +868 -0
  80. package/src/base/popover.ts +624 -73
  81. package/src/base/popup.ts +187 -52
  82. package/src/base/portal-core.ts +99 -2
  83. package/src/base/price-text.ts +51 -17
  84. package/src/base/progress.ts +100 -18
  85. package/src/base/qr-code.ts +64 -17
  86. package/src/base/qty-stepper.ts +141 -22
  87. package/src/base/radio.ts +43 -2
  88. package/src/base/range.ts +194 -39
  89. package/src/base/rating.ts +117 -31
  90. package/src/base/reason-tip.ts +58 -16
  91. package/src/base/relation-cells.ts +541 -0
  92. package/src/base/resize-handle.ts +5 -3
  93. package/src/base/row-fresh.ts +84 -0
  94. package/src/base/section-spy.ts +79 -0
  95. package/src/base/segmented.ts +70 -26
  96. package/src/base/select.ts +8 -3
  97. package/src/base/shared.ts +482 -71
  98. package/src/base/spinner.ts +107 -0
  99. package/src/base/state-panel.ts +77 -22
  100. package/src/base/sticky-edge.ts +96 -29
  101. package/src/base/swap.ts +39 -21
  102. package/src/base/switch.ts +158 -38
  103. package/src/base/tabs.ts +292 -0
  104. package/src/base/tag-input.ts +123 -54
  105. package/src/base/tag.ts +184 -66
  106. package/src/base/text.ts +461 -71
  107. package/src/base/textarea.ts +88 -39
  108. package/src/base/time-picker.ts +335 -55
  109. package/src/base/time-range.ts +846 -0
  110. package/src/base/tree-select.ts +342 -88
  111. package/src/base/upload.ts +604 -158
  112. package/src/base/view-transition.ts +7 -3
  113. package/src/base/virtual-list.ts +49 -14
  114. package/src/biz/approval-desk/compile.ts +70 -5
  115. package/src/biz/approval-desk/index.ts +2 -0
  116. package/src/biz/approval-desk/shell.ts +52 -12
  117. package/src/biz/auth-panel/compile.ts +13 -3
  118. package/src/biz/auth-panel/shell.ts +27 -7
  119. package/src/biz/category-crud/compile.ts +51 -13
  120. package/src/biz/category-crud/index.ts +2 -0
  121. package/src/biz/category-crud/shell.ts +29 -9
  122. package/src/biz/checkout-page/compile.ts +37 -3
  123. package/src/biz/checkout-page/index.ts +1 -0
  124. package/src/biz/checkout-page/shell.ts +26 -9
  125. package/src/biz/compose.ts +6 -1
  126. package/src/biz/data-components.ts +2 -0
  127. package/src/biz/import-wizard/compile.ts +4 -1
  128. package/src/biz/import-wizard/index.ts +1 -0
  129. package/src/biz/import-wizard/shell.ts +32 -18
  130. package/src/biz/index.ts +1 -1
  131. package/src/biz/landing-page/compile.ts +3 -2
  132. package/src/biz/landing-page/shell.ts +22 -3
  133. package/src/biz/layout-contracts.ts +918 -0
  134. package/src/biz/link/hub.ts +199 -8
  135. package/src/biz/link/shared.ts +54 -15
  136. package/src/biz/master-sub/compile.ts +194 -57
  137. package/src/biz/master-sub/detail-head.ts +141 -18
  138. package/src/biz/master-sub/index.ts +3 -0
  139. package/src/biz/master-sub/shell.ts +188 -62
  140. package/src/biz/multi-board/compile.ts +87 -36
  141. package/src/biz/multi-board/composition.ts +7 -20
  142. package/src/biz/multi-board/index.ts +3 -2
  143. package/src/biz/multi-board/prose-fold.ts +15 -11
  144. package/src/biz/multi-board/shell.ts +148 -37
  145. package/src/biz/notification-center/compile.ts +20 -6
  146. package/src/biz/notification-center/index.ts +2 -0
  147. package/src/biz/notification-center/shell.ts +43 -10
  148. package/src/biz/page-templates/domain-templates.ts +145 -22
  149. package/src/biz/page-templates/result-page/compile.ts +4 -1
  150. package/src/biz/page-templates/result-page/index.ts +1 -0
  151. package/src/biz/page-templates/result-page/shell.ts +17 -4
  152. package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
  153. package/src/biz/page-templates/sign-in-page/index.ts +1 -0
  154. package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
  155. package/src/biz/record-detail/compile.ts +39 -11
  156. package/src/biz/record-detail/index.ts +1 -0
  157. package/src/biz/record-detail/shell.ts +41 -10
  158. package/src/biz/settings-center/compile.ts +4 -1
  159. package/src/biz/settings-center/index.ts +1 -0
  160. package/src/biz/settings-center/shell.ts +30 -9
  161. package/src/biz/shared/action-host.ts +137 -46
  162. package/src/biz/shared/compile-helpers.ts +152 -28
  163. package/src/biz/shared/coordinator.ts +628 -147
  164. package/src/biz/shared/focus-return.ts +180 -0
  165. package/src/biz/shared/object-aliases.ts +7 -1
  166. package/src/biz/shared/overlay-compile.ts +58 -10
  167. package/src/biz/shared/overlay-shell.ts +40 -10
  168. package/src/biz/shared/page-form-actions.ts +151 -0
  169. package/src/biz/shared/page-form.ts +255 -0
  170. package/src/biz/shared/pipeline.ts +74 -0
  171. package/src/biz/shared/runtime-hub.ts +101 -8
  172. package/src/biz/shared/verbs.ts +129 -0
  173. package/src/biz/single-form/compile.ts +4 -2
  174. package/src/biz/single-form/index.ts +2 -0
  175. package/src/biz/single-form/shell.ts +21 -11
  176. package/src/biz/standard-crud/compile.ts +206 -38
  177. package/src/biz/standard-crud/index.ts +2 -1
  178. package/src/biz/standard-crud/shell.ts +82 -22
  179. package/src/biz/standard-crud/summary.ts +2 -37
  180. package/src/biz/step-form/compile.ts +12 -3
  181. package/src/biz/step-form/hub.ts +165 -50
  182. package/src/biz/step-form/index.ts +1 -0
  183. package/src/biz/step-form/shell.ts +31 -15
  184. package/src/biz/types.ts +40 -4
  185. package/src/cli/kit-cli.ts +145 -26
  186. package/src/cli/kit-init.ts +3 -3
  187. package/src/cli/migrate/theme-map.ts +35 -28
  188. package/src/cli/migrate/ts-rules.ts +2 -2
  189. package/src/cli/migrate/types.ts +3 -3
  190. package/src/cli/migrate/yaml-rules.ts +11 -9
  191. package/src/cli/view-writes.ts +13 -0
  192. package/src/compile/closed-set.ts +102 -6
  193. package/src/compile/compile-page.ts +446 -53
  194. package/src/compile/component-candidates.ts +56 -4
  195. package/src/compile/danger-tier.ts +65 -0
  196. package/src/compile/hints.ts +1 -1
  197. package/src/compile/info-structure.ts +155 -0
  198. package/src/compile/layout-lint/rules-composition.ts +2 -1
  199. package/src/compile/layout-lint/rules-table.ts +4 -19
  200. package/src/compile/look-page.ts +551 -0
  201. package/src/compile/look.ts +376 -0
  202. package/src/compile/page-composition.ts +382 -46
  203. package/src/compile/page-hierarchy.ts +131 -0
  204. package/src/compile/page-pipeline-look.ts +156 -0
  205. package/src/compile/page-pipeline.ts +200 -0
  206. package/src/compile/parse.ts +12 -11
  207. package/src/compile/relation-render.ts +120 -0
  208. package/src/compile/remove-guard.ts +115 -41
  209. package/src/compile/stages.ts +645 -28
  210. package/src/compile/styles.ts +226 -26
  211. package/src/compile/types.ts +62 -5
  212. package/src/compile/view-check.ts +190 -1
  213. package/src/data/access-gate.ts +17 -9
  214. package/src/data/amount-breakdown.ts +49 -22
  215. package/src/data/anchor-nav.ts +73 -15
  216. package/src/data/approval-flow.ts +210 -124
  217. package/src/data/assignment-picker.ts +163 -85
  218. package/src/data/async-result-panel.ts +110 -46
  219. package/src/data/audit-log.ts +461 -0
  220. package/src/data/breadcrumbs.ts +141 -19
  221. package/src/data/calendar.ts +434 -96
  222. package/src/data/card-grid.ts +319 -0
  223. package/src/data/carousel.ts +72 -38
  224. package/src/data/cell-value.ts +253 -0
  225. package/src/data/chart.ts +904 -77
  226. package/src/data/checklist.ts +78 -35
  227. package/src/data/code-view.ts +106 -48
  228. package/src/data/comment-thread.ts +607 -87
  229. package/src/data/compare-view.ts +227 -0
  230. package/src/data/confirm-dialog.ts +198 -30
  231. package/src/data/context-menu.ts +95 -21
  232. package/src/data/d9-limits.ts +2 -0
  233. package/src/data/d9-util.ts +13 -5
  234. package/src/data/diff.ts +107 -50
  235. package/src/data/display-util.ts +9 -4
  236. package/src/data/dock.ts +33 -17
  237. package/src/data/embed.ts +142 -7
  238. package/src/data/engine-ports.ts +13 -4
  239. package/src/data/field-mapper.ts +104 -48
  240. package/src/data/file-list.ts +522 -0
  241. package/src/data/flow-editor.ts +603 -142
  242. package/src/data/flow-node-options.ts +24 -5
  243. package/src/data/flow-remote-options.ts +94 -19
  244. package/src/data/footer.ts +85 -27
  245. package/src/data/form-draft-registry.ts +183 -12
  246. package/src/data/gantt.ts +637 -117
  247. package/src/data/graph-view.ts +51 -0
  248. package/src/data/heat-calendar.ts +412 -0
  249. package/src/data/hero.ts +38 -15
  250. package/src/data/image-viewer.ts +261 -62
  251. package/src/data/index.ts +63 -1
  252. package/src/data/item-list.ts +217 -57
  253. package/src/data/json-view.ts +165 -100
  254. package/src/data/kanban.ts +339 -87
  255. package/src/data/kit-contract.ts +230 -0
  256. package/src/data/leaderboard.ts +343 -0
  257. package/src/data/level-class.ts +21 -0
  258. package/src/data/log-stream.ts +347 -0
  259. package/src/data/markdown-view.ts +155 -45
  260. package/src/data/matrix.ts +217 -112
  261. package/src/data/media-grid.ts +162 -38
  262. package/src/data/mega-menu.ts +39 -23
  263. package/src/data/menu-bar.ts +254 -0
  264. package/src/data/menu-dom.ts +50 -15
  265. package/src/data/menu.ts +131 -47
  266. package/src/data/mockup.ts +30 -22
  267. package/src/data/modal-dialog.ts +90 -13
  268. package/src/data/navbar.ts +143 -61
  269. package/src/data/notice-list.ts +100 -48
  270. package/src/data/notify-renderer.ts +61 -7
  271. package/src/data/object-form.ts +1389 -130
  272. package/src/data/org-chart.ts +544 -0
  273. package/src/data/outcome-watch.ts +90 -21
  274. package/src/data/pager.ts +122 -42
  275. package/src/data/panel-head.ts +237 -75
  276. package/src/data/permission-matrix.ts +371 -119
  277. package/src/data/permission-tree.ts +135 -80
  278. package/src/data/pricing-table.ts +106 -42
  279. package/src/data/prompt-dialog.ts +49 -21
  280. package/src/data/reaction-bar.ts +63 -31
  281. package/src/data/record-card.ts +239 -70
  282. package/src/data/record-picker.ts +56 -27
  283. package/src/data/redirect.ts +39 -15
  284. package/src/data/request-console.ts +131 -41
  285. package/src/data/resident.ts +11 -1
  286. package/src/data/result-panel.ts +65 -27
  287. package/src/data/rich-text.ts +206 -35
  288. package/src/data/row-confirm.ts +47 -0
  289. package/src/data/row-editor.ts +376 -102
  290. package/src/data/rule-builder.ts +129 -80
  291. package/src/data/schedule-grid.ts +238 -0
  292. package/src/data/segment-bar.ts +221 -0
  293. package/src/data/shape-util.ts +86 -43
  294. package/src/data/stage-flow.ts +244 -0
  295. package/src/data/staged-rows.ts +207 -24
  296. package/src/data/stat-group.ts +438 -86
  297. package/src/data/static-lazy.ts +18 -0
  298. package/src/data/static-registry.ts +38 -2
  299. package/src/data/status-strip.ts +171 -0
  300. package/src/data/steps.ts +63 -34
  301. package/src/data/summary-strip.ts +136 -0
  302. package/src/data/summary-util.ts +116 -0
  303. package/src/data/survey.ts +128 -47
  304. package/src/data/system-switcher.ts +40 -20
  305. package/src/data/target-progress.ts +208 -0
  306. package/src/data/text-action-button.ts +28 -7
  307. package/src/data/text-diff.ts +99 -31
  308. package/src/data/tile-grid.ts +343 -0
  309. package/src/data/timeline.ts +205 -36
  310. package/src/data/tour-guide.ts +110 -47
  311. package/src/data/transfer.ts +195 -47
  312. package/src/data/tree-table.ts +194 -112
  313. package/src/data/tree.ts +191 -70
  314. package/src/data/trend-line.ts +68 -12
  315. package/src/data/virtual-rows.ts +242 -102
  316. package/src/data/waterfall.ts +171 -0
  317. package/src/data/watermark.ts +35 -6
  318. package/src/data/wrap.ts +26 -4
  319. package/src/frames/blank-frame.ts +6 -4
  320. package/src/frames/index.ts +1 -2
  321. package/src/frames/inherited-shell.ts +54 -13
  322. package/src/frames/page-bar.ts +205 -27
  323. package/src/frames/page-status.ts +3 -2
  324. package/src/frames/resident-components.ts +0 -2
  325. package/src/frames/shared.ts +64 -21
  326. package/src/frames/single-frame.ts +20 -4
  327. package/src/frames/split-frame/shell.ts +11 -7
  328. package/src/frames/split-frame/wiring.ts +14 -10
  329. package/src/frames/tabs-frame/shell.ts +3 -2
  330. package/src/frames/tabs-frame/wiring.ts +2 -1
  331. package/src/frames/top-main-frame.ts +55 -3
  332. package/src/frames/types.ts +2 -0
  333. package/src/frames/workspace-frame/extras.ts +5 -3
  334. package/src/frames/workspace-frame/index.ts +1 -1
  335. package/src/frames/workspace-frame/pipeline-key.ts +6 -0
  336. package/src/frames/workspace-frame/shell.ts +22 -2
  337. package/src/frames/workspace-frame/state.ts +42 -14
  338. package/src/frames/workspace-frame/view.ts +697 -167
  339. package/src/generated/kit-grammar-runtime.ts +1016 -54
  340. package/src/generated/kit-page.ts +272 -0
  341. package/src/i18n/index.ts +2 -0
  342. package/src/i18n/kit-text.ts +96 -3
  343. package/src/object-renderer/action-group.ts +175 -23
  344. package/src/object-renderer/action-more.ts +48 -17
  345. package/src/object-renderer/arrange.ts +241 -29
  346. package/src/object-renderer/category-tone.ts +96 -0
  347. package/src/object-renderer/collapse-wiring.ts +19 -9
  348. package/src/object-renderer/collection-expand.ts +3 -3
  349. package/src/object-renderer/collection-parts.ts +432 -107
  350. package/src/object-renderer/collection-table.ts +347 -45
  351. package/src/object-renderer/collection.ts +291 -62
  352. package/src/object-renderer/compile-data.ts +12 -2
  353. package/src/object-renderer/defaults.ts +6 -5
  354. package/src/object-renderer/emit-events.ts +45 -19
  355. package/src/object-renderer/emit-object.ts +35 -9
  356. package/src/object-renderer/emit-static.ts +734 -159
  357. package/src/object-renderer/filter-plan.ts +3 -3
  358. package/src/object-renderer/filter-toolbar.ts +105 -18
  359. package/src/object-renderer/form-detail.ts +87 -2
  360. package/src/object-renderer/key-field.ts +21 -0
  361. package/src/object-renderer/layout-facts.ts +18 -2
  362. package/src/object-renderer/layout-plan.ts +6 -3
  363. package/src/object-renderer/overlay-decide.ts +44 -2
  364. package/src/object-renderer/pick-component.ts +8 -2
  365. package/src/object-renderer/pipeline-mode.ts +6 -0
  366. package/src/object-renderer/relation-field.ts +79 -0
  367. package/src/object-renderer/render-object.ts +71 -26
  368. package/src/object-renderer/request-actions.ts +119 -21
  369. package/src/object-renderer/table-actions.ts +423 -104
  370. package/src/object-renderer/table-gap.ts +2 -1
  371. package/src/object-renderer/table-reorder.ts +237 -0
  372. package/src/object-renderer/table-summary.ts +26 -12
  373. package/src/object-renderer/table-tools.ts +428 -128
  374. package/src/object-renderer/types.ts +91 -2
  375. package/src/object-renderer/value-present.ts +49 -0
  376. package/src/page-target/ai-surface.ts +15 -22
  377. package/src/page-target/compile.ts +5 -6
  378. package/src/page-target/drift.ts +0 -7
  379. package/src/page-target/intent-schema.ts +46 -43
  380. package/src/page-target/target.ts +4 -5
  381. package/src/page-target/writer-policy.ts +4 -5
  382. package/src/recipes/chrome-surface.ts +20 -0
  383. package/src/recipes/code-view.ts +15 -14
  384. package/src/recipes/color-role.ts +442 -0
  385. package/src/recipes/compact-group.ts +3 -2
  386. package/src/recipes/composition-projector.ts +321 -0
  387. package/src/recipes/container.ts +76 -19
  388. package/src/recipes/control.ts +64 -5
  389. package/src/recipes/desc-list.ts +101 -7
  390. package/src/recipes/divider.ts +30 -9
  391. package/src/recipes/emphasis.ts +90 -5
  392. package/src/recipes/field-text.ts +72 -0
  393. package/src/recipes/form-section.ts +177 -0
  394. package/src/recipes/frame-bleed.ts +3 -2
  395. package/src/recipes/index.ts +28 -4
  396. package/src/recipes/inherited-shell.ts +21 -15
  397. package/src/recipes/json-view.ts +6 -5
  398. package/src/recipes/look.ts +56 -0
  399. package/src/recipes/mark.ts +138 -0
  400. package/src/recipes/markdown.ts +16 -6
  401. package/src/recipes/overlay.ts +47 -19
  402. package/src/recipes/page-width.ts +31 -0
  403. package/src/recipes/pipeline-runtime.ts +366 -0
  404. package/src/recipes/placeholder.ts +37 -19
  405. package/src/recipes/rail-grid.ts +6 -3
  406. package/src/recipes/self-owned.ts +59 -0
  407. package/src/recipes/slot-align.ts +5 -3
  408. package/src/recipes/stat-state.ts +5 -5
  409. package/src/recipes/state.ts +54 -3
  410. package/src/recipes/status.ts +14 -14
  411. package/src/recipes/strip.ts +47 -5
  412. package/src/recipes/surface-edge.ts +3 -1
  413. package/src/recipes/surface.ts +33 -4
  414. package/src/recipes/table-gap.ts +3 -2
  415. package/src/recipes/table-native-edit.ts +22 -9
  416. package/src/recipes/table-row.ts +45 -12
  417. package/src/recipes/tabs.ts +54 -22
  418. package/src/recipes/text-diff.ts +15 -8
  419. package/src/recipes/text-fit.ts +132 -0
  420. package/src/recipes/title-row.ts +68 -3
  421. package/src/shared/action-func.ts +106 -0
  422. package/src/shared/color-scheme.ts +127 -0
  423. package/src/shared/confirm-decl.ts +5 -2
  424. package/src/shared/danger-facts.ts +55 -0
  425. package/src/shared/dom-attrs-registry.ts +1009 -0
  426. package/src/shared/dom-attrs.ts +743 -0
  427. package/src/shared/field-kind.ts +49 -0
  428. package/src/shared/field-value-format.ts +58 -12
  429. package/src/shared/glyphs.ts +127 -0
  430. package/src/shared/icons.ts +28 -1
  431. package/src/shared/identifier-field.ts +66 -0
  432. package/src/shared/list-pager.ts +23 -0
  433. package/src/shared/list-title.ts +29 -0
  434. package/src/shared/order-value.ts +15 -0
  435. package/src/shared/page-attrs-runtime.ts +327 -0
  436. package/src/shared/page-attrs.ts +262 -0
  437. package/src/shared/pipeline-mode.ts +64 -0
  438. package/src/shared/row-key.ts +15 -0
  439. package/src/shared/theme-runtime-shared.ts +165 -24
  440. package/src/shared/theme-usage.ts +16 -0
  441. package/src/shared/value-table-contract.ts +68 -0
  442. package/src/spatial/action-func.ts +4 -0
  443. package/src/spatial/declared-actions.ts +116 -0
  444. package/src/spatial/emit.ts +660 -0
  445. package/src/spatial/expand.ts +1482 -0
  446. package/src/spatial/field-types.ts +48 -0
  447. package/src/spatial/index.ts +82 -0
  448. package/src/spatial/layout.ts +697 -0
  449. package/src/spatial/look-apply.ts +206 -0
  450. package/src/spatial/page-decl.ts +44 -0
  451. package/src/spatial/page-object.ts +349 -0
  452. package/src/spatial/recognize.ts +491 -0
  453. package/src/spatial/self-report.ts +571 -0
  454. package/src/spatial/shape.ts +205 -0
  455. package/src/spatial/spatial-map.ts +136 -0
  456. package/src/spatial/tone.ts +145 -0
  457. package/src/theme/index.ts +11 -2
  458. package/src/theme/kit-theme-text.ts +1 -1
  459. package/src/theme/kit-theme.css +527 -16
  460. package/src/theme/kit-theme.tpl +491 -16
  461. package/src/theme/look-carrier.ts +65 -0
  462. package/src/theme/nine-dim-structure.ts +522 -185
  463. package/src/theme/private-vars.ts +153 -0
  464. package/src/theme/surface-layers.ts +3 -2
  465. package/src/theme/theme-tokens.ts +1601 -93
  466. package/src/theme/theme-types.ts +38 -59
  467. package/src/theme/value-table.ts +2379 -0
  468. package/src/frames/list-summary.ts +0 -123
  469. package/src/recipes/nowrap.ts +0 -16
  470. package/src/theme/block-theme.ts +0 -202
package/src/base/popup.ts CHANGED
@@ -8,9 +8,26 @@
8
8
  import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
9
9
  import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
10
10
  import { kitDirAt } from '../i18n/kit-text';
11
+ import { mergeClass } from '../shared/merge-class';
12
+ import { KIT_ATTR_BOUNDARY, KIT_ATTR_QUIET } from '../shared/dom-attrs';
13
+ import { KIT_INVERSE_TOOLTIP_SURFACE_CLASS } from '../recipes/color-role';
11
14
  import { kitSurfaceRecipe } from '../recipes/surface';
12
- import { KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
15
+ import { kitSelectedRecipe } from '../recipes/state';
16
+ import { KIT_MENU_ITEM_HEIGHT_TOKEN, KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
13
17
  import { leaveAnchored, markAnchored, unmarkAnchored } from './anchored-layer';
18
+ import { kitReportSelf } from './kit-contract';
19
+ import { kitLevelClassFor } from '../recipes/pipeline-runtime';
20
+
21
+ /**
22
+ * 锚定浮起面板(下拉、联想、菜单、气泡、提示)的层级角色自报:「浮起」。全部锚定面板都经本文件的落位出口显示,
23
+ * 所以在落位出口统一自报,各组件不必各写一遍;不覆盖面板上已有的层级角色(组件自己报了更准的就以它为准)。
24
+ */
25
+ function reportFloat(panel: HTMLElement): void {
26
+ // 反色提示气泡(role="tooltip")是成对的 bg-surface-inverse + text-fg-inverse,不自报 float,
27
+ // 避免 next 模式取值表覆写浮起面底色/边框/阴影导致字底撞色
28
+ if (panel.getAttribute('role') === 'tooltip') return;
29
+ kitReportSelf(panel, { level: 'float' });
30
+ }
14
31
  import type { KitLeaveHandle } from './overlay-runtime';
15
32
  import {
16
33
  createPanelPortalWith, KIT_PANEL_PORTAL_CLASS_CANDIDATES, showAtPoint,
@@ -23,13 +40,15 @@ import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-run
23
40
  type WiringOptions = Parameters<typeof createKeyboardWiring>[0];
24
41
 
25
42
  // 下拉面板高度与浮层阴影档的真源:阴影 / 描边类读 spec/kit-grammar.json#dropdown;行高 = 条带阶梯的菜单项行高 sizeSpec.strip.menuItemPx(AR42),
26
- // 内边距与各档像素读 design 的 kit-limits.json#dropdown(最大高 = 内边距 + (整数行 + 半行) × 行高;行数从大到小);类按像素写成 max-h-[Npx](与行高同口径,密度无关)
43
+ // 内边距与行数档读 design 的 kit-limits.json#dropdown(最大高 = 内边距 + (整数行 + 半行) × 项高;行数从大到小)。
44
+ // 项高随密度(令牌 --soma-menu-item-height = R2(8 · u),主题公式 F1),所以类按行数写成 max-h-menu-rows-<行数>,规则由 compile/styles 注入、在 CSS 里按项高令牌算;
45
+ // px 是标准密度下的标称值(真源 clamps),运行期挑档时按面板上读到的项高重算(见 clampDropdownClass)
27
46
  type DropdownRules = { panelShadowClass: string; panelBorderClass: string };
28
47
  const DD = (grammarJson as unknown as { dropdown: DropdownRules }).dropdown;
29
48
 
30
49
  /** 空间不足时面板内部滚动的 max-h 闭集档位,从大到小;每档都是「整数行 + 半行」(真源 dropdown.clamps),空间不够也不腰斩一行 */
31
- export const DROPDOWN_CLAMPS: readonly { cls: string; px: number }[] = Object.freeze(
32
- KIT_DROPDOWN_LIMITS.clamps.map((c) => ({ cls: `max-h-[${c.px}px]`, px: c.px })),
50
+ export const DROPDOWN_CLAMPS: readonly { cls: string; px: number; rows: number }[] = Object.freeze(
51
+ KIT_DROPDOWN_LIMITS.clamps.map((c) => ({ cls: `max-h-menu-rows-${c.rows}`, px: c.px, rows: c.rows })),
33
52
  );
34
53
  /** 下拉面板的默认最大高(最大一档:visibleRows 行 + 半行) */
35
54
  export const KIT_DROPDOWN_PANEL_MAX_CLASS: string = DROPDOWN_CLAMPS[0]!.cls;
@@ -96,8 +115,9 @@ export function createListNav(o: ListNavOptions): ListNav {
96
115
  };
97
116
  }
98
117
 
99
- /** 点组件之外的地方时收起;返回摘除函数 */
118
+ /** 点组件之外的地方时收起;监听归属 scope.ownerDocument(兼容 iframe 工作区),返回摘除函数 */
100
119
  export function onOutsidePress(scope: HTMLElement, isOpen: () => boolean, close: () => void, alsoInside?: (node: Node) => boolean): () => void {
120
+ const doc = scope.ownerDocument ?? document;
101
121
  const handler = (event: Event): void => {
102
122
  if (!isOpen()) return;
103
123
  const target = event.target as Node | null;
@@ -105,8 +125,8 @@ export function onOutsidePress(scope: HTMLElement, isOpen: () => boolean, close:
105
125
  if (target && (scope.contains(target) || alsoInside?.(target) === true || inDropdownPortalOf(scope, target))) return;
106
126
  close();
107
127
  };
108
- document.addEventListener('pointerdown', handler, true);
109
- return () => document.removeEventListener('pointerdown', handler, true);
128
+ doc.addEventListener('pointerdown', handler, true);
129
+ return () => doc.removeEventListener('pointerdown', handler, true);
110
130
  }
111
131
 
112
132
  export function cssEscape(value: string): string {
@@ -124,10 +144,10 @@ export function scrollIntoViewIfAny(el: Element | null): void {
124
144
  // 记最近一次交互是不是指针(文档级捕获监听只装一次);是指针则落点标 data-kit-quiet,
125
145
  // 类串里的 data-kit-quiet:focus-visible:ring-0 把环压掉;键盘一动由面板的 keydown 摘掉标记。
126
146
  let lastInputIsPointer = false;
127
- let inputTrackerOn = false;
147
+ const trackedModalityDocs = new WeakSet<Document>();
128
148
  export function trackInputModality(doc: Document): void {
129
- if (inputTrackerOn) return;
130
- inputTrackerOn = true;
149
+ if (trackedModalityDocs.has(doc)) return;
150
+ trackedModalityDocs.add(doc);
131
151
  doc.addEventListener('pointerdown', () => { lastInputIsPointer = true; }, true);
132
152
  doc.addEventListener('mousedown', () => { lastInputIsPointer = true; }, true);
133
153
  doc.addEventListener('keydown', () => { lastInputIsPointer = false; }, true);
@@ -136,8 +156,8 @@ export function trackInputModality(doc: Document): void {
136
156
  /** 程序化落焦:最近交互是鼠标则压掉焦点环;键盘操作照常显示。落焦不滚动页面 */
137
157
  export function focusCellQuiet(node: HTMLElement | null | undefined): void {
138
158
  if (!node) return;
139
- if (lastInputIsPointer) node.setAttribute('data-kit-quiet', '');
140
- else node.removeAttribute('data-kit-quiet');
159
+ if (lastInputIsPointer) node.setAttribute(KIT_ATTR_QUIET, '');
160
+ else node.removeAttribute(KIT_ATTR_QUIET);
141
161
  node.focus({ preventScroll: true });
142
162
  }
143
163
 
@@ -147,18 +167,21 @@ const MENU_MAX_WIDTH_CLASS = `max-w-[${KIT_OVERLAY_LIMITS.menuMaxPx}px]`;
147
167
  /** 默认的整串面板类:显隐只换整串,`hidden` 不与布局类并存 */
148
168
  export const PANEL_HIDDEN_CLASS = 'hidden';
149
169
  export const PANEL_SHOWN_CLASS =
150
- `absolute start-0 top-full z-10 mt-1 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} py-1`;
170
+ `absolute start-0 top-full z-10 mt-1 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} p-1`;
151
171
 
152
172
  // 选项行高固定(条带阶梯的菜单项行高 strip.menuItemPx),面板最大高才能算成「整数行 + 半行」
153
173
  const ROW = KIT_STRIP_MENU_ITEM_CLASS;
154
174
  export const OPTION_CLASS = {
155
- idle: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 px-3 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press`,
175
+ idle: `flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2 px-3 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press`,
156
176
  // 键盘当前项与鼠标悬停同一层;选中项 = 主色淡底,选中项上的悬停 / 当前 = tonal 层(第三级,KT-K0-2 / KT-K-select-3)
157
- active: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-state-layer-hover px-3 text-sm text-fg transition-colors`,
158
- selected: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`,
159
- selectedActive: `flex ${ROW} cursor-pointer items-center whitespace-nowrap gap-2 bg-state-layer-tonal-hover px-3 text-sm font-medium text-primary-on-soft transition-colors`,
177
+ active: `flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2 bg-state-layer-hover px-3 text-sm text-fg transition-colors`,
178
+ selected: mergeClass(
179
+ mergeClass(`flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2`, kitSelectedRecipe()),
180
+ 'px-3 text-sm transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press',
181
+ ),
182
+ selectedActive: `flex ${ROW} cursor-pointer items-center whitespace-nowrap rounded-item gap-2 bg-state-layer-tonal-hover px-3 text-sm font-medium text-primary-on-soft transition-colors`,
160
183
  // 置灰项 = 禁用字色令牌(KT-K-select-5 / KT-K0-4),不降透明度
161
- disabled: `flex ${ROW} cursor-not-allowed items-center whitespace-nowrap gap-2 px-3 text-sm text-fg-disabled`,
184
+ disabled: `flex ${ROW} cursor-not-allowed items-center whitespace-nowrap rounded-item gap-2 px-3 text-sm text-fg-disabled`,
162
185
  } as const;
163
186
 
164
187
  export const EMPTY_ROW_CLASS = `flex ${ROW} items-center whitespace-nowrap px-3 text-sm text-fg-subtle`;
@@ -171,12 +194,19 @@ export function optionClass(selected: boolean, active: boolean, disabled: boolea
171
194
 
172
195
  /** 本文件自带的类(供各组件并入候选类清单) */
173
196
  export const KIT_POPUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
174
- 'hidden', 'absolute', 'start-0', 'top-full', 'z-10', 'mt-1', KIT_DROPDOWN_PANEL_MAX_CLASS, KIT_STRIP_MENU_ITEM_CLASS, 'w-full', 'w-max', 'min-w-full', MENU_MAX_WIDTH_CLASS, 'overflow-auto',
175
- 'rounded-md', 'rounded-lg', 'border', 'border-border', 'border-border-subtle', 'bg-surface-raised', 'py-1', DD.panelShadowClass, 'shadow-sm',
176
- ...SURFACE_RAISED.split(/\s+/),
177
- 'flex', 'cursor-pointer', 'cursor-not-allowed', 'items-center', 'whitespace-nowrap', 'gap-2', 'px-3', 'py-2', 'text-sm',
178
- 'text-fg', 'text-fg-subtle', 'bg-surface-sunken', 'font-medium', 'text-primary-on-soft',
179
- 'transition-colors', 'hover:bg-state-layer-hover', 'active:bg-state-layer-press', 'bg-primary-soft', 'text-primary-on-soft', 'text-fg-disabled',
197
+ ...new Set([
198
+ 'hidden', 'absolute', 'start-0', 'top-full', 'z-10', 'mt-1', KIT_DROPDOWN_PANEL_MAX_CLASS, KIT_STRIP_MENU_ITEM_CLASS, 'w-full', 'w-max', 'min-w-full', MENU_MAX_WIDTH_CLASS, 'overflow-auto',
199
+ 'rounded-float', 'rounded-item', 'border', 'border-border', 'border-border-subtle', 'bg-surface-raised', 'p-1', 'py-1', DD.panelShadowClass, 'shadow-sm',
200
+ ...SURFACE_RAISED.split(/\s+/),
201
+ ...PANEL_SHOWN_CLASS.split(/\s+/),
202
+ ...Object.values(OPTION_CLASS).flatMap((s) => s.split(/\s+/)),
203
+ ...EMPTY_ROW_CLASS.split(/\s+/),
204
+ 'px-3', 'py-2',
205
+ // Popover / Popconfirm / 行内气泡确认在未静态声明 Popover 的页面命令式挂载时也需保留默认宽高约束(PW2-Biz P2-6)
206
+ 'min-w-52', 'min-w-60', 'w-64', 'w-80', 'max-w-80',
207
+ ...kitSelectedRecipe().split(/\s+/),
208
+ ...KIT_INVERSE_TOOLTIP_SURFACE_CLASS.split(/\s+/),
209
+ ].filter(Boolean)),
180
210
  ]);
181
211
 
182
212
  /**
@@ -184,8 +214,10 @@ export const KIT_POPUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
184
214
  * 通用 `tooltip` prop(shared.ts 的 withTooltip)取用;Popover / Popconfirm 的面板另用 PANEL_*。
185
215
  */
186
216
  export const POPUP_TIP_HIDDEN_CLASS = PANEL_HIDDEN_CLASS;
187
- export const POPUP_TIP_BASE =
188
- 'absolute z-10 w-max max-w-xs rounded-md bg-fg px-3 py-1 text-xs font-normal leading-5 text-surface shadow-md pointer-events-none';
217
+ export const POPUP_TIP_BASE = mergeClass(
218
+ 'absolute z-10 w-max max-w-60 rounded-float px-2 py-1 text-sm font-normal pointer-events-none',
219
+ KIT_INVERSE_TOOLTIP_SURFACE_CLASS,
220
+ );
189
221
 
190
222
  // ── 贴边自动翻转 ──────────────────────────────────────────────
191
223
  //
@@ -283,12 +315,40 @@ export function showPopupFitted(
283
315
  classFor: (place: PopPlace) => string,
284
316
  gapPx = ANCHORED_GAP_PX,
285
317
  ): PopPlace {
318
+ // 先自报、后落类:贴边翻转里的类由调用方的 classFor 经 kitLevelClassFor 按面板上的层级角色出(气泡提示是反色面,取值表给不了,调用方不剥)
319
+ reportFloat(panel);
286
320
  const place = fitPopupPlace(panel, anchor, pref, classFor, gapPx);
287
321
  // 锚定浮层统一标记(anchored-layer.ts):落位后的实际方向,重定位 / 翻转时随之更新
288
322
  markAnchored(panel, place);
289
323
  return place;
290
324
  }
291
325
 
326
+ /** 定位边界标记(KT-D9-5):窗格、窗口正文、页面内容区由各自的配方打;浮层不跨出锚点所在的这一块 */
327
+ export { KIT_ATTR_BOUNDARY as KIT_BOUNDARY_ATTR } from '../shared/dom-attrs';
328
+
329
+ /**
330
+ * 浮层落位的边界(封闭清单 ②,只读矩形):锚点最近的 `[data-kit-boundary]` 祖先与视口的交集(横向;纵向取视口);没有标记取视口。
331
+ * 返回边界矩形与「把锚点矩形换算到边界坐标系」后的锚点——resolvePopPlace / resolveDropdown 的纯函数只认「原点在 0 的视口」,
332
+ * 换算后同一份翻转 / 对齐判定就以窗格为界,不另写第二套。视口宽高为 0(无布局环境)返回 null。
333
+ */
334
+ export function placementFrame(anchor: HTMLElement): { anchor: { left: number; right: number; top: number; bottom: number }; viewport: { width: number; height: number } } | null {
335
+ const doc = anchor.ownerDocument ?? document;
336
+ const win = doc.defaultView;
337
+ const vw = doc.documentElement.clientWidth || win?.innerWidth || (typeof window !== 'undefined' ? window.innerWidth : 0);
338
+ const vh = doc.documentElement.clientHeight || win?.innerHeight || (typeof window !== 'undefined' ? window.innerHeight : 0);
339
+ if (vw === 0 || vh === 0) return null;
340
+ let left = 0; let top = 0; let right = vw; let bottom = vh;
341
+ const box = anchor.closest(`[${KIT_ATTR_BOUNDARY}]`);
342
+ if (box !== null) {
343
+ const r = box.getBoundingClientRect();
344
+ // 只收行内方向(左右):「不盖住相邻窗格」是横向的事;纵向仍以视口为界(窗口正文 / 窗格底部离触发器很近时,下拉照常越过它,不被压成一两行)
345
+ if (r.width > 0 && r.height > 0) { left = Math.max(left, r.left); right = Math.min(right, r.right); }
346
+ }
347
+ if (right - left <= 0 || bottom - top <= 0) { left = 0; top = 0; right = vw; bottom = vh; }
348
+ const a = anchor.getBoundingClientRect();
349
+ return { anchor: { left: a.left - left, right: a.right - left, top: a.top - top, bottom: a.bottom - top }, viewport: { width: right - left, height: bottom - top } };
350
+ }
351
+
292
352
  function fitPopupPlace(
293
353
  panel: HTMLElement,
294
354
  anchor: HTMLElement,
@@ -298,12 +358,10 @@ function fitPopupPlace(
298
358
  ): PopPlace {
299
359
  panel.className = classFor(pref);
300
360
  if (typeof panel.getBoundingClientRect !== 'function') return pref;
301
- const a = anchor.getBoundingClientRect();
361
+ const frame = placementFrame(anchor);
362
+ if (frame === null) return pref;
302
363
  const b = panel.getBoundingClientRect();
303
- const vw = document.documentElement.clientWidth || (typeof window !== 'undefined' ? window.innerWidth : 0);
304
- const vh = document.documentElement.clientHeight || (typeof window !== 'undefined' ? window.innerHeight : 0);
305
- if (vw === 0 || vh === 0) return pref;
306
- const place = resolvePopPlace(a, { width: b.width, height: b.height }, { width: vw, height: vh }, pref, gapPx, kitDirAt(anchor) === 'rtl');
364
+ const place = resolvePopPlace(frame.anchor, { width: b.width, height: b.height }, frame.viewport, pref, gapPx, kitDirAt(anchor) === 'rtl');
307
365
  if (place.side !== pref.side || place.align !== pref.align) panel.className = classFor(place);
308
366
  return place;
309
367
  }
@@ -322,7 +380,7 @@ export const POPUP_TIP_SHOWN_CLASS = popupTipClass(POPUP_TIP_PREF);
322
380
 
323
381
  /** 下拉面板外观类(不含位置类):与 PANEL_SHOWN_CLASS 同一份外观 */
324
382
  export const PANEL_BASE_CLASS =
325
- `absolute z-10 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} py-1`;
383
+ `absolute z-10 ${KIT_DROPDOWN_PANEL_MAX_CLASS} w-max min-w-full ${MENU_MAX_WIDTH_CLASS} overflow-auto ${SURFACE_RAISED} p-1`;
326
384
 
327
385
  /** 下拉翻转用到的全部类(位置类、间距类、max-h 档位、滚动) */
328
386
  export const KIT_DROPDOWN_CLASS_CANDIDATES: readonly string[] = Object.freeze([
@@ -365,9 +423,11 @@ export function resolveDropdown(
365
423
  }
366
424
 
367
425
  /** 去掉 max-h-* 后按档位加上放得下的一档(内部滚动);没有 overflow 类时补 overflow-y-auto */
368
- export function clampDropdownClass(cls: string, clampPx: number): string {
426
+ export function clampDropdownClass(cls: string, clampPx: number, itemPx: number | null = null): string {
369
427
  const tokens = cls.split(/\s+/).filter((t) => t !== '' && !t.startsWith('max-h-'));
370
- const step = DROPDOWN_CLAMPS.find((c) => c.px <= clampPx) ?? DROPDOWN_CLAMPS[DROPDOWN_CLAMPS.length - 1]!;
428
+ // 每档的实际最大高:给了当前项高就按「内边距 + (行数 + 半行) × 项高」现算(随密度),没给取标准密度的标称值
429
+ const pxOf = (c: { px: number; rows: number }): number => (itemPx === null ? c.px : KIT_DROPDOWN_LIMITS.panelPadYPx + (c.rows + KIT_DROPDOWN_LIMITS.partialRow) * itemPx);
430
+ const step = DROPDOWN_CLAMPS.find((c) => pxOf(c) <= clampPx) ?? DROPDOWN_CLAMPS[DROPDOWN_CLAMPS.length - 1]!;
371
431
  tokens.push(step.cls);
372
432
  if (!tokens.some((t) => t.startsWith('overflow-'))) tokens.push('overflow-y-auto');
373
433
  return tokens.join(' ');
@@ -383,6 +443,8 @@ export function showDropdownFitted(
383
443
  base: string,
384
444
  prefAlign: PopAlign = 'start',
385
445
  ): PopPlace {
446
+ // 先自报、后落类:下拉面板的类经 kitLevelClassFor 按面板上实际的层级角色出(新模式剥掉取值表负责的外观类)
447
+ reportFloat(panel);
386
448
  const place = fitDropdownPlace(panel, anchor, base, prefAlign);
387
449
  markAnchored(panel, place);
388
450
  return place;
@@ -394,21 +456,26 @@ function fitDropdownPlace(
394
456
  base: string,
395
457
  prefAlign: PopAlign,
396
458
  ): PopPlace {
397
- const classFor = (place: PopPlace): string => `${base} ${popPlaceClass(place)}`;
459
+ const classFor = (place: PopPlace): string => kitLevelClassFor(panel, `${base} ${popPlaceClass(place)}`);
398
460
  const pref: PopPlace = { side: 'bottom', align: prefAlign };
399
461
  panel.className = classFor(pref);
400
462
  if (typeof panel.getBoundingClientRect !== 'function') return pref;
401
- const vw = document.documentElement.clientWidth || (typeof window !== 'undefined' ? window.innerWidth : 0);
402
- const vh = document.documentElement.clientHeight || (typeof window !== 'undefined' ? window.innerHeight : 0);
403
- if (vw === 0 || vh === 0) return pref;
404
- const a = anchor.getBoundingClientRect();
463
+ const frame = placementFrame(anchor);
464
+ if (frame === null) return pref;
405
465
  const b = panel.getBoundingClientRect();
406
- const { place, clampPx } = resolveDropdown(a, { width: b.width, height: b.height }, { width: vw, height: vh }, prefAlign, ANCHORED_GAP_PX, kitDirAt(anchor) === 'rtl');
407
- const next = clampPx === null ? classFor(place) : `${clampDropdownClass(base, clampPx)} ${popPlaceClass(place)}`;
466
+ const { place, clampPx } = resolveDropdown(frame.anchor, { width: b.width, height: b.height }, frame.viewport, prefAlign, ANCHORED_GAP_PX, kitDirAt(anchor) === 'rtl');
467
+ const next = clampPx === null ? classFor(place) : kitLevelClassFor(panel, `${clampDropdownClass(base, clampPx, menuItemPxAt(panel))} ${popPlaceClass(place)}`);
408
468
  if (panel.className !== next) panel.className = next;
409
469
  return place;
410
470
  }
411
471
 
472
+ /** 面板所在处的菜单项高(px,读令牌 --soma-menu-item-height);读不到(无 DOM、令牌表没有它)回 null,挑档退回标称值 */
473
+ function menuItemPxAt(panel: HTMLElement): number | null {
474
+ if (typeof getComputedStyle !== 'function') return null;
475
+ const px = Number.parseFloat(getComputedStyle(panel).getPropertyValue(KIT_MENU_ITEM_HEIGHT_TOKEN));
476
+ return Number.isFinite(px) && px > 0 ? px : null;
477
+ }
478
+
412
479
  // ── 浮层端口挂载(下拉 / 菜单默认走这里,只此一份实现)──
413
480
  //
414
481
  // 下拉面板默认挂到 core 的浮层挂载点(body 下专用根),不再受触发器祖先的 overflow / transform 裁切。
@@ -425,6 +492,7 @@ export function createPanelPortal(owner: Element | null): PanelPortal {
425
492
  * 几何只在 portal-core 的 placeAtPoint 写一次。端口不可用返回 null(调用方走就地绝对定位,不写 CSSOM)。
426
493
  */
427
494
  export function showMenuAtPoint(panel: HTMLElement, point: PointXY, opts: Omit<PointPanelOptions, 'resolve' | 'rtl'> & { anchor: Element }): PointPanel | null {
495
+ reportFloat(panel);
428
496
  return showAtPoint(panel, point, { ...opts, rtl: kitDirAt(opts.anchor) === 'rtl', resolve: resolvePopPlace });
429
497
  }
430
498
 
@@ -493,6 +561,23 @@ export function queryWithDropdowns(scope: Element, selector: string): HTMLElemen
493
561
  return null;
494
562
  }
495
563
 
564
+ /** scope 内锚点挂出去的、当前在浮层里的面板中全部匹配 selector 的节点(含面板本身);不含 scope 自己后代里的匹配 */
565
+ export function queryAllWithDropdowns(scope: Element, selector: string): HTMLElement[] {
566
+ const out: HTMLElement[] = [];
567
+ for (const panel of livePanelsIn(scope)) {
568
+ if (panel.matches(selector)) out.push(panel);
569
+ out.push(...Array.from(panel.querySelectorAll<HTMLElement>(selector)));
570
+ }
571
+ return out;
572
+ }
573
+
574
+ /** 面板新挂到浮层端口时的回调(组件骨架据此补写面板里的自报,见 base/shared.ts#ensurePanelHook);返回撤销函数 */
575
+ const PANEL_MOUNT_HOOKS = new Set<(anchor: HTMLElement, panel: HTMLElement) => void>();
576
+ export function onKitPanelMounted(hook: (anchor: HTMLElement, panel: HTMLElement) => void): () => void {
577
+ PANEL_MOUNT_HOOKS.add(hook);
578
+ return () => { PANEL_MOUNT_HOOKS.delete(hook); };
579
+ }
580
+
496
581
  /** 焦点是否落在 scope 内或它挂出去的下拉面板里;是则返回聚焦元素 */
497
582
  export function activeWithDropdowns(scope: Element): HTMLElement | null {
498
583
  const active = scope.ownerDocument.activeElement as HTMLElement | null;
@@ -506,6 +591,15 @@ export function releaseDropdownsIn(scope: Element): void {
506
591
  for (const m of [...DROPDOWN_LIVE]) if (scope.contains(m.anchor)) releaseDropdown(m.panel, false);
507
592
  }
508
593
 
594
+ /** 端口被销毁时要通知的属主(一次性面板登记:整树重画的 releaseDropdownsIn 直接销毁端口,属主据此按取消收口、摘监听) */
595
+ const DESTROY_HOOKS = new WeakMap<HTMLElement, () => void>();
596
+
597
+ /** 登记 / 撤销面板端口被销毁时的回调(cb 为 null 撤销);回调只触发一次,触发前先撤销登记 */
598
+ export function onDropdownDestroyed(panel: HTMLElement, cb: (() => void) | null): void {
599
+ if (cb === null) DESTROY_HOOKS.delete(panel);
600
+ else DESTROY_HOOKS.set(panel, cb);
601
+ }
602
+
509
603
  /** 收起并放回原位(restore)或直接销毁(组件卸载) */
510
604
  export function releaseDropdown(panel: HTMLElement, restore = true): void {
511
605
  cancelLeave(panel);
@@ -514,7 +608,11 @@ export function releaseDropdown(panel: HTMLElement, restore = true): void {
514
608
  DROPDOWN_MOUNTS.delete(panel);
515
609
  DROPDOWN_LIVE.delete(m);
516
610
  if (restore) m.portal.hide(true);
517
- else m.portal.destroy();
611
+ else {
612
+ m.portal.destroy();
613
+ const hook = DESTROY_HOOKS.get(panel);
614
+ if (hook !== undefined) { DESTROY_HOOKS.delete(panel); hook(); }
615
+ }
518
616
  }
519
617
 
520
618
  // ── 锚定面板的出场 ──
@@ -527,8 +625,15 @@ function cancelLeave(panel: HTMLElement): void {
527
625
  LEAVING.delete(panel);
528
626
  }
529
627
 
530
- /** 收起锚定面板:已挂出且有退场动画 -> 播完再放回 + hidden;否则立即放回 + hidden */
531
- function retireAnchored(panel: HTMLElement): void {
628
+ /** 收起锚定面板:已挂出且有退场动画(且非 immediate) -> 播完再放回 + hidden;否则立即放回 + hidden */
629
+ function retireAnchored(panel: HTMLElement, immediate = false): void {
630
+ if (immediate) {
631
+ cancelLeave(panel);
632
+ releaseDropdown(panel);
633
+ panel.className = PANEL_HIDDEN_CLASS;
634
+ unmarkAnchored(panel);
635
+ return;
636
+ }
532
637
  if (LEAVING.has(panel)) return;
533
638
  const finish = (): void => {
534
639
  LEAVING.delete(panel);
@@ -544,13 +649,29 @@ function retireAnchored(panel: HTMLElement): void {
544
649
  if (handle !== null) LEAVING.set(panel, handle);
545
650
  }
546
651
 
652
+ export interface SyncOverlayOptions {
653
+ /** Esc 回调(走层栈栈顶:多浮层叠放时只关栈顶一层) */
654
+ onEscape?: () => void;
655
+ /** 收起时立即释放浮层端口与隐藏(选定提交 / Esc 关闭等避免残留半透明残影或滞留层栈) */
656
+ immediate?: boolean;
657
+ }
658
+
547
659
  /** 挂到端口并落位;返回实际锚点,端口不可用返回 null(调用方走原位) */
548
- function mountAnchored(panel: HTMLElement, anchor: HTMLElement | undefined, pref: PopPlace, fit: (p: HTMLElement, box: HTMLElement) => PopPlace): HTMLElement | null {
660
+ function mountAnchored(
661
+ panel: HTMLElement,
662
+ anchor: HTMLElement | undefined,
663
+ pref: PopPlace,
664
+ fit: (p: HTMLElement, box: HTMLElement) => PopPlace,
665
+ onEscape?: () => void,
666
+ ): HTMLElement | null {
549
667
  const prev = DROPDOWN_MOUNTS.get(panel);
550
668
  const at = anchor ?? prev?.anchor ?? panel.parentElement ?? panel;
551
669
  const portal = prev?.portal ?? createPanelPortal(at);
552
670
  // 端口给的 box 是内部零宽高包裹盒,不能当锚点测视口空间;贴边翻转一律用真实触发器
553
- const placed = portal.show(panel, at, pref, () => '', { fit: (p) => fit(p, at) });
671
+ const placed = portal.show(panel, at, pref, () => '', {
672
+ fit: (p) => fit(p, at),
673
+ ...(onEscape ? { onEscape } : {}),
674
+ });
554
675
  if (placed === null) {
555
676
  if (prev) DROPDOWN_LIVE.delete(prev);
556
677
  DROPDOWN_MOUNTS.delete(panel);
@@ -560,6 +681,7 @@ function mountAnchored(panel: HTMLElement, anchor: HTMLElement | undefined, pref
560
681
  const m: DropdownMount = { portal, anchor: at, panel };
561
682
  DROPDOWN_MOUNTS.set(panel, m);
562
683
  DROPDOWN_LIVE.add(m);
684
+ for (const hook of PANEL_MOUNT_HOOKS) hook(at, panel);
563
685
  }
564
686
  return at;
565
687
  }
@@ -568,14 +690,21 @@ function mountAnchored(panel: HTMLElement, anchor: HTMLElement | undefined, pref
568
690
  * 下拉显隐一步到位:收起 = 放回原位 + 整串 hidden;展开 = 挂到浮层端口并贴边翻转(锚点缺省取面板的父盒,
569
691
  * 面板已挂出时取上次的锚点)。端口不可用时退回原位绝对定位。
570
692
  */
571
- export function syncDropdown(panel: HTMLElement, open: boolean, base: string = PANEL_BASE_CLASS, anchor?: HTMLElement, prefAlign: PopAlign = 'start'): void {
693
+ export function syncDropdown(
694
+ panel: HTMLElement,
695
+ open: boolean,
696
+ base: string = PANEL_BASE_CLASS,
697
+ anchor?: HTMLElement,
698
+ prefAlign: PopAlign = 'start',
699
+ opts?: SyncOverlayOptions,
700
+ ): void {
572
701
  if (!open) {
573
- retireAnchored(panel);
702
+ retireAnchored(panel, opts?.immediate === true);
574
703
  return;
575
704
  }
576
705
  cancelLeave(panel);
577
706
  const live = `${base} ${DROPDOWN_LIVE_CLASS}`;
578
- const at = mountAnchored(panel, anchor, { side: 'bottom', align: prefAlign }, (p, box) => showDropdownFitted(p, box, live, prefAlign));
707
+ const at = mountAnchored(panel, anchor, { side: 'bottom', align: prefAlign }, (p, box) => showDropdownFitted(p, box, live, prefAlign), opts?.onEscape);
579
708
  if (at === null) showDropdownFitted(panel, anchor ?? panel.parentElement ?? panel, base, prefAlign);
580
709
  }
581
710
 
@@ -584,15 +713,21 @@ export function syncDropdown(panel: HTMLElement, open: boolean, base: string = P
584
713
  * classFor 给位置类 + 外观类。端口不可用时退回原位。
585
714
  */
586
715
  export function syncAnchored(
587
- panel: HTMLElement, open: boolean, anchor: HTMLElement, pref: PopPlace, classFor: (place: PopPlace) => string, gapPx?: number,
716
+ panel: HTMLElement,
717
+ open: boolean,
718
+ anchor: HTMLElement,
719
+ pref: PopPlace,
720
+ classFor: (place: PopPlace) => string,
721
+ gapPx?: number,
722
+ opts?: SyncOverlayOptions,
588
723
  ): void {
589
724
  if (!open) {
590
- retireAnchored(panel);
725
+ retireAnchored(panel, opts?.immediate === true);
591
726
  return;
592
727
  }
593
728
  cancelLeave(panel);
594
729
  const live = (place: PopPlace): string => `${classFor(place)} ${DROPDOWN_LIVE_CLASS}`;
595
- const at = mountAnchored(panel, anchor, pref, (p, box) => showPopupFitted(p, box, pref, live, gapPx));
730
+ const at = mountAnchored(panel, anchor, pref, (p, box) => showPopupFitted(p, box, pref, live, gapPx), opts?.onEscape);
596
731
  if (at === null) showPopupFitted(panel, anchor, pref, classFor, gapPx);
597
732
  }
598
733
 
@@ -13,6 +13,7 @@ import { getOverlayHost } from 'soma-core/behavior';
13
13
  import type { OverlayMount } from 'soma-core/behavior';
14
14
  import type { PopPlace } from './popup';
15
15
  import { markAnchored, unmarkAnchored } from './anchored-layer';
16
+ import { KIT_ATTR_LAYER, KIT_ATTR_LEVEL, KIT_ATTR_OVERLAY_OWNER, KIT_ATTR_SCOPE, KIT_ATTR_SCRIM } from '../shared/dom-attrs';
16
17
 
17
18
  export interface KitOverlayOptions {
18
19
  /** 逻辑所有者(组件宿主 / 触发元素):作用域属性从它取,它脱离文档后浮层自动卸载 */
@@ -36,14 +37,97 @@ export function mountKitOverlay(content: HTMLElement, opts: KitOverlayOptions =
36
37
  if (!doc) return null;
37
38
  if (opts.anchor) {
38
39
  OVERLAY_OWNERS.set(content, opts.anchor);
39
- content.setAttribute('data-kit-overlay-owner', '');
40
+ content.setAttribute(KIT_ATTR_OVERLAY_OWNER, '');
40
41
  }
41
42
  const handle = getOverlayHost(doc).mount(content, {
42
43
  anchor: opts.anchor ?? null,
43
44
  ...(opts.releaseWithAnchor !== undefined ? { releaseWithAnchor: opts.releaseWithAnchor } : {}),
44
45
  ...(opts.onEscape ? { onEscape: () => opts.onEscape!() } : {}),
45
46
  });
46
- return handle.mounted ? handle : null;
47
+ if (!handle.mounted) return null;
48
+ // 宿主身份 / 明暗类 / 作用域属性严格镜像到每个浮层自己的 layer(handle.host),
49
+ // 严禁改写共享单例 [data-soma-overlay-root],杜绝多宿主(如亮色主宿主 + 局部暗色宿主)浮层并存时串扰。
50
+ const layer: HTMLElement = (handle.host instanceof HTMLElement ? handle.host : null)
51
+ ?? (content.parentElement instanceof HTMLElement && content.parentElement !== doc.body && content.parentElement !== doc.documentElement
52
+ ? content.parentElement
53
+ : content);
54
+ const prevHostAttr = layer.hasAttribute('data-soma-host') ? layer.getAttribute('data-soma-host') : null;
55
+ const prevScopeAttr = layer.hasAttribute(KIT_ATTR_SCOPE) ? layer.getAttribute(KIT_ATTR_SCOPE) : null;
56
+ const prevDark = layer.classList.contains('soma-scheme-dark');
57
+ const prevLight = layer.classList.contains('soma-scheme-light');
58
+ let unmounted = false;
59
+
60
+ const syncAnchorScope = (): void => {
61
+ if (unmounted || !handle.mounted) return;
62
+ const anchor = opts.anchor ?? null;
63
+ const hostAncestor = anchor?.closest('[data-soma-host]') ?? null;
64
+ const hostVal = hostAncestor !== null ? (hostAncestor.getAttribute('data-soma-host') ?? '') : (prevHostAttr ?? '');
65
+ if (!layer.hasAttribute('data-soma-host') || layer.getAttribute('data-soma-host') !== hostVal) {
66
+ layer.setAttribute('data-soma-host', hostVal);
67
+ }
68
+
69
+ const schemeAncestor = anchor?.closest('.soma-scheme-dark, .soma-scheme-light') ?? null;
70
+ if (schemeAncestor !== null && schemeAncestor !== doc.documentElement && schemeAncestor !== doc.body) {
71
+ const dark = schemeAncestor.classList.contains('soma-scheme-dark');
72
+ layer.classList.toggle('soma-scheme-dark', dark);
73
+ layer.classList.toggle('soma-scheme-light', !dark);
74
+ } else {
75
+ layer.classList.toggle('soma-scheme-dark', prevDark);
76
+ layer.classList.toggle('soma-scheme-light', prevLight);
77
+ }
78
+
79
+ const scopeAncestor = anchor?.closest(`[${KIT_ATTR_SCOPE}]`) ?? null;
80
+ if (scopeAncestor !== null) {
81
+ const scopeVal = scopeAncestor.getAttribute(KIT_ATTR_SCOPE) ?? '';
82
+ if (layer.getAttribute(KIT_ATTR_SCOPE) !== scopeVal) layer.setAttribute(KIT_ATTR_SCOPE, scopeVal);
83
+ } else if (prevScopeAttr === null) {
84
+ if (layer.hasAttribute(KIT_ATTR_SCOPE)) layer.removeAttribute(KIT_ATTR_SCOPE);
85
+ } else if (layer.getAttribute(KIT_ATTR_SCOPE) !== prevScopeAttr) {
86
+ layer.setAttribute(KIT_ATTR_SCOPE, prevScopeAttr);
87
+ }
88
+ };
89
+ syncAnchorScope();
90
+ const isShellWrapper = content.classList.contains('contents')
91
+ || content.hasAttribute(KIT_ATTR_SCRIM)
92
+ || content.getAttribute('role') === 'tooltip'
93
+ || content.querySelector(`[${KIT_ATTR_LAYER}]`) !== null
94
+ || content.querySelector(`[${KIT_ATTR_LEVEL}="overlay"]`) !== null;
95
+ const addedLayer = !isShellWrapper && !content.hasAttribute(KIT_ATTR_LAYER);
96
+ if (addedLayer) content.setAttribute(KIT_ATTR_LAYER, 'float');
97
+ const rawUnmount = handle.unmount.bind(handle);
98
+ const rawSync = handle.sync.bind(handle);
99
+ return new Proxy(handle, {
100
+ get(target, prop) {
101
+ if (prop === 'sync') {
102
+ return (): void => {
103
+ rawSync();
104
+ syncAnchorScope();
105
+ };
106
+ }
107
+ if (prop === 'unmount') {
108
+ return (): void => {
109
+ if (unmounted) return;
110
+ unmounted = true;
111
+ rawUnmount();
112
+ if (prevHostAttr === null) {
113
+ if (layer.hasAttribute('data-soma-host')) layer.removeAttribute('data-soma-host');
114
+ } else if (layer.getAttribute('data-soma-host') !== prevHostAttr) {
115
+ layer.setAttribute('data-soma-host', prevHostAttr);
116
+ }
117
+ if (prevScopeAttr === null) {
118
+ if (layer.hasAttribute(KIT_ATTR_SCOPE)) layer.removeAttribute(KIT_ATTR_SCOPE);
119
+ } else if (layer.getAttribute(KIT_ATTR_SCOPE) !== prevScopeAttr) {
120
+ layer.setAttribute(KIT_ATTR_SCOPE, prevScopeAttr);
121
+ }
122
+ layer.classList.toggle('soma-scheme-dark', prevDark);
123
+ layer.classList.toggle('soma-scheme-light', prevLight);
124
+ if (addedLayer) content.removeAttribute(KIT_ATTR_LAYER);
125
+ };
126
+ }
127
+ const val = Reflect.get(target, prop, target);
128
+ return typeof val === 'function' ? val.bind(target) : val;
129
+ },
130
+ });
47
131
  }
48
132
 
49
133
  // ── 按点定位(右键菜单)──
@@ -202,6 +286,7 @@ export function createPanelPortalWith(owner: Element | null, defaultFit: PortalF
202
286
  let offBind: (() => void) | null = null;
203
287
  let offMove: Array<() => void> = [];
204
288
  let panelEl: HTMLElement | null = null;
289
+ let panelAddedLayer = false;
205
290
  let origin: { parent: Node; next: Node | null } | null = null;
206
291
  let escape: (() => void) | undefined;
207
292
  let last: {
@@ -239,6 +324,10 @@ export function createPanelPortalWith(owner: Element | null, defaultFit: PortalF
239
324
 
240
325
  const hide = (restore = true): void => {
241
326
  const el = panelEl;
327
+ if (el && panelAddedLayer) {
328
+ el.removeAttribute(KIT_ATTR_LAYER);
329
+ }
330
+ panelAddedLayer = false;
242
331
  if (el && restore && origin && origin.parent.isConnected !== false) {
243
332
  origin.parent.insertBefore(el, origin.next && origin.next.parentNode === origin.parent ? origin.next : null);
244
333
  }
@@ -288,9 +377,17 @@ export function createPanelPortalWith(owner: Element | null, defaultFit: PortalF
288
377
  ];
289
378
  }
290
379
  if (panel.parentNode !== box) {
380
+ if (panelEl !== null && panelEl !== panel && panelAddedLayer) {
381
+ panelEl.removeAttribute(KIT_ATTR_LAYER);
382
+ panelAddedLayer = false;
383
+ }
291
384
  if (panelEl === null && panel.parentNode) origin = { parent: panel.parentNode, next: panel.nextSibling };
292
385
  box!.replaceChildren(panel);
293
386
  }
387
+ if (panelEl !== panel) {
388
+ panelAddedLayer = panel.getAttribute('role') !== 'tooltip' && !panel.hasAttribute(KIT_ATTR_LAYER);
389
+ if (panelAddedLayer) panel.setAttribute(KIT_ATTR_LAYER, 'float');
390
+ }
294
391
  panelEl = panel;
295
392
  last = { anchor, pref, classFor, gapPx: opts.gapPx, fit: opts.fit };
296
393
  return place();