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.
- package/README.md +541 -2
- package/bin/soma-kit.mjs +27 -0
- package/package.json +66 -4
- package/packs/ai/agent-run-card.ts +64 -0
- package/packs/ai/evaluation-card.ts +51 -0
- package/packs/ai/guardrail-policy-card.ts +48 -0
- package/packs/ai/index.ts +31 -0
- package/packs/ai/model-card.ts +55 -0
- package/packs/ai/model-routing-card.ts +49 -0
- package/packs/ai/prompt-template-card.ts +49 -0
- package/packs/ai/texts.ts +19 -0
- package/packs/commerce/address-card.ts +58 -0
- package/packs/commerce/coupon-card.ts +64 -0
- package/packs/commerce/index.ts +25 -0
- package/packs/commerce/order-card.ts +60 -0
- package/packs/commerce/purchase-order-card.ts +74 -0
- package/packs/commerce/texts.ts +14 -0
- package/packs/finance/index.ts +30 -0
- package/packs/finance/invoice-summary-card.ts +48 -0
- package/packs/finance/reconcile-board.ts +450 -0
- package/packs/finance/reconcile-case-card.ts +70 -0
- package/packs/finance/reconcile-desk/compile.ts +208 -0
- package/packs/finance/reconcile-desk/index.ts +20 -0
- package/packs/finance/reconcile-desk/shell.ts +27 -0
- package/packs/finance/texts.ts +21 -0
- package/packs/ops/change-window-card.ts +54 -0
- package/packs/ops/dependency-status-card.ts +50 -0
- package/packs/ops/error-budget-card.ts +60 -0
- package/packs/ops/execution-task-runner.ts +61 -0
- package/packs/ops/index.ts +36 -0
- package/packs/ops/integration-status-card.ts +45 -0
- package/packs/ops/release-readiness-card.ts +63 -0
- package/packs/ops/runbook-execution-card.ts +81 -0
- package/packs/ops/texts.ts +21 -0
- package/packs/security/control-evidence-card.ts +54 -0
- package/packs/security/finding-card.ts +96 -0
- package/packs/security/index.ts +29 -0
- package/packs/security/texts.ts +31 -0
- package/packs/shared/card-util.ts +60 -0
- package/packs/shared/wrap.ts +12 -0
- package/spec/generated/kit-app.schema.json +84 -0
- package/spec/generated/kit-page.schema.json +2766 -0
- package/spec/kit-grammar.json +1357 -0
- package/spec/kit-grammar.schema.json +715 -0
- package/src/app/app-config.ts +108 -0
- package/src/app/compose-apps.ts +155 -0
- package/src/app/define-kit-actions.ts +89 -0
- package/src/app/define-kit-app.ts +383 -0
- package/src/app/define-kit-pack.ts +114 -0
- package/src/app/envelope.ts +138 -0
- package/src/app/index.ts +53 -0
- package/src/app/notify-renderer.ts +114 -0
- package/src/app/paged-list-adapter.ts +240 -0
- package/src/app/server-pages.ts +303 -0
- package/src/app/server.ts +244 -0
- package/src/app/submit.types.ts +87 -0
- package/src/base/action-busy.ts +159 -0
- package/src/base/action-gate.ts +267 -0
- package/src/base/action-status.ts +31 -0
- package/src/base/alert.ts +136 -0
- package/src/base/avatar.ts +271 -0
- package/src/base/button.ts +139 -0
- package/src/base/cascader.ts +523 -0
- package/src/base/check-core.ts +214 -0
- package/src/base/checkbox.ts +35 -0
- package/src/base/choice.ts +183 -0
- package/src/base/color-picker.ts +316 -0
- package/src/base/combobox.ts +61 -0
- package/src/base/command-palette.ts +371 -0
- package/src/base/context-menu.ts +103 -0
- package/src/base/countdown.ts +168 -0
- package/src/base/date-range.ts +444 -0
- package/src/base/date.ts +899 -0
- package/src/base/divider.ts +156 -0
- package/src/base/fab.ts +192 -0
- package/src/base/icons.ts +106 -0
- package/src/base/image.ts +177 -0
- package/src/base/index.ts +214 -0
- package/src/base/input.ts +316 -0
- package/src/base/kbd.ts +99 -0
- package/src/base/link.ts +167 -0
- package/src/base/listbox-core.ts +965 -0
- package/src/base/mentions.ts +323 -0
- package/src/base/menu-button.ts +240 -0
- package/src/base/menu-core.ts +341 -0
- package/src/base/month-grid.ts +171 -0
- package/src/base/motion/aura.ts +94 -0
- package/src/base/motion/hover-3d.ts +154 -0
- package/src/base/motion/hover-gallery.ts +185 -0
- package/src/base/motion/index.ts +27 -0
- package/src/base/motion/limits.ts +75 -0
- package/src/base/motion/marquee.ts +157 -0
- package/src/base/motion/text-rotate.ts +195 -0
- package/src/base/number.ts +121 -0
- package/src/base/otp.ts +259 -0
- package/src/base/permission-gate.ts +99 -0
- package/src/base/popover.ts +352 -0
- package/src/base/popup.ts +542 -0
- package/src/base/portal-core.ts +297 -0
- package/src/base/price-text.ts +126 -0
- package/src/base/progress.ts +216 -0
- package/src/base/qr-code.ts +446 -0
- package/src/base/qty-stepper.ts +241 -0
- package/src/base/radio.ts +33 -0
- package/src/base/range.ts +444 -0
- package/src/base/rating.ts +249 -0
- package/src/base/segmented.ts +286 -0
- package/src/base/select.ts +57 -0
- package/src/base/shared.ts +708 -0
- package/src/base/swap.ts +86 -0
- package/src/base/switch.ts +111 -0
- package/src/base/tag-input.ts +464 -0
- package/src/base/tag.ts +250 -0
- package/src/base/text.ts +126 -0
- package/src/base/textarea.ts +129 -0
- package/src/base/time-picker.ts +606 -0
- package/src/base/tree-select.ts +629 -0
- package/src/base/upload.ts +548 -0
- package/src/base/virtual-list.ts +286 -0
- package/src/biz/approval-desk/compile.ts +179 -0
- package/src/biz/approval-desk/index.ts +21 -0
- package/src/biz/approval-desk/shell.ts +50 -0
- package/src/biz/auth-panel/compile.ts +196 -0
- package/src/biz/auth-panel/index.ts +24 -0
- package/src/biz/auth-panel/shell.ts +46 -0
- package/src/biz/category-crud/compile.ts +173 -0
- package/src/biz/category-crud/index.ts +19 -0
- package/src/biz/category-crud/shell.ts +29 -0
- package/src/biz/checkout-page/compile.ts +111 -0
- package/src/biz/checkout-page/index.ts +20 -0
- package/src/biz/checkout-page/shell.ts +50 -0
- package/src/biz/compose.ts +313 -0
- package/src/biz/data-components.ts +26 -0
- package/src/biz/define.ts +23 -0
- package/src/biz/import-wizard/compile.ts +204 -0
- package/src/biz/import-wizard/hub.ts +540 -0
- package/src/biz/import-wizard/index.ts +24 -0
- package/src/biz/import-wizard/shell.ts +161 -0
- package/src/biz/index.ts +80 -0
- package/src/biz/landing-page/compile.ts +67 -0
- package/src/biz/landing-page/index.ts +20 -0
- package/src/biz/landing-page/shell.ts +48 -0
- package/src/biz/link/hub.ts +255 -0
- package/src/biz/link/shared.ts +493 -0
- package/src/biz/master-sub/compile.ts +232 -0
- package/src/biz/master-sub/index.ts +20 -0
- package/src/biz/master-sub/shell.ts +56 -0
- package/src/biz/multi-board/compile.ts +234 -0
- package/src/biz/multi-board/index.ts +19 -0
- package/src/biz/multi-board/shell.ts +70 -0
- package/src/biz/names.ts +30 -0
- package/src/biz/notification-center/compile.ts +138 -0
- package/src/biz/notification-center/index.ts +29 -0
- package/src/biz/notification-center/shell.ts +42 -0
- package/src/biz/page-templates/result-page/compile.ts +46 -0
- package/src/biz/page-templates/result-page/index.ts +19 -0
- package/src/biz/page-templates/result-page/shell.ts +31 -0
- package/src/biz/page-templates/shared.ts +121 -0
- package/src/biz/page-templates/sign-in-page/compile.ts +176 -0
- package/src/biz/page-templates/sign-in-page/index.ts +18 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +116 -0
- package/src/biz/record-detail/compile.ts +290 -0
- package/src/biz/record-detail/index.ts +22 -0
- package/src/biz/record-detail/shell.ts +64 -0
- package/src/biz/settings-center/compile.ts +100 -0
- package/src/biz/settings-center/index.ts +18 -0
- package/src/biz/settings-center/shell.ts +51 -0
- package/src/biz/shared/action-host.ts +469 -0
- package/src/biz/shared/coordinator.ts +516 -0
- package/src/biz/shared/index.ts +9 -0
- package/src/biz/shared/pipes.ts +58 -0
- package/src/biz/shared/runtime-hub.ts +112 -0
- package/src/biz/shared/step-values.ts +25 -0
- package/src/biz/single-form/compile.ts +146 -0
- package/src/biz/single-form/index.ts +18 -0
- package/src/biz/single-form/shell.ts +38 -0
- package/src/biz/standard-crud/compile.ts +546 -0
- package/src/biz/standard-crud/index.ts +18 -0
- package/src/biz/standard-crud/shell.ts +157 -0
- package/src/biz/step-form/compile.ts +400 -0
- package/src/biz/step-form/hub.ts +412 -0
- package/src/biz/step-form/index.ts +23 -0
- package/src/biz/step-form/shell.ts +96 -0
- package/src/biz/step-form/steps-ref.ts +112 -0
- package/src/biz/types.ts +96 -0
- package/src/cli/kit-cli.ts +102 -0
- package/src/compile/action-host-attach.ts +76 -0
- package/src/compile/compile-page.ts +472 -0
- package/src/compile/component-candidates.ts +147 -0
- package/src/compile/fragment.ts +104 -0
- package/src/compile/hints.ts +255 -0
- package/src/compile/index.ts +16 -0
- package/src/compile/locate.ts +166 -0
- package/src/compile/page-params.ts +80 -0
- package/src/compile/parse.ts +355 -0
- package/src/compile/redirect.ts +90 -0
- package/src/compile/registry.ts +30 -0
- package/src/compile/remove-guard.ts +99 -0
- package/src/compile/styles.ts +244 -0
- package/src/compile/types.ts +106 -0
- package/src/data/amount-breakdown.ts +132 -0
- package/src/data/anchor-nav.ts +225 -0
- package/src/data/approval-flow.ts +269 -0
- package/src/data/assignment-picker.ts +652 -0
- package/src/data/async-result-panel.ts +308 -0
- package/src/data/breadcrumbs.ts +197 -0
- package/src/data/calendar.ts +363 -0
- package/src/data/carousel.ts +408 -0
- package/src/data/chart.ts +726 -0
- package/src/data/checklist.ts +215 -0
- package/src/data/code-view.ts +415 -0
- package/src/data/comment-thread.ts +342 -0
- package/src/data/confirm-dialog.ts +144 -0
- package/src/data/context-menu.ts +216 -0
- package/src/data/d9-limits.ts +42 -0
- package/src/data/d9-util.ts +81 -0
- package/src/data/diff.ts +239 -0
- package/src/data/display-util.ts +135 -0
- package/src/data/dock.ts +152 -0
- package/src/data/embed.ts +200 -0
- package/src/data/field-mapper.ts +544 -0
- package/src/data/flow-editor-contract.ts +41 -0
- package/src/data/flow-editor.ts +2622 -0
- package/src/data/flow-remote-options.ts +257 -0
- package/src/data/footer.ts +157 -0
- package/src/data/form-draft-registry.ts +76 -0
- package/src/data/gantt.ts +430 -0
- package/src/data/hero.ts +149 -0
- package/src/data/image-viewer.ts +333 -0
- package/src/data/index.ts +268 -0
- package/src/data/item-list.ts +335 -0
- package/src/data/kanban.ts +667 -0
- package/src/data/media-grid.ts +246 -0
- package/src/data/mega-menu.ts +257 -0
- package/src/data/menu-dom.ts +169 -0
- package/src/data/menu.ts +464 -0
- package/src/data/mockup.ts +176 -0
- package/src/data/modal-dialog.ts +182 -0
- package/src/data/navbar.ts +292 -0
- package/src/data/object-form.ts +1981 -0
- package/src/data/options-bus.ts +24 -0
- package/src/data/outcome-watch.ts +40 -0
- package/src/data/overlay-portal.ts +6 -0
- package/src/data/pager.ts +472 -0
- package/src/data/permission-matrix.ts +432 -0
- package/src/data/permission-tree.ts +916 -0
- package/src/data/pricing-table.ts +269 -0
- package/src/data/prompt-dialog.ts +235 -0
- package/src/data/reaction-bar.ts +236 -0
- package/src/data/record-card.ts +413 -0
- package/src/data/record-picker.ts +489 -0
- package/src/data/redirect.ts +109 -0
- package/src/data/remote-options.ts +54 -0
- package/src/data/request-console.ts +399 -0
- package/src/data/resident.ts +58 -0
- package/src/data/result-panel.ts +160 -0
- package/src/data/rich-text.ts +626 -0
- package/src/data/row-editor.ts +1066 -0
- package/src/data/rule-builder.ts +1135 -0
- package/src/data/shape-util.ts +221 -0
- package/src/data/staged-rows.ts +69 -0
- package/src/data/stat-group.ts +231 -0
- package/src/data/static-lazy.ts +63 -0
- package/src/data/static-registry.ts +227 -0
- package/src/data/steps.ts +195 -0
- package/src/data/survey.ts +455 -0
- package/src/data/system-switcher.ts +243 -0
- package/src/data/timeline.ts +204 -0
- package/src/data/tour-guide.ts +392 -0
- package/src/data/transfer.ts +597 -0
- package/src/data/tree-check.ts +30 -0
- package/src/data/tree-table.ts +674 -0
- package/src/data/tree.ts +656 -0
- package/src/data/trend-line.ts +147 -0
- package/src/data/virtual-rows.ts +556 -0
- package/src/data/watermark.ts +140 -0
- package/src/data/wrap.ts +264 -0
- package/src/data/wrapped-candidates.ts +96 -0
- package/src/frames/blank-frame.ts +19 -0
- package/src/frames/index.ts +44 -0
- package/src/frames/page-bar.ts +185 -0
- package/src/frames/page-header.ts +185 -0
- package/src/frames/page-status.ts +54 -0
- package/src/frames/resize-handle.ts +147 -0
- package/src/frames/shared.ts +216 -0
- package/src/frames/single-frame.ts +16 -0
- package/src/frames/split-frame/index.ts +4 -0
- package/src/frames/split-frame/shell.ts +219 -0
- package/src/frames/split-frame/span.ts +64 -0
- package/src/frames/split-frame/wiring.ts +164 -0
- package/src/frames/tabs-frame/index.ts +3 -0
- package/src/frames/tabs-frame/shell.ts +112 -0
- package/src/frames/tabs-frame/wiring.ts +69 -0
- package/src/frames/top-main-frame.ts +20 -0
- package/src/frames/types.ts +72 -0
- package/src/frames/workspace-frame/extras.ts +197 -0
- package/src/frames/workspace-frame/index.ts +13 -0
- package/src/frames/workspace-frame/shell.ts +282 -0
- package/src/frames/workspace-frame/state.ts +152 -0
- package/src/frames/workspace-frame/view.ts +1013 -0
- package/src/generated/kit-grammar-runtime.ts +2811 -0
- package/src/generated/page-origin.ts +57 -0
- package/src/i18n/index.ts +22 -0
- package/src/i18n/kit-text.ts +692 -0
- package/src/i18n/resolve-text-refs.ts +128 -0
- package/src/index.ts +6 -0
- package/src/object-renderer/action-gate.ts +216 -0
- package/src/object-renderer/adopt-gate.ts +333 -0
- package/src/object-renderer/arrange.ts +411 -0
- package/src/object-renderer/candidates.ts +68 -0
- package/src/object-renderer/collapse-wiring.ts +99 -0
- package/src/object-renderer/collection-expand.ts +185 -0
- package/src/object-renderer/collection-parts.ts +653 -0
- package/src/object-renderer/collection-table.ts +503 -0
- package/src/object-renderer/collection.ts +626 -0
- package/src/object-renderer/compile-data.ts +549 -0
- package/src/object-renderer/defaults.ts +252 -0
- package/src/object-renderer/display-checks.ts +169 -0
- package/src/object-renderer/emit-events.ts +498 -0
- package/src/object-renderer/emit-object.ts +98 -0
- package/src/object-renderer/emit-static.ts +1035 -0
- package/src/object-renderer/field-policy.ts +89 -0
- package/src/object-renderer/field-value.ts +581 -0
- package/src/object-renderer/form-detail.ts +116 -0
- package/src/object-renderer/index.ts +13 -0
- package/src/object-renderer/linkage.ts +370 -0
- package/src/object-renderer/merge-class.ts +126 -0
- package/src/object-renderer/mode.ts +25 -0
- package/src/object-renderer/outcome-draft.ts +61 -0
- package/src/object-renderer/parts.ts +136 -0
- package/src/object-renderer/pick-component.ts +36 -0
- package/src/object-renderer/render-object.ts +724 -0
- package/src/object-renderer/request-actions.ts +581 -0
- package/src/object-renderer/skeleton.ts +101 -0
- package/src/object-renderer/table-actions.ts +438 -0
- package/src/object-renderer/table-summary.ts +105 -0
- package/src/object-renderer/table-tools.ts +1072 -0
- package/src/object-renderer/types.ts +933 -0
- package/src/page-target/ai-surface.ts +154 -0
- package/src/page-target/compile.ts +354 -0
- package/src/page-target/drift.ts +186 -0
- package/src/page-target/index.ts +25 -0
- package/src/page-target/intent-map.ts +137 -0
- package/src/page-target/intent-schema.ts +711 -0
- package/src/page-target/origin.ts +17 -0
- package/src/page-target/target.ts +450 -0
- package/src/page-target/writer-policy.ts +315 -0
- package/src/theme/block-theme.ts +202 -0
- package/src/theme/kit-theme-text.ts +2 -0
- package/src/theme/kit-theme.css +275 -0
- package/src/theme/kit-theme.tpl +275 -0
- 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
|
+
}
|