soma-kit 0.1.14 → 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 +4 -2
- package/spec/generated/kit-page.schema.json +72 -2
- package/spec/kit-grammar.json +163 -57
- package/spec/kit-grammar.schema.json +0 -24
- package/src/app/app-config.ts +1 -1
- 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 +7 -7
- package/src/app/kit-view-context.ts +11 -2
- 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 +30 -15
- 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/fab.ts +11 -6
- package/src/base/gap-value.ts +1 -1
- package/src/base/hint-tips.ts +1 -1
- package/src/base/index.ts +15 -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 +63 -27
- 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 +2 -2
- 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 +35 -36
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +43 -7
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +53 -59
- package/src/base/text.ts +37 -13
- 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 +21 -13
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +2 -2
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +2 -2
- package/src/biz/category-crud/compile.ts +17 -4
- package/src/biz/category-crud/shell.ts +7 -5
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +7 -6
- package/src/biz/compose.ts +3 -3
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +6 -4
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +5 -4
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +162 -19
- package/src/biz/master-sub/detail-head.ts +7 -6
- package/src/biz/master-sub/index.ts +3 -3
- package/src/biz/master-sub/shell.ts +90 -53
- package/src/biz/multi-board/compile.ts +3 -3
- package/src/biz/multi-board/index.ts +24 -9
- package/src/biz/multi-board/prose-fold.ts +2 -2
- package/src/biz/multi-board/shell.ts +17 -13
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +9 -2
- package/src/biz/page-templates/domain-templates.ts +6 -2
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +4 -3
- 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 +4 -4
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +4 -4
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +8 -5
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +4 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +48 -18
- package/src/biz/shared/overlay-shell.ts +63 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +8 -4
- package/src/biz/standard-crud/compile.ts +11 -4
- package/src/biz/standard-crud/shell.ts +26 -9
- package/src/biz/standard-crud/summary.ts +3 -1
- 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 +6 -4
- package/src/biz/types.ts +11 -4
- 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/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +29 -234
- package/src/compile/component-candidates.ts +2 -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 +43 -13
- package/src/compile/page-composition.ts +33 -31
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +70 -32
- package/src/compile/types.ts +2 -2
- package/src/data/amount-breakdown.ts +4 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +9 -4
- package/src/data/assignment-picker.ts +28 -18
- package/src/data/async-result-panel.ts +6 -2
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +4 -3
- package/src/data/carousel.ts +11 -5
- package/src/data/chart.ts +153 -23
- package/src/data/checklist.ts +5 -4
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +7 -2
- package/src/data/confirm-dialog.ts +56 -13
- 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 +12 -6
- package/src/data/flow-editor.ts +105 -29
- package/src/data/footer.ts +6 -2
- package/src/data/gantt.ts +11 -8
- package/src/data/hero.ts +6 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +12 -5
- package/src/data/item-list.ts +6 -5
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +11 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +23 -14
- 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 +15 -9
- package/src/data/mockup.ts +9 -5
- package/src/data/modal-dialog.ts +39 -88
- package/src/data/navbar.ts +11 -7
- package/src/data/notice-list.ts +1 -1
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +129 -48
- package/src/data/pager.ts +12 -8
- package/src/data/panel-head.ts +1 -1
- package/src/data/permission-matrix.ts +15 -8
- package/src/data/permission-tree.ts +24 -11
- package/src/data/pricing-table.ts +8 -3
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +13 -9
- 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 +0 -12
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +10 -5
- package/src/data/rule-builder.ts +14 -8
- package/src/data/shape-util.ts +14 -3
- package/src/data/stat-group.ts +63 -22
- package/src/data/static-lazy.ts +3 -0
- package/src/data/static-registry.ts +8 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +9 -3
- package/src/data/system-switcher.ts +15 -6
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +6 -3
- package/src/data/transfer.ts +19 -10
- package/src/data/tree-table.ts +77 -12
- package/src/data/tree.ts +5 -2
- package/src/data/virtual-rows.ts +17 -7
- package/src/data/wrap.ts +2 -2
- package/src/frames/index.ts +3 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +59 -36
- package/src/frames/page-bar.ts +4 -2
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +18 -14
- 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 +12 -6
- package/src/frames/types.ts +3 -2
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +2 -1
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/view.ts +125 -76
- package/src/generated/kit-grammar-runtime.ts +61 -39
- package/src/i18n/kit-text.ts +114 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +31 -1
- package/src/object-renderer/action-more.ts +28 -12
- package/src/object-renderer/arrange.ts +37 -7
- package/src/object-renderer/collection-parts.ts +38 -7
- package/src/object-renderer/collection-table.ts +68 -23
- package/src/object-renderer/collection.ts +63 -30
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +8 -0
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +3 -0
- package/src/object-renderer/emit-static.ts +140 -37
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/layout-facts.ts +37 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/render-object.ts +1 -1
- package/src/object-renderer/table-actions.ts +70 -23
- package/src/object-renderer/table-tools.ts +12 -5
- package/src/object-renderer/types.ts +9 -15
- 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 +25 -15
- package/src/recipes/control.ts +21 -3
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +12 -8
- package/src/recipes/frame-bleed.ts +3 -3
- package/src/recipes/index.ts +11 -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 +112 -26
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +1 -1
- package/src/recipes/stat-state.ts +1 -1
- package/src/recipes/state.ts +10 -8
- package/src/recipes/status.ts +13 -12
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +1 -1
- package/src/recipes/table-native-edit.ts +4 -4
- package/src/recipes/table-row.ts +11 -8
- package/src/recipes/tabs.ts +108 -31
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +4 -2
- package/src/recipes/typography.ts +2 -2
- 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 +38 -14
- package/src/theme/kit-theme.tpl +38 -14
- package/src/theme/nine-dim-structure.ts +66 -41
- package/src/theme/surface-layers.ts +11 -3
- package/src/theme/theme-tokens.ts +5 -1
- 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
|
@@ -5,10 +5,21 @@ import { KIT_METRIC_HIGHLIGHT_CLASS, resolveFieldEmphasisClass } from './form-de
|
|
|
5
5
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
6
6
|
|
|
7
7
|
const DEFAULT_CELL_LABEL_CLASS = kitTypographyRecipe('label');
|
|
8
|
+
/** 按字段类型取宽度档的单行控件(KT-K-form-8):多行文本、富文本、子表、上传、选项组(单选 / 复选 / 分段)撑满列宽,不在此列 */
|
|
9
|
+
const WIDTH_CAPPED_COMPONENTS: ReadonlySet<string> = new Set(['Input', 'Number', 'Select', 'Combobox', 'Date', 'DateRange', 'TimePicker', 'Cascader', 'TreeSelect', 'Switch']);
|
|
10
|
+
/** 规则里的最大长度(max_len / maxLength 取最小);没有则 null */
|
|
11
|
+
const maxLenOfRules = (rules: readonly KitRule[] | undefined): number | null => {
|
|
12
|
+
let out: number | null = null;
|
|
13
|
+
for (const r of rules ?? []) {
|
|
14
|
+
const v = typeof r.max_len === 'number' ? r.max_len : typeof r.maxLength === 'number' ? r.maxLength : undefined;
|
|
15
|
+
if (v !== undefined) out = out === null ? v : Math.min(out, v);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
};
|
|
8
19
|
const DEFAULT_CELL_VALUE_CLASS = KIT_CLASS_DEFAULTS.value;
|
|
9
20
|
import { builtinEmitsOf, optionsFromOf, staticOptionsOf } from './linkage';
|
|
10
|
-
import { checkClasses, mergeClass } from '
|
|
11
|
-
import { hintOf, nameSuggestion } from '../
|
|
21
|
+
import { checkClasses, mergeClass } from '../shared/merge-class';
|
|
22
|
+
import { hintOf, nameSuggestion } from '../shared/hints';
|
|
12
23
|
import { pickComponent } from './pick-component';
|
|
13
24
|
import { kitText } from '../i18n/kit-text';
|
|
14
25
|
import {
|
|
@@ -40,9 +51,13 @@ import type {
|
|
|
40
51
|
KitFieldSchema,
|
|
41
52
|
KitLayoutIR,
|
|
42
53
|
KitMode,
|
|
54
|
+
KitRule,
|
|
43
55
|
KitSchema,
|
|
44
56
|
KitViewForm,
|
|
45
57
|
} from './types';
|
|
58
|
+
import { kitFieldWidthStep } from 'soma-foundation/kit-layout';
|
|
59
|
+
import { KIT_FIELD_WIDTH_CLASS } from '../recipes/strip';
|
|
60
|
+
import { KIT_DESC_CELL_CLASS, KIT_DESC_LABEL_CLASS } from '../recipes/desc-list';
|
|
46
61
|
|
|
47
62
|
export interface KitCellEnv {
|
|
48
63
|
schema: KitSchema;
|
|
@@ -56,7 +71,7 @@ export interface KitCellEnv {
|
|
|
56
71
|
empty?: { hide: boolean; text: string };
|
|
57
72
|
/** 当前视图槽位(字段联动键 when 按槽位判定可用性) */
|
|
58
73
|
slot?: 'list' | 'summary' | 'filter' | 'form';
|
|
59
|
-
/** 必填星号位置(view.form.requiredMark,缺省
|
|
74
|
+
/** 必填星号位置(view.form.requiredMark,缺省 start = 标签前,KT-K-form-3) */
|
|
60
75
|
requiredMark?: 'start' | 'end';
|
|
61
76
|
/** 页面语言(布尔列缺省「是 / 否」等编译期文案);缺省取 zh-CN */
|
|
62
77
|
locale?: string;
|
|
@@ -218,7 +233,10 @@ export function buildCell(
|
|
|
218
233
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${where}.highlight`, message: `字段 ${ref.name} 的 highlight 必须是布尔值` });
|
|
219
234
|
}
|
|
220
235
|
}
|
|
221
|
-
|
|
236
|
+
// 只读详情(summary 槽的展示格)= 描述列表:标签在左定宽、弱化墨(KT-K-desc-1,二-16);调用方另给了基准类(如统计 / 指标格)的不改
|
|
237
|
+
const descCell = mode === 'show' && env.slot === 'summary' && extraBase === KIT_CLASS_DEFAULTS.cell;
|
|
238
|
+
const cellBase = descCell ? KIT_DESC_CELL_CLASS : extraBase;
|
|
239
|
+
const baseWithHighlight = fieldHighlight ? mergeClass(`${spanClass} ${cellBase}`.trim(), KIT_METRIC_HIGHLIGHT_CLASS) : `${spanClass} ${cellBase}`.trim();
|
|
222
240
|
const base = mergeClass(baseWithHighlight, view.cellClass, view.replaceClass);
|
|
223
241
|
const baseValRaw = SELF_COLORED_COMPONENTS.has(pick.component) ? '' : DEFAULT_CELL_VALUE_CLASS;
|
|
224
242
|
// 日期时间类值(type 或 format 属日期族)只读展示时整段不折行:2026-11-13 不在连字符处断开,列宽不足交给单元格既有的省略 / 提示机制
|
|
@@ -234,12 +252,20 @@ export function buildCell(
|
|
|
234
252
|
props: fieldProps(field, ref, mode),
|
|
235
253
|
parts,
|
|
236
254
|
cellClass: mergeClass(base, ref.class),
|
|
237
|
-
labelClass: mergeClass(DEFAULT_CELL_LABEL_CLASS, ref.labelClass),
|
|
255
|
+
labelClass: mergeClass(descCell ? KIT_DESC_LABEL_CLASS : DEFAULT_CELL_LABEL_CLASS, ref.labelClass),
|
|
238
256
|
valueClass: mergeClass(valWithEmphasis, ref.valueClass),
|
|
239
257
|
errorClass: KIT_CLASS_DEFAULTS.error,
|
|
240
258
|
...(fieldEmphasis !== undefined ? { emphasis: fieldEmphasis } : {}),
|
|
241
259
|
...(fieldHighlight ? { highlight: true } : {}),
|
|
242
260
|
};
|
|
261
|
+
// 新建 / 编辑表单的单行控件按字段类型取宽度档(KT-K-form-8,§6.1 G-12):档名取已有引擎 kitFieldWidthStep(content-layout#formFieldWidth
|
|
262
|
+
// byType + 最大长度),槽设上限、控件 w-full → 控件宽 = min(档宽, 列宽);多行文本 / 富文本 / 子表 / 选项组不在此列(撑满)
|
|
263
|
+
if (mode === 'edit' && env.slot === 'form' && WIDTH_CAPPED_COMPONENTS.has(pick.component)) {
|
|
264
|
+
const maxLen = maxLenOfRules(field.rules);
|
|
265
|
+
const step = kitFieldWidthStep({ key: ref.name, type: field.type as never, label: '', ...(maxLen !== null ? { maxLen } : {}) });
|
|
266
|
+
const cls = KIT_FIELD_WIDTH_CLASS[step];
|
|
267
|
+
if (cls !== undefined) cell.bodyClass = cls;
|
|
268
|
+
}
|
|
243
269
|
// 下拉没写占位文案、又没有值时的默认占位:筛选栏「全部」(不筛选),表单「请选择」;字段 / 视图自己写了 placeholder 的不动
|
|
244
270
|
if (mode === 'edit' && pick.component === 'Select' && cell.props.placeholder === undefined && (env.slot === 'filter' || env.slot === 'form')) {
|
|
245
271
|
cell.props.placeholder = kitText(env.slot === 'filter' ? 'soma.kit.filter_all_option' : 'soma.kit.please_select', undefined, env.locale ?? '');
|
|
@@ -268,6 +294,10 @@ export function buildCell(
|
|
|
268
294
|
else cell.helpTip = ref.help;
|
|
269
295
|
}
|
|
270
296
|
}
|
|
297
|
+
// 描述列表的缺失值缺省也写「—」(KT-K-desc-2):summary 没声明 emptyText / hideEmpty 时同样给占位,不留空白
|
|
298
|
+
if (env.empty === undefined && descCell && KIT_SUMMARY_EMPTY.placeholderComponents.includes(pick.component) && cell.props.placeholder === undefined) {
|
|
299
|
+
cell.props.placeholder = KIT_SUMMARY_EMPTY.emptyDefault;
|
|
300
|
+
}
|
|
271
301
|
if (env.empty !== undefined && mode === 'show') {
|
|
272
302
|
if (env.empty.hide) {
|
|
273
303
|
// 发射成纯路径绑定 show[id].when = 字段值路径(只判真值),数字 / 布尔字段的 0 / false 会被误隐,故不许 hideEmpty
|
|
@@ -449,8 +479,8 @@ export function arrange(input: KitArrangeInput, refs: KitFieldRef[], view: KitVi
|
|
|
449
479
|
};
|
|
450
480
|
}
|
|
451
481
|
|
|
452
|
-
/** 编辑 /
|
|
453
|
-
function requiredOf(label: string, field: { rules?: Array<{ required?: boolean }> }, mode: string, position: 'start' | 'end' = '
|
|
482
|
+
/** 编辑 / 新建态的必填字段标星号位置(缺省 start = 标签前,KT-K-form-3;end = 标签后,作者显式写 requiredMark 时才取);星号由发射层 / 表单画成红色子元素,不并入标签文本 */
|
|
483
|
+
function requiredOf(label: string, field: { rules?: Array<{ required?: boolean }> }, mode: string, position: 'start' | 'end' = 'start', slot?: string): { required?: 'start' | 'end' } {
|
|
454
484
|
if (slot === 'filter' || mode === 'show' || label === '') return {};
|
|
455
485
|
if (field.rules?.some((r) => r.required === true) !== true) return {};
|
|
456
486
|
return { required: position };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { SomaComponentDefinition, SomaRegionPort } from 'soma-core';
|
|
9
9
|
import { CLASS_PROP, createKitController, findRoot, joinClass, str } from '../base/shared';
|
|
10
|
-
import { kitIcon } from '../
|
|
10
|
+
import { kitIcon } from '../shared/icons';
|
|
11
11
|
import { releaseReasonTipsIn, KIT_APP_TOOLTIP_CLASS_CANDIDATES } from '../base/reason-tip';
|
|
12
12
|
import { KIT_TIPS_SCOPE_ATTR, kitHelpButton } from '../base/hint-tips';
|
|
13
13
|
import { KIT_FACE_FIELD, KIT_FACE_RAISED, KIT_PART_ATTRIBUTE, KIT_PART_TABLE_HEAD, kitControlRecipe, kitFocusRingRecipe, kitTextActionRecipe, setKitFace } from '../recipes';
|
|
@@ -23,7 +23,9 @@ import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, isMark, mark
|
|
|
23
23
|
import { KIT_TABLE_EXT } from './defaults';
|
|
24
24
|
import { KIT_TABLE_GAP_CLASS_CANDIDATES, KIT_TABLE_GAP_HEAD_ATTR, analyzeTableGaps, paintTableGapNotes } from '../recipes/table-gap';
|
|
25
25
|
import { kitText } from '../i18n/kit-text';
|
|
26
|
-
import { mergeClass } from '
|
|
26
|
+
import { mergeClass } from '../shared/merge-class';
|
|
27
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
28
|
+
import { KIT_PART_TABLE } from '../recipes/table-row';
|
|
27
29
|
import { KIT_SKELETON_CLASS_CANDIDATES, buildSkeleton, skeletonConfigOf } from './skeleton';
|
|
28
30
|
import { KIT_ILLUSTRATION_CLASS_CANDIDATES } from '../base/illustrations';
|
|
29
31
|
import { KIT_STATE_PANEL_CLASS_CANDIDATES, paintKitStatePanel, splitHttpErrorPrefix } from '../base/state-panel';
|
|
@@ -41,10 +43,11 @@ const HEAD_CELL_FILTER_CLASS = 'relative';
|
|
|
41
43
|
const FILTER_BUTTON_CLASS = 'inline-flex h-6 w-6 items-center justify-center rounded-md text-fg-subtle transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
42
44
|
const FILTER_BUTTON_ACTIVE_CLASS = 'inline-flex h-6 w-6 items-center justify-center rounded-md bg-primary-soft text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
43
45
|
const FILTER_ICON_CLASS = 'h-3.5 w-3.5 fill-none stroke-current stroke-2';
|
|
44
|
-
|
|
46
|
+
// 列筛选弹层 = 浮起表面(KT-B4)
|
|
47
|
+
const FILTER_PANEL_BASE = mergeClass('absolute z-20 w-56 p-3 text-sm font-normal text-fg', kitSurfaceRecipe('raised'));
|
|
45
48
|
/** 筛选面板的偏好位置:漏斗钮下方、起点对齐;贴边时翻转 */
|
|
46
49
|
const FILTER_PREF: PopPlace = { side: 'bottom', align: 'start' };
|
|
47
|
-
const filterClassFor = (place: PopPlace): string => `${FILTER_PANEL_BASE} ${popPlaceClass(place
|
|
50
|
+
const filterClassFor = (place: PopPlace): string => `${FILTER_PANEL_BASE} ${popPlaceClass(place)}`;
|
|
48
51
|
const FILTER_LIST_CLASS = 'flex max-h-48 flex-col gap-1 overflow-y-auto';
|
|
49
52
|
const FILTER_OPTION_CLASS = 'w-full px-1 py-1 hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
50
53
|
// 表头筛选面板的输入与按钮:控件引擎的配方(输入 = 单行控件 outline;确定 / 清除 = 工具条宿主 tight 按钮)
|
|
@@ -696,10 +699,12 @@ const META_ROOT_CLASS = 'me-auto flex flex-wrap items-baseline gap-x-3 text-sm t
|
|
|
696
699
|
const META_HINT_CLASS = 'inline-flex items-baseline gap-2';
|
|
697
700
|
const META_HINT_CLEAR_CLASS = kitTextActionRecipe('primary');
|
|
698
701
|
const FILTERED_EMPTY_CLEAR_CLASS = kitTextActionRecipe('primary');
|
|
702
|
+
/** 并入筛选行(config.inline:主从左窗格头)的根类:筛选控件右侧一个不收缩的「清除筛选」,生效条件就在旁边的控件里看得见,不再重复「已筛选 · N 项条件」 */
|
|
703
|
+
const META_INLINE_ROOT_CLASS = 'flex shrink-0 items-center';
|
|
699
704
|
|
|
700
705
|
export const KIT_COLLECTION_STATE_CLASS_CANDIDATES: readonly string[] = ['hidden']
|
|
701
706
|
.concat(KIT_STATE_PANEL_CLASS_CANDIDATES, KIT_SKELETON_CLASS_CANDIDATES, KIT_ILLUSTRATION_CLASS_CANDIDATES,
|
|
702
|
-
[META_ROOT_CLASS, META_HINT_CLASS, META_HINT_CLEAR_CLASS, FILTERED_EMPTY_CLEAR_CLASS].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')));
|
|
707
|
+
[META_ROOT_CLASS, META_HINT_CLASS, META_HINT_CLEAR_CLASS, FILTERED_EMPTY_CLEAR_CLASS, META_INLINE_ROOT_CLASS].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')));
|
|
703
708
|
|
|
704
709
|
function pick(data: unknown, path: string): unknown {
|
|
705
710
|
let cur: unknown = data;
|
|
@@ -832,7 +837,17 @@ export function createKitCollectionState(): SomaComponentDefinition {
|
|
|
832
837
|
shown += 1;
|
|
833
838
|
}
|
|
834
839
|
const active = cfg.hint === true ? activeNow() : { form: 0, columns: 0, total: 0 };
|
|
835
|
-
|
|
840
|
+
const inline = cfg.inline === true;
|
|
841
|
+
if (active.total > 0 && inline) {
|
|
842
|
+
const clear = doc.createElement('button');
|
|
843
|
+
clear.setAttribute('type', 'button');
|
|
844
|
+
clear.setAttribute('data-kit-filter-clear-all', '');
|
|
845
|
+
clear.setAttribute('aria-label', `${kitText('soma.kit.filter_active', { n: active.total }, root)},${kitText('soma.kit.clear_filter', undefined, root)}`);
|
|
846
|
+
clear.className = META_HINT_CLEAR_CLASS;
|
|
847
|
+
clear.textContent = kitText('soma.kit.clear_filter', undefined, root);
|
|
848
|
+
target.appendChild(clear);
|
|
849
|
+
shown += 1;
|
|
850
|
+
} else if (active.total > 0) {
|
|
836
851
|
const hint = doc.createElement('span');
|
|
837
852
|
hint.setAttribute('data-kit-filter-hint', '');
|
|
838
853
|
hint.className = META_HINT_CLASS;
|
|
@@ -847,7 +862,7 @@ export function createKitCollectionState(): SomaComponentDefinition {
|
|
|
847
862
|
target.appendChild(hint);
|
|
848
863
|
shown += 1;
|
|
849
864
|
}
|
|
850
|
-
root.className = shown === 0 ? joinClass('hidden', p.class) : joinClass(META_ROOT_CLASS, p.class);
|
|
865
|
+
root.className = shown === 0 ? joinClass('hidden', p.class) : joinClass(inline ? META_INLINE_ROOT_CLASS : META_ROOT_CLASS, p.class);
|
|
851
866
|
};
|
|
852
867
|
return {
|
|
853
868
|
attach(root) {
|
|
@@ -894,6 +909,10 @@ export function createKitCollectionState(): SomaComponentDefinition {
|
|
|
894
909
|
// ② 失败后点重试:错误路径上的失败标记不会清,重试进行中按加载态呈现,不再显示失败与重试按钮;
|
|
895
910
|
// 上一轮是空数组、这一轮显式重取,同样给加载反馈而不是停在「暂无数据」
|
|
896
911
|
if (status === 'error' || status === 'empty') { status = 'loading'; message = ''; }
|
|
912
|
+
} else if (readState === 'idle' && status === 'loading') {
|
|
913
|
+
// ③ 依赖前置选择(如 requireLink 未选分类)时对象停在 idle 未发起请求:展示空闲提示而非永久卡在加载骨架
|
|
914
|
+
status = 'empty';
|
|
915
|
+
message = str(cfg.idle);
|
|
897
916
|
}
|
|
898
917
|
// meta 形态(标题旁的辅助文字):只画「共 N 条」与「已筛选」提示,不画三态面板
|
|
899
918
|
if (str(cfg.mode) === 'meta') {
|
|
@@ -909,6 +928,14 @@ export function createKitCollectionState(): SomaComponentDefinition {
|
|
|
909
928
|
if ((status === 'ready' || status === 'empty') && readState !== 'loading') retryByKeyboard = false;
|
|
910
929
|
// errorOnly(state: false):只有失败才画面板,加载 / 空态 / 就绪一律隐藏
|
|
911
930
|
const errorOnly = str(cfg.mode) === 'errorOnly';
|
|
931
|
+
// 表格的空 / 加载 / 失败整块替换表体(KT-K-table-6,二-17):三态面板出现时隐藏紧挨在前的表壳(含表头),面板占表体位置;
|
|
932
|
+
// 重取期间旧行还在时 status 仍是 ready,表壳不动(不闪)
|
|
933
|
+
if (!single) {
|
|
934
|
+
const tableBody = api.host.previousElementSibling;
|
|
935
|
+
if (tableBody && (tableBody.getAttribute(KIT_PART_ATTRIBUTE) === KIT_PART_TABLE || tableBody.hasAttribute('data-kit-vscroll'))) {
|
|
936
|
+
tableBody.classList.toggle('hidden', !(status === 'ready' || (errorOnly && status !== 'error')));
|
|
937
|
+
}
|
|
938
|
+
}
|
|
912
939
|
if (status === 'ready' || (errorOnly && status !== 'error')) {
|
|
913
940
|
root.className = joinClass('hidden', p.class);
|
|
914
941
|
box.textContent = '';
|
|
@@ -929,6 +956,10 @@ export function createKitCollectionState(): SomaComponentDefinition {
|
|
|
929
956
|
text: kitText('soma.kit.empty_filtered', undefined, root),
|
|
930
957
|
action: { label: kitText('soma.kit.clear_filter', undefined, root), attr: 'data-kit-filter-clear-all' },
|
|
931
958
|
});
|
|
959
|
+
} else if (readState === 'idle') {
|
|
960
|
+
paintKitStatePanel(box, 'empty', {
|
|
961
|
+
text: message !== '' ? message : str(cfg.empty, kitText('soma.kit.empty', undefined, root)),
|
|
962
|
+
});
|
|
932
963
|
} else {
|
|
933
964
|
// 尚无数据:给页面主操作的同名入口(同一对象的工具栏最后一个主操作按钮,点它即点该操作,事件仍走原动作);没有就只有标题
|
|
934
965
|
const doc = box.ownerDocument;
|
|
@@ -492,6 +492,11 @@ export function parseEditMode(raw: unknown, anyEditable: boolean, env: KitCollec
|
|
|
492
492
|
|
|
493
493
|
// ---------------------------------------------------------------- 类拼装
|
|
494
494
|
|
|
495
|
+
/** 紧凑密度缩放补偿:COMPACT_DENSE 下 --spacing 为 3.5px(标准为 4px),确保定宽列与单动作操作列在紧凑档不撞字、不截断表头 */
|
|
496
|
+
const COMPACT_DENSITY_RATIO = 4 / 3.5;
|
|
497
|
+
/** 滚动模式单元格(tableScrollCell)自带 px-4 左右双向内边距(共 8 个间距单位) */
|
|
498
|
+
const SCROLL_CELL_PAD_STEPS = 8;
|
|
499
|
+
|
|
495
500
|
/** 列宽刻度:min > width 份数换算 > 缺省 */
|
|
496
501
|
export function stepOf(ext: ColExt, width: number | undefined): number {
|
|
497
502
|
if (ext.min !== undefined) return ext.min;
|
|
@@ -499,6 +504,21 @@ export function stepOf(ext: ColExt, width: number | undefined): number {
|
|
|
499
504
|
return X.scroll.defaultMin;
|
|
500
505
|
}
|
|
501
506
|
|
|
507
|
+
/** 滚动模式列宽刻度:计入 tableScrollCell 的 px-4 双向内边距与紧凑密度(3.5px/step)下的表头可读宽度,并贴齐 minSteps 档位 */
|
|
508
|
+
export function scrollStepOf(ext: ColExt, width: number | undefined, label = ''): number {
|
|
509
|
+
const font = KIT_LAYOUT_SMELLS.reference.bodyFontRem;
|
|
510
|
+
const stepRem = KIT_ARRANGE.columns.track.stepRem;
|
|
511
|
+
const headerUnits = label === '' ? 0 : Math.ceil((textWidthEm(label) * font * COMPACT_DENSITY_RATIO) / stepRem);
|
|
512
|
+
if (ext.min !== undefined) {
|
|
513
|
+
const floor = Math.max(ext.min, headerUnits + SCROLL_CELL_PAD_STEPS);
|
|
514
|
+
return X.scroll.minSteps.find((s) => s >= floor) ?? X.scroll.minSteps[X.scroll.minSteps.length - 1]!;
|
|
515
|
+
}
|
|
516
|
+
const base = stepOf(ext, width);
|
|
517
|
+
const needed = Math.max(Math.ceil(base * COMPACT_DENSITY_RATIO), headerUnits + SCROLL_CELL_PAD_STEPS, base + SCROLL_CELL_PAD_STEPS);
|
|
518
|
+
const hit = X.scroll.minSteps.find((s) => s >= needed);
|
|
519
|
+
return hit ?? X.scroll.minSteps[X.scroll.minSteps.length - 1]!;
|
|
520
|
+
}
|
|
521
|
+
|
|
502
522
|
/** 列轨求解的一列事实(编译期信息:字段名 / 类型 / 表头 / 枚举文案 / 长度上限 / 表头图标 / 显式份数) */
|
|
503
523
|
export interface ColumnTrackColumn {
|
|
504
524
|
name: string;
|
|
@@ -517,6 +537,8 @@ export interface ColumnTrackColumn {
|
|
|
517
537
|
treeIndent?: boolean;
|
|
518
538
|
/** 页面声明了 ellipsis(作者接受截断):非主文本列窄容器里先让位(引擎 columns.ellipsis) */
|
|
519
539
|
ellipsis?: boolean;
|
|
540
|
+
/** 格内附件的文案宽(em,如 copyable 的「复制」钮):列的最小宽与理想宽各加附件宽(引擎 columns.attach) */
|
|
541
|
+
attachLabelEms?: readonly number[];
|
|
520
542
|
}
|
|
521
543
|
|
|
522
544
|
export interface ColumnTrackPlan {
|
|
@@ -577,38 +599,54 @@ export function columnTrackPlan(input: {
|
|
|
577
599
|
actionCount: number;
|
|
578
600
|
/** 窄档线的容器档名 */
|
|
579
601
|
tier: string;
|
|
602
|
+
/** 单元格自身额外水平内边距(间距单位,例如 bordered 完整网格线的 px-3 = 6) */
|
|
603
|
+
cellPadUnits?: number;
|
|
580
604
|
}): ColumnTrackPlan {
|
|
581
605
|
const g = X.narrowGrid;
|
|
582
606
|
const T = KIT_ARRANGE.columns.track;
|
|
583
607
|
const font = KIT_LAYOUT_SMELLS.reference.bodyFontRem;
|
|
584
608
|
const idName = new RegExp(KIT_ARRANGE.columns.idNamePattern);
|
|
585
609
|
const v = `@max-${input.tier}:`;
|
|
610
|
+
const padUnits = input.cellPadUnits ?? 0;
|
|
611
|
+
// 优化主列选取:默认沿用排布引擎的第一个文本列(带 capRem 封顶);当首文本列声明短 maxLen(≤16)而后续有 longtext 或较长普通文本列时,改由较长列做主列,避免短首列吃掉空白
|
|
612
|
+
const firstTextIdx = input.columns.findIndex((c) => (c.type === undefined || c.type === 'text') && c.key !== true && !idName.test(c.name));
|
|
613
|
+
const betterMainIdx = firstTextIdx >= 0 && input.columns[firstTextIdx]!.maxLen !== undefined && input.columns[firstTextIdx]!.maxLen! <= 16
|
|
614
|
+
? input.columns.findIndex((c, idx) => idx > firstTextIdx && (c.type === 'longtext' || ((c.type === undefined || c.type === 'text') && c.key !== true && !idName.test(c.name) && c.ellipsis !== true && (c.maxLen === undefined || c.maxLen > 24))))
|
|
615
|
+
: -1;
|
|
616
|
+
const colMeta = input.columns.map((c, idx) => {
|
|
617
|
+
const textual = c.type === undefined || c.type === 'text';
|
|
618
|
+
const optionEm = (c.options ?? []).reduce((m, o) => Math.max(m, textWidthEm(typeof o.label === 'string' && o.label !== '' ? o.label : typeof o.value === 'string' ? o.value : '')), 0);
|
|
619
|
+
const extraEm = (c.sortable === true ? T.headerExtraEm.sortable : 0) + (c.filter === true ? T.headerExtraEm.filter : 0);
|
|
620
|
+
const content = (c.dateEm ?? 0) > 0 ? (c.dateEm as number) : optionEm;
|
|
621
|
+
const labelEm = textWidthEm(c.label) + extraEm;
|
|
622
|
+
return {
|
|
623
|
+
key: c.name,
|
|
624
|
+
type: textual && (c.key === true || idName.test(c.name)) ? 'id' : (c.type ?? 'text'),
|
|
625
|
+
labelEm,
|
|
626
|
+
...(content > 0 ? { optionEm: content } : {}),
|
|
627
|
+
...(c.maxLen !== undefined ? { maxLen: c.maxLen } : {}),
|
|
628
|
+
...(c.ellipsis === true ? { ellipsis: true } : {}),
|
|
629
|
+
...(c.attachLabelEms !== undefined && c.attachLabelEms.length > 0 ? { attachLabelEms: c.attachLabelEms } : {}),
|
|
630
|
+
...(betterMainIdx === idx ? { main: true } : {}),
|
|
631
|
+
};
|
|
632
|
+
});
|
|
586
633
|
const solved = arrangeColumns({
|
|
587
634
|
fontRem: font,
|
|
588
|
-
columns:
|
|
589
|
-
const textual = c.type === undefined || c.type === 'text';
|
|
590
|
-
const optionEm = (c.options ?? []).reduce((m, o) => Math.max(m, textWidthEm(typeof o.label === 'string' && o.label !== '' ? o.label : typeof o.value === 'string' ? o.value : '')), 0);
|
|
591
|
-
const extraEm = (c.sortable === true ? T.headerExtraEm.sortable : 0) + (c.filter === true ? T.headerExtraEm.filter : 0);
|
|
592
|
-
const content = (c.dateEm ?? 0) > 0 ? (c.dateEm as number) : optionEm;
|
|
593
|
-
return {
|
|
594
|
-
key: c.name,
|
|
595
|
-
type: textual && (c.key === true || idName.test(c.name)) ? 'id' : (c.type ?? 'text'),
|
|
596
|
-
labelEm: textWidthEm(c.label) + extraEm,
|
|
597
|
-
...(content > 0 ? { optionEm: content } : {}),
|
|
598
|
-
...(c.maxLen !== undefined ? { maxLen: c.maxLen } : {}),
|
|
599
|
-
...(c.ellipsis === true ? { ellipsis: true } : {}),
|
|
600
|
-
};
|
|
601
|
-
}),
|
|
635
|
+
columns: colMeta,
|
|
602
636
|
actions: input.actionCount > 0 ? { labelEms: [...input.actionLabelEms], hasMore: input.actionHasMore } : null,
|
|
603
637
|
});
|
|
604
638
|
let minUnits = 0;
|
|
605
639
|
let cols = 0;
|
|
606
640
|
const explicitAny = input.columns.some((c) => (c.explicitWidth ?? 0) > 0);
|
|
641
|
+
// 若非主列声明了 longtext 或 ellipsis: true(长描述/地址/角色列表列),在宽屏有余量时让其 flex-1 伸展吸收余量(而非锁死在 176px 并把空白扔给末尾 spacer),窄屏仍可收到让位最小宽
|
|
642
|
+
const hasFlexLong = !explicitAny && solved.columns.some((col, i) => !col.grow && (input.columns[i]!.type === 'longtext' || input.columns[i]!.ellipsis === true));
|
|
643
|
+
const useSpacer = solved.spacer && !explicitAny && !hasFlexLong;
|
|
607
644
|
const cellClasses = solved.columns.map((col, i) => {
|
|
608
645
|
const src = input.columns[i]!;
|
|
646
|
+
const meta = colMeta[i]!;
|
|
609
647
|
const extra = src.treeIndent === true ? T.treeIndentRem : 0;
|
|
610
|
-
const min = trackStep(col.min + extra);
|
|
611
|
-
const ideal = Math.max(min, trackStep(col.ideal + extra));
|
|
648
|
+
const min = trackStep(col.min + extra) + padUnits;
|
|
649
|
+
const ideal = Math.max(min, trackStep(col.ideal + extra) + padUnits);
|
|
612
650
|
minUnits += min;
|
|
613
651
|
cols += 1;
|
|
614
652
|
const share = src.explicitWidth ?? 0;
|
|
@@ -620,10 +658,14 @@ export function columnTrackPlan(input: {
|
|
|
620
658
|
minUnits += gapUnits;
|
|
621
659
|
const gap = gapUnits > 0 ? ` me-${gapUnits}` : '';
|
|
622
660
|
// 末尾留白轨:最后一个数据列的 `me-auto` 把封顶后的余量留在它与操作列之间(无操作列则在它之后),行与表头带仍铺满
|
|
623
|
-
const lastSpacer =
|
|
661
|
+
const lastSpacer = useSpacer && i === solved.columns.length - 1 ? ' me-auto' : '';
|
|
624
662
|
if (share > 0) return `min-w-${min} flex-${Math.round(share)}${clip}${gap}`;
|
|
625
|
-
if (col.grow && !explicitAny) return `min-w-${min} flex-1${col.capRem !== null ? ` max-w-${Math.max(ideal, trackStep(col.capRem + extra))}` : ''}${clip}${gap}${lastSpacer}`;
|
|
626
|
-
return `
|
|
663
|
+
if (col.grow && !explicitAny) return `min-w-${min} flex-1${col.capRem !== null ? ` max-w-${Math.max(ideal, trackStep(col.capRem + extra) + padUnits)}` : ''}${clip}${gap}${lastSpacer}`;
|
|
664
|
+
if ((src.type === 'longtext' || src.ellipsis === true) && !explicitAny) return `min-w-${min} flex-1${clip}${gap}`;
|
|
665
|
+
// 紧凑密度下 --spacing 缩至 3.5px,对非主定宽列计入表头与紧凑内容宽下限,避免 w-16/w-24 撞字与表头截断
|
|
666
|
+
const compactRem = Math.max(meta.labelEm, meta.optionEm ?? 0) * font * COMPACT_DENSITY_RATIO;
|
|
667
|
+
const compactIdeal = Math.max(ideal, trackStep(compactRem + extra) + padUnits);
|
|
668
|
+
return `w-${compactIdeal} min-w-${min}${clip}${gap}${lastSpacer}`;
|
|
627
669
|
});
|
|
628
670
|
let selectClass = '';
|
|
629
671
|
if (input.hasSelect) {
|
|
@@ -633,13 +675,16 @@ export function columnTrackPlan(input: {
|
|
|
633
675
|
}
|
|
634
676
|
let actionsClass = '';
|
|
635
677
|
if (input.actionCount > 0) {
|
|
636
|
-
|
|
678
|
+
// 操作列最小步长不低于 2 * floorStep(16 步 = 标准 64px / 紧凑 56px),绝不算成 w-8 = 32px,确保放得下 2–4 字中文 + 内边距
|
|
679
|
+
const actionFloor = g.floorStep * 2;
|
|
680
|
+
const wide = Math.max(actionFloor, trackStep(solved.actionsRem ?? 0) + padUnits);
|
|
637
681
|
// 窄档行内 ≤ 1 个按钮 + 「更多」:操作列宽 = 留在行内的那个按钮文案宽 + 间距 + 「更多」入口宽,以窄档格数上限封顶(窄档放不下就会让整表多滚一截)
|
|
638
682
|
const cap = g.actionsSteps[String(Math.min(input.actionCount, g.actionsStepMax))]!;
|
|
639
683
|
const slots = Math.min(input.actionCount, g.actionsStepMax);
|
|
640
|
-
const
|
|
684
|
+
const narrowRaw = input.narrowActionLabelEm === undefined
|
|
641
685
|
? cap
|
|
642
|
-
: Math.
|
|
686
|
+
: Math.ceil(input.narrowActionLabelEm * g.actionFontStep) + (slots >= 2 ? g.actionGapStep + g.actionMoreStep : 0) + g.gapStep;
|
|
687
|
+
const narrow = Math.min(cap, Math.max(actionFloor, narrowRaw));
|
|
643
688
|
actionsClass = `w-${wide} shrink-0 ${v}w-${Math.min(narrow, wide)}`;
|
|
644
689
|
// 内层最小宽按窄档操作宽算:放不下(需要横滚)的恰是窄容器,宽档操作列只在容器 ≥ 窄档线时才用、那时容器本来就够宽
|
|
645
690
|
minUnits += Math.min(narrow, wide);
|
|
@@ -650,7 +695,7 @@ export function columnTrackPlan(input: {
|
|
|
650
695
|
return {
|
|
651
696
|
cellClasses, selectClass, actionsClass, innerMinUnits: Math.ceil(minUnits),
|
|
652
697
|
columns: solved.columns.map((c) => ({ key: c.key, min: c.min, ideal: c.ideal, max: c.max, grow: c.grow, capRem: c.capRem, gapAfterRem: c.gapAfterRem })),
|
|
653
|
-
spacer:
|
|
698
|
+
spacer: useSpacer,
|
|
654
699
|
actionsRem: solved.actionsRem,
|
|
655
700
|
};
|
|
656
701
|
}
|
|
@@ -3,23 +3,27 @@
|
|
|
3
3
|
import { kitRowActionsNarrowTier, kitRuleTableOf, kitTextWidthEm } from 'soma-foundation/kit-layout';
|
|
4
4
|
import { KIT_ARRANGE } from 'soma-foundation/arrange';
|
|
5
5
|
import { columnClassOfType } from 'soma-foundation/arrange/table';
|
|
6
|
+
import { kitText } from '../i18n/kit-text';
|
|
6
7
|
import { arrange, buildCell, type KitCellEnv } from './arrange';
|
|
7
8
|
import {
|
|
8
9
|
KIT_CLASS_DEFAULTS, KIT_CONTEXT_MENU, KIT_OBJECT_DEFAULTS, KIT_SKELETON, KIT_TABLE_EXT, KIT_TABLE_VIRTUAL, KIT_TREE_TABLE, KIT_WIDTH,
|
|
9
10
|
} from './defaults';
|
|
10
11
|
import {
|
|
11
12
|
actionsStepOf, alignClass, columnFilterOf, columnMetaOf, parseBatch, parseColExt, parseColumnGroups, parseEditMode, parseSelect, parseSummary, parseToolbar,
|
|
12
|
-
columnTrackPlan, dateContentEm, pillColumnType, plainRowClass, pyTokens, resolveResizable, resolveStickyCombo, scrollRowClass, STICKY_HEAD_CLASS, STICKY_HEAD_COMBO_CLASS, stepOf, stickyPlan, type ColExt, type ColGroup,
|
|
13
|
+
columnTrackPlan, dateContentEm, pillColumnType, plainRowClass, pyTokens, resolveResizable, resolveStickyCombo, scrollRowClass, scrollStepOf, STICKY_HEAD_CLASS, STICKY_HEAD_COMBO_CLASS, stepOf, stickyPlan, type ColExt, type ColGroup,
|
|
13
14
|
} from './collection-table';
|
|
14
15
|
import { splitRowActions } from './table-actions';
|
|
15
16
|
import { expandListIR, parseExpandDecl } from './collection-expand';
|
|
16
|
-
import { checkClasses, mergeClass } from '
|
|
17
|
-
import {
|
|
17
|
+
import { checkClasses, mergeClass } from '../shared/merge-class';
|
|
18
|
+
import { kitDividerVariantRecipe, kitStripBoundaryClasses } from '../recipes/divider';
|
|
19
|
+
import { hintOf, nameSuggestion } from '../shared/hints';
|
|
18
20
|
import { checkRowPath } from './view-binding';
|
|
19
21
|
import { gridColsClasses, gridLevels, partsOverflow } from './parts';
|
|
20
22
|
|
|
21
23
|
/** 表头 / 行的栅格间距与横向内边距类(含容器查询变体 @lg:):带边框的整格网格模式里由单元格自己的内边距接管,整组去掉 */
|
|
22
24
|
const GRID_SPACING_TOKEN = /^(?:@[a-z0-9]+:)?(?:gap-\d+|gap-x-\d+|px-\d+)$/;
|
|
25
|
+
/** bordered: true 网格表的列间竖线(表头与数据格同一组):分隔线出口,非末列朝结束侧一条(KT-B5 / KT-B8 第 4 点) */
|
|
26
|
+
const GRID_COL_DIVIDER = kitDividerVariantRecipe('end', 'not-last');
|
|
23
27
|
import type {
|
|
24
28
|
KitAction,
|
|
25
29
|
KitDiagnostic,
|
|
@@ -67,7 +71,9 @@ function stateOf(c: KitCollectionStateDecl, env: KitCollectionEnv, path: string)
|
|
|
67
71
|
}
|
|
68
72
|
return v;
|
|
69
73
|
};
|
|
70
|
-
|
|
74
|
+
// 能预知版式的集合缺省出骨架(KT-K-table-6 / KT-K-empty-3,二-17):没写 loading 文案即骨架(形态由发射处按列 / 卡片推,推不出时回落文字盒);
|
|
75
|
+
// 写了自定义 loading 文案的按文案
|
|
76
|
+
const skeleton = c.loading === KIT_SKELETON.keyword || c.loading === undefined;
|
|
71
77
|
return { loading: skeleton ? STATE_DEFAULTS.loading : text('loading'), empty: text('empty'), error: text('error'), skeleton };
|
|
72
78
|
}
|
|
73
79
|
|
|
@@ -322,18 +328,32 @@ function keptInlineActionEm(actions: ReadonlyArray<{ name: string; tone?: string
|
|
|
322
328
|
return kept === undefined ? undefined : kitTextWidthEm(kept.name);
|
|
323
329
|
}
|
|
324
330
|
|
|
325
|
-
/**
|
|
326
|
-
|
|
327
|
-
* 整串加 `@max-<档>:` 前缀,窄档线以上(含)不生效、宽表输出不变。
|
|
328
|
-
*/
|
|
329
|
-
export function narrowStickyEnd(rowPy: readonly string[], tier: string): string {
|
|
331
|
+
/** 贴右固定操作格的原始类令牌(无容器查询前缀);headRow 为真时用表头带底色遮罩,避免吸右表头露白块 */
|
|
332
|
+
function stickyEndTokens(rowPy: readonly string[], headRow = false): string[] {
|
|
330
333
|
const pad = rowPy.flatMap((t) => {
|
|
331
334
|
const m = /^((?:[^:]+:)*)py-(.+)$/.exec(t);
|
|
332
335
|
return m === null ? [] : [`${m[1]}-my-${m[2]}`, t];
|
|
333
336
|
});
|
|
334
337
|
// 列表页对齐轴(祖先带 data-kit-axis)里行的左右内缩落在文字轴上,但贴右固定的格贴的是滚动容器边缘、不吃行内缩:格自己补轴内边距(content-box:宽度档不变,底仍铺到边缘),操作文字才落在右轴上
|
|
335
338
|
const axis = ['in-data-kit-axis:pe-card', 'in-data-kit-axis:box-content'];
|
|
336
|
-
|
|
339
|
+
const baseTokens = KIT_CLASS_DEFAULTS.tableNarrowStickyEnd
|
|
340
|
+
.split(/\s+/)
|
|
341
|
+
.map((t) => (headRow && t === 'before:bg-surface' ? 'before:bg-surface-band' : t));
|
|
342
|
+
return [...baseTokens, ...KIT_CLASS_DEFAULTS.tableEdgeRight.split(/\s+/), ...axis, ...pad].filter((t) => t !== '');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 窄容器档贴右固定操作格的类:classDefaults.tableNarrowStickyEnd + 抵消行纵向内边距(py-N → -my-N 再补回 py-N,内容仍居中),
|
|
347
|
+
* 整串加 `@max-<档>:` 前缀,窄档线以上(含)不生效、宽表输出不变。
|
|
348
|
+
*/
|
|
349
|
+
export function narrowStickyEnd(rowPy: readonly string[], tier: string, headRow = false): string {
|
|
350
|
+
return stickyEndTokens(rowPy, headRow).map((t) => `@max-${tier}:${t}`).join(' ');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** 宽表溢出吸右操作格(表最小宽超出桌面常规容器时无条件 sticky right-0 + 实底遮罩,防止宽表操作列掉出视口) */
|
|
354
|
+
const WIDE_TABLE_OVERFLOW_MIN_UNITS = 168;
|
|
355
|
+
function wideStickyEnd(rowPy: readonly string[], headRow = false): string {
|
|
356
|
+
return stickyEndTokens(rowPy, headRow).join(' ');
|
|
337
357
|
}
|
|
338
358
|
|
|
339
359
|
/**
|
|
@@ -469,11 +489,12 @@ export function collection(
|
|
|
469
489
|
message: `列宽份数超出可用 ${avail} 份(总 ${KIT_WIDTH.totalParts},选择列 ${selectParts},操作列 ${actionParts})`,
|
|
470
490
|
});
|
|
471
491
|
}
|
|
472
|
-
const steps = refs.map((r, i) =>
|
|
492
|
+
const steps = refs.map((r, i) => scrollStepOf(ext[i]!, r.width, typeof r.label === 'string' ? r.label : (env.schema[r.name]?.name ?? '')));
|
|
473
493
|
const selectStep = select === 'none' ? 0 : X.scroll.selectStep;
|
|
474
494
|
const actionsStep = actionsStepOf(rowActions.length);
|
|
495
|
+
const scrollWideActionsSticky = scroll && actionParts > 0 && !sticky && selectStep + actionsStep + steps.reduce((s, n) => s + n, 0) > WIDE_TABLE_OVERFLOW_MIN_UNITS;
|
|
475
496
|
// 表头行层级:并存、或虚拟滚动 + 固定列时抬到 z-20(表体固定格 z-10,同层时 DOM 靠后者在上,会盖住表头)
|
|
476
|
-
const headAboveFixed = scroll && (combo || (virt !== null && ext.some((e) => e.fixed !== undefined)));
|
|
497
|
+
const headAboveFixed = scroll && (combo || (virt !== null && (ext.some((e) => e.fixed !== undefined) || scrollWideActionsSticky)));
|
|
477
498
|
const plan = scroll ? stickyPlan(steps, ext, selectStep, actionsStep) : null;
|
|
478
499
|
const densityToolbar = toolbar.includes('density');
|
|
479
500
|
const bodyPy = pyTokens(dens.row);
|
|
@@ -521,7 +542,7 @@ export function collection(
|
|
|
521
542
|
const stk = plan !== null && plan.offset[i] !== '';
|
|
522
543
|
const edge = plan === null ? '' : plan.edgeLeft === i ? D.tableEdgeLeft : plan.edgeRight === i ? D.tableEdgeRight : '';
|
|
523
544
|
const gridBorderCell = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...bodyPy, ...denseRow] : [];
|
|
524
|
-
const colDivider = bordered ?
|
|
545
|
+
const colDivider = bordered ? GRID_COL_DIVIDER : '';
|
|
525
546
|
cell.cellClass = join(
|
|
526
547
|
cell.cellClass, al, ex.ellipsis ? D.tableCellEllipsis : '',
|
|
527
548
|
scroll ? [...bodyPy, ...denseRow] : gridBorderCell,
|
|
@@ -558,7 +579,7 @@ export function collection(
|
|
|
558
579
|
}
|
|
559
580
|
const headGridBorder = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...headPy, ...denseHead] : [];
|
|
560
581
|
// 表头列间竖分隔线只在显式 bordered: true(完整网格线)时有;默认表头只有下分隔线(2026-11-17 评审 S6)
|
|
561
|
-
const headTick = bordered ?
|
|
582
|
+
const headTick = bordered ? GRID_COL_DIVIDER : '';
|
|
562
583
|
const headCls = join(
|
|
563
584
|
widthCls, 'truncate', 'whitespace-nowrap', al,
|
|
564
585
|
scroll ? [...headPy, ...denseHead] : headGridBorder,
|
|
@@ -577,9 +598,10 @@ export function collection(
|
|
|
577
598
|
}
|
|
578
599
|
head.push(h);
|
|
579
600
|
summaryCellClasses.push(join(
|
|
580
|
-
widthCls, al,
|
|
601
|
+
widthCls, al, 'overflow-hidden whitespace-nowrap truncate',
|
|
581
602
|
scroll ? [...bodyPy, ...denseRow] : '',
|
|
582
|
-
|
|
603
|
+
// 合计行固定列用与合计行一致的实底 bg-surface-sunken + z-20 遮罩,避免滚动数字透叠到固定列下
|
|
604
|
+
stk ? ['sticky z-20 bg-surface-sunken', plan!.offset[i]!, edge] : '',
|
|
583
605
|
));
|
|
584
606
|
});
|
|
585
607
|
// 宽档行内动作(与发射 KitTableActions 同一个切分函数):操作列按这些动作的文案估宽定宽
|
|
@@ -607,6 +629,8 @@ export function collection(
|
|
|
607
629
|
dateEm: dateContentEm(f?.type),
|
|
608
630
|
...(isTree && cells[i]?.field === indentName ? { treeIndent: true } : {}),
|
|
609
631
|
...(colExt[i]?.ellipsis === true ? { ellipsis: true } : {}),
|
|
632
|
+
// 格内附件:值后常显的「复制」钮算进列宽(不与长编码重叠、不截成半个字)
|
|
633
|
+
...(cells[i]?.props.copyable === true ? { attachLabelEms: [kitTextWidthEm(typeof cells[i]?.props.copy_label === 'string' ? cells[i]!.props.copy_label as string : kitText('soma.kit.copy'))] } : {}),
|
|
610
634
|
};
|
|
611
635
|
}),
|
|
612
636
|
hasSelect: selectParts > 0,
|
|
@@ -615,6 +639,7 @@ export function collection(
|
|
|
615
639
|
...(keptInlineActionEm(rowActions) !== undefined ? { narrowActionLabelEm: keptInlineActionEm(rowActions) as number } : {}),
|
|
616
640
|
actionCount: actionParts > 0 ? rowActions.length : 0,
|
|
617
641
|
tier: narrowTier,
|
|
642
|
+
...(bordered ? { cellPadUnits: 6 } : {}),
|
|
618
643
|
})
|
|
619
644
|
: null;
|
|
620
645
|
if (narrowGrid !== null) {
|
|
@@ -675,15 +700,22 @@ export function collection(
|
|
|
675
700
|
// 选择列 / 操作列:滚动模式下定宽,有固定列时 sticky(行里底色随行,表头里随表头)
|
|
676
701
|
const lead = (headRow: boolean): string => join(
|
|
677
702
|
scroll ? [D.tableScrollCell, `w-${selectStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [narrowGrid?.selectClass ?? '', ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
678
|
-
bordered ?
|
|
703
|
+
bordered ? GRID_COL_DIVIDER : '',
|
|
679
704
|
plan !== null && plan.selectSticky ? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'left-0'] : '',
|
|
680
705
|
);
|
|
706
|
+
const wideOverflowSticky = narrowEnd && narrowGrid !== null && actionParts > 0 && narrowGrid.innerMinUnits > WIDE_TABLE_OVERFLOW_MIN_UNITS;
|
|
681
707
|
const tail = (headRow: boolean): string => join(
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
? [
|
|
685
|
-
: '',
|
|
686
|
-
|
|
708
|
+
// 操作列表头与单元格统一采用 flex items-center justify-end(消除 scroll/bordered/sticky 下 columnheader: end 与 cell: start 错位)
|
|
709
|
+
scroll
|
|
710
|
+
? [D.tableScrollCell, 'justify-end', headRow ? 'whitespace-nowrap' : '', `w-${actionsStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])]
|
|
711
|
+
: [narrowGrid?.actionsClass ?? '', 'flex items-center justify-end', headRow ? 'whitespace-nowrap' : '', ...(bordered ? ['px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
712
|
+
(plan !== null && plan.actionsSticky) || scrollWideActionsSticky
|
|
713
|
+
? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'right-0', (plan?.edgeRight ?? -1) === -1 ? D.tableEdgeRight : '']
|
|
714
|
+
: '',
|
|
715
|
+
// 宽表溢出时操作列常驻吸右(不限窄容器档),普通表则在窄容器档吸右,防止操作列掉出视口
|
|
716
|
+
wideOverflowSticky
|
|
717
|
+
? wideStickyEnd(bordered ? [] : pyTokens(headRow ? dens.head : dens.row), headRow)
|
|
718
|
+
: (narrowEnd && narrowGrid !== null && actionParts > 0 ? narrowStickyEnd(bordered ? [] : pyTokens(headRow ? dens.head : dens.row), narrowTier, headRow) : ''),
|
|
687
719
|
);
|
|
688
720
|
const selectRow = selectParts > 0 ? lead(false) : '';
|
|
689
721
|
const actionsRow = actionParts > 0 ? tail(false) : '';
|
|
@@ -694,12 +726,13 @@ export function collection(
|
|
|
694
726
|
const headBase = scroll ? scrollRowClass(dens.head) : bordered ? gridBorderedRow(dens.head) : dens.head;
|
|
695
727
|
const rawSummaryRow = D.tableSummaryRow;
|
|
696
728
|
const summaryRowBase = unbordered
|
|
697
|
-
? rawSummaryRow
|
|
729
|
+
? kitStripBoundaryClasses(rawSummaryRow)
|
|
698
730
|
: rawSummaryRow;
|
|
699
|
-
|
|
731
|
+
// 宽表横向滚动时给合计行留底部安全间距(pb-3),防止横向滚动条腰斩合计行数字
|
|
732
|
+
const summaryRowClass = summary === null ? "" : join(plainRowClass(rowBase), summaryRowBase, scroll ? "relative pb-3" : "", virt !== null ? KIT_TABLE_VIRTUAL.summarySticky : "");
|
|
700
733
|
const rawWrapBase = scroll ? D.tableScrollWrap : sticky ? '' : D.tableWrap;
|
|
701
734
|
const wrapBase = unbordered
|
|
702
|
-
? rawWrapBase
|
|
735
|
+
? kitStripBoundaryClasses(rawWrapBase)
|
|
703
736
|
: rawWrapBase;
|
|
704
737
|
return {
|
|
705
738
|
kind: 'table',
|
|
@@ -765,7 +798,7 @@ export function collection(
|
|
|
765
798
|
const list = `${D.cardsList} ${gridColsClasses(gridLevels(cols))}`;
|
|
766
799
|
const rawCardsItem = D.cardsItem;
|
|
767
800
|
const cardsItem = c.bordered === false
|
|
768
|
-
? rawCardsItem
|
|
801
|
+
? kitStripBoundaryClasses(rawCardsItem)
|
|
769
802
|
: rawCardsItem;
|
|
770
803
|
return {
|
|
771
804
|
kind: 'cards',
|
|
@@ -792,22 +825,22 @@ export function collection(
|
|
|
792
825
|
return {
|
|
793
826
|
kind: 'stack',
|
|
794
827
|
wrapClass: '',
|
|
795
|
-
listClass: mergeClass(D.compactList, mergeClass(c.class ?? '', view.class), view.replaceClass),
|
|
796
|
-
itemClass: mergeClass(D.compactItem, view.rowClass, view.replaceClass),
|
|
828
|
+
listClass: mergeClass(view.paneItem === true ? D.paneList : D.compactList, mergeClass(c.class ?? '', view.class), view.replaceClass),
|
|
829
|
+
itemClass: mergeClass(view.paneItem === true ? D.paneItem : D.compactItem, view.rowClass, view.replaceClass),
|
|
797
830
|
inner,
|
|
798
831
|
rowActions,
|
|
799
832
|
...(itemRowTone !== undefined ? { rowTone: itemRowTone } : {}),
|
|
800
833
|
pager: optionalPagerOf(c.page),
|
|
801
834
|
...countIr,
|
|
802
835
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
803
|
-
...(titleCell !== undefined ? { compact: { title: titleCell, meta: metaCells } } : {}),
|
|
836
|
+
...(titleCell !== undefined ? { compact: { title: titleCell, meta: metaCells, ...(view.paneItem === true ? { pane: true } : {}) } } : {}),
|
|
804
837
|
...ctxMenuIr,
|
|
805
838
|
};
|
|
806
839
|
}
|
|
807
840
|
|
|
808
841
|
const rawStackItem = D.stackItem;
|
|
809
842
|
const stackItem = c.bordered === false
|
|
810
|
-
? rawStackItem
|
|
843
|
+
? kitStripBoundaryClasses(rawStackItem)
|
|
811
844
|
: rawStackItem;
|
|
812
845
|
return {
|
|
813
846
|
kind: 'stack',
|
|
@@ -14,7 +14,7 @@ import { regionMirrorStatePath } from 'soma-core';
|
|
|
14
14
|
import type { SomaScopeDecl, SomaScopeMirrorDecl, SomaScopeSliceDecl } from 'soma-core';
|
|
15
15
|
import { getCompileEnvelope, resolveEnvelopeSubPath } from '../shared/envelope';
|
|
16
16
|
import { KIT_CORE_MAPPING, KIT_FORM_LINKAGE, KIT_GRAMMAR } from './defaults';
|
|
17
|
-
import { hintOf, nameSuggestion } from '../
|
|
17
|
+
import { hintOf, nameSuggestion } from '../shared/hints';
|
|
18
18
|
import { checkFieldRules } from './field-value';
|
|
19
19
|
import { staticOptionsOf } from './linkage';
|
|
20
20
|
import { classifyParamBinding, viewPathToCore } from './view-binding';
|