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
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
// - 每个动作进行中都登记到 base/action-busy(忙闲通道):带保存钮的组件声明 busy_action 即可禁用触发钮、防重复提交。
|
|
13
13
|
|
|
14
14
|
import { currentKitActionTarget, getKitHubByScope, hasKitHub, kitActionExtras, type KitActionExtras } from '../biz/shared/runtime-hub';
|
|
15
|
+
import { KIT_SUBMIT_ACTIONS_ATTR } from '../biz/shared/overlay-shell';
|
|
16
|
+
import { kitText } from '../i18n/kit-text';
|
|
15
17
|
import { beginKitAction } from '../base/action-busy';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
+
import { clearKitInlineError, reportKitInlineError } from '../base/inline-error';
|
|
19
|
+
import { envelopeMessage, isEnvelopeFailure, kitHostEnvelopeAt, type KitEnvelope } from '../shared/envelope';
|
|
20
|
+
import { kitFail } from '../shared/kit-error';
|
|
18
21
|
import { SOMA_STD_KEY_LIMITS } from 'soma-core';
|
|
19
22
|
import { SOMA_PIPELINE_HOST_HTTP_REQUEST_TIMEOUT_MS } from 'soma-foundation/values';
|
|
20
23
|
|
|
@@ -36,6 +39,11 @@ export interface KitActionHttp {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export interface KitActionArgs extends KitActionExtras {
|
|
42
|
+
/**
|
|
43
|
+
* 浮层的提交动作成功后框架默认关窗并给成功反馈;调用它表示这次不关(例如保存后留在窗口里继续编辑)。
|
|
44
|
+
* 处理函数自己调过 close() / notify() 的,框架不重复。
|
|
45
|
+
*/
|
|
46
|
+
keepOpen(): void;
|
|
39
47
|
row: Record<string, unknown>;
|
|
40
48
|
value: unknown;
|
|
41
49
|
/** core 交来的完整载荷 */
|
|
@@ -44,6 +52,16 @@ export interface KitActionArgs extends KitActionExtras {
|
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
export type KitActionHandler = (args: KitActionArgs) => unknown;
|
|
55
|
+
|
|
56
|
+
/** 请求层失败(HTTP 非 2xx / 非 JSON):message 是给开发者的技术原话(方法、地址、状态码),给用户的提示另取产品文案 */
|
|
57
|
+
export class KitActionRequestError extends Error {
|
|
58
|
+
readonly detail: { method: string; url: string; status: number };
|
|
59
|
+
constructor(message: string, detail: { method: string; url: string; status: number }) {
|
|
60
|
+
super(message);
|
|
61
|
+
this.name = 'KitActionRequestError';
|
|
62
|
+
this.detail = detail;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
47
65
|
/** 带动作级缺省超时的登记条目:`{ handler, timeoutMs }`;timeoutMs 取 0(禁用)或 write.timeoutMs 区间内的整数毫秒 */
|
|
48
66
|
export interface KitActionEntry {
|
|
49
67
|
handler: KitActionHandler;
|
|
@@ -129,14 +147,14 @@ async function request(
|
|
|
129
147
|
|
|
130
148
|
try {
|
|
131
149
|
const res = await fetch(fullUrl, { ...init, signal: controller.signal });
|
|
132
|
-
if (!res.ok) throw new
|
|
150
|
+
if (!res.ok) throw new KitActionRequestError(`请求失败 ${method} ${fullUrl}:HTTP ${res.status}`, { method, url: fullUrl, status: res.status });
|
|
133
151
|
const text = await res.text();
|
|
134
152
|
let json: unknown = null;
|
|
135
153
|
if (text !== '') {
|
|
136
154
|
try {
|
|
137
155
|
json = JSON.parse(text);
|
|
138
156
|
} catch {
|
|
139
|
-
throw new
|
|
157
|
+
throw new KitActionRequestError(`请求失败 ${method} ${fullUrl}:接口返回了非 JSON 内容(可能登录态已失效或网关拦截)`, { method, url: fullUrl, status: res.status });
|
|
140
158
|
}
|
|
141
159
|
}
|
|
142
160
|
// 业务信封失败:判定与文案位置来自应用声明的信封约定(kit.app.yaml#envelope),这里不写任何后端字段
|
|
@@ -221,17 +239,43 @@ export function isKitDefinedAction(action: KitNamedAction): boolean {
|
|
|
221
239
|
return DEFINED_ACTION_FACTORIES.has(action);
|
|
222
240
|
}
|
|
223
241
|
|
|
242
|
+
/** 触发元素所在的浮层把这个动作登记为它的「提交」动作(biz/shared/overlay-shell 的 KIT_SUBMIT_ACTIONS_ATTR) */
|
|
243
|
+
function isOverlaySubmitAction(target: KitActionTarget, name: string): boolean {
|
|
244
|
+
if (!(typeof Element !== 'undefined' && target instanceof Element)) return false;
|
|
245
|
+
const host = target.closest(`[${KIT_SUBMIT_ACTIONS_ATTR}]`);
|
|
246
|
+
return host !== null && (host.getAttribute(KIT_SUBMIT_ACTIONS_ATTR) ?? '').split(/\s+/).includes(name);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 动作失败给用户的文案:请求层的失败(HTTP 非 2xx、超时、取消、非 JSON)不露出方法与地址等引擎原话,换成产品文案;
|
|
251
|
+
* 业务信封的失败消息(后端写给人看的)与处理函数自己抛的错误文案原样给出。技术细节留在控制台。
|
|
252
|
+
*/
|
|
253
|
+
function kitActionFailureText(error: unknown, at: KitActionTarget): string {
|
|
254
|
+
const el = typeof Element !== 'undefined' && at instanceof Element ? at : null;
|
|
255
|
+
if (error instanceof KitActionRequestError) {
|
|
256
|
+
console.error('[soma-kit] 具名动作请求失败', error.detail);
|
|
257
|
+
return kitText('soma.kit.request_failed', undefined, el);
|
|
258
|
+
}
|
|
259
|
+
return error instanceof Error && error.message !== '' ? error.message : String(error);
|
|
260
|
+
}
|
|
261
|
+
|
|
224
262
|
function createNamedAction(name: string, handler: KitActionHandler, httpFor: KitActionHttpFor): KitNamedAction {
|
|
225
263
|
return async (payload) => {
|
|
226
264
|
const p = payload ?? {};
|
|
227
265
|
// 动作目标在调用同步段里取一次(此后 handler 可能 await,栈顶会换成别的动作的目标)
|
|
228
266
|
const ambientTarget = currentKitActionTarget();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
267
|
+
// 绑定目标按「载荷 scope → 载荷 object → 触发元素 / 动作栈」取第一个真有协调组件登记的;
|
|
268
|
+
// 内置件(PermissionTree / AssignmentPicker 等)抛出的 object 是页面作者写的组件 prop(如 role_menu),不一定是协调组件的对象名,
|
|
269
|
+
// 命中不了协调组件时必须退到触发元素,否则 focusRow() / selected 全部读空(AF-8)。都命中不了才保留第一个候选(信封解析仍可用它)。
|
|
270
|
+
const candidates: Array<string | HTMLElement | undefined> = [
|
|
271
|
+
typeof p.scope === 'string' && p.scope !== '' ? p.scope : undefined,
|
|
272
|
+
typeof p.object === 'string' && p.object !== '' ? p.object : undefined,
|
|
273
|
+
ambientTarget,
|
|
274
|
+
];
|
|
275
|
+
const hubHit = candidates.find((c) => c !== undefined && hasKitHub(c));
|
|
276
|
+
const boundTarget = hubHit ?? ambientTarget;
|
|
233
277
|
// 本次调用的信封:按 boundTarget 所属页面宿主解析一次(定位不到元素时退回调用时的动作目标),固定进本次专用的 http
|
|
234
|
-
const http = httpFor(targetEnvelope(
|
|
278
|
+
const http = httpFor(targetEnvelope(hubHit ?? candidates.find((c) => c !== undefined), ambientTarget));
|
|
235
279
|
const extras = kitActionExtras(boundTarget);
|
|
236
280
|
const row = p.row !== null && typeof p.row === 'object' ? (p.row as Record<string, unknown>) : {};
|
|
237
281
|
const end = beginKitAction(name);
|
|
@@ -240,13 +284,41 @@ function createNamedAction(name: string, handler: KitActionHandler, httpFor: Kit
|
|
|
240
284
|
const endRow = typeof p.kit_row_busy === 'string' && p.kit_row_busy !== '' ? beginKitAction(p.kit_row_busy) : undefined;
|
|
241
285
|
try {
|
|
242
286
|
let result: unknown;
|
|
287
|
+
// 反馈唯一出口(AF-8):动作抛错时用户必须看到一条提示,不能只进控制台;处理函数自己已发过危险提示的不重复弹
|
|
288
|
+
let toasted = false;
|
|
289
|
+
let informed = false;
|
|
290
|
+
let closed = false;
|
|
291
|
+
let keep = false;
|
|
292
|
+
const notify: KitActionExtras['notify'] = (message, tone) => {
|
|
293
|
+
if (tone === 'danger') toasted = true;
|
|
294
|
+
else informed = true;
|
|
295
|
+
extras.notify(message, tone);
|
|
296
|
+
};
|
|
297
|
+
const close: KitActionExtras['close'] = (scope) => {
|
|
298
|
+
closed = true;
|
|
299
|
+
extras.close(scope);
|
|
300
|
+
};
|
|
243
301
|
try {
|
|
244
|
-
result = await handler({ ...extras, row, value: p.value, payload: p, http });
|
|
302
|
+
result = await handler({ ...extras, notify, close, keepOpen: () => { keep = true; }, row, value: p.value, payload: p, http });
|
|
303
|
+
} catch (error) {
|
|
304
|
+
// 错误不用轻提示(KT-K-feedback-3,§6.1 G-17):失败在发起处给就地提示条(窗口内进窗口槽,页面级进页头下),无槽才回退轻提示
|
|
305
|
+
if (!toasted) {
|
|
306
|
+
const failure = kitActionFailureText(error, ambientTarget);
|
|
307
|
+
reportKitInlineError(ambientTarget instanceof Element ? ambientTarget : null, failure, `action:${name}`, () => extras.notify(failure, 'danger'));
|
|
308
|
+
}
|
|
309
|
+
throw error;
|
|
245
310
|
} finally {
|
|
246
311
|
end();
|
|
247
312
|
}
|
|
248
313
|
// 返回 false = 动作主动中止:与抛错同一口径
|
|
249
314
|
if (result === false) throw new Error(`[soma-kit] 具名动作 ${name} 返回 false,终止后续步骤`);
|
|
315
|
+
// 同一动作下一次成功:撤掉它上一次失败留下的就地提示条(KT-K-feedback-3)
|
|
316
|
+
clearKitInlineError(ambientTarget instanceof Element ? ambientTarget : null, `action:${name}`);
|
|
317
|
+
// 浮层的提交动作(编译期在浮层外层登记)成功:框架默认关窗 + 成功反馈;处理函数自己关过 / 提示过的不重复,调了 keepOpen() 的不关
|
|
318
|
+
if (!keep && isOverlaySubmitAction(ambientTarget, name)) {
|
|
319
|
+
if (!closed) extras.close();
|
|
320
|
+
if (!informed) extras.notify(kitText('soma.kit.saved', undefined, ambientTarget instanceof Element ? ambientTarget : null), 'success');
|
|
321
|
+
}
|
|
250
322
|
// 业务组件的固定协作:有协调组件的页面里,动作成功后重取主对象与附带对象(重取失败只记日志,不让动作失败)
|
|
251
323
|
if (hasKitHub(boundTarget)) {
|
|
252
324
|
try { await extras.reload(); } catch (error) { console.error('[soma-kit] 具名动作后的重取失败', error); }
|
|
@@ -20,11 +20,12 @@ import { KIT_BIZ_COMPONENT_NAMES, KIT_FRAME_NAMES } from '../biz/names';
|
|
|
20
20
|
import type { KitBizDefinition } from '../biz/types';
|
|
21
21
|
import type { KitThemeConfig } from '../theme/theme-tokens';
|
|
22
22
|
import type { KitAppDicts, KitAppEntities, KitAppTheme } from './app-config';
|
|
23
|
-
import { parseKitAppEnvelopeFromYaml, registerKitAppDefaultEnvelope, type KitEnvelope } from '
|
|
23
|
+
import { parseKitAppEnvelopeFromYaml, registerKitAppDefaultEnvelope, type KitEnvelope } from '../shared/envelope';
|
|
24
24
|
import { KitPackError, type KitPack } from './define-kit-pack';
|
|
25
25
|
import { readKitViewInfo, type KitViewClass } from './define-kit-view';
|
|
26
26
|
import type { KitDiagnostic } from '../object-renderer/types';
|
|
27
27
|
import { createKitResidentDataComponents } from '../data/resident';
|
|
28
|
+
import { createKitFrameResidentComponents } from '../frames/resident-components';
|
|
28
29
|
import { addWrappedOwnCandidates } from '../data/wrapped-candidates';
|
|
29
30
|
import { assertSinglePathComponent } from './component-gate';
|
|
30
31
|
import { KIT_STATIC_BUILTIN_LAZY_NAMES as KIT_STATIC_BUILTIN_NAMES, KIT_STATIC_LAZY_LOADERS } from '../data/static-lazy';
|
|
@@ -32,10 +33,10 @@ import type { KitFrameDefinition } from '../frames/types';
|
|
|
32
33
|
import { bindKitActionRequestTimeout, isKitDefinedAction, validateKitAppRequestTimeout, type KitNamedAction } from './define-kit-actions';
|
|
33
34
|
import type { KitServerFace } from './server';
|
|
34
35
|
import { checkNoRelativeOrSystemPath } from '../shared/path-guard';
|
|
35
|
-
import { kitFail } from '../
|
|
36
|
+
import { kitFail } from '../shared/kit-error';
|
|
36
37
|
import { configureKitThemeAppId, installKitThemeRuntime, restoreKitThemeBeforeFirstPaint } from './theme-runtime';
|
|
37
38
|
import { withActiveKitActionTarget } from '../biz/shared/runtime-hub';
|
|
38
|
-
import { buildKitThemeBootDataElement, buildKitThemeFirstPaintScript, isKitThemePath, toKitRuntimeTheme } from '
|
|
39
|
+
import { buildKitThemeBootDataElement, buildKitThemeFirstPaintScript, isKitThemePath, toKitRuntimeTheme } from '../shared/theme-runtime-shared';
|
|
39
40
|
|
|
40
41
|
export { checkNoRelativeOrSystemPath };
|
|
41
42
|
|
|
@@ -406,8 +407,8 @@ function mergePacks(packs: readonly KitPack[], t: PackMergeTarget): void {
|
|
|
406
407
|
export function buildBrowserMount(registry: KitAppRegistry): KitBrowserMount {
|
|
407
408
|
const base: Record<string, SomaComponentDefinition> = { ...createKitBaseComponents(), ...registry.baseComponents };
|
|
408
409
|
const data = createKitResidentDataComponents(base);
|
|
409
|
-
//
|
|
410
|
-
const components: Record<string, SomaComponentDefinition> = { ...base, ...data, ...bizDataComponents() };
|
|
410
|
+
// 业务组件壳与页面框层依赖的协作常驻组件与内置数据组件同表;内置名不与应用名冲突(应用名须 App 开头)
|
|
411
|
+
const components: Record<string, SomaComponentDefinition> = { ...base, ...data, ...createKitFrameResidentComponents(), ...bizDataComponents() };
|
|
411
412
|
for (const [name, entry] of Object.entries(registry.staticComponents)) components[name] = entry.definition;
|
|
412
413
|
for (const [name, def] of Object.entries(registry.packDataComponents)) components[name] = def;
|
|
413
414
|
// 应用登记项同名覆盖内置时,常驻表优先(core 以 components 为准),不再按需加载内置版
|
|
@@ -31,7 +31,7 @@ export { readKitViewInfo };
|
|
|
31
31
|
import type { SomaPageRootBase, SomaState, SomaViewContext } from 'soma-core/base';
|
|
32
32
|
import { extendKitViewContext, type KitViewContext } from './kit-view-context';
|
|
33
33
|
import { findSharedStateReferences, type ViewStateShape } from 'soma-foundation/view-state';
|
|
34
|
-
import { kitFail } from '../
|
|
34
|
+
import { kitFail } from '../shared/kit-error';
|
|
35
35
|
import { isViewName } from '../object-renderer/view-binding';
|
|
36
36
|
|
|
37
37
|
/** 表单草稿钩子(`view.form.onDraft`)等展示对象方法的标准载荷类型 */
|
package/src/app/index.ts
CHANGED
|
@@ -16,8 +16,8 @@ export { defineKitActions, kitActionHttp, createKitActionHttp } from './define-k
|
|
|
16
16
|
export type { KitActionArgs, KitActionHandler, KitActionHttp, KitNamedAction } from './define-kit-actions';
|
|
17
17
|
// 业务信封读取(浏览器与服务端共用的约定读取点);分页整形助手(createPagedListAdapter / cursorPageWindow / withRowId)
|
|
18
18
|
// 实现在 soma-core/server/paged-list,kit 应用只经服务端入口 soma-kit/app/server 取用(J6;浏览器入口不导出)
|
|
19
|
-
export { unwrapEnvelope as unwrapBizEnvelope, isEnvelopeFailure as isBizFailure } from '
|
|
20
|
-
export type { UnwrappedEnvelope } from '
|
|
19
|
+
export { unwrapEnvelope as unwrapBizEnvelope, isEnvelopeFailure as isBizFailure } from '../shared/envelope';
|
|
20
|
+
export type { UnwrappedEnvelope } from '../shared/envelope';
|
|
21
21
|
export { KIT_PLACEHOLDER_URL, KitSubmitError } from './submit.types';
|
|
22
22
|
export type {
|
|
23
23
|
KitPageBindingView,
|
|
@@ -29,14 +29,14 @@ export type {
|
|
|
29
29
|
KitSubmitPersist,
|
|
30
30
|
KitSubmitResult,
|
|
31
31
|
} from './submit.types';
|
|
32
|
-
export { isEnvelopeFailure, envelopeMessage, unwrapEnvelope, parseKitEnvelope, getKitAppEnvelope } from '
|
|
33
|
-
export type { KitEnvelope } from '
|
|
32
|
+
export { isEnvelopeFailure, envelopeMessage, unwrapEnvelope, parseKitEnvelope, getKitAppEnvelope } from '../shared/envelope';
|
|
33
|
+
export type { KitEnvelope } from '../shared/envelope';
|
|
34
34
|
export { parseAppConfig } from './app-config';
|
|
35
35
|
// 运行期主题切换(浏览器面):服务端端点按九维声明求解令牌 CSS,浏览器替换 <style data-soma-kit-theme>
|
|
36
36
|
export { applyKitTheme, currentKitTheme, currentKitThemeOverrides, resetKitThemeOverrides, readAppBaseTheme, subscribeKitTheme, installKitThemeRuntime, restoreKitThemeBeforeFirstPaint, buildKitThemeFirstPaintScript, kitThemeStorageKey, kitThemeCssStorageKey, normalizeKitThemeAppId, configureKitThemeAppId, currentKitThemeAppId, normalizeKitRuntimeTheme, kitThemeQuery, KIT_THEME_ENDPOINT, KIT_THEME_STYLE_ATTR, KIT_THEME_STORAGE_KEY, KIT_THEME_CSS_STORAGE_KEY, KIT_THEME_CHANNEL, KIT_RUNTIME_THEME_KEYS } from './theme-runtime';
|
|
37
37
|
export type { ApplyKitThemeOptions, KitRuntimeTheme, KitRuntimeThemeKey, KitThemeApplyResult, KitThemeTables } from './theme-runtime';
|
|
38
38
|
export type { KitAppConfig, KitAppTheme } from './app-config';
|
|
39
|
-
export { createKitNotifyRenderer, KIT_NOTIFY_CLASS_CANDIDATES } from '
|
|
39
|
+
export { createKitNotifyRenderer, KIT_NOTIFY_CLASS_CANDIDATES } from '../data/notify-renderer';
|
|
40
40
|
/** 权限集异步加载完成后显式调用:已挂载的带权限码按钮按新权限重判显隐(core 权限服务无变更通知) */
|
|
41
41
|
export { addKitPermissionChecker, kitPermissionAllows, refreshKitPermissionGates, setKitPermissionChecker } from '../base/permission-gate';
|
|
42
42
|
// 应用叠加合并:把叠加应用并入基座应用的选项(登记表重名报错、基座独占面、requestHook 链、pageGrants 并集)与权限并集的点击拦截
|
|
@@ -79,8 +79,8 @@ export {
|
|
|
79
79
|
export type { KitControlRecipeOptions, KitControlVariant, KitControlSize, KitTypographyRecipeRole } from '../recipes';
|
|
80
80
|
export type { KitBizContext, KitBizDefinition, KitBizInput, KitBizRole, KitOverlayDecl } from '../biz/types';
|
|
81
81
|
export type { KitFrameCapabilities, KitFrameDefinition, KitFrameInput, KitPageMeta } from '../frames/types';
|
|
82
|
-
export { emptyFragment, mergeFragments, fragmentFromEmit } from '../
|
|
83
|
-
export type { KitFragment } from '../
|
|
82
|
+
export { emptyFragment, mergeFragments, fragmentFromEmit } from '../object-renderer/fragment';
|
|
83
|
+
export type { KitFragment } from '../object-renderer/fragment';
|
|
84
84
|
export type { KitDiagnostic, KitObject } from '../object-renderer/types';
|
|
85
85
|
|
|
86
86
|
// core 的公开类型再导出:kit 应用写自定义组件 / 控制器 / 鉴权选项时统一从 soma-kit/app 或 soma-core 取用
|
|
@@ -17,7 +17,7 @@ import { opsAnchor, selAnchor, viewAnchor } from '../object-renderer/emit-static
|
|
|
17
17
|
import { KIT_ACT_SCOPE, requestSemanticName } from '../object-renderer/request-actions';
|
|
18
18
|
import type { KitRequestSpec } from '../object-renderer/request-actions';
|
|
19
19
|
import { KIT_GRAMMAR } from '../object-renderer/defaults';
|
|
20
|
-
import { getKitAppEnvelope, unwrapEnvelope, type KitEnvelope } from '
|
|
20
|
+
import { getKitAppEnvelope, unwrapEnvelope, type KitEnvelope } from '../shared/envelope';
|
|
21
21
|
import { kitActionExtras, openKitHubCreate, type KitNotifyTone } from '../biz/shared/runtime-hub';
|
|
22
22
|
import { runtimeNoticeText } from '../object-renderer/form-notify';
|
|
23
23
|
import { askKitConfirm, type KitConfirmOptions } from '../data/confirm-dialog';
|
|
@@ -369,12 +369,21 @@ export function extendKitViewContext(ctx: SomaViewContext, viewName?: string): K
|
|
|
369
369
|
if (view.status === 'pending' || view.status === 'idle') return;
|
|
370
370
|
const rowKey = scope === into ? undefined : scope.slice(into.length + OUTCOME_KEY_SEP.length);
|
|
371
371
|
const result = asRec(view.result);
|
|
372
|
+
const rawData = result.data;
|
|
373
|
+
let data: unknown = rawData;
|
|
374
|
+
if (view.status === 'saved' && rawData !== undefined) {
|
|
375
|
+
const env = getKitAppEnvelope();
|
|
376
|
+
if (env !== undefined) {
|
|
377
|
+
const unwrapped = unwrapEnvelope(rawData, env);
|
|
378
|
+
if (unwrapped.ok && unwrapped.data !== undefined) data = unwrapped.data;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
372
381
|
listener({
|
|
373
382
|
scope,
|
|
374
383
|
ok: view.status === 'saved',
|
|
375
384
|
status: view.status,
|
|
376
385
|
message: view.message,
|
|
377
|
-
data
|
|
386
|
+
data,
|
|
378
387
|
...(rowKey !== undefined ? { rowKey } : {}),
|
|
379
388
|
});
|
|
380
389
|
}) },
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 本文件只在服务端可达(经 server.ts 惰性载入),浏览器侧见 ./theme-runtime.ts。
|
|
6
6
|
|
|
7
7
|
import type { KitAppTheme } from './app-config';
|
|
8
|
-
import { KIT_THEME_ENDPOINT, KIT_RUNTIME_THEME_KEYS, isKitThemePath, toKitRuntimeTheme, type KitRuntimeTheme } from '
|
|
8
|
+
import { KIT_THEME_ENDPOINT, KIT_RUNTIME_THEME_KEYS, isKitThemePath, toKitRuntimeTheme, type KitRuntimeTheme } from '../shared/theme-runtime-shared';
|
|
9
9
|
import { NINE_DIM_STRUCTURE_CSS } from '../theme/nine-dim-structure';
|
|
10
10
|
import { serializeTokenTables, solveKitTheme, type KitThemeConfig } from '../theme/theme-tokens';
|
|
11
11
|
|
package/src/app/theme-runtime.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// 本文件不 import 任何 foundation / 服务端模块(浏览器包安全)。
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
+
KIT_EMBED_ATTR,
|
|
13
14
|
KIT_RUNTIME_THEME_KEYS,
|
|
14
15
|
KIT_THEME_BOOT_ID,
|
|
15
16
|
KIT_THEME_CSS_STORAGE_PREFIX,
|
|
@@ -19,13 +20,14 @@ import {
|
|
|
19
20
|
KIT_THEME_STYLE_ATTR,
|
|
20
21
|
buildKitThemeBootDataElement,
|
|
21
22
|
buildKitThemeFirstPaintScript,
|
|
23
|
+
isEmbedQuery,
|
|
22
24
|
kitThemeCssStorageKey,
|
|
23
25
|
kitThemeStorageKey,
|
|
24
26
|
normalizeKitRuntimeTheme,
|
|
25
27
|
normalizeKitThemeAppId,
|
|
26
28
|
toKitRuntimeTheme,
|
|
27
|
-
} from '
|
|
28
|
-
import type { KitRuntimeTheme, KitRuntimeThemeKey } from '
|
|
29
|
+
} from '../shared/theme-runtime-shared';
|
|
30
|
+
import type { KitRuntimeTheme, KitRuntimeThemeKey } from '../shared/theme-runtime-shared';
|
|
29
31
|
|
|
30
32
|
export {
|
|
31
33
|
KIT_RUNTIME_THEME_KEYS,
|
|
@@ -485,6 +487,9 @@ function broadcastOverrides(overrides: KitRuntimeTheme, appId?: string): void {
|
|
|
485
487
|
*/
|
|
486
488
|
export function restoreKitThemeBeforeFirstPaint(doc?: Document, appId?: string): KitRuntimeTheme | undefined {
|
|
487
489
|
const targetDoc = doc ?? (typeof document === 'undefined' ? undefined : document);
|
|
490
|
+
if (targetDoc !== undefined && isEmbedQuery()) {
|
|
491
|
+
targetDoc.documentElement?.setAttribute?.(KIT_EMBED_ATTR, '1');
|
|
492
|
+
}
|
|
488
493
|
if (targetDoc === undefined || typeof localStorage === 'undefined') return undefined;
|
|
489
494
|
const effAppId = resolveEffectiveAppId(appId, targetDoc);
|
|
490
495
|
try {
|
package/src/base/alert.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
6
6
|
import { kitText } from '../i18n/kit-text';
|
|
7
7
|
import { KIT_PART_ATTRIBUTE, KIT_PART_TOAST, kitOverlayPartOf } from '../recipes';
|
|
8
|
-
|
|
8
|
+
// 就地提示条(knowledge/Kit主题规则与算法.md KT-K-feedback-1,2026-11-25 裁决):浅底 + 语气图标 + 正文,不描边、无左色条;中性 = 凹槽浅底
|
|
9
|
+
const NEUTRAL_BOX = 'rounded-lg bg-surface-sunken';
|
|
10
|
+
import { kitIcon, type KitIconName } from '../shared/icons';
|
|
9
11
|
import {
|
|
10
12
|
CLASS_PROP, SIZE_PROP,
|
|
11
13
|
bool, createKitController, joinClass, setAttr, sizeOf, str, toneOf,
|
|
@@ -16,42 +18,43 @@ import {
|
|
|
16
18
|
const OUTER_SHOWN = 'block';
|
|
17
19
|
const OUTER_HIDDEN = 'hidden';
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
/** 提示条配方(KT-K-feedback-1;就地错误提示条 base/inline-error.ts 复用,§6.1 G-17) */
|
|
22
|
+
export const BOX_CLASS: Record<KitSize, Record<KitTone, string>> = {
|
|
20
23
|
sm: {
|
|
21
|
-
neutral: 'flex items-start gap-2
|
|
22
|
-
info: 'flex items-start gap-2 rounded-lg
|
|
23
|
-
success: 'flex items-start gap-2 rounded-lg
|
|
24
|
-
warning: 'flex items-start gap-2 rounded-lg
|
|
25
|
-
danger: 'flex items-start gap-2 rounded-lg
|
|
24
|
+
neutral: 'flex items-start gap-2 ' + NEUTRAL_BOX + ' px-3 py-2 text-xs text-fg-muted',
|
|
25
|
+
info: 'flex items-start gap-2 rounded-lg bg-info-soft px-3 py-2 text-xs text-info-on-soft',
|
|
26
|
+
success: 'flex items-start gap-2 rounded-lg bg-success-soft px-3 py-2 text-xs text-success-on-soft',
|
|
27
|
+
warning: 'flex items-start gap-2 rounded-lg bg-warning-soft px-3 py-2 text-xs text-warning-on-soft',
|
|
28
|
+
danger: 'flex items-start gap-2 rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger-on-soft',
|
|
26
29
|
},
|
|
27
30
|
md: {
|
|
28
|
-
neutral: 'flex items-start gap-3
|
|
29
|
-
info: 'flex items-start gap-3 rounded-lg
|
|
30
|
-
success: 'flex items-start gap-3 rounded-lg
|
|
31
|
-
warning: 'flex items-start gap-3 rounded-lg
|
|
32
|
-
danger: 'flex items-start gap-3 rounded-lg
|
|
31
|
+
neutral: 'flex items-start gap-3 ' + NEUTRAL_BOX + ' px-4 py-3 text-sm text-fg-muted',
|
|
32
|
+
info: 'flex items-start gap-3 rounded-lg bg-info-soft px-4 py-3 text-sm text-info-on-soft',
|
|
33
|
+
success: 'flex items-start gap-3 rounded-lg bg-success-soft px-4 py-3 text-sm text-success-on-soft',
|
|
34
|
+
warning: 'flex items-start gap-3 rounded-lg bg-warning-soft px-4 py-3 text-sm text-warning-on-soft',
|
|
35
|
+
danger: 'flex items-start gap-3 rounded-lg bg-danger-soft px-4 py-3 text-sm text-danger-on-soft',
|
|
33
36
|
},
|
|
34
37
|
lg: {
|
|
35
|
-
neutral: 'flex items-start gap-3
|
|
36
|
-
info: 'flex items-start gap-3 rounded-lg
|
|
37
|
-
success: 'flex items-start gap-3 rounded-lg
|
|
38
|
-
warning: 'flex items-start gap-3 rounded-lg
|
|
39
|
-
danger: 'flex items-start gap-3 rounded-lg
|
|
38
|
+
neutral: 'flex items-start gap-3 ' + NEUTRAL_BOX + ' px-5 py-4 text-base text-fg-muted',
|
|
39
|
+
info: 'flex items-start gap-3 rounded-lg bg-info-soft px-5 py-4 text-base text-info-on-soft',
|
|
40
|
+
success: 'flex items-start gap-3 rounded-lg bg-success-soft px-5 py-4 text-base text-success-on-soft',
|
|
41
|
+
warning: 'flex items-start gap-3 rounded-lg bg-warning-soft px-5 py-4 text-base text-warning-on-soft',
|
|
42
|
+
danger: 'flex items-start gap-3 rounded-lg bg-danger-soft px-5 py-4 text-base text-danger-on-soft',
|
|
40
43
|
},
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
// 图标位:圆形实心徽(实心底只配 -fg);neutral 用灰底
|
|
44
|
-
const ICON_CLASS: Record<KitTone, string> = {
|
|
47
|
+
export const ICON_CLASS: Record<KitTone, string> = {
|
|
45
48
|
neutral: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-border text-xs font-medium text-fg-muted',
|
|
46
49
|
info: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-info text-xs font-medium text-info-fg',
|
|
47
50
|
success: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-success text-xs font-medium text-success-fg',
|
|
48
51
|
warning: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-warning text-xs font-medium text-warning-fg',
|
|
49
52
|
danger: 'inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-danger text-xs font-medium text-danger-fg',
|
|
50
53
|
};
|
|
51
|
-
const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
54
|
+
export const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
52
55
|
const TITLE_CLASS = 'font-medium';
|
|
53
56
|
const CONTENT_CLASS = 'block';
|
|
54
|
-
const CLOSE_CLASS = 'shrink-0 cursor-pointer rounded-md px-1 opacity-70 transition-colors hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
57
|
+
export const CLOSE_CLASS = 'shrink-0 cursor-pointer rounded-md px-1 opacity-70 transition-colors hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
55
58
|
|
|
56
59
|
const ICON_NAME: Record<KitTone, KitIconName> = {
|
|
57
60
|
neutral: 'minus',
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 锚盒跟随触发点、随滚动与尺寸变化重定位);
|
|
6
6
|
// - 标记(本文件):面板根标 data-kit-anchored 与 data-kit-placement="top|bottom|start|end"(落位后的实际方向,翻转 / 重定位后随之更新)。
|
|
7
7
|
// 样式只认这两个属性(nine-dim-structure 的「载体与布局构件」规则(carrierRules)):进场 120ms / 出场 80ms(motion.json 的 popover 意图令牌),从锚点方向小位移 + 缩放 + 淡入,
|
|
8
|
-
// 减弱动效只淡入淡出;表面(浮起面 +
|
|
8
|
+
// 减弱动效只淡入淡出;表面(浮起面 + 发丝描边 + 双层阴影,不叠顶部内高光——D-05 / KT-B4)读 --soma-surface-raised / --soma-elevation-raised;
|
|
9
9
|
// - 出场(本文件的 leaveAnchored):复用 overlay-runtime 的隐藏前过渡机制(beginKitLeave:标 data-kit-leaving + inert,等退场动画结束再收尾,
|
|
10
10
|
// 带超时兜底,没有退场动画则立即收尾)。
|
|
11
11
|
// 层栈与焦点域仍各有唯一裁决者:Esc 只关栈顶由 core 浮层挂载点登记的层栈裁决,焦点隔离 / 回焦归各组件的 focus-scope;本文件不另立。
|
package/src/base/button.ts
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
setKitFace,
|
|
19
19
|
} from '../recipes';
|
|
20
20
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
21
|
+
import { KIT_CONTROL } from 'soma-foundation/kit-control';
|
|
22
|
+
import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
|
|
21
23
|
import { KIT_REASON_TIP_CLASS_CANDIDATES, releaseReasonTip, syncReasonTip } from './reason-tip';
|
|
22
24
|
import { KIT_BUSY_SPIN_ATTR, KIT_BUSY_SPIN_CLASS_CANDIDATES } from './action-busy';
|
|
23
25
|
|
|
@@ -34,43 +36,50 @@ export type ButtonVariant = 'primary' | 'neutral' | 'danger' | 'ghost' | 'tonal'
|
|
|
34
36
|
|
|
35
37
|
// 变体 × 档位,直接由 kitControlRecipe 生成
|
|
36
38
|
export const BUTTON_CLASS: Record<ButtonVariant, Record<KitSize, string>> = {
|
|
39
|
+
// tonal = 与主动作并列的品牌性备选(品牌浅色填充;页面显式写 tone: tonal 才有,默认的次级动作是描边中性钮)
|
|
37
40
|
tonal: {
|
|
38
|
-
sm:
|
|
39
|
-
md:
|
|
40
|
-
lg:
|
|
41
|
+
sm: kitEmphasisButtonRecipe('button.brandAlt', { size: 'sm' }),
|
|
42
|
+
md: kitEmphasisButtonRecipe('button.brandAlt', { size: 'md' }),
|
|
43
|
+
lg: kitEmphasisButtonRecipe('button.brandAlt', { size: 'lg' }),
|
|
41
44
|
},
|
|
42
45
|
primary: {
|
|
43
46
|
sm: kitControlRecipe({ variant: 'primary', size: 'sm' }),
|
|
44
47
|
md: kitControlRecipe({ variant: 'primary', size: 'md' }),
|
|
45
48
|
lg: kitControlRecipe({ variant: 'primary', size: 'lg' }),
|
|
46
49
|
},
|
|
47
|
-
// neutral =
|
|
50
|
+
// neutral = 次级动作(取消 / 返回 / 关闭 / 刷新 / 重置):白底 1px 描边的中性钮(强调四档的第二档),不是色调填充
|
|
48
51
|
neutral: {
|
|
49
52
|
sm: kitEmphasisButtonRecipe('button.toolbar', { size: 'sm' }),
|
|
50
53
|
md: kitEmphasisButtonRecipe('button.toolbar', { size: 'md' }),
|
|
51
54
|
lg: kitEmphasisButtonRecipe('button.toolbar', { size: 'lg' }),
|
|
52
55
|
},
|
|
56
|
+
// danger = 危险:平时中性灰字、悬停才变红(实心危险色只给确认弹层的确认钮,见 data/shape-util 的 ACTION_BUTTON_CONFIRM_DANGER)
|
|
53
57
|
danger: {
|
|
54
|
-
sm:
|
|
55
|
-
md:
|
|
56
|
-
lg:
|
|
58
|
+
sm: kitEmphasisButtonRecipe('button.danger', { size: 'sm' }),
|
|
59
|
+
md: kitEmphasisButtonRecipe('button.danger', { size: 'md' }),
|
|
60
|
+
lg: kitEmphasisButtonRecipe('button.danger', { size: 'lg' }),
|
|
57
61
|
},
|
|
62
|
+
// ghost = 安静:仅图标或灰色文字
|
|
58
63
|
ghost: {
|
|
59
|
-
sm:
|
|
60
|
-
md:
|
|
61
|
-
lg:
|
|
64
|
+
sm: kitEmphasisButtonRecipe('button.quiet', { size: 'sm' }),
|
|
65
|
+
md: kitEmphasisButtonRecipe('button.quiet', { size: 'md' }),
|
|
66
|
+
lg: kitEmphasisButtonRecipe('button.quiet', { size: 'lg' }),
|
|
62
67
|
},
|
|
63
68
|
};
|
|
64
69
|
|
|
65
70
|
const SPINNER_WRAP_CLASS = 'absolute inset-0 flex items-center justify-center';
|
|
66
71
|
const SPINNER_CLASS = KIT_SPINNER_CLASS;
|
|
67
72
|
|
|
68
|
-
// icon_only
|
|
69
|
-
const ICON_ONLY_WIDTH: Record<KitSize, string> = {
|
|
73
|
+
// icon_only:宽度等于同档高度(正方形,KT-K0-1 / KT-K-button-3),宽与高读同一个真源键 KC heightUnits;文字藏起来只留符号
|
|
74
|
+
const ICON_ONLY_WIDTH: Record<KitSize, string> = {
|
|
75
|
+
sm: `w-${KIT_CONTROL.heightUnits.sm}`,
|
|
76
|
+
md: `w-${KIT_CONTROL.heightUnits.md}`,
|
|
77
|
+
lg: `w-${KIT_CONTROL.heightUnits.lg}`,
|
|
78
|
+
};
|
|
70
79
|
|
|
71
80
|
export const KIT_BUTTON_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
72
81
|
Object.values(BUTTON_CLASS).flatMap((m) => Object.values(m)), Object.values(ICON_ONLY_WIDTH), SPINNER_WRAP_CLASS, SPINNER_CLASS,
|
|
73
|
-
KIT_BUSY_SPIN_CLASS_CANDIDATES, 'hidden', 'inline-block', 'relative',
|
|
82
|
+
KIT_BUSY_SPIN_CLASS_CANDIDATES, 'hidden', 'inline-block', 'inline-flex', 'relative',
|
|
74
83
|
KIT_BADGE_CLASS_CANDIDATES, KIT_REASON_TIP_CLASS_CANDIDATES, kitDisabledRecipe('aria'),
|
|
75
84
|
);
|
|
76
85
|
|
|
@@ -155,8 +164,14 @@ export function createButton(): SomaComponentDefinition {
|
|
|
155
164
|
}
|
|
156
165
|
if (icon) {
|
|
157
166
|
const glyph = str(p.icon);
|
|
158
|
-
icon
|
|
159
|
-
|
|
167
|
+
// icon 写 kit 图标名(如新建的 plus)画 SVG,其余按短符号原样画
|
|
168
|
+
if ((KIT_ICON_NAMES as readonly string[]).includes(glyph)) {
|
|
169
|
+
icon.replaceChildren(kitIcon(glyph as KitIconName, 'sm'));
|
|
170
|
+
icon.className = 'inline-flex';
|
|
171
|
+
} else {
|
|
172
|
+
icon.textContent = glyph;
|
|
173
|
+
icon.className = glyph !== '' ? 'inline-block' : 'hidden';
|
|
174
|
+
}
|
|
160
175
|
}
|
|
161
176
|
if (label) {
|
|
162
177
|
label.textContent = str(p.label);
|
package/src/base/cascader.ts
CHANGED
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
14
14
|
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
15
15
|
import { kitKey, kitText } from '../i18n/kit-text';
|
|
16
|
-
import { kitIcon } from '
|
|
16
|
+
import { kitIcon } from '../shared/icons';
|
|
17
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
|
+
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
19
|
+
import { kitDivideRecipe } from '../recipes/divider';
|
|
17
20
|
import type { CollectionItem } from 'soma-core/keyboard';
|
|
18
21
|
import {
|
|
19
|
-
EMPTY_ROW_CLASS, KIT_POPUP_CLASS_CANDIDATES, KIT_DROPDOWN_CLASS_CANDIDATES, PANEL_BASE_CLASS,
|
|
22
|
+
EMPTY_ROW_CLASS, KIT_POPUP_CLASS_CANDIDATES, KIT_DROPDOWN_CLASS_CANDIDATES, KIT_DROPDOWN_PANEL_MAX_CLASS, PANEL_BASE_CLASS,
|
|
20
23
|
syncDropdown, releaseDropdown, cssEscape, createListNav, onOutsidePress, optionClass, scrollIntoViewIfAny,
|
|
21
24
|
} from './popup';
|
|
22
25
|
import {
|
|
@@ -31,9 +34,10 @@ const WRAP = 'relative block w-full';
|
|
|
31
34
|
const STATUS = 'sr-only';
|
|
32
35
|
const PANEL_HIDDEN = 'hidden';
|
|
33
36
|
// 位置类(left-0 top-full mt-1 或翻转后的整串)由 popup.ts 的 syncDropdown 拼上,这里只写外观
|
|
34
|
-
|
|
37
|
+
// 多列面板 = 浮起表面(KT-B4);列与列之间的线由父出(kitDivideRecipe,KT-B5)
|
|
38
|
+
const PANEL_COLUMNS = mergeClass('absolute z-10 flex max-w-full overflow-auto', `${kitSurfaceRecipe('raised')} ${kitDivideRecipe('x')}`);
|
|
35
39
|
const PANEL_FLAT = PANEL_BASE_CLASS;
|
|
36
|
-
const COLUMN =
|
|
40
|
+
const COLUMN = `${KIT_DROPDOWN_PANEL_MAX_CLASS} min-w-40 overflow-auto py-1`;
|
|
37
41
|
const CHEVRON = 'ms-auto text-fg-subtle';
|
|
38
42
|
const LABEL = 'min-w-0 truncate';
|
|
39
43
|
|
package/src/base/check-core.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// 状态同时由 JS 着色(paintCheck);用户操作后浏览器已翻转 checked,交互层只在回调里交出「想切到的值」。
|
|
16
16
|
|
|
17
17
|
import { classCandidates, type KitSize } from './shared';
|
|
18
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
18
19
|
|
|
19
20
|
export type CheckKind = 'checkbox' | 'radio';
|
|
20
21
|
export type CheckState = boolean | 'mixed';
|
|
@@ -41,16 +42,18 @@ const INPUT = 'peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appea
|
|
|
41
42
|
const INPUT_RO = 'peer absolute inset-0 z-10 m-0 h-full w-full cursor-default appearance-none opacity-0';
|
|
42
43
|
|
|
43
44
|
const FRAME = 'col-start-1 row-start-1 transition-colors group-hover:border-primary peer-checked:border-primary peer-checked:bg-primary peer-indeterminate:border-primary peer-indeterminate:bg-primary peer-focus-visible:ring-2 peer-focus-visible:ring-ring';
|
|
45
|
+
// 复选 / 单选外圈 = 控件轮廓(KT-B1「复选 / 单选框外圈」,§4 C6);悬停变色由 FRAME 的 group-hover 给
|
|
46
|
+
const EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
44
47
|
const BOX: Record<CheckKind, Record<KitSize, string>> = {
|
|
45
48
|
checkbox: {
|
|
46
|
-
sm: `${FRAME} h-4 w-4 rounded-sm
|
|
47
|
-
md: `${FRAME} h-4 w-4 rounded-sm
|
|
48
|
-
lg: `${FRAME} h-5 w-5 rounded-sm
|
|
49
|
+
sm: `${FRAME} h-4 w-4 rounded-sm ${EDGE} bg-surface`,
|
|
50
|
+
md: `${FRAME} h-4 w-4 rounded-sm ${EDGE} bg-surface`,
|
|
51
|
+
lg: `${FRAME} h-5 w-5 rounded-sm ${EDGE} bg-surface`,
|
|
49
52
|
},
|
|
50
53
|
radio: {
|
|
51
|
-
sm: `${FRAME} h-4 w-4 rounded-full
|
|
52
|
-
md: `${FRAME} h-4 w-4 rounded-full
|
|
53
|
-
lg: `${FRAME} h-5 w-5 rounded-full
|
|
54
|
+
sm: `${FRAME} h-4 w-4 rounded-full ${EDGE} bg-surface`,
|
|
55
|
+
md: `${FRAME} h-4 w-4 rounded-full ${EDGE} bg-surface`,
|
|
56
|
+
lg: `${FRAME} h-5 w-5 rounded-full ${EDGE} bg-surface`,
|
|
54
57
|
},
|
|
55
58
|
};
|
|
56
59
|
const TICK: Record<KitSize, string> = {
|
package/src/base/color-picker.ts
CHANGED
|
@@ -14,8 +14,9 @@ import { createKeyboardWiring } from 'soma-core/keyboard';
|
|
|
14
14
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
15
15
|
import { part, wirePopLayer } from './popover';
|
|
16
16
|
import { KIT_DROPDOWN_CLASS_CANDIDATES } from './popup';
|
|
17
|
-
import { mergeClass } from '../
|
|
17
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
18
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
19
|
+
import { kitControlEdgeRecipe, kitControlRecipe } from '../recipes/control';
|
|
19
20
|
import {
|
|
20
21
|
CLASS_PROP, ID_PROPS, INVALID_PROPS, SIZE_PROP,
|
|
21
22
|
applyCommon, applyCompositeField, bool, classCandidates, createKitController, joinClass, nextUid, setAttr, sizeOf, str,
|
|
@@ -64,10 +65,13 @@ export function presetsOf(raw: unknown): string[] {
|
|
|
64
65
|
// ── 类串 ──────────────────────────────────────────────────────
|
|
65
66
|
|
|
66
67
|
const ROOT = 'relative block w-full';
|
|
68
|
+
// 触发钮 / 色块 / 自定义输入的边 = 控件轮廓出口(KT-B1 / §4 C6)
|
|
69
|
+
const EDGE = kitControlEdgeRecipe();
|
|
70
|
+
const CHIP_EDGE = kitControlEdgeRecipe({ wrapper: true });
|
|
67
71
|
const TRIGGER: Record<KitSize, string> = {
|
|
68
|
-
sm:
|
|
69
|
-
md:
|
|
70
|
-
lg:
|
|
72
|
+
sm: `inline-flex h-6 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-2.5 text-sm text-fg transition-colors 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:opacity-60`,
|
|
73
|
+
md: `inline-flex h-8 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-3 text-sm text-fg transition-colors 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:opacity-60`,
|
|
74
|
+
lg: `inline-flex h-10 w-full cursor-pointer items-center gap-2 rounded-md ${EDGE} bg-surface px-4 text-base text-fg transition-colors 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:opacity-60`,
|
|
71
75
|
};
|
|
72
76
|
const TRIGGER_TEXT = 'min-w-0 flex-1 truncate text-start';
|
|
73
77
|
const TRIGGER_TEXT_EMPTY = 'min-w-0 flex-1 truncate text-start text-fg-subtle';
|
|
@@ -76,11 +80,11 @@ const SWATCH_RECT = 'stroke-border stroke-1';
|
|
|
76
80
|
const PANEL = mergeClass('absolute z-10 w-64 p-3 focus-visible:outline-none', kitSurfaceRecipe('raised'));
|
|
77
81
|
const HIDDEN = 'hidden';
|
|
78
82
|
const PRESETS = 'flex flex-wrap gap-2';
|
|
79
|
-
const CHIP_IDLE =
|
|
83
|
+
const CHIP_IDLE = `inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md ${CHIP_EDGE} transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;
|
|
80
84
|
const CHIP_ON = 'inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md border-2 border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
81
85
|
const CHIP_SVG = 'h-4 w-4';
|
|
82
86
|
const CUSTOM = 'mt-3 flex flex-col gap-1';
|
|
83
|
-
const CUSTOM_INPUT =
|
|
87
|
+
const CUSTOM_INPUT = kitControlRecipe();
|
|
84
88
|
const CUSTOM_INPUT_BAD = 'block h-8 w-full rounded-md border border-danger-on-soft bg-surface px-2.5 text-sm text-fg transition-colors placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
85
89
|
const ERROR = 'text-xs text-danger-on-soft';
|
|
86
90
|
|