@windrun-huaiin/third-ui 20.1.0 → 22.0.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.
Files changed (123) hide show
  1. package/LICENSE +1 -1
  2. package/dist/ai/ai-markdown.js +1 -1
  3. package/dist/ai/ai-markdown.mjs +1 -1
  4. package/dist/clerk/clerk-page-context-generator.js +3 -2
  5. package/dist/clerk/clerk-page-context-generator.mjs +3 -2
  6. package/dist/clerk/clerk-page-generator.d.ts +0 -8
  7. package/dist/clerk/clerk-page-generator.js +4 -3
  8. package/dist/clerk/clerk-page-generator.mjs +4 -3
  9. package/dist/fuma/base/custom-header.d.ts +1 -1
  10. package/dist/fuma/base/custom-header.js +38 -36
  11. package/dist/fuma/base/custom-header.mjs +25 -23
  12. package/dist/fuma/base/custom-home-layout.d.ts +1 -1
  13. package/dist/fuma/base/custom-home-layout.js +1 -1
  14. package/dist/fuma/base/custom-home-layout.mjs +1 -1
  15. package/dist/fuma/base/header-theme-switch.d.ts +5 -0
  16. package/dist/fuma/base/header-theme-switch.js +42 -0
  17. package/dist/fuma/base/header-theme-switch.mjs +40 -0
  18. package/dist/fuma/base/index.d.ts +1 -0
  19. package/dist/fuma/base/index.js +7 -0
  20. package/dist/fuma/base/index.mjs +1 -0
  21. package/dist/fuma/base/site-layout.d.ts +116 -0
  22. package/dist/fuma/base/site-layout.js +72 -0
  23. package/dist/fuma/base/site-layout.mjs +65 -0
  24. package/dist/fuma/fuma-banner-suit.js +9 -6
  25. package/dist/fuma/fuma-banner-suit.mjs +10 -7
  26. package/dist/fuma/fuma-page-genarator.d.ts +2 -2
  27. package/dist/fuma/fuma-page-genarator.js +21 -8
  28. package/dist/fuma/fuma-page-genarator.mjs +21 -8
  29. package/dist/fuma/heavy/image-grid.d.ts +6 -0
  30. package/dist/fuma/heavy/image-grid.js +17 -0
  31. package/dist/fuma/heavy/image-grid.mjs +15 -0
  32. package/dist/fuma/heavy/image-zoom.d.ts +22 -0
  33. package/dist/fuma/heavy/image-zoom.js +39 -0
  34. package/dist/fuma/heavy/image-zoom.mjs +37 -0
  35. package/dist/fuma/heavy/index.d.ts +4 -0
  36. package/dist/fuma/heavy/index.js +15 -0
  37. package/dist/fuma/heavy/index.mjs +5 -0
  38. package/dist/fuma/heavy/math.d.ts +17 -0
  39. package/dist/fuma/heavy/math.js +60 -0
  40. package/dist/fuma/heavy/math.mjs +57 -0
  41. package/dist/fuma/heavy/mermaid.d.ts +13 -0
  42. package/dist/fuma/heavy/mermaid.js +360 -0
  43. package/dist/fuma/heavy/mermaid.mjs +358 -0
  44. package/dist/fuma/llm-copy-handler.js +3 -2
  45. package/dist/fuma/llm-copy-handler.mjs +3 -2
  46. package/dist/fuma/mdx/features.d.ts +8 -0
  47. package/dist/fuma/mdx/features.js +92 -0
  48. package/dist/fuma/mdx/features.mjs +85 -0
  49. package/dist/fuma/mdx/index.d.ts +0 -4
  50. package/dist/fuma/mdx/index.js +0 -8
  51. package/dist/fuma/mdx/index.mjs +0 -4
  52. package/dist/fuma/mdx/markdown-component-map.js +7 -1
  53. package/dist/fuma/mdx/markdown-component-map.mjs +7 -1
  54. package/dist/fuma/mdx/math.d.ts +17 -0
  55. package/dist/fuma/mdx/math.js +60 -0
  56. package/dist/fuma/mdx/math.mjs +57 -0
  57. package/dist/fuma/mdx/site-mdx-components.d.ts +13 -0
  58. package/dist/fuma/mdx/site-mdx-components.js +19 -0
  59. package/dist/fuma/mdx/site-mdx-components.mjs +17 -0
  60. package/dist/fuma/mdx/site-mdx-presets.d.ts +13 -0
  61. package/dist/fuma/mdx/site-mdx-presets.js +49 -0
  62. package/dist/fuma/mdx/site-mdx-presets.mjs +45 -0
  63. package/dist/fuma/mdx/toc-clerk-portable.js +9 -5
  64. package/dist/fuma/mdx/toc-clerk-portable.mjs +8 -4
  65. package/dist/fuma/mdx/zia-card.js +1 -1
  66. package/dist/fuma/mdx/zia-card.mjs +1 -1
  67. package/dist/fuma/mdx/zia-file.js +1 -0
  68. package/dist/fuma/mdx/zia-file.mjs +1 -0
  69. package/dist/fuma/server/optional-features.d.ts +8 -0
  70. package/dist/fuma/server/optional-features.js +111 -0
  71. package/dist/fuma/server/optional-features.mjs +104 -0
  72. package/dist/fuma/server/site-mdx-components.d.ts +13 -0
  73. package/dist/fuma/server/site-mdx-components.js +19 -0
  74. package/dist/fuma/server/site-mdx-components.mjs +17 -0
  75. package/dist/fuma/server/site-mdx-presets.d.ts +194 -0
  76. package/dist/fuma/server/site-mdx-presets.js +46 -0
  77. package/dist/fuma/server/site-mdx-presets.mjs +42 -0
  78. package/dist/fuma/share/index.d.ts +1 -0
  79. package/dist/fuma/share/index.js +7 -0
  80. package/dist/fuma/share/index.mjs +1 -0
  81. package/dist/fuma/share/markdown-component-map.d.ts +3 -0
  82. package/dist/fuma/share/markdown-component-map.js +79 -0
  83. package/dist/fuma/share/markdown-component-map.mjs +77 -0
  84. package/dist/lib/fuma-schema-check-util.js +19 -5
  85. package/dist/lib/fuma-schema-check-util.mjs +19 -5
  86. package/dist/lib/seo-metadata.d.ts +10 -0
  87. package/dist/main/x-button.js +2 -2
  88. package/dist/main/x-button.mjs +2 -2
  89. package/package.json +31 -8
  90. package/src/ai/ai-markdown.tsx +1 -1
  91. package/src/clerk/clerk-page-context-generator.tsx +6 -3
  92. package/src/clerk/clerk-page-generator.tsx +7 -13
  93. package/src/fuma/base/custom-header.tsx +32 -35
  94. package/src/fuma/base/custom-home-layout.tsx +2 -2
  95. package/src/fuma/base/header-theme-switch.tsx +88 -0
  96. package/src/fuma/base/index.ts +1 -0
  97. package/src/fuma/base/site-layout.tsx +289 -0
  98. package/src/fuma/fuma-banner-suit.tsx +30 -28
  99. package/src/fuma/fuma-page-genarator.tsx +27 -10
  100. package/src/fuma/{mdx → heavy}/image-grid.tsx +1 -1
  101. package/src/fuma/heavy/index.ts +7 -0
  102. package/src/fuma/heavy/math.tsx +130 -0
  103. package/src/fuma/llm-copy-handler.ts +3 -3
  104. package/src/fuma/mdx/index.ts +0 -4
  105. package/src/fuma/mdx/toc-clerk-portable.tsx +27 -24
  106. package/src/fuma/mdx/zia-card.tsx +1 -0
  107. package/src/fuma/mdx/zia-file.tsx +3 -1
  108. package/src/fuma/server/optional-features.tsx +168 -0
  109. package/src/fuma/server/site-mdx-components.tsx +48 -0
  110. package/src/fuma/server/site-mdx-presets.ts +80 -0
  111. package/src/fuma/share/index.ts +1 -0
  112. package/src/fuma/{mdx → share}/markdown-component-map.tsx +1 -1
  113. package/src/lib/fuma-schema-check-util.ts +22 -6
  114. package/src/lib/seo-metadata.ts +47 -0
  115. package/src/main/language-detector.tsx +0 -8
  116. package/src/main/x-button.tsx +2 -2
  117. package/src/styles/fuma.css +3 -7
  118. package/src/styles/third-ui.css +0 -4
  119. package/dist/main/ads-alert-dialog.d.ts +0 -15
  120. package/dist/main/ads-alert-dialog.js +0 -21
  121. package/dist/main/ads-alert-dialog.mjs +0 -19
  122. /package/src/fuma/{mdx → heavy}/image-zoom.tsx +0 -0
  123. /package/src/fuma/{mdx → heavy}/mermaid.tsx +0 -0
@@ -4,7 +4,13 @@ var tslib = require('tslib');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var utils = require('@windrun-huaiin/lib/utils');
6
6
  var defaultMdxComponents = require('fumadocs-ui/mdx');
7
- var imageZoom = require('./image-zoom.js');
7
+ var imageZoom = require('../heavy/image-zoom.js');
8
+ require('katex');
9
+ require('@windrun-huaiin/base-ui/icons');
10
+ require('next-themes');
11
+ require('roughjs');
12
+ require('react');
13
+ require('@windrun-huaiin/base-ui/lib');
8
14
 
9
15
  function normalizeMarkdownProps(props) {
10
16
  const { class: legacyClassName, className } = props, restProps = tslib.__rest(props, ["class", "className"]);
@@ -2,7 +2,13 @@ import { __rest } from 'tslib';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { cn } from '@windrun-huaiin/lib/utils';
4
4
  import defaultMdxComponents from 'fumadocs-ui/mdx';
5
- import { ImageZoom } from './image-zoom.mjs';
5
+ import { ImageZoom } from '../heavy/image-zoom.mjs';
6
+ import 'katex';
7
+ import '@windrun-huaiin/base-ui/icons';
8
+ import 'next-themes';
9
+ import 'roughjs';
10
+ import 'react';
11
+ import '@windrun-huaiin/base-ui/lib';
6
12
 
7
13
  function normalizeMarkdownProps(props) {
8
14
  const { class: legacyClassName, className } = props, restProps = __rest(props, ["class", "className"]);
@@ -0,0 +1,17 @@
1
+ import type { HTMLAttributes, ReactNode } from 'react';
2
+ type MathSourceProps = {
3
+ children?: ReactNode;
4
+ math?: string;
5
+ formula?: string;
6
+ };
7
+ type Align = 'left' | 'center' | 'right';
8
+ export type MathBlockProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & MathSourceProps & {
9
+ title?: ReactNode;
10
+ titleAlign?: Align;
11
+ };
12
+ export type InlineMathProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & MathSourceProps & {
13
+ align?: Align;
14
+ };
15
+ export declare function MathBlock({ title, titleAlign, children, math, formula, className, ...props }: MathBlockProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function InlineMath({ children, math, formula, align, className, ...props }: InlineMathProps): import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var katex = require('katex');
6
+ var utils = require('@windrun-huaiin/lib/utils');
7
+
8
+ const alignClassMap = {
9
+ left: 'text-left justify-start',
10
+ center: 'text-center justify-center',
11
+ right: 'text-right justify-end',
12
+ };
13
+ const textAlignClassMap = {
14
+ left: 'text-left',
15
+ center: 'text-center',
16
+ right: 'text-right',
17
+ };
18
+ function getMathSource({ children, math, formula }) {
19
+ if (typeof math === 'string' && math.trim() !== '')
20
+ return math.trim();
21
+ if (typeof formula === 'string' && formula.trim() !== '')
22
+ return formula.trim();
23
+ if (typeof children === 'string' && children.trim() !== '')
24
+ return children.trim();
25
+ if (Array.isArray(children)) {
26
+ const text = children
27
+ .map((item) => (typeof item === 'string' ? item : ''))
28
+ .join('')
29
+ .trim();
30
+ if (text !== '')
31
+ return text;
32
+ }
33
+ return '';
34
+ }
35
+ function renderMath(source, displayMode) {
36
+ if (source === '')
37
+ return '';
38
+ return katex.renderToString(source, {
39
+ displayMode,
40
+ throwOnError: false,
41
+ output: 'html',
42
+ strict: 'ignore',
43
+ trust: false,
44
+ });
45
+ }
46
+ function MathBlock(_a) {
47
+ var { title, titleAlign = 'center', children, math, formula, className } = _a, props = tslib.__rest(_a, ["title", "titleAlign", "children", "math", "formula", "className"]);
48
+ const source = getMathSource({ children, math, formula });
49
+ const html = renderMath(source, true);
50
+ return (jsxRuntime.jsxs("div", Object.assign({}, props, { className: utils.cn('not-prose my-6 overflow-x-auto rounded-xl border bg-fd-card p-4 text-fd-card-foreground', className), children: [title ? (jsxRuntime.jsx("div", { className: utils.cn('mb-3 text-sm font-medium text-fd-muted-foreground', alignClassMap[titleAlign].split(' ')[0]), children: title })) : null, html ? (jsxRuntime.jsx("div", { className: "min-w-fit [&_.katex-display]:my-0 [&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden", dangerouslySetInnerHTML: { __html: html } })) : (jsxRuntime.jsx("div", { className: "text-sm text-fd-muted-foreground", children: "Empty math block." }))] })));
51
+ }
52
+ function InlineMath(_a) {
53
+ var { children, math, formula, align = 'center', className } = _a, props = tslib.__rest(_a, ["children", "math", "formula", "align", "className"]);
54
+ const source = getMathSource({ children, math, formula });
55
+ const html = renderMath(source, false);
56
+ return (jsxRuntime.jsx("span", Object.assign({}, props, { className: utils.cn('mx-1 inline-flex max-w-full align-middle rounded-md bg-neutral-200 px-2 py-0.5 text-sm leading-none dark:bg-white/20 [&_.katex]:text-inherit', textAlignClassMap[align], className), children: jsxRuntime.jsx("span", { dangerouslySetInnerHTML: { __html: html } }) })));
57
+ }
58
+
59
+ exports.InlineMath = InlineMath;
60
+ exports.MathBlock = MathBlock;
@@ -0,0 +1,57 @@
1
+ import { __rest } from 'tslib';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import katex from 'katex';
4
+ import { cn } from '@windrun-huaiin/lib/utils';
5
+
6
+ const alignClassMap = {
7
+ left: 'text-left justify-start',
8
+ center: 'text-center justify-center',
9
+ right: 'text-right justify-end',
10
+ };
11
+ const textAlignClassMap = {
12
+ left: 'text-left',
13
+ center: 'text-center',
14
+ right: 'text-right',
15
+ };
16
+ function getMathSource({ children, math, formula }) {
17
+ if (typeof math === 'string' && math.trim() !== '')
18
+ return math.trim();
19
+ if (typeof formula === 'string' && formula.trim() !== '')
20
+ return formula.trim();
21
+ if (typeof children === 'string' && children.trim() !== '')
22
+ return children.trim();
23
+ if (Array.isArray(children)) {
24
+ const text = children
25
+ .map((item) => (typeof item === 'string' ? item : ''))
26
+ .join('')
27
+ .trim();
28
+ if (text !== '')
29
+ return text;
30
+ }
31
+ return '';
32
+ }
33
+ function renderMath(source, displayMode) {
34
+ if (source === '')
35
+ return '';
36
+ return katex.renderToString(source, {
37
+ displayMode,
38
+ throwOnError: false,
39
+ output: 'html',
40
+ strict: 'ignore',
41
+ trust: false,
42
+ });
43
+ }
44
+ function MathBlock(_a) {
45
+ var { title, titleAlign = 'center', children, math, formula, className } = _a, props = __rest(_a, ["title", "titleAlign", "children", "math", "formula", "className"]);
46
+ const source = getMathSource({ children, math, formula });
47
+ const html = renderMath(source, true);
48
+ return (jsxs("div", Object.assign({}, props, { className: cn('not-prose my-6 overflow-x-auto rounded-xl border bg-fd-card p-4 text-fd-card-foreground', className), children: [title ? (jsx("div", { className: cn('mb-3 text-sm font-medium text-fd-muted-foreground', alignClassMap[titleAlign].split(' ')[0]), children: title })) : null, html ? (jsx("div", { className: "min-w-fit [&_.katex-display]:my-0 [&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden", dangerouslySetInnerHTML: { __html: html } })) : (jsx("div", { className: "text-sm text-fd-muted-foreground", children: "Empty math block." }))] })));
49
+ }
50
+ function InlineMath(_a) {
51
+ var { children, math, formula, align = 'center', className } = _a, props = __rest(_a, ["children", "math", "formula", "align", "className"]);
52
+ const source = getMathSource({ children, math, formula });
53
+ const html = renderMath(source, false);
54
+ return (jsx("span", Object.assign({}, props, { className: cn('mx-1 inline-flex max-w-full align-middle rounded-md bg-neutral-200 px-2 py-0.5 text-sm leading-none dark:bg-white/20 [&_.katex]:text-inherit', textAlignClassMap[align], className), children: jsx("span", { dangerouslySetInnerHTML: { __html: html } }) })));
55
+ }
56
+
57
+ export { InlineMath, MathBlock };
@@ -0,0 +1,13 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import type { ReactNode } from 'react';
3
+ export type SiteMdxFeature = 'base' | 'code' | 'math' | 'mermaid' | 'type-table' | 'fuma-ui' | 'widgets';
4
+ export interface SiteMdxComponentsOptions {
5
+ imageFallbackSrc?: string;
6
+ cdnBaseUrl?: string;
7
+ watermarkEnabled?: boolean;
8
+ watermarkText?: string;
9
+ additionalComponents?: MDXComponents;
10
+ iconMap?: Record<string, ReactNode>;
11
+ features?: SiteMdxFeature[];
12
+ }
13
+ export declare function createSiteMdxComponents(options: SiteMdxComponentsOptions): (components?: MDXComponents) => MDXComponents;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var siteMdxPresets = require('./site-mdx-presets.js');
4
+
5
+ function createSiteMdxComponents(options) {
6
+ const { additionalComponents, cdnBaseUrl, features = siteMdxPresets.DEFAULT_SITE_MDX_FEATURES, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
7
+ const featureMap = siteMdxPresets.createSiteFeatureComponentMap({
8
+ cdnBaseUrl,
9
+ iconMap,
10
+ imageFallbackSrc,
11
+ watermarkEnabled,
12
+ watermarkText,
13
+ });
14
+ return function getMDXComponents(components) {
15
+ return siteMdxPresets.composeSiteMdxComponents(features, featureMap, additionalComponents, components);
16
+ };
17
+ }
18
+
19
+ exports.createSiteMdxComponents = createSiteMdxComponents;
@@ -0,0 +1,17 @@
1
+ import { DEFAULT_SITE_MDX_FEATURES, createSiteFeatureComponentMap, composeSiteMdxComponents } from './site-mdx-presets.mjs';
2
+
3
+ function createSiteMdxComponents(options) {
4
+ const { additionalComponents, cdnBaseUrl, features = DEFAULT_SITE_MDX_FEATURES, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
5
+ const featureMap = createSiteFeatureComponentMap({
6
+ cdnBaseUrl,
7
+ iconMap,
8
+ imageFallbackSrc,
9
+ watermarkEnabled,
10
+ watermarkText,
11
+ });
12
+ return function getMDXComponents(components) {
13
+ return composeSiteMdxComponents(features, featureMap, additionalComponents, components);
14
+ };
15
+ }
16
+
17
+ export { createSiteMdxComponents };
@@ -0,0 +1,13 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import type { SiteMdxFeature, SiteMdxComponentsOptions } from './site-mdx-components';
3
+ export declare const DEFAULT_SITE_MDX_FEATURES: SiteMdxFeature[];
4
+ export declare function createSiteFeatureComponentMap(options: SiteMdxComponentsOptions): {
5
+ base: MDXComponents;
6
+ code: MDXComponents;
7
+ math: MDXComponents;
8
+ mermaid: MDXComponents;
9
+ 'type-table': MDXComponents;
10
+ 'fuma-ui': MDXComponents;
11
+ widgets: MDXComponents;
12
+ };
13
+ export declare function composeSiteMdxComponents(features: readonly SiteMdxFeature[], featureMap: Record<SiteMdxFeature, MDXComponents>, additionalComponents?: MDXComponents, components?: MDXComponents): MDXComponents;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var defaultMdxComponents = require('fumadocs-ui/mdx');
4
+ var tabs = require('fumadocs-ui/components/tabs');
5
+ var callout = require('fumadocs-ui/components/callout');
6
+ var files = require('fumadocs-ui/components/files');
7
+ var accordion = require('fumadocs-ui/components/accordion');
8
+ var features = require('./features.js');
9
+
10
+ const defaultFumaUiComponents = {
11
+ Callout: callout.Callout,
12
+ File: files.File,
13
+ Folder: files.Folder,
14
+ Files: files.Files,
15
+ Accordion: accordion.Accordion,
16
+ Accordions: accordion.Accordions,
17
+ Tab: tabs.Tab,
18
+ Tabs: tabs.Tabs,
19
+ };
20
+ const DEFAULT_SITE_MDX_FEATURES = [
21
+ 'base',
22
+ 'code',
23
+ 'math',
24
+ 'mermaid',
25
+ 'type-table',
26
+ 'fuma-ui',
27
+ 'widgets',
28
+ ];
29
+ function createSiteFeatureComponentMap(options) {
30
+ const { cdnBaseUrl, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
31
+ return {
32
+ base: features.createBaseMdxComponents(imageFallbackSrc),
33
+ code: features.createCodeMdxComponents(iconMap),
34
+ math: features.createMathMdxComponents(),
35
+ mermaid: features.createMermaidMdxComponents(watermarkEnabled, watermarkText),
36
+ 'type-table': features.createTypeTableMdxComponents(),
37
+ 'fuma-ui': defaultFumaUiComponents,
38
+ widgets: features.createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc),
39
+ };
40
+ }
41
+ function composeSiteMdxComponents(features, featureMap, additionalComponents, components) {
42
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultMdxComponents), features.reduce((acc, feature) => {
43
+ return Object.assign(Object.assign({}, acc), featureMap[feature]);
44
+ }, {})), additionalComponents), components);
45
+ }
46
+
47
+ exports.DEFAULT_SITE_MDX_FEATURES = DEFAULT_SITE_MDX_FEATURES;
48
+ exports.composeSiteMdxComponents = composeSiteMdxComponents;
49
+ exports.createSiteFeatureComponentMap = createSiteFeatureComponentMap;
@@ -0,0 +1,45 @@
1
+ import defaultMdxComponents from 'fumadocs-ui/mdx';
2
+ import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
3
+ import { Callout } from 'fumadocs-ui/components/callout';
4
+ import { Files, Folder, File } from 'fumadocs-ui/components/files';
5
+ import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
6
+ import { createWidgetMdxComponents, createTypeTableMdxComponents, createMermaidMdxComponents, createMathMdxComponents, createCodeMdxComponents, createBaseMdxComponents } from './features.mjs';
7
+
8
+ const defaultFumaUiComponents = {
9
+ Callout,
10
+ File,
11
+ Folder,
12
+ Files,
13
+ Accordion,
14
+ Accordions,
15
+ Tab,
16
+ Tabs,
17
+ };
18
+ const DEFAULT_SITE_MDX_FEATURES = [
19
+ 'base',
20
+ 'code',
21
+ 'math',
22
+ 'mermaid',
23
+ 'type-table',
24
+ 'fuma-ui',
25
+ 'widgets',
26
+ ];
27
+ function createSiteFeatureComponentMap(options) {
28
+ const { cdnBaseUrl, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
29
+ return {
30
+ base: createBaseMdxComponents(imageFallbackSrc),
31
+ code: createCodeMdxComponents(iconMap),
32
+ math: createMathMdxComponents(),
33
+ mermaid: createMermaidMdxComponents(watermarkEnabled, watermarkText),
34
+ 'type-table': createTypeTableMdxComponents(),
35
+ 'fuma-ui': defaultFumaUiComponents,
36
+ widgets: createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc),
37
+ };
38
+ }
39
+ function composeSiteMdxComponents(features, featureMap, additionalComponents, components) {
40
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultMdxComponents), features.reduce((acc, feature) => {
41
+ return Object.assign(Object.assign({}, acc), featureMap[feature]);
42
+ }, {})), additionalComponents), components);
43
+ }
44
+
45
+ export { DEFAULT_SITE_MDX_FEATURES, composeSiteMdxComponents, createSiteFeatureComponentMap };
@@ -4,7 +4,7 @@
4
4
  var tslib = require('tslib');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var Primitive = require('fumadocs-core/toc');
7
- var page = require('fumadocs-ui/layouts/docs/page');
7
+ var toc = require('fumadocs-ui/layouts/docs/page/slots/toc');
8
8
  var React = require('react');
9
9
  var lib = require('@windrun-huaiin/base-ui/lib');
10
10
 
@@ -49,11 +49,15 @@ const CLERK_STEP_BADGE_RADIUS = 7;
49
49
  const CLERK_DEPTH_GROUP_LINE_OFFSETS = [6, 18, 30, 42];
50
50
  // Max number of characters rendered for a TOC label before trimming with ellipsis.
51
51
  const CLERK_MAX_LABEL_LENGTH = 44;
52
- function PortableClerkTOC({ toc, header, footer, title, emptyLabel = 'No headings', className, }) {
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] }));
52
+ function PortableClerkTOC({ toc: toc$1, header, footer, title, emptyLabel = 'No headings', className, }) {
53
+ return (jsxRuntime.jsx(toc.TOC, { style: "clerk", container: { className }, header: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [header, title !== null && title !== void 0 ? title : null] }), footer: footer, list: {
54
+ children: jsxRuntime.jsx(PortableClerkTOCItems, { toc: toc$1, emptyLabel: emptyLabel }),
55
+ } }));
54
56
  }
55
- function PortableClerkTOCPopover({ toc, header, footer, emptyLabel = 'No headings', }) {
56
- return (jsxRuntime.jsxs(page.PageTOCPopover, { children: [jsxRuntime.jsx(page.PageTOCPopoverTrigger, {}), jsxRuntime.jsxs(page.PageTOCPopoverContent, { children: [header, jsxRuntime.jsx(PortableClerkTOCScrollArea, { children: jsxRuntime.jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }) }), footer] })] }));
57
+ function PortableClerkTOCPopover({ toc: toc$1, header, footer, emptyLabel = 'No headings', }) {
58
+ return (jsxRuntime.jsx(toc.TOCPopover, { style: "clerk", header: header, footer: footer, list: {
59
+ children: jsxRuntime.jsx(PortableClerkTOCItems, { toc: toc$1, emptyLabel: emptyLabel }),
60
+ } }));
57
61
  }
58
62
  function PortableClerkTOCScrollArea(_a) {
59
63
  var { ref, className } = _a, props = tslib.__rest(_a, ["ref", "className"]);
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { __rest } from 'tslib';
3
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import * as Primitive from 'fumadocs-core/toc';
5
- import { PageTOC, PageTOCTitle, PageTOCPopover, PageTOCPopoverTrigger, PageTOCPopoverContent } from 'fumadocs-ui/layouts/docs/page';
5
+ import { TOC, TOCPopover } from 'fumadocs-ui/layouts/docs/page/slots/toc';
6
6
  import { useRef, useState, useMemo, useLayoutEffect, useEffect } from 'react';
7
7
  import { themeSvgIconColor, themeIconColor } from '@windrun-huaiin/base-ui/lib';
8
8
 
@@ -29,10 +29,14 @@ const CLERK_DEPTH_GROUP_LINE_OFFSETS = [6, 18, 30, 42];
29
29
  // Max number of characters rendered for a TOC label before trimming with ellipsis.
30
30
  const CLERK_MAX_LABEL_LENGTH = 44;
31
31
  function PortableClerkTOC({ toc, header, footer, title, emptyLabel = 'No headings', className, }) {
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] }));
32
+ return (jsx(TOC, { style: "clerk", container: { className }, header: jsxs(Fragment, { children: [header, title !== null && title !== void 0 ? title : null] }), footer: footer, list: {
33
+ children: jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }),
34
+ } }));
33
35
  }
34
36
  function PortableClerkTOCPopover({ toc, header, footer, emptyLabel = 'No headings', }) {
35
- return (jsxs(PageTOCPopover, { children: [jsx(PageTOCPopoverTrigger, {}), jsxs(PageTOCPopoverContent, { children: [header, jsx(PortableClerkTOCScrollArea, { children: jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }) }), footer] })] }));
37
+ return (jsx(TOCPopover, { style: "clerk", header: header, footer: footer, list: {
38
+ children: jsx(PortableClerkTOCItems, { toc: toc, emptyLabel: emptyLabel }),
39
+ } }));
36
40
  }
37
41
  function PortableClerkTOCScrollArea(_a) {
38
42
  var { ref, className } = _a, props = __rest(_a, ["ref", "className"]);
@@ -12,7 +12,7 @@ function ZiaCard(_a) {
12
12
  const validHref = typeof props.href === 'string' && props.href.trim() !== '';
13
13
  const validDescription = typeof description === 'string' && (description === null || description === void 0 ? void 0 : description.trim()) !== '';
14
14
  if (validHref) {
15
- return (jsxRuntime.jsxs(Link, Object.assign({ href: props.href, "data-card": true, className: utils.cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', 'hover:bg-fd-accent/80', props.className) }, props, { children: [jsxRuntime.jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon ? icon : jsxRuntime.jsx(icons.CircleSmallIcon, {}) }), jsxRuntime.jsx("h3", { className: "not-prose mb-1 text-sm font-medium line-clamp-2 min-h-10", children: title }), validDescription ? (jsxRuntime.jsx("p", { className: "my-0! text-sm text-fd-muted-foreground", children: description })) : (jsxRuntime.jsx("p", { className: "my-0! text-sm text-fd-muted-foreground opacity-0 select-none", children: "\u00A0" })), props.children ? (jsxRuntime.jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] })));
15
+ return (jsxRuntime.jsxs(Link, Object.assign({ href: props.href, prefetch: false, "data-card": true, className: utils.cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', 'hover:bg-fd-accent/80', props.className) }, props, { children: [jsxRuntime.jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon ? icon : jsxRuntime.jsx(icons.CircleSmallIcon, {}) }), jsxRuntime.jsx("h3", { className: "not-prose mb-1 text-sm font-medium line-clamp-2 min-h-10", children: title }), validDescription ? (jsxRuntime.jsx("p", { className: "my-0! text-sm text-fd-muted-foreground", children: description })) : (jsxRuntime.jsx("p", { className: "my-0! text-sm text-fd-muted-foreground opacity-0 select-none", children: "\u00A0" })), props.children ? (jsxRuntime.jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] })));
16
16
  }
17
17
  return (jsxRuntime.jsxs("div", Object.assign({ "data-card": true, className: utils.cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', props.className) }, props, { children: [jsxRuntime.jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon ? icon : jsxRuntime.jsx(icons.CircleSmallIcon, {}) }), jsxRuntime.jsx("h3", { className: "not-prose mb-1 text-sm font-medium line-clamp-2 min-h-10", children: title }), validDescription ? (jsxRuntime.jsx("p", { className: "my-0! text-sm text-fd-muted-foreground", children: description })) : (jsxRuntime.jsx("p", { className: "my-0! text-sm text-fd-muted-foreground opacity-0 select-none", children: "\u00A0" })), props.children ? (jsxRuntime.jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] })));
18
18
  }
@@ -10,7 +10,7 @@ function ZiaCard(_a) {
10
10
  const validHref = typeof props.href === 'string' && props.href.trim() !== '';
11
11
  const validDescription = typeof description === 'string' && (description === null || description === void 0 ? void 0 : description.trim()) !== '';
12
12
  if (validHref) {
13
- return (jsxs(Link, Object.assign({ href: props.href, "data-card": true, className: cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', 'hover:bg-fd-accent/80', props.className) }, props, { children: [jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon ? icon : jsx(CircleSmallIcon, {}) }), jsx("h3", { className: "not-prose mb-1 text-sm font-medium line-clamp-2 min-h-10", children: title }), validDescription ? (jsx("p", { className: "my-0! text-sm text-fd-muted-foreground", children: description })) : (jsx("p", { className: "my-0! text-sm text-fd-muted-foreground opacity-0 select-none", children: "\u00A0" })), props.children ? (jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] })));
13
+ return (jsxs(Link, Object.assign({ href: props.href, prefetch: false, "data-card": true, className: cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', 'hover:bg-fd-accent/80', props.className) }, props, { children: [jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon ? icon : jsx(CircleSmallIcon, {}) }), jsx("h3", { className: "not-prose mb-1 text-sm font-medium line-clamp-2 min-h-10", children: title }), validDescription ? (jsx("p", { className: "my-0! text-sm text-fd-muted-foreground", children: description })) : (jsx("p", { className: "my-0! text-sm text-fd-muted-foreground opacity-0 select-none", children: "\u00A0" })), props.children ? (jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] })));
14
14
  }
15
15
  return (jsxs("div", Object.assign({ "data-card": true, className: cn('block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full', props.className) }, props, { children: [jsx("div", { className: "not-prose mb-2 w-fit rounded-md border bg-fd-muted p-1.5 text-fd-muted-foreground [&_svg]:size-4", children: icon ? icon : jsx(CircleSmallIcon, {}) }), jsx("h3", { className: "not-prose mb-1 text-sm font-medium line-clamp-2 min-h-10", children: title }), validDescription ? (jsx("p", { className: "my-0! text-sm text-fd-muted-foreground", children: description })) : (jsx("p", { className: "my-0! text-sm text-fd-muted-foreground opacity-0 select-none", children: "\u00A0" })), props.children ? (jsx("div", { className: "text-sm text-fd-muted-foreground prose-no-margin", children: props.children })) : null] })));
16
16
  }
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  'use strict';
2
3
 
3
4
  var tslib = require('tslib');
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { __rest } from 'tslib';
2
3
  import { jsx, jsxs } from 'react/jsx-runtime';
3
4
  import { FileIcon, FolderOpenIcon, FolderIcon } from '@windrun-huaiin/base-ui/icons';
@@ -0,0 +1,8 @@
1
+ import type { MDXComponents } from 'mdx/types';
2
+ import type { ReactNode } from 'react';
3
+ export declare function createBaseMdxComponents(imageFallbackSrc?: string): MDXComponents;
4
+ export declare function createCodeMdxComponents(iconMap?: Record<string, ReactNode>): MDXComponents;
5
+ export declare function createMathMdxComponents(): MDXComponents;
6
+ export declare function createMermaidMdxComponents(watermarkEnabled?: boolean, watermarkText?: string): MDXComponents;
7
+ export declare function createTypeTableMdxComponents(): MDXComponents;
8
+ export declare function createWidgetMdxComponents(cdnBaseUrl?: string, imageFallbackSrc?: string): MDXComponents;
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var codeblock = require('fumadocs-ui/components/codeblock');
5
+ var typeTable = require('fumadocs-ui/components/type-table');
6
+ var icons = require('@windrun-huaiin/base-ui/icons');
7
+ var markdownComponentMap = require('../share/markdown-component-map.js');
8
+ var imageZoom = require('../heavy/image-zoom.js');
9
+ var imageGrid = require('../heavy/image-grid.js');
10
+ var math = require('../heavy/math.js');
11
+ var mermaid = require('../heavy/mermaid.js');
12
+ var trophyCard = require('../mdx/trophy-card.js');
13
+ var ziaCard = require('../mdx/zia-card.js');
14
+ var gradientButton = require('../mdx/gradient-button.js');
15
+ var ziaFile = require('../mdx/zia-file.js');
16
+ var sunoEmbed = require('../mdx/suno-embed.js');
17
+
18
+ const defaultCodeLanguageIconMap = {
19
+ css: jsxRuntime.jsx(icons.CSSIcon, {}),
20
+ csv: jsxRuntime.jsx(icons.CSVIcon, {}),
21
+ diff: jsxRuntime.jsx(icons.DiffIcon, {}),
22
+ html: jsxRuntime.jsx(icons.HtmlIcon, {}),
23
+ http: jsxRuntime.jsx(icons.HttpIcon, {}),
24
+ java: jsxRuntime.jsx(icons.JavaIcon, {}),
25
+ json: jsxRuntime.jsx(icons.JsonIcon, {}),
26
+ jsonc: jsxRuntime.jsx(icons.SquareDashedBottomCodeIcon, {}),
27
+ log: jsxRuntime.jsx(icons.LogIcon, {}),
28
+ mdx: jsxRuntime.jsx(icons.MDXIcon, {}),
29
+ plaintext: jsxRuntime.jsx(icons.TxtIcon, {}),
30
+ regex: jsxRuntime.jsx(icons.RegexIcon, {}),
31
+ scheme: jsxRuntime.jsx(icons.SchemeIcon, {}),
32
+ sql: jsxRuntime.jsx(icons.SQLIcon, {}),
33
+ text: jsxRuntime.jsx(icons.TxtIcon, {}),
34
+ txt: jsxRuntime.jsx(icons.TxtIcon, {}),
35
+ xml: jsxRuntime.jsx(icons.XMLIcon, {}),
36
+ yaml: jsxRuntime.jsx(icons.YamlIcon, {}),
37
+ yml: jsxRuntime.jsx(icons.YamlIcon, {}),
38
+ };
39
+ function tryToMatchIcon(props, iconMap) {
40
+ var _a;
41
+ let lang;
42
+ const dataLanguage = props['data-language'];
43
+ if (dataLanguage && dataLanguage.trim() !== '') {
44
+ lang = dataLanguage.trim().toLowerCase();
45
+ }
46
+ else {
47
+ const title = props.title;
48
+ if (title) {
49
+ const titleParts = title.split('.');
50
+ if (titleParts.length > 1 && titleParts[0] !== '') {
51
+ const extension = (_a = titleParts.pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
52
+ if (extension) {
53
+ lang = extension;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ if (lang && iconMap[lang]) {
59
+ return iconMap[lang];
60
+ }
61
+ return undefined;
62
+ }
63
+ function createBaseMdxComponents(imageFallbackSrc) {
64
+ return Object.assign(Object.assign({}, markdownComponentMap.baseMarkdownComponents), { img: (props) => (jsxRuntime.jsx(imageZoom.ImageZoom, Object.assign({}, props, { fallbackSrc: imageFallbackSrc }))) });
65
+ }
66
+ function createCodeMdxComponents(iconMap = {}) {
67
+ const mergedIconMap = Object.assign(Object.assign({}, defaultCodeLanguageIconMap), iconMap);
68
+ return {
69
+ pre: (props) => {
70
+ const customIcon = tryToMatchIcon(props, mergedIconMap);
71
+ return (jsxRuntime.jsx(codeblock.CodeBlock, Object.assign({}, props, (customIcon && { icon: customIcon }), { children: jsxRuntime.jsx(codeblock.Pre, { children: props.children }) })));
72
+ },
73
+ CodeBlock: codeblock.CodeBlock,
74
+ Pre: codeblock.Pre,
75
+ };
76
+ }
77
+ function createMathMdxComponents() {
78
+ return {
79
+ MathBlock: math.MathBlock,
80
+ InlineMath: math.InlineMath,
81
+ };
82
+ }
83
+ function createMermaidMdxComponents(watermarkEnabled, watermarkText) {
84
+ return {
85
+ Mermaid: (props) => (jsxRuntime.jsx(mermaid.Mermaid, Object.assign({}, props, { watermarkEnabled: watermarkEnabled, watermarkText: watermarkText }))),
86
+ };
87
+ }
88
+ function createTypeTableMdxComponents() {
89
+ return {
90
+ TypeTable: typeTable.TypeTable,
91
+ };
92
+ }
93
+ function createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc) {
94
+ return {
95
+ TrophyCard: trophyCard.TrophyCard,
96
+ ZiaCard: ziaCard.ZiaCard,
97
+ GradientButton: gradientButton.GradientButton,
98
+ ZiaFile: ziaFile.ZiaFile,
99
+ ZiaFolder: ziaFile.ZiaFolder,
100
+ SunoEmbed: sunoEmbed.SunoEmbed,
101
+ ImageGrid: (props) => (jsxRuntime.jsx(imageGrid.ImageGrid, Object.assign({}, props, { cdnBaseUrl: cdnBaseUrl }))),
102
+ ImageZoom: (props) => (jsxRuntime.jsx(imageZoom.ImageZoom, Object.assign({}, props, { fallbackSrc: imageFallbackSrc }))),
103
+ };
104
+ }
105
+
106
+ exports.createBaseMdxComponents = createBaseMdxComponents;
107
+ exports.createCodeMdxComponents = createCodeMdxComponents;
108
+ exports.createMathMdxComponents = createMathMdxComponents;
109
+ exports.createMermaidMdxComponents = createMermaidMdxComponents;
110
+ exports.createTypeTableMdxComponents = createTypeTableMdxComponents;
111
+ exports.createWidgetMdxComponents = createWidgetMdxComponents;