@windrun-huaiin/third-ui 23.0.0 → 23.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,131 +0,0 @@
1
- import defaultMdxComponents from 'fumadocs-ui/mdx';
2
- import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
3
- import { Callout } from 'fumadocs-ui/components/callout';
4
- import { File, Folder, Files } from 'fumadocs-ui/components/files';
5
- import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
6
- import type { MDXComponents } from 'mdx/types';
7
- import {
8
- createBaseMdxComponents,
9
- createCodeMdxComponents,
10
- createMathMdxComponents,
11
- createMermaidMdxComponents,
12
- createTypeTableMdxComponents,
13
- createWidgetMdxComponents,
14
- } from './optional-features';
15
- import { SiteX } from '../site-x';
16
- import type { SiteMdxComponentsOptions } from './site-mdx-components';
17
-
18
- export type SiteMdxFeature = 'base' | 'code' | 'math' | 'mermaid' | 'type-table';
19
-
20
- const defaultFumaUiComponents: MDXComponents = {
21
- Callout,
22
- File,
23
- Folder,
24
- Files,
25
- Accordion,
26
- Accordions,
27
- Tab,
28
- Tabs,
29
- };
30
-
31
- export const DEFAULT_SITE_MDX_FEATURES: SiteMdxFeature[] = [
32
- 'base',
33
- 'code',
34
- 'math',
35
- 'mermaid',
36
- 'type-table',
37
- ];
38
-
39
- export function createSiteFeatureComponentMap(
40
- options: SiteMdxComponentsOptions,
41
- ) {
42
- const {
43
- cdnBaseUrl,
44
- iconMap = {},
45
- imageFallbackSrc,
46
- watermarkEnabled,
47
- watermarkText,
48
- } = options;
49
-
50
- return {
51
- base: {
52
- ...defaultFumaUiComponents,
53
- SiteX,
54
- ...createBaseMdxComponents(imageFallbackSrc),
55
- ...createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc),
56
- },
57
- code: createCodeMdxComponents(iconMap),
58
- math: createMathMdxComponents(),
59
- mermaid: createMermaidMdxComponents(watermarkEnabled, watermarkText),
60
- 'type-table': createTypeTableMdxComponents(),
61
- } satisfies Record<SiteMdxFeature, MDXComponents>;
62
- }
63
-
64
- function createSiteFeatureComponents(
65
- feature: SiteMdxFeature,
66
- options: SiteMdxComponentsOptions,
67
- ): MDXComponents {
68
- const {
69
- cdnBaseUrl,
70
- iconMap = {},
71
- imageFallbackSrc,
72
- watermarkEnabled,
73
- watermarkText,
74
- } = options;
75
-
76
- switch (feature) {
77
- case 'base':
78
- return {
79
- ...defaultFumaUiComponents,
80
- SiteX,
81
- ...createBaseMdxComponents(imageFallbackSrc),
82
- ...createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc),
83
- };
84
- case 'code':
85
- return createCodeMdxComponents(iconMap);
86
- case 'math':
87
- return createMathMdxComponents();
88
- case 'mermaid':
89
- return createMermaidMdxComponents(watermarkEnabled, watermarkText);
90
- case 'type-table':
91
- return createTypeTableMdxComponents();
92
- }
93
- }
94
-
95
- export function composeSiteMdxComponents(
96
- features: readonly SiteMdxFeature[],
97
- featureMap: Record<SiteMdxFeature, MDXComponents>,
98
- additionalComponents?: MDXComponents,
99
- components?: MDXComponents,
100
- ): MDXComponents {
101
- return {
102
- ...defaultMdxComponents,
103
- ...features.reduce<MDXComponents>((acc, feature) => {
104
- return {
105
- ...acc,
106
- ...featureMap[feature],
107
- };
108
- }, {}),
109
- ...additionalComponents,
110
- ...components,
111
- };
112
- }
113
-
114
- export function createComposedSiteMdxComponents(
115
- features: readonly SiteMdxFeature[],
116
- options: SiteMdxComponentsOptions,
117
- additionalComponents?: MDXComponents,
118
- components?: MDXComponents,
119
- ): MDXComponents {
120
- return {
121
- ...defaultMdxComponents,
122
- ...features.reduce<MDXComponents>((acc, feature) => {
123
- return {
124
- ...acc,
125
- ...createSiteFeatureComponents(feature, options),
126
- };
127
- }, {}),
128
- ...additionalComponents,
129
- ...components,
130
- };
131
- }