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
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
// emitEvents:IR + 动作表 -> `_event.yaml` 片段(设计稿 §4.4)。输出是对象树,键 = selector,值 =
|
|
1
|
+
// emitEvents:IR + 动作表 -> `_event.yaml` 片段(设计稿 §4.4)。输出是对象树,键 = selector,值 = 单条管道串(core 只认这一种叶子);
|
|
2
2
|
// 行模板内的事件嵌套在行数组锚点之下(与 `_ui.yaml` 的 bind 层级一一对应,手册 1.4)。
|
|
3
|
+
// 页面不留编排:一个事件键只绑一条管道,没有 steps、没有按载荷分流、没有「动作之后再做 X」。多动作组件(行操作、批量条、
|
|
4
|
+
// 表单底栏、右键菜单)每个动作各抛各的槽位事件 `<事件名>_<序号>`(见 base/action-slots.ts),这里给每个槽位各绑自己的管道。
|
|
5
|
+
// 需要顺序的事(请求 → 提示 → 重取)写成展示对象方法(async/await + ctx)或具名动作处理函数。
|
|
3
6
|
//
|
|
4
7
|
// ── G15 静态核实结论(裁决 Q2,D 组必报):走「KitTableActions」退路,不走「行内按钮 + SCOPE set focus from:row」──
|
|
5
8
|
// 读 core 源码得到两条硬阻塞:
|
|
@@ -12,21 +15,27 @@
|
|
|
12
15
|
// 行内路由用 `ACTION | 名字`(emit 载荷原样透传含 `row`,event-engine.ts:529-538)。「把行写进区域切片」交给
|
|
13
16
|
// 具名动作 / 第 3 层业务组件去做(它们在页面级拿得到 `services.region`),D 组不发射行内 SCOPE set。
|
|
14
17
|
//
|
|
15
|
-
//
|
|
18
|
+
// 多个行操作各抛各的槽位事件 `row_action_<序号>`(序号 = 动作在组件 actions 数组里的位置),每个动作各绑一条管道。
|
|
16
19
|
|
|
17
20
|
import type { KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitObjectIR, KitViewOnValue } from './types';
|
|
21
|
+
import { hintOf, nameSuggestion } from '../compile/hints';
|
|
18
22
|
import { filterAnchor, headAnchor, pagerAnchor } from './compile-data';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
23
|
+
import { registerSliceReload } from './filter-reload';
|
|
24
|
+
import { KIT_ACTION_SLOT_BASE, actionSlotEvent, actionSlotOverflow } from '../base/action-slots';
|
|
25
|
+
import { checkRequestFieldMapping, isRequestLikeAction, registerRequestAction } from './request-actions';
|
|
26
|
+
import { isValidBuiltinName, isValidPermissionCode, formatBuiltinInvalidMessage, formatPermissionInvalidMessage } from '../shared/action-field-guard';
|
|
27
|
+
import { checkKitConfirmObject, checkKitConfirmText, confirmScopeOfAction, confirmSegmentOfText, confirmToneOfAction, isConfirmObject } from '../shared/confirm-decl';
|
|
28
|
+
import { classifyEventBinding } from './view-binding';
|
|
29
|
+
export { checkRequestFieldMapping };
|
|
30
|
+
import { cellAnchor, collectionMetaOf, ctxMenuAnchor, expandCellAnchor, expandToggleAnchor, metaAnchor, opsAnchor, rowsAnchor, selAnchor, staticCtxAnchor, stateAnchor, toolbarAnchor, toolsAnchor, treeAnchor, viewAnchor, virtualAnchor } from './emit-static';
|
|
24
31
|
|
|
25
32
|
export interface KitEventOptions {
|
|
26
33
|
/** behavior.actions 全表(解析 cell.action 与工具栏动作) */
|
|
27
34
|
actions?: readonly KitAction[];
|
|
28
35
|
/** 对象是否声明了 write(可编辑 form 才发 `data.submit`) */
|
|
29
36
|
hasWrite: boolean;
|
|
37
|
+
/** 对象有读来源 behavior.from:独立(非弹窗)表单冲突后的「刷新」据此接作用域重取 */
|
|
38
|
+
hasFrom?: boolean;
|
|
30
39
|
/** 当前对象名:request / download 动作按「对象 + 动作 id」命名自己的语义事件与合成写对象 */
|
|
31
40
|
object?: string;
|
|
32
41
|
/** 对象的主键字段名(空串 = 没有 key: true 字段);request.into 按行分槽时核对 key 必须是它 */
|
|
@@ -56,15 +65,36 @@ export interface KitEventEmit {
|
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
const BUILTIN_PREFIX = 'kit.';
|
|
68
|
+
export const KIT_ACTION_TONES: readonly string[] = ['primary', 'neutral', 'danger', 'ghost', 'tonal', 'info', 'success', 'warning'];
|
|
59
69
|
|
|
60
70
|
function permissionOf(action: KitAction, at: string, diagnostics: KitDiagnostic[]): string | null {
|
|
61
|
-
const p = action.permission;
|
|
71
|
+
const p = action.permission as unknown;
|
|
62
72
|
if (p === undefined) return null;
|
|
63
|
-
if (
|
|
64
|
-
diagnostics.push({
|
|
73
|
+
if (typeof p !== 'string') {
|
|
74
|
+
diagnostics.push({
|
|
75
|
+
code: Array.isArray(p) ? 'KIT-OBJ-006' : 'KIT-ACT-010',
|
|
76
|
+
message: Array.isArray(p)
|
|
77
|
+
? `动作 ${action.id ?? ''} 的 permission 写成数组:kit 层每个动作只允许一个权限码`
|
|
78
|
+
: `动作 ${action.id ?? ''} 的 permission 必须是字符串(收到 ${typeof p})`,
|
|
79
|
+
path: `${at}.permission`,
|
|
80
|
+
});
|
|
65
81
|
return null;
|
|
66
82
|
}
|
|
67
|
-
|
|
83
|
+
if (p === '') return null;
|
|
84
|
+
if (!isValidPermissionCode(p)) {
|
|
85
|
+
diagnostics.push({
|
|
86
|
+
code: 'KIT-ACT-010',
|
|
87
|
+
message: formatPermissionInvalidMessage(p, `动作 ${action.id ?? ''} 的 permission`),
|
|
88
|
+
path: `${at}.permission`,
|
|
89
|
+
});
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return p;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 事件绑展示对象方法的管道(动作 submit: view.<方法>、view.on / 浮层 events 的 view.<方法> 共用):UI_REFRESH | page.<方法>,载荷(组件 emit 的载荷 / 行动作信息)交方法第二参 */
|
|
96
|
+
export function viewMethodPipe(method: string): string {
|
|
97
|
+
return `UI_REFRESH | page.${method}`;
|
|
68
98
|
}
|
|
69
99
|
|
|
70
100
|
/** 一个动作 -> 管道串;失败返回 null 并记诊断 */
|
|
@@ -74,18 +104,90 @@ export function actionPipeline(
|
|
|
74
104
|
options: KitEventOptions,
|
|
75
105
|
diagnostics: KitDiagnostic[],
|
|
76
106
|
): string | null {
|
|
107
|
+
if (action === null || typeof action !== 'object') {
|
|
108
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: at, message: '动作必须是对象' });
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
if (action.id !== undefined && typeof action.id !== 'string') {
|
|
112
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.id`, message: `动作 id 必须是字符串(收到 ${typeof action.id})` });
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
if (action.name !== undefined && typeof action.name !== 'string') {
|
|
116
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.name`, message: `动作 name 必须是字符串(收到 ${typeof action.name})` });
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
if (action.on !== undefined && typeof action.on !== 'string') {
|
|
120
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.on`, message: `动作 on 必须是字符串(收到 ${typeof action.on})` });
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (action.tone !== undefined) {
|
|
124
|
+
if (typeof action.tone !== 'string' || !KIT_ACTION_TONES.includes(action.tone)) {
|
|
125
|
+
diagnostics.push({
|
|
126
|
+
code: 'KIT-ACT-010',
|
|
127
|
+
path: `${at}.tone`,
|
|
128
|
+
message: `动作 ${action.id ?? ''} 的 tone "${String(action.tone)}" 不在闭集(允许:${KIT_ACTION_TONES.join(' / ')})`,
|
|
129
|
+
});
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (action.submit !== undefined && typeof action.submit !== 'string') {
|
|
134
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.submit`, message: `动作 ${action.id ?? ''} 的 submit 必须是字符串(收到 ${typeof action.submit})` });
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
if (action.builtin !== undefined) {
|
|
138
|
+
if (typeof action.builtin !== 'string') {
|
|
139
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.builtin`, message: `动作 ${action.id ?? ''} 的 builtin 必须是字符串(收到 ${typeof action.builtin})` });
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (action.builtin !== '' && !isValidBuiltinName(action.builtin)) {
|
|
143
|
+
diagnostics.push({
|
|
144
|
+
code: 'KIT-ACT-010',
|
|
145
|
+
path: `${at}.builtin`,
|
|
146
|
+
message: formatBuiltinInvalidMessage(action.builtin, `动作 ${action.id ?? ''} 的 builtin`),
|
|
147
|
+
});
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
let confirmSegment: string | undefined;
|
|
152
|
+
if (action.confirm !== undefined) {
|
|
153
|
+
if (isConfirmObject(action.confirm)) {
|
|
154
|
+
// 对象形(字面量版):编成 core 的结构化确认段 confirm:{…JSON};规则与诊断在 shared/confirm-decl(判据是 core 的 checkConfirmSpec)
|
|
155
|
+
const checked = checkKitConfirmObject(action.confirm, confirmScopeOfAction(action.on), confirmToneOfAction(action));
|
|
156
|
+
if (!checked.ok) {
|
|
157
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.confirm`, message: `动作 ${action.id ?? ''} 的 confirm:${checked.error}` });
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
confirmSegment = checked.segment;
|
|
161
|
+
} else if (typeof action.confirm !== 'string') {
|
|
162
|
+
diagnostics.push({ code: 'KIT-ACT-010', path: `${at}.confirm`, message: `动作 ${action.id ?? ''} 的 confirm 必须是字符串或 { level, text, phrase?, impact? } 对象(收到 ${Array.isArray(action.confirm) ? 'array' : typeof action.confirm})` });
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
if (typeof action.confirm === 'string') {
|
|
166
|
+
const problem = checkKitConfirmText(action.confirm, confirmScopeOfAction(action.on));
|
|
167
|
+
if (problem !== null) {
|
|
168
|
+
diagnostics.push({ code: 'KIT-ACT-010', message: `动作 ${action.id} 的 confirm ${problem}`, path: `${at}.confirm` });
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
77
174
|
let name: string;
|
|
78
175
|
let segments: string[] = [];
|
|
176
|
+
const submitEvt = classifyEventBinding(action.submit, 'submit');
|
|
79
177
|
if (isRequestLikeAction(action)) {
|
|
80
178
|
name = '';
|
|
81
179
|
// 声明式请求 / 下载:编成交页面级 KitActionHost 的语义事件(尾段 confirm / permission 与其它动作同口径)
|
|
82
180
|
const base = registerRequestAction(action, options.object ?? '', at, diagnostics, options.keyField === undefined ? {} : { keyField: options.keyField });
|
|
83
181
|
if (base === null) return null;
|
|
84
182
|
segments = base.split(' | ');
|
|
183
|
+
} else if (submitEvt.kind === 'method') {
|
|
184
|
+
// 事件绑展示对象方法(submit: view.<方法>):编成 UI_REFRESH | page.<方法>,载荷(行 / 动作信息)交方法第二参;方法是否登记由 compile/view-check 核(KIT-VIEW-002 / 004)
|
|
185
|
+
name = '';
|
|
186
|
+
segments = viewMethodPipe(submitEvt.name).split(' | ');
|
|
85
187
|
} else if (action.submit !== undefined && action.submit !== '') {
|
|
86
188
|
name = action.submit;
|
|
87
189
|
if (options.registeredActions !== undefined && !options.registeredActions.has(name)) {
|
|
88
|
-
diagnostics.push({ code: 'KIT-EVT-001', message: `动作 ${action.id} 的 submit "${name}" 未在应用的具名动作中登记`, path: `${at}.submit
|
|
190
|
+
diagnostics.push({ code: 'KIT-EVT-001', message: `动作 ${action.id} 的 submit "${name}" 未在应用的具名动作中登记`, path: `${at}.submit`, ...hintOf(nameSuggestion(name, options.registeredActions)) });
|
|
89
191
|
return null;
|
|
90
192
|
}
|
|
91
193
|
} else if (action.builtin !== undefined && action.builtin !== '') {
|
|
@@ -94,19 +196,15 @@ export function actionPipeline(
|
|
|
94
196
|
diagnostics.push({ code: 'KIT-EVT-001', message: `动作 ${action.id} 既没有 submit / builtin,也没有 request / download`, path: at });
|
|
95
197
|
return null;
|
|
96
198
|
}
|
|
97
|
-
if (!isRequestLikeAction(action)) segments = ['ACTION', name];
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
segments.push(`confirm:${action.confirm}`);
|
|
199
|
+
if (!isRequestLikeAction(action) && segments.length === 0) segments = ['ACTION', name];
|
|
200
|
+
if (confirmSegment !== undefined) segments.push(confirmSegment);
|
|
201
|
+
else if (typeof action.confirm === 'string' && action.confirm !== '') {
|
|
202
|
+
segments.push(confirmSegmentOfText(action.confirm, confirmToneOfAction(action)));
|
|
104
203
|
}
|
|
105
204
|
const permission = permissionOf(action, at, diagnostics);
|
|
106
205
|
if (permission !== null) segments.push(`permission:${permission}`);
|
|
107
206
|
return segments.join(' | ');
|
|
108
207
|
}
|
|
109
|
-
|
|
110
208
|
/** view.on 内置角色 -> 协调组件语义事件(与 overlayEventRoles.conventional 同口径;cancel 等同 close) */
|
|
111
209
|
const VIEW_ON_ROLE_SEMANTIC: Readonly<Record<string, string>> = {
|
|
112
210
|
saved: KIT_SAVED_SEMANTIC,
|
|
@@ -117,7 +215,7 @@ const VIEW_ON_ROLE_SEMANTIC: Readonly<Record<string, string>> = {
|
|
|
117
215
|
/** 纯顺序载荷的 core 内置动作(Kanban 的 move 原样透传) */
|
|
118
216
|
const VIEW_ON_ORDER_MOVE = 'data.orderMove';
|
|
119
217
|
|
|
120
|
-
/** view.on 一项 ->
|
|
218
|
+
/** view.on 一项 -> 事件值(单条管道串);动作未登记返回 null 并记 KIT-EVT-001 */
|
|
121
219
|
function viewOnEvent(
|
|
122
220
|
value: KitViewOnValue,
|
|
123
221
|
scope: string,
|
|
@@ -128,18 +226,21 @@ function viewOnEvent(
|
|
|
128
226
|
const actionPipe = (name: string, path: string): string | null => {
|
|
129
227
|
if (name === VIEW_ON_ORDER_MOVE) return `ACTION | ${VIEW_ON_ORDER_MOVE}`;
|
|
130
228
|
if (options.registeredActions !== undefined && !options.registeredActions.has(name)) {
|
|
131
|
-
diagnostics.push({ code: 'KIT-EVT-001', message: `view.on 的动作 "${name}" 未在应用的具名动作中登记(也不是 data.orderMove / reload / saved / cancel)`, path });
|
|
229
|
+
diagnostics.push({ code: 'KIT-EVT-001', message: `view.on 的动作 "${name}" 未在应用的具名动作中登记(也不是 data.orderMove / reload / saved / cancel)`, path, ...hintOf(nameSuggestion(name, options.registeredActions)) });
|
|
132
230
|
return null;
|
|
133
231
|
}
|
|
134
232
|
return `ACTION | ${name}`;
|
|
135
233
|
};
|
|
136
|
-
// GA1:值写 behavior.actions 里 request / download 动作的 id
|
|
137
|
-
//
|
|
234
|
+
// GA1:值写 behavior.actions 里 request / download 动作的 id;
|
|
235
|
+
// 页面级宿主执行(写操作请求成功后宿主固定重取)
|
|
138
236
|
const requestLike = (name: string): KitAction | undefined => {
|
|
139
237
|
if (!Object.prototype.hasOwnProperty.call(VIEW_ON_ROLE_SEMANTIC, name)) return options.actions?.find((a) => a.id === name && isRequestLikeAction(a));
|
|
140
238
|
return undefined;
|
|
141
239
|
};
|
|
142
240
|
if (typeof value === 'string') {
|
|
241
|
+
// view.<方法>:组件抛出的事件调展示对象方法(载荷 = 组件 emit 的载荷);组件事件不经具名动作、不写数据,方法里要写请求走 ctx.request / ctx.action
|
|
242
|
+
const evt = classifyEventBinding(value, at);
|
|
243
|
+
if (evt.kind === 'method') return viewMethodPipe(evt.name);
|
|
143
244
|
const hit = requestLike(value);
|
|
144
245
|
if (hit !== undefined) return actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
|
|
145
246
|
// 只认自有键:动作名叫 constructor / toString 时不能命中原型上的函数
|
|
@@ -148,58 +249,29 @@ function viewOnEvent(
|
|
|
148
249
|
return actionPipe(value, at);
|
|
149
250
|
}
|
|
150
251
|
const hitObj = requestLike(value.action);
|
|
151
|
-
if (hitObj !== undefined) {
|
|
152
|
-
|
|
153
|
-
diagnostics.push({ code: 'KIT-ACT-003', path: `${at}.then`, message: `view.on 接的 ${hitObj.id} 是 request / download 动作,由页面级宿主异步执行,不能再写 then(刷新写 request.then)` });
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
return actionPipeline(hitObj, `behavior.actions.${hitObj.id}`, options, diagnostics);
|
|
157
|
-
}
|
|
158
|
-
const first = actionPipe(value.action, `${at}.action`);
|
|
159
|
-
if (first === null) return null;
|
|
160
|
-
const steps: Array<{ do: string }> = [{ do: first }];
|
|
161
|
-
if (value.then !== undefined) steps.push({ do: `SCOPE | semantic | ${scope} | ${VIEW_ON_ROLE_SEMANTIC[value.then]!}` });
|
|
162
|
-
return { steps };
|
|
252
|
+
if (hitObj !== undefined) return actionPipeline(hitObj, `behavior.actions.${hitObj.id}`, options, diagnostics);
|
|
253
|
+
return actionPipe(value.action, `${at}.action`);
|
|
163
254
|
}
|
|
164
255
|
|
|
165
256
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
257
|
+
* 一组多按钮动作 -> 槽位事件绑定:第 i 个动作的管道绑在 `<key(槽位基名)>_<i>` 上(序号 = 动作在组件 actions 数组里的位置)。
|
|
258
|
+
* 动作写不对(诊断已记)的槽位留空;动作数超过槽位上限报 KIT-EVT-001。返回是否绑了至少一个。
|
|
259
|
+
* 业务组件(standard-crud 等)整段改写行操作时也用它。
|
|
168
260
|
*/
|
|
169
|
-
export function
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
export function actionEvent(pipe: string, action: KitAction, scope: string): string | { steps: Array<{ do: string }> } {
|
|
177
|
-
const after = actionThenPipes(action, scope);
|
|
178
|
-
return after.length === 0 ? pipe : { steps: [{ do: pipe }, ...after.map((p) => ({ do: p }))] };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** 行操作 steps 的前置条件:动作判别 + 可选的行条件 when(业务组件自己拼 steps 时也用它) */
|
|
182
|
-
export function rowActionGate(a: KitAction): Record<string, unknown> {
|
|
183
|
-
const base = { field: 'kit_action', op: 'eq', value: a.id };
|
|
184
|
-
const cond = a.when === undefined ? null : predicateToCore(a.when, 'when', null, []);
|
|
185
|
-
return cond === null ? base : { all_of: [base, rowPredicate(cond)] };
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function rowActionEvent(actions: readonly KitAction[], at: string, options: KitEventOptions, diagnostics: KitDiagnostic[], scope: string): unknown | null {
|
|
189
|
-
const steps: Array<Record<string, unknown>> = [];
|
|
261
|
+
export function bindActionSlots(
|
|
262
|
+
target: Record<string, unknown>, key: (event: string) => string, base: string,
|
|
263
|
+
actions: readonly KitAction[], at: string, options: KitEventOptions, diagnostics: KitDiagnostic[],
|
|
264
|
+
): boolean {
|
|
265
|
+
const overflow = actionSlotOverflow(actions.length, at);
|
|
266
|
+
if (overflow !== null) diagnostics.push({ code: 'KIT-EVT-001', message: overflow, path: at });
|
|
267
|
+
let bound = false;
|
|
190
268
|
actions.forEach((a, i) => {
|
|
191
269
|
const pipe = actionPipeline(a, `${at}[${i}]`, options, diagnostics);
|
|
192
270
|
if (pipe === null) return;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const cond = a.when === undefined ? null : predicateToCore(a.when, `${at}[${i}].when`, null, []);
|
|
196
|
-
const when = cond === null ? base : { all_of: [base, rowPredicate(cond)] };
|
|
197
|
-
steps.push({ when, do: pipe });
|
|
198
|
-
for (const p of actionThenPipes(a, scope)) steps.push({ when, do: p });
|
|
271
|
+
target[key(actionSlotEvent(base, i))] = pipe;
|
|
272
|
+
bound = true;
|
|
199
273
|
});
|
|
200
|
-
|
|
201
|
-
// 只有一个动作时也保留 when:载荷 id 不匹配就什么都不做,行为与多动作一致
|
|
202
|
-
return { steps };
|
|
274
|
+
return bound;
|
|
203
275
|
}
|
|
204
276
|
|
|
205
277
|
function collectCells(layout: KitLayoutIR): KitCell[] {
|
|
@@ -230,6 +302,30 @@ function rowActionsOf(layout: KitLayoutIR): readonly KitAction[] {
|
|
|
230
302
|
return layout.kind === 'table' || layout.kind === 'cards' || layout.kind === 'stack' ? layout.rowActions : [];
|
|
231
303
|
}
|
|
232
304
|
|
|
305
|
+
/** 一个对象渲染出的各处行动作组件里,动作 id 的排列(= 组件 actions / menu prop 的顺序,槽位序号取它的位置);业务组件改写行动作事件时按它取槽位 */
|
|
306
|
+
export interface KitRowActionSlots {
|
|
307
|
+
/** 行操作列 / 虚拟滚动表 / 树表的行操作 */
|
|
308
|
+
rows: string[];
|
|
309
|
+
/** 表格 / 卡片 / 堆叠集合的右键菜单 */
|
|
310
|
+
menu: string[];
|
|
311
|
+
/** 写死形状行视图(ItemList / Tree / Kanban)各槽位的右键菜单 */
|
|
312
|
+
staticMenus: Partial<Record<'list' | 'summary' | 'filter' | 'form', string[]>>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export function rowActionSlotsOf(ir: KitObjectIR): KitRowActionSlots {
|
|
316
|
+
const out: KitRowActionSlots = { rows: [], menu: [], staticMenus: {} };
|
|
317
|
+
const list = ir.views.list?.layout;
|
|
318
|
+
if (list !== undefined) {
|
|
319
|
+
out.rows = rowActionsOf(list).map((a) => a.id);
|
|
320
|
+
if (list.kind === 'table' || list.kind === 'cards' || list.kind === 'stack') out.menu = (list.contextMenu ?? []).map((a) => a.id);
|
|
321
|
+
}
|
|
322
|
+
for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
|
|
323
|
+
const layout = ir.views[slot]?.layout;
|
|
324
|
+
if (layout !== undefined && layout.kind === 'static' && (layout.contextMenu ?? []).length > 0) out.staticMenus[slot] = layout.contextMenu!.map((a) => a.id);
|
|
325
|
+
}
|
|
326
|
+
return out;
|
|
327
|
+
}
|
|
328
|
+
|
|
233
329
|
export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEventEmit {
|
|
234
330
|
const object = ir.object;
|
|
235
331
|
const options: KitEventOptions = rawOptions.object === undefined ? { ...rawOptions, object } : rawOptions;
|
|
@@ -238,105 +334,60 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
238
334
|
const events: Record<string, unknown> = {};
|
|
239
335
|
const all = options.actions ?? [];
|
|
240
336
|
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
const surfaces = new Map<string, KitGateSurface>();
|
|
244
|
-
for (const a of all) {
|
|
245
|
-
if (a.on === 'row') surfaces.set(a.id, 'row');
|
|
246
|
-
else if (a.on === 'toolbar') surfaces.set(a.id, 'toolbar');
|
|
247
|
-
}
|
|
248
|
-
for (const id of ir.views.form?.formOpts?.footerActions ?? []) if (!surfaces.has(id)) surfaces.set(id, 'footer');
|
|
249
|
-
checkActionGates(all, surfaces, null, diagnostics);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// 筛选:提交与重置都是「写 filter 切片 + 重取」;重置时组件抛空 values
|
|
337
|
+
// 筛选:提交与重置都只写 filter 切片(单管道;重置时组件抛空 values);
|
|
338
|
+
// 「切片一变就重取」登记给页面级宿主(它订阅 filter 切片,等一拍让分页器回第 1 页后再重取),不再靠第二步 window-reload
|
|
253
339
|
if (ir.views.filter !== undefined && ir.views.filter.layout.kind !== 'static') {
|
|
254
340
|
const id = filterAnchor(object);
|
|
255
|
-
const apply = {
|
|
256
|
-
steps: [
|
|
257
|
-
{ do: `SCOPE | set | ${scope} | filter | from:values` },
|
|
258
|
-
{ do: `SCOPE | window-reload | ${scope}` },
|
|
259
|
-
],
|
|
260
|
-
};
|
|
341
|
+
const apply = `SCOPE | set | ${scope} | filter | from:values`;
|
|
261
342
|
events[`${id}.submit`] = apply;
|
|
262
343
|
events[`${id}.reset`] = apply;
|
|
344
|
+
registerSliceReload({ scope, slice: 'filter', reload: [{ scope }] });
|
|
345
|
+
// 集合的「清除筛选」兜底(空态面板 / 标题旁提示;优先点筛选栏自己的「重置」,找不到才抛 clear_filter):同一条 SCOPE | set filter 管道,不直调数据写入
|
|
346
|
+
const listLayout = ir.views.list?.layout;
|
|
347
|
+
if (listLayout !== undefined && (listLayout.kind === 'table' || listLayout.kind === 'cards' || listLayout.kind === 'stack')) {
|
|
348
|
+
events[`${stateAnchor(object)}.clear_filter`] = apply;
|
|
349
|
+
if (collectionMetaOf(ir)?.hint === true) events[`${metaAnchor(object)}.clear_filter`] = apply;
|
|
350
|
+
}
|
|
263
351
|
}
|
|
264
352
|
|
|
265
353
|
// 可编辑表单:提交走内置 data.submit,载荷由 KitObjectForm 自己组装 { object, model, mode, scope }
|
|
266
354
|
const form = ir.views.form;
|
|
267
355
|
if (form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show' && options.hasWrite) {
|
|
268
356
|
events[`${viewAnchor(object, 'form')}.submit`] = 'ACTION | data.submit';
|
|
269
|
-
//
|
|
270
|
-
|
|
271
|
-
if (after !== undefined && after.length > 0) {
|
|
272
|
-
events[`${viewAnchor(object, 'form')}.saved`] = { steps: thenPipes(after, scope).map((p) => ({ do: p })) };
|
|
273
|
-
}
|
|
357
|
+
// 冲突后的「刷新」:表单的 initial 绑对象值时由宿主重取该作用域的对象(弹窗表单由 wireDialogForm 在其后改写为协调组件语义管道)
|
|
358
|
+
if (options.hasFrom === true) events[`${viewAnchor(object, 'form')}.reload`] = `SCOPE | window-reload | ${scope}`;
|
|
274
359
|
}
|
|
275
360
|
|
|
276
|
-
//
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (footerIds.length > 0) {
|
|
280
|
-
const steps: Array<{ when: Record<string, unknown>; do: string }> = [];
|
|
281
|
-
for (const aid of footerIds) {
|
|
282
|
-
const a = all.find((x) => x.id === aid);
|
|
283
|
-
if (a === undefined || !isRequestLikeAction(a)) {
|
|
284
|
-
diagnostics.push({ code: 'KIT-EVT-001', message: `footerActions 的 "${aid}" 不是本对象 behavior.actions 里的 request / download 动作`, path: 'views.form.footerActions' });
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
const pipe = actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
|
|
288
|
-
if (pipe !== null) steps.push({ when: { field: 'id', op: 'eq', value: aid }, do: pipe });
|
|
289
|
-
}
|
|
290
|
-
if (steps.length > 0) events[`${viewAnchor(object, 'form')}.footer_action`] = { steps };
|
|
361
|
+
// 展示对象方法:表单草稿变化(draft_change,载荷 { values, dirty })-> UI_REFRESH | page.<方法>;方法改写展示对象成员,页面经路径绑定被动刷新
|
|
362
|
+
if (form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show' && form.formOpts?.onDraft !== undefined) {
|
|
363
|
+
events[`${viewAnchor(object, 'form')}.draft_change`] = `UI_REFRESH | page.${form.formOpts.onDraft}`;
|
|
291
364
|
}
|
|
292
|
-
|
|
293
|
-
//
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
298
|
-
diagnostics.push({ code: 'KIT-
|
|
299
|
-
} else if (hit.on !== undefined) {
|
|
300
|
-
diagnostics.push({ code: 'KIT-FORM-009', message: `adopt.ask 指向的动作 ${askId} 不能写 on(它只由采纳条上的钮触发,不渲染成别处的按钮)`, path: `behavior.actions.${askId}.on` });
|
|
301
|
-
} else if (hit.request.into !== form.formOpts?.adopt?.from) {
|
|
302
|
-
diagnostics.push({ code: 'KIT-FORM-009', message: `adopt.ask 的动作 ${askId} 的 request.into 必须是字符串且等于 adopt.from("${form.formOpts?.adopt?.from}"),否则采纳条收不到它的结果(采纳条没有「当前行」,不能引用按行分槽的 into)`, path: `behavior.actions.${askId}.request.into` });
|
|
303
|
-
} else {
|
|
304
|
-
const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
|
|
305
|
-
if (pipe !== null) events[`${viewAnchor(object, 'form')}.adopt_ask`] = actionEvent(pipe, hit, scope);
|
|
365
|
+
// 编辑表单底栏动作(view.form.footerActions):每个动作各抛 footer_action_<序号>(序号 = 它在表单 footerActions prop 里的位置,
|
|
366
|
+
// 即 footerActions 里存在于 behavior.actions 的那些),各绑一条 request / download 管道(交页面级宿主的语义事件)
|
|
367
|
+
const footerIds = (ir.views.form?.formOpts?.footerActions ?? []).filter((aid) => all.some((x) => x.id === aid));
|
|
368
|
+
for (const aid of ir.views.form?.formOpts?.footerActions ?? []) {
|
|
369
|
+
const a = all.find((x) => x.id === aid);
|
|
370
|
+
if (a === undefined || !isRequestLikeAction(a)) {
|
|
371
|
+
diagnostics.push({ code: 'KIT-EVT-001', message: `footerActions 的 "${aid}" 不是本对象 behavior.actions 里的 request / download 动作`, path: 'views.form.footerActions' });
|
|
306
372
|
}
|
|
307
373
|
}
|
|
374
|
+
const footerOverflow = actionSlotOverflow(footerIds.length, 'views.form.footerActions');
|
|
375
|
+
if (footerOverflow !== null) diagnostics.push({ code: 'KIT-EVT-001', message: footerOverflow, path: 'views.form.footerActions' });
|
|
376
|
+
footerIds.forEach((aid, i) => {
|
|
377
|
+
const a = all.find((x) => x.id === aid)!;
|
|
378
|
+
if (!isRequestLikeAction(a)) return;
|
|
379
|
+
const pipe = actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
|
|
380
|
+
if (pipe !== null) events[`${viewAnchor(object, 'form')}.${actionSlotEvent(KIT_ACTION_SLOT_BASE.footer, i)}`] = pipe;
|
|
381
|
+
});
|
|
308
382
|
|
|
309
|
-
// H1d
|
|
383
|
+
// H1d / 展示对象 ctx.request:不挂在按钮上的 request 动作(request.on: mount,或无 on 供展示对象触发)登记进页面级请求宿主
|
|
310
384
|
for (const a of all) {
|
|
311
|
-
if (a.request
|
|
385
|
+
if (a.request === undefined) continue;
|
|
386
|
+
if (a.request.on === undefined && (a.on !== undefined || footerIds.includes(a.id))) continue;
|
|
312
387
|
actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
|
|
313
388
|
}
|
|
314
389
|
|
|
315
|
-
//
|
|
316
|
-
const changeMap = ir.views.form?.formOpts?.onChange;
|
|
317
|
-
if (changeMap !== undefined && form !== undefined && form.layout.kind !== 'static' && form.mode !== 'show') {
|
|
318
|
-
const steps: Array<{ when: Record<string, unknown>; do: string }> = [];
|
|
319
|
-
for (const [field, aid] of Object.entries(changeMap)) {
|
|
320
|
-
const a = all.find((x) => x.id === aid);
|
|
321
|
-
const at = `view.form.onChange.${field}`;
|
|
322
|
-
if (a === undefined || a.request === undefined) {
|
|
323
|
-
diagnostics.push({ code: 'KIT-ACT-008', path: at, message: `onChange 的 "${aid}" 不是本对象 behavior.actions 里的 request 动作` });
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
if (!checkAutoTriggerable(a, `behavior.actions.${a.id}`, diagnostics)) continue;
|
|
327
|
-
const pipe = actionPipeline(a, `behavior.actions.${a.id}`, options, diagnostics);
|
|
328
|
-
if (pipe !== null) steps.push({ when: { field: 'field', op: 'eq', value: field }, do: pipe });
|
|
329
|
-
}
|
|
330
|
-
if (steps.length > 0) events[`${viewAnchor(object, 'form')}.field_change`] = { steps };
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// groups 页签(groupsAs: tabs,只读视图):点页签 = 关别的面板、开本面板(同 tabs-frame 的 UI_INTERACT)
|
|
334
|
-
for (const slot of ['summary', 'form'] as const) {
|
|
335
|
-
const v = ir.views[slot];
|
|
336
|
-
if (v === undefined || (slot === 'form' && v.mode !== 'show')) continue;
|
|
337
|
-
if (v.layout.kind !== 'groups' || v.layout.tabs !== true) continue;
|
|
338
|
-
Object.assign(events, groupTabEvents(object, slot, v.layout.groups.length));
|
|
339
|
-
}
|
|
390
|
+
// groups 页签(groupsAs: tabs,只读视图):面板显隐由 KitTabsWiring 在组件内自己切(点页签 / 键盘),不走事件声明
|
|
340
391
|
|
|
341
392
|
// 列表:分页 + 行操作 + 列内字段动作
|
|
342
393
|
const list = ir.views.list;
|
|
@@ -357,16 +408,9 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
357
408
|
if (layout.toolbar?.includes('reload') === true) events[`${tid}.reload`] = `SCOPE | window-reload | ${scope}`;
|
|
358
409
|
if (options.selectable === true && layout.select === 'multi') events[`${tid}.select_change`] = `SCOPE | semantic | ${scope} | ${KIT_SELECT_SEMANTIC}`;
|
|
359
410
|
if (options.selectable === true && (layout.batch?.length ?? 0) > 0) {
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
const pipe = actionPipeline(b.action, `views.list.batchActions[${i}]`, options, diagnostics);
|
|
364
|
-
if (pipe === null) return;
|
|
365
|
-
const when = { field: 'kit_action', op: 'eq', value: b.id };
|
|
366
|
-
steps.push({ when, do: pipe });
|
|
367
|
-
steps.push({ when, do: after });
|
|
368
|
-
});
|
|
369
|
-
if (steps.length > 0) events[`${tid}.batch_action`] = { steps };
|
|
411
|
+
// 批量动作:每个按钮各抛 batch_action_<序号>,各绑自己的管道(具名动作做完在有协调组件的页面里由 defineKitActions 固定重取)
|
|
412
|
+
const batchActs = layout.batch!.map((b) => b.action);
|
|
413
|
+
bindActionSlots(events, (n) => `${tid}.${n}`, KIT_ACTION_SLOT_BASE.batch, batchActs, 'views.list.batchActions', options, diagnostics);
|
|
370
414
|
}
|
|
371
415
|
if (layout.editMode !== undefined && layout.editMode !== null) {
|
|
372
416
|
if (options.hasWrite) events[`${tid}.cell_edit`] = 'ACTION | data.submit';
|
|
@@ -376,7 +420,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
376
420
|
const nested: Record<string, unknown> = {};
|
|
377
421
|
// 展开子表(Q 波 G5):行里的展开开关(KitTableActions)把"展开哪一行"交协调组件写 focus.expandId
|
|
378
422
|
if (layout.kind === 'table' && layout.expand?.list !== undefined && options.expandable === true) {
|
|
379
|
-
nested[`${expandToggleAnchor(object)}.
|
|
423
|
+
nested[`${expandToggleAnchor(object)}.row_expand`] = `SCOPE | semantic | ${scope} | ${KIT_EXPAND_SEMANTIC}`;
|
|
380
424
|
}
|
|
381
425
|
if (layout.kind === 'table' && layout.expand !== null && layout.expand.list === undefined) {
|
|
382
426
|
for (const cell of collectCells(layout.expand.layout)) {
|
|
@@ -387,7 +431,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
387
431
|
continue;
|
|
388
432
|
}
|
|
389
433
|
const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
|
|
390
|
-
if (pipe !== null) nested[`${expandCellAnchor(object, cell.field)}.${fieldEventName(cell.component, cell.event)}`] =
|
|
434
|
+
if (pipe !== null) nested[`${expandCellAnchor(object, cell.field)}.${fieldEventName(cell.component, cell.event)}`] = pipe;
|
|
391
435
|
}
|
|
392
436
|
}
|
|
393
437
|
// 树表:表体 KitTreeTable 是页面直接实例(不在行模板里),row_select / row_action 挂在它自己的锚点上,不嵌套在 rowsAnchor 下
|
|
@@ -398,27 +442,24 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
398
442
|
target[key('row_select')] = `SCOPE | semantic | ${scope} | ${KIT_SELECT_SEMANTIC}`;
|
|
399
443
|
}
|
|
400
444
|
const rowActions = rowActionsOf(layout);
|
|
401
|
-
if (rowActions.length > 0)
|
|
402
|
-
const ev = rowActionEvent(rowActions, 'views.list.rowActions', options, diagnostics, scope);
|
|
403
|
-
if (ev !== null) target[key('row_action')] = ev;
|
|
404
|
-
}
|
|
445
|
+
if (rowActions.length > 0) bindActionSlots(target, key, KIT_ACTION_SLOT_BASE.row, rowActions, 'views.list.rowActions', options, diagnostics);
|
|
405
446
|
};
|
|
406
447
|
// 虚拟滚动表体 KitVirtualRows 同树表:页面直接实例,事件挂在它自己的锚点上
|
|
407
448
|
const isVirtual = layout.kind === 'table' && layout.virtual !== undefined && layout.tree === null;
|
|
408
449
|
if (isTree) bodyEvents(events, (n) => `${treeAnchor(object)}.${n}`);
|
|
409
450
|
else if (isVirtual) bodyEvents(events, (n) => `${virtualAnchor(object)}.${n}`);
|
|
410
|
-
else bodyEvents(nested, (n) => (n === 'row_select' ? `${selAnchor(object)}.row_select` : `${opsAnchor(object)}
|
|
411
|
-
// 右键菜单(Q 波 G6):KitContextMenu
|
|
451
|
+
else bodyEvents(nested, (n) => (n === 'row_select' ? `${selAnchor(object)}.row_select` : `${opsAnchor(object)}.${n}`));
|
|
452
|
+
// 右键菜单(Q 波 G6):KitContextMenu 每个菜单项各抛 row_action_<序号>(序号 = 它在 menu 数组里的位置),与行操作同形、各绑一条管道。
|
|
412
453
|
// 行实例在行模板里(嵌套在 rowsAnchor 下),虚拟滚动表的实例是页面直接实例。已在 rowActions 里报过的动作诊断不重复报
|
|
413
454
|
if ((layout.kind === 'table' || layout.kind === 'cards' || layout.kind === 'stack') && (layout.contextMenu ?? []).length > 0) {
|
|
414
455
|
const ctxActions = layout.contextMenu!;
|
|
415
456
|
const known = new Set(rowActionsOf(layout).map((a) => a.id));
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
457
|
+
const ctxAt = 'views.list.contextMenu';
|
|
458
|
+
const tmp: KitDiagnostic[] = [];
|
|
459
|
+
bindActionSlots(isVirtual || isTree ? events : nested, (n) => `${ctxMenuAnchor(object)}.${n}`, KIT_ACTION_SLOT_BASE.row, ctxActions, ctxAt, options, tmp);
|
|
460
|
+
ctxActions.forEach((a, i) => {
|
|
461
|
+
if (!known.has(a.id)) diagnostics.push(...tmp.filter((d) => d.path.startsWith(`${ctxAt}[${i}]`)));
|
|
462
|
+
});
|
|
422
463
|
}
|
|
423
464
|
for (const cell of collectCells(layout)) {
|
|
424
465
|
if (cell.action === undefined || cell.component === '') continue;
|
|
@@ -428,7 +469,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
428
469
|
continue;
|
|
429
470
|
}
|
|
430
471
|
const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
|
|
431
|
-
if (pipe !== null) nested[`${cellAnchor(object, 'list', cell.field)}.${fieldEventName(cell.component, cell.event)}`] =
|
|
472
|
+
if (pipe !== null) nested[`${cellAnchor(object, 'list', cell.field)}.${fieldEventName(cell.component, cell.event)}`] = pipe;
|
|
432
473
|
}
|
|
433
474
|
if (Object.keys(nested).length > 0) events[rowsAnchor(object)] = nested;
|
|
434
475
|
}
|
|
@@ -445,7 +486,7 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
445
486
|
continue;
|
|
446
487
|
}
|
|
447
488
|
const pipe = actionPipeline(hit, `behavior.actions.${hit.id}`, options, diagnostics);
|
|
448
|
-
if (pipe !== null) events[`${cellAnchor(object, slot, cell.field)}.${fieldEventName(cell.component, cell.event)}`] =
|
|
489
|
+
if (pipe !== null) events[`${cellAnchor(object, slot, cell.field)}.${fieldEventName(cell.component, cell.event)}`] = pipe;
|
|
449
490
|
}
|
|
450
491
|
}
|
|
451
492
|
|
|
@@ -479,19 +520,26 @@ export function emitEvents(ir: KitObjectIR, rawOptions: KitEventOptions): KitEve
|
|
|
479
520
|
}
|
|
480
521
|
}
|
|
481
522
|
|
|
523
|
+
// 读失败自动重试:静态视图的错误框带重试钮(emit-static 补文案),页面没接 retry 时接重取本对象的管道
|
|
524
|
+
for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
|
|
525
|
+
const layout = ir.views[slot]?.layout;
|
|
526
|
+
if (layout === undefined || layout.kind !== 'static' || layout.autoRetry !== true) continue;
|
|
527
|
+
const key = `${viewAnchor(object, slot)}.retry`;
|
|
528
|
+
if (events[key] === undefined) events[key] = `SCOPE | window-reload | ${scope}`;
|
|
529
|
+
}
|
|
530
|
+
|
|
482
531
|
// 写死形状行视图(ItemList / Tree / Kanban)的右键菜单:页面里一个 KitContextMenu,row_action 与行操作同形
|
|
483
532
|
for (const slot of ['list', 'summary', 'filter', 'form'] as const) {
|
|
484
533
|
const layout = ir.views[slot]?.layout;
|
|
485
534
|
if (layout === undefined || layout.kind !== 'static' || (layout.contextMenu ?? []).length === 0) continue;
|
|
486
|
-
|
|
487
|
-
if (ctxEv !== null) events[`${staticCtxAnchor(object, slot)}.row_action`] = ctxEv;
|
|
535
|
+
bindActionSlots(events, (n) => `${staticCtxAnchor(object, slot)}.${n}`, KIT_ACTION_SLOT_BASE.row, layout.contextMenu!, `views.${slot}.contextMenu`, options, diagnostics);
|
|
488
536
|
}
|
|
489
537
|
|
|
490
538
|
// 工具栏动作:不在行里,载荷无 row
|
|
491
539
|
all.forEach((a, i) => {
|
|
492
540
|
if (a.on !== 'toolbar') return;
|
|
493
541
|
const pipe = actionPipeline(a, `behavior.actions[${i}]`, options, diagnostics);
|
|
494
|
-
if (pipe !== null) events[`${toolbarAnchor(object, a.id)}.click`] =
|
|
542
|
+
if (pipe !== null) events[`${toolbarAnchor(object, a.id)}.click`] = pipe;
|
|
495
543
|
});
|
|
496
544
|
|
|
497
545
|
return { events, diagnostics };
|