@dsh-workbench/shared 0.2.16 → 0.3.1
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/dist/components/Rows.css
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
.wb-rows {
|
|
2
|
-
display:
|
|
3
|
-
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: minmax(72px, max-content) minmax(0, 1fr);
|
|
4
|
+
column-gap: var(--wb-len-8);
|
|
5
|
+
}
|
|
6
|
+
.wb-rows > :not(.wb-row) {
|
|
7
|
+
grid-column: 1 / -1;
|
|
4
8
|
}
|
|
5
9
|
.wb-row {
|
|
6
10
|
display: grid;
|
|
11
|
+
grid-column: 1 / -1;
|
|
7
12
|
grid-template-columns: minmax(72px, max-content) minmax(0, 1fr);
|
|
8
13
|
align-items: baseline;
|
|
9
14
|
gap: var(--wb-len-8);
|
|
@@ -31,6 +31,7 @@ export declare const DEFAULT_WORKSPACE_TITLE = "default-workspace";
|
|
|
31
31
|
export declare const STORAGE_KEY_PROJECT = "dsh-workbench.project";
|
|
32
32
|
export declare const STORAGE_KEY_RIGHTBAR = "dsh-workbench.rightbar.expanded";
|
|
33
33
|
export declare const STORAGE_KEY_RIGHTBAR_COLUMN = "dsh-workbench.rightbar.column";
|
|
34
|
+
export declare const STORAGE_KEY_RIGHTBAR_WIDTH = "dsh-workbench.rightbar.width";
|
|
34
35
|
export declare const RIGHTBAR_FULLSCREEN_WIDTH = 768;
|
|
35
36
|
export declare const LOCALE_NS = "workbench";
|
|
36
37
|
export declare const LOCALES: readonly ["zh", "en"];
|
package/dist/config/constants.js
CHANGED
|
@@ -34,6 +34,7 @@ export const DEFAULT_WORKSPACE_TITLE = "default-workspace";
|
|
|
34
34
|
export const STORAGE_KEY_PROJECT = "dsh-workbench.project";
|
|
35
35
|
export const STORAGE_KEY_RIGHTBAR = "dsh-workbench.rightbar.expanded";
|
|
36
36
|
export const STORAGE_KEY_RIGHTBAR_COLUMN = "dsh-workbench.rightbar.column";
|
|
37
|
+
export const STORAGE_KEY_RIGHTBAR_WIDTH = "dsh-workbench.rightbar.width";
|
|
37
38
|
export const RIGHTBAR_FULLSCREEN_WIDTH = 768;
|
|
38
39
|
export const LOCALE_NS = "workbench";
|
|
39
40
|
export const LOCALES = ["zh", "en"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "工作台与模块共享的纯代码与契约类型:类型、纯逻辑、哑组件、平台解析。宿主侧的东西从 /host 进(不影响浏览器产物)。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@arch-guard/core": "^0.11.0",
|
|
33
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.1
|
|
33
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.2",
|
|
34
34
|
"@types/node": "^24.19.0",
|
|
35
35
|
"@types/react": "^19.0.0",
|
|
36
36
|
"@vitest/coverage-v8": "^5.0.2",
|
package/src/components/Rows.css
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
.wb-rows {
|
|
2
|
-
display:
|
|
3
|
-
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: minmax(72px, max-content) minmax(0, 1fr);
|
|
4
|
+
column-gap: var(--wb-len-8);
|
|
5
|
+
}
|
|
6
|
+
.wb-rows > :not(.wb-row) {
|
|
7
|
+
grid-column: 1 / -1;
|
|
4
8
|
}
|
|
5
9
|
.wb-row {
|
|
6
10
|
display: grid;
|
|
11
|
+
grid-column: 1 / -1;
|
|
7
12
|
grid-template-columns: minmax(72px, max-content) minmax(0, 1fr);
|
|
8
13
|
align-items: baseline;
|
|
9
14
|
gap: var(--wb-len-8);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { Row, Rows } from './Rows.js';
|
|
4
|
+
|
|
5
|
+
function texts(node: unknown): string[] {
|
|
6
|
+
if (node === null || node === undefined || typeof node === 'boolean') return [];
|
|
7
|
+
if (typeof node === 'string') return [node];
|
|
8
|
+
if (typeof node === 'number') return [String(node)];
|
|
9
|
+
if (Array.isArray(node)) return node.flatMap((one) => texts(one));
|
|
10
|
+
const element = node as { props?: { children?: unknown } };
|
|
11
|
+
return texts(element.props?.children);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function childrenOf(node: unknown): unknown[] {
|
|
15
|
+
return (node as { props: { children: unknown } }).props.children as unknown[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('Row', () => {
|
|
19
|
+
it('键、值按顺序落在两个 span 里(样式那两条选择器认的就是它们、且就认这一层)', () => {
|
|
20
|
+
const node = Row({ label: '环境', value: '生产' }) as unknown as {
|
|
21
|
+
props: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
const children = childrenOf(node) as { props: Record<string, unknown> }[];
|
|
24
|
+
|
|
25
|
+
expect(node.props['className']).toBe('wb-row');
|
|
26
|
+
expect(children.map((one) => one.props['className'])).toEqual(['wb-rowKey', 'wb-rowValue']);
|
|
27
|
+
expect(texts(node)).toEqual(['环境', '生产']);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('Rows 只是一层容器,不替调用点决定格子', () => {
|
|
31
|
+
const node = Rows({ children: '两行' }) as unknown as { props: Record<string, unknown> };
|
|
32
|
+
|
|
33
|
+
expect(node.props['className']).toBe('wb-rows');
|
|
34
|
+
expect(texts(node)).toEqual(['两行']);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const ROWS_CSS = readFileSync(new URL('./Rows.css', import.meta.url), 'utf8');
|
|
39
|
+
const FLEX_CONTAINER = `.wb-rows {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}`;
|
|
43
|
+
|
|
44
|
+
function declarationsIn(css: string, selector: string): string[] {
|
|
45
|
+
for (const block of css.split('}')) {
|
|
46
|
+
const [head, ...rest] = block.split('{');
|
|
47
|
+
if (rest.length === 0 || head === undefined) continue;
|
|
48
|
+
if (head.trim() !== selector) continue;
|
|
49
|
+
return rest
|
|
50
|
+
.join('{')
|
|
51
|
+
.split(';')
|
|
52
|
+
.map((one) => one.replace(/\s+/g, ' ').trim())
|
|
53
|
+
.filter((one) => one !== '');
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Rows.css 里没有这条规则:${selector}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function declarations(selector: string): string[] {
|
|
59
|
+
return declarationsIn(ROWS_CSS, selector);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function containerIsGrid(css: string): boolean {
|
|
63
|
+
return declarationsIn(css, '.wb-rows').includes('display: grid');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe('标签列:同一个 Rows 共用一列(ADR-0052 §12)', () => {
|
|
67
|
+
it('★ 容器自己必须是网格 —— 不是网格项的元素上 subgrid 算 none,两行当场塌成一列', () => {
|
|
68
|
+
expect(containerIsGrid(ROWS_CSS)).toBe(true);
|
|
69
|
+
expect(declarations('.wb-rows')).toContain(
|
|
70
|
+
'grid-template-columns: minmax(72px, max-content) minmax(0, 1fr)',
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('★ 反例:容器写回 flex(0.2.16 那次事故)—— 同一条判据当场判它不是网格', () => {
|
|
75
|
+
expect(containerIsGrid(FLEX_CONTAINER)).toBe(false);
|
|
76
|
+
expect(declarationsIn(FLEX_CONTAINER, '.wb-rows')).toContain('display: flex');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('★ 行先留回退两列,再由 subgrid 继承父网格那两列;行自己还得通栏', () => {
|
|
80
|
+
expect(declarations('.wb-row')).toContain(
|
|
81
|
+
'grid-template-columns: minmax(72px, max-content) minmax(0, 1fr)',
|
|
82
|
+
);
|
|
83
|
+
expect(declarations('.wb-row')).toContain('grid-column: 1 / -1');
|
|
84
|
+
expect(declarations('.wb-rows > .wb-row')).toContain('grid-template-columns: subgrid');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('★ 不是 Row 的子项(分组标题那种)通栏,别被塞进标签那一列', () => {
|
|
88
|
+
expect(declarations('.wb-rows > :not(.wb-row)')).toContain('grid-column: 1 / -1');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('★ 两处列距同值(subgrid 用的是行自己那条:不同值就是值左沿参差)', () => {
|
|
92
|
+
const rowGap = declarations('.wb-row').find((one) => one.startsWith('gap:'));
|
|
93
|
+
const rowsGap = declarations('.wb-rows').find((one) => one.startsWith('column-gap:'));
|
|
94
|
+
|
|
95
|
+
expect(rowGap).toBe('gap: var(--wb-len-8)');
|
|
96
|
+
expect(rowsGap).toBe('column-gap: var(--wb-len-8)');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('★ 标签不折行;值那一格能缩、长值能断词', () => {
|
|
100
|
+
expect(declarations('.wb-rowKey')).toContain('white-space: nowrap');
|
|
101
|
+
expect(declarations('.wb-rowValue')).toContain('min-width: 0');
|
|
102
|
+
expect(declarations('.wb-rowValue')).toContain('overflow-wrap: anywhere');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('★ 老浏览器解析期就丢掉 subgrid 那条 ⇒ 回退那两列仍要在册', () => {
|
|
106
|
+
expect(ROWS_CSS).toContain('@supports not (grid-template-columns: subgrid)');
|
|
107
|
+
expect(ROWS_CSS).toContain('.wb-rows > .wb-row');
|
|
108
|
+
});
|
|
109
|
+
});
|
package/src/config/constants.ts
CHANGED
|
@@ -65,6 +65,8 @@ export const STORAGE_KEY_RIGHTBAR = "dsh-workbench.rightbar.expanded";
|
|
|
65
65
|
|
|
66
66
|
export const STORAGE_KEY_RIGHTBAR_COLUMN = "dsh-workbench.rightbar.column";
|
|
67
67
|
|
|
68
|
+
export const STORAGE_KEY_RIGHTBAR_WIDTH = "dsh-workbench.rightbar.width";
|
|
69
|
+
|
|
68
70
|
export const RIGHTBAR_FULLSCREEN_WIDTH = 768;
|
|
69
71
|
|
|
70
72
|
export const LOCALE_NS = "workbench";
|