soma-kit 0.1.13 → 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/package.json +3 -3
- package/spec/generated/kit-app.schema.json +14 -0
- package/spec/generated/kit-page.schema.json +25 -0
- package/spec/kit-grammar.json +178 -27
- package/spec/kit-grammar.schema.json +1 -3
- package/src/app/app-config.ts +10 -4
- package/src/app/index.ts +13 -1
- package/src/app/kit-view-context.ts +19 -2
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/base/button.ts +5 -3
- package/src/base/end-edge.ts +14 -2
- package/src/base/gap-value.ts +24 -4
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +5 -0
- package/src/base/menu-button.ts +10 -23
- package/src/base/popover.ts +5 -4
- package/src/base/segmented.ts +14 -4
- package/src/base/shared.ts +11 -13
- package/src/base/state-panel.ts +34 -13
- package/src/base/tag.ts +18 -13
- package/src/base/text.ts +1 -1
- package/src/base/upload.ts +5 -4
- package/src/biz/approval-desk/shell.ts +8 -7
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +3 -2
- package/src/biz/category-crud/shell.ts +4 -3
- package/src/biz/checkout-page/shell.ts +9 -8
- package/src/biz/compose.ts +2 -2
- package/src/biz/data-components.ts +4 -0
- package/src/biz/import-wizard/shell.ts +12 -10
- package/src/biz/landing-page/shell.ts +2 -2
- package/src/biz/master-sub/compile.ts +114 -15
- package/src/biz/master-sub/detail-head.ts +61 -0
- package/src/biz/master-sub/index.ts +3 -2
- package/src/biz/master-sub/shell.ts +95 -63
- package/src/biz/multi-board/compile.ts +164 -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 +91 -23
- package/src/biz/notification-center/shell.ts +6 -5
- package/src/biz/page-templates/domain-templates.ts +2 -2
- package/src/biz/page-templates/result-page/shell.ts +2 -2
- package/src/biz/page-templates/sign-in-page/shell.ts +14 -14
- package/src/biz/record-detail/shell.ts +8 -7
- package/src/biz/settings-center/shell.ts +8 -7
- package/src/biz/shared/compile-helpers.ts +82 -3
- package/src/biz/shared/overlay-compile.ts +46 -4
- package/src/biz/shared/overlay-shell.ts +8 -6
- package/src/biz/single-form/shell.ts +6 -4
- package/src/biz/standard-crud/compile.ts +14 -1
- package/src/biz/standard-crud/shell.ts +18 -27
- package/src/biz/standard-crud/summary.ts +40 -0
- package/src/biz/step-form/shell.ts +11 -9
- package/src/biz/types.ts +6 -1
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/compile-page.ts +15 -4
- package/src/compile/component-candidates.ts +2 -0
- package/src/compile/fragment.ts +11 -0
- package/src/compile/layout-lint/rules-composition.ts +55 -6
- 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 +189 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/styles.ts +11 -1
- package/src/compile/types.ts +3 -1
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +3 -1
- package/src/data/approval-flow.ts +4 -1
- package/src/data/assignment-picker.ts +9 -4
- package/src/data/async-result-panel.ts +1 -1
- package/src/data/calendar.ts +7 -2
- package/src/data/carousel.ts +2 -0
- package/src/data/chart.ts +609 -42
- package/src/data/checklist.ts +4 -1
- package/src/data/comment-thread.ts +2 -1
- package/src/data/confirm-dialog.ts +4 -10
- package/src/data/field-mapper.ts +4 -1
- package/src/data/flow-editor.ts +2 -1
- package/src/data/footer.ts +2 -0
- package/src/data/gantt.ts +187 -25
- package/src/data/hero.ts +2 -0
- package/src/data/index.ts +10 -3
- package/src/data/item-list.ts +10 -3
- package/src/data/kanban.ts +3 -1
- package/src/data/matrix.ts +391 -0
- package/src/data/menu.ts +23 -11
- package/src/data/mockup.ts +3 -3
- package/src/data/modal-dialog.ts +118 -18
- package/src/data/navbar.ts +3 -1
- package/src/data/notice-list.ts +52 -19
- package/src/data/object-form.ts +128 -112
- package/src/data/pager.ts +3 -2
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +4 -1
- package/src/data/permission-tree.ts +6 -2
- package/src/data/pricing-table.ts +2 -1
- package/src/data/record-card.ts +18 -6
- package/src/data/resident.ts +8 -0
- package/src/data/row-editor.ts +2 -2
- package/src/data/rule-builder.ts +9 -4
- package/src/data/shape-util.ts +15 -14
- package/src/data/stat-group.ts +313 -69
- package/src/data/static-lazy.ts +4 -0
- package/src/data/static-registry.ts +6 -0
- package/src/data/survey.ts +4 -1
- package/src/data/system-switcher.ts +2 -1
- package/src/data/tour-guide.ts +2 -1
- package/src/data/transfer.ts +6 -2
- package/src/data/tree-table.ts +7 -5
- package/src/data/tree.ts +1 -1
- package/src/data/virtual-rows.ts +5 -4
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +1 -0
- package/src/frames/list-summary.ts +100 -0
- package/src/frames/page-bar.ts +6 -14
- package/src/frames/shared.ts +20 -4
- package/src/frames/tabs-frame/shell.ts +8 -6
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +3 -1
- package/src/frames/workspace-frame/shell.ts +2 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +41 -25
- package/src/generated/kit-grammar-runtime.ts +175 -28
- package/src/i18n/kit-text.ts +27 -0
- package/src/object-renderer/action-group.ts +139 -0
- package/src/object-renderer/action-more.ts +144 -0
- package/src/object-renderer/arrange.ts +49 -19
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +34 -13
- package/src/object-renderer/collection-table.ts +133 -65
- package/src/object-renderer/collection.ts +72 -59
- package/src/object-renderer/defaults.ts +2 -5
- package/src/object-renderer/emit-object.ts +4 -0
- package/src/object-renderer/emit-static.ts +116 -63
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/index.ts +5 -0
- package/src/object-renderer/layout-facts.ts +9 -1
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +59 -46
- package/src/object-renderer/table-actions.ts +72 -40
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +51 -20
- package/src/object-renderer/types.ts +7 -7
- package/src/recipes/container.ts +31 -0
- package/src/recipes/control.ts +57 -155
- package/src/recipes/emphasis.ts +56 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +23 -0
- package/src/recipes/overlay.ts +46 -1
- package/src/recipes/placeholder.ts +20 -4
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +12 -22
- package/src/recipes/status.ts +8 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +112 -6
- package/src/recipes/tabs.ts +49 -0
- package/src/recipes/title-row.ts +3 -3
- package/src/recipes/typography.ts +23 -42
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +13 -2
- package/src/theme/kit-theme.tpl +13 -2
- package/src/theme/nine-dim-structure.ts +77 -10
- package/src/theme/surface-layers.ts +6 -1
- package/src/theme/theme-tokens.ts +12 -5
- package/src/theme/typography.ts +21 -17
|
@@ -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,21 +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';
|
|
6
|
-
import { KIT_SHELL_FLAT_MARK, kitShellRecipe } from '../../recipes/container';
|
|
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_HOIST_ATTR, KIT_HOIST_HEADER_ACTIONS, tablesOnCanvas } from '../shared/compile-helpers';
|
|
8
10
|
import { cls, esc, host } from '../link/shared';
|
|
9
11
|
|
|
10
12
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
11
13
|
export const MULTI_BOARD_AREAS = ['root', 'filter', 'panels', 'panel'] as const;
|
|
12
14
|
export type MultiBoardArea = (typeof MULTI_BOARD_AREAS)[number];
|
|
13
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
|
+
|
|
14
21
|
export const MULTI_BOARD_CLASS = {
|
|
15
|
-
root: '@container flex flex-col gap-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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',
|
|
19
41
|
} as const;
|
|
20
42
|
|
|
21
43
|
const WIDTH_GRAMMAR = KIT_GRAMMAR.width as {
|
|
@@ -30,8 +52,7 @@ export const MULTI_BOARD_GRID_SPANS: readonly number[] = Object.freeze(
|
|
|
30
52
|
WIDTH_GRAMMAR.gridSpans ?? Object.keys(WIDTH_GRAMMAR.spanClassTable).map(Number),
|
|
31
53
|
);
|
|
32
54
|
|
|
33
|
-
/** 面板宽度:窄容器恒整行,md 档起占 N/12 */
|
|
34
|
-
export const MULTI_BOARD_SPAN_DEFAULT = KIT_WIDTH.totalParts / 2;
|
|
55
|
+
/** 面板宽度:窄容器恒整行,md 档起占 N/12(份数由构成分析推导,作者写的 span 覆盖;这里只给「份数 → 类串」) */
|
|
35
56
|
export const MULTI_BOARD_SPANS: Readonly<Record<number, string>> = Object.freeze(
|
|
36
57
|
Object.fromEntries(
|
|
37
58
|
MULTI_BOARD_GRID_SPANS.map((span) => [
|
|
@@ -43,8 +64,8 @@ export const MULTI_BOARD_SPANS: Readonly<Record<number, string>> = Object.freeze
|
|
|
43
64
|
),
|
|
44
65
|
);
|
|
45
66
|
|
|
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` };
|
|
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` };
|
|
48
69
|
}
|
|
49
70
|
|
|
50
71
|
export interface BoardPanelBlock {
|
|
@@ -55,28 +76,75 @@ export interface BoardPanelBlock {
|
|
|
55
76
|
span: number;
|
|
56
77
|
/** 面板声明里的 `class`(同族覆写,最后合并) */
|
|
57
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>`;
|
|
58
118
|
}
|
|
59
119
|
|
|
60
120
|
/** 整个壳:协作组件宿主 + 筛选卡 + 面板栅格。区域类按 7.3 同族规则覆写 */
|
|
61
121
|
export function multiBoardHtml(
|
|
62
122
|
ids: ReturnType<typeof multiBoardIds>,
|
|
63
|
-
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 },
|
|
64
124
|
areaClass: Record<string, string>,
|
|
65
125
|
extra: string | undefined,
|
|
66
126
|
): string {
|
|
67
|
-
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)}`;
|
|
68
128
|
const filter = parts.filter === ''
|
|
69
129
|
? ''
|
|
70
|
-
: `<section${cls(mergeClass(MULTI_BOARD_CLASS.filter, areaClass.filter))}>${parts.filter}</section>`;
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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);
|
|
80
147
|
const root = mergeClass(mergeClass(MULTI_BOARD_CLASS.root, areaClass.root), extra);
|
|
81
|
-
|
|
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>`;
|
|
82
150
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { KIT_TIPS_SCOPE_ATTR } from '../../base/hint-tips';
|
|
5
5
|
import { mergeClass } from '../../object-renderer/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,11 @@ 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
|
-
title: 'min-w-0 truncate
|
|
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
|
+
title: mergeClass('min-w-0 truncate', kitTypographyRecipe('sectionTitle')),
|
|
19
20
|
} as const;
|
|
20
21
|
|
|
21
22
|
export function notificationCenterIds(pageId: string): { root: string; hub: string; coord: string; link: string } {
|
|
@@ -129,7 +129,7 @@ function compileDomainTemplate(
|
|
|
129
129
|
const customClass = areaClass[rName] ?? "";
|
|
130
130
|
const sectionClass = customClass ? ` ${customClass}` : "";
|
|
131
131
|
sectionHtmls.push(
|
|
132
|
-
`<section class="p-
|
|
132
|
+
`<section class="p-card rounded-lg bg-surface border border-border-subtle${sectionClass}" data-soma-id="${objectName}__root">\n${emitRes.html}\n</section>`,
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -148,7 +148,7 @@ function compileDomainTemplate(
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
const rootClass = input.class ? ` ${input.class}` : "";
|
|
151
|
-
const html = `<div data-soma-id="${ctx.pageId}__${kind.toLowerCase()}_root" class="flex flex-col gap-
|
|
151
|
+
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
152
|
|
|
153
153
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
154
154
|
return finishTemplate(out, html);
|
|
@@ -10,9 +10,9 @@ export const RESULT_PAGE_AREAS = ['root', 'card', 'detail'] as const;
|
|
|
10
10
|
export type ResultPageArea = (typeof RESULT_PAGE_AREAS)[number];
|
|
11
11
|
|
|
12
12
|
export const RESULT_PAGE_CLASS = {
|
|
13
|
-
root: '@container flex w-full min-h-screen items-center justify-center p-
|
|
13
|
+
root: '@container flex w-full min-h-screen items-center justify-center p-inset-roomy',
|
|
14
14
|
card: mergeClass('flex w-full max-w-xl flex-col', kitShellRecipe()),
|
|
15
|
-
detail: 'border-t border-border-subtle p-
|
|
15
|
+
detail: 'border-t border-border-subtle p-inset-roomy',
|
|
16
16
|
} as const;
|
|
17
17
|
|
|
18
18
|
export function resultPageIds(pageId: string): { root: string } {
|
|
@@ -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
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-
|
|
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 {
|
|
@@ -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 {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { KIT_TIPS_SCOPE_ATTR } from '../../base/hint-tips';
|
|
6
6
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
7
7
|
import { KIT_SHELL_FLAT_MARK, kitShellRecipe } from '../../recipes/container';
|
|
8
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
8
9
|
import { cls, esc, host } from '../link/shared';
|
|
9
10
|
|
|
10
11
|
/** 壳的内部区域名(`areaClass` 的合法键) */
|
|
@@ -12,14 +13,14 @@ export const RECORD_DETAIL_AREAS = ['root', 'header', 'actions', 'groups', 'grou
|
|
|
12
13
|
export type RecordDetailArea = (typeof RECORD_DETAIL_AREAS)[number];
|
|
13
14
|
|
|
14
15
|
export const RECORD_DETAIL_CLASS = {
|
|
15
|
-
root: '@container flex flex-col gap-
|
|
16
|
-
header: mergeClass('flex flex-wrap items-start justify-between gap-
|
|
16
|
+
root: '@container flex flex-col gap-section',
|
|
17
|
+
header: mergeClass('flex flex-wrap items-start justify-between gap-section p-card', kitShellRecipe()),
|
|
17
18
|
summary: 'min-w-0 flex-1',
|
|
18
|
-
actions: 'flex shrink-0 flex-
|
|
19
|
-
groups: 'grid grid-cols-12 gap-
|
|
20
|
-
group: mergeClass('col-span-12 @md:col-span-6 flex min-w-0 flex-col gap-
|
|
21
|
-
sub: mergeClass('flex min-w-0 flex-col gap-
|
|
22
|
-
blockTitle: 'min-w-0 truncate
|
|
19
|
+
actions: 'flex shrink-0 flex-nowrap items-center gap-cluster',
|
|
20
|
+
groups: 'grid grid-cols-12 gap-section',
|
|
21
|
+
group: mergeClass('col-span-12 @md:col-span-6 flex min-w-0 flex-col gap-region p-card', kitShellRecipe()),
|
|
22
|
+
sub: mergeClass('flex min-w-0 flex-col gap-region p-card', kitShellRecipe()),
|
|
23
|
+
blockTitle: mergeClass('min-w-0 truncate', kitTypographyRecipe('sectionTitle')),
|
|
23
24
|
} as const;
|
|
24
25
|
|
|
25
26
|
export function recordDetailIds(pageId: string): {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { KIT_TIPS_SCOPE_ATTR } from '../../base/hint-tips';
|
|
5
5
|
import { mergeClass } from '../../object-renderer/merge-class';
|
|
6
6
|
import { kitShellRecipe } from '../../recipes/container';
|
|
7
|
+
import { kitTypographyRecipe } from '../../recipes/typography';
|
|
7
8
|
import { cls, esc } from '../link/shared';
|
|
8
9
|
import { kitText } from '../../i18n/kit-text';
|
|
9
10
|
|
|
@@ -12,14 +13,14 @@ export const SETTINGS_CENTER_AREAS = ['root', 'nav', 'content', 'section'] as co
|
|
|
12
13
|
export type SettingsCenterArea = (typeof SETTINGS_CENTER_AREAS)[number];
|
|
13
14
|
|
|
14
15
|
export const SETTINGS_CENTER_CLASS = {
|
|
15
|
-
root: '@container flex flex-col gap-
|
|
16
|
-
nav: mergeClass('flex w-full shrink-0 flex-col gap-1 p-
|
|
16
|
+
root: '@container flex flex-col gap-stack @md:flex-row @md:items-start',
|
|
17
|
+
nav: mergeClass('flex w-full shrink-0 flex-col gap-1 p-inset-tight @md:sticky @md:top-4 @md:w-56', kitShellRecipe()),
|
|
17
18
|
navLink: 'flex h-9 min-w-0 items-center truncate rounded-md px-3 text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring',
|
|
18
|
-
content: 'flex min-w-0 flex-1 flex-col gap-
|
|
19
|
-
section: mergeClass('flex flex-col gap-
|
|
20
|
-
title: 'min-w-0 truncate
|
|
21
|
-
/**
|
|
22
|
-
footer: 'mt-2 flex flex-
|
|
19
|
+
content: 'flex min-w-0 flex-1 flex-col gap-stack',
|
|
20
|
+
section: mergeClass('flex flex-col gap-section p-inset-roomy', kitShellRecipe()),
|
|
21
|
+
title: mergeClass('min-w-0 truncate', kitTypographyRecipe('sectionTitle')),
|
|
22
|
+
/** 分区保存栏:贴卡内底部,上方分隔线;动作组恒单行不折行(排布引擎动作组规则) */
|
|
23
|
+
footer: 'mt-2 flex flex-nowrap items-end gap-cluster border-t border-border-subtle pt-4',
|
|
23
24
|
} as const;
|
|
24
25
|
|
|
25
26
|
export function settingsCenterIds(pageId: string): { root: string; nav: string; section(name: string): string } {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// 业务组件编译期公共辅助函数:角色视图槽白名单校验、区域类闭集校验、对象命名与编译片段收敛。纯函数。
|
|
2
2
|
|
|
3
3
|
import { KIT_VIEW_SLOTS } from '../../object-renderer/defaults';
|
|
4
|
+
import { KIT_LIST_BAR_CLASS, KIT_LIST_BAR_FLAT_CLASS } from '../../recipes/container';
|
|
5
|
+
import { mergeClass } from '../../object-renderer/merge-class';
|
|
6
|
+
import { flowToolbarHtml } from '../../object-renderer/action-group';
|
|
4
7
|
import type { KitDiagnostic } from '../../object-renderer/types';
|
|
5
8
|
import type { KitFragment } from '../../compile/fragment';
|
|
6
9
|
import type { KitBizInput, KitBizRole } from '../types';
|
|
@@ -85,14 +88,90 @@ export function finishBizCompile(out: Parts, html: string): KitFragment {
|
|
|
85
88
|
* 与输入框同一水平线(不靠固定偏移);容器放不下「筛选 + 工具栏」时工具栏另起一行靠右、占位隐藏。
|
|
86
89
|
*/
|
|
87
90
|
export const KIT_FILTER_TOOLBAR_CLASS = {
|
|
88
|
-
row: '@container flex flex-wrap items-start justify-end gap-x-
|
|
91
|
+
row: '@container flex flex-wrap items-start justify-end gap-x-section gap-y-region',
|
|
89
92
|
filter: 'min-w-0 flex-1 basis-80',
|
|
90
|
-
|
|
93
|
+
// max-w-full:工具列随内容定宽,但不超过所在栏(行容器),窄栏里被压窄后内部动作组按真实栏宽收进「更多」,不溢出
|
|
94
|
+
tools: 'flex max-w-full shrink-0 flex-col gap-1.5',
|
|
91
95
|
pad: 'hidden w-full invisible text-xs @lg:block',
|
|
92
96
|
} as const;
|
|
93
97
|
|
|
94
98
|
export function filterToolbarRow(filter: string, toolbar: string): string {
|
|
95
99
|
const C = KIT_FILTER_TOOLBAR_CLASS;
|
|
96
100
|
return `<div class="${C.row}"><div class="${C.filter}">${filter}</div>`
|
|
97
|
-
|
|
101
|
+
// 工具列收缩包裹(shrink-0):查询容器没有固有宽度,工具条宿主改取定宽版(放得下的档宽,恒全部内联;放不下时整行换行,不拆组)
|
|
102
|
+
+ `<div class="${C.tools}"><span class="${C.pad}" aria-hidden="true"> </span>${flowToolbarHtml(toolbar)}</div></div>`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 列表类业务壳的单一面板结构(排布引擎的内边距归属:最外层面板持有内边距,内层区块不重复加):
|
|
107
|
+
* 工具条区(筛选 + 主操作)→ 通栏 hairline → 集合 + 计数 / 分页,全部在同一个面板里;面板自己带令牌类 `p-card`,
|
|
108
|
+
* hairline 用 `-mx-card` 抵消面板内边距、铺满面板宽。StandardCrud 的列表卡、主从工作台的主列表卡、分类管理的条目面板同用。
|
|
109
|
+
*/
|
|
110
|
+
export const KIT_LIST_PANEL_CLASS = {
|
|
111
|
+
// 筛选带:取值在配方出口 recipes/container#KIT_LIST_BAR_CLASS
|
|
112
|
+
bar: KIT_LIST_BAR_CLASS,
|
|
113
|
+
listHeadRow: 'flex flex-wrap items-center justify-between gap-cluster',
|
|
114
|
+
} as const;
|
|
115
|
+
|
|
116
|
+
/** 列表标题(`<h3 …__list__title>`)与其后的集合:有标题时主操作并入标题行右侧 */
|
|
117
|
+
const LIST_TITLE_RE = /^(<h3\b[^>]*__list__title"[^>]*>[\s\S]*?<\/h3>)([\s\S]*)$/;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 列表类业务壳的内容拆分:filterInner = 筛选区(没有列表标题时主操作并入同一行靠右),listInner = 集合区(有列表标题时标题行右侧带主操作)。
|
|
121
|
+
* `unified`:筛选与集合都有内容时为真,调用方把「筛选区 + hairline + 集合」放进同一个面板;否则各自成块。
|
|
122
|
+
*/
|
|
123
|
+
export function listPanelParts(parts: { filter: string; toolbar: string; list: string }): { filterInner: string; listInner: string; unified: boolean } {
|
|
124
|
+
const m = parts.toolbar !== '' ? LIST_TITLE_RE.exec(parts.list) : null;
|
|
125
|
+
const toolbarInFilter = parts.toolbar !== '' && m === null && parts.filter !== '';
|
|
126
|
+
const filterInner = toolbarInFilter ? filterToolbarRow(parts.filter, parts.toolbar) : parts.filter;
|
|
127
|
+
let listInner: string;
|
|
128
|
+
if (toolbarInFilter) listInner = parts.list;
|
|
129
|
+
else if (m !== null) {
|
|
130
|
+
const titleH3 = m[1]!.replace(/\bmb-\d+(?:\.\d+)?\s*/g, '');
|
|
131
|
+
listInner = [`<div class="${KIT_LIST_PANEL_CLASS.listHeadRow}">${titleH3}${parts.toolbar}</div>`, m[2]!].filter((p) => p !== '').join('\n');
|
|
132
|
+
} else listInner = [parts.toolbar, parts.list].filter((p) => p !== '').join('\n');
|
|
133
|
+
return { filterInner, listInner, unified: parts.filter !== '' && listInner !== '' };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 无容器作用域(页面画布上的无卡列 / 面板)里的表壳标成层 0:表壳自己是透明的(结构 CSS 的嵌套容器规则),但带 bg-surface 类会被表面层标注
|
|
138
|
+
* 记成「比外层深一层」的容器,把 --soma-surface-base 重指到白色面板层——表里的粘性单元(操作列底色垫层 before:bg-surface 等)因此在灰色画布上露出白带。
|
|
139
|
+
* 标成层 0 后表里的面令牌取画布色(与它真正落在的面一致)。已带 data-kit-layer 的元素表面层标注不再改。
|
|
140
|
+
*/
|
|
141
|
+
export function tablesOnCanvas(html: string): string {
|
|
142
|
+
return html.split('data-kit-part="table"').join('data-kit-layer="0" data-kit-part="table"');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 页头动作槽的搬运标记(值):区域主动作(button.region)由页面编译搬进页头尾端,没有页头的页面框原位保留(靠右一行)。 */
|
|
146
|
+
export const KIT_HOIST_HEADER_ACTIONS = 'header-actions';
|
|
147
|
+
/** 页头概况行的搬运标记(值):页面编译把它搬进页头标题行之后(StandardCrud 的 KitListSummary);没有页头的页面框原位保留。 */
|
|
148
|
+
export const KIT_HOIST_HEADER_SUMMARY = 'header-summary';
|
|
149
|
+
/** 搬运标记属性名 */
|
|
150
|
+
export const KIT_HOIST_ATTR = 'data-kit-hoist';
|
|
151
|
+
|
|
152
|
+
/** 区域主动作(工具栏)的搬运包装:页面编译把它搬进页头尾端;没有页头的页面框原位保留(靠右一行)。空工具栏返回空串。 */
|
|
153
|
+
export function hoistedToolbarHtml(toolbar: string): string {
|
|
154
|
+
return toolbar === '' ? '' : `<div ${KIT_HOIST_ATTR}="${KIT_HOIST_HEADER_ACTIONS}" class="flex justify-end">${flowToolbarHtml(toolbar)}</div>`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 无容器的列表工作面(唯一主体 = 页面本身,`container: plain`):区域主动作(工具栏)打搬运标记(页头承载),筛选带是自带圆角的下沉带,
|
|
159
|
+
* 表头 / 数据行 / 计数分页直接铺在页面上。主操作一律由页头承载(有无列表标题都一样)。
|
|
160
|
+
*/
|
|
161
|
+
export function flatListPanelHtml(parts: { filter: string; toolbar: string; list: string }, barClass = ''): string {
|
|
162
|
+
const hoist = parts.toolbar !== '';
|
|
163
|
+
const hoisted = hoistedToolbarHtml(parts.toolbar);
|
|
164
|
+
const rest = hoist ? { filter: parts.filter, toolbar: '', list: parts.list } : parts;
|
|
165
|
+
const { filterInner, listInner } = listPanelParts(rest);
|
|
166
|
+
const bar = filterInner === '' ? '' : `<div class="${mergeClass(KIT_LIST_BAR_FLAT_CLASS, barClass)}">${filterInner}</div>`;
|
|
167
|
+
return [hoisted, bar, listInner].filter((p) => p !== '').join('\n');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** 单一面板的内部 HTML:筛选带(工具条区)+ 集合(筛选与集合不全时只给有内容的部分)。`barClass` 是筛选带 div 的附加类。 */
|
|
171
|
+
export function listPanelBody(parts: { filter: string; toolbar: string; list: string }, barClass = '', flat = false): string {
|
|
172
|
+
const { filterInner, listInner, unified } = listPanelParts(parts);
|
|
173
|
+
if (!unified) return [filterInner, listInner].filter((p) => p !== '').join('\n');
|
|
174
|
+
// flat:无容器的列(控件列 / 唯一主体),筛选带自带圆角、不抵消面板内边距
|
|
175
|
+
const bar = `<div class="${flat ? KIT_LIST_BAR_FLAT_CLASS : KIT_LIST_PANEL_CLASS.bar}${barClass === '' ? '' : ` ${barClass}`}">`;
|
|
176
|
+
return `${bar}${filterInner}</div>\n${listInner}`;
|
|
98
177
|
}
|