@fangxinyan/lumina 0.1.2 → 0.1.3
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/Typography-NKPWTJCV.css +235 -0
- package/dist/Typography.cjs +29 -0
- package/dist/Typography.cjs.map +1 -0
- package/dist/Typography.d.cts +151 -0
- package/dist/Typography.d.ts +151 -0
- package/dist/Typography.js +4 -0
- package/dist/Typography.js.map +1 -0
- package/dist/chunk-5WF6M47X.cjs +510 -0
- package/dist/chunk-5WF6M47X.cjs.map +1 -0
- package/dist/chunk-GZGZR4FT.js +484 -0
- package/dist/chunk-GZGZR4FT.js.map +1 -0
- package/dist/index.cjs +22 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +217 -0
- package/package.json +1 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Typography
|
|
3
|
+
* ========================================================================== */
|
|
4
|
+
|
|
5
|
+
.typo-root {
|
|
6
|
+
font-family: var(--font-sans);
|
|
7
|
+
color: var(--fg);
|
|
8
|
+
line-height: 1.7;
|
|
9
|
+
font-size: 14px;
|
|
10
|
+
}
|
|
11
|
+
.typo-root > * + * { margin-top: 0.85em; }
|
|
12
|
+
.typo-root .typo-title + .typo-paragraph,
|
|
13
|
+
.typo-root .typo-paragraph + .typo-paragraph { margin-top: 1em; }
|
|
14
|
+
.typo-root .typo-title { margin-top: 1.2em; }
|
|
15
|
+
.typo-root > .typo-title:first-child { margin-top: 0; }
|
|
16
|
+
|
|
17
|
+
/* ---- Base ---- */
|
|
18
|
+
.typo {
|
|
19
|
+
color: var(--fg);
|
|
20
|
+
font-family: var(--font-sans);
|
|
21
|
+
word-wrap: break-word;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Semantic colors */
|
|
25
|
+
.typo.secondary { color: var(--fg-muted); }
|
|
26
|
+
.typo.success { color: var(--success); }
|
|
27
|
+
.typo.warning { color: var(--warning); }
|
|
28
|
+
.typo.danger { color: var(--danger); }
|
|
29
|
+
.typo.disabled { color: var(--fg-subtle); cursor: not-allowed; user-select: none; }
|
|
30
|
+
|
|
31
|
+
/* Decorations */
|
|
32
|
+
.typo.strong { font-weight: 600; }
|
|
33
|
+
.typo.italic { font-style: italic; }
|
|
34
|
+
.typo.underline { text-decoration: underline; text-underline-offset: 3px; }
|
|
35
|
+
.typo.del { text-decoration: line-through; text-decoration-thickness: 1.5px; }
|
|
36
|
+
|
|
37
|
+
/* mark / code / kbd render their own elements; we still color the shell */
|
|
38
|
+
.typo mark {
|
|
39
|
+
background: color-mix(in oklch, var(--warning) 35%, transparent);
|
|
40
|
+
color: inherit;
|
|
41
|
+
padding: 0 3px;
|
|
42
|
+
border-radius: 3px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.typo code {
|
|
46
|
+
font-family: var(--font-mono);
|
|
47
|
+
font-size: 0.88em;
|
|
48
|
+
padding: 1px 6px;
|
|
49
|
+
border-radius: 5px;
|
|
50
|
+
background: var(--bg-sunken);
|
|
51
|
+
box-shadow: var(--neu-in-sm);
|
|
52
|
+
color: var(--accent-ink);
|
|
53
|
+
margin: 0 2px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.typo kbd {
|
|
57
|
+
font-family: var(--font-mono);
|
|
58
|
+
font-size: 0.82em;
|
|
59
|
+
padding: 1px 7px;
|
|
60
|
+
border-radius: 5px;
|
|
61
|
+
background: var(--bg-raised);
|
|
62
|
+
box-shadow: var(--neu-flat);
|
|
63
|
+
border: 1px solid var(--border);
|
|
64
|
+
color: var(--fg);
|
|
65
|
+
margin: 0 2px;
|
|
66
|
+
line-height: 1.4;
|
|
67
|
+
display: inline-block;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* ---- Title ---- */
|
|
71
|
+
.typo-title {
|
|
72
|
+
display: block;
|
|
73
|
+
font-family: var(--font-display);
|
|
74
|
+
font-weight: 700;
|
|
75
|
+
letter-spacing: -0.01em;
|
|
76
|
+
line-height: 1.25;
|
|
77
|
+
color: var(--fg);
|
|
78
|
+
margin: 0;
|
|
79
|
+
}
|
|
80
|
+
.typo-title.h1 { font-size: 32px; letter-spacing: -0.02em; }
|
|
81
|
+
.typo-title.h2 { font-size: 26px; letter-spacing: -0.015em; }
|
|
82
|
+
.typo-title.h3 { font-size: 21px; }
|
|
83
|
+
.typo-title.h4 { font-size: 17px; }
|
|
84
|
+
.typo-title.h5 { font-size: 14px; }
|
|
85
|
+
|
|
86
|
+
/* ---- Paragraph ---- */
|
|
87
|
+
.typo-paragraph {
|
|
88
|
+
display: block;
|
|
89
|
+
font-size: 14px;
|
|
90
|
+
line-height: 1.75;
|
|
91
|
+
margin: 0;
|
|
92
|
+
color: var(--fg);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* ---- Text ---- */
|
|
96
|
+
.typo-text { font-size: inherit; line-height: inherit; }
|
|
97
|
+
|
|
98
|
+
/* ---- Link ---- */
|
|
99
|
+
.typo-link {
|
|
100
|
+
color: var(--accent-ink);
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
transition: color var(--dur-fast) var(--ease), text-decoration-color var(--dur-fast) var(--ease);
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
text-underline-offset: 3px;
|
|
105
|
+
display: inline-flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
gap: 3px;
|
|
108
|
+
}
|
|
109
|
+
.typo-link:hover { color: var(--accent); text-decoration: underline; }
|
|
110
|
+
.typo-link:focus-visible {
|
|
111
|
+
outline: 2px solid var(--accent-glow);
|
|
112
|
+
outline-offset: 2px;
|
|
113
|
+
border-radius: 2px;
|
|
114
|
+
}
|
|
115
|
+
.typo-link.disabled {
|
|
116
|
+
color: var(--fg-subtle);
|
|
117
|
+
cursor: not-allowed;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
text-decoration: none;
|
|
120
|
+
}
|
|
121
|
+
.typo-link-ext {
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
opacity: 0.7;
|
|
125
|
+
transform: rotate(-45deg);
|
|
126
|
+
transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
|
|
127
|
+
}
|
|
128
|
+
.typo-link:hover .typo-link-ext { opacity: 1; transform: rotate(-45deg) translateX(1px); }
|
|
129
|
+
|
|
130
|
+
/* ---- Action affordances (copy / edit) ---- */
|
|
131
|
+
.typo-action {
|
|
132
|
+
display: inline-flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
width: 22px;
|
|
136
|
+
height: 22px;
|
|
137
|
+
margin-left: 6px;
|
|
138
|
+
border-radius: 7px;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
color: var(--fg-subtle);
|
|
141
|
+
transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
|
|
142
|
+
vertical-align: middle;
|
|
143
|
+
user-select: none;
|
|
144
|
+
}
|
|
145
|
+
.typo-action:hover {
|
|
146
|
+
color: var(--accent-ink);
|
|
147
|
+
background: var(--bg);
|
|
148
|
+
box-shadow: var(--neu-flat);
|
|
149
|
+
}
|
|
150
|
+
.typo-action:focus-visible {
|
|
151
|
+
outline: 2px solid var(--accent-glow);
|
|
152
|
+
outline-offset: 1px;
|
|
153
|
+
}
|
|
154
|
+
.typo-copy.copied { color: var(--success); }
|
|
155
|
+
|
|
156
|
+
/* Editable text trigger overlays */
|
|
157
|
+
.typo-edit-text-trigger {
|
|
158
|
+
cursor: text;
|
|
159
|
+
border-radius: 4px;
|
|
160
|
+
transition: background var(--dur-fast) var(--ease);
|
|
161
|
+
padding: 0 2px;
|
|
162
|
+
margin: 0 -2px;
|
|
163
|
+
}
|
|
164
|
+
.typo-edit-text-trigger:hover { background: color-mix(in oklch, var(--accent) 8%, transparent); }
|
|
165
|
+
|
|
166
|
+
/* ---- Editor (input / textarea) ---- */
|
|
167
|
+
.typo.editing { display: block; }
|
|
168
|
+
.typo-editor {
|
|
169
|
+
font: inherit;
|
|
170
|
+
color: inherit;
|
|
171
|
+
background: var(--bg-sunken);
|
|
172
|
+
box-shadow: var(--neu-in);
|
|
173
|
+
border: none;
|
|
174
|
+
outline: none;
|
|
175
|
+
width: 100%;
|
|
176
|
+
border-radius: var(--r-sm);
|
|
177
|
+
padding: 6px 12px;
|
|
178
|
+
resize: none;
|
|
179
|
+
line-height: inherit;
|
|
180
|
+
letter-spacing: inherit;
|
|
181
|
+
font-weight: inherit;
|
|
182
|
+
font-style: inherit;
|
|
183
|
+
font-size: inherit;
|
|
184
|
+
font-family: inherit;
|
|
185
|
+
}
|
|
186
|
+
.typo-editor:focus {
|
|
187
|
+
box-shadow: var(--neu-in), 0 0 0 3px var(--accent-glow);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* ---- Ellipsis ---- */
|
|
191
|
+
.typo.ellipsis {
|
|
192
|
+
display: inline-block;
|
|
193
|
+
max-width: 100%;
|
|
194
|
+
overflow: hidden;
|
|
195
|
+
white-space: nowrap;
|
|
196
|
+
text-overflow: ellipsis;
|
|
197
|
+
vertical-align: bottom;
|
|
198
|
+
}
|
|
199
|
+
.typo.ellipsis-multi {
|
|
200
|
+
display: -webkit-box;
|
|
201
|
+
-webkit-box-orient: vertical;
|
|
202
|
+
overflow: hidden;
|
|
203
|
+
/* WebkitLineClamp set inline by component */
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Block-level (paragraph/title) keeps block layout for clamp container */
|
|
207
|
+
.typo-paragraph.ellipsis,
|
|
208
|
+
.typo-title.ellipsis {
|
|
209
|
+
display: block;
|
|
210
|
+
max-width: 100%;
|
|
211
|
+
white-space: nowrap;
|
|
212
|
+
overflow: hidden;
|
|
213
|
+
text-overflow: ellipsis;
|
|
214
|
+
}
|
|
215
|
+
.typo-paragraph.ellipsis-multi,
|
|
216
|
+
.typo-title.ellipsis-multi {
|
|
217
|
+
display: -webkit-box;
|
|
218
|
+
-webkit-box-orient: vertical;
|
|
219
|
+
overflow: hidden;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.typo-expand {
|
|
223
|
+
margin-left: 4px;
|
|
224
|
+
color: var(--accent-ink);
|
|
225
|
+
cursor: pointer;
|
|
226
|
+
font-size: 0.92em;
|
|
227
|
+
user-select: none;
|
|
228
|
+
}
|
|
229
|
+
.typo-expand:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
|
|
230
|
+
|
|
231
|
+
/* In dark mode, mark needs slightly higher contrast */
|
|
232
|
+
[data-theme="dark"] .typo mark {
|
|
233
|
+
background: color-mix(in oklch, var(--warning) 30%, transparent);
|
|
234
|
+
color: var(--fg);
|
|
235
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk5WF6M47X_cjs = require('./chunk-5WF6M47X.cjs');
|
|
4
|
+
require('./chunk-YVO7XO4W.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "Link", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk5WF6M47X_cjs.Link; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Paragraph", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunk5WF6M47X_cjs.Paragraph; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "Text", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunk5WF6M47X_cjs.Text; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "Title", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunk5WF6M47X_cjs.Title; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "Typography", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunk5WF6M47X_cjs.Typography; }
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=Typography.cjs.map
|
|
29
|
+
//# sourceMappingURL=Typography.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Typography.cjs"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IconName } from './Icon.cjs';
|
|
3
|
+
|
|
4
|
+
type TypographyType = "secondary" | "success" | "warning" | "danger";
|
|
5
|
+
interface CopyableConfig {
|
|
6
|
+
/** Text to copy. Defaults to the rendered children string. */
|
|
7
|
+
text?: string;
|
|
8
|
+
/** Fired after a successful copy. */
|
|
9
|
+
onCopy?: (event: React.MouseEvent<HTMLSpanElement>) => void;
|
|
10
|
+
/** Custom icons `[default, copied]`. */
|
|
11
|
+
icon?: [React.ReactNode, React.ReactNode];
|
|
12
|
+
/** Custom tooltip text `[default, copied]`. Pass `false` to disable. */
|
|
13
|
+
tooltips?: [React.ReactNode, React.ReactNode] | false;
|
|
14
|
+
/** Format/MIME hint when calling `navigator.clipboard.write` is not used. */
|
|
15
|
+
format?: "text/plain" | "text/html";
|
|
16
|
+
}
|
|
17
|
+
interface EditableConfig {
|
|
18
|
+
/** Controlled editing flag. Omit for uncontrolled (click icon to start). */
|
|
19
|
+
editing?: boolean;
|
|
20
|
+
/** Text shown in the editor; falls back to `children` string. */
|
|
21
|
+
text?: string;
|
|
22
|
+
/** Fired with the new value when the user confirms. */
|
|
23
|
+
onChange?: (value: string) => void;
|
|
24
|
+
/** Fired when the user cancels (Escape or blur without confirm). */
|
|
25
|
+
onCancel?: () => void;
|
|
26
|
+
/** Fired when editing starts. */
|
|
27
|
+
onStart?: () => void;
|
|
28
|
+
/** Fired when editing ends (regardless of save/cancel). */
|
|
29
|
+
onEnd?: () => void;
|
|
30
|
+
/** Maximum input length. */
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
/** Auto resize textarea. `true` = autosize; or pass row bounds. */
|
|
33
|
+
autoSize?: boolean | {
|
|
34
|
+
minRows?: number;
|
|
35
|
+
maxRows?: number;
|
|
36
|
+
};
|
|
37
|
+
/** What triggers entering edit mode. Defaults to `["icon"]`. */
|
|
38
|
+
triggerType?: Array<"icon" | "text">;
|
|
39
|
+
/** Override the edit icon. */
|
|
40
|
+
icon?: React.ReactNode;
|
|
41
|
+
/** Tooltip text on the trigger icon. Pass `false` to disable. */
|
|
42
|
+
tooltip?: React.ReactNode | false;
|
|
43
|
+
/** Use a single-line input instead of textarea. */
|
|
44
|
+
enterIcon?: React.ReactNode;
|
|
45
|
+
}
|
|
46
|
+
interface EllipsisConfig {
|
|
47
|
+
/** Number of rows to clamp at. Defaults to 1. */
|
|
48
|
+
rows?: number;
|
|
49
|
+
/** Show an "Expand" affordance after clamping. */
|
|
50
|
+
expandable?: boolean;
|
|
51
|
+
/** Custom expand-button label. */
|
|
52
|
+
symbol?: React.ReactNode;
|
|
53
|
+
/** Fired on expand. */
|
|
54
|
+
onExpand?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
55
|
+
/** Show full text in a `title` attribute. */
|
|
56
|
+
tooltip?: boolean | React.ReactNode;
|
|
57
|
+
/** Optional suffix that should always remain visible (e.g. an em-dash author). */
|
|
58
|
+
suffix?: string;
|
|
59
|
+
}
|
|
60
|
+
interface BaseTypographyProps {
|
|
61
|
+
/** Semantic color. */
|
|
62
|
+
type?: TypographyType;
|
|
63
|
+
/** Render disabled (muted + not selectable). */
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** Highlight with mark background. */
|
|
66
|
+
mark?: boolean;
|
|
67
|
+
/** Render as inline `<code>`. */
|
|
68
|
+
code?: boolean;
|
|
69
|
+
/** Render as keyboard key `<kbd>`. */
|
|
70
|
+
keyboard?: boolean;
|
|
71
|
+
/** Underline. */
|
|
72
|
+
underline?: boolean;
|
|
73
|
+
/** Strikethrough. */
|
|
74
|
+
delete?: boolean;
|
|
75
|
+
/** Bold. */
|
|
76
|
+
strong?: boolean;
|
|
77
|
+
/** Italic. */
|
|
78
|
+
italic?: boolean;
|
|
79
|
+
/** Add a copy button. Pass an object to customize. */
|
|
80
|
+
copyable?: boolean | CopyableConfig;
|
|
81
|
+
/** Add an edit button. Pass an object to customize. */
|
|
82
|
+
editable?: boolean | EditableConfig;
|
|
83
|
+
/** Truncate to N rows with optional expand affordance. */
|
|
84
|
+
ellipsis?: boolean | EllipsisConfig;
|
|
85
|
+
/** Extra class names. */
|
|
86
|
+
className?: string;
|
|
87
|
+
/** Inline style. */
|
|
88
|
+
style?: React.CSSProperties;
|
|
89
|
+
children?: React.ReactNode;
|
|
90
|
+
}
|
|
91
|
+
type TitleLevel = 1 | 2 | 3 | 4 | 5;
|
|
92
|
+
interface TitleProps extends BaseTypographyProps {
|
|
93
|
+
/** Heading level — 1..5. Defaults to 1. */
|
|
94
|
+
level?: TitleLevel;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* `Typography.Title` — semantic heading.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* <Title level={2} copyable>章节标题</Title>
|
|
101
|
+
*/
|
|
102
|
+
declare const Title: React.ForwardRefExoticComponent<TitleProps & React.RefAttributes<HTMLElement>>;
|
|
103
|
+
interface TextProps extends BaseTypographyProps {
|
|
104
|
+
/** Force the rendered tag (default `<span>`). */
|
|
105
|
+
as?: keyof JSX.IntrinsicElements;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* `Typography.Text` — inline text with semantic / decorative variants.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* <Text type="success" strong>成功</Text>
|
|
112
|
+
* <Text code>npm install</Text>
|
|
113
|
+
* <Text copyable>可复制内容</Text>
|
|
114
|
+
*/
|
|
115
|
+
declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<HTMLElement>>;
|
|
116
|
+
interface ParagraphProps extends BaseTypographyProps {
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* `Typography.Paragraph` — block paragraph with the same decorations as `Text`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* <Paragraph ellipsis={{ rows: 3, expandable: true }}>{long}</Paragraph>
|
|
123
|
+
*/
|
|
124
|
+
declare const Paragraph: React.ForwardRefExoticComponent<ParagraphProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
125
|
+
interface LinkProps extends BaseTypographyProps, Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseTypographyProps | "type"> {
|
|
126
|
+
href?: string;
|
|
127
|
+
/** Add the leading external icon. */
|
|
128
|
+
external?: boolean;
|
|
129
|
+
/** Override the external icon. */
|
|
130
|
+
externalIcon?: IconName;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `Typography.Link` — styled `<a>` that participates in the same decoration
|
|
134
|
+
* system as `Text`. Adds a small `arrow` for `external` links.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* <Link href="https://example.com" external>外部链接</Link>
|
|
138
|
+
*/
|
|
139
|
+
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
140
|
+
interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
141
|
+
children?: React.ReactNode;
|
|
142
|
+
}
|
|
143
|
+
interface TypographyComponent extends React.ForwardRefExoticComponent<TypographyProps & React.RefAttributes<HTMLDivElement>> {
|
|
144
|
+
Title: typeof Title;
|
|
145
|
+
Text: typeof Text;
|
|
146
|
+
Paragraph: typeof Paragraph;
|
|
147
|
+
Link: typeof Link;
|
|
148
|
+
}
|
|
149
|
+
declare const Typography: TypographyComponent;
|
|
150
|
+
|
|
151
|
+
export { type BaseTypographyProps, type CopyableConfig, type EditableConfig, type EllipsisConfig, Link, type LinkProps, Paragraph, type ParagraphProps, Text, type TextProps, Title, type TitleLevel, type TitleProps, Typography, type TypographyProps, type TypographyType };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IconName } from './Icon.js';
|
|
3
|
+
|
|
4
|
+
type TypographyType = "secondary" | "success" | "warning" | "danger";
|
|
5
|
+
interface CopyableConfig {
|
|
6
|
+
/** Text to copy. Defaults to the rendered children string. */
|
|
7
|
+
text?: string;
|
|
8
|
+
/** Fired after a successful copy. */
|
|
9
|
+
onCopy?: (event: React.MouseEvent<HTMLSpanElement>) => void;
|
|
10
|
+
/** Custom icons `[default, copied]`. */
|
|
11
|
+
icon?: [React.ReactNode, React.ReactNode];
|
|
12
|
+
/** Custom tooltip text `[default, copied]`. Pass `false` to disable. */
|
|
13
|
+
tooltips?: [React.ReactNode, React.ReactNode] | false;
|
|
14
|
+
/** Format/MIME hint when calling `navigator.clipboard.write` is not used. */
|
|
15
|
+
format?: "text/plain" | "text/html";
|
|
16
|
+
}
|
|
17
|
+
interface EditableConfig {
|
|
18
|
+
/** Controlled editing flag. Omit for uncontrolled (click icon to start). */
|
|
19
|
+
editing?: boolean;
|
|
20
|
+
/** Text shown in the editor; falls back to `children` string. */
|
|
21
|
+
text?: string;
|
|
22
|
+
/** Fired with the new value when the user confirms. */
|
|
23
|
+
onChange?: (value: string) => void;
|
|
24
|
+
/** Fired when the user cancels (Escape or blur without confirm). */
|
|
25
|
+
onCancel?: () => void;
|
|
26
|
+
/** Fired when editing starts. */
|
|
27
|
+
onStart?: () => void;
|
|
28
|
+
/** Fired when editing ends (regardless of save/cancel). */
|
|
29
|
+
onEnd?: () => void;
|
|
30
|
+
/** Maximum input length. */
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
/** Auto resize textarea. `true` = autosize; or pass row bounds. */
|
|
33
|
+
autoSize?: boolean | {
|
|
34
|
+
minRows?: number;
|
|
35
|
+
maxRows?: number;
|
|
36
|
+
};
|
|
37
|
+
/** What triggers entering edit mode. Defaults to `["icon"]`. */
|
|
38
|
+
triggerType?: Array<"icon" | "text">;
|
|
39
|
+
/** Override the edit icon. */
|
|
40
|
+
icon?: React.ReactNode;
|
|
41
|
+
/** Tooltip text on the trigger icon. Pass `false` to disable. */
|
|
42
|
+
tooltip?: React.ReactNode | false;
|
|
43
|
+
/** Use a single-line input instead of textarea. */
|
|
44
|
+
enterIcon?: React.ReactNode;
|
|
45
|
+
}
|
|
46
|
+
interface EllipsisConfig {
|
|
47
|
+
/** Number of rows to clamp at. Defaults to 1. */
|
|
48
|
+
rows?: number;
|
|
49
|
+
/** Show an "Expand" affordance after clamping. */
|
|
50
|
+
expandable?: boolean;
|
|
51
|
+
/** Custom expand-button label. */
|
|
52
|
+
symbol?: React.ReactNode;
|
|
53
|
+
/** Fired on expand. */
|
|
54
|
+
onExpand?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
55
|
+
/** Show full text in a `title` attribute. */
|
|
56
|
+
tooltip?: boolean | React.ReactNode;
|
|
57
|
+
/** Optional suffix that should always remain visible (e.g. an em-dash author). */
|
|
58
|
+
suffix?: string;
|
|
59
|
+
}
|
|
60
|
+
interface BaseTypographyProps {
|
|
61
|
+
/** Semantic color. */
|
|
62
|
+
type?: TypographyType;
|
|
63
|
+
/** Render disabled (muted + not selectable). */
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/** Highlight with mark background. */
|
|
66
|
+
mark?: boolean;
|
|
67
|
+
/** Render as inline `<code>`. */
|
|
68
|
+
code?: boolean;
|
|
69
|
+
/** Render as keyboard key `<kbd>`. */
|
|
70
|
+
keyboard?: boolean;
|
|
71
|
+
/** Underline. */
|
|
72
|
+
underline?: boolean;
|
|
73
|
+
/** Strikethrough. */
|
|
74
|
+
delete?: boolean;
|
|
75
|
+
/** Bold. */
|
|
76
|
+
strong?: boolean;
|
|
77
|
+
/** Italic. */
|
|
78
|
+
italic?: boolean;
|
|
79
|
+
/** Add a copy button. Pass an object to customize. */
|
|
80
|
+
copyable?: boolean | CopyableConfig;
|
|
81
|
+
/** Add an edit button. Pass an object to customize. */
|
|
82
|
+
editable?: boolean | EditableConfig;
|
|
83
|
+
/** Truncate to N rows with optional expand affordance. */
|
|
84
|
+
ellipsis?: boolean | EllipsisConfig;
|
|
85
|
+
/** Extra class names. */
|
|
86
|
+
className?: string;
|
|
87
|
+
/** Inline style. */
|
|
88
|
+
style?: React.CSSProperties;
|
|
89
|
+
children?: React.ReactNode;
|
|
90
|
+
}
|
|
91
|
+
type TitleLevel = 1 | 2 | 3 | 4 | 5;
|
|
92
|
+
interface TitleProps extends BaseTypographyProps {
|
|
93
|
+
/** Heading level — 1..5. Defaults to 1. */
|
|
94
|
+
level?: TitleLevel;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* `Typography.Title` — semantic heading.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* <Title level={2} copyable>章节标题</Title>
|
|
101
|
+
*/
|
|
102
|
+
declare const Title: React.ForwardRefExoticComponent<TitleProps & React.RefAttributes<HTMLElement>>;
|
|
103
|
+
interface TextProps extends BaseTypographyProps {
|
|
104
|
+
/** Force the rendered tag (default `<span>`). */
|
|
105
|
+
as?: keyof JSX.IntrinsicElements;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* `Typography.Text` — inline text with semantic / decorative variants.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* <Text type="success" strong>成功</Text>
|
|
112
|
+
* <Text code>npm install</Text>
|
|
113
|
+
* <Text copyable>可复制内容</Text>
|
|
114
|
+
*/
|
|
115
|
+
declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<HTMLElement>>;
|
|
116
|
+
interface ParagraphProps extends BaseTypographyProps {
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* `Typography.Paragraph` — block paragraph with the same decorations as `Text`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* <Paragraph ellipsis={{ rows: 3, expandable: true }}>{long}</Paragraph>
|
|
123
|
+
*/
|
|
124
|
+
declare const Paragraph: React.ForwardRefExoticComponent<ParagraphProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
125
|
+
interface LinkProps extends BaseTypographyProps, Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseTypographyProps | "type"> {
|
|
126
|
+
href?: string;
|
|
127
|
+
/** Add the leading external icon. */
|
|
128
|
+
external?: boolean;
|
|
129
|
+
/** Override the external icon. */
|
|
130
|
+
externalIcon?: IconName;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `Typography.Link` — styled `<a>` that participates in the same decoration
|
|
134
|
+
* system as `Text`. Adds a small `arrow` for `external` links.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* <Link href="https://example.com" external>外部链接</Link>
|
|
138
|
+
*/
|
|
139
|
+
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
140
|
+
interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
141
|
+
children?: React.ReactNode;
|
|
142
|
+
}
|
|
143
|
+
interface TypographyComponent extends React.ForwardRefExoticComponent<TypographyProps & React.RefAttributes<HTMLDivElement>> {
|
|
144
|
+
Title: typeof Title;
|
|
145
|
+
Text: typeof Text;
|
|
146
|
+
Paragraph: typeof Paragraph;
|
|
147
|
+
Link: typeof Link;
|
|
148
|
+
}
|
|
149
|
+
declare const Typography: TypographyComponent;
|
|
150
|
+
|
|
151
|
+
export { type BaseTypographyProps, type CopyableConfig, type EditableConfig, type EllipsisConfig, Link, type LinkProps, Paragraph, type ParagraphProps, Text, type TextProps, Title, type TitleLevel, type TitleProps, Typography, type TypographyProps, type TypographyType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"Typography.js"}
|