soma-kit 0.1.13 → 0.1.15
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/package.json +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/spec/generated/kit-app.schema.json +18 -2
- package/spec/generated/kit-page.schema.json +95 -0
- package/spec/kit-grammar.json +332 -75
- package/spec/kit-grammar.schema.json +1 -27
- package/src/app/app-config.ts +11 -5
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +82 -10
- package/src/app/define-kit-app.ts +6 -5
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +20 -8
- package/src/app/kit-view-context.ts +30 -4
- package/src/app/server-pages.ts +5 -1
- package/src/app/server.ts +15 -5
- package/src/app/theme-endpoint.ts +1 -1
- package/src/app/theme-runtime.ts +7 -2
- package/src/base/alert.ts +23 -20
- package/src/base/anchored-layer.ts +1 -1
- package/src/base/button.ts +34 -17
- package/src/base/cascader.ts +8 -4
- package/src/base/check-core.ts +9 -6
- package/src/base/color-picker.ts +10 -6
- package/src/base/command-palette.ts +10 -4
- package/src/base/context-menu.ts +5 -2
- package/src/base/date-range.ts +9 -6
- package/src/base/date.ts +10 -6
- package/src/base/delta.ts +4 -2
- package/src/base/divider.ts +15 -66
- package/src/base/end-edge.ts +14 -2
- package/src/base/fab.ts +11 -6
- package/src/base/gap-value.ts +25 -5
- package/src/base/hint-tips.ts +1 -1
- package/src/base/illustrations.ts +2 -1
- package/src/base/index.ts +20 -4
- package/src/base/inline-error.ts +84 -0
- package/src/base/input.ts +54 -18
- package/src/base/kbd.ts +4 -3
- package/src/base/link.ts +1 -1
- package/src/base/listbox-core.ts +70 -22
- package/src/base/mentions.ts +6 -3
- package/src/base/menu-button.ts +73 -50
- package/src/base/menu-core.ts +9 -2
- package/src/base/motion/hover-3d.ts +4 -1
- package/src/base/motion/hover-gallery.ts +4 -1
- package/src/base/otp.ts +7 -3
- package/src/base/overlay-runtime.ts +3 -2
- package/src/base/overlay-shell.ts +141 -0
- package/src/base/popover.ts +7 -6
- package/src/base/popup.ts +47 -41
- package/src/base/qty-stepper.ts +14 -9
- package/src/base/reason-tip.ts +2 -2
- package/src/{frames → base}/resize-handle.ts +1 -1
- package/src/base/segmented.ts +44 -35
- package/src/base/select.ts +1 -0
- package/src/base/shared.ts +52 -18
- package/src/base/state-panel.ts +34 -13
- package/src/base/status-tone.ts +1 -1
- package/src/base/tag-input.ts +13 -8
- package/src/base/tag.ts +56 -57
- package/src/base/text.ts +38 -14
- package/src/base/textarea.ts +1 -1
- package/src/base/time-picker.ts +9 -5
- package/src/base/tree-select.ts +12 -9
- package/src/base/upload.ts +26 -17
- package/src/biz/approval-desk/compile.ts +28 -1
- package/src/biz/approval-desk/shell.ts +10 -9
- package/src/biz/auth-panel/compile.ts +1 -1
- package/src/biz/auth-panel/shell.ts +7 -6
- package/src/biz/category-crud/compile.ts +20 -6
- package/src/biz/category-crud/shell.ts +10 -7
- package/src/biz/checkout-page/compile.ts +1 -1
- package/src/biz/checkout-page/shell.ts +15 -13
- package/src/biz/compose.ts +5 -5
- package/src/biz/data-components.ts +4 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +1 -1
- package/src/biz/import-wizard/shell.ts +17 -13
- package/src/biz/index.ts +4 -3
- package/src/biz/landing-page/compile.ts +1 -1
- package/src/biz/landing-page/shell.ts +6 -5
- package/src/biz/link/shared.ts +8 -1
- package/src/biz/master-sub/compile.ts +269 -27
- package/src/biz/master-sub/detail-head.ts +62 -0
- package/src/biz/master-sub/index.ts +5 -4
- package/src/biz/master-sub/shell.ts +138 -69
- package/src/biz/multi-board/compile.ts +166 -11
- package/src/biz/multi-board/composition.ts +58 -0
- package/src/biz/multi-board/index.ts +25 -10
- package/src/biz/multi-board/prose-fold.ts +143 -0
- package/src/biz/multi-board/shell.ts +96 -24
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +9 -2
- package/src/biz/notification-center/shell.ts +15 -7
- package/src/biz/page-templates/domain-templates.ts +7 -3
- package/src/biz/page-templates/result-page/compile.ts +1 -1
- package/src/biz/page-templates/result-page/shell.ts +5 -4
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +1 -1
- package/src/biz/page-templates/sign-in-page/shell.ts +18 -18
- package/src/biz/record-detail/compile.ts +5 -2
- package/src/biz/record-detail/shell.ts +12 -11
- package/src/biz/settings-center/compile.ts +1 -1
- package/src/biz/settings-center/shell.ts +14 -10
- package/src/biz/shared/action-host.ts +12 -5
- package/src/biz/shared/compile-helpers.ts +83 -4
- package/src/biz/shared/coordinator.ts +104 -21
- package/src/biz/shared/overlay-compile.ts +76 -4
- package/src/biz/shared/overlay-shell.ts +65 -112
- package/src/biz/single-form/compile.ts +2 -2
- package/src/biz/single-form/shell.ts +13 -7
- package/src/biz/standard-crud/compile.ts +24 -4
- package/src/biz/standard-crud/shell.ts +38 -30
- package/src/biz/standard-crud/summary.ts +42 -0
- package/src/biz/step-form/compile.ts +1 -1
- package/src/biz/step-form/hub.ts +4 -0
- package/src/biz/step-form/shell.ts +16 -12
- package/src/biz/types.ts +15 -3
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +35 -8
- package/src/cli/kit-init.ts +149 -0
- package/src/cli/layout-cli.ts +7 -7
- package/src/compile/access-gate-attach.ts +27 -0
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/compile-page.ts +36 -230
- package/src/compile/component-candidates.ts +4 -1
- package/src/compile/hints.ts +5 -58
- package/src/compile/index.ts +2 -2
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +97 -18
- package/src/compile/layout-lint/rules-form.ts +6 -7
- package/src/compile/layout-lint/rules-table.ts +98 -14
- package/src/compile/page-composition.ts +191 -0
- package/src/compile/parse.ts +4 -0
- package/src/compile/producer-fingerprint.ts +56 -0
- package/src/compile/redirect.ts +1 -1
- package/src/compile/stages.ts +169 -0
- package/src/compile/styles.ts +80 -32
- package/src/compile/types.ts +5 -3
- package/src/data/access-gate.ts +112 -0
- package/src/data/amount-breakdown.ts +6 -2
- package/src/data/anchor-nav.ts +4 -1
- package/src/data/approval-flow.ts +13 -5
- package/src/data/assignment-picker.ts +35 -20
- package/src/data/async-result-panel.ts +7 -3
- package/src/data/breadcrumbs.ts +13 -9
- package/src/data/calendar.ts +10 -4
- package/src/data/carousel.ts +13 -5
- package/src/data/chart.ts +745 -48
- package/src/data/checklist.ts +9 -5
- package/src/data/code-view.ts +220 -26
- package/src/data/comment-thread.ts +9 -3
- package/src/data/confirm-dialog.ts +57 -20
- package/src/data/diff.ts +4 -1
- package/src/data/dock.ts +5 -1
- package/src/data/embed.ts +1 -1
- package/src/data/engine-ports.ts +126 -0
- package/src/data/field-mapper.ts +16 -7
- package/src/data/flow-editor.ts +106 -29
- package/src/data/footer.ts +8 -2
- package/src/data/gantt.ts +192 -27
- package/src/data/hero.ts +8 -2
- package/src/data/image-viewer.ts +7 -3
- package/src/data/index.ts +22 -8
- package/src/data/item-list.ts +11 -3
- package/src/data/json-view.ts +844 -0
- package/src/data/kanban.ts +13 -8
- package/src/data/markdown-view.ts +487 -0
- package/src/data/matrix.ts +400 -0
- package/src/data/media-grid.ts +5 -2
- package/src/data/mega-menu.ts +4 -3
- package/src/data/menu-dom.ts +9 -8
- package/src/data/menu.ts +35 -17
- package/src/data/mockup.ts +12 -8
- package/src/data/modal-dialog.ts +108 -57
- package/src/data/navbar.ts +13 -7
- package/src/data/notice-list.ts +53 -20
- package/src/data/notify-renderer.ts +21 -10
- package/src/data/object-form.ts +248 -151
- package/src/data/pager.ts +15 -10
- package/src/data/panel-head.ts +406 -0
- package/src/data/permission-matrix.ts +19 -9
- package/src/data/permission-tree.ts +30 -13
- package/src/data/pricing-table.ts +10 -4
- package/src/data/reaction-bar.ts +6 -3
- package/src/data/record-card.ts +30 -14
- package/src/data/record-picker.ts +8 -4
- package/src/data/redirect.ts +1 -1
- package/src/data/request-console.ts +20 -7
- package/src/data/resident.ts +6 -10
- package/src/data/result-panel.ts +2 -2
- package/src/data/rich-text.ts +58 -96
- package/src/data/row-editor.ts +12 -7
- package/src/data/rule-builder.ts +22 -11
- package/src/data/shape-util.ts +26 -14
- package/src/data/stat-group.ts +369 -84
- package/src/data/static-lazy.ts +7 -0
- package/src/data/static-registry.ts +14 -2
- package/src/data/steps.ts +6 -2
- package/src/data/survey.ts +13 -4
- package/src/data/system-switcher.ts +17 -7
- package/src/data/text-diff.ts +663 -0
- package/src/data/timeline.ts +1 -1
- package/src/data/tour-guide.ts +8 -4
- package/src/data/transfer.ts +24 -11
- package/src/data/tree-table.ts +84 -17
- package/src/data/tree.ts +6 -3
- package/src/data/virtual-rows.ts +22 -11
- package/src/data/wrap.ts +2 -2
- package/src/data/wrapped-candidates.ts +22 -1
- package/src/frames/index.ts +4 -2
- package/src/frames/inherited-shell.ts +178 -0
- package/src/frames/list-summary.ts +123 -0
- package/src/frames/page-bar.ts +10 -16
- package/src/frames/resident-components.ts +20 -0
- package/src/frames/shared.ts +37 -17
- package/src/frames/split-frame/shell.ts +17 -11
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +17 -9
- package/src/frames/top-main-frame.ts +1 -1
- package/src/frames/types.ts +6 -3
- package/src/frames/workspace-frame/extras.ts +19 -5
- package/src/frames/workspace-frame/shell.ts +4 -3
- package/src/frames/workspace-frame/state.ts +8 -2
- package/src/frames/workspace-frame/tab-scroll.ts +28 -0
- package/src/frames/workspace-frame/view.ts +156 -91
- package/src/generated/kit-grammar-runtime.ts +227 -58
- package/src/i18n/kit-text.ts +141 -2
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +169 -0
- package/src/object-renderer/action-more.ts +160 -0
- package/src/object-renderer/arrange.ts +86 -26
- package/src/object-renderer/candidates.ts +4 -0
- package/src/object-renderer/collection-parts.ts +72 -20
- package/src/object-renderer/collection-table.ts +178 -65
- package/src/object-renderer/collection.ts +129 -83
- package/src/object-renderer/compile-data.ts +1 -1
- package/src/object-renderer/defaults.ts +10 -5
- package/src/object-renderer/emit-events.ts +1 -1
- package/src/object-renderer/emit-object.ts +7 -0
- package/src/object-renderer/emit-static.ts +243 -87
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +84 -0
- package/src/object-renderer/filter-toolbar.ts +103 -0
- package/src/{compile → object-renderer}/fragment.ts +13 -2
- package/src/object-renderer/index.ts +6 -1
- package/src/object-renderer/layout-facts.ts +46 -6
- package/src/object-renderer/layout-plan.ts +136 -43
- package/src/object-renderer/layout-plan.types.ts +42 -5
- package/src/object-renderer/overlay-decide.ts +82 -0
- package/src/object-renderer/parts.ts +7 -259
- package/src/object-renderer/render-object.ts +60 -47
- package/src/object-renderer/table-actions.ts +135 -56
- package/src/object-renderer/table-gap.ts +37 -0
- package/src/object-renderer/table-tools.ts +63 -25
- package/src/object-renderer/types.ts +16 -22
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/code-view.ts +56 -0
- package/src/recipes/compact-group.ts +31 -0
- package/src/recipes/container.ts +54 -13
- package/src/recipes/control.ts +77 -157
- package/src/recipes/desc-list.ts +14 -0
- package/src/recipes/divider.ts +53 -0
- package/src/recipes/emphasis.ts +60 -0
- package/src/recipes/frame-bleed.ts +33 -0
- package/src/recipes/index.ts +34 -1
- package/src/recipes/inherited-shell.ts +37 -0
- package/src/recipes/json-view.ts +49 -0
- package/src/recipes/markdown.ts +86 -0
- package/src/recipes/overlay.ts +149 -18
- package/src/recipes/page-width.ts +20 -0
- package/src/recipes/placeholder.ts +21 -5
- package/src/recipes/rail-grid.ts +3 -0
- package/src/recipes/stat-state.ts +65 -0
- package/src/recipes/state.ts +20 -28
- package/src/recipes/status.ts +17 -8
- package/src/recipes/strip.ts +72 -0
- package/src/recipes/surface-edge.ts +16 -0
- package/src/recipes/surface.ts +10 -6
- package/src/recipes/table-gap.ts +80 -0
- package/src/recipes/table-native-edit.ts +242 -0
- package/src/recipes/table-row.ts +120 -11
- package/src/recipes/tabs.ts +126 -0
- package/src/recipes/text-diff.ts +90 -0
- package/src/recipes/title-row.ts +7 -5
- package/src/recipes/typography.ts +24 -43
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-value-format.ts +246 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +12 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/theme-runtime-shared.ts +19 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +49 -14
- package/src/theme/kit-theme.tpl +49 -14
- package/src/theme/nine-dim-structure.ts +129 -37
- package/src/theme/surface-layers.ts +17 -4
- package/src/theme/theme-tokens.ts +16 -5
- package/src/theme/typography.ts +21 -17
- 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/{base → shared}/class-candidates.ts +0 -0
package/src/data/breadcrumbs.ts
CHANGED
|
@@ -11,16 +11,20 @@ import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
|
11
11
|
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
12
12
|
import { safeHref } from '../base/link';
|
|
13
13
|
import { kitText } from '../i18n/kit-text';
|
|
14
|
-
import { kitIcon, kitIconHtml } from '../
|
|
14
|
+
import { kitIcon, kitIconHtml } from '../shared/icons';
|
|
15
15
|
import { classSet, FOCUS, h, isRec, recList, textOf, type Child, type Rec } from './menu-dom';
|
|
16
16
|
|
|
17
17
|
const ROOT_CLASS = 'flex min-w-0 items-center text-sm text-fg-muted';
|
|
18
18
|
const ROOT_SCROLL_CLASS = 'flex min-w-0 items-center overflow-x-auto text-sm text-fg-muted';
|
|
19
|
-
|
|
19
|
+
// 溢出策略 = 单行、不折行(面包屑在 40 高的条带里,折行会被条带裁掉上下,@320 外壳顶栏);放不下时上级先收缩成「…」、当前项保整(AR45):
|
|
20
|
+
// 上级项最窄收到一个省略号宽(min-w-5 + truncate,项本身不设 min-w-0,最小宽 = 分隔符 + 省略号),当前项不收缩(shrink-0,只在独占整行仍放不下时才省略)
|
|
21
|
+
const LIST_CLASS = 'flex min-w-0 flex-nowrap items-center gap-1';
|
|
20
22
|
const LIST_SCROLL_CLASS = 'flex flex-nowrap items-center gap-1 whitespace-nowrap';
|
|
21
|
-
const ITEM_CLASS = 'flex
|
|
23
|
+
const ITEM_CLASS = 'flex items-center gap-1';
|
|
24
|
+
const CURRENT_ITEM_CLASS = 'flex min-w-0 max-w-full shrink-0 items-center gap-1';
|
|
22
25
|
// border-0 bg-transparent p-0:按钮型面包屑项没有 preflight 时带浏览器默认 6px 横向内边距,会让分隔符两侧间距不等、首项比当前项缩进多 6px
|
|
23
|
-
const LINK_CLASS = `min-w-
|
|
26
|
+
const LINK_CLASS = `min-w-5 cursor-pointer truncate rounded-sm border-0 bg-transparent px-0 py-1 -my-1 text-start text-fg-muted transition-colors hover:text-fg hover:underline ${FOCUS}`;
|
|
27
|
+
const ANCESTOR_TEXT_CLASS = 'min-w-5 truncate';
|
|
24
28
|
const CURRENT_CLASS = 'min-w-0 truncate font-medium text-fg';
|
|
25
29
|
const SEP_CLASS = 'shrink-0 text-fg-subtle';
|
|
26
30
|
const ELLIPSIS_CLASS = `inline-flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-sm px-1 text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ${FOCUS}`;
|
|
@@ -28,7 +32,7 @@ const ELLIPSIS_STATIC_CLASS = 'shrink-0 px-1 text-fg-muted';
|
|
|
28
32
|
|
|
29
33
|
/** 本组件自带的全部类(供编译器并入候选类,页面框静态页头同用) */
|
|
30
34
|
export const KIT_BREADCRUMBS_CLASS_CANDIDATES: readonly string[] = classSet(
|
|
31
|
-
ROOT_CLASS, ROOT_SCROLL_CLASS, LIST_CLASS, LIST_SCROLL_CLASS, ITEM_CLASS, LINK_CLASS, CURRENT_CLASS, SEP_CLASS, ELLIPSIS_CLASS, ELLIPSIS_STATIC_CLASS,
|
|
35
|
+
ROOT_CLASS, ROOT_SCROLL_CLASS, LIST_CLASS, LIST_SCROLL_CLASS, ITEM_CLASS, CURRENT_ITEM_CLASS, LINK_CLASS, ANCESTOR_TEXT_CLASS, CURRENT_CLASS, SEP_CLASS, ELLIPSIS_CLASS, ELLIPSIS_STATIC_CLASS,
|
|
32
36
|
);
|
|
33
37
|
|
|
34
38
|
export const KIT_BREADCRUMBS_DEFAULT_MAX: number = KIT_STATIC_COMPONENT_LIMITS.navigation.breadcrumbs.defaultMaxItems;
|
|
@@ -92,11 +96,11 @@ export function breadcrumbsHtml(items: readonly { label: string; href?: string }
|
|
|
92
96
|
return `<li class="${ITEM_CLASS}">${lead}<span title="${esc(title)}" class="${ELLIPSIS_STATIC_CLASS}">…</span></li>`;
|
|
93
97
|
}
|
|
94
98
|
const { crumb, current } = p;
|
|
95
|
-
if (current) return `<li class="${
|
|
99
|
+
if (current) return `<li class="${CURRENT_ITEM_CLASS}">${lead}<span aria-current="page" class="${CURRENT_CLASS}">${esc(crumb.label)}</span></li>`;
|
|
96
100
|
const href = crumb.href !== '' ? safeHref(crumb.href) : '';
|
|
97
101
|
const inner = href !== ''
|
|
98
102
|
? `<a href="${esc(href)}" class="${LINK_CLASS}">${esc(crumb.label)}</a>`
|
|
99
|
-
: `<span class="
|
|
103
|
+
: `<span class="${ANCESTOR_TEXT_CLASS}">${esc(crumb.label)}</span>`;
|
|
100
104
|
return `<li class="${ITEM_CLASS}">${lead}${inner}</li>`;
|
|
101
105
|
});
|
|
102
106
|
const id = opts.anchorId !== undefined ? ` data-soma-id="${esc(opts.anchorId)}"` : '';
|
|
@@ -126,7 +130,7 @@ export function mountKitBreadcrumbs(root: HTMLElement, emit: (name: string, payl
|
|
|
126
130
|
root.setAttribute('aria-label', str(props.label, kitText('soma.kit.nav_breadcrumb', undefined, root)));
|
|
127
131
|
const list = h('ol', scroll ? LIST_SCROLL_CLASS : LIST_CLASS);
|
|
128
132
|
breadcrumbParts(crumbs, max, expanded).forEach((p, i) => {
|
|
129
|
-
const li = h('li', ITEM_CLASS);
|
|
133
|
+
const li = h('li', p.kind !== 'ellipsis' && p.current ? CURRENT_ITEM_CLASS : ITEM_CLASS);
|
|
130
134
|
if (i > 0) li.append(h('span', SEP_CLASS, { 'aria-hidden': 'true' }, str(props.marker) === 'chevron' ? kitIcon('chevron-right', 'xs', 'rtl:-scale-x-100') : sep));
|
|
131
135
|
if (p.kind === 'ellipsis') {
|
|
132
136
|
const title = p.hidden.map((c) => c.label).join(' / ');
|
|
@@ -142,7 +146,7 @@ export function mountKitBreadcrumbs(root: HTMLElement, emit: (name: string, payl
|
|
|
142
146
|
const href = crumb.href !== '' ? safeHref(crumb.href) : '';
|
|
143
147
|
if (isRec(crumb.raw) && crumb.raw.inert === true) {
|
|
144
148
|
// inert:只是层级文字(如菜单分组名),不可点
|
|
145
|
-
li.append(h('span',
|
|
149
|
+
li.append(h('span', ANCESTOR_TEXT_CLASS, {}, ...text));
|
|
146
150
|
} else {
|
|
147
151
|
const el = href !== ''
|
|
148
152
|
? h('a', LINK_CLASS, { href }, ...text)
|
package/src/data/calendar.ts
CHANGED
|
@@ -14,6 +14,11 @@ import { kitText } from '../i18n/kit-text';
|
|
|
14
14
|
import { setKitFace } from '../recipes';
|
|
15
15
|
import { classTokens, keyMap, mk, rowsOf, shapeToneOf, textOf, TONE_SOFT, type Rec } from './shape-util';
|
|
16
16
|
import { monthGridCells, monthGridRange, monthGridStep, weekdayHeads, type MonthGridRange } from '../base/month-grid';
|
|
17
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
18
|
+
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
19
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
20
|
+
import { mergeClass } from '../shared/merge-class';
|
|
21
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
17
22
|
import {
|
|
18
23
|
addMonths, anchorOf, attrEsc, dayNumOf, monthTitle, rowKey, textOfDayNum, timeTail, weekdayOfDayNum,
|
|
19
24
|
} from './d9-util';
|
|
@@ -24,11 +29,11 @@ export type KitCalendarView = 'month' | 'week';
|
|
|
24
29
|
|
|
25
30
|
const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
26
31
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
27
|
-
const TITLE_CLASS = 'min-w-24
|
|
32
|
+
const TITLE_CLASS = mergeClass('min-w-24', kitTypographyRecipe('sectionTitle'));
|
|
28
33
|
const SPACER_CLASS = 'flex-1';
|
|
29
|
-
const BTN_CLASS = '
|
|
34
|
+
const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
30
35
|
const BTN_ON_CLASS = 'inline-flex h-8 items-center justify-center rounded-md border border-primary bg-primary-soft px-3 text-sm font-medium text-primary-on-soft transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
31
|
-
const GRID_CLASS = 'flex flex-col overflow-hidden
|
|
36
|
+
const GRID_CLASS = mergeClass('flex flex-col overflow-hidden', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
32
37
|
const ROW_CLASS = 'grid grid-cols-7 border-border-subtle';
|
|
33
38
|
const ROW_BORDER = 'border-t';
|
|
34
39
|
const HEADCELL_CLASS = 'px-2 py-1.5 text-center text-xs font-medium text-fg-muted';
|
|
@@ -117,7 +122,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
117
122
|
},
|
|
118
123
|
keyboard: { layout: 'grid', date_grid: true, wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
119
124
|
},
|
|
120
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
125
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
121
126
|
controllerFactory: createKitController((api) => {
|
|
122
127
|
const P = (): Record<string, unknown> => api.props();
|
|
123
128
|
let root: HTMLElement | null = null;
|
|
@@ -247,6 +252,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
247
252
|
|
|
248
253
|
// 网格
|
|
249
254
|
const grid = mk('div', GRID_CLASS);
|
|
255
|
+
markKitEdge(grid);
|
|
250
256
|
grid.setAttribute('role', 'grid');
|
|
251
257
|
grid.setAttribute('aria-label', title.textContent ?? '');
|
|
252
258
|
const hr = mk('div', ROW_CLASS);
|
package/src/data/carousel.ts
CHANGED
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
16
|
import { KIT_CAROUSEL_LIMITS, KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
17
17
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
18
|
-
import { kitIcon } from '../
|
|
18
|
+
import { kitIcon } from '../shared/icons';
|
|
19
19
|
import { kitText } from '../i18n/kit-text';
|
|
20
20
|
import { setKitFace } from '../recipes';
|
|
21
|
+
import { kitButtonEdgeRecipe } from '../recipes/control';
|
|
22
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
21
23
|
import { kitKey } from '../i18n/kit-text';
|
|
22
24
|
import { classTokens, emptyNode, mk, textOf, type Rec } from './shape-util';
|
|
23
25
|
import { clampInt, keyOfRow, listOf, prefersReducedMotion, urlOf } from './display-util';
|
|
26
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
24
27
|
|
|
25
28
|
export const KIT_CAROUSEL_LAYOUTS = ['slide', 'stack'] as const;
|
|
26
29
|
export type KitCarouselLayout = (typeof KIT_CAROUSEL_LAYOUTS)[number];
|
|
@@ -28,7 +31,11 @@ export const KIT_CAROUSEL_EDGES = ['top', 'bottom', 'start', 'end'] as const;
|
|
|
28
31
|
export type KitCarouselEdge = (typeof KIT_CAROUSEL_EDGES)[number];
|
|
29
32
|
|
|
30
33
|
const ROOT_CLASS = 'flex flex-col gap-3 text-fg';
|
|
31
|
-
|
|
34
|
+
// 视窗 / 叠卡 = 壳配方(容器边,KT-B2);切换钮 = 带文字中性按钮描边(KT-B1)
|
|
35
|
+
const VIEWPORT_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
|
|
36
|
+
const NAV_EDGE = kitButtonEdgeRecipe();
|
|
37
|
+
const STACK_EDGE = kitShellRecipe({ tone: 'base' });
|
|
38
|
+
const VIEWPORT_CLASS = `overflow-hidden ${VIEWPORT_EDGE}`;
|
|
32
39
|
const SLIDE_IMAGE_CLASS = 'flex flex-col';
|
|
33
40
|
const IMG_CLASS = 'aspect-16/9 w-full object-cover';
|
|
34
41
|
const CAPTION_CLASS = 'flex flex-col gap-1 px-4 py-3';
|
|
@@ -37,7 +44,7 @@ const TITLE_CLASS = 'text-lg font-semibold';
|
|
|
37
44
|
const TEXT_CLASS = 'text-sm text-fg-muted';
|
|
38
45
|
const CARD_TEXT_CLASS = 'text-sm';
|
|
39
46
|
const BAR_CLASS = 'flex items-center justify-between gap-3';
|
|
40
|
-
const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md
|
|
47
|
+
const NAV_CLASS = 'inline-flex h-8 min-w-8 items-center justify-center rounded-md ' + NAV_EDGE + ' bg-surface px-2 text-sm 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';
|
|
41
48
|
// 圆点尺寸与间距取 design 真源 kit-limits#carousel(间距步数,乘 --spacing);排容器 hit-gap-N 写 gap 与 --kit-hit-gap,
|
|
42
49
|
// 圆点用 hit-area-row(读 hitTarget;沿排热区 = min(命中边长, 中心距),相邻热区相接零重叠,垂直方向仍是完整命中边长),不手写外扩。
|
|
43
50
|
const DOTS_CLASS = `flex flex-1 items-center justify-center hit-gap-${KIT_CAROUSEL_LIMITS.dotGapStep}`;
|
|
@@ -51,7 +58,7 @@ const STACK_PAD: Readonly<Record<KitCarouselEdge, string>> = Object.freeze({
|
|
|
51
58
|
start: 'grid ps-6',
|
|
52
59
|
end: 'grid pe-6',
|
|
53
60
|
});
|
|
54
|
-
const STACK_CARD_BASE =
|
|
61
|
+
const STACK_CARD_BASE = `col-start-1 row-start-1 flex min-h-32 flex-col gap-2 ${STACK_EDGE} p-4 text-start motion-safe:transition-transform`;
|
|
55
62
|
const STACK_TOP = 'z-30 cursor-pointer hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring';
|
|
56
63
|
/** 后面两张牌的位置:edge × 深度(1、2) */
|
|
57
64
|
const STACK_BEHIND: Readonly<Record<KitCarouselEdge, readonly [string, string]>> = Object.freeze({
|
|
@@ -273,7 +280,7 @@ export function createCarousel(): SomaComponentDefinition {
|
|
|
273
280
|
select: { payload: { index: { type: 'number' }, item: { type: 'object' } }, desc: 'slide 布局下点当前张的内容' },
|
|
274
281
|
},
|
|
275
282
|
},
|
|
276
|
-
templateHtml: `<section data-soma-id="root" role="region" aria-roledescription="carousel" class="${ROOT_CLASS}"></section>`,
|
|
283
|
+
templateHtml: `<section data-kit-container="card" data-soma-id="root" role="region" aria-roledescription="carousel" class="${ROOT_CLASS}"></section>`,
|
|
277
284
|
controllerFactory: createKitController(() => ({
|
|
278
285
|
attach(root, api) {
|
|
279
286
|
const s = stateOf(root);
|
|
@@ -367,6 +374,7 @@ export function createCarousel(): SomaComponentDefinition {
|
|
|
367
374
|
root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, root))));
|
|
368
375
|
} else {
|
|
369
376
|
const viewport = mk('div', layout === 'stack' ? STACK_PAD[edge] : VIEWPORT_CLASS);
|
|
377
|
+
if (layout !== 'stack') markKitEdge(viewport);
|
|
370
378
|
slides.forEach((slide, i) => viewport.appendChild(buildSlide(slide, i, slides.length, layout)));
|
|
371
379
|
root.appendChild(viewport);
|
|
372
380
|
}
|