soma-kit 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/spec/generated/kit-app.schema.json +14 -0
- package/spec/generated/kit-page.schema.json +25 -0
- package/spec/kit-grammar.json +178 -27
- package/spec/kit-grammar.schema.json +1 -3
- package/src/app/app-config.ts +10 -4
- package/src/app/index.ts +13 -1
- package/src/app/kit-view-context.ts +19 -2
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/base/button.ts +5 -3
- package/src/base/end-edge.ts +14 -2
- package/src/base/gap-value.ts +24 -4
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +5 -0
- package/src/base/menu-button.ts +10 -23
- package/src/base/popover.ts +5 -4
- package/src/base/segmented.ts +14 -4
- package/src/base/shared.ts +11 -13
- package/src/base/state-panel.ts +34 -13
- package/src/base/tag.ts +18 -13
- package/src/base/text.ts +1 -1
- package/src/base/upload.ts +5 -4
- package/src/biz/approval-desk/shell.ts +8 -7
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +3 -2
- package/src/biz/category-crud/shell.ts +4 -3
- package/src/biz/checkout-page/shell.ts +9 -8
- package/src/biz/compose.ts +2 -2
- package/src/biz/data-components.ts +4 -0
- package/src/biz/import-wizard/shell.ts +12 -10
- package/src/biz/landing-page/shell.ts +2 -2
- package/src/biz/master-sub/compile.ts +114 -15
- package/src/biz/master-sub/detail-head.ts +61 -0
- package/src/biz/master-sub/index.ts +3 -2
- package/src/biz/master-sub/shell.ts +95 -63
- package/src/biz/multi-board/compile.ts +164 -9
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +1 -1
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +91 -23
- package/src/biz/notification-center/shell.ts +6 -5
- package/src/biz/page-templates/domain-templates.ts +2 -2
- package/src/biz/page-templates/result-page/shell.ts +2 -2
- package/src/biz/page-templates/sign-in-page/shell.ts +14 -14
- package/src/biz/record-detail/shell.ts +8 -7
- package/src/biz/settings-center/shell.ts +8 -7
- package/src/biz/shared/compile-helpers.ts +82 -3
- package/src/biz/shared/overlay-compile.ts +46 -4
- package/src/biz/shared/overlay-shell.ts +8 -6
- package/src/biz/single-form/shell.ts +6 -4
- package/src/biz/standard-crud/compile.ts +14 -1
- package/src/biz/standard-crud/shell.ts +18 -27
- package/src/biz/standard-crud/summary.ts +40 -0
- package/src/biz/step-form/shell.ts +11 -9
- package/src/biz/types.ts +6 -1
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/compile-page.ts +15 -4
- package/src/compile/component-candidates.ts +2 -0
- package/src/compile/fragment.ts +11 -0
- package/src/compile/layout-lint/rules-composition.ts +55 -6
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +189 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/styles.ts +11 -1
- package/src/compile/types.ts +3 -1
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +3 -1
- package/src/data/approval-flow.ts +4 -1
- package/src/data/assignment-picker.ts +9 -4
- package/src/data/async-result-panel.ts +1 -1
- package/src/data/calendar.ts +7 -2
- package/src/data/carousel.ts +2 -0
- package/src/data/chart.ts +609 -42
- package/src/data/checklist.ts +4 -1
- package/src/data/comment-thread.ts +2 -1
- package/src/data/confirm-dialog.ts +4 -10
- package/src/data/field-mapper.ts +4 -1
- package/src/data/flow-editor.ts +2 -1
- package/src/data/footer.ts +2 -0
- package/src/data/gantt.ts +187 -25
- package/src/data/hero.ts +2 -0
- package/src/data/index.ts +10 -3
- package/src/data/item-list.ts +10 -3
- package/src/data/kanban.ts +3 -1
- package/src/data/matrix.ts +391 -0
- package/src/data/menu.ts +23 -11
- package/src/data/mockup.ts +3 -3
- package/src/data/modal-dialog.ts +118 -18
- package/src/data/navbar.ts +3 -1
- package/src/data/notice-list.ts +52 -19
- package/src/data/object-form.ts +128 -112
- package/src/data/pager.ts +3 -2
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +4 -1
- package/src/data/permission-tree.ts +6 -2
- package/src/data/pricing-table.ts +2 -1
- package/src/data/record-card.ts +18 -6
- package/src/data/resident.ts +8 -0
- package/src/data/row-editor.ts +2 -2
- package/src/data/rule-builder.ts +9 -4
- package/src/data/shape-util.ts +15 -14
- package/src/data/stat-group.ts +313 -69
- package/src/data/static-lazy.ts +4 -0
- package/src/data/static-registry.ts +6 -0
- package/src/data/survey.ts +4 -1
- package/src/data/system-switcher.ts +2 -1
- package/src/data/tour-guide.ts +2 -1
- package/src/data/transfer.ts +6 -2
- package/src/data/tree-table.ts +7 -5
- package/src/data/tree.ts +1 -1
- package/src/data/virtual-rows.ts +5 -4
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +1 -0
- package/src/frames/list-summary.ts +100 -0
- package/src/frames/page-bar.ts +6 -14
- package/src/frames/shared.ts +20 -4
- package/src/frames/tabs-frame/shell.ts +8 -6
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +3 -1
- package/src/frames/workspace-frame/shell.ts +2 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +41 -25
- package/src/generated/kit-grammar-runtime.ts +175 -28
- package/src/i18n/kit-text.ts +27 -0
- package/src/object-renderer/action-group.ts +139 -0
- package/src/object-renderer/action-more.ts +144 -0
- package/src/object-renderer/arrange.ts +49 -19
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +34 -13
- package/src/object-renderer/collection-table.ts +133 -65
- package/src/object-renderer/collection.ts +72 -59
- package/src/object-renderer/defaults.ts +2 -5
- package/src/object-renderer/emit-object.ts +4 -0
- package/src/object-renderer/emit-static.ts +116 -63
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/index.ts +5 -0
- package/src/object-renderer/layout-facts.ts +9 -1
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +59 -46
- package/src/object-renderer/table-actions.ts +72 -40
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +51 -20
- package/src/object-renderer/types.ts +7 -7
- package/src/recipes/container.ts +31 -0
- package/src/recipes/control.ts +57 -155
- package/src/recipes/emphasis.ts +56 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +23 -0
- package/src/recipes/overlay.ts +46 -1
- package/src/recipes/placeholder.ts +20 -4
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +12 -22
- package/src/recipes/status.ts +8 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +112 -6
- package/src/recipes/tabs.ts +49 -0
- package/src/recipes/title-row.ts +3 -3
- package/src/recipes/typography.ts +23 -42
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +13 -2
- package/src/theme/kit-theme.tpl +13 -2
- package/src/theme/nine-dim-structure.ts +77 -10
- package/src/theme/surface-layers.ts +6 -1
- package/src/theme/theme-tokens.ts +12 -5
- package/src/theme/typography.ts +21 -17
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
// 面板头控件(layer: data,写死形状):放进看板面板标题行右侧的小控件,也可作独立面板内容。
|
|
2
|
+
//
|
|
3
|
+
// SegmentedSwitch 分段单选(accept: single):options + current 由展示对象给,点选抛 change { value },组件不持有状态;
|
|
4
|
+
// MetaAction 元信息一行 + 至多一个动作钮(accept: single):text / label / can_act / busy,点钮只抛 act(确认与请求在展示对象);
|
|
5
|
+
// ScopeSwitch 范围切换(accept: single):一个选项来源 + 当前项元信息(状态 / 起止)+ 前后步进;
|
|
6
|
+
// 选项少且短 = 分段,多或宽 = 下拉(foundation arrangeChoicePresentation,阈值 kit-limits#choiceForm);
|
|
7
|
+
// 切换 = 链接导航(href 模板 `{value}` 与数据里的标量),同时抛 pick { value, href }。组件不路由、不发请求。
|
|
8
|
+
//
|
|
9
|
+
// 面板头槽位(MultiObjectBoard 的面板键 `head: <宿主面板名>`)由看板编译把本组件的宿主节点放进宿主面板标题行;
|
|
10
|
+
// 本文件只管控件自己的画法与事件,不知道自己是否在面板头里。颜色只用令牌,无内联样式。
|
|
11
|
+
|
|
12
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
13
|
+
import { textWidthEm } from 'soma-foundation/arrange';
|
|
14
|
+
import { arrangeChoicePresentation } from 'soma-foundation/arrange/table';
|
|
15
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon } from '../base/icons';
|
|
16
|
+
import { kitText } from '../i18n/kit-text';
|
|
17
|
+
import { createRadio } from '../base/radio';
|
|
18
|
+
import {
|
|
19
|
+
KIT_STATE_PANEL_CLASS_CANDIDATES, applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS,
|
|
20
|
+
} from '../base/state-panel';
|
|
21
|
+
import { CLASS_PROP, bool, createKitController, joinClass, str } from '../base/shared';
|
|
22
|
+
import { kitControlRecipe } from '../recipes';
|
|
23
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
24
|
+
import { createKitEmbedBag, mountKitComponent, mountKitSelectField, type KitEmbedBag } from './embed';
|
|
25
|
+
import { classTokens, keyMap, recOf, rowsOf, type Rec } from './shape-util';
|
|
26
|
+
|
|
27
|
+
const ROW_CLASS = 'flex flex-wrap items-center gap-x-3 gap-y-1';
|
|
28
|
+
const META_ROW_CLASS = 'flex flex-wrap items-center justify-between gap-x-4 gap-y-2';
|
|
29
|
+
const HINT_CLASS = kitTypographyRecipe('caption');
|
|
30
|
+
const MUTED_CLASS = 'text-fg-muted';
|
|
31
|
+
const SUBTLE_CLASS = 'text-fg-subtle tabular-nums';
|
|
32
|
+
const LABEL_CLASS = `shrink-0 ${HINT_CLASS} ${MUTED_CLASS}`;
|
|
33
|
+
const NAME_CLASS = kitTypographyRecipe('text');
|
|
34
|
+
const SELECT_SLOT_CLASS = 'w-56 max-w-full';
|
|
35
|
+
const STEP_GROUP_CLASS = 'inline-flex items-center gap-1';
|
|
36
|
+
const STEP_CLASS = kitControlRecipe({ variant: 'quiet', tight: true, pointer: true });
|
|
37
|
+
const STEP_OFF_CLASS = 'inline-flex size-8 items-center justify-center text-fg-subtle';
|
|
38
|
+
const BUTTON_CLASS = kitControlRecipe({ variant: 'neutral', tight: true });
|
|
39
|
+
|
|
40
|
+
export const KIT_PANEL_HEAD_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
41
|
+
ROW_CLASS, META_ROW_CLASS, HINT_CLASS, MUTED_CLASS, SUBTLE_CLASS, LABEL_CLASS, NAME_CLASS, SELECT_SLOT_CLASS,
|
|
42
|
+
STEP_GROUP_CLASS, STEP_CLASS, STEP_OFF_CLASS, BUTTON_CLASS, KIT_STATE_PANEL_CLASS_CANDIDATES, KIT_ICON_CLASS_CANDIDATES,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const texts = (raw: unknown): string => (typeof raw === 'string' ? raw.trim() : typeof raw === 'number' ? String(raw) : '');
|
|
46
|
+
|
|
47
|
+
// ───────── 分段单选 ─────────
|
|
48
|
+
|
|
49
|
+
export interface KitSwitchOption { value: string; label: string; disabled: boolean; hint: string }
|
|
50
|
+
|
|
51
|
+
/** 展示对象给的选项数组 → 规整选项(无 value 的项丢弃;label 缺省取 value) */
|
|
52
|
+
export function switchOptionsOf(raw: unknown): KitSwitchOption[] {
|
|
53
|
+
const out: KitSwitchOption[] = [];
|
|
54
|
+
for (const item of rowsOf(raw)) {
|
|
55
|
+
const value = texts(item.value);
|
|
56
|
+
if (value === '') continue;
|
|
57
|
+
out.push({ value, label: texts(item.label) || value, disabled: item.disabled === true, hint: texts(item.hint) });
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** 在槽里挂一个分段单选(内置 Radio 的 segmented 形态);值受控,调用方重画后再传新值 */
|
|
63
|
+
function mountSegmented(slot: HTMLElement, bag: KitEmbedBag, o: {
|
|
64
|
+
ariaLabel: string; options: readonly KitSwitchOption[]; value: string; size: 'sm' | 'md'; onChange(value: string): void;
|
|
65
|
+
}): void {
|
|
66
|
+
bag.add(mountKitComponent(createRadio(), slot, {
|
|
67
|
+
value: o.value,
|
|
68
|
+
options: o.options.map((x) => ({ value: x.value, label: x.label, ...(x.disabled ? { disabled: true } : {}) })),
|
|
69
|
+
variant: 'segmented',
|
|
70
|
+
size: o.size,
|
|
71
|
+
aria_label: o.ariaLabel,
|
|
72
|
+
}, {
|
|
73
|
+
change: (payload: { value?: unknown }) => {
|
|
74
|
+
const next = payload?.value === undefined || payload.value === null ? '' : String(payload.value);
|
|
75
|
+
if (next !== o.value) o.onChange(next);
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function createSegmentedSwitch(): SomaComponentDefinition {
|
|
81
|
+
return {
|
|
82
|
+
contract: {
|
|
83
|
+
name: 'SegmentedSwitch',
|
|
84
|
+
layer: 'data',
|
|
85
|
+
props: {
|
|
86
|
+
options: { type: 'array', default: [], desc: '选项 [{ value, label, disabled?, hint? }],由展示对象成员给(禁用项的原因写 hint,出在控件旁一行)' },
|
|
87
|
+
current: { type: 'string', default: '', desc: '当前选中值,由展示对象成员给(value 是编译器保留键,故叫 current)' },
|
|
88
|
+
aria_label: { type: 'string', default: '', desc: '分组可访问名' },
|
|
89
|
+
size: { type: 'enum', values: ['sm', 'md'], default: 'sm', desc: '控件尺寸档' },
|
|
90
|
+
class: CLASS_PROP,
|
|
91
|
+
},
|
|
92
|
+
emits: {
|
|
93
|
+
change: { payload: { value: { type: 'string' } }, desc: '点选某段(受控:值由展示对象持有,抛出后由展示对象写回成员)' },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
templateHtml: `<div data-soma-id="root" class="${ROW_CLASS}"></div>`,
|
|
97
|
+
controllerFactory: createKitController(() => {
|
|
98
|
+
const bag = createKitEmbedBag();
|
|
99
|
+
return {
|
|
100
|
+
attach(root) { return () => bag.release(root); },
|
|
101
|
+
render(root, p, api) {
|
|
102
|
+
bag.release(root);
|
|
103
|
+
root.className = joinClass(ROW_CLASS, str(p.class));
|
|
104
|
+
root.textContent = '';
|
|
105
|
+
const options = switchOptionsOf(p.options);
|
|
106
|
+
root.hidden = options.length === 0;
|
|
107
|
+
if (options.length === 0) return;
|
|
108
|
+
const slot = root.ownerDocument.createElement('span');
|
|
109
|
+
root.appendChild(slot);
|
|
110
|
+
mountSegmented(slot, bag, {
|
|
111
|
+
ariaLabel: str(p.aria_label) || options.map((o) => o.label).join(' / '),
|
|
112
|
+
options,
|
|
113
|
+
value: str(p.current),
|
|
114
|
+
size: p.size === 'md' ? 'md' : 'sm',
|
|
115
|
+
onChange: (value) => api.emit('change', { value }),
|
|
116
|
+
});
|
|
117
|
+
const hint = options.map((o) => (o.disabled ? o.hint : '')).find((h) => h !== '') ?? '';
|
|
118
|
+
if (hint !== '') {
|
|
119
|
+
const note = root.ownerDocument.createElement('span');
|
|
120
|
+
note.className = `${HINT_CLASS} ${MUTED_CLASS}`;
|
|
121
|
+
note.textContent = hint;
|
|
122
|
+
root.appendChild(note);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ───────── 元信息 + 动作 ─────────
|
|
131
|
+
|
|
132
|
+
export function createMetaAction(): SomaComponentDefinition {
|
|
133
|
+
return {
|
|
134
|
+
contract: {
|
|
135
|
+
name: 'MetaAction',
|
|
136
|
+
layer: 'data',
|
|
137
|
+
props: {
|
|
138
|
+
text: { type: 'string', default: '', desc: '元信息一行(展示对象给的成品文本)' },
|
|
139
|
+
label: { type: 'string', default: '', desc: '动作钮文字' },
|
|
140
|
+
can_act: { type: 'boolean', default: false, desc: '是否出动作钮(角色判定在展示对象,组件不判)' },
|
|
141
|
+
busy: { type: 'boolean', default: false, desc: '动作进行中:钮置灰' },
|
|
142
|
+
class: CLASS_PROP,
|
|
143
|
+
},
|
|
144
|
+
emits: {
|
|
145
|
+
act: { payload: {}, desc: '点动作钮(确认与请求由展示对象负责,组件不确认、不发请求、不判定角色)' },
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
templateHtml: `<div data-soma-id="root" class="${META_ROW_CLASS}"></div>`,
|
|
149
|
+
controllerFactory: createKitController(() => ({
|
|
150
|
+
attach(root, api) {
|
|
151
|
+
const onClick = (event: Event): void => {
|
|
152
|
+
const target = event.target as HTMLElement | null;
|
|
153
|
+
const btn = target?.closest<HTMLButtonElement>('[data-kit-meta-act]');
|
|
154
|
+
if (btn !== null && btn !== undefined && !btn.disabled) api.emit('act', {});
|
|
155
|
+
};
|
|
156
|
+
root.addEventListener('click', onClick);
|
|
157
|
+
return () => root.removeEventListener('click', onClick);
|
|
158
|
+
},
|
|
159
|
+
render(root, p) {
|
|
160
|
+
const doc = root.ownerDocument;
|
|
161
|
+
root.className = joinClass(META_ROW_CLASS, str(p.class));
|
|
162
|
+
root.textContent = '';
|
|
163
|
+
const text = str(p.text).trim();
|
|
164
|
+
const label = str(p.label).trim();
|
|
165
|
+
const showBtn = bool(p.can_act) && label !== '';
|
|
166
|
+
root.hidden = text === '' && !showBtn;
|
|
167
|
+
if (text !== '') {
|
|
168
|
+
const span = doc.createElement('span');
|
|
169
|
+
span.className = `${HINT_CLASS} ${MUTED_CLASS}`;
|
|
170
|
+
span.textContent = text;
|
|
171
|
+
root.appendChild(span);
|
|
172
|
+
}
|
|
173
|
+
if (showBtn) {
|
|
174
|
+
const btn = doc.createElement('button');
|
|
175
|
+
btn.type = 'button';
|
|
176
|
+
btn.className = BUTTON_CLASS;
|
|
177
|
+
btn.setAttribute('data-kit-meta-act', '');
|
|
178
|
+
btn.disabled = bool(p.busy);
|
|
179
|
+
btn.textContent = label;
|
|
180
|
+
root.appendChild(btn);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
})),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ───────── 范围切换 ─────────
|
|
188
|
+
|
|
189
|
+
export const KIT_SCOPE_SWITCH_DEFAULT_MAP = Object.freeze({ value: 'value', label: 'label', status: 'status', start: 'start', end: 'end' });
|
|
190
|
+
|
|
191
|
+
export interface KitScopeOption { value: string; label: string; status: string; start: string; end: string; raw: Rec }
|
|
192
|
+
|
|
193
|
+
/** 数据里取点路径 */
|
|
194
|
+
function pickAt(data: unknown, path: string): unknown {
|
|
195
|
+
let cur: unknown = data;
|
|
196
|
+
for (const seg of path.split('.')) {
|
|
197
|
+
if (seg === '') continue;
|
|
198
|
+
if (cur === null || typeof cur !== 'object' || Array.isArray(cur)) return undefined;
|
|
199
|
+
cur = (cur as Rec)[seg];
|
|
200
|
+
}
|
|
201
|
+
return cur;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** 数据 → 选项(optionsKey 指向选项数组;map 改写键名;无 value 的丢弃) */
|
|
205
|
+
export function scopeOptionsOf(data: unknown, optionsKey: string, map: unknown): KitScopeOption[] {
|
|
206
|
+
const m = keyMap(KIT_SCOPE_SWITCH_DEFAULT_MAP, map);
|
|
207
|
+
const list = Array.isArray(data) ? data : pickAt(data, optionsKey);
|
|
208
|
+
const out: KitScopeOption[] = [];
|
|
209
|
+
for (const raw of rowsOf(list)) {
|
|
210
|
+
const value = texts(raw[m.value]);
|
|
211
|
+
if (value === '') continue;
|
|
212
|
+
out.push({ value, label: texts(raw[m.label]) || value, status: texts(raw[m.status]), start: texts(raw[m.start]), end: texts(raw[m.end]), raw });
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** 起止文字:同年 `MM-DD ~ MM-DD`,跨年写全日期;两端都缺 = 空串,缺一端用「—」 */
|
|
218
|
+
export function scopeRangeText(start: string, end: string): string {
|
|
219
|
+
const s = start.slice(0, 10);
|
|
220
|
+
const e = end.slice(0, 10);
|
|
221
|
+
if (s === '' && e === '') return '';
|
|
222
|
+
const iso = /^\d{4}-\d{2}-\d{2}$/;
|
|
223
|
+
const sameYear = iso.test(s) && iso.test(e) && s.slice(0, 4) === e.slice(0, 4);
|
|
224
|
+
const cut = (v: string): string => (v === '' ? '—' : sameYear ? v.slice(5) : v);
|
|
225
|
+
return `${cut(s)} ~ ${cut(e)}`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 链接模板填参:`{名}` 取 vars(URL 编码);任一缺失 = null(不出半截链接);只许站内路径(以 / 开头、非 //)。
|
|
230
|
+
* 查询串里的 `键={名?}` 是可选参数:变量缺失时整段(连同前面的 ? / &)省略,不让入口消失。
|
|
231
|
+
*/
|
|
232
|
+
export function scopeHref(tpl: string, vars: Readonly<Record<string, string>>): string | null {
|
|
233
|
+
if (tpl === '') return null;
|
|
234
|
+
let missing = false;
|
|
235
|
+
let filled = tpl.replace(/([?&])([A-Za-z0-9_]+)=\{([A-Za-z_][A-Za-z0-9_]*)\?\}/g, (_m, sep: string, key: string, name: string) => {
|
|
236
|
+
const v = vars[name];
|
|
237
|
+
return v === undefined || v === '' ? '' : `${sep}${key}=${encodeURIComponent(v)}`;
|
|
238
|
+
});
|
|
239
|
+
if (!filled.includes('?') && filled.includes('&')) filled = filled.replace('&', '?'); // 省略了首个可选参数后,第一个 & 升为 ?
|
|
240
|
+
const out = filled.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_m, name: string) => {
|
|
241
|
+
const v = vars[name];
|
|
242
|
+
if (v === undefined || v === '') { missing = true; return ''; }
|
|
243
|
+
return encodeURIComponent(v);
|
|
244
|
+
});
|
|
245
|
+
if (missing || !out.startsWith('/') || out.startsWith('//')) return null;
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** 本行可用的链接变量:数据顶层标量 ∪ 选项行标量(行优先)∪ value */
|
|
250
|
+
function scopeVars(data: unknown, opt: KitScopeOption): Record<string, string> {
|
|
251
|
+
const vars: Record<string, string> = {};
|
|
252
|
+
for (const [k, v] of Object.entries(recOf(data))) if (typeof v === 'string' || typeof v === 'number') vars[k] = String(v);
|
|
253
|
+
for (const [k, v] of Object.entries(opt.raw)) if (typeof v === 'string' || typeof v === 'number') vars[k] = String(v);
|
|
254
|
+
vars.value = opt.value;
|
|
255
|
+
return vars;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function createScopeSwitch(): SomaComponentDefinition {
|
|
259
|
+
return {
|
|
260
|
+
contract: {
|
|
261
|
+
name: 'ScopeSwitch',
|
|
262
|
+
layer: 'data',
|
|
263
|
+
props: {
|
|
264
|
+
data: { type: 'object', default: {}, desc: '选项来源:对象(options_key 指向选项数组)或选项数组本身;每个选项 { value, label, status?, start?, end? },键名由 map 对照' },
|
|
265
|
+
map: { type: 'object', default: {}, desc: '键名对照:value / label / status / start / end -> 数据里的键' },
|
|
266
|
+
options_key: { type: 'string', default: 'rows', desc: '数据对象里选项数组的点路径(data 本身是数组时忽略)' },
|
|
267
|
+
active_key: { type: 'string', default: '', desc: '数据对象里服务端给的当前项 id 的点路径(current 与 fallback 都空时用它)' },
|
|
268
|
+
label: { type: 'string', default: '', desc: '控件前的小标题(如「迭代」「管理域」);空则不写' },
|
|
269
|
+
current: { type: 'string', default: '', desc: '当前项 id(页面绑地址参数)' },
|
|
270
|
+
fallback: { type: 'string', default: '', desc: 'current 为空时的回退 id(页面绑服务端回显)' },
|
|
271
|
+
href: { type: 'string', default: '', desc: '切换链接模板:`{value}` 与数据顶层 / 选项行里的标量(如 {domainId}、{activeIterationId});空 = 只显示不导航' },
|
|
272
|
+
step: { type: 'boolean', default: false, desc: '出前一项 / 后一项步进钮(按 start 先后,没有 start 则按给定顺序),是真链接' },
|
|
273
|
+
collapse_single: { type: 'boolean', default: false, desc: '只有一个选项(没有可选的)时整块不渲染' },
|
|
274
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
275
|
+
class: CLASS_PROP,
|
|
276
|
+
},
|
|
277
|
+
emits: {
|
|
278
|
+
pick: { payload: { value: { type: 'string' }, href: { type: 'string' } }, desc: '选了某一项(同时按 href 导航)' },
|
|
279
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
templateHtml: `<div data-soma-id="root" class="${ROW_CLASS}"></div>`,
|
|
283
|
+
controllerFactory: createKitController(() => {
|
|
284
|
+
const bag = createKitEmbedBag();
|
|
285
|
+
return {
|
|
286
|
+
attach(root, api) {
|
|
287
|
+
const onClick = (event: Event): void => {
|
|
288
|
+
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-scope-pick]');
|
|
289
|
+
if (hit === null || hit === undefined || !root.contains(hit)) return;
|
|
290
|
+
api.emit('pick', { value: hit.getAttribute('data-kit-scope-pick') ?? '', href: hit.getAttribute('href') ?? '' });
|
|
291
|
+
};
|
|
292
|
+
root.addEventListener('click', onClick);
|
|
293
|
+
return () => { root.removeEventListener('click', onClick); bag.release(root); };
|
|
294
|
+
},
|
|
295
|
+
render(root, p, api) {
|
|
296
|
+
bag.release(root);
|
|
297
|
+
const doc = root.ownerDocument;
|
|
298
|
+
root.className = joinClass(ROW_CLASS, str(p.class));
|
|
299
|
+
root.textContent = '';
|
|
300
|
+
root.hidden = false;
|
|
301
|
+
const options = scopeOptionsOf(p.data, str(p.options_key) || 'rows', p.map);
|
|
302
|
+
if (applyKitReadState(root, p as Record<string, unknown>, {
|
|
303
|
+
hasContent: options.length > 0,
|
|
304
|
+
onRetry: () => api.emit('retry', {}),
|
|
305
|
+
repaint: () => api.refresh(),
|
|
306
|
+
})) return;
|
|
307
|
+
if (options.length === 0) { root.hidden = root.childElementCount === 0; return; }
|
|
308
|
+
if (options.length === 1 && bool(p.collapse_single)) { root.hidden = true; return; }
|
|
309
|
+
const tpl = str(p.href);
|
|
310
|
+
const active = str(p.active_key) === '' ? '' : texts(pickAt(p.data, str(p.active_key)));
|
|
311
|
+
const currentId = str(p.current) || str(p.fallback) || active;
|
|
312
|
+
const selected = options.find((o) => o.value === currentId) ?? null;
|
|
313
|
+
const hrefOf = (o: KitScopeOption): string | null => scopeHref(tpl, scopeVars(p.data, o));
|
|
314
|
+
const go = (o: KitScopeOption): void => {
|
|
315
|
+
const href = hrefOf(o);
|
|
316
|
+
if (href === null || o.value === selected?.value) return;
|
|
317
|
+
// 与点链接同一条路径:造一个真链接并点击(壳按链接导航,同时走 pick 事件)
|
|
318
|
+
const a = doc.createElement('a');
|
|
319
|
+
a.setAttribute('href', href);
|
|
320
|
+
a.setAttribute('data-kit-scope-pick', o.value);
|
|
321
|
+
a.hidden = true;
|
|
322
|
+
root.appendChild(a);
|
|
323
|
+
a.click();
|
|
324
|
+
};
|
|
325
|
+
root.setAttribute('role', 'group');
|
|
326
|
+
if (str(p.label) !== '') root.setAttribute('aria-label', str(p.label)); else root.removeAttribute('aria-label');
|
|
327
|
+
if (str(p.label) !== '') {
|
|
328
|
+
const lab = doc.createElement('span');
|
|
329
|
+
lab.className = LABEL_CLASS;
|
|
330
|
+
lab.textContent = str(p.label);
|
|
331
|
+
root.appendChild(lab);
|
|
332
|
+
}
|
|
333
|
+
if (options.length === 1) {
|
|
334
|
+
const only = options[0]!;
|
|
335
|
+
const name = doc.createElement('span');
|
|
336
|
+
name.className = NAME_CLASS;
|
|
337
|
+
name.textContent = only.label;
|
|
338
|
+
root.appendChild(name);
|
|
339
|
+
} else {
|
|
340
|
+
const presentation = arrangeChoicePresentation(options.map((o) => textWidthEm(o.label))).mode;
|
|
341
|
+
const slot = doc.createElement('span');
|
|
342
|
+
root.appendChild(slot);
|
|
343
|
+
if (presentation === 'segmented') {
|
|
344
|
+
mountSegmented(slot, bag, {
|
|
345
|
+
ariaLabel: str(p.label) || options.map((o) => o.label).join(' / '),
|
|
346
|
+
options: options.map((o) => ({ value: o.value, label: o.label, disabled: false, hint: '' })),
|
|
347
|
+
value: selected?.value ?? '',
|
|
348
|
+
size: 'sm',
|
|
349
|
+
onChange: (value) => { const o = options.find((x) => x.value === value); if (o !== undefined) go(o); },
|
|
350
|
+
});
|
|
351
|
+
} else {
|
|
352
|
+
slot.className = SELECT_SLOT_CLASS;
|
|
353
|
+
const field = bag.add(mountKitSelectField({
|
|
354
|
+
options: options.map((o) => ({ value: o.value, label: o.label })),
|
|
355
|
+
value: selected?.value ?? '',
|
|
356
|
+
placeholder: str(p.label),
|
|
357
|
+
ariaLabel: str(p.label) || options.map((o) => o.label).join(' / '),
|
|
358
|
+
size: 'sm',
|
|
359
|
+
onChange: (value) => { const o = options.find((x) => x.value === value); if (o !== undefined) go(o); },
|
|
360
|
+
}));
|
|
361
|
+
slot.appendChild(field.el);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (selected !== null) {
|
|
365
|
+
for (const [text, cls] of [[selected.status, `${HINT_CLASS} ${MUTED_CLASS}`], [scopeRangeText(selected.start, selected.end), `${HINT_CLASS} ${SUBTLE_CLASS}`]] as const) {
|
|
366
|
+
if (text === '') continue;
|
|
367
|
+
const span = doc.createElement('span');
|
|
368
|
+
span.className = cls;
|
|
369
|
+
span.textContent = text;
|
|
370
|
+
root.appendChild(span);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (bool(p.step) && options.length > 1) {
|
|
374
|
+
const ordered = options.some((o) => o.start !== '') ? [...options].sort((a, b) => a.start.localeCompare(b.start)) : options;
|
|
375
|
+
const at = selected === null ? -1 : ordered.findIndex((o) => o.value === selected.value);
|
|
376
|
+
const prev = at > 0 ? ordered[at - 1]! : null;
|
|
377
|
+
const next = at >= 0 && at < ordered.length - 1 ? ordered[at + 1]! : null;
|
|
378
|
+
const group = doc.createElement('span');
|
|
379
|
+
group.className = STEP_GROUP_CLASS;
|
|
380
|
+
const step = (target: KitScopeOption | null, glyph: 'chevron-left' | 'chevron-right', aria: string): void => {
|
|
381
|
+
const href = target === null ? null : hrefOf(target);
|
|
382
|
+
if (target !== null && href !== null) {
|
|
383
|
+
const a = doc.createElement('a');
|
|
384
|
+
a.className = STEP_CLASS;
|
|
385
|
+
a.setAttribute('href', href);
|
|
386
|
+
a.setAttribute('aria-label', `${aria}:${target.label}`);
|
|
387
|
+
a.setAttribute('data-kit-scope-pick', target.value);
|
|
388
|
+
a.appendChild(kitIcon(glyph, 'sm'));
|
|
389
|
+
group.appendChild(a);
|
|
390
|
+
} else {
|
|
391
|
+
const off = doc.createElement('span');
|
|
392
|
+
off.className = STEP_OFF_CLASS;
|
|
393
|
+
off.setAttribute('aria-hidden', 'true');
|
|
394
|
+
off.appendChild(kitIcon(glyph, 'sm'));
|
|
395
|
+
group.appendChild(off);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
step(prev, 'chevron-left', kitText('soma.kit.scope_prev', undefined, root));
|
|
399
|
+
step(next, 'chevron-right', kitText('soma.kit.scope_next', undefined, root));
|
|
400
|
+
root.appendChild(group);
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}),
|
|
405
|
+
};
|
|
406
|
+
}
|
|
@@ -15,6 +15,8 @@ import { kitIcon, type KitIconName } from '../base/icons';
|
|
|
15
15
|
import { markCheckBox } from '../base/check-core';
|
|
16
16
|
import { kitText } from '../i18n/kit-text';
|
|
17
17
|
import { kitStateMarkRecipe, setKitFace } from '../recipes';
|
|
18
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
19
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
18
20
|
import { createKitBusy, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
19
21
|
|
|
20
22
|
// ── 数据规整纯函数:键名对照、三态、data 解析、授权表规整 ──
|
|
@@ -136,7 +138,7 @@ const READONLY_MARK_CLASS = kitStateMarkRecipe('done', 'md');
|
|
|
136
138
|
const EMPTY_CLASS = 'px-3 py-6 text-center text-fg-muted';
|
|
137
139
|
const FOOT_CLASS = 'flex items-center justify-end gap-2';
|
|
138
140
|
const SAVE_CLASS = 'inline-flex h-8 items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-fg hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50';
|
|
139
|
-
const CANCEL_CLASS = '
|
|
141
|
+
const CANCEL_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
140
142
|
|
|
141
143
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
142
144
|
export const KIT_PERMISSION_MATRIX_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
@@ -317,6 +319,7 @@ export function createPermissionMatrix(): SomaComponentDefinition {
|
|
|
317
319
|
}
|
|
318
320
|
const lock = locked();
|
|
319
321
|
const wrap = el('div', WRAP_CLASS);
|
|
322
|
+
markKitEdge(wrap);
|
|
320
323
|
const table = el('table', TABLE_CLASS);
|
|
321
324
|
const thead = el('thead', '');
|
|
322
325
|
const hr = el('tr', HEAD_ROW_CLASS);
|
|
@@ -39,6 +39,7 @@ import { kitIcon } from '../base/icons';
|
|
|
39
39
|
import { markCheckBox } from '../base/check-core';
|
|
40
40
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
41
41
|
import { kitControlRecipe, kitTextActionRecipe, setKitFace } from '../recipes';
|
|
42
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
42
43
|
import {
|
|
43
44
|
KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
|
|
44
45
|
} from '../recipes/overlay';
|
|
@@ -46,6 +47,8 @@ import { createKitBusy, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
|
46
47
|
import { classTokens, keyMap, mk, recOf } from './shape-util';
|
|
47
48
|
import { KIT_TREE_MAX_DEPTH } from './tree';
|
|
48
49
|
import { aggregateCheck, nextCheckTarget } from './tree-check';
|
|
50
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
51
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
49
52
|
|
|
50
53
|
// ── 类串表:全部完整写死,不拼接片段 ──
|
|
51
54
|
|
|
@@ -58,7 +61,7 @@ const CAPTION_CLASS = 'text-sm text-fg-muted';
|
|
|
58
61
|
const STRONG_CLASS = 'text-sm font-semibold text-fg';
|
|
59
62
|
const ALERT_CLASS = 'rounded-md bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
60
63
|
const HEAD_CLASS = 'flex items-center justify-between gap-3';
|
|
61
|
-
const TITLE_CLASS = '
|
|
64
|
+
const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
62
65
|
const SUMMARY_CLASS = 'text-sm text-fg-muted';
|
|
63
66
|
const CHANGES_CLASS = 'flex flex-wrap items-center gap-2 text-sm text-fg-muted';
|
|
64
67
|
const LINK_CLASS = 'rounded-md px-1 text-sm text-primary-on-soft transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
@@ -95,7 +98,7 @@ const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
|
95
98
|
const FOOT_CLASS = 'flex items-center justify-end gap-2 pt-1';
|
|
96
99
|
// 保存 / 取消(返回)都是标准高度的实心 / 描边按钮(与对话框底栏同一配方),不再一个文字链接一个按钮
|
|
97
100
|
const SAVE_CLASS = kitControlRecipe({ variant: 'primary' });
|
|
98
|
-
const CANCEL_CLASS =
|
|
101
|
+
const CANCEL_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
99
102
|
const DEPTH = ['ps-2', 'ps-6', 'ps-10', 'ps-14', 'ps-18', 'ps-22', 'ps-26'] as const;
|
|
100
103
|
|
|
101
104
|
export const KIT_PERMISSION_TREE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
@@ -859,6 +862,7 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
859
862
|
toolsBox = mk('div', TOOLS_CLASS);
|
|
860
863
|
toolsBox.append(searchBox, bulkBox);
|
|
861
864
|
treeEl = mk('div', TREE_CLASS);
|
|
865
|
+
markKitEdge(treeEl);
|
|
862
866
|
treeEl.setAttribute('role', 'tree');
|
|
863
867
|
cancelBtn = mk('button', CANCEL_CLASS); cancelBtn.type = 'button';
|
|
864
868
|
saveBtn = mk('button', SAVE_CLASS); saveBtn.type = 'button';
|
|
@@ -14,6 +14,7 @@ import { createKitController, joinClass, str, type KitView } from '../base/share
|
|
|
14
14
|
import { kitIcon } from '../base/icons';
|
|
15
15
|
import { kitText } from '../i18n/kit-text';
|
|
16
16
|
import { setKitFace } from '../recipes';
|
|
17
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
17
18
|
import { markKitSlot, markKitSlotGrid } from '../recipes/slot-align';
|
|
18
19
|
import { classTokens, emptyNode, mk, recOf, rowsOf, textOf, type Rec } from './shape-util';
|
|
19
20
|
import { singleOf } from './display-util';
|
|
@@ -45,7 +46,7 @@ const TICK_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center roun
|
|
|
45
46
|
const CROSS_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-sunken text-xs text-fg-subtle';
|
|
46
47
|
const VALUE_CLASS = 'ms-auto shrink-0 text-fg-muted';
|
|
47
48
|
const ACTION_CLASS = 'inline-flex h-10 items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-fg transition-colors hover:bg-primary-hover active:bg-primary-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
48
|
-
const ACTION_PLAIN_CLASS = '
|
|
49
|
+
const ACTION_PLAIN_CLASS = kitEmphasisButtonRecipe('button.toolbar', { size: 'lg' });
|
|
49
50
|
|
|
50
51
|
export const KIT_PRICING_TABLE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
51
52
|
ROOT_CLASS, CYCLES_CLASS, CYCLE_CLASS, NOTE_CLASS, GRID_CLASS, CARD_CLASS, CARD_RECOMMENDED_CLASS, SLOT_TITLE_CLASS, SLOT_ACTION_CLASS, BADGE_CLASS, NAME_CLASS,
|
package/src/data/record-card.ts
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
} from './shape-util';
|
|
17
17
|
import { safeImgSrc } from './d9-util';
|
|
18
18
|
import { kitText } from '../i18n/kit-text';
|
|
19
|
+
import { KIT_STATUS_BADGE_CLASS, KIT_STATUS_DOT_CLASS } from '../recipes/status';
|
|
20
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
19
21
|
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
20
22
|
import type { SomaDataPort } from 'soma-core';
|
|
21
23
|
import { watchKitOutcome, type KitOutcome } from './outcome-watch';
|
|
@@ -54,12 +56,14 @@ const RAIL_CLASS = 'w-1 shrink-0 self-stretch rounded-full';
|
|
|
54
56
|
const MAIN_CLASS = 'flex flex-1 flex-col gap-3';
|
|
55
57
|
const HEAD_CLASS = 'flex items-start justify-between gap-2';
|
|
56
58
|
const HEAD_TEXT = 'flex flex-col gap-0.5';
|
|
57
|
-
const TITLE_CLASS = '
|
|
59
|
+
const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
58
60
|
const SUBTITLE_CLASS = 'text-fg-muted';
|
|
59
61
|
const FACTS_CLASS = 'grid grid-cols-2 gap-x-4 gap-y-2';
|
|
60
62
|
const FACT_CLASS = 'flex flex-col gap-0.5';
|
|
61
63
|
const FACT_LABEL = 'text-xs font-medium text-fg-muted';
|
|
62
64
|
const FACT_VALUE = 'text-sm text-fg';
|
|
65
|
+
const STATUS_CLASS = KIT_STATUS_BADGE_CLASS;
|
|
66
|
+
const STATUS_DOT_CLASS = KIT_STATUS_DOT_CLASS;
|
|
63
67
|
const TAGS_CLASS = 'flex flex-wrap gap-1';
|
|
64
68
|
const TAG_CLASS = 'rounded-full bg-surface-sunken px-2 py-0.5 text-xs font-medium text-fg-muted';
|
|
65
69
|
const PROGRESS_CLASS = 'block h-2 w-full overflow-hidden rounded-full';
|
|
@@ -76,7 +80,7 @@ const SECRET_BAR_CLASS = 'flex items-center justify-between gap-2';
|
|
|
76
80
|
export const KIT_RECORD_CARD_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
77
81
|
Object.values(VARIANT_CLASS), Object.values(VARIANT_INTERACT), LAYOUT_PLAIN, LAYOUT_MEDIA, BODY_ROW_CLASS, MEDIA_CLASS, RAIL_CLASS, MAIN_CLASS, HEAD_CLASS, HEAD_TEXT, TITLE_CLASS, SUBTITLE_CLASS, FACTS_CLASS, FACT_CLASS,
|
|
78
82
|
FACT_LABEL, FACT_VALUE, TAGS_CLASS, TAG_CLASS, PROGRESS_CLASS, PROGRESS_TRACK_CLASS, PROGRESS_FILL_CLASS, FOOT_CLASS, BADGE_BASE, BUTTON_CLASS_TOKENS,
|
|
79
|
-
FACT_ROW_CLASS, FACT_MONO_CLASS, SECRET_CLASS, SECRET_VALUE_CLASS, SECRET_NOTE_CLASS, SECRET_BAR_CLASS,
|
|
83
|
+
STATUS_CLASS, STATUS_DOT_CLASS, FACT_ROW_CLASS, FACT_MONO_CLASS, SECRET_CLASS, SECRET_VALUE_CLASS, SECRET_NOTE_CLASS, SECRET_BAR_CLASS,
|
|
80
84
|
Object.values(TONE_SOFT), Object.values(TONE_DOT),
|
|
81
85
|
);
|
|
82
86
|
|
|
@@ -302,7 +306,7 @@ export function createRecordCard(): SomaComponentDefinition {
|
|
|
302
306
|
// 没有记录(data 空、也没有 outcome 来源的 secret):画共享的紧凑空态,不画一张只有空标题的卡
|
|
303
307
|
if (Object.keys(data).length === 0 && Object.keys(secretOf(root, p, data, m.secret ?? 'secret')).length === 0) {
|
|
304
308
|
// 卡根是横排 flex:空态占满整行(否则缩成左上角一小块)
|
|
305
|
-
const empty = emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root))
|
|
309
|
+
const empty = emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root)));
|
|
306
310
|
empty.classList.add('flex-1');
|
|
307
311
|
root.appendChild(empty);
|
|
308
312
|
return;
|
|
@@ -328,13 +332,21 @@ export function createRecordCard(): SomaComponentDefinition {
|
|
|
328
332
|
|
|
329
333
|
const head = mk('div', HEAD_CLASS);
|
|
330
334
|
const text = mk('div', HEAD_TEXT);
|
|
331
|
-
|
|
335
|
+
const titleText = textOf(data[m.title]);
|
|
336
|
+
if (titleText !== '') text.appendChild(mk('h3', TITLE_CLASS, titleText));
|
|
332
337
|
const sub = textOf(data[m.subtitle]);
|
|
333
338
|
if (sub !== '') text.appendChild(mk('p', SUBTITLE_CLASS, sub));
|
|
334
339
|
head.appendChild(text);
|
|
335
340
|
const status = textOf(data[m.status]);
|
|
336
|
-
|
|
337
|
-
|
|
341
|
+
// 标题 / 副标题 / 状态都没有(如主从页把头让给详情头):不画头行,不留空行
|
|
342
|
+
if (status !== '') {
|
|
343
|
+
// 状态徽标:浅底 + 圆点 + 文字(与表格 / 紧凑列表 / 条目列表同一种呈现)
|
|
344
|
+
const badge = mk('span', `${STATUS_CLASS} ${TONE_SOFT[tone]}`);
|
|
345
|
+
badge.appendChild(mk('span', `${STATUS_DOT_CLASS} ${TONE_DOT[tone]}`));
|
|
346
|
+
badge.appendChild(mk('span', '', status));
|
|
347
|
+
head.appendChild(badge);
|
|
348
|
+
}
|
|
349
|
+
if (titleText !== '' || sub !== '' || status !== '') main.appendChild(head);
|
|
338
350
|
|
|
339
351
|
const facts = recordFactsOf(data, m.facts, p.fields, str(p.locale));
|
|
340
352
|
if (facts.length > 0) {
|
package/src/data/resident.ts
CHANGED
|
@@ -7,8 +7,10 @@ import { createKitObjectForm } from './object-form';
|
|
|
7
7
|
import { createRowEditor } from './row-editor';
|
|
8
8
|
import { FLOW_EDITOR_CONTRACT } from './flow-editor-contract';
|
|
9
9
|
import { createKitTableActions } from '../object-renderer/table-actions';
|
|
10
|
+
import { createKitActionMore } from '../object-renderer/action-more';
|
|
10
11
|
import { createKitTableTools } from '../object-renderer/table-tools';
|
|
11
12
|
import { createKitTableSummary } from '../object-renderer/table-summary';
|
|
13
|
+
import { createKitTableGap } from '../object-renderer/table-gap';
|
|
12
14
|
import { createKitCollectionState, createKitTableHead } from '../object-renderer/collection-parts';
|
|
13
15
|
import { createKitTabsWiring } from '../frames/tabs-frame/wiring';
|
|
14
16
|
import { createKitSplitWiring } from '../frames/split-frame/wiring';
|
|
@@ -20,6 +22,8 @@ import { createKitRedirect } from './redirect';
|
|
|
20
22
|
import { createKitWorkspace } from '../frames/workspace-frame/view';
|
|
21
23
|
import { createKitPageBar } from '../frames/page-bar';
|
|
22
24
|
import { createKitPageStatus } from '../frames/page-status';
|
|
25
|
+
import { createKitListSummary } from '../frames/list-summary';
|
|
26
|
+
import { createKitAccessGate } from './access-gate';
|
|
23
27
|
|
|
24
28
|
/** 常驻数据组件表(KitObjectForm 的行模板按基础组件表生成) */
|
|
25
29
|
export function createKitResidentDataComponents(
|
|
@@ -41,9 +45,11 @@ export function createKitResidentDataComponents(
|
|
|
41
45
|
RowEditor: rowEditor,
|
|
42
46
|
KitObjectForm: createKitObjectForm({ ...baseComponents, RowEditor: rowEditor, FlowEditor: flowEditorShell }),
|
|
43
47
|
KitTableActions: createKitTableActions(),
|
|
48
|
+
KitActionMore: createKitActionMore(),
|
|
44
49
|
KitTableHead: createKitTableHead(),
|
|
45
50
|
KitTableTools: createKitTableTools(),
|
|
46
51
|
KitTableSummary: createKitTableSummary(),
|
|
52
|
+
KitTableGap: createKitTableGap(),
|
|
47
53
|
KitCollectionState: createKitCollectionState(),
|
|
48
54
|
KitTabsWiring: createKitTabsWiring(),
|
|
49
55
|
KitSplitWiring: createKitSplitWiring(),
|
|
@@ -55,5 +61,7 @@ export function createKitResidentDataComponents(
|
|
|
55
61
|
KitWorkspace: createKitWorkspace(),
|
|
56
62
|
KitPageBar: createKitPageBar(),
|
|
57
63
|
KitPageStatus: createKitPageStatus(),
|
|
64
|
+
KitListSummary: createKitListSummary(),
|
|
65
|
+
KitAccessGate: createKitAccessGate(),
|
|
58
66
|
};
|
|
59
67
|
}
|
package/src/data/row-editor.ts
CHANGED
|
@@ -1053,7 +1053,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1053
1053
|
const structural = !readonly && !fixedRows;
|
|
1054
1054
|
const spanOf = (c: KitRowColumn): string => `${structural ? `${FLEX_SPAN[c.span] ?? 'flex-2'} min-w-0` : SPAN_CLASS[c.span] ?? 'col-span-2'}${isNumericRowKind(c.kind) ? ` ${NUM_ALIGN}` : ''}`;
|
|
1055
1055
|
if (st.rows.length === 0) {
|
|
1056
|
-
list.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root))
|
|
1056
|
+
list.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root))));
|
|
1057
1057
|
} else {
|
|
1058
1058
|
const head = mk('div', structural ? HEAD_END_CLASS : HEAD_CLASS);
|
|
1059
1059
|
for (const c of shown) {
|
|
@@ -1214,7 +1214,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
} else if (st.rows.length === 0) {
|
|
1216
1216
|
list.textContent = '';
|
|
1217
|
-
list.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root))
|
|
1217
|
+
list.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root))));
|
|
1218
1218
|
} else {
|
|
1219
1219
|
list.textContent = '';
|
|
1220
1220
|
const structural = !readonly && !fixedRows;
|