soma-kit 0.0.0-stage → 0.1.1

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 (352) hide show
  1. package/README.md +541 -2
  2. package/bin/soma-kit.mjs +27 -0
  3. package/package.json +66 -4
  4. package/packs/ai/agent-run-card.ts +64 -0
  5. package/packs/ai/evaluation-card.ts +51 -0
  6. package/packs/ai/guardrail-policy-card.ts +48 -0
  7. package/packs/ai/index.ts +31 -0
  8. package/packs/ai/model-card.ts +55 -0
  9. package/packs/ai/model-routing-card.ts +49 -0
  10. package/packs/ai/prompt-template-card.ts +49 -0
  11. package/packs/ai/texts.ts +19 -0
  12. package/packs/commerce/address-card.ts +58 -0
  13. package/packs/commerce/coupon-card.ts +64 -0
  14. package/packs/commerce/index.ts +25 -0
  15. package/packs/commerce/order-card.ts +60 -0
  16. package/packs/commerce/purchase-order-card.ts +74 -0
  17. package/packs/commerce/texts.ts +14 -0
  18. package/packs/finance/index.ts +30 -0
  19. package/packs/finance/invoice-summary-card.ts +48 -0
  20. package/packs/finance/reconcile-board.ts +450 -0
  21. package/packs/finance/reconcile-case-card.ts +70 -0
  22. package/packs/finance/reconcile-desk/compile.ts +208 -0
  23. package/packs/finance/reconcile-desk/index.ts +20 -0
  24. package/packs/finance/reconcile-desk/shell.ts +27 -0
  25. package/packs/finance/texts.ts +21 -0
  26. package/packs/ops/change-window-card.ts +54 -0
  27. package/packs/ops/dependency-status-card.ts +50 -0
  28. package/packs/ops/error-budget-card.ts +60 -0
  29. package/packs/ops/execution-task-runner.ts +61 -0
  30. package/packs/ops/index.ts +36 -0
  31. package/packs/ops/integration-status-card.ts +45 -0
  32. package/packs/ops/release-readiness-card.ts +63 -0
  33. package/packs/ops/runbook-execution-card.ts +81 -0
  34. package/packs/ops/texts.ts +21 -0
  35. package/packs/security/control-evidence-card.ts +54 -0
  36. package/packs/security/finding-card.ts +96 -0
  37. package/packs/security/index.ts +29 -0
  38. package/packs/security/texts.ts +31 -0
  39. package/packs/shared/card-util.ts +60 -0
  40. package/packs/shared/wrap.ts +12 -0
  41. package/spec/generated/kit-app.schema.json +84 -0
  42. package/spec/generated/kit-page.schema.json +2766 -0
  43. package/spec/kit-grammar.json +1357 -0
  44. package/spec/kit-grammar.schema.json +715 -0
  45. package/src/app/app-config.ts +108 -0
  46. package/src/app/compose-apps.ts +155 -0
  47. package/src/app/define-kit-actions.ts +89 -0
  48. package/src/app/define-kit-app.ts +383 -0
  49. package/src/app/define-kit-pack.ts +114 -0
  50. package/src/app/envelope.ts +138 -0
  51. package/src/app/index.ts +53 -0
  52. package/src/app/notify-renderer.ts +114 -0
  53. package/src/app/paged-list-adapter.ts +240 -0
  54. package/src/app/server-pages.ts +303 -0
  55. package/src/app/server.ts +244 -0
  56. package/src/app/submit.types.ts +87 -0
  57. package/src/base/action-busy.ts +159 -0
  58. package/src/base/action-gate.ts +267 -0
  59. package/src/base/action-status.ts +31 -0
  60. package/src/base/alert.ts +136 -0
  61. package/src/base/avatar.ts +271 -0
  62. package/src/base/button.ts +139 -0
  63. package/src/base/cascader.ts +523 -0
  64. package/src/base/check-core.ts +214 -0
  65. package/src/base/checkbox.ts +35 -0
  66. package/src/base/choice.ts +183 -0
  67. package/src/base/color-picker.ts +316 -0
  68. package/src/base/combobox.ts +61 -0
  69. package/src/base/command-palette.ts +371 -0
  70. package/src/base/context-menu.ts +103 -0
  71. package/src/base/countdown.ts +168 -0
  72. package/src/base/date-range.ts +444 -0
  73. package/src/base/date.ts +899 -0
  74. package/src/base/divider.ts +156 -0
  75. package/src/base/fab.ts +192 -0
  76. package/src/base/icons.ts +106 -0
  77. package/src/base/image.ts +177 -0
  78. package/src/base/index.ts +214 -0
  79. package/src/base/input.ts +316 -0
  80. package/src/base/kbd.ts +99 -0
  81. package/src/base/link.ts +167 -0
  82. package/src/base/listbox-core.ts +965 -0
  83. package/src/base/mentions.ts +323 -0
  84. package/src/base/menu-button.ts +240 -0
  85. package/src/base/menu-core.ts +341 -0
  86. package/src/base/month-grid.ts +171 -0
  87. package/src/base/motion/aura.ts +94 -0
  88. package/src/base/motion/hover-3d.ts +154 -0
  89. package/src/base/motion/hover-gallery.ts +185 -0
  90. package/src/base/motion/index.ts +27 -0
  91. package/src/base/motion/limits.ts +75 -0
  92. package/src/base/motion/marquee.ts +157 -0
  93. package/src/base/motion/text-rotate.ts +195 -0
  94. package/src/base/number.ts +121 -0
  95. package/src/base/otp.ts +259 -0
  96. package/src/base/permission-gate.ts +99 -0
  97. package/src/base/popover.ts +352 -0
  98. package/src/base/popup.ts +542 -0
  99. package/src/base/portal-core.ts +297 -0
  100. package/src/base/price-text.ts +126 -0
  101. package/src/base/progress.ts +216 -0
  102. package/src/base/qr-code.ts +446 -0
  103. package/src/base/qty-stepper.ts +241 -0
  104. package/src/base/radio.ts +33 -0
  105. package/src/base/range.ts +444 -0
  106. package/src/base/rating.ts +249 -0
  107. package/src/base/segmented.ts +286 -0
  108. package/src/base/select.ts +57 -0
  109. package/src/base/shared.ts +708 -0
  110. package/src/base/swap.ts +86 -0
  111. package/src/base/switch.ts +111 -0
  112. package/src/base/tag-input.ts +464 -0
  113. package/src/base/tag.ts +250 -0
  114. package/src/base/text.ts +126 -0
  115. package/src/base/textarea.ts +129 -0
  116. package/src/base/time-picker.ts +606 -0
  117. package/src/base/tree-select.ts +629 -0
  118. package/src/base/upload.ts +548 -0
  119. package/src/base/virtual-list.ts +286 -0
  120. package/src/biz/approval-desk/compile.ts +179 -0
  121. package/src/biz/approval-desk/index.ts +21 -0
  122. package/src/biz/approval-desk/shell.ts +50 -0
  123. package/src/biz/auth-panel/compile.ts +196 -0
  124. package/src/biz/auth-panel/index.ts +24 -0
  125. package/src/biz/auth-panel/shell.ts +46 -0
  126. package/src/biz/category-crud/compile.ts +173 -0
  127. package/src/biz/category-crud/index.ts +19 -0
  128. package/src/biz/category-crud/shell.ts +29 -0
  129. package/src/biz/checkout-page/compile.ts +111 -0
  130. package/src/biz/checkout-page/index.ts +20 -0
  131. package/src/biz/checkout-page/shell.ts +50 -0
  132. package/src/biz/compose.ts +313 -0
  133. package/src/biz/data-components.ts +26 -0
  134. package/src/biz/define.ts +23 -0
  135. package/src/biz/import-wizard/compile.ts +204 -0
  136. package/src/biz/import-wizard/hub.ts +540 -0
  137. package/src/biz/import-wizard/index.ts +24 -0
  138. package/src/biz/import-wizard/shell.ts +161 -0
  139. package/src/biz/index.ts +80 -0
  140. package/src/biz/landing-page/compile.ts +67 -0
  141. package/src/biz/landing-page/index.ts +20 -0
  142. package/src/biz/landing-page/shell.ts +48 -0
  143. package/src/biz/link/hub.ts +255 -0
  144. package/src/biz/link/shared.ts +493 -0
  145. package/src/biz/master-sub/compile.ts +232 -0
  146. package/src/biz/master-sub/index.ts +20 -0
  147. package/src/biz/master-sub/shell.ts +56 -0
  148. package/src/biz/multi-board/compile.ts +234 -0
  149. package/src/biz/multi-board/index.ts +19 -0
  150. package/src/biz/multi-board/shell.ts +70 -0
  151. package/src/biz/names.ts +30 -0
  152. package/src/biz/notification-center/compile.ts +138 -0
  153. package/src/biz/notification-center/index.ts +29 -0
  154. package/src/biz/notification-center/shell.ts +42 -0
  155. package/src/biz/page-templates/result-page/compile.ts +46 -0
  156. package/src/biz/page-templates/result-page/index.ts +19 -0
  157. package/src/biz/page-templates/result-page/shell.ts +31 -0
  158. package/src/biz/page-templates/shared.ts +121 -0
  159. package/src/biz/page-templates/sign-in-page/compile.ts +176 -0
  160. package/src/biz/page-templates/sign-in-page/index.ts +18 -0
  161. package/src/biz/page-templates/sign-in-page/shell.ts +116 -0
  162. package/src/biz/record-detail/compile.ts +290 -0
  163. package/src/biz/record-detail/index.ts +22 -0
  164. package/src/biz/record-detail/shell.ts +64 -0
  165. package/src/biz/settings-center/compile.ts +100 -0
  166. package/src/biz/settings-center/index.ts +18 -0
  167. package/src/biz/settings-center/shell.ts +51 -0
  168. package/src/biz/shared/action-host.ts +469 -0
  169. package/src/biz/shared/coordinator.ts +516 -0
  170. package/src/biz/shared/index.ts +9 -0
  171. package/src/biz/shared/pipes.ts +58 -0
  172. package/src/biz/shared/runtime-hub.ts +112 -0
  173. package/src/biz/shared/step-values.ts +25 -0
  174. package/src/biz/single-form/compile.ts +146 -0
  175. package/src/biz/single-form/index.ts +18 -0
  176. package/src/biz/single-form/shell.ts +38 -0
  177. package/src/biz/standard-crud/compile.ts +546 -0
  178. package/src/biz/standard-crud/index.ts +18 -0
  179. package/src/biz/standard-crud/shell.ts +157 -0
  180. package/src/biz/step-form/compile.ts +400 -0
  181. package/src/biz/step-form/hub.ts +412 -0
  182. package/src/biz/step-form/index.ts +23 -0
  183. package/src/biz/step-form/shell.ts +96 -0
  184. package/src/biz/step-form/steps-ref.ts +112 -0
  185. package/src/biz/types.ts +96 -0
  186. package/src/cli/kit-cli.ts +102 -0
  187. package/src/compile/action-host-attach.ts +76 -0
  188. package/src/compile/compile-page.ts +472 -0
  189. package/src/compile/component-candidates.ts +147 -0
  190. package/src/compile/fragment.ts +104 -0
  191. package/src/compile/hints.ts +255 -0
  192. package/src/compile/index.ts +16 -0
  193. package/src/compile/locate.ts +166 -0
  194. package/src/compile/page-params.ts +80 -0
  195. package/src/compile/parse.ts +355 -0
  196. package/src/compile/redirect.ts +90 -0
  197. package/src/compile/registry.ts +30 -0
  198. package/src/compile/remove-guard.ts +99 -0
  199. package/src/compile/styles.ts +244 -0
  200. package/src/compile/types.ts +106 -0
  201. package/src/data/amount-breakdown.ts +132 -0
  202. package/src/data/anchor-nav.ts +225 -0
  203. package/src/data/approval-flow.ts +269 -0
  204. package/src/data/assignment-picker.ts +652 -0
  205. package/src/data/async-result-panel.ts +308 -0
  206. package/src/data/breadcrumbs.ts +197 -0
  207. package/src/data/calendar.ts +363 -0
  208. package/src/data/carousel.ts +408 -0
  209. package/src/data/chart.ts +726 -0
  210. package/src/data/checklist.ts +215 -0
  211. package/src/data/code-view.ts +415 -0
  212. package/src/data/comment-thread.ts +342 -0
  213. package/src/data/confirm-dialog.ts +144 -0
  214. package/src/data/context-menu.ts +216 -0
  215. package/src/data/d9-limits.ts +42 -0
  216. package/src/data/d9-util.ts +81 -0
  217. package/src/data/diff.ts +239 -0
  218. package/src/data/display-util.ts +135 -0
  219. package/src/data/dock.ts +152 -0
  220. package/src/data/embed.ts +200 -0
  221. package/src/data/field-mapper.ts +544 -0
  222. package/src/data/flow-editor-contract.ts +41 -0
  223. package/src/data/flow-editor.ts +2622 -0
  224. package/src/data/flow-remote-options.ts +257 -0
  225. package/src/data/footer.ts +157 -0
  226. package/src/data/form-draft-registry.ts +76 -0
  227. package/src/data/gantt.ts +430 -0
  228. package/src/data/hero.ts +149 -0
  229. package/src/data/image-viewer.ts +333 -0
  230. package/src/data/index.ts +268 -0
  231. package/src/data/item-list.ts +335 -0
  232. package/src/data/kanban.ts +667 -0
  233. package/src/data/media-grid.ts +246 -0
  234. package/src/data/mega-menu.ts +257 -0
  235. package/src/data/menu-dom.ts +169 -0
  236. package/src/data/menu.ts +464 -0
  237. package/src/data/mockup.ts +176 -0
  238. package/src/data/modal-dialog.ts +182 -0
  239. package/src/data/navbar.ts +292 -0
  240. package/src/data/object-form.ts +1981 -0
  241. package/src/data/options-bus.ts +24 -0
  242. package/src/data/outcome-watch.ts +40 -0
  243. package/src/data/overlay-portal.ts +6 -0
  244. package/src/data/pager.ts +472 -0
  245. package/src/data/permission-matrix.ts +432 -0
  246. package/src/data/permission-tree.ts +916 -0
  247. package/src/data/pricing-table.ts +269 -0
  248. package/src/data/prompt-dialog.ts +235 -0
  249. package/src/data/reaction-bar.ts +236 -0
  250. package/src/data/record-card.ts +413 -0
  251. package/src/data/record-picker.ts +489 -0
  252. package/src/data/redirect.ts +109 -0
  253. package/src/data/remote-options.ts +54 -0
  254. package/src/data/request-console.ts +399 -0
  255. package/src/data/resident.ts +58 -0
  256. package/src/data/result-panel.ts +160 -0
  257. package/src/data/rich-text.ts +626 -0
  258. package/src/data/row-editor.ts +1066 -0
  259. package/src/data/rule-builder.ts +1135 -0
  260. package/src/data/shape-util.ts +221 -0
  261. package/src/data/staged-rows.ts +69 -0
  262. package/src/data/stat-group.ts +231 -0
  263. package/src/data/static-lazy.ts +63 -0
  264. package/src/data/static-registry.ts +227 -0
  265. package/src/data/steps.ts +195 -0
  266. package/src/data/survey.ts +455 -0
  267. package/src/data/system-switcher.ts +243 -0
  268. package/src/data/timeline.ts +204 -0
  269. package/src/data/tour-guide.ts +392 -0
  270. package/src/data/transfer.ts +597 -0
  271. package/src/data/tree-check.ts +30 -0
  272. package/src/data/tree-table.ts +674 -0
  273. package/src/data/tree.ts +656 -0
  274. package/src/data/trend-line.ts +147 -0
  275. package/src/data/virtual-rows.ts +556 -0
  276. package/src/data/watermark.ts +140 -0
  277. package/src/data/wrap.ts +264 -0
  278. package/src/data/wrapped-candidates.ts +96 -0
  279. package/src/frames/blank-frame.ts +19 -0
  280. package/src/frames/index.ts +44 -0
  281. package/src/frames/page-bar.ts +185 -0
  282. package/src/frames/page-header.ts +185 -0
  283. package/src/frames/page-status.ts +54 -0
  284. package/src/frames/resize-handle.ts +147 -0
  285. package/src/frames/shared.ts +216 -0
  286. package/src/frames/single-frame.ts +16 -0
  287. package/src/frames/split-frame/index.ts +4 -0
  288. package/src/frames/split-frame/shell.ts +219 -0
  289. package/src/frames/split-frame/span.ts +64 -0
  290. package/src/frames/split-frame/wiring.ts +164 -0
  291. package/src/frames/tabs-frame/index.ts +3 -0
  292. package/src/frames/tabs-frame/shell.ts +112 -0
  293. package/src/frames/tabs-frame/wiring.ts +69 -0
  294. package/src/frames/top-main-frame.ts +20 -0
  295. package/src/frames/types.ts +72 -0
  296. package/src/frames/workspace-frame/extras.ts +197 -0
  297. package/src/frames/workspace-frame/index.ts +13 -0
  298. package/src/frames/workspace-frame/shell.ts +282 -0
  299. package/src/frames/workspace-frame/state.ts +152 -0
  300. package/src/frames/workspace-frame/view.ts +1013 -0
  301. package/src/generated/kit-grammar-runtime.ts +2811 -0
  302. package/src/generated/page-origin.ts +57 -0
  303. package/src/i18n/index.ts +22 -0
  304. package/src/i18n/kit-text.ts +692 -0
  305. package/src/i18n/resolve-text-refs.ts +128 -0
  306. package/src/index.ts +6 -0
  307. package/src/object-renderer/action-gate.ts +216 -0
  308. package/src/object-renderer/adopt-gate.ts +333 -0
  309. package/src/object-renderer/arrange.ts +411 -0
  310. package/src/object-renderer/candidates.ts +68 -0
  311. package/src/object-renderer/collapse-wiring.ts +99 -0
  312. package/src/object-renderer/collection-expand.ts +185 -0
  313. package/src/object-renderer/collection-parts.ts +653 -0
  314. package/src/object-renderer/collection-table.ts +503 -0
  315. package/src/object-renderer/collection.ts +626 -0
  316. package/src/object-renderer/compile-data.ts +549 -0
  317. package/src/object-renderer/defaults.ts +252 -0
  318. package/src/object-renderer/display-checks.ts +169 -0
  319. package/src/object-renderer/emit-events.ts +498 -0
  320. package/src/object-renderer/emit-object.ts +98 -0
  321. package/src/object-renderer/emit-static.ts +1035 -0
  322. package/src/object-renderer/field-policy.ts +89 -0
  323. package/src/object-renderer/field-value.ts +581 -0
  324. package/src/object-renderer/form-detail.ts +116 -0
  325. package/src/object-renderer/index.ts +13 -0
  326. package/src/object-renderer/linkage.ts +370 -0
  327. package/src/object-renderer/merge-class.ts +126 -0
  328. package/src/object-renderer/mode.ts +25 -0
  329. package/src/object-renderer/outcome-draft.ts +61 -0
  330. package/src/object-renderer/parts.ts +136 -0
  331. package/src/object-renderer/pick-component.ts +36 -0
  332. package/src/object-renderer/render-object.ts +724 -0
  333. package/src/object-renderer/request-actions.ts +581 -0
  334. package/src/object-renderer/skeleton.ts +101 -0
  335. package/src/object-renderer/table-actions.ts +438 -0
  336. package/src/object-renderer/table-summary.ts +105 -0
  337. package/src/object-renderer/table-tools.ts +1072 -0
  338. package/src/object-renderer/types.ts +933 -0
  339. package/src/page-target/ai-surface.ts +154 -0
  340. package/src/page-target/compile.ts +354 -0
  341. package/src/page-target/drift.ts +186 -0
  342. package/src/page-target/index.ts +25 -0
  343. package/src/page-target/intent-map.ts +137 -0
  344. package/src/page-target/intent-schema.ts +711 -0
  345. package/src/page-target/origin.ts +17 -0
  346. package/src/page-target/target.ts +450 -0
  347. package/src/page-target/writer-policy.ts +315 -0
  348. package/src/theme/block-theme.ts +202 -0
  349. package/src/theme/kit-theme-text.ts +2 -0
  350. package/src/theme/kit-theme.css +275 -0
  351. package/src/theme/kit-theme.tpl +275 -0
  352. package/src/theme/theme-tokens.ts +135 -0
@@ -0,0 +1,60 @@
1
+ // CommerceOrderCard:订单卡(accept: single)。包一层内置 RecordCard。
2
+ //
3
+ // 数据:{ order_no, status, tone?, placed_at?, items: [{ name, qty, price? }], amounts: [{ label, amount }], exception? }
4
+ // (键名可由 map 改写)。
5
+ // 呈现:标题 = 订单号,副标题 = 下单时间,状态位 = status(语气取 tone);
6
+ // 事实 = 商品行(名称 -> ×数量,有单价追加「 单价」)+ 金额行(label -> amount,按 `amount_format` 格式化,组件不计算);
7
+ // 异常档 exception 非空时以标签形式显示(如「缺货」「超时未发货」)并把状态语气提到 warning(数据没给 tone 时)。
8
+ // 动作位 `actions` 抛 action { key };`selectable` 时整卡可点抛 select { item }。
9
+
10
+ import type { SomaComponentDefinition } from 'soma-core';
11
+ import { createRecordCard } from '../../src/data/record-card';
12
+ import { list, mapKeys, rec, tone, txt, wrapKitDataComponent, type PackProps } from '../shared/wrap';
13
+
14
+ export const COMMERCE_ORDER_DEFAULT_MAP = Object.freeze({
15
+ order_no: 'order_no', status: 'status', tone: 'tone', placed_at: 'placed_at', items: 'items', amounts: 'amounts', exception: 'exception',
16
+ });
17
+
18
+ export function orderCardProps(p: PackProps): PackProps {
19
+ const m = mapKeys(COMMERCE_ORDER_DEFAULT_MAP, p.map);
20
+ const d = rec(p.data);
21
+ const fmt = txt(p.amount_format);
22
+ const exception = txt(d[m.exception]);
23
+ const facts: PackProps[] = [];
24
+ for (const it of list(d[m.items])) {
25
+ const qty = txt(it.qty);
26
+ const price = txt(it.price);
27
+ facts.push({ label: txt(it.name), value: `×${qty}${price !== '' ? ` ${price}` : ''}` });
28
+ }
29
+ for (const a of list(d[m.amounts])) facts.push({ label: txt(a.label), value: a.amount, format: fmt });
30
+ return {
31
+ data: {
32
+ title: txt(d[m.order_no]),
33
+ subtitle: txt(d[m.placed_at]),
34
+ status: txt(d[m.status]),
35
+ tone: tone(d[m.tone], exception !== '' ? 'warning' : 'neutral'),
36
+ facts,
37
+ tags: exception === '' ? [] : [exception],
38
+ actions: list(p.actions),
39
+ },
40
+ map: {},
41
+ fields: [],
42
+ rail: exception !== '',
43
+ selectable: p.selectable === true || p.selectable === 'true',
44
+ locale: txt(p.locale),
45
+ class: txt(p.class),
46
+ };
47
+ }
48
+
49
+ export function createCommerceOrderCard(): SomaComponentDefinition {
50
+ return wrapKitDataComponent(createRecordCard(), {
51
+ name: 'CommerceOrderCard',
52
+ props: {
53
+ data: { type: 'object', default: {}, desc: '一张订单 { order_no, status, tone?, placed_at?, items[], amounts[], exception? }' },
54
+ map: { type: 'object', default: {}, desc: '键名对照:order_no / status / tone / placed_at / items / amounts / exception' },
55
+ actions: { type: 'array', default: [], desc: '底部动作 [{ key, label, tone?, disabled? }],点击抛 action { key }' },
56
+ amount_format: { type: 'string', default: '', desc: '金额行的格式化写法(如 currency:CNY);空则原样显示' },
57
+ },
58
+ adapt: orderCardProps,
59
+ });
60
+ }
@@ -0,0 +1,74 @@
1
+ // CommercePurchaseOrderCard:采购单摘要卡(accept: single)。包一层内置 RecordCard。
2
+ //
3
+ // 数据:{ po_no, supplier, status, tone?, amount?, expected_at?, ordered_qty?, received_qty? }(键名可由 map 改写)。
4
+ // 呈现:标题 = 采购单号,副标题 = 供应商,状态位 = status;
5
+ // 事实 = 金额 / 预计到货 / 已收货 / 订购量;收货进度条 = received_qty / ordered_qty(两者都给才画,百分比由组件按这两个数换算,
6
+ // 属展示换算,不是业务计算)。动作位 `actions` 抛 action { key };`selectable` 时整卡可点抛 select { item }。
7
+
8
+ import type { SomaComponentDefinition } from 'soma-core';
9
+ import { createRecordCard } from '../../src/data/record-card';
10
+ import { list, mapKeys, rec, txt, wrapKitDataComponent, type PackProps } from '../shared/wrap';
11
+ import { packLabel } from '../shared/card-util';
12
+ import './texts';
13
+
14
+ const L = (p: PackProps, key: string): string => packLabel('commerce.purchase_order', p, key);
15
+
16
+ export const COMMERCE_PO_DEFAULT_MAP = Object.freeze({
17
+ po_no: 'po_no', supplier: 'supplier', status: 'status', tone: 'tone', amount: 'amount',
18
+ expected_at: 'expected_at', ordered_qty: 'ordered_qty', received_qty: 'received_qty',
19
+ });
20
+
21
+ function numOf(raw: unknown): number | null {
22
+ if (raw === null || raw === undefined || raw === '') return null;
23
+ const n = typeof raw === 'number' ? raw : Number(raw);
24
+ return Number.isFinite(n) ? n : null;
25
+ }
26
+
27
+ export function purchaseOrderCardProps(p: PackProps): PackProps {
28
+ const m = mapKeys(COMMERCE_PO_DEFAULT_MAP, p.map);
29
+ const d = rec(p.data);
30
+ const facts: PackProps[] = [];
31
+ if (d[m.amount] !== undefined && d[m.amount] !== null && d[m.amount] !== '') {
32
+ facts.push({ label: L(p, 'amount_label'), value: d[m.amount], format: txt(p.amount_format) });
33
+ }
34
+ if (txt(d[m.expected_at]) !== '') facts.push({ label: L(p, 'expected_label'), value: txt(d[m.expected_at]) });
35
+ const ordered = numOf(d[m.ordered_qty]);
36
+ const received = numOf(d[m.received_qty]);
37
+ if (ordered !== null) facts.push({ label: L(p, 'ordered_label'), value: ordered });
38
+ if (received !== null) facts.push({ label: L(p, 'received_label'), value: received });
39
+ const progress = ordered !== null && received !== null && ordered > 0 ? Math.min(100, Math.max(0, (received / ordered) * 100)) : undefined;
40
+ return {
41
+ data: {
42
+ title: txt(d[m.po_no]),
43
+ subtitle: txt(d[m.supplier]),
44
+ status: txt(d[m.status]),
45
+ tone: d[m.tone],
46
+ facts,
47
+ ...(progress !== undefined ? { progress } : {}),
48
+ actions: list(p.actions),
49
+ },
50
+ map: {},
51
+ fields: [],
52
+ rail: false,
53
+ selectable: p.selectable === true || p.selectable === 'true',
54
+ locale: txt(p.locale),
55
+ class: txt(p.class),
56
+ };
57
+ }
58
+
59
+ export function createCommercePurchaseOrderCard(): SomaComponentDefinition {
60
+ return wrapKitDataComponent(createRecordCard(), {
61
+ name: 'CommercePurchaseOrderCard',
62
+ props: {
63
+ data: { type: 'object', default: {}, desc: '一张采购单 { po_no, supplier, status, tone?, amount?, expected_at?, ordered_qty?, received_qty? }' },
64
+ map: { type: 'object', default: {}, desc: '键名对照:po_no / supplier / status / tone / amount / expected_at / ordered_qty / received_qty' },
65
+ actions: { type: 'array', default: [], desc: '底部动作 [{ key, label, tone?, disabled? }],点击抛 action { key }' },
66
+ amount_format: { type: 'string', default: '', desc: '金额的格式化写法(如 currency:CNY);空则原样显示' },
67
+ amount_label: { type: 'string', default: '', desc: '金额事实行的标签;空取包词条(随页面语言)' },
68
+ expected_label: { type: 'string', default: '', desc: '预计到货事实行的标签;空取包词条(随页面语言)' },
69
+ ordered_label: { type: 'string', default: '', desc: '订购量事实行的标签;空取包词条(随页面语言)' },
70
+ received_label: { type: 'string', default: '', desc: '已收货事实行的标签;空取包词条(随页面语言)' },
71
+ },
72
+ adapt: purchaseOrderCardProps,
73
+ });
74
+ }
@@ -0,0 +1,14 @@
1
+ // 电商包词条表(zh-CN / en):卡片契约的默认文案为空串,空串时回退到这里(packLabel)。键形 pack.<包>.<卡片>.<prop 名>。
2
+ import { defineKitPackTexts } from '../../src/i18n/kit-text';
3
+
4
+ defineKitPackTexts({
5
+ 'pack.commerce.address.default_text': { 'zh-CN': '默认', en: 'Default' },
6
+ 'pack.commerce.address.address_label': { 'zh-CN': '收货地址', en: 'Shipping address' },
7
+ 'pack.commerce.coupon.face_label': { 'zh-CN': '面值', en: 'Face value' },
8
+ 'pack.commerce.coupon.threshold_label': { 'zh-CN': '使用门槛', en: 'Minimum spend' },
9
+ 'pack.commerce.coupon.valid_label': { 'zh-CN': '有效期', en: 'Valid period' },
10
+ 'pack.commerce.purchase_order.amount_label': { 'zh-CN': '金额', en: 'Amount' },
11
+ 'pack.commerce.purchase_order.expected_label': { 'zh-CN': '预计到货', en: 'Expected arrival' },
12
+ 'pack.commerce.purchase_order.ordered_label': { 'zh-CN': '订购量', en: 'Ordered' },
13
+ 'pack.commerce.purchase_order.received_label': { 'zh-CN': '已收货', en: 'Received' },
14
+ });
@@ -0,0 +1,30 @@
1
+ // 金融领域包:对账核销台(业务组件)+ 账单摘要金额卡 + 对账差异卡。
2
+ // 金额卡都是包一层内置件(AmountBreakdown / RecordCard);对账核销台是领域流程,
3
+ // 界面与协作件 FinanceReconcileBoard 是包私有的协作数据组件(页面不可直接选用)。
4
+ // 应用登记:`defineKitApp({ packs: [financePack] })`。
5
+
6
+ import { defineKitPack } from '../../src/app/define-kit-pack';
7
+ import { createFinanceInvoiceSummaryCard } from './invoice-summary-card';
8
+ import { createFinanceReconcileCaseCard } from './reconcile-case-card';
9
+ import { FinanceReconcileDesk } from './reconcile-desk';
10
+ import { createFinanceReconcileBoard, FINANCE_RECONCILE_BOARD_CLASS_CANDIDATES } from './reconcile-board';
11
+
12
+ export { createFinanceInvoiceSummaryCard, invoiceSummaryProps, FINANCE_INVOICE_DEFAULT_MAP } from './invoice-summary-card';
13
+ export { createFinanceReconcileCaseCard, reconcileCaseProps, FINANCE_CASE_DEFAULT_MAP } from './reconcile-case-card';
14
+ export {
15
+ createFinanceReconcileBoard, toCents, reconcileRowsOf, reconcileSums, reconcilePayload, pruneSelection,
16
+ FINANCE_RECONCILE_BOARD_CLASS_CANDIDATES,
17
+ } from './reconcile-board';
18
+ export { FinanceReconcileDesk, compileFinanceReconcileDesk, financeReconcileObjectName } from './reconcile-desk';
19
+
20
+ export const financePack = defineKitPack({
21
+ name: 'finance',
22
+ staticComponents: {
23
+ FinanceInvoiceSummaryCard: { define: createFinanceInvoiceSummaryCard, accept: 'single', desc: '账单摘要金额卡:明细行 + 合计行,金额原样展示' },
24
+ FinanceReconcileCaseCard: { define: createFinanceReconcileCaseCard, accept: 'single', desc: '对账差异卡:银行 / 账单 / 差额 / 原因 / 证据' },
25
+ },
26
+ bizComponents: { FinanceReconcileDesk },
27
+ dataComponents: { FinanceReconcileBoard: createFinanceReconcileBoard },
28
+ // 金额卡 / 差异卡 wrapKitDataComponent 内置件,底层类随包装元数据按页并入;协作件 Board 的类只在用到它的页并入
29
+ componentCandidates: { FinanceReconcileBoard: FINANCE_RECONCILE_BOARD_CLASS_CANDIDATES },
30
+ });
@@ -0,0 +1,48 @@
1
+ // FinanceInvoiceSummaryCard:账单摘要金额卡(accept: single)。包一层内置 AmountBreakdown。
2
+ //
3
+ // 数据:{ invoice_no, title?, lines: [{ id, label, amount, level?, tone?, note? }], total? }(键名可由 map 改写)。
4
+ // 呈现:标题 = 「账单号 标题」,明细行原样交给 AmountBreakdown;`total` 给出时末尾追加合计行(金额原样展示,组件不相加)。
5
+ // 金额按 `amount_format`(如 currency:CNY)格式化;`row_action` 配 { key, label } 时每行末出小按钮,抛 action { key, id }。
6
+
7
+ import type { SomaComponentDefinition } from 'soma-core';
8
+ import { createAmountBreakdown } from '../../src/data/amount-breakdown';
9
+ import { list, mapKeys, rec, txt, wrapKitDataComponent, type PackProps } from '../shared/wrap';
10
+ import { packLabel } from '../shared/card-util';
11
+ import './texts';
12
+
13
+ const L = (p: PackProps, key: string): string => packLabel('finance.invoice_summary', p, key);
14
+
15
+ export const FINANCE_INVOICE_DEFAULT_MAP = Object.freeze({ invoice_no: 'invoice_no', title: 'title', lines: 'lines', total: 'total' });
16
+
17
+ export function invoiceSummaryProps(p: PackProps): PackProps {
18
+ const m = mapKeys(FINANCE_INVOICE_DEFAULT_MAP, p.map);
19
+ const d = rec(p.data);
20
+ const lines = list(d[m.lines]).map((l) => ({ ...l }));
21
+ const total = d[m.total];
22
+ if (total !== undefined && total !== null && total !== '') {
23
+ lines.push({ id: '__total', label: L(p, 'total_label'), amount: total, total: true });
24
+ }
25
+ return {
26
+ data: lines,
27
+ map: {},
28
+ title: [txt(d[m.invoice_no]), txt(d[m.title])].filter((s) => s !== '').join(' '),
29
+ format: txt(p.amount_format),
30
+ locale: txt(p.locale),
31
+ row_action: rec(p.row_action),
32
+ empty_text: txt(p.empty_text),
33
+ class: txt(p.class),
34
+ };
35
+ }
36
+
37
+ export function createFinanceInvoiceSummaryCard(): SomaComponentDefinition {
38
+ return wrapKitDataComponent(createAmountBreakdown(), {
39
+ name: 'FinanceInvoiceSummaryCard',
40
+ props: {
41
+ data: { type: 'object', default: {}, desc: '一张账单 { invoice_no, title?, lines[], total? }' },
42
+ map: { type: 'object', default: {}, desc: '键名对照:invoice_no / title / lines / total' },
43
+ amount_format: { type: 'string', default: '', desc: '金额的格式化写法(如 currency:CNY);空则原样显示' },
44
+ total_label: { type: 'string', default: '', desc: '合计行标签;空取包词条(随页面语言)' },
45
+ },
46
+ adapt: invoiceSummaryProps,
47
+ });
48
+ }