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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { kitRowActionsNarrowCap } from 'soma-foundation/kit-layout';
|
|
1
2
|
import { esc } from '../shared/escape';
|
|
2
3
|
import { getCompileEnvelope } from '../shared/envelope';
|
|
3
4
|
// emitStatic:IR -> 静态 HTML + `_ui.yaml` 的 `show:` 片段(设计稿 §1.2 做法 B、§6)。
|
|
@@ -21,8 +22,11 @@ import { KIT_CLASS_DEFAULTS, KIT_GRAMMAR, KIT_GROUP_MARKERS, KIT_REQUIRED_STAR_C
|
|
|
21
22
|
import type { KitSkeletonCol, KitSkeletonConfig } from './skeleton';
|
|
22
23
|
import { isNumericColumnType } from './collection-table';
|
|
23
24
|
import { mergeClass } from './merge-class';
|
|
24
|
-
import {
|
|
25
|
+
import { projectActionGroup, type KitActionImportance } from './action-group';
|
|
26
|
+
import { kitTabRecipe } from '../recipes/tabs';
|
|
27
|
+
import { KIT_TABLE_GAP_HEAD_ATTR, tableGapReasonField } from '../recipes/table-gap';
|
|
25
28
|
import { kitTextActionRecipe } from '../recipes/control';
|
|
29
|
+
import { kitStatusPillProps } from '../recipes/emphasis';
|
|
26
30
|
import { KIT_OVERLAY_FORM_HOST_CLASS } from '../recipes/overlay';
|
|
27
31
|
import { KIT_PANEL_TITLE_CLASS, kitPanelTitleHtml } from '../recipes/title-row';
|
|
28
32
|
import { headAnchor } from './compile-data';
|
|
@@ -43,7 +47,14 @@ export function rowVarOf(object: string): string { return `kit_row_${object}`; }
|
|
|
43
47
|
// ---------------------------------------------------------------- 锚点命名
|
|
44
48
|
|
|
45
49
|
export function viewAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}`; }
|
|
46
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 同槽(`<对象>__list__`)里集合自己的实例后缀:字段名撞上它们会让页面锚点重复(CORE-ANCHOR-DUPLICATE,整页 500)。
|
|
52
|
+
* `state` / `title` / `meta` 都是常见的业务字段名,所以字段单元锚点遇到这些后缀时追加 `_cell`,字段名不受限。
|
|
53
|
+
*/
|
|
54
|
+
export const KIT_RESERVED_LIST_ANCHORS: ReadonlySet<string> = new Set(['ctx', 'exp', 'head', 'meta', 'ops', 'rows', 'sel', 'state', 'sum', 'title', 'tools', 'tree', 'virtual']);
|
|
55
|
+
export function cellAnchor(object: string, slot: KitViewSlot, field: string): string {
|
|
56
|
+
return `${object}__${slot}__${slot === 'list' && KIT_RESERVED_LIST_ANCHORS.has(field) ? `${field}_cell` : field}`;
|
|
57
|
+
}
|
|
47
58
|
export function rowsAnchor(object: string): string { return `${object}__list__rows`; }
|
|
48
59
|
export function opsAnchor(object: string): string { return `${object}__list__ops`; }
|
|
49
60
|
/** 右键菜单实例(Q 波 G6):行模板里每行一个,虚拟滚动表 / 树表是页面里一个 */
|
|
@@ -97,12 +108,19 @@ export interface KitStaticOptions {
|
|
|
97
108
|
schema?: KitSchema;
|
|
98
109
|
/** 是否有列表视图(决定 from 是否带 into);缺省由 IR 判断 */
|
|
99
110
|
wrapped?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 没有列表视图(from 不带 into,数据对象存的是原样响应)时,`accept: list` 的写死形状件(Chart 等)的行数组在响应体里的相对路径
|
|
113
|
+
* (来自 behavior.list.rowsPath);缺省时行数组就是数据对象本身
|
|
114
|
+
*/
|
|
115
|
+
staticRowsPath?: string;
|
|
100
116
|
/** 摘要 / 只读 form / single 写死形状件读的“当前行”路径(如 `page.region_mirror.<scope>.focus_row`);缺省同 singlePath */
|
|
101
117
|
summaryPath?: string;
|
|
102
118
|
/** 可编辑 form 的 mode 绑定路径(镜像路径);给了就不写死 formMode 字面量 */
|
|
103
119
|
formModePath?: string;
|
|
104
120
|
/** 可编辑 form 的 initial 绑定路径(镜像路径);缺省 `{}` */
|
|
105
121
|
formInitialPath?: string;
|
|
122
|
+
/** 分页条的附加类(业务壳给:列表页贴工作面底 sticky + 轴内边距) */
|
|
123
|
+
pagerClass?: string;
|
|
106
124
|
/** 表格行可点选:行容器标 data-kit-row,KitTableActions 开 pickOnRow,行点击抛 row_action(builtin select) */
|
|
107
125
|
pickOnRow?: boolean;
|
|
108
126
|
/**
|
|
@@ -141,7 +159,7 @@ function attr(name: string, value: string): string {
|
|
|
141
159
|
}
|
|
142
160
|
|
|
143
161
|
const OVERLAY_FOOTER_HOSTS: ReadonlySet<string> = new Set(['KitObjectForm', 'Transfer', 'PermissionTree', 'AssignmentPicker']);
|
|
144
|
-
const COLLAPSING_HOSTS: ReadonlySet<string> = new Set(['KitTableTools', 'KitCollectionState', 'Pager']);
|
|
162
|
+
const COLLAPSING_HOSTS: ReadonlySet<string> = new Set(['KitTableTools', 'KitTableGap', 'KitCollectionState', 'Pager']);
|
|
145
163
|
|
|
146
164
|
function host(component: string, id: string): string {
|
|
147
165
|
// 自带底栏的表单 / 穿梭框 / 授权树,其宿主在浮层滚动体里是体的 flex 子项并撑满体高(底栏才能落在浮层底部);变体只在 group-data-kit-overlay-scroll 祖先下生效
|
|
@@ -251,6 +269,14 @@ function cellProps(ctx: Ctx, cell: KitCell, valuePath: string, _at: string): Rec
|
|
|
251
269
|
props.aria_label = cell.label;
|
|
252
270
|
}
|
|
253
271
|
if (cell.valueClass !== '') props.class = cell.valueClass;
|
|
272
|
+
// 状态类字段(单选枚举且选项带 tone)默认呈现为状态徽标(emphasis.status = pill:浅色底 + on-soft 字 + 6px 圆点),全应用统一,与紧凑列表、表格一致;
|
|
273
|
+
// 圆点 + 文字(dot)形态只留给页面显式写的 variant: dot
|
|
274
|
+
// 集合里(表格 / 紧凑列表)作者写的 `variant: dot` 与不写等价——「全应用统一」是框架默认值的事,不逐页改应用页面;dot 形态留给集合之外的 Tag / StatusDot 用法
|
|
275
|
+
if (cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) {
|
|
276
|
+
const field = ctx.options.schema?.[cell.field] as { type?: string; options?: unknown } | undefined;
|
|
277
|
+
const opts = Array.isArray(field?.options) ? (field!.options as unknown[]) : [];
|
|
278
|
+
if (field?.type === 'enum' && opts.some((o) => o !== null && typeof o === 'object' && 'tone' in (o as Record<string, unknown>))) Object.assign(props, kitStatusPillProps());
|
|
279
|
+
}
|
|
254
280
|
return props;
|
|
255
281
|
}
|
|
256
282
|
|
|
@@ -364,7 +390,8 @@ export function groupTabAnchor(object: string, slot: KitViewSlot, index: number
|
|
|
364
390
|
export function groupPanelAnchor(object: string, slot: KitViewSlot, index: number | string): string { return `${object}__${slot}__gpanel__${index}`; }
|
|
365
391
|
export function groupTabWireAnchor(object: string, slot: KitViewSlot): string { return `${object}__${slot}__gwire`; }
|
|
366
392
|
|
|
367
|
-
|
|
393
|
+
// 分组页签的类:页签呈现唯一出口 recipes/tabs(与页内页签 / 外壳页签条同一套)
|
|
394
|
+
const GROUPS_AS = { barClass: `mb-4 ${kitTabRecipe().bar}`, tabClass: kitTabRecipe().tab };
|
|
368
395
|
|
|
369
396
|
/**
|
|
370
397
|
* groups 呈现为页签:tablist + 若干 tab 按钮 + 各组面板(首签显示,其余外层 hidden)。
|
|
@@ -408,7 +435,7 @@ export function groupTabsFrame(
|
|
|
408
435
|
showInto: Record<string, unknown>,
|
|
409
436
|
components: Set<string>,
|
|
410
437
|
): string {
|
|
411
|
-
const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}"
|
|
438
|
+
const buttons = titles.map((title, i) => `<button type="button" data-soma-id="${esc(groupTabAnchor(object, slot, i))}" data-key="${i}" role="tab" aria-selected="${i === 0 ? 'true' : 'false'}"${attr('class', GROUPS_AS.tabClass)}>${esc(title)}</button>`).join('');
|
|
412
439
|
const panelEls = panels.map((inner, i) => `<div data-soma-id="${esc(groupPanelAnchor(object, slot, i))}"${i === 0 ? '' : ' hidden'}>${inner}</div>`).join('');
|
|
413
440
|
const wireId = groupTabWireAnchor(object, slot);
|
|
414
441
|
components.add('KitTabsWiring');
|
|
@@ -493,14 +520,32 @@ function rejectRowState(actions: readonly KitAction[], ctx: Ctx, where: string):
|
|
|
493
520
|
}
|
|
494
521
|
}
|
|
495
522
|
|
|
523
|
+
/**
|
|
524
|
+
* 表格的缺失值列:schema 里同时声明了 `<字段>` 与 `<字段>_reason`(缺失原因字段,后缀读真源)的只读文字类列,
|
|
525
|
+
* 单元格改用 GapValue 的 plain 形态(缺失 = 次级色短横 + 悬停原因;有值 = 与 Text 同一套格式化)。
|
|
526
|
+
* 带选项(徽标)的列不动。返回 字段名 -> 改写后的格。
|
|
527
|
+
*/
|
|
528
|
+
function gapColumnsOf(ctx: Ctx, cells: readonly KitCell[]): Map<string, KitCell> {
|
|
529
|
+
const out = new Map<string, KitCell>();
|
|
530
|
+
const schema = ctx.options.schema;
|
|
531
|
+
for (const c of cells) {
|
|
532
|
+
if (c.component !== 'Text' || c.mode !== 'show' || c.placeholder === true || c.props.options !== undefined) continue;
|
|
533
|
+
const reasonField = tableGapReasonField(c.field);
|
|
534
|
+
if (schema === undefined || schema[reasonField] === undefined || c.rowProps?.reason !== undefined) continue;
|
|
535
|
+
out.set(c.field, { ...c, component: 'GapValue', props: { ...c.props, plain: true }, rowProps: { ...(c.rowProps ?? {}), reason: reasonField } });
|
|
536
|
+
}
|
|
537
|
+
return out;
|
|
538
|
+
}
|
|
539
|
+
|
|
496
540
|
function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>): string {
|
|
497
541
|
const object = ctx.object;
|
|
498
542
|
const at = 'views.list.layout';
|
|
499
543
|
const rowShow: Record<string, unknown> = {};
|
|
544
|
+
const gapCols = layout.tree === null && layout.virtual === undefined ? gapColumnsOf(ctx, layout.cells) : new Map<string, KitCell>();
|
|
500
545
|
|
|
501
546
|
const tools = layout.tools === true && layout.tree === null;
|
|
502
547
|
const selHead = layout.selectHeadClass ?? layout.selectClass;
|
|
503
|
-
const actHead = layout.actionsHeadClass ?? layout.actionsClass
|
|
548
|
+
const actHead = `${layout.actionsHeadClass ?? layout.actionsClass} text-end`;
|
|
504
549
|
// 表格语义(W3C table 模式:table > row > columnheader / cell,aria-sort 在 columnheader 上):
|
|
505
550
|
// 树表(外壳由 KitTreeTable 自带 treegrid,表头在它之外)与展开详情行(行下挂非 row 的开关与详情体)不满足 table 的结构要求,这两种不写表格角色
|
|
506
551
|
const semTable = layout.tree === null && layout.expand === null;
|
|
@@ -520,6 +565,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
520
565
|
...(h.group !== undefined ? { group: h.group } : {}),
|
|
521
566
|
...(tools && h.resizable === true ? { resizable: true } : {}),
|
|
522
567
|
...(h.help !== undefined ? { help: h.help } : {}),
|
|
568
|
+
...(h.col !== undefined && gapCols.has(h.col) ? { gapField: h.col } : {}),
|
|
523
569
|
});
|
|
524
570
|
}
|
|
525
571
|
if (layout.rowActions.length > 0) cells.push({ label: opsHeadLabel(ctx), class: actHead });
|
|
@@ -527,6 +573,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
527
573
|
ctx.show[headAnchor(object)] = {
|
|
528
574
|
props: {
|
|
529
575
|
cells, scope: ctx.scope(), class: layout.headClass, ...(semTable ? { semantics: 'table' } : {}),
|
|
576
|
+
...(gapCols.size > 0 ? { rows: ctx.rowsPath } : {}),
|
|
530
577
|
// 读状态:点表头排序后重取失败,表头据此把 sort / order / page 回滚到最近一次读成功的值
|
|
531
578
|
readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
|
|
532
579
|
...(layout.headGroups !== undefined ? { groups: layout.headGroups } : {}),
|
|
@@ -551,7 +598,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
551
598
|
};
|
|
552
599
|
for (const h of layout.head) {
|
|
553
600
|
if (h.group !== openGroup) flushGroup();
|
|
554
|
-
const leaf = `<div${headRole}${tools && h.col !== undefined ? ` data-kit-col="${esc(h.col)}"` : ''}${tools && h.resizable === true ? ' data-kit-resizable=""' : ''}${attr('class', h.class)}>${esc(h.label)}${kitHelpButtonHtml(h.help ?? '', h.label, ctx.options.locale ?? '')}</div>`;
|
|
601
|
+
const leaf = `<div${headRole}${tools && h.col !== undefined ? ` data-kit-col="${esc(h.col)}"` : ''}${h.col !== undefined && gapCols.has(h.col) ? ` ${KIT_TABLE_GAP_HEAD_ATTR}="${esc(h.col)}"` : ''}${tools && h.resizable === true ? ' data-kit-resizable=""' : ''}${attr('class', h.class)}>${esc(h.label)}${kitHelpButtonHtml(h.help ?? '', h.label, ctx.options.locale ?? '')}</div>`;
|
|
555
602
|
if (h.group === undefined) headParts.push(leaf);
|
|
556
603
|
else {
|
|
557
604
|
openGroup = h.group;
|
|
@@ -624,11 +671,11 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
624
671
|
rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.selectClass)}>${host('Checkbox', selAnchor(object))}</div>`);
|
|
625
672
|
}
|
|
626
673
|
}
|
|
627
|
-
layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
|
|
674
|
+
layout.cells.forEach((c, i) => rowParts.push(columnCell(ctx, gapCols.get(c.field) ?? c, `${at}.cells[${i}]`, rowShow, tools, cellRole)));
|
|
628
675
|
if (layout.rowActions.length > 0) {
|
|
629
676
|
ctx.components.add('KitTableActions');
|
|
630
677
|
rowShow[opsAnchor(object)] = {
|
|
631
|
-
props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx) },
|
|
678
|
+
props: { actions: actionItems(layout.rowActions, ctx), ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...rowToneProp(layout, ctx), ...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}), ...removeBusyProps(ctx), ...selectedProps(ctx), ...(layout.tools === true && (layout.batch?.length ?? 0) > 0 && ctx.options.selectedPath !== undefined ? { bulkLock: true } : {}) },
|
|
632
679
|
};
|
|
633
680
|
rowParts.push(`<div${cellRoleAttr(cellRole)}${attr('class', layout.actionsClass)}>${host('KitTableActions', opsAnchor(object))}</div>`);
|
|
634
681
|
}
|
|
@@ -682,7 +729,15 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
682
729
|
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
|
|
683
730
|
const summary = renderSummary(ctx, layout, selHead, actHead, semTable);
|
|
684
731
|
const tableA11y = semTable ? ` role="table"${attr('aria-label', ctx.object)}` : '';
|
|
685
|
-
|
|
732
|
+
// 静态表头(不可排序)的整列缺失原因标注由 KitTableGap 接线件画;可排序表头由 KitTableHead 自己画(上面已给 rows)
|
|
733
|
+
let gapHost = '';
|
|
734
|
+
if (gapCols.size > 0 && !layout.sort) {
|
|
735
|
+
const gapId = `${object}__table_gap`;
|
|
736
|
+
ctx.components.add('KitTableGap');
|
|
737
|
+
ctx.show[gapId] = { props: { rows: ctx.rowsPath, fields: [...gapCols.keys()] } };
|
|
738
|
+
gapHost = host('KitTableGap', gapId);
|
|
739
|
+
}
|
|
740
|
+
const body = `<div${attr('class', layout.wrapClass)}${wrapA11y}${tools ? ` data-kit-table="" data-kit-table-of="${esc(toolsAnchor(object))}"` : ''} data-kit-part="${KIT_PART_TABLE}"${gridMark(layout)} ${KIT_TIPS_SCOPE_ATTR}=""><div${tableA11y}${attr('class', layout.innerClass)}>${gapHost}${head}${rows}${summary}</div></div>`;
|
|
686
741
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
687
742
|
}
|
|
688
743
|
|
|
@@ -919,6 +974,7 @@ function renderPager(ctx: Ctx, pager: { size: number; sizes: number[]; jump: boo
|
|
|
919
974
|
scope: ctx.scope(), total: ctx.totalPath, size: pager.size, sizes: pager.sizes, jump: pager.jump,
|
|
920
975
|
// 读状态:翻页后重取失败,分页器据此把页码 / 页长回滚到最近一次读成功的值
|
|
921
976
|
readState: `${readStatePathsOf(ctx.object, ctx.basePath).dataPath}.readState`,
|
|
977
|
+
...(ctx.options.pagerClass !== undefined ? { class: ctx.options.pagerClass } : {}),
|
|
922
978
|
...(pager.mode !== undefined ? { mode: pager.mode } : {}),
|
|
923
979
|
...(pager.layout !== undefined ? { layout: pager.layout } : {}),
|
|
924
980
|
...(pager.showTotal === false ? { show_total: false } : {}),
|
|
@@ -947,8 +1003,8 @@ function renderCompactBody(ctx: Ctx, compact: NonNullable<Extract<KitLayoutIR, {
|
|
|
947
1003
|
const id = cellAnchor(ctx.object, 'list', cell.field);
|
|
948
1004
|
ctx.components.add(cell.component);
|
|
949
1005
|
const props = sized(cell);
|
|
950
|
-
//
|
|
951
|
-
if (cell.component === 'Tag'
|
|
1006
|
+
// 状态字段:状态徽标(浅色底 + on-soft 字 + 圆点,emphasis.status);其余文本沿用组件默认外观
|
|
1007
|
+
if (cell.component === 'Tag' && (props.variant === undefined || props.variant === 'dot')) Object.assign(props, kitStatusPillProps());
|
|
952
1008
|
// 次要信息是辅助文字:纯文本值走次要字色(Text 根自带正文色,色类由值类补上)
|
|
953
1009
|
if (cell.component === 'Text') props.class = joinClasses(typeof props.class === 'string' ? props.class : '', 'text-fg-muted');
|
|
954
1010
|
rowShow[id] = { props };
|
|
@@ -978,7 +1034,9 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
|
|
|
978
1034
|
const toneProps = layout.rowTone !== undefined ? { ...rowToneProp(layout, ctx), rowToneSet: 'item' } : {};
|
|
979
1035
|
if (layout.rowActions.length > 0) {
|
|
980
1036
|
ctx.components.add('KitTableActions');
|
|
981
|
-
|
|
1037
|
+
// 紧凑列表(主从的控件列)是窄栏:行内只留主动作(行内上限取窄档上限),其余进「更多」(危险动作在菜单末位,与前面分隔)——一行不堆四个文字动作
|
|
1038
|
+
const compactCap = compact !== undefined ? { maxInline: kitRowActionsNarrowCap() } : {};
|
|
1039
|
+
rowShow[opsAnchor(object)] = { props: { actions: actionItems(layout.rowActions, ctx), ...compactCap, ...actionStateProp(layout.rowActions, ctx), row: ctx.rowVar, ...toneProps, ...pickProps, ...removeBusyProps(ctx) } };
|
|
982
1040
|
actions = host('KitTableActions', opsAnchor(object));
|
|
983
1041
|
} else if (layout.rowTone !== undefined || pickOnly) {
|
|
984
1042
|
ctx.components.add('KitTableActions');
|
|
@@ -998,7 +1056,8 @@ function renderCollection(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'cards'
|
|
|
998
1056
|
const itemClass = pickOnly ? joinClasses(layout.itemClass, 'cursor-pointer') : layout.itemClass;
|
|
999
1057
|
const rowMark = layout.rowTone !== undefined || pickOnly ? ' data-kit-row=""' : '';
|
|
1000
1058
|
const actionsPart = compact !== undefined && actions !== '' ? `<div${attr('class', KIT_CLASS_DEFAULTS.compactActions)}>${actions}</div>` : actions;
|
|
1001
|
-
const
|
|
1059
|
+
const compactMark = compact !== undefined ? ' data-kit-compact=""' : '';
|
|
1060
|
+
const template = `<template data-soma-role="item"><div${attr('class', itemClass)}${rowMark}${compactMark}${ctxItems.length > 0 ? ' data-kit-ctx=""' : ''}${itemPart}>${inner}${actionsPart}${ctxHost}</div></template>`;
|
|
1002
1061
|
ctx.show[rowsAnchor(object)] = { bind: { obj: ctx.rowsPath, var: ctx.rowVar }, show: rowShow };
|
|
1003
1062
|
const list = `<div${attr('class', layout.listClass)} data-soma-id="${esc(rowsAnchor(object))}">${template}</div>`;
|
|
1004
1063
|
return `<div${attr('class', layout.wrapClass)}>${list}</div>${renderState(ctx, layout.state, skeletonShapeOf(layout, ctx.options.schema))}${renderPager(ctx, layout.pager)}`;
|
|
@@ -1121,6 +1180,8 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1121
1180
|
}
|
|
1122
1181
|
const id = viewAnchor(ctx.object, slot);
|
|
1123
1182
|
ctx.components.add('KitObjectForm');
|
|
1183
|
+
// 底栏动作组的「更多」入口(可编辑表单;筛选表单没有)
|
|
1184
|
+
if (slot === 'form') ctx.components.add('KitActionMore');
|
|
1124
1185
|
for (const c of packed.fields) if (c.component !== '') ctx.components.add(c.component);
|
|
1125
1186
|
// 可编辑 form 的 mode / initial 可绑镜像路径(字符串路径由 core 解析成绑定);filter 恒为字面量
|
|
1126
1187
|
const bindMode = slot === 'form' ? ctx.options.formModePath : undefined;
|
|
@@ -1141,45 +1202,26 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1141
1202
|
if (envelope !== undefined) props.envelope = envelope;
|
|
1142
1203
|
// M 波 G3:布局 / 筛选折叠 / 即时校验 / 离开守卫(只在写了的时候带,缺省保持存量行为)
|
|
1143
1204
|
const fo = ir.views[slot]?.formOpts;
|
|
1144
|
-
//
|
|
1145
|
-
//
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
props.classes = {
|
|
1158
|
-
wrap: joinClasses(joinClasses(layout.wrapClass, pack.wrapClass), keep.join(' ')),
|
|
1159
|
-
grid: KIT_FILTER_INLINE_CLASS.grid,
|
|
1160
|
-
actions: mergeClass('', pack.actionsClass),
|
|
1161
|
-
pad: pack.padClass,
|
|
1162
|
-
notice: pack.noticeClass,
|
|
1163
|
-
};
|
|
1164
|
-
} else if (flow !== undefined) {
|
|
1165
|
-
props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, flow.widthClasses[i] ?? '') }));
|
|
1166
|
-
const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
|
|
1167
|
-
props.classes = {
|
|
1168
|
-
wrap: joinClasses(joinClasses(layout.wrapClass, flow.wrapClass), keep.join(' ')),
|
|
1169
|
-
grid: KIT_FILTER_INLINE_CLASS.grid,
|
|
1170
|
-
actions: mergeClass('', flow.actionsClass),
|
|
1171
|
-
pad: flow.padClass,
|
|
1172
|
-
notice: flow.noticeClass,
|
|
1173
|
-
};
|
|
1174
|
-
// 折叠搜索区也走流式版式:折起哪些字段要按容器宽度现算(定宽字段每行放几个),由表单量宿主宽度判,不再按 12 份栅格的份数折行
|
|
1175
|
-
props.flow = true;
|
|
1176
|
-
}
|
|
1205
|
+
// 筛选栏(cols 排布):排布引擎的投影(filter-plan.ts)——根容器左起流式换行、字段按类型取 [最小, 理想, 最大] 定宽(不拉伸)、
|
|
1206
|
+
// 动作区(查询 / 重置,或即时档的「清除」)紧跟最后一个字段并对齐到控件那一行;档位(即时 / 提交 / 更多)与钉住个数作为 props,运行时不量宽
|
|
1207
|
+
const proj = slot === 'filter' && layout.kind === 'grid' ? layout.filterProjection : undefined;
|
|
1208
|
+
if (proj !== undefined && layout.kind === 'grid') {
|
|
1209
|
+
props.fields = packed.fields.map((c, i) => (c.placeholder === true ? c : { ...c, cellClass: swapSpanForWidth(c.cellClass, proj.widthClasses[i] ?? '') }));
|
|
1210
|
+
const keep = layout.gridClass.split(/\s+/).filter((t) => t !== '' && !/^(?:@[a-z0-9]+:)?(?:grid|grid-cols-\d+|gap-[a-z0-9.]+)$/.test(t));
|
|
1211
|
+
props.classes = {
|
|
1212
|
+
wrap: joinClasses(joinClasses(layout.wrapClass, proj.wrapClass), keep.join(' ')),
|
|
1213
|
+
grid: 'contents',
|
|
1214
|
+
actions: proj.actionsClass,
|
|
1215
|
+
pad: proj.padClass,
|
|
1216
|
+
notice: proj.noticeClass,
|
|
1217
|
+
};
|
|
1177
1218
|
}
|
|
1178
1219
|
if (fo?.labelPosition !== undefined) { props.labelPosition = fo.labelPosition; props.labelWidth = fo.labelWidth ?? 3; }
|
|
1179
1220
|
if (typeof fo?.scrollToError === 'boolean') props.scrollToError = fo.scrollToError;
|
|
1180
1221
|
if (fo?.requiredMark === 'start') props.requiredMark = 'start';
|
|
1181
|
-
if (fo?.collapsible === true) { props.collapsible = true; props.collapsedRows = fo.collapsedRows ?? 1; }
|
|
1182
1222
|
if (fo?.trigger === 'change') props.trigger = 'change';
|
|
1223
|
+
if (fo?.filterMode !== undefined) props.filterMode = fo.filterMode;
|
|
1224
|
+
if (fo?.pinned !== undefined) props.pinned = fo.pinned;
|
|
1183
1225
|
if (fo?.groupTabs === true) props.groupTabs = true;
|
|
1184
1226
|
if (slot === 'form') {
|
|
1185
1227
|
if (ctx.options.validateOn !== undefined) props.validateOn = ctx.options.validateOn;
|
|
@@ -1218,9 +1260,11 @@ function renderObjectForm(ctx: Ctx, slot: 'filter' | 'form', layout: KitLayoutIR
|
|
|
1218
1260
|
ctx.show[id] = { props };
|
|
1219
1261
|
// 页面真有按需字段控件(画布)时在宿主上点名,core 才补载其分片
|
|
1220
1262
|
const needs = [...new Set(packed.fields.map((c) => c.component).filter((n) => n === 'FlowEditor'))];
|
|
1221
|
-
const isOverflowFilter = slot === 'filter' && (fo?.filterOverflow === true || (fo?.collapsible === true && packed.fields.filter((c) => c.placeholder !== true && c.divider !== true && c.component !== '').length > (fo?.defaultCollapsedCount ?? 4)));
|
|
1222
1263
|
let html = host('KitObjectForm', id);
|
|
1223
|
-
|
|
1264
|
+
// 容器查询只对后代生效:表单根上的字段宽度 / 动作区变体类(@<档>:w-N)要查到宿主这一层,所以宿主做查询容器
|
|
1265
|
+
if (proj !== undefined) {
|
|
1266
|
+
html = html.includes(' class="') ? html.replace(' class="', ` class="${KIT_WIDTH.containerClass} `) : html.replace('></div>', ` class="${KIT_WIDTH.containerClass}"></div>`);
|
|
1267
|
+
}
|
|
1224
1268
|
return needs.length === 0 ? html : html.replace('></div>', ` data-soma-needs="${needs.join(' ')}"></div>`);
|
|
1225
1269
|
}
|
|
1226
1270
|
|
|
@@ -1249,20 +1293,23 @@ function toolbarReasonProp(a: KitAction): { disabled_reason?: string } {
|
|
|
1249
1293
|
return source.kind === 'literal' && source.text.trim() !== '' ? { disabled_reason: source.text } : {};
|
|
1250
1294
|
}
|
|
1251
1295
|
|
|
1252
|
-
/**
|
|
1253
|
-
function
|
|
1296
|
+
/** 动作在动作组里的重要度:primary 语气 = 主操作(恒在行尾、恒可见);danger 语气最后保留;其余为次要 */
|
|
1297
|
+
function toolbarImportance(a: KitAction): KitActionImportance {
|
|
1254
1298
|
const t = actionTone(a);
|
|
1255
|
-
return t
|
|
1299
|
+
return t === 'primary' ? 'primary' : t === 'danger' ? 'danger' : 'secondary';
|
|
1256
1300
|
}
|
|
1257
1301
|
|
|
1258
1302
|
/**
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1303
|
+
* 工具栏(主操作与次级工具)一律不独占一整行:有列表标题时并入标题行右侧,没有标题时紧贴列表上方靠右。
|
|
1304
|
+
* 成组排布经排布引擎(action-group.ts):恒单行、文字不折行;空间不足时次要动作按优先级逐个收进「更多」(KitActionMore,菜单里危险项置末),
|
|
1305
|
+
* 主操作恒在行尾可见;视觉序取引擎 order(非主操作按声明序在前,主操作在行尾)。
|
|
1261
1306
|
*/
|
|
1262
1307
|
function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
1263
1308
|
const declared = actions.filter((a) => a.on === 'toolbar');
|
|
1264
1309
|
if (declared.length === 0) return '';
|
|
1265
|
-
const
|
|
1310
|
+
const projection = projectActionGroup(declared.map((a) => ({ id: a.id, label: a.name, importance: toolbarImportance(a) })));
|
|
1311
|
+
const byId = new Map(declared.map((a) => [a.id, a] as const));
|
|
1312
|
+
const list = projection.order.flatMap((id) => { const a = byId.get(id); return a === undefined ? [] : [a]; });
|
|
1266
1313
|
const parts = list.map((a) => {
|
|
1267
1314
|
const id = toolbarAnchor(ctx.object, a.id);
|
|
1268
1315
|
ctx.components.add('Button');
|
|
@@ -1278,9 +1325,15 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
|
1278
1325
|
...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
|
|
1279
1326
|
},
|
|
1280
1327
|
};
|
|
1281
|
-
|
|
1328
|
+
// 外壳承载「按档隐藏」类与「更多」菜单要读的标记(标签 / 语气);壳里是真按钮,菜单选中即对它 click() 回放
|
|
1329
|
+
return `<div${attr('class', projection.itemClass[a.id] ?? 'shrink-0')} data-kit-ag-item="${esc(a.id)}" data-kit-ag-label="${esc(a.name)}" data-kit-ag-tone="${esc(actionTone(a))}">${host('Button', id)}</div>`;
|
|
1282
1330
|
});
|
|
1283
|
-
|
|
1331
|
+
let more = '';
|
|
1332
|
+
if (projection.plan.hasMore) {
|
|
1333
|
+
ctx.components.add('KitActionMore');
|
|
1334
|
+
more = `<div${attr('class', projection.moreClass)}>${host('KitActionMore', `${ctx.object}__tb_more`)}</div>`;
|
|
1335
|
+
}
|
|
1336
|
+
return `<div${attr('class', projection.hostClass)} data-kit-action-group="" data-kit-ag-flow="${esc(projection.flowHostClass)}"><div${attr('class', projection.rowClass)}>${parts.join('')}${more}</div></div>`;
|
|
1284
1337
|
}
|
|
1285
1338
|
|
|
1286
1339
|
// ---------------------------------------------------------------- 主函数
|
|
@@ -1304,7 +1357,7 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1304
1357
|
diagnostics: [],
|
|
1305
1358
|
singlePath: summaryBase,
|
|
1306
1359
|
rowVar: rowVarOf(object),
|
|
1307
|
-
rowsPath: wrapped ? `${base}.${options.listShape.rows}` : base,
|
|
1360
|
+
rowsPath: wrapped ? `${base}.${options.listShape.rows}` : options.staticRowsPath !== undefined && options.staticRowsPath !== '' ? `${base}.${options.staticRowsPath}` : base,
|
|
1308
1361
|
totalPath: `${base}.${options.listShape.total}`,
|
|
1309
1362
|
basePath: base,
|
|
1310
1363
|
scope: () => ir.scope,
|
|
@@ -1402,18 +1455,18 @@ export function emitStatic(ir: KitObjectIR, options: KitStaticOptions): KitStati
|
|
|
1402
1455
|
? `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${mergeToolbar ? parts.toolbar! : ''}</div>`
|
|
1403
1456
|
: parts.toolbar!;
|
|
1404
1457
|
// 集合辅助文字紧随标题作标题行的直接子项(宿主 display: contents,其根自带 me-auto 把工具区推到最右)
|
|
1405
|
-
html = `<div class="${KIT_CLASS_DEFAULTS.toolbarTitleRow}">${titleEl}${metaHtml}${right}</div>${html}`;
|
|
1458
|
+
html = `<div data-kit-title-row="" class="${KIT_CLASS_DEFAULTS.toolbarTitleRow}">${titleEl}${metaHtml}${right}</div>${html}`;
|
|
1406
1459
|
if (mergeToolbar) delete parts.toolbar;
|
|
1407
1460
|
} else {
|
|
1408
|
-
html = `${metaHtml === '' ? titleEl : `<div class="${TITLE_GROUP_CLASS}">${titleEl}${metaHtml}</div>`}${html}`;
|
|
1461
|
+
html = `${metaHtml === '' ? titleEl : `<div data-kit-title-row="" class="${TITLE_GROUP_CLASS}">${titleEl}${metaHtml}</div>`}${html}`;
|
|
1409
1462
|
}
|
|
1410
1463
|
} else {
|
|
1411
1464
|
if (treeCtl !== '') {
|
|
1412
1465
|
if (secondaryToolbar && parts.toolbar !== undefined) parts.toolbar = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}${parts.toolbar}</div>`;
|
|
1413
1466
|
else html = `<div${attr('class', KIT_CLASS_DEFAULTS.toolbarSecondary)}>${treeCtl}</div>${html}`;
|
|
1414
1467
|
}
|
|
1415
|
-
// 没有标题行:只有「已筛选」提示(共 N
|
|
1416
|
-
if (metaHtml !== '') html =
|
|
1468
|
+
// 没有标题行:只有「已筛选」提示(共 N 条需要标题行),放在列表上方;包一层标题行壳,与有标题时同走对齐轴的内缩规则(文字落在轴上)
|
|
1469
|
+
if (metaHtml !== '') html = `<div data-kit-title-row="" class="${TITLE_GROUP_CLASS}">${metaHtml}</div>${html}`;
|
|
1417
1470
|
}
|
|
1418
1471
|
parts[slot] = html;
|
|
1419
1472
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// 筛选区的排布投影:引擎(soma-foundation/arrange#arrangeFilter → 参考实现 solveFilterBar)给出档位与字段 [最小, 理想, 最大] 宽,这里只把 plan 翻成类串与标记。
|
|
2
|
+
// · 档位三选一(字段数 → 即时 / 提交 / 更多),页面可显式指定(filter.mode / filter.pinned,见 render-object);
|
|
3
|
+
// · 字段按类型取理想宽、靠左流式排布(`w-full @<档>:w-<理想>`,最大宽封顶,不拉伸);分隔线占满一行;
|
|
4
|
+
// · 动作区(查询 / 重置,或即时档的「清除」)紧跟最后一个字段:容器达到「最后字段 + 动作区」所需宽的档起同行,更窄时整行靠左;
|
|
5
|
+
// · 动作区顶部的标签行占位与字段格同结构,把按钮对齐到控件那一行。
|
|
6
|
+
// 运行时不再代算:不量宽、不读容器宽,只切换这里写出的变体类。旧的 12 份制装行(filterPackOf)与折叠搜索区的量宽折行已删除。
|
|
7
|
+
|
|
8
|
+
import { arrangeFilter, arrangeTierAtLeastRem, arrangeTiers, type ArrangeFilterPlan } from 'soma-foundation/arrange';
|
|
9
|
+
import { KIT_CLASS_DEFAULTS } from './defaults';
|
|
10
|
+
|
|
11
|
+
/** 筛选栏里整行分隔线占位的字段类型名(分隔线不计入可筛选字段数,宽度恒占满一行) */
|
|
12
|
+
export const KIT_FILTER_DIVIDER = 'divider';
|
|
13
|
+
|
|
14
|
+
/** 筛选栏投影:根容器 / 各格宽度 / 动作区 / 标签行占位 / 提示条的类 */
|
|
15
|
+
export interface KitFilterProjection {
|
|
16
|
+
readonly plan: ArrangeFilterPlan;
|
|
17
|
+
/** 根容器:左起、可换行、控件顶对齐(间距走 classDefaults.gridGap) */
|
|
18
|
+
readonly wrapClass: string;
|
|
19
|
+
/** 各格宽度类(与传入的 fieldTypes 一一对应;分隔线 `w-full`) */
|
|
20
|
+
readonly widthClasses: string[];
|
|
21
|
+
/** 动作区类:紧跟最后一个字段,同行起点档取 plan.tailTier */
|
|
22
|
+
readonly actionsClass: string;
|
|
23
|
+
/** 动作区顶部标签行占位类:与动作区同行的档起显示并占满一行,把按钮挤到控件那一行 */
|
|
24
|
+
readonly padClass: string;
|
|
25
|
+
readonly noticeClass: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** rem → 间距刻度步数(4 步 = 1rem,与 `w-60` = 15rem 同口径) */
|
|
29
|
+
const stepOf = (rem: number): number => Math.round(rem * 4);
|
|
30
|
+
|
|
31
|
+
/** 最大宽类:恰有同 rem 的容器档时取具名档(`max-w-xs`),否则取间距刻度 */
|
|
32
|
+
function maxWidthClass(rem: number): string {
|
|
33
|
+
const tier = arrangeTiers().find((t) => t.rem === rem);
|
|
34
|
+
return tier === undefined ? `max-w-${stepOf(rem)}` : `max-w-${tier.name}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface KitFilterOverride {
|
|
38
|
+
/** 页面显式指定的档位(instant / submit / more);非法值由 render-object 先报诊断,不会走到这里 */
|
|
39
|
+
readonly mode?: string;
|
|
40
|
+
/** 更多档钉住的字段数 */
|
|
41
|
+
readonly pinned?: number;
|
|
42
|
+
/** 页面写了 trigger: submit(显式不要即时生效):自动选到即时档时改取提交档 */
|
|
43
|
+
readonly noInstant?: boolean;
|
|
44
|
+
/** 页面写了 trigger: change(字段一变即生效):与档位无关——更多档同样按它生效,只是不再把档位钉成即时档 */
|
|
45
|
+
readonly liveTrigger?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 取筛选区 plan:fieldTypes 是全部字段的类型(分隔线传 KIT_FILTER_DIVIDER,不计数)。 */
|
|
49
|
+
export function filterPlanOf(fieldTypes: ReadonlyArray<string | undefined>, override: KitFilterOverride = {}): ArrangeFilterPlan {
|
|
50
|
+
const fields = fieldTypes.filter((t) => t !== KIT_FILTER_DIVIDER).map((t) => ({ type: t ?? 'text' }));
|
|
51
|
+
const solve = (mode: string | undefined): ArrangeFilterPlan => arrangeFilter({ fields, ...(mode !== undefined ? { mode } : {}), ...(override.pinned !== undefined ? { pinned: override.pinned } : {}) });
|
|
52
|
+
const plan = solve(override.mode);
|
|
53
|
+
return override.noInstant === true && plan.mode === 'instant' ? solve('submit') : plan;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** plan → 类串(见文件头)。 */
|
|
57
|
+
export function projectFilter(fieldTypes: ReadonlyArray<string | undefined>, override: KitFilterOverride = {}): KitFilterProjection {
|
|
58
|
+
const plan = filterPlanOf(fieldTypes, override);
|
|
59
|
+
let k = 0;
|
|
60
|
+
const widthClasses = fieldTypes.map((t) => {
|
|
61
|
+
if (t === KIT_FILTER_DIVIDER) return 'w-full';
|
|
62
|
+
const w = plan.widths[k++]!;
|
|
63
|
+
const tier = arrangeTierAtLeastRem(w.ideal);
|
|
64
|
+
const fixed = tier === null ? '' : ` @${tier}:w-${stepOf(w.ideal)}`;
|
|
65
|
+
return `w-full${fixed} ${maxWidthClass(w.max)}`;
|
|
66
|
+
});
|
|
67
|
+
// 标签行与控件行的间距取字段格同一个值(classDefaults.cell 的 gap-*):动作区的占位行才与输入框对齐
|
|
68
|
+
const cellGap = /(?:^|\s)gap-([\d.]+)(?=\s|$)/.exec(KIT_CLASS_DEFAULTS.cell)?.[1] ?? '1.5';
|
|
69
|
+
const tail = plan.tailTier;
|
|
70
|
+
const sameRow = tail === null ? '' : ` @${tail}:w-auto @${tail}:justify-start`;
|
|
71
|
+
return {
|
|
72
|
+
plan,
|
|
73
|
+
wrapClass: `flex flex-wrap items-start ${KIT_CLASS_DEFAULTS.gridGap}`,
|
|
74
|
+
widthClasses,
|
|
75
|
+
actionsClass: `mt-0 gap-y-${cellGap} items-center w-full justify-start${sameRow}`,
|
|
76
|
+
padClass: tail === null ? 'hidden' : `hidden w-full invisible @${tail}:block`,
|
|
77
|
+
noticeClass: 'w-full',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** 投影里会用到的全部类(候选类:类串安全,一并交样式引擎) */
|
|
82
|
+
export function filterProjectionClasses(p: KitFilterProjection): string[] {
|
|
83
|
+
return [p.wrapClass, ...p.widthClasses, p.actionsClass, p.padClass, p.noticeClass].flatMap((s) => s.split(/\s+/)).filter((c) => c !== '');
|
|
84
|
+
}
|
|
@@ -10,6 +10,11 @@ export { rowVarOf, emitStatic } from './emit-static';
|
|
|
10
10
|
export type { KitStaticOptions, KitStaticEmit } from './emit-static';
|
|
11
11
|
export { collectCandidates, classesInHtml } from './candidates';
|
|
12
12
|
export { createKitTableActions, KIT_TABLE_ACTIONS_CLASS_CANDIDATES } from './table-actions';
|
|
13
|
+
// 动作组(排布引擎投影)出口:应用组件自己成组的动作用同一套恒单行 / 「更多」规则
|
|
14
|
+
export { projectActionGroup, projectionClasses as actionGroupClasses, planActionGroup, menuOrderDangerLast, KIT_ACTION_GROUP_CLASS_CANDIDATES } from './action-group';
|
|
15
|
+
export type { KitActionEntry, KitActionImportance, KitActionGroupOptions, KitActionGroupProjection } from './action-group';
|
|
16
|
+
export { createKitActionMore, buildActionGroup, mountActionMore, KIT_ACTION_MORE_CLASS_CANDIDATES } from './action-more';
|
|
17
|
+
export type { DomActionEntry } from './action-more';
|
|
13
18
|
export type * from './types';
|
|
14
19
|
export {
|
|
15
20
|
CURRENCY_SYMBOLS,
|
|
@@ -96,6 +96,10 @@ export interface KitFactObject {
|
|
|
96
96
|
readonly isPanel: boolean;
|
|
97
97
|
readonly title: string | null;
|
|
98
98
|
readonly panelSpan: number | null;
|
|
99
|
+
/** 面板组名(MultiObjectBoard 的 panels.*.group);null = 首屏常显区 */
|
|
100
|
+
readonly panelGroup?: string | null;
|
|
101
|
+
/** 面板头槽位的宿主面板名(panels.*.head);null = 独立面板 */
|
|
102
|
+
readonly panelHead?: string | null;
|
|
99
103
|
readonly panelKind: KitPanelKind;
|
|
100
104
|
readonly views: readonly KitFactView[];
|
|
101
105
|
readonly actions: readonly KitFactAction[];
|
|
@@ -326,6 +330,8 @@ function objectFact(raw: Rec, role: string, name: string | null, isPanel: boolea
|
|
|
326
330
|
isPanel,
|
|
327
331
|
title: str(raw.title) ?? null,
|
|
328
332
|
panelSpan: num(raw.span) ?? null,
|
|
333
|
+
panelGroup: isPanel ? (str(raw.group)?.trim() || null) : null,
|
|
334
|
+
panelHead: isPanel ? (str(raw.head)?.trim() || null) : null,
|
|
329
335
|
panelKind: panelKindOf(views),
|
|
330
336
|
views,
|
|
331
337
|
actions: actionFacts(raw.behavior, at),
|
|
@@ -345,7 +351,9 @@ function productFact(product: KitProductDecl, at: string, slot: string): KitFact
|
|
|
345
351
|
} else {
|
|
346
352
|
// 对象表(many 角色:panels / subs / steps …):名字 → 对象;MultiObjectBoard 的 panels 是面板
|
|
347
353
|
for (const [name, sub] of Object.entries(value)) {
|
|
348
|
-
|
|
354
|
+
// 面板头控件(panels.<控件>.head: <宿主>)不是面板:画在宿主标题行里,不占栅格、不单独成卡(不进面板计数 / 栅格求解 / 表面层数)
|
|
355
|
+
const isHeadControl = role === 'panels' && isRec(sub) && typeof sub.head === 'string' && sub.head.trim() !== '';
|
|
356
|
+
if (isRec(sub)) objects.push(objectFact(sub, role, name, role === 'panels' && !isHeadControl, `${at}.objects.${role}.${name}`));
|
|
349
357
|
}
|
|
350
358
|
}
|
|
351
359
|
}
|