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
|
@@ -12,23 +12,24 @@
|
|
|
12
12
|
|
|
13
13
|
import { regionMirrorStatePath } from 'soma-core';
|
|
14
14
|
import type { SomaScopeDecl, SomaScopeMirrorDecl, SomaScopeSliceDecl } from 'soma-core';
|
|
15
|
-
import { getCompileEnvelope, resolveEnvelopeSubPath } from '../
|
|
15
|
+
import { getCompileEnvelope, resolveEnvelopeSubPath } from '../shared/envelope';
|
|
16
16
|
import { KIT_CORE_MAPPING, KIT_FORM_LINKAGE, KIT_GRAMMAR } from './defaults';
|
|
17
|
-
import {
|
|
17
|
+
import { hintOf, nameSuggestion } from '../compile/hints';
|
|
18
|
+
import { checkFieldRules } from './field-value';
|
|
19
|
+
import { staticOptionsOf } from './linkage';
|
|
20
|
+
import { classifyParamBinding, viewPathToCore } from './view-binding';
|
|
18
21
|
import type {
|
|
19
|
-
KitBehavior,
|
|
22
|
+
KitBehavior, KitDiagnostic, KitListShape, KitObject, KitObjectIR, KitRenderContext, KitRule,
|
|
20
23
|
} from './types';
|
|
21
24
|
|
|
22
25
|
/** behavior 透传键的限值与闭集(读真源 formLinkage,不手抄) */
|
|
23
26
|
const PASS = KIT_FORM_LINKAGE.behaviorPassthrough as {
|
|
24
|
-
poll: { keys: string[]; whileKeys: string[]; everyMin: number; everyMax: number };
|
|
25
27
|
subscribe: { keys: string[]; transports: string[]; max: number };
|
|
26
28
|
validateOn: string[];
|
|
27
29
|
leaveGuard: { values: string[]; trueMeans: string };
|
|
28
30
|
unsupported: string[];
|
|
29
31
|
};
|
|
30
32
|
const LIST_ADAPTER = KIT_GRAMMAR.formLinkage.listAdapter as { listKeys: string[]; pathBase: string };
|
|
31
|
-
const REQUIRED_MESSAGE = KIT_GRAMMAR.formLinkage.conditions.requiredMessage as string;
|
|
32
33
|
|
|
33
34
|
// ---------------------------------------------------------------- 输出形状(core `data:` 片段)
|
|
34
35
|
|
|
@@ -53,8 +54,8 @@ export interface CoreFromEntry {
|
|
|
53
54
|
api: string;
|
|
54
55
|
into?: string;
|
|
55
56
|
params?: Record<string, string>;
|
|
56
|
-
/** 任一必填参数为空时 core 不发请求(对象落 idle
|
|
57
|
-
require?: string[]
|
|
57
|
+
/** 任一必填参数为空时 core 不发请求(对象落 idle);数组元素是「至少一个非空」分组 */
|
|
58
|
+
require?: Array<string | string[]>;
|
|
58
59
|
}
|
|
59
60
|
export interface CoreEndpoint { api: string; method: string }
|
|
60
61
|
export interface CoreWriteDecl {
|
|
@@ -70,12 +71,8 @@ export interface CoreWriteDecl {
|
|
|
70
71
|
}
|
|
71
72
|
export interface CoreDataObject {
|
|
72
73
|
from?: CoreFromEntry[];
|
|
73
|
-
/** behavior.adapter 原样编成(只作用于对象根) */
|
|
74
|
-
transform?: Record<string, string>;
|
|
75
74
|
write?: CoreWriteDecl;
|
|
76
75
|
fields: Record<string, CoreFieldDecl>;
|
|
77
|
-
/** behavior.poll 原样编成 core 的对象级轮询(core 运行时执行:命中 while 的行还在就每 every 秒重取) */
|
|
78
|
-
poll?: KitPollDecl;
|
|
79
76
|
/**
|
|
80
77
|
* 内部暂存(不是 core 键):behavior.subscribe。core 的 `subscribe:` 是页面顶层段,
|
|
81
78
|
* 由 compile-page 在合并后提到顶层(refresh 恒为本对象)并删掉这个键。
|
|
@@ -129,8 +126,6 @@ export interface KitCompiledData {
|
|
|
129
126
|
listShape: KitListShape;
|
|
130
127
|
/** 筛选字段名 -> 镜像状态路径(`page.region_mirror...`),供测试与 Pager 引用 */
|
|
131
128
|
mirrorPaths: Record<string, string>;
|
|
132
|
-
/** 已校验的 behavior.poll(已编进 data.<对象>.poll,由 core 执行);没写为 null */
|
|
133
|
-
poll: KitPollDecl | null;
|
|
134
129
|
diagnostics: KitDiagnostic[];
|
|
135
130
|
}
|
|
136
131
|
|
|
@@ -199,8 +194,16 @@ export function listShapeOf(behavior: KitBehavior, dataPath = getCompileEnvelope
|
|
|
199
194
|
|
|
200
195
|
// ---------------------------------------------------------------- 字段字典
|
|
201
196
|
|
|
197
|
+
function escapeRegExp(s: string): string {
|
|
198
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, (ch) => `\\${ch}`);
|
|
199
|
+
}
|
|
200
|
+
|
|
202
201
|
function coreRules(rule: KitRule): CoreRule[] {
|
|
203
|
-
const
|
|
202
|
+
const raw = rule as unknown as Record<string, unknown>;
|
|
203
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return [];
|
|
204
|
+
const src: Record<string, unknown> = { ...raw };
|
|
205
|
+
if (src.min_len === undefined && src.minLength !== undefined) src.min_len = src.minLength;
|
|
206
|
+
if (src.max_len === undefined && src.maxLength !== undefined) src.max_len = src.maxLength;
|
|
204
207
|
const condKeys = KIT_CORE_MAPPING.ruleKeys.filter((k) => k !== 'message' && src[k] !== undefined);
|
|
205
208
|
if (condKeys.length <= 1) {
|
|
206
209
|
const out: Record<string, unknown> = {};
|
|
@@ -213,46 +216,19 @@ function coreRules(rule: KitRule): CoreRule[] {
|
|
|
213
216
|
return condKeys.map((k) => ({ [k]: src[k], ...(message !== undefined ? { message } : {}) }) as unknown as CoreRule);
|
|
214
217
|
}
|
|
215
218
|
|
|
216
|
-
function
|
|
217
|
-
if (layout === undefined) return [];
|
|
218
|
-
switch (layout.kind) {
|
|
219
|
-
case 'grid':
|
|
220
|
-
case 'flex':
|
|
221
|
-
case 'table': return layout.cells;
|
|
222
|
-
case 'rows': return layout.rows.flat();
|
|
223
|
-
case 'groups': return layout.groups.flatMap((g) => cellsOfLayout(g.layout));
|
|
224
|
-
case 'cards':
|
|
225
|
-
case 'stack': return cellsOfLayout(layout.inner);
|
|
226
|
-
default: return [];
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/** form 视图里字段的 requiredWhen(已规整成 core 谓词):编成该字段的条件必填规则 */
|
|
231
|
-
function requiredWhenOf(ir: KitObjectIR): Map<string, Record<string, unknown>> {
|
|
232
|
-
const out = new Map<string, Record<string, unknown>>();
|
|
233
|
-
for (const c of cellsOfLayout(ir.views.form?.layout)) {
|
|
234
|
-
if (c.requiredWhen !== undefined && c.placeholder !== true && !out.has(c.field)) out.set(c.field, c.requiredWhen);
|
|
235
|
-
}
|
|
236
|
-
return out;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function compileFields(obj: KitObject, ir: KitObjectIR, diagnostics: KitDiagnostic[]): Record<string, CoreFieldDecl> {
|
|
219
|
+
function compileFields(obj: KitObject, diagnostics: KitDiagnostic[]): Record<string, CoreFieldDecl> {
|
|
240
220
|
const fields: Record<string, CoreFieldDecl> = {};
|
|
241
221
|
const optValue = KIT_CORE_MAPPING.optionKeys.value;
|
|
242
222
|
const optLabel = KIT_CORE_MAPPING.optionKeys.label;
|
|
243
|
-
const requiredWhen = requiredWhenOf(ir);
|
|
244
223
|
for (const [name, field] of Object.entries(obj.schema)) {
|
|
245
224
|
const type = KIT_CORE_MAPPING.fieldTypes[field.type];
|
|
246
225
|
if (type === undefined) {
|
|
247
|
-
diagnostics.push({ code: 'KIT-TYPE-001', message: `字段 ${name} 的类型 ${field.type} 未在映射表登记`, path: `schema.${name}.type
|
|
226
|
+
diagnostics.push({ code: 'KIT-TYPE-001', message: `字段 ${name} 的类型 ${field.type} 未在映射表登记`, path: `schema.${name}.type`, ...hintOf(nameSuggestion(String(field.type), Object.keys(KIT_CORE_MAPPING.fieldTypes))) });
|
|
248
227
|
continue;
|
|
249
228
|
}
|
|
229
|
+
checkFieldRules(name, field.rules, `schema.${name}.rules`, diagnostics);
|
|
250
230
|
const decl: CoreFieldDecl = { name: field.name, type };
|
|
251
|
-
const rules: CoreRule[] = field.rules
|
|
252
|
-
// requiredWhen:条件必填规则,core 校验时按(读态 ∪ model)求值 when,不成立本条不参与
|
|
253
|
-
const cond = requiredWhen.get(name);
|
|
254
|
-
if (cond !== undefined) rules.push({ required: true, message: REQUIRED_MESSAGE, when: cond } as unknown as CoreRule);
|
|
255
|
-
if (rules.length > 0) decl.rules = rules;
|
|
231
|
+
const rules: CoreRule[] = Array.isArray(field.rules) && field.rules.length > 0 ? field.rules.flatMap(coreRules) : [];
|
|
256
232
|
// 远程选项(options 写成对象)不进 core 字典:候选由 KitObjectForm 经 http 取
|
|
257
233
|
const staticOptions = staticOptionsOf(field);
|
|
258
234
|
// core 候选项的 key 必须非空(parseOptions 拒收空 key):「全部」这类空值筛选项只留在组件 props 里,不进字典
|
|
@@ -261,6 +237,20 @@ function compileFields(obj: KitObject, ir: KitObjectIR, diagnostics: KitDiagnost
|
|
|
261
237
|
// tone 只留在传给组件的 props 里(cell.props.options),core 字典里不带
|
|
262
238
|
decl.options = dictOptions.map((o) => ({ [optValue]: o.value, [optLabel]: o.label }) as unknown as CoreOption);
|
|
263
239
|
}
|
|
240
|
+
// 按字段类型自动补齐本征规则(接上 soma-foundation 值协议)
|
|
241
|
+
const rawAccess = field.access ?? field.permission;
|
|
242
|
+
const isReadOnly = rawAccess === 'read' || rawAccess === 'r' || field.readonly === true || (field.key === true && rawAccess === undefined);
|
|
243
|
+
const isSummaryOnlyView = obj.view !== undefined && obj.view.form === undefined && obj.view.list === undefined && Array.isArray(field.rules) && field.rules.length > 0;
|
|
244
|
+
if (!isReadOnly && !isSummaryOnlyView && !rules.some((r) => r.pattern !== undefined)) {
|
|
245
|
+
const label = field.name || name;
|
|
246
|
+
if (field.type === 'int') {
|
|
247
|
+
rules.push({ pattern: '^-?\\d+$', message: `${label}须为整数` });
|
|
248
|
+
} else if ((field.type === 'enum' || (field.type as string) === 'select') && dictOptions !== undefined && dictOptions.length > 0) {
|
|
249
|
+
const escaped = dictOptions.map((o) => escapeRegExp(String(o.value))).join('|');
|
|
250
|
+
rules.push({ pattern: `^(?:${escaped})$`, message: `${label}取值不在允许的选项范围内` });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (rules.length > 0) decl.rules = rules;
|
|
264
254
|
fields[name] = decl;
|
|
265
255
|
}
|
|
266
256
|
return fields;
|
|
@@ -288,52 +278,6 @@ function checkListShape(behavior: KitBehavior, diagnostics: KitDiagnostic[]): vo
|
|
|
288
278
|
}
|
|
289
279
|
}
|
|
290
280
|
|
|
291
|
-
/** behavior.adapter -> core transform;写法不对记 KIT-FORM-004 */
|
|
292
|
-
function compileAdapter(behavior: KitBehavior, diagnostics: KitDiagnostic[]): Record<string, string> | undefined {
|
|
293
|
-
const raw = behavior.adapter as unknown;
|
|
294
|
-
if (raw === undefined) return undefined;
|
|
295
|
-
if (!isRec(raw) || Object.keys(raw).length === 0) {
|
|
296
|
-
diagnostics.push({ code: 'KIT-FORM-004', message: 'behavior.adapter 必须是 { 目标字段: 源路径 } 的非空映射', path: 'behavior.adapter' });
|
|
297
|
-
return undefined;
|
|
298
|
-
}
|
|
299
|
-
const out: Record<string, string> = {};
|
|
300
|
-
for (const [k, v] of Object.entries(raw)) {
|
|
301
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k) || !nonEmpty(v)) {
|
|
302
|
-
diagnostics.push({ code: 'KIT-FORM-004', message: `behavior.adapter.${k}:目标须是标识符,源路径须是非空字符串`, path: `behavior.adapter.${k}` });
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
out[k] = v;
|
|
306
|
-
}
|
|
307
|
-
return Object.keys(out).length > 0 ? out : undefined;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/** behavior.poll 校验:字段须是枚举字段、in 为其候选值 */
|
|
311
|
-
function checkPoll(obj: KitObject, diagnostics: KitDiagnostic[]): KitPollDecl | null {
|
|
312
|
-
const raw = obj.behavior.poll as unknown;
|
|
313
|
-
if (raw === undefined) return null;
|
|
314
|
-
const bad = (message: string, path = 'behavior.poll'): null => { diagnostics.push({ code: 'KIT-FORM-005', message, path }); return null; };
|
|
315
|
-
if (!isRec(raw)) return bad('poll 必须是 { every, while: { field, in } }');
|
|
316
|
-
const extra = Object.keys(raw).filter((k) => !PASS.poll.keys.includes(k));
|
|
317
|
-
if (extra.length > 0) return bad(`poll 不认键 ${extra.join(' / ')}`);
|
|
318
|
-
const every = raw.every;
|
|
319
|
-
if (typeof every !== 'number' || !Number.isInteger(every) || every < PASS.poll.everyMin || every > PASS.poll.everyMax) {
|
|
320
|
-
return bad(`poll.every 必须是 ${PASS.poll.everyMin}~${PASS.poll.everyMax} 的整数秒`, 'behavior.poll.every');
|
|
321
|
-
}
|
|
322
|
-
const wh = raw.while;
|
|
323
|
-
if (!isRec(wh) || Object.keys(wh).some((k) => !PASS.poll.whileKeys.includes(k))) return bad('poll.while 必须是 { field, in }', 'behavior.poll.while');
|
|
324
|
-
const field = obj.schema[wh.field as string];
|
|
325
|
-
if (!nonEmpty(wh.field) || field === undefined) return bad(`poll.while.field 引用了 schema 中不存在的字段 ${String(wh.field)}`, 'behavior.poll.while.field');
|
|
326
|
-
if (field.type !== 'enum') return bad(`poll.while.field ${wh.field} 必须是枚举字段(type: enum)`, 'behavior.poll.while.field');
|
|
327
|
-
const list = wh.in;
|
|
328
|
-
if (!Array.isArray(list) || list.length === 0 || list.some((v) => !['string', 'number', 'boolean'].includes(typeof v))) {
|
|
329
|
-
return bad('poll.while.in 必须是非空的候选值数组', 'behavior.poll.while.in');
|
|
330
|
-
}
|
|
331
|
-
const known = (staticOptionsOf(field) ?? []).map((o) => String(o.value));
|
|
332
|
-
const unknown = (list as unknown[]).filter((v) => known.length > 0 && !known.includes(String(v)));
|
|
333
|
-
if (unknown.length > 0) return bad(`poll.while.in 的 ${unknown.map(String).join(' / ')} 不是字段 ${wh.field} 的候选值`, 'behavior.poll.while.in');
|
|
334
|
-
return { every, while: { field: wh.field, in: list as Array<string | number | boolean> } };
|
|
335
|
-
}
|
|
336
|
-
|
|
337
281
|
/** behavior.subscribe:单条或数组,refresh 恒为本对象 */
|
|
338
282
|
function compileSubscribe(behavior: KitBehavior, diagnostics: KitDiagnostic[]): CoreDataObject['__kit_subscribe'] {
|
|
339
283
|
const raw = behavior.subscribe as unknown;
|
|
@@ -406,12 +350,20 @@ function compileWrite(obj: KitObject, validateOn?: string[], diagnostics: KitDia
|
|
|
406
350
|
// core 语义:不写 only = 不限制;写了就是白名单。对象没有 schema、或没有任何字段声明 permission 时
|
|
407
351
|
// 没有“要排除的字段”,不生成 only(否则会编成 [] 把提交的字段全滤掉)。
|
|
408
352
|
const entries = Object.entries(obj.schema ?? {});
|
|
409
|
-
const anyDeclared = entries.some(([, f]) => f.permission !== undefined);
|
|
353
|
+
const anyDeclared = entries.some(([, f]) => f.permission !== undefined || f.access !== undefined || f.readonly !== undefined);
|
|
410
354
|
const out: CoreWriteDecl = { reload: 'self' };
|
|
411
355
|
if (anyDeclared) {
|
|
412
356
|
const only: string[] = [];
|
|
357
|
+
const primaryKey = typeof obj.primaryKey === 'string' && obj.primaryKey.trim() !== '' ? obj.primaryKey.trim() : 'id';
|
|
358
|
+
const allExplicitReadOnly = entries.every(([, f]) => {
|
|
359
|
+
const a = f.access ?? f.permission;
|
|
360
|
+
return a === 'read' || a === 'r' || f.readonly === true;
|
|
361
|
+
});
|
|
413
362
|
for (const [name, field] of entries) {
|
|
414
|
-
|
|
363
|
+
const a = field.access ?? field.permission;
|
|
364
|
+
const isRead = a === 'read' || a === 'r' || field.readonly === true;
|
|
365
|
+
const isWrite = a === 'write' || a === 'w' || a === 'create' || (a === undefined && !isRead && !allExplicitReadOnly && name !== primaryKey && field.key !== true && entries.some(([, f2]) => f2.access !== undefined || f2.readonly !== undefined));
|
|
366
|
+
if (field.key === true || isWrite) only.push(name);
|
|
415
367
|
}
|
|
416
368
|
// 白名单为空(字段全部显式只读且没有 key)= 对象实际不可写。core 解析阶段拒收空 only("only 必须是非空字段名数组"),
|
|
417
369
|
// 所以不生成 write:只读对象本就不该有写通道,比编出会让整页挂掉的 `only: []` 更符合"只读即只读"的口径;
|
|
@@ -496,6 +448,14 @@ export function compileData(obj: KitObject, ctx: KitRenderContext, ir: KitObject
|
|
|
496
448
|
const mirrors: SomaScopeMirrorDecl[] = [];
|
|
497
449
|
const mirrorPaths: Record<string, string> = {};
|
|
498
450
|
const params: Record<string, string> = { ...(obj.behavior.params ?? {}) };
|
|
451
|
+
// 请求参数绑展示对象成员(RV-1119):view.<成员> 编成 core 的读参数路径 $page.<成员>(成员值变化时由 core 驱动重取);
|
|
452
|
+
// row. / 取反 / 非纯 view 路径记诊断;原始运行期路径在 view-check 对着页面声明核(编译产物里 biz 层会合法注入镜像路径,这里不能拦)
|
|
453
|
+
for (const [k, raw] of Object.entries(params)) {
|
|
454
|
+
const b = classifyParamBinding(raw, `behavior.params.${k}`, false);
|
|
455
|
+
if (b.kind === 'view') params[k] = `$${viewPathToCore(b.path)}`;
|
|
456
|
+
else if (b.kind === 'row') diagnostics.push({ code: 'KIT-ROW-002', path: `behavior.params.${k}`, message: `behavior.params.${k} 不能绑 row.<字段>(请求参数没有行):写 view.<成员> 或字面量` });
|
|
457
|
+
else if (b.kind === 'invalid') diagnostics.push({ code: b.code, path: `behavior.params.${k}`, message: b.message });
|
|
458
|
+
}
|
|
499
459
|
for (const field of filterFields) {
|
|
500
460
|
const key = filterMirrorKey(field);
|
|
501
461
|
mirrors.push({ key, slice: 'filter', path: field, as: 'value' });
|
|
@@ -528,30 +488,80 @@ export function compileData(obj: KitObject, ctx: KitRenderContext, ir: KitObject
|
|
|
528
488
|
params[f.param] = `$${mirrorPaths[f.param]}`;
|
|
529
489
|
}
|
|
530
490
|
|
|
491
|
+
// requireParams / require_params 编译期校验(禁止静默过滤拼错的参数键)
|
|
492
|
+
const rawBehavior = obj.behavior as unknown as Record<string, unknown>;
|
|
493
|
+
if (rawBehavior.require_params !== undefined) {
|
|
494
|
+
diagnostics.push({
|
|
495
|
+
code: 'KIT-PAGE-001',
|
|
496
|
+
path: 'behavior.require_params',
|
|
497
|
+
message: '未知键 require_params(请改写为 behavior.requireParams)',
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
const rawReqParams = rawBehavior.requireParams;
|
|
501
|
+
const validReqParams: Array<string | string[]> = [];
|
|
502
|
+
if (rawReqParams !== undefined) {
|
|
503
|
+
if (!Array.isArray(rawReqParams)) {
|
|
504
|
+
diagnostics.push({
|
|
505
|
+
code: 'KIT-FORM-004',
|
|
506
|
+
path: 'behavior.requireParams',
|
|
507
|
+
message: 'behavior.requireParams 必须是非空字符串数组',
|
|
508
|
+
});
|
|
509
|
+
} else {
|
|
510
|
+
rawReqParams.forEach((k, i) => {
|
|
511
|
+
if (typeof k !== 'string' || k.trim() === '' || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) {
|
|
512
|
+
diagnostics.push({
|
|
513
|
+
code: 'KIT-FORM-004',
|
|
514
|
+
path: `behavior.requireParams[${i}]`,
|
|
515
|
+
message: `behavior.requireParams[${i}] 必须是合法的参数名标识符`,
|
|
516
|
+
});
|
|
517
|
+
} else if (!(k in params)) {
|
|
518
|
+
diagnostics.push({
|
|
519
|
+
code: 'KIT-FORM-004',
|
|
520
|
+
path: `behavior.requireParams[${i}]`,
|
|
521
|
+
message: `behavior.requireParams 的参数 "${k}" 不在该对象的请求参数(params / 筛选 / 分页 / 排序)中`,
|
|
522
|
+
});
|
|
523
|
+
} else {
|
|
524
|
+
validReqParams.push(k);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// behavior.require(J14,人写页的公开写法):与上面的内部 requireParams 并入同一个 core `require`;
|
|
531
|
+
// 写法 / 名字合法性由 closed-set 的 checkBehavior 报(KIT-OBJ-012),这里只收声明在 behavior.params 里的合法名字(不重复登记)。
|
|
532
|
+
if (Array.isArray(rawBehavior.require)) {
|
|
533
|
+
const declared = obj.behavior.params ?? {};
|
|
534
|
+
for (const k of rawBehavior.require) {
|
|
535
|
+
if (typeof k === 'string' && k in declared && !validReqParams.includes(k)) validReqParams.push(k);
|
|
536
|
+
// 「至少一个」分组(J17):整组合法(≥2 个不同、都在 params 里的标识符名)才直通 core,不合的由 closed-set 报 KIT-OBJ-012
|
|
537
|
+
else if (
|
|
538
|
+
Array.isArray(k) && k.length >= 2 && new Set(k).size === k.length &&
|
|
539
|
+
k.every((m) => typeof m === 'string' && m in declared)
|
|
540
|
+
) {
|
|
541
|
+
validReqParams.push([...(k as string[])]);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
531
546
|
// data.<对象>
|
|
532
|
-
const dataObject: CoreDataObject = { fields: compileFields(obj,
|
|
547
|
+
const dataObject: CoreDataObject = { fields: compileFields(obj, diagnostics) };
|
|
533
548
|
if (obj.behavior.from !== undefined) {
|
|
534
549
|
const entry: CoreFromEntry = { api: obj.behavior.from };
|
|
535
550
|
if (hasList(ir)) entry.into = KIT_CORE_MAPPING.fromWrap.listInto;
|
|
536
551
|
if (Object.keys(params).length > 0) entry.params = params;
|
|
537
|
-
|
|
538
|
-
if (req.length > 0) entry.require = req;
|
|
552
|
+
if (validReqParams.length > 0) entry.require = validReqParams;
|
|
539
553
|
dataObject.from = [entry];
|
|
540
554
|
}
|
|
541
555
|
const validateOn = checkPassthrough(obj.behavior, obj.behavior.write !== undefined, diagnostics);
|
|
542
556
|
const write = compileWrite(obj, validateOn, diagnostics);
|
|
543
557
|
if (write !== undefined) dataObject.write = write;
|
|
544
|
-
//
|
|
558
|
+
// 列表键与轮询 / 订阅的写法在这里一并校验
|
|
545
559
|
checkListShape(obj.behavior, diagnostics);
|
|
546
|
-
const transform = compileAdapter(obj.behavior, diagnostics);
|
|
547
|
-
if (transform !== undefined) dataObject.transform = transform;
|
|
548
560
|
const subscribe = compileSubscribe(obj.behavior, diagnostics);
|
|
549
561
|
if (subscribe !== undefined) dataObject.__kit_subscribe = subscribe;
|
|
550
562
|
// D8 syncUrl:镜像路径(页码 / 每页条数 / 排序 / 筛选字段)绑进页面 state.query,由 compile-page 提到顶层并补信封 query
|
|
551
563
|
const urlSync = compileUrlSync(obj.behavior, mirrorPaths, pager, sort, filterFields, diagnostics);
|
|
552
564
|
if (urlSync !== undefined) dataObject.__kit_url_sync = urlSync;
|
|
553
|
-
const poll = checkPoll(obj, diagnostics);
|
|
554
|
-
if (poll !== null) dataObject.poll = poll;
|
|
555
565
|
|
|
556
566
|
// scopes
|
|
557
567
|
const slices: SomaScopeSliceDecl[] = [];
|
|
@@ -575,5 +585,5 @@ export function compileData(obj: KitObject, ctx: KitRenderContext, ir: KitObject
|
|
|
575
585
|
? []
|
|
576
586
|
: [{ id: scope, object, slices, ...(mirrors.length > 0 ? { mirrors } : {}) }];
|
|
577
587
|
|
|
578
|
-
return { object, scope, data: { [object]: dataObject }, scopes, listShape, mirrorPaths,
|
|
588
|
+
return { object, scope, data: { [object]: dataObject }, scopes, listShape, mirrorPaths, diagnostics };
|
|
579
589
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// crud-bridge.ts:对象渲染层的请求体映射桥与读状态路径生成。
|
|
2
|
+
import { applyRequestPayloadMapping } from './request-actions';
|
|
3
|
+
|
|
4
|
+
export { applyRequestPayloadMapping };
|
|
5
|
+
|
|
6
|
+
export interface KitReadStatePaths {
|
|
7
|
+
readonly object: string;
|
|
8
|
+
readonly dataPath: string;
|
|
9
|
+
readonly readStatePath: string;
|
|
10
|
+
readonly dollarReadStatePath: string;
|
|
11
|
+
readonly errorMessagePath: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 判断对象是否声明了读数据源 behavior.from */
|
|
15
|
+
export function hasBehaviorFrom(behavior: { from?: unknown } | undefined): boolean {
|
|
16
|
+
if (!behavior || behavior.from === undefined || behavior.from === null) return false;
|
|
17
|
+
if (typeof behavior.from === 'string') return behavior.from.trim() !== '';
|
|
18
|
+
if (Array.isArray(behavior.from)) return behavior.from.length > 0;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 生成指定数据对象的标准读状态绑定路径 */
|
|
23
|
+
export function readStatePathsOf(objectName: string, basePath?: string): KitReadStatePaths {
|
|
24
|
+
const dataPath = basePath !== undefined && basePath !== '' ? basePath : `page.data.${objectName}`;
|
|
25
|
+
return {
|
|
26
|
+
object: objectName,
|
|
27
|
+
dataPath,
|
|
28
|
+
readStatePath: `${dataPath}.readState`,
|
|
29
|
+
dollarReadStatePath: `$data.${objectName}.readState`,
|
|
30
|
+
errorMessagePath: `${dataPath}.errorMessage`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 对象渲染的默认值与语法常量:闭集与类名读 spec/kit-grammar.json,数字读 design 的 kit-limits(soma-foundation/kit-limits),代码里不手抄数字与类名。
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
KIT_COLLECTION_LIMITS, KIT_FORM_LINKAGE_LIMITS, KIT_SKELETON_LIMITS, KIT_TREE_TABLE_LIMITS, KIT_UTILITY_SCALES, KIT_VIEW_DEFAULTS, KIT_WIDTH_LIMITS,
|
|
4
|
+
KIT_COLLECTION_LIMITS, KIT_FORM_LINKAGE_LIMITS, KIT_NINE_DIM_DOMAINS, KIT_SKELETON_LIMITS, KIT_TREE_TABLE_LIMITS, KIT_UTILITY_SCALES, KIT_VIEW_DEFAULTS, KIT_WIDTH_LIMITS,
|
|
5
5
|
} from 'soma-foundation/kit-limits';
|
|
6
6
|
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
7
7
|
import type { KitArrange, KitCollection, KitType, KitViewSlot } from './types';
|
|
@@ -54,7 +54,7 @@ export const KIT_WIDTH = {
|
|
|
54
54
|
wideTier: G.width.wideTier as string,
|
|
55
55
|
matrixMaxCols: KIT_WIDTH_LIMITS.matrixMaxCols as number,
|
|
56
56
|
colsAllowed: KIT_WIDTH_LIMITS.colsToParts.allowed as readonly number[],
|
|
57
|
-
tableFixedParts: KIT_WIDTH_LIMITS.tableFixedParts as { select: number; actions: number },
|
|
57
|
+
tableFixedParts: KIT_WIDTH_LIMITS.tableFixedParts as { select: number; actions: number; actionsWide: number; actionsWideFromInline: number },
|
|
58
58
|
tierOrder: G.width.tierOrder as readonly string[],
|
|
59
59
|
tierRem: KIT_UTILITY_SCALES.container.rem as Readonly<Record<string, number>>,
|
|
60
60
|
colsTable: KIT_WIDTH_LIMITS.colsTable as Readonly<Record<string, readonly number[] | string>>,
|
|
@@ -94,21 +94,33 @@ export interface KitClassDefaults {
|
|
|
94
94
|
tableInner: string;
|
|
95
95
|
tableHead: string;
|
|
96
96
|
tableRow: string;
|
|
97
|
-
tableHeadCompact: string;
|
|
98
|
-
tableHeadComfortable: string;
|
|
99
|
-
tableRowCompact: string;
|
|
100
|
-
tableRowComfortable: string;
|
|
101
97
|
tableRowStriped: string;
|
|
102
98
|
tableRowSelected: string;
|
|
103
99
|
/** 展开行 + 斑马纹:外壳加 group/row,内层行在偶数外壳下换悬停色(否则内层 hover 与外层底色相同) */
|
|
104
100
|
tableRowStripedExpandOuter: string;
|
|
105
101
|
tableRowStripedExpandInner: string;
|
|
102
|
+
/** 普通表格专用:行容器首子节点是 <template>,数据行从第 2 个子节点起,斑马纹改用奇数(odd);树表 / 虚拟表无 template,仍用 even 键 */
|
|
103
|
+
tableRowStripedAfterTemplate: string;
|
|
104
|
+
tableRowStripedExpandInnerAfterTemplate: string;
|
|
106
105
|
help: string;
|
|
107
106
|
tableActions: string;
|
|
107
|
+
/** 工具栏只有次要动作(无主操作):靠右的紧凑一行,不独占整行高 */
|
|
108
|
+
toolbarSecondary: string;
|
|
109
|
+
/** 次要工具栏并入列表标题行:标题在左、工具靠右同一行 */
|
|
110
|
+
toolbarTitleRow: string;
|
|
108
111
|
cardsList: string;
|
|
109
112
|
cardsItem: string;
|
|
110
113
|
stackList: string;
|
|
111
114
|
stackItem: string;
|
|
115
|
+
/** 紧凑列表(collection.type: compact-list):列表容器 / 条目(行高随密度令牌 py-N,选中态 data-kit-selected)/ 文字列 / 主标题 / 次要信息行 / 次要信息项 / 「·」分隔符 / 行操作壳 */
|
|
116
|
+
compactList: string;
|
|
117
|
+
compactItem: string;
|
|
118
|
+
compactBody: string;
|
|
119
|
+
compactTitle: string;
|
|
120
|
+
compactMeta: string;
|
|
121
|
+
compactMetaItem: string;
|
|
122
|
+
compactSep: string;
|
|
123
|
+
compactActions: string;
|
|
112
124
|
staticRoot: string;
|
|
113
125
|
groupsWrap: string;
|
|
114
126
|
groupSection: string;
|
|
@@ -128,6 +140,12 @@ export interface KitClassDefaults {
|
|
|
128
140
|
/** 滚动后固定区边缘的分隔线 + 阴影(wrap 上由 KitTableTools 标 data-kit-edge-l / -r) */
|
|
129
141
|
tableEdgeLeft: string;
|
|
130
142
|
tableEdgeRight: string;
|
|
143
|
+
/**
|
|
144
|
+
* 窄容器档(栅格表在表壳内横滚时)贴右固定的操作格:底色 = 所在行的实际底色(斑马纹 / 悬停 / 选中都随行,不另配色)——
|
|
145
|
+
* 格自身 bg-inherit,其下垫一层不透明表面(::before)挡住滚过来的内容,其上再叠一层 inherit(::after)还原行的半透明底色;
|
|
146
|
+
* 右侧还有被遮住的内容时(表壳带 data-kit-edge-r)起始侧出分隔线 + 阴影(同 tableEdgeRight);高度撑满行(行的纵向内边距由调用方用负外边距抵消)。调用方整串加窄档容器变体前缀。
|
|
147
|
+
*/
|
|
148
|
+
tableNarrowStickyEnd: string;
|
|
131
149
|
/** 省略列:单元格内文字单行截断(title 由 KitTableTools 补) */
|
|
132
150
|
tableCellEllipsis: string;
|
|
133
151
|
/** 工具栏密度切换的变体类(wrap 上标 data-kit-dense / data-kit-roomy) */
|
|
@@ -166,11 +184,12 @@ export const KIT_TABLE_EXT = {
|
|
|
166
184
|
actionsSteps: Readonly<Record<string, number>>; swap: { drop: readonly string[]; add: readonly string[] };
|
|
167
185
|
fixedValues: readonly ('left' | 'right')[]; alignValues: readonly ('start' | 'center' | 'end')[]; alignClass: Readonly<Record<string, string>>;
|
|
168
186
|
},
|
|
187
|
+
/** 窄容器栅格表(非滚动模式)的列轨参数,见 kit-limits collection.tableExt.narrowGrid */
|
|
188
|
+
narrowGrid: TX.narrowGrid as { headerFontStep: number; headerPadStep: number; tagFontStep: number; tagPadStep: number; dateFontStep: number; datePadStep: number; dateEms: Readonly<Record<string, number>>; floorStep: number; capStep: number; selectStep: number; gapStep: number; padStep: number; actionsStepMax: number; actionFontStep: number; actionGapStep: number; actionMoreStep: number; actionsSteps: Readonly<Record<string, number>> },
|
|
169
189
|
toolbarItems: TX.toolbarItems as readonly string[],
|
|
170
190
|
toolbarMax: TX.toolbarMax as number,
|
|
171
191
|
batchActionKeys: TX.batchActionKeys as readonly string[],
|
|
172
192
|
batchMax: TX.batchMax as number,
|
|
173
|
-
batchConfirmCount: TX.batchConfirmCount as string,
|
|
174
193
|
selectScopes: TX.selectScopes as readonly ('page' | 'all')[],
|
|
175
194
|
selectScopeDefault: TX.selectScopeDefault as 'page' | 'all',
|
|
176
195
|
summaryOps: TX.summaryOps as readonly ('sum' | 'avg' | 'min' | 'max' | 'count')[],
|
|
@@ -192,15 +211,13 @@ export const KIT_TABLE_EXT = {
|
|
|
192
211
|
export const KIT_SUMMARY_EMPTY = G.summaryEmpty as { emptyDefault: string; placeholderComponents: readonly string[]; hideEmptyForbiddenTypes: readonly string[]; slots: readonly string[] };
|
|
193
212
|
export const KIT_CLASS_DEFAULTS: Readonly<KitClassDefaults> = G.classDefaults as KitClassDefaults;
|
|
194
213
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
export
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
comfortable: { head: KIT_CLASS_DEFAULTS.tableHeadComfortable, row: KIT_CLASS_DEFAULTS.tableRowComfortable },
|
|
203
|
-
};
|
|
214
|
+
/**
|
|
215
|
+
* 工具栏「行高」切换的三档就是九维 density 枚举(真源 kit-nine-dim.json#dimensions.density),不另立名字;
|
|
216
|
+
* 默认档读语法真源 collectionKeys.toolbarDensity.default。表级密度键 collection.density 已删除(KIT-OBJ-011)。
|
|
217
|
+
*/
|
|
218
|
+
export type KitTableDensity = (typeof KIT_NINE_DIM_DOMAINS.density)[number];
|
|
219
|
+
export const KIT_TABLE_DENSITIES: readonly KitTableDensity[] = KIT_NINE_DIM_DOMAINS.density;
|
|
220
|
+
export const KIT_TABLE_DENSITY_DEFAULT: KitTableDensity = (G.collectionKeys.toolbarDensity as { default: KitTableDensity }).default;
|
|
204
221
|
|
|
205
222
|
// ---------------------------------------------------------------- kit -> core 映射(D 组消费)
|
|
206
223
|
|
|
@@ -230,6 +247,11 @@ export const KIT_TREE_TABLE = {
|
|
|
230
247
|
maxDepth: KIT_TREE_TABLE_LIMITS.maxDepth as number,
|
|
231
248
|
windowThreshold: KIT_TREE_TABLE_LIMITS.windowThreshold as number,
|
|
232
249
|
windowBatch: KIT_TREE_TABLE_LIMITS.windowBatch as number,
|
|
250
|
+
/** 树表列没写 width 份数时的默认权重(数值在 kit-limits#treeTable.columnWeights,判据在 kit-grammar#treeTable.columnWeightRules) */
|
|
251
|
+
columnWeights: KIT_TREE_TABLE_LIMITS.columnWeights as { identifier: number; long: number; text: number; date: number; short: number },
|
|
252
|
+
columnWeightRules: G.treeTable.columnWeightRules as {
|
|
253
|
+
identifierNamePattern: string; dateTypes: readonly string[]; shortTypes: readonly string[]; longTypes: readonly string[];
|
|
254
|
+
},
|
|
233
255
|
} as const;
|
|
234
256
|
|
|
235
257
|
export const KIT_SKELETON = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// 展示与状态(GC)的编译期校验:写死形状组件的 view.props 里新增的几组键。规则与图样读 spec/kit-grammar.json#staticProps.show,
|
|
2
|
-
//
|
|
2
|
+
// 本文件不手抄闭集与正则。几个诊断码:
|
|
3
3
|
// KIT-SHOW-001 CodeView 的 variants_from KIT-SHOW-002 RecordCard 的 outcome / secret_*
|
|
4
|
-
// KIT-SHOW-003 RowEditor 的 staged / value_key
|
|
4
|
+
// KIT-SHOW-003 RowEditor 的 staged / value_key
|
|
5
5
|
// KIT-SHOW-007 Transfer 的 confirm_remove / empty_selected_notice / empty_texts / outcome
|
|
6
6
|
// KIT-SHOW-008 RuleBuilder 的 fields[].type 不在闭集
|
|
7
|
-
// (KIT-SHOW-004 = 版本锁,在
|
|
7
|
+
// (KIT-SHOW-004 = 版本锁,在 compile-data.ts 的 write.version 里报。)
|
|
8
8
|
|
|
9
9
|
import { KIT_GRAMMAR } from './defaults';
|
|
10
10
|
import { noteOutcomeUse } from './action-gate';
|
|
@@ -20,7 +20,6 @@ const SHOW = ((KIT_GRAMMAR as Json).staticProps as Json).show as {
|
|
|
20
20
|
recordCard: { keys: readonly string[] };
|
|
21
21
|
rowEditor: { keys: readonly string[] };
|
|
22
22
|
transfer: { keys: readonly string[]; textKeys: readonly string[]; emptyTextsKeys: readonly string[] };
|
|
23
|
-
flowEditor: { adoptKeys: readonly string[] };
|
|
24
23
|
requestConsole: { targetsFromKeys: readonly string[] };
|
|
25
24
|
};
|
|
26
25
|
|
|
@@ -38,7 +37,7 @@ export function checkDisplayProps(form: KitViewForm, obj: KitObject, path: strin
|
|
|
38
37
|
|
|
39
38
|
if (component === 'CodeView' && props.variants_from !== undefined) {
|
|
40
39
|
if (!nonEmpty(props.variants_from) || !PATH.test(props.variants_from)) {
|
|
41
|
-
diags.push({ code: 'KIT-SHOW-001', path: `${at}.variants_from`, message: 'variants_from 必须是 data 里的点路径(如 clients 或 view.
|
|
40
|
+
diags.push({ code: 'KIT-SHOW-001', path: `${at}.variants_from`, message: 'variants_from 必须是 data 里的点路径(如 clients 或 data.tabs;以 view. 开头的值是展示对象绑定,不是 data 路径)' });
|
|
42
41
|
} else if (props.variants !== undefined) {
|
|
43
42
|
diags.push({ code: 'KIT-SHOW-001', path: `${at}.variants_from`, message: 'variants_from 与 variants 不能同写(页签要么写死在 props,要么来自数据)' });
|
|
44
43
|
}
|
|
@@ -146,24 +145,4 @@ export function checkDisplayProps(form: KitViewForm, obj: KitObject, path: strin
|
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
|
-
|
|
150
|
-
if (component === 'FlowEditor' && props.adopt !== undefined) {
|
|
151
|
-
const adopt = props.adopt;
|
|
152
|
-
if (!isRec(adopt)) {
|
|
153
|
-
diags.push({ code: 'KIT-SHOW-005', path: `${at}.adopt`, message: 'adopt 必须是对象 { from, path?, label? }' });
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
for (const k of Object.keys(adopt)) {
|
|
157
|
-
if (!SHOW.flowEditor.adoptKeys.includes(k)) diags.push({ code: 'KIT-SHOW-005', path: `${at}.adopt.${k}`, message: `adopt 的键 ${k} 不认识(可用:${SHOW.flowEditor.adoptKeys.join(' / ')})` });
|
|
158
|
-
}
|
|
159
|
-
if (!nonEmpty(adopt.from) || !NAME.test(adopt.from)) {
|
|
160
|
-
diags.push({ code: 'KIT-SHOW-005', path: `${at}.adopt.from`, message: 'adopt.from 必须是小写字母开头的标识符,等于某个 request 动作的 request.into' });
|
|
161
|
-
} else noteOutcomeUse(adopt.from, `${at}.adopt.from`);
|
|
162
|
-
if (adopt.path !== undefined && adopt.path !== '' && (!nonEmpty(adopt.path) || !PATH.test(adopt.path))) {
|
|
163
|
-
diags.push({ code: 'KIT-SHOW-005', path: `${at}.adopt.path`, message: 'adopt.path 必须是请求结果响应体里的点路径' });
|
|
164
|
-
}
|
|
165
|
-
if (adopt.label !== undefined && typeof adopt.label !== 'string') {
|
|
166
|
-
diags.push({ code: 'KIT-SHOW-005', path: `${at}.adopt.label`, message: 'adopt.label 必须是字符串' });
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
148
|
}
|