soma-kit 0.0.0-stage → 0.1.0
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 +539 -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 +13 -0
- package/spec/generated/kit-app.schema.json +84 -0
- package/spec/generated/kit-page.schema.json +2766 -0
- package/spec/kit-grammar.json +1358 -0
- package/spec/kit-grammar.schema.json +716 -0
- package/src/app/app-config.ts +108 -0
- package/src/app/compose-apps.ts +139 -0
- package/src/app/define-kit-actions.ts +89 -0
- package/src/app/define-kit-app.ts +362 -0
- package/src/app/define-kit-pack.ts +114 -0
- package/src/app/envelope.ts +117 -0
- package/src/app/index.ts +50 -0
- package/src/app/notify-renderer.ts +114 -0
- package/src/app/paged-list-adapter.ts +246 -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/bridge.ts +11 -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 +473 -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 +1137 -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 +267 -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 +242 -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 +2822 -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 +628 -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 +153 -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 +1036 -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 +371 -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 +936 -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,286 @@
|
|
|
1
|
+
// 虚拟滚动接线(N3 组):Select / Combobox / Tree / ItemList 的下拉面板与列表、表格表体 KitVirtualRows 共用。
|
|
2
|
+
//
|
|
3
|
+
// 引擎走 core 的虚拟滚动端口(`ctx.services.engines.virtual`,组件契约要声明 `services: ['engines']`;缺省适配器
|
|
4
|
+
// `@tanstack/virtual-core` 由 core 动态加载,kit 不 import 它)。端口只算「画哪几行」:条数、滚动容器、估算行高、预渲染行数
|
|
5
|
+
// 全由本文件按设计真源(spec/kit-grammar.json#collectionKeys.virtual)传入,端口回 items() = 当前该画的下标区间。
|
|
6
|
+
//
|
|
7
|
+
// 行高:声明方写档位名 sm / md / lg(不是像素);档位像素值只是估算基准,第一行画出后用实测高度校准一次
|
|
8
|
+
// (间距基准随密度档变化,4px 的假设不一定成立)。固定行高是前提:行不会自己长高,所以不走端口的动态测量。
|
|
9
|
+
//
|
|
10
|
+
// 回退:端口取不到(`engines` 未装配、`virtual` 读取抛错、引擎加载失败)时,窗口报告 fallback(),调用方改画全部行,
|
|
11
|
+
// 控制台只提示一次。引擎还在异步加载时,先按「前 initialRows 行」画,加载完成再切成真窗口。
|
|
12
|
+
//
|
|
13
|
+
// 间距元素(顶 / 底占位)的高度是运行期算出的像素值,没有对应的预置类,只能经 CSSOM 写 `el.style.height`
|
|
14
|
+
// (不是 HTML style 属性、不进模板,CSP 安全)。这是 kit 里唯一的运行期几何写入,集中在 `setSpacerHeight`。
|
|
15
|
+
|
|
16
|
+
import { KIT_COLLECTION_LIMITS } from 'soma-foundation/kit-limits';
|
|
17
|
+
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
18
|
+
|
|
19
|
+
type Json = Record<string, any>;
|
|
20
|
+
const V = ((grammarJson as unknown as Json).collectionKeys as Json).virtual as Json;
|
|
21
|
+
|
|
22
|
+
export type KitRowTier = 'sm' | 'md' | 'lg';
|
|
23
|
+
export const KIT_ROW_TIERS: readonly KitRowTier[] = V.tiers as KitRowTier[];
|
|
24
|
+
export const KIT_VIRTUAL_ROW_PX: Readonly<Record<KitRowTier, number>> = KIT_COLLECTION_LIMITS.virtual.rowHeightPx;
|
|
25
|
+
export const KIT_VIRTUAL_ROW_CLASS: Readonly<Record<KitRowTier, string>> = V.rowClass;
|
|
26
|
+
export const KIT_VIRTUAL_OPTION_ROW_CLASS: Readonly<Record<KitRowTier, string>> = V.componentProps.optionRowClass;
|
|
27
|
+
export const KIT_VIRTUAL_VIEWPORT_CLASS: Readonly<Record<KitRowTier, string>> = V.viewportClass;
|
|
28
|
+
export const KIT_VIRTUAL_VIEWPORT_DEFAULT: KitRowTier = V.viewportDefault;
|
|
29
|
+
export const KIT_VIRTUAL_VIEWPORT_BASE: string = V.viewportBase;
|
|
30
|
+
export const KIT_VIRTUAL_OVERSCAN: number = KIT_COLLECTION_LIMITS.virtual.overscan;
|
|
31
|
+
export const KIT_VIRTUAL_INITIAL_ROWS: number = KIT_COLLECTION_LIMITS.virtual.initialRows;
|
|
32
|
+
export const KIT_VIRTUAL_MAX_COUNT: number = KIT_COLLECTION_LIMITS.virtual.maxCount;
|
|
33
|
+
export const KIT_VIRTUAL_SUMMARY_STICKY: string = V.summarySticky;
|
|
34
|
+
export const KIT_VIRTUAL_WARN: string = V.fallbackWarn;
|
|
35
|
+
export const KIT_VIRTUAL_LABELS: Readonly<Record<string, string>> = V.labels;
|
|
36
|
+
|
|
37
|
+
const split = (s: string): string[] => s.split(/\s+/).filter((c) => c !== '');
|
|
38
|
+
|
|
39
|
+
/** 虚拟滚动相关的全部类(供候选类汇总):行高类、选项行高类、视口最大高度类 */
|
|
40
|
+
export const KIT_VIRTUAL_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set([
|
|
41
|
+
...Object.values(KIT_VIRTUAL_ROW_CLASS),
|
|
42
|
+
...Object.values(KIT_VIRTUAL_OPTION_ROW_CLASS),
|
|
43
|
+
...Object.values(KIT_VIRTUAL_VIEWPORT_CLASS),
|
|
44
|
+
KIT_VIRTUAL_VIEWPORT_BASE,
|
|
45
|
+
KIT_VIRTUAL_SUMMARY_STICKY,
|
|
46
|
+
'items-center',
|
|
47
|
+
].flatMap(split))].sort());
|
|
48
|
+
|
|
49
|
+
export function rowTierOf(raw: unknown, dflt: KitRowTier = 'md'): KitRowTier {
|
|
50
|
+
return typeof raw === 'string' && (KIT_ROW_TIERS as readonly string[]).includes(raw) ? raw as KitRowTier : dflt;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 摘掉类串里的纵向内边距 py-* 与固定行高 h-N(虚拟行由档位行高类 + items-center 定高,内边距会让内容溢出,行高类并存会互相打架) */
|
|
54
|
+
export function withoutPy(cls: string): string {
|
|
55
|
+
return split(cls).filter((t) => !/(^|:)(py-|h-\d)/.test(t)).join(' ');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 顶 / 底占位元素的高度(运行期几何,唯一的 style 写入点) */
|
|
59
|
+
export function setSpacerHeight(el: HTMLElement, px: number): void {
|
|
60
|
+
const h = Number.isFinite(px) && px > 0 ? Math.round(px) : 0;
|
|
61
|
+
el.style.height = `${h}px`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 面板 / 列表型宿主的窗口重画(Select / Combobox / Tree / ItemList 共用):清空宿主,画「顶占位 + 窗口内的行 + 底占位」。
|
|
66
|
+
* 回退(引擎不可用)时画全部行、不放占位。第一行画出后用实测高度校准一次档位估算,校准发生则下一轮由窗口的 onChange 重画。
|
|
67
|
+
*/
|
|
68
|
+
export function paintVirtualRows(
|
|
69
|
+
host: HTMLElement, win: VirtualWindow, count: number, build: (index: number) => HTMLElement, spacerTag = 'div',
|
|
70
|
+
): { start: number; end: number; rows: Map<number, HTMLElement> } {
|
|
71
|
+
const doc = host.ownerDocument;
|
|
72
|
+
const rows = new Map<number, HTMLElement>();
|
|
73
|
+
host.textContent = '';
|
|
74
|
+
const fb = win.fallback();
|
|
75
|
+
const range = win.range();
|
|
76
|
+
const start = fb ? 0 : range.start;
|
|
77
|
+
const end = fb ? count : Math.min(count, Math.max(range.end, start));
|
|
78
|
+
const top = doc.createElement(spacerTag);
|
|
79
|
+
top.setAttribute('aria-hidden', 'true');
|
|
80
|
+
const bottom = doc.createElement(spacerTag);
|
|
81
|
+
bottom.setAttribute('aria-hidden', 'true');
|
|
82
|
+
if (spacerTag === 'li') {
|
|
83
|
+
top.setAttribute('role', 'presentation');
|
|
84
|
+
bottom.setAttribute('role', 'presentation');
|
|
85
|
+
}
|
|
86
|
+
if (!fb) {
|
|
87
|
+
setSpacerHeight(top, start * win.px());
|
|
88
|
+
setSpacerHeight(bottom, (count - end) * win.px());
|
|
89
|
+
host.appendChild(top);
|
|
90
|
+
}
|
|
91
|
+
for (let i = start; i < end; i++) {
|
|
92
|
+
const el = build(i);
|
|
93
|
+
rows.set(i, el);
|
|
94
|
+
host.appendChild(el);
|
|
95
|
+
}
|
|
96
|
+
if (!fb) host.appendChild(bottom);
|
|
97
|
+
const first = rows.get(start);
|
|
98
|
+
if (first && !fb) win.calibrate(first.offsetHeight);
|
|
99
|
+
return { start, end, rows };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ── 端口 ────────────────────────────────────────────────────────
|
|
103
|
+
|
|
104
|
+
interface VirtualItemLike { readonly index: number; readonly start: number; readonly size: number }
|
|
105
|
+
interface VirtualizerLike {
|
|
106
|
+
items(): readonly VirtualItemLike[];
|
|
107
|
+
totalSize(): number;
|
|
108
|
+
scrollToIndex(index: number, align?: 'start' | 'center' | 'end' | 'auto'): void;
|
|
109
|
+
update(patch: { count?: number }): void;
|
|
110
|
+
subscribe(l: () => void): () => void;
|
|
111
|
+
dispose(): void;
|
|
112
|
+
}
|
|
113
|
+
interface VirtualPortLike {
|
|
114
|
+
create(options: {
|
|
115
|
+
count: number;
|
|
116
|
+
scroller: () => HTMLElement | null;
|
|
117
|
+
estimateSize: (index: number) => number;
|
|
118
|
+
overscan: number;
|
|
119
|
+
getItemKey?: (index: number) => string | number;
|
|
120
|
+
}): Promise<VirtualizerLike>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let warned = false;
|
|
124
|
+
function warnOnce(): void {
|
|
125
|
+
if (warned) return;
|
|
126
|
+
warned = true;
|
|
127
|
+
console.warn(KIT_VIRTUAL_WARN);
|
|
128
|
+
}
|
|
129
|
+
/** 测试用:重置「只提示一次」的记忆 */
|
|
130
|
+
export function resetVirtualWarn(): void { warned = false; }
|
|
131
|
+
|
|
132
|
+
function portOf(services: unknown): VirtualPortLike | null {
|
|
133
|
+
try {
|
|
134
|
+
const engines = (services as { engines?: { virtual?: unknown } } | undefined | null)?.engines;
|
|
135
|
+
const port = engines?.virtual;
|
|
136
|
+
return port !== null && typeof port === 'object' && typeof (port as VirtualPortLike).create === 'function' ? port as VirtualPortLike : null;
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface VirtualWindowOptions {
|
|
143
|
+
/** `ctx.services`(契约要声明 services: ['engines']) */
|
|
144
|
+
services: unknown;
|
|
145
|
+
/** 滚动容器(纵向);未挂载时给 null,窗口先按初始行数画 */
|
|
146
|
+
scroller: () => HTMLElement | null;
|
|
147
|
+
count: number;
|
|
148
|
+
/** 档位对应的估算行高(px) */
|
|
149
|
+
rowPx: number;
|
|
150
|
+
/** 窗口变了(引擎就绪、滚动、回退):调用方重画 */
|
|
151
|
+
onChange: () => void;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface VirtualWindow {
|
|
155
|
+
/** 该画的下标区间 [start, end);回退时是 [0, count) */
|
|
156
|
+
range(): { start: number; end: number };
|
|
157
|
+
/** 顶 / 底占位高度(px);回退时为 0 */
|
|
158
|
+
padding(): { top: number; bottom: number };
|
|
159
|
+
/** 当前采用的行高(px):档位估算值,校准后是实测值 */
|
|
160
|
+
px(): number;
|
|
161
|
+
/** 引擎不可用,整表普通渲染 */
|
|
162
|
+
fallback(): boolean;
|
|
163
|
+
/** 引擎已就绪(窗口由真实滚动位置决定) */
|
|
164
|
+
ready(): boolean;
|
|
165
|
+
setCount(count: number): void;
|
|
166
|
+
/** 第一行实测高度和估算差超过半像素时校准一次估算并重建(返回是否发生了校准) */
|
|
167
|
+
calibrate(measuredPx: number): boolean;
|
|
168
|
+
scrollToIndex(index: number): void;
|
|
169
|
+
/** 行高档位换了(密度切换):换估算行高、清掉校准记录并重建虚拟化器,下一轮重新测量 */
|
|
170
|
+
setRowPx(px: number): void;
|
|
171
|
+
dispose(): void;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function createVirtualWindow(o: VirtualWindowOptions): VirtualWindow {
|
|
175
|
+
const port = portOf(o.services);
|
|
176
|
+
let count = Math.max(0, Math.min(Math.floor(o.count), KIT_VIRTUAL_MAX_COUNT));
|
|
177
|
+
let px = o.rowPx;
|
|
178
|
+
let virt: VirtualizerLike | null = null;
|
|
179
|
+
let off: (() => void) | null = null;
|
|
180
|
+
let failed = port === null;
|
|
181
|
+
let starting = false;
|
|
182
|
+
let disposed = false;
|
|
183
|
+
let calibrated = false;
|
|
184
|
+
if (failed) warnOnce();
|
|
185
|
+
|
|
186
|
+
const start = (): void => {
|
|
187
|
+
if (disposed || failed || starting || virt !== null || port === null) return;
|
|
188
|
+
// 滚动容器还没挂上:端口 create 会抛 CORE-VIRTUAL-SCROLLER,那不是引擎故障,等下一次 range() 再试
|
|
189
|
+
if (o.scroller() === null) return;
|
|
190
|
+
starting = true;
|
|
191
|
+
port.create({
|
|
192
|
+
count,
|
|
193
|
+
scroller: o.scroller,
|
|
194
|
+
estimateSize: () => px,
|
|
195
|
+
overscan: KIT_VIRTUAL_OVERSCAN,
|
|
196
|
+
getItemKey: (i) => i,
|
|
197
|
+
}).then((v) => {
|
|
198
|
+
starting = false;
|
|
199
|
+
if (disposed) { v.dispose(); return; }
|
|
200
|
+
virt = v;
|
|
201
|
+
off = v.subscribe(() => o.onChange());
|
|
202
|
+
o.onChange();
|
|
203
|
+
}).catch(() => {
|
|
204
|
+
starting = false;
|
|
205
|
+
if (disposed) return;
|
|
206
|
+
failed = true;
|
|
207
|
+
warnOnce();
|
|
208
|
+
o.onChange();
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
start();
|
|
212
|
+
|
|
213
|
+
const initialEnd = (): number => Math.min(count, KIT_VIRTUAL_INITIAL_ROWS);
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
range() {
|
|
217
|
+
if (failed) return { start: 0, end: count };
|
|
218
|
+
if (virt === null) {
|
|
219
|
+
start();
|
|
220
|
+
return { start: 0, end: initialEnd() };
|
|
221
|
+
}
|
|
222
|
+
const items = virt.items();
|
|
223
|
+
if (items.length === 0) return { start: 0, end: initialEnd() };
|
|
224
|
+
return { start: items[0]!.index, end: Math.min(count, items[items.length - 1]!.index + 1) };
|
|
225
|
+
},
|
|
226
|
+
padding() {
|
|
227
|
+
if (failed) return { top: 0, bottom: 0 };
|
|
228
|
+
if (virt === null) return { top: 0, bottom: Math.max(0, count - initialEnd()) * px };
|
|
229
|
+
const items = virt.items();
|
|
230
|
+
if (items.length === 0) return { top: 0, bottom: Math.max(0, count - initialEnd()) * px };
|
|
231
|
+
const first = items[0]!;
|
|
232
|
+
const last = items[items.length - 1]!;
|
|
233
|
+
return { top: first.start, bottom: Math.max(0, virt.totalSize() - (last.start + last.size)) };
|
|
234
|
+
},
|
|
235
|
+
px: () => px,
|
|
236
|
+
fallback: () => failed,
|
|
237
|
+
ready: () => virt !== null,
|
|
238
|
+
setCount(next) {
|
|
239
|
+
const n = Math.max(0, Math.min(Math.floor(next), KIT_VIRTUAL_MAX_COUNT));
|
|
240
|
+
if (n === count) return;
|
|
241
|
+
count = n;
|
|
242
|
+
virt?.update({ count: n });
|
|
243
|
+
},
|
|
244
|
+
calibrate(measured) {
|
|
245
|
+
if (calibrated || !(measured > 0) || Math.abs(measured - px) < 0.5) return false;
|
|
246
|
+
calibrated = true;
|
|
247
|
+
px = measured;
|
|
248
|
+
if (virt !== null) {
|
|
249
|
+
off?.();
|
|
250
|
+
off = null;
|
|
251
|
+
virt.dispose();
|
|
252
|
+
virt = null;
|
|
253
|
+
start();
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
},
|
|
257
|
+
setRowPx(next) {
|
|
258
|
+
if (!(next > 0) || next === px) return;
|
|
259
|
+
px = next;
|
|
260
|
+
calibrated = false;
|
|
261
|
+
if (virt !== null) {
|
|
262
|
+
off?.();
|
|
263
|
+
off = null;
|
|
264
|
+
virt.dispose();
|
|
265
|
+
virt = null;
|
|
266
|
+
start();
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
scrollToIndex(index) {
|
|
270
|
+
const i = Math.max(0, Math.min(Math.floor(index), Math.max(0, count - 1)));
|
|
271
|
+
if (virt !== null) {
|
|
272
|
+
try { virt.scrollToIndex(i, 'auto'); } catch { /* 容器已卸载:忽略 */ }
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const sc = o.scroller();
|
|
276
|
+
if (sc !== null) sc.scrollTop = i * px;
|
|
277
|
+
},
|
|
278
|
+
dispose() {
|
|
279
|
+
disposed = true;
|
|
280
|
+
off?.();
|
|
281
|
+
off = null;
|
|
282
|
+
virt?.dispose();
|
|
283
|
+
virt = null;
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// ApprovalDesk 编译:左待办队列 + 中审批单 + 右历史 / 比对(规格 5.3 的三对象审批台)。
|
|
2
|
+
// 协作链沿用 MasterSub 的枢纽与协调组件,不新造协调件:
|
|
3
|
+
//
|
|
4
|
+
// 默认选中首条 KitLinkHub 的 rows(绑队列行数据)到达时选首行
|
|
5
|
+
// 切换选中 队列行点击(pickOnRow)-> SCOPE semantic link_pick -> 枢纽写 selection;
|
|
6
|
+
// 审批单 / 历史的 from.params 带关联键(link_sel_key);枢纽抛 picked -> 页面对二者 `SCOPE | window-reload`
|
|
7
|
+
// 通过 / 驳回 做成审批单摘要里的「字段按钮」(schema 里声明虚拟字段,component: Button,action 指向 on: field 的动作):
|
|
8
|
+
// 按钮点击 -> 枢纽语义事件 -> 枢纽补上当前选中行抛 field_action { id, row } -> 页面按 id 分流到具名动作,
|
|
9
|
+
// 动作之后追加 kit_reload(协调组件重取队列 + 审批单 + 历史)
|
|
10
|
+
// 工具栏按钮载荷里没有行,所以审批单不接受 on: toolbar 的具名动作(KIT-BIZ-003)
|
|
11
|
+
// 处理完选中下一条 枢纽 afterRemove: next:队列刷新后选中项消失,选它原位置的下一条(没有就选上一条)
|
|
12
|
+
//
|
|
13
|
+
// 缺关联键不取数:审批单 / 历史的 from 编成 core `from[].require`(requireLink),尚未选中时对象落 idle,不发请求。
|
|
14
|
+
// 队列为空时审批单与历史取不到数据(走各自视图的空态)。
|
|
15
|
+
|
|
16
|
+
import type { SomaScopeMirrorDecl } from 'soma-core';
|
|
17
|
+
import type { KitObject } from '../../object-renderer/types';
|
|
18
|
+
import type { KitFragment } from '../../compile/fragment';
|
|
19
|
+
import type { KitBizContext, KitBizInput } from '../types';
|
|
20
|
+
import { KIT_COORD_EVENTS } from '../shared/coordinator';
|
|
21
|
+
import { KIT_LINK_MIRRORS, KIT_SEL_PATH } from '../link/hub';
|
|
22
|
+
import {
|
|
23
|
+
classesIn, dedupeDiagnostics, emitMember, grantPageReset, isRec, keyFieldOf, mirrorPath, newParts,
|
|
24
|
+
normalizeMember, reloadPipe, semanticPipe, sortMirrors, type Parts, type Rec,
|
|
25
|
+
} from '../link/shared';
|
|
26
|
+
import { APPROVAL_DESK_AREAS, APPROVAL_DESK_CLASS, approvalDeskHtml, approvalDeskIds } from './shell';
|
|
27
|
+
|
|
28
|
+
const RESERVED = new Set(['page', 'p', 'ctrl', 'frame', 'tabs']);
|
|
29
|
+
|
|
30
|
+
export function approvalDeskObjectName(pageId: string, role: 'queue' | 'request' | 'history'): string {
|
|
31
|
+
const name = `${pageId}_${role}`;
|
|
32
|
+
return RESERVED.has(name) ? `${name}_obj` : name;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function finish(out: Parts, html: string): KitFragment {
|
|
36
|
+
return {
|
|
37
|
+
html,
|
|
38
|
+
ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
|
|
39
|
+
events: out.events,
|
|
40
|
+
components: [...out.components].sort(),
|
|
41
|
+
candidates: [...out.candidates].sort(),
|
|
42
|
+
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isStaticView(s: unknown): boolean {
|
|
47
|
+
const v = isRec(s) && isRec(s.view) ? s.view : undefined;
|
|
48
|
+
return !!v && (v.staticComponent !== undefined || (isRec(v.summary) && v.summary.staticComponent !== undefined) || (isRec(v.list) && v.list.staticComponent !== undefined));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function compileApprovalDesk(input: KitBizInput, ctx: KitBizContext): KitFragment {
|
|
52
|
+
const out = newParts(['KitLinkHub', 'KitCrudBridge']);
|
|
53
|
+
const fail = (code: string, message: string, path: string): void => { out.diagnostics.push({ code, message, path }); };
|
|
54
|
+
|
|
55
|
+
const rawQueue = input.objects.queue;
|
|
56
|
+
const rawRequest = input.objects.request;
|
|
57
|
+
const rawHistory = input.objects.history;
|
|
58
|
+
if (!isRec(rawQueue) || !isRec(rawQueue.schema) || !isRec(rawQueue.behavior)) {
|
|
59
|
+
fail('KIT-BIZ-001', 'ApprovalDesk 缺少必填对象角色槽 queue(需含 schema 与 behavior)', 'product.objects.queue');
|
|
60
|
+
}
|
|
61
|
+
if (!isRec(rawRequest) || (!isStaticView(rawRequest) && !isRec(rawRequest.schema)) || !isRec(rawRequest.behavior)) {
|
|
62
|
+
fail('KIT-BIZ-001', 'ApprovalDesk 缺少必填对象角色槽 request(需含 schema 与 behavior;写死形状组件可省 schema)', 'product.objects.request');
|
|
63
|
+
}
|
|
64
|
+
if (rawHistory !== undefined && (!isRec(rawHistory) || (!isStaticView(rawHistory) && !isRec(rawHistory.schema)) || !isRec(rawHistory.behavior))) {
|
|
65
|
+
fail('KIT-BIZ-001', 'ApprovalDesk 的 history 必须是对象声明(schema / behavior;写死形状组件可省 schema)', 'product.objects.history');
|
|
66
|
+
}
|
|
67
|
+
for (const key of Object.keys(input.areaClass ?? {})) {
|
|
68
|
+
if (!(APPROVAL_DESK_AREAS as readonly string[]).includes(key)) {
|
|
69
|
+
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 ApprovalDesk 的区域闭集 ${APPROVAL_DESK_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (out.diagnostics.length > 0) return finish(out, '');
|
|
73
|
+
|
|
74
|
+
// 审批单的具名动作必须是字段按钮:工具栏载荷里没有行
|
|
75
|
+
const reqActions = isRec(rawRequest) && isRec(rawRequest.behavior) && Array.isArray((rawRequest.behavior as Rec).actions)
|
|
76
|
+
? ((rawRequest.behavior as Rec).actions as Array<Rec>)
|
|
77
|
+
: [];
|
|
78
|
+
reqActions.forEach((a, i) => {
|
|
79
|
+
if (a.on === 'toolbar') {
|
|
80
|
+
fail('KIT-BIZ-003', `request 的动作 ${String(a.id)}:审批单的通过 / 驳回要做成摘要里的字段按钮(on: field + 字段 action),工具栏按钮拿不到当前审批单`, `product.objects.request.behavior.actions[${i}].on`);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (out.diagnostics.length > 0) return finish(out, '');
|
|
84
|
+
|
|
85
|
+
const ids = approvalDeskIds(ctx.pageId);
|
|
86
|
+
const areaClass = input.areaClass ?? {};
|
|
87
|
+
const link = ids.link;
|
|
88
|
+
const queueName = approvalDeskObjectName(ctx.pageId, 'queue');
|
|
89
|
+
const queueNorm = normalizeMember(rawQueue, {
|
|
90
|
+
path: 'product.objects.queue',
|
|
91
|
+
allowedViews: ['list'],
|
|
92
|
+
ensure: ['list'],
|
|
93
|
+
withForm: false,
|
|
94
|
+
});
|
|
95
|
+
out.diagnostics.push(...queueNorm.diagnostics);
|
|
96
|
+
const queue: KitObject = queueNorm.obj;
|
|
97
|
+
const queueKey = keyFieldOf(queue);
|
|
98
|
+
if (queueKey === undefined) {
|
|
99
|
+
fail('KIT-BIZ-001', 'queue 的 schema 必须有 key 字段(或名为 id 的字段):审批单与历史靠它关联', 'product.objects.queue.schema');
|
|
100
|
+
return finish(out, '');
|
|
101
|
+
}
|
|
102
|
+
const selKey = mirrorPath(link, KIT_LINK_MIRRORS.selKey);
|
|
103
|
+
|
|
104
|
+
const members: Array<{ role: 'request' | 'history'; object: string; scope: string; obj: KitObject; title: string }> = [];
|
|
105
|
+
for (const role of ['request', 'history'] as const) {
|
|
106
|
+
const raw = input.objects[role] as unknown as Rec | undefined;
|
|
107
|
+
if (!isRec(raw)) continue;
|
|
108
|
+
const behavior = raw.behavior as Rec;
|
|
109
|
+
const linkKey = typeof behavior.linkKey === 'string' && behavior.linkKey !== '' ? behavior.linkKey : queueKey;
|
|
110
|
+
const norm = normalizeMember(raw, {
|
|
111
|
+
path: `product.objects.${role}`,
|
|
112
|
+
allowedViews: role === 'request' ? ['summary'] : ['list', 'summary'],
|
|
113
|
+
ensure: role === 'request' ? ['summary'] : 'any',
|
|
114
|
+
withForm: false,
|
|
115
|
+
params: { [linkKey]: `$${selKey}` },
|
|
116
|
+
requireLink: true,
|
|
117
|
+
});
|
|
118
|
+
out.diagnostics.push(...norm.diagnostics);
|
|
119
|
+
const object = approvalDeskObjectName(ctx.pageId, role);
|
|
120
|
+
members.push({ role, object, scope: `${object}_scope`, obj: norm.obj, title: typeof raw.title === 'string' ? raw.title : '' });
|
|
121
|
+
}
|
|
122
|
+
if (out.diagnostics.length > 0) return finish(out, '');
|
|
123
|
+
|
|
124
|
+
const refresh = [semanticPipe(link, KIT_COORD_EVENTS.reload)];
|
|
125
|
+
const fieldSteps: Array<Rec> = [];
|
|
126
|
+
const q = emitMember(out, {
|
|
127
|
+
object: queueName, scope: `${queueName}_scope`, obj: queue, ctx, link, hubId: ids.hub, refresh, pick: true, fieldSteps,
|
|
128
|
+
});
|
|
129
|
+
const pageScopes: string[] = [];
|
|
130
|
+
const blocks: Record<string, { title: string; html: string }> = {};
|
|
131
|
+
for (const m of members) {
|
|
132
|
+
const em = emitMember(out, { object: m.object, scope: m.scope, obj: m.obj, ctx, link, hubId: ids.hub, refresh, fieldSteps });
|
|
133
|
+
blocks[m.role] = {
|
|
134
|
+
title: m.title,
|
|
135
|
+
html: [em.r.parts.toolbar ?? '', em.r.parts.filter ?? '', em.listHtml, em.r.parts.summary ?? ''].filter((x) => x !== '').join('\n'),
|
|
136
|
+
};
|
|
137
|
+
if (grantPageReset(out, m.scope, ids.hub)) pageScopes.push(m.scope);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 链接作用域:selection 归枢纽,focus 归协调组件(它在 onMount 里要拿到 focus 切片)
|
|
141
|
+
const mirrors: SomaScopeMirrorDecl[] = [
|
|
142
|
+
{ key: KIT_LINK_MIRRORS.selKey, slice: 'selection', path: `${KIT_SEL_PATH}.${queueKey}`, as: 'value' },
|
|
143
|
+
{ key: KIT_LINK_MIRRORS.selRow, slice: 'selection', path: KIT_SEL_PATH, as: 'value' },
|
|
144
|
+
];
|
|
145
|
+
out.scopes[link] = {
|
|
146
|
+
id: link,
|
|
147
|
+
object: queueName,
|
|
148
|
+
slices: [{ name: 'selection', owner: ids.hub }, { name: 'focus', owner: ids.coord }],
|
|
149
|
+
mirrors: sortMirrors(mirrors),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const rowsPath = `page.data.${queueName}.${q.r.compiled.listShape.rows}`;
|
|
153
|
+
out.show[ids.hub] = {
|
|
154
|
+
props: { scope: link, keyField: queueKey, linkKey: '', autoSelect: true, afterRemove: 'next', rows: rowsPath, pageScopes },
|
|
155
|
+
};
|
|
156
|
+
out.show[ids.coord] = {
|
|
157
|
+
props: { scope: link, object: queueName, keyField: queueKey, reloads: members.map((m) => m.object), overlays: {} },
|
|
158
|
+
};
|
|
159
|
+
out.events[`${ids.hub}.picked`] = { steps: members.map((m) => ({ do: reloadPipe(m.scope) })) };
|
|
160
|
+
if (fieldSteps.length > 0) {
|
|
161
|
+
// 字段按钮的 confirm / permission 尾段直接带在 ACTION 步骤上(core 在 steps 内执行,被拒整串停止)
|
|
162
|
+
out.events[`${ids.hub}.field_action`] = { steps: [...fieldSteps, ...refresh.map((p) => ({ do: p }))] };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const queueHtml = [q.r.parts.toolbar ?? '', q.r.parts.filter ?? '', q.listHtml].filter((x) => x !== '').join('\n');
|
|
166
|
+
const html = approvalDeskHtml(
|
|
167
|
+
ids,
|
|
168
|
+
{
|
|
169
|
+
queue: { title: typeof (rawQueue as unknown as Rec).title === 'string' ? ((rawQueue as unknown as Rec).title as string) : '', html: queueHtml },
|
|
170
|
+
request: blocks.request ?? { title: '', html: '' },
|
|
171
|
+
history: blocks.history ?? null,
|
|
172
|
+
},
|
|
173
|
+
areaClass,
|
|
174
|
+
input.class,
|
|
175
|
+
);
|
|
176
|
+
for (const c of classesIn(html)) out.candidates.add(c);
|
|
177
|
+
for (const c of Object.values(APPROVAL_DESK_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
178
|
+
return finish(out, html);
|
|
179
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ApprovalDesk:三对象审批台(规格 5.3)。
|
|
2
|
+
// 对象角色槽:queue(必填:待办队列,只有 list 视图)、request(必填:审批单,只有 summary 视图;通过 / 驳回写成摘要里的字段按钮)、
|
|
3
|
+
// history(可选:历史 / 比对,list / summary 或写死形状件,如 Timeline / ApprovalFlow)。
|
|
4
|
+
|
|
5
|
+
import { defineKitBizComponent } from '../define';
|
|
6
|
+
import { compileApprovalDesk } from './compile';
|
|
7
|
+
import { APPROVAL_DESK_AREAS } from './shell';
|
|
8
|
+
|
|
9
|
+
export const ApprovalDesk = defineKitBizComponent({
|
|
10
|
+
kind: 'ApprovalDesk',
|
|
11
|
+
roles: {
|
|
12
|
+
queue: { required: true, views: ['list'] },
|
|
13
|
+
request: { required: true, views: ['summary'] },
|
|
14
|
+
history: { required: false, views: ['list', 'summary'] },
|
|
15
|
+
},
|
|
16
|
+
areas: [...APPROVAL_DESK_AREAS],
|
|
17
|
+
compile: compileApprovalDesk,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { compileApprovalDesk, approvalDeskObjectName } from './compile';
|
|
21
|
+
export { APPROVAL_DESK_AREAS, APPROVAL_DESK_CLASS, approvalDeskIds } from './shell';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// ApprovalDesk 的 HTML 代码壳:左待办队列 + 中审批单 + 右历史 / 比对三栏。只有结构与 Tailwind 类(语义色名 + utilityScales 里有的尺度),不写原生 CSS。
|
|
2
|
+
// 三栏靠容器查询变体 `@md:`:窄容器下上下堆叠;达到 md 档左 3 / 中 5 / 右 4(共 12 份)。
|
|
3
|
+
|
|
4
|
+
import { mergeClass } from '../../object-renderer/merge-class';
|
|
5
|
+
import { cls, esc, host } from '../link/shared';
|
|
6
|
+
|
|
7
|
+
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
8
|
+
export const APPROVAL_DESK_AREAS = ['root', 'queue', 'request', 'history'] as const;
|
|
9
|
+
export type ApprovalDeskArea = (typeof APPROVAL_DESK_AREAS)[number];
|
|
10
|
+
|
|
11
|
+
export const APPROVAL_DESK_CLASS = {
|
|
12
|
+
root: '@container flex flex-col gap-4',
|
|
13
|
+
grid: 'grid grid-cols-12 gap-4',
|
|
14
|
+
queue: 'col-span-12 @md:col-span-3 flex min-w-0 flex-col gap-3 rounded-lg border border-border-subtle bg-surface-raised p-4 shadow-xs',
|
|
15
|
+
request: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-3 rounded-lg border border-border-subtle bg-surface-raised p-4 shadow-xs',
|
|
16
|
+
history: 'col-span-12 @md:col-span-4 flex min-w-0 flex-col gap-3 rounded-lg border border-border-subtle bg-surface-raised p-4 shadow-xs',
|
|
17
|
+
title: 'text-base font-semibold text-fg',
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export function approvalDeskIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
21
|
+
return { root: `${pageId}__ad_root`, hub: `${pageId}__hub`, coord: `${pageId}__coord`, link: `${pageId}_link` };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface DeskColumn {
|
|
25
|
+
title: string;
|
|
26
|
+
html: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 整个壳:协作组件宿主 + 三栏。区域类按 7.3 同族规则覆写 */
|
|
30
|
+
export function approvalDeskHtml(
|
|
31
|
+
ids: ReturnType<typeof approvalDeskIds>,
|
|
32
|
+
parts: { queue: DeskColumn; request: DeskColumn; history: DeskColumn | null },
|
|
33
|
+
areaClass: Record<string, string>,
|
|
34
|
+
extra: string | undefined,
|
|
35
|
+
): string {
|
|
36
|
+
const col = (area: 'queue' | 'request' | 'history', c: DeskColumn, wide?: string): string => {
|
|
37
|
+
const title = c.title === '' ? '' : `<h3${cls(APPROVAL_DESK_CLASS.title)}>${esc(c.title)}</h3>`;
|
|
38
|
+
const base = wide === undefined ? APPROVAL_DESK_CLASS[area] : wide;
|
|
39
|
+
return `<section${cls(mergeClass(base, areaClass[area]))}>${title}${c.html}</section>`;
|
|
40
|
+
};
|
|
41
|
+
// 没有历史栏时,审批单栏吃掉右侧 4 份
|
|
42
|
+
const requestBase = parts.history === null
|
|
43
|
+
? 'col-span-12 @md:col-span-9 flex min-w-0 flex-col gap-3 rounded-lg border border-border-subtle bg-surface-raised p-4 shadow-xs'
|
|
44
|
+
: undefined;
|
|
45
|
+
const cols = [col('queue', parts.queue), col('request', parts.request, requestBase)];
|
|
46
|
+
if (parts.history !== null) cols.push(col('history', parts.history));
|
|
47
|
+
const root = mergeClass(mergeClass(APPROVAL_DESK_CLASS.root, areaClass.root), extra);
|
|
48
|
+
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${host('KitLinkHub', ids.hub)}${host('KitCrudBridge', ids.coord)}\n`
|
|
49
|
+
+ `<div${cls(APPROVAL_DESK_CLASS.grid)}>\n${cols.join('\n')}\n</div>\n</div>`;
|
|
50
|
+
}
|