soma-kit 0.1.2 → 0.1.4
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/README.md +3 -3
- package/package.json +6 -4
- package/spec/generated/kit-page.schema.json +3 -0
- package/spec/kit-grammar.json +4652 -563
- package/src/app/app-config.ts +10 -3
- package/src/app/index.ts +3 -0
- package/src/base/text.ts +2 -0
- package/src/biz/approval-desk/shell.ts +5 -5
- package/src/biz/auth-panel/shell.ts +1 -1
- package/src/biz/category-crud/compile.ts +5 -2
- package/src/biz/category-crud/shell.ts +1 -1
- package/src/biz/checkout-page/shell.ts +3 -3
- package/src/biz/import-wizard/shell.ts +1 -1
- package/src/biz/master-sub/compile.ts +5 -2
- package/src/biz/master-sub/shell.ts +5 -5
- package/src/biz/multi-board/shell.ts +2 -2
- package/src/biz/notification-center/shell.ts +3 -3
- package/src/biz/page-templates/result-page/shell.ts +1 -1
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +5 -5
- package/src/biz/settings-center/compile.ts +3 -1
- package/src/biz/settings-center/shell.ts +4 -4
- package/src/biz/single-form/shell.ts +1 -1
- package/src/biz/standard-crud/compile.ts +10 -2
- package/src/biz/standard-crud/shell.ts +20 -9
- package/src/biz/step-form/shell.ts +1 -1
- package/src/compile/compile-page.ts +1 -0
- package/src/data/object-form.ts +1 -1
- package/src/frames/blank-frame.ts +1 -1
- package/src/frames/shared.ts +19 -11
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/view.ts +42 -21
- package/src/generated/kit-grammar-runtime.ts +16 -13
- package/src/index.ts +4 -0
- package/src/object-renderer/arrange.ts +3 -3
- package/src/object-renderer/collection.ts +29 -8
- package/src/object-renderer/emit-static.ts +14 -1
- package/src/object-renderer/types.ts +4 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +3 -0
- package/src/theme/kit-theme.tpl +3 -0
- package/src/theme/theme-tokens.ts +6 -0
- package/src/theme/typography.ts +44 -0
|
@@ -39,12 +39,12 @@ import {
|
|
|
39
39
|
} from './state';
|
|
40
40
|
|
|
41
41
|
const C = {
|
|
42
|
-
root: '@container flex h-screen w-full flex-col overflow-hidden bg-surface-sunken text-fg',
|
|
43
|
-
rootFill: '@container flex min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-sunken text-fg',
|
|
42
|
+
root: '@container flex h-screen w-full flex-col overflow-hidden bg-surface-sunken text-sm text-fg',
|
|
43
|
+
rootFill: '@container flex min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-sunken text-sm text-fg',
|
|
44
44
|
stage: 'flex min-h-0 w-full flex-1 overflow-hidden',
|
|
45
|
-
sidebarBase: 'hidden @4xl:flex w-56 shrink-0 flex-col border-e border-border-
|
|
46
|
-
sidebarCollapsed: 'hidden @4xl:flex w-16 shrink-0 flex-col border-e border-border-
|
|
47
|
-
sidebarDrawer: 'fixed inset-y-0 start-0 z-30 flex w-56 flex-col border-e border-border-
|
|
45
|
+
sidebarBase: 'hidden @4xl:flex w-56 shrink-0 flex-col border-e border-border-strong bg-surface',
|
|
46
|
+
sidebarCollapsed: 'hidden @4xl:flex w-16 shrink-0 flex-col border-e border-border-strong bg-surface',
|
|
47
|
+
sidebarDrawer: 'fixed inset-y-0 start-0 z-30 flex w-56 flex-col border-e border-border-strong bg-surface shadow-xl',
|
|
48
48
|
brand: `flex h-14 shrink-0 cursor-pointer items-center gap-3 border-b border-border-subtle px-4 ${FOCUS}`,
|
|
49
49
|
logo: 'flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary text-sm font-semibold text-primary-fg',
|
|
50
50
|
brandName: 'min-w-0 truncate text-base font-semibold text-fg',
|
|
@@ -58,18 +58,20 @@ const C = {
|
|
|
58
58
|
btnDanger: `inline-flex h-9 cursor-pointer items-center justify-center rounded-md border border-border bg-surface px-3 text-sm font-medium text-danger-on-soft transition-colors hover:bg-danger-soft ${FOCUS}`,
|
|
59
59
|
btnGhost: `inline-flex h-9 cursor-pointer items-center justify-center rounded-md px-3 text-sm text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg ${FOCUS}`,
|
|
60
60
|
column: 'flex min-w-0 flex-1 flex-col',
|
|
61
|
-
header: 'relative z-20 flex shrink-0 flex-col border-b border-border-
|
|
61
|
+
header: 'relative z-20 flex shrink-0 flex-col border-b border-border-strong bg-surface',
|
|
62
62
|
panelHost: 'absolute inset-x-4 top-full z-30 mt-1.5',
|
|
63
|
-
tabBar: 'flex items-
|
|
64
|
-
tabList: 'flex min-w-0 flex-1 flex-row gap-1 overflow-x-auto',
|
|
65
|
-
tabRow: 'inline-flex shrink-0 items-center rounded-t-md border border-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
tabBar: 'flex items-end gap-2 border-t border-border-subtle bg-surface-sunken px-3 pt-1.5',
|
|
64
|
+
tabList: 'flex min-w-0 flex-1 flex-row items-end gap-1 overflow-x-auto -mb-px',
|
|
65
|
+
tabRow: 'inline-flex shrink-0 items-center rounded-t-md border border-border-subtle border-b-border-strong bg-surface/60 transition-colors hover:bg-surface',
|
|
66
|
+
tabRowActive: 'relative inline-flex shrink-0 items-center rounded-t-md border border-border-strong border-b-surface border-t-2 border-t-primary bg-surface shadow-xs',
|
|
67
|
+
tab: `inline-flex h-8 max-w-48 cursor-pointer items-center truncate rounded-t-md px-3 text-sm text-fg-muted transition-colors hover:text-fg aria-selected:font-medium aria-selected:text-primary-on-soft ${FOCUS_INSET}`,
|
|
68
|
+
tabClose: `inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-sm text-xs text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg ${FOCUS_INSET}`,
|
|
68
69
|
tabPin: 'inline-flex h-6 w-4 items-center justify-center text-xs text-fg-subtle',
|
|
69
70
|
tabOps: 'relative flex shrink-0 items-center pb-1',
|
|
70
|
-
content: 'relative flex min-h-0 flex-1 flex-col',
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
content: '@container relative flex min-h-0 flex-1 flex-col',
|
|
72
|
+
stageHost: 'relative flex min-h-0 flex-1 flex-col overflow-auto',
|
|
73
|
+
notice: 'm-auto flex max-w-md flex-col items-center gap-2 rounded-lg border border-border-strong bg-surface-raised p-6 text-center',
|
|
74
|
+
noticeTitle: 'text-base font-semibold text-fg',
|
|
73
75
|
noticeText: 'text-sm text-fg-muted',
|
|
74
76
|
noticeDetail: 'font-medium text-fg',
|
|
75
77
|
empty: 'm-auto text-sm text-fg-subtle',
|
|
@@ -93,7 +95,7 @@ const C = {
|
|
|
93
95
|
footerLink: `truncate rounded-sm text-xs text-fg-muted hover:text-fg hover:underline ${FOCUS}`,
|
|
94
96
|
// 顶栏图标钮(主题、全屏)与主题抽屉(F2、F5)
|
|
95
97
|
navBtn: `inline-flex h-9 w-9 cursor-pointer items-center justify-center rounded-md text-base text-fg-muted transition-colors hover:bg-surface-sunken hover:text-fg ${FOCUS}`,
|
|
96
|
-
themePanel: 'fixed inset-y-0 end-0 z-40 flex w-72 flex-col gap-3 border-s border-border-
|
|
98
|
+
themePanel: 'fixed inset-y-0 end-0 z-40 flex w-72 flex-col gap-3 border-s border-border-strong bg-surface p-4 shadow-xl',
|
|
97
99
|
themeHead: 'flex items-center justify-between',
|
|
98
100
|
themeTitle: 'text-base font-semibold text-fg',
|
|
99
101
|
themeGroup: 'flex flex-col gap-1',
|
|
@@ -127,7 +129,7 @@ const SIDEBAR_TIERS_GRAMMAR = (grammarJson as unknown as {
|
|
|
127
129
|
}).workspaceFrame.sidebarTiers;
|
|
128
130
|
// 档位数字读 design 投影(soma-foundation/kit-limits),宽度类与存取前缀读 kit-grammar
|
|
129
131
|
export const KIT_SIDEBAR_TIERS: typeof SIDEBAR_TIERS_GRAMMAR = { ...SIDEBAR_TIERS_GRAMMAR, ...KIT_WORKSPACE_FRAME_LIMITS.sidebarTiers };
|
|
130
|
-
const SIDEBAR_TAIL = 'shrink-0 flex-col border-e border-border-
|
|
132
|
+
const SIDEBAR_TAIL = 'shrink-0 flex-col border-e border-border-strong bg-surface';
|
|
131
133
|
const sidebarTierClass = (tier: number): string => `relative hidden @4xl:flex ${KIT_SIDEBAR_TIERS.widthClass[String(tier)] ?? 'w-56'} ${SIDEBAR_TAIL}`;
|
|
132
134
|
const tierPx = (tier: number): number => Number((KIT_SIDEBAR_TIERS.widthClass[String(tier)] ?? 'w-56').slice(2)) * 4;
|
|
133
135
|
function tierFromPx(px: number): number {
|
|
@@ -208,6 +210,8 @@ export interface KitWorkspaceHandle {
|
|
|
208
210
|
tabs(): WorkspaceTab[];
|
|
209
211
|
/** 顶栏下方的面板挂载点:宿主往里放自己的下拉面板(组件不会清它) */
|
|
210
212
|
panelHost: HTMLElement;
|
|
213
|
+
/** 受控自定义舞台槽位:宿主在非 iframe 页签(url 为空或 config.custom_stage 为真)时挂载自定义视图;与 frameBox / notice / empty 严格互斥(同步切换 hidden 属性与 hidden 类) */
|
|
214
|
+
stageHost: HTMLElement;
|
|
211
215
|
destroy(): void;
|
|
212
216
|
}
|
|
213
217
|
|
|
@@ -289,12 +293,14 @@ export function mountKitWorkspace(root: HTMLElement, emit: KitWorkspaceEmit): Ki
|
|
|
289
293
|
emptyBox.hidden = true;
|
|
290
294
|
const loadingEl = h('div', C.loading, { role: 'status' });
|
|
291
295
|
loadingEl.hidden = true;
|
|
296
|
+
const stageHost = h('section', 'hidden', { 'data-kit-workspace-stage': '' });
|
|
297
|
+
stageHost.hidden = true;
|
|
292
298
|
const frameBox = h('section', C.frameBox, { 'data-kit-workspace-frames': '' }, loadingEl);
|
|
293
299
|
frameBox.hidden = true;
|
|
294
300
|
frameBox.className = 'hidden';
|
|
295
301
|
const watermarkBox = h('div', '');
|
|
296
302
|
const watermarkId = nextUid('kit-ws-wm');
|
|
297
|
-
const content = h('div', C.content, {}, noticeBox, emptyBox, frameBox, watermarkBox);
|
|
303
|
+
const content = h('div', C.content, {}, noticeBox, emptyBox, stageHost, frameBox, watermarkBox);
|
|
298
304
|
const alertBox = h('div', 'hidden', { 'data-kit-workspace-alerts': '' });
|
|
299
305
|
const column = h('div', C.column, {}, alertBox, header, content);
|
|
300
306
|
stage.append(sidebar, column);
|
|
@@ -731,8 +737,9 @@ export function mountKitWorkspace(root: HTMLElement, emit: KitWorkspaceEmit): Ki
|
|
|
731
737
|
const focusedKey = doc.activeElement instanceof HTMLElement && tabBarBox.contains(doc.activeElement) && doc.activeElement.hasAttribute('data-kit-tab')
|
|
732
738
|
? (doc.activeElement.dataset.key ?? null) : null;
|
|
733
739
|
const list = h('div', C.tabList, { 'aria-label': labels.tabs }, ...tabs.map((tab) => {
|
|
740
|
+
const isActive = tab.key === active;
|
|
734
741
|
const open = h('button', C.tab, { type: 'button', title: tab.title, 'data-kit-tab': true, 'data-key': tab.key }, tab.title);
|
|
735
|
-
const row = h('div', C.tabRow, {}, open);
|
|
742
|
+
const row = h('div', isActive ? C.tabRowActive : C.tabRow, { 'data-kit-tab-active': isActive ? 'true' : 'false' }, open);
|
|
736
743
|
if (tab.pinned) row.insertBefore(h('span', C.tabPin, { 'aria-label': labels.pinned, title: labels.pinned }, '•'), open);
|
|
737
744
|
if (isTabClosable(tab)) {
|
|
738
745
|
const close = h('button', C.tabClose, { type: 'button', 'aria-label': labels.closeTab }, kitIcon('close', 'xs'));
|
|
@@ -834,8 +841,15 @@ export function mountKitWorkspace(root: HTMLElement, emit: KitWorkspaceEmit): Ki
|
|
|
834
841
|
node.outer.hidden = hide;
|
|
835
842
|
node.outer.className = hide ? 'hidden' : C.frameOuter;
|
|
836
843
|
}
|
|
837
|
-
|
|
838
|
-
|
|
844
|
+
const curTab = tabs.find((t) => t.key === active);
|
|
845
|
+
const useCustomStage = !notice().show && (bool(cfg.custom_stage) || cfg.stage === 'host' || (stageHost.childElementCount > 0 && (curTab === undefined ? tabs.length === 0 : curTab.url === '')));
|
|
846
|
+
stageHost.hidden = !useCustomStage;
|
|
847
|
+
stageHost.className = useCustomStage ? C.stageHost : 'hidden';
|
|
848
|
+
const hideFrames = useCustomStage || withUrl.length === 0 || notice().show || (curTab !== undefined && curTab.url === '');
|
|
849
|
+
frameBox.hidden = hideFrames;
|
|
850
|
+
frameBox.className = hideFrames ? 'hidden' : C.frameBox;
|
|
851
|
+
emptyBox.hidden = notice().show || useCustomStage || tabs.length > 0;
|
|
852
|
+
emptyBox.className = emptyBox.hidden ? 'hidden' : C.empty;
|
|
839
853
|
frameBox.setAttribute('aria-label', labels.workspace);
|
|
840
854
|
paintLoading();
|
|
841
855
|
};
|
|
@@ -865,7 +879,8 @@ export function mountKitWorkspace(root: HTMLElement, emit: KitWorkspaceEmit): Ki
|
|
|
865
879
|
...(n.detail !== '' ? [h('p', C.noticeText, {}, str(isRec(cfg.notice) ? cfg.notice.detail_label : '', ''), h('span', C.noticeDetail, {}, n.detail))] : []));
|
|
866
880
|
}
|
|
867
881
|
emptyBox.textContent = str(cfg.empty_text, labels.empty);
|
|
868
|
-
emptyBox.hidden = n.show || model().tabs.length > 0;
|
|
882
|
+
emptyBox.hidden = n.show || model().tabs.length > 0 || bool(cfg.custom_stage) || cfg.stage === 'host' || stageHost.childElementCount > 0;
|
|
883
|
+
emptyBox.className = emptyBox.hidden ? 'hidden' : C.empty;
|
|
869
884
|
};
|
|
870
885
|
|
|
871
886
|
const drawWatermark = (): void => {
|
|
@@ -908,6 +923,10 @@ export function mountKitWorkspace(root: HTMLElement, emit: KitWorkspaceEmit): Ki
|
|
|
908
923
|
extras.escape();
|
|
909
924
|
if (drawerOpen) { drawerOpen = false; render(); }
|
|
910
925
|
};
|
|
926
|
+
const stageObserver = typeof MutationObserver !== 'undefined'
|
|
927
|
+
? new MutationObserver(() => { if (!destroyed && started) syncFrames(); })
|
|
928
|
+
: null;
|
|
929
|
+
stageObserver?.observe(stageHost, { childList: true });
|
|
911
930
|
doc.addEventListener('pointerdown', onPointerDown, true);
|
|
912
931
|
doc.addEventListener('keydown', onKeyDown, true);
|
|
913
932
|
|
|
@@ -937,8 +956,10 @@ export function mountKitWorkspace(root: HTMLElement, emit: KitWorkspaceEmit): Ki
|
|
|
937
956
|
},
|
|
938
957
|
tabs: () => model().tabs,
|
|
939
958
|
panelHost,
|
|
959
|
+
stageHost,
|
|
940
960
|
destroy() {
|
|
941
961
|
destroyed = true;
|
|
962
|
+
stageObserver?.disconnect();
|
|
942
963
|
extras.destroy();
|
|
943
964
|
releaseDropdownsIn(footBox);
|
|
944
965
|
releaseDropdownsIn(tabBarBox);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 生成物,不得改写:由 soma-kit/scripts/build-kit-grammar-runtime.mjs 从 spec/kit-grammar.json 抽出。
|
|
2
2
|
// 浏览器侧只读这份运行期切片(闭集与限值);编译侧读完整真源。改真源后运行 `npm run grammar:runtime -w soma-kit` 重新生成。
|
|
3
|
-
// 真源指纹 sha256:
|
|
3
|
+
// 真源指纹 sha256:3ab3728363470542a29b171c0706dadee96abdddc0ae84bcad56231d0a9eb76c
|
|
4
4
|
|
|
5
5
|
export const KIT_GRAMMAR_RUNTIME = {
|
|
6
6
|
"i18n": {
|
|
@@ -1060,10 +1060,13 @@ export const KIT_GRAMMAR_RUNTIME = {
|
|
|
1060
1060
|
"fg-muted": "--soma-text-secondary",
|
|
1061
1061
|
"fg-subtle": "--soma-text-muted",
|
|
1062
1062
|
"border": "--soma-border-control",
|
|
1063
|
+
"border-strong": "--soma-border-strong",
|
|
1063
1064
|
"border-subtle": "--soma-border-hairline",
|
|
1065
|
+
"border-divider": "--soma-border-divider",
|
|
1064
1066
|
"input": "--soma-border-control",
|
|
1065
1067
|
"input-hover": "--soma-border-control",
|
|
1066
1068
|
"subtle": "--soma-border-hairline",
|
|
1069
|
+
"divider": "--soma-border-divider",
|
|
1067
1070
|
"primary": "--soma-c-primary",
|
|
1068
1071
|
"primary-fg": "--soma-c-primary-fg",
|
|
1069
1072
|
"primary-soft": "--soma-c-primary-soft",
|
|
@@ -1473,31 +1476,31 @@ export const KIT_GRAMMAR_RUNTIME = {
|
|
|
1473
1476
|
"error": "hidden text-xs text-danger-on-soft",
|
|
1474
1477
|
"placeholderCell": "",
|
|
1475
1478
|
"flexWrap": "flex flex-wrap items-end gap-3",
|
|
1476
|
-
"tableWrap": "overflow-x-auto",
|
|
1479
|
+
"tableWrap": "overflow-x-auto rounded-lg border border-border-strong/70 bg-surface",
|
|
1477
1480
|
"tableInner": "min-w-160 flex flex-col",
|
|
1478
|
-
"tableHead": "grid grid-cols-12 gap-4 px-4 py-
|
|
1479
|
-
"tableRow": "grid grid-cols-12 gap-4 px-4 py-
|
|
1480
|
-
"tableHeadCompact": "grid grid-cols-12 gap-4 px-4 py-1.5 text-
|
|
1481
|
-
"tableHeadComfortable": "grid grid-cols-12 gap-4 px-4 py-
|
|
1482
|
-
"tableRowCompact": "grid grid-cols-12 gap-4 px-4 py-1.5 border-b border-border-
|
|
1483
|
-
"tableRowComfortable": "grid grid-cols-12 gap-4 px-4 py-
|
|
1484
|
-
"tableRowStriped": "even:bg-surface-sunken even:hover:bg-
|
|
1481
|
+
"tableHead": "grid grid-cols-12 gap-4 px-4 py-2 text-xs font-semibold text-fg-muted bg-surface-sunken border-b border-border-subtle rounded-t-lg",
|
|
1482
|
+
"tableRow": "grid grid-cols-12 gap-4 px-4 py-2 border-b border-border-divider last:border-b-0 items-center text-sm text-fg transition-colors hover:bg-fg/8 active:bg-fg/12 data-kit-selected:bg-primary-soft",
|
|
1483
|
+
"tableHeadCompact": "grid grid-cols-12 gap-4 px-4 py-1.5 text-xs font-semibold text-fg-muted bg-surface-sunken border-b border-border-subtle rounded-t-lg",
|
|
1484
|
+
"tableHeadComfortable": "grid grid-cols-12 gap-4 px-4 py-3.5 text-xs font-semibold text-fg-muted bg-surface-sunken border-b border-border-subtle rounded-t-lg",
|
|
1485
|
+
"tableRowCompact": "grid grid-cols-12 gap-4 px-4 py-1.5 border-b border-border-divider last:border-b-0 items-center text-sm text-fg transition-colors hover:bg-fg/8 active:bg-fg/12 data-kit-selected:bg-primary-soft",
|
|
1486
|
+
"tableRowComfortable": "grid grid-cols-12 gap-4 px-4 py-3.5 border-b border-border-divider last:border-b-0 items-center text-sm text-fg transition-colors hover:bg-fg/8 active:bg-fg/12 data-kit-selected:bg-primary-soft",
|
|
1487
|
+
"tableRowStriped": "even:bg-surface-sunken/60 even:hover:bg-fg/8",
|
|
1485
1488
|
"tableRowStripedExpandOuter": "group/row",
|
|
1486
|
-
"tableRowStripedExpandInner": "group-even/row:hover:bg-
|
|
1489
|
+
"tableRowStripedExpandInner": "group-even/row:hover:bg-fg/8",
|
|
1487
1490
|
"tableRowSelected": "data-kit-selected:bg-primary-soft",
|
|
1488
1491
|
"help": "text-xs text-fg-muted",
|
|
1489
1492
|
"tableActions": "flex flex-wrap items-center gap-2",
|
|
1490
1493
|
"cardsList": "grid gap-4",
|
|
1491
|
-
"cardsItem": "rounded-lg border border-border-
|
|
1494
|
+
"cardsItem": "rounded-lg border border-border-strong/70 bg-surface p-4 shadow-xs",
|
|
1492
1495
|
"stackList": "flex flex-col gap-3",
|
|
1493
|
-
"stackItem": "rounded-lg border border-border-
|
|
1496
|
+
"stackItem": "rounded-lg border border-border-strong/70 bg-surface p-3 shadow-xs",
|
|
1494
1497
|
"staticRoot": "",
|
|
1495
1498
|
"groupsWrap": "flex flex-col gap-4",
|
|
1496
1499
|
"groupSection": "flex flex-col gap-3",
|
|
1497
1500
|
"groupTitle": "text-sm font-semibold text-fg",
|
|
1498
1501
|
"groupToggle": "flex w-full items-center justify-between gap-2 rounded-md py-1 text-start text-sm font-semibold text-fg transition-colors hover:text-fg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",
|
|
1499
1502
|
"groupMark": "w-4 shrink-0 text-center text-fg-subtle",
|
|
1500
|
-
"tableScrollWrap": "overflow-x-auto group/tbl",
|
|
1503
|
+
"tableScrollWrap": "overflow-x-auto rounded-lg border border-border-strong/70 bg-surface group/tbl",
|
|
1501
1504
|
"tableScrollInner": "flex w-max min-w-full flex-col",
|
|
1502
1505
|
"tableScrollCell": "box-border flex flex-none items-center px-4",
|
|
1503
1506
|
"tableCellSticky": "sticky z-10 bg-surface group-hover/trow:bg-surface-sunken group-data-kit-selected/trow:bg-primary-soft",
|
package/src/index.ts
CHANGED
|
@@ -4,3 +4,7 @@ export { defineKitApp, defineKitActions } from './app';
|
|
|
4
4
|
export type { DefineKitAppOptions, KitApp } from './app';
|
|
5
5
|
export { compileKitPage, emptyFragment, mergeFragments, fragmentFromEmit } from './compile';
|
|
6
6
|
export type { KitFragment, KitAppContext, KitPageArtifact, KitCompileResult } from './compile';
|
|
7
|
+
|
|
8
|
+
export { classCandidates } from './base/shared';
|
|
9
|
+
export { KIT_TYPOGRAPHY, KIT_TYPOGRAPHY_CLASS_CANDIDATES } from './theme/typography';
|
|
10
|
+
export type { KitTypographyRole } from './theme/typography';
|
|
@@ -174,7 +174,7 @@ export function buildCell(
|
|
|
174
174
|
source: pick.source,
|
|
175
175
|
mode,
|
|
176
176
|
label: typeof ref.label === 'string' ? ref.label : field.name,
|
|
177
|
-
...requiredOf(typeof ref.label === 'string' ? ref.label : field.name, field, mode, env.requiredMark),
|
|
177
|
+
...requiredOf(typeof ref.label === 'string' ? ref.label : field.name, field, mode, env.requiredMark, env.slot),
|
|
178
178
|
props: fieldProps(field, ref, mode),
|
|
179
179
|
parts,
|
|
180
180
|
cellClass: mergeClass(base, ref.class),
|
|
@@ -356,8 +356,8 @@ export function arrange(input: KitArrangeInput, refs: KitFieldRef[], view: KitVi
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
/** 编辑 / 新建态的必填字段标星号位置(end = 标签后,start = 标签前);星号由发射层 / 表单画成红色子元素,不并入标签文本 */
|
|
359
|
-
function requiredOf(label: string, field: { rules?: Array<{ required?: boolean }> }, mode: string, position: 'start' | 'end' = 'end'): { required?: 'start' | 'end' } {
|
|
360
|
-
if (mode === 'show' || label === '') return {};
|
|
359
|
+
function requiredOf(label: string, field: { rules?: Array<{ required?: boolean }> }, mode: string, position: 'start' | 'end' = 'end', slot?: string): { required?: 'start' | 'end' } {
|
|
360
|
+
if (slot === 'filter' || mode === 'show' || label === '') return {};
|
|
361
361
|
if (field.rules?.some((r) => r.required === true) !== true) return {};
|
|
362
362
|
return { required: position };
|
|
363
363
|
}
|
|
@@ -342,8 +342,12 @@ export function collection(
|
|
|
342
342
|
if (c.striped !== undefined && typeof c.striped !== 'boolean') {
|
|
343
343
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.striped`, message: 'striped 必须是布尔' });
|
|
344
344
|
}
|
|
345
|
+
if (c.bordered !== undefined && typeof c.bordered !== 'boolean') {
|
|
346
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.bordered`, message: 'bordered 必须是布尔' });
|
|
347
|
+
}
|
|
345
348
|
const dens = KIT_TABLE_DENSITY_CLASS[density];
|
|
346
349
|
const striped = c.striped === true;
|
|
350
|
+
const bordered = c.bordered === true;
|
|
347
351
|
|
|
348
352
|
// ---- M 波 G2:列模型 / 滚动模式 / 工具栏
|
|
349
353
|
const ext = parseColExt(refs, env, { isTree, sticky });
|
|
@@ -410,7 +414,7 @@ export function collection(
|
|
|
410
414
|
refs.forEach((r, i) => {
|
|
411
415
|
const p = parts[i]!;
|
|
412
416
|
const ex = ext[i]!;
|
|
413
|
-
const widthCls = scroll ? join(D.tableScrollCell, `w-${steps[i]}`) : fixedSpan(p);
|
|
417
|
+
const widthCls = scroll ? join(D.tableScrollCell, `w-${steps[i]}`) : join('min-w-0', fixedSpan(p));
|
|
414
418
|
const cell = buildCell(r, env, i, widthCls, { base: p, wide: p, full: p }, view, '');
|
|
415
419
|
if (!cell) return;
|
|
416
420
|
if (isTree && cell.action !== undefined) {
|
|
@@ -426,12 +430,19 @@ export function collection(
|
|
|
426
430
|
const al = alignClass(ex.align, scroll);
|
|
427
431
|
const stk = plan !== null && plan.offset[i] !== '';
|
|
428
432
|
const edge = plan === null ? '' : plan.edgeLeft === i ? D.tableEdgeLeft : plan.edgeRight === i ? D.tableEdgeRight : '';
|
|
433
|
+
const gridBorderCell = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...bodyPy, ...denseRow] : [];
|
|
434
|
+
const colDivider = bordered ? 'not-last:border-e not-last:border-border-divider' : '';
|
|
429
435
|
cell.cellClass = join(
|
|
430
436
|
cell.cellClass, al, ex.ellipsis ? D.tableCellEllipsis : '',
|
|
431
|
-
scroll ? [...bodyPy, ...denseRow] :
|
|
437
|
+
scroll ? [...bodyPy, ...denseRow] : gridBorderCell,
|
|
438
|
+
colDivider,
|
|
432
439
|
stk ? [D.tableCellSticky, stripeSticky, plan!.offset[i]!, edge] : '',
|
|
433
440
|
);
|
|
434
441
|
if (ex.ellipsis) cell.ellipsis = true;
|
|
442
|
+
// 表格只读文本列默认单行省略防横向重叠(显式 ellipsis: false 时改为换行折词)
|
|
443
|
+
if ((cell.component === 'Text' || cell.component === 'Link') && cell.mode === 'show') {
|
|
444
|
+
cell.valueClass = join(cell.valueClass, r.ellipsis === false ? 'block min-w-0 break-words' : 'block min-w-0 truncate');
|
|
445
|
+
}
|
|
435
446
|
// 就地编辑:字段须可写(permission w),且不是主键
|
|
436
447
|
const schemaField = env.schema[r.name];
|
|
437
448
|
if (ex.editable) {
|
|
@@ -455,9 +466,16 @@ export function collection(
|
|
|
455
466
|
if (edge !== '') gs.edge = edge;
|
|
456
467
|
}
|
|
457
468
|
}
|
|
469
|
+
const headGridBorder = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...headPy, ...denseHead] : [];
|
|
470
|
+
const headTick = bordered
|
|
471
|
+
? 'not-last:border-e not-last:border-border-subtle'
|
|
472
|
+
: scroll
|
|
473
|
+
? 'not-last:border-e not-last:border-border-divider'
|
|
474
|
+
: 'not-last:border-e not-last:border-border-divider not-last:pe-3';
|
|
458
475
|
const headCls = join(
|
|
459
|
-
widthCls, al,
|
|
460
|
-
scroll ? [...headPy, ...denseHead] :
|
|
476
|
+
widthCls, 'truncate', al,
|
|
477
|
+
scroll ? [...headPy, ...denseHead] : headGridBorder,
|
|
478
|
+
headTick,
|
|
461
479
|
stk && gi < 0 ? [D.tableHeadCellSticky, plan!.offset[i]!, edge] : '',
|
|
462
480
|
ex.resizable === true ? X.resize.cell : '',
|
|
463
481
|
);
|
|
@@ -525,11 +543,12 @@ export function collection(
|
|
|
525
543
|
}
|
|
526
544
|
// 选择列 / 操作列:滚动模式下定宽,有固定列时 sticky(行里底色随行,表头里随表头)
|
|
527
545
|
const lead = (headRow: boolean): string => join(
|
|
528
|
-
scroll ? [D.tableScrollCell, `w-${selectStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : fixedSpan(selectParts),
|
|
546
|
+
scroll ? [D.tableScrollCell, `w-${selectStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(selectParts), ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
547
|
+
bordered ? (headRow ? 'not-last:border-e not-last:border-border-subtle' : 'not-last:border-e not-last:border-border-divider') : (headRow ? (scroll ? 'not-last:border-e not-last:border-border-divider' : 'not-last:border-e not-last:border-border-divider not-last:pe-3') : ''),
|
|
529
548
|
plan !== null && plan.selectSticky ? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'left-0'] : '',
|
|
530
549
|
);
|
|
531
550
|
const tail = (headRow: boolean): string => join(
|
|
532
|
-
scroll ? [D.tableScrollCell, `w-${actionsStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : fixedSpan(actionParts),
|
|
551
|
+
scroll ? [D.tableScrollCell, `w-${actionsStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(actionParts), ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
533
552
|
plan !== null && plan.actionsSticky
|
|
534
553
|
? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'right-0', plan.edgeRight === -1 ? D.tableEdgeRight : '']
|
|
535
554
|
: '',
|
|
@@ -538,8 +557,9 @@ export function collection(
|
|
|
538
557
|
const actionsRow = actionParts > 0 ? tail(false) : '';
|
|
539
558
|
const selectHead = selectParts > 0 ? lead(true) : '';
|
|
540
559
|
const actionsHead = actionParts > 0 ? tail(true) : '';
|
|
541
|
-
const
|
|
542
|
-
const
|
|
560
|
+
const gridBorderedRow = (cls: string): string => cls.split(/\s+/).filter((t) => t !== '' && t !== 'gap-4' && t !== 'px-4' && t !== 'items-center' && !/^py-/.test(t)).concat(['gap-0', 'items-stretch']).join(' ');
|
|
561
|
+
const rowBase = scroll ? scrollRowClass(dens.row) : bordered ? gridBorderedRow(dens.row) : dens.row;
|
|
562
|
+
const headBase = scroll ? scrollRowClass(dens.head) : bordered ? gridBorderedRow(dens.head) : dens.head;
|
|
543
563
|
const summaryRowClass = summary === null ? '' : join(plainRowClass(rowBase), D.tableSummaryRow, virt !== null ? KIT_TABLE_VIRTUAL.summarySticky : '');
|
|
544
564
|
const wrapBase = scroll ? D.tableScrollWrap : sticky ? '' : D.tableWrap;
|
|
545
565
|
const rcw = rowClassWhenOf(view, !isTree, env);
|
|
@@ -560,6 +580,7 @@ export function collection(
|
|
|
560
580
|
sort: head.some((h) => h.sort !== undefined || h.filter !== undefined),
|
|
561
581
|
stickyHeader: sticky,
|
|
562
582
|
stripeClass: striped ? D.tableRowStriped : '',
|
|
583
|
+
...(bordered ? { bordered: true } : {}),
|
|
563
584
|
density,
|
|
564
585
|
expand,
|
|
565
586
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
@@ -940,6 +940,19 @@ function toolbarGateBindings(ctx: Ctx, a: KitAction): Record<string, string> {
|
|
|
940
940
|
return out;
|
|
941
941
|
}
|
|
942
942
|
|
|
943
|
+
const AUXILIARY_BUILTINS = new Set(['reload', 'reset', 'export', 'back']);
|
|
944
|
+
const AUXILIARY_IDS = new Set(['reload', 'refresh', 'reset', 'export', 'back']);
|
|
945
|
+
|
|
946
|
+
function actionTone(a: KitAction): 'primary' | 'neutral' | 'danger' {
|
|
947
|
+
if (a.tone === 'danger') return 'danger';
|
|
948
|
+
if (a.tone === 'neutral') return 'neutral';
|
|
949
|
+
if (a.tone === 'primary') return 'primary';
|
|
950
|
+
if ((a.builtin !== undefined && AUXILIARY_BUILTINS.has(a.builtin)) || AUXILIARY_IDS.has(a.id)) {
|
|
951
|
+
return 'neutral';
|
|
952
|
+
}
|
|
953
|
+
return 'primary';
|
|
954
|
+
}
|
|
955
|
+
|
|
943
956
|
function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
944
957
|
const list = actions.filter((a) => a.on === 'toolbar');
|
|
945
958
|
if (list.length === 0) return '';
|
|
@@ -949,7 +962,7 @@ function renderToolbar(ctx: Ctx, actions: readonly KitAction[]): string {
|
|
|
949
962
|
ctx.show[id] = {
|
|
950
963
|
props: {
|
|
951
964
|
label: a.name,
|
|
952
|
-
variant: a
|
|
965
|
+
variant: actionTone(a),
|
|
953
966
|
// K1-2:Button 读 permission 服务,无权不渲染
|
|
954
967
|
...(typeof a.permission === 'string' && a.permission !== '' ? { permission: a.permission } : {}),
|
|
955
968
|
// GA2:状态条件(叶子 outcome.* 与页面读态 total / selectedCount / selected.<字段>),Button 订阅写入结果自行重判;
|
|
@@ -381,7 +381,7 @@ export interface KitColumnGroupDecl {
|
|
|
381
381
|
export type KitCollection =
|
|
382
382
|
| ({
|
|
383
383
|
type: 'table'; tree?: KitTreeDecl; select?: KitSelectDecl; rowActions?: string[]; page?: KitPageDecl; stickyHeader?: boolean; expand?: KitExpandDecl;
|
|
384
|
-
density?: 'compact' | 'standard' | 'comfortable'; striped?: boolean;
|
|
384
|
+
density?: 'compact' | 'standard' | 'comfortable'; striped?: boolean; bordered?: boolean;
|
|
385
385
|
/** 工具栏:reload / density / columns / export(顺序即显示顺序) */
|
|
386
386
|
toolbar?: Array<'reload' | 'density' | 'columns' | 'export'>;
|
|
387
387
|
/** 批量操作:`@动作id` 引用 behavior.actions,或内联 { id, name, submit | builtin, confirm?, tone?, permission? };confirm 里 `{n}` 换成已选个数 */
|
|
@@ -399,7 +399,7 @@ export type KitCollection =
|
|
|
399
399
|
/** 列宽拖拽(Q 波 G4):true = 所有非固定列可拖(10 个预置档);字段级 resizable 可单列开关;写了视同进入滚动模式 */
|
|
400
400
|
resizable?: boolean;
|
|
401
401
|
} & KitCollectionStateDecl)
|
|
402
|
-
| ({ type: 'treeTable'; tree?: KitTreeDecl; select?: 'none' | 'single' | 'multi'; rowActions?: string[]; page?: KitPageDecl; stickyHeader?: boolean; density?: 'compact' | 'standard' | 'comfortable'; striped?: boolean; contextMenu?: string[] } & KitCollectionStateDecl)
|
|
402
|
+
| ({ type: 'treeTable'; tree?: KitTreeDecl; select?: 'none' | 'single' | 'multi'; rowActions?: string[]; page?: KitPageDecl; stickyHeader?: boolean; density?: 'compact' | 'standard' | 'comfortable'; striped?: boolean; bordered?: boolean; contextMenu?: string[] } & KitCollectionStateDecl)
|
|
403
403
|
| ({ type: 'cards'; cols: 1 | 2 | 3 | 4 | 6; class?: string; rowActions?: string[]; page?: KitPageDecl; contextMenu?: string[] } & KitCollectionStateDecl)
|
|
404
404
|
| ({ type: 'stack'; class?: string; rowActions?: string[]; page?: KitPageDecl; contextMenu?: string[] } & KitCollectionStateDecl);
|
|
405
405
|
|
|
@@ -818,6 +818,8 @@ export type KitLayoutIR =
|
|
|
818
818
|
stickyHeader: boolean;
|
|
819
819
|
/** 斑马纹类(collection.striped: true 时为 classDefaults.tableRowStriped,否则 ''),挂在每条数据项的最外层元素 */
|
|
820
820
|
stripeClass: string;
|
|
821
|
+
/** 完整网格线模式(collection.bordered: true) */
|
|
822
|
+
bordered?: boolean;
|
|
821
823
|
/** 单元格内边距档位 */
|
|
822
824
|
density: 'compact' | 'standard' | 'comfortable';
|
|
823
825
|
expand: KitExpandIR | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// 默认主题头文本(与 ./kit-theme.css 同源,均由 scripts/build-kit-theme.mjs 从 kit-theme.tpl + kit-limits 生成,勿手改;tests/app/server.test.ts 字节对账;避免打包器改写 import.meta.url 导致 fileURLToPath 报错)
|
|
2
|
-
export const KIT_DEFAULT_THEME_CSS: string = "/*\n * 用 @theme inline:值引用 var(--soma-*),inline 让工具类直接展开成 var(--soma-*),\n * 运行时换主题、切密度时跟着变,不被 @theme 提前固化到 :root 的 --color-* 副本上。\n * core 样式引擎禁止 @import / @plugin / @config,Tailwind 默认色板与尺度全为空,\n * 所以这里必须自带用到的全部尺度;没声明的键不会生成工具类。\n * 尺度允许的键见 spec/kit-grammar.json 的 utilityScales;尺度里的数字(容器档、命中区、透视、模糊、动画时长等)\n * 由 scripts/build-kit-theme.mjs 从 soma-design/spec/pipeline/kit-limits.json 写入,本文件由 src/theme/kit-theme.tpl 生成,勿手改。\n */\n@theme inline {\n --color-surface: var(--soma-surface-base);\n --color-surface-sunken: var(--soma-surface-sunken);\n --color-surface-raised: var(--soma-surface-raised);\n\n --color-fg: var(--soma-text-primary);\n --color-fg-muted: var(--soma-text-secondary);\n --color-fg-subtle: var(--soma-text-muted);\n\n --color-border: var(--soma-border-control);\n --color-border-subtle: var(--soma-border-hairline);\n --color-subtle: var(--soma-border-hairline);\n --color-input: color-mix(in oklab, var(--soma-border-control) 60%, var(--soma-surface-base));\n --color-input-hover: var(--soma-border-control);\n\n --color-primary: var(--soma-c-primary);\n --color-primary-fg: var(--soma-c-primary-fg);\n --color-primary-soft: var(--soma-c-primary-soft);\n --color-primary-on-soft: var(--soma-c-primary-on-soft);\n --color-primary-hover: var(--soma-c-primary-hover);\n --color-primary-active: var(--soma-c-primary-active);\n\n --color-success: var(--soma-c-success);\n --color-success-fg: var(--soma-c-success-fg);\n --color-success-soft: var(--soma-c-success-soft);\n --color-success-on-soft: var(--soma-c-success-on-soft);\n\n --color-warning: var(--soma-c-warning);\n --color-warning-fg: var(--soma-c-warning-fg);\n --color-warning-soft: var(--soma-c-warning-soft);\n --color-warning-on-soft: var(--soma-c-warning-on-soft);\n\n --color-danger: var(--soma-c-danger);\n --color-danger-fg: var(--soma-c-danger-fg);\n --color-danger-soft: var(--soma-c-danger-soft);\n --color-danger-on-soft: var(--soma-c-danger-on-soft);\n --color-danger-hover: var(--soma-c-danger-hover);\n --color-danger-active: var(--soma-c-danger-active);\n\n --color-info: var(--soma-c-info);\n --color-info-fg: var(--soma-c-info-fg);\n --color-info-soft: var(--soma-c-info-soft);\n --color-info-on-soft: var(--soma-c-info-on-soft);\n\n --color-ring: var(--soma-focus-ring);\n\n --spacing: var(--soma-space-1);\n\n --radius-sm: var(--soma-radius-sm);\n --radius-md: var(--soma-radius-md);\n --radius-lg: var(--soma-radius-lg);\n --radius-xl: var(--soma-radius-xl);\n --radius-full: var(--soma-radius-full);\n\n --text-xs: var(--soma-font-size-xs);\n --text-xs--line-height: var(--soma-line-height-xs);\n --text-sm: var(--soma-font-size-sm);\n --text-sm--line-height: var(--soma-line-height-sm);\n --text-base: var(--soma-font-size-md);\n --text-base--line-height: var(--soma-line-height-md);\n --text-lg: var(--soma-font-size-lg);\n --text-lg--line-height: var(--soma-line-height-lg);\n --text-xl: var(--soma-font-size-xl);\n --text-xl--line-height: var(--soma-line-height-xl);\n --text-2xl: var(--soma-font-size-xxl);\n --text-2xl--line-height: var(--soma-line-height-xxl);\n\n --font-weight-normal: var(--soma-font-weight-normal);\n --font-weight-medium: var(--soma-font-weight-medium);\n --font-weight-semibold: var(--soma-font-weight-bold);\n --font-weight-bold: var(--soma-font-weight-heavy);\n\n --font-sans: var(--soma-font-family);\n --font-mono: var(--soma-font-family-mono);\n\n --shadow-xs: var(--soma-shadow-step-0);\n --shadow-sm: var(--soma-shadow-step-1);\n --shadow-md: var(--soma-shadow-step-2);\n --shadow-lg: var(--soma-shadow-popover);\n --shadow-xl: var(--soma-shadow-dialog);\n\n --ease-standard: var(--soma-motion-easing-standard);\n --ease-enter: var(--soma-motion-easing-enter);\n --ease-exit: var(--soma-motion-easing-exit);\n --ease-emphasized: var(--soma-motion-spring-emphasized-easing);\n\n --default-transition-duration: var(--soma-motion-duration-base);\n --default-transition-timing-function: var(--soma-motion-easing-standard);\n\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 36rem;\n --container-xl: 40rem;\n --container-2xl: 48rem;\n --container-3xl: 56rem;\n --container-4xl: 64rem;\n\n --aspect-video: 16 / 9;\n}\n\n/*\n * 进退动效组:时长与缓动成对取自 design 动效真源(进入 200ms、退出 150ms,退出短于进入;减少动效档令牌自动归 100ms / linear)。\n * motion-enter 用于出现,motion-exit 用于消失,motion-emphasized 用于强调进入(弹簧曲线);使用处一律 motion-safe: 前缀。\n * 命中区 hit-area:小控件的不可见扩展点击区(伪元素铺满),最小边长取 design adaptive#/…/hitTarget(精细指针 24px、粗指针 44px,生成时换算成 rem);\n * 宿主元素自带 relative 定位,宿主本身要有 overflow 可见。\n * 文本框去自动填充底色 autofill-clear:文本类输入(input / textarea)与 appearance-none 同用,:-webkit-autofill 的黄 / 蓝底改回令牌色(surface-base / text-primary);\n * 数字框不再用原生 type=number(改 type=text + role=spinbutton,步进自绘),所以没有隐藏原生微调钮的类。\n */\n@utility motion-enter {\n transition-duration: var(--soma-motion-duration-enter);\n transition-timing-function: var(--soma-motion-easing-enter);\n}\n\n@utility motion-exit {\n transition-duration: var(--soma-motion-duration-exit);\n transition-timing-function: var(--soma-motion-easing-exit);\n}\n\n@utility motion-emphasized {\n transition-duration: var(--soma-motion-spring-emphasized-duration);\n transition-timing-function: var(--soma-motion-spring-emphasized-easing);\n}\n\n@utility autofill-clear {\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus {\n -webkit-text-fill-color: var(--soma-text-primary);\n caret-color: var(--soma-text-primary);\n box-shadow: 0 0 0 100vmax var(--soma-surface-base) inset;\n transition: background-color 9999s ease-out 0s;\n }\n}\n\n@utility hit-area {\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n width: max(100%, 1.5rem);\n height: max(100%, 1.5rem);\n transform: translate(-50%, -50%);\n }\n\n @media (pointer: coarse) {\n &::after {\n width: max(100%, 2.75rem);\n height: max(100%, 2.75rem);\n }\n }\n}\n\n/* 导航件(Menu / Navbar / MegaMenu / workspace-frame)的弹层入场;使用处一律 motion-safe: 前缀 */\n@theme inline {\n --animate-kit-menu-in: kit-menu-in var(--soma-motion-duration-base) var(--soma-motion-easing-standard);\n\n @keyframes kit-menu-in {\n from {\n opacity: 0;\n transform: translateY(-0.25rem);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n\n/* 状态件(StatusDot 脉冲、ProgressBar 不确定态):使用处一律 motion-safe: 前缀,motion-reduce 下静止 */\n@theme inline {\n --animate-kit-ping: kit-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-kit-indeterminate: kit-indeterminate 1.4s ease-in-out infinite;\n\n @keyframes kit-ping {\n 75%,\n 100% {\n opacity: 0;\n transform: scale(2.2);\n }\n }\n\n @keyframes kit-indeterminate {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(250%);\n }\n }\n}\n\n/* 动效展示件(TextRotate / Hover3d / HoverGallery / Aura / Marquee):关键帧与透视、模糊刻度;使用处一律 motion-safe: 前缀,motion-reduce 下静止 */\n@theme inline {\n --perspective-normal: 1000px;\n --blur-sm: 4px;\n --blur-md: 12px;\n\n --animate-kit-rise: kit-rise var(--soma-motion-duration-base) var(--soma-motion-easing-standard);\n --animate-kit-fade: kit-fade var(--soma-motion-duration-base) var(--soma-motion-easing-standard);\n --animate-kit-aura: kit-aura 3s ease-in-out infinite;\n --animate-kit-marquee-slow: kit-marquee 40s linear infinite;\n --animate-kit-marquee-slow-paused: kit-marquee 40s linear infinite paused;\n --animate-kit-marquee-normal: kit-marquee 25s linear infinite;\n --animate-kit-marquee-normal-paused: kit-marquee 25s linear infinite paused;\n --animate-kit-marquee-fast: kit-marquee 12s linear infinite;\n --animate-kit-marquee-fast-paused: kit-marquee 12s linear infinite paused;\n\n @keyframes kit-rise {\n from {\n opacity: 0;\n transform: translateY(0.5rem);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes kit-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n\n @keyframes kit-aura {\n 0%,\n 100% {\n opacity: 0.5;\n transform: scale(1);\n }\n 50% {\n opacity: 1;\n transform: scale(1.03);\n }\n }\n\n @keyframes kit-marquee {\n from {\n transform: translateX(0);\n }\n to {\n transform: translateX(-50%);\n }\n }\n}\n\n/* 骨架屏(KitCollectionState 的 loading: skeleton):呼吸占位;使用处一律 motion-safe: 前缀,减少动效下静止 */\n@theme inline {\n --animate-kit-pulse: kit-pulse 2s ease-in-out infinite;\n\n @keyframes kit-pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n }\n}\n";
|
|
2
|
+
export const KIT_DEFAULT_THEME_CSS: string = "/*\n * 用 @theme inline:值引用 var(--soma-*),inline 让工具类直接展开成 var(--soma-*),\n * 运行时换主题、切密度时跟着变,不被 @theme 提前固化到 :root 的 --color-* 副本上。\n * core 样式引擎禁止 @import / @plugin / @config,Tailwind 默认色板与尺度全为空,\n * 所以这里必须自带用到的全部尺度;没声明的键不会生成工具类。\n * 尺度允许的键见 spec/kit-grammar.json 的 utilityScales;尺度里的数字(容器档、命中区、透视、模糊、动画时长等)\n * 由 scripts/build-kit-theme.mjs 从 soma-design/spec/pipeline/kit-limits.json 写入,本文件由 src/theme/kit-theme.tpl 生成,勿手改。\n */\n@theme inline {\n --color-surface: var(--soma-surface-base);\n --color-surface-sunken: var(--soma-surface-sunken);\n --color-surface-raised: var(--soma-surface-raised);\n\n --color-fg: var(--soma-text-primary);\n --color-fg-muted: var(--soma-text-secondary);\n --color-fg-subtle: var(--soma-text-muted);\n\n --color-border: var(--soma-border-control);\n --color-border-strong: var(--soma-border-strong);\n --color-border-subtle: var(--soma-border-hairline);\n --color-border-divider: var(--soma-border-divider);\n --color-subtle: var(--soma-border-hairline);\n --color-divider: var(--soma-border-divider);\n --color-input: color-mix(in oklab, var(--soma-border-control) 60%, var(--soma-surface-base));\n --color-input-hover: var(--soma-border-control);\n\n --color-primary: var(--soma-c-primary);\n --color-primary-fg: var(--soma-c-primary-fg);\n --color-primary-soft: var(--soma-c-primary-soft);\n --color-primary-on-soft: var(--soma-c-primary-on-soft);\n --color-primary-hover: var(--soma-c-primary-hover);\n --color-primary-active: var(--soma-c-primary-active);\n\n --color-success: var(--soma-c-success);\n --color-success-fg: var(--soma-c-success-fg);\n --color-success-soft: var(--soma-c-success-soft);\n --color-success-on-soft: var(--soma-c-success-on-soft);\n\n --color-warning: var(--soma-c-warning);\n --color-warning-fg: var(--soma-c-warning-fg);\n --color-warning-soft: var(--soma-c-warning-soft);\n --color-warning-on-soft: var(--soma-c-warning-on-soft);\n\n --color-danger: var(--soma-c-danger);\n --color-danger-fg: var(--soma-c-danger-fg);\n --color-danger-soft: var(--soma-c-danger-soft);\n --color-danger-on-soft: var(--soma-c-danger-on-soft);\n --color-danger-hover: var(--soma-c-danger-hover);\n --color-danger-active: var(--soma-c-danger-active);\n\n --color-info: var(--soma-c-info);\n --color-info-fg: var(--soma-c-info-fg);\n --color-info-soft: var(--soma-c-info-soft);\n --color-info-on-soft: var(--soma-c-info-on-soft);\n\n --color-ring: var(--soma-focus-ring);\n\n --spacing: var(--soma-space-1);\n\n --radius-sm: var(--soma-radius-sm);\n --radius-md: var(--soma-radius-md);\n --radius-lg: var(--soma-radius-lg);\n --radius-xl: var(--soma-radius-xl);\n --radius-full: var(--soma-radius-full);\n\n --text-xs: var(--soma-font-size-xs);\n --text-xs--line-height: var(--soma-line-height-xs);\n --text-sm: var(--soma-font-size-sm);\n --text-sm--line-height: var(--soma-line-height-sm);\n --text-base: var(--soma-font-size-md);\n --text-base--line-height: var(--soma-line-height-md);\n --text-lg: var(--soma-font-size-lg);\n --text-lg--line-height: var(--soma-line-height-lg);\n --text-xl: var(--soma-font-size-xl);\n --text-xl--line-height: var(--soma-line-height-xl);\n --text-2xl: var(--soma-font-size-xxl);\n --text-2xl--line-height: var(--soma-line-height-xxl);\n\n --font-weight-normal: var(--soma-font-weight-normal);\n --font-weight-medium: var(--soma-font-weight-medium);\n --font-weight-semibold: var(--soma-font-weight-bold);\n --font-weight-bold: var(--soma-font-weight-heavy);\n\n --font-sans: var(--soma-font-family);\n --font-mono: var(--soma-font-family-mono);\n\n --shadow-xs: var(--soma-shadow-step-0);\n --shadow-sm: var(--soma-shadow-step-1);\n --shadow-md: var(--soma-shadow-step-2);\n --shadow-lg: var(--soma-shadow-popover);\n --shadow-xl: var(--soma-shadow-dialog);\n\n --ease-standard: var(--soma-motion-easing-standard);\n --ease-enter: var(--soma-motion-easing-enter);\n --ease-exit: var(--soma-motion-easing-exit);\n --ease-emphasized: var(--soma-motion-spring-emphasized-easing);\n\n --default-transition-duration: var(--soma-motion-duration-base);\n --default-transition-timing-function: var(--soma-motion-easing-standard);\n\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 36rem;\n --container-xl: 40rem;\n --container-2xl: 48rem;\n --container-3xl: 56rem;\n --container-4xl: 64rem;\n\n --aspect-video: 16 / 9;\n}\n\n/*\n * 进退动效组:时长与缓动成对取自 design 动效真源(进入 200ms、退出 150ms,退出短于进入;减少动效档令牌自动归 100ms / linear)。\n * motion-enter 用于出现,motion-exit 用于消失,motion-emphasized 用于强调进入(弹簧曲线);使用处一律 motion-safe: 前缀。\n * 命中区 hit-area:小控件的不可见扩展点击区(伪元素铺满),最小边长取 design adaptive#/…/hitTarget(精细指针 24px、粗指针 44px,生成时换算成 rem);\n * 宿主元素自带 relative 定位,宿主本身要有 overflow 可见。\n * 文本框去自动填充底色 autofill-clear:文本类输入(input / textarea)与 appearance-none 同用,:-webkit-autofill 的黄 / 蓝底改回令牌色(surface-base / text-primary);\n * 数字框不再用原生 type=number(改 type=text + role=spinbutton,步进自绘),所以没有隐藏原生微调钮的类。\n */\n@utility motion-enter {\n transition-duration: var(--soma-motion-duration-enter);\n transition-timing-function: var(--soma-motion-easing-enter);\n}\n\n@utility motion-exit {\n transition-duration: var(--soma-motion-duration-exit);\n transition-timing-function: var(--soma-motion-easing-exit);\n}\n\n@utility motion-emphasized {\n transition-duration: var(--soma-motion-spring-emphasized-duration);\n transition-timing-function: var(--soma-motion-spring-emphasized-easing);\n}\n\n@utility autofill-clear {\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus {\n -webkit-text-fill-color: var(--soma-text-primary);\n caret-color: var(--soma-text-primary);\n box-shadow: 0 0 0 100vmax var(--soma-surface-base) inset;\n transition: background-color 9999s ease-out 0s;\n }\n}\n\n@utility hit-area {\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n width: max(100%, 1.5rem);\n height: max(100%, 1.5rem);\n transform: translate(-50%, -50%);\n }\n\n @media (pointer: coarse) {\n &::after {\n width: max(100%, 2.75rem);\n height: max(100%, 2.75rem);\n }\n }\n}\n\n/* 导航件(Menu / Navbar / MegaMenu / workspace-frame)的弹层入场;使用处一律 motion-safe: 前缀 */\n@theme inline {\n --animate-kit-menu-in: kit-menu-in var(--soma-motion-duration-base) var(--soma-motion-easing-standard);\n\n @keyframes kit-menu-in {\n from {\n opacity: 0;\n transform: translateY(-0.25rem);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n\n/* 状态件(StatusDot 脉冲、ProgressBar 不确定态):使用处一律 motion-safe: 前缀,motion-reduce 下静止 */\n@theme inline {\n --animate-kit-ping: kit-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-kit-indeterminate: kit-indeterminate 1.4s ease-in-out infinite;\n\n @keyframes kit-ping {\n 75%,\n 100% {\n opacity: 0;\n transform: scale(2.2);\n }\n }\n\n @keyframes kit-indeterminate {\n from {\n transform: translateX(-100%);\n }\n to {\n transform: translateX(250%);\n }\n }\n}\n\n/* 动效展示件(TextRotate / Hover3d / HoverGallery / Aura / Marquee):关键帧与透视、模糊刻度;使用处一律 motion-safe: 前缀,motion-reduce 下静止 */\n@theme inline {\n --perspective-normal: 1000px;\n --blur-sm: 4px;\n --blur-md: 12px;\n\n --animate-kit-rise: kit-rise var(--soma-motion-duration-base) var(--soma-motion-easing-standard);\n --animate-kit-fade: kit-fade var(--soma-motion-duration-base) var(--soma-motion-easing-standard);\n --animate-kit-aura: kit-aura 3s ease-in-out infinite;\n --animate-kit-marquee-slow: kit-marquee 40s linear infinite;\n --animate-kit-marquee-slow-paused: kit-marquee 40s linear infinite paused;\n --animate-kit-marquee-normal: kit-marquee 25s linear infinite;\n --animate-kit-marquee-normal-paused: kit-marquee 25s linear infinite paused;\n --animate-kit-marquee-fast: kit-marquee 12s linear infinite;\n --animate-kit-marquee-fast-paused: kit-marquee 12s linear infinite paused;\n\n @keyframes kit-rise {\n from {\n opacity: 0;\n transform: translateY(0.5rem);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n @keyframes kit-fade {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n\n @keyframes kit-aura {\n 0%,\n 100% {\n opacity: 0.5;\n transform: scale(1);\n }\n 50% {\n opacity: 1;\n transform: scale(1.03);\n }\n }\n\n @keyframes kit-marquee {\n from {\n transform: translateX(0);\n }\n to {\n transform: translateX(-50%);\n }\n }\n}\n\n/* 骨架屏(KitCollectionState 的 loading: skeleton):呼吸占位;使用处一律 motion-safe: 前缀,减少动效下静止 */\n@theme inline {\n --animate-kit-pulse: kit-pulse 2s ease-in-out infinite;\n\n @keyframes kit-pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n }\n}\n";
|
package/src/theme/kit-theme.css
CHANGED
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
--color-fg-subtle: var(--soma-text-muted);
|
|
17
17
|
|
|
18
18
|
--color-border: var(--soma-border-control);
|
|
19
|
+
--color-border-strong: var(--soma-border-strong);
|
|
19
20
|
--color-border-subtle: var(--soma-border-hairline);
|
|
21
|
+
--color-border-divider: var(--soma-border-divider);
|
|
20
22
|
--color-subtle: var(--soma-border-hairline);
|
|
23
|
+
--color-divider: var(--soma-border-divider);
|
|
21
24
|
--color-input: color-mix(in oklab, var(--soma-border-control) 60%, var(--soma-surface-base));
|
|
22
25
|
--color-input-hover: var(--soma-border-control);
|
|
23
26
|
|
package/src/theme/kit-theme.tpl
CHANGED
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
--color-fg-subtle: var(--soma-text-muted);
|
|
17
17
|
|
|
18
18
|
--color-border: var(--soma-border-control);
|
|
19
|
+
--color-border-strong: var(--soma-border-strong);
|
|
19
20
|
--color-border-subtle: var(--soma-border-hairline);
|
|
21
|
+
--color-border-divider: var(--soma-border-divider);
|
|
20
22
|
--color-subtle: var(--soma-border-hairline);
|
|
23
|
+
--color-divider: var(--soma-border-divider);
|
|
21
24
|
--color-input: color-mix(in oklab, var(--soma-border-control) 60%, var(--soma-surface-base));
|
|
22
25
|
--color-input-hover: var(--soma-border-control);
|
|
23
26
|
|
|
@@ -30,9 +30,12 @@ export interface KitThemeConfig {
|
|
|
30
30
|
color?: string;
|
|
31
31
|
/** 极性:light / dark / system / soft;缺省 system */
|
|
32
32
|
mode?: 'light' | 'dark' | 'system' | 'soft';
|
|
33
|
+
/** 界面规格密度档:compact(默认,中后台紧凑标准)| standard(宽松均衡档) */
|
|
34
|
+
density?: 'compact' | 'standard';
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
export const KIT_THEME_MODES: readonly string[] = ['light', 'dark', 'system', 'soft'];
|
|
38
|
+
export const KIT_THEME_DENSITIES: readonly string[] = ['compact', 'standard'];
|
|
36
39
|
const HEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
37
40
|
|
|
38
41
|
export interface KitThemeTokensResult {
|
|
@@ -96,6 +99,9 @@ export function solveKitTheme(
|
|
|
96
99
|
if (cfg.mode !== undefined && !KIT_THEME_MODES.includes(cfg.mode)) {
|
|
97
100
|
diagnostics.push(themeDiag('KIT-APP-002', 'kit.app.yaml.theme.mode', `mode「${String(cfg.mode)}」只能是 ${KIT_THEME_MODES.join(' / ')}`));
|
|
98
101
|
}
|
|
102
|
+
if (cfg.density !== undefined && !KIT_THEME_DENSITIES.includes(cfg.density)) {
|
|
103
|
+
diagnostics.push(themeDiag('KIT-APP-002', 'kit.app.yaml.theme.density', `density「${String(cfg.density)}」只能是 ${KIT_THEME_DENSITIES.join(' / ')}`));
|
|
104
|
+
}
|
|
99
105
|
if (diagnostics.length > 0) return { diagnostics };
|
|
100
106
|
|
|
101
107
|
const palette = cfg.paletteScheme === undefined ? undefined : paletteById(cfg.paletteScheme);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// 系统级角色排版规格(中后台优先默认紧凑标准,对齐 6 档字阶闭集 12px–24px,底线 12px)。
|
|
2
|
+
// 供页面框、业务组件与外部宿主自定义组件(App*)统一引用,避免手写散乱字号与字重。
|
|
3
|
+
|
|
4
|
+
import { classCandidates } from "../base/shared";
|
|
5
|
+
|
|
6
|
+
export const KIT_TYPOGRAPHY = Object.freeze({
|
|
7
|
+
/** 工作台左上品牌名(16px 半粗) */
|
|
8
|
+
brand: "text-base font-semibold text-fg",
|
|
9
|
+
/** 页面主标题 — 中后台默认紧凑档(16px 半粗) */
|
|
10
|
+
pageTitle: "text-base font-semibold text-fg",
|
|
11
|
+
/** 页面主标题 — 宽松均衡档(20px 半粗) */
|
|
12
|
+
pageTitleStandard: "text-xl font-semibold text-fg",
|
|
13
|
+
/** 卡片 / 分组 / 列表区块标题(14px 半粗) */
|
|
14
|
+
sectionTitle: "text-sm font-semibold text-fg",
|
|
15
|
+
/** 弹窗 / 抽屉标题(16px 半粗) */
|
|
16
|
+
dialogTitle: "text-base font-semibold text-fg",
|
|
17
|
+
/** 核心指标大数字(24px 半粗等宽数字) */
|
|
18
|
+
metricValue: "text-2xl font-semibold text-fg tabular-nums",
|
|
19
|
+
/** 导航菜单分组小标题(12px 中粗弱化色) */
|
|
20
|
+
menuGroup: "text-xs font-medium text-fg-subtle",
|
|
21
|
+
/** 一级 / 二级导航菜单项(14px 中粗) */
|
|
22
|
+
menuItem: "text-sm font-medium text-fg",
|
|
23
|
+
/** 页签待命态(14px 次级色) */
|
|
24
|
+
tab: "text-sm text-fg-muted",
|
|
25
|
+
/** 页签激活态(14px 中粗主色文字) */
|
|
26
|
+
tabActive: "text-sm font-medium text-primary-on-soft",
|
|
27
|
+
/** 表格列头(12px 半粗次级色) */
|
|
28
|
+
tableHead: "text-xs font-semibold text-fg-muted",
|
|
29
|
+
/** 表格数据单元格(14px 主文本色) */
|
|
30
|
+
tableCell: "text-sm text-fg",
|
|
31
|
+
/** 表单字段标签(14px 中粗主文本色) */
|
|
32
|
+
formLabel: "text-sm font-medium text-fg",
|
|
33
|
+
/** 正文主层级(14px 主文本色) */
|
|
34
|
+
body: "text-sm text-fg",
|
|
35
|
+
/** 正文次级说明(14px 次级色) */
|
|
36
|
+
bodySecondary: "text-sm text-fg-muted",
|
|
37
|
+
/** 辅助说明 / 时间戳 / 徽标底线字号(12px 弱化色,严禁小于 12px) */
|
|
38
|
+
caption: "text-xs text-fg-subtle",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type KitTypographyRole = keyof typeof KIT_TYPOGRAPHY;
|
|
42
|
+
|
|
43
|
+
/** KIT_TYPOGRAPHY 涉及的全部原子类候选(供应用自定义组件并入 appCandidates) */
|
|
44
|
+
export const KIT_TYPOGRAPHY_CLASS_CANDIDATES: readonly string[] = classCandidates(Object.values(KIT_TYPOGRAPHY));
|