soma-kit 0.1.13 → 0.1.15
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/package.json +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +34 -17
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +73 -50
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +7 -6
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +16 -12
- package/src/biz/types.ts +15 -3
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +97 -18
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { KIT_GRAMMAR_RUNTIME } from '../../generated/kit-grammar-runtime';
|
|
5
5
|
import { defineKitBizComponent } from '../define';
|
|
6
|
+
import type { KitBizDefinition } from '../types';
|
|
6
7
|
import { compileMultiBoard } from './compile';
|
|
7
8
|
import { MULTI_BOARD_AREAS } from './shell';
|
|
8
9
|
|
|
@@ -17,20 +18,34 @@ interface GrammarRuntimeNarrow {
|
|
|
17
18
|
const MULTI_BOARD_PANEL_KEYS: readonly string[] =
|
|
18
19
|
(KIT_GRAMMAR_RUNTIME as unknown as GrammarRuntimeNarrow).bizComponents?.MultiObjectBoard?.panelKeys ?? [];
|
|
19
20
|
|
|
21
|
+
const BOARD_ROLES: KitBizDefinition['roles'] = {
|
|
22
|
+
filter: { required: false, views: ['filter'] },
|
|
23
|
+
panels: {
|
|
24
|
+
required: true,
|
|
25
|
+
views: ['list', 'summary'],
|
|
26
|
+
many: true,
|
|
27
|
+
extraKeys: MULTI_BOARD_PANEL_KEYS,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
20
31
|
export const MultiObjectBoard = defineKitBizComponent({
|
|
21
32
|
kind: 'MultiObjectBoard',
|
|
22
|
-
roles:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
roles: BOARD_ROLES,
|
|
34
|
+
areas: [...MULTI_BOARD_AREAS],
|
|
35
|
+
compile: compileMultiBoard,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* ReportBoard:报告阅读页(尺寸规格 §3 阅读型)。区块构成与 MultiObjectBoard 相同(同一编译、同一套角色槽),
|
|
40
|
+
* 区别只在页面模式推导的版心:阅读版心 800(pageHeader.maxWidths.medium,取自 sizeSpec.page.readMaxPx),页面不写 max_width。
|
|
41
|
+
*/
|
|
42
|
+
export const ReportBoard = defineKitBizComponent({
|
|
43
|
+
kind: 'ReportBoard',
|
|
44
|
+
roles: BOARD_ROLES,
|
|
31
45
|
areas: [...MULTI_BOARD_AREAS],
|
|
46
|
+
pageMaxWidth: 'medium',
|
|
32
47
|
compile: compileMultiBoard,
|
|
33
48
|
});
|
|
34
49
|
|
|
35
50
|
export { compileMultiBoard, boardFilterName, boardPanelName } from './compile';
|
|
36
|
-
export { MULTI_BOARD_AREAS, MULTI_BOARD_CLASS, MULTI_BOARD_SPANS,
|
|
51
|
+
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 '../../shared/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 '../../shared/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,21 +1,48 @@
|
|
|
1
1
|
// MultiObjectBoard 的 HTML 代码壳:顶部全局筛选条 + 下方 12 栅格的面板区。只有结构与 Tailwind 类(语义色名 + utilityScales 里有的尺度),不写原生 CSS。
|
|
2
2
|
// 面板默认窄容器整行、达到 md 档占 6/12;单个面板用 `span`(1~12)改成 N/12。分栏靠容器查询变体 `@md:`。
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { KIT_ARRANGE, arrangeSplit } from 'soma-foundation/arrange';
|
|
5
|
+
import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_WIDTH } from '../../object-renderer/defaults';
|
|
6
|
+
import { mergeClass } from '../../shared/merge-class';
|
|
7
|
+
import { KIT_LIST_BAR_FLAT_CLASS, KIT_SHELL_FLAT_MARK, kitShellRecipe } from '../../recipes/container';
|
|
7
8
|
import { kitPanelTitleRowHtml } from '../../recipes/title-row';
|
|
9
|
+
import { KIT_DIVIDER_HEAD_CLASS, kitDividerRecipe } from '../../recipes/divider';
|
|
10
|
+
import { KIT_HOIST_ATTR, KIT_HOIST_HEADER_ACTIONS, tablesOnCanvas } from '../shared/compile-helpers';
|
|
8
11
|
import { cls, esc, host } from '../link/shared';
|
|
9
12
|
|
|
10
13
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
11
14
|
export const MULTI_BOARD_AREAS = ['root', 'filter', 'panels', 'panel'] as const;
|
|
12
15
|
export type MultiBoardArea = (typeof MULTI_BOARD_AREAS)[number];
|
|
13
16
|
|
|
17
|
+
const HERO_CFG = KIT_ARRANGE.composition.hero;
|
|
18
|
+
/** 概况条并排的容器档与份数(排布引擎求解:结论块 / 统计块各自的最小宽都放得下的最窄容器档;结论块最小宽与份数只读真源 composition.hero,TF-4) */
|
|
19
|
+
const HERO_SPLIT = arrangeSplit({ aMinRem: HERO_CFG.conclusionMinRem, bMinRem: HERO_CFG.statsMinRem, aSpans: [HERO_CFG.conclusionSpan] });
|
|
20
|
+
const HERO_STAT_KINDS: ReadonlySet<string> = new Set(HERO_CFG.statKinds);
|
|
21
|
+
/** 结论与统计之间的竖线:分隔线出口朝起始侧的一条(发丝宽一个灰) */
|
|
22
|
+
const HERO_DIVIDER_LINE = kitDividerRecipe('start');
|
|
23
|
+
|
|
14
24
|
export const MULTI_BOARD_CLASS = {
|
|
15
|
-
root: '@container flex flex-col gap-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
root: '@container flex flex-col gap-section',
|
|
26
|
+
/** 全局筛选:控件,不独立成卡——自带圆角的下沉带(well) */
|
|
27
|
+
filter: KIT_LIST_BAR_FLAT_CLASS,
|
|
28
|
+
panels: 'grid grid-cols-12 gap-section',
|
|
29
|
+
/** E1 / E2 面板(容器 card);E3 / E4 与被包含者无容器(plain) */
|
|
30
|
+
panel: mergeClass('flex min-w-0 flex-col gap-region p-card', kitShellRecipe({ shadow: false })),
|
|
31
|
+
panelPlain: 'flex min-w-0 flex-col gap-region',
|
|
32
|
+
/** 概况条(hero):无容器,成员并排、成员之间一条细线,下缘一条通栏细线与主体分开 */
|
|
33
|
+
hero: `flex flex-wrap items-stretch gap-x-section gap-y-region ${KIT_DIVIDER_HEAD_CLASS} pb-4 mb-title-block`,
|
|
34
|
+
heroItem: 'min-w-0 flex-1 basis-80',
|
|
35
|
+
heroLabel: 'mb-1 text-xs text-fg-muted',
|
|
36
|
+
/** 概况条有结论块也有统计块:容器够宽时结论在左、统计一排在右、中间一条细线;窄容器结论在上、统计在下(并排档由引擎 arrangeSplit 给出) */
|
|
37
|
+
// 统计一侧整体为空(统计块自报没有可显示的概况,运行期给概况条标 data-kit-hero-solo,见 base/shared 的 kitSyncHeroSolo):统计块与细线收起,结论占满整行
|
|
38
|
+
heroSplit: `group/hero flex flex-col gap-region @${HERO_SPLIT.tier}:flex-row @${HERO_SPLIT.tier}:gap-section ${KIT_DIVIDER_HEAD_CLASS} pb-4 mb-title-block`,
|
|
39
|
+
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 group-data-kit-hero-solo/hero:@${HERO_SPLIT.tier}:w-full`,
|
|
40
|
+
// 结论与统计之间的竖线:分隔线出口的竖向一侧(发丝宽一个灰),不再用 1px 底色条
|
|
41
|
+
heroDivider: `${HERO_DIVIDER_LINE} hidden self-stretch @${HERO_SPLIT.tier}:block group-data-kit-hero-solo/hero:@${HERO_SPLIT.tier}:hidden`,
|
|
42
|
+
/** 统计块:并排与堆叠时均撑满可用宽度,不再用 max-w-156 截断导致报告页右侧出现 35% 空白空洞 */
|
|
43
|
+
heroStats: 'flex min-w-0 flex-1 flex-col gap-region group-data-kit-hero-solo/hero:hidden',
|
|
44
|
+
/** 头带:被 head 指向的概况挂在宿主标题行下,无容器 */
|
|
45
|
+
band: mergeClass(mergeClass('py-3', kitDividerRecipe('top')), KIT_DIVIDER_HEAD_CLASS),
|
|
19
46
|
} as const;
|
|
20
47
|
|
|
21
48
|
const WIDTH_GRAMMAR = KIT_GRAMMAR.width as {
|
|
@@ -30,8 +57,7 @@ export const MULTI_BOARD_GRID_SPANS: readonly number[] = Object.freeze(
|
|
|
30
57
|
WIDTH_GRAMMAR.gridSpans ?? Object.keys(WIDTH_GRAMMAR.spanClassTable).map(Number),
|
|
31
58
|
);
|
|
32
59
|
|
|
33
|
-
/** 面板宽度:窄容器恒整行,md 档起占 N/12 */
|
|
34
|
-
export const MULTI_BOARD_SPAN_DEFAULT = KIT_WIDTH.totalParts / 2;
|
|
60
|
+
/** 面板宽度:窄容器恒整行,md 档起占 N/12(份数由构成分析推导,作者写的 span 覆盖;这里只给「份数 → 类串」) */
|
|
35
61
|
export const MULTI_BOARD_SPANS: Readonly<Record<number, string>> = Object.freeze(
|
|
36
62
|
Object.fromEntries(
|
|
37
63
|
MULTI_BOARD_GRID_SPANS.map((span) => [
|
|
@@ -43,8 +69,8 @@ export const MULTI_BOARD_SPANS: Readonly<Record<number, string>> = Object.freeze
|
|
|
43
69
|
),
|
|
44
70
|
);
|
|
45
71
|
|
|
46
|
-
export function multiBoardIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
47
|
-
return { root: `${pageId}__mb_root`, hub: `${pageId}__hub`, coord: `${pageId}__coord`, link: `${pageId}_link` };
|
|
72
|
+
export function multiBoardIds(pageId: string): { root: string; hub: string; coord: string; link: string; prose: string } {
|
|
73
|
+
return { root: `${pageId}__mb_root`, hub: `${pageId}__hub`, coord: `${pageId}__coord`, link: `${pageId}_link`, prose: `${pageId}__mb_prose` };
|
|
48
74
|
}
|
|
49
75
|
|
|
50
76
|
export interface BoardPanelBlock {
|
|
@@ -55,28 +81,74 @@ export interface BoardPanelBlock {
|
|
|
55
81
|
span: number;
|
|
56
82
|
/** 面板声明里的 `class`(同族覆写,最后合并) */
|
|
57
83
|
class?: string;
|
|
84
|
+
/** 面板组名(语义键,如「进度」):同组面板收进页内页签的同一签;缺省 = 首屏常显区 */
|
|
85
|
+
group?: string;
|
|
86
|
+
/** 面板头控件槽位(panels.<控件>.head: <本面板>):已编好的控件 HTML,放进标题行右侧;无标题时单独成一行靠右 */
|
|
87
|
+
head?: string;
|
|
88
|
+
/** 页面构成:强调级(primary 主 / secondary 次 …)与容器形态(card 有框 / plain 无容器);缺省 secondary + card */
|
|
89
|
+
emphasis?: 'primary' | 'secondary' | 'tertiary' | 'quiet';
|
|
90
|
+
container?: 'card' | 'plain';
|
|
91
|
+
/** 头带(被 head 指向的概况类构件 HTML):挂在标题行下,无容器 */
|
|
92
|
+
band?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 面板头控件的容器:靠右(标题行里 ms-auto),窄时换行 */
|
|
96
|
+
export const MULTI_BOARD_HEAD_CLASS = 'ms-auto flex min-w-0 flex-wrap items-center justify-end gap-region';
|
|
97
|
+
|
|
98
|
+
/** 并为前一面板页脚的数据说明(紧跟其后、无标题、collapse 的 NoticeList 面板):放在宿主面板内容最后 */
|
|
99
|
+
export function appendPanelFooter(block: BoardPanelBlock, footerHtml: string): void {
|
|
100
|
+
block.html = `${block.html}\n<div data-kit-panel-footer="">${footerHtml}</div>`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** 一组面板的栅格 HTML(首屏区与每个页签签内共用同一份) */
|
|
104
|
+
export function boardGridHtml(blocks: readonly BoardPanelBlock[], areaClass: Record<string, string>): string {
|
|
105
|
+
const sections = blocks.map((p) => {
|
|
106
|
+
const head = p.head === undefined || p.head === '' ? '' : `<div${cls(MULTI_BOARD_HEAD_CLASS)} data-kit-panel-head="">${p.head}</div>`;
|
|
107
|
+
const title = p.title === ''
|
|
108
|
+
? (head === '' ? '' : `<div${cls(KIT_CLASS_DEFAULTS.toolbarTitleRow)}>${head}</div>`)
|
|
109
|
+
: kitPanelTitleRowHtml({ title: p.title, actionsHtml: `${p.toolbar ?? ''}${head}` });
|
|
110
|
+
const plain = p.container === 'plain';
|
|
111
|
+
const klass = mergeClass(
|
|
112
|
+
mergeClass(mergeClass(plain ? MULTI_BOARD_CLASS.panelPlain : MULTI_BOARD_CLASS.panel, MULTI_BOARD_SPANS[p.span]), areaClass.panel),
|
|
113
|
+
p.class,
|
|
114
|
+
);
|
|
115
|
+
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>`;
|
|
116
|
+
const compose = ` data-kit-emphasis="${p.emphasis ?? 'secondary'}" data-kit-container="${plain ? 'plain' : 'card'}"`;
|
|
117
|
+
// 无容器的面板(E3 / E4、被包含者、唯一主体)是 div:section 标签会吃容器的外圈与阴影,画出一张零内边距的卡、内容贴边;
|
|
118
|
+
// 有卡的面板才是 section(p-card 标准内边距)。唯一主体不套卡时内容落在页面对齐轴上
|
|
119
|
+
const tag = plain ? 'div' : 'section';
|
|
120
|
+
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}>`;
|
|
121
|
+
});
|
|
122
|
+
return `<div${cls(mergeClass(MULTI_BOARD_CLASS.panels, areaClass.panels))}>\n${sections.join('\n')}\n</div>`;
|
|
58
123
|
}
|
|
59
124
|
|
|
60
125
|
/** 整个壳:协作组件宿主 + 筛选卡 + 面板栅格。区域类按 7.3 同族规则覆写 */
|
|
61
126
|
export function multiBoardHtml(
|
|
62
127
|
ids: ReturnType<typeof multiBoardIds>,
|
|
63
|
-
parts: { filter: string; panels: BoardPanelBlock[]; hub: boolean },
|
|
128
|
+
parts: { filter: string; panels: BoardPanelBlock[]; hub: boolean; /** 分组页签块(已渲染,在首屏区之后) */ tabs?: string; /** 概况条成员(hero 槽,合成一条无容器的带;kind = 构件名,统计块与结论块分左右并排) */ hero?: Array<{ title: string; html: string; kind?: string }>; /** 概况条成员的范围切换类控件:搬运标记块,页面编译搬进页头标题右侧 */ heroHead?: string; },
|
|
64
129
|
areaClass: Record<string, string>,
|
|
65
130
|
extra: string | undefined,
|
|
66
131
|
): string {
|
|
67
|
-
const hosts = `${parts.hub ? host('KitLinkHub', ids.hub) : ''}${host('KitCrudBridge', ids.coord)}`;
|
|
132
|
+
const hosts = `${parts.hub ? host('KitLinkHub', ids.hub) : ''}${host('KitCrudBridge', ids.coord)}${host('KitBoardProse', ids.prose)}`;
|
|
68
133
|
const filter = parts.filter === ''
|
|
69
134
|
? ''
|
|
70
|
-
: `<section${cls(mergeClass(MULTI_BOARD_CLASS.filter, areaClass.filter))}>${parts.filter}</section>`;
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
135
|
+
: `<section${cls(mergeClass(MULTI_BOARD_CLASS.filter, areaClass.filter))} data-kit-container="plain">${parts.filter}</section>`;
|
|
136
|
+
const heroItems = parts.hero ?? [];
|
|
137
|
+
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>`;
|
|
138
|
+
const stats = heroItems.filter((h) => h.kind !== undefined && HERO_STAT_KINDS.has(h.kind));
|
|
139
|
+
const conclusions = heroItems.filter((h) => !stats.includes(h));
|
|
140
|
+
const heroAttrs = 'data-kit-slot="hero" data-kit-summary="" data-kit-role="summary" data-kit-emphasis="primary" data-kit-container="plain"';
|
|
141
|
+
// 概况条是 div(不是 section:section 标签会吃容器的外圈与阴影,概况条是一条带,不是卡)。
|
|
142
|
+
// 有结论块也有统计块:结论左、统计右(引擎给并排档);只有一类:成员并排、窄时换行
|
|
143
|
+
const hero = heroItems.length === 0
|
|
144
|
+
? ''
|
|
145
|
+
: stats.length > 0 && conclusions.length > 0
|
|
146
|
+
? `<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 data-kit-hero-stats=""${cls(MULTI_BOARD_CLASS.heroStats)}>${stats.map((h) => heroMember(h, 'min-w-0')).join('')}</div></div>`
|
|
147
|
+
: `<div ${heroAttrs}${cls(MULTI_BOARD_CLASS.hero)}>${heroItems.map((h) => heroMember(h, MULTI_BOARD_CLASS.heroItem)).join('')}</div>`;
|
|
148
|
+
const heroHead = parts.heroHead === undefined || parts.heroHead === ''
|
|
149
|
+
? ''
|
|
150
|
+
: `<div ${KIT_HOIST_ATTR}="${KIT_HOIST_HEADER_ACTIONS}" class="${MULTI_BOARD_HEAD_CLASS}" data-kit-panel-head="">${parts.heroHead}</div>`;
|
|
151
|
+
const grid = parts.panels.length === 0 ? '' : boardGridHtml(parts.panels, areaClass);
|
|
80
152
|
const root = mergeClass(mergeClass(MULTI_BOARD_CLASS.root, areaClass.root), extra);
|
|
81
|
-
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${hosts}\n${[filter, grid].filter((x) => x !== '').join('\n')}\n</div>`;
|
|
153
|
+
return `<div data-soma-id="${esc(ids.root)}" data-kit-board=""${cls(root)}>\n${hosts}\n${[heroHead, filter, hero, grid, parts.tabs ?? ''].filter((x) => x !== '').join('\n')}\n</div>`;
|
|
82
154
|
}
|
package/src/biz/names.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type { SomaScopeMirrorDecl } from 'soma-core';
|
|
11
11
|
import type { KitObject } from '../../object-renderer/types';
|
|
12
|
-
import type { KitFragment } from '../../
|
|
12
|
+
import type { KitFragment } from '../../object-renderer/fragment';
|
|
13
13
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
14
14
|
import { KIT_COORD_MIRRORS } from '../shared/coordinator';
|
|
15
15
|
import {
|
|
@@ -111,10 +111,17 @@ export function compileNotificationCenter(input: KitBizInput, ctx: KitBizContext
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
const title = typeof raw.title === 'string' ? raw.title : '';
|
|
114
|
+
const toolbarHtml = m.r.parts.toolbar ?? '';
|
|
115
|
+
const filterHtml = m.r.parts.filter ?? '';
|
|
116
|
+
// 有标题时:批量操作与标题同行左右对齐;无标题且有筛选时:批量操作与筛选分段同行左右对齐,消除三行锯齿
|
|
117
|
+
const listHeadToolbar = title !== '' ? toolbarHtml : '';
|
|
118
|
+
const listControls = title === '' && toolbarHtml !== '' && filterHtml !== ''
|
|
119
|
+
? `<div class="${NOTIFICATION_CENTER_CLASS.headRow}"><div class="min-w-0 flex-1">${filterHtml}</div><div class="shrink-0">${toolbarHtml}</div></div>`
|
|
120
|
+
: [title === '' ? toolbarHtml : '', filterHtml].filter((x) => x !== '').join('\n');
|
|
114
121
|
const html = notificationCenterHtml(
|
|
115
122
|
ids,
|
|
116
123
|
{
|
|
117
|
-
list: { title,
|
|
124
|
+
list: { title, toolbar: listHeadToolbar, html: [listControls, m.listHtml].filter((x) => x !== '').join('\n') },
|
|
118
125
|
detail: { title: '', html: m.r.parts.summary ?? '' },
|
|
119
126
|
},
|
|
120
127
|
areaClass,
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// 分栏靠容器查询变体 `@md:`:窄容器下上下堆叠;达到 md 档左 5 / 右 7(共 12 份)。
|
|
3
3
|
|
|
4
4
|
import { KIT_TIPS_SCOPE_ATTR } from '../../base/hint-tips';
|
|
5
|
-
import { mergeClass } from '../../
|
|
5
|
+
import { mergeClass } from '../../shared/merge-class';
|
|
6
6
|
import { KIT_SHELL_FLAT_MARK, kitShellRecipe } from '../../recipes/container';
|
|
7
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
7
8
|
import { cls, esc, host } from '../link/shared';
|
|
8
9
|
|
|
9
10
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -11,11 +12,12 @@ export const NOTIFICATION_CENTER_AREAS = ['root', 'list', 'detail'] as const;
|
|
|
11
12
|
export type NotificationCenterArea = (typeof NOTIFICATION_CENTER_AREAS)[number];
|
|
12
13
|
|
|
13
14
|
export const NOTIFICATION_CENTER_CLASS = {
|
|
14
|
-
root: '@container flex flex-col gap-
|
|
15
|
-
grid: 'grid grid-cols-12 gap-
|
|
16
|
-
list: mergeClass('col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-
|
|
17
|
-
detail: mergeClass('col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-
|
|
18
|
-
|
|
15
|
+
root: '@container flex flex-col gap-section',
|
|
16
|
+
grid: 'grid grid-cols-12 gap-section',
|
|
17
|
+
list: mergeClass('col-span-12 @md:col-span-5 flex min-w-0 flex-col gap-region p-card', kitShellRecipe()),
|
|
18
|
+
detail: mergeClass('col-span-12 @md:col-span-7 flex min-w-0 flex-col gap-region p-card', kitShellRecipe()),
|
|
19
|
+
headRow: 'flex flex-wrap items-center justify-between gap-region',
|
|
20
|
+
title: mergeClass('min-w-0 truncate', kitTypographyRecipe('sectionTitle')),
|
|
19
21
|
} as const;
|
|
20
22
|
|
|
21
23
|
export function notificationCenterIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
@@ -24,6 +26,8 @@ export function notificationCenterIds(pageId: string): { root: string; hub: stri
|
|
|
24
26
|
|
|
25
27
|
export interface NoticeColumn {
|
|
26
28
|
title: string;
|
|
29
|
+
/** 与标题(或筛选分段)同行右对齐的批量工具栏 HTML */
|
|
30
|
+
toolbar?: string;
|
|
27
31
|
html: string;
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -36,7 +40,11 @@ export function notificationCenterHtml(
|
|
|
36
40
|
): string {
|
|
37
41
|
const col = (area: 'list' | 'detail', c: NoticeColumn): string => {
|
|
38
42
|
const title = c.title === '' ? '' : `<h3${cls(NOTIFICATION_CENTER_CLASS.title)} ${KIT_TIPS_SCOPE_ATTR}="">${esc(c.title)}</h3>`;
|
|
39
|
-
|
|
43
|
+
const toolbar = c.toolbar ?? '';
|
|
44
|
+
const head = title !== '' && toolbar !== ''
|
|
45
|
+
? `<div${cls(NOTIFICATION_CENTER_CLASS.headRow)}>${title}<div class="shrink-0">${toolbar}</div></div>`
|
|
46
|
+
: `${title}${toolbar}`;
|
|
47
|
+
return `<section data-kit-container="card"${cls(mergeClass(NOTIFICATION_CENTER_CLASS[area], areaClass[area]))}${KIT_SHELL_FLAT_MARK}>${head}${c.html}</section>`;
|
|
40
48
|
};
|
|
41
49
|
const root = mergeClass(mergeClass(NOTIFICATION_CENTER_CLASS.root, areaClass.root), extra);
|
|
42
50
|
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${host('KitLinkHub', ids.hub)}${host('KitCrudBridge', ids.coord)}\n`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import { defineKitBizComponent } from "../define";
|
|
13
13
|
import type { KitBizContext, KitBizDefinition, KitBizInput, KitBizRole } from "../types";
|
|
14
|
-
import type { KitFragment } from "../../
|
|
14
|
+
import type { KitFragment } from "../../object-renderer/fragment";
|
|
15
15
|
import type { KitObject } from "../../object-renderer/types";
|
|
16
16
|
import { filterAnchor } from "../../object-renderer/compile-data";
|
|
17
17
|
import { emitObject } from "../../object-renderer/emit-object";
|
|
@@ -19,6 +19,10 @@ import { dropSliceReload, registerSliceReload } from "../../object-renderer/filt
|
|
|
19
19
|
import { checkRoleAllowedViews } from "../shared/compile-helpers";
|
|
20
20
|
import { addEmit, classesIn, isRec, newParts, type Rec } from "../link/shared";
|
|
21
21
|
import { checkAreas, finishTemplate, templateObjectName } from "./shared";
|
|
22
|
+
import { kitShellRecipe } from "../../recipes/container";
|
|
23
|
+
|
|
24
|
+
/** 领域模板区块的外缘 = 壳配方(容器边,KT-B2) */
|
|
25
|
+
const SECTION_EDGE = kitShellRecipe({ tone: "base", shadow: false });
|
|
22
26
|
|
|
23
27
|
function cloneRec(raw: Rec): Rec {
|
|
24
28
|
return JSON.parse(JSON.stringify(raw)) as Rec;
|
|
@@ -129,7 +133,7 @@ function compileDomainTemplate(
|
|
|
129
133
|
const customClass = areaClass[rName] ?? "";
|
|
130
134
|
const sectionClass = customClass ? ` ${customClass}` : "";
|
|
131
135
|
sectionHtmls.push(
|
|
132
|
-
`<section class="p-
|
|
136
|
+
`<section data-kit-container="card" class="p-card ${SECTION_EDGE}${sectionClass}" data-soma-id="${objectName}__root">\n${emitRes.html}\n</section>`,
|
|
133
137
|
);
|
|
134
138
|
}
|
|
135
139
|
|
|
@@ -148,7 +152,7 @@ function compileDomainTemplate(
|
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
const rootClass = input.class ? ` ${input.class}` : "";
|
|
151
|
-
const html = `<div data-soma-id="${ctx.pageId}__${kind.toLowerCase()}_root" class="flex flex-col gap-
|
|
155
|
+
const html = `<div data-soma-id="${ctx.pageId}__${kind.toLowerCase()}_root" class="flex flex-col gap-section p-card${rootClass}">\n${sectionHtmls.join("\n")}\n</div>`;
|
|
152
156
|
|
|
153
157
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
154
158
|
return finishTemplate(out, html);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// detail 可选,只读展示对象,卡片下半的明细(错误详情 / 回执摘要,常用 summary)
|
|
6
6
|
// 状态码不由本模板判定:页面是 403 还是 404 由路由与服务端决定,模板只负责把它摆好看。
|
|
7
7
|
|
|
8
|
-
import type { KitFragment } from '../../../
|
|
8
|
+
import type { KitFragment } from '../../../object-renderer/fragment';
|
|
9
9
|
import type { KitBizContext, KitBizInput } from '../../types';
|
|
10
10
|
import { classesIn, isRec, newParts } from '../../link/shared';
|
|
11
11
|
import {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// ResultPage 的 HTML 代码壳:整页居中承载一个结果面板(成功 / 失败 / 403 / 404 / 500 / 空),可选附一块明细。
|
|
2
2
|
// 只有结构与 Tailwind 类。放进 blank-frame 时垂直水平居中;放进 single-frame 时只是顶部居中的一张卡。
|
|
3
3
|
|
|
4
|
-
import { mergeClass } from '../../../
|
|
4
|
+
import { mergeClass } from '../../../shared/merge-class';
|
|
5
5
|
import { kitShellRecipe } from '../../../recipes/container';
|
|
6
|
+
import { KIT_DIVIDER_FOOT_CLASS } from '../../../recipes/divider';
|
|
6
7
|
import { cls, esc } from '../../link/shared';
|
|
7
8
|
|
|
8
9
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -10,9 +11,9 @@ export const RESULT_PAGE_AREAS = ['root', 'card', 'detail'] as const;
|
|
|
10
11
|
export type ResultPageArea = (typeof RESULT_PAGE_AREAS)[number];
|
|
11
12
|
|
|
12
13
|
export const RESULT_PAGE_CLASS = {
|
|
13
|
-
root: '@container flex w-full min-h-screen items-center justify-center p-
|
|
14
|
+
root: '@container flex w-full min-h-screen items-center justify-center p-inset-roomy',
|
|
14
15
|
card: mergeClass('flex w-full max-w-xl flex-col', kitShellRecipe()),
|
|
15
|
-
detail:
|
|
16
|
+
detail: `${KIT_DIVIDER_FOOT_CLASS} p-inset-roomy`,
|
|
16
17
|
} as const;
|
|
17
18
|
|
|
18
19
|
export function resultPageIds(pageId: string): { root: string } {
|
|
@@ -26,7 +27,7 @@ export function resultPageHtml(
|
|
|
26
27
|
extra: string | undefined,
|
|
27
28
|
): string {
|
|
28
29
|
const detail = parts.detail === '' ? '' : `\n<div${cls(mergeClass(RESULT_PAGE_CLASS.detail, areaClass.detail))}>${parts.detail}</div>`;
|
|
29
|
-
const card = `<section${cls(mergeClass(RESULT_PAGE_CLASS.card, areaClass.card))}>\n${parts.result}${detail}\n</section>`;
|
|
30
|
+
const card = `<section data-kit-container="card"${cls(mergeClass(RESULT_PAGE_CLASS.card, areaClass.card))}>\n${parts.result}${detail}\n</section>`;
|
|
30
31
|
const root = mergeClass(mergeClass(RESULT_PAGE_CLASS.root, areaClass.root), extra);
|
|
31
32
|
return `<div data-soma-id="${esc(ids.root)}"${cls(root)}>\n${card}\n</div>`;
|
|
32
33
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { KIT_VIEW_FORM_KEYS, KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
5
5
|
import { emitObject } from '../../object-renderer/emit-object';
|
|
6
6
|
import type { KitDiagnostic, KitObject } from '../../object-renderer/types';
|
|
7
|
-
import type { KitFragment } from '../../
|
|
7
|
+
import type { KitFragment } from '../../object-renderer/fragment';
|
|
8
8
|
import type { KitBizContext, KitBizInput, KitBizRole } from '../types';
|
|
9
9
|
import {
|
|
10
10
|
bizObjectName, checkRoleAllowedViews, finishBizCompile, validateBizAreaClass,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { KIT_BIZ_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
16
16
|
import type { KitDiagnostic } from '../../../object-renderer/types';
|
|
17
|
-
import type { KitFragment } from '../../../
|
|
17
|
+
import type { KitFragment } from '../../../object-renderer/fragment';
|
|
18
18
|
import { safeHref } from '../../../base/link';
|
|
19
19
|
import { classesIn, isRec, IDENT, type Rec } from '../../link/shared';
|
|
20
20
|
import { wrapKitBizComponent } from '../../compose';
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
// split 左品牌右表单:窄容器上下堆叠,够宽时左右各半;左栏是品牌区(名称 / 标语 / 要点),右栏同 center 的表单列
|
|
6
6
|
// 表单卡就是内层 SingleObjectForm 的产物;本壳只负责它周围的内容。链接与第三方按钮是 Link / Button 实例,只抛 click 事件。
|
|
7
7
|
|
|
8
|
-
import { mergeClass } from '../../../
|
|
8
|
+
import { mergeClass } from '../../../shared/merge-class';
|
|
9
9
|
import { cls, esc, host } from '../../link/shared';
|
|
10
|
-
import { kitIconHtml } from '../../../
|
|
10
|
+
import { kitIconHtml } from '../../../shared/icons';
|
|
11
11
|
|
|
12
12
|
export const SIGN_IN_LAYOUTS = ['center', 'split'] as const;
|
|
13
13
|
export type SignInLayout = (typeof SIGN_IN_LAYOUTS)[number];
|
|
@@ -16,28 +16,28 @@ export type SignInLayout = (typeof SIGN_IN_LAYOUTS)[number];
|
|
|
16
16
|
export const SIGN_IN_EXTRA_AREAS = ['page', 'aside', 'brand', 'column', 'links', 'social'] as const;
|
|
17
17
|
|
|
18
18
|
export const SIGN_IN_CLASS = {
|
|
19
|
-
pageCenter: 'flex min-h-screen w-full items-center justify-center bg-surface-sunken p-
|
|
19
|
+
pageCenter: 'flex min-h-screen w-full items-center justify-center bg-surface-sunken p-inset-roomy',
|
|
20
20
|
pageSplitHost: '@container w-full',
|
|
21
|
-
pageSplit: 'grid min-h-screen w-full grid-cols-1 bg-surface @2xl:grid-cols-2',
|
|
22
|
-
column: 'flex w-full max-w-md flex-col gap-
|
|
23
|
-
columnSplit: 'flex w-full items-center justify-center p-
|
|
24
|
-
columnInner: 'flex w-full max-w-md flex-col gap-
|
|
25
|
-
brand: 'flex flex-col items-center gap-
|
|
21
|
+
pageSplit: 'grid min-h-screen w-full grid-cols-1 bg-surface-sunken @2xl:grid-cols-2',
|
|
22
|
+
column: 'flex w-full max-w-md flex-col gap-stack',
|
|
23
|
+
columnSplit: 'flex w-full items-center justify-center p-inset-roomy @2xl:p-12',
|
|
24
|
+
columnInner: 'flex w-full max-w-md flex-col gap-stack',
|
|
25
|
+
brand: 'flex flex-col items-center gap-cluster text-center',
|
|
26
26
|
brandLogo: 'h-10 w-10 rounded-md object-contain',
|
|
27
27
|
brandName: 'text-display text-fg',
|
|
28
28
|
brandTagline: 'text-sm text-fg-muted',
|
|
29
|
-
aside: 'flex flex-col justify-center gap-
|
|
29
|
+
aside: 'flex flex-col justify-center gap-stack bg-primary p-8 text-primary-fg @2xl:p-12',
|
|
30
30
|
asideName: 'text-display',
|
|
31
31
|
asideTagline: 'text-base opacity-80',
|
|
32
|
-
asidePoints: 'flex flex-col gap-
|
|
33
|
-
asidePoint: 'flex items-start gap-
|
|
32
|
+
asidePoints: 'flex flex-col gap-cluster text-sm',
|
|
33
|
+
asidePoint: 'flex items-start gap-cluster',
|
|
34
34
|
card: 'max-w-md',
|
|
35
|
-
links: 'flex flex-wrap items-center justify-between gap-
|
|
36
|
-
linksEnd: 'flex flex-wrap items-center justify-end gap-
|
|
37
|
-
socialWrap: 'flex flex-col gap-
|
|
38
|
-
socialLabel: 'flex items-center gap-
|
|
35
|
+
links: 'flex flex-wrap items-center justify-between gap-cluster text-sm',
|
|
36
|
+
linksEnd: 'flex flex-wrap items-center justify-end gap-cluster text-sm',
|
|
37
|
+
socialWrap: 'flex flex-col gap-region',
|
|
38
|
+
socialLabel: 'flex items-center gap-region text-xs text-fg-subtle',
|
|
39
39
|
socialRule: 'h-px flex-1 bg-border-subtle',
|
|
40
|
-
socialList: 'flex flex-col gap-
|
|
40
|
+
socialList: 'flex flex-col gap-cluster',
|
|
41
41
|
} as const;
|
|
42
42
|
|
|
43
43
|
export interface SignInBrand {
|
|
@@ -78,7 +78,7 @@ function asideHtml(brand: SignInBrand, areaClass: Record<string, string>): strin
|
|
|
78
78
|
const points = brand.points.length === 0
|
|
79
79
|
? ''
|
|
80
80
|
: `<ul${cls(SIGN_IN_CLASS.asidePoints)}>${brand.points.map((p) => `<li${cls(SIGN_IN_CLASS.asidePoint)}><span aria-hidden="true">${kitIconHtml('check', 'sm')}</span><span>${esc(p)}</span></li>`).join('')}</ul>`;
|
|
81
|
-
return `<aside${cls(mergeClass(SIGN_IN_CLASS.aside, areaClass.aside))}>${name}${tagline}${points}</aside>`;
|
|
81
|
+
return `<aside data-kit-container="card"${cls(mergeClass(SIGN_IN_CLASS.aside, areaClass.aside))}>${name}${tagline}${points}</aside>`;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function linksHtml(items: readonly SignInLinkItem[], areaClass: Record<string, string>): string {
|
|
@@ -88,7 +88,7 @@ function linksHtml(items: readonly SignInLinkItem[], areaClass: Record<string, s
|
|
|
88
88
|
const row = (list: readonly SignInLinkItem[], base: string): string =>
|
|
89
89
|
list.length === 0 ? '' : `<div${cls(base)}>${list.map((i) => host('Link', i.id)).join('')}</div>`;
|
|
90
90
|
const base = start.length === 0 ? SIGN_IN_CLASS.linksEnd : SIGN_IN_CLASS.links;
|
|
91
|
-
return `<div${cls(mergeClass(base, areaClass.links))}>${row(start, 'flex items-center gap-
|
|
91
|
+
return `<div${cls(mergeClass(base, areaClass.links))}>${row(start, 'flex items-center gap-cluster')}${row(end, 'flex items-center gap-cluster')}</div>`;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function socialHtml(block: SignInSocialBlock | undefined, areaClass: Record<string, string>): string {
|