@manohub/ui 0.8.1 → 0.9.0

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.
@@ -1,163 +0,0 @@
1
- import { type PropType } from 'vue';
2
- /** 自适应高度的行数区间(`true` 等价于 `{ minRows: 3, maxRows: 12 }`) */
3
- export interface CodeEditorAutoSize {
4
- minRows?: number;
5
- maxRows?: number;
6
- }
7
- /** `CodeEditor` 的公开 props */
8
- export interface CodeEditorProps {
9
- /** 受控值 */
10
- modelValue?: string;
11
- /** 非受控初始值 */
12
- defaultValue?: string;
13
- /** 空值提示 */
14
- placeholder?: string;
15
- /** 固定可见行数(`autoSize: false` 时生效;缺省 4) */
16
- rows?: number;
17
- /**
18
- * 按内容行数自适应高度(**本件缺省开启**,与 `Textarea` 的缺省相反:
19
- * 代码区按内容长高是常态,固定行数才是特例)。
20
- */
21
- autoSize?: boolean | CodeEditorAutoSize;
22
- /** 最大高度(数字按 px):超出后**框内滚动** */
23
- maxHeight?: string | number;
24
- /** 只读态(原生 `readonly`:仍可选中、可滚动、可复制,只是不可改) */
25
- readonly?: boolean;
26
- /** 禁用态 */
27
- disabled?: boolean;
28
- /** 右上角语言角标(如 `sql` / `json`);只做标注,**不做语法高亮** */
29
- language?: string;
30
- /** 值变更回调(每次输入都调) */
31
- onChange?: (v: string) => void;
32
- }
33
- /**
34
- * 可编辑代码区(**自绘**;等宽多行 + 按行自适应 + 可限高内滚 + 只读/禁用态)。
35
- *
36
- * 与只读展示件 `Code` 是一对:**看**用 `Code`(可按只读块观感渲染已高亮节点),
37
- * **改**用本件。两件视觉同源(同底 / 同圆角 / 同等宽字),互切时块体不跳。
38
- *
39
- * ## 与 `Textarea` 的分工(不要重复造)
40
- *
41
- * 表单里的普通多行文本用 `Input.Textarea`;本件服务**代码**:等宽字、去掉拼写检查与自动大写、
42
- * 折行行为按代码区的口径来。两者共用同一套受控词表(`modelValue` / `onChange` / `readonly` / `disabled`)。
43
- *
44
- * ## 不做的事(有意)
45
- *
46
- * - **不做语法高亮**:编辑态就是原生 `textarea`,着色一律交给消费方(只读态用 `Code` 的插槽接高亮);
47
- * - **不内建动作按钮**(编辑 / 保存 / 取消 / 复制):动作条由消费方在外部摆放,本件只负责"能改";
48
- * - 不做行号、不做 Tab 缩进接管(会与浏览器的焦点导航与粘贴行为打架)。
49
- *
50
- * ## 自适应高度怎么算
51
- *
52
- * 按 `\n` **计数行数**在 `minRows` / `maxRows` 间截断(同 `Input.Textarea`):不测 `scrollHeight`
53
- * ——那要在每次输入后读布局(强制同步回流),且软换行 / 隐藏容器 / SSR 下都拿不到可靠值。
54
- * 代价是**超长单行不会自己长高**(此时由 `maxHeight` + 框内滚动兜底,或由外层容器限宽)。
55
- *
56
- * @example 受控
57
- * <CodeEditor v-model="sql" language="sql" placeholder="写一条 SQL" />
58
- *
59
- * @example 固定高度 + 限高内滚
60
- * <CodeEditor v-model="config" :auto-size="false" :rows="6" :max-height="240" language="json" />
61
- *
62
- * @example 只读切换(动作按钮由外部摆放)
63
- * <CodeEditor v-model="draft" :readonly="!editing" :max-height="320" />
64
- * <Button v-if="!editing" @click="editing = true">编辑</Button>
65
- */
66
- export declare const CodeEditor: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
67
- modelValue: {
68
- type: StringConstructor;
69
- default: undefined;
70
- };
71
- defaultValue: {
72
- type: StringConstructor;
73
- default: string;
74
- };
75
- placeholder: {
76
- type: StringConstructor;
77
- default: undefined;
78
- };
79
- rows: {
80
- type: NumberConstructor;
81
- default: undefined;
82
- };
83
- autoSize: {
84
- type: PropType<boolean | CodeEditorAutoSize>;
85
- default: boolean;
86
- };
87
- maxHeight: {
88
- type: PropType<string | number>;
89
- default: undefined;
90
- };
91
- readonly: {
92
- type: BooleanConstructor;
93
- default: boolean;
94
- };
95
- disabled: {
96
- type: BooleanConstructor;
97
- default: boolean;
98
- };
99
- language: {
100
- type: StringConstructor;
101
- default: string;
102
- };
103
- onChange: {
104
- type: PropType<(v: string) => void>;
105
- default: undefined;
106
- };
107
- }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
108
- 'update:modelValue': (v: string) => true;
109
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
110
- modelValue: {
111
- type: StringConstructor;
112
- default: undefined;
113
- };
114
- defaultValue: {
115
- type: StringConstructor;
116
- default: string;
117
- };
118
- placeholder: {
119
- type: StringConstructor;
120
- default: undefined;
121
- };
122
- rows: {
123
- type: NumberConstructor;
124
- default: undefined;
125
- };
126
- autoSize: {
127
- type: PropType<boolean | CodeEditorAutoSize>;
128
- default: boolean;
129
- };
130
- maxHeight: {
131
- type: PropType<string | number>;
132
- default: undefined;
133
- };
134
- readonly: {
135
- type: BooleanConstructor;
136
- default: boolean;
137
- };
138
- disabled: {
139
- type: BooleanConstructor;
140
- default: boolean;
141
- };
142
- language: {
143
- type: StringConstructor;
144
- default: string;
145
- };
146
- onChange: {
147
- type: PropType<(v: string) => void>;
148
- default: undefined;
149
- };
150
- }>> & Readonly<{
151
- "onUpdate:modelValue"?: ((v: string) => any) | undefined;
152
- }>, {
153
- disabled: boolean;
154
- onChange: (v: string) => void;
155
- defaultValue: string;
156
- placeholder: string;
157
- rows: number;
158
- modelValue: string;
159
- readonly: boolean;
160
- autoSize: boolean | CodeEditorAutoSize;
161
- language: string;
162
- maxHeight: string | number;
163
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,98 +0,0 @@
1
- import { defineComponent, ref, computed, createVNode } from "vue";
2
- const CodeEditor = /* @__PURE__ */ defineComponent({
3
- name: "CodeEditor",
4
- inheritAttrs: false,
5
- props: {
6
- modelValue: {
7
- type: String,
8
- default: void 0
9
- },
10
- defaultValue: {
11
- type: String,
12
- default: ""
13
- },
14
- placeholder: {
15
- type: String,
16
- default: void 0
17
- },
18
- rows: {
19
- type: Number,
20
- default: void 0
21
- },
22
- autoSize: {
23
- type: [Boolean, Object],
24
- default: true
25
- },
26
- maxHeight: {
27
- type: [String, Number],
28
- default: void 0
29
- },
30
- readonly: {
31
- type: Boolean,
32
- default: false
33
- },
34
- disabled: {
35
- type: Boolean,
36
- default: false
37
- },
38
- language: {
39
- type: String,
40
- default: ""
41
- },
42
- onChange: {
43
- type: Function,
44
- default: void 0
45
- }
46
- },
47
- emits: {
48
- "update:modelValue": (v) => true
49
- },
50
- setup(props, {
51
- emit,
52
- attrs
53
- }) {
54
- const inner = ref(props.defaultValue);
55
- const current = computed(() => props.modelValue ?? inner.value);
56
- const visibleRows = computed(() => {
57
- if (props.autoSize === false) return props.rows ?? 4;
58
- const option = typeof props.autoSize === "object" ? props.autoSize : {};
59
- const min = option.minRows ?? 3;
60
- const max = option.maxRows ?? 12;
61
- const lines = (current.value ?? "").split("\n").length;
62
- return Math.min(Math.max(lines, min), max);
63
- });
64
- const areaStyle = computed(() => props.maxHeight === void 0 ? void 0 : {
65
- maxHeight: typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight,
66
- overflow: "auto"
67
- });
68
- const onInput = (event) => {
69
- const el = event.target;
70
- const value = el.value;
71
- if (props.modelValue === void 0) inner.value = value;
72
- emit("update:modelValue", value);
73
- props.onChange?.(value);
74
- if (props.modelValue !== void 0 && props.modelValue !== value) el.value = props.modelValue;
75
- };
76
- return () => createVNode("div", {
77
- "class": ["mh-code-editor", attrs.class].filter(Boolean).join(" "),
78
- "style": attrs.style
79
- }, [createVNode("textarea", {
80
- "class": "mh-code-editor__area",
81
- "rows": visibleRows.value,
82
- "value": current.value,
83
- "placeholder": props.placeholder,
84
- "readonly": props.readonly,
85
- "disabled": props.disabled,
86
- "style": areaStyle.value,
87
- "spellcheck": false,
88
- "autocapitalize": "off",
89
- "autocomplete": "off",
90
- "onInput": onInput
91
- }, null), props.language ? createVNode("span", {
92
- "class": "mh-code-editor__lang"
93
- }, [props.language]) : null]);
94
- }
95
- });
96
- export {
97
- CodeEditor
98
- };
@@ -1,91 +0,0 @@
1
- /**
2
- * CodeEditor —— 可编辑代码区(等宽多行 + 按行自适应 + 可限高内滚 + 只读/禁用态)。
3
- *
4
- * 与 `Code`(只读展示)**视觉同源**:同一份底(`--ui-base-200`)、同一个圆角档(`--ui-radius-control`)、
5
- * 同一族等宽字与字号(`--ui-font-mono` / `--ui-font-caption`)—— 两件互切时块体不"跳"。
6
- *
7
- * 两处**有意**的差别(改之前先读):
8
- *
9
- * 1. 本件**画框的是容器**(`.mh-code-editor`),内部 `textarea` 透明、无边框、无 outline ——
10
- * 原生 `textarea` 的框模型(内距 / 滚动条 / 聚焦轮廓)会把框画歪,收归容器才能与只读块对齐;
11
- * 2. 代码块缺省**横向滚动**,本件是**软换行**(`textarea` 的原生行为):编辑态不折行会让长行看不见尾巴。
12
- *
13
- * 状态一律走**原生属性**(`[readonly]` / `:disabled` / `:focus-within`),组件不下发 `data-*`:
14
- * 只读与禁用本就有原生表达,多一套协议就多一处会漂的真相。
15
- *
16
- * ⚠️ 令牌**不复用** `code.css` 的 `--ui-code-*`:那些只服务 `Code` 单件,跨件复用按硬约束要迁进
17
- * `theme/`(跨件共用令牌单一来源)。本件只有几何,色 / 圆角 / 字族一律直接取 theme 令牌。
18
- */
19
- .mh-code-editor {
20
-
21
- position: relative;
22
- display: block;
23
- border-radius: var(--ui-code-editor-radius);
24
- background: var(--ui-base-200); /* 与只读块同底 */
25
- font-family: var(--ui-font-mono);
26
- font-size: var(--ui-code-editor-font-size);
27
- line-height: var(--ui-code-editor-line);
28
- color: var(--ui-base-content);
29
- transition: box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
30
- }
31
- /* 聚焦环:与输入框族同一句(主色弱底当环,不新造阴影令牌) */
32
- .mh-code-editor:focus-within {
33
- box-shadow: 0 0 0 2px var(--ui-primary-weak);
34
- }
35
-
36
- /* 编辑区:透明底 + 无框 + 无 outline(框与聚焦环都画在容器上) */
37
- .mh-code-editor__area {
38
- display: block;
39
- width: 100%;
40
- margin: 0;
41
- padding: var(--ui-code-editor-padding-y) var(--ui-code-editor-padding-x);
42
- border: 0;
43
- border-radius: inherit;
44
- background: transparent;
45
- font: inherit;
46
- line-height: inherit;
47
- color: inherit;
48
- outline: none;
49
- resize: none; /* 高度由 autoSize / maxHeight 决定,不留拖拽把手(同只读块:不被用户拖变形) */
50
- overflow: auto;
51
- tab-size: 2;
52
- }
53
- .mh-code-editor__area::placeholder {
54
- color: var(--ui-base-content-subtle);
55
- }
56
-
57
- /* 语言角标(可选):与只读块的角标同槽位。本件**不叠在文字上**(编辑区内容会折行,压住就看不见了),
58
- 而是让首行右端**预留**出它的宽度 —— 预留只影响折行位置,短行看不见任何变化 */
59
- .mh-code-editor__lang {
60
- position: absolute;
61
- top: var(--ui-code-editor-padding-y);
62
- right: var(--ui-code-editor-padding-x);
63
- display: flex;
64
- align-items: center;
65
- height: var(--ui-code-editor-line);
66
- font-family: var(--ui-font-mono);
67
- font-size: var(--ui-code-editor-font-size);
68
- line-height: 1;
69
- color: var(--ui-base-content-subtle);
70
- user-select: none;
71
- pointer-events: none;
72
- }
73
- .mh-code-editor:has(> .mh-code-editor__lang) > .mh-code-editor__area {
74
- padding-right: calc(var(--ui-code-editor-padding-x) + var(--ui-code-editor-lang-reserve));
75
- }
76
-
77
- /* 只读态(原生 `readonly`:仍可选中、可滚动、可复制,只是不可改)——不弱化字色,
78
- 代码是拿来读的;与只读块观感一致 */
79
- .mh-code-editor:has(> .mh-code-editor__area[readonly]) {
80
- cursor: default;
81
- }
82
-
83
- /* 禁用态:底与字色弱化 + 内描边(本件没有外描边,靠内描边表达"锁住") */
84
- .mh-code-editor:has(> .mh-code-editor__area:disabled) {
85
- background: var(--ui-base-100);
86
- color: var(--ui-base-content-subtle);
87
- box-shadow: inset 0 0 0 1px var(--ui-base-300);
88
- }
89
- .mh-code-editor:has(> .mh-code-editor__area:disabled) > .mh-code-editor__area {
90
- cursor: not-allowed;
91
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * code-editor —— 单件令牌(**基础值**)。
3
- *
4
- * 本件自己的几何 / 尺寸 / 色彩槽位;只服务本件,故不随主题进 `@manohub/theme`。
5
- *
6
- * ## 抽出说明
7
- * 本文件从面文件里抽出(原先混写在 `code-editor.css` 顶部):这些是**基础值**,锚在
8
- * `[data-manohub-ui]` —— 跨包唯一作用域锚,由入口层无条件写在应用容器上,因此**任何落在
9
- * 容器里的分件都取得到值**,不再依赖「声明在某个组件根类上」这条脆弱假设
10
- * (历史症状:跨件消费的 `--ui-*-group-*` 取不到值,组内间距变 0)。
11
- *
12
- * ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里 —— 它们靠「同一元素上两个
13
- * 选择器改写同一个令牌」生效,搬到本文件会让档位失效。
14
- * ⚠️ 新增组件要登记两处:本文件 + `src/styles/index.css`(见其文件头「五处齐备」)。
15
- */
16
- [data-manohub-ui] {
17
- /* 单件令牌(只服务本件:几何) */
18
- --ui-code-editor-radius: var(--ui-radius-control); /* 6:与只读块同档(原注释写 8,是旧稿残留) */
19
- --ui-code-editor-padding-x: var(--ui-space-3); /* 12 */
20
- --ui-code-editor-padding-y: var(--ui-space-2); /* 8 */
21
- --ui-code-editor-font-size: var(--ui-font-caption); /* 13:与只读块同档 */
22
- --ui-code-editor-line: var(--ui-line-caption); /* 20:行高(角标也吃它) */
23
- --ui-code-editor-lang-reserve: 56px; /* 角标位:首行右端预留宽度(只影响折行位置) */
24
- }
@@ -1,153 +0,0 @@
1
- /**
2
- * Code —— 代码(行内 chip + 代码块 + 语言角标 + 复制位)。
3
- *
4
- * 观感基准:**无边框浅底块 + 方圆角 + 右上角语言角标 + 悬浮/聚焦让位后出现的方形图标复制按钮**。
5
- * 出处:`@aihub/theme` 的 `playground/components/code.css` 与 `src/components/code.css`
6
- * (行内 chip 主色字 + 浅底、圆角全;`--plain` 档中性底 + 小圆角;代码块 = 页面底 + 等宽字 + 内距 12)。
7
- *
8
- * 三件结构决定(照规范的分工,不另创):
9
- *
10
- * - **复制按钮的面仍归按钮族**(`.mh-button--icon`),本族只补「浮在代码块上需要自己的底与定位」;
11
- * 故标记是 `class="mh-button mh-button--icon mh-code__copy"`。
12
- * - **复制按钮与语言角标都不能放进代码块里**:代码块是 `overflow-x: auto` 的滚动容器,
13
- * 会裁掉外挂的绝对定位件 —— 故两者都挂在宿主 `.mh-code__wrap` 上(宿主只做 `position: relative`)。
14
- * - **隐藏用 `opacity` + `pointer-events`**(不是 `visibility` / `display`):键盘仍能 Tab 到它,
15
- * `:focus-within` 会把它显出来,且隐藏时不残留一块看不见的可点区。
16
- *
17
- * **本族与按钮族的层序**(改这几条规则前先读):`styles/index.css` 里 `code.css` 在 `button.css`
18
- * **之前**导入,故 `background` / `color` / `box-shadow` 这些**同特异性的声明会被按钮族的档位规则压掉**
19
- * (历史 bug:`.mh-code__copy` 的白底被 `.mh-button--text { background: transparent }` 压成透明,
20
- * 复制位看起来像一段悬空文字)。修法不是调层序,而是让本族的声明**升一档特异性**
21
- * (`.mh-code__wrap > .mh-code__copy`,悬停 / 成功态再各叠一层)—— 按钮族日后换皮肤也压不掉它。
22
- *
23
- * 零 JS 可表达:全部皮肤 + 角标让位 + 复制位的显隐。**真正的复制动作归组件层**(要 `navigator.clipboard`)。
24
- */
25
-
26
- /* 几何只挂在行内 chip 上:令牌在同名 `.tokens.css`(锚 `[data-manohub-ui]`),几何若跟着挂会把壳与块级元素也画成 chip */
27
- .mh-code {
28
- display: inline-flex;
29
- align-items: center;
30
- padding: 1px var(--ui-space-3);
31
- border-radius: var(--ui-radius-full);
32
- background: var(--ui-code-chip-bg);
33
- color: var(--ui-primary);
34
- font-family: var(--ui-font-mono);
35
- font-size: var(--ui-code-font-size);
36
- }
37
-
38
- /* 中性档(规范 `.chip--plain`:规则 ID 这类不强调的短标识) */
39
- .mh-code--plain {
40
- background: var(--ui-code-block-bg);
41
- color: var(--ui-base-content);
42
- border-radius: var(--ui-code-radius);
43
- }
44
-
45
- /* 代码块:无边框浅底 + 方圆角;**缺省不折行**(保持 `pre` 的横向滚动,缩进与列对齐不被破坏),
46
- `--wrap` 档才软换行 */
47
- .mh-code--block {
48
- display: block;
49
- margin: var(--ui-space-2) 0 0;
50
- padding: var(--ui-code-block-padding);
51
- border: 0;
52
- border-radius: var(--ui-code-radius);
53
- background: var(--ui-code-block-bg);
54
- font-family: var(--ui-font-mono);
55
- font-size: var(--ui-code-font-size);
56
- line-height: var(--ui-code-line);
57
- color: var(--ui-base-content);
58
- overflow-x: auto;
59
- white-space: pre;
60
- overflow-wrap: normal;
61
- }
62
-
63
- /* 宿主:给复制位与语言角标一个不受裁切的定位上下文;同时把「缺省不折行」的代价收在块内 ——
64
- `min-width: 0` 让它在 flex / grid 里能被压到容器宽度(否则长行的 min-content 会把轨道撑宽、
65
- 页面跟着横向溢出),长行改为块内横向滚动。 */
66
- .mh-code__wrap {
67
- position: relative;
68
- min-width: 0;
69
- }
70
-
71
- /* 语言角标(可选):与复制位**同槽位**,悬浮/聚焦时淡出让位(零 JS 互斥)。
72
- 装饰位:不吃指针事件,否则它会挡住复制位的悬停热区 */
73
- .mh-code__lang {
74
- position: absolute;
75
- top: var(--ui-code-copy-inset);
76
- right: var(--ui-code-copy-inset);
77
- display: flex;
78
- align-items: center;
79
- height: var(--ui-code-copy-size); /* 与复制位等高:让位互换时基线不跳 */
80
- font-family: var(--ui-font-mono);
81
- font-size: var(--ui-code-font-size);
82
- line-height: 1;
83
- color: var(--ui-base-content-subtle);
84
- user-select: none;
85
- pointer-events: none;
86
- transition: opacity 0.15s ease;
87
- }
88
- .mh-code__wrap:hover > .mh-code__lang,
89
- .mh-code__wrap:focus-within > .mh-code__lang,
90
- .mh-code__wrap.is-hover > .mh-code__lang {
91
- opacity: 0;
92
- }
93
-
94
- /* 复制位(面归按钮族,这里只给定位、浮底、方形几何、显隐)。
95
- 选择器**刻意升一档**(`.mh-code__wrap >`):同特异性下按钮族的档位规则会压掉这几条(见文件头) */
96
- .mh-code__wrap > .mh-code__copy {
97
- position: absolute;
98
- top: var(--ui-code-copy-inset);
99
- right: var(--ui-code-copy-inset);
100
- width: var(--ui-code-copy-size);
101
- height: var(--ui-code-copy-size);
102
- padding: 0;
103
- border: 1px solid var(--ui-code-block-line);
104
- border-radius: var(--ui-radius-sm);
105
- background: var(--ui-base-100);
106
- color: var(--ui-base-content);
107
- box-shadow: none; /* 压掉图标按钮 hover 档的卡片光晕(本件浮在块上,再加影会脏) */
108
- opacity: 0;
109
- pointer-events: none;
110
- transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
111
- }
112
- /* 显形:宿主悬停 / 键盘聚焦进入(`.is-hover` 是**静态档**,供静态页与读图对状态,与全库同款三源等价) */
113
- .mh-code__wrap:hover > .mh-code__copy,
114
- .mh-code__wrap:focus-within > .mh-code__copy,
115
- .mh-code__wrap.is-hover > .mh-code__copy {
116
- opacity: 1;
117
- pointer-events: auto;
118
- }
119
- /* 悬停 / 键盘聚焦的加深档(再叠一层,压过 `.mh-button--icon:hover` 的字色与光晕) */
120
- .mh-code__wrap > .mh-code__copy:hover,
121
- .mh-code__wrap > .mh-code__copy:focus-visible,
122
- .mh-code__wrap.is-hover > .mh-code__copy {
123
- border-color: var(--ui-base-content-subtle);
124
- color: var(--ui-primary);
125
- box-shadow: none;
126
- }
127
-
128
- /* 复制成功态(组件下发 `data-state`;原生无此态,静态档 `.is-copied` 供读图) */
129
- .mh-code__wrap > .mh-code__copy.is-copied,
130
- .mh-code__wrap > .mh-code__copy[data-state='copied'] {
131
- border-color: var(--ui-success);
132
- color: var(--ui-success);
133
- opacity: 1;
134
- pointer-events: auto;
135
- }
136
-
137
- /* 无悬停能力的设备(触屏):复制位常显;角标让位(`display: none` 而非透明 —— 它只是装饰,
138
- 不占焦点序列,隐藏掉才不会与常显的复制位叠在一起) */
139
- @media (hover: none) {
140
- .mh-code__wrap > .mh-code__copy {
141
- opacity: 1;
142
- pointer-events: auto;
143
- }
144
- .mh-code__lang {
145
- display: none;
146
- }
147
- }
148
-
149
- /* ===== 软换行档(缺省保持 `pre` 的横向不换行 + 横向滚动) ===== */
150
- .mh-code--wrap {
151
- white-space: pre-wrap;
152
- overflow-wrap: anywhere;
153
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * code —— 单件令牌(**基础值**)。
3
- *
4
- * 本件自己的几何 / 尺寸 / 色彩槽位;只服务本件,故不随主题进 `@manohub/theme`。
5
- *
6
- * ## 抽出说明
7
- * 本文件从面文件里抽出(原先混写在 `code.css` 顶部):这些是**基础值**,锚在
8
- * `[data-manohub-ui]` —— 跨包唯一作用域锚,由入口层无条件写在应用容器上,因此**任何落在
9
- * 容器里的分件都取得到值**,不再依赖「声明在某个组件根类上」这条脆弱假设
10
- * (历史症状:跨件消费的 `--ui-*-group-*` 取不到值,组内间距变 0)。
11
- *
12
- * ⚠️ `.mh-<件>--<档>` 这类**档位改写**留在面文件的修饰符块里 —— 它们靠「同一元素上两个
13
- * 选择器改写同一个令牌」生效,搬到本文件会让档位失效。
14
- * ⚠️ 新增组件要登记两处:本文件 + `src/styles/index.css`(见其文件头「五处齐备」)。
15
- */
16
- [data-manohub-ui] {
17
- /* 单件令牌(也挂到外层容器与块级元素上:块级 `<pre>` 是 `.mh-code__wrap` 的子元素、
18
- 并不带 `.mh-code`(行内 chip)类,只在 `.mh-code` 上声明会让块级与复制位全部取不到值) */
19
- --ui-code-chip-bg: var(--ui-primary-weak); /* 规范 Au02 行内底 */
20
- --ui-code-block-bg: var(--ui-base-200); /* 规范代码块底(页面底 Ne11) */
21
- --ui-code-block-line: var(--ui-base-300); /* 描边色:块自身已去边框,本令牌现服务复制位按钮 */
22
- --ui-code-radius: var(--ui-radius-control);
23
- --ui-code-font-size: var(--ui-font-caption); /* 规范等宽字号档对位 */
24
- --ui-code-line: var(--ui-line-caption); /* 等宽行高:角标与复制位的行高同源 */
25
- --ui-code-block-padding: var(--ui-space-3); /* 12:代码块内距 */
26
- --ui-code-copy-size: var(--ui-control-height-md); /* 32:复制位方形热区(与按钮族标准档同高) */
27
- /* 复制位是 `Button`(`mh-button__icon`):字形尺寸归按钮族的图标槽(常规图标档),本件不另设令牌 */
28
- --ui-code-copy-inset: var(--ui-space-2); /* 8:复制位 / 角标距块边 */
29
- }