@windrun-huaiin/third-ui 14.4.1 → 14.4.2

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.
@@ -45,6 +45,10 @@ const CLERK_ACTIVE_ANIMATION_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
45
45
  const CLERK_TEXT_GAP_FROM_PATH = 12;
46
46
  // Radius of numbered step badges rendered on top of the path centerline.
47
47
  const CLERK_STEP_BADGE_RADIUS = 7;
48
+ // Visual line offsets by grouped heading depth: 1/2, 3, 4, >4.
49
+ const CLERK_DEPTH_GROUP_LINE_OFFSETS = [6, 18, 30, 42];
50
+ // Max number of characters rendered for a TOC label before trimming with ellipsis.
51
+ const CLERK_MAX_LABEL_LENGTH = 44;
48
52
  function PortableClerkTOC({ toc, header, footer, title, emptyLabel = 'No headings', className, }) {
49
53
  return (jsxRuntime.jsxs(page.PageTOC, { className: className, children: [header, title !== null && title !== void 0 ? title : jsxRuntime.jsx(page.PageTOCTitle, {}), jsxRuntime.jsx(PortableClerkTOCScrollArea, { children: jsxRuntime.jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }) }), footer] }));
50
54
  }
@@ -124,16 +128,16 @@ function PortableClerkTOCItems(_a) {
124
128
  if (toc.length === 0) {
125
129
  return (jsxRuntime.jsx("div", { className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground", children: emptyLabel }));
126
130
  }
127
- return (jsxRuntime.jsxs("div", Object.assign({ ref: mergeRefs(containerRef, ref), className: cn('relative flex flex-col', className) }, props, { children: [jsxRuntime.jsx(ClerkOutline, { path: outlinePath, items: layout.items, activePath: activePath, activeAnchors: activeAnchors, activeEndpoint: activeEndpoint }), metas.map((meta, i) => (jsxRuntime.jsx(PortableClerkTOCItem, { item: meta.item, isActive: activeAnchors.includes(meta.item.url.slice(1)), resolvedContent: meta.resolvedContent, itemPadding: meta.itemPadding, contentRef: (node) => {
131
+ return (jsxRuntime.jsxs("div", Object.assign({ ref: mergeRefs(containerRef, ref), className: cn('relative flex flex-col', className) }, props, { children: [jsxRuntime.jsx(ClerkOutline, { path: outlinePath, items: layout.items, activePath: activePath, activeAnchors: activeAnchors, activeEndpoint: activeEndpoint }), metas.map((meta, i) => (jsxRuntime.jsx(PortableClerkTOCItem, { item: meta.item, isActive: activeAnchors.includes(meta.item.url.slice(1)), resolvedContent: meta.resolvedContent, fullTitle: meta.fullTitle, itemPadding: meta.itemPadding, contentRef: (node) => {
128
132
  contentRefs.current[i] = node;
129
133
  }, ref: (node) => {
130
134
  itemRefs.current[i] = node;
131
135
  } }, meta.item.url)))] })));
132
136
  }
133
- function PortableClerkTOCItem({ item, isActive, resolvedContent, itemPadding, contentRef, ref, }) {
134
- return (jsxRuntime.jsx(Primitive__namespace.TOCItem, { ref: ref, href: item.url, "data-clerk-item": "", style: {
137
+ function PortableClerkTOCItem({ item, isActive, resolvedContent, fullTitle, itemPadding, contentRef, ref, }) {
138
+ return (jsxRuntime.jsx(Primitive__namespace.TOCItem, { ref: ref, href: item.url, "data-clerk-item": "", title: fullTitle !== null && fullTitle !== void 0 ? fullTitle : undefined, style: {
135
139
  paddingInlineStart: itemPadding,
136
- }, className: cn('prose group relative py-1.5 text-sm transition-colors wrap-anywhere first:pt-0 last:pb-0 hover:text-fd-accent-foreground', isActive ? lib.themeIconColor : 'text-fd-muted-foreground'), children: jsxRuntime.jsx("span", { ref: contentRef, className: "relative z-10", children: resolvedContent }) }));
140
+ }, className: cn('prose group relative py-1.5 text-sm transition-colors first:pt-0 last:pb-0 hover:text-fd-accent-foreground', isActive ? lib.themeIconColor : 'text-fd-muted-foreground'), children: jsxRuntime.jsx("span", { ref: contentRef, className: "relative z-10 block overflow-hidden text-ellipsis whitespace-nowrap", children: resolvedContent }) }));
137
141
  }
138
142
  function ClerkOutline({ path, items, activePath, activeAnchors, activeEndpoint, }) {
139
143
  const activeSet = new Set(activeAnchors);
@@ -176,19 +180,33 @@ function getItemOffset(depth) {
176
180
  return lineOffset + badgeRadius + CLERK_TEXT_GAP_FROM_PATH;
177
181
  }
178
182
  function getLineOffset(depth) {
179
- return depth >= 3 ? 18 : 6;
183
+ const group = getDepthGroup(depth);
184
+ return CLERK_DEPTH_GROUP_LINE_OFFSETS[group];
180
185
  }
181
186
  function getVisualLinePosition(depth) {
182
187
  return getLineOffset(depth);
183
188
  }
189
+ function getDepthGroup(depth) {
190
+ if (depth <= 2)
191
+ return 0;
192
+ if (depth === 3)
193
+ return 1;
194
+ if (depth === 4)
195
+ return 2;
196
+ return 3;
197
+ }
184
198
  function resolveClerkItem(item) {
185
199
  const isH3 = item.depth === 3;
186
200
  const rawTitle = typeof item.title === 'string' ? item.title : '';
187
201
  const { isStep, displayStep, content } = getStepInfoFromTitle(rawTitle);
188
202
  let stepNumber = isH3 && isStep ? String(displayStep) : null;
189
203
  let resolvedContent = item.title;
204
+ let fullTitle = rawTitle || null;
190
205
  if (isH3 && isStep) {
191
206
  resolvedContent = content !== null && content !== void 0 ? content : item.title;
207
+ if (typeof content === 'string') {
208
+ fullTitle = content;
209
+ }
192
210
  }
193
211
  if (isH3 && !stepNumber) {
194
212
  const urlNum = getDigitsFromUrl(item.url);
@@ -199,18 +217,30 @@ function resolveClerkItem(item) {
199
217
  const match = rawTitle.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
200
218
  if (match === null || match === void 0 ? void 0 : match[2]) {
201
219
  resolvedContent = match[2];
220
+ fullTitle = match[2];
202
221
  }
203
222
  }
204
223
  }
205
224
  }
225
+ if (typeof resolvedContent === 'string') {
226
+ fullTitle = resolvedContent;
227
+ resolvedContent = truncateClerkLabel(resolvedContent);
228
+ }
206
229
  return {
207
230
  item,
208
231
  resolvedContent,
232
+ fullTitle,
209
233
  stepNumber,
210
234
  itemPadding: getItemOffset(item.depth),
211
235
  lineOffset: getVisualLinePosition(item.depth),
212
236
  };
213
237
  }
238
+ function truncateClerkLabel(value) {
239
+ const normalized = value.trim();
240
+ if (normalized.length <= CLERK_MAX_LABEL_LENGTH)
241
+ return normalized;
242
+ return `${normalized.slice(0, CLERK_MAX_LABEL_LENGTH).trimEnd()}...`;
243
+ }
214
244
  function buildOutlinePath(items) {
215
245
  if (items.length === 0)
216
246
  return '';
@@ -24,6 +24,10 @@ const CLERK_ACTIVE_ANIMATION_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
24
24
  const CLERK_TEXT_GAP_FROM_PATH = 12;
25
25
  // Radius of numbered step badges rendered on top of the path centerline.
26
26
  const CLERK_STEP_BADGE_RADIUS = 7;
27
+ // Visual line offsets by grouped heading depth: 1/2, 3, 4, >4.
28
+ const CLERK_DEPTH_GROUP_LINE_OFFSETS = [6, 18, 30, 42];
29
+ // Max number of characters rendered for a TOC label before trimming with ellipsis.
30
+ const CLERK_MAX_LABEL_LENGTH = 44;
27
31
  function PortableClerkTOC({ toc, header, footer, title, emptyLabel = 'No headings', className, }) {
28
32
  return (jsxs(PageTOC, { className: className, children: [header, title !== null && title !== void 0 ? title : jsx(PageTOCTitle, {}), jsx(PortableClerkTOCScrollArea, { children: jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }) }), footer] }));
29
33
  }
@@ -103,16 +107,16 @@ function PortableClerkTOCItems(_a) {
103
107
  if (toc.length === 0) {
104
108
  return (jsx("div", { className: "rounded-lg border bg-fd-card p-3 text-xs text-fd-muted-foreground", children: emptyLabel }));
105
109
  }
106
- return (jsxs("div", Object.assign({ ref: mergeRefs(containerRef, ref), className: cn('relative flex flex-col', className) }, props, { children: [jsx(ClerkOutline, { path: outlinePath, items: layout.items, activePath: activePath, activeAnchors: activeAnchors, activeEndpoint: activeEndpoint }), metas.map((meta, i) => (jsx(PortableClerkTOCItem, { item: meta.item, isActive: activeAnchors.includes(meta.item.url.slice(1)), resolvedContent: meta.resolvedContent, itemPadding: meta.itemPadding, contentRef: (node) => {
110
+ return (jsxs("div", Object.assign({ ref: mergeRefs(containerRef, ref), className: cn('relative flex flex-col', className) }, props, { children: [jsx(ClerkOutline, { path: outlinePath, items: layout.items, activePath: activePath, activeAnchors: activeAnchors, activeEndpoint: activeEndpoint }), metas.map((meta, i) => (jsx(PortableClerkTOCItem, { item: meta.item, isActive: activeAnchors.includes(meta.item.url.slice(1)), resolvedContent: meta.resolvedContent, fullTitle: meta.fullTitle, itemPadding: meta.itemPadding, contentRef: (node) => {
107
111
  contentRefs.current[i] = node;
108
112
  }, ref: (node) => {
109
113
  itemRefs.current[i] = node;
110
114
  } }, meta.item.url)))] })));
111
115
  }
112
- function PortableClerkTOCItem({ item, isActive, resolvedContent, itemPadding, contentRef, ref, }) {
113
- return (jsx(Primitive.TOCItem, { ref: ref, href: item.url, "data-clerk-item": "", style: {
116
+ function PortableClerkTOCItem({ item, isActive, resolvedContent, fullTitle, itemPadding, contentRef, ref, }) {
117
+ return (jsx(Primitive.TOCItem, { ref: ref, href: item.url, "data-clerk-item": "", title: fullTitle !== null && fullTitle !== void 0 ? fullTitle : undefined, style: {
114
118
  paddingInlineStart: itemPadding,
115
- }, className: cn('prose group relative py-1.5 text-sm transition-colors wrap-anywhere first:pt-0 last:pb-0 hover:text-fd-accent-foreground', isActive ? themeIconColor : 'text-fd-muted-foreground'), children: jsx("span", { ref: contentRef, className: "relative z-10", children: resolvedContent }) }));
119
+ }, className: cn('prose group relative py-1.5 text-sm transition-colors first:pt-0 last:pb-0 hover:text-fd-accent-foreground', isActive ? themeIconColor : 'text-fd-muted-foreground'), children: jsx("span", { ref: contentRef, className: "relative z-10 block overflow-hidden text-ellipsis whitespace-nowrap", children: resolvedContent }) }));
116
120
  }
117
121
  function ClerkOutline({ path, items, activePath, activeAnchors, activeEndpoint, }) {
118
122
  const activeSet = new Set(activeAnchors);
@@ -155,19 +159,33 @@ function getItemOffset(depth) {
155
159
  return lineOffset + badgeRadius + CLERK_TEXT_GAP_FROM_PATH;
156
160
  }
157
161
  function getLineOffset(depth) {
158
- return depth >= 3 ? 18 : 6;
162
+ const group = getDepthGroup(depth);
163
+ return CLERK_DEPTH_GROUP_LINE_OFFSETS[group];
159
164
  }
160
165
  function getVisualLinePosition(depth) {
161
166
  return getLineOffset(depth);
162
167
  }
168
+ function getDepthGroup(depth) {
169
+ if (depth <= 2)
170
+ return 0;
171
+ if (depth === 3)
172
+ return 1;
173
+ if (depth === 4)
174
+ return 2;
175
+ return 3;
176
+ }
163
177
  function resolveClerkItem(item) {
164
178
  const isH3 = item.depth === 3;
165
179
  const rawTitle = typeof item.title === 'string' ? item.title : '';
166
180
  const { isStep, displayStep, content } = getStepInfoFromTitle(rawTitle);
167
181
  let stepNumber = isH3 && isStep ? String(displayStep) : null;
168
182
  let resolvedContent = item.title;
183
+ let fullTitle = rawTitle || null;
169
184
  if (isH3 && isStep) {
170
185
  resolvedContent = content !== null && content !== void 0 ? content : item.title;
186
+ if (typeof content === 'string') {
187
+ fullTitle = content;
188
+ }
171
189
  }
172
190
  if (isH3 && !stepNumber) {
173
191
  const urlNum = getDigitsFromUrl(item.url);
@@ -178,18 +196,30 @@ function resolveClerkItem(item) {
178
196
  const match = rawTitle.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
179
197
  if (match === null || match === void 0 ? void 0 : match[2]) {
180
198
  resolvedContent = match[2];
199
+ fullTitle = match[2];
181
200
  }
182
201
  }
183
202
  }
184
203
  }
204
+ if (typeof resolvedContent === 'string') {
205
+ fullTitle = resolvedContent;
206
+ resolvedContent = truncateClerkLabel(resolvedContent);
207
+ }
185
208
  return {
186
209
  item,
187
210
  resolvedContent,
211
+ fullTitle,
188
212
  stepNumber,
189
213
  itemPadding: getItemOffset(item.depth),
190
214
  lineOffset: getVisualLinePosition(item.depth),
191
215
  };
192
216
  }
217
+ function truncateClerkLabel(value) {
218
+ const normalized = value.trim();
219
+ if (normalized.length <= CLERK_MAX_LABEL_LENGTH)
220
+ return normalized;
221
+ return `${normalized.slice(0, CLERK_MAX_LABEL_LENGTH).trimEnd()}...`;
222
+ }
193
223
  function buildOutlinePath(items) {
194
224
  if (items.length === 0)
195
225
  return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "14.4.1",
3
+ "version": "14.4.2",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -40,6 +40,7 @@ type PortableClerkTOCProps = {
40
40
  type ClerkItemMeta = {
41
41
  item: TOCItemType;
42
42
  resolvedContent: ReactNode;
43
+ fullTitle: string | null;
43
44
  stepNumber: string | null;
44
45
  itemPadding: number;
45
46
  lineOffset: number;
@@ -70,6 +71,10 @@ const CLERK_ACTIVE_ANIMATION_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';
70
71
  const CLERK_TEXT_GAP_FROM_PATH = 12;
71
72
  // Radius of numbered step badges rendered on top of the path centerline.
72
73
  const CLERK_STEP_BADGE_RADIUS = 7;
74
+ // Visual line offsets by grouped heading depth: 1/2, 3, 4, >4.
75
+ const CLERK_DEPTH_GROUP_LINE_OFFSETS = [6, 18, 30, 42] as const;
76
+ // Max number of characters rendered for a TOC label before trimming with ellipsis.
77
+ const CLERK_MAX_LABEL_LENGTH = 44;
73
78
 
74
79
  export function PortableClerkTOC({
75
80
  toc,
@@ -250,6 +255,7 @@ export function PortableClerkTOCItems({
250
255
  item={meta.item}
251
256
  isActive={activeAnchors.includes(meta.item.url.slice(1))}
252
257
  resolvedContent={meta.resolvedContent}
258
+ fullTitle={meta.fullTitle}
253
259
  itemPadding={meta.itemPadding}
254
260
  contentRef={(node: HTMLSpanElement | null) => {
255
261
  contentRefs.current[i] = node;
@@ -267,6 +273,7 @@ function PortableClerkTOCItem({
267
273
  item,
268
274
  isActive,
269
275
  resolvedContent,
276
+ fullTitle,
270
277
  itemPadding,
271
278
  contentRef,
272
279
  ref,
@@ -274,6 +281,7 @@ function PortableClerkTOCItem({
274
281
  item: TOCItemType;
275
282
  isActive: boolean;
276
283
  resolvedContent: ReactNode;
284
+ fullTitle: string | null;
277
285
  itemPadding: number;
278
286
  contentRef?: ((node: HTMLSpanElement | null) => void) | null;
279
287
  ref?: ((node: HTMLAnchorElement | null) => void) | null;
@@ -283,15 +291,19 @@ function PortableClerkTOCItem({
283
291
  ref={ref}
284
292
  href={item.url}
285
293
  data-clerk-item=""
294
+ title={fullTitle ?? undefined}
286
295
  style={{
287
296
  paddingInlineStart: itemPadding,
288
297
  }}
289
298
  className={cn(
290
- 'prose group relative py-1.5 text-sm transition-colors wrap-anywhere first:pt-0 last:pb-0 hover:text-fd-accent-foreground',
299
+ 'prose group relative py-1.5 text-sm transition-colors first:pt-0 last:pb-0 hover:text-fd-accent-foreground',
291
300
  isActive ? themeIconColor : 'text-fd-muted-foreground',
292
301
  )}
293
302
  >
294
- <span ref={contentRef} className="relative z-10">
303
+ <span
304
+ ref={contentRef}
305
+ className="relative z-10 block overflow-hidden text-ellipsis whitespace-nowrap"
306
+ >
295
307
  {resolvedContent}
296
308
  </span>
297
309
  </Primitive.TOCItem>
@@ -453,22 +465,34 @@ function getItemOffset(depth: number): number {
453
465
  }
454
466
 
455
467
  function getLineOffset(depth: number): number {
456
- return depth >= 3 ? 18 : 6;
468
+ const group = getDepthGroup(depth);
469
+ return CLERK_DEPTH_GROUP_LINE_OFFSETS[group];
457
470
  }
458
471
 
459
472
  function getVisualLinePosition(depth: number): number {
460
473
  return getLineOffset(depth);
461
474
  }
462
475
 
476
+ function getDepthGroup(depth: number): number {
477
+ if (depth <= 2) return 0;
478
+ if (depth === 3) return 1;
479
+ if (depth === 4) return 2;
480
+ return 3;
481
+ }
482
+
463
483
  function resolveClerkItem(item: TOCItemType): ClerkItemMeta {
464
484
  const isH3 = item.depth === 3;
465
485
  const rawTitle = typeof item.title === 'string' ? item.title : '';
466
486
  const { isStep, displayStep, content } = getStepInfoFromTitle(rawTitle);
467
487
  let stepNumber: string | null = isH3 && isStep ? String(displayStep) : null;
468
488
  let resolvedContent: ReactNode = item.title;
489
+ let fullTitle: string | null = rawTitle || null;
469
490
 
470
491
  if (isH3 && isStep) {
471
492
  resolvedContent = content ?? item.title;
493
+ if (typeof content === 'string') {
494
+ fullTitle = content;
495
+ }
472
496
  }
473
497
 
474
498
  if (isH3 && !stepNumber) {
@@ -480,20 +504,34 @@ function resolveClerkItem(item: TOCItemType): ClerkItemMeta {
480
504
  const match = rawTitle.match(/^(\d+(?:\.\d+)*\.?)\s+(.+)$/);
481
505
  if (match?.[2]) {
482
506
  resolvedContent = match[2];
507
+ fullTitle = match[2];
483
508
  }
484
509
  }
485
510
  }
486
511
  }
487
512
 
513
+ if (typeof resolvedContent === 'string') {
514
+ fullTitle = resolvedContent;
515
+ resolvedContent = truncateClerkLabel(resolvedContent);
516
+ }
517
+
488
518
  return {
489
519
  item,
490
520
  resolvedContent,
521
+ fullTitle,
491
522
  stepNumber,
492
523
  itemPadding: getItemOffset(item.depth),
493
524
  lineOffset: getVisualLinePosition(item.depth),
494
525
  };
495
526
  }
496
527
 
528
+ function truncateClerkLabel(value: string): string {
529
+ const normalized = value.trim();
530
+ if (normalized.length <= CLERK_MAX_LABEL_LENGTH) return normalized;
531
+
532
+ return `${normalized.slice(0, CLERK_MAX_LABEL_LENGTH).trimEnd()}...`;
533
+ }
534
+
497
535
  function buildOutlinePath(items: ClerkItemMeasure[]): string {
498
536
  if (items.length === 0) return '';
499
537
 
@@ -3,6 +3,19 @@
3
3
  @apply top-20!;
4
4
  }
5
5
 
6
+ @media (min-width: 1280px) {
7
+ /* 给桌面端固定 TOC 留一点底部呼吸感,避免视觉上直接压到 footer */
8
+ #nd-toc {
9
+ bottom: 1.25rem !important;
10
+ }
11
+
12
+ /* 文档主区域补一小段底部缓冲,减少 footer 刚进入视口就与 TOC 相撞 */
13
+ #nd-page {
14
+ padding-bottom: 5rem !important;
15
+ min-height: calc(100dvh - 5rem) !important;
16
+ }
17
+ }
18
+
6
19
  /* 移动端文章目录下拉框的边距,建议移动端不要目录导航 96px */
7
20
  #nd-tocnav {
8
21
  @apply top-24!;
@@ -35,7 +48,7 @@ button[aria-label="Open Search"][data-search=""] {
35
48
 
36
49
  /* Custome Fuma Steps */
37
50
  .fd-step::before {
38
- @apply size-5 -start-2.5 rounded-full;
51
+ @apply size-5 -inset-s-2.5 rounded-full;
39
52
  background-color: #000;
40
53
  color: #fff;
41
54
  font-size: 0.75rem;
@@ -128,4 +141,4 @@ button[aria-label="Open Search"][data-search=""] {
128
141
  [data-rmiz-modal-img] {
129
142
  transition-duration: 0.01ms !important;
130
143
  }
131
- }
144
+ }