soma-kit 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +4 -2
- package/spec/generated/kit-page.schema.json +72 -2
- package/spec/kit-grammar.json +163 -57
- package/spec/kit-grammar.schema.json +0 -24
- package/src/app/app-config.ts +1 -1
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +7 -7
- package/src/app/kit-view-context.ts +11 -2
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +30 -15
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +1 -1
- package/src/base/hint-tips.ts +1 -1
- package/src/base/index.ts +15 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +63 -27
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +2 -2
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +35 -36
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +43 -7
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +53 -59
- package/src/base/text.ts +37 -13
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +21 -13
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +2 -2
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +2 -2
- package/src/biz/category-crud/compile.ts +17 -4
- package/src/biz/category-crud/shell.ts +7 -5
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +7 -6
- package/src/biz/compose.ts +3 -3
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +6 -4
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +5 -4
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +162 -19
- package/src/biz/master-sub/detail-head.ts +7 -6
- package/src/biz/master-sub/index.ts +3 -3
- package/src/biz/master-sub/shell.ts +90 -53
- package/src/biz/multi-board/compile.ts +3 -3
- package/src/biz/multi-board/index.ts +24 -9
- package/src/biz/multi-board/prose-fold.ts +2 -2
- package/src/biz/multi-board/shell.ts +17 -13
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +9 -2
- package/src/biz/page-templates/domain-templates.ts +6 -2
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +4 -3
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +4 -4
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +4 -4
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +8 -5
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +4 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +48 -18
- package/src/biz/shared/overlay-shell.ts +63 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +8 -4
- package/src/biz/standard-crud/compile.ts +11 -4
- package/src/biz/standard-crud/shell.ts +26 -9
- package/src/biz/standard-crud/summary.ts +3 -1
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +6 -4
- package/src/biz/types.ts +11 -4
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +29 -234
- package/src/compile/component-candidates.ts +2 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +43 -13
- package/src/compile/page-composition.ts +33 -31
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +70 -32
- package/src/compile/types.ts +2 -2
- package/src/data/amount-breakdown.ts +4 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +9 -4
- package/src/data/assignment-picker.ts +28 -18
- package/src/data/async-result-panel.ts +6 -2
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +4 -3
- package/src/data/carousel.ts +11 -5
- package/src/data/chart.ts +153 -23
- package/src/data/checklist.ts +5 -4
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +7 -2
- package/src/data/confirm-dialog.ts +56 -13
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +12 -6
- package/src/data/flow-editor.ts +105 -29
- package/src/data/footer.ts +6 -2
- package/src/data/gantt.ts +11 -8
- package/src/data/hero.ts +6 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +12 -5
- package/src/data/item-list.ts +6 -5
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +11 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +23 -14
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +15 -9
- package/src/data/mockup.ts +9 -5
- package/src/data/modal-dialog.ts +39 -88
- package/src/data/navbar.ts +11 -7
- package/src/data/notice-list.ts +1 -1
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +129 -48
- package/src/data/pager.ts +12 -8
- package/src/data/panel-head.ts +1 -1
- package/src/data/permission-matrix.ts +15 -8
- package/src/data/permission-tree.ts +24 -11
- package/src/data/pricing-table.ts +8 -3
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +13 -9
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +0 -12
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +10 -5
- package/src/data/rule-builder.ts +14 -8
- package/src/data/shape-util.ts +14 -3
- package/src/data/stat-group.ts +63 -22
- package/src/data/static-lazy.ts +3 -0
- package/src/data/static-registry.ts +8 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +9 -3
- package/src/data/system-switcher.ts +15 -6
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +6 -3
- package/src/data/transfer.ts +19 -10
- package/src/data/tree-table.ts +77 -12
- package/src/data/tree.ts +5 -2
- package/src/data/virtual-rows.ts +17 -7
- package/src/data/wrap.ts +2 -2
- package/src/frames/index.ts +3 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +59 -36
- package/src/frames/page-bar.ts +4 -2
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +18 -14
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +12 -6
- package/src/frames/types.ts +3 -2
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +2 -1
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/view.ts +125 -76
- package/src/generated/kit-grammar-runtime.ts +61 -39
- package/src/i18n/kit-text.ts +114 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +31 -1
- package/src/object-renderer/action-more.ts +28 -12
- package/src/object-renderer/arrange.ts +37 -7
- package/src/object-renderer/collection-parts.ts +38 -7
- package/src/object-renderer/collection-table.ts +68 -23
- package/src/object-renderer/collection.ts +63 -30
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +8 -0
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +3 -0
- package/src/object-renderer/emit-static.ts +140 -37
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/layout-facts.ts +37 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/render-object.ts +1 -1
- package/src/object-renderer/table-actions.ts +70 -23
- package/src/object-renderer/table-tools.ts +12 -5
- package/src/object-renderer/types.ts +9 -15
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +25 -15
- package/src/recipes/control.ts +21 -3
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +12 -8
- package/src/recipes/frame-bleed.ts +3 -3
- package/src/recipes/index.ts +11 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +112 -26
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +1 -1
- package/src/recipes/stat-state.ts +1 -1
- package/src/recipes/state.ts +10 -8
- package/src/recipes/status.ts +13 -12
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +1 -1
- package/src/recipes/table-native-edit.ts +4 -4
- package/src/recipes/table-row.ts +11 -8
- package/src/recipes/tabs.ts +108 -31
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +4 -2
- package/src/recipes/typography.ts +2 -2
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -14
- package/src/theme/kit-theme.tpl +38 -14
- package/src/theme/nine-dim-structure.ts +66 -41
- package/src/theme/surface-layers.ts +11 -3
- package/src/theme/theme-tokens.ts +5 -1
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/timeline.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
9
9
|
import { bool, createKitController, formatValue, joinClass, str } from '../base/shared';
|
|
10
10
|
import { kitText } from '../i18n/kit-text';
|
|
11
|
-
import { KIT_ICON_CLASS_CANDIDATES, KIT_ICON_NAMES, kitIcon, type KitIconName } from '../
|
|
11
|
+
import { KIT_ICON_CLASS_CANDIDATES, KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
|
|
12
12
|
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
13
13
|
import {
|
|
14
14
|
classTokens, compareTime, emptyNode, keyMap, mk, rowsOf, shapeToneOf, textOf,
|
package/src/data/tour-guide.ts
CHANGED
|
@@ -22,6 +22,8 @@ import type { OverlayMount } from 'soma-core/behavior';
|
|
|
22
22
|
import { KIT_POPUP_PLACE_CLASS_CANDIDATES, popPlaceClass, resolvePopPlace } from '../base/popup';
|
|
23
23
|
import type { PopPlace } from '../base/popup';
|
|
24
24
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
25
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
26
|
+
import { mergeClass } from '../shared/merge-class';
|
|
25
27
|
|
|
26
28
|
export const KIT_TOUR_DEFAULT_MAP = Object.freeze({ id: 'id', target: 'target', title: 'title', text: 'text' });
|
|
27
29
|
|
|
@@ -33,7 +35,8 @@ const START_CLASS = 'inline-flex w-fit';
|
|
|
33
35
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
34
36
|
/** 洞比目标大一圈(px,SVG 坐标) */
|
|
35
37
|
const HOLE_PAD = 4;
|
|
36
|
-
|
|
38
|
+
// 引导卡 = 浮起表面(发丝描边 + 浮起面 + 双层浮起阴影,KT-B4)
|
|
39
|
+
const CARD_LOOK = mergeClass('pointer-events-auto flex flex-col gap-3 p-4 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', kitSurfaceRecipe('raised'));
|
|
37
40
|
/** 无目标或贴不下时:卡片落在视口底部居中(锚盒铺满视口,卡片相对它绝对定位) */
|
|
38
41
|
const CARD_FIXED_CLASS = `absolute inset-x-4 bottom-6 z-50 mx-auto w-full max-w-sm ${CARD_LOOK}`;
|
|
39
42
|
/** 有目标时:锚盒 = 目标的洞矩形,卡片用 popup 的预置方位类贴边(翻转由 resolvePopPlace 裁决) */
|
|
@@ -164,14 +167,14 @@ export function createTourGuide(): SomaComponentDefinition {
|
|
|
164
167
|
let anchored = false;
|
|
165
168
|
if (hole) {
|
|
166
169
|
setBox(hole);
|
|
167
|
-
dlg.className = `${CARD_ANCHORED_CLASS} ${popPlaceClass(CARD_PREF
|
|
170
|
+
dlg.className = `${CARD_ANCHORED_CLASS} ${popPlaceClass(CARD_PREF)}`;
|
|
168
171
|
const size = dlg.getBoundingClientRect();
|
|
169
172
|
const rtl = kitDirAt(dlg) === 'rtl';
|
|
170
173
|
const pl = resolvePopPlace(
|
|
171
174
|
{ left: hole.x, right: hole.x + hole.w, top: hole.y, bottom: hole.y + hole.h },
|
|
172
175
|
{ width: size.width, height: size.height }, { width: vw, height: vh }, CARD_PREF, CARD_GAP_PX, rtl,
|
|
173
176
|
);
|
|
174
|
-
const cls = `${CARD_ANCHORED_CLASS} ${popPlaceClass(pl
|
|
177
|
+
const cls = `${CARD_ANCHORED_CLASS} ${popPlaceClass(pl)}`;
|
|
175
178
|
if (dlg.className !== cls) dlg.className = cls;
|
|
176
179
|
const r = dlg.getBoundingClientRect();
|
|
177
180
|
anchored = r.width === 0 || (r.left >= 0 && r.top >= 0 && r.right <= vw && r.bottom <= vh);
|
package/src/data/transfer.ts
CHANGED
|
@@ -23,16 +23,19 @@ import { watchKitOutcome } from './outcome-watch';
|
|
|
23
23
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
24
24
|
import { kitText } from '../i18n/kit-text';
|
|
25
25
|
import { setKitFace } from '../recipes';
|
|
26
|
+
import { kitControlEdgeRecipe, kitControlRecipe } from '../recipes/control';
|
|
27
|
+
import { kitDivideRecipe } from '../recipes/divider';
|
|
28
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
26
29
|
import {
|
|
27
30
|
KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
|
|
28
31
|
} from '../recipes/overlay';
|
|
29
32
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
30
33
|
import { applyCompositeField, bool, createKitController, ID_PROPS, INVALID_PROPS, joinClass, setAttr, str } from '../base/shared';
|
|
31
|
-
import { kitIcon } from '../
|
|
34
|
+
import { kitIcon } from '../shared/icons';
|
|
32
35
|
import { markCheckBox } from '../base/check-core';
|
|
33
36
|
import { markKitEdge } from '../recipes/surface-edge';
|
|
34
37
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
35
|
-
import { mergeClass } from '../
|
|
38
|
+
import { mergeClass } from '../shared/merge-class';
|
|
36
39
|
import { createKitBusy, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
37
40
|
|
|
38
41
|
// ───────── 样式常量:Tailwind 类串与候选类清单 ─────────
|
|
@@ -42,17 +45,20 @@ const ROOT_CLASS = `@container flex flex-col gap-3 ${KIT_OVERLAY_ROOT_FILL_CLASS
|
|
|
42
45
|
const BODY_CLASS = 'flex flex-col gap-3 @lg:flex-row @lg:items-stretch';
|
|
43
46
|
// 浮层滚动体里(对话框 / 抽屉)两栏不再是带内边距的小卡(无边框主题下卡看不见,12px 内边距只让输入框右缘比页脚按钮右缘内缩 12px):
|
|
44
47
|
// 去内边距 / 边框 / 底色,输入框与列表直接贴浮层内容边,与页脚按钮同一条右缘
|
|
45
|
-
|
|
48
|
+
// 两侧面板外缘 = 壳配方(容器边,KT-B2);搜索框 = 控件配方;条目之间的线由父出(kitDivideRecipe,KT-B5)
|
|
49
|
+
const PANEL_CLASS = mergeClass('flex min-w-0 flex-1 flex-col gap-2 p-3 group-data-kit-overlay-scroll:border-0 group-data-kit-overlay-scroll:bg-surface-raised group-data-kit-overlay-scroll:p-0', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
46
50
|
const HEAD_CLASS = 'flex items-center justify-between gap-2 text-sm';
|
|
47
51
|
const TITLE_CLASS = 'font-medium text-fg';
|
|
48
52
|
const COUNT_CLASS = 'text-fg-muted';
|
|
49
|
-
const SEARCH_CLASS =
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
53
|
+
const SEARCH_CLASS = kitControlRecipe();
|
|
54
|
+
const ROWS_DIVIDE = kitDivideRecipe('y');
|
|
55
|
+
const BOX_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
56
|
+
const LIST_CLASS = `flex max-h-80 min-h-24 flex-col overflow-y-auto rounded-md focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring ${ROWS_DIVIDE}`;
|
|
57
|
+
const ITEM_CLASS = 'flex cursor-pointer items-center gap-2 px-2 py-1.5 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
58
|
+
const ITEM_ON_CLASS = 'flex cursor-pointer items-center gap-2 bg-primary-soft px-2 py-1.5 text-sm text-primary-on-soft';
|
|
59
|
+
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-2 px-2 py-1.5 text-sm text-fg-subtle';
|
|
54
60
|
const CURSOR_CLASS = 'ring-1 ring-inset ring-ring';
|
|
55
|
-
const BOX_CLASS =
|
|
61
|
+
const BOX_CLASS = `inline-flex size-4 shrink-0 items-center justify-center rounded-sm ${BOX_EDGE} bg-surface`;
|
|
56
62
|
const BOX_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-sm border border-primary bg-primary text-primary-fg';
|
|
57
63
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
58
64
|
const SUB_CLASS = 'truncate text-xs text-fg-muted';
|
|
@@ -461,6 +467,7 @@ export function createTransfer(): SomaComponentDefinition {
|
|
|
461
467
|
const build = (host: HTMLElement): void => {
|
|
462
468
|
const makePanel = (side: 'left' | 'right'): { panel: HTMLElement; title: HTMLElement; count: HTMLElement; search: HTMLInputElement; searchBox: HTMLElement; list: HTMLElement } => {
|
|
463
469
|
const panel = el('section', PANEL_CLASS);
|
|
470
|
+
panel.setAttribute('data-kit-container', 'card');
|
|
464
471
|
markKitEdge(panel);
|
|
465
472
|
panel.setAttribute('data-kit-list-panel', '');
|
|
466
473
|
const head = el('div', HEAD_CLASS);
|
|
@@ -472,7 +479,9 @@ export function createTransfer(): SomaComponentDefinition {
|
|
|
472
479
|
setKitFace(search, 'field');
|
|
473
480
|
search.type = 'search';
|
|
474
481
|
search.setAttribute('autocomplete', 'off');
|
|
475
|
-
|
|
482
|
+
const searchLabel = kitText(side === 'left' ? 'soma.kit.transfer_search_source' : 'soma.kit.transfer_search_target', undefined, root);
|
|
483
|
+
search.setAttribute('aria-label', searchLabel);
|
|
484
|
+
search.placeholder = searchLabel;
|
|
476
485
|
const list = el('div', LIST_CLASS);
|
|
477
486
|
list.setAttribute('role', 'listbox');
|
|
478
487
|
list.setAttribute('aria-multiselectable', 'true');
|
package/src/data/tree-table.ts
CHANGED
|
@@ -18,16 +18,20 @@
|
|
|
18
18
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
19
19
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
20
20
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
21
|
-
import { TAG_CLASS } from '../base/tag';
|
|
21
|
+
import { DOT_CORE, DOT_RING, DOT_ROOT, DOT_TEXT, DOT_WRAP, TAG_CLASS } from '../base/tag';
|
|
22
|
+
import { COPY_BTN_CLASS, COPY_TEXT_CLASS } from '../base/text';
|
|
23
|
+
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
24
|
+
import { KIT_TAG_UNKNOWN_DOT_CORE, KIT_TAG_UNKNOWN_SOFT } from '../recipes/status';
|
|
22
25
|
import { permissionCheckerOf } from '../base/permission-gate';
|
|
23
26
|
import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, setMarkLabel } from '../base/check-core';
|
|
24
|
-
import { CLASS_PROP, bool, createKitController, displayOf, joinClass, optionsOf, str, toneOf } from '../base/shared';
|
|
27
|
+
import { CLASS_PROP, bool, createKitController, displayOf, joinClass, optionsOf, sizeOf, str, toneOf, type KitSize } from '../base/shared';
|
|
25
28
|
import { kitLocaleAt, kitText } from '../i18n/kit-text';
|
|
26
29
|
import { setKitFace } from '../recipes';
|
|
27
30
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
28
|
-
import { kitIcon } from '../
|
|
31
|
+
import { kitIcon } from '../shared/icons';
|
|
29
32
|
import { KIT_TREE_TABLE } from '../object-renderer/defaults';
|
|
30
33
|
import { KIT_PART_TABLE_ROW } from '../recipes/table-row';
|
|
34
|
+
import { kitStripBoundaryClasses } from '../recipes/divider';
|
|
31
35
|
import { ROW_ACTION_BUTTON_CLASS, rowActionRanks, rowBusyName, removeKeyOf } from '../object-renderer/table-actions';
|
|
32
36
|
import { KIT_ROW_TONE_CLASS, rowToneClass } from '../object-renderer/view-binding';
|
|
33
37
|
import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
|
|
@@ -44,6 +48,16 @@ const SPACER_CLASS = 'inline-block h-5 w-5 shrink-0';
|
|
|
44
48
|
const TOGGLE_CLASS = 'hit-area inline-flex h-5 w-5 shrink-0 p-0 cursor-pointer items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
45
49
|
// 单元格文字:块级 + min-w-0 + 单行省略(长 ID 不再压到相邻列);被截断时悬停出全文提示(表壳带 data-kit-tips,由 base/hint-tips 按需挂)
|
|
46
50
|
const TEXT_CLASS = 'block min-w-0 truncate text-sm text-fg';
|
|
51
|
+
const CELL_TEXT_SIZE_CLASS: Readonly<Record<KitSize, string>> = Object.freeze({
|
|
52
|
+
sm: 'block min-w-0 truncate text-xs text-fg',
|
|
53
|
+
md: TEXT_CLASS,
|
|
54
|
+
lg: 'block min-w-0 truncate text-base text-fg',
|
|
55
|
+
});
|
|
56
|
+
const CELL_COPY_ROOT_CLASS: Readonly<Record<KitSize, string>> = Object.freeze({
|
|
57
|
+
sm: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-xs text-fg',
|
|
58
|
+
md: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-sm text-fg',
|
|
59
|
+
lg: 'inline-flex max-w-full min-w-0 items-center gap-2 whitespace-nowrap text-base text-fg',
|
|
60
|
+
});
|
|
47
61
|
const ACTIONS_CELL_CLASS = 'flex flex-nowrap items-center justify-end gap-x-4 whitespace-nowrap';
|
|
48
62
|
const MORE_WRAP_CLASS = 'flex items-center justify-center px-4 py-3';
|
|
49
63
|
const MORE_BUTTON_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
@@ -54,9 +68,12 @@ const CONTROL_CLASS = new WeakMap<HTMLElement, string>();
|
|
|
54
68
|
|
|
55
69
|
export const KIT_TREE_TABLE_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set([
|
|
56
70
|
ROOT_CLASS, GRID_CLASS, INDENT_CELL_CLASS, SPACER_CLASS, TOGGLE_CLASS, TEXT_CLASS,
|
|
71
|
+
...Object.values(CELL_TEXT_SIZE_CLASS), ...Object.values(CELL_COPY_ROOT_CLASS), COPY_TEXT_CLASS, COPY_BTN_CLASS,
|
|
57
72
|
...KIT_CHECK_CLASS_CANDIDATES, ACTIONS_CELL_CLASS, MORE_WRAP_CLASS, MORE_BUTTON_CLASS, ROW_FOCUS_CLASS,
|
|
58
73
|
...Object.values(ROW_ACTION_BUTTON_CLASS),
|
|
59
|
-
...Object.values(TAG_CLASS.
|
|
74
|
+
...Object.values(TAG_CLASS).flatMap((m) => Object.values(m)),
|
|
75
|
+
...Object.values(DOT_ROOT), ...Object.values(DOT_TEXT), ...Object.values(DOT_WRAP), ...Object.values(DOT_CORE), ...Object.values(DOT_RING),
|
|
76
|
+
...Object.values(KIT_TAG_UNKNOWN_SOFT), KIT_TAG_UNKNOWN_DOT_CORE,
|
|
60
77
|
...Object.values(KIT_ROW_TONE_CLASS),
|
|
61
78
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')))].sort());
|
|
62
79
|
|
|
@@ -256,11 +273,9 @@ function actionsOf(raw: unknown): ActionItem[] {
|
|
|
256
273
|
return out;
|
|
257
274
|
}
|
|
258
275
|
|
|
276
|
+
/** bordered: false 剥边界类:只经分隔线出口的剥离函数(KT-B8 第 4 点,一个决定一个出口) */
|
|
259
277
|
function stripBorderClasses(cls: string): string {
|
|
260
|
-
return cls
|
|
261
|
-
.split(/\s+/)
|
|
262
|
-
.filter((t) => t !== '' && t !== 'border' && t !== 'border-b' && t !== 'border-e' && t !== 'not-last:border-e' && !t.startsWith('border-border') && !t.startsWith('not-last:border-border'))
|
|
263
|
-
.join(' ');
|
|
278
|
+
return kitStripBoundaryClasses(cls);
|
|
264
279
|
}
|
|
265
280
|
|
|
266
281
|
function rowKeyOf(row: unknown, keyField: string): string {
|
|
@@ -520,15 +535,44 @@ export function createKitTreeTable(): SomaComponentDefinition {
|
|
|
520
535
|
onCollapse: (key) => setOpen(key, false),
|
|
521
536
|
});
|
|
522
537
|
|
|
523
|
-
/**
|
|
538
|
+
/** 单元格内容:支持 Tag(含 variant: dot / size / unknown / pulse)与 Text(含 size / copyable) */
|
|
524
539
|
const cellContent = (cell: CellDef, row: Rec): HTMLElement => {
|
|
525
540
|
const placeholder = str(cell.props.placeholder);
|
|
526
541
|
const { text, option } = displayOf(row[cell.field], optionsOf(cell.props.options), str(cell.props.format), str(cell.props.locale, kitLocaleAt(api.host) || 'zh-CN'), placeholder);
|
|
542
|
+
const size = sizeOf(cell.props.size);
|
|
527
543
|
if (cell.component === 'Tag' && text !== '') {
|
|
528
|
-
const
|
|
529
|
-
|
|
544
|
+
const rawTone = option?.tone ?? cell.props.tone;
|
|
545
|
+
const isUnknown = rawTone === 'unknown';
|
|
546
|
+
const tone = toneOf(rawTone, 'neutral');
|
|
547
|
+
if (str(cell.props.variant) === 'dot') {
|
|
548
|
+
const rootCls = isUnknown ? `${DOT_ROOT[size]} text-fg-muted` : `${DOT_ROOT[size]} ${DOT_TEXT[tone]}`;
|
|
549
|
+
const el = mk('span', rootCls);
|
|
550
|
+
const dot = mk('span', DOT_WRAP[size]);
|
|
551
|
+
dot.setAttribute('aria-hidden', 'true');
|
|
552
|
+
if (!isUnknown && bool(cell.props.pulse)) dot.appendChild(mk('span', DOT_RING[tone]));
|
|
553
|
+
dot.appendChild(mk('span', isUnknown ? KIT_TAG_UNKNOWN_DOT_CORE : DOT_CORE[tone]));
|
|
554
|
+
el.append(dot, document.createTextNode(text));
|
|
555
|
+
return el;
|
|
556
|
+
}
|
|
557
|
+
if (isUnknown) return mk('span', KIT_TAG_UNKNOWN_SOFT[size], text);
|
|
558
|
+
return mk('span', TAG_CLASS[size][tone], text);
|
|
559
|
+
}
|
|
560
|
+
const raw = row[cell.field];
|
|
561
|
+
const empty = raw === null || raw === undefined || raw === '' || (Array.isArray(raw) && raw.length === 0);
|
|
562
|
+
if (bool(cell.props.copyable) && !empty && text !== '') {
|
|
563
|
+
const wrap = mk('span', CELL_COPY_ROOT_CLASS[size]);
|
|
564
|
+
wrap.setAttribute('data-kit-copy-value', text);
|
|
565
|
+
const valEl = mk('span', COPY_TEXT_CLASS, text);
|
|
566
|
+
valEl.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
567
|
+
const btn = mk('button', COPY_BTN_CLASS, str(cell.props.copy_label, kitText('soma.kit.copy', undefined, api.host)));
|
|
568
|
+
btn.setAttribute('type', 'button');
|
|
569
|
+
btn.setAttribute('data-kit-action', 'copy');
|
|
570
|
+
if (str(cell.props.copy_label) !== '') btn.setAttribute('data-kit-copy-label', str(cell.props.copy_label));
|
|
571
|
+
if (str(cell.props.copied_label) !== '') btn.setAttribute('data-kit-copied-label', str(cell.props.copied_label));
|
|
572
|
+
wrap.append(valEl, btn);
|
|
573
|
+
return wrap;
|
|
530
574
|
}
|
|
531
|
-
return mk('span',
|
|
575
|
+
return mk('span', CELL_TEXT_SIZE_CLASS[size], text);
|
|
532
576
|
};
|
|
533
577
|
|
|
534
578
|
// ── 表格工具位里的「全部展开 / 全部收起」(页面编译放的静态链接,按对象名认领;本组件只接线与显隐)
|
|
@@ -693,9 +737,30 @@ export function createKitTreeTable(): SomaComponentDefinition {
|
|
|
693
737
|
root = rootEl;
|
|
694
738
|
alive = true;
|
|
695
739
|
const r = root;
|
|
740
|
+
const copyTimers = new WeakMap<HTMLElement, ReturnType<typeof setTimeout>>();
|
|
696
741
|
const onClick = (event: Event): void => {
|
|
697
742
|
const t = event.target as HTMLElement | null;
|
|
698
743
|
if (!t) return;
|
|
744
|
+
const copyBtn = t.closest<HTMLElement>('[data-kit-action="copy"]');
|
|
745
|
+
if (copyBtn && r.contains(copyBtn)) {
|
|
746
|
+
event.stopPropagation();
|
|
747
|
+
const copyVal = copyBtn.closest('[data-kit-copy-value]')?.getAttribute('data-kit-copy-value') ?? '';
|
|
748
|
+
const clip = typeof navigator !== 'undefined' ? navigator.clipboard : undefined;
|
|
749
|
+
if (clip && typeof clip.writeText === 'function') {
|
|
750
|
+
void clip.writeText(copyVal).then(() => {
|
|
751
|
+
const copiedLabel = copyBtn.getAttribute('data-kit-copied-label') || kitText('soma.kit.copied', undefined, r);
|
|
752
|
+
const copyLabel = copyBtn.getAttribute('data-kit-copy-label') || kitText('soma.kit.copy', undefined, r);
|
|
753
|
+
copyBtn.textContent = copiedLabel;
|
|
754
|
+
const prev = copyTimers.get(copyBtn);
|
|
755
|
+
if (prev !== undefined) clearTimeout(prev);
|
|
756
|
+
copyTimers.set(copyBtn, setTimeout(() => {
|
|
757
|
+
copyBtn.textContent = copyLabel;
|
|
758
|
+
copyTimers.delete(copyBtn);
|
|
759
|
+
}, 1500));
|
|
760
|
+
}, () => undefined);
|
|
761
|
+
}
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
699
764
|
if (t.closest('[data-kit-more]')) {
|
|
700
765
|
limit = (limit > 0 ? limit : cfg().windowThreshold) + KIT_TREE_TABLE.windowBatch;
|
|
701
766
|
paint();
|
package/src/data/tree.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
17
17
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
18
18
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
19
19
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
20
|
-
import { kitIcon } from '../
|
|
20
|
+
import { kitIcon } from '../shared/icons';
|
|
21
21
|
import { markCheckBox } from '../base/check-core';
|
|
22
22
|
import { kitText } from '../i18n/kit-text';
|
|
23
23
|
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS, KIT_STATE_PANEL_CLASS_CANDIDATES, kitEmptyPanel } from '../base/state-panel';
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
import { classTokens } from './shape-util';
|
|
29
29
|
import { provideCtxRows } from './context-menu';
|
|
30
30
|
import { aggregateCheck, nextCheckTarget } from './tree-check';
|
|
31
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
31
32
|
|
|
32
33
|
export interface KitTreeMap {
|
|
33
34
|
id: string;
|
|
@@ -49,7 +50,9 @@ const ROW_CLASS = 'flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5
|
|
|
49
50
|
const ROW_SELECTED_CLASS = 'flex cursor-pointer items-center gap-2 rounded-md bg-primary-soft px-2 py-1.5 text-primary-on-soft';
|
|
50
51
|
const ROW_DISABLED_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-md px-2 py-1.5 text-fg-subtle opacity-60';
|
|
51
52
|
const TOGGLE_CLASS = 'w-4 shrink-0 text-fg-subtle';
|
|
52
|
-
|
|
53
|
+
// 勾选框外圈 = 控件轮廓出口(KT-B1)
|
|
54
|
+
const CHECK_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
55
|
+
const CHECK_CLASS = `inline-flex size-4 shrink-0 items-center justify-center rounded-sm ${CHECK_EDGE} bg-surface`;
|
|
53
56
|
const CHECK_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-sm border border-primary bg-primary text-primary-fg';
|
|
54
57
|
const HIT_CLASS = 'rounded-sm bg-warning-soft px-0.5 text-warning-on-soft';
|
|
55
58
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
package/src/data/virtual-rows.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
24
24
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
25
25
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
26
|
-
import { TAG_CLASS } from '../base/tag';
|
|
26
|
+
import { DOT_CORE, DOT_ROOT, DOT_TEXT, DOT_WRAP, TAG_CLASS } from '../base/tag';
|
|
27
27
|
import { permissionCheckerOf } from '../base/permission-gate';
|
|
28
28
|
import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, markChecked, paintCheck, setMarkLabel } from '../base/check-core';
|
|
29
29
|
import { CLASS_PROP, bool, createKitController, displayOf, joinClass, optionsOf, str, toneOf } from '../base/shared';
|
|
@@ -37,6 +37,8 @@ import { KIT_ROW_TONE_CLASS, rowToneClass } from '../object-renderer/view-bindin
|
|
|
37
37
|
import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
|
|
38
38
|
import type { KitTableDensity } from '../object-renderer/defaults';
|
|
39
39
|
import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
|
|
40
|
+
import { KIT_PART_TABLE_ROW } from '../recipes/table-row';
|
|
41
|
+
import { kitStripBoundaryClasses } from '../recipes/divider';
|
|
40
42
|
|
|
41
43
|
const ROOT_CLASS = 'flex flex-col focus-visible:outline-none';
|
|
42
44
|
const SPACER_CLASS = 'w-full';
|
|
@@ -50,6 +52,7 @@ export const KIT_VIRTUAL_ROWS_CLASS_CANDIDATES: readonly string[] = Object.freez
|
|
|
50
52
|
...KIT_VIRTUAL_CLASS_CANDIDATES,
|
|
51
53
|
...Object.values(ROW_ACTION_BUTTON_CLASS),
|
|
52
54
|
...Object.values(TAG_CLASS.md),
|
|
55
|
+
DOT_ROOT.md, DOT_WRAP.md, ...Object.values(DOT_TEXT), ...Object.values(DOT_CORE),
|
|
53
56
|
...Object.values(KIT_ROW_TONE_CLASS),
|
|
54
57
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')))].sort());
|
|
55
58
|
|
|
@@ -105,11 +108,9 @@ function actionsOf(raw: unknown): ActionItem[] {
|
|
|
105
108
|
return out;
|
|
106
109
|
}
|
|
107
110
|
|
|
111
|
+
/** bordered: false 剥边界类:只经分隔线出口的剥离函数(KT-B8 第 4 点,一个决定一个出口) */
|
|
108
112
|
function stripBorderClasses(cls: string): string {
|
|
109
|
-
return cls
|
|
110
|
-
.split(/\s+/)
|
|
111
|
-
.filter((t) => t !== "" && t !== "border" && t !== "border-b" && t !== "border-e" && t !== "not-last:border-e" && !t.startsWith("border-border") && !t.startsWith("not-last:border-border"))
|
|
112
|
-
.join(" ");
|
|
113
|
+
return kitStripBoundaryClasses(cls);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
function rowKeyOf(row: unknown, keyField: string): string {
|
|
@@ -307,8 +308,16 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
307
308
|
const placeholder = str(cell.props.placeholder);
|
|
308
309
|
const { text, option } = displayOf(row[cell.field], optionsOf(cell.props.options), str(cell.props.format), str(cell.props.locale, kitLocaleAt(api.host) || 'zh-CN'), placeholder);
|
|
309
310
|
if (cell.component === 'Tag' && text !== '') {
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
// 值带语气 = 状态:6px 圆点 + 语义色文字(KT-K-status-1,与 Tag dot / Text 同一组类);不带语气 = 标签(浅底小圆角)
|
|
312
|
+
if (option?.tone !== undefined) {
|
|
313
|
+
const host = mk('span', `${DOT_ROOT.md} ${DOT_TEXT[option.tone]}`, '');
|
|
314
|
+
const dot = mk('span', DOT_WRAP.md, '');
|
|
315
|
+
dot.setAttribute('aria-hidden', 'true');
|
|
316
|
+
dot.appendChild(mk('span', DOT_CORE[option.tone], ''));
|
|
317
|
+
host.append(dot, document.createTextNode(text));
|
|
318
|
+
return host;
|
|
319
|
+
}
|
|
320
|
+
return mk('span', TAG_CLASS.md[toneOf(cell.props.tone, 'neutral')], text);
|
|
312
321
|
}
|
|
313
322
|
return mk('span', joinClass(TEXT_CLASS, cell.valueClass), text);
|
|
314
323
|
};
|
|
@@ -331,6 +340,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
331
340
|
const el = mk('div', rowClassOf(row));
|
|
332
341
|
el.setAttribute('role', 'row');
|
|
333
342
|
el.setAttribute('aria-rowindex', String(index + 2));
|
|
343
|
+
el.setAttribute('data-kit-part', KIT_PART_TABLE_ROW);
|
|
334
344
|
el.setAttribute('data-kit-row', '');
|
|
335
345
|
el.setAttribute('data-kit-index', String(index));
|
|
336
346
|
el.setAttribute('data-kit-key', String(index));
|
package/src/data/wrap.ts
CHANGED
|
@@ -9,10 +9,10 @@ import type {
|
|
|
9
9
|
} from 'soma-core';
|
|
10
10
|
import { createKitController, findRoot } from '../base/shared';
|
|
11
11
|
import { kitLocaleAt } from '../i18n/kit-text';
|
|
12
|
-
import { checkClasses, mergeClass } from '../
|
|
12
|
+
import { checkClasses, mergeClass } from '../shared/merge-class';
|
|
13
13
|
import { mountKitComponent, type KitMount } from './embed';
|
|
14
14
|
import { attachWrappedCandidates, splitClassTokens } from './wrapped-candidates';
|
|
15
|
-
import { kitFail } from '../
|
|
15
|
+
import { kitFail } from '../shared/kit-error';
|
|
16
16
|
|
|
17
17
|
export type PackProps = Record<string, unknown>;
|
|
18
18
|
|
package/src/frames/index.ts
CHANGED
|
@@ -28,8 +28,9 @@ export type { WorkspaceState, WorkspaceTab, WorkspaceTabInput } from './workspac
|
|
|
28
28
|
|
|
29
29
|
export { createKitTabsWiring } from './tabs-frame/wiring';
|
|
30
30
|
export { createKitSplitWiring } from './split-frame/wiring';
|
|
31
|
-
export {
|
|
32
|
-
export
|
|
31
|
+
export { createKitFrameResidentComponents } from './resident-components';
|
|
32
|
+
export { attachResizeHandle, clampStep } from '../base/resize-handle';
|
|
33
|
+
export type { ResizeHandle, ResizeHandleOptions, ResizeAxis, ResizeSource } from '../base/resize-handle';
|
|
33
34
|
export { checkSplitConfig, splitSpanClass, splitSpanClasses, KIT_SPLIT_CLASS_CANDIDATES } from './split-frame';
|
|
34
35
|
export type { SplitConfig, SplitDirection, SplitSide } from './split-frame';
|
|
35
36
|
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// 应用级继承外壳(kit.app.yaml#layout 的 header / sidebar / footer)与产品旋钮(product.emphasis / product.surface)的渲染。
|
|
2
|
+
// 原住 compile/compile-page.ts(业务层不该持有类串);现在是页面框层的写死模板,类串在 recipes/inherited-shell,编译环节只调用。
|
|
3
|
+
import { escapeHtml } from '../shared/escape';
|
|
4
|
+
import { KIT_EMBED_ATTR, isEmbedQuery } from '../shared/theme-runtime-shared';
|
|
5
|
+
import { KIT_WORKSPACE_FRAME_LIMITS } from 'soma-foundation/kit-limits';
|
|
6
|
+
import type { KitFragment } from '../object-renderer/fragment';
|
|
7
|
+
import {
|
|
8
|
+
KIT_PRODUCT_EMPHASIS_CLASSES, KIT_PRODUCT_SURFACE_CLASSES,
|
|
9
|
+
KIT_SHELL_ACTIONS_CLASS, KIT_SHELL_ACTION_LINK_CLASS, KIT_SHELL_BODY_CLASS, KIT_SHELL_BRAND_LINK_CLASS, KIT_SHELL_BRAND_TEXT_CLASS,
|
|
10
|
+
KIT_SHELL_FOOTER_CLASS, KIT_SHELL_FOOTER_LINKS_CLASS, KIT_SHELL_FOOTER_LINK_CLASS, KIT_SHELL_HEADER_CLASS, KIT_SHELL_HEADER_LEFT_CLASS,
|
|
11
|
+
KIT_SHELL_MAIN_CLASS, KIT_SHELL_NAV_CLASS, KIT_SHELL_NAV_LINK_CLASS, KIT_SHELL_SIDEBAR_CLASS, KIT_SHELL_SIDEBAR_ITEM_CLASS,
|
|
12
|
+
KIT_SHELL_SIDEBAR_MENU_CLASS, KIT_SHELL_SIDEBAR_TITLE_CLASS,
|
|
13
|
+
} from '../recipes/inherited-shell';
|
|
14
|
+
|
|
15
|
+
export interface KitInheritedNavItem {
|
|
16
|
+
label: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 继承外壳的输入形状(与 `kit.app.yaml#layout` 的 header / sidebar / footer 结构兼容) */
|
|
22
|
+
export interface KitInheritedLayout {
|
|
23
|
+
header?: {
|
|
24
|
+
brand?: { text: string; href?: string };
|
|
25
|
+
nav?: KitInheritedNavItem[];
|
|
26
|
+
actions?: KitInheritedNavItem[];
|
|
27
|
+
};
|
|
28
|
+
sidebar?: {
|
|
29
|
+
title?: string;
|
|
30
|
+
width?: number;
|
|
31
|
+
menu?: KitInheritedNavItem[];
|
|
32
|
+
};
|
|
33
|
+
footer?: {
|
|
34
|
+
text?: string;
|
|
35
|
+
links?: Array<{ label: string; href: string }>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function renderInheritedHeader(header: NonNullable<KitInheritedLayout['header']>): string {
|
|
40
|
+
let brandHtml = '';
|
|
41
|
+
if (header.brand?.text) {
|
|
42
|
+
const b = header.brand;
|
|
43
|
+
brandHtml = b.href
|
|
44
|
+
? `<a href="${escapeHtml(b.href)}" class="${KIT_SHELL_BRAND_LINK_CLASS}">${escapeHtml(b.text)}</a>`
|
|
45
|
+
: `<span class="${KIT_SHELL_BRAND_TEXT_CLASS}">${escapeHtml(b.text)}</span>`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let navHtml = '';
|
|
49
|
+
if (header.nav && header.nav.length > 0) {
|
|
50
|
+
const navItems = header.nav.map((it) => {
|
|
51
|
+
const target = it.url ?? it.href ?? '#';
|
|
52
|
+
return `<a href="${escapeHtml(target)}" class="${KIT_SHELL_NAV_LINK_CLASS}">${escapeHtml(it.label)}</a>`;
|
|
53
|
+
}).join('\n');
|
|
54
|
+
navHtml = `<nav class="${KIT_SHELL_NAV_CLASS}">\n${navItems}\n</nav>`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let actionsHtml = '';
|
|
58
|
+
if (header.actions && header.actions.length > 0) {
|
|
59
|
+
const actionItems = header.actions.map((it) => {
|
|
60
|
+
const target = it.url ?? it.href ?? "#";
|
|
61
|
+
return `<a href="${escapeHtml(target)}" class="${KIT_SHELL_ACTION_LINK_CLASS}">${escapeHtml(it.label)}</a>`;
|
|
62
|
+
}).join("\n");
|
|
63
|
+
actionsHtml = `<div class="${KIT_SHELL_ACTIONS_CLASS}">\n${actionItems}\n</div>`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const leftPart = [brandHtml, navHtml].filter(Boolean).join('\n');
|
|
67
|
+
return `<header data-kit-layout-header="true" class="${KIT_SHELL_HEADER_CLASS}">\n<div class="${KIT_SHELL_HEADER_LEFT_CLASS}">\n${leftPart}\n</div>\n${actionsHtml}\n</header>`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function renderInheritedSidebar(sidebar: NonNullable<KitInheritedLayout['sidebar']>): string {
|
|
71
|
+
let sidebarInner = '';
|
|
72
|
+
if (sidebar.title) {
|
|
73
|
+
sidebarInner += `<div class="${KIT_SHELL_SIDEBAR_TITLE_CLASS}">${escapeHtml(sidebar.title)}</div>\n`;
|
|
74
|
+
}
|
|
75
|
+
if (sidebar.menu && sidebar.menu.length > 0) {
|
|
76
|
+
const menuItems = sidebar.menu.map((it) => {
|
|
77
|
+
const target = it.url ?? it.href ?? "#";
|
|
78
|
+
return `<a href="${escapeHtml(target)}" class="${KIT_SHELL_SIDEBAR_ITEM_CLASS}">${escapeHtml(it.label)}</a>`;
|
|
79
|
+
}).join("\n");
|
|
80
|
+
sidebarInner += `<nav class="${KIT_SHELL_SIDEBAR_MENU_CLASS}">\n${menuItems}\n</nav>`;
|
|
81
|
+
}
|
|
82
|
+
return sidebarInner;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function renderInheritedFooter(footer: NonNullable<KitInheritedLayout['footer']>): string {
|
|
86
|
+
const textHtml = footer.text ? `<span>${escapeHtml(footer.text)}</span>` : '<span></span>';
|
|
87
|
+
let linksHtml = '';
|
|
88
|
+
if (footer.links && footer.links.length > 0) {
|
|
89
|
+
const linkItems = footer.links.map((link) => {
|
|
90
|
+
return `<a href="${escapeHtml(link.href)}" class="${KIT_SHELL_FOOTER_LINK_CLASS}">${escapeHtml(link.label)}</a>`;
|
|
91
|
+
}).join("\n");
|
|
92
|
+
linksHtml = `<div class="${KIT_SHELL_FOOTER_LINKS_CLASS}">\n${linkItems}\n</div>`;
|
|
93
|
+
}
|
|
94
|
+
return `<footer data-kit-layout-footer="true" class="${KIT_SHELL_FOOTER_CLASS}">\n${textHtml}\n${linksHtml}\n</footer>`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 继承侧栏宽度类:宽度与密度无关,一律写任意值 px 类 `w-[Npx]`(--spacing 倍数类 w-44…w-80 会随密度缩放,不用)。
|
|
99
|
+
* 缺省取 design 真源 sidebarTiers 的默认档 px;有 width 时按原分档阈值归到标准密度下的精确 px(原 w-N 的 N×4),
|
|
100
|
+
* 其中 192..320 恰与真源档位 px 一致,176 无对应档位,仍按 176 输出。
|
|
101
|
+
*/
|
|
102
|
+
function sidebarWidthClass(width: number | undefined): string {
|
|
103
|
+
const tiers = KIT_WORKSPACE_FRAME_LIMITS.sidebarTiers;
|
|
104
|
+
const widthMap = tiers.widthPx as Record<string, number>;
|
|
105
|
+
if (width === undefined) return `w-[${widthMap[String(tiers.default)]}px]`;
|
|
106
|
+
const px = width <= 184 ? 176
|
|
107
|
+
: width <= 200 ? 192
|
|
108
|
+
: width <= 216 ? 208
|
|
109
|
+
: width <= 232 ? 224
|
|
110
|
+
: width <= 248 ? 240
|
|
111
|
+
: width <= 272 ? 256
|
|
112
|
+
: width <= 304 ? 288
|
|
113
|
+
: 320;
|
|
114
|
+
return `w-[${px}px]`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** 该应用布局是否真有外壳要渲染(header / sidebar / footer 任一) */
|
|
118
|
+
export function hasInheritedShell(layout: KitInheritedLayout | undefined): boolean {
|
|
119
|
+
return layout !== undefined && (layout.header !== undefined || layout.sidebar !== undefined || layout.footer !== undefined);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { KIT_EMBED_ATTR, isEmbedQuery };
|
|
123
|
+
|
|
124
|
+
/** 同步嵌入模式标记(?embed=1 时在文档根写入 data-kit-embed="1" 以抑制继承的应用级顶栏) */
|
|
125
|
+
export function syncInheritedShellEmbed(doc?: Document, search?: string): boolean {
|
|
126
|
+
const embedded = isEmbedQuery(search);
|
|
127
|
+
const targetDoc = doc ?? (typeof document === 'undefined' ? undefined : document);
|
|
128
|
+
const el = targetDoc?.documentElement;
|
|
129
|
+
if (el !== undefined && el !== null && typeof el.setAttribute === 'function') {
|
|
130
|
+
if (embedded) el.setAttribute(KIT_EMBED_ATTR, '1');
|
|
131
|
+
else el.removeAttribute?.(KIT_EMBED_ATTR);
|
|
132
|
+
}
|
|
133
|
+
return embedded;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function renderInheritedLayout(framedHtml: string, layout: KitInheritedLayout, options?: { embed?: boolean }): string {
|
|
137
|
+
const headerHtml = layout.header && options?.embed !== true ? renderInheritedHeader(layout.header) : '';
|
|
138
|
+
let bodyHtml = framedHtml;
|
|
139
|
+
if (layout.sidebar !== undefined) {
|
|
140
|
+
const sidebarContent = renderInheritedSidebar(layout.sidebar);
|
|
141
|
+
const widthCls = sidebarWidthClass(layout.sidebar.width);
|
|
142
|
+
const widthAttr = layout.sidebar.width !== undefined ? ` data-kit-sidebar-width="${layout.sidebar.width}"` : "";
|
|
143
|
+
bodyHtml = `<div class="${KIT_SHELL_BODY_CLASS}"><aside data-kit-container="card" data-kit-layout-sidebar="true"${widthAttr} class="${widthCls} ${KIT_SHELL_SIDEBAR_CLASS}">\n${sidebarContent}\n</aside><div class="${KIT_SHELL_MAIN_CLASS}">\n${framedHtml}\n</div></div>`;
|
|
144
|
+
}
|
|
145
|
+
const footerHtml = layout.footer ? renderInheritedFooter(layout.footer) : '';
|
|
146
|
+
const parts = [headerHtml, bodyHtml, footerHtml].filter(Boolean);
|
|
147
|
+
return `<div data-kit-inherited-layout="true">\n${parts.join('\n')}\n</div>`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ---------------------------------------------------------------- 产品旋钮
|
|
151
|
+
|
|
152
|
+
export interface KitProductKnobs {
|
|
153
|
+
emphasis?: string;
|
|
154
|
+
surface?: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function applyProductKnobsToFragment(frag: KitFragment, product: KitProductKnobs): KitFragment {
|
|
158
|
+
if (product.emphasis === undefined && product.surface === undefined) return frag;
|
|
159
|
+
const attrs: string[] = [];
|
|
160
|
+
const classes: string[] = [];
|
|
161
|
+
if (product.surface !== undefined && KIT_PRODUCT_SURFACE_CLASSES[product.surface] !== undefined) {
|
|
162
|
+
attrs.push(`data-kit-surface="${product.surface}"`);
|
|
163
|
+
classes.push(KIT_PRODUCT_SURFACE_CLASSES[product.surface]!);
|
|
164
|
+
}
|
|
165
|
+
if (product.emphasis !== undefined && KIT_PRODUCT_EMPHASIS_CLASSES[product.emphasis] !== undefined) {
|
|
166
|
+
attrs.push(`data-kit-emphasis="${product.emphasis}"`);
|
|
167
|
+
classes.push(KIT_PRODUCT_EMPHASIS_CLASSES[product.emphasis]!);
|
|
168
|
+
}
|
|
169
|
+
if (attrs.length === 0) return frag;
|
|
170
|
+
const clsStr = classes.join(' ');
|
|
171
|
+
const tokens = clsStr.split(/\s+/).filter(Boolean);
|
|
172
|
+
const candidates = [...new Set([...frag.candidates, ...tokens])].sort();
|
|
173
|
+
return {
|
|
174
|
+
...frag,
|
|
175
|
+
html: `<div ${attrs.join(' ')} class="${clsStr}">${frag.html}</div>`,
|
|
176
|
+
candidates,
|
|
177
|
+
};
|
|
178
|
+
}
|