soma-kit 0.1.11 → 0.1.13

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 (376) hide show
  1. package/README.md +106 -112
  2. package/bin/soma-kit.mjs +32 -2
  3. package/bin/soma.mjs +22 -0
  4. package/package.json +14 -7
  5. package/packs/finance/reconcile-board.ts +5 -2
  6. package/packs/finance/reconcile-desk/compile.ts +3 -2
  7. package/spec/generated/kit-app.schema.json +929 -37
  8. package/spec/generated/kit-page.schema.json +1684 -161
  9. package/spec/kit-grammar.json +1176 -584
  10. package/spec/kit-grammar.schema.json +1971 -393
  11. package/src/app/app-config.ts +449 -347
  12. package/src/app/component-gate.ts +283 -28
  13. package/src/app/compose-apps.ts +79 -8
  14. package/src/app/define-kit-actions.ts +245 -41
  15. package/src/app/define-kit-app.ts +176 -33
  16. package/src/app/define-kit-view.ts +104 -0
  17. package/src/app/dev-diagnostic.ts +5 -0
  18. package/src/app/envelope.ts +1 -161
  19. package/src/app/index.ts +29 -6
  20. package/src/app/kit-view-context.ts +439 -0
  21. package/src/app/notify-renderer.ts +1 -115
  22. package/src/app/paged-list-adapter.ts +1 -240
  23. package/src/app/render-ports.ts +18 -0
  24. package/src/app/server-pages.ts +11 -3
  25. package/src/app/server.ts +530 -103
  26. package/src/app/submit.types.ts +1 -1
  27. package/src/app/theme-endpoint.ts +63 -0
  28. package/src/app/theme-runtime-shared.ts +1 -0
  29. package/src/app/theme-runtime.ts +667 -0
  30. package/src/base/action-busy.ts +103 -6
  31. package/src/base/action-gate.ts +4 -255
  32. package/src/base/action-slots.ts +58 -0
  33. package/src/base/alert.ts +5 -3
  34. package/src/base/anchored-layer.ts +50 -0
  35. package/src/base/avatar.ts +2 -2
  36. package/src/base/button.ts +99 -37
  37. package/src/base/cascader.ts +11 -12
  38. package/src/base/check-core.ts +9 -1
  39. package/src/base/checkbox.ts +2 -1
  40. package/src/base/choice.ts +49 -28
  41. package/src/base/class-candidates.ts +17 -0
  42. package/src/base/color-picker.ts +16 -11
  43. package/src/base/combobox.ts +5 -3
  44. package/src/base/command-palette.ts +10 -6
  45. package/src/base/context-menu.ts +10 -7
  46. package/src/base/countdown.ts +1 -1
  47. package/src/base/date-range.ts +32 -18
  48. package/src/base/date.ts +135 -28
  49. package/src/base/delta.ts +72 -0
  50. package/src/base/divider.ts +2 -2
  51. package/src/base/end-edge.ts +49 -0
  52. package/src/base/fab.ts +12 -5
  53. package/src/base/gap-value.ts +148 -0
  54. package/src/base/hint-tips.ts +170 -0
  55. package/src/base/icons.ts +8 -0
  56. package/src/base/illustrations.ts +94 -0
  57. package/src/base/image.ts +1 -1
  58. package/src/base/index.ts +35 -11
  59. package/src/base/input.ts +42 -13
  60. package/src/base/kbd.ts +3 -1
  61. package/src/base/link.ts +4 -4
  62. package/src/base/listbox-core.ts +56 -35
  63. package/src/base/loading-gate.ts +186 -0
  64. package/src/base/mentions.ts +7 -6
  65. package/src/base/menu-button.ts +28 -12
  66. package/src/base/menu-core.ts +41 -8
  67. package/src/base/motion/aura.ts +2 -2
  68. package/src/base/motion/hover-3d.ts +3 -3
  69. package/src/base/motion/hover-gallery.ts +2 -2
  70. package/src/base/motion/marquee.ts +3 -3
  71. package/src/base/motion/text-rotate.ts +2 -2
  72. package/src/base/number.ts +93 -80
  73. package/src/base/otp.ts +9 -5
  74. package/src/base/overlay-runtime.ts +235 -0
  75. package/src/base/permission-gate.ts +6 -0
  76. package/src/base/popover.ts +48 -16
  77. package/src/base/popup.ts +143 -19
  78. package/src/base/portal-core.ts +4 -0
  79. package/src/base/price-text.ts +2 -2
  80. package/src/base/progress.ts +2 -2
  81. package/src/base/qr-code.ts +4 -4
  82. package/src/base/qty-stepper.ts +14 -8
  83. package/src/base/radio.ts +2 -1
  84. package/src/base/range.ts +21 -4
  85. package/src/base/rating.ts +12 -7
  86. package/src/base/reason-tip.ts +150 -0
  87. package/src/base/segmented.ts +27 -21
  88. package/src/base/select.ts +4 -3
  89. package/src/base/shared.ts +387 -49
  90. package/src/base/state-panel.ts +346 -0
  91. package/src/base/status-tone.ts +27 -0
  92. package/src/base/sticky-edge.ts +116 -0
  93. package/src/base/swap.ts +10 -7
  94. package/src/base/switch.ts +11 -6
  95. package/src/base/tag-input.ts +20 -16
  96. package/src/base/tag.ts +68 -34
  97. package/src/base/text.ts +80 -18
  98. package/src/base/textarea.ts +37 -11
  99. package/src/base/time-picker.ts +18 -13
  100. package/src/base/tree-select.ts +21 -12
  101. package/src/base/trend-tone.ts +9 -0
  102. package/src/base/upload.ts +48 -14
  103. package/src/base/view-transition.ts +77 -0
  104. package/src/base/virtual-list.ts +107 -1
  105. package/src/biz/approval-desk/compile.ts +23 -41
  106. package/src/biz/approval-desk/shell.ts +11 -8
  107. package/src/biz/auth-panel/compile.ts +37 -52
  108. package/src/biz/auth-panel/index.ts +1 -1
  109. package/src/biz/auth-panel/shell.ts +5 -4
  110. package/src/biz/category-crud/compile.ts +23 -37
  111. package/src/biz/category-crud/shell.ts +2 -1
  112. package/src/biz/checkout-page/compile.ts +22 -5
  113. package/src/biz/checkout-page/shell.ts +4 -3
  114. package/src/biz/compose.ts +13 -27
  115. package/src/biz/define.ts +5 -4
  116. package/src/biz/import-wizard/compile.ts +22 -26
  117. package/src/biz/import-wizard/hub.ts +126 -61
  118. package/src/biz/import-wizard/shell.ts +5 -4
  119. package/src/biz/index.ts +3 -3
  120. package/src/biz/landing-page/compile.ts +19 -3
  121. package/src/biz/link/hub.ts +69 -22
  122. package/src/biz/link/shared.ts +127 -119
  123. package/src/biz/master-sub/compile.ts +127 -48
  124. package/src/biz/master-sub/index.ts +5 -2
  125. package/src/biz/master-sub/shell.ts +95 -18
  126. package/src/biz/multi-board/compile.ts +38 -50
  127. package/src/biz/multi-board/index.ts +18 -1
  128. package/src/biz/multi-board/shell.ts +32 -20
  129. package/src/biz/notification-center/compile.ts +21 -33
  130. package/src/biz/notification-center/shell.ts +6 -4
  131. package/src/biz/page-templates/domain-templates.ts +80 -13
  132. package/src/biz/page-templates/result-page/compile.ts +11 -2
  133. package/src/biz/page-templates/result-page/shell.ts +2 -1
  134. package/src/biz/page-templates/shared.ts +34 -36
  135. package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
  136. package/src/biz/record-detail/compile.ts +48 -43
  137. package/src/biz/record-detail/index.ts +11 -1
  138. package/src/biz/record-detail/shell.ts +8 -6
  139. package/src/biz/settings-center/compile.ts +7 -5
  140. package/src/biz/settings-center/shell.ts +6 -4
  141. package/src/biz/shared/action-host.ts +97 -211
  142. package/src/biz/shared/compile-helpers.ts +98 -0
  143. package/src/biz/shared/coordinator.ts +472 -92
  144. package/src/biz/shared/index.ts +13 -2
  145. package/src/biz/shared/object-aliases.ts +154 -0
  146. package/src/biz/shared/overlay-compile.ts +239 -0
  147. package/src/biz/shared/overlay-shell.ts +209 -0
  148. package/src/biz/shared/pipes.ts +50 -31
  149. package/src/biz/shared/remove-wire.ts +14 -0
  150. package/src/biz/shared/runtime-hub.ts +226 -24
  151. package/src/biz/single-form/compile.ts +16 -37
  152. package/src/biz/single-form/shell.ts +4 -3
  153. package/src/biz/standard-crud/compile.ts +72 -255
  154. package/src/biz/standard-crud/shell.ts +21 -99
  155. package/src/biz/step-form/compile.ts +26 -97
  156. package/src/biz/step-form/hub.ts +34 -41
  157. package/src/biz/step-form/shell.ts +5 -5
  158. package/src/biz/types.ts +4 -3
  159. package/src/cli/core-imports.ts +54 -0
  160. package/src/cli/kit-cli.ts +254 -25
  161. package/src/cli/kit-init.ts +227 -0
  162. package/src/cli/layout-cli.ts +167 -0
  163. package/src/cli/migrate/index.ts +10 -0
  164. package/src/cli/migrate/migrate.ts +248 -0
  165. package/src/cli/migrate/text-utils.ts +306 -0
  166. package/src/cli/migrate/theme-map.ts +104 -0
  167. package/src/cli/migrate/ts-rules.ts +235 -0
  168. package/src/cli/migrate/types.ts +95 -0
  169. package/src/cli/migrate/view-skeleton.ts +159 -0
  170. package/src/cli/migrate/yaml-report.ts +376 -0
  171. package/src/cli/migrate/yaml-rules.ts +465 -0
  172. package/src/cli/service-endpoint-check.ts +425 -0
  173. package/src/cli/source-path-check.d.mts +17 -0
  174. package/src/cli/source-path-check.mjs +334 -0
  175. package/src/cli/view-writes.ts +761 -0
  176. package/src/compile/action-host-attach.ts +21 -29
  177. package/src/compile/closed-set.ts +570 -0
  178. package/src/compile/compile-page.ts +267 -76
  179. package/src/compile/component-candidates.ts +13 -2
  180. package/src/compile/hints.ts +30 -1
  181. package/src/compile/index.ts +1 -0
  182. package/src/compile/kit-error.ts +1 -0
  183. package/src/compile/layout-lint/engine.ts +82 -0
  184. package/src/compile/layout-lint/index.ts +55 -0
  185. package/src/compile/layout-lint/rules-composition.ts +218 -0
  186. package/src/compile/layout-lint/rules-form.ts +192 -0
  187. package/src/compile/layout-lint/rules-table.ts +194 -0
  188. package/src/compile/layout-lint/score.ts +52 -0
  189. package/src/compile/layout-lint/types.ts +51 -0
  190. package/src/compile/locate.ts +21 -1
  191. package/src/compile/parse.ts +370 -41
  192. package/src/compile/redirect.ts +6 -2
  193. package/src/compile/remove-guard.ts +10 -7
  194. package/src/compile/styles.ts +63 -2
  195. package/src/compile/types.ts +31 -3
  196. package/src/compile/view-check.ts +284 -0
  197. package/src/data/amount-breakdown.ts +8 -3
  198. package/src/data/anchor-nav.ts +2 -2
  199. package/src/data/approval-flow.ts +3 -3
  200. package/src/data/assignment-picker.ts +92 -55
  201. package/src/data/async-result-panel.ts +111 -9
  202. package/src/data/breadcrumbs.ts +5 -4
  203. package/src/data/calendar.ts +24 -27
  204. package/src/data/carousel.ts +13 -8
  205. package/src/data/chart.ts +183 -44
  206. package/src/data/checklist.ts +20 -7
  207. package/src/data/code-view.ts +12 -6
  208. package/src/data/comment-thread.ts +7 -4
  209. package/src/data/confirm-dialog.ts +81 -18
  210. package/src/data/context-menu.ts +29 -37
  211. package/src/data/d9-util.ts +2 -18
  212. package/src/data/diff.ts +4 -2
  213. package/src/data/dock.ts +3 -3
  214. package/src/data/embed.ts +233 -30
  215. package/src/data/field-mapper.ts +35 -30
  216. package/src/data/flow-editor-contract.ts +8 -1
  217. package/src/data/flow-editor.ts +113 -108
  218. package/src/data/flow-node-options.ts +120 -0
  219. package/src/data/flow-remote-options.ts +0 -103
  220. package/src/data/footer.ts +2 -2
  221. package/src/data/form-draft-registry.ts +2 -4
  222. package/src/data/gantt.ts +19 -19
  223. package/src/data/hero.ts +4 -3
  224. package/src/data/image-viewer.ts +27 -30
  225. package/src/data/index.ts +5 -2
  226. package/src/data/item-list.ts +48 -31
  227. package/src/data/kanban.ts +82 -52
  228. package/src/data/media-grid.ts +20 -20
  229. package/src/data/mega-menu.ts +6 -4
  230. package/src/data/menu-dom.ts +4 -2
  231. package/src/data/menu.ts +47 -15
  232. package/src/data/mockup.ts +10 -6
  233. package/src/data/modal-dialog.ts +49 -25
  234. package/src/data/navbar.ts +12 -7
  235. package/src/data/notice-list.ts +268 -0
  236. package/src/data/notify-renderer.ts +250 -0
  237. package/src/data/object-form.ts +1360 -666
  238. package/src/data/outcome-watch.ts +61 -2
  239. package/src/data/pager.ts +80 -34
  240. package/src/data/permission-matrix.ts +52 -31
  241. package/src/data/permission-tree.ts +71 -44
  242. package/src/data/pricing-table.ts +30 -14
  243. package/src/data/prompt-dialog.ts +124 -194
  244. package/src/data/reaction-bar.ts +83 -92
  245. package/src/data/read-rollback.ts +73 -0
  246. package/src/data/record-card.ts +26 -5
  247. package/src/data/record-picker.ts +104 -55
  248. package/src/data/redirect.ts +32 -32
  249. package/src/data/remote-options.ts +13 -6
  250. package/src/data/request-console.ts +5 -3
  251. package/src/data/resident.ts +2 -1
  252. package/src/data/result-panel.ts +8 -4
  253. package/src/data/rich-text.ts +61 -55
  254. package/src/data/row-editor.ts +362 -76
  255. package/src/data/rule-builder.ts +26 -20
  256. package/src/data/shape-util.ts +27 -9
  257. package/src/data/stat-group.ts +392 -109
  258. package/src/data/static-lazy.ts +1 -0
  259. package/src/data/static-registry.ts +24 -11
  260. package/src/data/steps.ts +10 -5
  261. package/src/data/survey.ts +27 -32
  262. package/src/data/system-switcher.ts +3 -3
  263. package/src/data/text-action-button.ts +17 -0
  264. package/src/data/timeline.ts +19 -8
  265. package/src/data/tour-guide.ts +23 -30
  266. package/src/data/transfer.ts +62 -38
  267. package/src/data/tree-table.ts +152 -78
  268. package/src/data/tree.ts +49 -36
  269. package/src/data/trend-line.ts +6 -24
  270. package/src/data/virtual-rows.ts +133 -82
  271. package/src/data/watermark.ts +2 -2
  272. package/src/data/wrap.ts +63 -38
  273. package/src/data/wrapped-candidates.ts +10 -0
  274. package/src/frames/blank-frame.ts +1 -0
  275. package/src/frames/index.ts +2 -2
  276. package/src/frames/page-bar.ts +26 -24
  277. package/src/frames/page-header.ts +14 -5
  278. package/src/frames/page-status.ts +9 -7
  279. package/src/frames/shared.ts +36 -25
  280. package/src/frames/single-frame.ts +1 -0
  281. package/src/frames/split-frame/shell.ts +6 -6
  282. package/src/frames/split-frame/wiring.ts +2 -2
  283. package/src/frames/tabs-frame/shell.ts +4 -14
  284. package/src/frames/tabs-frame/wiring.ts +5 -8
  285. package/src/frames/top-main-frame.ts +3 -2
  286. package/src/frames/types.ts +13 -2
  287. package/src/frames/workspace-frame/extras.ts +21 -5
  288. package/src/frames/workspace-frame/index.ts +1 -1
  289. package/src/frames/workspace-frame/shell.ts +3 -2
  290. package/src/frames/workspace-frame/state.ts +13 -6
  291. package/src/frames/workspace-frame/view.ts +250 -48
  292. package/src/generated/kit-grammar-runtime.ts +645 -397
  293. package/src/generated/page-origin.ts +0 -11
  294. package/src/i18n/kit-text.ts +84 -29
  295. package/src/i18n/resolve-text-refs.ts +22 -6
  296. package/src/index.ts +2 -1
  297. package/src/object-renderer/action-gate.ts +11 -147
  298. package/src/object-renderer/arrange.ts +112 -84
  299. package/src/object-renderer/collapse-wiring.ts +2 -2
  300. package/src/object-renderer/collection-expand.ts +2 -2
  301. package/src/object-renderer/collection-parts.ts +401 -104
  302. package/src/object-renderer/collection-table.ts +287 -45
  303. package/src/object-renderer/collection.ts +258 -104
  304. package/src/object-renderer/compile-data.ts +112 -102
  305. package/src/object-renderer/crud-bridge.ts +32 -0
  306. package/src/object-renderer/defaults.ts +38 -16
  307. package/src/object-renderer/display-checks.ts +4 -25
  308. package/src/object-renderer/emit-events.ts +224 -176
  309. package/src/object-renderer/emit-object.ts +15 -2
  310. package/src/object-renderer/emit-static.ts +533 -151
  311. package/src/object-renderer/field-value.ts +593 -396
  312. package/src/object-renderer/filter-reload.ts +70 -0
  313. package/src/object-renderer/form-detail.ts +111 -2
  314. package/src/object-renderer/form-notify.ts +45 -0
  315. package/src/object-renderer/index.ts +26 -0
  316. package/src/object-renderer/key-field.ts +12 -0
  317. package/src/object-renderer/layout-facts.ts +386 -0
  318. package/src/object-renderer/layout-plan.ts +132 -0
  319. package/src/object-renderer/layout-plan.types.ts +22 -0
  320. package/src/object-renderer/linkage.ts +7 -270
  321. package/src/object-renderer/merge-class.ts +18 -1
  322. package/src/object-renderer/parts.ts +252 -1
  323. package/src/object-renderer/path-pick.ts +27 -0
  324. package/src/object-renderer/render-object.ts +456 -89
  325. package/src/object-renderer/request-actions.ts +232 -249
  326. package/src/object-renderer/skeleton.ts +58 -19
  327. package/src/object-renderer/table-actions.ts +319 -111
  328. package/src/object-renderer/table-summary.ts +2 -2
  329. package/src/object-renderer/table-tools.ts +429 -94
  330. package/src/object-renderer/types.ts +204 -127
  331. package/src/object-renderer/view-binding.ts +393 -0
  332. package/src/page-target/ai-surface.ts +37 -0
  333. package/src/page-target/compile.ts +48 -8
  334. package/src/page-target/index.ts +8 -1
  335. package/src/page-target/intent-schema.ts +165 -28
  336. package/src/page-target/target.ts +262 -51
  337. package/src/page-target/writer-policy.ts +14 -3
  338. package/src/recipes/container.ts +210 -0
  339. package/src/recipes/control.ts +277 -0
  340. package/src/recipes/index.ts +312 -0
  341. package/src/recipes/nowrap.ts +16 -0
  342. package/src/recipes/overlay.ts +240 -0
  343. package/src/recipes/placeholder.ts +79 -0
  344. package/src/recipes/rail-grid.ts +45 -0
  345. package/src/recipes/slot-align.ts +56 -0
  346. package/src/recipes/state.ts +99 -0
  347. package/src/recipes/status.ts +139 -0
  348. package/src/recipes/surface.ts +40 -0
  349. package/src/recipes/table-row.ts +88 -0
  350. package/src/recipes/title-row.ts +37 -0
  351. package/src/recipes/typography.ts +99 -0
  352. package/src/shared/action-field-guard.ts +41 -0
  353. package/src/shared/confirm-decl.ts +118 -0
  354. package/src/shared/envelope.ts +207 -0
  355. package/src/shared/escape.ts +57 -0
  356. package/src/shared/kit-error.ts +21 -0
  357. package/src/shared/paged-list-adapter.ts +15 -0
  358. package/src/shared/path-guard.ts +127 -0
  359. package/src/shared/theme-runtime-shared.ts +180 -0
  360. package/src/shared/view-info.ts +10 -0
  361. package/src/theme/index.ts +13 -0
  362. package/src/theme/kit-theme-text.ts +1 -1
  363. package/src/theme/kit-theme.css +407 -10
  364. package/src/theme/kit-theme.tpl +407 -10
  365. package/src/theme/nine-dim-structure.ts +247 -0
  366. package/src/theme/surface-layers.ts +101 -0
  367. package/src/theme/theme-tokens.ts +130 -84
  368. package/src/theme/theme-types.ts +103 -0
  369. package/src/theme/typography.ts +17 -17
  370. package/src/biz/shared/step-values.ts +0 -25
  371. package/src/biz/step-form/steps-ref.ts +0 -112
  372. package/src/data/options-bus.ts +0 -24
  373. package/src/object-renderer/adopt-gate.ts +0 -333
  374. package/src/object-renderer/field-policy.ts +0 -89
  375. package/src/object-renderer/outcome-draft.ts +0 -61
  376. package/src/theme/nine-dim-palettes.ts +0 -1473
@@ -8,13 +8,15 @@
8
8
  // import_files Upload 变化:取第一个文件,在浏览器内读成文本、按 CSV 解析(首行是表头);超过体积 / 行数上限给出错误提示
9
9
  // import_next 0 -> 1:按表头与目标字段自动建议映射;1 -> 2:按映射逐行用目标对象字典校验(services.data.validate)
10
10
  // import_commit 2 -> 3:把校验通过的行逐行 services.data.submit(目标, 行, 'create')(有限并发),收集失败行;写入全经 core 的 data 端口
11
+ // import_cancel 写入中取消:不再发起后续行(已发出的等落定),未处理行与失败行并入同一个「仅重试失败行」入口
11
12
  // import_download 下载问题行报告(CSV,单元格防公式注入)
12
13
  // import_prev 回上一步;import_restart 回第 1 步清空
13
14
  // 错误行不会被导入,也不阻断其余行:预览里标出,结果里汇总,随时可下载报告。
14
15
  //
15
16
  // 本组件不读 / 不存任何凭据;文件内容只在浏览器内存里,不写本地存储。
16
17
 
17
- import type { SomaComponentControllerContext, SomaComponentDefinition, SomaDataPort, SomaRegionPort } from 'soma-core';
18
+ import type { SomaComponentDefinition, SomaDataPort, SomaRegionPort } from 'soma-core';
19
+ import { createKitController } from '../../base/shared';
18
20
  import { KIT_BIZ_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
19
21
  import { kitText } from '../../i18n/kit-text';
20
22
 
@@ -27,6 +29,7 @@ export const KIT_IMPORT_EVENTS = {
27
29
  commit: 'import_commit',
28
30
  download: 'import_download',
29
31
  restart: 'import_restart',
32
+ cancel: 'import_cancel',
30
33
  result: 'import_result',
31
34
  } as const;
32
35
 
@@ -53,6 +56,8 @@ export const KIT_IMPORT_MIRRORS = {
53
56
  hasErrors: { key: 'imp_has_errors', path: 'has_errors', as: 'truthy' } as const,
54
57
  commitReady: { key: 'imp_commit_ready', path: 'commit_ready', as: 'truthy' } as const,
55
58
  commitBlocked: { key: 'imp_commit_blocked', path: 'commit_blocked', as: 'truthy' } as const,
59
+ cancelReady: { key: 'imp_cancel_ready', path: 'cancel_ready', as: 'truthy' } as const,
60
+ cancelBlocked: { key: 'imp_cancel_blocked', path: 'cancel_blocked', as: 'truthy' } as const,
56
61
  busy: { key: 'imp_busy', path: 'busy', as: 'truthy' } as const,
57
62
  notBusy: { key: 'imp_not_busy', path: 'not_busy', as: 'truthy' } as const,
58
63
  result: { key: 'imp_result', path: 'result', as: 'value' } as const,
@@ -66,6 +71,22 @@ function isRec(raw: unknown): raw is Rec {
66
71
 
67
72
  // ───────── CSV:解析、映射建议、行转换、报告(均为纯函数) ─────────
68
73
 
74
+ /** CSV 字节解码:先严格 UTF-8,失败(如 Excel 另存的 GBK)回退 GBK,环境不支持 GBK 再回退非严格 UTF-8;去掉开头 BOM */
75
+ export function decodeCsvBytes(buf: ArrayBuffer): string {
76
+ let text: string;
77
+ try {
78
+ text = new TextDecoder('utf-8', { fatal: true }).decode(buf);
79
+ } catch {
80
+ try {
81
+ text = new TextDecoder('gbk').decode(buf);
82
+ } catch {
83
+ // 运行环境不支持 gbk(RangeError):退回非严格 UTF-8,个别字符显示为替换符,也让用户看到内容自行判断
84
+ text = new TextDecoder('utf-8').decode(buf);
85
+ }
86
+ }
87
+ return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
88
+ }
89
+
69
90
  /** RFC 4180 的 CSV 解析:引号包裹、双引号转义、CRLF / LF;去掉 BOM 与全空行。返回行数组(每行是单元格数组) */
70
91
  export function parseCsv(text: string): string[][] {
71
92
  const src = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
@@ -147,12 +168,8 @@ export function mapRow(
147
168
  return out;
148
169
  }
149
170
 
150
- /** CSV 单元格转义;以 = + - @ 开头的文本前补单引号,防止在表格软件里被当公式执行 */
151
- export function csvCell(value: unknown): string {
152
- let s = value === undefined || value === null ? '' : String(value);
153
- if (/^[=+\-@]/.test(s)) s = `'${s}`;
154
- return /[",\r\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
155
- }
171
+ import { csvCell } from '../../shared/escape';
172
+ export { csvCell };
156
173
 
157
174
  export interface KitImportIssue { row: number; field: string; message: string }
158
175
 
@@ -188,11 +205,20 @@ export interface KitImportMem {
188
205
  progress: { done: number; total: number } | null;
189
206
  result: { status: string; title: string; subtitle: string; extra: Array<{ key: string; label: string }> } | null;
190
207
  seq: number;
208
+ runId: number;
209
+ /** 累计写入成功的行号(含重试) */
210
+ written: number[];
211
+ /** 最近一轮写入失败的行号(可重试) */
212
+ failedRows: number[];
213
+ /** 取消后未处理的行号(与失败行同一个重试入口) */
214
+ pendingRows: number[];
215
+ /** 已请求取消、在途行尚未落定(取消按钮禁用的依据);下一轮开始 / 重开 / 一轮结束时复位 */
216
+ cancelling: boolean;
191
217
  }
192
218
 
193
- export function initialImportMem(seq = 0): KitImportMem {
219
+ export function initialImportMem(seq = 0, runId = 0): KitImportMem {
194
220
  return {
195
- step: 0, files: [], parseError: '', columns: [], rows: [], mapping: {}, checked: null, busy: false, progress: null, result: null, seq,
221
+ step: 0, files: [], parseError: '', columns: [], rows: [], mapping: {}, checked: null, busy: false, progress: null, result: null, seq, runId, written: [], failedRows: [], pendingRows: [], cancelling: false,
196
222
  };
197
223
  }
198
224
 
@@ -214,8 +240,11 @@ export interface KitImportFocus {
214
240
  has_errors: boolean;
215
241
  commit_ready: boolean;
216
242
  commit_blocked: boolean;
243
+ cancel_ready: boolean;
244
+ cancel_blocked: boolean;
217
245
  busy: boolean;
218
246
  not_busy: boolean;
247
+ progress: { done: number; total: number } | null;
219
248
  result: Rec;
220
249
  seq: number;
221
250
  }
@@ -283,8 +312,11 @@ export function viewOfImport(mem: KitImportMem, targets: readonly KitImportTarge
283
312
  has_errors: errorRows > 0 || (mem.result !== null && (checked?.issues.length ?? 0) > 0),
284
313
  commit_ready: checked !== null && okCount > 0 && !mem.busy,
285
314
  commit_blocked: !(checked !== null && okCount > 0 && !mem.busy),
315
+ cancel_ready: !mem.cancelling,
316
+ cancel_blocked: mem.cancelling,
286
317
  busy: mem.busy,
287
318
  not_busy: !mem.busy,
319
+ progress: mem.progress,
288
320
  result: mem.result ?? {},
289
321
  seq: mem.seq,
290
322
  };
@@ -314,51 +346,55 @@ export function createKitImportHub(): SomaComponentDefinition {
314
346
  },
315
347
  emits: {
316
348
  step_change: { payload: { step: { type: 'number' } }, desc: '当前步变化' },
317
- imported: { payload: { ok: { type: 'number' }, failed: { type: 'number' } }, desc: '导入结束(成功 / 失败行数)' },
349
+ imported: { payload: { ok: { type: 'number' }, failed: { type: 'number' }, added: { type: 'number' } }, desc: '导入结束:ok 为累计成功行数(含此前各轮重试),failed 为当前未成功行数(失败 + 校验跳过 + 未处理),added 为本轮新增成功行数;宿主要累加请用 added,不要把各次的 ok 相加' },
318
350
  },
319
351
  scope: { slices: ['focus'] },
320
352
  },
321
353
  services: ['region', 'data', 'notify'],
322
354
  templateHtml: '<div data-soma-id="root" class="hidden"></div>',
323
- controllerFactory: (ctx: SomaComponentControllerContext) => {
355
+ controllerFactory: createKitController((api) => {
324
356
  let off: (() => void) | undefined;
325
357
  let alive = false;
326
358
  let mem = initialImportMem();
359
+ /** 独立的提交轮次标识(取消或重开时更换) */
360
+ let activeRunId = 0;
361
+ /** 已请求取消的轮次(0 = 无):不再发起后续行,已发出的一行等它落定 */
362
+ let cancelRun = 0;
327
363
  /** 当前选中的文件对象(不进切片,只在浏览器内存里) */
328
364
  let pickedFile: File | null = null;
329
- const props = (): Rec => (ctx.readProps ? ctx.readProps() : ctx.props);
365
+ const props = (): Rec => api.props() as Rec;
330
366
  const targets = (): KitImportTarget[] => targetsOf(props().targets);
331
367
  const types = (): Record<string, string | undefined> => {
332
368
  const t = props().types;
333
369
  return isRec(t) ? (t as Record<string, string | undefined>) : {};
334
370
  };
335
371
  const dataPort = (): SomaDataPort | undefined => {
336
- const port = (ctx.services as { data?: SomaDataPort } | undefined)?.data;
372
+ const port = (api.services as { data?: SomaDataPort } | undefined)?.data;
337
373
  return port && typeof port === 'object' ? port : undefined;
338
374
  };
339
375
  const toast = (level: string, message: string): void => {
340
- const svc = (ctx.services as { notify?: { toast?: (o: { level: string; message: string }) => void } } | undefined)?.notify;
376
+ const svc = (api.services as { notify?: { toast?: (o: { level: string; message: string }) => void } } | undefined)?.notify;
341
377
  if (svc && typeof svc.toast === 'function') svc.toast({ level, message });
342
378
  };
343
379
 
344
380
  const run = (port: SomaRegionPort, next: KitImportMem): void => {
345
381
  const prevStep = mem.step;
346
382
  mem = { ...next, seq: mem.seq + 1 };
347
- port.slice('focus')?.set(viewOfImport(mem, targets(), ctx.host) as unknown as Rec);
348
- if (mem.step !== prevStep) ctx.emit('step_change', { step: mem.step });
383
+ port.slice('focus')?.set(viewOfImport(mem, targets(), api.host) as unknown as Rec);
384
+ if (mem.step !== prevStep) api.emit('step_change', { step: mem.step });
349
385
  };
350
386
 
351
387
  const readFile = async (port: SomaRegionPort, file: File): Promise<void> => {
352
388
  const files: KitImportFile[] = [{ name: file.name, size: file.size, status: 'done' }];
353
389
  if (file.size > LIMITS.maxFileKb * 1024) {
354
- run(port, { ...mem, files: [{ ...files[0]!, status: 'error' }], parseError: kitText('soma.kit.iw_too_big', { n: LIMITS.maxFileKb }, ctx.host), columns: [], rows: [], mapping: {}, checked: null });
390
+ run(port, { ...mem, files: [{ ...files[0]!, status: 'error' }], parseError: kitText('soma.kit.iw_too_big', { n: LIMITS.maxFileKb }, api.host), columns: [], rows: [], mapping: {}, checked: null });
355
391
  return;
356
392
  }
357
393
  let text = '';
358
394
  try {
359
- text = await file.text();
395
+ text = decodeCsvBytes(await file.arrayBuffer());
360
396
  } catch {
361
- if (alive) run(port, { ...mem, files: [{ ...files[0]!, status: 'error' }], parseError: kitText('soma.kit.iw_read_failed', undefined, ctx.host), columns: [], rows: [], mapping: {}, checked: null });
397
+ if (alive) run(port, { ...mem, files: [{ ...files[0]!, status: 'error' }], parseError: kitText('soma.kit.iw_read_failed', undefined, api.host), columns: [], rows: [], mapping: {}, checked: null });
362
398
  return;
363
399
  }
364
400
  if (!alive || pickedFile !== file) return;
@@ -366,10 +402,10 @@ export function createKitImportHub(): SomaComponentDefinition {
366
402
  const header = (table[0] ?? []).map((h) => h.trim());
367
403
  const body = table.slice(1);
368
404
  let error = '';
369
- if (header.length === 0 || header.every((h) => h === '')) error = kitText('soma.kit.iw_no_header', undefined, ctx.host);
370
- else if (new Set(header).size !== header.length) error = kitText('soma.kit.iw_dup_header', undefined, ctx.host);
371
- else if (body.length === 0) error = kitText('soma.kit.iw_no_rows', undefined, ctx.host);
372
- else if (body.length > LIMITS.maxRows) error = kitText('soma.kit.iw_too_many', { n: LIMITS.maxRows }, ctx.host);
405
+ if (header.length === 0 || header.every((h) => h === '')) error = kitText('soma.kit.iw_no_header', undefined, api.host);
406
+ else if (new Set(header).size !== header.length) error = kitText('soma.kit.iw_dup_header', undefined, api.host);
407
+ else if (body.length === 0) error = kitText('soma.kit.iw_no_rows', undefined, api.host);
408
+ else if (body.length > LIMITS.maxRows) error = kitText('soma.kit.iw_too_many', { n: LIMITS.maxRows }, api.host);
373
409
  if (error !== '') {
374
410
  run(port, { ...mem, files: [{ ...files[0]!, status: 'error' }], parseError: error, columns: [], rows: [], mapping: {}, checked: null });
375
411
  return;
@@ -398,56 +434,76 @@ export function createKitImportHub(): SomaComponentDefinition {
398
434
  return { okRows, issues };
399
435
  };
400
436
 
401
- const commit = async (port: SomaRegionPort): Promise<void> => {
437
+ /** 写入:首次 = 全部校验通过的行;重试 = 上次失败行 + 未处理行(同一条写入路径) */
438
+ const commit = async (port: SomaRegionPort, retry = false): Promise<void> => {
402
439
  const data = dataPort();
403
440
  const object = typeof props().object === 'string' ? (props().object as string) : '';
404
441
  const checked = mem.checked;
405
- if (!data || object === '' || checked === null || checked.okRows.length === 0) return;
406
- const seq0 = mem.seq + 1;
407
- const queue = [...checked.okRows];
442
+ if (!data || object === '' || checked === null) return;
443
+ const retryRows = [...mem.failedRows, ...mem.pendingRows].sort((x, y) => x - y);
444
+ const queue = retry ? retryRows : [...checked.okRows];
445
+ if (queue.length === 0) return;
446
+ activeRunId += 1;
447
+ const thisRun = activeRunId;
448
+ cancelRun = 0;
408
449
  const total = queue.length;
450
+ const priorWritten = retry ? mem.written : [];
409
451
  const failed: KitImportIssue[] = [];
452
+ const okNow: number[] = [];
410
453
  let done = 0;
411
- run(port, { ...mem, step: 3, busy: true, progress: { done: 0, total }, result: null });
454
+ // 重试的行先清掉旧的失败原因,仍失败的会带最新原因写回
455
+ const baseIssues = retry ? checked.issues.filter((x) => !queue.includes(x.row)) : checked.issues;
456
+ run(port, { ...mem, step: 3, busy: true, cancelling: false, progress: { done: 0, total }, result: null, runId: thisRun, ...(retry ? {} : { written: [], failedRows: [], pendingRows: [] }) });
412
457
  const worker = async (): Promise<void> => {
413
458
  for (;;) {
459
+ if (!alive || activeRunId !== thisRun || cancelRun === thisRun) return;
414
460
  const n = queue.shift();
415
- if (n === undefined || !alive) return;
461
+ if (n === undefined) return;
416
462
  const r = await data.submit(object, mapRow(mem.rows[n - 1] ?? {}, mem.mapping, types()), 'create');
463
+ if (!alive || activeRunId !== thisRun) return;
417
464
  if (!r.ok) {
418
465
  const fe = Object.entries(r.fieldErrors ?? {});
419
466
  if (fe.length > 0) for (const [field, message] of fe) failed.push({ row: n, field, message });
420
- else failed.push({ row: n, field: '', message: r.message !== '' ? r.message : '写入失败' });
421
- }
467
+ else failed.push({ row: n, field: '', message: r.message !== '' ? r.message : kitText('soma.kit.iw_write_failed', undefined, api.host) });
468
+ } else okNow.push(n);
422
469
  done += 1;
423
- // 重新开始(seq 变了)后,过期的进度不再写回
424
- if (alive && mem.seq === seq0) run(port, { ...mem, progress: { done, total } });
470
+ // 重新开始(轮次变了)后,过期的进度不再写回
471
+ if (alive && activeRunId === thisRun) run(port, { ...mem, progress: { done, total } });
425
472
  }
426
473
  };
427
474
  await Promise.all(Array.from({ length: Math.min(LIMITS.concurrency, total) }, () => worker()));
428
- if (!alive || mem.step !== 3) return;
429
- const okCount = total - new Set(failed.map((f) => f.row)).size;
430
- const failCount = total - okCount;
431
- const issues = [...checked.issues, ...failed];
432
- const skipped = new Set(checked.issues.map((x) => x.row)).size;
433
- const status = failCount === 0 && skipped === 0 ? 'success' : okCount === 0 ? 'error' : 'warning';
434
- const subtitle = kitText('soma.kit.iw_sub', { ok: okCount, fail: failCount, skipped }, ctx.host);
475
+ if (!alive || activeRunId !== thisRun || mem.step !== 3) return;
476
+ // 取消后没来得及发出的行:queue 里剩下的
477
+ const pendingRows = [...queue];
478
+ const failedRows = [...new Set(failed.map((f) => f.row))];
479
+ const written = [...priorWritten, ...okNow];
480
+ const okCount = written.length;
481
+ const failCount = failedRows.length;
482
+ const issues = [...baseIssues, ...failed];
483
+ const skipped = new Set(baseIssues.map((x) => x.row)).size;
484
+ const clean = failCount === 0 && skipped === 0 && pendingRows.length === 0;
485
+ // 用户取消(确有未处理行)且一行都没写成功:不算错误态,用「已取消」标题
486
+ const cancelled = cancelRun === thisRun && pendingRows.length > 0;
487
+ const status = clean ? 'success' : okCount === 0 && !cancelled ? 'error' : 'warning';
488
+ let subtitle = kitText('soma.kit.iw_sub', { ok: okCount, fail: failCount, skipped }, api.host);
489
+ if (pendingRows.length > 0) subtitle += `${kitText('soma.kit.semicolon', undefined, api.host)}${kitText('soma.kit.iw_unprocessed', { n: pendingRows.length }, api.host)}`;
435
490
  const extra: Array<{ key: string; label: string }> = [];
436
- if (issues.length > 0) extra.push({ key: 'download', label: kitText('soma.kit.iw_download_issues', undefined, ctx.host) });
437
- extra.push({ key: 'restart', label: kitText('soma.kit.iw_restart', undefined, ctx.host) });
491
+ if (failCount + pendingRows.length > 0) extra.push({ key: 'retry', label: kitText('soma.kit.iw_retry_failed', { n: failCount + pendingRows.length }, api.host) });
492
+ if (issues.length > 0) extra.push({ key: 'download', label: kitText('soma.kit.iw_download_issues', undefined, api.host) });
493
+ extra.push({ key: 'restart', label: kitText('soma.kit.iw_restart', undefined, api.host) });
438
494
  run(port, {
439
- ...mem, busy: false, progress: null,
440
- checked: { okRows: checked.okRows.filter((n) => !failed.some((f) => f.row === n)), issues },
441
- result: { status, title: kitText(status === 'success' ? 'soma.kit.iw_done' : status === 'error' ? 'soma.kit.iw_failed' : 'soma.kit.iw_partial', undefined, ctx.host), subtitle, extra },
495
+ ...mem, busy: false, cancelling: false, progress: null, written, failedRows, pendingRows,
496
+ checked: { okRows: [...new Set([...checked.okRows, ...okNow])].filter((n) => !failedRows.includes(n)).sort((x, y) => x - y), issues },
497
+ result: { status, title: kitText(status === 'success' ? 'soma.kit.iw_done' : status === 'error' ? 'soma.kit.iw_failed' : cancelled && okCount === 0 ? 'soma.kit.request_cancelled' : 'soma.kit.iw_partial', undefined, api.host), subtitle, extra },
442
498
  });
443
- ctx.emit('imported', { ok: okCount, failed: failCount + skipped });
444
- if (failCount === 0 && skipped === 0) toast('success', kitText('soma.kit.iw_imported', { n: okCount }, ctx.host));
499
+ api.emit('imported', { ok: okCount, failed: failCount + skipped + pendingRows.length, added: okNow.length });
500
+ if (clean) toast('success', kitText('soma.kit.iw_imported', { n: okCount }, api.host));
445
501
  };
446
502
 
447
503
  const download = (): void => {
448
504
  const checked = mem.checked;
449
505
  if (!checked || checked.issues.length === 0 || typeof document === 'undefined' || typeof Blob === 'undefined') return;
450
- const csv = buildIssueReport(mem.columns, mem.rows, checked.issues, ctx.host);
506
+ const csv = buildIssueReport(mem.columns, mem.rows, checked.issues, api.host);
451
507
  const url = URL.createObjectURL(new Blob([`${csv}`], { type: 'text/csv;charset=utf-8' }));
452
508
  const a = document.createElement('a');
453
509
  a.href = url;
@@ -459,15 +515,16 @@ export function createKitImportHub(): SomaComponentDefinition {
459
515
  };
460
516
 
461
517
  return {
462
- onMount(): void {
518
+ attach() {
463
519
  alive = true;
464
520
  const scope = typeof props().scope === 'string' ? (props().scope as string) : '';
465
- const svc = (ctx.services as { region?: (id: string) => SomaRegionPort | null } | undefined)?.region;
521
+ const svc = (api.services as { region?: (id: string) => SomaRegionPort | null } | undefined)?.region;
466
522
  const port = scope !== '' && typeof svc === 'function' ? svc(scope) : null;
467
523
  const focus = port?.slice('focus');
468
524
  if (!port || !focus) return;
469
- mem = initialImportMem();
470
- focus.set(viewOfImport(mem, targets(), ctx.host) as unknown as Rec);
525
+ activeRunId += 1;
526
+ mem = initialImportMem(0, activeRunId);
527
+ focus.set(viewOfImport(mem, targets(), api.host) as unknown as Rec);
471
528
  off = port.onSemantic((name, payload) => {
472
529
  const p = isRec(payload) ? payload : {};
473
530
  switch (name) {
@@ -514,25 +571,33 @@ export function createKitImportHub(): SomaComponentDefinition {
514
571
  case KIT_IMPORT_EVENTS.result: {
515
572
  const key = typeof p.key === 'string' ? p.key : '';
516
573
  if (key === 'download') download();
517
- else if (key === 'restart' && !mem.busy) { pickedFile = null; run(port, initialImportMem(mem.seq)); }
574
+ else if (key === 'retry') { if (!mem.busy && mem.step === 3) void commit(port, true); }
575
+ else if (key === 'restart') { activeRunId += 1; pickedFile = null; run(port, initialImportMem(mem.seq, activeRunId)); }
518
576
  return;
519
577
  }
578
+ case KIT_IMPORT_EVENTS.cancel:
579
+ if (mem.busy && mem.step === 3) { cancelRun = activeRunId; if (!mem.cancelling) run(port, { ...mem, cancelling: true }); }
580
+ return;
520
581
  case KIT_IMPORT_EVENTS.restart:
521
- if (!mem.busy) { pickedFile = null; run(port, initialImportMem(mem.seq)); }
582
+ activeRunId += 1;
583
+ pickedFile = null;
584
+ run(port, initialImportMem(mem.seq, activeRunId));
522
585
  return;
523
586
  default:
524
587
  return;
525
588
  }
526
589
  });
590
+ return () => {
591
+ alive = false;
592
+ activeRunId += 1;
593
+ pickedFile = null;
594
+ if (off) off();
595
+ off = undefined;
596
+ };
527
597
  },
528
- onUnmount(): void {
529
- alive = false;
530
- pickedFile = null;
531
- if (off) off();
532
- off = undefined;
533
- },
598
+ render() {},
534
599
  };
535
- },
600
+ }),
536
601
  };
537
602
  }
538
603
 
@@ -3,6 +3,7 @@
3
3
  // 显隐规则同 StepForm:面板 / 步骤条变体 / 按钮都是「外层只放 core 写的 hidden、内层放布局类」两层;各步组件一直挂着,只靠外层显隐切换。
4
4
 
5
5
  import { mergeClass } from '../../object-renderer/merge-class';
6
+ import { kitShellRecipe } from '../../recipes/container';
6
7
  import { cls, esc, host } from '../link/shared';
7
8
  import { kitText } from '../../i18n/kit-text';
8
9
  import { kitIconHtml } from '../../base/icons';
@@ -18,7 +19,7 @@ export const IMPORT_WIZARD_STEP_TITLES = [
18
19
 
19
20
  export const IMPORT_WIZARD_CLASS = {
20
21
  root: '@container flex justify-center',
21
- card: 'flex w-full max-w-3xl flex-col gap-6 rounded-lg border border-border-strong bg-surface-raised p-6 shadow-xs',
22
+ card: mergeClass('flex w-full max-w-3xl flex-col gap-6 p-6', kitShellRecipe()),
22
23
  title: 'text-lg font-semibold text-fg',
23
24
  steps: 'flex flex-wrap items-center gap-2',
24
25
  stepItem: 'flex items-center gap-2',
@@ -55,9 +56,9 @@ export interface ImportWizardIds {
55
56
  resultWrap: string;
56
57
  result: string;
57
58
  /** 带显隐门的按钮:`<名>` 可用态与 `<名>_off` 禁用态成对 */
58
- btn(name: 'up_next' | 'map_prev' | 'map_next' | 'pre_prev' | 'pre_download' | 'pre_commit', off?: boolean): string;
59
+ btn(name: 'up_next' | 'map_prev' | 'map_next' | 'pre_prev' | 'pre_download' | 'pre_commit' | 'cancel', off?: boolean): string;
59
60
  /** 带显隐门的按钮外层(只放 core 写的 hidden);门与按钮 id 不同,避免重复 */
60
- btnGate(name: 'up_next' | 'map_prev' | 'map_next' | 'pre_prev' | 'pre_download' | 'pre_commit', off?: boolean): string;
61
+ btnGate(name: 'up_next' | 'map_prev' | 'map_next' | 'pre_prev' | 'pre_download' | 'pre_commit' | 'cancel', off?: boolean): string;
61
62
  }
62
63
 
63
64
  export function importWizardIds(pageId: string): ImportWizardIds {
@@ -149,7 +150,7 @@ export function importWizardHtml(
149
150
  ].join(''));
150
151
  const p3 = gate(ids.panel(3), `<div${cls(mergeClass(C.done, areaClass.done))}>`
151
152
  + `<h3${cls(C.panelTitle)}>${esc(T(3))}</h3>`
152
- + gate(ids.progress, text(`${ids.progress}_text`, C.hint))
153
+ + gate(ids.progress, text(`${ids.progress}_text`, C.hint) + buttons(gatedBtn('cancel'), gatedBtn('cancel', true)))
153
154
  + gate(ids.resultWrap, host('ResultPanel', ids.result))
154
155
  + parts.job
155
156
  + '</div>');
package/src/biz/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // 业务组件登记表:内置闭集。编译器按 `product.kind` 查 KIT_BIZ_COMPONENTS。
2
- // 五个:StandardCrud / MasterSubWorkstation / CategoryCrud / MultiObjectBoard / SingleObjectForm。
2
+ // 15 个内置业务组件闭集(StandardCrud / MasterSubWorkstation / CategoryCrud / MultiObjectBoard / SingleObjectForm / ApprovalDesk / RecordDetail / StepForm / NotificationCenter / AuthPanel / SettingsCenter / CheckoutPage / LandingPage / ResultPage / ImportWizard)+ KIT_PAGE_TEMPLATES 10 个可选页面模板。
3
3
  // 业务组件壳依赖两个无界面协作数据组件:KitCrudBridge(focus 切片 owner:浮层开合、预填、保存后重取、删除)
4
4
  // 与 KitLinkHub(selection 切片 owner:主子 / 分类联动选中、默认首条、字段动作带当前行),登记在 KIT_BIZ_DATA_COMPONENTS,
5
5
  // 由应用装配并入数据组件表(与 createKitDataComponents 的产物合并,重名要显式 overrides)。
@@ -29,7 +29,7 @@ import {
29
29
  CapacityScheduleDesk,
30
30
  TraceDiagnosticDesk,
31
31
  TicketServiceDesk,
32
- } from "./page-templates/domain-templates";
32
+ } from './page-templates/domain-templates';
33
33
 
34
34
  import type { KitBizDefinition } from './types';
35
35
 
@@ -66,7 +66,7 @@ export {
66
66
  CapacityScheduleDesk,
67
67
  TraceDiagnosticDesk,
68
68
  TicketServiceDesk,
69
- } from "./page-templates/domain-templates";
69
+ } from './page-templates/domain-templates';
70
70
 
71
71
  export {
72
72
  ImportWizard, compileImportWizard, importWizardObjectName, createKitImportHub, KIT_IMPORT_EVENTS, KIT_IMPORT_MIRRORS,
@@ -13,6 +13,7 @@ import { IDENT, classesIn, isRec, newParts, type Rec } from '../link/shared';
13
13
  import {
14
14
  addClassTokens, checkAreas, emitReadOnlyMember, finishTemplate, templateObjectName,
15
15
  } from '../page-templates/shared';
16
+ import { LandingPage } from './index';
16
17
  import {
17
18
  LANDING_PAGE_AREAS, LANDING_PAGE_CLASS, landingPageHtml, landingPageIds, type LandingSectionBlock,
18
19
  } from './shell';
@@ -33,6 +34,9 @@ export function compileLandingPage(input: KitBizInput, ctx: KitBizContext): KitF
33
34
  checkAreas(input, 'LandingPage', LANDING_PAGE_AREAS, out);
34
35
  const names = isRec(rawSections) ? Object.keys(rawSections) : [];
35
36
  for (const n of names) {
37
+ if (n === 'hero' || n === 'footer') {
38
+ fail('KIT-BIZ-001', `内容段名 "${n}" 与保留角色名撞名,禁止静默覆盖主视觉或页脚对象`, `product.objects.sections.${n}`);
39
+ }
36
40
  if (!IDENT.test(n)) fail('KIT-PAGE-001', `内容段名 "${n}" 必须是标识符(字母数字下划线)`, `product.objects.sections.${n}`);
37
41
  }
38
42
  if (out.diagnostics.length > 0) return finishTemplate(out, '');
@@ -41,20 +45,32 @@ export function compileLandingPage(input: KitBizInput, ctx: KitBizContext): KitF
41
45
  const areaClass = input.areaClass ?? {};
42
46
 
43
47
  const hero = emitReadOnlyMember(out, rawHero, {
44
- object: landingPageObjectName(ctx.pageId, 'hero'), path: 'product.objects.hero', allowed: ['summary', 'list'], ctx,
48
+ object: landingPageObjectName(ctx.pageId, 'hero'),
49
+ path: 'product.objects.hero',
50
+ roleName: 'hero',
51
+ roleDef: LandingPage.roles.hero,
52
+ ctx,
45
53
  });
46
54
  const blocks: LandingSectionBlock[] = [];
47
55
  for (const n of names) {
48
56
  const raw = (rawSections as Rec)[n];
49
57
  const m = emitReadOnlyMember(out, raw, {
50
- object: landingPageObjectName(ctx.pageId, n), path: `product.objects.sections.${n}`, allowed: ['list', 'summary'], ctx,
58
+ object: landingPageObjectName(ctx.pageId, n),
59
+ path: `product.objects.sections.${n}`,
60
+ roleName: 'sections',
61
+ roleDef: LandingPage.roles.sections,
62
+ ctx,
51
63
  });
52
64
  if (m !== undefined) blocks.push({ title: isRec(raw) && typeof raw.title === 'string' ? raw.title : '', html: m.html });
53
65
  }
54
66
  let footer = '';
55
67
  if (rawFooter !== undefined) {
56
68
  const m = emitReadOnlyMember(out, rawFooter, {
57
- object: landingPageObjectName(ctx.pageId, 'footer'), path: 'product.objects.footer', allowed: ['summary', 'list'], ctx,
69
+ object: landingPageObjectName(ctx.pageId, 'footer'),
70
+ path: 'product.objects.footer',
71
+ roleName: 'footer',
72
+ roleDef: LandingPage.roles.footer,
73
+ ctx,
58
74
  });
59
75
  footer = m?.html ?? '';
60
76
  }