soma-kit 0.1.16 → 0.1.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soma-kit",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "SOMA 第三条 UI 路线:写死模板与规则,DSL 显式传入,基础组件 + 数据组件",
5
5
  "type": "module",
6
6
  "exports": {
@@ -53,7 +53,7 @@
53
53
  "jiti": "1.21.7",
54
54
  "js-yaml": "4.3.2",
55
55
  "soma-core": "^2.2.11",
56
- "soma-foundation": "^0.1.7",
56
+ "soma-foundation": "^0.1.8",
57
57
  "tailwindcss": "^4.1.0",
58
58
  "typescript": "5.9.3"
59
59
  },
@@ -880,7 +880,7 @@
880
880
  "cardsList": "grid gap-4",
881
881
  "cardsItem": "rounded-card border-edge border-border-container bg-surface p-card transition-shadow hover:shadow-sm",
882
882
  "stackList": "flex flex-col gap-4",
883
- "stackItem": "rounded-card border-edge border-border-container bg-surface p-3 shadow-xs",
883
+ "stackItem": "rounded-card border-edge border-border-container bg-surface p-3",
884
884
  "compactList": "@container flex flex-col",
885
885
  "compactItem": "inset-row flex flex-wrap items-center gap-x-3 gap-y-1 px-3 in-data-kit-axis:px-card py-2 border-b-hairline border-border-subtle last:border-b-0 text-sm text-fg transition-colors hover:bg-state-layer-row-hover active:bg-state-layer-press data-kit-selected:bg-state-layer-selected data-kit-selected:sel-bar data-kit-selected:hover:bg-state-layer-tonal-hover data-kit-fresh:bg-primary-soft",
886
886
  "compactBody": "flex min-w-40 flex-1 flex-col gap-0.5",
@@ -10,10 +10,10 @@ import { KIT_SIZE_SPEC } from 'soma-foundation/kit-limits';
10
10
  import { KIT_TIPS_SCOPE_ATTR } from '../../base/hint-tips';
11
11
  import { kitFixedPaneClass, kitListPaneClass, type KitListLayout } from '../../recipes/page-width';
12
12
  import { mergeClass } from '../../shared/merge-class';
13
- import { KIT_FACE_HEAD_CLASS, KIT_MS_ASIDE_IDLE_ATTR, KIT_MS_BACK_ATTR, KIT_MS_ROOT_ATTR, KIT_MS_VIEW_LIST_ATTR, KIT_SHELL_FLAT_MARK, kitShellRecipe } from '../../recipes/container';
13
+ import { KIT_FACE_HEAD_CLASS, KIT_MS_ASIDE_IDLE_ATTR, KIT_MS_BACK_ATTR, KIT_MS_ROOT_ATTR, KIT_MS_VIEW_LIST_ATTR, KIT_SHELL_FLAT_MARK } from '../../recipes/container';
14
14
  import { KIT_STATE_DESC_CLASS, KIT_STATE_EMPTY_BOX } from '../../recipes/placeholder';
15
15
  import { KIT_STRIP_HEAD_CLASS, KIT_STRIP_HEAD_MIN_CLASS } from '../../recipes/strip';
16
- import { KIT_DIVIDER_HEAD_CLASS, kitDividerVariantRecipe } from '../../recipes/divider';
16
+ import { KIT_DIVIDER_HEAD_CLASS, kitDividerRecipe, kitDividerVariantRecipe } from '../../recipes/divider';
17
17
  import { kitSurfaceRecipe } from '../../recipes/surface';
18
18
  import { kitTypographyRecipe } from '../../recipes/typography';
19
19
  import { kitActionRecipe } from '../../recipes/emphasis';
@@ -36,9 +36,6 @@ import type { KitStripProjection } from '../../object-renderer/action-group';
36
36
  export const MASTER_SUB_AREAS = ['root', 'masterList', 'masterSummary', 'subWorkspace', 'subBlock', 'aside', 'dialog'] as const;
37
37
  export type MasterSubArea = (typeof MASTER_SUB_AREAS)[number];
38
38
 
39
- /** 卡片外观(圆角 + 容器边界色 + 凸起底 + 浅阴影):一份配方,三栏与区块同源,随九维边界维度变化 */
40
- const CARD = kitShellRecipe();
41
-
42
39
  /** 左窗格定档的输入(编译期由主列表的条目样本 / 表格列轨推出,见 compile.ts 的 paneSampleOf) */
43
40
  export type MasterPaneSample = Omit<ArrangePaneWidthInput, 'withAside'>;
44
41
 
@@ -75,7 +72,7 @@ export function masterSubSplit(sample: MasterPaneSample, withAside: boolean, lay
75
72
  row: 'flex-row flex-wrap',
76
73
  left: 'w-full group-data-kit-ms-detail/ms:hidden',
77
74
  right: 'flex-1 group-data-kit-ms-list/ms:hidden',
78
- aside: 'w-full group-data-kit-ms-list/ms:hidden',
75
+ aside: ['w-full group-data-kit-ms-list/ms:hidden', kitDividerRecipe('top')].join(' '),
79
76
  tier: null,
80
77
  px: plan.px,
81
78
  fits: plan.fits,
@@ -92,7 +89,7 @@ export function masterSubSplit(sample: MasterPaneSample, withAside: boolean, lay
92
89
  row: ['flex-row flex-wrap', `@${TA}:flex-nowrap`, kitDividerVariantRecipe('end', `@${T}:*:first`)].join(' '),
93
90
  left: `${kitListPaneClass(plan.px, T)} @max-${T}:w-full @max-${T}:group-data-kit-ms-detail/ms:hidden`,
94
91
  right: `flex-1 @max-${T}:group-data-kit-ms-list/ms:hidden`,
95
- aside: `${kitFixedPaneClass(M.pane.sideRailPx, TA)} @max-${TA}:w-full @max-${T}:group-data-kit-ms-list/ms:hidden`,
92
+ aside: [kitFixedPaneClass(M.pane.sideRailPx, TA), `@max-${TA}:w-full`, `@max-${T}:group-data-kit-ms-list/ms:hidden`, kitDividerVariantRecipe('start', `@${TA}`), kitDividerVariantRecipe('top', `@max-${TA}`)].join(' '),
96
93
  tier: T,
97
94
  px: plan.px,
98
95
  fits: plan.fits,
@@ -145,7 +142,7 @@ export const MASTER_SUB_CLASS = {
145
142
  emptyBox: mergeClass(KIT_STATE_EMPTY_BOX, 'flex-1 flex-col items-center justify-center min-h-60 py-12 text-center gap-cluster px-card'),
146
143
  emptyText: KIT_STATE_DESC_CLASS,
147
144
  // self-start:辅助栏(结果 / 说明)按内容定高,不拉成与最高一栏等高的一整列空白卡
148
- asideBase: mergeClass('self-start flex min-w-0 flex-col gap-section p-card group-data-kit-aside-idle/ms:hidden', CARD),
145
+ asideBase: 'self-start flex min-w-0 flex-col gap-section p-card group-data-kit-aside-idle/ms:hidden',
149
146
  } as const;
150
147
 
151
148
  /** 「返回」钮:文字钮(三级强调)+ 左箭头图标,与其它窗格头动作同一套控件配方 */
@@ -320,7 +317,7 @@ export function masterSubHtml(
320
317
  const aside = !withAside ? ''
321
318
  : nx !== undefined
322
319
  ? `<aside data-soma-id="${esc(kitObjectAnchor(nx.aside))}"${cls(kitNeutralClass(mergeClass(`${S.aside} ${MASTER_SUB_CLASS.asideBase}`, areaClass.aside)))}>${parts.aside}</aside>`
323
- : `<aside ${KIT_ATTR_CONTAINER}="card"${cls(mergeClass(`${S.aside} ${MASTER_SUB_CLASS.asideBase}`, areaClass.aside))}${FLAT}>${parts.aside}</aside>`;
320
+ : `<aside ${KIT_ATTR_CONTAINER}="plain"${cls(mergeClass(`${S.aside} ${MASTER_SUB_CLASS.asideBase}`, areaClass.aside))}${FLAT}>${parts.aside}</aside>`;
324
321
  const root = mergeClass(mergeClass(MASTER_SUB_CLASS.root, areaClass.root), extra);
325
322
  const msAttrs = ` ${KIT_MS_ROOT_ATTR}="" ${KIT_MS_VIEW_LIST_ATTR}=""${withAside && parts.asideIdleInit === true ? ` ${KIT_MS_ASIDE_IDLE_ATTR}=""` : ''}${nx !== undefined ? insetNone : ''}`;
326
323
  // 新模式:分窗格的那张面是业务组件节点自己(层级角色由布局写到根锚点 __ms_root 上),分栏行只留结构类(面框、窗格中缝由取值表给)
@@ -148,7 +148,28 @@ export function splitTitleRow(html: string): [string, string] {
148
148
  return ['', html];
149
149
  }
150
150
 
151
- export function filterToolbarRow(filter: string, toolbar: string, inlineMeta?: string | null): string {
151
+ /**
152
+ * 判定工具栏片段最外层动作组宿主(带 data-kit-action-group)自身是否声明为容器查询宿主(@container):
153
+ * 只检查最外层动作组开标签的 class 词元,避免工具栏内部任意子元素带 @container 时被误判成查询容器工具列。
154
+ */
155
+ function isQueryActionGroupHost(toolbar: string): boolean {
156
+ const attrAt = toolbar.indexOf(`${KIT_ATTR_ACTION_GROUP}=`);
157
+ if (attrAt < 0) return false;
158
+ const open = toolbar.lastIndexOf('<div', attrAt);
159
+ const close = toolbar.indexOf('>', attrAt);
160
+ if (open < 0 || close < 0 || toolbar.indexOf('>', open) !== close) return false;
161
+ const openTag = toolbar.slice(open, close + 1);
162
+ const clsMatch = /\bclass="([^"]*)"/.exec(openTag);
163
+ if (clsMatch === null) return false;
164
+ return clsMatch[1]!.split(/\s+/).includes('@container');
165
+ }
166
+
167
+ export function filterToolbarRow(
168
+ filter: string,
169
+ toolbar: string,
170
+ inlineMeta?: string | null,
171
+ options?: { readonly queryToolbar?: boolean },
172
+ ): string {
152
173
  const C = KIT_FILTER_TOOLBAR_CLASS;
153
174
  // 标签占位(与「标签在上」的筛选表单的控件行对齐)只在筛选带标签时才要;工具条式筛选没有标签行,占位会把主操作压低半行
154
175
  const pad = filter.includes(KIT_FILTER_TOOLBAR_MARK) ? '' : `<span class="${C.pad}" aria-hidden="true">&nbsp;</span>`;
@@ -159,7 +180,8 @@ export function filterToolbarRow(filter: string, toolbar: string, inlineMeta?: s
159
180
  const filterBody = inlineMeta !== undefined && inlineMeta !== null && inlineMeta !== ''
160
181
  ? wrapFilterWithInlineMeta(filter, inlineMeta)
161
182
  : filter;
162
- const toolsClass = toolbar.includes('@container') ? C.toolsQuery : C.tools;
183
+ const isQuery = options?.queryToolbar ?? isQueryActionGroupHost(toolbar);
184
+ const toolsClass = isQuery ? C.toolsQuery : C.tools;
163
185
  return `<div class="${row}"><div class="${C.filter}">${filterBody}</div>`
164
186
  + `<div class="${toolsClass}">${pad}${toolbar}</div></div>`;
165
187
  }
@@ -1,6 +1,6 @@
1
1
  // 生成物,不得改写:由 soma-kit/scripts/build-kit-grammar-runtime.mjs 从 spec/kit-grammar.json 抽出。
2
2
  // 浏览器侧只读这份运行期切片(闭集与限值);编译侧读完整真源。改真源后运行 `npm run grammar:runtime -w soma-kit` 重新生成。
3
- // 真源指纹 sha256:6793a8321f898a266dccf5a2a8b9987d2024bd27cccf1e34c36c8ba36c9d4b11
3
+ // 真源指纹 sha256:6ec6018db18518977c7b44090e1c8582d1feeeea8fcec69eec48e555b71132a4
4
4
 
5
5
  export const KIT_GRAMMAR_RUNTIME = {
6
6
  "i18n": {
@@ -2249,7 +2249,7 @@ export const KIT_GRAMMAR_RUNTIME = {
2249
2249
  "cardsList": "grid gap-4",
2250
2250
  "cardsItem": "rounded-card border-edge border-border-container bg-surface p-card transition-shadow hover:shadow-sm",
2251
2251
  "stackList": "flex flex-col gap-4",
2252
- "stackItem": "rounded-card border-edge border-border-container bg-surface p-3 shadow-xs",
2252
+ "stackItem": "rounded-card border-edge border-border-container bg-surface p-3",
2253
2253
  "compactList": "@container flex flex-col",
2254
2254
  "compactItem": "inset-row flex flex-wrap items-center gap-x-3 gap-y-1 px-3 in-data-kit-axis:px-card py-2 border-b-hairline border-border-subtle last:border-b-0 text-sm text-fg transition-colors hover:bg-state-layer-row-hover active:bg-state-layer-press data-kit-selected:bg-state-layer-selected data-kit-selected:sel-bar data-kit-selected:hover:bg-state-layer-tonal-hover data-kit-fresh:bg-primary-soft",
2255
2255
  "compactBody": "flex min-w-40 flex-1 flex-col gap-0.5",
@@ -512,10 +512,9 @@ export function createKitTableActions(): SomaComponentDefinition {
512
512
  let renderedEcho = '';
513
513
  // 最近一次渲染时动作数组的权限判定签名(权限异步到达 / 收回 / 切换判定器时仅在结果变化时重绘)
514
514
  let renderedPerm = '';
515
- const permStateOf = (p: KitProps): string => {
515
+ const permStateOf = (p: KitProps, check = permissionCheckerOf(api as unknown as any)): string => {
516
516
  const items = itemsOf(p.actions);
517
517
  if (!items.some((item) => item.permission !== undefined)) return '';
518
- const check = permissionCheckerOf(api as unknown as any);
519
518
  return items.map((item) => (item.permission !== undefined && check !== null ? (check(item.permission) ? '1' : '0') : '-')).join('');
520
519
  };
521
520
  // 在途期间按钮被禁用会丢焦点:记下用户点的是哪个控件,落定恢复后还给它(仅当焦点已落到 body)
@@ -670,7 +669,7 @@ export function createKitTableActions(): SomaComponentDefinition {
670
669
  const check = permissionCheckerOf(api as unknown as any);
671
670
  const busy = removeBusyOf(p);
672
671
  renderedBusy = busy;
673
- renderedPerm = permStateOf(p);
672
+ renderedPerm = permStateOf(p, check);
674
673
  // 保存回声:所在行容器打 / 摘 data-kit-fresh(行类的 data-kit-fresh 变体画底色,摘掉时 transition-colors 淡出);
675
674
  // 常规行里正被置顶的那条记录隐去(置顶行容器里的副本不隐),不出现两份。只改行容器属性、不动本组件内容,放在签名跳过之前
676
675
  const echo = rowEchoState(p, root);
@@ -704,8 +703,7 @@ export function createKitTableActions(): SomaComponentDefinition {
704
703
  const selState = Array.isArray(p.selected) ? (p.selected.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0) : -1;
705
704
  const pickedRows = selectedRowsOf(p.picked);
706
705
  const pickState = pickedRows === null ? -1 : (pickedRows.some((r) => rowKeyOf(r, keyF) === rowKeyOf(p.row, keyF)) ? 1 : 0);
707
- const perms = itemsOf(p.actions).map((item) => (item.permission !== undefined && check !== null ? (check(item.permission) ? 1 : 0) : -1));
708
- return JSON.stringify([rest, selState, pickState, perms]) + (busy ? '|busy' : '') + (locked ? '|lock' : '');
706
+ return JSON.stringify([rest, selState, pickState, renderedPerm]) + (busy ? '|busy' : '') + (locked ? '|lock' : '');
709
707
  } catch {
710
708
  return null; // 含环等不可序列化:不跳过
711
709
  }