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
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
import { substituteConfirmText, type SomaComponentDefinition, type SomaDataPort, type SomaRegionPort } from 'soma-core';
|
|
14
14
|
import { tableQuerySignature } from './collection-table';
|
|
15
15
|
import { KIT_ROW_TONE_CLASS } from './view-binding';
|
|
16
|
-
import { KIT_FACE_FIELD, KIT_FACE_RAISED, kitDisabledRecipe, setKitFace, type KitFaceKind } from '../recipes';
|
|
16
|
+
import { KIT_FACE_FIELD, KIT_FACE_RAISED, kitDisabledRecipe, kitSegmentRecipe, kitTextActionRecipe, setKitFace, type KitFaceKind } from '../recipes';
|
|
17
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
18
|
+
import { measureEdges } from '../base/end-edge';
|
|
17
19
|
import { CLASS_PROP, createKitController, num, str } from '../base/shared';
|
|
18
20
|
import { KIT_DROPDOWN_CLASS_CANDIDATES, onOutsidePress, overlayVerdict, releaseDropdownsIn, syncDropdown } from '../base/popup';
|
|
19
21
|
import { permissionCheckerOf } from '../base/permission-gate';
|
|
@@ -28,21 +30,24 @@ import { attachResizeHandle, type ResizeHandle } from '../frames/resize-handle';
|
|
|
28
30
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
29
31
|
import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
|
|
30
32
|
import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
|
|
33
|
+
import { KIT_ACTION_MORE_CLASS_CANDIDATES, buildActionGroup, type DomActionEntry } from './action-more';
|
|
31
34
|
|
|
32
35
|
/** 按语气取质感标记:primary 实心 / neutral 描边有面;danger 是透明底幽灵钮,无面不标 */
|
|
33
36
|
const faceOfTone = (tone: 'primary' | 'danger' | 'neutral'): KitFaceKind | null => (tone === 'danger' ? null : KIT_FACE_RAISED);
|
|
34
37
|
|
|
35
38
|
// ---------------------------------------------------------------- 类(整串字面量)
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
+
// 工具条 / 批量条里的成组动作恒单行(action-group.ts:排布引擎投影):根与组都不换行,放不下的次要动作收进「更多」
|
|
41
|
+
const ROOT_CLASS = 'flex flex-nowrap items-center justify-between gap-2 pb-2';
|
|
42
|
+
const GROUP_CLASS = 'flex min-w-0 flex-1 flex-nowrap items-center justify-end gap-2';
|
|
43
|
+
// 工具条按钮 / 分段按钮 / 文字链接:控件引擎的配方(工具条宿主 tight),不再手写按钮类串
|
|
44
|
+
const TOOL_BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar', { tight: true });
|
|
40
45
|
const SEG_GROUP_CLASS = 'inline-flex items-center rounded-md border border-border-subtle bg-surface p-0.5';
|
|
41
|
-
const SEG_BTN_CLASS =
|
|
42
|
-
const SEG_BTN_ON_CLASS =
|
|
43
|
-
const BATCH_BAR_CLASS = 'flex w-full flex-
|
|
44
|
-
const BATCH_TEXT_CLASS = 'font-medium';
|
|
45
|
-
const LINK_BTN_CLASS = '
|
|
46
|
+
const SEG_BTN_CLASS = kitSegmentRecipe(false);
|
|
47
|
+
const SEG_BTN_ON_CLASS = kitSegmentRecipe(true);
|
|
48
|
+
const BATCH_BAR_CLASS = 'flex w-full flex-nowrap items-center gap-2 whitespace-nowrap rounded-lg bg-primary-soft px-3 py-1.5 text-sm text-primary-on-soft';
|
|
49
|
+
const BATCH_TEXT_CLASS = 'shrink-0 font-medium';
|
|
50
|
+
const LINK_BTN_CLASS = kitTextActionRecipe('primary');
|
|
46
51
|
const CHECK_TEXT_CLASS = 'text-sm text-fg';
|
|
47
52
|
const PANEL_CHECK_CLASS = 'w-full px-2 py-1 text-sm text-fg hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
48
53
|
const PANEL_CHECK_LOCKED_CLASS = 'w-full px-2 py-1 text-sm';
|
|
@@ -92,7 +97,7 @@ export const KIT_TABLE_TOOLS_CLASS_CANDIDATES: readonly string[] = [
|
|
|
92
97
|
CHECK_TEXT_CLASS, PANEL_CHECK_CLASS, PANEL_CHECK_LOCKED_CLASS, ...KIT_CHECK_CLASS_CANDIDATES, ANCHOR_CLASS, PANEL_BASE, PANEL_ITEM_CLASS, PANEL_ITEM_LOCKED_CLASS, PANEL_FOOT_CLASS, NOTICE_CLASS, NOTICE_ERR_CLASS,
|
|
93
98
|
EDIT_CELL_CLASS, EDIT_INPUT_CLASS, EDIT_DATE_CLASS, EDIT_SELECT_CLASS, EDIT_ERR_CLASS, HIDDEN_CLASS, BUSY_TABLE_CLASS, BUSY_BTN_CLASS,
|
|
94
99
|
...KIT_DATE_CLASS_CANDIDATES, ...KIT_LISTBOX_CLASS_CANDIDATES,
|
|
95
|
-
...Object.values(ACTION_BUTTON_CLASS), ...KIT_TABLE_ACTIONS_CLASS_CANDIDATES, ...KIT_DROPDOWN_CLASS_CANDIDATES,
|
|
100
|
+
...Object.values(ACTION_BUTTON_CLASS), ...KIT_TABLE_ACTIONS_CLASS_CANDIDATES, ...KIT_DROPDOWN_CLASS_CANDIDATES, ...KIT_ACTION_MORE_CLASS_CANDIDATES,
|
|
96
101
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== ''));
|
|
97
102
|
|
|
98
103
|
// ---------------------------------------------------------------- 纯函数
|
|
@@ -513,8 +518,7 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
513
518
|
|
|
514
519
|
const applyEdges = (): void => {
|
|
515
520
|
if (!table || P().scroll !== true) return;
|
|
516
|
-
const left = table
|
|
517
|
-
const right = table.scrollLeft + table.clientWidth < table.scrollWidth - 1;
|
|
521
|
+
const { left, right } = measureEdges(table);
|
|
518
522
|
if (left) table.setAttribute('data-kit-edge-l', ''); else table.removeAttribute('data-kit-edge-l');
|
|
519
523
|
if (right) table.setAttribute('data-kit-edge-r', ''); else table.removeAttribute('data-kit-edge-r');
|
|
520
524
|
};
|
|
@@ -777,16 +781,28 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
777
781
|
/** 重新读取中:读状态 loading 且当前已有行(首次加载无行,走三态骨架,不叠加) */
|
|
778
782
|
const reading = (p: Rec): boolean => str(p.readState) === 'loading' && Array.isArray(p.rows) && p.rows.length > 0;
|
|
779
783
|
|
|
784
|
+
// 动作组「更多」菜单的清理函数(每次整体重建前先清)
|
|
785
|
+
let groupOffs: Array<() => void> = [];
|
|
786
|
+
const releaseGroups = (): void => {
|
|
787
|
+
for (const off of groupOffs) off();
|
|
788
|
+
groupOffs = [];
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
/** 工具栏:密度分段是视图模式开关(不进动作组,恒可见);刷新 / 列设置 / 导出是动作,成组经排布引擎(恒单行,放不下的次要项收进「更多」,列设置 = 主操作恒可见) */
|
|
780
792
|
const renderToolbar = (doc: Document, items: string[], busy: boolean): HTMLElement => {
|
|
781
793
|
const group = doc.createElement('div');
|
|
782
794
|
group.className = GROUP_CLASS;
|
|
795
|
+
const entries: DomActionEntry[] = [];
|
|
783
796
|
for (const it of items) {
|
|
784
797
|
if (it === 'reload') {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
798
|
+
entries.push({
|
|
799
|
+
id: 'reload', label: T('soma.kit.refresh'), importance: 'secondary',
|
|
800
|
+
button: btn(
|
|
801
|
+
doc, busy ? `${TOOL_BTN_CLASS} ${BUSY_BTN_CLASS}` : TOOL_BTN_CLASS, T('soma.kit.refresh'),
|
|
802
|
+
busy ? { 'data-kit-tool': 'reload', disabled: '', 'aria-busy': 'true' } : { 'data-kit-tool': 'reload' },
|
|
803
|
+
KIT_FACE_RAISED,
|
|
804
|
+
),
|
|
805
|
+
});
|
|
790
806
|
} else if (it === 'density') {
|
|
791
807
|
const seg = doc.createElement('div');
|
|
792
808
|
seg.className = SEG_GROUP_CLASS;
|
|
@@ -797,17 +813,23 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
797
813
|
const b = btn(doc, on ? SEG_BTN_ON_CLASS : SEG_BTN_CLASS, T(d.label), { 'data-kit-table-density': d.id, 'aria-pressed': on ? 'true' : 'false' }, on ? KIT_FACE_RAISED : null);
|
|
798
814
|
seg.appendChild(b);
|
|
799
815
|
}
|
|
816
|
+
seg.classList.add('shrink-0');
|
|
800
817
|
group.appendChild(seg);
|
|
801
818
|
} else if (it === 'columns') {
|
|
802
819
|
const anchor = doc.createElement('div');
|
|
803
820
|
anchor.className = ANCHOR_CLASS;
|
|
804
821
|
anchor.appendChild(btn(doc, TOOL_BTN_CLASS, T('soma.kit.columns'), { 'data-kit-tool': 'columns', 'aria-haspopup': 'dialog', 'aria-expanded': panelOpen ? 'true' : 'false' }, KIT_FACE_RAISED));
|
|
805
822
|
if (panelOpen) anchor.appendChild(columnPanel(doc));
|
|
806
|
-
|
|
823
|
+
entries.push({ id: 'columns', label: T('soma.kit.columns'), importance: 'primary', button: anchor });
|
|
807
824
|
} else if (it === 'export') {
|
|
808
|
-
|
|
825
|
+
entries.push({ id: 'export', label: T('soma.kit.export'), importance: 'secondary', button: btn(doc, TOOL_BTN_CLASS, T('soma.kit.export'), { 'data-kit-tool': 'export', title: T('soma.kit.export_page_hint') }, KIT_FACE_RAISED) });
|
|
809
826
|
}
|
|
810
827
|
}
|
|
828
|
+
if (entries.length > 0) {
|
|
829
|
+
const built = buildActionGroup(doc, entries);
|
|
830
|
+
groupOffs.push(built.destroy);
|
|
831
|
+
group.appendChild(built.el);
|
|
832
|
+
}
|
|
811
833
|
return group;
|
|
812
834
|
};
|
|
813
835
|
|
|
@@ -884,6 +906,8 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
884
906
|
return bar;
|
|
885
907
|
}
|
|
886
908
|
}
|
|
909
|
+
// 批量动作成组经排布引擎:恒单行,放不下的次要动作收进「更多」(危险项置末加分隔线),主操作恒在行尾可见
|
|
910
|
+
const entries: DomActionEntry[] = [];
|
|
887
911
|
for (const b of batch) {
|
|
888
912
|
if (b.permission !== '' && check !== null && !check(b.permission)) continue;
|
|
889
913
|
const busy = isKitActionBusy(batchBusyNames(b));
|
|
@@ -894,7 +918,12 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
894
918
|
}
|
|
895
919
|
const button = btn(doc, ACTION_BUTTON_CLASS[b.tone], b.name, attrs, faceOfTone(b.tone));
|
|
896
920
|
if (busy) button.disabled = true;
|
|
897
|
-
|
|
921
|
+
entries.push({ id: b.id, label: b.name, importance: b.tone === 'primary' ? 'primary' : b.tone === 'danger' ? 'danger' : 'secondary', tone: b.tone, button });
|
|
922
|
+
}
|
|
923
|
+
if (entries.length > 0) {
|
|
924
|
+
const built = buildActionGroup(doc, entries);
|
|
925
|
+
groupOffs.push(built.destroy);
|
|
926
|
+
bar.appendChild(built.el);
|
|
898
927
|
}
|
|
899
928
|
return bar;
|
|
900
929
|
};
|
|
@@ -935,6 +964,7 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
935
964
|
// 重建会销毁旧面板;开着时由 columnPanel 重新登记,关着就保持空
|
|
936
965
|
colsPanelEl = null;
|
|
937
966
|
releaseDropdownsIn(root);
|
|
967
|
+
releaseGroups();
|
|
938
968
|
root.replaceChildren();
|
|
939
969
|
if (!liveEl || liveEl.parentElement === null) {
|
|
940
970
|
liveEl = doc.createElement('div');
|
|
@@ -1113,6 +1143,7 @@ export function createKitTableTools(): SomaComponentDefinition {
|
|
|
1113
1143
|
const offs: Array<() => void> = [];
|
|
1114
1144
|
cancelHeldRebuild = () => { rebuildHeld = false; renderHeld = false; pressing = false; disarmHeld(); };
|
|
1115
1145
|
offs.push(() => cancelHeldRebuild());
|
|
1146
|
+
offs.push(() => releaseGroups());
|
|
1116
1147
|
offs.push(onKitActionBusy(() => rebuild()));
|
|
1117
1148
|
for (const sliceName of ['filter', 'view'] as const) {
|
|
1118
1149
|
const slice = regionPort()?.slice(sliceName);
|
|
@@ -818,7 +818,7 @@ export interface KitExpandIR {
|
|
|
818
818
|
}
|
|
819
819
|
|
|
820
820
|
export type KitLayoutIR =
|
|
821
|
-
| { kind: 'grid'; wrapClass: string; gridClass: string; cells: KitCell[]; /** filter 视图(cols
|
|
821
|
+
| { kind: 'grid'; wrapClass: string; gridClass: string; cells: KitCell[]; /** filter 视图(cols 排布):排布引擎的筛选区投影(档位 + 字段 [最小, 理想, 最大] 宽的类串 + 动作区 / 占位 / 提示条类),见 filter-plan.ts */ filterProjection?: import('./filter-plan').KitFilterProjection }
|
|
822
822
|
| { kind: 'rows'; wrapClass: string; rowClass: string; rows: KitCell[][] }
|
|
823
823
|
| { kind: 'flex'; wrapClass: string; cells: KitCell[] }
|
|
824
824
|
/** summary.groups:每节 = 小标题 + 一个单对象排布(grid / rows / flex) */
|
|
@@ -974,13 +974,13 @@ export interface KitFormOpts {
|
|
|
974
974
|
scrollToError?: boolean;
|
|
975
975
|
/** 必填星号在标签前(缺省在后) */
|
|
976
976
|
requiredMark?: 'start';
|
|
977
|
-
/** filter
|
|
978
|
-
collapsible?: boolean;
|
|
979
|
-
collapsedRows?: number;
|
|
980
|
-
defaultCollapsedCount?: number;
|
|
981
|
-
/** filter 字段数 > 4(或 > defaultCollapsedCount)时自动开启的更多筛选溢出标记 */
|
|
982
|
-
filterOverflow?: boolean;
|
|
977
|
+
/** filter:触发方式(即时生效档由排布引擎选定后为 change) */
|
|
983
978
|
trigger?: 'submit' | 'change';
|
|
979
|
+
/** filter:排布引擎选定的档位(instant / submit / more)与更多档钉住的字段数 */
|
|
980
|
+
filterMode?: 'instant' | 'submit' | 'more';
|
|
981
|
+
pinned?: number;
|
|
982
|
+
/** filter:页面键对档位的显式覆盖(formOptsOf 产出,render-object 选档后即删,不进最终 IR) */
|
|
983
|
+
filterOverride?: import('./filter-plan').KitFilterOverride;
|
|
984
984
|
/** groupsAs: tabs(form 的 groups 平铺成页签) */
|
|
985
985
|
groupTabs?: boolean;
|
|
986
986
|
/** 底栏动作 id(已校验为字符串数组;是否 request / download 动作在 emit 阶段核对) */
|
package/src/recipes/container.ts
CHANGED
|
@@ -2,10 +2,20 @@
|
|
|
2
2
|
// 提供 card / panel / section / well 四类 data-kit-part 常量与纯函数配方,
|
|
3
3
|
// 以及 slot 视图槽、容器 emphasis、highlight 高亮子配方函数,消除平行重复字面量。
|
|
4
4
|
|
|
5
|
+
import { arrangePairBalance } from 'soma-foundation/arrange';
|
|
5
6
|
import { classCandidates } from '../base/class-candidates';
|
|
6
7
|
import { mergeClass } from '../object-renderer/merge-class';
|
|
7
8
|
import { kitSurfaceRecipe } from './surface';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* 筛选带(R04 / 视觉语言第 1 期):列表面板顶部的下沉带(--soma-surface-band,通栏、顶部圆角随面板),取代原先的通栏 hairline;
|
|
12
|
+
* 负外边距抵消面板内边距 p-card,内容位置不变。容器内的段与段用色带与间距分,不用线(线只留给重复项之间:表格行)。
|
|
13
|
+
*/
|
|
14
|
+
export const KIT_LIST_BAR_CLASS = '-mx-card -mt-card rounded-t-lg bg-surface-band p-card';
|
|
15
|
+
|
|
16
|
+
/** 无容器列表(唯一主体 = 页面本身,container: plain)的筛选带:自己带圆角的下沉带,不再抵消面板内边距(没有面板)。 */
|
|
17
|
+
export const KIT_LIST_BAR_FLAT_CLASS = 'rounded-lg bg-surface-band p-card';
|
|
18
|
+
|
|
9
19
|
export const KIT_PART_CARD = 'card' as const;
|
|
10
20
|
export const KIT_PART_PANEL = 'panel' as const;
|
|
11
21
|
export const KIT_PART_SECTION = 'section' as const;
|
|
@@ -120,6 +130,10 @@ export const KIT_SHELL_FLAT_MARK = ` ${KIT_SHELL_FLAT_ATTR}="true"`;
|
|
|
120
130
|
/** 主从工作台根标记,及「辅助栏里的结果面板尚无结果」状态标记(打在根上,壳上的 `group-data-kit-aside-idle/ms:` 变体据此收起辅助栏、让中栏占满) */
|
|
121
131
|
export const KIT_MS_ROOT_ATTR = 'data-kit-ms-root' as const;
|
|
122
132
|
export const KIT_MS_ASIDE_IDLE_ATTR = 'data-kit-aside-idle' as const;
|
|
133
|
+
/** 概况条成员(应用组件)没有可显示的概况(缺失 / 门禁未过)时,在自己的宿主上打这个属性;条内成员全部带它时整条概况条不渲染(结构 CSS),由下方的卡自己说明 */
|
|
134
|
+
export const KIT_SUMMARY_EMPTY_ATTR = 'data-kit-summary-empty' as const;
|
|
135
|
+
/** 面板主体(应用组件)整个就是一行空态时,在自己的宿主上打这个属性;面板里的组件宿主全部带它时面板不画卡(无边框 / 底色 / 阴影 / 内边距),只留标题与一行空态(与列表页空态同版式) */
|
|
136
|
+
export const KIT_HOST_EMPTY_ATTR = 'data-kit-host-empty' as const;
|
|
123
137
|
|
|
124
138
|
export type KitShellTone = 'raised' | 'base' | 'sunken';
|
|
125
139
|
|
|
@@ -205,6 +219,23 @@ function collectContainerRecipeCandidates(): string[] {
|
|
|
205
219
|
return classes;
|
|
206
220
|
}
|
|
207
221
|
|
|
222
|
+
/**
|
|
223
|
+
* 并排块配比的类串(真源 kit-arrange#pairBalance,判定在 foundation 的 arrangePairBalance):两个并排块(概况 / 汇总类,如「谁没交」|「谁有风险」)
|
|
224
|
+
* 内容单位数(行 / 条,空态算 1)悬殊时,少的一侧收窄到内容宽、多的一侧吃余量;否则等宽并排。窄于 @3xl 一律上下堆叠。
|
|
225
|
+
* 调用方把 root / a / b 写到容器与两个块上;a、b 是块的位置(第一块 / 第二块)。
|
|
226
|
+
*/
|
|
227
|
+
export interface KitPairBalanceClasses { readonly mode: 'equal' | 'fit-a' | 'fit-b'; readonly root: string; readonly a: string; readonly b: string }
|
|
228
|
+
const PAIR_EQUAL = 'grid grid-cols-1 gap-x-section gap-y-region @3xl:grid-cols-2';
|
|
229
|
+
const PAIR_FIT = 'flex flex-col gap-x-section gap-y-region @3xl:flex-row';
|
|
230
|
+
const PAIR_LIGHT = 'min-w-0 @3xl:w-fit @3xl:max-w-xs @3xl:shrink-0';
|
|
231
|
+
const PAIR_HEAVY = 'min-w-0 @3xl:flex-1 @3xl:max-w-2xl';
|
|
232
|
+
export function kitPairBalanceRecipe(unitsA: number, unitsB: number): KitPairBalanceClasses {
|
|
233
|
+
const { mode } = arrangePairBalance(unitsA, unitsB);
|
|
234
|
+
if (mode === 'equal') return { mode, root: PAIR_EQUAL, a: 'min-w-0', b: 'min-w-0' };
|
|
235
|
+
return { mode, root: PAIR_FIT, a: mode === 'fit-a' ? PAIR_LIGHT : PAIR_HEAVY, b: mode === 'fit-b' ? PAIR_LIGHT : PAIR_HEAVY };
|
|
236
|
+
}
|
|
237
|
+
export const KIT_PAIR_BALANCE_CLASS_CANDIDATES: readonly string[] = classCandidates(PAIR_EQUAL, PAIR_FIT, PAIR_LIGHT, PAIR_HEAVY, 'min-w-0');
|
|
238
|
+
|
|
208
239
|
export const KIT_CONTAINER_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
209
240
|
collectContainerRecipeCandidates(),
|
|
210
241
|
);
|
package/src/recipes/control.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
// 控件配方(control.ts
|
|
1
|
+
// 控件配方(control.ts):覆盖单行输入、选择器触发器、多行文本(多行不进胶囊圆角)、按钮与徽标、行内文字链接、分段按钮、说明钮,
|
|
2
2
|
// 统一高度(sm / md / lg)、内边距、边框与圆角,并提供 data-kit-part 常量标识。
|
|
3
|
+
//
|
|
4
|
+
// 本文件只做「配方出口」:高度 / 内边距 / 间距 / 字号档 / 圆角 / 变体的面与状态层 / 焦点环 / 禁用态的取值与类集合全部在
|
|
5
|
+
// soma-design/spec/pipeline/kit-control.json,求解在 soma-foundation/kit-control(控件几何引擎,E6),这里不写任何 h-* / px-* / text-* / rounded-* 字面。
|
|
6
|
+
// 按钮、输入、选择器、徽标、分段、行内操作、说明钮一律经 kitControlRecipe / kitTextActionRecipe / kitSegmentRecipe / kitHelpTriggerRecipe 取类串,
|
|
7
|
+
// 不再手写各自的按钮类串(原六套并存已迁入)。
|
|
3
8
|
|
|
4
|
-
import {
|
|
9
|
+
import { controlRecipe, controlSizeClasses } from 'soma-foundation/kit-control';
|
|
5
10
|
import { classCandidates } from '../base/class-candidates';
|
|
6
11
|
import type { KitSize } from '../base/shared';
|
|
7
|
-
import { kitDisabledRecipe, kitFocusRingRecipe, kitInvalidRecipe } from './state';
|
|
8
|
-
|
|
9
|
-
/** 小号控件高度类(间距单位倍数,读 design 真源 kit-nine-dim.json#structure.smallControlHeightUnits:标准密度 6 × 4 = 24px,随密度同比走) */
|
|
10
|
-
const SMALL_CONTROL_H = `h-${KIT_NINE_DIM.structure.smallControlHeightUnits}`;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 按钮按下反馈:自定义工具类 press-feedback(kit-theme.tpl),按下时 transform 取 --soma-lift-press(design motion.json#lift.pressScale 0.985);
|
|
14
|
-
* 只在 prefers-reduced-motion: no-preference 下生效,减少动效下令牌同时被 design reducedMotion 归 none。
|
|
15
|
-
*/
|
|
16
|
-
const PRESS_FEEDBACK = 'press-feedback';
|
|
17
12
|
|
|
18
13
|
export const KIT_PART_CONTROL = 'control' as const;
|
|
19
14
|
export const KIT_PART_BUTTON = 'button' as const;
|
|
@@ -35,6 +30,9 @@ export type KitControlVariant =
|
|
|
35
30
|
| 'danger'
|
|
36
31
|
| 'ghost'
|
|
37
32
|
| 'tonal'
|
|
33
|
+
| 'dangerSoft'
|
|
34
|
+
| 'dangerOutline'
|
|
35
|
+
| 'quiet'
|
|
38
36
|
| 'badge';
|
|
39
37
|
|
|
40
38
|
export interface KitControlRecipeOptions {
|
|
@@ -43,39 +41,23 @@ export interface KitControlRecipeOptions {
|
|
|
43
41
|
invalid?: boolean;
|
|
44
42
|
disabled?: boolean;
|
|
45
43
|
multiline?: boolean;
|
|
44
|
+
/** 工具条按钮:横向内边距降一档(四元组其余不变);只对按钮变体生效 */
|
|
45
|
+
tight?: boolean;
|
|
46
|
+
/** 鼠标指针(cursor-pointer):<button> 在页头 / 外壳里要手形时给 */
|
|
47
|
+
pointer?: boolean;
|
|
48
|
+
/** <a> 链接宿主:没有 enabled 伪类,换成裸伪类并加 no-underline */
|
|
49
|
+
link?: boolean;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
const SINGLE_LINE_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string }>> = Object.freeze({
|
|
49
|
-
// 控件高度档(默认主题):小号读真源 structure.smallControlHeightUnits(24)、标准 32 = h-8(间距单位 4 × 8,与 design 真源 density.controlUnits = 8 同值)
|
|
50
|
-
sm: { h: SMALL_CONTROL_H, px: 'px-2.5', text: 'text-sm' },
|
|
51
|
-
md: { h: 'h-8', px: 'px-3', text: 'text-sm' },
|
|
52
|
-
lg: { h: 'h-10', px: 'px-4', text: 'text-base' },
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const BUTTON_SIZE_CLASS: Readonly<Record<KitControlSize, { h: string; px: string; text: string; gap: string }>> = Object.freeze({
|
|
56
|
-
sm: { h: SMALL_CONTROL_H, px: 'px-3', text: 'text-sm', gap: 'gap-1' },
|
|
57
|
-
md: { h: 'h-8', px: 'px-4', text: 'text-sm', gap: 'gap-2' },
|
|
58
|
-
lg: { h: 'h-10', px: 'px-5', text: 'text-base', gap: 'gap-2' },
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const MULTILINE_SIZE_CLASS: Readonly<Record<KitControlSize, { minH: string; px: string; py: string; text: string }>> = Object.freeze({
|
|
62
|
-
sm: { minH: 'min-h-20', px: 'px-2.5', py: 'py-1.5', text: 'text-sm' },
|
|
63
|
-
md: { minH: 'min-h-24', px: 'px-3', py: 'py-2', text: 'text-sm' },
|
|
64
|
-
lg: { minH: 'min-h-28', px: 'px-4', py: 'py-2.5', text: 'text-base' },
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const BADGE_SIZE_CLASS: Readonly<Record<KitControlSize, string>> = Object.freeze({
|
|
68
|
-
sm: 'h-5 px-1.5 text-xs gap-1',
|
|
69
|
-
md: 'h-6 px-2 text-xs gap-1',
|
|
70
|
-
lg: 'h-7 px-2.5 text-sm gap-1.5',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
52
|
const BUTTON_VARIANTS: ReadonlySet<KitControlVariant> = new Set([
|
|
74
53
|
'primary',
|
|
75
54
|
'neutral',
|
|
76
55
|
'danger',
|
|
77
56
|
'ghost',
|
|
78
57
|
'tonal',
|
|
58
|
+
'dangerSoft',
|
|
59
|
+
'dangerOutline',
|
|
60
|
+
'quiet',
|
|
79
61
|
]);
|
|
80
62
|
|
|
81
63
|
/**
|
|
@@ -95,9 +77,7 @@ export function kitButtonEdgeRecipe(): string {
|
|
|
95
77
|
* 供 input.ts 的 BOX_SIZE 等直接同源调用,严禁 .split / .find 回捞。
|
|
96
78
|
*/
|
|
97
79
|
export function kitControlSizeRecipe(size: KitControlSize = 'md'): string {
|
|
98
|
-
|
|
99
|
-
const sz = SINGLE_LINE_SIZE_CLASS[normalized];
|
|
100
|
-
return `${sz.h} ${sz.px} ${sz.text}`;
|
|
80
|
+
return controlSizeClasses('field', size).join(' ');
|
|
101
81
|
}
|
|
102
82
|
|
|
103
83
|
/**
|
|
@@ -111,124 +91,41 @@ export function kitControlPartOf(options: KitControlRecipeOptions = {}): KitCont
|
|
|
111
91
|
}
|
|
112
92
|
|
|
113
93
|
/**
|
|
114
|
-
* 控件配方纯函数:按「骨架 + 变体 + 档位(size / variant / invalid / disabled / multiline)」返回标准 Tailwind
|
|
94
|
+
* 控件配方纯函数:按「骨架 + 变体 + 档位(size / variant / invalid / disabled / multiline)」返回标准 Tailwind 类串(取自控件几何引擎)。
|
|
115
95
|
* 多行文本(multiline: true)固定采用容器级圆角 rounded-md,不进入单行胶囊圆角(rounded-full)。
|
|
116
96
|
*/
|
|
117
97
|
export function kitControlRecipe(options: KitControlRecipeOptions = {}): string {
|
|
118
|
-
const size: KitControlSize = options.size === 'sm' || options.size === 'lg' ? options.size : 'md';
|
|
119
98
|
const variant: KitControlVariant = options.variant ?? 'outline';
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const parts = [
|
|
126
|
-
'inline-flex items-center justify-center rounded-full transition-colors',
|
|
127
|
-
BADGE_SIZE_CLASS[size],
|
|
128
|
-
'bg-surface-sunken font-medium text-fg-muted',
|
|
129
|
-
];
|
|
130
|
-
if (invalid) parts.push(kitInvalidRecipe(true));
|
|
131
|
-
if (disabled) parts.push(kitDisabledRecipe('text'));
|
|
132
|
-
return parts.filter(Boolean).join(' ');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const isButton = !multiline && BUTTON_VARIANTS.has(variant);
|
|
136
|
-
const focusCls = kitFocusRingRecipe(isButton ? 'button' : 'control');
|
|
137
|
-
const disabledCls = kitDisabledRecipe(isButton ? 'button' : 'control');
|
|
138
|
-
const activeDisabledCls = disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
139
|
-
const invalidCls = kitInvalidRecipe(invalid);
|
|
140
|
-
|
|
141
|
-
if (isButton) {
|
|
142
|
-
const sz = BUTTON_SIZE_CLASS[size];
|
|
143
|
-
let middle = '';
|
|
144
|
-
switch (variant) {
|
|
145
|
-
case 'primary':
|
|
146
|
-
middle = `bg-primary ${sz.px} ${sz.text} font-medium text-primary-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-primary-hover enabled:active:bg-primary-active`;
|
|
147
|
-
break;
|
|
148
|
-
case 'neutral':
|
|
149
|
-
// 带文字的中性按钮的描边走「按钮描边」令牌(--soma-button-border-color,随九维边界维度求解:无边框 / 色块档降为弱描边,其余档 = 控件描边);
|
|
150
|
-
// 输入框 / 选择框 / 多行文本仍走 border-input(≥ 3:1,不豁免)
|
|
151
|
-
middle = `${BUTTON_EDGE_CLASS} bg-surface ${sz.px} ${sz.text} font-medium text-fg transition-colors ${PRESS_FEEDBACK} state-layer enabled:hover:border-button-edge-hover`;
|
|
152
|
-
// 悬停 / 按下 = 白底上叠统一状态层(state-layer 工具类,8% / 12%,底色不换,三态各自可辨);文字对比由 G82 的状态层配对判;按下与悬停同时命中时描边已是悬停描边(控件描边)
|
|
153
|
-
break;
|
|
154
|
-
case 'danger':
|
|
155
|
-
middle = `bg-danger ${sz.px} ${sz.text} font-medium text-danger-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-danger-hover enabled:active:bg-danger-active`;
|
|
156
|
-
break;
|
|
157
|
-
case 'ghost':
|
|
158
|
-
// 悬停 / 按下读统一状态层阶梯(真源 structure.stateLayer:墨色 4% / 8%),不再散写 bg-fg/8、/12
|
|
159
|
-
middle = `${sz.px} ${sz.text} font-medium text-fg transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-state-layer-hover enabled:active:bg-state-layer-press`;
|
|
160
|
-
break;
|
|
161
|
-
case 'tonal':
|
|
162
|
-
// 柔和底(primary-soft)上的悬停 / 按下:同一阶梯百分比叠主色(--soma-state-layer-tonal-*),不再用 /70 /50 透明度
|
|
163
|
-
middle = `bg-primary-soft ${sz.px} ${sz.text} font-medium text-primary-on-soft transition-colors ${PRESS_FEEDBACK} enabled:hover:bg-state-layer-tonal-hover enabled:active:bg-state-layer-tonal-press`;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
return [
|
|
167
|
-
`inline-flex ${sz.h} items-center justify-center ${sz.gap} whitespace-nowrap rounded-md`,
|
|
168
|
-
middle,
|
|
169
|
-
focusCls,
|
|
170
|
-
disabledCls,
|
|
171
|
-
activeDisabledCls,
|
|
172
|
-
invalidCls,
|
|
173
|
-
].filter(Boolean).join(' ');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (multiline) {
|
|
177
|
-
const sz = MULTILINE_SIZE_CLASS[size];
|
|
178
|
-
return [
|
|
179
|
-
'block w-full appearance-none autofill-clear resize-none rounded-md border border-input bg-surface',
|
|
180
|
-
sz.px,
|
|
181
|
-
sz.py,
|
|
182
|
-
sz.text,
|
|
183
|
-
'text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover',
|
|
184
|
-
focusCls,
|
|
185
|
-
disabledCls,
|
|
186
|
-
'read-only:bg-surface-sunken',
|
|
187
|
-
activeDisabledCls,
|
|
188
|
-
invalidCls,
|
|
189
|
-
].filter(Boolean).join(' ');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// 单行控件(Input / Select / Date 等)
|
|
193
|
-
const sz = SINGLE_LINE_SIZE_CLASS[size];
|
|
194
|
-
|
|
195
|
-
if (variant === 'filled') {
|
|
196
|
-
return [
|
|
197
|
-
`block ${sz.h} w-full appearance-none autofill-clear rounded-md border border-transparent bg-surface-sunken ${sz.px} ${sz.text} text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-border focus-visible:bg-surface`,
|
|
198
|
-
focusCls,
|
|
199
|
-
disabledCls,
|
|
200
|
-
'read-only:bg-surface-sunken',
|
|
201
|
-
activeDisabledCls,
|
|
202
|
-
invalidCls,
|
|
203
|
-
].filter(Boolean).join(' ');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return [
|
|
207
|
-
`block ${sz.h} w-full appearance-none autofill-clear rounded-md border border-input bg-surface ${sz.px} ${sz.text} text-fg transition-colors placeholder:text-fg-subtle enabled:hover:border-input-hover`,
|
|
208
|
-
focusCls,
|
|
209
|
-
disabledCls,
|
|
210
|
-
'read-only:bg-surface-sunken',
|
|
211
|
-
activeDisabledCls,
|
|
212
|
-
invalidCls,
|
|
213
|
-
].filter(Boolean).join(' ');
|
|
99
|
+
const common = { size: options.size, invalid: options.invalid, disabled: options.disabled };
|
|
100
|
+
if (options.multiline) return controlRecipe({ part: 'multiline', ...common });
|
|
101
|
+
if (variant === 'badge') return controlRecipe({ part: 'badge', ...common });
|
|
102
|
+
if (BUTTON_VARIANTS.has(variant)) return controlRecipe({ part: 'button', variant, tight: options.tight, pointer: options.pointer, link: options.link, ...common });
|
|
103
|
+
return controlRecipe({ part: 'field', variant, ...common });
|
|
214
104
|
}
|
|
215
105
|
|
|
216
|
-
export type KitTextActionTone = 'primary' | 'neutral' | 'danger';
|
|
106
|
+
export type KitTextActionTone = 'primary' | 'neutral' | 'danger' | 'quiet';
|
|
217
107
|
|
|
218
108
|
/**
|
|
219
109
|
* 行内操作的文字链接配方(表格 / 树表 / 虚拟表的操作列与「更多」触发器):
|
|
220
110
|
* 无底无描边,primary / neutral 同为主色文字(primary-on-soft 压表面,配对 primary-on-soft-surface),danger 为危险语义色文字(danger-on-soft-surface);
|
|
221
|
-
* 点击热区高度
|
|
111
|
+
* 点击热区高度 = 标准控件高(不低于原按钮),负外边距把它在行里的占高收回到一行文字(表格行高因此固定一档,不被操作列撑高);焦点环与禁用态走控件引擎。
|
|
112
|
+
* px-0:<button> 没有 preflight,浏览器默认左右内边距 6px 会让文字比表头「操作」缩进 6px,显式清零使首个操作与表头同一左缘。
|
|
222
113
|
*/
|
|
223
114
|
export function kitTextActionRecipe(tone: KitTextActionTone = 'primary'): string {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
115
|
+
return controlRecipe({ part: 'textAction', tone });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 分段按钮(工具条里的视图 / 密度切换等):on 为选中态(主色浅底),off 为待命态;选中项不加字重差(两态字重同为 medium,宽度不跳)。 */
|
|
119
|
+
export function kitSegmentRecipe(on = false): string {
|
|
120
|
+
return controlRecipe({ part: 'segment', on });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 说明气泡触发钮(字段 help 的「i」小图标钮:列头 / 摘要标签旁;点读气泡走 kitTooltip,按需挂载,见 base/hint-tips.ts)。
|
|
125
|
+
* 小圆钮、弱化色、悬停转正文色;焦点环统一走 button 档。
|
|
126
|
+
*/
|
|
127
|
+
export function kitHelpTriggerRecipe(): string {
|
|
128
|
+
return controlRecipe({ part: 'help' });
|
|
232
129
|
}
|
|
233
130
|
|
|
234
131
|
const ALL_VARIANTS: readonly KitControlVariant[] = Object.freeze([
|
|
@@ -239,6 +136,9 @@ const ALL_VARIANTS: readonly KitControlVariant[] = Object.freeze([
|
|
|
239
136
|
'danger',
|
|
240
137
|
'ghost',
|
|
241
138
|
'tonal',
|
|
139
|
+
'dangerSoft',
|
|
140
|
+
'dangerOutline',
|
|
141
|
+
'quiet',
|
|
242
142
|
'badge',
|
|
243
143
|
]);
|
|
244
144
|
const ALL_SIZES: readonly KitControlSize[] = Object.freeze(['sm', 'md', 'lg']);
|
|
@@ -255,23 +155,25 @@ function collectControlRecipeCandidates(): string[] {
|
|
|
255
155
|
}
|
|
256
156
|
}
|
|
257
157
|
}
|
|
158
|
+
// 宿主选项(工具条 tight / 手形 / 链接宿主)只对按钮变体生效
|
|
159
|
+
if (BUTTON_VARIANTS.has(variant)) {
|
|
160
|
+
classes.push(kitControlRecipe({ variant, size, tight: true }));
|
|
161
|
+
classes.push(kitControlRecipe({ variant, size, pointer: true }));
|
|
162
|
+
classes.push(kitControlRecipe({ variant, size, pointer: true, link: true }));
|
|
163
|
+
classes.push(kitControlRecipe({ variant, size, tight: true, pointer: true }));
|
|
164
|
+
}
|
|
258
165
|
}
|
|
259
166
|
}
|
|
260
167
|
return classes;
|
|
261
168
|
}
|
|
262
169
|
|
|
263
|
-
/**
|
|
264
|
-
* 说明气泡触发钮(字段 help 的「i」小图标钮:列头 / 摘要标签旁;点读气泡走 kitTooltip,按需挂载,见 base/hint-tips.ts)。
|
|
265
|
-
* 小圆钮、弱化色、悬停转正文色;焦点环统一走 button 档。
|
|
266
|
-
*/
|
|
267
|
-
const HELP_TRIGGER_CLASS = 'hit-area ms-1 inline-flex h-5 w-5 shrink-0 p-0 items-center justify-center rounded-full align-middle text-fg-subtle transition-colors hover:text-fg';
|
|
268
|
-
export function kitHelpTriggerRecipe(): string {
|
|
269
|
-
return `${HELP_TRIGGER_CLASS} ${kitFocusRingRecipe('button')}`;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
170
|
export const KIT_CONTROL_RECIPE_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
273
171
|
collectControlRecipeCandidates(),
|
|
274
172
|
kitHelpTriggerRecipe(),
|
|
275
173
|
kitTextActionRecipe('primary'),
|
|
174
|
+
kitTextActionRecipe('neutral'),
|
|
276
175
|
kitTextActionRecipe('danger'),
|
|
176
|
+
kitTextActionRecipe('quiet'),
|
|
177
|
+
kitSegmentRecipe(false),
|
|
178
|
+
kitSegmentRecipe(true),
|
|
277
179
|
);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// 强调等级配方(emphasis.ts):元素按「角色」由编译器自动定级,等级 → 外观的映射只有一张表(真源 kit-limits#emphasis,生成投影 KIT_EMPHASIS)。
|
|
2
|
+
//
|
|
3
|
+
// 视觉语言落地第 1 期(R01 / R10 / R12 / R18):问题不是缺变体(kit-control 早有 primary / tonal / ghost / quiet / dangerSoft),
|
|
4
|
+
// 而是各构件默认全部写死 `neutral`(灰描边线框),有限的对比手段被平均撒开。这里把「该元素在本屏有多重要」变成一个输入:
|
|
5
|
+
// · button.region 区域主动作(每个页面 / 页签 / 叠层至多一个,primaryPerPage)→ 实心主按钮
|
|
6
|
+
// · button.toolbar 工具条 / 分页 / 取消 / 重置这类次级动作 → 色调按钮(品牌浅色填充,无描边线框)
|
|
7
|
+
// · button.quiet 三级动作 → 文字按钮(ghost)
|
|
8
|
+
// · button.danger 危险的次级动作 → 危险色调(透明底危险字)
|
|
9
|
+
// · rowAction.lead / rest / danger 行内动作:首个为主(品牌色)、其余退后(弱化色)、危险动作保持危险色并与前者隔开(间距另有 dangerSeparatorRem)
|
|
10
|
+
// · status 带语气的状态 → 状态徽标(浅色底 + on-soft 字 + 6px 圆点)
|
|
11
|
+
// · stat.value 统计数字保持中性墨色(有语义时才用语义色,且彩色文字只走 on-soft 角色)
|
|
12
|
+
// 取值(角色 → 变体 / 语气 / 形态)只在真源,这里不写任何一个变体名字面量以外的取值;各构件取变体一律经本文件,不再各写 'neutral'。
|
|
13
|
+
|
|
14
|
+
import { KIT_EMPHASIS } from 'soma-foundation/kit-limits';
|
|
15
|
+
import { kitControlRecipe, kitTextActionRecipe, type KitControlRecipeOptions, type KitControlVariant, type KitTextActionTone } from './control';
|
|
16
|
+
|
|
17
|
+
type EmphasisRoles = typeof KIT_EMPHASIS.roles;
|
|
18
|
+
/** 按钮角色(取变体的角色) */
|
|
19
|
+
export type KitEmphasisButtonRole = Extract<keyof EmphasisRoles, `button.${string}`>;
|
|
20
|
+
/** 行内动作的秩 */
|
|
21
|
+
export type KitRowActionRank = 'lead' | 'rest' | 'danger';
|
|
22
|
+
|
|
23
|
+
/** 每屏主焦点数的上限(一个页面 / 每个页签 / 每个叠层各至多这么多个 primary;编译期级联 compile/page-composition#capActionEmphasis(经 foundation 的 arrangeActionEmphasis)与渲染判定 CP01 读它) */
|
|
24
|
+
export const KIT_EMPHASIS_PRIMARY_PER_PAGE: number = KIT_EMPHASIS.primaryPerPage;
|
|
25
|
+
|
|
26
|
+
/** 按钮角色 → 控件变体(真源 roles.<角色>.variant) */
|
|
27
|
+
export function kitEmphasisVariant(role: KitEmphasisButtonRole): KitControlVariant {
|
|
28
|
+
return KIT_EMPHASIS.roles[role].variant as KitControlVariant;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 强调等级 → 控件变体(编译期级联降级后改写按钮 variant 用):取该等级下的 button.* 角色(危险角色不参与,危险有自己的语气);没有对应角色的等级取最弱的按钮角色 */
|
|
32
|
+
export function kitEmphasisVariantOfLevel(level: string): KitControlVariant {
|
|
33
|
+
const buttons = (Object.keys(KIT_EMPHASIS.roles) as Array<keyof EmphasisRoles>).filter((k): k is KitEmphasisButtonRole => k.startsWith('button.') && k !== 'button.danger');
|
|
34
|
+
const hit = buttons.find((k) => KIT_EMPHASIS.roles[k].level === level) ?? buttons[buttons.length - 1]!;
|
|
35
|
+
return kitEmphasisVariant(hit);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 按角色取按钮配方类串(控件引擎的按钮配方 + 角色对应的变体;宿主选项同 kitControlRecipe) */
|
|
39
|
+
export function kitEmphasisButtonRecipe(role: KitEmphasisButtonRole, options: Omit<KitControlRecipeOptions, 'variant'> = {}): string {
|
|
40
|
+
return kitControlRecipe({ ...options, variant: kitEmphasisVariant(role) });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** 行内动作的秩 → 文字链接语气(真源 roles.rowAction.<秩>.tone) */
|
|
44
|
+
export function kitRowActionTone(rank: KitRowActionRank): KitTextActionTone {
|
|
45
|
+
return KIT_EMPHASIS.roles[`rowAction.${rank}`].tone as KitTextActionTone;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 行内动作配方类串(按秩取语气) */
|
|
49
|
+
export function kitRowActionRecipe(rank: KitRowActionRank): string {
|
|
50
|
+
return kitTextActionRecipe(kitRowActionTone(rank));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 状态徽标的 Tag 属性:真源 roles.status.form = pill → soft 变体 + 圆点(全应用统一,替换「圆点 + 正文色文字」) */
|
|
54
|
+
export function kitStatusPillProps(): { readonly variant: 'soft'; readonly dot: true } {
|
|
55
|
+
return { variant: 'soft', dot: true };
|
|
56
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// 页面框通栏(frame.bleed)配方:画布不留页边距、页头自带水平 / 顶部页边距与下分隔线、页签栏水平页边距。
|
|
2
|
+
// 页边距读真源 density.pageMarginPx(--soma-page-margin,经 px-page / pt-page 工具类),标题到首块间距读 --soma-title-block-gap(pb-title-block);
|
|
3
|
+
// 本文件没有数字。内容容器去圆角 / 去外描边由主题结构规则(nine-dim-structure 的 frame-bleed 块,据 data-kit-frame-bleed 标记)负责。
|
|
4
|
+
|
|
5
|
+
import { classCandidates } from '../base/class-candidates';
|
|
6
|
+
import { mergeClass } from '../object-renderer/merge-class';
|
|
7
|
+
|
|
8
|
+
const BLEED_CANVAS_CLASS = 'bg-surface-sunken min-h-screen text-sm text-fg';
|
|
9
|
+
const BLEED_HEADER_CLASS = 'px-page pt-page pb-title-block border-b border-border-divider @container';
|
|
10
|
+
const BLEED_HEADER_STICKY_CLASS = 'sticky top-0 z-10 bg-surface-sunken';
|
|
11
|
+
const BLEED_TAB_BAR_CLASS = 'px-page';
|
|
12
|
+
|
|
13
|
+
/** 通栏画布:与普通画布只差页边距(无 p-page) */
|
|
14
|
+
export function kitFrameBleedCanvasRecipe(): string {
|
|
15
|
+
return BLEED_CANVAS_CLASS;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 通栏页头:自带 px-page / pt-page 与下发丝线;吸顶版再加吸顶与画布底色(盖住滚上来的内容) */
|
|
19
|
+
export function kitFrameBleedHeaderRecipe(sticky: boolean): string {
|
|
20
|
+
return sticky ? mergeClass(BLEED_HEADER_STICKY_CLASS, BLEED_HEADER_CLASS) : BLEED_HEADER_CLASS;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 通栏页签栏:水平页边距 */
|
|
24
|
+
export function kitFrameBleedTabBarRecipe(): string {
|
|
25
|
+
return BLEED_TAB_BAR_CLASS;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const KIT_FRAME_BLEED_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
29
|
+
BLEED_CANVAS_CLASS,
|
|
30
|
+
BLEED_HEADER_CLASS,
|
|
31
|
+
BLEED_HEADER_STICKY_CLASS,
|
|
32
|
+
BLEED_TAB_BAR_CLASS,
|
|
33
|
+
);
|