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
package/src/recipes/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
kitControlSizeRecipe,
|
|
28
28
|
kitButtonEdgeRecipe,
|
|
29
29
|
kitHelpTriggerRecipe,
|
|
30
|
+
kitSegmentRecipe,
|
|
30
31
|
kitTextActionRecipe,
|
|
31
32
|
type KitControlPart,
|
|
32
33
|
type KitControlRecipeOptions,
|
|
@@ -46,6 +47,9 @@ import {
|
|
|
46
47
|
kitContainerEmphasisRecipe,
|
|
47
48
|
kitContainerPartOf,
|
|
48
49
|
kitContainerRecipe,
|
|
50
|
+
KIT_PAIR_BALANCE_CLASS_CANDIDATES,
|
|
51
|
+
kitPairBalanceRecipe,
|
|
52
|
+
type KitPairBalanceClasses,
|
|
49
53
|
kitHighlightRecipe,
|
|
50
54
|
kitShellRecipe,
|
|
51
55
|
kitSlotSurfaceRecipe,
|
|
@@ -84,9 +88,12 @@ import {
|
|
|
84
88
|
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
85
89
|
kitTableCellRecipe,
|
|
86
90
|
kitTableNativeCellRecipe,
|
|
91
|
+
kitTableNativeTrack,
|
|
87
92
|
type KitTableAlign,
|
|
88
93
|
type KitTableCellRecipeOptions,
|
|
89
94
|
type KitTableNativeCellRecipeOptions,
|
|
95
|
+
type KitTableNativeTrack,
|
|
96
|
+
type KitTableNativeTrackColumn,
|
|
90
97
|
type KitTablePart,
|
|
91
98
|
} from './table-row';
|
|
92
99
|
import {
|
|
@@ -143,6 +150,7 @@ export {
|
|
|
143
150
|
kitControlSizeRecipe,
|
|
144
151
|
kitButtonEdgeRecipe,
|
|
145
152
|
kitHelpTriggerRecipe,
|
|
153
|
+
kitSegmentRecipe,
|
|
146
154
|
kitTextActionRecipe,
|
|
147
155
|
kitControlPartOf,
|
|
148
156
|
KIT_CONTROL_RECIPE_CLASS_CANDIDATES,
|
|
@@ -152,6 +160,8 @@ export {
|
|
|
152
160
|
KIT_PART_SECTION,
|
|
153
161
|
KIT_PART_WELL,
|
|
154
162
|
kitContainerRecipe,
|
|
163
|
+
kitPairBalanceRecipe,
|
|
164
|
+
KIT_PAIR_BALANCE_CLASS_CANDIDATES,
|
|
155
165
|
kitContainerPartOf,
|
|
156
166
|
kitSlotSurfaceRecipe,
|
|
157
167
|
kitContainerEmphasisRecipe,
|
|
@@ -180,10 +190,13 @@ export {
|
|
|
180
190
|
KIT_PART_TABLE_CELL,
|
|
181
191
|
kitTableCellRecipe,
|
|
182
192
|
kitTableNativeCellRecipe,
|
|
193
|
+
kitTableNativeTrack,
|
|
183
194
|
KIT_TABLE_NATIVE_CLASS,
|
|
184
195
|
KIT_TABLE_NATIVE_CLASS_CANDIDATES,
|
|
185
196
|
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
186
197
|
type KitTableNativeCellRecipeOptions,
|
|
198
|
+
type KitTableNativeTrack,
|
|
199
|
+
type KitTableNativeTrackColumn,
|
|
187
200
|
// title-row
|
|
188
201
|
KIT_PANEL_TITLE_CLASS,
|
|
189
202
|
KIT_PANEL_TITLE_CLASS_CANDIDATES,
|
|
@@ -208,6 +221,7 @@ export {
|
|
|
208
221
|
};
|
|
209
222
|
|
|
210
223
|
export type {
|
|
224
|
+
KitPairBalanceClasses,
|
|
211
225
|
KitFocusRingKind,
|
|
212
226
|
KitDisabledKind,
|
|
213
227
|
KitSelectedTone,
|
|
@@ -299,6 +313,12 @@ export const KIT_PARTS = Object.freeze({
|
|
|
299
313
|
export type KitPartValue = (typeof KIT_PARTS)[keyof typeof KIT_PARTS];
|
|
300
314
|
|
|
301
315
|
export * from './status';
|
|
316
|
+
export { kitEmphasisButtonRecipe, kitRowActionRecipe, kitStatusPillProps } from './emphasis';
|
|
317
|
+
export * from './table-native-edit';
|
|
318
|
+
export * from './tabs';
|
|
319
|
+
import { KIT_TAB_RECIPE_CLASS_CANDIDATES } from './tabs';
|
|
320
|
+
import { KIT_TABLE_NATIVE_EDIT_SPAN_CLASS_CANDIDATES } from './table-native-edit';
|
|
321
|
+
import { KIT_FRAME_BLEED_CLASS_CANDIDATES } from './frame-bleed';
|
|
302
322
|
|
|
303
323
|
export const KIT_RECIPES_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
304
324
|
KIT_STATUS_RECIPE_CLASS_CANDIDATES,
|
|
@@ -307,6 +327,9 @@ export const KIT_RECIPES_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
|
307
327
|
KIT_CONTAINER_RECIPE_CLASS_CANDIDATES,
|
|
308
328
|
KIT_TYPOGRAPHY_RECIPE_CLASS_CANDIDATES,
|
|
309
329
|
KIT_TABLE_RECIPE_CLASS_CANDIDATES,
|
|
330
|
+
KIT_TABLE_NATIVE_EDIT_SPAN_CLASS_CANDIDATES,
|
|
331
|
+
KIT_FRAME_BLEED_CLASS_CANDIDATES,
|
|
310
332
|
KIT_PANEL_TITLE_CLASS_CANDIDATES,
|
|
311
333
|
KIT_OVERLAY_RECIPE_CLASS_CANDIDATES,
|
|
334
|
+
KIT_TAB_RECIPE_CLASS_CANDIDATES,
|
|
312
335
|
);
|
package/src/recipes/overlay.ts
CHANGED
|
@@ -13,13 +13,44 @@ import { KIT_SURFACE_EDGE_CLASS, kitSurfaceRecipe } from './surface';
|
|
|
13
13
|
/** 对话框面板的表面:浮层级(圆角 xl + hairline 描边 + overlay 底 + 双层阴影 + 高光边,见 recipes/surface.ts);业务浮层壳 / 命令式模态 / 对话框配方共用这一份 */
|
|
14
14
|
export const KIT_DIALOG_SURFACE_CLASS = mergeClass('overflow-hidden', kitSurfaceRecipe('overlay'));
|
|
15
15
|
|
|
16
|
+
/** 抽屉宽度三档(同对话框三档的结构:数字在 kit-limits#overlay.drawerPx 的 narrow / default / wide);小屏下 max-w-full 不超过视口宽 */
|
|
17
|
+
export type KitDrawerWidth = 'narrow' | 'default' | 'wide';
|
|
18
|
+
export const KIT_DRAWER_WIDTHS: readonly KitDrawerWidth[] = Object.freeze(['narrow', 'default', 'wide'] as const);
|
|
19
|
+
|
|
20
|
+
export const KIT_DRAWER_WIDTH_CLASS: Readonly<Record<KitDrawerWidth, string>> = Object.freeze({
|
|
21
|
+
narrow: `w-[${KIT_OVERLAY_LIMITS.drawerPx.narrow}px] max-w-full`,
|
|
22
|
+
default: `w-[${KIT_OVERLAY_LIMITS.drawerPx.default}px] max-w-full`,
|
|
23
|
+
wide: `w-[${KIT_OVERLAY_LIMITS.drawerPx.wide}px] max-w-full`,
|
|
24
|
+
});
|
|
25
|
+
|
|
16
26
|
export const KIT_OVERLAY_WIDTH_CLASS = Object.freeze({
|
|
17
27
|
dialog: `max-w-[${KIT_OVERLAY_LIMITS.dialogPx.default}px]`,
|
|
18
28
|
dialogWide: `max-w-[${KIT_OVERLAY_LIMITS.dialogPx.wide}px]`,
|
|
19
29
|
dialogXWide: `max-w-[${KIT_OVERLAY_LIMITS.dialogPx.xwide}px]`,
|
|
20
|
-
drawer:
|
|
30
|
+
drawer: KIT_DRAWER_WIDTH_CLASS.default,
|
|
31
|
+
drawerNarrow: KIT_DRAWER_WIDTH_CLASS.narrow,
|
|
32
|
+
drawerWide: KIT_DRAWER_WIDTH_CLASS.wide,
|
|
21
33
|
});
|
|
22
34
|
|
|
35
|
+
/** 对话框宽度档名(页面 DSL 的 kind: dialog 的 width;档位与像素读 kit-limits#overlay.dialogPx:default 480 / wide 720 / xwide 960) */
|
|
36
|
+
export const KIT_DIALOG_WIDTH_TIERS: readonly string[] = Object.freeze(Object.keys(KIT_OVERLAY_LIMITS.dialogPx));
|
|
37
|
+
export function isKitDialogWidth(value: unknown): value is 'default' | 'wide' | 'xwide' {
|
|
38
|
+
return typeof value === 'string' && KIT_DIALOG_WIDTH_TIERS.includes(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 是抽屉宽度档名(命令式选项与页面 DSL 共用的判据) */
|
|
42
|
+
export function isKitDrawerWidth(value: unknown): value is KitDrawerWidth {
|
|
43
|
+
return typeof value === 'string' && (KIT_DRAWER_WIDTHS as readonly string[]).includes(value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 抽屉面板类串(命令式 mountKitDrawer 与页面 DSL 的抽屉外壳共用一份):贴 end 侧的纵向 flex 列(头 / 底栏 shrink-0、体滚动由调用方的体子配方给),
|
|
48
|
+
* 表面是浮层级贴边表面(kitSurfaceRecipe('overlay') 的无圆角对应物),进场从 end 侧滑入(RTL 自动换向),宽度三档。
|
|
49
|
+
*/
|
|
50
|
+
export function kitDrawerPanelClass(width: KitDrawerWidth = 'default'): string {
|
|
51
|
+
return `flex h-full ${KIT_DRAWER_WIDTH_CLASS[width]} flex-col overflow-hidden border-s border-border-container ${KIT_SURFACE_EDGE_CLASS} motion-safe:animate-kit-drawer-in-end rtl:motion-safe:animate-kit-drawer-in-start`;
|
|
52
|
+
}
|
|
53
|
+
|
|
23
54
|
export const KIT_PART_DIALOG = 'dialog' as const;
|
|
24
55
|
export const KIT_PART_DRAWER = 'drawer' as const;
|
|
25
56
|
export const KIT_PART_POPOVER = 'popover' as const;
|
|
@@ -173,6 +204,19 @@ export function kitOverlayBodyRecipe(): string {
|
|
|
173
204
|
return OVERLAY_BODY_CLASS;
|
|
174
205
|
}
|
|
175
206
|
|
|
207
|
+
/**
|
|
208
|
+
* 命令式抽屉(mountKitDrawer)的内容区子配方:浮层主体(独立滚动区)+ 纵向间距 + 正文字号 / 辅助色。
|
|
209
|
+
* 与页面 DSL 的抽屉外壳不同,命令式抽屉的 body 由调用方塞内容,这里给内容的默认排版。
|
|
210
|
+
*/
|
|
211
|
+
export function kitDrawerContentRecipe(): string {
|
|
212
|
+
return mergeClass(OVERLAY_BODY_CLASS, 'gap-3 text-sm text-fg-muted');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** 命令式抽屉面板的焦点处理:面板自己(tabindex -1)获得焦点时不画轮廓,焦点环只给内部可操作元素 */
|
|
216
|
+
export function kitDrawerFocusRecipe(): string {
|
|
217
|
+
return 'focus-visible:outline-none';
|
|
218
|
+
}
|
|
219
|
+
|
|
176
220
|
/**
|
|
177
221
|
* 浮层尾部子配方(固定底部操作栏 shrink-0,不随主体滚动)。
|
|
178
222
|
*/
|
|
@@ -222,6 +266,7 @@ export const KIT_OVERLAY_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandi
|
|
|
222
266
|
TOAST_TONED_SKELETON_CLASS,
|
|
223
267
|
Object.values(DIALOG_SIZE_CLASS),
|
|
224
268
|
Object.values(DRAWER_SIZE_CLASS),
|
|
269
|
+
KIT_DRAWER_WIDTHS.map((w) => kitDrawerPanelClass(w)),
|
|
225
270
|
Object.values(POPOVER_SIZE_CLASS),
|
|
226
271
|
Object.values(TOAST_SIZE_CLASS),
|
|
227
272
|
OVERLAY_HEADER_CLASS,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// 占位配方(placeholder.ts):骨架屏占位条 / 骨架行与卡 / 集合空态盒的类串(G101:圆角、边框色、字阶等受控类只在 recipes/)。
|
|
2
2
|
// 全部是整串字面量,调用方整串取用,不拆 token 回捞。
|
|
3
3
|
|
|
4
|
+
import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
|
|
4
5
|
import { mergeClass } from '../object-renderer/merge-class';
|
|
5
|
-
import {
|
|
6
|
+
import { kitShellRecipe } from './container';
|
|
7
|
+
import { kitControlRecipe, kitTextActionRecipe } from './control';
|
|
6
8
|
import { kitTypographyRecipe } from './typography';
|
|
7
9
|
|
|
8
10
|
export const KIT_SKELETON_BAR_BASE = 'rounded-md bg-surface-sunken motion-safe:animate-kit-pulse';
|
|
@@ -39,7 +41,14 @@ export const KIT_SKELETON_SINGLE_PAIR = 'flex flex-col gap-1';
|
|
|
39
41
|
export const KIT_LOADING_HELD_ATTR = 'data-kit-loading-held';
|
|
40
42
|
export const KIT_STATE_LOADING_BOX ='flex items-center justify-center py-5 text-sm text-fg-muted';
|
|
41
43
|
export const KIT_STATE_ERROR_BOX = 'flex flex-wrap items-center justify-center gap-x-3 gap-y-1 py-5 text-center text-sm text-danger-on-soft';
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* 空态只有两种口径(取代原来的 BOX / COMPACT / 集合三种写法):
|
|
46
|
+
* · 集合内空态 EMPTY_BOX(表格、列表、主从右栏、面板内、各数据组件):一行标题 + 至多一个操作,无插画、无框,总高 <= 真源 structure.emptyState.maxHeightPx(88);
|
|
47
|
+
* · 整页 / 首次使用空态 EMPTY_PAGE:才带插画,标题 + 一行说明 + 至多一个操作。
|
|
48
|
+
*/
|
|
49
|
+
// 2026-11-21:收成紧凑一行——左对齐(落在所在面板的文字轴上)、上下内边距取真源 structure.emptyState.padYUnits,不保留主体高度
|
|
50
|
+
export const KIT_STATE_EMPTY_BOX = `flex flex-wrap items-center justify-start gap-x-3 gap-y-1 py-${KIT_NINE_DIM.structure.emptyState.padYUnits} text-left text-sm text-fg-muted`;
|
|
51
|
+
export const KIT_STATE_EMPTY_PAGE = 'flex flex-col items-center justify-center gap-2 py-12 text-center text-sm text-fg-muted';
|
|
43
52
|
|
|
44
53
|
/**
|
|
45
54
|
* 三态面板新增三态(未就绪 / 上游断供 / 无权限)的盒与重试钮尾:
|
|
@@ -50,6 +59,13 @@ export const KIT_STATE_EMPTY_COMPACT = 'py-4 text-center text-sm text-fg-subtle'
|
|
|
50
59
|
export const KIT_STATE_NOT_READY_BOX = 'flex flex-col items-center justify-center gap-1 py-5 text-center text-sm text-fg-muted';
|
|
51
60
|
export const KIT_STATE_UPSTREAM_BOX = 'flex flex-wrap items-center justify-center gap-x-3 gap-y-1 py-5 text-center text-sm text-warning-on-soft';
|
|
52
61
|
export const KIT_STATE_DENIED_BOX = 'flex flex-col items-center justify-center gap-1 py-5 text-center text-sm text-fg-muted';
|
|
62
|
+
/**
|
|
63
|
+
* 整页无权访问(KitAccessGate):页面框整块隐藏后唯一可见的状态,按空状态同一套规则呈现——
|
|
64
|
+
* 在页面边距内的一张面板里水平垂直居中(宿主 WRAP 给页边距,面板取面板配方),标题 + 一句说明两级字号,标题不带句号,不加图标 / 插画。
|
|
65
|
+
*/
|
|
66
|
+
export const KIT_STATE_DENIED_WRAP = 'px-page pt-page';
|
|
67
|
+
export const KIT_STATE_DENIED_PAGE = mergeClass(kitShellRecipe(), 'flex flex-col items-center justify-center gap-2 py-24 text-center text-sm text-fg-muted');
|
|
68
|
+
export const KIT_STATE_DENIED_TITLE = kitTypographyRecipe('sectionTitle');
|
|
53
69
|
|
|
54
70
|
export type KitRetryTone = 'neutral' | 'danger' | 'warning';
|
|
55
71
|
|
|
@@ -72,8 +88,8 @@ export const KIT_STATE_RETRY_CLASS_CANDIDATES: readonly string[] = Object.freeze
|
|
|
72
88
|
[kitRetryRecipe('neutral'), kitRetryRecipe('danger'), kitRetryRecipe('warning')].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')),
|
|
73
89
|
);
|
|
74
90
|
|
|
75
|
-
/**
|
|
76
|
-
export const
|
|
91
|
+
/** 空态里的操作(「清除筛选」/ 页面主操作同名入口):文字操作形态,与行内文字操作同一配方 */
|
|
92
|
+
export const KIT_STATE_EMPTY_ACTION = kitTextActionRecipe('primary');
|
|
77
93
|
/** 三态块里的标题(半粗正文色)与说明(次要色):字阶取自文字配方 */
|
|
78
94
|
export const KIT_STATE_TITLE_CLASS = kitTypographyRecipe('bodyStrong');
|
|
79
95
|
export const KIT_STATE_DESC_CLASS = kitTypographyRecipe('muted');
|
package/src/recipes/rail-grid.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// 调用方在类串里显式写 grid-cols-* / @md:grid-cols-* 时以类串为准(层内规则弱于无层工具类)。
|
|
9
9
|
|
|
10
10
|
import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
|
|
11
|
+
import { markKitEdge } from './surface-edge';
|
|
11
12
|
|
|
12
13
|
/** 导轨拼合容器标记 */
|
|
13
14
|
export const KIT_RAIL_ATTR = 'data-kit-rail';
|
|
@@ -32,6 +33,8 @@ export function kitRailGridRecipe(): KitRailGridRecipe {
|
|
|
32
33
|
/** 给容器打导轨标记(幂等) */
|
|
33
34
|
export function markKitRail(el: Element): void {
|
|
34
35
|
if (!el.hasAttribute(KIT_RAIL_ATTR)) el.setAttribute(KIT_RAIL_ATTR, '');
|
|
36
|
+
// 导轨容器自带外圈:处在面板内时由 surface-edge 规则去掉,只留块间细线
|
|
37
|
+
markKitEdge(el);
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
/** 取值(真源 structure.railGrid):只读投影,供测试与调用方核对,不在这里另写数字 */
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// 统计块三态配方(stat-state.ts):StatGroup 单项的 ready / missing / error 呈现。
|
|
2
|
+
//
|
|
3
|
+
// 状态由数据给(页面不写逻辑);本文件只做「状态词 -> 外观」的对照。取值(占位文字、每个非 ready 态的语义色、
|
|
4
|
+
// 同组原因相同时提到组级的最少项数)只在真源 soma-design 的 kit-limits#statStates(生成投影 KIT_STAT_STATES),这里不写取值:
|
|
5
|
+
// · 缺失项主位只显示「—」(次级色);原因是辅助色小字,不画圆圈 / 图标类标记;
|
|
6
|
+
// · 同一组里多项缺失 / 出错且原因相同(达到 groupReasonMin)时,原因只在组底写一次(组级说明行),各项只留「—」;
|
|
7
|
+
// · 重试 = 行内文字钮(kitTextActionRecipe),与整块可点分属两个目标;组级说明行带一个重试入口。
|
|
8
|
+
|
|
9
|
+
import { KIT_STAT_STATES } from 'soma-foundation/kit-limits';
|
|
10
|
+
import { classCandidates } from '../base/class-candidates';
|
|
11
|
+
import { kitTextActionRecipe } from './control';
|
|
12
|
+
|
|
13
|
+
export type KitStatState = 'ready' | 'missing' | 'error';
|
|
14
|
+
type KitStatNonReady = Exclude<KitStatState, 'ready'>;
|
|
15
|
+
type KitStatTone = 'neutral' | 'warning' | 'danger';
|
|
16
|
+
|
|
17
|
+
const PRESENTATION = KIT_STAT_STATES.presentation as unknown as Readonly<Record<KitStatNonReady, { tone: KitStatTone }>>;
|
|
18
|
+
|
|
19
|
+
/** 缺失态主数值位的占位文字(真源 kit-limits#statStates.placeholder) */
|
|
20
|
+
export const KIT_STAT_PLACEHOLDER: string = KIT_STAT_STATES.placeholder as string;
|
|
21
|
+
/** 同组原因相同的非 ready 项达到这个数,原因提到组级(真源 kit-limits#statStates.groupReasonMin) */
|
|
22
|
+
export const KIT_STAT_GROUP_REASON_MIN: number = KIT_STAT_STATES.groupReasonMin as number;
|
|
23
|
+
|
|
24
|
+
/** 状态词归一:只认 missing / error,其余(含空、gap / unknown 旧词)一律 ready 由原有逻辑处理 */
|
|
25
|
+
export function statStateOf(raw: unknown): KitStatState {
|
|
26
|
+
return raw === 'missing' || raw === 'error' ? raw : 'ready';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 警告语气的指标名前圆点(图形标记,aria-hidden;数字本身不着色,彩色大号文字不用警告色,评审 §1.2) */
|
|
30
|
+
export const KIT_STAT_WARN_DOT_CLASS = 'me-1.5 inline-block h-1.5 w-1.5 rounded-full bg-warning align-middle';
|
|
31
|
+
|
|
32
|
+
/** 状态行:原因文字单行;min-w-0 让原因在窄块里截断 */
|
|
33
|
+
export const KIT_STAT_STATE_ROW = 'flex min-w-0 items-center gap-1.5 text-xs';
|
|
34
|
+
/** 原因文字:单行截断(悬停 / 聚焦被截断时由 hint-tips 挂全文气泡,作用范围由行上的 data-kit-tips 标出) */
|
|
35
|
+
export const KIT_STAT_STATE_REASON = 'min-w-0 truncate';
|
|
36
|
+
/** 组级说明行:统计组底部一行,原因全文(可换行,不截断)+ 重试入口 */
|
|
37
|
+
export const KIT_STAT_GROUP_NOTE = 'flex flex-wrap items-center gap-x-3 gap-y-1 px-1 pt-2 text-xs';
|
|
38
|
+
|
|
39
|
+
const TEXT_TONE: Readonly<Record<KitStatTone, string>> = Object.freeze({
|
|
40
|
+
neutral: 'text-fg-muted',
|
|
41
|
+
warning: 'text-warning-on-soft',
|
|
42
|
+
danger: 'text-danger-on-soft',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/** 状态原因行的类(含语义色文字) */
|
|
46
|
+
export function kitStatStateRowClass(state: KitStatNonReady): string {
|
|
47
|
+
return `${KIT_STAT_STATE_ROW} ${TEXT_TONE[PRESENTATION[state].tone]}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 组级说明行的类(含语义色文字;同一行里 missing 与 error 分行,各自取色) */
|
|
51
|
+
export function kitStatGroupNoteClass(state: KitStatNonReady): string {
|
|
52
|
+
return `${KIT_STAT_GROUP_NOTE} ${TEXT_TONE[PRESENTATION[state].tone]}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 重试钮:行内文字钮 */
|
|
56
|
+
export const KIT_STAT_RETRY_CLASS = kitTextActionRecipe('primary');
|
|
57
|
+
|
|
58
|
+
/** StatGroup 三态自带的全部类(并入 StatGroup 候选) */
|
|
59
|
+
export const KIT_STAT_STATE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
60
|
+
KIT_STAT_STATE_ROW,
|
|
61
|
+
KIT_STAT_STATE_REASON,
|
|
62
|
+
KIT_STAT_GROUP_NOTE,
|
|
63
|
+
Object.values(TEXT_TONE),
|
|
64
|
+
KIT_STAT_RETRY_CLASS,
|
|
65
|
+
);
|
package/src/recipes/state.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// 统一采用单一焦点环(消除双环与非预期蓝色轮廓;高对比度模式由 kit-theme.tpl @media (forced-colors: active) 保底);
|
|
3
3
|
// 统一采用禁用态透明度(opacity-60),去掉架空 cursor-not-allowed 的指针事件阻断类。
|
|
4
4
|
|
|
5
|
+
import { controlDisabled, controlFocus, controlInvalid } from 'soma-foundation/kit-control';
|
|
5
6
|
import { classCandidates } from '../base/class-candidates';
|
|
6
7
|
|
|
7
8
|
export type KitFocusRingKind = 'control' | 'button' | 'item';
|
|
@@ -10,26 +11,16 @@ export type KitSelectedTone = 'primary' | 'subtle';
|
|
|
10
11
|
|
|
11
12
|
// 焦点环 = 实心描边(G82 判它 ≥ 3:1:控件 1px 主色描边 + ring-1、按钮 / 条目 2px 环,宽度见真源 structure.focusRing)
|
|
12
13
|
// + 外侧柔和外晕(shadow-focus-halo*,主色低透明度,纯装饰,不判对比度;外晕半径 = 环宽 + structure.stateLayer.focusHaloPx)。
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
control:
|
|
24
|
-
'disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60',
|
|
25
|
-
button:
|
|
26
|
-
'disabled:cursor-not-allowed disabled:opacity-60',
|
|
27
|
-
text:
|
|
28
|
-
'cursor-not-allowed text-fg-subtle opacity-60',
|
|
29
|
-
// 带原因的置灰(只留 aria-disabled、不用原生 disabled,保持可聚焦):伪类 disabled: 不生效,直接写静态类
|
|
30
|
-
aria:
|
|
31
|
-
'cursor-not-allowed opacity-60',
|
|
32
|
-
});
|
|
14
|
+
// 焦点环(按宿主)、禁用态(专用令牌 + 统一透明度,带原因的置灰用静态类 aria)、错误态的类集合都在 soma-design/spec/pipeline/kit-control.json,
|
|
15
|
+
// 求解在 soma-foundation/kit-control;本文件只给出口,不写字面。
|
|
16
|
+
const FOCUS_RING_KINDS: readonly KitFocusRingKind[] = Object.freeze(['control', 'button', 'item']);
|
|
17
|
+
const DISABLED_KINDS: readonly KitDisabledKind[] = Object.freeze(['control', 'button', 'text', 'aria']);
|
|
18
|
+
const FOCUS_RING_MAP: Readonly<Record<KitFocusRingKind, string>> = Object.freeze(
|
|
19
|
+
Object.fromEntries(FOCUS_RING_KINDS.map((k) => [k, controlFocus(k).join(' ')])) as Record<KitFocusRingKind, string>,
|
|
20
|
+
);
|
|
21
|
+
const DISABLED_MAP: Readonly<Record<KitDisabledKind, string>> = Object.freeze(
|
|
22
|
+
Object.fromEntries(DISABLED_KINDS.map((k) => [k, controlDisabled(k).join(' ')])) as Record<KitDisabledKind, string>,
|
|
23
|
+
);
|
|
33
24
|
|
|
34
25
|
const SELECTED_MAP: Readonly<Record<KitSelectedTone, string>> = Object.freeze({
|
|
35
26
|
// 选中 = 主色状态层(真源 structure.stateLayer.selectedPct,8%),文字 primary-on-soft 余量只增不减
|
|
@@ -37,8 +28,7 @@ const SELECTED_MAP: Readonly<Record<KitSelectedTone, string>> = Object.freeze({
|
|
|
37
28
|
subtle: 'bg-surface-sunken text-fg font-medium',
|
|
38
29
|
});
|
|
39
30
|
|
|
40
|
-
const INVALID_CLASS =
|
|
41
|
-
'border-danger focus-visible:border-danger focus-visible:ring-danger focus-within:border-danger focus-within:ring-danger';
|
|
31
|
+
const INVALID_CLASS = controlInvalid(true).join(' ');
|
|
42
32
|
|
|
43
33
|
/**
|
|
44
34
|
* 焦点环配方:统一使用单一焦点环,消除双焦点指示。
|
package/src/recipes/status.ts
CHANGED
|
@@ -54,6 +54,9 @@ export const KIT_TAG_UNKNOWN_DOT_CORE = 'relative inline-flex h-full w-full roun
|
|
|
54
54
|
|
|
55
55
|
// ── NoticeList ────────────────────────────────────────────────
|
|
56
56
|
|
|
57
|
+
/** 状态徽标(浅底 + on-soft 字 + 6px 圆点):卡片头部 / 条目列表里带语气的状态与表格、紧凑列表同一种呈现(emphasis.status = pill);底色字色(TONE_SOFT)与圆点色(bg-<tone>)由语气另给 */
|
|
58
|
+
export const KIT_STATUS_BADGE_CLASS = 'inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5 text-xs font-medium';
|
|
59
|
+
export const KIT_STATUS_DOT_CLASS = 'size-1.5 shrink-0 rounded-full';
|
|
57
60
|
export const KIT_NOTICE_BOX = 'flex flex-col gap-2 rounded-lg border border-border-subtle bg-surface-raised px-4 py-3';
|
|
58
61
|
export const KIT_NOTICE_TITLE = 'm-0 text-xs font-semibold text-fg-muted';
|
|
59
62
|
export const KIT_NOTICE_LIST = 'm-0 flex list-none flex-col gap-2 p-0';
|
|
@@ -80,6 +83,9 @@ export const KIT_NOTICE_TIME = 'text-xs font-normal text-fg-subtle tabular-nums'
|
|
|
80
83
|
export const KIT_NOTICE_ACTION = mergeClass(kitFocusRingRecipe('item'), 'rounded-sm text-xs font-medium text-primary-on-soft underline underline-offset-2 hover:opacity-80');
|
|
81
84
|
export const KIT_NOTICE_TOGGLE = mergeClass(kitFocusRingRecipe('button'), 'self-start rounded-sm text-xs font-medium text-primary-on-soft hover:opacity-80');
|
|
82
85
|
export const KIT_NOTICE_SR_ONLY = 'sr-only';
|
|
86
|
+
/** 页脚形态(作为宿主面板的页脚,footer: true):无自己的面与边、不加内边距;折叠开关用次级色,不抢面板主体 */
|
|
87
|
+
export const KIT_NOTICE_BOX_FOOTER = 'flex flex-col gap-2';
|
|
88
|
+
export const KIT_NOTICE_TOGGLE_FOOTER = mergeClass(kitFocusRingRecipe('button'), 'self-start rounded-sm text-xs font-medium text-fg-muted hover:text-fg');
|
|
83
89
|
|
|
84
90
|
// ── StatGroup 项扩展(语气 / 多值 / 缺口 / 标记)────────────────
|
|
85
91
|
|
|
@@ -129,6 +135,8 @@ export const KIT_NOTICE_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandid
|
|
|
129
135
|
KIT_NOTICE_ACTION,
|
|
130
136
|
KIT_NOTICE_TOGGLE,
|
|
131
137
|
KIT_NOTICE_SR_ONLY,
|
|
138
|
+
KIT_NOTICE_BOX_FOOTER,
|
|
139
|
+
KIT_NOTICE_TOGGLE_FOOTER,
|
|
132
140
|
);
|
|
133
141
|
|
|
134
142
|
export const KIT_STATUS_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// 数据组件的外框标记(surface-edge.ts):表面层级的通用规则,按层级标记判定、不逐组件写特例。
|
|
2
|
+
//
|
|
3
|
+
// 规则:数据组件自带外圈(描边 / 圆角 / 阴影)只在「独立放在画布上」时才有面;处在面板里(祖先有 data-kit-layer 且不是 0 的画布层)时,
|
|
4
|
+
// 外圈由面板给,数据组件自己不再画第二圈(卡中卡),只保留内部细线。
|
|
5
|
+
// 做法:数据组件在自己的外框元素上标 data-kit-edge(本文件的 markKitEdge),样式在 theme/nine-dim-structure.ts 的「载体与布局构件」规则
|
|
6
|
+
// (carrierRules:`[data-kit-layer]:not([data-kit-layer="0"]) [data-kit-edge]`),这里不写数字、不写类。
|
|
7
|
+
// 与「嵌套面板去第二圈描边」(layerRules 的层 ≥ nested.fromLayer 把容器边界令牌归 transparent)同一意图,区别是它只认标了 data-kit-layer 的表面容器,
|
|
8
|
+
// 数据组件的外框(div + 工具类 / 导轨容器)不是表面容器、不被它覆盖,所以由这条规则按「祖先是面板」补齐。
|
|
9
|
+
|
|
10
|
+
/** 数据组件外框标记 */
|
|
11
|
+
export const KIT_EDGE_ATTR = 'data-kit-edge';
|
|
12
|
+
|
|
13
|
+
/** 给数据组件的外框元素打标记(幂等) */
|
|
14
|
+
export function markKitEdge(el: Element): void {
|
|
15
|
+
if (!el.hasAttribute(KIT_EDGE_ATTR)) el.setAttribute(KIT_EDGE_ATTR, '');
|
|
16
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// 表格缺失值的呈现配方与原生表格出口(数字与约定读 design 真源 kit-limits#tableGap,经 soma-foundation/kit-limits)。
|
|
2
|
+
//
|
|
3
|
+
// 规则(一个概念一种表达):
|
|
4
|
+
// · 数据约定:缺失用 `null`,原因放同行的 `<字段>_reason`(后缀读真源);字段与原因字段都在 schema 里声明;
|
|
5
|
+
// · 零散缺失:单元格只显示「—」(次级色),原因走悬停提示(GapValue 的 plain 形态);
|
|
6
|
+
// · 整列同因(全部缺失,或缺失比例 ≥ 阈值且缺失项原因相同):单元格仍只显示「—」,原因在列头旁写一次(次级标注);
|
|
7
|
+
// · 集合表由 `KitTableGap`(静态表头)/ `KitTableHead`(可排序表头)接管列头标注;原生 `<table>` 用本文件的 `kitTableGapCell` / `kitTableGapHeadNote`。
|
|
8
|
+
|
|
9
|
+
import { KIT_TABLE_GAP } from 'soma-foundation/kit-limits';
|
|
10
|
+
import { analyzeTableGaps, isTableValueMissing, tableGapReasonField, type TableGapColumn } from 'soma-foundation/arrange/table';
|
|
11
|
+
import { classCandidates } from '../base/class-candidates';
|
|
12
|
+
|
|
13
|
+
export { KIT_TABLE_GAP, analyzeTableGaps, isTableValueMissing, tableGapReasonField };
|
|
14
|
+
export type { TableGapColumn };
|
|
15
|
+
|
|
16
|
+
/** 缺失占位短横:次级色,不占行高 */
|
|
17
|
+
export const KIT_TABLE_GAP_MARK = 'text-sm font-normal text-fg-muted';
|
|
18
|
+
/** 列头旁的原因标注:次级色小字,不加粗(列头字重 600 不继承) */
|
|
19
|
+
export const KIT_TABLE_GAP_NOTE = 'ms-1.5 text-xs font-normal text-fg-muted';
|
|
20
|
+
|
|
21
|
+
export const KIT_TABLE_GAP_CLASS_CANDIDATES: readonly string[] = classCandidates(KIT_TABLE_GAP_MARK, KIT_TABLE_GAP_NOTE);
|
|
22
|
+
|
|
23
|
+
/** 列头旁标注的节点标记(KitTableGap / KitTableHead 写、渲染判定读) */
|
|
24
|
+
export const KIT_TABLE_GAP_NOTE_ATTR = 'data-kit-gap-note';
|
|
25
|
+
/** 表头格上的字段标记(只给有缺失原因约定的列写;标注接线按它找格) */
|
|
26
|
+
export const KIT_TABLE_GAP_HEAD_ATTR = 'data-kit-head-field';
|
|
27
|
+
|
|
28
|
+
/** 一个原生表格单元格的缺失呈现:`missing` 为 false 时 text 是原值文字,调用方照常渲染 */
|
|
29
|
+
export interface KitTableGapCell {
|
|
30
|
+
readonly missing: boolean;
|
|
31
|
+
/** 缺失时 = 占位短横;否则空串(调用方自己渲染值) */
|
|
32
|
+
readonly text: string;
|
|
33
|
+
/** 缺失时的悬停提示(零散缺失的逐格原因;整列同因时为空,原因在列头);用作 `title` / 提示气泡文字 */
|
|
34
|
+
readonly title: string;
|
|
35
|
+
/** 缺失时的类串(次级色);否则空串 */
|
|
36
|
+
readonly className: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 原生表格出口:给一行、一个字段、该列的判定(`analyzeTableGaps(rows, fields)` 的对应项),返回该格的缺失呈现。
|
|
41
|
+
* 非缺失 → `{ missing: false }`;缺失 → 短横 + 逐格原因(整列同因时不带原因)。
|
|
42
|
+
*/
|
|
43
|
+
export function kitTableGapCell(row: unknown, field: string, column?: TableGapColumn): KitTableGapCell {
|
|
44
|
+
const rec = row !== null && typeof row === 'object' ? row as Record<string, unknown> : {};
|
|
45
|
+
if (!isTableValueMissing(rec[field])) return { missing: false, text: '', title: '', className: '' };
|
|
46
|
+
const why = rec[tableGapReasonField(field)];
|
|
47
|
+
const reason = typeof why === 'string' ? why.trim() : '';
|
|
48
|
+
return {
|
|
49
|
+
missing: true,
|
|
50
|
+
text: KIT_TABLE_GAP.marker,
|
|
51
|
+
title: column?.mode === 'column' ? '' : reason,
|
|
52
|
+
className: KIT_TABLE_GAP_MARK,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 原生表格出口:列头旁的整列原因标注文字(整列同因且有原因才有;否则 null,不写标注) */
|
|
57
|
+
export function kitTableGapHeadNote(column: TableGapColumn): { text: string; className: string } | null {
|
|
58
|
+
if (column.mode !== 'column' || column.reason === '') return null;
|
|
59
|
+
return { text: `· ${column.reason}`, className: KIT_TABLE_GAP_NOTE };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 把整列原因标注画到表头格里(集合表的 KitTableGap / KitTableHead 共用):先摘掉旧标注,整列同因再追加一条。
|
|
64
|
+
* `scope` 内按 `data-kit-head-field` 找格;找不到格就跳过。
|
|
65
|
+
*/
|
|
66
|
+
export function paintTableGapNotes(scope: ParentNode, columns: readonly TableGapColumn[]): void {
|
|
67
|
+
const cells = Array.from(scope.querySelectorAll<HTMLElement>(`[${KIT_TABLE_GAP_HEAD_ATTR}]`));
|
|
68
|
+
for (const c of columns) {
|
|
69
|
+
const cell = cells.find((x) => x.getAttribute(KIT_TABLE_GAP_HEAD_ATTR) === c.field);
|
|
70
|
+
if (cell === undefined) continue;
|
|
71
|
+
cell.querySelectorAll(`[${KIT_TABLE_GAP_NOTE_ATTR}]`).forEach((n) => n.remove());
|
|
72
|
+
const note = kitTableGapHeadNote(c);
|
|
73
|
+
if (note === null) continue;
|
|
74
|
+
const el = cell.ownerDocument.createElement('span');
|
|
75
|
+
el.setAttribute(KIT_TABLE_GAP_NOTE_ATTR, '');
|
|
76
|
+
el.className = note.className;
|
|
77
|
+
el.textContent = note.text;
|
|
78
|
+
cell.appendChild(el);
|
|
79
|
+
}
|
|
80
|
+
}
|