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
|
@@ -93,76 +93,6 @@ export function flowOptionSlots(nodeTypes: unknown): FlowOptionSlot[] {
|
|
|
93
93
|
return out;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
/** RowEditor 列的远程选项槽的 type 标记(与画布节点槽共用同一套取数 / 解析 / 失效清理,槽 id = `$cols.<列键>`) */
|
|
97
|
-
export const ROW_COLUMN_SLOT_TYPE = '$cols';
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* RowEditor 列里 params 含 { field: 表单字段 } 的 select 远程选项槽(只含依赖表单草稿的列;
|
|
101
|
-
* 只有字面量参数的列仍由 RowEditor 自己取)。params 解析复用画布槽同一个 planOptionSourceRequest,不另写。
|
|
102
|
-
*/
|
|
103
|
-
export function rowColumnSlots(columns: unknown): FlowOptionSlot[] {
|
|
104
|
-
const out: FlowOptionSlot[] = [];
|
|
105
|
-
if (!Array.isArray(columns)) return out;
|
|
106
|
-
columns.forEach((c, index) => {
|
|
107
|
-
if (out.length >= FO_LIM.slotsMax || !isRec(c) || c.kind !== 'select' || !isRec(c.options)) return;
|
|
108
|
-
const o = c.options;
|
|
109
|
-
if (typeof o.from !== 'string' || !o.from.startsWith('/') || !isRec(o.params)) return;
|
|
110
|
-
if (!Object.values(o.params).some((v) => isRec(v) && typeof v.field === 'string')) return;
|
|
111
|
-
const key = text(c.key);
|
|
112
|
-
if (key === '') return;
|
|
113
|
-
out.push({
|
|
114
|
-
id: `${ROW_COLUMN_SLOT_TYPE}.${key}`,
|
|
115
|
-
type: ROW_COLUMN_SLOT_TYPE,
|
|
116
|
-
index,
|
|
117
|
-
key,
|
|
118
|
-
mapping: false,
|
|
119
|
-
prefix: '',
|
|
120
|
-
from: o.from,
|
|
121
|
-
params: o.params,
|
|
122
|
-
valueKey: typeof o.valueKey === 'string' && o.valueKey !== '' ? o.valueKey : FO.valueKeyDefault,
|
|
123
|
-
labelKey: typeof o.labelKey === 'string' && o.labelKey !== '' ? o.labelKey : FO.labelKeyDefault,
|
|
124
|
-
rowsPath: typeof o.rowsPath === 'string' ? o.rowsPath : '',
|
|
125
|
-
meta: {},
|
|
126
|
-
groupKey: '',
|
|
127
|
-
hintKey: '',
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
return out;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** 把取到的候选并回 RowEditor 的 columns(静态选项数组;加载中 / 失败写占位),返回新数组 */
|
|
134
|
-
export function withRowColumnOptions(
|
|
135
|
-
columns: unknown,
|
|
136
|
-
resolve: (slot: FlowOptionSlot) => FlowOptionResolved,
|
|
137
|
-
placeholderOf: (state: FlowOptionState) => string,
|
|
138
|
-
): unknown {
|
|
139
|
-
const slots = rowColumnSlots(columns);
|
|
140
|
-
if (slots.length === 0 || !Array.isArray(columns)) return columns;
|
|
141
|
-
const out = columns.slice();
|
|
142
|
-
for (const slot of slots) {
|
|
143
|
-
const col = out[slot.index];
|
|
144
|
-
if (!isRec(col)) continue;
|
|
145
|
-
const got = resolve(slot);
|
|
146
|
-
const holder = placeholderOf(got.state);
|
|
147
|
-
out[slot.index] = { ...col, options: got.options.map((o) => ({ value: o.value, label: o.label })), ...(holder !== '' ? { placeholder: holder } : {}) };
|
|
148
|
-
}
|
|
149
|
-
return out;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** 依赖变化后的失效清理(行表):该列已选值不在新候选里的行,清空这一格;返回新行与被清的行数,没有要清的返回 null */
|
|
153
|
-
export function clearStaleRowSelections(rows: unknown, slot: FlowOptionSlot, valid: ReadonlySet<string>): { rows: Rec[]; cleared: number } | null {
|
|
154
|
-
if (!Array.isArray(rows)) return null;
|
|
155
|
-
let cleared = 0;
|
|
156
|
-
const next = rows.map((r) => {
|
|
157
|
-
if (!isRec(r)) return r as Rec;
|
|
158
|
-
const cur = r[slot.key];
|
|
159
|
-
if (cur === undefined || cur === null || cur === '' || valid.has(text(cur))) return r;
|
|
160
|
-
cleared += 1;
|
|
161
|
-
return { ...r, [slot.key]: '' };
|
|
162
|
-
});
|
|
163
|
-
return cleared === 0 ? null : { rows: next, cleared };
|
|
164
|
-
}
|
|
165
|
-
|
|
166
96
|
/** mapping 字段的目标前缀:`{key}` 占位取 meta 里同名键的当前值(flow-editor 的 mappingPrefix 即此函数,存储键 = 前缀 + 候选 key) */
|
|
167
97
|
export function mappingPrefixOf(f: { prefix?: string }, meta: Record<string, unknown>): string {
|
|
168
98
|
return (f.prefix ?? '').replace(/\{([^}]+)\}/g, (_, k: string) => text(meta[k]));
|
|
@@ -222,36 +152,3 @@ export function withFlowOptions(
|
|
|
222
152
|
}
|
|
223
153
|
return out;
|
|
224
154
|
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 依赖字段变化后的失效清理(纯函数,不改入参):该槽类型的节点里,已选值不在新候选里的,清掉值(及随选中并入的 meta 键)。
|
|
228
|
-
* select 槽清单值;mapping 槽清映射里目标键不在新候选中的条目(目标键与候选 value 全量比较,不剥前缀),条目清空则整个映射键去掉。
|
|
229
|
-
* 返回新图和被清的节点数,没有要清的返回 null。
|
|
230
|
-
*/
|
|
231
|
-
export function clearStaleFlowSelections(graph: unknown, slot: FlowOptionSlot, valid: ReadonlySet<string>): { graph: Rec; cleared: number } | null {
|
|
232
|
-
if (!isRec(graph) || !Array.isArray(graph.nodes)) return null;
|
|
233
|
-
let cleared = 0;
|
|
234
|
-
const nodes = graph.nodes.map((n) => {
|
|
235
|
-
if (!isRec(n) || n.type !== slot.type || !isRec(n.meta)) return n;
|
|
236
|
-
if (slot.mapping) {
|
|
237
|
-
const cm = n.meta[slot.key];
|
|
238
|
-
if (!isRec(cm)) return n;
|
|
239
|
-
// 存储键 = 字段前缀(按本节点 meta 解占位)+ 候选 key,与编辑器同一拼法
|
|
240
|
-
const pre = mappingPrefixOf({ prefix: slot.prefix }, n.meta);
|
|
241
|
-
const kept = Object.entries(cm).filter(([target]) => valid.has(target) || (pre !== '' && target.startsWith(pre) && valid.has(target.slice(pre.length))));
|
|
242
|
-
if (kept.length === Object.keys(cm).length) return n;
|
|
243
|
-
const mmeta: Rec = { ...n.meta };
|
|
244
|
-
if (kept.length === 0) delete mmeta[slot.key]; else mmeta[slot.key] = Object.fromEntries(kept);
|
|
245
|
-
cleared += 1;
|
|
246
|
-
return { ...n, meta: mmeta };
|
|
247
|
-
}
|
|
248
|
-
const cur = n.meta[slot.key];
|
|
249
|
-
if (cur === undefined || cur === null || cur === '' || valid.has(text(cur))) return n;
|
|
250
|
-
const meta: Rec = { ...n.meta };
|
|
251
|
-
delete meta[slot.key];
|
|
252
|
-
for (const k of Object.keys(slot.meta)) delete meta[k];
|
|
253
|
-
cleared += 1;
|
|
254
|
-
return { ...n, meta };
|
|
255
|
-
});
|
|
256
|
-
return cleared === 0 ? null : { graph: { ...graph, nodes }, cleared };
|
|
257
|
-
}
|
package/src/data/footer.ts
CHANGED
|
@@ -87,7 +87,7 @@ export function createFooter(): SomaComponentDefinition {
|
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
89
|
templateHtml: `<footer data-soma-id="root" class="${ROOT_CLASS}"></footer>`,
|
|
90
|
-
controllerFactory: createKitController({
|
|
90
|
+
controllerFactory: createKitController(() => ({
|
|
91
91
|
attach(root, api) {
|
|
92
92
|
const onClick = (event: Event): void => {
|
|
93
93
|
const a = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-pick]');
|
|
@@ -152,6 +152,6 @@ export function createFooter(): SomaComponentDefinition {
|
|
|
152
152
|
root.appendChild(bottom);
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
|
-
}),
|
|
155
|
+
})),
|
|
156
156
|
};
|
|
157
157
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 表单草稿读口登记(代码侧读口:具名动作的 `kitActionExtras().draft()` 与请求状态行插值;页面声明里没有 $draft 取值路径)。
|
|
2
2
|
//
|
|
3
3
|
// 草稿本身仍是 KitObjectForm 的 createFormDraft(foundation 一份),这里只登记一个读口,不另存一份副本:
|
|
4
4
|
// 表单挂载时登记、卸载时撤销;值变化 / 重置 / 详情到达时 touch(刷新「最近动过」)。
|
|
5
5
|
//
|
|
6
|
-
//
|
|
6
|
+
// 选表单的规则(写死、无推断):
|
|
7
7
|
// · 只认非筛选表单(create / edit)、已就绪(详情取数中或失败的不算)、当前可见(隐藏的浮层表单不算);
|
|
8
8
|
// · 给了 scope(= 表单的 scope prop)只在该 scope 里找;
|
|
9
9
|
// · 多个并存取 touch 序号最大的(最近动过)。
|
|
@@ -21,8 +21,6 @@ export interface KitFormDraftEntry {
|
|
|
21
21
|
dirty(): boolean;
|
|
22
22
|
/** 编辑详情取数中 / 失败时为 false:这时表单没有可信的草稿 */
|
|
23
23
|
ready(): boolean;
|
|
24
|
-
/** 采纳建议回填草稿(W2 的 patch 口):把 values 合并进草稿并重绘,成功返回 true;本批只定义读,未实现的表单不填 */
|
|
25
|
-
patch?(values: Record<string, unknown>): boolean;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
interface Slot {
|
package/src/data/gantt.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
//(item 是源数据里的原对象),键盘用 Tab 走行、Enter / Space 触发。
|
|
18
18
|
// 画面用一张 SVG(任务条、进度、刻度线、今日线、依赖线),左栏与表头是 HTML;SVG 只用语义色名类与属性,无内联样式。
|
|
19
19
|
|
|
20
|
-
import type {
|
|
21
|
-
import {
|
|
20
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
21
|
+
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
22
22
|
import { kitText } from '../i18n/kit-text';
|
|
23
23
|
|
|
24
24
|
// ── 数据规整纯函数:日期换算、任务解析、时间轴、任务条位置、刻度、行序 ──
|
|
@@ -271,11 +271,10 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
271
271
|
},
|
|
272
272
|
},
|
|
273
273
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
274
|
-
controllerFactory: (
|
|
275
|
-
const P = (): Record<string, unknown> =>
|
|
274
|
+
controllerFactory: createKitController((api) => {
|
|
275
|
+
const P = (): Record<string, unknown> => api.props();
|
|
276
276
|
let root: HTMLElement | null = null;
|
|
277
277
|
let tasks: KitGanttTask[] = [];
|
|
278
|
-
let cleanup: (() => void) | undefined;
|
|
279
278
|
|
|
280
279
|
const el = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, text?: string): HTMLElementTagNameMap[K] => {
|
|
281
280
|
const node = document.createElement(tag);
|
|
@@ -403,28 +402,26 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
403
402
|
};
|
|
404
403
|
|
|
405
404
|
return {
|
|
406
|
-
|
|
407
|
-
root =
|
|
405
|
+
attach(rootEl) {
|
|
406
|
+
root = rootEl;
|
|
408
407
|
const r = root;
|
|
409
408
|
const onClick = (event: Event): void => {
|
|
410
409
|
const id = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-task]')?.getAttribute('data-kit-task');
|
|
411
410
|
if (!id) return;
|
|
412
411
|
const task = tasks.find((t) => t.id === id);
|
|
413
|
-
if (task)
|
|
412
|
+
if (task) api.emit('pick', { id: task.id, item: task.raw });
|
|
414
413
|
};
|
|
415
414
|
r.addEventListener('click', onClick);
|
|
416
|
-
|
|
417
|
-
|
|
415
|
+
return () => {
|
|
416
|
+
r.removeEventListener('click', onClick);
|
|
417
|
+
root = null;
|
|
418
|
+
};
|
|
418
419
|
},
|
|
419
|
-
|
|
420
|
+
render(rootEl) {
|
|
421
|
+
root = rootEl;
|
|
420
422
|
paint();
|
|
421
423
|
},
|
|
422
|
-
onUnmount(): void {
|
|
423
|
-
if (cleanup) cleanup();
|
|
424
|
-
cleanup = undefined;
|
|
425
|
-
root = null;
|
|
426
|
-
},
|
|
427
424
|
};
|
|
428
|
-
},
|
|
425
|
+
}),
|
|
429
426
|
};
|
|
430
427
|
}
|
package/src/data/hero.ts
CHANGED
|
@@ -98,7 +98,7 @@ export function createHero(): SomaComponentDefinition {
|
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
100
|
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
101
|
-
controllerFactory: createKitController({
|
|
101
|
+
controllerFactory: createKitController(() => ({
|
|
102
102
|
attach(root, api) {
|
|
103
103
|
const onClick = (event: Event): void => {
|
|
104
104
|
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-action]');
|
|
@@ -144,6 +144,6 @@ export function createHero(): SomaComponentDefinition {
|
|
|
144
144
|
}
|
|
145
145
|
root.appendChild(wrap);
|
|
146
146
|
},
|
|
147
|
-
}),
|
|
147
|
+
})),
|
|
148
148
|
};
|
|
149
149
|
}
|
package/src/data/image-viewer.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
// 事件:`open { index, item }`、`change { index, item }`(换图)、`close {}`。
|
|
10
10
|
// `open` / `index` prop 只在它们自己变化时覆盖内部状态。
|
|
11
11
|
|
|
12
|
-
import type {
|
|
13
|
-
import { bool, joinClass, num, str } from '../base/shared';
|
|
12
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
13
|
+
import { bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
14
14
|
import { kitKey, kitText } from '../i18n/kit-text';
|
|
15
15
|
import { classTokens, emptyNode, keyMap, mk, rowsOf, textOf } from './shape-util';
|
|
16
16
|
import { attrEsc, rowKey, safeImgSrc, trapTab } from './d9-util';
|
|
@@ -24,7 +24,7 @@ const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
|
24
24
|
const THUMBS_CLASS = 'grid grid-cols-3 gap-2 @md:grid-cols-4 @xl:grid-cols-6';
|
|
25
25
|
const THUMB_CLASS = 'aspect-square overflow-hidden rounded-lg border border-border-subtle bg-surface-sunken transition-colors hover:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
26
26
|
const THUMB_IMG = 'size-full object-cover';
|
|
27
|
-
const LAYER_CLASS = 'fixed inset-0 z-50 flex flex-col bg-
|
|
27
|
+
const LAYER_CLASS = 'fixed inset-0 z-50 flex flex-col bg-scrim focus-visible:outline-none';
|
|
28
28
|
const BAR_CLASS = 'flex flex-wrap items-center gap-2 border-b border-border-subtle bg-surface-raised px-4 py-2';
|
|
29
29
|
const BAR_TITLE = 'min-w-0 flex-1 truncate font-medium text-fg';
|
|
30
30
|
const BAR_TEXT = 'text-xs text-fg-muted';
|
|
@@ -100,8 +100,8 @@ export function createImageViewer(): SomaComponentDefinition {
|
|
|
100
100
|
},
|
|
101
101
|
},
|
|
102
102
|
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
103
|
-
controllerFactory: (
|
|
104
|
-
const P = (): Record<string, unknown> =>
|
|
103
|
+
controllerFactory: createKitController((api) => {
|
|
104
|
+
const P = (): Record<string, unknown> => api.props();
|
|
105
105
|
let root: HTMLElement | null = null;
|
|
106
106
|
let isOpen = false;
|
|
107
107
|
let index = 0;
|
|
@@ -151,14 +151,14 @@ export function createImageViewer(): SomaComponentDefinition {
|
|
|
151
151
|
opener = from;
|
|
152
152
|
paint();
|
|
153
153
|
focusLayer();
|
|
154
|
-
|
|
154
|
+
api.emit('open', { index, item: list[index]!.raw });
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
const close = (): void => {
|
|
158
158
|
if (!isOpen) return;
|
|
159
159
|
isOpen = false;
|
|
160
160
|
paint();
|
|
161
|
-
|
|
161
|
+
api.emit('close', {});
|
|
162
162
|
const back = opener && root?.contains(opener) ? opener : root?.querySelector<HTMLElement>('[data-kit-thumb]') ?? null;
|
|
163
163
|
opener = null;
|
|
164
164
|
back?.focus();
|
|
@@ -173,7 +173,7 @@ export function createImageViewer(): SomaComponentDefinition {
|
|
|
173
173
|
rotate = 0;
|
|
174
174
|
paint();
|
|
175
175
|
focusLayer();
|
|
176
|
-
|
|
176
|
+
api.emit('change', { index, item: list[index]!.raw });
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
const focusLayer = (): void => {
|
|
@@ -215,7 +215,7 @@ export function createImageViewer(): SomaComponentDefinition {
|
|
|
215
215
|
if (shell && mount?.mounted) return shell;
|
|
216
216
|
releaseMount();
|
|
217
217
|
const el = mk('div', 'contents');
|
|
218
|
-
const handle = mountKitOverlay(el, { anchor:
|
|
218
|
+
const handle = mountKitOverlay(el, { anchor: api.host, onEscape: () => { if (isOpen) close(); } });
|
|
219
219
|
if (!handle) return null;
|
|
220
220
|
el.addEventListener('click', onClick);
|
|
221
221
|
el.addEventListener('keydown', onKeydown as EventListener);
|
|
@@ -302,32 +302,26 @@ export function createImageViewer(): SomaComponentDefinition {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
return {
|
|
305
|
-
|
|
306
|
-
root =
|
|
307
|
-
?? ctx.host.querySelector<HTMLElement>('[data-soma-id="root"]')
|
|
308
|
-
?? ctx.host;
|
|
305
|
+
attach(rootEl) {
|
|
306
|
+
root = rootEl;
|
|
309
307
|
const r = root;
|
|
310
|
-
sync();
|
|
311
308
|
// 根只管缩略图点击;预览层的点击与键盘在浮层壳上(见 ensureShell)
|
|
312
309
|
r.addEventListener('click', onClick);
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
return () => {
|
|
311
|
+
r.removeEventListener('click', onClick);
|
|
312
|
+
releaseMount();
|
|
313
|
+
opener = null;
|
|
314
|
+
root = null;
|
|
315
|
+
};
|
|
316
316
|
},
|
|
317
|
-
|
|
317
|
+
render(rootEl) {
|
|
318
|
+
root = rootEl;
|
|
318
319
|
const was = isOpen;
|
|
319
320
|
sync();
|
|
320
321
|
paint();
|
|
321
322
|
if (isOpen && !was) focusLayer();
|
|
322
323
|
},
|
|
323
|
-
onUnmount(): void {
|
|
324
|
-
for (const off of removeListeners) off();
|
|
325
|
-
removeListeners = [];
|
|
326
|
-
releaseMount();
|
|
327
|
-
opener = null;
|
|
328
|
-
root = null;
|
|
329
|
-
},
|
|
330
324
|
};
|
|
331
|
-
},
|
|
325
|
+
}),
|
|
332
326
|
};
|
|
333
327
|
}
|
package/src/data/index.ts
CHANGED
|
@@ -47,8 +47,6 @@ export { mountKitModal, KIT_MODAL_CLASS_CANDIDATES } from './modal-dialog';
|
|
|
47
47
|
export type { KitModalHandle, KitModalOptions, KitModalSize } from './modal-dialog';
|
|
48
48
|
export { askKitConfirm, KIT_CONFIRM_CLASS_CANDIDATES } from './confirm-dialog';
|
|
49
49
|
export type { KitConfirmOptions } from './confirm-dialog';
|
|
50
|
-
export { askKitPrompt, KIT_PROMPT_CLASS_CANDIDATES } from './prompt-dialog';
|
|
51
|
-
export type { KitPromptOptions } from './prompt-dialog';
|
|
52
50
|
export { mountKitComponent, mountKitSelectField, createKitEmbedBag } from './embed';
|
|
53
51
|
export type { KitEmitHandlers, KitMount, KitSelectField, KitSelectFieldOptions, KitEmbedBag, KitEmbedHandle } from './embed';
|
|
54
52
|
export { declareKitUses } from './wrapped-candidates';
|
package/src/data/item-list.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { kitText } from '../i18n/kit-text';
|
|
|
14
14
|
import {
|
|
15
15
|
actionButton, actionsOf, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_SOFT,
|
|
16
16
|
} from './shape-util';
|
|
17
|
+
import { KIT_ROW_TONE_CLASS } from '../object-renderer/view-binding';
|
|
17
18
|
import { AVATAR_CLASS_TOKENS, avatarNode } from './d9-util';
|
|
18
19
|
import { provideCtxRows } from './context-menu';
|
|
19
20
|
|
|
@@ -45,9 +46,11 @@ const TAGS_CLASS = 'flex flex-wrap items-center gap-2';
|
|
|
45
46
|
const ACTIONS_CLASS = 'flex shrink-0 items-center gap-1 py-2 pe-2';
|
|
46
47
|
const STATE_ERR_CLASS = 'flex items-center justify-between gap-2 rounded-md bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
47
48
|
const STATE_BUSY_CLASS = 'rounded-md bg-surface-sunken px-3 py-4 text-center text-sm text-fg-subtle';
|
|
49
|
+
/** 已有条目时重新读取:保留条目,外壳降不透明度(与表格同口径) */
|
|
50
|
+
const BUSY_LIST_CLASS = `${KIT_ROW_TONE_CLASS.muted} transition-opacity`;
|
|
48
51
|
|
|
49
52
|
export const KIT_ITEM_LIST_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
50
|
-
STATE_ERR_CLASS, STATE_BUSY_CLASS,
|
|
53
|
+
STATE_ERR_CLASS, STATE_BUSY_CLASS, BUSY_LIST_CLASS,
|
|
51
54
|
ROOT_CLASS, Object.values(ROOT_SCROLL), ITEM_CLASS, ITEM_ON_CLASS, MAIN_CLASS, MAIN_DISABLED, TITLE_CLASS, SUB_CLASS, TEXT_CLASS,
|
|
52
55
|
TAGS_CLASS, ACTIONS_CLASS, BADGE_BASE, Object.values(TONE_SOFT), BUTTON_CLASS_TOKENS,
|
|
53
56
|
PREFIX_CLASS, SUFFIX_CLASS, HEAD_ROW_CLASS, BODY_COL_CLASS, AVATAR_CLASS_TOKENS, GROUP_HEAD_CLASS,
|
|
@@ -140,9 +143,9 @@ export function createItemList(): SomaComponentDefinition {
|
|
|
140
143
|
selectable: { type: 'boolean', default: true, desc: '条目可点选;假则只展示' },
|
|
141
144
|
max_height: { type: 'enum', values: ['none', 'sm', 'md', 'lg'], default: 'none', desc: '列表最大高度档,超出滚动' },
|
|
142
145
|
empty_text: { type: 'string', default: '', desc: '没有条目时的文案' },
|
|
143
|
-
loading: { type: 'boolean', default: false, desc: '
|
|
146
|
+
loading: { type: 'boolean', default: false, desc: '加载中(优先级:错误 > 加载 > 空;有错误时不算重取;没有条目时显示加载提示,已有条目时保留条目并标 aria-busy、外壳降不透明度)' },
|
|
144
147
|
loading_text: { type: 'string', default: '', desc: '加载中文案' },
|
|
145
|
-
error: { type: 'string', default: '', desc: '
|
|
148
|
+
error: { type: 'string', default: '', desc: '错误文案,非空即错误态:没有条目时只显示错误框,已有条目时错误框画在条目之前、条目保留;retry_text 非空时带重试钮' },
|
|
146
149
|
retry_text: { type: 'string', default: '', desc: '错误态重试钮文字,空则不显示' },
|
|
147
150
|
aria_label: { type: 'string', default: '', desc: '列表的无障碍名称' },
|
|
148
151
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
@@ -155,7 +158,7 @@ export function createItemList(): SomaComponentDefinition {
|
|
|
155
158
|
},
|
|
156
159
|
},
|
|
157
160
|
templateHtml: `<ul data-soma-id="root" class="${ROOT_CLASS}"></ul>`,
|
|
158
|
-
controllerFactory: createKitController({
|
|
161
|
+
controllerFactory: createKitController(() => ({
|
|
159
162
|
attach(root, api) {
|
|
160
163
|
const itemOf = (id: string): KitListItem | undefined => {
|
|
161
164
|
const p = api.props();
|
|
@@ -227,30 +230,36 @@ export function createItemList(): SomaComponentDefinition {
|
|
|
227
230
|
}
|
|
228
231
|
const selectable = bool(p.selectable);
|
|
229
232
|
const scroll = ROOT_SCROLL[str(p.max_height, 'none')] ?? '';
|
|
230
|
-
|
|
233
|
+
const reloading = bool(p.loading) && items.length > 0 && str(p.error) === '';
|
|
234
|
+
// joinClass 只收「基础类 + 页面类」两段:降不透明度类并进基础类,页面类(view.class)始终保留
|
|
235
|
+
const rootBase = scroll === '' ? ROOT_CLASS : `${ROOT_CLASS} ${scroll}`;
|
|
236
|
+
root.className = joinClass(reloading ? `${rootBase} ${BUSY_LIST_CLASS}` : rootBase, p.class);
|
|
237
|
+
if (reloading) root.setAttribute('aria-busy', 'true'); else root.removeAttribute('aria-busy');
|
|
231
238
|
if (str(p.aria_label) !== '') root.setAttribute('aria-label', str(p.aria_label)); else root.removeAttribute('aria-label');
|
|
232
239
|
const hadFocus = root.contains(document.activeElement);
|
|
233
240
|
const focusedId = hadFocus ? (document.activeElement as HTMLElement).closest('[data-kit-item]')?.getAttribute('data-kit-item') ?? null : null;
|
|
234
241
|
root.textContent = '';
|
|
235
242
|
const errorText = str(p.error);
|
|
236
|
-
if (errorText !== ''
|
|
243
|
+
if (errorText !== '') {
|
|
244
|
+
// 错误框画在条目之前;重取失败而旧条目还在时条目照常画(与表格同口径:保留行、另给失败提示),没有条目时只有错误框
|
|
237
245
|
const li = mk('li', '');
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
box.appendChild(btn);
|
|
246
|
-
}
|
|
247
|
-
li.appendChild(box);
|
|
248
|
-
} else {
|
|
249
|
-
const box = mk('div', STATE_BUSY_CLASS, str(p.loading_text, kitText('soma.kit.processing', undefined, root)));
|
|
250
|
-
box.setAttribute('role', 'status');
|
|
251
|
-
box.setAttribute('data-kit-loading', '');
|
|
252
|
-
li.appendChild(box);
|
|
246
|
+
const box = mk('div', STATE_ERR_CLASS);
|
|
247
|
+
box.setAttribute('role', 'alert');
|
|
248
|
+
box.appendChild(mk('span', '', errorText));
|
|
249
|
+
if (str(p.retry_text) !== '') {
|
|
250
|
+
const btn = actionButton({ key: 'retry', label: str(p.retry_text), tone: 'neutral', disabled: false, reason: '' });
|
|
251
|
+
btn.setAttribute('data-kit-retry', '');
|
|
252
|
+
box.appendChild(btn);
|
|
253
253
|
}
|
|
254
|
+
li.appendChild(box);
|
|
255
|
+
root.appendChild(li);
|
|
256
|
+
if (items.length === 0) return;
|
|
257
|
+
} else if (bool(p.loading) && items.length === 0) {
|
|
258
|
+
const li = mk('li', '');
|
|
259
|
+
const box = mk('div', STATE_BUSY_CLASS, str(p.loading_text, kitText('soma.kit.processing', undefined, root)));
|
|
260
|
+
box.setAttribute('role', 'status');
|
|
261
|
+
box.setAttribute('data-kit-loading', '');
|
|
262
|
+
li.appendChild(box);
|
|
254
263
|
root.appendChild(li);
|
|
255
264
|
return;
|
|
256
265
|
}
|
|
@@ -314,7 +323,7 @@ export function createItemList(): SomaComponentDefinition {
|
|
|
314
323
|
root.querySelector<HTMLElement>(`[data-kit-item="${cssEscape(focusedId)}"] [data-kit-main]`)?.focus();
|
|
315
324
|
}
|
|
316
325
|
},
|
|
317
|
-
}),
|
|
326
|
+
})),
|
|
318
327
|
};
|
|
319
328
|
|
|
320
329
|
/** 只改选中态,不重画(点击后立即反馈,焦点不丢) */
|
package/src/data/kanban.ts
CHANGED
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
// 与 `change { value }`(value 为移动后的全部行,供 view.value 写回)。
|
|
25
25
|
// 点卡片抛 `select { id, item }`。data 内容变化(内容签名变)才重置本地顺序。
|
|
26
26
|
|
|
27
|
-
import type {
|
|
28
|
-
import { bool,
|
|
27
|
+
import type { SomaComponentDefinition, SomaDataPort } from 'soma-core';
|
|
28
|
+
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
29
29
|
import { kitText } from '../i18n/kit-text';
|
|
30
|
+
import { setKitFace } from '../recipes';
|
|
30
31
|
import { provideCtxRows } from './context-menu';
|
|
31
32
|
|
|
32
33
|
// ───────── 样式常量:Tailwind 类串与候选类清单 ─────────
|
|
@@ -192,8 +193,8 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
192
193
|
},
|
|
193
194
|
services: ['engines', 'data', 'notify'],
|
|
194
195
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
195
|
-
controllerFactory: (
|
|
196
|
-
const P = (): Record<string, unknown> =>
|
|
196
|
+
controllerFactory: createKitController((api) => {
|
|
197
|
+
const P = (): Record<string, unknown> => api.props();
|
|
197
198
|
const uid = `kit-kanban-${++instanceCount}`;
|
|
198
199
|
let root: HTMLElement | null = null;
|
|
199
200
|
let noticeEl: HTMLElement | null = null;
|
|
@@ -217,11 +218,11 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
217
218
|
let armTimer: ReturnType<typeof setTimeout> | null = null;
|
|
218
219
|
let offOutcome: (() => void) | null = null;
|
|
219
220
|
const dataPort = (): SomaDataPort | undefined => {
|
|
220
|
-
const port = (
|
|
221
|
+
const port = (api.services as { data?: SomaDataPort } | undefined)?.data;
|
|
221
222
|
return port && typeof port === 'object' ? port : undefined;
|
|
222
223
|
};
|
|
223
224
|
const notifyPort = (): { toast?: (o: { level: string; message: string }) => void } | undefined =>
|
|
224
|
-
(
|
|
225
|
+
(api.services as { notify?: { toast?: (o: { level: string; message: string }) => void } } | undefined)?.notify;
|
|
225
226
|
|
|
226
227
|
const config = (): KitKanbanConfig => {
|
|
227
228
|
const p = P();
|
|
@@ -232,7 +233,7 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
232
233
|
const softWip = (): boolean => str(P().wip_mode) === 'soft';
|
|
233
234
|
const idOf = (r: Row): string => str(r[idField()]);
|
|
234
235
|
const dndPort = (): DragPortLike | null => {
|
|
235
|
-
const engines = (
|
|
236
|
+
const engines = (api.services as { engines?: { dnd?: DragPortLike } } | undefined)?.engines;
|
|
236
237
|
return engines?.dnd ?? null;
|
|
237
238
|
};
|
|
238
239
|
|
|
@@ -263,12 +264,12 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
263
264
|
const restore = first !== undefined && snapEpoch === epoch;
|
|
264
265
|
clearTrack();
|
|
265
266
|
const reason = message !== '' ? message
|
|
266
|
-
: kitText(conflict ? 'soma.kit.order_unsaved_conflict' : 'soma.kit.order_unsaved_unknown', undefined,
|
|
267
|
-
const text = kitText('soma.kit.order_unsaved', { reason },
|
|
267
|
+
: kitText(conflict ? 'soma.kit.order_unsaved_conflict' : 'soma.kit.order_unsaved_unknown', undefined, api.host);
|
|
268
|
+
const text = kitText('soma.kit.order_unsaved', { reason }, api.host);
|
|
268
269
|
if (restore && first !== undefined) {
|
|
269
270
|
rows = first.map((r) => ({ ...r }));
|
|
270
271
|
menuFor = null;
|
|
271
|
-
|
|
272
|
+
api.emit('change', { value: rows.map((r) => ({ ...r })) });
|
|
272
273
|
}
|
|
273
274
|
showNotice(text);
|
|
274
275
|
announce(text);
|
|
@@ -339,17 +340,17 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
339
340
|
if (from !== to && limit !== undefined && laneRows(cfg, to).length >= limit) {
|
|
340
341
|
const laneLabel = cfg.lanes.find((l) => l.value === to)?.label ?? to;
|
|
341
342
|
if (!softWip()) {
|
|
342
|
-
const msg = kitText('soma.kit.wip_limit', { lane: laneLabel, n: limit },
|
|
343
|
+
const msg = kitText('soma.kit.wip_limit', { lane: laneLabel, n: limit }, api.host);
|
|
343
344
|
announce(msg);
|
|
344
345
|
showNotice(msg);
|
|
345
|
-
|
|
346
|
+
api.emit('wip_blocked', { id, to, limit });
|
|
346
347
|
return false;
|
|
347
348
|
}
|
|
348
349
|
// 软上限:只提示与抛事件,移入照常进行(超限的计数由 paint 标红)
|
|
349
|
-
const msg = kitText('soma.kit.wip_exceeded', { lane: laneLabel, n: limit },
|
|
350
|
+
const msg = kitText('soma.kit.wip_exceeded', { lane: laneLabel, n: limit }, api.host);
|
|
350
351
|
announce(msg);
|
|
351
352
|
showNotice(msg);
|
|
352
|
-
|
|
353
|
+
api.emit('wip_exceeded', { id, to, limit });
|
|
353
354
|
}
|
|
354
355
|
const peers = laneRows(cfg, to).filter((r) => idOf(r) !== id);
|
|
355
356
|
const position = Math.max(0, Math.min(index, peers.length));
|
|
@@ -367,7 +368,7 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
367
368
|
menuFor = null;
|
|
368
369
|
tabKey = id;
|
|
369
370
|
pendingFocus = id;
|
|
370
|
-
|
|
371
|
+
api.emit('move', {
|
|
371
372
|
id, from, to, index: position,
|
|
372
373
|
target: id,
|
|
373
374
|
...(orderField !== '' ? { orderField } : {}),
|
|
@@ -375,9 +376,9 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
375
376
|
set: { [cfg.group]: to },
|
|
376
377
|
object: str(P().object),
|
|
377
378
|
});
|
|
378
|
-
|
|
379
|
+
api.emit('change', { value: rows.map((r) => ({ ...r })) });
|
|
379
380
|
showNotice('');
|
|
380
|
-
announce(kitText('soma.kit.moved_to', { lane: cfg.lanes.find((l) => l.value === to)?.label ?? to, n: position + 1 },
|
|
381
|
+
announce(kitText('soma.kit.moved_to', { lane: cfg.lanes.find((l) => l.value === to)?.label ?? to, n: position + 1 }, api.host));
|
|
381
382
|
paint();
|
|
382
383
|
return true;
|
|
383
384
|
};
|
|
@@ -411,8 +412,9 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
411
412
|
card.appendChild(line);
|
|
412
413
|
}
|
|
413
414
|
if (!hasDnd && !locked()) {
|
|
414
|
-
const btn = el('button', MOVE_BTN_CLASS, str(P().move_label) || kitText('soma.kit.move_to', undefined,
|
|
415
|
+
const btn = el('button', MOVE_BTN_CLASS, str(P().move_label) || kitText('soma.kit.move_to', undefined, api.host));
|
|
415
416
|
btn.type = 'button';
|
|
417
|
+
setKitFace(btn, 'raised');
|
|
416
418
|
btn.setAttribute('data-kit-move', id);
|
|
417
419
|
btn.setAttribute('aria-haspopup', 'menu');
|
|
418
420
|
btn.setAttribute('aria-expanded', menuFor === id ? 'true' : 'false');
|
|
@@ -451,7 +453,7 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
451
453
|
const cfg = config();
|
|
452
454
|
const port = dndPort();
|
|
453
455
|
const hasDnd = port !== null;
|
|
454
|
-
const emptyText = str(p.empty_text, kitText('soma.kit.empty_card', undefined,
|
|
456
|
+
const emptyText = str(p.empty_text, kitText('soma.kit.empty_card', undefined, api.host));
|
|
455
457
|
const keys = cardKeys(cfg);
|
|
456
458
|
const all = keys.flat();
|
|
457
459
|
if (tabKey === null || !all.includes(tabKey)) tabKey = all[0] ?? null;
|
|
@@ -553,7 +555,7 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
553
555
|
const key = e.key;
|
|
554
556
|
if (key === 'Enter' || key === ' ') {
|
|
555
557
|
e.preventDefault();
|
|
556
|
-
|
|
558
|
+
api.emit('select', { id, item: rows.find((r) => idOf(r) === id) ?? {} });
|
|
557
559
|
return;
|
|
558
560
|
}
|
|
559
561
|
if ((key === 'm' || key === 'M') && !e.altKey && !e.ctrlKey && !e.metaKey && !dndPort() && !locked()) {
|
|
@@ -610,13 +612,13 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
610
612
|
if (cardEl) {
|
|
611
613
|
const id = cardEl.getAttribute('data-kit-key')!;
|
|
612
614
|
tabKey = id;
|
|
613
|
-
|
|
615
|
+
api.emit('select', { id, item: rows.find((r) => idOf(r) === id) ?? {} });
|
|
614
616
|
}
|
|
615
617
|
};
|
|
616
618
|
|
|
617
619
|
return {
|
|
618
|
-
|
|
619
|
-
root =
|
|
620
|
+
attach(rootEl) {
|
|
621
|
+
root = rootEl;
|
|
620
622
|
root.textContent = '';
|
|
621
623
|
noticeEl = el('div', HIDDEN_CLASS);
|
|
622
624
|
noticeEl.setAttribute('role', 'alert');
|
|
@@ -639,29 +641,28 @@ export function createKanban(): SomaComponentDefinition {
|
|
|
639
641
|
if (port) offMove = port.onMove(intentMove);
|
|
640
642
|
// 右键菜单(页面声明了 contextMenu 才有宿主壳):按卡主键取行
|
|
641
643
|
removers.push(provideCtxRows(root, (key) => rows.find((r) => idOf(r) === key)));
|
|
642
|
-
|
|
643
|
-
|
|
644
|
+
return () => {
|
|
645
|
+
for (const fn of cleanups) fn();
|
|
646
|
+
cleanups = [];
|
|
647
|
+
for (const fn of removers) fn();
|
|
648
|
+
removers = [];
|
|
649
|
+
offMove?.();
|
|
650
|
+
offMove = null;
|
|
651
|
+
offOutcome?.();
|
|
652
|
+
offOutcome = null;
|
|
653
|
+
clearTrack();
|
|
654
|
+
root = null;
|
|
655
|
+
noticeEl = null;
|
|
656
|
+
board = null;
|
|
657
|
+
live = null;
|
|
658
|
+
};
|
|
644
659
|
},
|
|
645
|
-
|
|
660
|
+
render(rootEl) {
|
|
661
|
+
root = rootEl;
|
|
646
662
|
sync();
|
|
647
663
|
paint();
|
|
648
664
|
},
|
|
649
|
-
onUnmount(): void {
|
|
650
|
-
for (const fn of cleanups) fn();
|
|
651
|
-
cleanups = [];
|
|
652
|
-
for (const fn of removers) fn();
|
|
653
|
-
removers = [];
|
|
654
|
-
offMove?.();
|
|
655
|
-
offMove = null;
|
|
656
|
-
offOutcome?.();
|
|
657
|
-
offOutcome = null;
|
|
658
|
-
clearTrack();
|
|
659
|
-
root = null;
|
|
660
|
-
noticeEl = null;
|
|
661
|
-
board = null;
|
|
662
|
-
live = null;
|
|
663
|
-
},
|
|
664
665
|
};
|
|
665
|
-
},
|
|
666
|
+
}),
|
|
666
667
|
};
|
|
667
668
|
}
|