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
|
@@ -14,30 +14,20 @@ import type { KitObject, KitType } from '../../object-renderer/types';
|
|
|
14
14
|
import type { KitFragment } from '../../compile/fragment';
|
|
15
15
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
16
16
|
import { KIT_COORD_EVENTS, KIT_COORD_MIRRORS } from '../shared/coordinator';
|
|
17
|
+
import { bizObjectName, finishBizCompile, validateBizAreaClass } from '../shared/compile-helpers';
|
|
17
18
|
import { wireDialogForm } from '../shared/pipes';
|
|
18
|
-
import {
|
|
19
|
+
import { OVERLAY_SHELL_CLASS, dialogHtml, dialogIds, dialogTitles, dialogWidthOf } from '../shared/overlay-shell';
|
|
19
20
|
import { KIT_LINK_MIRRORS, KIT_SEL_PATH } from '../link/hub';
|
|
20
21
|
import {
|
|
21
|
-
IDENT, classesIn,
|
|
22
|
-
normalizeMember, patchProps, semanticPipe, sortMirrors, type
|
|
22
|
+
IDENT, classesIn, emitMember, grantPageReset, isRec, keyFieldOf, linkRemoveProps, mirrorPath, newParts,
|
|
23
|
+
normalizeMember, patchProps, semanticPipe, sortMirrors, type Rec,
|
|
23
24
|
} from '../link/shared';
|
|
24
25
|
import { kitText } from '../../i18n/kit-text';
|
|
26
|
+
import { CategoryCrud } from './index';
|
|
25
27
|
import { CATEGORY_CRUD_AREAS, CATEGORY_CRUD_CLASS, categoryCrudHtml, categoryCrudIds } from './shell';
|
|
26
28
|
|
|
27
29
|
export function categoryObjectName(pageId: string, role: 'category' | 'item'): string {
|
|
28
|
-
|
|
29
|
-
return name === 'page' || name === 'p' || name === 'ctrl' ? `${name}_obj` : name;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function finish(out: Parts, html: string): KitFragment {
|
|
33
|
-
return {
|
|
34
|
-
html,
|
|
35
|
-
ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
|
|
36
|
-
events: out.events,
|
|
37
|
-
components: [...out.components].sort(),
|
|
38
|
-
candidates: [...out.candidates].sort(),
|
|
39
|
-
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
40
|
-
};
|
|
30
|
+
return bizObjectName(pageId, role);
|
|
41
31
|
}
|
|
42
32
|
|
|
43
33
|
export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): KitFragment {
|
|
@@ -53,12 +43,8 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
53
43
|
fail('KIT-BIZ-001', `CategoryCrud 缺少必填对象角色槽 ${role}(需含 behavior)`, `product.objects.${role}`);
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 CategoryCrud 的区域闭集 ${CATEGORY_CRUD_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (out.diagnostics.length > 0) return finish(out, '');
|
|
46
|
+
validateBizAreaClass(input, 'CategoryCrud', CATEGORY_CRUD_AREAS, out.diagnostics);
|
|
47
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
62
48
|
|
|
63
49
|
const ids = categoryCrudIds(ctx.pageId);
|
|
64
50
|
const areaClass = input.areaClass ?? {};
|
|
@@ -72,8 +58,9 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
72
58
|
// ---- 分类
|
|
73
59
|
const catNorm = normalizeMember({ schema: {}, ...(rawCat as unknown as Rec) }, {
|
|
74
60
|
path: 'product.objects.category',
|
|
61
|
+
roleName: 'category',
|
|
75
62
|
// filter:分类列表的筛选条(筛选驱动分类对象重取;分类树/列表的选中项失效时由枢纽按既有规则处理)
|
|
76
|
-
|
|
63
|
+
roleDef: CategoryCrud.roles.category,
|
|
77
64
|
ensure: 'any',
|
|
78
65
|
withForm: false,
|
|
79
66
|
});
|
|
@@ -83,7 +70,7 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
83
70
|
const catKey = staticView?.map?.id ?? keyFieldOf(cat) ?? (staticView !== undefined ? 'id' : undefined);
|
|
84
71
|
if (catKey === undefined) {
|
|
85
72
|
fail('KIT-BIZ-001', 'category 的 schema 必须有 key 字段(或名为 id 的字段):条目靠它关联', 'product.objects.category.schema');
|
|
86
|
-
return
|
|
73
|
+
return finishBizCompile(out, '');
|
|
87
74
|
}
|
|
88
75
|
const catType: KitType = cat.schema[catKey]?.type === 'int' ? 'int' : 'text';
|
|
89
76
|
|
|
@@ -94,7 +81,8 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
94
81
|
const selKey = mirrorPath(link, KIT_LINK_MIRRORS.selKey);
|
|
95
82
|
const itemNorm = normalizeMember(rawItem, {
|
|
96
83
|
path: 'product.objects.item',
|
|
97
|
-
|
|
84
|
+
roleName: 'item',
|
|
85
|
+
roleDef: CategoryCrud.roles.item,
|
|
98
86
|
ensure: ['list'],
|
|
99
87
|
withForm: true,
|
|
100
88
|
...(ctx.locale !== undefined ? { locale: ctx.locale } : {}),
|
|
@@ -103,15 +91,12 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
103
91
|
link: { field: linkKey, type: catType },
|
|
104
92
|
});
|
|
105
93
|
out.diagnostics.push(...itemNorm.diagnostics);
|
|
106
|
-
if (out.diagnostics.length > 0) return
|
|
94
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
107
95
|
const item: KitObject = itemNorm.obj;
|
|
108
96
|
|
|
109
|
-
const
|
|
110
|
-
// H1a:带预填的「新建」钮(语义事件名 -> { 字段: 字面量 }),整表交协调组件(新建表单是明细对象的,分类对象的新建钮不带预填)
|
|
111
|
-
const createPrefills: Record<string, Record<string, unknown>> = {};
|
|
112
|
-
const c = emitMember(out, { object: catName, scope: catScope, obj: cat, ctx, link, hubId: ids.hub, refresh: [], pick: staticView === undefined });
|
|
97
|
+
const c = emitMember(out, { object: catName, scope: catScope, obj: cat, ctx, link, hubId: ids.hub, pick: staticView === undefined });
|
|
113
98
|
const it = emitMember(out, {
|
|
114
|
-
object: itemName, scope: itemScope, obj: item, ctx, link, hubId: ids.hub,
|
|
99
|
+
object: itemName, scope: itemScope, obj: item, ctx, link, hubId: ids.hub,
|
|
115
100
|
emitInput: { formModePath: mirrorPath(link, mk.mode.key), formInitialPath: mirrorPath(link, mk.row.key) },
|
|
116
101
|
});
|
|
117
102
|
const pageScopes = grantPageReset(out, itemScope, ids.hub) ? [itemScope] : [];
|
|
@@ -120,7 +105,8 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
120
105
|
const treeId = staticView !== undefined ? viewAnchor(catName, 'summary') : undefined;
|
|
121
106
|
// 选中后按新的类目键重取右侧列表(读接口 params 引用选中镜像)
|
|
122
107
|
if (treeId !== undefined) {
|
|
123
|
-
|
|
108
|
+
// 单管道:只写 selection;枢纽见选中项一变就回第 1 页并上抛 picked,picked 再交协调组件重取(见下方 picked 的接线)
|
|
109
|
+
out.events[`${treeId}.select`] = `SCOPE | set | ${link} | selection | path:${KIT_SEL_PATH} | from:item`;
|
|
124
110
|
}
|
|
125
111
|
|
|
126
112
|
// ---- 链接作用域:selection 归分类树(或枢纽),focus 归协调组件
|
|
@@ -152,16 +138,16 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
152
138
|
out.events[`${d.dialogClose}.click`] = semanticPipe(link, KIT_COORD_EVENTS.close);
|
|
153
139
|
const createName = item.behavior.actions?.find((a) => a.builtin === 'openCreate')?.name ?? kitText('soma.kit.create', undefined, ctx.locale);
|
|
154
140
|
const editName = item.behavior.actions?.find((a) => a.builtin === 'openEdit')?.name ?? kitText('soma.kit.edit', undefined, ctx.locale);
|
|
155
|
-
dialog = dialogHtml(d, dialogTitles(item.view?.form?.title, { create: createName, edit: editName }), it.r.parts.form ?? '', { dialog: areaClass.dialog ?? '' }, CLOSE_LABEL);
|
|
156
|
-
for (const cl of Object.values(
|
|
141
|
+
dialog = dialogHtml(d, dialogTitles(item.view?.form?.title, { create: createName, edit: editName }), it.r.parts.form ?? '', { dialog: areaClass.dialog ?? '' }, CLOSE_LABEL, '', dialogWidthOf({ form: item.view?.form, schema: item.schema }));
|
|
142
|
+
for (const cl of Object.values(OVERLAY_SHELL_CLASS)) for (const t of cl.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
157
143
|
}
|
|
158
144
|
|
|
159
145
|
// ---- 枢纽与协调组件
|
|
160
146
|
out.show[ids.hub] = { props: { scope: link, keyField: catKey, linkKey, autoSelect: false, rows: [], pageScopes } };
|
|
161
147
|
out.show[ids.coord] = {
|
|
162
148
|
props: {
|
|
163
|
-
scope: link, object: itemName, keyField: keyFieldOf(item) ?? '', reloads: [], overlays: {},
|
|
164
|
-
...(
|
|
149
|
+
scope: link, object: itemName, keyField: keyFieldOf(item) ?? '', reloads: [], overlays: {}, rowsPath: it.r.compiled.listShape.rows,
|
|
150
|
+
...linkRemoveProps(out),
|
|
165
151
|
},
|
|
166
152
|
};
|
|
167
153
|
out.events[`${ids.hub}.picked`] = semanticPipe(link, KIT_COORD_EVENTS.pick);
|
|
@@ -172,5 +158,5 @@ export function compileCategoryCrud(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
172
158
|
const html = categoryCrudHtml(ids, { category: catHtml, item: itemHtml, dialog }, areaClass, input.class);
|
|
173
159
|
for (const cl of classesIn(html)) out.candidates.add(cl);
|
|
174
160
|
for (const cl of Object.values(CATEGORY_CRUD_CLASS)) for (const t of cl.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
175
|
-
return
|
|
161
|
+
return finishBizCompile(out, html);
|
|
176
162
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// CategoryCrud 的 HTML 代码壳:左侧固定紧凑分类栏(默认 w-56)+ 右侧条目管理区。只有结构与 Tailwind 类,分栏靠容器查询变体。
|
|
2
2
|
|
|
3
3
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
4
|
+
import { kitShellRecipe } from '../../recipes/container';
|
|
4
5
|
import { cls, esc, host } from '../link/shared';
|
|
5
6
|
|
|
6
7
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -8,7 +9,7 @@ export const CATEGORY_CRUD_AREAS = ['root', 'categorySidebar', 'itemWorkspace',
|
|
|
8
9
|
|
|
9
10
|
export const CATEGORY_CRUD_CLASS = {
|
|
10
11
|
root: '@container flex flex-col gap-4 @md:flex-row',
|
|
11
|
-
categorySidebar: 'w-full shrink-0 @md:w-56
|
|
12
|
+
categorySidebar: mergeClass('w-full shrink-0 @md:w-56 p-3 flex flex-col gap-2', kitShellRecipe()),
|
|
12
13
|
itemWorkspace: 'flex min-w-0 flex-1 flex-col gap-4',
|
|
13
14
|
} as const;
|
|
14
15
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// 与 StepForm 的区别:单页结算,表单与摘要并排,没有分步;与 MultiObjectBoard 的区别:表单是提交主体,摘要栏是写死的附属。
|
|
8
8
|
|
|
9
9
|
import { emitObject } from '../../object-renderer/emit-object';
|
|
10
|
+
import { savedNoticePipe } from '../../object-renderer/form-notify';
|
|
10
11
|
import { viewAnchor } from '../../object-renderer/emit-static';
|
|
11
12
|
import type { KitObject, KitViewForm } from '../../object-renderer/types';
|
|
12
13
|
import type { KitFragment } from '../../compile/fragment';
|
|
@@ -15,6 +16,7 @@ import { addEmit, classesIn, isRec, newParts, patchProps, type Rec } from '../li
|
|
|
15
16
|
import {
|
|
16
17
|
addClassTokens, checkAreas, emitReadOnlyMember, finishTemplate, normalizeFormObject, templateObjectName,
|
|
17
18
|
} from '../page-templates/shared';
|
|
19
|
+
import { CheckoutPage } from './index';
|
|
18
20
|
import { CHECKOUT_PAGE_AREAS, CHECKOUT_PAGE_CLASS, checkoutPageHtml, checkoutPageIds } from './shell';
|
|
19
21
|
import { kitText } from '../../i18n/kit-text';
|
|
20
22
|
|
|
@@ -46,14 +48,21 @@ export function compileCheckoutPage(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
46
48
|
const ids = checkoutPageIds(ctx.pageId);
|
|
47
49
|
|
|
48
50
|
// ---- 表单
|
|
49
|
-
const target = normalizeFormObject(
|
|
51
|
+
const target = normalizeFormObject(
|
|
52
|
+
rawForm as unknown as Rec,
|
|
53
|
+
'product.objects.form',
|
|
54
|
+
'CheckoutPage 的 form',
|
|
55
|
+
out.diagnostics,
|
|
56
|
+
CheckoutPage.roles.form,
|
|
57
|
+
);
|
|
50
58
|
if (out.diagnostics.length > 0) return finishTemplate(out, '');
|
|
51
59
|
const formObject = checkoutPageObjectName(ctx.pageId, 'form');
|
|
60
|
+
const scope = `${formObject}_scope`;
|
|
52
61
|
const hasFrom = target.behavior.from !== undefined;
|
|
53
62
|
const formView = (target.view?.form ?? {}) as KitViewForm;
|
|
54
63
|
const r = emitObject(
|
|
55
64
|
target as KitObject,
|
|
56
|
-
{ object: formObject, scope
|
|
65
|
+
{ object: formObject, scope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
57
66
|
{
|
|
58
67
|
registeredActions: ctx.registeredActions,
|
|
59
68
|
formMode: hasFrom ? 'edit' : 'create',
|
|
@@ -75,18 +84,26 @@ export function compileCheckoutPage(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
75
84
|
resetLabel: RESET_LABEL,
|
|
76
85
|
classes: { ...classes, actions: CHECKOUT_PAGE_CLASS.footer },
|
|
77
86
|
});
|
|
78
|
-
out.events[`${formId}.saved`] =
|
|
87
|
+
out.events[`${formId}.saved`] = savedNoticePipe(formView, SAVED_NOTICE);
|
|
79
88
|
const ft = formView.title;
|
|
80
89
|
const formTitle = typeof ft === 'string' ? ft : isRec(ft) ? String((hasFrom ? ft.edit : ft.create) ?? '') : '';
|
|
81
90
|
|
|
82
91
|
// ---- 摘要栏
|
|
83
92
|
const items = emitReadOnlyMember(out, rawItems, {
|
|
84
|
-
object: checkoutPageObjectName(ctx.pageId, 'items'),
|
|
93
|
+
object: checkoutPageObjectName(ctx.pageId, 'items'),
|
|
94
|
+
path: 'product.objects.items',
|
|
95
|
+
roleName: 'items',
|
|
96
|
+
roleDef: CheckoutPage.roles.items,
|
|
97
|
+
ctx,
|
|
85
98
|
});
|
|
86
99
|
let amounts = undefined as ReturnType<typeof emitReadOnlyMember>;
|
|
87
100
|
if (rawAmounts !== undefined) {
|
|
88
101
|
amounts = emitReadOnlyMember(out, rawAmounts, {
|
|
89
|
-
object: checkoutPageObjectName(ctx.pageId, 'amounts'),
|
|
102
|
+
object: checkoutPageObjectName(ctx.pageId, 'amounts'),
|
|
103
|
+
path: 'product.objects.amounts',
|
|
104
|
+
roleName: 'amounts',
|
|
105
|
+
roleDef: CheckoutPage.roles.amounts,
|
|
106
|
+
ctx,
|
|
90
107
|
});
|
|
91
108
|
}
|
|
92
109
|
if (out.diagnostics.length > 0 || items === undefined) return finishTemplate(out, '');
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// 窄容器下摘要在表单之后上下堆叠;达到 md 档左 7 / 右 5(共 12 份)。
|
|
3
3
|
|
|
4
4
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
5
|
+
import { kitShellRecipe } from '../../recipes/container';
|
|
5
6
|
import { cls, esc } from '../link/shared';
|
|
6
7
|
|
|
7
8
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -10,10 +11,10 @@ export type CheckoutPageArea = (typeof CHECKOUT_PAGE_AREAS)[number];
|
|
|
10
11
|
|
|
11
12
|
export const CHECKOUT_PAGE_CLASS = {
|
|
12
13
|
root: '@container grid grid-cols-12 gap-4',
|
|
13
|
-
form: 'col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-4
|
|
14
|
+
form: mergeClass('col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-4 p-6', kitShellRecipe()),
|
|
14
15
|
summary: 'col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-4',
|
|
15
|
-
items: 'flex flex-col gap-3
|
|
16
|
-
amounts: 'flex flex-col gap-3
|
|
16
|
+
items: mergeClass('flex flex-col gap-3 p-4', kitShellRecipe()),
|
|
17
|
+
amounts: mergeClass('flex flex-col gap-3 p-4', kitShellRecipe({ tone: 'sunken', shadow: false })),
|
|
17
18
|
title: 'text-base font-semibold text-fg',
|
|
18
19
|
/** 表单底部提交栏(表单 actions 区) */
|
|
19
20
|
footer: 'mt-2 flex flex-wrap items-end gap-2 border-t border-border-subtle pt-4',
|
package/src/biz/compose.ts
CHANGED
|
@@ -9,7 +9,9 @@ import { emptyFragment, mergeFragments, type KitFragment } from '../compile/frag
|
|
|
9
9
|
import { checkClasses, mergeClass } from '../object-renderer/merge-class';
|
|
10
10
|
import type { KitDiagnostic, KitObject } from '../object-renderer/types';
|
|
11
11
|
import { defineKitBizComponent } from './define';
|
|
12
|
+
import { validateBizAreaClass } from './shared/compile-helpers';
|
|
12
13
|
import type { KitBizContext, KitBizDefinition, KitBizInput, KitBizRole } from './types';
|
|
14
|
+
import { kitFail } from '../compile/kit-error';
|
|
13
15
|
|
|
14
16
|
export interface WrapBizShellContext {
|
|
15
17
|
input: KitBizInput;
|
|
@@ -53,7 +55,7 @@ export function wrapKitBizComponent(inner: KitBizDefinition, options: WrapBizOpt
|
|
|
53
55
|
const extraTokens = splitCandidateTokens(options.candidates);
|
|
54
56
|
for (const tok of extraTokens) {
|
|
55
57
|
const bad = checkClasses(tok, `${options.kind}.candidates`);
|
|
56
|
-
if (bad.length > 0)
|
|
58
|
+
if (bad.length > 0) kitFail('KIT-COMP-003', `${options.kind}.candidates`, `${options.kind} 的 candidates 含非法类 "${tok}":${bad[0]!.message}`, '候选类只能用刻度内的 Tailwind 类,不写方括号任意值');
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
return defineKitBizComponent({
|
|
@@ -65,15 +67,7 @@ export function wrapKitBizComponent(inner: KitBizDefinition, options: WrapBizOpt
|
|
|
65
67
|
const diagnostics: KitDiagnostic[] = [];
|
|
66
68
|
|
|
67
69
|
// 1. 先按包装后的完整区域闭集校验页面传入的 areaClass
|
|
68
|
-
|
|
69
|
-
if (!allAreaSet.has(key)) {
|
|
70
|
-
diagnostics.push({
|
|
71
|
-
code: 'KIT-PAGE-001',
|
|
72
|
-
path: `product.areaClass.${key}`,
|
|
73
|
-
message: `areaClass 里的区域名 "${key}" 不在 ${options.kind} 的区域闭集 ${allAreas.join(' / ')} 内`,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
70
|
+
validateBizAreaClass(input, options.kind, allAreas, diagnostics);
|
|
77
71
|
|
|
78
72
|
// 2. 执行前置输入翻译(专属语法 -> 标准业务组件入参)
|
|
79
73
|
const adapted = options.adaptInput ? options.adaptInput(input, ctx, diagnostics) : input;
|
|
@@ -179,47 +173,47 @@ const PART_KEY_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
|
179
173
|
export function composeKitBizComponents(options: ComposeBizOptions): KitBizDefinition {
|
|
180
174
|
const partEntries = Object.entries(options.parts);
|
|
181
175
|
if (partEntries.length === 0) {
|
|
182
|
-
|
|
176
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts`, `composeKitBizComponents(${options.kind}) 至少需要 1 个子部件`, 'parts 里至少登记一个子部件');
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
const roles: Record<string, KitBizRole> = {};
|
|
186
180
|
let overlayOwnerCount = 0;
|
|
187
181
|
for (const [partKey, part] of partEntries) {
|
|
188
182
|
if (!PART_KEY_RE.test(partKey)) {
|
|
189
|
-
|
|
183
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}`, `${options.kind} 的子部件名 "${partKey}" 只能是字母开头的字母数字下划线`, '子部件名改成字母开头、只含字母数字下划线');
|
|
190
184
|
}
|
|
191
185
|
if (part.forwardOverlays === true) overlayOwnerCount += 1;
|
|
192
186
|
const mappedInner = new Set<string>(Object.keys(part.roleMap));
|
|
193
187
|
for (const [innerRole, innerSpec] of Object.entries(part.component.roles)) {
|
|
194
188
|
if (innerSpec.required && !mappedInner.has(innerRole)) {
|
|
195
|
-
|
|
189
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}.roleMap`, `${options.kind}.parts.${partKey} 未映射子组件 ${part.component.kind} 的必填角色 "${innerRole}"`, `在 roleMap 里加 ${innerRole}: 对外角色名`);
|
|
196
190
|
}
|
|
197
191
|
}
|
|
198
192
|
for (const [innerRole, outerRole] of Object.entries(part.roleMap)) {
|
|
199
193
|
const spec = part.component.roles[innerRole];
|
|
200
194
|
if (!spec) {
|
|
201
|
-
|
|
195
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}.roleMap.${innerRole}`, `${options.kind}.parts.${partKey} 映射了 ${part.component.kind} 不存在的角色 "${innerRole}"`, `roleMap 的键必须是 ${part.component.kind} 的角色名:${Object.keys(part.component.roles).join(' / ')}`);
|
|
202
196
|
}
|
|
203
197
|
if (outerRole in roles) {
|
|
204
|
-
|
|
198
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}.roleMap`, `${options.kind} 的对外角色名 "${outerRole}" 在多个子部件中重复`, '各子部件的对外角色名互不相同');
|
|
205
199
|
}
|
|
206
200
|
roles[outerRole] = { ...spec };
|
|
207
201
|
}
|
|
208
202
|
}
|
|
209
203
|
if (overlayOwnerCount > 1) {
|
|
210
|
-
|
|
204
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts`, `${options.kind} 至多只能有 1 个子部件开启 forwardOverlays`, '只保留一个子部件的 forwardOverlays: true');
|
|
211
205
|
}
|
|
212
206
|
|
|
213
207
|
const baseRootClass = options.rootClass ?? '@container flex flex-col gap-6';
|
|
214
208
|
const badRoot = checkClasses(baseRootClass, `${options.kind}.rootClass`);
|
|
215
|
-
if (badRoot.length > 0)
|
|
209
|
+
if (badRoot.length > 0) kitFail('KIT-COMP-003', `${options.kind}.rootClass`, `${options.kind} 的 rootClass 非法:${badRoot[0]!.message}`, 'rootClass 只能用刻度内的 Tailwind 类');
|
|
216
210
|
|
|
217
211
|
const areas = [...new Set(['root', ...(options.areas ?? [])])];
|
|
218
212
|
const areaSet = new Set<string>(areas);
|
|
219
213
|
const extraTokens = splitCandidateTokens([baseRootClass, ...(options.candidates ?? [])]);
|
|
220
214
|
for (const tok of extraTokens) {
|
|
221
215
|
const bad = checkClasses(tok, `${options.kind}.candidates`);
|
|
222
|
-
if (bad.length > 0)
|
|
216
|
+
if (bad.length > 0) kitFail('KIT-COMP-003', `${options.kind}.candidates`, `${options.kind} 的 candidates 含非法类 "${tok}":${bad[0]!.message}`, '候选类只能用刻度内的 Tailwind 类,不写方括号任意值');
|
|
223
217
|
}
|
|
224
218
|
|
|
225
219
|
return defineKitBizComponent({
|
|
@@ -231,15 +225,7 @@ export function composeKitBizComponents(options: ComposeBizOptions): KitBizDefin
|
|
|
231
225
|
const diagnostics: KitDiagnostic[] = [];
|
|
232
226
|
const areaMap = input.areaClass ?? {};
|
|
233
227
|
|
|
234
|
-
|
|
235
|
-
if (!areaSet.has(key)) {
|
|
236
|
-
diagnostics.push({
|
|
237
|
-
code: 'KIT-PAGE-001',
|
|
238
|
-
path: `product.areaClass.${key}`,
|
|
239
|
-
message: `areaClass 里的区域名 "${key}" 不在 ${options.kind} 的区域闭集 ${areas.join(' / ')} 内`,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
228
|
+
validateBizAreaClass(input, options.kind, areas, diagnostics);
|
|
243
229
|
if (input.overlays !== undefined && overlayOwnerCount === 0) {
|
|
244
230
|
diagnostics.push({
|
|
245
231
|
code: 'KIT-BIZ-003',
|
package/src/biz/define.ts
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
// 业务组件的 kind 必须是 PascalCase;roles 至少一个必填角色;areas 不得重名。
|
|
3
3
|
|
|
4
4
|
import type { KitBizDefinition } from './types';
|
|
5
|
+
import { kitFail } from '../compile/kit-error';
|
|
5
6
|
|
|
6
7
|
const KIND = /^[A-Z][A-Za-z0-9]*$/;
|
|
7
8
|
|
|
8
9
|
export function defineKitBizComponent(def: KitBizDefinition): KitBizDefinition {
|
|
9
10
|
if (!KIND.test(def.kind)) {
|
|
10
|
-
|
|
11
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}`, `业务组件名必须是 PascalCase,收到 "${def.kind}"`, '改成大写字母开头的驼峰名,如 OrderBoard');
|
|
11
12
|
}
|
|
12
13
|
const roles = Object.entries(def.roles);
|
|
13
14
|
if (roles.length === 0 || !roles.some(([, r]) => r.required)) {
|
|
14
|
-
|
|
15
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}.roles`, `业务组件 ${def.kind} 至少要有一个必填的对象角色槽`, 'roles 里至少有一个 required: true 的角色');
|
|
15
16
|
}
|
|
16
17
|
if (new Set(def.areas).size !== def.areas.length) {
|
|
17
|
-
|
|
18
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}.areas`, `业务组件 ${def.kind} 的 areas 有重名`, 'areas 里每个区域名只写一次');
|
|
18
19
|
}
|
|
19
20
|
if (typeof def.compile !== 'function') {
|
|
20
|
-
|
|
21
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}.compile`, `业务组件 ${def.kind} 缺 compile()`, '提供 compile(input, ctx) 返回片段');
|
|
21
22
|
}
|
|
22
23
|
return def;
|
|
23
24
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// 对象角色槽 target(必填):{ schema, behavior: { write }, title? }——导入目标:字段字典就是映射目标(rules.required 的字段为必映射),
|
|
4
4
|
// write 是逐行新增的写接口;不写 view(界面由模板写死)
|
|
5
|
-
// job(可选):只读展示对象,放在结果步里,常用 AsyncResultPanel
|
|
5
|
+
// job(可选):只读展示对象,放在结果步里,常用 AsyncResultPanel 接服务端的后台任务
|
|
6
6
|
// 上传 Upload 选一个 CSV(首行表头),浏览器内解析,不上传原文件
|
|
7
7
|
// 映射 FieldMapper:目标字段 <- 文件列;表头与字段 key / 名称相同的自动配上
|
|
8
8
|
// 预览校验 逐行按目标字典(rules)校验,问题行置顶并标红,可下载问题行报告;有问题的行不导入
|
|
@@ -15,10 +15,12 @@ import type { KitFieldSchema, KitObject } from '../../object-renderer/types';
|
|
|
15
15
|
import type { KitFragment } from '../../compile/fragment';
|
|
16
16
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
17
17
|
import { kitText, type KitTextKey } from '../../i18n/kit-text';
|
|
18
|
+
import { finishBizCompile, validateBizAreaClass } from '../shared/compile-helpers';
|
|
18
19
|
import { KIT_IMPORT_EVENTS, KIT_IMPORT_MIRRORS, KIT_IMPORT_STEPS, type KitImportTarget } from './hub';
|
|
20
|
+
import { ImportWizard } from './index';
|
|
19
21
|
import {
|
|
20
|
-
classesIn,
|
|
21
|
-
type
|
|
22
|
+
classesIn, isRec, mirrorPath, newParts, semanticPipe, sortMirrors,
|
|
23
|
+
type Rec,
|
|
22
24
|
} from '../link/shared';
|
|
23
25
|
import { emitReadOnlyMember, templateObjectName } from '../page-templates/shared';
|
|
24
26
|
import {
|
|
@@ -29,17 +31,6 @@ export function importWizardObjectName(pageId: string, role: string): string {
|
|
|
29
31
|
return templateObjectName(pageId, role);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
function finish(out: Parts, html: string): KitFragment {
|
|
33
|
-
return {
|
|
34
|
-
html,
|
|
35
|
-
ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
|
|
36
|
-
events: out.events,
|
|
37
|
-
components: [...out.components].sort(),
|
|
38
|
-
candidates: [...out.candidates].sort(),
|
|
39
|
-
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
34
|
function requiredOf(field: KitFieldSchema): boolean {
|
|
44
35
|
const rules = (field as unknown as { rules?: unknown }).rules;
|
|
45
36
|
return Array.isArray(rules) && rules.some((r) => isRec(r) && r.required === true);
|
|
@@ -53,7 +44,7 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
53
44
|
const rawJob = input.objects.job;
|
|
54
45
|
if (!isRec(rawTarget) || !isRec(rawTarget.schema) || Object.keys(rawTarget.schema).length === 0) {
|
|
55
46
|
fail('KIT-BIZ-001', 'ImportWizard 缺少必填对象角色槽 target(需含非空 schema:导入字段字典)', 'product.objects.target');
|
|
56
|
-
return
|
|
47
|
+
return finishBizCompile(out, '');
|
|
57
48
|
}
|
|
58
49
|
if (!isRec(rawTarget.behavior) || (rawTarget.behavior as Rec).write === undefined) {
|
|
59
50
|
fail('KIT-BIZ-001', 'ImportWizard 的 target 需含 behavior.write(逐行新增的写接口)', 'product.objects.target.behavior.write');
|
|
@@ -64,12 +55,8 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
64
55
|
if ((rawTarget.behavior as Rec)[k] !== undefined) fail('KIT-BIZ-003', `ImportWizard 的 target 不支持 behavior.${k}`, `product.objects.target.behavior.${k}`);
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 ImportWizard 的区域闭集 ${IMPORT_WIZARD_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (out.diagnostics.length > 0) return finish(out, '');
|
|
58
|
+
validateBizAreaClass(input, 'ImportWizard', IMPORT_WIZARD_AREAS, out.diagnostics);
|
|
59
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
73
60
|
|
|
74
61
|
const schema = rawTarget.schema as Record<string, KitFieldSchema>;
|
|
75
62
|
const targets: KitImportTarget[] = [];
|
|
@@ -84,7 +71,7 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
84
71
|
}
|
|
85
72
|
if (targets.length === 0) {
|
|
86
73
|
fail('KIT-BIZ-003', 'ImportWizard 的 target.schema 里没有可导入的字段(permission 不能全是 r)', 'product.objects.target.schema');
|
|
87
|
-
return
|
|
74
|
+
return finishBizCompile(out, '');
|
|
88
75
|
}
|
|
89
76
|
|
|
90
77
|
const ids = importWizardIds(ctx.pageId);
|
|
@@ -112,11 +99,15 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
112
99
|
let job = '';
|
|
113
100
|
if (rawJob !== undefined) {
|
|
114
101
|
const m = emitReadOnlyMember(out, rawJob, {
|
|
115
|
-
object: importWizardObjectName(ctx.pageId, 'job'),
|
|
102
|
+
object: importWizardObjectName(ctx.pageId, 'job'),
|
|
103
|
+
path: 'product.objects.job',
|
|
104
|
+
roleName: 'job',
|
|
105
|
+
roleDef: ImportWizard.roles.job,
|
|
106
|
+
ctx,
|
|
116
107
|
});
|
|
117
108
|
job = m?.html ?? '';
|
|
118
109
|
}
|
|
119
|
-
if (out.diagnostics.length > 0) return
|
|
110
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
120
111
|
|
|
121
112
|
// ---- 链接作用域:focus 归 KitImportHub
|
|
122
113
|
const mirrors: SomaScopeMirrorDecl[] = [];
|
|
@@ -124,7 +115,7 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
124
115
|
for (let i = 0; i < KIT_IMPORT_STEPS; i += 1) { add(M.at(i)); add(M.past(i)); add(M.fut(i)); }
|
|
125
116
|
for (const x of [
|
|
126
117
|
M.files, M.parseError, M.fileInfo, M.upReady, M.upBlocked, M.mapData, M.mapReady, M.mapBlocked, M.summary, M.preview,
|
|
127
|
-
M.hasErrors, M.commitReady, M.commitBlocked, M.busy, M.notBusy, M.result,
|
|
118
|
+
M.hasErrors, M.commitReady, M.commitBlocked, M.cancelReady, M.cancelBlocked, M.busy, M.notBusy, M.result,
|
|
128
119
|
]) add(x);
|
|
129
120
|
out.scopes[link] = {
|
|
130
121
|
id: link,
|
|
@@ -149,6 +140,8 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
149
140
|
out.show[ids.btnGate('pre_download')] = { when: at(M.hasErrors.key) };
|
|
150
141
|
out.show[ids.btnGate('pre_commit')] = { when: at(M.commitReady.key) };
|
|
151
142
|
out.show[ids.btnGate('pre_commit', true)] = { when: at(M.commitBlocked.key) };
|
|
143
|
+
out.show[ids.btnGate('cancel')] = { when: at(M.cancelReady.key) };
|
|
144
|
+
out.show[ids.btnGate('cancel', true)] = { when: at(M.cancelBlocked.key) };
|
|
152
145
|
|
|
153
146
|
// ---- 各步组件与按钮
|
|
154
147
|
const T = (key: KitTextKey): string => kitText(key, undefined, ctx.locale);
|
|
@@ -189,6 +182,9 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
189
182
|
wire(ids.btn('pre_commit'), KIT_IMPORT_EVENTS.commit);
|
|
190
183
|
|
|
191
184
|
out.show[`${ids.progress}_text`] = { props: { value: at(M.summary.key), size: 'sm' } };
|
|
185
|
+
btn(ids.btn('cancel'), T('soma.kit.cancel'), 'neutral');
|
|
186
|
+
btn(ids.btn('cancel', true), T('soma.kit.cancel'), 'neutral', true);
|
|
187
|
+
wire(ids.btn('cancel'), KIT_IMPORT_EVENTS.cancel);
|
|
192
188
|
out.show[ids.result] = { props: { data: at(M.result.key) } };
|
|
193
189
|
out.events[`${ids.result}.action`] = semanticPipe(link, KIT_IMPORT_EVENTS.result);
|
|
194
190
|
|
|
@@ -200,5 +196,5 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
200
196
|
const html = importWizardHtml(ids, { title, job }, areaClass, input.class, ctx.locale);
|
|
201
197
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
202
198
|
for (const c of Object.values(IMPORT_WIZARD_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
203
|
-
return
|
|
199
|
+
return finishBizCompile(out, html);
|
|
204
200
|
}
|