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
|
@@ -31,12 +31,17 @@
|
|
|
31
31
|
// 每次勾选抛 `change { value, added, removed }`;save_label 非空时底部出现保存钮,抛 `saved`(载荷同对象表单,另带 added / removed);
|
|
32
32
|
// 勾中了「未登记」节点时拒绝保存,抛 `blocked { reason: 'unregistered', ids }`;cancel_label 非空时出现取消钮,抛 `cancel {}` 并还原草稿。
|
|
33
33
|
|
|
34
|
-
import type {
|
|
34
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
35
35
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
36
36
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
37
|
-
import { bool,
|
|
37
|
+
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
38
38
|
import { kitIcon } from '../base/icons';
|
|
39
|
+
import { markCheckBox } from '../base/check-core';
|
|
39
40
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
41
|
+
import { kitControlRecipe, kitTextActionRecipe, setKitFace } from '../recipes';
|
|
42
|
+
import {
|
|
43
|
+
KIT_OVERLAY_FOOT_ATTR, KIT_OVERLAY_FORM_FOOTER_CLASS, KIT_OVERLAY_FORM_SCROLL_ATTR, KIT_OVERLAY_ROOT_FILL_CLASS, kitOverlayFormScrollClass,
|
|
44
|
+
} from '../recipes/overlay';
|
|
40
45
|
import { createKitBusy, KIT_BUSY_PROP_DEFS } from '../base/action-busy';
|
|
41
46
|
import { classTokens, keyMap, mk, recOf } from './shape-util';
|
|
42
47
|
import { KIT_TREE_MAX_DEPTH } from './tree';
|
|
@@ -44,7 +49,8 @@ import { aggregateCheck, nextCheckTarget } from './tree-check';
|
|
|
44
49
|
|
|
45
50
|
// ── 类串表:全部完整写死,不拼接片段 ──
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
// 浮层滚动体里(宿主见 KIT_OVERLAY_FORM_HOST_CLASS)根撑满体高,底栏 mt-auto 落在浮层底部
|
|
53
|
+
const ROOT_CLASS = `flex flex-col gap-3 text-sm text-fg ${KIT_OVERLAY_ROOT_FILL_CLASS}`;
|
|
48
54
|
const HELP_CLASS = 'text-sm text-fg-muted';
|
|
49
55
|
const SUBJECT_CLASS = 'flex flex-wrap items-center gap-4';
|
|
50
56
|
const SUBJECT_ITEM_CLASS = 'flex items-center gap-2';
|
|
@@ -55,25 +61,26 @@ const HEAD_CLASS = 'flex items-center justify-between gap-3';
|
|
|
55
61
|
const TITLE_CLASS = 'text-base font-semibold text-fg';
|
|
56
62
|
const SUMMARY_CLASS = 'text-sm text-fg-muted';
|
|
57
63
|
const CHANGES_CLASS = 'flex flex-wrap items-center gap-2 text-sm text-fg-muted';
|
|
58
|
-
const LINK_CLASS = 'rounded-md px-1 text-sm text-primary transition-colors hover:bg-
|
|
64
|
+
const LINK_CLASS = 'rounded-md px-1 text-sm text-primary-on-soft transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
59
65
|
const DETAIL_CLASS = 'flex flex-col gap-1 rounded-md bg-surface-sunken px-3 py-2 text-sm text-fg';
|
|
60
66
|
const DETAIL_ADDED_CLASS = 'text-success-on-soft';
|
|
61
67
|
const DETAIL_REMOVED_CLASS = 'text-danger-on-soft';
|
|
62
68
|
const TOOLS_CLASS = 'flex flex-wrap items-center gap-2';
|
|
63
69
|
const SEARCH_CLASS = 'block h-9 min-w-40 flex-1 appearance-none autofill-clear rounded-md border border-border bg-surface px-3 text-sm text-fg placeholder:text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
70
|
+
// 展开 / 收起 / 全选 / 清空:文字链接(唯一主按钮是保存),配方 kitTextActionRecipe
|
|
71
|
+
const TOOL_BTN_CLASS = kitTextActionRecipe('primary');
|
|
72
|
+
const TREE_CLASS = 'flex flex-col overflow-hidden rounded-md border border-border-subtle';
|
|
73
|
+
const ROW_BASE_CLASS = 'flex min-h-table-row items-center hit-gap-2 border-b border-border-divider bg-surface pe-2 py-1.5 text-fg last:border-b-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring';
|
|
74
|
+
const ROW_LIVE_CLASS = 'cursor-pointer transition-colors hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
68
75
|
const ROW_LOCKED_CLASS = 'cursor-not-allowed text-fg-subtle';
|
|
69
76
|
const ROW_GROUP_CLASS = 'bg-surface-sunken font-medium';
|
|
70
77
|
const ROW_ADDED_CLASS = 'bg-success-soft text-success-on-soft';
|
|
71
78
|
const ROW_REMOVED_CLASS = 'bg-danger-soft text-danger-on-soft';
|
|
72
79
|
const CURSOR_CLASS = 'ring-1 ring-inset ring-ring';
|
|
73
|
-
const CARET_CLASS = 'w-4 shrink-0 cursor-pointer text-center text-fg-subtle';
|
|
74
|
-
const BOX_OFF_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-border bg-surface text-xs';
|
|
75
|
-
const BOX_ON_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-fg';
|
|
76
|
-
const BOX_MIXED_CLASS = 'inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary-soft text-xs text-primary-on-soft';
|
|
80
|
+
const CARET_CLASS = 'hit-area-row w-4 shrink-0 cursor-pointer text-center text-fg-subtle';
|
|
81
|
+
const BOX_OFF_CLASS = 'relative z-10 inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-border bg-surface text-xs';
|
|
82
|
+
const BOX_ON_CLASS = 'relative z-10 inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary text-xs text-primary-fg';
|
|
83
|
+
const BOX_MIXED_CLASS = 'relative z-10 inline-flex size-4 shrink-0 items-center justify-center rounded-md border border-primary bg-primary-soft text-xs text-primary-on-soft';
|
|
77
84
|
const BOX_LOCKED_CLASS = 'opacity-60';
|
|
78
85
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
79
86
|
const LABEL_CLASS = 'truncate text-sm';
|
|
@@ -86,8 +93,9 @@ const CHIP_STATUS_CLASS = 'bg-surface-sunken text-fg-muted';
|
|
|
86
93
|
const CHIP_WARN_CLASS = 'bg-warning-soft text-warning-on-soft';
|
|
87
94
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
88
95
|
const FOOT_CLASS = 'flex items-center justify-end gap-2 pt-1';
|
|
89
|
-
|
|
90
|
-
const
|
|
96
|
+
// 保存 / 取消(返回)都是标准高度的实心 / 描边按钮(与对话框底栏同一配方),不再一个文字链接一个按钮
|
|
97
|
+
const SAVE_CLASS = kitControlRecipe({ variant: 'primary' });
|
|
98
|
+
const CANCEL_CLASS = kitControlRecipe({ variant: 'neutral' });
|
|
91
99
|
const DEPTH = ['ps-2', 'ps-6', 'ps-10', 'ps-14', 'ps-18', 'ps-22', 'ps-26'] as const;
|
|
92
100
|
|
|
93
101
|
export const KIT_PERMISSION_TREE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
@@ -96,7 +104,7 @@ export const KIT_PERMISSION_TREE_CLASS_CANDIDATES: readonly string[] = classToke
|
|
|
96
104
|
TOOL_BTN_CLASS, TREE_CLASS, ROW_BASE_CLASS, ROW_LIVE_CLASS, ROW_LOCKED_CLASS, ROW_GROUP_CLASS, ROW_ADDED_CLASS, ROW_REMOVED_CLASS,
|
|
97
105
|
CURSOR_CLASS, CARET_CLASS, BOX_OFF_CLASS, BOX_ON_CLASS, BOX_MIXED_CLASS, BOX_LOCKED_CLASS, TEXT_CLASS, LABEL_CLASS, SUB_CLASS,
|
|
98
106
|
CHIPS_CLASS, CHIP_BASE, CHIP_ADDED_CLASS, CHIP_REMOVED_CLASS, CHIP_STATUS_CLASS, CHIP_WARN_CLASS, EMPTY_CLASS, FOOT_CLASS,
|
|
99
|
-
SAVE_CLASS, CANCEL_CLASS, DEPTH, 'hidden', 'flex', 'flex-1',
|
|
107
|
+
SAVE_CLASS, CANCEL_CLASS, KIT_OVERLAY_FORM_FOOTER_CLASS, kitOverlayFormScrollClass('gap-3'), DEPTH, 'hidden', 'flex', 'flex-1',
|
|
100
108
|
);
|
|
101
109
|
|
|
102
110
|
// ── 数据规整与勾选状态机(纯函数,不碰 DOM) ──
|
|
@@ -234,6 +242,8 @@ export function buildPermissionModel(items: unknown, map: KitPermissionTreeMap):
|
|
|
234
242
|
|
|
235
243
|
export interface KitPermSummary {
|
|
236
244
|
count: number;
|
|
245
|
+
/** 已勾选且不可编辑的授权主体数(锁定 / 只读;未登记节点不提交,不计):只用于摘要展示,不进提交载荷 */
|
|
246
|
+
lockedOn: number;
|
|
237
247
|
added: number[];
|
|
238
248
|
removed: number[];
|
|
239
249
|
}
|
|
@@ -317,15 +327,17 @@ export function createPermissionState(model: KitPermModel, value: readonly strin
|
|
|
317
327
|
},
|
|
318
328
|
summary() {
|
|
319
329
|
let count = 0;
|
|
330
|
+
let lockedOn = 0;
|
|
320
331
|
const added: number[] = [];
|
|
321
332
|
const removed: number[] = [];
|
|
322
333
|
for (let i = 0; i < n; i += 1) {
|
|
323
334
|
if (!submittable(i)) continue;
|
|
324
335
|
if (st[i] === 1 && editable[i] === 1) count += 1;
|
|
336
|
+
else if (st[i] === 1 && nodes[i]!.status !== 'unregistered') lockedOn += 1;
|
|
325
337
|
if (base[i] !== 1 && st[i] === 1) added.push(i);
|
|
326
338
|
else if (base[i] === 1 && st[i] !== 1) removed.push(i);
|
|
327
339
|
}
|
|
328
|
-
return { count, added, removed };
|
|
340
|
+
return { count, lockedOn, added, removed };
|
|
329
341
|
},
|
|
330
342
|
submitValue(keep) {
|
|
331
343
|
const out = new Set<string>();
|
|
@@ -370,6 +382,7 @@ const TEXT_KEYS = Object.freeze({
|
|
|
370
382
|
select_all: 'soma.kit.ptree_select_all',
|
|
371
383
|
clear: 'soma.kit.ptree_clear',
|
|
372
384
|
selected: 'soma.kit.ptree_selected',
|
|
385
|
+
selected_locked: 'soma.kit.ptree_selected_locked',
|
|
373
386
|
no_change: 'soma.kit.ptree_no_change',
|
|
374
387
|
changes: 'soma.kit.ptree_changes',
|
|
375
388
|
detail_open: 'soma.kit.ptree_detail_open',
|
|
@@ -427,7 +440,7 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
427
440
|
props: {
|
|
428
441
|
data: { type: 'object', default: {}, desc: '{ items: 节点树, value: 原有已授权标识[], keep?, subject?, error? }' },
|
|
429
442
|
map: { type: 'object', default: {}, desc: '键名对照:组件期望的键 -> 数据里的键' },
|
|
430
|
-
texts: { type: 'object', default: {}, desc: '文案覆盖(search / expand_all / collapse_all / select_all / clear / selected / no_change / changes / added / removed / locked / unregistered / readonly / locked_hint / empty / invalid …)' },
|
|
443
|
+
texts: { type: 'object', default: {}, desc: '文案覆盖(search / expand_all / collapse_all / select_all / clear / selected(占位 {n},可用 {locked})/ selected_locked / no_change / changes / added / removed / locked / unregistered / readonly / locked_hint / empty / invalid …)' },
|
|
431
444
|
title: { type: 'string', default: '', desc: '树标题(右侧是已选摘要)' },
|
|
432
445
|
help: { type: 'string', default: '', desc: '顶部说明' },
|
|
433
446
|
expand_depth: { type: 'number', default: 1, desc: '初始展开层数:0 全部收起,1 根节点展开,大数 = 全部展开' },
|
|
@@ -456,8 +469,8 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
456
469
|
keyboard: { layout: 'tree', wrap: false, typeahead: false, focus_model: 'roving', space: 'toggle_select' },
|
|
457
470
|
},
|
|
458
471
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
459
|
-
controllerFactory: (
|
|
460
|
-
const P = (): Record<string, unknown> =>
|
|
472
|
+
controllerFactory: createKitController((api) => {
|
|
473
|
+
const P = (): Record<string, unknown> => api.props();
|
|
461
474
|
const uid = `kit-ptree-${++instanceCount}`;
|
|
462
475
|
let root: HTMLElement | null = null;
|
|
463
476
|
let model: KitPermModel = { nodes: [], byId: new Map() };
|
|
@@ -483,7 +496,7 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
483
496
|
let saveBtn: HTMLButtonElement; let cancelBtn: HTMLButtonElement;
|
|
484
497
|
let error = '';
|
|
485
498
|
|
|
486
|
-
const T = (): KitPermissionTreeTexts => textsOf(P().texts,
|
|
499
|
+
const T = (): KitPermissionTreeTexts => textsOf(P().texts, api.host);
|
|
487
500
|
const locked = (): boolean => bool(P().disabled);
|
|
488
501
|
const strict = (): boolean => bool(P().strict);
|
|
489
502
|
const mixedAction = (): 'clear' | 'select' => (P().mixed_action === 'select' ? 'select' : 'clear');
|
|
@@ -585,6 +598,7 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
585
598
|
caret.setAttribute('aria-hidden', 'true');
|
|
586
599
|
caret.setAttribute('data-kit-toggle', '');
|
|
587
600
|
const box = mk('span', BOX_OFF_CLASS);
|
|
601
|
+
markCheckBox(box);
|
|
588
602
|
box.setAttribute('aria-hidden', 'true');
|
|
589
603
|
box.setAttribute('data-kit-box', '');
|
|
590
604
|
const text = mk('span', TEXT_CLASS);
|
|
@@ -650,7 +664,13 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
650
664
|
titleEl.textContent = str(p.title);
|
|
651
665
|
titleEl.hidden = str(p.title) === '';
|
|
652
666
|
const sum = state.summary();
|
|
653
|
-
|
|
667
|
+
// 摘要计数含已勾选的锁定节点(只改展示,不改提交载荷);有锁定项且没有自定义 texts.selected 时用「含 m 项固定」文案;
|
|
668
|
+
// 自定义 texts.selected 仍按原样填 {n},另可用 {locked}
|
|
669
|
+
const shownCount = sum.count + sum.lockedOn;
|
|
670
|
+
const customSelected = typeof recOf(P().texts).selected === 'string' && recOf(P().texts).selected !== '';
|
|
671
|
+
summaryEl.textContent = sum.lockedOn > 0 && !customSelected
|
|
672
|
+
? fill(t.selected_locked, { n: shownCount, locked: sum.lockedOn })
|
|
673
|
+
: fill(t.selected, { n: shownCount, locked: sum.lockedOn });
|
|
654
674
|
changesText.textContent = sum.added.length + sum.removed.length === 0 ? t.no_change : fill(t.changes, { added: sum.added.length, removed: sum.removed.length });
|
|
655
675
|
detailBtn.hidden = sum.added.length + sum.removed.length === 0;
|
|
656
676
|
detailBtn.textContent = detailOpen ? t.detail_close : t.detail_open;
|
|
@@ -695,7 +715,7 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
695
715
|
|
|
696
716
|
const emitChange = (): void => {
|
|
697
717
|
const sum = state.summary();
|
|
698
|
-
|
|
718
|
+
api.emit('change', {
|
|
699
719
|
value: state.submitValue(keep),
|
|
700
720
|
added: sum.added.map((i) => model.nodes[i]!.id),
|
|
701
721
|
removed: sum.removed.map((i) => model.nodes[i]!.id),
|
|
@@ -791,10 +811,10 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
791
811
|
if (locked() || error !== '' || busy()) return;
|
|
792
812
|
const bad = state.unsubmittable();
|
|
793
813
|
if (bad.length > 0) {
|
|
794
|
-
const names = bad.map((i) => model.nodes[i]!.label).join(kitText('soma.kit.list_sep', undefined,
|
|
814
|
+
const names = bad.map((i) => model.nodes[i]!.label).join(kitText('soma.kit.list_sep', undefined, api.host));
|
|
795
815
|
notice = fill(T().invalid, { names });
|
|
796
816
|
paintHeader();
|
|
797
|
-
|
|
817
|
+
api.emit('blocked', { reason: 'unregistered', ids: bad.map((i) => model.nodes[i]!.id) });
|
|
798
818
|
return;
|
|
799
819
|
}
|
|
800
820
|
const sum = state.summary();
|
|
@@ -802,7 +822,7 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
802
822
|
const added = sum.added.map((i) => model.nodes[i]!.id);
|
|
803
823
|
const removed = sum.removed.map((i) => model.nodes[i]!.id);
|
|
804
824
|
const body = { value, added, removed };
|
|
805
|
-
|
|
825
|
+
api.emit('saved', { values: body, object: str(P().object), model: body, mode: str(P().mode, 'edit'), value, added, removed });
|
|
806
826
|
};
|
|
807
827
|
|
|
808
828
|
const build = (host: HTMLElement): void => {
|
|
@@ -813,16 +833,18 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
813
833
|
titleEl = mk('h3', TITLE_CLASS);
|
|
814
834
|
summaryEl = mk('span', SUMMARY_CLASS);
|
|
815
835
|
const head = mk('div', HEAD_CLASS);
|
|
816
|
-
head.append(titleEl
|
|
836
|
+
head.append(titleEl);
|
|
817
837
|
changesText = mk('span', '');
|
|
818
838
|
detailBtn = mk('button', LINK_CLASS);
|
|
819
839
|
detailBtn.type = 'button';
|
|
840
|
+
// 「已选择 n 项」与「本次变更」合成一行状态文字
|
|
820
841
|
const changesRow = mk('div', CHANGES_CLASS);
|
|
821
|
-
changesRow.append(changesText, detailBtn);
|
|
842
|
+
changesRow.append(summaryEl, changesText, detailBtn);
|
|
822
843
|
detailBox = mk('div', DETAIL_CLASS);
|
|
823
844
|
changesBox = mk('div', '');
|
|
824
845
|
changesBox.append(changesRow, detailBox);
|
|
825
846
|
search = mk('input', SEARCH_CLASS);
|
|
847
|
+
setKitFace(search, 'field');
|
|
826
848
|
search.type = 'search';
|
|
827
849
|
search.setAttribute('autocomplete', 'off');
|
|
828
850
|
searchBox = boxOf(search);
|
|
@@ -840,13 +862,21 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
840
862
|
treeEl.setAttribute('role', 'tree');
|
|
841
863
|
cancelBtn = mk('button', CANCEL_CLASS); cancelBtn.type = 'button';
|
|
842
864
|
saveBtn = mk('button', SAVE_CLASS); saveBtn.type = 'button';
|
|
865
|
+
setKitFace(saveBtn, 'raised');
|
|
843
866
|
cancelBox = boxOf(cancelBtn);
|
|
844
867
|
saveBox = boxOf(saveBtn);
|
|
845
868
|
const foot = mk('div', FOOT_CLASS);
|
|
846
869
|
foot.append(cancelBox, saveBox);
|
|
847
870
|
footBox = boxOf(foot);
|
|
871
|
+
// 浮层滚动体里底栏吸底并贴着浮层底边(外包层是 sticky 元素;变体只在 group-data-kit-overlay-scroll 祖先下生效)
|
|
872
|
+
footBox.className = KIT_OVERLAY_FORM_FOOTER_CLASS;
|
|
873
|
+
// 滚动区(底栏之外的内容):页面级 contents、浮层里 flex-1 min-h-0 overflow-y-auto;底栏在它之外,不随内容滚动
|
|
874
|
+
const scrollArea = mk('div', kitOverlayFormScrollClass('gap-3'));
|
|
875
|
+
scrollArea.setAttribute(KIT_OVERLAY_FORM_SCROLL_ATTR, '');
|
|
876
|
+
scrollArea.append(helpEl, subjectEl, alertEl, head, changesBox, toolsBox, treeEl);
|
|
877
|
+
footBox.setAttribute(KIT_OVERLAY_FOOT_ATTR, '');
|
|
848
878
|
host.textContent = '';
|
|
849
|
-
host.append(
|
|
879
|
+
host.append(scrollArea, footBox);
|
|
850
880
|
|
|
851
881
|
const on = (target: HTMLElement, type: string, fn: (event: Event) => void): void => {
|
|
852
882
|
target.addEventListener(type, fn);
|
|
@@ -882,35 +912,32 @@ export function createPermissionTree(): SomaComponentDefinition {
|
|
|
882
912
|
state.reset();
|
|
883
913
|
notice = '';
|
|
884
914
|
afterChange();
|
|
885
|
-
|
|
915
|
+
api.emit('cancel', {});
|
|
886
916
|
});
|
|
887
917
|
};
|
|
888
918
|
|
|
889
919
|
return {
|
|
890
|
-
|
|
891
|
-
root =
|
|
920
|
+
attach(rootEl) {
|
|
921
|
+
root = rootEl;
|
|
892
922
|
build(root);
|
|
893
|
-
sync();
|
|
894
|
-
renderTree();
|
|
895
|
-
paintHeader();
|
|
896
923
|
kb.subscribe(() => { if (root) paintHeader(); });
|
|
924
|
+
return () => {
|
|
925
|
+
kb.dispose();
|
|
926
|
+
for (const fn of removers) fn();
|
|
927
|
+
removers = [];
|
|
928
|
+
rowEls = new Map();
|
|
929
|
+
root = null;
|
|
930
|
+
};
|
|
897
931
|
},
|
|
898
|
-
|
|
899
|
-
|
|
932
|
+
render(rootEl) {
|
|
933
|
+
root = rootEl;
|
|
900
934
|
const before = sig;
|
|
901
935
|
sync();
|
|
902
936
|
if (sig !== before) renderTree();
|
|
903
937
|
paintHeader();
|
|
904
938
|
if (sig === before) patchRows();
|
|
905
939
|
},
|
|
906
|
-
onUnmount(): void {
|
|
907
|
-
kb.dispose();
|
|
908
|
-
for (const fn of removers) fn();
|
|
909
|
-
removers = [];
|
|
910
|
-
rowEls = new Map();
|
|
911
|
-
root = null;
|
|
912
|
-
},
|
|
913
940
|
};
|
|
914
|
-
},
|
|
941
|
+
}),
|
|
915
942
|
};
|
|
916
943
|
}
|
|
@@ -13,6 +13,8 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
13
13
|
import { createKitController, joinClass, str, type KitView } from '../base/shared';
|
|
14
14
|
import { kitIcon } from '../base/icons';
|
|
15
15
|
import { kitText } from '../i18n/kit-text';
|
|
16
|
+
import { setKitFace } from '../recipes';
|
|
17
|
+
import { markKitSlot, markKitSlotGrid } from '../recipes/slot-align';
|
|
16
18
|
import { classTokens, emptyNode, mk, recOf, rowsOf, textOf, type Rec } from './shape-util';
|
|
17
19
|
import { singleOf } from './display-util';
|
|
18
20
|
import { attrEsc } from './d9-util';
|
|
@@ -23,9 +25,13 @@ const ROOT_CLASS = '@container flex flex-col gap-5 text-fg';
|
|
|
23
25
|
const CYCLES_CLASS = 'mx-auto inline-flex items-center gap-1 rounded-lg bg-surface-sunken p-1';
|
|
24
26
|
const CYCLE_CLASS = 'inline-flex h-8 items-center gap-1 rounded-md px-3 text-sm font-medium text-fg-muted transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-kit-selected:bg-surface data-kit-selected:text-fg data-kit-selected:shadow-sm';
|
|
25
27
|
const NOTE_CLASS = 'rounded-full bg-success-soft px-1.5 text-xs font-medium text-success-on-soft';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
28
|
+
// 卡片三槽对齐(宽档间距 comfortable,真源 structure.slotAlign.slotGapTiers):卡片是父 grid 的直接子节点,显示方式(subgrid / 不支持时 flex 纵向)与槽间距由结构 CSS 给,
|
|
29
|
+
// 所以卡片类里不写 flex / gap,父 grid 的行距也交给结构 CSS(只写列距 gap-x-4);三槽 = 标题(名称 + 说明)/ 指标(价格)/ 操作(功能列表 + 按钮)
|
|
30
|
+
const GRID_CLASS = 'grid grid-cols-1 gap-x-4 @md:grid-cols-2 @xl:grid-cols-3';
|
|
31
|
+
const CARD_CLASS = 'relative rounded-lg border border-border-subtle bg-surface p-5';
|
|
32
|
+
const CARD_RECOMMENDED_CLASS = 'relative rounded-lg border border-primary bg-surface p-5 shadow-md ring-1 ring-primary';
|
|
33
|
+
const SLOT_TITLE_CLASS = 'flex flex-col gap-4';
|
|
34
|
+
const SLOT_ACTION_CLASS = 'flex flex-1 flex-col gap-4';
|
|
29
35
|
const BADGE_CLASS = 'absolute end-4 top-4 rounded-full bg-primary-soft px-2 py-0.5 text-xs font-medium text-primary-on-soft';
|
|
30
36
|
const NAME_CLASS = 'text-lg font-semibold text-fg';
|
|
31
37
|
const DESC_CLASS = 'text-sm text-fg-muted';
|
|
@@ -39,10 +45,10 @@ const TICK_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center roun
|
|
|
39
45
|
const CROSS_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-sunken text-xs text-fg-subtle';
|
|
40
46
|
const VALUE_CLASS = 'ms-auto shrink-0 text-fg-muted';
|
|
41
47
|
const ACTION_CLASS = 'inline-flex h-10 items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-fg transition-colors hover:bg-primary-hover active:bg-primary-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
42
|
-
const ACTION_PLAIN_CLASS = 'inline-flex h-10 items-center justify-center rounded-md border border-
|
|
48
|
+
const ACTION_PLAIN_CLASS = 'inline-flex h-10 items-center justify-center rounded-md border border-button-edge bg-surface px-4 text-sm font-medium text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60';
|
|
43
49
|
|
|
44
50
|
export const KIT_PRICING_TABLE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
45
|
-
ROOT_CLASS, CYCLES_CLASS, CYCLE_CLASS, NOTE_CLASS, GRID_CLASS, CARD_CLASS, CARD_RECOMMENDED_CLASS, BADGE_CLASS, NAME_CLASS,
|
|
51
|
+
ROOT_CLASS, CYCLES_CLASS, CYCLE_CLASS, NOTE_CLASS, GRID_CLASS, CARD_CLASS, CARD_RECOMMENDED_CLASS, SLOT_TITLE_CLASS, SLOT_ACTION_CLASS, BADGE_CLASS, NAME_CLASS,
|
|
46
52
|
DESC_CLASS, PRICE_ROW_CLASS, PRICE_CLASS, PERIOD_CLASS, FEATURES_CLASS, FEATURE_CLASS, FEATURE_OFF_CLASS, TICK_CLASS,
|
|
47
53
|
CROSS_CLASS, VALUE_CLASS, ACTION_CLASS, ACTION_PLAIN_CLASS,
|
|
48
54
|
);
|
|
@@ -135,7 +141,6 @@ const stateOf = (root: HTMLElement): State => {
|
|
|
135
141
|
};
|
|
136
142
|
|
|
137
143
|
export function createPricingTable(): SomaComponentDefinition {
|
|
138
|
-
let self: KitView;
|
|
139
144
|
return {
|
|
140
145
|
contract: {
|
|
141
146
|
name: 'PricingTable',
|
|
@@ -157,8 +162,10 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
157
162
|
},
|
|
158
163
|
},
|
|
159
164
|
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
160
|
-
controllerFactory: createKitController(
|
|
161
|
-
|
|
165
|
+
controllerFactory: createKitController((api) => {
|
|
166
|
+
let self: KitView;
|
|
167
|
+
return (self = {
|
|
168
|
+
attach(root) {
|
|
162
169
|
const s = stateOf(root);
|
|
163
170
|
const onClick = (event: Event): void => {
|
|
164
171
|
const t = event.target as HTMLElement | null;
|
|
@@ -171,6 +178,7 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
171
178
|
for (const el of Array.from(root.querySelectorAll<HTMLElement>('[data-kit-cycle]'))) {
|
|
172
179
|
const on = el.getAttribute('data-kit-cycle') === key;
|
|
173
180
|
if (on) el.setAttribute('data-kit-selected', ''); else el.removeAttribute('data-kit-selected');
|
|
181
|
+
setKitFace(el, on ? 'raised' : null);
|
|
174
182
|
el.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
175
183
|
}
|
|
176
184
|
// 价格文案随周期换:整体重绘(周期条与卡片都在 render 里画)
|
|
@@ -220,6 +228,7 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
220
228
|
const on = c.key === s.cycle;
|
|
221
229
|
btn.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
222
230
|
if (on) btn.setAttribute('data-kit-selected', '');
|
|
231
|
+
setKitFace(btn, on ? 'raised' : null); // 选中的周期钮才有底色 + shadow-sm(分段滑块式),未选中透明无面
|
|
223
232
|
btn.appendChild(mk('span', '', c.label));
|
|
224
233
|
if (c.note !== '') btn.appendChild(mk('span', NOTE_CLASS, c.note));
|
|
225
234
|
bar.appendChild(btn);
|
|
@@ -228,17 +237,20 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
228
237
|
}
|
|
229
238
|
const current = textOf(src.current_key);
|
|
230
239
|
const grid = mk('div', GRID_CLASS);
|
|
240
|
+
markKitSlotGrid(grid, 3, 'comfortable');
|
|
231
241
|
for (const plan of plans) {
|
|
232
242
|
const isCurrent = current !== '' && plan.key === current;
|
|
233
243
|
const card = mk('article', plan.recommended ? CARD_RECOMMENDED_CLASS : CARD_CLASS);
|
|
234
244
|
card.setAttribute('data-kit-plan', plan.key);
|
|
235
245
|
const badge = isCurrent ? str(p.current_text, kitText('soma.kit.pt_current', undefined, root)) : plan.badge;
|
|
236
246
|
if (badge !== '') card.appendChild(mk('span', BADGE_CLASS, badge));
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
const head = markKitSlot(mk('div', SLOT_TITLE_CLASS), 'title');
|
|
248
|
+
head.appendChild(mk('h3', NAME_CLASS, plan.name));
|
|
249
|
+
if (plan.desc !== '') head.appendChild(mk('p', DESC_CLASS, plan.desc));
|
|
250
|
+
card.appendChild(head);
|
|
239
251
|
const price = plan.prices ? pricingTextFor(plan.prices, s.cycle) : plan.price;
|
|
240
252
|
const period = plan.periods ? pricingTextFor(plan.periods, s.cycle) : plan.period;
|
|
241
|
-
const row = mk('div', PRICE_ROW_CLASS);
|
|
253
|
+
const row = markKitSlot(mk('div', PRICE_ROW_CLASS), 'metric');
|
|
242
254
|
row.appendChild(mk('span', PRICE_CLASS, price));
|
|
243
255
|
if (period !== '') row.appendChild(mk('span', PERIOD_CLASS, period));
|
|
244
256
|
card.appendChild(row);
|
|
@@ -254,16 +266,20 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
254
266
|
if (f.kind === 'value') li.appendChild(mk('span', VALUE_CLASS, f.value));
|
|
255
267
|
ul.appendChild(li);
|
|
256
268
|
}
|
|
257
|
-
|
|
258
|
-
|
|
269
|
+
const foot = markKitSlot(mk('div', SLOT_ACTION_CLASS), 'action');
|
|
270
|
+
foot.appendChild(ul);
|
|
271
|
+
const btn =mk('button', plan.recommended ? ACTION_CLASS : ACTION_PLAIN_CLASS, plan.actionText || str(p.action_text, kitText('soma.kit.pt_choose', undefined, root)));
|
|
259
272
|
btn.type = 'button';
|
|
273
|
+
setKitFace(btn, 'raised');
|
|
260
274
|
btn.setAttribute('data-kit-plan-action', plan.key);
|
|
261
275
|
if (isCurrent || plan.disabled) { btn.disabled = true; btn.setAttribute('aria-disabled', 'true'); }
|
|
262
|
-
|
|
276
|
+
foot.appendChild(btn);
|
|
277
|
+
card.appendChild(foot);
|
|
263
278
|
grid.appendChild(card);
|
|
264
279
|
}
|
|
265
280
|
root.appendChild(grid);
|
|
266
281
|
},
|
|
282
|
+
});
|
|
267
283
|
}),
|
|
268
284
|
};
|
|
269
285
|
}
|