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