soma-kit 0.1.12 → 0.1.14
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 +5 -4
- package/bin/soma-kit.mjs +31 -1
- package/bin/soma.mjs +0 -0
- package/package.json +5 -4
- package/spec/generated/kit-app.schema.json +172 -4
- package/spec/generated/kit-page.schema.json +164 -5
- package/spec/kit-grammar.json +598 -96
- package/spec/kit-grammar.schema.json +12 -6
- package/src/app/app-config.ts +92 -8
- package/src/app/component-gate.ts +271 -13
- package/src/app/define-kit-app.ts +2 -2
- package/src/app/define-kit-view.ts +9 -5
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/index.ts +29 -5
- package/src/app/kit-view-context.ts +181 -15
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +55 -8
- package/src/app/theme-runtime.ts +4 -0
- package/src/base/action-busy.ts +101 -4
- package/src/base/action-slots.ts +13 -2
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/button.ts +62 -15
- package/src/base/check-core.ts +8 -0
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +21 -2
- package/src/base/color-picker.ts +10 -5
- package/src/base/command-palette.ts +1 -1
- package/src/base/context-menu.ts +10 -7
- package/src/base/date-range.ts +7 -7
- package/src/base/date.ts +55 -16
- package/src/base/delta.ts +72 -0
- package/src/base/end-edge.ts +61 -0
- package/src/base/fab.ts +1 -1
- package/src/base/gap-value.ts +168 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +95 -0
- package/src/base/index.ts +32 -9
- package/src/base/listbox-core.ts +6 -5
- package/src/base/loading-gate.ts +140 -87
- package/src/base/mentions.ts +2 -1
- package/src/base/menu-button.ts +16 -18
- package/src/base/menu-core.ts +37 -8
- package/src/base/motion/hover-3d.ts +1 -1
- package/src/base/motion/marquee.ts +1 -1
- package/src/base/otp.ts +5 -4
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/popover.ts +10 -9
- package/src/base/popup.ts +67 -8
- package/src/base/portal-core.ts +4 -0
- package/src/base/qty-stepper.ts +5 -5
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +19 -2
- package/src/base/rating.ts +11 -6
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +36 -24
- package/src/base/shared.ts +180 -36
- package/src/base/state-panel.ts +367 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +6 -6
- package/src/base/switch.ts +10 -5
- package/src/base/tag-input.ts +6 -6
- package/src/base/tag.ts +76 -41
- package/src/base/text.ts +43 -14
- package/src/base/time-picker.ts +7 -5
- package/src/base/tree-select.ts +6 -4
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +15 -9
- package/src/base/view-transition.ts +77 -0
- package/src/biz/approval-desk/shell.ts +15 -11
- package/src/biz/auth-panel/shell.ts +9 -7
- package/src/biz/category-crud/compile.ts +5 -4
- package/src/biz/category-crud/shell.ts +5 -3
- package/src/biz/checkout-page/compile.ts +2 -1
- package/src/biz/checkout-page/shell.ts +10 -8
- package/src/biz/compose.ts +2 -2
- package/src/biz/data-components.ts +4 -0
- package/src/biz/import-wizard/shell.ts +13 -10
- package/src/biz/landing-page/shell.ts +2 -2
- package/src/biz/link/hub.ts +23 -5
- package/src/biz/link/shared.ts +23 -12
- package/src/biz/master-sub/compile.ts +207 -16
- package/src/biz/master-sub/detail-head.ts +61 -0
- package/src/biz/master-sub/index.ts +7 -3
- package/src/biz/master-sub/shell.ts +133 -24
- package/src/biz/multi-board/compile.ts +167 -9
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +1 -1
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +94 -23
- package/src/biz/notification-center/shell.ts +10 -7
- package/src/biz/page-templates/domain-templates.ts +2 -2
- package/src/biz/page-templates/result-page/shell.ts +4 -3
- package/src/biz/page-templates/sign-in-page/shell.ts +16 -16
- package/src/biz/record-detail/compile.ts +2 -2
- package/src/biz/record-detail/shell.ts +13 -10
- package/src/biz/settings-center/compile.ts +2 -1
- package/src/biz/settings-center/shell.ts +12 -9
- package/src/biz/shared/action-host.ts +6 -0
- package/src/biz/shared/compile-helpers.ts +97 -0
- package/src/biz/shared/coordinator.ts +7 -30
- package/src/biz/shared/index.ts +5 -0
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +281 -0
- package/src/biz/shared/overlay-shell.ts +142 -11
- package/src/biz/shared/pipes.ts +11 -5
- package/src/biz/shared/remove-wire.ts +4 -19
- package/src/biz/shared/runtime-hub.ts +10 -0
- package/src/biz/single-form/compile.ts +3 -2
- package/src/biz/single-form/shell.ts +9 -6
- package/src/biz/standard-crud/compile.ts +36 -161
- package/src/biz/standard-crud/shell.ts +23 -60
- package/src/biz/standard-crud/summary.ts +40 -0
- package/src/biz/step-form/shell.ts +15 -13
- package/src/biz/types.ts +6 -1
- package/src/cli/kit-cli.ts +138 -13
- package/src/cli/kit-init.ts +6 -1
- 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/view-writes.ts +69 -60
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/closed-set.ts +65 -4
- package/src/compile/compile-page.ts +66 -11
- package/src/compile/component-candidates.ts +14 -1
- package/src/compile/fragment.ts +11 -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 +267 -0
- package/src/compile/layout-lint/rules-form.ts +191 -0
- package/src/compile/layout-lint/rules-table.ts +278 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -0
- package/src/compile/page-composition.ts +189 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/remove-guard.ts +10 -7
- package/src/compile/styles.ts +46 -8
- package/src/compile/types.ts +16 -2
- package/src/compile/view-check.ts +149 -16
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +9 -2
- package/src/data/approval-flow.ts +5 -2
- package/src/data/assignment-picker.ts +59 -28
- package/src/data/async-result-panel.ts +49 -3
- package/src/data/breadcrumbs.ts +3 -2
- package/src/data/calendar.ts +8 -3
- package/src/data/carousel.ts +10 -6
- package/src/data/chart.ts +744 -46
- package/src/data/checklist.ts +22 -6
- package/src/data/code-view.ts +8 -4
- package/src/data/comment-thread.ts +3 -2
- package/src/data/confirm-dialog.ts +72 -25
- package/src/data/context-menu.ts +3 -3
- package/src/data/dock.ts +1 -1
- package/src/data/embed.ts +231 -29
- package/src/data/field-mapper.ts +7 -4
- package/src/data/flow-editor-contract.ts +7 -0
- package/src/data/flow-editor.ts +26 -9
- package/src/data/flow-node-options.ts +33 -3
- package/src/data/footer.ts +2 -0
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +4 -1
- package/src/data/image-viewer.ts +7 -4
- package/src/data/index.ts +16 -4
- package/src/data/item-list.ts +27 -12
- package/src/data/kanban.ts +41 -10
- package/src/data/matrix.ts +391 -0
- package/src/data/media-grid.ts +6 -1
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +60 -16
- package/src/data/mockup.ts +5 -1
- package/src/data/modal-dialog.ts +146 -26
- package/src/data/navbar.ts +8 -6
- package/src/data/notice-list.ts +301 -0
- package/src/data/notify-renderer.ts +21 -6
- package/src/data/object-form.ts +409 -87
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +19 -8
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +36 -11
- package/src/data/permission-tree.ts +52 -23
- package/src/data/pricing-table.ts +22 -11
- package/src/data/prompt-dialog.ts +165 -0
- package/src/data/reaction-bar.ts +6 -4
- package/src/data/record-card.ts +40 -7
- package/src/data/record-picker.ts +13 -7
- package/src/data/resident.ts +8 -0
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +17 -1
- package/src/data/row-editor.ts +77 -24
- package/src/data/rule-builder.ts +14 -9
- package/src/data/shape-util.ts +27 -12
- package/src/data/stat-group.ts +459 -74
- package/src/data/static-lazy.ts +5 -0
- package/src/data/static-registry.ts +8 -0
- package/src/data/steps.ts +8 -3
- package/src/data/survey.ts +7 -4
- package/src/data/system-switcher.ts +3 -2
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +17 -6
- package/src/data/tour-guide.ts +3 -2
- package/src/data/transfer.ts +40 -16
- package/src/data/tree-table.ts +65 -37
- package/src/data/tree.ts +22 -2
- package/src/data/virtual-rows.ts +21 -11
- package/src/data/wrapped-candidates.ts +32 -1
- package/src/frames/index.ts +1 -0
- package/src/frames/list-summary.ts +100 -0
- package/src/frames/page-bar.ts +7 -14
- package/src/frames/page-status.ts +7 -5
- package/src/frames/shared.ts +34 -13
- package/src/frames/split-frame/shell.ts +1 -1
- package/src/frames/tabs-frame/shell.ts +9 -6
- package/src/frames/tabs-frame/wiring.ts +1 -0
- package/src/frames/top-main-frame.ts +3 -3
- package/src/frames/types.ts +3 -1
- package/src/frames/workspace-frame/extras.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +4 -4
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +168 -44
- package/src/generated/kit-grammar-runtime.ts +390 -59
- package/src/i18n/kit-text.ts +90 -4
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/object-renderer/action-group.ts +139 -0
- package/src/object-renderer/action-more.ts +144 -0
- package/src/object-renderer/arrange.ts +71 -7
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +264 -62
- package/src/object-renderer/collection-table.ts +177 -5
- package/src/object-renderer/collection.ts +188 -37
- package/src/object-renderer/compile-data.ts +28 -3
- package/src/object-renderer/defaults.ts +27 -2
- package/src/object-renderer/display-checks.ts +1 -1
- package/src/object-renderer/emit-events.ts +43 -9
- package/src/object-renderer/emit-object.ts +4 -0
- package/src/object-renderer/emit-static.ts +434 -41
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/form-detail.ts +1 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +5 -0
- package/src/object-renderer/layout-facts.ts +394 -0
- package/src/object-renderer/layout-plan.ts +225 -0
- package/src/object-renderer/layout-plan.types.ts +59 -0
- package/src/object-renderer/parts.ts +6 -7
- package/src/object-renderer/render-object.ts +107 -46
- package/src/object-renderer/request-actions.ts +4 -2
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +172 -32
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +62 -30
- package/src/object-renderer/types.ts +84 -13
- package/src/object-renderer/view-binding.ts +205 -8
- package/src/page-target/intent-schema.ts +11 -0
- package/src/page-target/target.ts +5 -1
- package/src/recipes/container.ts +77 -1
- package/src/recipes/control.ts +76 -116
- package/src/recipes/emphasis.ts +56 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +72 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +120 -17
- package/src/recipes/placeholder.ts +95 -0
- package/src/recipes/rail-grid.ts +48 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +40 -21
- package/src/recipes/status.ts +147 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +146 -3
- package/src/recipes/tabs.ts +49 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +30 -37
- package/src/shared/confirm-decl.ts +118 -0
- package/src/shared/envelope.ts +2 -2
- package/src/shared/paged-list-adapter.ts +15 -240
- package/src/shared/theme-runtime-shared.ts +6 -1
- package/src/theme/index.ts +1 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +384 -13
- package/src/theme/kit-theme.tpl +384 -13
- package/src/theme/nine-dim-structure.ts +244 -7
- package/src/theme/surface-layers.ts +10 -1
- package/src/theme/theme-tokens.ts +63 -16
- package/src/theme/theme-types.ts +32 -0
- package/src/theme/typography.ts +21 -17
- package/src/biz/shared/remove-key.ts +0 -6
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
// 接口必须直接返回对象(StatGroup,accept: single)或数组(Chart,accept: list);只有 list 视图的面板才走 { rows, total } 信封。
|
|
16
16
|
// · 筛选对象没有 from,其 data 对象只有 fields(core 注册已确认可收)。
|
|
17
17
|
|
|
18
|
+
import { KIT_ARRANGE } from 'soma-foundation/arrange';
|
|
18
19
|
import { filterAnchor } from '../../object-renderer/compile-data';
|
|
19
20
|
import { emitObject } from '../../object-renderer/emit-object';
|
|
21
|
+
import { groupTabsFrame } from '../../object-renderer/emit-static';
|
|
22
|
+
import { KIT_CLASS_DEFAULTS } from '../../object-renderer/defaults';
|
|
20
23
|
import { dropSliceReload, registerSliceReload } from '../../object-renderer/filter-reload';
|
|
21
24
|
import { checkClasses } from '../../object-renderer/merge-class';
|
|
22
25
|
import type { KitObject } from '../../object-renderer/types';
|
|
@@ -30,14 +33,36 @@ import {
|
|
|
30
33
|
type FieldSlots, type Rec,
|
|
31
34
|
} from '../link/shared';
|
|
32
35
|
import { MultiObjectBoard } from './index';
|
|
36
|
+
import { KIT_BOARD_PROSE_CLASS_CANDIDATES } from './prose-fold';
|
|
33
37
|
import {
|
|
34
|
-
MULTI_BOARD_AREAS, MULTI_BOARD_CLASS, MULTI_BOARD_GRID_SPANS, MULTI_BOARD_SPANS,
|
|
38
|
+
appendPanelFooter, boardGridHtml, MULTI_BOARD_AREAS, MULTI_BOARD_CLASS, MULTI_BOARD_GRID_SPANS, MULTI_BOARD_SPANS, multiBoardHtml, multiBoardIds,
|
|
35
39
|
type BoardPanelBlock,
|
|
36
40
|
} from './shell';
|
|
41
|
+
import { appRolesOf, boardCompositionNodes, boardPanelKind, composeBoard } from './composition';
|
|
37
42
|
|
|
38
43
|
/** 面板里 builtin 动作的闭集:看板没有表单 / 浮层,只许刷新 */
|
|
39
44
|
const PANEL_BUILTINS: ReadonlySet<string> = new Set(['reload']);
|
|
40
45
|
|
|
46
|
+
/** 面板是不是「collapse 的 NoticeList、无标题、不改跨度 / 类」:是则返回 props 所在位置(view 散键或 view.list) */
|
|
47
|
+
function noticeFooterHolder(raw: Rec): 'view' | 'list' | null {
|
|
48
|
+
if (typeof raw.title === 'string' && raw.title !== '') return null;
|
|
49
|
+
if (raw.span !== undefined || raw.class !== undefined || !isRec(raw.view)) return null;
|
|
50
|
+
const v = raw.view as Rec;
|
|
51
|
+
const at = v.staticComponent === 'NoticeList' ? 'view' : isRec(v.list) && (v.list as Rec).staticComponent === 'NoticeList' ? 'list' : null;
|
|
52
|
+
if (at === null) return null;
|
|
53
|
+
const holder = at === 'view' ? v : (v.list as Rec);
|
|
54
|
+
return isRec(holder.props) && (holder.props as Rec).collapse === true ? at : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 复制面板声明并给 NoticeList 写 footer: true(不改原声明) */
|
|
58
|
+
function withNoticeFooter(raw: Rec): Rec {
|
|
59
|
+
const at = noticeFooterHolder(raw);
|
|
60
|
+
const v = raw.view as Rec;
|
|
61
|
+
if (at === 'view') return { ...raw, view: { ...v, props: { ...(v.props as Rec), footer: true } } };
|
|
62
|
+
const list = v.list as Rec;
|
|
63
|
+
return { ...raw, view: { ...v, list: { ...list, props: { ...(list.props as Rec), footer: true } } } };
|
|
64
|
+
}
|
|
65
|
+
|
|
41
66
|
export function boardFilterName(pageId: string): string {
|
|
42
67
|
return bizObjectName(pageId, 'filter');
|
|
43
68
|
}
|
|
@@ -80,6 +105,23 @@ export function compileMultiBoard(input: KitBizInput, ctx: KitBizContext): KitFr
|
|
|
80
105
|
else out.diagnostics.push(...checkClasses(s.class, `${at}.class`));
|
|
81
106
|
}
|
|
82
107
|
if (s.title !== undefined && typeof s.title !== 'string') fail('KIT-PAGE-001', `panels.${n}.title 必须是字符串`, `${at}.title`);
|
|
108
|
+
if (s.group !== undefined && (typeof s.group !== 'string' || s.group.trim() === '')) {
|
|
109
|
+
fail('KIT-PAGE-001', `panels.${n}.group 必须是非空字符串(面板组名,同名面板收进页内页签的同一签)`, `${at}.group`);
|
|
110
|
+
}
|
|
111
|
+
if (s.head !== undefined) {
|
|
112
|
+
const host = typeof s.head === 'string' ? s.head.trim() : '';
|
|
113
|
+
const hostRaw = host === '' ? undefined : rawPanels[host];
|
|
114
|
+
if (host === '' || !isRec(hostRaw)) {
|
|
115
|
+
fail('KIT-PAGE-001', `panels.${n}.head 必须是另一个面板的名字(面板头控件槽位:本面板的控件画在宿主面板标题行右侧)`, `${at}.head`);
|
|
116
|
+
} else if (host === n || hostRaw.head !== undefined) {
|
|
117
|
+
fail('KIT-PAGE-001', `panels.${n}.head 不能指向自己或另一个面板头控件("${host}")`, `${at}.head`);
|
|
118
|
+
} else if (!isStatic) {
|
|
119
|
+
fail('KIT-PAGE-001', `panels.${n} 是面板头控件,必须是写死形状组件(staticComponent:SegmentedSwitch / MetaAction / ScopeSwitch 等)`, `${at}.view`);
|
|
120
|
+
}
|
|
121
|
+
for (const k of ['title', 'span', 'class', 'group'] as const) {
|
|
122
|
+
if (s[k] !== undefined) fail('KIT-PAGE-001', `panels.${n} 是面板头控件,不写 ${k}(位置与分组随宿主面板 "${host}")`, `${at}.${k}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
83
125
|
}
|
|
84
126
|
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
85
127
|
|
|
@@ -123,9 +165,14 @@ export function compileMultiBoard(input: KitBizInput, ctx: KitBizContext): KitFr
|
|
|
123
165
|
}
|
|
124
166
|
|
|
125
167
|
// ---- 展示对象
|
|
126
|
-
const panels: Array<{ name: string; object: string; scope: string; obj: KitObject; title: string; span: number; class: string; hasFrom: boolean }> = [];
|
|
168
|
+
const panels: Array<{ name: string; object: string; scope: string; obj: KitObject; title: string; span: number | undefined; class: string; group: string; footer: boolean; hasFrom: boolean; headOf: string }> = [];
|
|
127
169
|
for (const n of panelNames) {
|
|
128
|
-
|
|
170
|
+
let raw = rawPanels[n] as unknown as Rec;
|
|
171
|
+
const headOf = typeof raw.head === 'string' ? raw.head.trim() : '';
|
|
172
|
+
// 数据说明归属它所说明的面板:紧跟在某面板之后(同组)、无标题、collapse 的 NoticeList 面板并为前一面板的页脚(面板头控件不是面板,不打断「紧跟」)
|
|
173
|
+
const prev = [...panels].reverse().find((x) => x.headOf === '');
|
|
174
|
+
const asFooter = headOf === '' && prev !== undefined && prev.group === (typeof raw.group === 'string' ? raw.group.trim() : '') && noticeFooterHolder(raw) !== null;
|
|
175
|
+
if (asFooter) raw = withNoticeFooter(raw);
|
|
129
176
|
const own = isRec(raw.behavior) && isRec((raw.behavior as Rec).params) ? ((raw.behavior as Rec).params as Rec) : {};
|
|
130
177
|
const params: Record<string, string> = {};
|
|
131
178
|
for (const [k, v] of Object.entries(filterParams)) if (!(k in own)) params[k] = v;
|
|
@@ -150,24 +197,120 @@ export function compileMultiBoard(input: KitBizInput, ctx: KitBizContext): KitFr
|
|
|
150
197
|
scope: `${object}_scope`,
|
|
151
198
|
obj: norm.obj,
|
|
152
199
|
title: typeof raw.title === 'string' ? raw.title : '',
|
|
153
|
-
span: typeof raw.span === 'number' ? raw.span :
|
|
200
|
+
span: typeof raw.span === 'number' ? raw.span : undefined,
|
|
154
201
|
class: typeof raw.class === 'string' ? raw.class : '',
|
|
202
|
+
group: typeof raw.group === 'string' ? raw.group.trim() : '',
|
|
203
|
+
footer: asFooter,
|
|
155
204
|
hasFrom: norm.obj.behavior.from !== undefined,
|
|
205
|
+
headOf,
|
|
156
206
|
});
|
|
157
207
|
}
|
|
158
208
|
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
159
209
|
|
|
210
|
+
// ---- 页面构成(C1–C7):面板声明 → 构成节点 → solveComposition(角色 / 附着 / 强调级 / 容器 / 栅格份数 / hero),编译期定,运行时不测量
|
|
211
|
+
const plan = composeBoard(boardCompositionNodes(
|
|
212
|
+
panels.filter((p) => !p.footer).map((p) => ({ name: p.name, kind: boardPanelKind(rawPanels[p.name] as unknown as Rec), group: p.group, head: p.headOf, span: p.span })),
|
|
213
|
+
appRolesOf(ctx.staticComponents),
|
|
214
|
+
));
|
|
215
|
+
|
|
160
216
|
const fieldSteps: FieldSlots = [];
|
|
161
217
|
const blocks: BoardPanelBlock[] = [];
|
|
218
|
+
const heroItems: Array<{ title: string; html: string; name: string; kind: string }> = [];
|
|
219
|
+
/** 概况条成员的范围切换类控件(head-slot):上移到页头一行(标题右侧),不留在概况条里 */
|
|
220
|
+
const heroHeads: string[] = [];
|
|
221
|
+
/** 宿主面板名 -> 面板块(面板头控件的落点;并为页脚的面板不是宿主) */
|
|
222
|
+
const blockOf = new Map<string, BoardPanelBlock>();
|
|
223
|
+
const heads = new Map<string, string[]>();
|
|
224
|
+
const bands = new Map<string, string[]>();
|
|
225
|
+
const noteFooters = new Map<string, string[]>();
|
|
226
|
+
/** 构成分析附着(未显式写 head):宿主若不是独立面板(hero / 已并为页脚)则退回独立成块,不报错 */
|
|
227
|
+
const derivedAttach = new Map<string, { to: string; as: string; html: string; block: BoardPanelBlock }>();
|
|
162
228
|
for (const p of panels) {
|
|
163
229
|
const m = emitMember(out, { object: p.object, scope: p.scope, obj: p.obj, ctx, link, hubId: ids.coord, fieldSteps });
|
|
164
|
-
|
|
230
|
+
const pl = p.footer ? undefined : plan.placements[p.name];
|
|
231
|
+
// 面板头控件:不成面板,整块 HTML 放进宿主面板标题行右侧(宿主在后面声明也行,下面统一挂);概况类的头带挂在标题行下,说明类并为宿主页脚
|
|
232
|
+
if (p.headOf !== '') {
|
|
233
|
+
const headHtml = [m.r.parts.toolbar ?? '', m.r.parts.filter ?? '', m.listHtml, m.r.parts.summary ?? ''].filter((x) => x !== '').join('');
|
|
234
|
+
const as = pl?.attach?.as ?? 'head-slot';
|
|
235
|
+
const target = as === 'head-band' ? bands : as === 'footer' ? noteFooters : heads;
|
|
236
|
+
target.set(p.headOf, [...(target.get(p.headOf) ?? []), headHtml]);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
// 有标题:工具栏并入标题行右侧;无标题:工具栏仍在面板内容最前
|
|
240
|
+
const toolbarInTitle = p.title !== '' && (m.r.parts.toolbar ?? '') !== '';
|
|
241
|
+
const html = [toolbarInTitle ? '' : m.r.parts.toolbar ?? '', m.r.parts.filter ?? '', m.listHtml, m.r.parts.summary ?? ''].filter((x) => x !== '').join('\n');
|
|
242
|
+
if (p.footer && blocks.length > 0) {
|
|
243
|
+
appendPanelFooter(blocks[blocks.length - 1]!, html);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
// 概况类(hero 槽):合成页面唯一的一条概况条,不成面板
|
|
247
|
+
if (pl?.slot === 'hero') {
|
|
248
|
+
heroItems.push({ title: p.title, html, name: p.name, kind: boardPanelKind(rawPanels[p.name] as unknown as Rec) });
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const block: BoardPanelBlock = {
|
|
165
252
|
title: p.title,
|
|
166
|
-
|
|
167
|
-
|
|
253
|
+
...(toolbarInTitle ? { toolbar: m.r.parts.toolbar! } : {}),
|
|
254
|
+
html,
|
|
255
|
+
span: pl?.span ?? KIT_ARRANGE.composition.span.total,
|
|
256
|
+
emphasis: (pl?.emphasis ?? 'secondary') as NonNullable<BoardPanelBlock['emphasis']>,
|
|
257
|
+
container: pl?.container === 'plain' ? 'plain' : 'card',
|
|
168
258
|
...(p.class !== '' ? { class: p.class } : {}),
|
|
169
|
-
|
|
259
|
+
...(p.group !== '' ? { group: p.group } : {}),
|
|
260
|
+
};
|
|
261
|
+
// 构成分析附着(作者没写 head):控件进宿主标题行、说明并为宿主页脚;宿主不是独立面板时在下面退回独立成块
|
|
262
|
+
const att = pl?.attach;
|
|
263
|
+
if (att !== undefined && att !== null && (att.as === 'head-slot' || att.as === 'footer')) {
|
|
264
|
+
derivedAttach.set(p.name, { to: att.to, as: att.as, html: [m.r.parts.toolbar ?? '', m.r.parts.filter ?? '', m.listHtml, m.r.parts.summary ?? ''].filter((x) => x !== '').join(''), block });
|
|
265
|
+
blocks.push(block);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
blocks.push(block);
|
|
269
|
+
blockOf.set(p.name, block);
|
|
270
|
+
}
|
|
271
|
+
// 推导的附着落位:宿主是独立面板才并入,否则保留为独立块
|
|
272
|
+
for (const [name, a] of derivedAttach) {
|
|
273
|
+
const host = blockOf.get(a.to);
|
|
274
|
+
if (host === undefined) { blockOf.set(name, a.block); continue; }
|
|
275
|
+
blocks.splice(blocks.indexOf(a.block), 1);
|
|
276
|
+
if (a.as === 'footer') appendPanelFooter(host, a.html);
|
|
277
|
+
else host.head = `${host.head ?? ''}${a.html}`;
|
|
278
|
+
}
|
|
279
|
+
// 概况条成员也可以是宿主:控件(head-slot)画成成员内容上方靠右的一行、头带 / 页脚说明接在内容前 / 后
|
|
280
|
+
const heroHost = (host: string): { html: string } | undefined => heroItems.find((h) => h.name === host);
|
|
281
|
+
// 概况条成员的头控件(范围切换):整块上移页头(hoist 标记,页面编译搬进 <header> 标题右侧;没有页头时留在原位靠右一行)
|
|
282
|
+
for (const [host, list] of heads) { if (heroHost(host) !== undefined) { heroHeads.push(list.join('')); heads.delete(host); } }
|
|
283
|
+
for (const [host, list] of bands) { const h = heroHost(host); if (h !== undefined) { h.html = `${h.html}${list.join('')}`; bands.delete(host); } }
|
|
284
|
+
for (const [host, list] of noteFooters) { const h = heroHost(host); if (h !== undefined) { h.html = `${h.html}${list.map((x) => `<div data-kit-panel-footer="">${x}</div>`).join('')}`; noteFooters.delete(host); } }
|
|
285
|
+
let headFailed = false;
|
|
286
|
+
for (const [host, list] of heads) {
|
|
287
|
+
const block = blockOf.get(host);
|
|
288
|
+
if (block === undefined) {
|
|
289
|
+
fail('KIT-PAGE-001', `面板头控件指向的宿主面板 "${host}" 不是独立面板(并为页脚的说明面板不能作宿主)`, `product.objects.panels.${host}`);
|
|
290
|
+
headFailed = true;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
block.head = `${block.head ?? ''}${list.join('')}`;
|
|
170
294
|
}
|
|
295
|
+
for (const [host, list] of bands) {
|
|
296
|
+
const block = blockOf.get(host);
|
|
297
|
+
if (block === undefined) {
|
|
298
|
+
fail('KIT-PAGE-001', `头带指向的宿主面板 "${host}" 不是独立面板`, `product.objects.panels.${host}`);
|
|
299
|
+
headFailed = true;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
block.band = list.join('');
|
|
303
|
+
}
|
|
304
|
+
for (const [host, list] of noteFooters) {
|
|
305
|
+
const block = blockOf.get(host);
|
|
306
|
+
if (block === undefined) {
|
|
307
|
+
fail('KIT-PAGE-001', `页脚说明指向的宿主面板 "${host}" 不是独立面板`, `product.objects.panels.${host}`);
|
|
308
|
+
headFailed = true;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
for (const h of list) appendPanelFooter(block, h);
|
|
312
|
+
}
|
|
313
|
+
if (headFailed) return finishBizCompile(out, '');
|
|
171
314
|
if (fieldSteps.length > 0) {
|
|
172
315
|
fail('KIT-BIZ-003', '看板面板的 summary 不支持字段动作(请改用工具栏动作或列表行动作)', 'product.objects.panels');
|
|
173
316
|
return finishBizCompile(out, '');
|
|
@@ -201,6 +344,9 @@ export function compileMultiBoard(input: KitBizInput, ctx: KitBizContext): KitFr
|
|
|
201
344
|
};
|
|
202
345
|
|
|
203
346
|
// ---- 协作组件
|
|
347
|
+
out.components.add('KitBoardProse');
|
|
348
|
+
out.show[ids.prose] = { props: {} };
|
|
349
|
+
for (const c of KIT_BOARD_PROSE_CLASS_CANDIDATES) out.candidates.add(c);
|
|
204
350
|
out.show[ids.coord] = {
|
|
205
351
|
props: { scope: link, object: '', keyField: '', reloads: reloadable.map((p) => p.object), overlays: {}, ...linkRemoveProps(out) },
|
|
206
352
|
};
|
|
@@ -211,7 +357,19 @@ export function compileMultiBoard(input: KitBizInput, ctx: KitBizContext): KitFr
|
|
|
211
357
|
}
|
|
212
358
|
|
|
213
359
|
// ---- 壳
|
|
214
|
-
|
|
360
|
+
// ---- 面板组页签:未分组面板常显在页签之上(首屏区);同组面板收进同一签(组名按首次出现排序)。
|
|
361
|
+
// 所有面板对象与筛选 / 协调组件都已在上面一次编好,页签只改显隐(KitTabsWiring,不重新取数、不丢页面级状态)
|
|
362
|
+
const groupNames: string[] = [];
|
|
363
|
+
for (const b of blocks) if (b.group !== undefined && !groupNames.includes(b.group)) groupNames.push(b.group);
|
|
364
|
+
const topBlocks = blocks.filter((b) => b.group === undefined);
|
|
365
|
+
const tabsHtml = groupNames.length === 0
|
|
366
|
+
? ''
|
|
367
|
+
: groupTabsFrame(
|
|
368
|
+
`${ctx.pageId}__mb_tabs`, 'list', groupNames,
|
|
369
|
+
groupNames.map((g) => boardGridHtml(blocks.filter((b) => b.group === g), areaClass)),
|
|
370
|
+
KIT_CLASS_DEFAULTS.groupsWrap, out.show, out.components,
|
|
371
|
+
);
|
|
372
|
+
const html = multiBoardHtml(ids, { filter: filterHtml, panels: topBlocks, hub: useHub, tabs: tabsHtml, hero: heroItems, heroHead: heroHeads.join(''), surface: plan.frameCanvas === 'surface' }, areaClass, input.class);
|
|
215
373
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
216
374
|
for (const c of Object.values(MULTI_BOARD_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
217
375
|
for (const c of Object.values(MULTI_BOARD_SPANS)) for (const t of c.split(/\s+/)) if (t !== '' && html.includes(t)) out.candidates.add(t);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// MultiObjectBoard 的页面构成输入:把面板声明翻成构成分析的节点(角色按构件名查真源表,应用组件读注册元数据),再调 foundation 的 solveComposition。
|
|
2
|
+
// 编译(compile.ts)与布局体检(KIT-LAYOUT-041)共用这一份节点构造,不各写一份角色判定。
|
|
3
|
+
|
|
4
|
+
import { KIT_ARRANGE, arrangeComposition, arrangeTiers, compositionRoleOfKind } from 'soma-foundation/arrange';
|
|
5
|
+
import type { CompositionInput, CompositionNodeInput, CompositionPlan, CompositionRole } from 'soma-foundation/arrange';
|
|
6
|
+
|
|
7
|
+
/** 一个面板的构成输入事实(声明里读得出的,不看数据) */
|
|
8
|
+
export interface BoardPanelFact {
|
|
9
|
+
name: string;
|
|
10
|
+
/** 构件名:写死形状组件名(StatGroup / Chart / AppXxx …),否则 collection(列表 / 表格)或 KitObjectForm(表单) */
|
|
11
|
+
kind: string;
|
|
12
|
+
group: string;
|
|
13
|
+
head: string;
|
|
14
|
+
/** 作者写的栅格份数;没写 = undefined(由构成分析推导) */
|
|
15
|
+
span: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 面板声明(raw)→ 构件名:优先 view.staticComponent / view.summary.staticComponent / view.list.staticComponent,其次有 form 的面板是表单,其余是集合 */
|
|
19
|
+
export function boardPanelKind(raw: Record<string, unknown>): string {
|
|
20
|
+
const v = raw.view !== null && typeof raw.view === 'object' ? raw.view as Record<string, unknown> : {};
|
|
21
|
+
const pick = (o: unknown): string | undefined => (o !== null && typeof o === 'object' && typeof (o as Record<string, unknown>).staticComponent === 'string' ? (o as Record<string, string>).staticComponent : undefined);
|
|
22
|
+
const s = pick(v) ?? pick(v.summary) ?? pick(v.list);
|
|
23
|
+
if (s !== undefined) return s;
|
|
24
|
+
if (v.form !== undefined && v.list === undefined) return 'KitObjectForm';
|
|
25
|
+
return 'collection';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 面板事实 → 构成节点(应用组件的角色取 appRoles,缺省 subject) */
|
|
29
|
+
export function boardCompositionNodes(panels: readonly BoardPanelFact[], appRoles: Readonly<Record<string, CompositionRole | undefined>> = {}): CompositionNodeInput[] {
|
|
30
|
+
return panels.map((p, order) => {
|
|
31
|
+
const override = appRoles[p.name] ?? appRoles[p.kind];
|
|
32
|
+
return {
|
|
33
|
+
id: p.name,
|
|
34
|
+
kind: p.kind,
|
|
35
|
+
...(override !== undefined ? { role: override } : {}),
|
|
36
|
+
...(p.group !== '' ? { group: p.group } : {}),
|
|
37
|
+
...(p.head !== '' ? { head: p.head } : {}),
|
|
38
|
+
...(p.span !== undefined ? { span: p.span } : {}),
|
|
39
|
+
order,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 构成分析:容器档取「并排档」(栅格的窄容器退化由 `@md:` 容器查询在运行期完成,编译期按能并排的宽度推导份数) */
|
|
45
|
+
export function composeBoard(nodes: readonly CompositionNodeInput[], frame: CompositionInput['frame'] = 'single'): CompositionPlan {
|
|
46
|
+
const wide = arrangeTiers().find((t) => t.name === KIT_ARRANGE.composition.span.wideTier) ?? arrangeTiers()[arrangeTiers().length - 1]!;
|
|
47
|
+
const input: CompositionInput = { nodes, frame, tier: wide };
|
|
48
|
+
return arrangeComposition(input);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 应用组件名 → 声明的构成角色(来自应用组件注册元数据 declareKitComposition,经 staticComponents 契约表传来) */
|
|
52
|
+
export function appRolesOf(staticComponents: Readonly<Record<string, { composition?: CompositionRole }>>): Record<string, CompositionRole> {
|
|
53
|
+
const out: Record<string, CompositionRole> = {};
|
|
54
|
+
for (const [name, c] of Object.entries(staticComponents)) if (c.composition !== undefined) out[name] = c.composition;
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { compositionRoleOfKind };
|
|
@@ -33,4 +33,4 @@ export const MultiObjectBoard = defineKitBizComponent({
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
export { compileMultiBoard, boardFilterName, boardPanelName } from './compile';
|
|
36
|
-
export { MULTI_BOARD_AREAS, MULTI_BOARD_CLASS, MULTI_BOARD_SPANS,
|
|
36
|
+
export { MULTI_BOARD_AREAS, MULTI_BOARD_CLASS, MULTI_BOARD_SPANS, multiBoardIds } from './shell';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// KitBoardProse:看板面板里「常显的说明性段落」超过上限时,自动收成该面板底部的一行「数据说明(N)」(无数据组件界面,挂在看板根里)。
|
|
2
|
+
//
|
|
3
|
+
// 判定与渲染检测(scripts/kit-render-metrics/sweep-detect.mjs 的 prose)同源:阈值读 design 真源(kit-limits#panelProse,由
|
|
4
|
+
// render-judgements.json#panelProse 引用生成);说明性文字 = 次级色 / 小一档字阶里、成句的(够长、含汉字与中文标点)叶子文字块。
|
|
5
|
+
// 超限的面板:该面板内全部说明段落原位 hidden(不搬动节点,组件重绘不受影响),底部补一行收起项,展开后列出这些文字(每次扫描按当前文字重建)。
|
|
6
|
+
// 面板内已有页脚形态的 NoticeList(data-kit-notice-footer)本身就是这个落位,不再计入。
|
|
7
|
+
|
|
8
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
9
|
+
import { KIT_PANEL_PROSE } from 'soma-foundation/kit-limits';
|
|
10
|
+
import { createKitController } from '../../base/shared';
|
|
11
|
+
import { classCandidates } from '../../base/class-candidates';
|
|
12
|
+
import { KIT_NOTICE_BOX_FOOTER, KIT_NOTICE_LIST, KIT_NOTICE_TOGGLE_FOOTER } from '../../recipes/status';
|
|
13
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
14
|
+
import { mergeClass } from '../../object-renderer/merge-class';
|
|
15
|
+
import { kitText } from '../../i18n/kit-text';
|
|
16
|
+
|
|
17
|
+
const FOLD_LIST = mergeClass(`${KIT_NOTICE_LIST} text-fg-muted`, kitTypographyRecipe('caption'));
|
|
18
|
+
export const KIT_BOARD_PROSE_CLASS_CANDIDATES: readonly string[] = classCandidates(FOLD_LIST, KIT_NOTICE_TOGGLE_FOOTER, KIT_NOTICE_BOX_FOOTER);
|
|
19
|
+
|
|
20
|
+
const PANEL = '[data-kit-board-panel]';
|
|
21
|
+
const FOLD_ATTR = 'data-kit-prose-folded';
|
|
22
|
+
const FOOTER_ATTR = 'data-kit-prose-footer';
|
|
23
|
+
// 不算说明的位置(与检测脚本的 skip 同一份清单)
|
|
24
|
+
const SKIP = 'table, [role="table"], [role="grid"], [role="tablist"], svg, canvas, button, a, label, h1, h2, h3, h4, h5, h6, [data-kit-part^="title"], [data-kit-state], select, input, textarea, [role="tab"], [role="option"], [role="menu"]';
|
|
25
|
+
|
|
26
|
+
const sentence = (text: string): boolean => text.length >= KIT_PANEL_PROSE.minChars && /[一-鿿]/.test(text) && /[,。;:、()]/.test(text);
|
|
27
|
+
|
|
28
|
+
function proseIn(panel: HTMLElement): HTMLElement[] {
|
|
29
|
+
const out: HTMLElement[] = [];
|
|
30
|
+
for (const el of Array.from(panel.querySelectorAll<HTMLElement>('p, li, div, span'))) {
|
|
31
|
+
if (el.closest(`[${FOOTER_ATTR}]`) !== null || el.closest('[data-kit-notice-footer]') !== null) continue;
|
|
32
|
+
if (el.childElementCount > 0 && el.querySelector('p, li, div') !== null) continue;
|
|
33
|
+
if (el.closest(SKIP) !== null) continue;
|
|
34
|
+
if (el.closest('[class*="text-fg-muted"], [class*="text-fg-subtle"], [data-kit-notice], [role="note"]') === null) continue;
|
|
35
|
+
if (el.getClientRects().length === 0) continue; // 本来就不可见的不算
|
|
36
|
+
if (sentence((el.textContent ?? '').trim())) out.push(el);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── 空卡不渲染:没有标题、里面没有任何可见内容(文字 / 图形 / 控件 / 状态块)的面板整块收起;内容出现再还原(只还原自己收起的)
|
|
42
|
+
const EMPTY_ATTR = 'data-kit-empty-collapsed';
|
|
43
|
+
const CONTENT = 'svg, canvas, img, video, table, input, select, textarea, button, a, [role="img"], [role="progressbar"], [data-kit-state], [data-kit-skeleton], [aria-busy="true"]';
|
|
44
|
+
|
|
45
|
+
/** el 到 panel 之间(不含 panel 自己)没有被 hidden 的祖先 */
|
|
46
|
+
function shownWithin(el: HTMLElement, panel: HTMLElement): boolean {
|
|
47
|
+
for (let n: HTMLElement | null = el; n !== null && n !== panel; n = n.parentElement) if (n.hidden) return false;
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 面板里有没有可见内容(面板自己的 hidden 不算:收起的面板也要能判出「内容回来了」) */
|
|
52
|
+
export function panelHasContent(panel: HTMLElement): boolean {
|
|
53
|
+
for (const el of Array.from(panel.querySelectorAll<HTMLElement>('*'))) {
|
|
54
|
+
if (!shownWithin(el, panel)) continue;
|
|
55
|
+
if (el.matches(CONTENT)) return true;
|
|
56
|
+
for (const node of Array.from(el.childNodes)) if (node.nodeType === 3 && (node.textContent ?? '').trim() !== '') return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function collapseEmpty(board: HTMLElement): void {
|
|
62
|
+
for (const panel of Array.from(board.querySelectorAll<HTMLElement>(PANEL))) {
|
|
63
|
+
if (panel.getAttribute('data-kit-board-panel') !== 'bare') continue;
|
|
64
|
+
const collapsedByUs = panel.hasAttribute(EMPTY_ATTR);
|
|
65
|
+
if (panel.hidden && !collapsedByUs) continue; // 别人(kitCollapseBlock)收起的不动
|
|
66
|
+
if (!panelHasContent(panel)) {
|
|
67
|
+
panel.hidden = true;
|
|
68
|
+
panel.setAttribute(EMPTY_ATTR, '');
|
|
69
|
+
} else if (collapsedByUs) {
|
|
70
|
+
panel.hidden = false;
|
|
71
|
+
panel.removeAttribute(EMPTY_ATTR);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function scan(board: HTMLElement): void {
|
|
77
|
+
collapseEmpty(board);
|
|
78
|
+
for (const panel of Array.from(board.querySelectorAll<HTMLElement>(PANEL))) {
|
|
79
|
+
// 先还原上一轮折叠的段落(hidden 状态下量不到),再按当前文字重判:文字变了折叠结果跟着变
|
|
80
|
+
const folded = Array.from(panel.querySelectorAll<HTMLElement>(`[${FOLD_ATTR}]`));
|
|
81
|
+
const old = panel.querySelector(`[${FOOTER_ATTR}]`);
|
|
82
|
+
const openBefore = old?.querySelector('ul')?.hidden === false;
|
|
83
|
+
old?.remove();
|
|
84
|
+
for (const el of folded) { el.hidden = false; el.removeAttribute(FOLD_ATTR); }
|
|
85
|
+
const now = proseIn(panel);
|
|
86
|
+
if (now.length <= KIT_PANEL_PROSE.maxPerPanel) continue;
|
|
87
|
+
const doc = panel.ownerDocument;
|
|
88
|
+
const box = doc.createElement('div');
|
|
89
|
+
box.setAttribute(FOOTER_ATTR, '');
|
|
90
|
+
box.className = KIT_NOTICE_BOX_FOOTER;
|
|
91
|
+
const btn = doc.createElement('button');
|
|
92
|
+
btn.type = 'button';
|
|
93
|
+
btn.className = KIT_NOTICE_TOGGLE_FOOTER;
|
|
94
|
+
btn.textContent = kitText('soma.kit.data_notes', { n: now.length }, panel);
|
|
95
|
+
const ul = doc.createElement('ul');
|
|
96
|
+
ul.className = FOLD_LIST;
|
|
97
|
+
ul.hidden = !openBefore;
|
|
98
|
+
ul.id = `kit-prose-${Math.random().toString(36).slice(2, 8)}`;
|
|
99
|
+
btn.setAttribute('aria-expanded', openBefore ? 'true' : 'false');
|
|
100
|
+
btn.setAttribute('aria-controls', ul.id);
|
|
101
|
+
btn.addEventListener('click', () => {
|
|
102
|
+
ul.hidden = !ul.hidden;
|
|
103
|
+
btn.setAttribute('aria-expanded', ul.hidden ? 'false' : 'true');
|
|
104
|
+
});
|
|
105
|
+
for (const el of now) {
|
|
106
|
+
const li = doc.createElement('li');
|
|
107
|
+
li.textContent = (el.textContent ?? '').trim();
|
|
108
|
+
ul.appendChild(li);
|
|
109
|
+
el.hidden = true;
|
|
110
|
+
el.setAttribute(FOLD_ATTR, '');
|
|
111
|
+
}
|
|
112
|
+
box.append(btn, ul);
|
|
113
|
+
panel.appendChild(box);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function createKitBoardProse(): SomaComponentDefinition {
|
|
118
|
+
return {
|
|
119
|
+
contract: { name: 'KitBoardProse', layer: 'data', props: {} },
|
|
120
|
+
templateHtml: '<div data-soma-id="root" hidden></div>',
|
|
121
|
+
controllerFactory: createKitController(() => {
|
|
122
|
+
let observer: MutationObserver | null = null;
|
|
123
|
+
let frame = 0;
|
|
124
|
+
return {
|
|
125
|
+
attach(root) {
|
|
126
|
+
const board = root.closest<HTMLElement>('[data-kit-board]');
|
|
127
|
+
if (board === null || typeof MutationObserver === 'undefined') return undefined;
|
|
128
|
+
const run = (): void => {
|
|
129
|
+
frame = 0;
|
|
130
|
+
observer?.disconnect();
|
|
131
|
+
try { scan(board); } finally { observer?.observe(board, { childList: true, subtree: true, characterData: true }); }
|
|
132
|
+
};
|
|
133
|
+
const queue = (): void => { if (frame === 0) frame = board.ownerDocument.defaultView?.requestAnimationFrame(run) ?? 0; };
|
|
134
|
+
observer = new MutationObserver(queue);
|
|
135
|
+
observer.observe(board, { childList: true, subtree: true, characterData: true });
|
|
136
|
+
queue();
|
|
137
|
+
return () => { observer?.disconnect(); observer = null; };
|
|
138
|
+
},
|
|
139
|
+
render() { /* 无界面:扫描由 attach 里的观察者驱动 */ },
|
|
140
|
+
};
|
|
141
|
+
}),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
// MultiObjectBoard 的 HTML 代码壳:顶部全局筛选条 + 下方 12 栅格的面板区。只有结构与 Tailwind 类(语义色名 + utilityScales 里有的尺度),不写原生 CSS。
|
|
2
2
|
// 面板默认窄容器整行、达到 md 档占 6/12;单个面板用 `span`(1~12)改成 N/12。分栏靠容器查询变体 `@md:`。
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { KIT_ARRANGE, arrangeSplit } from 'soma-foundation/arrange';
|
|
5
|
+
import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_WIDTH } from '../../object-renderer/defaults';
|
|
5
6
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
7
|
+
import { KIT_LIST_BAR_FLAT_CLASS, KIT_SHELL_FLAT_MARK, kitShellRecipe } from '../../recipes/container';
|
|
8
|
+
import { kitPanelTitleRowHtml } from '../../recipes/title-row';
|
|
9
|
+
import { KIT_HOIST_ATTR, KIT_HOIST_HEADER_ACTIONS, tablesOnCanvas } from '../shared/compile-helpers';
|
|
6
10
|
import { cls, esc, host } from '../link/shared';
|
|
7
11
|
|
|
8
12
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
9
13
|
export const MULTI_BOARD_AREAS = ['root', 'filter', 'panels', 'panel'] as const;
|
|
10
14
|
export type MultiBoardArea = (typeof MULTI_BOARD_AREAS)[number];
|
|
11
15
|
|
|
16
|
+
const HERO_CFG = KIT_ARRANGE.composition.hero;
|
|
17
|
+
/** 概况条并排的容器档与份数(排布引擎求解:结论块 / 统计块各自的最小宽都放得下的最窄容器档) */
|
|
18
|
+
const HERO_SPLIT = arrangeSplit({ aMinRem: HERO_CFG.conclusionMinRem, bMinRem: HERO_CFG.statsMinRem, aSpans: [HERO_CFG.conclusionSpan] });
|
|
19
|
+
const HERO_STAT_KINDS: ReadonlySet<string> = new Set(HERO_CFG.statKinds);
|
|
20
|
+
|
|
12
21
|
export const MULTI_BOARD_CLASS = {
|
|
13
|
-
root: '@container flex flex-col gap-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
root: '@container flex flex-col gap-section',
|
|
23
|
+
/** 全局筛选:控件,不独立成卡——自带圆角的下沉带(well) */
|
|
24
|
+
filter: KIT_LIST_BAR_FLAT_CLASS,
|
|
25
|
+
panels: 'grid grid-cols-12 gap-section',
|
|
26
|
+
/** E1 / E2 面板(容器 card);E3 / E4 与被包含者无容器(plain) */
|
|
27
|
+
panel: mergeClass('flex min-w-0 flex-col gap-region p-card', kitShellRecipe({ shadow: false })),
|
|
28
|
+
panelPlain: 'flex min-w-0 flex-col gap-region',
|
|
29
|
+
/** 概况条(hero):无容器,成员并排、成员之间一条细线,下缘一条通栏细线与主体分开 */
|
|
30
|
+
hero: 'flex flex-wrap items-stretch gap-x-section gap-y-region border-b border-border-subtle pb-4 mb-title-block',
|
|
31
|
+
heroItem: 'min-w-0 flex-1 basis-80',
|
|
32
|
+
heroLabel: 'mb-1 text-xs text-fg-muted',
|
|
33
|
+
/** 概况条有结论块也有统计块:容器够宽时结论在左、统计一排在右、中间一条细线;窄容器结论在上、统计在下(并排档由引擎 arrangeSplit 给出) */
|
|
34
|
+
heroSplit: `flex flex-col gap-region @${HERO_SPLIT.tier}:flex-row @${HERO_SPLIT.tier}:gap-section border-b border-border-subtle pb-4 mb-title-block`,
|
|
35
|
+
heroConclusion: `flex min-w-0 flex-col gap-region @${HERO_SPLIT.tier}:w-${HERO_SPLIT.aSpan}/${HERO_SPLIT.aSpan + HERO_SPLIT.bSpan} @${HERO_SPLIT.tier}:shrink-0`,
|
|
36
|
+
heroDivider: `hidden w-px self-stretch bg-border-subtle @${HERO_SPLIT.tier}:block`,
|
|
37
|
+
/** 统计块:并排时占余下全宽;堆叠时限宽到放不下一排六项(统计块自己的容器查询于是换成 3×2) */
|
|
38
|
+
heroStats: `flex min-w-0 flex-1 flex-col gap-region @max-${HERO_SPLIT.tier}:max-w-${Math.round(HERO_CFG.stackedStatsMaxRem / KIT_ARRANGE.columns.track.stepRem)}`,
|
|
39
|
+
/** 头带:被 head 指向的概况挂在宿主标题行下,无容器 */
|
|
40
|
+
band: 'border-t border-b border-border-subtle py-3',
|
|
18
41
|
} as const;
|
|
19
42
|
|
|
20
43
|
const WIDTH_GRAMMAR = KIT_GRAMMAR.width as {
|
|
@@ -29,8 +52,7 @@ export const MULTI_BOARD_GRID_SPANS: readonly number[] = Object.freeze(
|
|
|
29
52
|
WIDTH_GRAMMAR.gridSpans ?? Object.keys(WIDTH_GRAMMAR.spanClassTable).map(Number),
|
|
30
53
|
);
|
|
31
54
|
|
|
32
|
-
/** 面板宽度:窄容器恒整行,md 档起占 N/12 */
|
|
33
|
-
export const MULTI_BOARD_SPAN_DEFAULT = KIT_WIDTH.totalParts / 2;
|
|
55
|
+
/** 面板宽度:窄容器恒整行,md 档起占 N/12(份数由构成分析推导,作者写的 span 覆盖;这里只给「份数 → 类串」) */
|
|
34
56
|
export const MULTI_BOARD_SPANS: Readonly<Record<number, string>> = Object.freeze(
|
|
35
57
|
Object.fromEntries(
|
|
36
58
|
MULTI_BOARD_GRID_SPANS.map((span) => [
|
|
@@ -42,38 +64,87 @@ export const MULTI_BOARD_SPANS: Readonly<Record<number, string>> = Object.freeze
|
|
|
42
64
|
),
|
|
43
65
|
);
|
|
44
66
|
|
|
45
|
-
export function multiBoardIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
46
|
-
return { root: `${pageId}__mb_root`, hub: `${pageId}__hub`, coord: `${pageId}__coord`, link: `${pageId}_link` };
|
|
67
|
+
export function multiBoardIds(pageId: string): { root: string; hub: string; coord: string; link: string; prose: string } {
|
|
68
|
+
return { root: `${pageId}__mb_root`, hub: `${pageId}__hub`, coord: `${pageId}__coord`, link: `${pageId}_link`, prose: `${pageId}__mb_prose` };
|
|
47
69
|
}
|
|
48
70
|
|
|
49
71
|
export interface BoardPanelBlock {
|
|
50
72
|
title: string;
|
|
51
73
|
html: string;
|
|
74
|
+
/** 面板有标题时并入标题行右侧的工具栏(无标题时工具栏留在 html 最前) */
|
|
75
|
+
toolbar?: string;
|
|
52
76
|
span: number;
|
|
53
77
|
/** 面板声明里的 `class`(同族覆写,最后合并) */
|
|
54
78
|
class?: string;
|
|
79
|
+
/** 面板组名(语义键,如「进度」):同组面板收进页内页签的同一签;缺省 = 首屏常显区 */
|
|
80
|
+
group?: string;
|
|
81
|
+
/** 面板头控件槽位(panels.<控件>.head: <本面板>):已编好的控件 HTML,放进标题行右侧;无标题时单独成一行靠右 */
|
|
82
|
+
head?: string;
|
|
83
|
+
/** 页面构成:强调级(primary 主 / secondary 次 …)与容器形态(card 有框 / plain 无容器);缺省 secondary + card */
|
|
84
|
+
emphasis?: 'primary' | 'secondary' | 'tertiary' | 'quiet';
|
|
85
|
+
container?: 'card' | 'plain';
|
|
86
|
+
/** 头带(被 head 指向的概况类构件 HTML):挂在标题行下,无容器 */
|
|
87
|
+
band?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 面板头控件的容器:靠右(标题行里 ms-auto),窄时换行 */
|
|
91
|
+
export const MULTI_BOARD_HEAD_CLASS = 'ms-auto flex min-w-0 flex-wrap items-center justify-end gap-region';
|
|
92
|
+
|
|
93
|
+
/** 并为前一面板页脚的数据说明(紧跟其后、无标题、collapse 的 NoticeList 面板):放在宿主面板内容最后 */
|
|
94
|
+
export function appendPanelFooter(block: BoardPanelBlock, footerHtml: string): void {
|
|
95
|
+
block.html = `${block.html}\n<div data-kit-panel-footer="">${footerHtml}</div>`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** 一组面板的栅格 HTML(首屏区与每个页签签内共用同一份) */
|
|
99
|
+
export function boardGridHtml(blocks: readonly BoardPanelBlock[], areaClass: Record<string, string>): string {
|
|
100
|
+
const sections = blocks.map((p) => {
|
|
101
|
+
const head = p.head === undefined || p.head === '' ? '' : `<div${cls(MULTI_BOARD_HEAD_CLASS)} data-kit-panel-head="">${p.head}</div>`;
|
|
102
|
+
const title = p.title === ''
|
|
103
|
+
? (head === '' ? '' : `<div${cls(KIT_CLASS_DEFAULTS.toolbarTitleRow)}>${head}</div>`)
|
|
104
|
+
: kitPanelTitleRowHtml({ title: p.title, actionsHtml: `${p.toolbar ?? ''}${head}` });
|
|
105
|
+
const plain = p.container === 'plain';
|
|
106
|
+
const klass = mergeClass(
|
|
107
|
+
mergeClass(mergeClass(plain ? MULTI_BOARD_CLASS.panelPlain : MULTI_BOARD_CLASS.panel, MULTI_BOARD_SPANS[p.span]), areaClass.panel),
|
|
108
|
+
p.class,
|
|
109
|
+
);
|
|
110
|
+
const band = p.band === undefined || p.band === '' ? '' : `<div${cls(MULTI_BOARD_CLASS.band)} data-kit-head-band="" data-kit-emphasis="secondary" data-kit-container="plain">${p.band}</div>`;
|
|
111
|
+
const compose = ` data-kit-emphasis="${p.emphasis ?? 'secondary'}" data-kit-container="${plain ? 'plain' : 'card'}"`;
|
|
112
|
+
// 无容器的面板(E3 / E4、被包含者、唯一主体)是 div:section 标签会吃容器的外圈与阴影,画出一张零内边距的卡、内容贴边;
|
|
113
|
+
// 有卡的面板才是 section(p-card 标准内边距)。唯一主体不套卡时内容落在页面对齐轴上
|
|
114
|
+
const tag = plain ? 'div' : 'section';
|
|
115
|
+
return `<${tag}${cls(klass)}${plain ? '' : KIT_SHELL_FLAT_MARK}${compose} data-kit-board-panel="${title === '' ? 'bare' : 'titled'}">${title}${band}${plain ? tablesOnCanvas(p.html) : p.html}</${tag}>`;
|
|
116
|
+
});
|
|
117
|
+
return `<div${cls(mergeClass(MULTI_BOARD_CLASS.panels, areaClass.panels))}>\n${sections.join('\n')}\n</div>`;
|
|
55
118
|
}
|
|
56
119
|
|
|
57
120
|
/** 整个壳:协作组件宿主 + 筛选卡 + 面板栅格。区域类按 7.3 同族规则覆写 */
|
|
58
121
|
export function multiBoardHtml(
|
|
59
122
|
ids: ReturnType<typeof multiBoardIds>,
|
|
60
|
-
parts: { filter: string; panels: BoardPanelBlock[]; hub: boolean },
|
|
123
|
+
parts: { filter: string; panels: BoardPanelBlock[]; hub: boolean; /** 分组页签块(已渲染,在首屏区之后) */ tabs?: string; /** 概况条成员(hero 槽,合成一条无容器的带;kind = 构件名,统计块与结论块分左右并排) */ hero?: Array<{ title: string; html: string; kind?: string }>; /** 概况条成员的范围切换类控件:搬运标记块,页面编译搬进页头标题右侧 */ heroHead?: string; /** 唯一主体页:页面底取面板面 */ surface?: boolean },
|
|
61
124
|
areaClass: Record<string, string>,
|
|
62
125
|
extra: string | undefined,
|
|
63
126
|
): string {
|
|
64
|
-
const hosts = `${parts.hub ? host('KitLinkHub', ids.hub) : ''}${host('KitCrudBridge', ids.coord)}`;
|
|
127
|
+
const hosts = `${parts.hub ? host('KitLinkHub', ids.hub) : ''}${host('KitCrudBridge', ids.coord)}${host('KitBoardProse', ids.prose)}`;
|
|
65
128
|
const filter = parts.filter === ''
|
|
66
129
|
? ''
|
|
67
|
-
: `<section${cls(mergeClass(MULTI_BOARD_CLASS.filter, areaClass.filter))}>${parts.filter}</section>`;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
130
|
+
: `<section${cls(mergeClass(MULTI_BOARD_CLASS.filter, areaClass.filter))} data-kit-container="plain">${parts.filter}</section>`;
|
|
131
|
+
const heroItems = parts.hero ?? [];
|
|
132
|
+
const heroMember = (h: { title: string; html: string }, klass: string): string => `<div${cls(klass)}>${h.title === '' ? '' : `<div${cls(MULTI_BOARD_CLASS.heroLabel)}>${esc(h.title)}</div>`}${h.html}</div>`;
|
|
133
|
+
const stats = heroItems.filter((h) => h.kind !== undefined && HERO_STAT_KINDS.has(h.kind));
|
|
134
|
+
const conclusions = heroItems.filter((h) => !stats.includes(h));
|
|
135
|
+
const heroAttrs = 'data-kit-slot="hero" data-kit-summary="" data-kit-role="summary" data-kit-emphasis="primary" data-kit-container="plain"';
|
|
136
|
+
// 概况条是 div(不是 section:section 标签会吃容器的外圈与阴影,概况条是一条带,不是卡)。
|
|
137
|
+
// 有结论块也有统计块:结论左、统计右(引擎给并排档);只有一类:成员并排、窄时换行
|
|
138
|
+
const hero = heroItems.length === 0
|
|
139
|
+
? ''
|
|
140
|
+
: stats.length > 0 && conclusions.length > 0
|
|
141
|
+
? `<div ${heroAttrs}${cls(MULTI_BOARD_CLASS.heroSplit)}><div${cls(MULTI_BOARD_CLASS.heroConclusion)}>${conclusions.map((h) => heroMember(h, 'min-w-0')).join('')}</div><div aria-hidden="true"${cls(MULTI_BOARD_CLASS.heroDivider)}></div><div${cls(MULTI_BOARD_CLASS.heroStats)}>${stats.map((h) => heroMember(h, 'min-w-0')).join('')}</div></div>`
|
|
142
|
+
: `<div ${heroAttrs}${cls(MULTI_BOARD_CLASS.hero)}>${heroItems.map((h) => heroMember(h, MULTI_BOARD_CLASS.heroItem)).join('')}</div>`;
|
|
143
|
+
const heroHead = parts.heroHead === undefined || parts.heroHead === ''
|
|
144
|
+
? ''
|
|
145
|
+
: `<div ${KIT_HOIST_ATTR}="${KIT_HOIST_HEADER_ACTIONS}" class="${MULTI_BOARD_HEAD_CLASS}" data-kit-panel-head="">${parts.heroHead}</div>`;
|
|
146
|
+
const grid = parts.panels.length === 0 ? '' : boardGridHtml(parts.panels, areaClass);
|
|
77
147
|
const root = mergeClass(mergeClass(MULTI_BOARD_CLASS.root, areaClass.root), extra);
|
|
78
|
-
|
|
148
|
+
const canvas = parts.surface === true ? ' data-kit-canvas-hint="surface"' : '';
|
|
149
|
+
return `<div data-soma-id="${esc(ids.root)}" data-kit-board=""${canvas}${cls(root)}>\n${hosts}\n${[heroHead, filter, hero, grid, parts.tabs ?? ''].filter((x) => x !== '').join('\n')}\n</div>`;
|
|
79
150
|
}
|