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/rich-text.ts
CHANGED
|
@@ -7,28 +7,36 @@
|
|
|
7
7
|
// 不可用环境(无 contenteditable 的执行环境)退化:命令钮不出,编辑区变只读。execCommand 缺失时命令钮禁用。
|
|
8
8
|
// 事件:`change { value, empty, length }`(输入或命令后,value 已净化;empty = 无可见文字;length = 文字长度,超 max_length 时计数变警示色,不截断)。
|
|
9
9
|
// `readonly` 为真时只展示净化后的内容,不出工具栏。
|
|
10
|
-
// `source: markdown`(A17):内容是 Markdown
|
|
10
|
+
// `source: markdown`(A17):内容是 Markdown 文本,经 core 端口 engines.markdown 解析、MarkdownView 的块渲染器出 DOM,固定只读;见「Markdown(只读来源)」段。
|
|
11
11
|
|
|
12
12
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
13
13
|
import { ID_PROPS, INVALID_PROPS, applyCommon, bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
14
14
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
15
15
|
import { setKitFace } from '../recipes';
|
|
16
|
+
import { kitControlEdgeRecipe, kitControlRecipe } from '../recipes/control';
|
|
17
|
+
import { KIT_DIVIDER_FOOT_CLASS, KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
|
|
18
|
+
import { mergeClass } from '../shared/merge-class';
|
|
16
19
|
import { classTokens, mk, recOf } from './shape-util';
|
|
17
20
|
import { RICH_ALLOWED_TAGS, RICH_COMMANDS, RICH_LINK_PROTOCOLS, RICH_MAX_LENGTH } from './d9-limits';
|
|
21
|
+
import { kitEnginePort, type KitHighlightEnginePort, type KitMarkdownEnginePort } from './engine-ports';
|
|
22
|
+
import { KIT_MARKDOWN_VIEW_CLASS_CANDIDATES, markdownIndentTopLevel, renderMdBlock, renderMdPlain, type KitMdRenderContext } from './markdown-view';
|
|
18
23
|
|
|
19
24
|
// ───────── 样式常量:Tailwind 类串与候选类清单 ─────────
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
// 富文本是一个多行控件:外圈 = 控件轮廓(KT-B1 / §4 C6);工具条是凹底带,与编辑区之间已有面差,不再加线(一处分隔一种手段,KT-B5);
|
|
27
|
+
// 链接条 / 字数脚条只画朝内的一条分隔线(分隔线出口)
|
|
28
|
+
const ROOT_EDGE = kitControlEdgeRecipe({ wrapper: true });
|
|
29
|
+
const ROOT_CLASS = `flex flex-col overflow-hidden rounded-lg ${ROOT_EDGE} bg-surface text-sm text-fg focus-within:ring-2 focus-within:ring-ring`;
|
|
30
|
+
const BAR_CLASS = 'flex flex-wrap items-center gap-1 bg-surface-sunken p-1';
|
|
23
31
|
const BTN_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md px-2 text-sm text-fg transition-colors hover:bg-surface active:opacity-80 disabled:cursor-not-allowed disabled:opacity-60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
24
32
|
const BTN_ON = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md bg-primary-soft px-2 text-sm font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
25
33
|
const BODY_CLASS = 'relative';
|
|
26
34
|
const AREA_CLASS = 'min-h-32 w-full px-3 py-2 text-sm text-fg focus-visible:outline-none';
|
|
27
35
|
const HOLDER_CLASS = 'pointer-events-none absolute start-3 top-2 text-fg-subtle';
|
|
28
|
-
const LINKBAR_CLASS =
|
|
29
|
-
const LINK_INPUT = '
|
|
30
|
-
const FOOT_CLASS =
|
|
31
|
-
const FOOT_OVER =
|
|
36
|
+
const LINKBAR_CLASS = `flex items-center gap-2 ${KIT_DIVIDER_HEAD_CLASS} p-1`;
|
|
37
|
+
const LINK_INPUT = mergeClass(kitControlRecipe(), 'min-w-0 flex-1');
|
|
38
|
+
const FOOT_CLASS = `flex justify-end ${KIT_DIVIDER_FOOT_CLASS} px-3 py-1 text-xs text-fg-subtle`;
|
|
39
|
+
const FOOT_OVER = `flex justify-end ${KIT_DIVIDER_FOOT_CLASS} px-3 py-1 text-xs text-danger-on-soft`;
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
* 编辑区 / 只读区里净化后的标签样式。宿主壳把 p / h* / ul / ol 的外边距与列表符号清零、把 a 的颜色与下划线继承掉,
|
|
@@ -46,7 +54,7 @@ export const KIT_RICH_TAG_CLASS: Readonly<Record<string, string>> = Object.freez
|
|
|
46
54
|
|
|
47
55
|
export const KIT_RICH_TEXT_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
48
56
|
ROOT_CLASS, BAR_CLASS, BTN_CLASS, BTN_ON, BODY_CLASS, AREA_CLASS, HOLDER_CLASS, LINKBAR_CLASS, LINK_INPUT, FOOT_CLASS, FOOT_OVER, 'hidden',
|
|
49
|
-
Object.values(KIT_RICH_TAG_CLASS),
|
|
57
|
+
Object.values(KIT_RICH_TAG_CLASS), KIT_MARKDOWN_VIEW_CLASS_CANDIDATES,
|
|
50
58
|
);
|
|
51
59
|
|
|
52
60
|
// ───────── 内容规整:HTML 净化(白名单重建)、链接地址校验、纯文本转段落、工具栏命令解析 ─────────
|
|
@@ -156,88 +164,24 @@ export function plainToFragment(text: string, doc: Document = document): Documen
|
|
|
156
164
|
|
|
157
165
|
// ── Markdown(只读来源)──────────────────────────────────────
|
|
158
166
|
//
|
|
159
|
-
// `readonly` + `source: markdown
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
// `readonly` + `source: markdown`:原文经 core 端口 engines.markdown 解析成块树,由 MarkdownView 的同一个块渲染器
|
|
168
|
+
// (renderMdBlock:按节点类型 createElement / textContent,不经 innerHTML、不渲染原始 HTML、地址白名单在端口)画进只读区。
|
|
169
|
+
// 原先手写的 Markdown 子集转换(markdownToRichHtml / markdownInline)已删除(内容展示批次 ④:一个能力一份实现)。
|
|
170
|
+
// 宿主没装配端口时按纯文本分段显示。
|
|
171
|
+
|
|
172
|
+
/** Markdown 原文 → 只读区(异步;seq 判定后发先至) */
|
|
173
|
+
async function paintRichMarkdown(area: HTMLElement, source: string, services: unknown, isCurrent: () => boolean): Promise<void> {
|
|
174
|
+
const port = kitEnginePort<KitMarkdownEnginePort>(services, 'markdown');
|
|
175
|
+
const text = source.slice(0, RICH_MAX_LENGTH);
|
|
176
|
+
const res = port === null ? null : await port.parse(text).catch(() => null);
|
|
177
|
+
if (!isCurrent()) return;
|
|
178
|
+
area.textContent = '';
|
|
179
|
+
if (res === null || !res.ok) { renderMdPlain(area, res === null ? text : res.plainText); return; }
|
|
180
|
+
const ctx: KitMdRenderContext = {
|
|
181
|
+
root: area, headingOffset: 0, idPrefix: 'krt-', indent: markdownIndentTopLevel(res.blocks),
|
|
182
|
+
highlight: kitEnginePort<KitHighlightEnginePort>(services, 'highlight'), copyCode: false,
|
|
174
183
|
};
|
|
175
|
-
|
|
176
|
-
s = s.replace(/\[([^\]\n]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g, (_m, label: string, url: string) =>
|
|
177
|
-
hold(`<a href="${url.replace(/"/g, '%22')}">${markdownInline(label)}</a>`));
|
|
178
|
-
s = s.replace(/\*\*([^*\n]+)\*\*/g, '<strong>$1</strong>').replace(/(^|[^\w])__([^_\n]+)__(?!\w)/g, '$1<strong>$2</strong>');
|
|
179
|
-
s = s.replace(/\*([^*\n]+)\*/g, '<em>$1</em>').replace(/(^|[^\w])_([^_\n]+)_(?!\w)/g, '$1<em>$2</em>');
|
|
180
|
-
return s.replace(/\u0001(\d+)\u0001/g, (_m, i: string) => stash[Number(i)] ?? '');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/** Markdown -> HTML 串(纯函数;输出尚未净化,必须交给 sanitizeRichFragment / sanitizeRichHtml) */
|
|
184
|
-
export function markdownToRichHtml(md: string): string {
|
|
185
|
-
const lines = md.slice(0, RICH_MAX_LENGTH).replace(/\r\n?/g, '\n').split('\n');
|
|
186
|
-
const out: string[] = [];
|
|
187
|
-
let para: string[] = [];
|
|
188
|
-
const flushPara = (): void => {
|
|
189
|
-
if (para.length > 0) out.push(`<p>${markdownInline(para.join(' '))}</p>`);
|
|
190
|
-
para = [];
|
|
191
|
-
};
|
|
192
|
-
let i = 0;
|
|
193
|
-
while (i < lines.length) {
|
|
194
|
-
const line = lines[i]!;
|
|
195
|
-
if (/^\s*```/.test(line)) {
|
|
196
|
-
flushPara();
|
|
197
|
-
const code: string[] = [];
|
|
198
|
-
i += 1;
|
|
199
|
-
while (i < lines.length && !/^\s*```/.test(lines[i]!)) { code.push(lines[i]!); i += 1; }
|
|
200
|
-
i += 1;
|
|
201
|
-
// 白名单里没有 pre / code:代码块逐行成段,内容转义成纯文字
|
|
202
|
-
for (const c of code) if (c.trim() !== '') out.push(`<p>${escapeText(c)}</p>`);
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if (line.trim() === '') { flushPara(); i += 1; continue; }
|
|
206
|
-
const heading = /^(#{1,6})\s+(.*?)\s*#*\s*$/.exec(line);
|
|
207
|
-
if (heading) {
|
|
208
|
-
flushPara();
|
|
209
|
-
out.push(`<h${heading[1]!.length}>${markdownInline(heading[2]!)}</h${heading[1]!.length}>`);
|
|
210
|
-
i += 1;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
if (/^\s*>/.test(line)) {
|
|
214
|
-
flushPara();
|
|
215
|
-
const quote: string[] = [];
|
|
216
|
-
while (i < lines.length && /^\s*>/.test(lines[i]!)) { quote.push(lines[i]!.replace(/^\s*>\s?/, '')); i += 1; }
|
|
217
|
-
out.push(`<blockquote><p>${markdownInline(quote.join(' '))}</p></blockquote>`);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
const bullet = /^\s*[-*+]\s+(.*)$/.exec(line);
|
|
221
|
-
const ordered = /^\s*\d+[.)]\s+(.*)$/.exec(line);
|
|
222
|
-
if (bullet || ordered) {
|
|
223
|
-
flushPara();
|
|
224
|
-
const tag = bullet ? 'ul' : 'ol';
|
|
225
|
-
const re = bullet ? /^\s*[-*+]\s+(.*)$/ : /^\s*\d+[.)]\s+(.*)$/;
|
|
226
|
-
const items: string[] = [];
|
|
227
|
-
while (i < lines.length) {
|
|
228
|
-
const m2 = re.exec(lines[i]!);
|
|
229
|
-
if (!m2) break;
|
|
230
|
-
items.push(`<li>${markdownInline(m2[1]!)}</li>`);
|
|
231
|
-
i += 1;
|
|
232
|
-
}
|
|
233
|
-
out.push(`<${tag}>${items.join('')}</${tag}>`);
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
para.push(line.trim());
|
|
237
|
-
i += 1;
|
|
238
|
-
}
|
|
239
|
-
flushPara();
|
|
240
|
-
return out.join('');
|
|
184
|
+
for (const b of res.blocks) area.appendChild(renderMdBlock(b, ctx, 0));
|
|
241
185
|
}
|
|
242
186
|
|
|
243
187
|
// ── 命令 ─────────────────────────────────────────────────────
|
|
@@ -286,7 +230,7 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
286
230
|
commands: { type: 'array', default: [], desc: '工具栏命令子集,取 bold / italic / h2 / ul / ol / link / unlink;空则全部' },
|
|
287
231
|
placeholder: { type: 'string', default: '', desc: '空内容时的占位文案' },
|
|
288
232
|
readonly: { type: 'boolean', default: false, desc: '只展示(净化后的)内容,不出工具栏' },
|
|
289
|
-
source: { type: 'enum', values: ['html', 'markdown'], default: 'html', desc: '内容来源:markdown 时 value / data.markdown 是 Markdown
|
|
233
|
+
source: { type: 'enum', values: ['html', 'markdown'], default: 'html', desc: '内容来源:markdown 时 value / data.markdown 是 Markdown 文本,经 core 端口 engines.markdown 解析后由 MarkdownView 的块渲染器出 DOM,组件固定只读(不出工具栏);只读展示 Markdown 优先用 MarkdownView' },
|
|
290
234
|
max_length: { type: 'number', default: 0, desc: '文字长度上限提示;非正数不显示计数。超出只变警示色,不截断' },
|
|
291
235
|
label: { type: 'string', default: '', desc: '编辑区的无障碍名称' },
|
|
292
236
|
...ID_PROPS,
|
|
@@ -299,6 +243,7 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
299
243
|
change: { payload: { value: { type: 'string' }, empty: { type: 'boolean' }, length: { type: 'number' } }, desc: '内容变化;value 已净化' },
|
|
300
244
|
},
|
|
301
245
|
},
|
|
246
|
+
services: ['engines'],
|
|
302
247
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
303
248
|
controllerFactory: createKitController((api) => {
|
|
304
249
|
const P = (): Record<string, unknown> => api.props();
|
|
@@ -315,14 +260,18 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
315
260
|
|
|
316
261
|
/** source: markdown 时内容是 Markdown 文本(value 优先,其次 data.markdown,再退 data.html),一律只读 */
|
|
317
262
|
const isMarkdown = (): boolean => P().source === 'markdown';
|
|
263
|
+
const initialMarkdown = (): string => {
|
|
264
|
+
const v = str(P().value);
|
|
265
|
+
const d = recOf(P().data);
|
|
266
|
+
return v !== '' ? v : str(d.markdown) !== '' ? str(d.markdown) : str(d.html);
|
|
267
|
+
};
|
|
318
268
|
const initialHtml = (): string => {
|
|
269
|
+
if (isMarkdown()) return '';
|
|
319
270
|
const v = str(P().value);
|
|
320
|
-
if (isMarkdown()) {
|
|
321
|
-
const d = recOf(P().data);
|
|
322
|
-
return markdownToRichHtml(v !== '' ? v : str(d.markdown) !== '' ? str(d.markdown) : str(d.html));
|
|
323
|
-
}
|
|
324
271
|
return v !== '' ? v : str(recOf(P().data).html);
|
|
325
272
|
};
|
|
273
|
+
let mdSeq = 0;
|
|
274
|
+
let lastMarkdown: string | null = null;
|
|
326
275
|
|
|
327
276
|
const refresh = (): void => {
|
|
328
277
|
if (!area) return;
|
|
@@ -605,10 +554,23 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
605
554
|
// 模式切换要重建 DOM:先带走当前内容
|
|
606
555
|
const keep = area ? sanitizeRichHtml(area.innerHTML) : null;
|
|
607
556
|
build();
|
|
557
|
+
lastMarkdown = null;
|
|
608
558
|
if (keep !== null) { setContent(keep); lastInit = initialHtml(); }
|
|
609
559
|
}
|
|
610
|
-
|
|
611
|
-
|
|
560
|
+
if (isMarkdown()) {
|
|
561
|
+
// Markdown 来源:经端口解析、块渲染器出 DOM(只读);原文没变不重画
|
|
562
|
+
const md = initialMarkdown();
|
|
563
|
+
if (area && md !== lastMarkdown) {
|
|
564
|
+
lastMarkdown = md;
|
|
565
|
+
const mine = (mdSeq += 1);
|
|
566
|
+
const target = area;
|
|
567
|
+
void paintRichMarkdown(target, md, api.services, () => mdSeq === mine && area === target).then(() => { if (mdSeq === mine) refresh(); });
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
lastMarkdown = null;
|
|
571
|
+
const init = initialHtml();
|
|
572
|
+
if (init !== lastInit) { lastInit = init; setContent(init); }
|
|
573
|
+
}
|
|
612
574
|
if (holder) holder.textContent = str(p.placeholder);
|
|
613
575
|
// 编辑区(role=textbox)承载 id / 可访问名 / 必填 / 无效 / 说明与标签关联;表单经 props 传入,重绘不丢
|
|
614
576
|
if (area) {
|
package/src/data/row-editor.ts
CHANGED
|
@@ -16,6 +16,8 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
16
16
|
import { applyCommon, bool, createKitController, FIELD_CLASS, formatValue, ID_PROPS, INVALID_PROPS, joinClass, nextUid, num, str, type KitApi } from '../base/shared';
|
|
17
17
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
18
18
|
import { setKitFace } from '../recipes';
|
|
19
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
20
|
+
import { KIT_DIVIDER_FOOT_CLASS, KIT_DIVIDER_HEAD_CLASS, kitDividerRecipe } from '../recipes/divider';
|
|
19
21
|
import { KIT_BUSY_PROP_DEFS, kitBusyOf } from '../base/action-busy';
|
|
20
22
|
import { KIT_DATE_CLASS_CANDIDATES, mountKitDateField } from '../base/date';
|
|
21
23
|
import { KIT_LISTBOX_CLASS_CANDIDATES } from '../base/listbox-core';
|
|
@@ -49,8 +51,11 @@ const FORM_COLS: Readonly<Record<number, string>> = Object.freeze({
|
|
|
49
51
|
const ROOT_CLASS = 'flex flex-col gap-3';
|
|
50
52
|
const TITLE_CLASS = 'text-sm font-semibold text-fg';
|
|
51
53
|
const HINT_CLASS = 'text-xs text-fg-subtle';
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
+
// 表头 / 行 / 合计行的线只经分隔线出口(发丝宽、分隔灰,KT-B1 / KT-B5)
|
|
55
|
+
const HEAD_CLASS = `grid grid-cols-12 items-center gap-2 ${KIT_DIVIDER_HEAD_CLASS} px-2 py-2 text-xs font-medium text-fg-muted`;
|
|
56
|
+
const ROW_LINE = kitDividerRecipe('bottom');
|
|
57
|
+
const DATE_EDGE = kitControlEdgeRecipe();
|
|
58
|
+
const ROW_CLASS = `grid grid-cols-12 items-center gap-2 ${ROW_LINE} px-2 py-2`;
|
|
54
59
|
const CELL_CLASS = 'min-w-0 break-all text-sm text-fg';
|
|
55
60
|
const CELL_MONO = 'min-w-0 break-all font-mono text-xs text-fg-muted';
|
|
56
61
|
const CELL_MUTED = 'min-w-0 break-all text-sm text-fg-muted';
|
|
@@ -71,14 +76,14 @@ const TEXTAREA_LIKE = 'font-mono';
|
|
|
71
76
|
const ERROR_CLASS = 'text-sm text-danger-on-soft';
|
|
72
77
|
const LIST_WRAP = 'flex flex-col';
|
|
73
78
|
const NUM_ALIGN = 'text-end tabular-nums';
|
|
74
|
-
const FOOTER_ROW_CLASS =
|
|
79
|
+
const FOOTER_ROW_CLASS = `grid grid-cols-12 items-center gap-2 ${KIT_DIVIDER_FOOT_CLASS} px-2 py-2 text-sm font-semibold text-fg`;
|
|
75
80
|
const HEAD_END_CLASS = toFlexRow(HEAD_CLASS);
|
|
76
81
|
const ROW_END_CLASS = toFlexRow(ROW_CLASS);
|
|
77
82
|
const FOOTER_END_CLASS = toFlexRow(FOOTER_ROW_CLASS);
|
|
78
83
|
const COUNT_CLASS = 'text-xs text-fg-subtle';
|
|
79
84
|
/** 出错单元格的外框(令牌色环,不撑行高;圆角不在此处手写,沿用单元格自身) */
|
|
80
85
|
const CELL_ERROR_CLASS = 'ring-1 ring-danger';
|
|
81
|
-
const DATE_FIELD_CLASS =
|
|
86
|
+
const DATE_FIELD_CLASS = `block h-9 w-full rounded-md ${DATE_EDGE} bg-surface ps-3 pe-8 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken`;
|
|
82
87
|
|
|
83
88
|
export const KIT_ROW_EDITOR_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
84
89
|
ROOT_CLASS, TITLE_CLASS, HINT_CLASS, HEAD_CLASS, ROW_CLASS, CELL_CLASS, CELL_MONO, CELL_MUTED, END_CLASS, FORM_CLASS, FIELD_WRAP,
|
|
@@ -711,7 +716,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
711
716
|
},
|
|
712
717
|
},
|
|
713
718
|
services: ['data', 'http'],
|
|
714
|
-
templateHtml: `<section data-soma-id="root" class="@container ${ROOT_CLASS}"></section>`,
|
|
719
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" class="@container ${ROOT_CLASS}"></section>`,
|
|
715
720
|
controllerFactory: createKitController(() => ({
|
|
716
721
|
busyAware: true,
|
|
717
722
|
attach(root, api) {
|
package/src/data/rule-builder.ts
CHANGED
|
@@ -23,9 +23,11 @@ import { KIT_LISTBOX_CLASS_CANDIDATES } from '../base/listbox-core';
|
|
|
23
23
|
import { createKitEmbedBag, mountKitSelectField, type KitEmbedBag } from './embed';
|
|
24
24
|
import { bool, num, str } from '../base/shared';
|
|
25
25
|
import { setKitFace, type KitFaceKind } from '../recipes';
|
|
26
|
+
import { kitButtonEdgeRecipe, kitControlEdgeRecipe } from '../recipes/control';
|
|
27
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
26
28
|
import { KIT_STATE_EMPTY_BOX } from '../recipes/placeholder';
|
|
27
29
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
28
|
-
import { mergeClass } from '../
|
|
30
|
+
import { mergeClass } from '../shared/merge-class';
|
|
29
31
|
|
|
30
32
|
// ════════════════════════════════════════════════════════════════
|
|
31
33
|
// 单条条件模块(纯函数 + 值控件构造):运算符表、按字段类型取运算符、值形状归一、校验文字、值控件(复用 kit 基础文本类控件的
|
|
@@ -240,10 +242,14 @@ export function describeCondition(cond: RuleCondition, field: RuleField | undefi
|
|
|
240
242
|
|
|
241
243
|
const VALUE_WRAP = 'flex min-w-40 flex-1 flex-wrap items-center gap-2';
|
|
242
244
|
const CONTROL = `${FIELD_CLASS.md} data-kit-invalid:border-danger`;
|
|
243
|
-
|
|
245
|
+
// 日期框的边 = 控件轮廓出口(KT-B1 / §4 C6);条件药丸 = 带文字中性按钮描边;组 / 条件框 = 壳配方(容器边,KT-B2)
|
|
246
|
+
const DATE_EDGE = kitControlEdgeRecipe();
|
|
247
|
+
const PILL_EDGE = kitButtonEdgeRecipe();
|
|
248
|
+
const MODE_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
249
|
+
const DATE_CONTROL = `block h-8 w-full rounded-md ${DATE_EDGE} bg-surface ps-3 pe-8 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-subtle disabled:opacity-60 read-only:bg-surface-sunken data-kit-invalid:border-danger`;
|
|
244
250
|
const RANGE_SEP = 'text-fg-subtle';
|
|
245
251
|
const PILLS = 'flex flex-wrap gap-1.5';
|
|
246
|
-
const PILL =
|
|
252
|
+
const PILL = `inline-flex h-8 items-center rounded-full ${PILL_EDGE} bg-surface px-3 text-xs text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-kit-selected:border-primary data-kit-selected:bg-primary-soft data-kit-selected:text-primary-on-soft`;
|
|
247
253
|
const HALF = 'min-w-28 flex-1';
|
|
248
254
|
|
|
249
255
|
export const KIT_RULE_CONDITION_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
@@ -588,10 +594,10 @@ export const parsePathKey = (key: string): number[] => key.split('.').slice(1).m
|
|
|
588
594
|
// ════════════════════════════════════════════════════════════════
|
|
589
595
|
|
|
590
596
|
const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
591
|
-
const GROUP_CLASS = 'flex flex-col gap-2
|
|
592
|
-
const GROUP_NESTED_CLASS = 'flex flex-col gap-2
|
|
597
|
+
const GROUP_CLASS = mergeClass('flex flex-col gap-2 p-3', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
598
|
+
const GROUP_NESTED_CLASS = mergeClass('flex flex-col gap-2 p-3', kitShellRecipe({ tone: 'sunken', shadow: false }));
|
|
593
599
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
594
|
-
const MODE_WRAP_CLASS =
|
|
600
|
+
const MODE_WRAP_CLASS = `inline-flex rounded-md ${MODE_EDGE} bg-surface p-0.5`;
|
|
595
601
|
const MODE_BTN_CLASS = 'inline-flex h-7 items-center justify-center rounded-md px-3 text-xs font-medium text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-kit-selected:bg-primary data-kit-selected:text-primary-fg data-kit-selected:hover:bg-primary-hover';
|
|
596
602
|
// 「非」开关:未选 = 色调按钮(次级),选中 = 实心主色(态差靠填充,不靠描边)
|
|
597
603
|
const NOT_BTN_CLASS = mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'data-kit-selected:bg-primary data-kit-selected:text-primary-fg');
|
|
@@ -601,7 +607,7 @@ const ACT_BTN_CLASS = 'inline-flex h-8 items-center justify-center rounded-md px
|
|
|
601
607
|
const DEL_BTN_CLASS = 'inline-flex h-8 items-center justify-center rounded-md px-2 text-xs text-danger-on-soft transition-colors hover:bg-danger-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
602
608
|
const ACTIONS_CLASS = 'inline-flex items-center gap-0.5';
|
|
603
609
|
const BODY_CLASS = 'flex flex-col gap-2';
|
|
604
|
-
const COND_CLASS = 'flex flex-col gap-1
|
|
610
|
+
const COND_CLASS = mergeClass('flex flex-col gap-1 px-2 py-2', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
605
611
|
const COND_ROW_CLASS = 'flex flex-wrap items-center gap-2';
|
|
606
612
|
const CELL_CLASS = 'min-w-28 flex-1';
|
|
607
613
|
const ERR_CLASS = 'text-xs text-danger-on-soft';
|
|
@@ -895,7 +901,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
895
901
|
cancel: { payload: {}, desc: '点取消' },
|
|
896
902
|
},
|
|
897
903
|
},
|
|
898
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
904
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
899
905
|
controllerFactory: createKitController(() => ({
|
|
900
906
|
busyAware: true,
|
|
901
907
|
attach(root, api) {
|
package/src/data/shape-util.ts
CHANGED
|
@@ -67,6 +67,15 @@ export const TONE_DOT: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
/** 淡底 + 同语气文字(标签、横幅、图标圈) */
|
|
70
|
+
/** 状态文字的语气色(状态 = 圆点 + 文字、没有容器:只有文字色,彩色只走 on-soft 角色,常态 neutral 用中性灰) */
|
|
71
|
+
export const TONE_TEXT: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
72
|
+
neutral: 'text-fg-muted',
|
|
73
|
+
primary: 'text-primary-on-soft',
|
|
74
|
+
info: 'text-info-on-soft',
|
|
75
|
+
success: 'text-success-on-soft',
|
|
76
|
+
warning: 'text-warning-on-soft',
|
|
77
|
+
danger: 'text-danger-on-soft',
|
|
78
|
+
});
|
|
70
79
|
export const TONE_SOFT: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
71
80
|
neutral: 'bg-surface-sunken text-fg-muted',
|
|
72
81
|
primary: 'bg-primary-soft text-primary-on-soft',
|
|
@@ -96,16 +105,18 @@ export const EMPTY_CLASS = KIT_STATE_EMPTY_BOX;
|
|
|
96
105
|
|
|
97
106
|
export type ActionTone = 'primary' | 'danger' | 'neutral';
|
|
98
107
|
|
|
99
|
-
/** 动作按钮三种语气的整串配方:主 = 实心主按钮,危险 =
|
|
108
|
+
/** 动作按钮三种语气的整串配方:主 = 实心主按钮,危险 = 三级形体 + 危险色文字(强调等级 button.danger),中性 = 三级文字钮(强调等级 button.toolbar) */
|
|
100
109
|
export const ACTION_BUTTON_TONE: Readonly<Record<ActionTone, string>> = Object.freeze({
|
|
101
110
|
primary: kitControlRecipe({ variant: 'primary' }),
|
|
102
|
-
danger:
|
|
111
|
+
danger: kitEmphasisButtonRecipe('button.danger'),
|
|
103
112
|
neutral: kitEmphasisButtonRecipe('button.toolbar'),
|
|
104
113
|
});
|
|
114
|
+
/** 确认弹层的确认钮(危险语气):全应用唯一的实心危险色按钮(强调等级 button.dangerConfirm) */
|
|
115
|
+
export const ACTION_BUTTON_CONFIRM_DANGER: string = kitEmphasisButtonRecipe('button.dangerConfirm');
|
|
105
116
|
const BUTTON_DISABLED = 'opacity-50 cursor-not-allowed';
|
|
106
117
|
|
|
107
118
|
export const BUTTON_CLASS_TOKENS: readonly string[] = classTokens(
|
|
108
|
-
Object.values(ACTION_BUTTON_TONE), BUTTON_DISABLED, KIT_STATE_RETRY_CLASS_CANDIDATES,
|
|
119
|
+
Object.values(ACTION_BUTTON_TONE), ACTION_BUTTON_CONFIRM_DANGER, BUTTON_DISABLED, KIT_STATE_RETRY_CLASS_CANDIDATES,
|
|
109
120
|
);
|
|
110
121
|
|
|
111
122
|
export function actionToneOf(raw: unknown): ActionTone {
|
package/src/data/stat-group.ts
CHANGED
|
@@ -18,18 +18,21 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
18
18
|
import { gridFillPlanOf, type SomaGridFillPlan } from 'soma-foundation/data/values';
|
|
19
19
|
import { KIT_STAT_GRID } from 'soma-foundation/kit-limits';
|
|
20
20
|
import { KIT_ARRANGE } from 'soma-foundation/arrange';
|
|
21
|
-
import { createKitController, formatValue, joinClass, num, str } from '../base/shared';
|
|
22
|
-
import { kitIcon } from '../
|
|
21
|
+
import { createKitController, formatValue, joinClass, kitSyncHeroSolo, num, str } from '../base/shared';
|
|
22
|
+
import { kitIcon } from '../shared/icons';
|
|
23
23
|
import { trendTone } from '../base/trend-tone';
|
|
24
24
|
import { TAG_CLASS } from '../base/tag';
|
|
25
|
+
import { KIT_DELTA_TONE_CLASS } from '../base/delta';
|
|
26
|
+
import { mergeClass } from '../shared/merge-class';
|
|
27
|
+
import { KIT_DELTA_TEXT } from '../recipes/typography';
|
|
25
28
|
import { gapMarkerNode } from '../base/gap-value';
|
|
26
29
|
import { safeHref } from '../base/link';
|
|
27
30
|
import { KIT_STATUS_TONE_TEXT_KEY, statusToneOrNull } from '../base/status-tone';
|
|
28
|
-
import { classCandidates } from '../
|
|
31
|
+
import { classCandidates } from '../shared/class-candidates';
|
|
29
32
|
import { kitText } from '../i18n/kit-text';
|
|
30
33
|
import { KIT_READ_STATE_PROP_DEFS, KIT_STATE_PANEL_CLASS_CANDIDATES, paintKitStatePanel } from '../base/state-panel';
|
|
31
34
|
import { KIT_TREND_LINE_CLASS_CANDIDATES, sparklineSvg, trendToneOf, trendValuesOf } from './trend-line';
|
|
32
|
-
import { KIT_PART_ATTRIBUTE, KIT_PART_STAT_VALUE, kitTypographyRecipe } from '../recipes';
|
|
35
|
+
import { KIT_PART_ATTRIBUTE, KIT_PART_STAT_VALUE, kitFocusRingRecipe, kitTypographyRecipe } from '../recipes';
|
|
33
36
|
import { KIT_RAIL_GRID_RECIPE_CLASS_CANDIDATES, kitRailGridRecipe, markKitRail } from '../recipes/rail-grid';
|
|
34
37
|
import { KIT_SUMMARY_EMPTY_ATTR } from '../recipes/container';
|
|
35
38
|
import { markKitSlot, markKitSlotGrid, slotCountOf } from '../recipes/slot-align';
|
|
@@ -56,8 +59,11 @@ function railSpans(): number[] {
|
|
|
56
59
|
for (let r = 1; r < maxCols; r += 1) set.add(KIT_RAIL_TRACKS / r);
|
|
57
60
|
return [...set].sort((a, b) => a - b);
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
const
|
|
62
|
+
// 可点的统计块 = 导轨里的集合项:手形光标、悬停 / 按下走状态层(KT-K0-2,不用整体透明度当按下),焦点 = 集合项 2px 内收环(KT-K0-3 唯一出口)
|
|
63
|
+
const BLOCK_FOCUS = kitFocusRingRecipe('item');
|
|
64
|
+
const BLOCK_CLASS = `${kitRailGridRecipe().cell} appearance-none border-0 cursor-pointer transition-colors state-layer ${BLOCK_FOCUS}`;
|
|
65
|
+
// 指标名:字阶角色 statLabel(KT-K-stat-5,标签在上、弱化墨,不手写类串)
|
|
66
|
+
const LABEL_CLASS = kitTypographyRecipe('statLabel');
|
|
61
67
|
/** 指标主数值样式:对齐规则卡 30px 大数字 + font-bold tabular-nums */
|
|
62
68
|
export const STAT_VALUE_CLASS = kitTypographyRecipe('statValue');
|
|
63
69
|
// 三槽(recipes/slot-align):标题 = 指标名,指标 = 数值 + 单位 + 迷你图 + 附加数值 + 标记,操作 = 变化率 / 对比期 / 提示;
|
|
@@ -74,19 +80,25 @@ const STAT_TONE_VALUE: Readonly<Partial<Record<string, string>>> = Object.freeze
|
|
|
74
80
|
const STAT_WARN_DOT_CLASS = KIT_STAT_WARN_DOT_CLASS;
|
|
75
81
|
// 数值行:数值 + 单位 + 变化率 / 对比期 / 提示同一条基线(没有副文本的块不为它留第三行,块高只由数值行决定)
|
|
76
82
|
const VALUE_ROW_CLASS = 'flex flex-wrap items-baseline gap-x-1 gap-y-0.5';
|
|
77
|
-
|
|
83
|
+
// 单位 / 前后缀:字阶角色 statUnit(字号 = 数值字号 × 真源 statUnitRatio、下限字阶最小档,同一条基线;KT-K-stat-2)
|
|
84
|
+
const UNIT_CLASS = kitTypographyRecipe('statUnit');
|
|
85
|
+
// 缺失 / 出错项主位的「—」:弱化墨(不是一个值),数值字号不变以保住块高(KT-K-stat-3)
|
|
86
|
+
const PLACEHOLDER_TONE = 'text-fg-subtle';
|
|
87
|
+
const VALUE_UNIT_CLASS = 'inline-flex items-baseline gap-x-1 whitespace-nowrap';
|
|
78
88
|
|
|
79
89
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
80
90
|
export const KIT_STAT_GROUP_CLASS_CANDIDATES: readonly string[] = Object.freeze([
|
|
81
91
|
'@container', 'grid', `grid-cols-${KIT_RAIL_TRACKS}`, 'min-w-0', 'appearance-none', 'border-0', 'bg-primary-soft',
|
|
82
92
|
'flex', 'flex-col', 'gap-1', 'text-start',
|
|
83
|
-
|
|
84
|
-
'
|
|
93
|
+
// 指标名 / 单位字阶(statLabel / statUnit)、缺失占位弱化墨、趋势文字(涨跌字阶 + 语气色)与方向读屏文字
|
|
94
|
+
...LABEL_CLASS.split(' '), ...UNIT_CLASS.split(' '), PLACEHOLDER_TONE, ...KIT_DELTA_TEXT.sm.split(' '), ...Object.values(KIT_DELTA_TONE_CLASS), 'sr-only',
|
|
95
|
+
'transition-colors', 'font-medium', 'font-normal', 'font-bold', 'tabular-nums',
|
|
96
|
+
'state-layer', 'cursor-pointer', ...BLOCK_FOCUS.split(' '),
|
|
85
97
|
...KIT_RAIL_GRID_RECIPE_CLASS_CANDIDATES,
|
|
86
98
|
'text-sm', 'text-fg-muted', 'text-2xl', 'text-stat-value', 'font-title', 'tracking-tight', 'font-semibold', 'text-fg',
|
|
87
99
|
'items-center', 'items-baseline', 'flex-wrap', 'rounded-md', 'px-1.5', 'py-0.5', 'text-xs', 'inline-flex',
|
|
88
100
|
// 数值行(VALUE_ROW_CLASS)与副文本(FOOT_CLASS)
|
|
89
|
-
'gap-x-1', 'gap-y-0.5', 'ms-1',
|
|
101
|
+
'gap-x-1', 'gap-y-0.5', 'ms-1', 'whitespace-nowrap',
|
|
90
102
|
...Object.values(TAG_CLASS.sm).flatMap((s) => s.split(' ')),
|
|
91
103
|
'bg-success-soft', 'text-success-on-soft', 'text-warning-on-soft', 'bg-danger-soft', 'text-danger-on-soft', 'bg-surface-sunken', 'text-fg-subtle', 'gap-2', 'border-primary', 'bg-primary-soft',
|
|
92
104
|
...KIT_TREND_LINE_CLASS_CANDIDATES, 'h-8', 'w-full', ...STAT_WARN_DOT_CLASS.split(' '),
|
|
@@ -200,12 +212,17 @@ export interface KitStatItem {
|
|
|
200
212
|
inline: Record<string, unknown> | null;
|
|
201
213
|
}
|
|
202
214
|
|
|
203
|
-
//
|
|
215
|
+
// 趋势 = 箭头 + 带正负号的数值文字,无底(不借标签形,状态与标签永不同形;KT-K-stat-4):字阶取涨跌字阶 KIT_DELTA_TEXT,语气色与 KitDelta 同一份
|
|
204
216
|
const TREND_UP_CLASS: Record<'good' | 'bad' | 'flat', string> = {
|
|
205
|
-
good:
|
|
206
|
-
bad:
|
|
207
|
-
flat:
|
|
217
|
+
good: `${KIT_DELTA_TEXT.sm} ${KIT_DELTA_TONE_CLASS.good}`,
|
|
218
|
+
bad: `${KIT_DELTA_TEXT.sm} ${KIT_DELTA_TONE_CLASS.bad}`,
|
|
219
|
+
flat: `${KIT_DELTA_TEXT.sm} ${KIT_DELTA_TONE_CLASS.flat}`,
|
|
208
220
|
};
|
|
221
|
+
/** 趋势数值带正负号(U+2212 减号):已带符号的原文不重复加 */
|
|
222
|
+
function signedChange(change: number, text: string): string {
|
|
223
|
+
if (/^[+\-−]/.test(text) || change === 0) return text;
|
|
224
|
+
return `${change > 0 ? '+' : '−'}${text}`;
|
|
225
|
+
}
|
|
209
226
|
const FOOT_CLASS = 'ms-1 inline-flex flex-wrap items-baseline gap-2';
|
|
210
227
|
const COMPARE_CLASS = 'text-xs text-fg-muted';
|
|
211
228
|
const HINT_CLASS = 'text-xs text-fg-subtle';
|
|
@@ -492,8 +509,9 @@ export function createStatGroup(): SomaComponentDefinition {
|
|
|
492
509
|
const items = statItemsOf(p.items, map, data, str(p.items_from));
|
|
493
510
|
// 没有任何指标项(数据说「这一块不适用」,如旧口径报告无摘要统计):整块不渲染(根 hidden、无子节点),不留空卡片;同 NoticeList 的空约定
|
|
494
511
|
// 概况条里的统计块没有指标可显示时自报(宿主带 data-kit-summary-empty):条内成员全空,整条概况条不渲染(结构 CSS)
|
|
495
|
-
if (items.length === 0 && readError === '') { root.hidden = true; grid.className = 'hidden'; grid.textContent = ''; api.host.setAttribute(KIT_SUMMARY_EMPTY_ATTR, ''); return; }
|
|
512
|
+
if (items.length === 0 && readError === '') { root.hidden = true; grid.className = 'hidden'; grid.textContent = ''; api.host.setAttribute(KIT_SUMMARY_EMPTY_ATTR, ''); kitSyncHeroSolo(api.host); return; }
|
|
496
513
|
api.host.removeAttribute(KIT_SUMMARY_EMPTY_ATTR);
|
|
514
|
+
kitSyncHeroSolo(api.host);
|
|
497
515
|
root.hidden = false;
|
|
498
516
|
const classes = statGridClasses(items.length, num(p.columns));
|
|
499
517
|
grid.className = classes.grid;
|
|
@@ -588,7 +606,19 @@ export function createStatGroup(): SomaComponentDefinition {
|
|
|
588
606
|
const reasonText = pickText(item.reason, item.reasonKey, map, data);
|
|
589
607
|
const valueMissing = value === undefined || value === null || value === '';
|
|
590
608
|
const gapKind = itemState !== 'ready' ? null : stateRaw === 'gap' || stateRaw === 'unknown' ? stateRaw : valueMissing && reasonText.trim() !== '' ? 'gap' : null;
|
|
591
|
-
|
|
609
|
+
// 缺失 / 出错 / 就绪但无值(且不是缺口):主位写占位「—」,弱化墨 + 读屏「暂无数据」(KT-K-stat-3)
|
|
610
|
+
const placeholder = itemState !== 'ready' || (valueMissing && gapKind === null);
|
|
611
|
+
const valueClass = placeholder ? mergeClass(VALUE_CLASS, PLACEHOLDER_TONE) : `${VALUE_CLASS}${toneText}`;
|
|
612
|
+
if (placeholder) {
|
|
613
|
+
val.className = valueClass;
|
|
614
|
+
const mark = document.createElement('span');
|
|
615
|
+
mark.setAttribute('aria-hidden', 'true');
|
|
616
|
+
mark.textContent = KIT_STAT_PLACEHOLDER;
|
|
617
|
+
const sr = document.createElement('span');
|
|
618
|
+
sr.className = KIT_NOTICE_SR_ONLY;
|
|
619
|
+
sr.textContent = kitText('soma.kit.stat_missing', undefined, rootEl);
|
|
620
|
+
val.replaceChildren(mark, sr);
|
|
621
|
+
}
|
|
592
622
|
if (gapKind !== null) {
|
|
593
623
|
val.textContent = '';
|
|
594
624
|
val.setAttribute('data-kit-gap', gapKind);
|
|
@@ -602,21 +632,25 @@ export function createStatGroup(): SomaComponentDefinition {
|
|
|
602
632
|
const unitText = gapKind !== null || itemState !== 'ready' ? '' : resolveMappedString(item.unit, item.unitKey, map, data);
|
|
603
633
|
// 三态原因行:状态圆点 + 原因文字;error 态指标位只有这一行(没有主数值),missing 态在占位「—」之下
|
|
604
634
|
const stateRow = itemState === 'ready' || isHoisted(item) ? null : statStateRowNode(itemState, reasonText, rootEl);
|
|
605
|
-
// error 与 missing
|
|
606
|
-
if (itemState === 'error') val.textContent = KIT_STAT_PLACEHOLDER;
|
|
635
|
+
// error 与 missing 一样主位只写「—」(上面 placeholder 已画),原因在其下(或提到组级)
|
|
607
636
|
let valRow: HTMLElement | null = null;
|
|
608
637
|
if (unitText !== '' || foots[index]!.any) {
|
|
609
638
|
valRow = document.createElement('span');
|
|
610
639
|
valRow.className = VALUE_ROW_CLASS;
|
|
611
640
|
// 带单位 / 副文本时贴底对齐交给整行(VALUE_ROW_CLASS);数值自己不再带 mt-auto,否则在行内被单独下推,单位浮到右上角
|
|
612
|
-
val.className =
|
|
613
|
-
valRow.appendChild(val);
|
|
641
|
+
val.className = valueClass;
|
|
614
642
|
if (unitText !== '') {
|
|
643
|
+
// 数值与单位是一个不可拆的读数:成对不折行(窄格里「11.1」与「%」不分两行),副文本仍可换到下一行
|
|
644
|
+
const pair = document.createElement('span');
|
|
645
|
+
pair.className = VALUE_UNIT_CLASS;
|
|
615
646
|
const unitEl = document.createElement('span');
|
|
616
647
|
unitEl.className = UNIT_CLASS;
|
|
617
648
|
unitEl.setAttribute('data-kit-stat-unit', '');
|
|
618
649
|
unitEl.textContent = unitText;
|
|
619
|
-
|
|
650
|
+
pair.append(val, unitEl);
|
|
651
|
+
valRow.appendChild(pair);
|
|
652
|
+
} else {
|
|
653
|
+
valRow.appendChild(val);
|
|
620
654
|
}
|
|
621
655
|
metric.appendChild(valRow);
|
|
622
656
|
} else {
|
|
@@ -691,7 +725,14 @@ export function createStatGroup(): SomaComponentDefinition {
|
|
|
691
725
|
badge.className = TREND_UP_CLASS[trendTone(change, item.upIs)];
|
|
692
726
|
badge.setAttribute('data-kit-trend', change > 0 ? 'up' : change < 0 ? 'down' : 'flat');
|
|
693
727
|
badge.appendChild(kitIcon(change > 0 ? 'arrow-up' : change < 0 ? 'arrow-down' : 'minus', 'xs'));
|
|
694
|
-
badge.appendChild(document.createTextNode(changeText));
|
|
728
|
+
badge.appendChild(document.createTextNode(signedChange(change, changeText)));
|
|
729
|
+
// 方向的读屏文字(箭头是 aria-hidden 的图形):与 KitDelta 同一词条
|
|
730
|
+
if (change !== 0) {
|
|
731
|
+
const srDir = document.createElement('span');
|
|
732
|
+
srDir.className = KIT_NOTICE_SR_ONLY;
|
|
733
|
+
srDir.textContent = kitText(change > 0 ? 'soma.kit.delta_up' : 'soma.kit.delta_down', undefined, rootEl);
|
|
734
|
+
badge.appendChild(srDir);
|
|
735
|
+
}
|
|
695
736
|
foot.appendChild(badge);
|
|
696
737
|
}
|
|
697
738
|
if (compareText !== '') {
|
package/src/data/static-lazy.ts
CHANGED
|
@@ -37,10 +37,13 @@ export const KIT_STATIC_LAZY_LOADERS: Readonly<Record<string, Loader>> = Object.
|
|
|
37
37
|
Carousel: () => import('./carousel').then((m) => m.createCarousel()),
|
|
38
38
|
Dock: () => import('./dock').then((m) => m.createDock()),
|
|
39
39
|
Diff: () => import('./diff').then((m) => m.createDiff()),
|
|
40
|
+
TextDiff: () => import('./text-diff').then((m) => m.createTextDiff()),
|
|
40
41
|
Mockup: () => import('./mockup').then((m) => m.createMockup()),
|
|
41
42
|
Footer: () => import('./footer').then((m) => m.createFooter()),
|
|
42
43
|
PricingTable: () => import('./pricing-table').then((m) => m.createPricingTable()),
|
|
43
44
|
CodeView: () => import('./code-view').then((m) => m.createCodeView()),
|
|
45
|
+
JsonView: () => import('./json-view').then((m) => m.createJsonView()),
|
|
46
|
+
MarkdownView: () => import('./markdown-view').then((m) => m.createMarkdownView()),
|
|
44
47
|
ItemList: () => import('./item-list').then((m) => m.createItemList()),
|
|
45
48
|
SystemSwitcher: () => import('./system-switcher').then((m) => m.createSystemSwitcher()),
|
|
46
49
|
RowEditor: () => import('./row-editor').then((m) => m.createRowEditor()),
|
|
@@ -35,10 +35,13 @@ import { createHero } from './hero';
|
|
|
35
35
|
import { createCarousel } from './carousel';
|
|
36
36
|
import { createDock } from './dock';
|
|
37
37
|
import { createDiff } from './diff';
|
|
38
|
+
import { createTextDiff } from './text-diff';
|
|
38
39
|
import { createMockup } from './mockup';
|
|
39
40
|
import { createFooter } from './footer';
|
|
40
41
|
import { createPricingTable } from './pricing-table';
|
|
41
42
|
import { createCodeView } from './code-view';
|
|
43
|
+
import { createJsonView } from './json-view';
|
|
44
|
+
import { createMarkdownView } from './markdown-view';
|
|
42
45
|
import { createItemList } from './item-list';
|
|
43
46
|
import { createSystemSwitcher } from './system-switcher';
|
|
44
47
|
import { createRowEditor } from './row-editor';
|
|
@@ -57,7 +60,7 @@ import { createTrendLine } from './trend-line';
|
|
|
57
60
|
import { createRecordPicker } from './record-picker';
|
|
58
61
|
import { createNoticeList } from './notice-list';
|
|
59
62
|
import { createMetaAction, createScopeSwitch, createSegmentedSwitch } from './panel-head';
|
|
60
|
-
import { kitFail } from '../
|
|
63
|
+
import { kitFail } from '../shared/kit-error';
|
|
61
64
|
|
|
62
65
|
export type KitStaticAccept = 'single' | 'list';
|
|
63
66
|
|
|
@@ -116,10 +119,13 @@ export const KIT_STATIC_BUILTIN_SPECS: readonly KitStaticSpec[] = Object.freeze(
|
|
|
116
119
|
{ name: 'Carousel', accept: 'list', desc: '轮播 / 卡片堆叠(layout 取 slide / stack,stack 的 edge 取 top / bottom / start / end):[{ id?, image?, alt?, title?, text? }],前后钮 / 指示点 / 键盘,autoplay 可选(悬停 / 焦点暂停,减少动效不播),抛 change { index, item } / select', define: createCarousel },
|
|
117
120
|
{ name: 'Dock', accept: 'list', desc: '底部图标栏:[{ key, label, icon?, badge?, disabled? }],当前项 data-kit-selected,横向 roving 键盘,抛 select { key, item }', define: createDock },
|
|
118
121
|
{ name: 'Diff', accept: 'single', desc: '前后对比:{ before, after }(图或文字块),拖动 / 键盘调分割位置(0–100,5% 一档,预置分数类),抛 change { position }', define: createDiff },
|
|
122
|
+
{ name: 'TextDiff', accept: 'single', desc: '文本 / 条目差异:{ before, after }——两段文本按段 → 句 → 词(中文按词)行内标注;两组对象数组按 key / 标题 / 内容配对,标出新增 / 删除 / 修改 / 移动与字段差异;标量显示「旧 → 新」;摘要条、仅看改动、上一处 / 下一处(F7),差异只经 core 引擎端口 engines.diff', define: createTextDiff },
|
|
119
123
|
{ name: 'Mockup', accept: 'single', desc: '设备外框:variant 取 browser(地址栏文字)/ phone / window / code(逐行带行号与前缀,等宽),内容为文字 / 图片 / 代码行,无事件', define: createMockup },
|
|
120
124
|
{ name: 'Footer', accept: 'single', desc: '页脚:{ brand?, columns[{ title, links[] }], copyright?, social? },链接走 safeHref,抛 pick { label, href, item }', define: createFooter },
|
|
121
125
|
{ name: 'PricingTable', accept: 'single', desc: '定价表:{ cycles?, plans[], current_key? },推荐标记、功能对勾 / 叉 / 文字、按周期切换价格文案(不计算价格),抛 cycle_change { key } / select { key, cycle, item }', define: createPricingTable },
|
|
122
|
-
{ name: 'CodeView', accept: 'single', desc: '只读代码 / 文本块:{ title?, text, caption? },等宽保留换行,max_height
|
|
126
|
+
{ name: 'CodeView', accept: 'single', desc: '只读代码 / 文本块:{ title?, text, caption? },等宽保留换行,max_height 档滚动,复制钮缺省显示(copyable: false 关闭),抛 copy { ok }', define: createCodeView },
|
|
127
|
+
{ name: 'JsonView', accept: 'single', desc: 'JSON / YAML 结构化查看:data 是任意 JSON 值或 JSON / YAML 原文(经 core 端口 engines.structured 解析);按节点数自动选初始展开深度、子项分页、长字符串截断可展开、节点多时出搜索(命中自动展开)、树 / 原文切换、每行复制值 / 复制路径(a.b[0].c);语法错误标出行列并按原文显示;键盘同 Tree,抛 copy { ok, what } / view { view }', define: createJsonView },
|
|
128
|
+
{ name: 'MarkdownView', accept: 'single', desc: 'Markdown 展示:data 是 Markdown 原文(或 { source | markdown | content | text }、字符串数组),经 core 端口 engines.markdown 解析成块树后按节点出 DOM(不渲染原始 HTML、地址白名单);标题偏移、目录自动、顶层成段正文首行缩进两字、代码块着色与复制、表格横滚、外链新窗口、任务列表只读;stream 流式只替换变化的块;抛 copy { ok }', define: createMarkdownView },
|
|
123
129
|
{ name: 'ItemList', accept: 'list', desc: '可选条目列表:[{ id, title, sub?, text?, tags?, disabled?, actions? }],selected 高亮,↑↓ Home End 移动焦点,loading / error(可重试)/ 空三态,抛 select { id, item } / action { key, id, item } / retry', define: createItemList },
|
|
124
130
|
{ name: 'NoticeList', accept: 'list', desc: '说明 / 披露条列表:[{ id?, code?, tone?, title?, text, time?, href?, action_label?, icon? }],语气竖线 + 图标 + 读屏语气文字双编码,fold_after 折叠其余(按钮 aria-expanded),空则整块不渲染(empty_text 可给紧凑空态),读状态与 state_kind(not_ready / upstream_broken / denied)走共用三态面板;顺序与去重由数据决定;抛 toggle { open } / action { id, href, item } / retry', define: createNoticeList },
|
|
125
131
|
{ name: 'SystemSwitcher', accept: 'single', desc: '系统 / 应用切换面板:{ items[{ id, title, sub?, favorite?, disabled? }], keyword?, server_search?, favorites_max? },已选常用 chip + 搜索(本地过滤或 server_search 抛 search)+ 系统列表,不乐观更新,抛 open { id, item } / favorite { id, on, item } / search { keyword }', define: createSystemSwitcher },
|