soma-kit 0.1.11 → 0.1.13
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 +106 -112
- package/bin/soma-kit.mjs +32 -2
- package/bin/soma.mjs +22 -0
- package/package.json +14 -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 +929 -37
- package/spec/generated/kit-page.schema.json +1684 -161
- package/spec/kit-grammar.json +1176 -584
- package/spec/kit-grammar.schema.json +1971 -393
- package/src/app/app-config.ts +449 -347
- package/src/app/component-gate.ts +283 -28
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +176 -33
- package/src/app/define-kit-view.ts +104 -0
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +29 -6
- package/src/app/kit-view-context.ts +439 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +11 -3
- package/src/app/server.ts +530 -103
- 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 +667 -0
- package/src/base/action-busy.ts +103 -6
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +58 -0
- package/src/base/alert.ts +5 -3
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +99 -37
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +9 -1
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +49 -28
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +16 -11
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +10 -6
- package/src/base/context-menu.ts +10 -7
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +32 -18
- package/src/base/date.ts +135 -28
- package/src/base/delta.ts +72 -0
- package/src/base/divider.ts +2 -2
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +12 -5
- package/src/base/gap-value.ts +148 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +94 -0
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +35 -11
- 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 +56 -35
- package/src/base/loading-gate.ts +186 -0
- package/src/base/mentions.ts +7 -6
- package/src/base/menu-button.ts +28 -12
- package/src/base/menu-core.ts +41 -8
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +3 -3
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +3 -3
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +9 -5
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +48 -16
- package/src/base/popup.ts +143 -19
- package/src/base/portal-core.ts +4 -0
- 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 +14 -8
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +21 -4
- package/src/base/rating.ts +12 -7
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +27 -21
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +387 -49
- package/src/base/state-panel.ts +346 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +10 -7
- package/src/base/switch.ts +11 -6
- package/src/base/tag-input.ts +20 -16
- package/src/base/tag.ts +68 -34
- package/src/base/text.ts +80 -18
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +18 -13
- package/src/base/tree-select.ts +21 -12
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +48 -14
- package/src/base/view-transition.ts +77 -0
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +23 -37
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +22 -5
- package/src/biz/checkout-page/shell.ts +4 -3
- 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 +5 -4
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +69 -22
- package/src/biz/link/shared.ts +127 -119
- package/src/biz/master-sub/compile.ts +127 -48
- package/src/biz/master-sub/index.ts +5 -2
- package/src/biz/master-sub/shell.ts +95 -18
- package/src/biz/multi-board/compile.ts +38 -50
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +32 -20
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/notification-center/shell.ts +6 -4
- 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/result-page/shell.ts +2 -1
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +48 -43
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +7 -5
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +97 -211
- package/src/biz/shared/compile-helpers.ts +98 -0
- package/src/biz/shared/coordinator.ts +472 -92
- package/src/biz/shared/index.ts +13 -2
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +239 -0
- package/src/biz/shared/overlay-shell.ts +209 -0
- package/src/biz/shared/pipes.ts +50 -31
- package/src/biz/shared/remove-wire.ts +14 -0
- package/src/biz/shared/runtime-hub.ts +226 -24
- package/src/biz/single-form/compile.ts +16 -37
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +72 -255
- package/src/biz/standard-crud/shell.ts +21 -99
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/step-form/shell.ts +5 -5
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +254 -25
- package/src/cli/kit-init.ts +227 -0
- package/src/cli/layout-cli.ts +167 -0
- package/src/cli/migrate/index.ts +10 -0
- package/src/cli/migrate/migrate.ts +248 -0
- package/src/cli/migrate/text-utils.ts +306 -0
- package/src/cli/migrate/theme-map.ts +104 -0
- package/src/cli/migrate/ts-rules.ts +235 -0
- package/src/cli/migrate/types.ts +95 -0
- package/src/cli/migrate/view-skeleton.ts +159 -0
- package/src/cli/migrate/yaml-report.ts +376 -0
- package/src/cli/migrate/yaml-rules.ts +465 -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 +761 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +570 -0
- package/src/compile/compile-page.ts +267 -76
- package/src/compile/component-candidates.ts +13 -2
- 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/layout-lint/engine.ts +82 -0
- package/src/compile/layout-lint/index.ts +55 -0
- package/src/compile/layout-lint/rules-composition.ts +218 -0
- package/src/compile/layout-lint/rules-form.ts +192 -0
- package/src/compile/layout-lint/rules-table.ts +194 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -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/remove-guard.ts +10 -7
- package/src/compile/styles.ts +63 -2
- package/src/compile/types.ts +31 -3
- package/src/compile/view-check.ts +284 -0
- package/src/data/amount-breakdown.ts +8 -3
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +3 -3
- package/src/data/assignment-picker.ts +92 -55
- package/src/data/async-result-panel.ts +111 -9
- package/src/data/breadcrumbs.ts +5 -4
- package/src/data/calendar.ts +24 -27
- package/src/data/carousel.ts +13 -8
- package/src/data/chart.ts +183 -44
- package/src/data/checklist.ts +20 -7
- package/src/data/code-view.ts +12 -6
- package/src/data/comment-thread.ts +7 -4
- package/src/data/confirm-dialog.ts +81 -18
- 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 +3 -3
- package/src/data/embed.ts +233 -30
- package/src/data/field-mapper.ts +35 -30
- package/src/data/flow-editor-contract.ts +8 -1
- package/src/data/flow-editor.ts +113 -108
- package/src/data/flow-node-options.ts +120 -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 +19 -19
- package/src/data/hero.ts +4 -3
- package/src/data/image-viewer.ts +27 -30
- package/src/data/index.ts +5 -2
- package/src/data/item-list.ts +48 -31
- package/src/data/kanban.ts +82 -52
- package/src/data/media-grid.ts +20 -20
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +47 -15
- package/src/data/mockup.ts +10 -6
- package/src/data/modal-dialog.ts +49 -25
- package/src/data/navbar.ts +12 -7
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +250 -0
- package/src/data/object-form.ts +1360 -666
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +80 -34
- package/src/data/permission-matrix.ts +52 -31
- package/src/data/permission-tree.ts +71 -44
- package/src/data/pricing-table.ts +30 -14
- package/src/data/prompt-dialog.ts +124 -194
- package/src/data/reaction-bar.ts +83 -92
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +26 -5
- package/src/data/record-picker.ts +104 -55
- 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 +8 -4
- package/src/data/rich-text.ts +61 -55
- package/src/data/row-editor.ts +362 -76
- package/src/data/rule-builder.ts +26 -20
- package/src/data/shape-util.ts +27 -9
- package/src/data/stat-group.ts +392 -109
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +24 -11
- package/src/data/steps.ts +10 -5
- package/src/data/survey.ts +27 -32
- package/src/data/system-switcher.ts +3 -3
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +19 -8
- package/src/data/tour-guide.ts +23 -30
- package/src/data/transfer.ts +62 -38
- package/src/data/tree-table.ts +152 -78
- package/src/data/tree.ts +49 -36
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +133 -82
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +26 -24
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +9 -7
- package/src/frames/shared.ts +36 -25
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +6 -6
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +4 -14
- package/src/frames/tabs-frame/wiring.ts +5 -8
- package/src/frames/top-main-frame.ts +3 -2
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +21 -5
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +250 -48
- package/src/generated/kit-grammar-runtime.ts +645 -397
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +84 -29
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +112 -84
- 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 +401 -104
- package/src/object-renderer/collection-table.ts +287 -45
- package/src/object-renderer/collection.ts +258 -104
- package/src/object-renderer/compile-data.ts +112 -102
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +38 -16
- package/src/object-renderer/display-checks.ts +4 -25
- package/src/object-renderer/emit-events.ts +224 -176
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +533 -151
- 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 +111 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/layout-facts.ts +386 -0
- package/src/object-renderer/layout-plan.ts +132 -0
- package/src/object-renderer/layout-plan.types.ts +22 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +456 -89
- package/src/object-renderer/request-actions.ts +232 -249
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +319 -111
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +429 -94
- package/src/object-renderer/types.ts +204 -127
- package/src/object-renderer/view-binding.ts +393 -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 +165 -28
- package/src/page-target/target.ts +262 -51
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +210 -0
- package/src/recipes/control.ts +277 -0
- package/src/recipes/index.ts +312 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +240 -0
- package/src/recipes/placeholder.ts +79 -0
- package/src/recipes/rail-grid.ts +45 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/state.ts +99 -0
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +88 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +99 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/confirm-decl.ts +118 -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 +15 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +180 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +13 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +407 -10
- package/src/theme/kit-theme.tpl +407 -10
- package/src/theme/nine-dim-structure.ts +247 -0
- package/src/theme/surface-layers.ts +101 -0
- package/src/theme/theme-tokens.ts +130 -84
- package/src/theme/theme-types.ts +103 -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/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 -1473
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
import type { SomaComponentDefinition, SomaDataPort } from 'soma-core';
|
|
14
14
|
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
15
15
|
import { kitText } from '../i18n/kit-text';
|
|
16
|
-
import {
|
|
16
|
+
import { setKitFace } from '../recipes';
|
|
17
|
+
import { pickPath } from '../object-renderer/path-pick';
|
|
17
18
|
import { watchKitOutcome, type KitOutcome } from './outcome-watch';
|
|
18
19
|
import { bool, createKitController, FIELD_CLASS, joinClass, str } from '../base/shared';
|
|
19
20
|
import {
|
|
@@ -164,7 +165,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
164
165
|
},
|
|
165
166
|
services: ['data'],
|
|
166
167
|
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
167
|
-
controllerFactory: createKitController({
|
|
168
|
+
controllerFactory: createKitController(() => ({
|
|
168
169
|
busyAware: true,
|
|
169
170
|
attach(root, api) {
|
|
170
171
|
const snapshot = (): { method: string; target: string; params: string } => {
|
|
@@ -238,7 +239,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
238
239
|
}
|
|
239
240
|
paint(root, p);
|
|
240
241
|
},
|
|
241
|
-
}),
|
|
242
|
+
})),
|
|
242
243
|
};
|
|
243
244
|
|
|
244
245
|
function paint(root: HTMLElement, p: Record<string, unknown>): void {
|
|
@@ -337,6 +338,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
337
338
|
const wrap = mk('label', FIELD_WRAP);
|
|
338
339
|
wrap.appendChild(mk('span', LABEL_CLASS, str(p.params_label, kitText('soma.kit.rc_params', undefined, root))));
|
|
339
340
|
const area = mk('textarea', AREA_CLASS);
|
|
341
|
+
setKitFace(area, 'field');
|
|
340
342
|
area.setAttribute('data-kit-params', '');
|
|
341
343
|
wrap.appendChild(area);
|
|
342
344
|
n.paramsWrap.appendChild(wrap);
|
package/src/data/resident.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// 浏览器面只 import 本文件(不 import ./index,那里静态连着全部写死形状件),写死形状件走 static-lazy 按需加载。
|
|
3
3
|
|
|
4
4
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
5
|
+
import { createKitController } from '../base/shared';
|
|
5
6
|
import { createKitObjectForm } from './object-form';
|
|
6
7
|
import { createRowEditor } from './row-editor';
|
|
7
8
|
import { FLOW_EDITOR_CONTRACT } from './flow-editor-contract';
|
|
@@ -34,7 +35,7 @@ export function createKitResidentDataComponents(
|
|
|
34
35
|
const flowEditorShell: SomaComponentDefinition = {
|
|
35
36
|
contract: FLOW_EDITOR_CONTRACT,
|
|
36
37
|
templateHtml: '<div data-soma-id="root"></div>',
|
|
37
|
-
controllerFactory: () => ({}),
|
|
38
|
+
controllerFactory: createKitController(() => ({ render() {} })),
|
|
38
39
|
} as unknown as SomaComponentDefinition;
|
|
39
40
|
return {
|
|
40
41
|
RowEditor: rowEditor,
|
package/src/data/result-panel.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
12
12
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
13
13
|
import { kitIcon, type KitIconName } from '../base/icons';
|
|
14
|
+
import { KIT_PART_ATTRIBUTE, KIT_PART_PANEL } from '../recipes';
|
|
14
15
|
import { singleOf } from './display-util';
|
|
15
16
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
16
17
|
import {
|
|
@@ -27,11 +28,13 @@ const ROOT_COMPACT_CLASS = '@container flex flex-col items-center gap-2 px-4 py-
|
|
|
27
28
|
const ICON_CLASS = 'flex h-16 w-16 items-center justify-center rounded-full text-2xl font-semibold';
|
|
28
29
|
const ICON_CODE_CLASS = 'flex h-16 min-w-24 items-center justify-center rounded-lg px-4 text-2xl font-semibold';
|
|
29
30
|
const TITLE_CLASS = 'text-xl font-semibold text-fg';
|
|
31
|
+
/** 整页 / 整卡结果(非 compact)的主标题:门户展示档(真源 structure.displayTier);compact 嵌在卡片里的结果仍用 TITLE_CLASS */
|
|
32
|
+
const TITLE_DISPLAY_CLASS = 'text-display text-fg';
|
|
30
33
|
const SUBTITLE_CLASS = 'max-w-md text-sm text-fg-muted';
|
|
31
34
|
const ACTIONS_CLASS = 'flex flex-wrap items-center justify-center gap-3 pt-4';
|
|
32
35
|
|
|
33
36
|
export const KIT_RESULT_PANEL_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
34
|
-
ROOT_CLASS, ROOT_COMPACT_CLASS, ICON_CLASS, ICON_CODE_CLASS, TITLE_CLASS, SUBTITLE_CLASS, ACTIONS_CLASS,
|
|
37
|
+
ROOT_CLASS, ROOT_COMPACT_CLASS, ICON_CLASS, ICON_CODE_CLASS, TITLE_CLASS, TITLE_DISPLAY_CLASS, SUBTITLE_CLASS, ACTIONS_CLASS,
|
|
35
38
|
Object.values(TONE_SOFT), BUTTON_CLASS_TOKENS,
|
|
36
39
|
);
|
|
37
40
|
|
|
@@ -120,7 +123,7 @@ export function createResultPanel(): SomaComponentDefinition {
|
|
|
120
123
|
},
|
|
121
124
|
},
|
|
122
125
|
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
123
|
-
controllerFactory: createKitController({
|
|
126
|
+
controllerFactory: createKitController(() => ({
|
|
124
127
|
attach(root, api) {
|
|
125
128
|
const onClick = (event: Event): void => {
|
|
126
129
|
const hit = (event.target as HTMLElement | null)?.closest<HTMLElement>('[data-kit-action]');
|
|
@@ -135,6 +138,7 @@ export function createResultPanel(): SomaComponentDefinition {
|
|
|
135
138
|
render(root, p) {
|
|
136
139
|
const compact = bool(p.compact);
|
|
137
140
|
root.className = joinClass(compact ? ROOT_COMPACT_CLASS : ROOT_CLASS, p.class);
|
|
141
|
+
root.setAttribute(KIT_PART_ATTRIBUTE, KIT_PART_PANEL);
|
|
138
142
|
root.textContent = '';
|
|
139
143
|
const model = resultModelOf(p.data, p, root);
|
|
140
144
|
const isCode = model.glyph.length === 3;
|
|
@@ -143,7 +147,7 @@ export function createResultPanel(): SomaComponentDefinition {
|
|
|
143
147
|
icon.setAttribute('aria-hidden', 'true');
|
|
144
148
|
icon.setAttribute('data-kit-result-status', model.status);
|
|
145
149
|
root.appendChild(icon);
|
|
146
|
-
root.appendChild(mk('h2', TITLE_CLASS, model.title));
|
|
150
|
+
root.appendChild(mk('h2', compact ? TITLE_CLASS : TITLE_DISPLAY_CLASS, model.title));
|
|
147
151
|
if (model.subtitle !== '') root.appendChild(mk('p', SUBTITLE_CLASS, model.subtitle));
|
|
148
152
|
if (model.actions.length > 0) {
|
|
149
153
|
const bar = mk('div', ACTIONS_CLASS);
|
|
@@ -155,6 +159,6 @@ export function createResultPanel(): SomaComponentDefinition {
|
|
|
155
159
|
root.appendChild(bar);
|
|
156
160
|
}
|
|
157
161
|
},
|
|
158
|
-
}),
|
|
162
|
+
})),
|
|
159
163
|
};
|
|
160
164
|
}
|
package/src/data/rich-text.ts
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
// `readonly` 为真时只展示净化后的内容,不出工具栏。
|
|
10
10
|
// `source: markdown`(A17):内容是 Markdown 文本,转成 HTML 后经同一净化器渲染,固定只读;见「Markdown(只读来源)」段。
|
|
11
11
|
|
|
12
|
-
import type {
|
|
13
|
-
import { bool, joinClass, num, str } from '../base/shared';
|
|
12
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
13
|
+
import { ID_PROPS, INVALID_PROPS, applyCommon, bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
14
14
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
15
|
+
import { setKitFace } from '../recipes';
|
|
15
16
|
import { classTokens, mk, recOf } from './shape-util';
|
|
16
17
|
import { RICH_ALLOWED_TAGS, RICH_COMMANDS, RICH_LINK_PROTOCOLS, RICH_MAX_LENGTH } from './d9-limits';
|
|
17
18
|
|
|
@@ -288,6 +289,8 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
288
289
|
source: { type: 'enum', values: ['html', 'markdown'], default: 'html', desc: '内容来源:markdown 时 value / data.markdown 是 Markdown 文本,转成 HTML 后经同一净化器渲染,组件固定只读(不出工具栏)' },
|
|
289
290
|
max_length: { type: 'number', default: 0, desc: '文字长度上限提示;非正数不显示计数。超出只变警示色,不截断' },
|
|
290
291
|
label: { type: 'string', default: '', desc: '编辑区的无障碍名称' },
|
|
292
|
+
...ID_PROPS,
|
|
293
|
+
...INVALID_PROPS,
|
|
291
294
|
link_text: { type: 'string', default: '', desc: '链接输入框的占位 / 无障碍名称' },
|
|
292
295
|
apply_text: { type: 'string', default: '', desc: '链接确认钮文案' },
|
|
293
296
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
@@ -297,8 +300,8 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
297
300
|
},
|
|
298
301
|
},
|
|
299
302
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
300
|
-
controllerFactory: (
|
|
301
|
-
const P = (): Record<string, unknown> =>
|
|
303
|
+
controllerFactory: createKitController((api) => {
|
|
304
|
+
const P = (): Record<string, unknown> => api.props();
|
|
302
305
|
let root: HTMLElement | null = null;
|
|
303
306
|
let area: HTMLElement | null = null;
|
|
304
307
|
let holder: HTMLElement | null = null;
|
|
@@ -309,7 +312,6 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
309
312
|
let savedRange: Range | null = null;
|
|
310
313
|
let lastInit = '\u0000';
|
|
311
314
|
let builtReadonly: boolean | null = null;
|
|
312
|
-
let removeListeners: Array<() => void> = [];
|
|
313
315
|
|
|
314
316
|
/** source: markdown 时内容是 Markdown 文本(value 优先,其次 data.markdown,再退 data.html),一律只读 */
|
|
315
317
|
const isMarkdown = (): boolean => P().source === 'markdown';
|
|
@@ -343,7 +345,7 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
343
345
|
const value = sanitizeRichHtml(area.innerHTML);
|
|
344
346
|
const text = (area.textContent ?? '');
|
|
345
347
|
refresh();
|
|
346
|
-
|
|
348
|
+
api.emit('change', { value: text.trim() === '' ? '' : value, empty: text.trim() === '', length: text.length });
|
|
347
349
|
};
|
|
348
350
|
|
|
349
351
|
const setContent = (html: string): void => {
|
|
@@ -480,9 +482,9 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
480
482
|
if (!ro) {
|
|
481
483
|
bar = mk('div', BAR_CLASS);
|
|
482
484
|
bar.setAttribute('role', 'toolbar');
|
|
483
|
-
bar.setAttribute('aria-label', str(p.label, kitText('soma.kit.rt_area', undefined,
|
|
485
|
+
bar.setAttribute('aria-label', str(p.label, kitText('soma.kit.rt_area', undefined, api.host)));
|
|
484
486
|
const can = typeof document.execCommand === 'function';
|
|
485
|
-
richCommandsOf(p.commands,
|
|
487
|
+
richCommandsOf(p.commands, api.host).forEach((c, i) => {
|
|
486
488
|
const b = mk('button', BTN_CLASS);
|
|
487
489
|
const glyph = mk('span', '', c.text);
|
|
488
490
|
glyph.setAttribute('aria-hidden', 'true');
|
|
@@ -499,10 +501,11 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
499
501
|
root.appendChild(bar);
|
|
500
502
|
linkBar = mk('div', `${LINKBAR_CLASS} hidden`);
|
|
501
503
|
linkInput = mk('input', LINK_INPUT);
|
|
504
|
+
setKitFace(linkInput, 'field');
|
|
502
505
|
linkInput.type = 'url';
|
|
503
|
-
linkInput.placeholder = str(p.link_text, kitText('soma.kit.rt_link_url', undefined,
|
|
504
|
-
linkInput.setAttribute('aria-label', str(p.link_text, kitText('soma.kit.rt_link_url', undefined,
|
|
505
|
-
const ok = mk('button', BTN_CLASS, str(p.apply_text, kitText('soma.kit.ok', undefined,
|
|
506
|
+
linkInput.placeholder = str(p.link_text, kitText('soma.kit.rt_link_url', undefined, api.host));
|
|
507
|
+
linkInput.setAttribute('aria-label', str(p.link_text, kitText('soma.kit.rt_link_url', undefined, api.host)));
|
|
508
|
+
const ok = mk('button', BTN_CLASS, str(p.apply_text, kitText('soma.kit.ok', undefined, api.host)));
|
|
506
509
|
ok.type = 'button';
|
|
507
510
|
ok.setAttribute('data-kit-link-apply', '');
|
|
508
511
|
linkBar.append(linkInput, ok);
|
|
@@ -512,7 +515,7 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
512
515
|
area = mk('div', AREA_CLASS);
|
|
513
516
|
area.setAttribute('role', 'textbox');
|
|
514
517
|
area.setAttribute('aria-multiline', 'true');
|
|
515
|
-
area.setAttribute('aria-label', str(p.label, kitText('soma.kit.rt_area', undefined,
|
|
518
|
+
area.setAttribute('aria-label', str(p.label, kitText('soma.kit.rt_area', undefined, api.host)));
|
|
516
519
|
if (!ro) area.setAttribute('contenteditable', 'true');
|
|
517
520
|
holder = mk('span', HOLDER_CLASS);
|
|
518
521
|
holder.setAttribute('aria-hidden', 'true');
|
|
@@ -523,26 +526,9 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
523
526
|
lastInit = '\u0000';
|
|
524
527
|
};
|
|
525
528
|
|
|
526
|
-
const paint = (): void => {
|
|
527
|
-
if (!root) return;
|
|
528
|
-
const ro = bool(P().readonly) || isMarkdown();
|
|
529
|
-
if (builtReadonly !== ro || !area) {
|
|
530
|
-
// 模式切换要重建 DOM:先带走当前内容
|
|
531
|
-
const keep = area ? sanitizeRichHtml(area.innerHTML) : null;
|
|
532
|
-
build();
|
|
533
|
-
if (keep !== null) { setContent(keep); lastInit = initialHtml(); }
|
|
534
|
-
}
|
|
535
|
-
const init = initialHtml();
|
|
536
|
-
if (init !== lastInit) { lastInit = init; setContent(init); }
|
|
537
|
-
if (holder) holder.textContent = str(P().placeholder);
|
|
538
|
-
refresh();
|
|
539
|
-
};
|
|
540
|
-
|
|
541
529
|
return {
|
|
542
|
-
|
|
543
|
-
root =
|
|
544
|
-
?? ctx.host.querySelector<HTMLElement>('[data-soma-id="root"]')
|
|
545
|
-
?? ctx.host;
|
|
530
|
+
attach(rootEl) {
|
|
531
|
+
root = rootEl;
|
|
546
532
|
const r = root;
|
|
547
533
|
const onClick = (event: Event): void => {
|
|
548
534
|
const t = event.target as HTMLElement | null;
|
|
@@ -595,32 +581,52 @@ export function createRichTextEditor(): SomaComponentDefinition {
|
|
|
595
581
|
r.addEventListener('paste', onPaste as EventListener);
|
|
596
582
|
r.addEventListener('mousedown', onDown);
|
|
597
583
|
document.addEventListener('selectionchange', onSelection);
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
584
|
+
return () => {
|
|
585
|
+
r.removeEventListener('click', onClick);
|
|
586
|
+
r.removeEventListener('input', onInput);
|
|
587
|
+
r.removeEventListener('keydown', onKeydown as EventListener);
|
|
588
|
+
r.removeEventListener('paste', onPaste as EventListener);
|
|
589
|
+
r.removeEventListener('mousedown', onDown);
|
|
590
|
+
document.removeEventListener('selectionchange', onSelection);
|
|
591
|
+
savedRange = null;
|
|
592
|
+
root = null;
|
|
593
|
+
area = null;
|
|
594
|
+
holder = null;
|
|
595
|
+
foot = null;
|
|
596
|
+
bar = null;
|
|
597
|
+
linkBar = null;
|
|
598
|
+
linkInput = null;
|
|
599
|
+
};
|
|
610
600
|
},
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
601
|
+
render(rootEl, p) {
|
|
602
|
+
root = rootEl;
|
|
603
|
+
const ro = bool(p.readonly) || isMarkdown();
|
|
604
|
+
if (builtReadonly !== ro || !area) {
|
|
605
|
+
// 模式切换要重建 DOM:先带走当前内容
|
|
606
|
+
const keep = area ? sanitizeRichHtml(area.innerHTML) : null;
|
|
607
|
+
build();
|
|
608
|
+
if (keep !== null) { setContent(keep); lastInit = initialHtml(); }
|
|
609
|
+
}
|
|
610
|
+
const init = initialHtml();
|
|
611
|
+
if (init !== lastInit) { lastInit = init; setContent(init); }
|
|
612
|
+
if (holder) holder.textContent = str(p.placeholder);
|
|
613
|
+
// 编辑区(role=textbox)承载 id / 可访问名 / 必填 / 无效 / 说明与标签关联;表单经 props 传入,重绘不丢
|
|
614
|
+
if (area) {
|
|
615
|
+
applyCommon(area, {
|
|
616
|
+
id: p.id,
|
|
617
|
+
aria_label: str(p.aria_label, str(p.label, kitText('soma.kit.rt_area', undefined, api.host))),
|
|
618
|
+
labelledby: p.labelledby,
|
|
619
|
+
required: ro ? false : p.required,
|
|
620
|
+
invalid: p.invalid,
|
|
621
|
+
describedby: p.describedby,
|
|
622
|
+
aria_describedby: p.aria_describedby,
|
|
623
|
+
errormessage: p.errormessage,
|
|
624
|
+
aria_errormessage: p.aria_errormessage,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
refresh();
|
|
622
628
|
},
|
|
623
629
|
};
|
|
624
|
-
},
|
|
630
|
+
}),
|
|
625
631
|
};
|
|
626
632
|
}
|