soma-kit 0.1.7 → 0.1.10
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 +2 -2
- package/spec/generated/kit-app.schema.json +27 -0
- package/spec/generated/kit-page.schema.json +7 -0
- package/spec/kit-grammar.json +110 -9
- package/src/app/app-config.ts +558 -20
- package/src/app/component-gate.ts +203 -0
- package/src/app/define-kit-app.ts +5 -1
- package/src/app/server.ts +18 -7
- package/src/base/shared.ts +48 -5
- package/src/base/text.ts +8 -2
- package/src/biz/index.ts +30 -0
- package/src/biz/page-templates/domain-templates.ts +184 -0
- package/src/compile/compile-page.ts +149 -4
- package/src/compile/parse.ts +4 -0
- package/src/compile/types.ts +5 -1
- package/src/data/embed.ts +2 -0
- package/src/data/mockup.ts +4 -4
- package/src/data/navbar.ts +2 -2
- package/src/data/row-editor.ts +2 -2
- package/src/data/rule-builder.ts +1 -1
- package/src/data/shape-util.ts +1 -1
- package/src/data/tree-table.ts +14 -3
- package/src/data/virtual-rows.ts +17 -3
- package/src/generated/kit-grammar-runtime.ts +8 -5
- package/src/object-renderer/collection.ts +32 -11
- package/src/object-renderer/emit-static.ts +9 -3
- package/src/object-renderer/types.ts +2 -2
- package/src/theme/nine-dim-palettes.ts +1278 -0
- package/src/theme/theme-tokens.ts +19 -5
|
@@ -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:
|
|
3
|
+
// 真源指纹 sha256:6b7245ec17dc7c2751114877b948a866eef1ba8a774ff29a35d12f78cd79adc4
|
|
4
4
|
|
|
5
5
|
export const KIT_GRAMMAR_RUNTIME = {
|
|
6
6
|
"i18n": {
|
|
@@ -288,7 +288,7 @@ export const KIT_GRAMMAR_RUNTIME = {
|
|
|
288
288
|
"KIT-PAGE-004": "页面结构非法(缺 page / product 或形状不对),或应用内页面 URL 重复",
|
|
289
289
|
"KIT-PAGE-005": "对象名或角色名用了保留名(frame / tabs / page / p / ctrl)或非字母数字下划线,或字段名含点号",
|
|
290
290
|
"KIT-APP-001": "kit.app.yaml 非法,或其登记(组件 accept 等)与 soma.app.ts 代码登记不一致",
|
|
291
|
-
"KIT-APP-002": "kit.app.yaml 的 theme 取值不在闭集内(
|
|
291
|
+
"KIT-APP-002": "kit.app.yaml 的 theme 取值不在闭集内(9 维正交页面主题 DSL:palette、color_depth、color_saturation、font_family、font_scale、boundary、shape、surface_texture、density,或兼容旧字段)",
|
|
292
292
|
"KIT-APP-003": "theme 交 soma-foundation 令牌求解失败(折叠或求解阶段返回错误诊断)",
|
|
293
293
|
"KIT-THEME-001": "块级 theme 形状非法:不是简写字符串或对象、空对象、或对象里的值不是字符串(page.theme / product.theme)",
|
|
294
294
|
"KIT-THEME-002": "块级 theme 含未知词:对象键不在 mode / color,简写不在闭集,词条不属于该维度",
|
|
@@ -365,7 +365,9 @@ export const KIT_GRAMMAR_RUNTIME = {
|
|
|
365
365
|
"KIT-AIT-003": "AI 页意图蓝图含未知键,或取值在闭集之外(意图词 frame / product、字段 type、字段 display、内置动作、tone、permission 档)",
|
|
366
366
|
"KIT-AIT-004": "AI 页意图蓝图引用了授权接口之外的 api / write_api / delete_api,或 delete_api 指向的不是授权表里的写类方法",
|
|
367
367
|
"KIT-AIT-005": "AI 页意图蓝图的对象描述不足以编译(form 视图没有 write_api、角色缺必填对象、既无接口也无样本、display 与字段类型不匹配或不在 list / summary 视图、remove 缺 delete_api 等)",
|
|
368
|
-
"KIT-AIT-006": "AI 页提交面拒收:persist 取了 registry(kit 目标只取 runtime / memory),或提交的源不是本目标 accept 出的"
|
|
368
|
+
"KIT-AIT-006": "AI 页提交面拒收:persist 取了 registry(kit 目标只取 runtime / memory),或提交的源不是本目标 accept 出的",
|
|
369
|
+
"KIT-APP-004": "应用扩展组件未经唯一接入路径登记(必须经 wrapKitDataComponent、composeKitDataComponents 或 declareKitUses 显式声明依赖组件与候选类,且候选类不得含非法任意值、依赖组件名必须在内置闭集内)",
|
|
370
|
+
"KIT-APP-005": "应用扩展组件或组件目录源码私造已被 soma-kit 标准组件接管的非标原生控件(如原生 select、range、date/time)或书写内联 style 属性"
|
|
369
371
|
},
|
|
370
372
|
"actionBuiltins": {
|
|
371
373
|
"removeTitleFields": [
|
|
@@ -1513,7 +1515,7 @@ export const KIT_GRAMMAR_RUNTIME = {
|
|
|
1513
1515
|
"tableRoomyRow": "group-data-kit-roomy/tbl:py-4",
|
|
1514
1516
|
"tableDenseHead": "group-data-kit-dense/tbl:py-1.5",
|
|
1515
1517
|
"tableRoomyHead": "group-data-kit-roomy/tbl:py-4",
|
|
1516
|
-
"tableSummaryRow": "border-t border-border bg-surface-sunken font-semibold text-fg"
|
|
1518
|
+
"tableSummaryRow": "border-t border-border-subtle bg-surface-sunken font-semibold text-fg"
|
|
1517
1519
|
},
|
|
1518
1520
|
"formLinkage": {
|
|
1519
1521
|
"limitsRef": "kit-limits#formLinkage",
|
|
@@ -2482,7 +2484,8 @@ export const KIT_AI_WRITER: KitAiWriter = {
|
|
|
2482
2484
|
"locale": "ai",
|
|
2483
2485
|
"dir": "human-only",
|
|
2484
2486
|
"theme": "ai",
|
|
2485
|
-
"envelope": "human-only"
|
|
2487
|
+
"envelope": "human-only",
|
|
2488
|
+
"inherit_layout": "human-only"
|
|
2486
2489
|
},
|
|
2487
2490
|
"frame": {
|
|
2488
2491
|
"kind": "ai",
|
|
@@ -348,6 +348,7 @@ export function collection(
|
|
|
348
348
|
const dens = KIT_TABLE_DENSITY_CLASS[density];
|
|
349
349
|
const striped = c.striped === true;
|
|
350
350
|
const bordered = c.bordered === true;
|
|
351
|
+
const unbordered = c.bordered === false;
|
|
351
352
|
|
|
352
353
|
// ---- M 波 G2:列模型 / 滚动模式 / 工具栏
|
|
353
354
|
const ext = parseColExt(refs, env, { isTree, sticky });
|
|
@@ -467,11 +468,13 @@ export function collection(
|
|
|
467
468
|
}
|
|
468
469
|
}
|
|
469
470
|
const headGridBorder = bordered && !scroll ? ['flex', 'items-center', 'px-3', ...headPy, ...denseHead] : [];
|
|
470
|
-
const headTick =
|
|
471
|
-
? '
|
|
472
|
-
:
|
|
473
|
-
? 'not-last:border-e not-last:border-border-
|
|
474
|
-
:
|
|
471
|
+
const headTick = unbordered
|
|
472
|
+
? ''
|
|
473
|
+
: bordered
|
|
474
|
+
? 'not-last:border-e not-last:border-border-subtle'
|
|
475
|
+
: scroll
|
|
476
|
+
? 'not-last:border-e not-last:border-border-divider'
|
|
477
|
+
: 'not-last:border-e not-last:border-border-divider not-last:pe-3';
|
|
475
478
|
const headCls = join(
|
|
476
479
|
widthCls, 'truncate', al,
|
|
477
480
|
scroll ? [...headPy, ...denseHead] : headGridBorder,
|
|
@@ -544,7 +547,7 @@ export function collection(
|
|
|
544
547
|
// 选择列 / 操作列:滚动模式下定宽,有固定列时 sticky(行里底色随行,表头里随表头)
|
|
545
548
|
const lead = (headRow: boolean): string => join(
|
|
546
549
|
scroll ? [D.tableScrollCell, `w-${selectStep}`, ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : ['min-w-0', fixedSpan(selectParts), ...(bordered ? ['flex', 'items-center', 'px-3', ...(headRow ? [...headPy, ...denseHead] : [...bodyPy, ...denseRow])] : [])],
|
|
547
|
-
bordered ? (headRow ? 'not-last:border-e not-last:border-border-subtle' : 'not-last:border-e not-last:border-border-divider') : (headRow ? (scroll ? 'not-last:border-e not-last:border-border-divider' : 'not-last:border-e not-last:border-border-divider not-last:pe-3') : ''),
|
|
550
|
+
unbordered ? '' : (bordered ? (headRow ? 'not-last:border-e not-last:border-border-subtle' : 'not-last:border-e not-last:border-border-divider') : (headRow ? (scroll ? 'not-last:border-e not-last:border-border-divider' : 'not-last:border-e not-last:border-border-divider not-last:pe-3') : '')),
|
|
548
551
|
plan !== null && plan.selectSticky ? [headRow ? D.tableHeadCellSticky : D.tableCellSticky, headRow ? '' : stripeSticky, 'left-0'] : '',
|
|
549
552
|
);
|
|
550
553
|
const tail = (headRow: boolean): string => join(
|
|
@@ -560,8 +563,15 @@ export function collection(
|
|
|
560
563
|
const gridBorderedRow = (cls: string): string => cls.split(/\s+/).filter((t) => t !== '' && t !== 'gap-4' && t !== 'px-4' && t !== 'items-center' && !/^py-/.test(t)).concat(['gap-0', 'items-stretch']).join(' ');
|
|
561
564
|
const rowBase = scroll ? scrollRowClass(dens.row) : bordered ? gridBorderedRow(dens.row) : dens.row;
|
|
562
565
|
const headBase = scroll ? scrollRowClass(dens.head) : bordered ? gridBorderedRow(dens.head) : dens.head;
|
|
563
|
-
const
|
|
564
|
-
const
|
|
566
|
+
const rawSummaryRow = D.tableSummaryRow;
|
|
567
|
+
const summaryRowBase = unbordered
|
|
568
|
+
? rawSummaryRow.split(/\s+/).filter((t) => t !== "" && t !== "border-t" && !t.startsWith("border-border")).join(" ")
|
|
569
|
+
: rawSummaryRow;
|
|
570
|
+
const summaryRowClass = summary === null ? "" : join(plainRowClass(rowBase), summaryRowBase, virt !== null ? KIT_TABLE_VIRTUAL.summarySticky : "");
|
|
571
|
+
const rawWrapBase = scroll ? D.tableScrollWrap : sticky ? '' : D.tableWrap;
|
|
572
|
+
const wrapBase = unbordered
|
|
573
|
+
? rawWrapBase.split(/\s+/).filter((t) => t !== '' && t !== 'border' && !t.startsWith('border-border')).join(' ')
|
|
574
|
+
: rawWrapBase;
|
|
565
575
|
const rcw = rowClassWhenOf(view, !isTree, env);
|
|
566
576
|
return {
|
|
567
577
|
kind: 'table',
|
|
@@ -580,7 +590,7 @@ export function collection(
|
|
|
580
590
|
sort: head.some((h) => h.sort !== undefined || h.filter !== undefined),
|
|
581
591
|
stickyHeader: sticky,
|
|
582
592
|
stripeClass: striped ? D.tableRowStriped : '',
|
|
583
|
-
...(bordered ? { bordered:
|
|
593
|
+
...(c.bordered !== undefined ? { bordered: c.bordered } : {}),
|
|
584
594
|
density,
|
|
585
595
|
expand,
|
|
586
596
|
state: stateOf(c, env, `${env.path}.collection`),
|
|
@@ -601,6 +611,9 @@ export function collection(
|
|
|
601
611
|
}
|
|
602
612
|
|
|
603
613
|
styleChecks(view, c, env);
|
|
614
|
+
if (c.bordered !== undefined && typeof c.bordered !== 'boolean') {
|
|
615
|
+
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.bordered`, message: 'bordered 必须是布尔' });
|
|
616
|
+
}
|
|
604
617
|
for (const k of ['density', 'striped', 'virtual', 'columnGroups', 'resizable'] as const) {
|
|
605
618
|
if ((c as unknown as Record<string, unknown>)[k] !== undefined) {
|
|
606
619
|
env.diagnostics.push({ code: 'KIT-OBJ-009', path: `${env.path}.collection.${k}`, message: `${k} 仅用于 table 集合,已忽略` });
|
|
@@ -620,11 +633,15 @@ export function collection(
|
|
|
620
633
|
cols = 1;
|
|
621
634
|
}
|
|
622
635
|
const list = `${D.cardsList} ${gridColsClasses(gridLevels(cols))}`;
|
|
636
|
+
const rawCardsItem = D.cardsItem;
|
|
637
|
+
const cardsItem = c.bordered === false
|
|
638
|
+
? rawCardsItem.split(/\s+/).filter((t) => t !== "" && t !== "border" && !t.startsWith("border-border")).join(" ")
|
|
639
|
+
: rawCardsItem;
|
|
623
640
|
return {
|
|
624
641
|
kind: 'cards',
|
|
625
642
|
wrapClass: KIT_WIDTH.containerClass,
|
|
626
643
|
listClass: mergeClass(list, mergeClass(c.class ?? '', view.class), view.replaceClass),
|
|
627
|
-
itemClass: mergeClass(
|
|
644
|
+
itemClass: mergeClass(cardsItem, view.rowClass, view.replaceClass),
|
|
628
645
|
inner,
|
|
629
646
|
rowActions,
|
|
630
647
|
pager: optionalPagerOf(c.page),
|
|
@@ -633,11 +650,15 @@ export function collection(
|
|
|
633
650
|
};
|
|
634
651
|
}
|
|
635
652
|
|
|
653
|
+
const rawStackItem = D.stackItem;
|
|
654
|
+
const stackItem = c.bordered === false
|
|
655
|
+
? rawStackItem.split(/\s+/).filter((t) => t !== "" && t !== "border" && !t.startsWith("border-border")).join(" ")
|
|
656
|
+
: rawStackItem;
|
|
636
657
|
return {
|
|
637
658
|
kind: 'stack',
|
|
638
659
|
wrapClass: '',
|
|
639
660
|
listClass: mergeClass(D.stackList, mergeClass(c.class ?? '', view.class), view.replaceClass),
|
|
640
|
-
itemClass: mergeClass(
|
|
661
|
+
itemClass: mergeClass(stackItem, view.rowClass, view.replaceClass),
|
|
641
662
|
inner,
|
|
642
663
|
rowActions,
|
|
643
664
|
pager: optionalPagerOf(c.page),
|
|
@@ -494,6 +494,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
494
494
|
actionsClass: layout.actionsClass,
|
|
495
495
|
actions: actionItems(layout.rowActions, ctx),
|
|
496
496
|
...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
|
|
497
|
+
...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
|
|
497
498
|
...selectedProps(ctx),
|
|
498
499
|
},
|
|
499
500
|
};
|
|
@@ -504,7 +505,9 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
504
505
|
ctx.show[ctxMenuAnchor(object)] = { props: { menu: actionItems(layout.contextMenu!, ctx), mode: 'host' } };
|
|
505
506
|
treeCtx = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
506
507
|
}
|
|
507
|
-
const
|
|
508
|
+
const treeScrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
509
|
+
const treeWrapA11y = treeScrollable ? ` tabindex="0" role="region"${attr('aria-label', ctx.object)}` : '';
|
|
510
|
+
const treeBody = `<div${attr('class', layout.wrapClass)}${treeWrapA11y}${treeCtx !== '' ? ' data-kit-ctxhost=""' : ''}><div${attr('class', layout.innerClass)}>${head}${host('KitTreeTable', id)}${treeCtx}</div></div>`;
|
|
508
511
|
return `${treeBody}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
|
|
509
512
|
}
|
|
510
513
|
|
|
@@ -580,7 +583,7 @@ function renderTable(ctx: Ctx, layout: Extract<KitLayoutIR, { kind: 'table' }>):
|
|
|
580
583
|
);
|
|
581
584
|
itemHtml = `<div${attr('class', striped ? joinClasses(stripe, KIT_CLASS_DEFAULTS.tableRowStripedExpandOuter) : stripe)} data-kit-expand-row="">${rowEl}`
|
|
582
585
|
+ `<div${attr('class', EXPAND_TOGGLE_CLASS)}>${host('KitTableActions', expandToggleAnchor(object))}</div>`
|
|
583
|
-
+ `<div class="hidden" data-kit-expand-body=""><div${attr('class', EXPAND_BODY_CLASS)}>${detail}</div></div></div>`;
|
|
586
|
+
+ `<div class="hidden" data-kit-expand-body=""><div${attr('class', layout.bordered === false ? 'bg-surface-sunken px-4 py-3' : EXPAND_BODY_CLASS)}>${detail}</div></div></div>`;
|
|
584
587
|
}
|
|
585
588
|
const rowTemplate = `<template data-soma-role="item">${itemHtml}</template>`;
|
|
586
589
|
const rows = `<div data-soma-id="${esc(rowsAnchor(object))}"${tools ? ' data-kit-rows=""' : ''}>${rowTemplate}</div>`;
|
|
@@ -621,6 +624,7 @@ function renderVirtualTable(
|
|
|
621
624
|
actions: actionItems(layout.rowActions, ctx),
|
|
622
625
|
label: object,
|
|
623
626
|
colCount: layout.cells.length + (layout.select !== 'none' ? 1 : 0) + (layout.rowActions.length > 0 ? 1 : 0),
|
|
627
|
+
...(layout.bordered !== undefined ? { bordered: layout.bordered } : {}),
|
|
624
628
|
...(ctx.options.pickOnRow === true ? { pickOnRow: true } : {}),
|
|
625
629
|
...selectedProps(ctx),
|
|
626
630
|
},
|
|
@@ -633,7 +637,9 @@ function renderVirtualTable(
|
|
|
633
637
|
ctx.show[ctxMenuAnchor(object)] = { props: { menu: actionItems(layout.contextMenu!, ctx), rows: ctx.rowsPath, mode: 'virtual' } };
|
|
634
638
|
ctxHost = `<div class="hidden">${host('KitContextMenu', ctxMenuAnchor(object))}</div>`;
|
|
635
639
|
}
|
|
636
|
-
const
|
|
640
|
+
const scrollable = /\boverflow-[xy]-auto\b/.test(layout.wrapClass);
|
|
641
|
+
const wrapA11y = scrollable ? ` tabindex="0" role="region"${attr('aria-label', object)}` : '';
|
|
642
|
+
const body = `<div${attr('class', layout.wrapClass)}${wrapA11y} data-kit-vscroll=""${tools ? ' data-kit-table=""' : ''}>`
|
|
637
643
|
+ `<div role="grid"${attr('aria-label', object)}${attr('class', layout.innerClass)}>${head}${host('KitVirtualRows', id)}${ctxHost}${summary}</div></div>`;
|
|
638
644
|
return `${renderTools(ctx, layout)}${body}${renderState(ctx, layout.state, skeletonShapeOf(layout))}${renderPager(ctx, layout.pager)}`;
|
|
639
645
|
}
|
|
@@ -400,8 +400,8 @@ export type KitCollection =
|
|
|
400
400
|
resizable?: boolean;
|
|
401
401
|
} & KitCollectionStateDecl)
|
|
402
402
|
| ({ type: 'treeTable'; tree?: KitTreeDecl; select?: 'none' | 'single' | 'multi'; rowActions?: string[]; page?: KitPageDecl; stickyHeader?: boolean; density?: 'compact' | 'standard' | 'comfortable'; striped?: boolean; bordered?: boolean; contextMenu?: string[] } & KitCollectionStateDecl)
|
|
403
|
-
| ({ type: 'cards'; cols: 1 | 2 | 3 | 4 | 6; class?: string; rowActions?: string[]; page?: KitPageDecl; contextMenu?: string[] } & KitCollectionStateDecl)
|
|
404
|
-
| ({ type: 'stack'; class?: string; rowActions?: string[]; page?: KitPageDecl; contextMenu?: string[] } & KitCollectionStateDecl);
|
|
403
|
+
| ({ type: 'cards'; cols: 1 | 2 | 3 | 4 | 6; class?: string; rowActions?: string[]; page?: KitPageDecl; contextMenu?: string[]; bordered?: boolean } & KitCollectionStateDecl)
|
|
404
|
+
| ({ type: 'stack'; class?: string; rowActions?: string[]; page?: KitPageDecl; contextMenu?: string[]; bordered?: boolean } & KitCollectionStateDecl);
|
|
405
405
|
|
|
406
406
|
export interface KitViewForm {
|
|
407
407
|
/**
|