soma-kit 0.1.10 → 0.1.12
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/README.md +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -7
- package/packs/finance/reconcile-board.ts +5 -2
- package/packs/finance/reconcile-desk/compile.ts +3 -2
- package/spec/generated/kit-app.schema.json +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- package/src/app/submit.types.ts +1 -1
- package/src/app/theme-endpoint.ts +63 -0
- package/src/app/theme-runtime-shared.ts +1 -0
- package/src/app/theme-runtime.ts +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- package/src/base/input.ts +42 -13
- package/src/base/kbd.ts +3 -1
- package/src/base/link.ts +4 -4
- package/src/base/listbox-core.ts +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- package/src/base/price-text.ts +2 -2
- package/src/base/progress.ts +2 -2
- package/src/base/qr-code.ts +4 -4
- package/src/base/qty-stepper.ts +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- package/src/biz/compose.ts +13 -27
- package/src/biz/define.ts +5 -4
- package/src/biz/import-wizard/compile.ts +22 -26
- package/src/biz/import-wizard/hub.ts +126 -61
- package/src/biz/import-wizard/shell.ts +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/page-templates/domain-templates.ts +80 -13
- package/src/biz/page-templates/result-page/compile.ts +11 -2
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -0
- package/src/cli/service-endpoint-check.ts +425 -0
- package/src/cli/source-path-check.d.mts +17 -0
- package/src/cli/source-path-check.mjs +334 -0
- package/src/cli/view-writes.ts +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- package/src/compile/hints.ts +30 -1
- package/src/compile/index.ts +1 -0
- package/src/compile/kit-error.ts +1 -0
- package/src/compile/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- package/src/data/context-menu.ts +29 -37
- package/src/data/d9-util.ts +2 -18
- package/src/data/diff.ts +4 -2
- package/src/data/dock.ts +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -0
- package/src/data/flow-remote-options.ts +0 -103
- package/src/data/footer.ts +2 -2
- package/src/data/form-draft-registry.ts +2 -4
- package/src/data/gantt.ts +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- package/src/data/redirect.ts +32 -32
- package/src/data/remote-options.ts +13 -6
- package/src/data/request-console.ts +5 -3
- package/src/data/resident.ts +2 -1
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- package/src/object-renderer/collapse-wiring.ts +2 -2
- package/src/object-renderer/collection-expand.ts +2 -2
- package/src/object-renderer/collection-parts.ts +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- package/src/object-renderer/field-value.ts +593 -396
- package/src/object-renderer/filter-reload.ts +70 -0
- package/src/object-renderer/form-detail.ts +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -0
- package/src/page-target/ai-surface.ts +37 -0
- package/src/page-target/compile.ts +48 -8
- package/src/page-target/index.ts +8 -1
- package/src/page-target/intent-schema.ts +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/envelope.ts +207 -0
- package/src/shared/escape.ts +57 -0
- package/src/shared/kit-error.ts +21 -0
- package/src/shared/paged-list-adapter.ts +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -0
- package/src/theme/typography.ts +17 -17
- package/src/biz/shared/step-values.ts +0 -25
- package/src/biz/step-form/steps-ref.ts +0 -112
- package/src/data/options-bus.ts +0 -24
- package/src/data/prompt-dialog.ts +0 -235
- package/src/object-renderer/adopt-gate.ts +0 -333
- package/src/object-renderer/field-policy.ts +0 -89
- package/src/object-renderer/outcome-draft.ts +0 -61
- package/src/theme/nine-dim-palettes.ts +0 -1278
package/src/theme/typography.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 系统级角色排版规格(6 档字阶;具体像素由九维 font_scale 的字号档决定,不在注释里写死;字号底线读 design 真源 kit-nine-dim.json#dimensions.fontScale.floorPx)。
|
|
2
2
|
// 供页面框、业务组件与外部宿主自定义组件(App*)统一引用,避免手写散乱字号与字重。
|
|
3
3
|
|
|
4
4
|
import { classCandidates } from "../base/shared";
|
|
5
5
|
|
|
6
6
|
export const KIT_TYPOGRAPHY = Object.freeze({
|
|
7
|
-
/**
|
|
7
|
+
/** 工作台左上品牌名(半粗) */
|
|
8
8
|
brand: "text-base font-semibold text-fg",
|
|
9
|
-
/** 页面主标题 —
|
|
9
|
+
/** 页面主标题 — 中后台默认紧凑档(半粗) */
|
|
10
10
|
pageTitle: "text-base font-semibold text-fg",
|
|
11
|
-
/** 页面主标题 —
|
|
11
|
+
/** 页面主标题 — 宽松均衡档(半粗) */
|
|
12
12
|
pageTitleStandard: "text-xl font-semibold text-fg",
|
|
13
|
-
/** 卡片 / 分组 /
|
|
13
|
+
/** 卡片 / 分组 / 列表区块标题(半粗) */
|
|
14
14
|
sectionTitle: "text-sm font-semibold text-fg",
|
|
15
|
-
/** 弹窗 /
|
|
15
|
+
/** 弹窗 / 抽屉标题(半粗) */
|
|
16
16
|
dialogTitle: "text-base font-semibold text-fg",
|
|
17
|
-
/**
|
|
17
|
+
/** 核心指标大数字(半粗等宽数字) */
|
|
18
18
|
metricValue: "text-2xl font-semibold text-fg tabular-nums",
|
|
19
|
-
/**
|
|
19
|
+
/** 导航菜单分组小标题(中粗弱化色) */
|
|
20
20
|
menuGroup: "text-xs font-medium text-fg-subtle",
|
|
21
|
-
/** 一级 /
|
|
21
|
+
/** 一级 / 二级导航菜单项(中粗) */
|
|
22
22
|
menuItem: "text-sm font-medium text-fg",
|
|
23
|
-
/**
|
|
23
|
+
/** 页签待命态(次级色) */
|
|
24
24
|
tab: "text-sm text-fg-muted",
|
|
25
|
-
/**
|
|
25
|
+
/** 页签激活态(中粗主色文字) */
|
|
26
26
|
tabActive: "text-sm font-medium text-primary-on-soft",
|
|
27
|
-
/**
|
|
27
|
+
/** 表格列头(半粗次级色) */
|
|
28
28
|
tableHead: "text-xs font-semibold text-fg-muted",
|
|
29
|
-
/**
|
|
29
|
+
/** 表格数据单元格(主文本色) */
|
|
30
30
|
tableCell: "text-sm text-fg",
|
|
31
|
-
/**
|
|
31
|
+
/** 表单字段标签(中粗主文本色) */
|
|
32
32
|
formLabel: "text-sm font-medium text-fg",
|
|
33
|
-
/**
|
|
33
|
+
/** 正文主层级(主文本色) */
|
|
34
34
|
body: "text-sm text-fg",
|
|
35
|
-
/**
|
|
35
|
+
/** 正文次级说明(次级色) */
|
|
36
36
|
bodySecondary: "text-sm text-fg-muted",
|
|
37
|
-
/** 辅助说明 / 时间戳 /
|
|
37
|
+
/** 辅助说明 / 时间戳 / 徽标底线字号(弱化色,严禁小于字号底线) */
|
|
38
38
|
caption: "text-xs text-fg-subtle",
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// 各步已确认值的读口登记(request 动作的 `$steps` 根;GB1)。
|
|
2
|
-
//
|
|
3
|
-
// 值本身仍归 KitStepHub 的 focus 切片,这里只登记一个读口,不另存一份副本:枢纽挂载时登记、卸载时撤销。
|
|
4
|
-
// 一页通常只有一个 StepForm;多个并存时读最近登记的。没有登记读作 {}。
|
|
5
|
-
// 读到的是 { s<i>: { 字段: 值 } },与阶段闸门的 steps.s<i>.字段 同一口径(点「下一步」确认过的值,或回退时带回的未校验草稿)。
|
|
6
|
-
|
|
7
|
-
type Reader = () => Record<string, unknown>;
|
|
8
|
-
|
|
9
|
-
const readers: Reader[] = [];
|
|
10
|
-
|
|
11
|
-
/** 登记读口;返回撤销函数 */
|
|
12
|
-
export function registerKitStepValues(read: Reader): () => void {
|
|
13
|
-
readers.push(read);
|
|
14
|
-
return () => {
|
|
15
|
-
const i = readers.lastIndexOf(read);
|
|
16
|
-
if (i >= 0) readers.splice(i, 1);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** 当前各步已确认的值(没有 StepForm 为 {}) */
|
|
21
|
-
export function readKitStepValues(): Record<string, unknown> {
|
|
22
|
-
const read = readers[readers.length - 1];
|
|
23
|
-
if (read === undefined) return {};
|
|
24
|
-
try { return read(); } catch { return {}; }
|
|
25
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// StepForm 跨步取值(补能力 GB1):把步骤声明里的 `$steps.<步骤名>.<字段>` 校验后改写成规范序号形态 `s<序号>`。
|
|
2
|
-
//
|
|
3
|
-
// 能写 $steps 的四处(都只许指向「更早的步骤」及其 schema 里的字段,不含本步与之后的步骤):
|
|
4
|
-
// · schema.<字段>.default "$steps.<步骤名>.<字段>" -> "$steps.s<i>.<字段>"
|
|
5
|
-
// · schema.<字段>.options.params { steps: "<步骤名>.<字段>" } -> { steps: "s<i>.<字段>" }
|
|
6
|
-
// · schema.<字段>.derive.template {steps.<步骤名>.<字段>[|过滤器…]} -> {steps.s<i>.<字段>…}
|
|
7
|
-
// · behavior.actions[].request.body "$steps.<步骤名>.<字段>" -> "$steps.s<i>.<字段>"
|
|
8
|
-
// 阶段闸门(gate.when 的叶子 steps.<步骤名>.<字段>)早已支持,仍由 adopt-gate.ts 的 gateOf 改写,这里不动。
|
|
9
|
-
// 改写发生在 emitObject 之前;规范形态只在 runInKitStepScope 里才被下游校验认作合法(别处写 $steps 报 KIT-STEP-005)。
|
|
10
|
-
// 运行期取值:表单读 gateSteps 镜像、请求宿主读 step-values 登记的读口,都是 { s<i>: { 字段: 值 } }。
|
|
11
|
-
|
|
12
|
-
import type { KitDiagnostic } from '../../object-renderer/types';
|
|
13
|
-
|
|
14
|
-
type Rec = Record<string, unknown>;
|
|
15
|
-
|
|
16
|
-
const isRec = (v: unknown): v is Rec => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
17
|
-
|
|
18
|
-
export type EarlierSteps = ReadonlyMap<string, { index: number; fields: ReadonlySet<string> }>;
|
|
19
|
-
|
|
20
|
-
export interface StepRefResult {
|
|
21
|
-
step: Rec;
|
|
22
|
-
/** 本步有没有用到 $steps(用到才需要把各步已确认值的镜像交给表单) */
|
|
23
|
-
used: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const IDENT = '[A-Za-z_][A-Za-z0-9_]*';
|
|
27
|
-
const DEFAULT_RE = new RegExp(`^\\$steps\\.(${IDENT})\\.(${IDENT})$`);
|
|
28
|
-
const PLACEHOLDER_RE = new RegExp(`\\{steps\\.(${IDENT})\\.(${IDENT})(?=[|}])`, 'g');
|
|
29
|
-
|
|
30
|
-
export function rewriteStepRefs(raw: Rec, path: string, earlier: EarlierSteps, diags: KitDiagnostic[]): StepRefResult {
|
|
31
|
-
let used = false;
|
|
32
|
-
const bad = (message: string, at: string): void => { diags.push({ code: 'KIT-STEP-005', path: at, message }); };
|
|
33
|
-
/** 步骤名 + 字段 -> s<序号> + 字段;引用不到记 KIT-STEP-005 并返回 null */
|
|
34
|
-
const lookup = (name: string, field: string, at: string): string | null => {
|
|
35
|
-
const hit = earlier.get(name);
|
|
36
|
-
if (hit === undefined) { bad(`$steps 引用的步骤 "${name}" 不是更早的步骤(只能指向本步之前已有的步骤;可用:${[...earlier.keys()].join(' / ') || '无,这是第一步'})`, at); return null; }
|
|
37
|
-
if (!hit.fields.has(field)) { bad(`步骤 "${name}" 的 schema 里没有字段 "${field}"`, at); return null; }
|
|
38
|
-
used = true;
|
|
39
|
-
return `s${hit.index}`;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// schema
|
|
43
|
-
let schema = raw.schema;
|
|
44
|
-
if (isRec(raw.schema)) {
|
|
45
|
-
const next: Rec = {};
|
|
46
|
-
for (const [fname, decl] of Object.entries(raw.schema)) {
|
|
47
|
-
if (!isRec(decl)) { next[fname] = decl; continue; }
|
|
48
|
-
let out: Rec = decl;
|
|
49
|
-
const at = `${path}.schema.${fname}`;
|
|
50
|
-
// default
|
|
51
|
-
if (typeof decl.default === 'string' && decl.default.startsWith('$steps.')) {
|
|
52
|
-
const m = DEFAULT_RE.exec(decl.default);
|
|
53
|
-
if (m === null) bad(`default "${decl.default}" 应写成 $steps.<步骤名>.<字段>`, `${at}.default`);
|
|
54
|
-
else {
|
|
55
|
-
const id = lookup(m[1]!, m[2]!, `${at}.default`);
|
|
56
|
-
if (id !== null) out = { ...out, default: `$steps.${id}.${m[2]!}` };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
// options.params
|
|
60
|
-
if (isRec(decl.options) && isRec(decl.options.params)) {
|
|
61
|
-
const params: Rec = {};
|
|
62
|
-
let changed = false;
|
|
63
|
-
for (const [pn, pv] of Object.entries(decl.options.params)) {
|
|
64
|
-
if (isRec(pv) && 'steps' in pv) {
|
|
65
|
-
const parts = typeof pv.steps === 'string' ? pv.steps.split('.') : [];
|
|
66
|
-
if (Object.keys(pv).length !== 1 || parts.length !== 2 || parts[0] === '' || parts[1] === '') {
|
|
67
|
-
bad(`params.${pn} 的 { steps } 应写成 { steps: '<步骤名>.<字段>' }`, `${at}.options.params.${pn}`);
|
|
68
|
-
params[pn] = pv;
|
|
69
|
-
} else {
|
|
70
|
-
const id = lookup(parts[0]!, parts[1]!, `${at}.options.params.${pn}`);
|
|
71
|
-
params[pn] = id === null ? pv : { steps: `${id}.${parts[1]!}` };
|
|
72
|
-
changed = true;
|
|
73
|
-
}
|
|
74
|
-
} else params[pn] = pv;
|
|
75
|
-
}
|
|
76
|
-
if (changed) out = { ...out, options: { ...decl.options, params } };
|
|
77
|
-
}
|
|
78
|
-
// derive.template
|
|
79
|
-
if (isRec(decl.derive) && typeof decl.derive.template === 'string' && decl.derive.template.includes('{steps.')) {
|
|
80
|
-
const tpl = decl.derive.template.replace(PLACEHOLDER_RE, (whole, name: string, field: string) => {
|
|
81
|
-
const id = lookup(name, field, `${at}.derive.template`);
|
|
82
|
-
return id === null ? whole : `{steps.${id}.${field}`;
|
|
83
|
-
});
|
|
84
|
-
out = { ...out, derive: { ...decl.derive, template: tpl } };
|
|
85
|
-
}
|
|
86
|
-
next[fname] = out;
|
|
87
|
-
}
|
|
88
|
-
schema = next;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 步骤动作的请求体
|
|
92
|
-
let behavior = raw.behavior;
|
|
93
|
-
if (isRec(raw.behavior) && Array.isArray(raw.behavior.actions)) {
|
|
94
|
-
const actions = raw.behavior.actions.map((a, i) => {
|
|
95
|
-
if (!isRec(a) || !isRec(a.request) || !isRec(a.request.body)) return a;
|
|
96
|
-
const body: Rec = {};
|
|
97
|
-
for (const [k, v] of Object.entries(a.request.body)) {
|
|
98
|
-
if (typeof v === 'string' && v.startsWith('$steps.')) {
|
|
99
|
-
const m = DEFAULT_RE.exec(v);
|
|
100
|
-
const at = `${path}.behavior.actions[${i}].request.body.${k}`;
|
|
101
|
-
if (m === null) { bad(`${v} 应写成 $steps.<步骤名>.<字段>`, at); body[k] = v; continue; }
|
|
102
|
-
const id = lookup(m[1]!, m[2]!, at);
|
|
103
|
-
body[k] = id === null ? v : `$steps.${id}.${m[2]!}`;
|
|
104
|
-
} else body[k] = v;
|
|
105
|
-
}
|
|
106
|
-
return { ...a, request: { ...a.request, body } };
|
|
107
|
-
});
|
|
108
|
-
behavior = { ...raw.behavior, actions };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return { step: { ...raw, ...(schema !== undefined ? { schema } : {}), ...(behavior !== undefined ? { behavior } : {}) }, used };
|
|
112
|
-
}
|
package/src/data/options-bus.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// 远程选项失效总线(补能力 H1b):写成功后让页面里 options.from 等于某接口的字段重取候选(含其它页签里的表单)。
|
|
2
|
-
//
|
|
3
|
-
// 为什么要它:options.from 的候选是 KitObjectForm 经 services.http 自取的,不是 core 数据对象,`reload` 点名数据对象够不着;
|
|
4
|
-
// tabs-frame 的各页签面板一次全部挂载,所以一个进程内的小总线就够——KitObjectForm 挂载时订阅,
|
|
5
|
-
// KitActionHost 在 request.then 的 `reload: /接口路径` 项触发时发布。不跨页面、不持久、不缓存,只做「通知重取」。
|
|
6
|
-
|
|
7
|
-
type Listener = (from: string) => void;
|
|
8
|
-
|
|
9
|
-
const listeners = new Set<Listener>();
|
|
10
|
-
|
|
11
|
-
/** 订阅选项源失效;返回取消订阅函数 */
|
|
12
|
-
export function onKitOptionsInvalidate(fn: Listener): () => void {
|
|
13
|
-
listeners.add(fn);
|
|
14
|
-
return () => { listeners.delete(fn); };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** 发布:接口路径为 `from` 的选项源作废,订阅者各自决定是否重取;返回通知到的订阅者个数 */
|
|
18
|
-
export function invalidateKitOptions(from: string): number {
|
|
19
|
-
let n = 0;
|
|
20
|
-
for (const fn of [...listeners]) {
|
|
21
|
-
try { fn(from); n += 1; } catch (error) { console.error('[soma-kit] 选项失效通知失败', error); }
|
|
22
|
-
}
|
|
23
|
-
return n;
|
|
24
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
// askKitPrompt:命令式的自绘「请求前输入」对话框(补能力 GA4,request.prompt 的运行端)。
|
|
2
|
-
//
|
|
3
|
-
// 壳用 mountKitModal(经 core 浮层端口挂出:Esc 走层栈只关栈顶、Tab 焦点陷阱、关闭后回焦);本文件只补输入项与按钮:
|
|
4
|
-
// - 返回 Promise<Record | null>:确认 = 输入值对象(键 = 输入项 name);取消 / Esc / 关闭钮 = null(调用方不发请求);
|
|
5
|
-
// - 输入项 type:text / textarea / number(原生 input 即可)、select(自绘单选列表,role=radiogroup,方向键 / Home / End 移动并选中)、
|
|
6
|
-
// switch(自绘 role=switch 开关)。不用原生 select / 原生对话框;
|
|
7
|
-
// - 必填项为空不能确认,错误写在该项下面(role=alert),不静默吞;number 只收有限数字;
|
|
8
|
-
// - 文案只用 textContent 写入,不经 innerHTML;无 DOM 环境(SSR / 测试)直接 resolve null。
|
|
9
|
-
// 输入项形状与限值见 object-renderer/request-actions.ts 的 promptOf(编译期已核,这里信任但不盲信:非法项忽略)。
|
|
10
|
-
|
|
11
|
-
import { kitText } from '../i18n/kit-text';
|
|
12
|
-
import { KIT_MODAL_CLASS_CANDIDATES, mountKitModal, watchKitModalDetached } from './modal-dialog';
|
|
13
|
-
import { BUTTON_CLASS_TOKENS, classTokens } from './shape-util';
|
|
14
|
-
import type { KitPromptSpec } from '../object-renderer/request-actions';
|
|
15
|
-
|
|
16
|
-
const BUTTON_BASE = 'inline-flex h-9 cursor-pointer items-center justify-center rounded-md px-4 text-sm font-medium transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
17
|
-
const BUTTON_PRIMARY = 'border-0 bg-primary text-primary-fg hover:opacity-90';
|
|
18
|
-
const BUTTON_NEUTRAL = 'border border-border bg-surface text-fg hover:bg-surface-sunken';
|
|
19
|
-
const FIELD_CLASS = 'flex flex-col gap-1';
|
|
20
|
-
const LABEL_CLASS = 'text-sm font-medium text-fg';
|
|
21
|
-
const STAR_CLASS = 'text-danger-on-soft';
|
|
22
|
-
const INPUT_CLASS = 'h-9 w-full rounded-md border border-border bg-surface px-3 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring';
|
|
23
|
-
const AREA_CLASS = 'block w-full resize-none rounded-md border border-border bg-surface px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-ring';
|
|
24
|
-
const ERROR_CLASS = 'm-0 text-xs text-danger-on-soft';
|
|
25
|
-
const GROUP_CLASS = 'flex max-h-48 flex-col gap-1 overflow-y-auto rounded-md border border-border bg-surface p-1';
|
|
26
|
-
// 选中态 / 开关态用整串字面量切换(不拼接类名,候选类一次收齐)
|
|
27
|
-
const RADIO_OFF = 'flex h-8 w-full border-0 bg-transparent cursor-pointer items-center rounded-md px-3 text-start text-sm text-fg transition-colors hover:bg-surface-sunken focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
28
|
-
const RADIO_ON = 'flex h-8 w-full border-0 cursor-pointer items-center rounded-md bg-primary-soft px-3 text-start text-sm text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
29
|
-
const SWITCH_OFF = 'inline-flex h-6 w-10 cursor-pointer items-center rounded-full border border-border bg-surface-sunken px-0.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
30
|
-
const SWITCH_ON = 'inline-flex h-6 w-10 cursor-pointer items-center rounded-full border border-primary bg-primary px-0.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
31
|
-
const KNOB_OFF = 'block size-4 translate-x-0 rounded-full bg-surface shadow-sm transition-transform motion-safe:duration-150';
|
|
32
|
-
const KNOB_ON = 'block size-4 translate-x-4 rounded-full bg-surface shadow-sm transition-transform motion-safe:duration-150';
|
|
33
|
-
const HIDDEN = 'hidden';
|
|
34
|
-
|
|
35
|
-
export const KIT_PROMPT_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
36
|
-
BUTTON_BASE, BUTTON_PRIMARY, BUTTON_NEUTRAL, FIELD_CLASS, LABEL_CLASS, STAR_CLASS, INPUT_CLASS, AREA_CLASS, ERROR_CLASS, GROUP_CLASS, RADIO_OFF, RADIO_ON,
|
|
37
|
-
SWITCH_OFF, SWITCH_ON, KNOB_OFF, KNOB_ON, HIDDEN, BUTTON_CLASS_TOKENS, KIT_MODAL_CLASS_CANDIDATES,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
export interface KitPromptOptions extends KitPromptSpec {
|
|
41
|
-
/** 输入项初值(name -> 值;调用方已把 $filter / $row 取值路径解析成值) */
|
|
42
|
-
defaults?: Readonly<Record<string, unknown>>;
|
|
43
|
-
/** 调用方元素:取页面语言与书写方向,也是回焦参照 */
|
|
44
|
-
at?: Element | null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type Field = KitPromptSpec['fields'][number];
|
|
48
|
-
|
|
49
|
-
interface Reader {
|
|
50
|
-
/** 当前值;number 空 / 非有限数返回 undefined */
|
|
51
|
-
read(): unknown;
|
|
52
|
-
/** 是否为空(必填判断用) */
|
|
53
|
-
blank(): boolean;
|
|
54
|
-
focus(): void;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function mk<K extends keyof HTMLElementTagNameMap>(doc: Document, tag: K, cls: string, text?: string): HTMLElementTagNameMap[K] {
|
|
58
|
-
const node = doc.createElement(tag);
|
|
59
|
-
if (cls !== '') node.className = cls;
|
|
60
|
-
if (text !== undefined) node.textContent = text;
|
|
61
|
-
return node;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function askKitPrompt(opts: KitPromptOptions): Promise<Record<string, unknown> | null> {
|
|
65
|
-
if (typeof document === 'undefined' || document.body === null) return Promise.resolve(null);
|
|
66
|
-
const doc = opts.at?.ownerDocument ?? document;
|
|
67
|
-
return new Promise((resolve) => {
|
|
68
|
-
let settled = false;
|
|
69
|
-
let unwatch: () => void = () => {};
|
|
70
|
-
const finish = (value: Record<string, unknown> | null): void => {
|
|
71
|
-
if (settled) return;
|
|
72
|
-
settled = true;
|
|
73
|
-
unwatch();
|
|
74
|
-
modal.close();
|
|
75
|
-
modal.destroy();
|
|
76
|
-
resolve(value);
|
|
77
|
-
};
|
|
78
|
-
const modal = mountKitModal({
|
|
79
|
-
title: opts.title ?? kitText('soma.kit.prompt_title', undefined, opts.at),
|
|
80
|
-
size: 'sm',
|
|
81
|
-
at: opts.at ?? null,
|
|
82
|
-
showClose: false,
|
|
83
|
-
onClose: () => finish(null),
|
|
84
|
-
}, doc);
|
|
85
|
-
|
|
86
|
-
const readers = new Map<string, Reader>();
|
|
87
|
-
const errors = new Map<string, HTMLElement>();
|
|
88
|
-
const defaults = opts.defaults ?? {};
|
|
89
|
-
let uid = 0;
|
|
90
|
-
|
|
91
|
-
for (const f of opts.fields as Field[]) {
|
|
92
|
-
if (typeof f.name !== 'string' || f.name === '') continue;
|
|
93
|
-
uid += 1;
|
|
94
|
-
const id = `kit-prompt-${uid}-${f.name}`;
|
|
95
|
-
const wrap = mk(doc, 'div', FIELD_CLASS);
|
|
96
|
-
const label = mk(doc, 'label', LABEL_CLASS, f.label ?? f.name);
|
|
97
|
-
label.id = `${id}-label`;
|
|
98
|
-
if (f.required === true) {
|
|
99
|
-
const star = mk(doc, 'span', STAR_CLASS, ' *');
|
|
100
|
-
star.setAttribute('aria-hidden', 'true');
|
|
101
|
-
label.appendChild(star);
|
|
102
|
-
}
|
|
103
|
-
wrap.appendChild(label);
|
|
104
|
-
const initial = defaults[f.name];
|
|
105
|
-
const err = mk(doc, 'p', HIDDEN);
|
|
106
|
-
err.setAttribute('role', 'alert');
|
|
107
|
-
errors.set(f.name, err);
|
|
108
|
-
|
|
109
|
-
if (f.type === 'select') {
|
|
110
|
-
const options = f.options ?? [];
|
|
111
|
-
let current: unknown = initial !== undefined && options.some((o) => o.value === initial) ? initial : undefined;
|
|
112
|
-
const group = mk(doc, 'div', GROUP_CLASS);
|
|
113
|
-
group.setAttribute('role', 'radiogroup');
|
|
114
|
-
group.setAttribute('aria-labelledby', label.id);
|
|
115
|
-
const buttons: HTMLButtonElement[] = [];
|
|
116
|
-
const paint = (): void => {
|
|
117
|
-
buttons.forEach((b, i) => {
|
|
118
|
-
const on = options[i]!.value === current;
|
|
119
|
-
b.setAttribute('aria-checked', on ? 'true' : 'false');
|
|
120
|
-
b.className = on ? RADIO_ON : RADIO_OFF;
|
|
121
|
-
// roving tabindex:已选项(没有选中则第一项)进 Tab 序
|
|
122
|
-
b.tabIndex = on || (current === undefined && i === 0) ? 0 : -1;
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
options.forEach((o, i) => {
|
|
126
|
-
const b = mk(doc, 'button', RADIO_OFF, o.label);
|
|
127
|
-
b.type = 'button';
|
|
128
|
-
b.setAttribute('role', 'radio');
|
|
129
|
-
b.addEventListener('click', () => { current = o.value; paint(); });
|
|
130
|
-
b.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
131
|
-
const last = options.length - 1;
|
|
132
|
-
let next = -1;
|
|
133
|
-
if (e.key === 'ArrowDown' || e.key === 'ArrowRight') next = i === last ? 0 : i + 1;
|
|
134
|
-
else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') next = i === 0 ? last : i - 1;
|
|
135
|
-
else if (e.key === 'Home') next = 0;
|
|
136
|
-
else if (e.key === 'End') next = last;
|
|
137
|
-
if (next < 0) return;
|
|
138
|
-
e.preventDefault();
|
|
139
|
-
current = options[next]!.value;
|
|
140
|
-
paint();
|
|
141
|
-
buttons[next]!.focus();
|
|
142
|
-
});
|
|
143
|
-
buttons.push(b);
|
|
144
|
-
group.appendChild(b);
|
|
145
|
-
});
|
|
146
|
-
paint();
|
|
147
|
-
wrap.appendChild(group);
|
|
148
|
-
readers.set(f.name, { read: () => current, blank: () => current === undefined, focus: () => (buttons.find((b) => b.tabIndex === 0) ?? buttons[0])?.focus() });
|
|
149
|
-
} else if (f.type === 'switch') {
|
|
150
|
-
let on = initial === true;
|
|
151
|
-
const sw = mk(doc, 'button', SWITCH_OFF);
|
|
152
|
-
sw.type = 'button';
|
|
153
|
-
sw.setAttribute('role', 'switch');
|
|
154
|
-
sw.setAttribute('aria-labelledby', label.id);
|
|
155
|
-
const knob = mk(doc, 'span', KNOB_OFF);
|
|
156
|
-
sw.appendChild(knob);
|
|
157
|
-
const paint = (): void => {
|
|
158
|
-
sw.setAttribute('aria-checked', on ? 'true' : 'false');
|
|
159
|
-
sw.className = on ? SWITCH_ON : SWITCH_OFF;
|
|
160
|
-
knob.className = on ? KNOB_ON : KNOB_OFF;
|
|
161
|
-
};
|
|
162
|
-
paint();
|
|
163
|
-
sw.addEventListener('click', () => { on = !on; paint(); });
|
|
164
|
-
wrap.appendChild(sw);
|
|
165
|
-
readers.set(f.name, { read: () => on, blank: () => false, focus: () => sw.focus() });
|
|
166
|
-
} else if (f.type === 'textarea') {
|
|
167
|
-
const area = mk(doc, 'textarea', AREA_CLASS);
|
|
168
|
-
area.id = id;
|
|
169
|
-
area.rows = 4;
|
|
170
|
-
area.value = typeof initial === 'string' || typeof initial === 'number' ? String(initial) : '';
|
|
171
|
-
area.placeholder = f.placeholder ?? '';
|
|
172
|
-
label.htmlFor = id;
|
|
173
|
-
wrap.appendChild(area);
|
|
174
|
-
readers.set(f.name, { read: () => area.value, blank: () => area.value.trim() === '', focus: () => area.focus() });
|
|
175
|
-
} else {
|
|
176
|
-
const input = mk(doc, 'input', INPUT_CLASS);
|
|
177
|
-
input.id = id;
|
|
178
|
-
input.type = f.type === 'number' ? 'number' : 'text';
|
|
179
|
-
input.autocomplete = 'off';
|
|
180
|
-
input.value = typeof initial === 'string' || typeof initial === 'number' ? String(initial) : '';
|
|
181
|
-
input.placeholder = f.placeholder ?? '';
|
|
182
|
-
label.htmlFor = id;
|
|
183
|
-
wrap.appendChild(input);
|
|
184
|
-
readers.set(f.name, {
|
|
185
|
-
read: () => {
|
|
186
|
-
if (f.type !== 'number') return input.value;
|
|
187
|
-
const n = Number(input.value);
|
|
188
|
-
return input.value.trim() === '' || !Number.isFinite(n) ? undefined : n;
|
|
189
|
-
},
|
|
190
|
-
blank: () => (f.type === 'number' ? input.value.trim() === '' || !Number.isFinite(Number(input.value)) : input.value.trim() === ''),
|
|
191
|
-
focus: () => input.focus(),
|
|
192
|
-
});
|
|
193
|
-
input.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
194
|
-
if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); submit(); }
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
wrap.appendChild(err);
|
|
198
|
-
modal.body.appendChild(wrap);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const submit = (): void => {
|
|
202
|
-
let firstBad: Reader | null = null;
|
|
203
|
-
for (const f of opts.fields as Field[]) {
|
|
204
|
-
const r = readers.get(f.name);
|
|
205
|
-
const err = errors.get(f.name);
|
|
206
|
-
if (r === undefined || err === undefined) continue;
|
|
207
|
-
const bad = f.required === true && r.blank();
|
|
208
|
-
err.textContent = bad ? kitText('soma.kit.prompt_required', undefined, opts.at) : '';
|
|
209
|
-
err.className = bad ? ERROR_CLASS : HIDDEN;
|
|
210
|
-
if (bad && firstBad === null) firstBad = r;
|
|
211
|
-
}
|
|
212
|
-
if (firstBad !== null) { (firstBad as Reader).focus(); return; }
|
|
213
|
-
const out: Record<string, unknown> = {};
|
|
214
|
-
for (const f of opts.fields as Field[]) {
|
|
215
|
-
const v = readers.get(f.name)?.read();
|
|
216
|
-
if (v !== undefined) out[f.name] = v;
|
|
217
|
-
}
|
|
218
|
-
finish(out);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
const cancel = mk(doc, 'button', `${BUTTON_BASE} ${BUTTON_NEUTRAL}`, kitText('soma.kit.cancel', undefined, opts.at));
|
|
222
|
-
cancel.type = 'button';
|
|
223
|
-
cancel.addEventListener('click', () => finish(null));
|
|
224
|
-
const ok = mk(doc, 'button', `${BUTTON_BASE} ${BUTTON_PRIMARY}`, opts.submitLabel ?? kitText('soma.kit.confirm', undefined, opts.at));
|
|
225
|
-
ok.type = 'button';
|
|
226
|
-
ok.addEventListener('click', submit);
|
|
227
|
-
modal.footer.append(cancel, ok);
|
|
228
|
-
|
|
229
|
-
(opts.at?.isConnected === true ? opts.at.parentNode ?? doc.body : doc.body).appendChild(modal.layer);
|
|
230
|
-
modal.open();
|
|
231
|
-
// 兜底:打开期间宿主区域被卸载(层锚点脱离文档)时按取消收口,调用方的 await 不会永久挂起
|
|
232
|
-
unwatch = watchKitModalDetached(modal.layer, doc, () => finish(null));
|
|
233
|
-
(readers.values().next().value as Reader | undefined)?.focus();
|
|
234
|
-
});
|
|
235
|
-
}
|