soma-kit 0.1.10 → 0.1.12
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 +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -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 +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- 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 +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- 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 +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- 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 +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- 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 +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- 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/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -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 +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- 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/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- 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 +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -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 +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- 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 +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- 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 +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- 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 +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -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 +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -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 +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -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/data/prompt-dialog.ts +0 -235
- 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 -1278
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { esc } from '../shared/escape';
|
|
2
|
+
import { getCompileEnvelope } from '../shared/envelope';
|
|
1
3
|
// emitStatic:IR -> 静态 HTML + `_ui.yaml` 的 `show:` 片段(设计稿 §1.2 做法 B、§6)。
|
|
2
4
|
//
|
|
3
5
|
// 两种发射:
|
|
@@ -8,24 +10,25 @@
|
|
|
8
10
|
//
|
|
9
11
|
// 绑定约定:行变量按对象取 `kit_row_<对象>`;单对象路径默认 `page.data.<对象>`;列表对象带 `into: result`,
|
|
10
12
|
// 行数组在 `page.data.<对象>.<listShape.rows>`、总数在 `...<listShape.total>`(compile-data 保证)。
|
|
11
|
-
// prop 值规则(core resolvePropValue
|
|
12
|
-
//
|
|
13
|
+
// prop 值规则(core resolvePropValue):字符串首段是已注册变量才算绑定路径,否则是字面量;
|
|
14
|
+
// `!path` 取反写法已删除,kit 绑定路径一律是纯路径(取反另给成员),以 `!` 开头的普通文案原样显示。
|
|
13
15
|
|
|
16
|
+
import { checkRowPath, checkViewPath, isRowPath, isViewPath, KIT_ROW_ACTION_KEYS, rowPathToCore, viewPathToCore } from './view-binding';
|
|
14
17
|
import type {
|
|
15
|
-
KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR,
|
|
18
|
+
KitAction, KitCell, KitDiagnostic, KitLayoutIR, KitListShape, KitObjectIR, KitSchema, KitViewSlot,
|
|
16
19
|
} from './types';
|
|
17
20
|
import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_CLASS, KIT_WIDTH } from './defaults';
|
|
18
21
|
import type { KitSkeletonConfig } from './skeleton';
|
|
19
22
|
import { headAnchor } from './compile-data';
|
|
20
23
|
import { KIT_STATE_DEFAULT_TEXT } from './collection';
|
|
21
24
|
import { kitText } from '../i18n/kit-text';
|
|
22
|
-
import { predicateToCore } from './linkage';
|
|
23
|
-
import { actionGateOf } from './action-gate';
|
|
24
25
|
import { expandHostId } from './collection-expand';
|
|
25
26
|
import { busyActionOf } from '../base/action-busy';
|
|
26
|
-
import { gateLeafFields } from '../base/action-gate';
|
|
27
27
|
import type { KitObjectFormClasses, KitObjectFormProps } from '../data/object-form';
|
|
28
|
-
import type
|
|
28
|
+
import { KIT_PART_CARD, KIT_PART_SECTION, KIT_PART_TITLE_SECTION, kitContainerPartOf, type KitFormDetail } from './form-detail';
|
|
29
|
+
import { KIT_PART_TABLE, KIT_PART_TABLE_CELL, KIT_PART_TABLE_HEAD, KIT_PART_TABLE_ROW } from './collection-table';
|
|
30
|
+
import { readStatePathsOf } from './crud-bridge';
|
|
31
|
+
import { primaryKeyFieldOf } from './key-field';
|
|
29
32
|
|
|
30
33
|
/** 行变量按对象取(`kit_row_<对象>`):core 的 varMap 按变量名建,同页两个列表共用一个名字会撞 */
|
|
31
34
|
export function rowVarOf(object: string): string { return `kit_row_${object}`; }
|
|
@@ -44,6 +47,11 @@ export function selAnchor(object: string): string { return `${object}__list__sel
|
|
|
44
47
|
export function pagerAnchorOf(object: string): string { return `${object}__pager`; }
|
|
45
48
|
/** 可排序表头实例(view 切片 sort / order 的写者) */
|
|
46
49
|
export function headAnchorOf(object: string): string { return headAnchor(object); }
|
|
50
|
+
/** 行样式档位:rowTone 的行字段编成 core 行路径(KitTableActions 读到档位名后给所在行容器加闭集类串) */
|
|
51
|
+
function rowToneProp(layout: { rowTone?: string }, ctx: Ctx): { rowTone?: string } {
|
|
52
|
+
return layout.rowTone !== undefined ? { rowTone: `${ctx.rowVar}.${layout.rowTone}` } : {};
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
/** 展开行:开合按钮实例(每行一个 KitTableActions expand) */
|
|
48
56
|
export function treeAnchor(object: string): string { return `${object}__list__tree`; }
|
|
49
57
|
/** 虚拟滚动表体 KitVirtualRows 实例(N3) */
|
|
@@ -88,6 +96,8 @@ export interface KitStaticOptions {
|
|
|
88
96
|
* KitTableActions(选择态存在协调组件的 focus 切片里);不给保持存量的惰性 Checkbox
|
|
89
97
|
*/
|
|
90
98
|
selectedPath?: string;
|
|
99
|
+
/** 行删除在途置灰读的协调组件作用域;忙闲通道名 = 作用域 + 行主键,必须与 KitCrudBridge 的 scope 一致;缺省用本对象作用域(standard-crud 两者相同) */
|
|
100
|
+
removeScope?: string;
|
|
91
101
|
/** 展开子表(Q 波 G5):协调组件 focus 切片 expandId 镜像的路径;给了,list 形展开的开关才读它判断本行是否展开 */
|
|
92
102
|
expandPath?: string;
|
|
93
103
|
/** behavior.validateOn(已校验):KitObjectForm 在 change / blur 时即时校验 */
|
|
@@ -112,10 +122,6 @@ export interface KitStaticEmit {
|
|
|
112
122
|
|
|
113
123
|
// ---------------------------------------------------------------- 小工具
|
|
114
124
|
|
|
115
|
-
function esc(text: string): string {
|
|
116
|
-
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
125
|
function attr(name: string, value: string): string {
|
|
120
126
|
return value === '' ? '' : ` ${name}="${esc(value)}"`;
|
|
121
127
|
}
|
|
@@ -140,6 +146,13 @@ function selectedProps(ctx: Ctx): Record<string, unknown> {
|
|
|
140
146
|
return { selected: ctx.options.selectedPath, keyField: keysOf(ctx.options.schema)[0] ?? '' };
|
|
141
147
|
}
|
|
142
148
|
|
|
149
|
+
/** 行操作组件读「本行删除在途」:协调组件按作用域 + 行主键经忙闲通道登记,这里只给出作用域与主键字段名(作用域空则不绑) */
|
|
150
|
+
function removeBusyProps(ctx: Ctx): Record<string, unknown> {
|
|
151
|
+
// 作用域取 options.removeScope(业务组件成员传协调组件的 link 作用域),缺省本对象作用域;主键规则与协调组件同一份实现
|
|
152
|
+
const scope = ctx.options.removeScope ?? ctx.scope();
|
|
153
|
+
return scope === '' ? {} : { removeScope: scope, removeObject: ctx.object, removeKeyField: primaryKeyFieldOf(ctx.options.schema) ?? '' };
|
|
154
|
+
}
|
|
155
|
+
|
|
143
156
|
interface Ctx {
|
|
144
157
|
object: string;
|
|
145
158
|
options: KitStaticOptions;
|
|
@@ -158,45 +171,14 @@ interface Ctx {
|
|
|
158
171
|
/** 列表响应里错误文案的缺省路径(listShape.errorPath 可改) */
|
|
159
172
|
export const KIT_LIST_ERROR_PATH = 'result.error';
|
|
160
173
|
|
|
161
|
-
/**
|
|
162
|
-
* core 的 prop 求值没有字面量转义:字符串以 `!` 开头一律当取反绑定,文案会静默错显。
|
|
163
|
-
* 排查口径统一在 emitStatic 收尾:扫描整张 show 里所有 props(含嵌套对象 / 数组),任何以 `!` 开头的字符串报诊断,提示改写。
|
|
164
|
-
*/
|
|
165
|
-
function warnBang(diagnostics: KitDiagnostic[], value: unknown, at: string): void {
|
|
166
|
-
if (typeof value === 'string') {
|
|
167
|
-
if (value.startsWith('!')) {
|
|
168
|
-
diagnostics.push({
|
|
169
|
-
code: 'KIT-STYLE-001',
|
|
170
|
-
message: `文案 ${JSON.stringify(value)} 以 ! 开头,core 会把它当成取反绑定而不是字面量;请改写(如去掉开头的 ! 或前置一个字符)`,
|
|
171
|
-
path: at,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
} else if (Array.isArray(value)) {
|
|
175
|
-
value.forEach((v, i) => warnBang(diagnostics, v, `${at}[${i}]`));
|
|
176
|
-
} else if (value !== null && typeof value === 'object') {
|
|
177
|
-
for (const [k, v] of Object.entries(value)) warnBang(diagnostics, v, `${at}.${k}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** 遍历 show 树:每个锚点的 props 全量查 `!` 开头字面量;嵌套的行级 show 递归 */
|
|
182
|
-
export function scanShowForBang(diagnostics: KitDiagnostic[], show: Record<string, unknown>, at: string): void {
|
|
183
|
-
for (const [anchor, node] of Object.entries(show)) {
|
|
184
|
-
if (node === null || typeof node !== 'object') continue;
|
|
185
|
-
const n = node as { props?: unknown; show?: unknown };
|
|
186
|
-
if (n.props !== undefined) warnBang(diagnostics, n.props, `${at}.${anchor}.props`);
|
|
187
|
-
if (n.show !== null && typeof n.show === 'object') scanShowForBang(diagnostics, n.show as Record<string, unknown>, `${at}.${anchor}.show`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
174
|
/** 只读单元内无自身文本标签的交互控件:未显式传 aria_label 时补字段名 */
|
|
192
175
|
const LABELLED_CELL_CONTROLS: ReadonlySet<string> = new Set([
|
|
193
176
|
'Switch', 'Checkbox', 'Range', 'Rating', 'Input', 'Textarea', 'Number', 'Select',
|
|
194
177
|
]);
|
|
195
178
|
|
|
196
179
|
/** 单元的 props:字段值绑定 + IR 里的 props + 值类 */
|
|
197
|
-
function cellProps(ctx: Ctx, cell: KitCell, valuePath: string,
|
|
180
|
+
function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Record<string, unknown> {
|
|
198
181
|
const props: Record<string, unknown> = { value: valuePath };
|
|
199
|
-
void at;
|
|
200
182
|
for (const [k, v] of Object.entries(cell.props)) props[k] = v;
|
|
201
183
|
if (LABELLED_CELL_CONTROLS.has(cell.component) && props.aria_label === undefined && Boolean(cell.label)) {
|
|
202
184
|
props.aria_label = cell.label;
|
|
@@ -218,22 +200,15 @@ function keyedCell(ctx: Ctx, slot: KitViewSlot, cell: KitCell, valuePath: string
|
|
|
218
200
|
showInto[id] = { props: cellProps(ctx, cell, valuePath, at) };
|
|
219
201
|
const star = cell.required === undefined ? '' : `<span${attr('class', KIT_REQUIRED_STAR_CLASS[cell.required])} aria-hidden="true">*</span>`;
|
|
220
202
|
const label = !cell.label ? '' : `<span${attr('class', cell.labelClass)}>${cell.required === 'start' ? star : ''}${esc(cell.label)}${cell.required === 'end' ? star : ''}</span>`;
|
|
203
|
+
const cellExtraAttrs = `${cell.emphasis !== undefined ? ` data-kit-emphasis="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ' data-kit-highlight="true"' : ''}${cell.overflow === true ? ' data-kit-filter-overflow="true"' : ''}`;
|
|
221
204
|
// summary 的 hideEmpty:格本身带锚点,show[锚点].when = 字段值路径(core 的 when 只判真值,故数字 / 布尔字段不许 hideEmpty,见 buildCell)
|
|
222
|
-
// 只读视图 showWhen:Show 对象谓词 when,条件字段取同一对象的路径前缀
|
|
223
|
-
if (cell.showWhen !== undefined && cell.hideEmpty !== true) {
|
|
224
|
-
const cellId = `${id}__cell`;
|
|
225
|
-
const prefix = valuePath.endsWith(`.${cell.field}`) ? valuePath.slice(0, -cell.field.length) : '';
|
|
226
|
-
const w = cell.showWhen as { field: string };
|
|
227
|
-
showInto[cellId] = { when: { ...cell.showWhen, field: `${prefix}${w.field}` } };
|
|
228
|
-
return `<div data-soma-id="${esc(cellId)}"${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
|
|
229
|
-
}
|
|
230
205
|
if (cell.hideEmpty === true) {
|
|
231
206
|
const cellId = `${id}__cell`;
|
|
232
|
-
//
|
|
233
|
-
showInto[cellId] = { when:
|
|
234
|
-
return `<div data-soma-id="${esc(cellId)}"${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
|
|
207
|
+
// 纯路径绑定(不发射对象形 when);数字 / 布尔字段由 buildCell 拒收
|
|
208
|
+
showInto[cellId] = { when: valuePath };
|
|
209
|
+
return `<div data-soma-id="${esc(cellId)}"${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
|
|
235
210
|
}
|
|
236
|
-
return `<div${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
|
|
211
|
+
return `<div${cellExtraAttrs}${attr('class', cell.cellClass)}>${label}${host(cell.component, id)}</div>`;
|
|
237
212
|
}
|
|
238
213
|
|
|
239
214
|
/** 表格行里的列单元:无 label,只有值组件 */
|
|
@@ -242,10 +217,11 @@ function columnCell(ctx: Ctx, cell: KitCell, at: string, showInto: Record<string
|
|
|
242
217
|
ctx.components.add(cell.component);
|
|
243
218
|
showInto[id] = { props: cellProps(ctx, cell, `${ctx.rowVar}.${cell.field}`, at) };
|
|
244
219
|
// KitTableTools 按这些标记接管:列显隐(data-kit-col)、省略 title、就地编辑
|
|
220
|
+
const cellKnobAttrs = `${cell.emphasis !== undefined ? ` data-kit-emphasis="${esc(cell.emphasis)}"` : ''}${cell.highlight === true ? ' data-kit-highlight="true"' : ''}`;
|
|
245
221
|
const marks = marked
|
|
246
222
|
? ` data-kit-col="${esc(cell.field)}"${cell.ellipsis === true ? ' data-kit-ellipsis=""' : ''}${cell.editable === true ? ' data-kit-editable=""' : ''}`
|
|
247
223
|
: '';
|
|
248
|
-
return `<div${marks}${cellRole !== '' ? ` role="${cellRole}"` : ''}${attr('class', cell.cellClass)}>${host(cell.component, id)}</div>`;
|
|
224
|
+
return `<div${marks}${cellKnobAttrs}${cellRole !== '' ? ` role="${cellRole}"` : ''}${attr('class', cell.cellClass)} data-kit-part="${KIT_PART_TABLE_CELL}">${host(cell.component, id)}</div>`;
|
|
249
225
|
}
|
|
250
226
|
|
|
251
227
|
// ---------------------------------------------------------------- 排布
|
|
@@ -280,8 +256,10 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
|
|
|
280
256
|
showInto[did] = { props: g.divider === '' ? {} : { label: g.divider } };
|
|
281
257
|
divider = host('KitDivider', did);
|
|
282
258
|
}
|
|
259
|
+
const grpPart = g.surface !== undefined ? kitContainerPartOf(g.surface) : KIT_PART_SECTION;
|
|
260
|
+
const grpAttrs = `${g.surface !== undefined ? ` data-kit-surface="${esc(g.surface)}"` : ''}${g.emphasis !== undefined ? ` data-kit-emphasis="${esc(g.emphasis)}"` : ''} data-kit-part="${esc(grpPart)}"`;
|
|
283
261
|
if (!g.collapsible) {
|
|
284
|
-
return `${divider}<section${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)}>${esc(g.title)}</h4>${inner}</section>`;
|
|
262
|
+
return `${divider}<section${grpAttrs}${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)} data-kit-part="${KIT_PART_TITLE_SECTION}">${esc(g.title)}</h4>${inner}</section>`;
|
|
285
263
|
}
|
|
286
264
|
// 可折叠:标题是 h4 里的 button(aria-expanded + aria-controls),折叠体是块级 div(hidden 不和 flex / grid 同元素),初态按 open 写好
|
|
287
265
|
const btn = `<button type="button" id="${esc(g.id)}__btn"${attr('class', KIT_CLASS_DEFAULTS.groupToggle)} data-kit-collapse-toggle="" aria-expanded="${g.open ? 'true' : 'false'}" aria-controls="${esc(g.id)}">`
|
|
@@ -289,7 +267,7 @@ function renderArrangement(ctx: Ctx, slot: KitViewSlot, layout: KitLayoutIR, val
|
|
|
289
267
|
+ `<span${attr('class', KIT_CLASS_DEFAULTS.groupMark)} aria-hidden="true" data-kit-collapse-mark="" data-kit-mark-open="${markers[1]}" data-kit-mark-closed="${markers[0]}">${g.open ? markers[1] : markers[0]}</span>`
|
|
290
268
|
+ '</button>';
|
|
291
269
|
const body = `<div id="${esc(g.id)}" role="region" aria-labelledby="${esc(g.id)}__btn"${attr('class', g.open ? '' : 'hidden')}>${inner}</div>`;
|
|
292
|
-
return `${divider}<section${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)}>${btn}</h4>${body}</section>`;
|
|
270
|
+
return `${divider}<section${grpAttrs}${attr('class', layout.sectionClass)}><h4${attr('class', layout.titleClass)} data-kit-part="${KIT_PART_TITLE_SECTION}">${btn}</h4>${body}</section>`;
|
|
293
271
|
}).join('');
|
|
294
272
|
const wrap = `<div${attr('class', layout.wrapClass)}${layout.collapsible ? ' data-kit-collapse-root=""' : ''}>${sections}</div>`;
|
|
295
273
|
if (!layout.collapsible) return wrap;
|
|
@@ -316,7 +294,7 @@ const GROUPS_AS = KIT_GRAMMAR.formLinkage.groupsAs as { barClass: string; tabCla
|
|
|
316
294
|
|
|
317
295
|
/**
|
|
318
296
|
* groups 呈现为页签:tablist + 若干 tab 按钮 + 各组面板(首签显示,其余外层 hidden)。
|
|
319
|
-
*
|
|
297
|
+
* 没有事件声明:面板显隐、ARIA 与 ←/→/Home/End 都由 KitTabsWiring(同 tabs-frame)在组件内完成;
|
|
320
298
|
* 外层 data-kit-tabs-frame 让接线件只在本块内查锚点。hidden 只放在面板外层,不和 flex / grid 同元素。
|
|
321
299
|
*/
|
|
322
300
|
function renderGroupTabs(
|
|
@@ -356,7 +334,7 @@ export function groupTabsFrame(
|
|
|
356
334
|
showInto: Record<string, unknown>,
|
|
357
335
|
components: Set<string>,
|
|
358
336
|
): string {
|
|
359
|
-
const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}" role="tab" aria-selected="${i === 0 ? 'true' : 'false'}"${attr('class', GROUPS_AS.tabClass)}>${esc(title)}</button>`).join('');
|
|
337
|
+
const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}" data-kit-face="tab" role="tab" aria-selected="${i === 0 ? 'true' : 'false'}"${attr('class', GROUPS_AS.tabClass)}>${esc(title)}</button>`).join('');
|
|
360
338
|
const panelEls = panels.map((inner, i) => `<div data-soma-id="${esc(groupPanelAnchor(object, slot, i))}"${i === 0 ? '' : ' hidden'}>${inner}</div>`).join('');
|
|
361
339
|
const wireId = groupTabWireAnchor(object, slot);
|
|
362
340
|
components.add('KitTabsWiring');
|
|
@@ -373,22 +351,9 @@ export function groupTabsFrame(
|
|
|
373
351
|
return `<div data-kit-tabs-frame=""${attr('class', wrapClass)}>${bar}${wiring}${panelEls}</div>`;
|
|
374
352
|
}
|
|
375
353
|
|
|
376
|
-
/** 页签点击事件(点页签 = 关别的面板、开本面板);与 groupsAs 共用,emit-events 与 RecordDetail 都用它 */
|
|
377
|
-
export function groupTabEvents(object: string, slot: KitViewSlot, n: number): Record<string, unknown> {
|
|
378
|
-
const events: Record<string, unknown> = {};
|
|
379
|
-
for (let i = 0; i < n; i += 1) {
|
|
380
|
-
events[`${groupTabAnchor(object, slot, i)}.click`] = {
|
|
381
|
-
steps: Array.from({ length: n }, (_x, j) => ({ do: `UI_INTERACT | ${groupPanelAnchor(object, slot, j)} | | ${j === i ? 'open' : 'close'}` })),
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
return events;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
354
|
// ---------------------------------------------------------------- list
|
|
388
355
|
|
|
389
356
|
function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<string, unknown>> {
|
|
390
|
-
// 按行分槽的 outcome 条件按主键读本行那一份:带状态条件的动作项附上主键字段名(gateKey)
|
|
391
|
-
const gateKey = keysOf(ctx.options.schema)[0] ?? '';
|
|
392
357
|
return actions.map((a) => ({
|
|
393
358
|
id: a.id,
|
|
394
359
|
name: a.name,
|
|
@@ -397,18 +362,38 @@ function actionItems(actions: readonly KitAction[], ctx: Ctx): Array<Record<stri
|
|
|
397
362
|
...(a.targetOverlay !== undefined ? { target: a.targetOverlay } : {}),
|
|
398
363
|
// K1-2:带权限码的行操作,没有权限不渲染(点击拦截的 permission 尾段保留作第二道防线)
|
|
399
364
|
...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
|
|
400
|
-
// 行操作条件(core 谓词形,字段是行字段):按钮组件可据此隐藏;执行前置已编进 steps,点不到也不会执行
|
|
401
|
-
...(a.when !== undefined ? whenItem(a) : {}),
|
|
402
365
|
...(a.more === true ? { more: true } : {}),
|
|
403
|
-
// GA2:状态条件(core 谓词;叶子是行字段或 outcome.<名>.…,运行期由 KitTableActions / 右键菜单求值)
|
|
404
|
-
...actionGateOf(a),
|
|
405
|
-
...(gateKey !== '' && Object.keys(actionGateOf(a)).length > 0 ? { gateKey } : {}),
|
|
406
366
|
}));
|
|
407
367
|
}
|
|
408
368
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
369
|
+
/**
|
|
370
|
+
* 行动作的行级状态绑定:on: row 动作的 hidden / disabled(row.<字段>,业务对象逐行给出)编成
|
|
371
|
+
* { 动作id: { hidden?, disabled? } },叶子是 core 行路径(行变量.<字段>),由 core 在行模板里逐行求值。
|
|
372
|
+
* 返回要并进 prop 的 { actionState };没有绑定返回空对象。非法写法已在 emitStatic 入口记过诊断,这里只收合法的。
|
|
373
|
+
*/
|
|
374
|
+
function actionStateProp(actions: readonly KitAction[], ctx: Ctx): { actionState?: Record<string, Record<string, string>> } {
|
|
375
|
+
const state: Record<string, Record<string, string>> = {};
|
|
376
|
+
for (const a of actions) {
|
|
377
|
+
if (a.on !== 'row') continue;
|
|
378
|
+
for (const key of KIT_ROW_ACTION_KEYS) {
|
|
379
|
+
const raw = a[key];
|
|
380
|
+
if (isRowPath(raw)) (state[a.id] ??= {})[key] = rowPathToCore(raw, ctx.rowVar);
|
|
381
|
+
// 行动作也可以绑展示对象成员(view.<成员>,编成页面变量 page.<成员>,行模板里 core 逐行求值同一个值),与 row.<字段> 二选一
|
|
382
|
+
else if (isViewPath(raw)) (state[a.id] ??= {})[key] = viewPathToCore(raw);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return Object.keys(state).length > 0 ? { actionState: state } : {};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** treeTable / 虚拟滚动表的行操作与右键菜单不支持行级状态绑定:写了记 KIT-ROW-002(动作照常渲染,绑定被忽略) */
|
|
389
|
+
function rejectRowState(actions: readonly KitAction[], ctx: Ctx, where: string): void {
|
|
390
|
+
for (const a of actions) {
|
|
391
|
+
for (const key of KIT_ROW_ACTION_KEYS) {
|
|
392
|
+
if (a.on === 'row' && a[key] !== undefined) {
|
|
393
|
+
ctx.diagnostics.push({ code: 'KIT-ROW-002', path: `behavior.actions.${a.id}.${key}`, message: `${where}的行操作 / 右键菜单不支持行级状态绑定(动作 ${a.id} 的 ${key})` });
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
412
397
|
}
|
|
413
398
|
|
|
414
399
|
function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>): string {
|
|
@@ -444,6 +429,8 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
444
429
|
ctx.show[headAnchor(object)] = {
|
|
445
430
|
props: {
|
|
446
431
|
cells, scope: ctx.scope(), class: layout.headClass, ...(semTable ? { semantics: 'table' } : {}),
|
|
432
|
+
// 读状态:点表头排序后重取失败,表头据此把 sort / order / page 回滚到最近一次读成功的值
|
|
433
|
+
readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
|
|
447
434
|
...(layout.headGroups !== undefined ? { groups: layout.headGroups } : {}),
|
|
448
435
|
},
|
|
449
436
|
};
|
|
@@ -475,12 +462,13 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
475
462
|
}
|
|
476
463
|
flushGroup();
|
|
477
464
|
if (layout.rowActions.length > 0) headParts.push(`<div${headRole}${attr('class', actHead)}>${esc(opsHeadLabel(ctx))}</div>`);
|
|
478
|
-
head = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.headClass)}>${headParts.join('')}</div>`;
|
|
465
|
+
head = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.headClass)} data-kit-part="${KIT_PART_TABLE_HEAD}">${headParts.join('')}</div>`;
|
|
479
466
|
}
|
|
480
467
|
|
|
481
468
|
// 树表:列 / 表头 / 三态 / 分页与普通表格同一条路径,只有表体换成 KitTreeTable(层级 + 展开状态在组件里)
|
|
482
469
|
if (layout.tree !== null) {
|
|
483
470
|
const id = treeAnchor(object);
|
|
471
|
+
rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, 'treeTable');
|
|
484
472
|
ctx.components.add('KitTreeTable');
|
|
485
473
|
ctx.show[id] = {
|
|
486
474
|
props: {
|
|
@@ -496,6 +484,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
496
484
|
...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
|
|
497
485
|
...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
|
|
498
486
|
...selectedProps(ctx),
|
|
487
|
+
...removeBusyProps(ctx),
|
|
499
488
|
},
|
|
500
489
|
};
|
|
501
490
|
// 右键菜单:页面里一个实例,宿主壳(data-kit-ctxhost)里的 KitTreeTable 按行主键登记取行函数(provideCtxRows)
|
|
@@ -525,6 +514,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
525
514
|
selectMode: layout.select,
|
|
526
515
|
selected: ctx.options.selectedPath,
|
|
527
516
|
keyField: keysOf(ctx.options.schema)[0] ?? '',
|
|
517
|
+
...removeBusyProps(ctx),
|
|
528
518
|
},
|
|
529
519
|
};
|
|
530
520
|
rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.selectClass)}>${host('KitTableActions', selAnchor(object))}</div>`);
|
|
@@ -535,37 +525,34 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
535
525
|
}
|
|
536
526
|
}
|
|
537
527
|
layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
|
|
538
|
-
// D9 rowClassWhen:条件行类由 KitTableActions 在行容器(data-kit-row)上切换
|
|
539
|
-
const hasRowWhen = (layout.rowClassWhen ?? []).length > 0;
|
|
540
|
-
const rowWhenProps = hasRowWhen ? { rowClassWhen: layout.rowClassWhen } : {};
|
|
541
528
|
if (layout.rowActions.length > 0) {
|
|
542
529
|
ctx.components.add('KitTableActions');
|
|
543
530
|
rowShow[opsAnchor(object)] = {
|
|
544
|
-
props: { actions: actionItems(layout.rowActions, ctx), row: ctx.rowVar, ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...
|
|
531
|
+
props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) },
|
|
545
532
|
};
|
|
546
533
|
rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.actionsClass)}>${host('KitTableActions', opsAnchor(object))}</div>`);
|
|
547
534
|
}
|
|
548
|
-
// pickOnRow
|
|
549
|
-
if ((ctx.options.pickOnRow === true ||
|
|
535
|
+
// pickOnRow 或行样式档位(rowTone)且没有行操作列:补一个无按钮的 KitTableActions 实例,专管行点击 / 行样式
|
|
536
|
+
if ((ctx.options.pickOnRow === true || layout.rowTone !== undefined) && layout.rowActions.length === 0) {
|
|
550
537
|
ctx.components.add('KitTableActions');
|
|
551
|
-
rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...
|
|
538
|
+
rowShow[opsAnchor(object)] = { props: { actions: [], row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) } };
|
|
552
539
|
rowParts.push(host('KitTableActions', opsAnchor(object)));
|
|
553
540
|
}
|
|
554
541
|
// 右键菜单(Q 波 G6):行内一个 KitContextMenu 实例(包在 hidden 壳里,不占栅格列),行容器标 data-kit-ctx 供它监听
|
|
555
542
|
const ctxItems = layout.contextMenu ?? [];
|
|
556
543
|
if (ctxItems.length > 0) {
|
|
557
544
|
ctx.components.add('KitContextMenu');
|
|
558
|
-
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), row: ctx.rowVar } };
|
|
545
|
+
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar } };
|
|
559
546
|
rowParts.push(`<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`);
|
|
560
547
|
}
|
|
561
548
|
const rowClass = ctx.options.pickOnRow === true ? joinClasses(layout.rowClass, 'cursor-pointer') : layout.rowClass;
|
|
562
549
|
// 行容器标 data-kit-row:pickOnRow 的行点击、选中行高亮(data-kit-selected)都靠它;斑马纹类挂在每条数据项的最外层元素
|
|
563
|
-
const marked = ctx.options.pickOnRow === true ||
|
|
550
|
+
const marked = ctx.options.pickOnRow === true || layout.rowTone !== undefined || (layout.select !== 'none' && ctx.options.selectedPath !== undefined);
|
|
564
551
|
const rowMark = `${marked ? ' data-kit-row=""' : ''}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}`;
|
|
565
552
|
const stripe = layout.stripeClass;
|
|
566
553
|
const striped = stripe !== '';
|
|
567
554
|
const expandRowClass = striped ? joinClasses(rowClass, KIT_CLASS_DEFAULTS.tableRowStripedExpandInner) : rowClass;
|
|
568
|
-
const rowEl = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.expand === null ? joinClasses(rowClass, stripe) : expandRowClass)}${rowMark}>${rowParts.join('')}</div>`;
|
|
555
|
+
const rowEl = `<div${semTable ? ' role="row"' : ''}${attr('class', layout.expand === null ? joinClasses(rowClass, stripe) : expandRowClass)}${rowMark} data-kit-part="${KIT_PART_TABLE_ROW}">${rowParts.join('')}</div>`;
|
|
569
556
|
let itemHtml = rowEl;
|
|
570
557
|
if (layout.expand !== null) {
|
|
571
558
|
// 展开行:行下一条“展开详情”开关(KitTableActions expand)+ 默认 hidden 的详情体;开合状态在开关组件里
|
|
@@ -594,7 +581,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
594
581
|
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
|
|
595
582
|
const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
|
|
596
583
|
const tableA11y = semTable ? ` role="table"${attr('aria-label', ctx.object)}` : '';
|
|
597
|
-
const body = `<div${attr('class', layout.wrapClass)}${wrapA11y}${tools ?
|
|
584
|
+
const body = `<div${attr('class', layout.wrapClass)}${wrapA11y}${tools ? ` data-kit-table="" data-kit-table-of="${esc(toolsAnchor(object))}"` : ''} data-kit-part="${KIT_PART_TABLE}"><div${tableA11y}${attr('class', layout.innerClass)}>${head}${rows}${summary}</div></div>`;
|
|
598
585
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
|
|
599
586
|
}
|
|
600
587
|
|
|
@@ -607,16 +594,14 @@ function renderVirtualTable(
|
|
|
607
594
|
): string {
|
|
608
595
|
const object = ctx.object;
|
|
609
596
|
const id = virtualAnchor(object);
|
|
597
|
+
rejectRowState([...layout.rowActions, ...(layout.contextMenu ?? [])], ctx, '虚拟滚动表');
|
|
610
598
|
ctx.components.add('KitVirtualRows');
|
|
611
|
-
const hasRowWhen = (layout.rowClassWhen ?? []).length > 0;
|
|
612
599
|
ctx.show[id] = {
|
|
613
600
|
props: {
|
|
614
601
|
rows: ctx.rowsPath,
|
|
615
602
|
cells: layout.cells,
|
|
616
603
|
rowHeight: layout.virtual!.rowHeight,
|
|
617
|
-
density: layout.density,
|
|
618
604
|
rowClass: layout.rowClass,
|
|
619
|
-
...(hasRowWhen ? { rowClassWhen: layout.rowClassWhen } : {}),
|
|
620
605
|
stripeClass: layout.stripeClass,
|
|
621
606
|
select: layout.select,
|
|
622
607
|
selectClass: layout.selectClass,
|
|
@@ -627,6 +612,7 @@ function renderVirtualTable(
|
|
|
627
612
|
...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
|
|
628
613
|
...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
|
|
629
614
|
...selectedProps(ctx),
|
|
615
|
+
...removeBusyProps(ctx),
|
|
630
616
|
},
|
|
631
617
|
};
|
|
632
618
|
const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
|
|
@@ -639,7 +625,7 @@ function renderVirtualTable(
|
|
|
639
625
|
}
|
|
640
626
|
const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
641
627
|
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)}` : '';
|
|
642
|
-
const body = `<div${attr('class', layout.wrapClass)}${wrapA11y} data-kit-vscroll=""${tools ?
|
|
628
|
+
const body = `<div${attr('class', layout.wrapClass)}${wrapA11y} data-kit-vscroll=""${tools ? ` data-kit-table="" data-kit-table-of="${esc(toolsAnchor(object))}"` : ''}>`
|
|
643
629
|
+ `<div role="grid"${attr('aria-label', object)}${attr('class', layout.innerClass)}>${head}${host('KitVirtualRows', id)}${ctxHost}${summary}</div></div>`;
|
|
644
630
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
|
|
645
631
|
}
|
|
@@ -651,7 +637,7 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
651
637
|
const keyField = keysOf(ctx.options.schema)[0] ?? '';
|
|
652
638
|
let batchOn = batch.length > 0;
|
|
653
639
|
if (batchOn && ctx.options.selectedPath === undefined) {
|
|
654
|
-
ctx.diagnostics.push({ code: 'KIT-OBJ-009', path: 'views.list.layout', message: 'batchActions 需要勾选态来源(StandardCrud
|
|
640
|
+
ctx.diagnostics.push({ code: 'KIT-OBJ-009', path: 'views.list.layout', message: 'batchActions 需要勾选态来源(StandardCrud 等带协调组件的业务组件),当前对象没有' });
|
|
655
641
|
batchOn = false;
|
|
656
642
|
}
|
|
657
643
|
const id = toolsAnchor(ctx.object);
|
|
@@ -663,9 +649,9 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
663
649
|
rows: ctx.rowsPath,
|
|
664
650
|
total: ctx.totalPath,
|
|
665
651
|
keyField,
|
|
652
|
+
readState: readStatePathsOf(ctx.object, ctx.basePath).readStatePath,
|
|
666
653
|
columns: layout.columns ?? [],
|
|
667
654
|
items: layout.toolbar ?? [],
|
|
668
|
-
density: layout.density,
|
|
669
655
|
scroll: layout.scroll === true,
|
|
670
656
|
editMode: layout.editMode ?? '',
|
|
671
657
|
selectMode: layout.select,
|
|
@@ -673,7 +659,17 @@ function renderTools(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
673
659
|
...(batchOn
|
|
674
660
|
? {
|
|
675
661
|
selected: ctx.options.selectedPath,
|
|
676
|
-
batch: batch.map((b) =>
|
|
662
|
+
batch: batch.map((b) => {
|
|
663
|
+
const busyAction = (b as { on?: string }).on ?? b.action?.on;
|
|
664
|
+
return {
|
|
665
|
+
id: b.id,
|
|
666
|
+
name: b.name,
|
|
667
|
+
tone: b.tone,
|
|
668
|
+
confirm: b.confirm,
|
|
669
|
+
...(b.permission !== undefined ? { permission: b.permission } : {}),
|
|
670
|
+
...(busyAction !== undefined && busyAction !== '' ? { busyAction } : {}),
|
|
671
|
+
};
|
|
672
|
+
}),
|
|
677
673
|
}
|
|
678
674
|
: {}),
|
|
679
675
|
},
|
|
@@ -724,7 +720,7 @@ const EXPAND_TOGGLE_CLASS = 'px-4 py-1';
|
|
|
724
720
|
const EXPAND_BODY_CLASS = 'border-b border-border-subtle bg-surface-sunken px-4 py-3';
|
|
725
721
|
|
|
726
722
|
/** 集合三态面板:列表之后、分页器之前 */
|
|
727
|
-
function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean } | null, shape?: KitSkeletonConfig): string {
|
|
723
|
+
function renderState(ctx: Ctx, state: { loading: string; empty: string; error: string; skeleton?: boolean; errorOnly?: boolean } | null, shape?: KitSkeletonConfig): string {
|
|
728
724
|
if (state === null) return '';
|
|
729
725
|
const id = stateAnchor(ctx.object);
|
|
730
726
|
ctx.components.add('KitCollectionState');
|
|
@@ -733,12 +729,16 @@ function renderState(ctx: Ctx, state: { loading: string; empty: string; error: s
|
|
|
733
729
|
data: ctx.basePath,
|
|
734
730
|
rows: ctx.rowsPath,
|
|
735
731
|
config: {
|
|
732
|
+
object: ctx.object,
|
|
736
733
|
rowsPath: ctx.options.listShape.rows,
|
|
737
734
|
errorPath: typeof ctx.options.listShape.errorPath === 'string' ? ctx.options.listShape.errorPath : KIT_LIST_ERROR_PATH,
|
|
735
|
+
readStatePath: readStatePathsOf(ctx.object, ctx.basePath).readStatePath,
|
|
736
|
+
errorMessagePath: readStatePathsOf(ctx.object, ctx.basePath).errorMessagePath,
|
|
738
737
|
loading: state.loading === KIT_STATE_DEFAULT_TEXT.loading ? kitText('soma.kit.loading', undefined, ctx.options.locale ?? '') : state.loading,
|
|
739
738
|
empty: state.empty === KIT_STATE_DEFAULT_TEXT.empty ? kitText('soma.kit.empty', undefined, ctx.options.locale ?? '') : state.empty,
|
|
740
739
|
error: state.error,
|
|
741
740
|
...(state.skeleton === true && shape !== undefined ? { skeleton: shape } : {}),
|
|
741
|
+
...(state.errorOnly === true ? { mode: 'errorOnly' } : {}),
|
|
742
742
|
},
|
|
743
743
|
},
|
|
744
744
|
};
|
|
@@ -752,6 +752,8 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
|
|
|
752
752
|
ctx.show[id] = {
|
|
753
753
|
props: {
|
|
754
754
|
scope: ctx.scope(), total: ctx.totalPath, size: pager.size, sizes: pager.sizes, jump: pager.jump,
|
|
755
|
+
// 读状态:翻页后重取失败,分页器据此把页码 / 页长回滚到最近一次读成功的值
|
|
756
|
+
readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
|
|
755
757
|
...(pager.mode !== undefined ? { mode: pager.mode } : {}),
|
|
756
758
|
...(pager.layout !== undefined ? { layout: pager.layout } : {}),
|
|
757
759
|
...(pager.showTotal === false ? { show_total: false } : {}),
|
|
@@ -768,7 +770,7 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
|
|
|
768
770
|
let actions = '';
|
|
769
771
|
if (layout.rowActions.length > 0) {
|
|
770
772
|
ctx.components.add('KitTableActions');
|
|
771
|
-
rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), row: ctx.rowVar } };
|
|
773
|
+
rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...removeBusyProps(ctx) } };
|
|
772
774
|
actions = host('KitTableActions', opsAnchor(object));
|
|
773
775
|
}
|
|
774
776
|
// 右键菜单(Q 波 G6):块 / 卡外壳标 data-kit-ctx,内含一个 KitContextMenu 实例(hidden 壳,不占版面)
|
|
@@ -776,10 +778,11 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
|
|
|
776
778
|
let ctxHost = '';
|
|
777
779
|
if (ctxItems.length > 0) {
|
|
778
780
|
ctx.components.add('KitContextMenu');
|
|
779
|
-
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), row: ctx.rowVar } };
|
|
781
|
+
rowShow[ctxMenuAnchor(object)] = { props: { menu: actionItems(ctxItems, ctx), ...actionStateProp(ctxItems, ctx), row: ctx.rowVar } };
|
|
780
782
|
ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
781
783
|
}
|
|
782
|
-
const
|
|
784
|
+
const itemPart = layout.kind === 'cards' ? ` data-kit-part="${KIT_PART_CARD}"` : '';
|
|
785
|
+
const template = `<template data-soma-role="item"><div${attr('class', layout.itemClass)}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}${itemPart}>${inner}${actions}${ctxHost}</div></template>`;
|
|
783
786
|
ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
|
|
784
787
|
const list = `<div${attr('class', layout.listClass)} data-soma-id="${esc(rowsAnchor(object))}">${template}</div>`;
|
|
785
788
|
return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
|
|
@@ -810,6 +813,20 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
|
|
|
810
813
|
if (layout.dataSubmit === true && layout.hasScopeProp === true && props.scope === undefined) {
|
|
811
814
|
props.scope = ctx.scope();
|
|
812
815
|
}
|
|
816
|
+
// 读状态:契约声明了 loading / error_text(或无 error_text 时 string 型 error)的组件,页面没显式给时绑到数据对象的读状态(loading / errorMessage)
|
|
817
|
+
if (layout.hasLoadingProp === true && props.loading === undefined) {
|
|
818
|
+
props.loading = `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.loading`;
|
|
819
|
+
}
|
|
820
|
+
if (layout.hasErrorTextProp === true && props.error_text === undefined) {
|
|
821
|
+
props.error_text = readStatePathsOf(ctx.object, ctx.basePath).errorMessagePath;
|
|
822
|
+
}
|
|
823
|
+
if (layout.hasErrorProp === true && props.error === undefined) {
|
|
824
|
+
props.error = readStatePathsOf(ctx.object, ctx.basePath).errorMessagePath;
|
|
825
|
+
}
|
|
826
|
+
// 读失败自动重试:页面没给 retry_text 时补缺省文案(接线在 emitEvents:页面没接 retry 时接重取管道)
|
|
827
|
+
if (layout.autoRetry === true && props.retry_text === undefined) {
|
|
828
|
+
props.retry_text = kitText('soma.kit.ct_retry', undefined, ctx.options.locale ?? '');
|
|
829
|
+
}
|
|
813
830
|
if (layout.class !== '') props.class = layout.class;
|
|
814
831
|
ctx.show[id] = { props };
|
|
815
832
|
// 右键菜单:宿主壳(display: contents,不影响版面)里放组件与一个 KitContextMenu(hidden 壳);组件按行主键登记取行函数
|
|
@@ -819,7 +836,11 @@ function renderStaticComponent(ctx: Ctx, slot: KitViewSlot, layout: Extract<KitL
|
|
|
819
836
|
ctx.show[menuId] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host' } };
|
|
820
837
|
return `<div class="contents" data-kit-ctxhost="">${host(layout.component, id)}<div class="hidden">${host('KitContextMenu', menuId)}</div></div>`;
|
|
821
838
|
}
|
|
822
|
-
|
|
839
|
+
const hasStatHighlight = layout.component === 'StatGroup'
|
|
840
|
+
&& Array.isArray(props.items)
|
|
841
|
+
&& props.items.some((it) => it !== null && typeof it === 'object' && (it as { highlight?: unknown }).highlight === true);
|
|
842
|
+
const rawHost = host(layout.component, id);
|
|
843
|
+
return hasStatHighlight ? rawHost.replace('></div>', ' data-kit-highlight="true"></div>') : rawHost;
|
|
823
844
|
}
|
|
824
845
|
|
|
825
846
|
// ---------------------------------------------------------------- KitObjectForm(filter / 可编辑 form)
|
|
@@ -870,7 +891,7 @@ export function formFieldsAndClasses(layout: KitLayoutIR): { fields: KitCell[];
|
|
|
870
891
|
}
|
|
871
892
|
|
|
872
893
|
function createOnlyOf(schema: KitSchema | undefined): string[] {
|
|
873
|
-
return Object.entries(schema ?? {}).filter(([, f]) => f.permission === 'create').map(([k]) => k);
|
|
894
|
+
return Object.entries(schema ?? {}).filter(([, f]) => f.permission === 'create' || f.access === 'create').map(([k]) => k);
|
|
874
895
|
}
|
|
875
896
|
export function keysOf(schema: KitSchema | undefined): string[] {
|
|
876
897
|
return Object.entries(schema ?? {}).filter(([, f]) => f.key === true).map(([k]) => k);
|
|
@@ -899,10 +920,13 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
899
920
|
keys: keysOf(ctx.options.schema),
|
|
900
921
|
...(slot === 'form' && ir.views.form?.submitLabel !== undefined ? { submitLabel: ir.views.form.submitLabel } : {}),
|
|
901
922
|
};
|
|
923
|
+
// 本页有效信封(与 detail.envelope 同一来源:编译期页面 > 应用);筛选与可编辑表单的远程选项、句柄 envelope() 据此解包。未声明不写这个 prop
|
|
924
|
+
const envelope = getCompileEnvelope();
|
|
925
|
+
if (envelope !== undefined) props.envelope = envelope;
|
|
902
926
|
// M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
|
|
903
927
|
const fo = ir.views[slot]?.formOpts;
|
|
904
928
|
if (fo?.labelPosition !== undefined) { props.labelPosition = fo.labelPosition; props.labelWidth = fo.labelWidth ?? 3; }
|
|
905
|
-
if (fo?.scrollToError ===
|
|
929
|
+
if (typeof fo?.scrollToError === 'boolean') props.scrollToError = fo.scrollToError;
|
|
906
930
|
if (fo?.requiredMark === 'start') props.requiredMark = 'start';
|
|
907
931
|
if (fo?.collapsible === true) { props.collapsible = true; props.collapsedRows = fo.collapsedRows ?? 1; }
|
|
908
932
|
if (fo?.trigger === 'change') props.trigger = 'change';
|
|
@@ -914,13 +938,15 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
914
938
|
if (fo?.footerActions !== undefined) {
|
|
915
939
|
const items = fo.footerActions.flatMap((aid) => {
|
|
916
940
|
const a = ctx.options.actions?.find((x) => x.id === aid);
|
|
917
|
-
return a === undefined ? [] : [{ id: aid, label: a.name
|
|
941
|
+
return a === undefined ? [] : [{ id: aid, label: a.name }];
|
|
918
942
|
});
|
|
919
943
|
if (items.length > 0) props.footerActions = items;
|
|
920
944
|
}
|
|
921
|
-
if (fo?.onChange !== undefined) props.changeFields = Object.keys(fo.onChange);
|
|
922
945
|
if (fo?.result !== undefined) props.result = fo.result;
|
|
923
|
-
|
|
946
|
+
// 展示对象的字段状态绑定:{ 字段: { hidden / disabled / required: page.<成员> } },叶子是路径,core 的 props 求值递归解析
|
|
947
|
+
if (fo?.fieldState !== undefined) props.fieldState = fo.fieldState;
|
|
948
|
+
if (fo?.submitDisabled !== undefined) props.submitDisabled = fo.submitDisabled;
|
|
949
|
+
if (fo?.onDraft !== undefined) props.draftNotify = true;
|
|
924
950
|
// GB2 / GB3:字段初值(新建时填空字段)与隐藏草稿字段(随草稿提交、不画)
|
|
925
951
|
if (ir.fieldValue !== undefined) {
|
|
926
952
|
if (Object.keys(ir.fieldValue.defaults).length > 0) props.defaults = ir.fieldValue.defaults;
|
|
@@ -930,29 +956,23 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
930
956
|
ctx.show[id] = { props };
|
|
931
957
|
// 页面真有按需字段控件(画布)时在宿主上点名,core 才补载其分片
|
|
932
958
|
const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
|
|
933
|
-
const
|
|
959
|
+
const isOverflowFilter = slot === 'filter' && (fo?.filterOverflow === true || (fo?.collapsible === true && packed.fields.filter((c) => c.placeholder !== true && c.divider !== true && c.component !== '').length > (fo?.defaultCollapsedCount ?? 4)));
|
|
960
|
+
let html = host('KitObjectForm', id);
|
|
961
|
+
if (isOverflowFilter) html = html.replace('></div>', ' data-kit-filter-overflow="true"></div>');
|
|
934
962
|
return needs.length === 0 ? html : html.replace('></div>', ` data-soma-needs="${needs.join(' ')}"></div>`);
|
|
935
963
|
}
|
|
936
964
|
|
|
937
965
|
// ---------------------------------------------------------------- 工具栏
|
|
938
966
|
|
|
939
|
-
/** 工具栏动作条件用到的页面读态绑定:total -> 列表总条数路径,selectedCount / selected.x -> 勾选态来源路径(没有勾选来源时不绑,selectedCount 恒 0) */
|
|
940
|
-
function toolbarGateBindings(ctx: Ctx, a: KitAction): Record<string, string> {
|
|
941
|
-
const g = actionGateOf(a);
|
|
942
|
-
const leaves = [...new Set([...gateLeafFields(g.disabledWhen), ...gateLeafFields(g.hiddenWhen)])];
|
|
943
|
-
const out: Record<string, string> = {};
|
|
944
|
-
if (leaves.includes('total')) out.gateTotal = ctx.totalPath;
|
|
945
|
-
if (ctx.options.selectedPath !== undefined && leaves.some((f) => f === 'selectedCount' || f.startsWith('selected.'))) out.gateSelected = ctx.options.selectedPath;
|
|
946
|
-
return out;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
967
|
const AUXILIARY_BUILTINS = new Set(['reload', 'reset', 'export', 'back']);
|
|
950
968
|
const AUXILIARY_IDS = new Set(['reload', 'refresh', 'reset', 'export', 'back']);
|
|
951
969
|
|
|
952
|
-
function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' {
|
|
953
|
-
if (a.tone === 'danger'
|
|
954
|
-
|
|
955
|
-
|
|
970
|
+
function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' | 'ghost' | 'tonal' {
|
|
971
|
+
if (a.tone === 'danger' || a.tone === 'neutral' || a.tone === 'primary' || a.tone === 'ghost' || a.tone === 'tonal') {
|
|
972
|
+
return a.tone;
|
|
973
|
+
}
|
|
974
|
+
if (a.tone === 'info' || a.tone === 'success') return 'primary';
|
|
975
|
+
if (a.tone === 'warning') return 'tonal';
|
|
956
976
|
if ((a.builtin !== undefined && AUXILIARY_BUILTINS.has(a.builtin)) || AUXILIARY_IDS.has(a.id)) {
|
|
957
977
|
return 'neutral';
|
|
958
978
|
}
|
|
@@ -969,11 +989,10 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
|
969
989
|
props: {
|
|
970
990
|
label: a.name,
|
|
971
991
|
variant: actionTone(a),
|
|
992
|
+
// 展示对象路径:路径取值为真时按钮置灰(Button 的 disabled prop)
|
|
993
|
+
...(a.disabled !== undefined && isViewPath(a.disabled) ? { disabled: viewPathToCore(a.disabled) } : {}),
|
|
972
994
|
// K1-2:Button 读 permission 服务,无权不渲染
|
|
973
995
|
...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
|
|
974
|
-
// GA2:状态条件(叶子 outcome.* 与页面读态 total / selectedCount / selected.<字段>),Button 订阅写入结果自行重判;
|
|
975
|
-
// 页面读态只在条件真用到时才绑(总条数 / 勾选态来源),免得无关按钮随数据白白重判
|
|
976
|
-
...(Object.keys(actionGateOf(a)).length > 0 ? { gate: actionGateOf(a), ...toolbarGateBindings(ctx, a) } : {}),
|
|
977
996
|
},
|
|
978
997
|
};
|
|
979
998
|
return host('Button', id);
|
|
@@ -1005,6 +1024,20 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1005
1024
|
scope: () => ir.scope,
|
|
1006
1025
|
};
|
|
1007
1026
|
|
|
1027
|
+
// 动作的状态绑定:on: toolbar 的 disabled 只许纯 view 路径(展示对象);on: row 的 hidden / disabled 只许纯 row 路径(业务对象逐行给出);其余位置不支持
|
|
1028
|
+
(options.actions ?? []).forEach((a, i) => {
|
|
1029
|
+
for (const key of ['disabled', 'hidden'] as const) {
|
|
1030
|
+
if (a[key] === undefined) continue;
|
|
1031
|
+
const at = `behavior.actions[${i}].${key}`;
|
|
1032
|
+
if (a.on === 'row') {
|
|
1033
|
+
// 行动作:row.<字段>(业务对象逐行给出)或 view.<成员>(展示对象给出,整页同值),二选一
|
|
1034
|
+
if (!isViewPath(a[key])) checkRowPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics, options.schema);
|
|
1035
|
+
}
|
|
1036
|
+
else if (a.on === 'toolbar' && key === 'disabled') checkViewPath(a[key], at, `动作 ${a.id} 的 ${key}`, ctx.diagnostics);
|
|
1037
|
+
else ctx.diagnostics.push({ code: 'KIT-VIEW-006', path: at, message: `动作 ${a.id} 的 ${key} 不支持 on: ${a.on}(toolbar 只支持 disabled,行级可用性写在 on: row 动作上)` });
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1008
1041
|
const parts: KitStaticEmit['parts'] = {};
|
|
1009
1042
|
const toolbar = renderToolbar(ctx, options.actions ?? []);
|
|
1010
1043
|
if (toolbar !== '') parts.toolbar = toolbar;
|
|
@@ -1031,18 +1064,27 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1031
1064
|
if (html !== '' && view.skeleton === true) {
|
|
1032
1065
|
const sid = `${viewAnchor(object, slot)}__skel`;
|
|
1033
1066
|
ctx.components.add('KitCollectionState');
|
|
1034
|
-
|
|
1067
|
+
const rsPaths = readStatePathsOf(object, summaryBase);
|
|
1068
|
+
ctx.show[sid] = { props: { data: summaryBase, config: { object, mode: 'single', readStatePath: rsPaths.readStatePath, errorMessagePath: rsPaths.errorMessagePath, loading: kitText('soma.kit.loading', undefined, ctx.options.locale ?? ''), skeleton: { kind: 'single' } } } };
|
|
1035
1069
|
html = `${host('KitCollectionState', sid)}<div data-kit-skeleton-body="">${html}</div>`;
|
|
1036
1070
|
}
|
|
1071
|
+
if (html !== '' && (view.surface !== undefined || view.emphasis !== undefined || view.highlight === true)) {
|
|
1072
|
+
const slotAttrs = [
|
|
1073
|
+
view.surface !== undefined ? `data-kit-part="${esc(kitContainerPartOf(view.surface))}" data-kit-surface="${esc(view.surface)}"` : '',
|
|
1074
|
+
view.emphasis !== undefined ? `data-kit-emphasis="${esc(view.emphasis)}"` : '',
|
|
1075
|
+
view.highlight === true ? 'data-kit-highlight="true"' : '',
|
|
1076
|
+
].filter(Boolean).join(' ');
|
|
1077
|
+
if (slotAttrs !== '') {
|
|
1078
|
+
html = html.replace(/^<([a-zA-Z0-9-]+)(\s|>)/, `<$1 ${slotAttrs}$2`);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1037
1081
|
// K-4:list / summary 的标题位(视图内静态文案,h3)
|
|
1038
1082
|
if (html !== '' && view.title !== undefined && view.title !== '') {
|
|
1039
|
-
html = `<h3 data-soma-id="${esc(viewAnchor(object, slot))}__title"${attr('class', VIEW_TITLE_CLASS)}>${esc(view.title)}</h3>${html}`;
|
|
1083
|
+
html = `<h3 data-soma-id="${esc(viewAnchor(object, slot))}__title" data-kit-part="${KIT_PART_TITLE_SECTION}"${attr('class', VIEW_TITLE_CLASS)}>${esc(view.title)}</h3>${html}`;
|
|
1040
1084
|
}
|
|
1041
1085
|
parts[slot] = html;
|
|
1042
1086
|
}
|
|
1043
1087
|
|
|
1044
|
-
scanShowForBang(ctx.diagnostics, ctx.show, 'show');
|
|
1045
|
-
|
|
1046
1088
|
const ordered = [parts.toolbar, ...SLOT_ORDER.map((s) => parts[s])].filter((p): p is string => p !== undefined && p !== '');
|
|
1047
1089
|
return {
|
|
1048
1090
|
parts,
|