soma-kit 0.1.14 → 0.1.16
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 +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
// AuditLog:审计日志(layer: data,写死形状,accept: list)。字段变更流:谁、何时、哪个字段从什么改成什么。
|
|
2
|
+
//
|
|
3
|
+
// 抄自 GitHub Primer 的 Timeline(TimelineItem:徽标 + 竖线 + 正文)与 shadcn blocks 的活动流;
|
|
4
|
+
// 变更行的「旧值删除线 -> 新值」沿用 Primer 事件流里 diff 小标签的写法。
|
|
5
|
+
// 数据:`data` 是 [{ id, time, actor, avatar?, action?, target?, changes?: [{ field, from, to }], field?, from?, to? }];
|
|
6
|
+
// 单字段变更可直接把 field / from / to 写在事件上;键名可由 `map` 改写。排序 `order`(none / asc / desc)。
|
|
7
|
+
// `selectable` 为真时每条事件是按钮,点击抛 `select { item }`(源数据原对象)。组件只展示,不写数据。
|
|
8
|
+
|
|
9
|
+
import { kitApplyLevelClass } from './level-class';
|
|
10
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
11
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
12
|
+
import { kitClosedValueRecipe, kitFieldNameRecipe } from '../recipes/field-text';
|
|
13
|
+
import { kitMarkRecipe } from '../recipes/mark';
|
|
14
|
+
import { kitPlainActionRecipe, kitActionRecipe } from '../recipes/emphasis';
|
|
15
|
+
import { kitDividerRecipe, kitThickDividerRecipe } from '../recipes/divider';
|
|
16
|
+
import { kitTextFit } from '../recipes/text-fit';
|
|
17
|
+
import { KIT_STATUS_BADGE_CLASS, KIT_STATUS_DOT_CLASS } from '../recipes/status';
|
|
18
|
+
import { mergeClass } from '../shared/merge-class';
|
|
19
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
20
|
+
import { bool, createKitController, formatValue, joinClass, str } from '../base/shared';
|
|
21
|
+
import { kitText } from '../i18n/kit-text';
|
|
22
|
+
import { kitIcon } from '../shared/icons';
|
|
23
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
24
|
+
import { classTokens, compareTime, emptyNode, keyMap, mk, recOf, rowsOf, textOf, TONE_DOT, type Rec, type ShapeTone } from './shape-util';
|
|
25
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
26
|
+
import { attrEsc, AVATAR_CLASS_TOKENS, avatarNode, dayNumOf, textOfDayNum } from './d9-util';
|
|
27
|
+
import {
|
|
28
|
+
KIT_ATTR_DAY, KIT_ATTR_DETAIL_OF, KIT_ATTR_ENTRY, KIT_ATTR_EXPORT, KIT_ATTR_FOLD, KIT_ATTR_FOLD_LABEL, KIT_ATTR_LOAD_MORE, KIT_ATTR_PART,
|
|
29
|
+
KIT_ATTR_PICK, KIT_ATTR_RESULT, kitAttrSel,
|
|
30
|
+
} from '../shared/dom-attrs';
|
|
31
|
+
|
|
32
|
+
export const KIT_AUDIT_LOG_DEFAULT_MAP = Object.freeze({
|
|
33
|
+
id: 'id', time: 'time', actor: 'actor', avatar: 'avatar', action: 'action', target: 'target',
|
|
34
|
+
changes: 'changes', field: 'field', from: 'from', to: 'to', result: 'result', source: 'source', sensitive: 'sensitive',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** 结果闭集:成功(不画标记)/ 失败 / 已拒绝;其它值按成功 */
|
|
38
|
+
export type KitAuditResult = 'success' | 'failure' | 'denied';
|
|
39
|
+
const RESULT_TONE: Readonly<Record<Exclude<KitAuditResult, 'success'>, ShapeTone>> = Object.freeze({ failure: 'danger', denied: 'warning' });
|
|
40
|
+
/** 敏感动作的语气:danger / warning(真值 true 取 warning);非敏感 = null */
|
|
41
|
+
export type KitAuditSensitive = 'danger' | 'warning' | null;
|
|
42
|
+
|
|
43
|
+
// 日期分组头(今天 / 昨天 / 具体日期):12 / 500 弱化墨 + 发丝线
|
|
44
|
+
const DAY_HEAD_CLASS = mergeClass(mergeClass('flex items-center gap-3 pb-2 pt-1', kitTypographyRecipe('menuGroup')), 'text-fg-muted');
|
|
45
|
+
const DAY_RULE_CLASS = mergeClass('flex-1', kitDividerRecipe('top'));
|
|
46
|
+
// 工具条 / 不可变提示 / 加载更多尾行 / 折叠钮
|
|
47
|
+
const TOOLBAR_CLASS = 'flex flex-wrap items-center justify-between gap-2 pb-3';
|
|
48
|
+
const HINT_CLASS = kitTypographyRecipe('captionPlain');
|
|
49
|
+
const EXPORT_BUTTON_CLASS = kitActionRecipe('export', { size: 'sm', tight: true, region: 'toolbar', rankInRegion: 1 });
|
|
50
|
+
const MORE_ROW_CLASS = 'flex items-center justify-center pb-2 pt-1';
|
|
51
|
+
const MORE_BUTTON_CLASS = kitPlainActionRecipe('more-text', { shape: 'button', tight: true });
|
|
52
|
+
const FOLD_BUTTON_CLASS = mergeClass(kitPlainActionRecipe('expand', { shape: 'button', tight: true }), 'ms-2');
|
|
53
|
+
// 表格形态(时间 / 操作人 / 动作 / 对象 / 结果 / 来源):原生 table,表头 / 行线 / 行高由主题结构 CSS 经 table 语义出
|
|
54
|
+
const TABLE_CLASS = mergeClass('w-full', kitTypographyRecipe('text')); // 与 Matrix / ScheduleGrid 同:不写 border-collapse(样式引擎拒收)
|
|
55
|
+
const COLUMN_HEADER_CLASS = mergeClass('px-3 text-start', kitFieldNameRecipe());
|
|
56
|
+
const TD_CLASS = 'px-3 py-2 align-middle';
|
|
57
|
+
const TD_TIME_CLASS = `px-3 py-2 align-middle ${kitTextFit('value').class} text-fg-muted`;
|
|
58
|
+
const TD_NAME_CLASS = `px-3 py-2 align-middle ${kitTextFit('name').class}`;
|
|
59
|
+
const TD_DETAIL_CLASS = 'px-3 pb-3 pt-1';
|
|
60
|
+
const ACTOR_CELL_CLASS = 'flex items-center gap-2';
|
|
61
|
+
const RESULT_MARK_CLASS = (tone: ShapeTone): string => `${KIT_STATUS_BADGE_CLASS} ${kitClosedValueRecipe(tone)}`;
|
|
62
|
+
|
|
63
|
+
const ROOT_CLASS = mergeClass('flex flex-col', kitTypographyRecipe('text'));
|
|
64
|
+
const ITEM_CLASS = 'flex gap-4';
|
|
65
|
+
const RAIL_CLASS = 'flex flex-col items-center gap-1 pt-1';
|
|
66
|
+
const LINE_CLASS = mergeClass('flex-1', kitThickDividerRecipe('start'));
|
|
67
|
+
const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-2 pb-5';
|
|
68
|
+
const BODY_BUTTON_CLASS = 'flex min-w-0 flex-1 flex-col gap-2 rounded-item px-2 pb-5 text-start transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ' + KIT_FOCUS_RING.button;
|
|
69
|
+
const HEAD_CLASS = 'flex flex-wrap items-baseline gap-x-2';
|
|
70
|
+
const ACTOR_CLASS = kitTypographyRecipe('menuItem');
|
|
71
|
+
const ACTION_CLASS = 'text-fg-muted';
|
|
72
|
+
const TARGET_CLASS = kitTypographyRecipe('menuItem');
|
|
73
|
+
const TIME_CLASS = kitTypographyRecipe('captionPlain');
|
|
74
|
+
const TIME_END_CLASS = `${TIME_CLASS} ms-auto ${kitTextFit('value').class}`;
|
|
75
|
+
const CHANGES_CLASS = 'flex flex-col gap-1';
|
|
76
|
+
const CHANGE_CLASS = 'flex flex-wrap items-center gap-x-2 gap-y-1';
|
|
77
|
+
// 字段名 = 字段名出口(F7 kitFieldNameRecipe);旧 / 新值 = 变更语气标记(kitMarkRecipe tone:移除 / 新增淡底)
|
|
78
|
+
const FIELD_CLASS = mergeClass('shrink-0', kitFieldNameRecipe());
|
|
79
|
+
const VALUE_BASE = 'max-w-full break-all whitespace-normal';
|
|
80
|
+
const FROM_CLASS = mergeClass(kitMarkRecipe('tone', 'danger'), `${VALUE_BASE} line-through`);
|
|
81
|
+
const TO_CLASS = mergeClass(kitMarkRecipe('tone', 'success'), VALUE_BASE);
|
|
82
|
+
const EMPTY_VALUE_CLASS = 'italic';
|
|
83
|
+
const ARROW_CLASS = mergeClass('shrink-0', kitTypographyRecipe('captionPlain'));
|
|
84
|
+
|
|
85
|
+
export const KIT_AUDIT_LOG_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
86
|
+
ROOT_CLASS, ITEM_CLASS, RAIL_CLASS, LINE_CLASS, BODY_CLASS, BODY_BUTTON_CLASS, HEAD_CLASS, ACTOR_CLASS, ACTION_CLASS, TARGET_CLASS,
|
|
87
|
+
TIME_CLASS, CHANGES_CLASS, CHANGE_CLASS, FIELD_CLASS, FROM_CLASS, TO_CLASS, EMPTY_VALUE_CLASS, ARROW_CLASS, AVATAR_CLASS_TOKENS,
|
|
88
|
+
TIME_END_CLASS, DAY_HEAD_CLASS, DAY_RULE_CLASS, TOOLBAR_CLASS, HINT_CLASS, EXPORT_BUTTON_CLASS, MORE_ROW_CLASS, MORE_BUTTON_CLASS, FOLD_BUTTON_CLASS,
|
|
89
|
+
TABLE_CLASS, COLUMN_HEADER_CLASS, TD_CLASS, TD_TIME_CLASS, TD_NAME_CLASS, TD_DETAIL_CLASS, ACTOR_CELL_CLASS,
|
|
90
|
+
KIT_STATUS_BADGE_CLASS, KIT_STATUS_DOT_CLASS, Object.values(TONE_DOT), RESULT_MARK_CLASS('danger'), RESULT_MARK_CLASS('warning'),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
export interface KitAuditChange { field: string; from: string; to: string; hasFrom: boolean; hasTo: boolean }
|
|
94
|
+
export interface KitAuditEntry {
|
|
95
|
+
key: string;
|
|
96
|
+
time: string;
|
|
97
|
+
actor: string;
|
|
98
|
+
avatar: string;
|
|
99
|
+
action: string;
|
|
100
|
+
target: string;
|
|
101
|
+
changes: KitAuditChange[];
|
|
102
|
+
/** 结果:缺省 / 未识别 = 成功(不画标记) */
|
|
103
|
+
result: KitAuditResult;
|
|
104
|
+
/** 来源(IP / 终端),表格形态的末列 */
|
|
105
|
+
source: string;
|
|
106
|
+
/** 敏感动作(删除 / 授权变更 / 导出 / 登录异常):动作用状态标记突出 */
|
|
107
|
+
sensitive: KitAuditSensitive;
|
|
108
|
+
/** 原始 time 的日期部分(日序号),按天分组用 */
|
|
109
|
+
day: number | null;
|
|
110
|
+
/** 原始 time 能解析时的机器可读值(<time datetime>) */
|
|
111
|
+
iso: string;
|
|
112
|
+
raw: Rec;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function resultOf(raw: unknown): KitAuditResult {
|
|
116
|
+
const v = textOf(raw).toLowerCase();
|
|
117
|
+
return v === 'failure' || v === 'failed' || v === 'fail' ? 'failure' : v === 'denied' || v === 'rejected' ? 'denied' : 'success';
|
|
118
|
+
}
|
|
119
|
+
function sensitiveOf(raw: unknown): KitAuditSensitive {
|
|
120
|
+
if (raw === true || raw === 'true' || raw === 'warning') return 'warning';
|
|
121
|
+
return raw === 'danger' ? 'danger' : null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** 值转展示文字:对象走 JSON,空值回空串 */
|
|
125
|
+
export function auditValueText(raw: unknown): string {
|
|
126
|
+
if (raw === null || raw === undefined) return '';
|
|
127
|
+
if (typeof raw === 'object') {
|
|
128
|
+
try { return JSON.stringify(raw); } catch { return ''; }
|
|
129
|
+
}
|
|
130
|
+
return textOf(raw);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function changeOf(raw: unknown, m: Record<'field' | 'from' | 'to', string>): KitAuditChange | null {
|
|
134
|
+
const r = recOf(raw);
|
|
135
|
+
const field = textOf(r[m.field]);
|
|
136
|
+
const hasFrom = r[m.from] !== undefined && r[m.from] !== null && r[m.from] !== '';
|
|
137
|
+
const hasTo = r[m.to] !== undefined && r[m.to] !== null && r[m.to] !== '';
|
|
138
|
+
if (field === '' && !hasFrom && !hasTo) return null;
|
|
139
|
+
return { field, from: auditValueText(r[m.from]), to: auditValueText(r[m.to]), hasFrom, hasTo };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** 源数据 -> 审计条目(纯函数,便于单测) */
|
|
143
|
+
export function auditEntriesOf(data: unknown, mapRaw: unknown, order: string, timeFormat = '', locale = ''): KitAuditEntry[] {
|
|
144
|
+
const m = keyMap(KIT_AUDIT_LOG_DEFAULT_MAP, mapRaw);
|
|
145
|
+
const indexed = rowsOf(data).map((raw, i) => ({ raw, i }));
|
|
146
|
+
if (order === 'asc' || order === 'desc') {
|
|
147
|
+
indexed.sort((a, b) => {
|
|
148
|
+
const c = compareTime(a.raw[m.time], b.raw[m.time]);
|
|
149
|
+
return (order === 'asc' ? c : -c) || a.i - b.i;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return indexed.map(({ raw, i }) => {
|
|
153
|
+
const id = raw[m.id];
|
|
154
|
+
const time = raw[m.time];
|
|
155
|
+
const listed = Array.isArray(raw[m.changes]) ? (raw[m.changes] as unknown[]) : [];
|
|
156
|
+
const changes = listed.map((c) => changeOf(c, m)).filter((c): c is KitAuditChange => c !== null);
|
|
157
|
+
if (changes.length === 0) {
|
|
158
|
+
const one = changeOf(raw, m);
|
|
159
|
+
if (one) changes.push(one);
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
key: id === undefined || id === null || id === '' ? `a${i}` : String(id),
|
|
163
|
+
time: time === undefined || time === null || time === '' ? '' : formatValue(time, timeFormat, locale),
|
|
164
|
+
actor: textOf(raw[m.actor]),
|
|
165
|
+
avatar: textOf(raw[m.avatar]),
|
|
166
|
+
action: textOf(raw[m.action]),
|
|
167
|
+
target: textOf(raw[m.target]),
|
|
168
|
+
changes,
|
|
169
|
+
result: resultOf(raw[m.result]),
|
|
170
|
+
source: textOf(raw[m.source]),
|
|
171
|
+
sensitive: sensitiveOf(raw[m.sensitive]),
|
|
172
|
+
day: dayNumOf(time),
|
|
173
|
+
iso: typeof time === 'string' && time !== '' && Number.isFinite(Date.parse(time)) ? time : '',
|
|
174
|
+
raw,
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function createAuditLog(): SomaComponentDefinition {
|
|
180
|
+
return {
|
|
181
|
+
contract: {
|
|
182
|
+
name: 'AuditLog',
|
|
183
|
+
layer: 'data',
|
|
184
|
+
props: {
|
|
185
|
+
data: { type: 'array', default: [], desc: '事件 [{ id, time, actor, avatar?, action?, target?, changes?: [{ field, from, to }], field?, from?, to? }];单字段变更可把 field / from / to 直接写在事件上' },
|
|
186
|
+
map: { type: 'object', default: {}, desc: '键名对照:id / time / actor / avatar / action / target / changes / field / from / to -> 数据里的键' },
|
|
187
|
+
order: { type: 'enum', values: ['none', 'asc', 'desc'], default: 'none', desc: '按 time 排序;none 保持给定顺序' },
|
|
188
|
+
selectable: { type: 'boolean', default: false, desc: '事件可点(按钮),点击抛 select(时间线形态)' },
|
|
189
|
+
variant: { type: 'enum', values: ['timeline', 'table'], default: 'timeline', desc: 'timeline = 竖轴时间线(缺省,对象详情内的变更记录);table = 表格(时间 / 操作人 / 动作 / 对象 / 结果 / 来源,变更行可展开)' },
|
|
190
|
+
collapse_changes: { type: 'boolean', default: false, desc: '变更差异折叠在下,「展开 N 处变更」可展开(aria-expanded);缺省全部展开(table 形态恒折叠)' },
|
|
191
|
+
group_by_day: { type: 'boolean', default: false, desc: '时间线形态按天分组:日期变化处插入日期分组头(今天 / 昨天 / 具体日期)' },
|
|
192
|
+
today: { type: 'string', default: '', desc: '今天 YYYY-MM-DD;给了才有「今天 / 昨天」分组头' },
|
|
193
|
+
today_text: { type: 'string', default: '', desc: '今天分组头文案' },
|
|
194
|
+
yesterday_text: { type: 'string', default: '', desc: '昨天分组头文案' },
|
|
195
|
+
immutable_hint: { type: 'boolean', default: false, desc: '页头一行「记录不可修改」弱化说明' },
|
|
196
|
+
export_text: { type: 'string', default: '', desc: '非空则工具条右侧出「导出」钮(文字取此值),点击抛 export;筛选由页面级条带承担' },
|
|
197
|
+
filtered: { type: 'boolean', default: false, desc: '当前有筛选条件:无记录时显示「没有符合条件的记录」而非「暂无记录」' },
|
|
198
|
+
has_more: { type: 'boolean', default: false, desc: '还有更多:末尾画「加载更多」文字钮,点击抛 load_more' },
|
|
199
|
+
load_more_text: { type: 'string', default: '', desc: '加载更多钮文字,空取缺省文案' },
|
|
200
|
+
action_text: { type: 'string', default: '', desc: '事件未给 action 时的动词;空则「修改了」' },
|
|
201
|
+
empty_value_text: { type: 'string', default: '', desc: '空值的占位文案;空则「(空)」' },
|
|
202
|
+
time_format: { type: 'string', default: '', desc: 'time 的格式化写法(datetime / date / relative 等,取 soma-foundation/values);空则原样' },
|
|
203
|
+
locale: { type: 'string', default: '', desc: '格式化语言;空则 zh-CN' },
|
|
204
|
+
empty_text: { type: 'string', default: '', desc: '无数据时的文案' },
|
|
205
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
206
|
+
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
207
|
+
},
|
|
208
|
+
emits: {
|
|
209
|
+
select: { payload: { item: { type: 'object' } }, desc: '点某一条事件(selectable 时);item 是源数据里的原对象' },
|
|
210
|
+
export: { payload: {}, desc: '点工具条「导出」(export_text 非空时)' },
|
|
211
|
+
load_more: { payload: {}, desc: '点末尾「加载更多」(has_more 时)' },
|
|
212
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
templateHtml: `<ol data-soma-id="root" role="list" class="${ROOT_CLASS}"></ol>`,
|
|
216
|
+
controllerFactory: createKitController(() => {
|
|
217
|
+
const expandedKeys = new Set<string>();
|
|
218
|
+
return {
|
|
219
|
+
attach(root, api) {
|
|
220
|
+
const onClick = (event: Event): void => {
|
|
221
|
+
const target = event.target as HTMLElement | null;
|
|
222
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_LOAD_MORE))) { api.emit('load_more', {}); return; }
|
|
223
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_EXPORT))) { api.emit('export', {}); return; }
|
|
224
|
+
// 差异折叠 / 展开:就地切 hidden 与 aria-expanded,并在闭包 Set 持久化已展开键(点「加载更多」重绘不丢)
|
|
225
|
+
const fold = target?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_FOLD));
|
|
226
|
+
if (fold) {
|
|
227
|
+
const foldKey = fold.getAttribute(KIT_ATTR_FOLD) ?? '';
|
|
228
|
+
const panel = root.querySelector<HTMLElement>(`[id="${attrEsc(fold.getAttribute('aria-controls') ?? '')}"]`);
|
|
229
|
+
const open = fold.getAttribute('aria-expanded') !== 'true';
|
|
230
|
+
if (foldKey !== '') {
|
|
231
|
+
if (open) expandedKeys.add(foldKey);
|
|
232
|
+
else expandedKeys.delete(foldKey);
|
|
233
|
+
}
|
|
234
|
+
fold.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
235
|
+
if (panel) panel.hidden = !open;
|
|
236
|
+
fold.textContent = open ? kitText('soma.kit.collapse', undefined, root) : fold.getAttribute(KIT_ATTR_FOLD_LABEL) ?? '';
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const hit = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PICK));
|
|
240
|
+
if (!hit) return;
|
|
241
|
+
const p = api.props();
|
|
242
|
+
const entry = auditEntriesOf(p.data, p.map, str(p.order, 'none')).find((e) => e.key === hit.getAttribute(KIT_ATTR_PICK));
|
|
243
|
+
if (entry) api.emit('select', { item: entry.raw });
|
|
244
|
+
};
|
|
245
|
+
root.addEventListener('click', onClick);
|
|
246
|
+
return () => root.removeEventListener('click', onClick);
|
|
247
|
+
},
|
|
248
|
+
render(root, p, api) {
|
|
249
|
+
root.className = joinClass(ROOT_CLASS, p.class);
|
|
250
|
+
root.textContent = '';
|
|
251
|
+
const entries = auditEntriesOf(p.data, p.map, str(p.order, 'none'), str(p.time_format), str(p.locale));
|
|
252
|
+
// 数据状态自报:读同 applyKitReadState 的 loading / error_text,外加有没有记录(审计日志本身不可改,但它不是可编辑组件的只读态,不报 readonly)
|
|
253
|
+
kitMarkDataFacts(root, { loading: p.loading === true || p.loading === 'true', error: str(p.error_text) !== '', empty: entries.length === 0 });
|
|
254
|
+
if (applyKitReadState(root, p, { hasContent: entries.length > 0, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) return;
|
|
255
|
+
// 工具条(导出)与不可变提示:页头一行,弱化文字、非提示条
|
|
256
|
+
const exportText = str(p.export_text);
|
|
257
|
+
if (exportText !== '' || bool(p.immutable_hint)) {
|
|
258
|
+
const bar = mk('li', TOOLBAR_CLASS);
|
|
259
|
+
bar.setAttribute(KIT_ATTR_PART, 'audit-toolbar');
|
|
260
|
+
// 页头一行的导出与提示 = 面头(部件位保留存量 audit-toolbar)
|
|
261
|
+
kitMarkLevel(bar, 'head'); kitApplyLevelClass(bar);
|
|
262
|
+
bar.appendChild(mk('span', HINT_CLASS, bool(p.immutable_hint) ? kitText('soma.kit.al_immutable', undefined, root) : ''));
|
|
263
|
+
if (exportText !== '') {
|
|
264
|
+
const btn = mk('button', EXPORT_BUTTON_CLASS, exportText);
|
|
265
|
+
btn.type = 'button';
|
|
266
|
+
btn.setAttribute(KIT_ATTR_EXPORT, '');
|
|
267
|
+
kitMarkPart(btn, 'action');
|
|
268
|
+
bar.appendChild(btn);
|
|
269
|
+
}
|
|
270
|
+
root.appendChild(bar);
|
|
271
|
+
}
|
|
272
|
+
if (entries.length === 0) {
|
|
273
|
+
// 空态分两种:有筛选条件而无结果 / 本就没有记录
|
|
274
|
+
const none = bool(p.filtered) ? kitText('soma.kit.al_no_match', undefined, root) : kitText('soma.kit.tl_empty', undefined, root);
|
|
275
|
+
root.appendChild(emptyNode(str(p.empty_text, none)));
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const defaultAction = str(p.action_text, kitText('soma.kit.al_changed', undefined, root));
|
|
279
|
+
const emptyValue = str(p.empty_value_text, kitText('soma.kit.al_empty_value', undefined, root));
|
|
280
|
+
const valueNode = (cls: string, has: boolean, text: string): HTMLElement =>
|
|
281
|
+
has && text !== '' ? mk('span', cls, text) : mk('span', `${cls} ${EMPTY_VALUE_CLASS}`, emptyValue);
|
|
282
|
+
const moreRow = (): void => {
|
|
283
|
+
if (!bool(p.has_more)) return;
|
|
284
|
+
const more = mk('li', MORE_ROW_CLASS);
|
|
285
|
+
more.setAttribute(KIT_ATTR_PART, 'audit-more');
|
|
286
|
+
kitMarkLevel(more, 'foot'); kitApplyLevelClass(more);
|
|
287
|
+
const btn = mk('button', MORE_BUTTON_CLASS, str(p.load_more_text, kitText('soma.kit.load_more', undefined, root)));
|
|
288
|
+
btn.type = 'button';
|
|
289
|
+
btn.setAttribute(KIT_ATTR_LOAD_MORE, '');
|
|
290
|
+
more.appendChild(btn);
|
|
291
|
+
root.appendChild(more);
|
|
292
|
+
};
|
|
293
|
+
let seq = 0;
|
|
294
|
+
// 结果与敏感动作:状态标记(圆点 + 语义色文字、图标 + 文字,不只靠颜色);成功不画
|
|
295
|
+
const markNode = (tone: ShapeTone, label: string): HTMLElement => {
|
|
296
|
+
const mark = mk('span', RESULT_MARK_CLASS(tone));
|
|
297
|
+
mark.append(mk('span', `${KIT_STATUS_DOT_CLASS} ${TONE_DOT[tone]}`), label);
|
|
298
|
+
kitMarkPart(mark, 'status');
|
|
299
|
+
return mark;
|
|
300
|
+
};
|
|
301
|
+
const resultMark = (e: KitAuditEntry): HTMLElement | null => {
|
|
302
|
+
if (e.result === 'success') return null;
|
|
303
|
+
const mark = markNode(RESULT_TONE[e.result], kitText(e.result === 'failure' ? 'soma.kit.al_failure' : 'soma.kit.al_denied', undefined, root));
|
|
304
|
+
mark.setAttribute(KIT_ATTR_RESULT, e.result);
|
|
305
|
+
return mark;
|
|
306
|
+
};
|
|
307
|
+
const timeNode = (cls: string, e: KitAuditEntry): HTMLElement => {
|
|
308
|
+
const el = mk('time', cls, e.time);
|
|
309
|
+
if (e.iso !== '') el.setAttribute('datetime', e.iso);
|
|
310
|
+
return el;
|
|
311
|
+
};
|
|
312
|
+
const changeList = (e: KitAuditEntry): HTMLElement => {
|
|
313
|
+
const list = mk('ul', CHANGES_CLASS);
|
|
314
|
+
list.setAttribute('role', 'list');
|
|
315
|
+
for (const c of e.changes) {
|
|
316
|
+
const row = mk('li', CHANGE_CLASS);
|
|
317
|
+
if (c.field !== '') { const name = mk('span', FIELD_CLASS, c.field); kitMarkPart(name, 'field-name'); row.appendChild(name); }
|
|
318
|
+
row.appendChild(valueNode(FROM_CLASS, c.hasFrom, c.from));
|
|
319
|
+
const arrow = mk('span', ARROW_CLASS);
|
|
320
|
+
arrow.appendChild(kitIcon('arrow-right', 'xs', 'rtl:-scale-x-100')); // 图标一律 SVG,不用字符(R5);rtl 下镜像
|
|
321
|
+
arrow.setAttribute('aria-hidden', 'true');
|
|
322
|
+
row.appendChild(arrow);
|
|
323
|
+
row.appendChild(valueNode(TO_CLASS, c.hasTo, c.to));
|
|
324
|
+
list.appendChild(row);
|
|
325
|
+
}
|
|
326
|
+
return list;
|
|
327
|
+
};
|
|
328
|
+
// 折叠钮 + 差异块:钮带 aria-expanded / aria-controls,已展开键重绘时自动恢复
|
|
329
|
+
const foldedChanges = (e: KitAuditEntry): HTMLElement[] => {
|
|
330
|
+
seq += 1;
|
|
331
|
+
const id = `soma-audit-${seq}-${e.key}`;
|
|
332
|
+
const label = kitText('soma.kit.al_expand_n', { n: e.changes.length }, root);
|
|
333
|
+
const isOpen = expandedKeys.has(e.key);
|
|
334
|
+
const btn = mk('button', FOLD_BUTTON_CLASS, isOpen ? kitText('soma.kit.collapse', undefined, root) : label);
|
|
335
|
+
btn.type = 'button';
|
|
336
|
+
btn.setAttribute(KIT_ATTR_FOLD, e.key);
|
|
337
|
+
kitMarkPart(btn, 'action');
|
|
338
|
+
btn.setAttribute(KIT_ATTR_FOLD_LABEL, label);
|
|
339
|
+
btn.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
|
340
|
+
btn.setAttribute('aria-controls', id);
|
|
341
|
+
const panel = changeList(e);
|
|
342
|
+
panel.id = id;
|
|
343
|
+
panel.hidden = !isOpen;
|
|
344
|
+
return [btn, panel];
|
|
345
|
+
};
|
|
346
|
+
const detailed = (e: KitAuditEntry): boolean => e.changes.length > 0;
|
|
347
|
+
if (str(p.variant) === 'table') {
|
|
348
|
+
const wrap = mk('li', '');
|
|
349
|
+
wrap.setAttribute('role', 'presentation');
|
|
350
|
+
const table = mk('table', TABLE_CLASS);
|
|
351
|
+
const cols = ['time', 'actor', 'action', 'target', 'result', 'source'] as const;
|
|
352
|
+
const head = mk('thead', '');
|
|
353
|
+
const hr = mk('tr', '');
|
|
354
|
+
// 表格形态:表头行 = 面头,表头格 = 字段名
|
|
355
|
+
kitMarkLevel(hr, 'head'); kitApplyLevelClass(hr);
|
|
356
|
+
for (const c of cols) {
|
|
357
|
+
const colKey = {
|
|
358
|
+
time: 'soma.kit.al_col_time', actor: 'soma.kit.al_col_actor', action: 'soma.kit.al_col_action',
|
|
359
|
+
target: 'soma.kit.al_col_target', result: 'soma.kit.al_col_result', source: 'soma.kit.al_col_source',
|
|
360
|
+
} as const;
|
|
361
|
+
const th = mk('th', COLUMN_HEADER_CLASS, kitText(colKey[c], undefined, root));
|
|
362
|
+
th.setAttribute('scope', 'col');
|
|
363
|
+
kitMarkPart(th, 'field-name');
|
|
364
|
+
hr.appendChild(th);
|
|
365
|
+
}
|
|
366
|
+
head.appendChild(hr);
|
|
367
|
+
table.appendChild(head);
|
|
368
|
+
const body = mk('tbody', '');
|
|
369
|
+
for (const e of entries) {
|
|
370
|
+
const tr = mk('tr', '');
|
|
371
|
+
tr.setAttribute(KIT_ATTR_ENTRY, e.key);
|
|
372
|
+
tr.setAttribute('data-result', e.result);
|
|
373
|
+
kitMarkLevel(tr, 'item', 'line'); kitApplyLevelClass(tr);
|
|
374
|
+
const td = (cls: string, ...kids: Array<Node | string>): HTMLElement => { const c = mk('td', cls); c.append(...kids); kitMarkPart(c, 'cell'); return c; };
|
|
375
|
+
tr.appendChild(td(TD_TIME_CLASS, timeNode('', e)));
|
|
376
|
+
const actorCell = mk('div', ACTOR_CELL_CLASS);
|
|
377
|
+
actorCell.append(avatarNode(e.actor || '?', e.avatar, 'sm'), mk('span', kitTextFit('name').class, e.actor));
|
|
378
|
+
tr.appendChild(td(TD_CLASS, actorCell));
|
|
379
|
+
const act = e.action !== '' ? e.action : defaultAction;
|
|
380
|
+
tr.appendChild(td(TD_CLASS, e.sensitive !== null ? markNode(e.sensitive, act) : act));
|
|
381
|
+
tr.appendChild(td(TD_NAME_CLASS, e.target));
|
|
382
|
+
const rm = resultMark(e);
|
|
383
|
+
tr.appendChild(td(TD_CLASS, ...(rm ? [rm] : [])));
|
|
384
|
+
tr.appendChild(td(TD_NAME_CLASS, e.source));
|
|
385
|
+
body.appendChild(tr);
|
|
386
|
+
if (detailed(e)) {
|
|
387
|
+
const [btn, panel] = foldedChanges(e) as [HTMLElement, HTMLElement];
|
|
388
|
+
// 展开钮放在动作列,差异块进整行跨列的展开行
|
|
389
|
+
tr.children[2]!.appendChild(btn);
|
|
390
|
+
const dr = mk('tr', '');
|
|
391
|
+
dr.setAttribute(KIT_ATTR_DETAIL_OF, e.key);
|
|
392
|
+
// 行内展开的差异块 = 子块
|
|
393
|
+
kitMarkLevel(dr, 'sub'); kitApplyLevelClass(dr);
|
|
394
|
+
const dtd = mk('td', TD_DETAIL_CLASS);
|
|
395
|
+
dtd.colSpan = cols.length;
|
|
396
|
+
dtd.appendChild(panel);
|
|
397
|
+
dr.appendChild(dtd);
|
|
398
|
+
body.appendChild(dr);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
table.appendChild(body);
|
|
402
|
+
wrap.appendChild(table);
|
|
403
|
+
root.appendChild(wrap);
|
|
404
|
+
moreRow();
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const byDay = bool(p.group_by_day);
|
|
408
|
+
const todayNum = dayNumOf(str(p.today));
|
|
409
|
+
const dayLabel = (day: number | null): string => {
|
|
410
|
+
if (day === null) return kitText('soma.kit.tl_other', undefined, root);
|
|
411
|
+
if (todayNum !== null && day === todayNum) return str(p.today_text, kitText('soma.kit.cal_today', undefined, root));
|
|
412
|
+
if (todayNum !== null && day === todayNum - 1) return str(p.yesterday_text, kitText('soma.kit.tl_yesterday', undefined, root));
|
|
413
|
+
return textOfDayNum(day);
|
|
414
|
+
};
|
|
415
|
+
const selectable = bool(p.selectable);
|
|
416
|
+
// 可点事件整条是按钮,不再嵌折叠钮(按钮里不能套按钮):此时差异保持展开
|
|
417
|
+
const collapse = bool(p.collapse_changes) && !selectable;
|
|
418
|
+
entries.forEach((e, index) => {
|
|
419
|
+
if (byDay && (index === 0 || entries[index - 1]!.day !== e.day)) {
|
|
420
|
+
const dayHead = mk('li', DAY_HEAD_CLASS);
|
|
421
|
+
const rule = (): HTMLElement => { const r = mk('span', DAY_RULE_CLASS); r.setAttribute('aria-hidden', 'true'); return r; };
|
|
422
|
+
dayHead.append(rule(), mk('span', '', dayLabel(e.day)), rule());
|
|
423
|
+
dayHead.setAttribute(KIT_ATTR_DAY, e.day === null ? '' : textOfDayNum(e.day));
|
|
424
|
+
kitMarkLevel(dayHead, 'band'); kitApplyLevelClass(dayHead);
|
|
425
|
+
root.appendChild(dayHead);
|
|
426
|
+
}
|
|
427
|
+
const li = mk('li', ITEM_CLASS);
|
|
428
|
+
li.setAttribute(KIT_ATTR_ENTRY, e.key);
|
|
429
|
+
kitMarkLevel(li, 'item', 'line'); kitApplyLevelClass(li);
|
|
430
|
+
const rail = mk('div', RAIL_CLASS);
|
|
431
|
+
rail.appendChild(avatarNode(e.actor || e.target || '?', e.avatar, 'md'));
|
|
432
|
+
if (index < entries.length - 1) rail.appendChild(mk('span', LINE_CLASS));
|
|
433
|
+
const body = selectable ? mk('button', BODY_BUTTON_CLASS) : mk('div', BODY_CLASS);
|
|
434
|
+
if (body instanceof HTMLButtonElement) {
|
|
435
|
+
body.type = 'button';
|
|
436
|
+
body.setAttribute(KIT_ATTR_PICK, e.key);
|
|
437
|
+
}
|
|
438
|
+
const head = mk('div', HEAD_CLASS);
|
|
439
|
+
if (e.actor !== '') head.appendChild(mk('span', ACTOR_CLASS, e.actor));
|
|
440
|
+
const act = e.action !== '' ? e.action : defaultAction;
|
|
441
|
+
head.appendChild(e.sensitive !== null ? markNode(e.sensitive, act) : mk('span', ACTION_CLASS, act));
|
|
442
|
+
if (e.target !== '') head.appendChild(mk('span', TARGET_CLASS, e.target));
|
|
443
|
+
const rm = resultMark(e);
|
|
444
|
+
if (rm) head.appendChild(rm);
|
|
445
|
+
// 内容首行 = 人 + 动作句 + 右端时间(时间贴行右端)
|
|
446
|
+
if (e.time !== '') head.appendChild(timeNode(TIME_END_CLASS, e));
|
|
447
|
+
body.appendChild(head);
|
|
448
|
+
if (detailed(e)) {
|
|
449
|
+
if (collapse) body.append(...foldedChanges(e));
|
|
450
|
+
else body.appendChild(changeList(e));
|
|
451
|
+
}
|
|
452
|
+
li.appendChild(rail);
|
|
453
|
+
li.appendChild(body);
|
|
454
|
+
root.appendChild(li);
|
|
455
|
+
});
|
|
456
|
+
moreRow();
|
|
457
|
+
},
|
|
458
|
+
};
|
|
459
|
+
}),
|
|
460
|
+
};
|
|
461
|
+
}
|