soma-kit 0.1.13 → 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 +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- 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 +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- 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 +34 -17
- 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/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -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 +73 -50
- 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 +7 -6
- 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 +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- 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 +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- 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 +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- 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 +16 -12
- package/src/biz/types.ts +15 -3
- 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/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -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 +97 -18
- 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 +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- 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 +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- 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 +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- 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 +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- 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 +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- 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 +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -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 +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- 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 +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- 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
|
@@ -21,6 +21,9 @@ import { mountKitOverlay } from './overlay-portal';
|
|
|
21
21
|
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
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
25
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
26
|
+
import { mergeClass } from '../shared/merge-class';
|
|
24
27
|
|
|
25
28
|
export const KIT_TOUR_DEFAULT_MAP = Object.freeze({ id: 'id', target: 'target', title: 'title', text: 'text' });
|
|
26
29
|
|
|
@@ -32,7 +35,8 @@ const START_CLASS = 'inline-flex w-fit';
|
|
|
32
35
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
33
36
|
/** 洞比目标大一圈(px,SVG 坐标) */
|
|
34
37
|
const HOLE_PAD = 4;
|
|
35
|
-
|
|
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'));
|
|
36
40
|
/** 无目标或贴不下时:卡片落在视口底部居中(锚盒铺满视口,卡片相对它绝对定位) */
|
|
37
41
|
const CARD_FIXED_CLASS = `absolute inset-x-4 bottom-6 z-50 mx-auto w-full max-w-sm ${CARD_LOOK}`;
|
|
38
42
|
/** 有目标时:锚盒 = 目标的洞矩形,卡片用 popup 的预置方位类贴边(翻转由 resolvePopPlace 裁决) */
|
|
@@ -45,7 +49,7 @@ const CARD_PREF: PopPlace = { side: 'bottom', align: 'start' };
|
|
|
45
49
|
const CARD_GAP_PX = 8;
|
|
46
50
|
const CARD_CLASS = CARD_FIXED_CLASS;
|
|
47
51
|
const COUNT_CLASS = 'text-xs text-fg-subtle';
|
|
48
|
-
const TITLE_CLASS = '
|
|
52
|
+
const TITLE_CLASS = kitTypographyRecipe('dialogTitle');
|
|
49
53
|
const TEXT_CLASS = 'whitespace-pre-wrap text-fg-muted';
|
|
50
54
|
const FOOT_CLASS = 'flex items-center justify-between gap-2';
|
|
51
55
|
const NAV_CLASS = 'flex items-center gap-2';
|
|
@@ -163,14 +167,14 @@ export function createTourGuide(): SomaComponentDefinition {
|
|
|
163
167
|
let anchored = false;
|
|
164
168
|
if (hole) {
|
|
165
169
|
setBox(hole);
|
|
166
|
-
dlg.className = `${CARD_ANCHORED_CLASS} ${popPlaceClass(CARD_PREF
|
|
170
|
+
dlg.className = `${CARD_ANCHORED_CLASS} ${popPlaceClass(CARD_PREF)}`;
|
|
167
171
|
const size = dlg.getBoundingClientRect();
|
|
168
172
|
const rtl = kitDirAt(dlg) === 'rtl';
|
|
169
173
|
const pl = resolvePopPlace(
|
|
170
174
|
{ left: hole.x, right: hole.x + hole.w, top: hole.y, bottom: hole.y + hole.h },
|
|
171
175
|
{ width: size.width, height: size.height }, { width: vw, height: vh }, CARD_PREF, CARD_GAP_PX, rtl,
|
|
172
176
|
);
|
|
173
|
-
const cls = `${CARD_ANCHORED_CLASS} ${popPlaceClass(pl
|
|
177
|
+
const cls = `${CARD_ANCHORED_CLASS} ${popPlaceClass(pl)}`;
|
|
174
178
|
if (dlg.className !== cls) dlg.className = cls;
|
|
175
179
|
const r = dlg.getBoundingClientRect();
|
|
176
180
|
anchored = r.width === 0 || (r.left >= 0 && r.top >= 0 && r.right <= vw && r.bottom <= vh);
|
package/src/data/transfer.ts
CHANGED
|
@@ -23,13 +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';
|
|
36
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
37
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
38
|
+
import { mergeClass } from '../shared/merge-class';
|
|
33
39
|
import { createKitBusy, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
34
40
|
|
|
35
41
|
// ───────── 样式常量:Tailwind 类串与候选类清单 ─────────
|
|
@@ -39,29 +45,32 @@ const ROOT_CLASS = `@container flex flex-col gap-3 ${KIT_OVERLAY_ROOT_FILL_CLASS
|
|
|
39
45
|
const BODY_CLASS = 'flex flex-col gap-3 @lg:flex-row @lg:items-stretch';
|
|
40
46
|
// 浮层滚动体里(对话框 / 抽屉)两栏不再是带内边距的小卡(无边框主题下卡看不见,12px 内边距只让输入框右缘比页脚按钮右缘内缩 12px):
|
|
41
47
|
// 去内边距 / 边框 / 底色,输入框与列表直接贴浮层内容边,与页脚按钮同一条右缘
|
|
42
|
-
|
|
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 }));
|
|
43
50
|
const HEAD_CLASS = 'flex items-center justify-between gap-2 text-sm';
|
|
44
51
|
const TITLE_CLASS = 'font-medium text-fg';
|
|
45
52
|
const COUNT_CLASS = 'text-fg-muted';
|
|
46
|
-
const SEARCH_CLASS =
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
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';
|
|
51
60
|
const CURSOR_CLASS = 'ring-1 ring-inset ring-ring';
|
|
52
|
-
const BOX_CLASS =
|
|
61
|
+
const BOX_CLASS = `inline-flex size-4 shrink-0 items-center justify-center rounded-sm ${BOX_EDGE} bg-surface`;
|
|
53
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';
|
|
54
63
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
55
64
|
const SUB_CLASS = 'truncate text-xs text-fg-muted';
|
|
56
65
|
// 空态文字与列表项同一左缘:列表项的行盒(分隔线、选中底)贴列表左缘,空态文字不再额外内缩 8px,与标题、搜索框左对齐
|
|
57
66
|
const EMPTY_CLASS = 'py-3 text-sm text-fg-muted';
|
|
58
67
|
const OPS_CLASS = 'flex items-center justify-center gap-2 @lg:flex-col';
|
|
59
|
-
const OP_CLASS = '
|
|
68
|
+
const OP_CLASS = mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'w-8 px-0');
|
|
60
69
|
const FOOT_CLASS = 'flex items-center justify-end gap-2';
|
|
61
70
|
const SAVE_CLASS = 'inline-flex h-8 items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-fg hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50';
|
|
62
71
|
const NOTICE_CLASS = 'rounded-md border border-warning-on-soft/20 bg-warning-soft px-3 py-2 text-sm text-warning-on-soft';
|
|
63
72
|
const ALERT_CLASS = 'rounded-md border border-danger-on-soft/20 bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
64
|
-
const CANCEL_CLASS ='
|
|
73
|
+
const CANCEL_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
65
74
|
|
|
66
75
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
67
76
|
export const KIT_TRANSFER_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
@@ -458,6 +467,8 @@ export function createTransfer(): SomaComponentDefinition {
|
|
|
458
467
|
const build = (host: HTMLElement): void => {
|
|
459
468
|
const makePanel = (side: 'left' | 'right'): { panel: HTMLElement; title: HTMLElement; count: HTMLElement; search: HTMLInputElement; searchBox: HTMLElement; list: HTMLElement } => {
|
|
460
469
|
const panel = el('section', PANEL_CLASS);
|
|
470
|
+
panel.setAttribute('data-kit-container', 'card');
|
|
471
|
+
markKitEdge(panel);
|
|
461
472
|
panel.setAttribute('data-kit-list-panel', '');
|
|
462
473
|
const head = el('div', HEAD_CLASS);
|
|
463
474
|
const title = el('span', TITLE_CLASS);
|
|
@@ -468,7 +479,9 @@ export function createTransfer(): SomaComponentDefinition {
|
|
|
468
479
|
setKitFace(search, 'field');
|
|
469
480
|
search.type = 'search';
|
|
470
481
|
search.setAttribute('autocomplete', 'off');
|
|
471
|
-
|
|
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;
|
|
472
485
|
const list = el('div', LIST_CLASS);
|
|
473
486
|
list.setAttribute('role', 'listbox');
|
|
474
487
|
list.setAttribute('aria-multiselectable', 'true');
|
package/src/data/tree-table.ts
CHANGED
|
@@ -18,16 +18,21 @@
|
|
|
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
|
-
import {
|
|
30
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
31
|
+
import { kitIcon } from '../shared/icons';
|
|
28
32
|
import { KIT_TREE_TABLE } from '../object-renderer/defaults';
|
|
29
33
|
import { KIT_PART_TABLE_ROW } from '../recipes/table-row';
|
|
30
|
-
import {
|
|
34
|
+
import { kitStripBoundaryClasses } from '../recipes/divider';
|
|
35
|
+
import { ROW_ACTION_BUTTON_CLASS, rowActionRanks, rowBusyName, removeKeyOf } from '../object-renderer/table-actions';
|
|
31
36
|
import { KIT_ROW_TONE_CLASS, rowToneClass } from '../object-renderer/view-binding';
|
|
32
37
|
import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
|
|
33
38
|
import { provideCtxRows } from './context-menu';
|
|
@@ -43,9 +48,19 @@ const SPACER_CLASS = 'inline-block h-5 w-5 shrink-0';
|
|
|
43
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';
|
|
44
49
|
// 单元格文字:块级 + min-w-0 + 单行省略(长 ID 不再压到相邻列);被截断时悬停出全文提示(表壳带 data-kit-tips,由 base/hint-tips 按需挂)
|
|
45
50
|
const TEXT_CLASS = 'block min-w-0 truncate text-sm text-fg';
|
|
46
|
-
const
|
|
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
|
+
});
|
|
61
|
+
const ACTIONS_CELL_CLASS = 'flex flex-nowrap items-center justify-end gap-x-4 whitespace-nowrap';
|
|
47
62
|
const MORE_WRAP_CLASS = 'flex items-center justify-center px-4 py-3';
|
|
48
|
-
const MORE_BUTTON_CLASS = '
|
|
63
|
+
const MORE_BUTTON_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
49
64
|
const ROW_FOCUS_CLASS = 'cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
50
65
|
|
|
51
66
|
/** 工具位链接的原始类串(显隐切类名时据此还原) */
|
|
@@ -53,9 +68,12 @@ const CONTROL_CLASS = new WeakMap<HTMLElement, string>();
|
|
|
53
68
|
|
|
54
69
|
export const KIT_TREE_TABLE_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set([
|
|
55
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,
|
|
56
72
|
...KIT_CHECK_CLASS_CANDIDATES, ACTIONS_CELL_CLASS, MORE_WRAP_CLASS, MORE_BUTTON_CLASS, ROW_FOCUS_CLASS,
|
|
57
73
|
...Object.values(ROW_ACTION_BUTTON_CLASS),
|
|
58
|
-
...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,
|
|
59
77
|
...Object.values(KIT_ROW_TONE_CLASS),
|
|
60
78
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')))].sort());
|
|
61
79
|
|
|
@@ -255,11 +273,9 @@ function actionsOf(raw: unknown): ActionItem[] {
|
|
|
255
273
|
return out;
|
|
256
274
|
}
|
|
257
275
|
|
|
276
|
+
/** bordered: false 剥边界类:只经分隔线出口的剥离函数(KT-B8 第 4 点,一个决定一个出口) */
|
|
258
277
|
function stripBorderClasses(cls: string): string {
|
|
259
|
-
return cls
|
|
260
|
-
.split(/\s+/)
|
|
261
|
-
.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'))
|
|
262
|
-
.join(' ');
|
|
278
|
+
return kitStripBoundaryClasses(cls);
|
|
263
279
|
}
|
|
264
280
|
|
|
265
281
|
function rowKeyOf(row: unknown, keyField: string): string {
|
|
@@ -519,15 +535,44 @@ export function createKitTreeTable(): SomaComponentDefinition {
|
|
|
519
535
|
onCollapse: (key) => setOpen(key, false),
|
|
520
536
|
});
|
|
521
537
|
|
|
522
|
-
/**
|
|
538
|
+
/** 单元格内容:支持 Tag(含 variant: dot / size / unknown / pulse)与 Text(含 size / copyable) */
|
|
523
539
|
const cellContent = (cell: CellDef, row: Rec): HTMLElement => {
|
|
524
540
|
const placeholder = str(cell.props.placeholder);
|
|
525
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);
|
|
526
543
|
if (cell.component === 'Tag' && text !== '') {
|
|
527
|
-
const
|
|
528
|
-
|
|
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;
|
|
529
574
|
}
|
|
530
|
-
return mk('span',
|
|
575
|
+
return mk('span', CELL_TEXT_SIZE_CLASS[size], text);
|
|
531
576
|
};
|
|
532
577
|
|
|
533
578
|
// ── 表格工具位里的「全部展开 / 全部收起」(页面编译放的静态链接,按对象名认领;本组件只接线与显隐)
|
|
@@ -656,8 +701,9 @@ export function createKitTreeTable(): SomaComponentDefinition {
|
|
|
656
701
|
const cell = mk('div', str(p.actionsClass));
|
|
657
702
|
cell.setAttribute('role', 'gridcell');
|
|
658
703
|
const box = mk('div', ACTIONS_CELL_CLASS);
|
|
659
|
-
|
|
660
|
-
|
|
704
|
+
const ranks = rowActionRanks(actions);
|
|
705
|
+
for (const [at, a] of actions.entries()) {
|
|
706
|
+
const btn = mk('button', ROW_ACTION_BUTTON_CLASS[ranks[at]!], a.name) as HTMLButtonElement;
|
|
661
707
|
btn.setAttribute('type', 'button');
|
|
662
708
|
// 行动作:文字链接形态(无面,不标 raised)
|
|
663
709
|
btn.setAttribute('data-kit-act', a.id);
|
|
@@ -691,9 +737,30 @@ export function createKitTreeTable(): SomaComponentDefinition {
|
|
|
691
737
|
root = rootEl;
|
|
692
738
|
alive = true;
|
|
693
739
|
const r = root;
|
|
740
|
+
const copyTimers = new WeakMap<HTMLElement, ReturnType<typeof setTimeout>>();
|
|
694
741
|
const onClick = (event: Event): void => {
|
|
695
742
|
const t = event.target as HTMLElement | null;
|
|
696
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
|
+
}
|
|
697
764
|
if (t.closest('[data-kit-more]')) {
|
|
698
765
|
limit = (limit > 0 ? limit : cfg().windowThreshold) + KIT_TREE_TABLE.windowBatch;
|
|
699
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';
|
|
@@ -574,7 +577,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
574
577
|
root.removeAttribute('aria-multiselectable');
|
|
575
578
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
576
579
|
if (!applyKitReadState(root, p, { hasContent: false, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) {
|
|
577
|
-
root.appendChild(kitEmptyPanel(document, str(p.empty_text, kitText('soma.kit.empty', undefined, api.host))
|
|
580
|
+
root.appendChild(kitEmptyPanel(document, str(p.empty_text, kitText('soma.kit.empty', undefined, api.host))));
|
|
578
581
|
}
|
|
579
582
|
return;
|
|
580
583
|
}
|
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';
|
|
@@ -32,16 +32,18 @@ import {
|
|
|
32
32
|
KIT_VIRTUAL_CLASS_CANDIDATES, KIT_VIRTUAL_LABELS, KIT_VIRTUAL_ROW_CLASS, virtualRowPx,
|
|
33
33
|
KIT_ROW_TIERS, createVirtualWindow, rowTierOf, setSpacerHeight, withoutPy, type KitRowTier, type VirtualWindow,
|
|
34
34
|
} from '../base/virtual-list';
|
|
35
|
-
import { ROW_ACTION_BUTTON_CLASS, rowBusyName, removeKeyOf } from '../object-renderer/table-actions';
|
|
35
|
+
import { ROW_ACTION_BUTTON_CLASS, rowActionRanks, rowBusyName, removeKeyOf } from '../object-renderer/table-actions';
|
|
36
36
|
import { KIT_ROW_TONE_CLASS, rowToneClass } from '../object-renderer/view-binding';
|
|
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';
|
|
43
45
|
const TEXT_CLASS = 'block min-w-0 truncate text-sm text-fg';
|
|
44
|
-
const ACTIONS_CELL_CLASS = 'flex flex-nowrap items-center gap-x-4 whitespace-nowrap';
|
|
46
|
+
const ACTIONS_CELL_CLASS = 'flex flex-nowrap items-center justify-end gap-x-4 whitespace-nowrap';
|
|
45
47
|
const ROW_FOCUS_CLASS = 'scroll-mt-10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
46
48
|
const ROW_PICK_CLASS = 'cursor-pointer';
|
|
47
49
|
|
|
@@ -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));
|
|
@@ -368,8 +378,9 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
368
378
|
const cell = mk('div', actionsClass);
|
|
369
379
|
cell.setAttribute('role', 'gridcell');
|
|
370
380
|
const box = mk('div', ACTIONS_CELL_CLASS);
|
|
371
|
-
|
|
372
|
-
|
|
381
|
+
const ranks = rowActionRanks(actions);
|
|
382
|
+
for (const [at, a] of actions.entries()) {
|
|
383
|
+
const btn = mk('button', ROW_ACTION_BUTTON_CLASS[ranks[at]!], a.name);
|
|
373
384
|
btn.setAttribute('type', 'button');
|
|
374
385
|
// 行动作:文字链接形态(无面,不标 raised)
|
|
375
386
|
btn.setAttribute('data-kit-act', a.id);
|
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
|
|
|
@@ -21,7 +21,7 @@ const KEY = Symbol.for('soma-kit.wrappedCandidates');
|
|
|
21
21
|
/** 运行期常驻组件名(与 compile/component-candidates 的 KIT_RESIDENT_RUNTIME_CLASS_CANDIDATES 对应):每页都带类,不必声明 */
|
|
22
22
|
export const KIT_RESIDENT_COMPONENT_NAMES: readonly string[] = Object.freeze([
|
|
23
23
|
'Button', 'Input', 'Textarea', 'Link', 'Text', 'Tag', 'Badge', 'Tooltip', 'Select',
|
|
24
|
-
'Dropdown', 'Popup', 'PopupPlace', 'Modal', 'Segmented', 'QtyStepper', 'ContextMenu',
|
|
24
|
+
'Dropdown', 'Popup', 'PopupPlace', 'Modal', 'Segmented', 'QtyStepper', 'ContextMenu', 'Radio',
|
|
25
25
|
]);
|
|
26
26
|
|
|
27
27
|
/** 进程内已声明过的组件名并集(只给开发态运行期提示用,不参与编译) */
|
|
@@ -46,6 +46,27 @@ export function declareKitUses<T extends SomaComponentDefinition>(def: T, uses:
|
|
|
46
46
|
return def;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
const COMPOSITION_KEY = Symbol.for('soma-kit.compositionRole');
|
|
50
|
+
|
|
51
|
+
/** 应用组件在页面构成里的角色:概况 summary / 主体 subject(缺省)/ 控件 control / 说明 note(真源 kit-arrange#composition) */
|
|
52
|
+
export type KitCompositionRole = 'summary' | 'subject' | 'control' | 'note';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 声明应用组件在页面构成里的角色(应用组件注册时可带的可选元数据,不进页面语法;缺省 subject)。
|
|
56
|
+
* 构成分析(foundation 的 solveComposition)按它给组件定级、附着与上 hero:概况类组件进页面顶部的概况条,
|
|
57
|
+
* 控件 / 说明不独立成块而附着于被控制 / 被说明的主体。返回同一个定义。
|
|
58
|
+
*/
|
|
59
|
+
export function declareKitComposition<T extends SomaComponentDefinition>(def: T, role: KitCompositionRole): T {
|
|
60
|
+
Object.defineProperty(def, COMPOSITION_KEY, { value: role, enumerable: false, configurable: true });
|
|
61
|
+
return def;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** 读回组件定义声明的构成角色;没声明为 undefined(编译期按 appDefaultRole = subject) */
|
|
65
|
+
export function kitCompositionOf(def: SomaComponentDefinition): KitCompositionRole | undefined {
|
|
66
|
+
const v = (def as unknown as Record<symbol, unknown>)[COMPOSITION_KEY];
|
|
67
|
+
return v === 'summary' || v === 'subject' || v === 'control' || v === 'note' ? v : undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
/**
|
|
50
71
|
* 应用组件里用了 `kitStatePanel` / `paintKitStatePanel`(含 not_ready / upstream_broken / denied)时调一次:
|
|
51
72
|
* 把三态面板的类(盒、插画、重试钮)并入该组件的候选类,并满足 KIT-STYLE-003 的「声明过用到哪些内置件」。
|
package/src/frames/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { blankFrame, singleFrame, splitFrame, tabsFrame, topMainFrame, workspace
|
|
|
14
14
|
export { checkWorkspaceConfig } from './workspace-frame';
|
|
15
15
|
export { createKitPageBar, KIT_PAGE_BAR_CLASS_CANDIDATES } from './page-bar';
|
|
16
16
|
export { createKitPageStatus, KIT_PAGE_STATUS_CLASS_CANDIDATES } from './page-status';
|
|
17
|
+
export { createKitListSummary, KIT_LIST_SUMMARY_CLASS_CANDIDATES } from './list-summary';
|
|
17
18
|
export { parsePageHeader } from './page-header';
|
|
18
19
|
export { headerFragment } from './shared';
|
|
19
20
|
export { createKitWorkspace, mountKitWorkspace, workspaceLabels, withFrameQuery, KIT_WORKSPACE_CLASS_CANDIDATES } from './workspace-frame/view';
|
|
@@ -27,8 +28,9 @@ export type { WorkspaceState, WorkspaceTab, WorkspaceTabInput } from './workspac
|
|
|
27
28
|
|
|
28
29
|
export { createKitTabsWiring } from './tabs-frame/wiring';
|
|
29
30
|
export { createKitSplitWiring } from './split-frame/wiring';
|
|
30
|
-
export {
|
|
31
|
-
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';
|
|
32
34
|
export { checkSplitConfig, splitSpanClass, splitSpanClasses, KIT_SPLIT_CLASS_CANDIDATES } from './split-frame';
|
|
33
35
|
export type { SplitConfig, SplitDirection, SplitSide } from './split-frame';
|
|
34
36
|
|