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
package/src/data/trend-line.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// 无障碍:role=img,aria-label 汇总最近值 / 最高 / 最低。点数不足 2 显示空态短横。
|
|
7
7
|
// 同一份折线也被 StatGroup 的 `spark` 项复用(`sparklineSvg`)。
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
import { bool, joinClass, num, str } from '../base/shared';
|
|
9
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
|
+
import { bool, createKitController, joinClass, type KitProps, num, str } from '../base/shared';
|
|
11
11
|
import { classTokens, mk, rowsOf, textOf } from './shape-util';
|
|
12
12
|
import { SPARKLINE_MAX_POINTS } from './d9-limits';
|
|
13
13
|
|
|
@@ -111,12 +111,8 @@ export function createTrendLine(): SomaComponentDefinition {
|
|
|
111
111
|
emits: {},
|
|
112
112
|
},
|
|
113
113
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
114
|
-
controllerFactory: (
|
|
115
|
-
|
|
116
|
-
let root: HTMLElement | null = null;
|
|
117
|
-
const paint = (): void => {
|
|
118
|
-
if (!root) return;
|
|
119
|
-
const p = P();
|
|
114
|
+
controllerFactory: createKitController((_api) => ({
|
|
115
|
+
render(root: HTMLElement, p: KitProps): void {
|
|
120
116
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
121
117
|
root.textContent = '';
|
|
122
118
|
const values = trendValuesOf(p.data, str(p.y, 'value'));
|
|
@@ -127,21 +123,7 @@ export function createTrendLine(): SomaComponentDefinition {
|
|
|
127
123
|
className: 'size-full',
|
|
128
124
|
});
|
|
129
125
|
if (svg) root.appendChild(svg); else root.appendChild(mk('span', EMPTY_CLASS, str(p.empty_text, '–')));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
onMount(): void {
|
|
133
|
-
root = ctx.host.querySelector<HTMLElement>('[data-soma-scoped-id="root"]')
|
|
134
|
-
?? ctx.host.querySelector<HTMLElement>('[data-soma-id="root"]')
|
|
135
|
-
?? ctx.host;
|
|
136
|
-
paint();
|
|
137
|
-
},
|
|
138
|
-
onPropsChange(): void {
|
|
139
|
-
paint();
|
|
140
|
-
},
|
|
141
|
-
onUnmount(): void {
|
|
142
|
-
root = null;
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
},
|
|
126
|
+
},
|
|
127
|
+
})),
|
|
146
128
|
};
|
|
147
129
|
}
|
package/src/data/virtual-rows.ts
CHANGED
|
@@ -20,33 +20,37 @@
|
|
|
20
20
|
// 窗口起点向下取偶数,保证斑马纹(nth-child 的 even)的奇偶不随窗口位置翻转。
|
|
21
21
|
// 卸载:摘事件、释放虚拟化器(观察者随之清掉)。
|
|
22
22
|
|
|
23
|
-
import type {
|
|
23
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
24
24
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
25
25
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
26
26
|
import { TAG_CLASS } from '../base/tag';
|
|
27
27
|
import { permissionCheckerOf } from '../base/permission-gate';
|
|
28
28
|
import { KIT_CHECK_CLASS_CANDIDATES, attachMarkEvents, createCheck, markChecked, paintCheck, setMarkLabel } from '../base/check-core';
|
|
29
|
-
import { CLASS_PROP, bool, displayOf, joinClass, optionsOf, str, toneOf } from '../base/shared';
|
|
29
|
+
import { CLASS_PROP, bool, createKitController, displayOf, joinClass, optionsOf, str, toneOf } from '../base/shared';
|
|
30
30
|
import { kitLocaleAt } from '../i18n/kit-text';
|
|
31
31
|
import {
|
|
32
|
-
KIT_VIRTUAL_CLASS_CANDIDATES, KIT_VIRTUAL_LABELS, KIT_VIRTUAL_ROW_CLASS,
|
|
32
|
+
KIT_VIRTUAL_CLASS_CANDIDATES, KIT_VIRTUAL_LABELS, KIT_VIRTUAL_ROW_CLASS, virtualRowPx,
|
|
33
33
|
KIT_ROW_TIERS, createVirtualWindow, rowTierOf, setSpacerHeight, withoutPy, type KitRowTier, type VirtualWindow,
|
|
34
34
|
} from '../base/virtual-list';
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
35
|
+
import { ROW_ACTION_BUTTON_CLASS, rowBusyName, removeKeyOf } from '../object-renderer/table-actions';
|
|
36
|
+
import { KIT_ROW_TONE_CLASS, rowToneClass } from '../object-renderer/view-binding';
|
|
37
|
+
import { isKitActionBusy, onKitActionBusy } from '../base/action-busy';
|
|
38
|
+
import type { KitTableDensity } from '../object-renderer/defaults';
|
|
39
|
+
import { KIT_ACTION_SLOT_BASE, actionSlotEmits, emitActionSlot } from '../base/action-slots';
|
|
37
40
|
|
|
38
41
|
const ROOT_CLASS = 'flex flex-col focus-visible:outline-none';
|
|
39
42
|
const SPACER_CLASS = 'w-full';
|
|
40
|
-
const TEXT_CLASS = 'truncate text-sm text-fg';
|
|
41
|
-
const ACTIONS_CELL_CLASS = 'flex flex-
|
|
43
|
+
const TEXT_CLASS = 'block min-w-0 truncate text-sm text-fg';
|
|
44
|
+
const ACTIONS_CELL_CLASS = 'flex flex-nowrap items-center gap-x-4 whitespace-nowrap';
|
|
42
45
|
const ROW_FOCUS_CLASS = 'scroll-mt-10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
43
46
|
const ROW_PICK_CLASS = 'cursor-pointer';
|
|
44
47
|
|
|
45
48
|
export const KIT_VIRTUAL_ROWS_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set([
|
|
46
49
|
ROOT_CLASS, SPACER_CLASS, TEXT_CLASS, ...KIT_CHECK_CLASS_CANDIDATES, ACTIONS_CELL_CLASS, ROW_FOCUS_CLASS, ROW_PICK_CLASS,
|
|
47
50
|
...KIT_VIRTUAL_CLASS_CANDIDATES,
|
|
48
|
-
...Object.values(
|
|
51
|
+
...Object.values(ROW_ACTION_BUTTON_CLASS),
|
|
49
52
|
...Object.values(TAG_CLASS.md),
|
|
53
|
+
...Object.values(KIT_ROW_TONE_CLASS),
|
|
50
54
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')))].sort());
|
|
51
55
|
|
|
52
56
|
type Rec = Record<string, unknown>;
|
|
@@ -81,7 +85,7 @@ function cellsOf(raw: unknown): CellDef[] {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
interface ActionItem {
|
|
84
|
-
id: string; name: string; tone: 'primary' | 'neutral' | 'danger'; builtin: string; target: string; permission: string;
|
|
88
|
+
id: string; name: string; tone: 'primary' | 'neutral' | 'danger'; builtin: string; target: string; permission: string;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
function actionsOf(raw: unknown): ActionItem[] {
|
|
@@ -96,7 +100,6 @@ function actionsOf(raw: unknown): ActionItem[] {
|
|
|
96
100
|
builtin: str(a.builtin),
|
|
97
101
|
target: str(a.target),
|
|
98
102
|
permission: str(a.permission),
|
|
99
|
-
...(isRec(a.when) ? { when: a.when } : {}),
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
return out;
|
|
@@ -129,17 +132,19 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
129
132
|
rows: { type: 'array', default: [], desc: '全部行(整张留在内存,只把窗口内的行画进 DOM)' },
|
|
130
133
|
cells: { type: 'array', default: [], desc: '列(编译器给出的 KitCell[]):field / component / props / cellClass / valueClass / editable / ellipsis' },
|
|
131
134
|
rowHeight: { type: 'string', default: 'md', desc: '固定行高档位 sm / md / lg(档位名,不接受像素;像素估算值读设计真源,第一行画出后以实测校准)' },
|
|
132
|
-
density: { type: 'string', default: 'standard', desc: '静态行高密度 compact / standard / comfortable(外壳带工具栏时以工具栏运行期选择为准):紧凑比 rowHeight 低一档、宽松高一档' },
|
|
133
135
|
rowClass: { type: 'string', default: '', desc: '行容器类(栅格 + 悬停 / 选中高亮;纵向内边距运行期摘掉,行高由档位类定)' },
|
|
134
|
-
rowClassWhen: { type: 'array', default: [], desc: '条件行类 [{ when(core 谓词,字段是行字段), class }]' },
|
|
135
136
|
stripeClass: { type: 'string', default: '', desc: '斑马纹类(偶数行)' },
|
|
137
|
+
rowToneField: { type: 'string', default: '', desc: '行样式档位取自的行字段名(view.list.rowTone: row.<字段>):该字段取值属于语法真源 viewObject.rowState.toneTiers 闭集时,行容器加该档位的类串;空 / 不在闭集不加类;行内容(含该字段值)变了整行重建,不残留旧档位' },
|
|
136
138
|
select: { type: 'string', default: 'none', desc: '勾选列 none / single / multi' },
|
|
137
139
|
selectClass: { type: 'string', default: '', desc: '勾选列跨度类' },
|
|
138
140
|
selected: { type: 'array', default: [], desc: '已选行数组(协调组件 focus 切片镜像)' },
|
|
139
141
|
keyField: { type: 'string', default: '', desc: '行主键字段名(比对已选行)' },
|
|
140
|
-
|
|
142
|
+
removeScope: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):协调组件的作用域 id;本行在途(经忙闲通道登记)时,本行全部操作置灰、行挂 aria-busy、不抛行点击 / 勾选 / 行操作;空 = 不读' },
|
|
143
|
+
removeObject: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):对象名,须与协调组件的主对象同名,空 = 不读;非空时行操作载荷附带 kit_object' },
|
|
144
|
+
removeKeyField: { type: 'string', default: '', desc: '行在途判断用(内置删除与具名行动作共用):行主键字段名(与协调组件登记忙态的键同一规则:显式主键 → id → 空串;独立于 keyField,不受选择影响)' },
|
|
145
|
+
actions: { type: 'array', default: [], desc: '行操作 [{ id, name, tone?, builtin?, target?, permission? }]' },
|
|
141
146
|
actionsClass: { type: 'string', default: '', desc: '操作列跨度类' },
|
|
142
|
-
pickOnRow: { type: 'boolean', default: false, desc: '点击行抛
|
|
147
|
+
pickOnRow: { type: 'boolean', default: false, desc: '点击行抛 row_pick(builtin: select)' },
|
|
143
148
|
bordered: { type: 'boolean', default: true, desc: '是否显示边框(collection.bordered: false 时移除边框类)' },
|
|
144
149
|
label: { type: 'string', default: '', desc: '表格的可访问名(aria-label)' },
|
|
145
150
|
colCount: { type: 'number', default: 0, desc: '总列数(含选择列 / 操作列),aria-colcount 用;0 = 按 cells 与选择 / 操作推出' },
|
|
@@ -155,25 +160,28 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
155
160
|
},
|
|
156
161
|
desc: '勾选列变化(同 KitTableActions.row_select)',
|
|
157
162
|
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
|
|
163
|
+
...actionSlotEmits(KIT_ACTION_SLOT_BASE.row, {
|
|
164
|
+
kit_action: { type: 'string', desc: '动作判别键' },
|
|
165
|
+
id: { type: 'string', desc: '动作 id' },
|
|
166
|
+
name: { type: 'string', desc: '动作显示名' },
|
|
167
|
+
builtin: { type: 'string', desc: '内置动作名' },
|
|
168
|
+
target: { type: 'string', desc: '目标浮层' },
|
|
169
|
+
row: { type: 'object', desc: '当前行' },
|
|
170
|
+
kit_object: { type: 'string', desc: '对象名(removeObject 非空时附带,协调组件据此认出本表所属对象)' },
|
|
171
|
+
kit_row_busy: { type: 'string', desc: '本行在途通道名(removeScope 与 removeObject 都非空时附带;动作执行器在具名行动作执行期间登记)' },
|
|
172
|
+
}, '点击行操作;载荷自带整行(同 KitTableActions.row_action_<序号>)'),
|
|
173
|
+
row_pick: {
|
|
174
|
+
payload: { kit_action: { type: 'string' }, id: { type: 'string' }, builtin: { type: 'string' }, row: { type: 'object', desc: '当前行' }, kit_object: { type: 'string', desc: '对象名(removeObject 非空时附带)' } },
|
|
175
|
+
desc: '点击行(pickOnRow);载荷自带整行(同 KitTableActions.row_pick)',
|
|
168
176
|
},
|
|
169
177
|
},
|
|
170
178
|
keyboard: { layout: 'list', wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
171
179
|
},
|
|
172
180
|
services: ['permission', 'engines'],
|
|
173
181
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
174
|
-
controllerFactory: (
|
|
175
|
-
const P = (): Rec =>
|
|
176
|
-
const check = permissionCheckerOf(
|
|
182
|
+
controllerFactory: createKitController((api) => {
|
|
183
|
+
const P = (): Rec => api.props();
|
|
184
|
+
const check = permissionCheckerOf(api as unknown as any);
|
|
177
185
|
let root: HTMLElement | null = null;
|
|
178
186
|
let top: HTMLElement | null = null;
|
|
179
187
|
let bottom: HTMLElement | null = null;
|
|
@@ -187,7 +195,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
187
195
|
let items: CollectionItem[] = [];
|
|
188
196
|
const rendered = new Map<number, HTMLElement>();
|
|
189
197
|
|
|
190
|
-
const doc = (): Document => (root ??
|
|
198
|
+
const doc = (): Document => (root ?? api.host).ownerDocument;
|
|
191
199
|
const mk = (tag: string, cls: string, text?: string): HTMLElement => {
|
|
192
200
|
const el = doc().createElement(tag);
|
|
193
201
|
if (cls !== '') el.className = cls;
|
|
@@ -195,31 +203,31 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
195
203
|
return el;
|
|
196
204
|
};
|
|
197
205
|
/** 承载 aria-rowcount / colcount 的 grid:外壳内层,没有就是根自己 */
|
|
198
|
-
const gridEl = (): HTMLElement => (root?.parentElement?.closest<HTMLElement>('[role="grid"]') ?? root ??
|
|
199
|
-
const scroller = (): HTMLElement | null =>
|
|
206
|
+
const gridEl = (): HTMLElement => (root?.parentElement?.closest<HTMLElement>('[role="grid"]') ?? root ?? api.host);
|
|
207
|
+
const scroller = (): HTMLElement | null => api.host.closest<HTMLElement>('[data-kit-vscroll]');
|
|
200
208
|
const cells = (): CellDef[] => cellsOf(P().cells);
|
|
201
209
|
const mode = (): string => str(P().select, 'none');
|
|
202
210
|
/**
|
|
203
211
|
* 当前密度:带工具栏(外壳有 data-kit-table)时以 KitTableTools 写在外壳上的 data-kit-dense / data-kit-roomy 为准(没有 = 标准,
|
|
204
|
-
*
|
|
212
|
+
* 含用户在工具栏里切回标准);没有工具栏时恒为标准档(表级密度键已删除,密度只在应用级 theme.density)。三档取值是九维 density 枚举。
|
|
205
213
|
*/
|
|
206
|
-
const densityNow = ():
|
|
214
|
+
const densityNow = (): KitTableDensity => {
|
|
207
215
|
const sc = scroller();
|
|
208
216
|
if (sc !== null && sc.hasAttribute('data-kit-table')) {
|
|
209
|
-
return sc.hasAttribute('data-kit-dense') ? '
|
|
217
|
+
return sc.hasAttribute('data-kit-dense') ? 'COMPACT_DENSE' : sc.hasAttribute('data-kit-roomy') ? 'SPACIOUS_AIRY' : 'STANDARD_BALANCED';
|
|
210
218
|
}
|
|
211
|
-
|
|
212
|
-
return d === 'compact' || d === 'comfortable' ? d : 'standard';
|
|
219
|
+
return 'STANDARD_BALANCED';
|
|
213
220
|
};
|
|
214
221
|
/** 有效行高档:rowHeight 是标准密度的档位,紧凑下移一档、宽松上移一档(夹在 sm..lg 内) */
|
|
215
222
|
const tier = (): KitRowTier => {
|
|
216
223
|
const base = rowTierOf(P().rowHeight);
|
|
217
224
|
const at = KIT_ROW_TIERS.indexOf(base);
|
|
218
225
|
const d = densityNow();
|
|
219
|
-
const shifted = d === '
|
|
226
|
+
const shifted = d === 'COMPACT_DENSE' ? at - 1 : d === 'SPACIOUS_AIRY' ? at + 1 : at;
|
|
220
227
|
return KIT_ROW_TIERS[Math.max(0, Math.min(KIT_ROW_TIERS.length - 1, shifted))]!;
|
|
221
228
|
};
|
|
222
229
|
let appliedTier: KitRowTier | null = null;
|
|
230
|
+
let appliedTone = '';
|
|
223
231
|
/** 密度变了换档:清行、换估算行高(窗口重新测量) */
|
|
224
232
|
const syncTier = (repaint = true): void => {
|
|
225
233
|
const t = tier();
|
|
@@ -227,7 +235,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
227
235
|
if (t === appliedTier) return;
|
|
228
236
|
appliedTier = t;
|
|
229
237
|
clearRows();
|
|
230
|
-
win?.setRowPx(
|
|
238
|
+
win?.setRowPx(virtualRowPx(t, scroller() ?? api.host));
|
|
231
239
|
if (repaint) paint();
|
|
232
240
|
};
|
|
233
241
|
let densityObserver: MutationObserver | null = null;
|
|
@@ -249,19 +257,55 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
249
257
|
const kf = str(P().keyField);
|
|
250
258
|
return Array.isArray(sel) && sel.some((r) => rowKeyOf(r, kf) === rowKeyOf(row, kf));
|
|
251
259
|
};
|
|
260
|
+
/** 本行删除在途:协调组件经忙闲通道登记(作用域 + 对象 + 行主键三段),与 KitTableActions 同一条规则 */
|
|
261
|
+
const rowBusy = (row: Rec): boolean => {
|
|
262
|
+
const p = P();
|
|
263
|
+
const scope = str(p.removeScope);
|
|
264
|
+
const object = str(p.removeObject);
|
|
265
|
+
return scope !== '' && object !== '' && isKitActionBusy(rowBusyName(scope, object, removeKeyOf(row, str(p.removeKeyField))));
|
|
266
|
+
};
|
|
267
|
+
/** 行动作载荷附带的对象名(removeObject 非空才有) */
|
|
268
|
+
const objectPayload = (): Rec => {
|
|
269
|
+
const object = str(P().removeObject);
|
|
270
|
+
return object !== '' ? { kit_object: object } : {};
|
|
271
|
+
};
|
|
272
|
+
/** 行动作载荷附带的本行在途通道名(removeScope 与 removeObject 都非空才有;动作执行器在具名行动作执行期间登记) */
|
|
273
|
+
const rowBusyPayload = (row: Rec): Rec => {
|
|
274
|
+
const p = P();
|
|
275
|
+
const scope = str(p.removeScope);
|
|
276
|
+
const object = str(p.removeObject);
|
|
277
|
+
return scope !== '' && object !== '' ? { kit_row_busy: rowBusyName(scope, object, removeKeyOf(row, str(p.removeKeyField))) } : {};
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* 把本行的删除在途呈现落到行元素:aria-busy、行操作按钮与勾选框置灰(沿用按钮 / 勾选标记自带的禁用呈现)。
|
|
281
|
+
* fresh = 刚建的行,未在途时无需处理;否则状态没变就跳过。
|
|
282
|
+
*/
|
|
283
|
+
const applyBusy = (el: HTMLElement, row: Rec, fresh = false): void => {
|
|
284
|
+
const busy = rowBusy(row);
|
|
285
|
+
if (fresh ? !busy : (el.getAttribute('aria-busy') === 'true') === busy) return;
|
|
286
|
+
if (busy) el.setAttribute('aria-busy', 'true'); else el.removeAttribute('aria-busy');
|
|
287
|
+
for (const btn of Array.from(el.querySelectorAll<HTMLButtonElement>('[data-kit-act]'))) {
|
|
288
|
+
btn.disabled = busy;
|
|
289
|
+
if (busy) btn.setAttribute('aria-disabled', 'true'); else btn.removeAttribute('aria-disabled');
|
|
290
|
+
}
|
|
291
|
+
const box = el.querySelector<HTMLElement>('[data-kit-sel]');
|
|
292
|
+
if (box) paintCheck(box, { checked: markChecked(box), disabled: busy });
|
|
293
|
+
};
|
|
252
294
|
const emitSelect = (row: Rec, checked: boolean): void => {
|
|
253
295
|
const m = mode();
|
|
254
296
|
if (m !== 'single' && m !== 'multi') return;
|
|
255
|
-
|
|
297
|
+
if (rowBusy(row)) return; // 删除在途:不抛勾选
|
|
298
|
+
api.emit('row_select', { row, checked, mode: m, keyField: str(P().keyField) });
|
|
256
299
|
};
|
|
257
300
|
const emitPick = (row: Rec): void => {
|
|
258
|
-
|
|
301
|
+
if (rowBusy(row)) return; // 删除在途:不抛行点击
|
|
302
|
+
api.emit('row_pick', { kit_action: 'select', id: 'select', name: '', builtin: 'select', target: '', row, ...objectPayload() });
|
|
259
303
|
};
|
|
260
304
|
|
|
261
305
|
/** 单元格内容:Tag(选项自带 tone)或 Text;走格式化 / 选项 */
|
|
262
306
|
const cellContent = (cell: CellDef, row: Rec): HTMLElement => {
|
|
263
307
|
const placeholder = str(cell.props.placeholder);
|
|
264
|
-
const { text, option } = displayOf(row[cell.field], optionsOf(cell.props.options), str(cell.props.format), str(cell.props.locale, kitLocaleAt(
|
|
308
|
+
const { text, option } = displayOf(row[cell.field], optionsOf(cell.props.options), str(cell.props.format), str(cell.props.locale, kitLocaleAt(api.host) || 'zh-CN'), placeholder);
|
|
265
309
|
if (cell.component === 'Tag' && text !== '') {
|
|
266
310
|
const tone = option?.tone ?? toneOf(cell.props.tone, 'neutral');
|
|
267
311
|
return mk('span', TAG_CLASS.md[tone], text);
|
|
@@ -271,17 +315,14 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
271
315
|
|
|
272
316
|
const rowClassOf = (row: Rec): string => {
|
|
273
317
|
const p = P();
|
|
318
|
+
const toneField = str(p.rowToneField);
|
|
274
319
|
const base = [
|
|
275
320
|
withoutPy(str(p.rowClass)), str(p.stripeClass), KIT_VIRTUAL_ROW_CLASS[tier()], 'items-center', ROW_FOCUS_CLASS,
|
|
276
321
|
bool(p.pickOnRow) ? ROW_PICK_CLASS : '',
|
|
322
|
+
// 行样式档位:行内容变了(含档位字段值变了)整行重建(见 syncRows 的签名),类串建行时现算,无旧档位残留
|
|
323
|
+
toneField === '' ? '' : rowToneClass(row[toneField]),
|
|
277
324
|
].filter((s) => s !== '').join(' ');
|
|
278
|
-
|
|
279
|
-
if (Array.isArray(p.rowClassWhen)) {
|
|
280
|
-
for (const w of p.rowClassWhen as Array<{ when?: Rec; class?: string }>) {
|
|
281
|
-
if (w && str(w.class) !== '' && holds(w.when, row)) extra.push(str(w.class));
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return extra.length === 0 ? base : `${base} ${extra.join(' ')}`;
|
|
325
|
+
return base;
|
|
285
326
|
};
|
|
286
327
|
|
|
287
328
|
const buildRow = (index: number): HTMLElement => {
|
|
@@ -320,7 +361,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
320
361
|
cell.appendChild(cellContent(col, row));
|
|
321
362
|
el.appendChild(cell);
|
|
322
363
|
}
|
|
323
|
-
const actions = actionsOf(p.actions).filter((a) => (a.permission === '' || check === null || check(a.permission))
|
|
364
|
+
const actions = actionsOf(p.actions).filter((a) => (a.permission === '' || check === null || check(a.permission)));
|
|
324
365
|
if (actionsOf(p.actions).length > 0) {
|
|
325
366
|
const rawActions = withoutPy(str(p.actionsClass));
|
|
326
367
|
const actionsClass = p.bordered === false ? stripBorderClasses(rawActions) : rawActions;
|
|
@@ -328,14 +369,16 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
328
369
|
cell.setAttribute('role', 'gridcell');
|
|
329
370
|
const box = mk('div', ACTIONS_CELL_CLASS);
|
|
330
371
|
for (const a of actions) {
|
|
331
|
-
const btn = mk('button',
|
|
372
|
+
const btn = mk('button', ROW_ACTION_BUTTON_CLASS[a.tone], a.name);
|
|
332
373
|
btn.setAttribute('type', 'button');
|
|
374
|
+
// 行动作:文字链接形态(无面,不标 raised)
|
|
333
375
|
btn.setAttribute('data-kit-act', a.id);
|
|
334
376
|
box.appendChild(btn);
|
|
335
377
|
}
|
|
336
378
|
cell.appendChild(box);
|
|
337
379
|
el.appendChild(cell);
|
|
338
380
|
}
|
|
381
|
+
applyBusy(el, row, true);
|
|
339
382
|
return el;
|
|
340
383
|
};
|
|
341
384
|
|
|
@@ -352,7 +395,8 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
352
395
|
if (picked) el.setAttribute('data-kit-selected', ''); else el.removeAttribute('data-kit-selected');
|
|
353
396
|
if (mode() !== 'none') el.setAttribute('aria-selected', picked ? 'true' : 'false');
|
|
354
397
|
const box = el.querySelector<HTMLElement>('[data-kit-sel]');
|
|
355
|
-
if (box && markChecked(box) !== picked) paintCheck(box, { checked: picked });
|
|
398
|
+
if (box && markChecked(box) !== picked) paintCheck(box, { checked: picked, disabled: rowBusy(row) });
|
|
399
|
+
applyBusy(el, row); // 在途状态变化(忙闲通道通知后重绘走这里)
|
|
356
400
|
}
|
|
357
401
|
};
|
|
358
402
|
|
|
@@ -433,7 +477,7 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
433
477
|
rowsRef = next;
|
|
434
478
|
const list = Array.isArray(next) ? next.filter(isRec) : [];
|
|
435
479
|
let sig: string;
|
|
436
|
-
try { sig = JSON.stringify([list, P().cells, P().rowClass, P().actions, P().select]); } catch { sig = `x${Math.random()}`; }
|
|
480
|
+
try { sig = JSON.stringify([list, P().cells, P().rowClass, P().actions, P().select, P().rowToneField]); } catch { sig = `x${Math.random()}`; }
|
|
437
481
|
if (sig === rowsSig && list.length === rows.length) { rows = list; return false; }
|
|
438
482
|
rowsSig = sig;
|
|
439
483
|
rows = list;
|
|
@@ -469,10 +513,8 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
469
513
|
});
|
|
470
514
|
|
|
471
515
|
return {
|
|
472
|
-
|
|
473
|
-
root =
|
|
474
|
-
?? ctx.host.querySelector<HTMLElement>('[data-soma-id="root"]')
|
|
475
|
-
?? ctx.host;
|
|
516
|
+
attach(rootEl) {
|
|
517
|
+
root = rootEl;
|
|
476
518
|
top = mk('div', SPACER_CLASS);
|
|
477
519
|
top.setAttribute('aria-hidden', 'true');
|
|
478
520
|
bottom = mk('div', SPACER_CLASS);
|
|
@@ -483,10 +525,10 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
483
525
|
syncRows();
|
|
484
526
|
appliedTier = tier();
|
|
485
527
|
win = createVirtualWindow({
|
|
486
|
-
services:
|
|
528
|
+
services: api.services,
|
|
487
529
|
scroller,
|
|
488
530
|
count: rows.length,
|
|
489
|
-
rowPx:
|
|
531
|
+
rowPx: virtualRowPx(appliedTier, scroller() ?? api.host),
|
|
490
532
|
onChange: () => paint(),
|
|
491
533
|
});
|
|
492
534
|
// 工具栏切行高:KitTableTools 改外壳的 data-kit-dense / data-kit-roomy,这里跟着换档
|
|
@@ -508,8 +550,10 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
508
550
|
syncTabindex();
|
|
509
551
|
const act = t.closest<HTMLElement>('[data-kit-act]');
|
|
510
552
|
if (act) {
|
|
511
|
-
const
|
|
512
|
-
|
|
553
|
+
const list = actionsOf(P().actions);
|
|
554
|
+
const idx = list.findIndex((x) => x.id === act.getAttribute('data-kit-act'));
|
|
555
|
+
const a = list[idx];
|
|
556
|
+
if (a && !rowBusy(row)) emitActionSlot((n, p) => api.emit(n, p), KIT_ACTION_SLOT_BASE.row, idx, { kit_action: a.id, id: a.id, name: a.name, builtin: a.builtin, target: a.target, row, ...objectPayload(), ...rowBusyPayload(row) });
|
|
513
557
|
return;
|
|
514
558
|
}
|
|
515
559
|
if (t.closest('[data-kit-sel]')) return; // change 事件处理
|
|
@@ -537,34 +581,41 @@ export function createKitVirtualRows(): SomaComponentDefinition {
|
|
|
537
581
|
r.addEventListener('click', onClick);
|
|
538
582
|
r.addEventListener('keydown', onKeydown as EventListener);
|
|
539
583
|
r.addEventListener('focusin', onFocusIn);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
584
|
+
// 删除在途的忙闲通道:已画出的行里有在途状态与现状不一致才重绘(窗口外的行建行时自己读)
|
|
585
|
+
const offBusy = onKitActionBusy(() => {
|
|
586
|
+
for (const [i, el] of rendered) {
|
|
587
|
+
if ((el.getAttribute('aria-busy') === 'true') !== rowBusy(rows[i] ?? {})) { api.refresh(); return; }
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
return () => {
|
|
591
|
+
offBusy();
|
|
592
|
+
r.removeEventListener('click', onClick);
|
|
593
|
+
offMark();
|
|
594
|
+
r.removeEventListener('keydown', onKeydown as EventListener);
|
|
595
|
+
r.removeEventListener('focusin', onFocusIn);
|
|
596
|
+
densityObserver?.disconnect();
|
|
597
|
+
densityObserver = null;
|
|
598
|
+
appliedTier = null;
|
|
599
|
+
win?.dispose();
|
|
600
|
+
win = null;
|
|
601
|
+
rendered.clear();
|
|
602
|
+
root = null;
|
|
603
|
+
top = null;
|
|
604
|
+
bottom = null;
|
|
605
|
+
};
|
|
547
606
|
},
|
|
548
|
-
|
|
549
|
-
|
|
607
|
+
render(rootEl) {
|
|
608
|
+
root = rootEl;
|
|
609
|
+
// 行样式档位字段换了:行元素复用会留旧档位类,整窗重建
|
|
610
|
+
const tone = str(P().rowToneField);
|
|
611
|
+
const toneChanged = tone !== appliedTone;
|
|
612
|
+
appliedTone = tone;
|
|
613
|
+
if (syncRows() || toneChanged) clearRows();
|
|
550
614
|
else refreshSelection();
|
|
551
615
|
syncTier();
|
|
552
616
|
paint();
|
|
553
617
|
},
|
|
554
|
-
onUnmount(): void {
|
|
555
|
-
for (const off of offs) off();
|
|
556
|
-
offs = [];
|
|
557
|
-
densityObserver?.disconnect();
|
|
558
|
-
densityObserver = null;
|
|
559
|
-
appliedTier = null;
|
|
560
|
-
win?.dispose();
|
|
561
|
-
win = null;
|
|
562
|
-
rendered.clear();
|
|
563
|
-
root = null;
|
|
564
|
-
top = null;
|
|
565
|
-
bottom = null;
|
|
566
|
-
},
|
|
567
618
|
};
|
|
568
|
-
},
|
|
619
|
+
}),
|
|
569
620
|
};
|
|
570
621
|
}
|
package/src/data/watermark.ts
CHANGED
|
@@ -129,12 +129,12 @@ export function createWatermark(): SomaComponentDefinition {
|
|
|
129
129
|
emits: {},
|
|
130
130
|
},
|
|
131
131
|
templateHtml: `<div data-soma-id="root" aria-hidden="true" class="${ROOT_CLASS}"></div>`,
|
|
132
|
-
controllerFactory: createKitController({
|
|
132
|
+
controllerFactory: createKitController(() => ({
|
|
133
133
|
render(root, p) {
|
|
134
134
|
let id = ids.get(root);
|
|
135
135
|
if (id === undefined) { id = nextUid('kit-wm'); ids.set(root, id); }
|
|
136
136
|
paintKitWatermark(root, p.data, p.class, id);
|
|
137
137
|
},
|
|
138
|
-
}),
|
|
138
|
+
})),
|
|
139
139
|
};
|
|
140
140
|
}
|