@windrun-huaiin/third-ui 20.1.0 → 21.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.
- package/LICENSE +1 -1
- package/dist/clerk/clerk-page-generator.d.ts +0 -8
- package/dist/fuma/fuma-page-genarator.d.ts +2 -2
- package/dist/fuma/fuma-page-genarator.js +21 -8
- package/dist/fuma/fuma-page-genarator.mjs +21 -8
- package/dist/fuma/llm-copy-handler.js +3 -2
- package/dist/fuma/llm-copy-handler.mjs +3 -2
- package/dist/fuma/mdx/index.d.ts +1 -0
- package/dist/fuma/mdx/index.js +3 -0
- package/dist/fuma/mdx/index.mjs +1 -0
- package/dist/fuma/mdx/math.d.ts +17 -0
- package/dist/fuma/mdx/math.js +60 -0
- package/dist/fuma/mdx/math.mjs +57 -0
- package/dist/fuma/mdx/zia-card.js +1 -1
- package/dist/fuma/mdx/zia-card.mjs +1 -1
- package/package.json +4 -4
- package/src/clerk/clerk-page-generator.tsx +0 -9
- package/src/fuma/fuma-page-genarator.tsx +26 -9
- package/src/fuma/llm-copy-handler.ts +3 -3
- package/src/fuma/mdx/index.ts +1 -0
- package/src/fuma/mdx/math.tsx +130 -0
- package/src/fuma/mdx/zia-card.tsx +1 -0
- package/src/main/language-detector.tsx +0 -8
- package/dist/main/ads-alert-dialog.d.ts +0 -15
- package/dist/main/ads-alert-dialog.js +0 -21
- package/dist/main/ads-alert-dialog.mjs +0 -19
package/LICENSE
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
* Copyright (c) 2026 D8ger
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
1
|
export declare function createSignInPage(): () => import("react/jsx-runtime").JSX.Element;
|
|
10
2
|
export declare function createSignUpPage(): () => import("react/jsx-runtime").JSX.Element;
|
|
11
3
|
export declare function createWaitlistPage(): () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { ReactNode, ReactElement } from 'react';
|
|
|
2
2
|
import type { LLMCopyButtonProps, LLMCopyButton } from '@third-ui/fuma/mdx/toc-base';
|
|
3
3
|
interface FumaPageParams {
|
|
4
4
|
sourceKey: string;
|
|
5
|
-
mdxContentSource: any;
|
|
5
|
+
mdxContentSource: any | (() => Promise<any>);
|
|
6
6
|
getMDXComponents: () => any;
|
|
7
7
|
mdxSourceDir: string;
|
|
8
8
|
githubBaseUrl?: string;
|
|
@@ -25,7 +25,7 @@ export declare function createFumaPage({ sourceKey, mdxContentSource, getMDXComp
|
|
|
25
25
|
slug?: string[];
|
|
26
26
|
}>;
|
|
27
27
|
}) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
28
|
-
generateStaticParams: () => any
|
|
28
|
+
generateStaticParams: () => Promise<any>;
|
|
29
29
|
generateMetadata: (props: {
|
|
30
30
|
params: Promise<{
|
|
31
31
|
slug?: string[];
|
|
@@ -9,36 +9,49 @@ var lib = require('@windrun-huaiin/lib');
|
|
|
9
9
|
var tocClerkPortable = require('./mdx/toc-clerk-portable.js');
|
|
10
10
|
|
|
11
11
|
function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
|
|
12
|
+
const getSource = () => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
if (typeof mdxContentSource === 'function') {
|
|
14
|
+
return yield mdxContentSource();
|
|
15
|
+
}
|
|
16
|
+
return mdxContentSource;
|
|
17
|
+
});
|
|
12
18
|
const Page = function Page(_a) {
|
|
13
19
|
return tslib.__awaiter(this, arguments, void 0, function* ({ params }) {
|
|
14
|
-
var _b, _c, _d;
|
|
20
|
+
var _b, _c, _d, _e;
|
|
15
21
|
const { slug, locale } = yield params;
|
|
16
|
-
const
|
|
22
|
+
const source = yield getSource();
|
|
23
|
+
const page$1 = source.getPage(slug, locale);
|
|
17
24
|
if (!page$1) {
|
|
18
|
-
console.log('[FumaPage] missing page', { slug, locale, available: (_d = (_c = (_b =
|
|
25
|
+
console.log('[FumaPage] missing page', { slug, locale, available: (_d = (_c = (_b = source.pageTree) === null || _b === void 0 ? void 0 : _b[locale]) === null || _c === void 0 ? void 0 : _c.children) === null || _d === void 0 ? void 0 : _d.map((c) => c.url) });
|
|
19
26
|
return jsxRuntime.jsx(FallbackPage, { siteIcon: siteIcon });
|
|
20
27
|
}
|
|
21
28
|
const path = githubBaseUrl ? `${mdxSourceDir}/${page$1.path}` : undefined;
|
|
22
29
|
const tocFooterElement = (jsxRuntime.jsx(tocFooterWrapper.TocFooterWrapper, { lastModified: page$1.data.date, copyButtonComponent: copyButtonComponent
|
|
23
30
|
? React.cloneElement(copyButtonComponent, { sourceKey })
|
|
24
31
|
: undefined, editPath: path, githubBaseUrl: githubBaseUrl }));
|
|
25
|
-
const
|
|
32
|
+
const content = typeof page$1.data.load === 'function'
|
|
33
|
+
? yield page$1.data.load(getMDXComponents())
|
|
34
|
+
: {
|
|
35
|
+
body: yield page$1.data.body({ components: getMDXComponents() }),
|
|
36
|
+
toc: (_e = page$1.data.toc) !== null && _e !== void 0 ? _e : [],
|
|
37
|
+
};
|
|
26
38
|
return (jsxRuntime.jsxs(page.DocsPage, { breadcrumb: { enabled: showBreadcrumb }, tableOfContent: {
|
|
27
39
|
enabled: showTableOfContent,
|
|
28
40
|
single: false,
|
|
29
|
-
component: (jsxRuntime.jsx(tocClerkPortable.PortableClerkTOC, { toc:
|
|
41
|
+
component: (jsxRuntime.jsx(tocClerkPortable.PortableClerkTOC, { toc: content.toc, footer: tocFooterElement })),
|
|
30
42
|
}, tableOfContentPopover: {
|
|
31
43
|
enabled: false,
|
|
32
|
-
}, toc:
|
|
44
|
+
}, toc: content.toc, article: { className: 'max-sm:pb-16' }, children: [jsxRuntime.jsx(page.DocsTitle, { children: page$1.data.title }), jsxRuntime.jsx(page.DocsDescription, { className: "mb-2", children: page$1.data.description }), jsxRuntime.jsx(page.DocsBody, { className: "text-fd-foreground/80", children: content.body })] }));
|
|
33
45
|
});
|
|
34
46
|
};
|
|
35
47
|
function generateStaticParams() {
|
|
36
|
-
return
|
|
48
|
+
return getSource().then((source) => source.generateParams('slug', 'locale'));
|
|
37
49
|
}
|
|
38
50
|
function generateMetadata(props) {
|
|
39
51
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
40
52
|
const { slug, locale } = yield props.params;
|
|
41
|
-
const
|
|
53
|
+
const source = yield getSource();
|
|
54
|
+
const page = source.getPage(slug, locale);
|
|
42
55
|
if (!page) {
|
|
43
56
|
return {
|
|
44
57
|
title: '404 - Page Not Found',
|
|
@@ -7,36 +7,49 @@ import { getAsNeededLocalizedUrl } from '@windrun-huaiin/lib';
|
|
|
7
7
|
import { PortableClerkTOC } from './mdx/toc-clerk-portable.mjs';
|
|
8
8
|
|
|
9
9
|
function createFumaPage({ sourceKey, mdxContentSource, getMDXComponents, mdxSourceDir, githubBaseUrl, copyButtonComponent, siteIcon, FallbackPage, supportedLocales = ['en'], showBreadcrumb = true, showTableOfContent = true, showTableOfContentPopover = false, localePrefixAsNeeded = true, defaultLocale = 'en', }) {
|
|
10
|
+
const getSource = () => __awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
if (typeof mdxContentSource === 'function') {
|
|
12
|
+
return yield mdxContentSource();
|
|
13
|
+
}
|
|
14
|
+
return mdxContentSource;
|
|
15
|
+
});
|
|
10
16
|
const Page = function Page(_a) {
|
|
11
17
|
return __awaiter(this, arguments, void 0, function* ({ params }) {
|
|
12
|
-
var _b, _c, _d;
|
|
18
|
+
var _b, _c, _d, _e;
|
|
13
19
|
const { slug, locale } = yield params;
|
|
14
|
-
const
|
|
20
|
+
const source = yield getSource();
|
|
21
|
+
const page = source.getPage(slug, locale);
|
|
15
22
|
if (!page) {
|
|
16
|
-
console.log('[FumaPage] missing page', { slug, locale, available: (_d = (_c = (_b =
|
|
23
|
+
console.log('[FumaPage] missing page', { slug, locale, available: (_d = (_c = (_b = source.pageTree) === null || _b === void 0 ? void 0 : _b[locale]) === null || _c === void 0 ? void 0 : _c.children) === null || _d === void 0 ? void 0 : _d.map((c) => c.url) });
|
|
17
24
|
return jsx(FallbackPage, { siteIcon: siteIcon });
|
|
18
25
|
}
|
|
19
26
|
const path = githubBaseUrl ? `${mdxSourceDir}/${page.path}` : undefined;
|
|
20
27
|
const tocFooterElement = (jsx(TocFooterWrapper, { lastModified: page.data.date, copyButtonComponent: copyButtonComponent
|
|
21
28
|
? cloneElement(copyButtonComponent, { sourceKey })
|
|
22
29
|
: undefined, editPath: path, githubBaseUrl: githubBaseUrl }));
|
|
23
|
-
const
|
|
30
|
+
const content = typeof page.data.load === 'function'
|
|
31
|
+
? yield page.data.load(getMDXComponents())
|
|
32
|
+
: {
|
|
33
|
+
body: yield page.data.body({ components: getMDXComponents() }),
|
|
34
|
+
toc: (_e = page.data.toc) !== null && _e !== void 0 ? _e : [],
|
|
35
|
+
};
|
|
24
36
|
return (jsxs(DocsPage, { breadcrumb: { enabled: showBreadcrumb }, tableOfContent: {
|
|
25
37
|
enabled: showTableOfContent,
|
|
26
38
|
single: false,
|
|
27
|
-
component: (jsx(PortableClerkTOC, { toc:
|
|
39
|
+
component: (jsx(PortableClerkTOC, { toc: content.toc, footer: tocFooterElement })),
|
|
28
40
|
}, tableOfContentPopover: {
|
|
29
41
|
enabled: false,
|
|
30
|
-
}, toc:
|
|
42
|
+
}, toc: content.toc, article: { className: 'max-sm:pb-16' }, children: [jsx(DocsTitle, { children: page.data.title }), jsx(DocsDescription, { className: "mb-2", children: page.data.description }), jsx(DocsBody, { className: "text-fd-foreground/80", children: content.body })] }));
|
|
31
43
|
});
|
|
32
44
|
};
|
|
33
45
|
function generateStaticParams() {
|
|
34
|
-
return
|
|
46
|
+
return getSource().then((source) => source.generateParams('slug', 'locale'));
|
|
35
47
|
}
|
|
36
48
|
function generateMetadata(props) {
|
|
37
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
50
|
const { slug, locale } = yield props.params;
|
|
39
|
-
const
|
|
51
|
+
const source = yield getSource();
|
|
52
|
+
const page = source.getPage(slug, locale);
|
|
40
53
|
if (!page) {
|
|
41
54
|
return {
|
|
42
55
|
title: '404 - Page Not Found',
|
|
@@ -11,6 +11,7 @@ var llmUtils = require('@windrun-huaiin/lib/llm-utils');
|
|
|
11
11
|
*/
|
|
12
12
|
function LLMCopyHandler(options) {
|
|
13
13
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
var _a, _b, _c, _d;
|
|
14
15
|
const { sourceDir, dataSource, requestedPath, locale } = options;
|
|
15
16
|
// log received parameters
|
|
16
17
|
console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);
|
|
@@ -28,8 +29,8 @@ function LLMCopyHandler(options) {
|
|
|
28
29
|
console.error(`[LLMCopy] file path information missing in page data for locale=${locale}, path=${requestedPath}`);
|
|
29
30
|
return { error: 'Page file path information missing', status: 500 };
|
|
30
31
|
}
|
|
31
|
-
const title = page.title;
|
|
32
|
-
const description = page.description;
|
|
32
|
+
const title = (_b = (_a = page.data) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : page.title;
|
|
33
|
+
const description = (_d = (_c = page.data) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : page.description;
|
|
33
34
|
const relativeMdxFilePath = page.path;
|
|
34
35
|
const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);
|
|
35
36
|
console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);
|
|
@@ -9,6 +9,7 @@ import { getLLMText } from '@windrun-huaiin/lib/llm-utils';
|
|
|
9
9
|
*/
|
|
10
10
|
function LLMCopyHandler(options) {
|
|
11
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
var _a, _b, _c, _d;
|
|
12
13
|
const { sourceDir, dataSource, requestedPath, locale } = options;
|
|
13
14
|
// log received parameters
|
|
14
15
|
console.log(`[LLMCopy] Received, locale=${locale}, path=${requestedPath}`);
|
|
@@ -26,8 +27,8 @@ function LLMCopyHandler(options) {
|
|
|
26
27
|
console.error(`[LLMCopy] file path information missing in page data for locale=${locale}, path=${requestedPath}`);
|
|
27
28
|
return { error: 'Page file path information missing', status: 500 };
|
|
28
29
|
}
|
|
29
|
-
const title = page.title;
|
|
30
|
-
const description = page.description;
|
|
30
|
+
const title = (_b = (_a = page.data) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : page.title;
|
|
31
|
+
const description = (_d = (_c = page.data) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : page.description;
|
|
31
32
|
const relativeMdxFilePath = page.path;
|
|
32
33
|
const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);
|
|
33
34
|
console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);
|
package/dist/fuma/mdx/index.d.ts
CHANGED
package/dist/fuma/mdx/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var tocClerkPortable = require('./toc-clerk-portable.js');
|
|
|
15
15
|
var banner = require('./banner.js');
|
|
16
16
|
var sunoEmbed = require('./suno-embed.js');
|
|
17
17
|
var markdownComponentMap = require('./markdown-component-map.js');
|
|
18
|
+
var math = require('./math.js');
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
@@ -38,3 +39,5 @@ exports.PortableClerkTOCScrollArea = tocClerkPortable.PortableClerkTOCScrollArea
|
|
|
38
39
|
exports.Banner = banner.Banner;
|
|
39
40
|
exports.SunoEmbed = sunoEmbed.SunoEmbed;
|
|
40
41
|
exports.baseMarkdownComponents = markdownComponentMap.baseMarkdownComponents;
|
|
42
|
+
exports.InlineMath = math.InlineMath;
|
|
43
|
+
exports.MathBlock = math.MathBlock;
|
package/dist/fuma/mdx/index.mjs
CHANGED
|
@@ -13,3 +13,4 @@ export { PortableClerkTOC, PortableClerkTOCItems, PortableClerkTOCPopover, Porta
|
|
|
13
13
|
export { Banner } from './banner.mjs';
|
|
14
14
|
export { SunoEmbed } from './suno-embed.mjs';
|
|
15
15
|
export { baseMarkdownComponents } from './markdown-component-map.mjs';
|
|
16
|
+
export { InlineMath, MathBlock } from './math.mjs';
|
|
@@ -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 };
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windrun-huaiin/third-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0",
|
|
4
4
|
"description": "Third-party integrated UI components for windrun-huaiin projects",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -102,9 +102,9 @@
|
|
|
102
102
|
"tslib": "^2.8.1",
|
|
103
103
|
"unified": "^11.0.5",
|
|
104
104
|
"zod": "^4.3.6",
|
|
105
|
-
"@windrun-huaiin/
|
|
106
|
-
"@windrun-huaiin/
|
|
107
|
-
"@windrun-huaiin/
|
|
105
|
+
"@windrun-huaiin/lib": "^21.0.0",
|
|
106
|
+
"@windrun-huaiin/base-ui": "^21.0.0",
|
|
107
|
+
"@windrun-huaiin/contracts": "^21.0.0"
|
|
108
108
|
},
|
|
109
109
|
"peerDependencies": {
|
|
110
110
|
"clsx": "^2.1.1",
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
* Copyright (c) 2026 D8ger
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
import { SignIn, SignUp, Waitlist } from '@clerk/nextjs';
|
|
11
2
|
|
|
12
3
|
// Legacy page generators (for backward compatibility)
|
|
@@ -13,7 +13,7 @@ interface FumaPageParams {
|
|
|
13
13
|
/*
|
|
14
14
|
* The source of the mdx content
|
|
15
15
|
*/
|
|
16
|
-
mdxContentSource: any;
|
|
16
|
+
mdxContentSource: any | (() => Promise<any>);
|
|
17
17
|
/*
|
|
18
18
|
* The mdx components handler, refer to fumadocs
|
|
19
19
|
*/
|
|
@@ -81,11 +81,20 @@ export function createFumaPage({
|
|
|
81
81
|
localePrefixAsNeeded = true,
|
|
82
82
|
defaultLocale = 'en',
|
|
83
83
|
}: FumaPageParams) {
|
|
84
|
+
const getSource = async () => {
|
|
85
|
+
if (typeof mdxContentSource === 'function') {
|
|
86
|
+
return await mdxContentSource();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return mdxContentSource;
|
|
90
|
+
};
|
|
91
|
+
|
|
84
92
|
const Page = async function Page({ params }: { params: Promise<{ locale: string; slug?: string[] }> }) {
|
|
85
93
|
const { slug, locale } = await params;
|
|
86
|
-
const
|
|
94
|
+
const source = await getSource();
|
|
95
|
+
const page = source.getPage(slug, locale);
|
|
87
96
|
if (!page) {
|
|
88
|
-
console.log('[FumaPage] missing page', { slug, locale, available:
|
|
97
|
+
console.log('[FumaPage] missing page', { slug, locale, available: source.pageTree?.[locale]?.children?.map((c: any) => c.url) });
|
|
89
98
|
return <FallbackPage siteIcon={siteIcon} />;
|
|
90
99
|
}
|
|
91
100
|
|
|
@@ -103,7 +112,14 @@ export function createFumaPage({
|
|
|
103
112
|
/>
|
|
104
113
|
);
|
|
105
114
|
|
|
106
|
-
const
|
|
115
|
+
const content =
|
|
116
|
+
typeof page.data.load === 'function'
|
|
117
|
+
? await page.data.load(getMDXComponents())
|
|
118
|
+
: {
|
|
119
|
+
body: await page.data.body({ components: getMDXComponents() }),
|
|
120
|
+
toc: page.data.toc ?? [],
|
|
121
|
+
};
|
|
122
|
+
|
|
107
123
|
return (
|
|
108
124
|
<DocsPage
|
|
109
125
|
breadcrumb={{enabled: showBreadcrumb}}
|
|
@@ -112,7 +128,7 @@ export function createFumaPage({
|
|
|
112
128
|
single: false,
|
|
113
129
|
component: (
|
|
114
130
|
<PortableClerkTOC
|
|
115
|
-
toc={
|
|
131
|
+
toc={content.toc}
|
|
116
132
|
footer={tocFooterElement}
|
|
117
133
|
/>
|
|
118
134
|
),
|
|
@@ -120,25 +136,26 @@ export function createFumaPage({
|
|
|
120
136
|
tableOfContentPopover={{
|
|
121
137
|
enabled: false,
|
|
122
138
|
}}
|
|
123
|
-
toc={
|
|
139
|
+
toc={content.toc}
|
|
124
140
|
article={{ className: 'max-sm:pb-16' }}
|
|
125
141
|
>
|
|
126
142
|
<DocsTitle>{page.data.title}</DocsTitle>
|
|
127
143
|
<DocsDescription className="mb-2">{page.data.description}</DocsDescription>
|
|
128
144
|
<DocsBody className="text-fd-foreground/80">
|
|
129
|
-
|
|
145
|
+
{content.body}
|
|
130
146
|
</DocsBody>
|
|
131
147
|
</DocsPage>
|
|
132
148
|
);
|
|
133
149
|
};
|
|
134
150
|
|
|
135
151
|
function generateStaticParams() {
|
|
136
|
-
return
|
|
152
|
+
return getSource().then((source) => source.generateParams('slug', 'locale'));
|
|
137
153
|
}
|
|
138
154
|
|
|
139
155
|
async function generateMetadata(props: { params: Promise<{ slug?: string[]; locale?: string }> }) {
|
|
140
156
|
const { slug, locale } = await props.params;
|
|
141
|
-
const
|
|
157
|
+
const source = await getSource();
|
|
158
|
+
const page = source.getPage(slug, locale);
|
|
142
159
|
if (!page) {
|
|
143
160
|
return {
|
|
144
161
|
title: '404 - Page Not Found',
|
|
@@ -42,8 +42,8 @@ export async function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{
|
|
|
42
42
|
return { error: 'Page file path information missing', status: 500 };
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const title = page.title;
|
|
46
|
-
const description = page.description;
|
|
45
|
+
const title = page.data?.title ?? page.title;
|
|
46
|
+
const description = page.data?.description ?? page.description;
|
|
47
47
|
const relativeMdxFilePath = page.path;
|
|
48
48
|
const absoluteFilePath = nodePath.join(process.cwd(), sourceDir, relativeMdxFilePath);
|
|
49
49
|
console.log(`[LLMCopy] Attempting to read MDX content from: ${absoluteFilePath}`);
|
|
@@ -90,4 +90,4 @@ export async function LLMCopyHandler(options: LLMCopyHandlerOptions): Promise<{
|
|
|
90
90
|
console.error('[LLMCopy] General Error object details:', JSON.stringify(error, Object.getOwnPropertyNames(error), 2));
|
|
91
91
|
return { error: 'Internal Server Error', status: 500 };
|
|
92
92
|
}
|
|
93
|
-
}
|
|
93
|
+
}
|
package/src/fuma/mdx/index.ts
CHANGED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import katex from 'katex';
|
|
2
|
+
import { cn } from '@windrun-huaiin/lib/utils';
|
|
3
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
type MathSourceProps = {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
math?: string;
|
|
8
|
+
formula?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Align = 'left' | 'center' | 'right';
|
|
12
|
+
|
|
13
|
+
export type MathBlockProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> &
|
|
14
|
+
MathSourceProps & {
|
|
15
|
+
title?: ReactNode;
|
|
16
|
+
titleAlign?: Align;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type InlineMathProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> &
|
|
20
|
+
MathSourceProps & {
|
|
21
|
+
align?: Align;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const alignClassMap: Record<Align, string> = {
|
|
25
|
+
left: 'text-left justify-start',
|
|
26
|
+
center: 'text-center justify-center',
|
|
27
|
+
right: 'text-right justify-end',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const textAlignClassMap: Record<Align, string> = {
|
|
31
|
+
left: 'text-left',
|
|
32
|
+
center: 'text-center',
|
|
33
|
+
right: 'text-right',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function getMathSource({ children, math, formula }: MathSourceProps): string {
|
|
37
|
+
if (typeof math === 'string' && math.trim() !== '') return math.trim();
|
|
38
|
+
if (typeof formula === 'string' && formula.trim() !== '') return formula.trim();
|
|
39
|
+
if (typeof children === 'string' && children.trim() !== '') return children.trim();
|
|
40
|
+
|
|
41
|
+
if (Array.isArray(children)) {
|
|
42
|
+
const text = children
|
|
43
|
+
.map((item) => (typeof item === 'string' ? item : ''))
|
|
44
|
+
.join('')
|
|
45
|
+
.trim();
|
|
46
|
+
|
|
47
|
+
if (text !== '') return text;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function renderMath(source: string, displayMode: boolean) {
|
|
54
|
+
if (source === '') return '';
|
|
55
|
+
|
|
56
|
+
return katex.renderToString(source, {
|
|
57
|
+
displayMode,
|
|
58
|
+
throwOnError: false,
|
|
59
|
+
output: 'html',
|
|
60
|
+
strict: 'ignore',
|
|
61
|
+
trust: false,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function MathBlock({
|
|
66
|
+
title,
|
|
67
|
+
titleAlign = 'center',
|
|
68
|
+
children,
|
|
69
|
+
math,
|
|
70
|
+
formula,
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: MathBlockProps) {
|
|
74
|
+
const source = getMathSource({ children, math, formula });
|
|
75
|
+
const html = renderMath(source, true);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
{...props}
|
|
80
|
+
className={cn(
|
|
81
|
+
'not-prose my-6 overflow-x-auto rounded-xl border bg-fd-card p-4 text-fd-card-foreground',
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{title ? (
|
|
86
|
+
<div
|
|
87
|
+
className={cn(
|
|
88
|
+
'mb-3 text-sm font-medium text-fd-muted-foreground',
|
|
89
|
+
alignClassMap[titleAlign].split(' ')[0],
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{title}
|
|
93
|
+
</div>
|
|
94
|
+
) : null}
|
|
95
|
+
{html ? (
|
|
96
|
+
<div
|
|
97
|
+
className="min-w-fit [&_.katex-display]:my-0 [&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden"
|
|
98
|
+
dangerouslySetInnerHTML={{ __html: html }}
|
|
99
|
+
/>
|
|
100
|
+
) : (
|
|
101
|
+
<div className="text-sm text-fd-muted-foreground">Empty math block.</div>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function InlineMath({
|
|
108
|
+
children,
|
|
109
|
+
math,
|
|
110
|
+
formula,
|
|
111
|
+
align = 'center',
|
|
112
|
+
className,
|
|
113
|
+
...props
|
|
114
|
+
}: InlineMathProps) {
|
|
115
|
+
const source = getMathSource({ children, math, formula });
|
|
116
|
+
const html = renderMath(source, false);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<span
|
|
120
|
+
{...props}
|
|
121
|
+
className={cn(
|
|
122
|
+
'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',
|
|
123
|
+
textAlignClassMap[align],
|
|
124
|
+
className,
|
|
125
|
+
)}
|
|
126
|
+
>
|
|
127
|
+
<span dangerouslySetInnerHTML={{ __html: html }} />
|
|
128
|
+
</span>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
@@ -22,6 +22,7 @@ export function ZiaCard({ icon, title, description, ...props }: ZiaCardProps) {
|
|
|
22
22
|
return (
|
|
23
23
|
<Link
|
|
24
24
|
href={props.href!}
|
|
25
|
+
prefetch={false}
|
|
25
26
|
data-card
|
|
26
27
|
className={cn(
|
|
27
28
|
'block rounded-lg border bg-fd-card p-4 text-fd-card-foreground shadow-md transition-colors @max-lg:col-span-full',
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* MIT License
|
|
4
|
-
* Copyright (c) 2026 D8ger
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/
|
|
9
1
|
'use client'
|
|
10
2
|
|
|
11
3
|
import { XIcon } from "@windrun-huaiin/base-ui/icons"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface AdsAlertDialogProps {
|
|
3
|
-
open: boolean;
|
|
4
|
-
onOpenChange: (open: boolean) => void;
|
|
5
|
-
title: React.ReactNode;
|
|
6
|
-
description: React.ReactNode;
|
|
7
|
-
imgSrc?: string;
|
|
8
|
-
imgHref?: string;
|
|
9
|
-
onCancel?: () => void;
|
|
10
|
-
cancelText?: string;
|
|
11
|
-
confirmText?: string;
|
|
12
|
-
onConfirm?: () => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function AdsAlertDialog({ open, onOpenChange, title, description, imgSrc, imgHref, cancelText, onCancel, confirmText, onConfirm, }: AdsAlertDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var Image = require('next/image');
|
|
7
|
-
var icons = require('@windrun-huaiin/base-ui/icons');
|
|
8
|
-
var ui = require('@windrun-huaiin/base-ui/ui');
|
|
9
|
-
|
|
10
|
-
function AdsAlertDialog({ open, onOpenChange, title, description, imgSrc, imgHref, cancelText, onCancel, confirmText, onConfirm, }) {
|
|
11
|
-
const [imgError, setImgError] = React.useState(false);
|
|
12
|
-
return (jsxRuntime.jsx(ui.AlertDialog, { open: open, onOpenChange: onOpenChange, children: jsxRuntime.jsxs(ui.AlertDialogContent, { className: "fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-neutral-900 rounded-2xl shadow-2xl border border-neutral-200 dark:border-neutral-700 max-w-md w-full min-w-[320px] p-4 flex flex-col items-stretch", children: [jsxRuntime.jsxs("div", { className: "flex flex-row items-center justify-between mb-2", children: [jsxRuntime.jsx(ui.AlertDialogTitle, { asChild: true, children: jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-1 min-w-0 text-xl font-semibold", children: [jsxRuntime.jsx(icons.InfoIcon, { className: "w-5 h-5" }), jsxRuntime.jsx("span", { className: "truncate", children: title })] }) }), jsxRuntime.jsx("button", { className: "text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 text-xl ml-4", onClick: () => onOpenChange(false), "aria-label": "Close", tabIndex: 0, children: jsxRuntime.jsx(icons.XIcon, { className: "w-5 h-5" }) })] }), jsxRuntime.jsx(ui.AlertDialogDescription, { className: "text-base font-medium text-neutral-800 dark:text-neutral-100 mb-2", children: description }), imgSrc && (jsxRuntime.jsx("div", { className: "w-full max-w-[400px] h-[220px] relative flex items-center justify-center mb-2", children: imgError ? (jsxRuntime.jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center bg-gray-100 dark:bg-neutral-800 border border-dashed border-neutral-300 dark:border-neutral-700 rounded-lg text-neutral-400 text-sm", children: [jsxRuntime.jsx(icons.ImageOffIcon, { className: "w-12 h-12 mb-2" }), jsxRuntime.jsx("span", { children: "Image loading failed" })] })) : imgHref ? (jsxRuntime.jsx("a", { href: imgHref, target: "_blank", rel: "noopener noreferrer", className: "block w-full h-full", children: jsxRuntime.jsx(Image, { src: imgSrc, alt: "image", fill: true, className: "object-contain rounded-lg", priority: false, placeholder: "empty", unoptimized: true, onError: () => setImgError(true), sizes: "(max-width: 400px) 100vw, 400px" }) })) : (jsxRuntime.jsx(Image, { src: imgSrc, alt: "image", fill: true, className: "object-contain rounded-lg", priority: false, placeholder: "empty", unoptimized: true, onError: () => setImgError(true), sizes: "(max-width: 400px) 100vw, 400px" })) })), (cancelText || confirmText) && (jsxRuntime.jsxs("div", { className: "flex justify-end gap-2 mt-2", children: [cancelText && (jsxRuntime.jsx("button", { onClick: () => {
|
|
13
|
-
onOpenChange(false);
|
|
14
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
15
|
-
}, className: "px-6 py-2 rounded-lg border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 font-semibold hover:bg-neutral-100 dark:hover:bg-neutral-700 transition", children: cancelText })), confirmText && (jsxRuntime.jsx(ui.AlertDialogAction, { onClick: () => {
|
|
16
|
-
onOpenChange(false);
|
|
17
|
-
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
18
|
-
}, className: "px-6 py-2 rounded-lg bg-purple-500 text-white font-semibold hover:bg-purple-600 transition", children: confirmText }))] }))] }) }));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.AdsAlertDialog = AdsAlertDialog;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import Image from 'next/image';
|
|
5
|
-
import { InfoIcon, XIcon, ImageOffIcon } from '@windrun-huaiin/base-ui/icons';
|
|
6
|
-
import { AlertDialog, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction } from '@windrun-huaiin/base-ui/ui';
|
|
7
|
-
|
|
8
|
-
function AdsAlertDialog({ open, onOpenChange, title, description, imgSrc, imgHref, cancelText, onCancel, confirmText, onConfirm, }) {
|
|
9
|
-
const [imgError, setImgError] = useState(false);
|
|
10
|
-
return (jsx(AlertDialog, { open: open, onOpenChange: onOpenChange, children: jsxs(AlertDialogContent, { className: "fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-white dark:bg-neutral-900 rounded-2xl shadow-2xl border border-neutral-200 dark:border-neutral-700 max-w-md w-full min-w-[320px] p-4 flex flex-col items-stretch", children: [jsxs("div", { className: "flex flex-row items-center justify-between mb-2", children: [jsx(AlertDialogTitle, { asChild: true, children: jsxs("div", { className: "flex flex-row items-center gap-1 min-w-0 text-xl font-semibold", children: [jsx(InfoIcon, { className: "w-5 h-5" }), jsx("span", { className: "truncate", children: title })] }) }), jsx("button", { className: "text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 text-xl ml-4", onClick: () => onOpenChange(false), "aria-label": "Close", tabIndex: 0, children: jsx(XIcon, { className: "w-5 h-5" }) })] }), jsx(AlertDialogDescription, { className: "text-base font-medium text-neutral-800 dark:text-neutral-100 mb-2", children: description }), imgSrc && (jsx("div", { className: "w-full max-w-[400px] h-[220px] relative flex items-center justify-center mb-2", children: imgError ? (jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center bg-gray-100 dark:bg-neutral-800 border border-dashed border-neutral-300 dark:border-neutral-700 rounded-lg text-neutral-400 text-sm", children: [jsx(ImageOffIcon, { className: "w-12 h-12 mb-2" }), jsx("span", { children: "Image loading failed" })] })) : imgHref ? (jsx("a", { href: imgHref, target: "_blank", rel: "noopener noreferrer", className: "block w-full h-full", children: jsx(Image, { src: imgSrc, alt: "image", fill: true, className: "object-contain rounded-lg", priority: false, placeholder: "empty", unoptimized: true, onError: () => setImgError(true), sizes: "(max-width: 400px) 100vw, 400px" }) })) : (jsx(Image, { src: imgSrc, alt: "image", fill: true, className: "object-contain rounded-lg", priority: false, placeholder: "empty", unoptimized: true, onError: () => setImgError(true), sizes: "(max-width: 400px) 100vw, 400px" })) })), (cancelText || confirmText) && (jsxs("div", { className: "flex justify-end gap-2 mt-2", children: [cancelText && (jsx("button", { onClick: () => {
|
|
11
|
-
onOpenChange(false);
|
|
12
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
13
|
-
}, className: "px-6 py-2 rounded-lg border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 font-semibold hover:bg-neutral-100 dark:hover:bg-neutral-700 transition", children: cancelText })), confirmText && (jsx(AlertDialogAction, { onClick: () => {
|
|
14
|
-
onOpenChange(false);
|
|
15
|
-
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
16
|
-
}, className: "px-6 py-2 rounded-lg bg-purple-500 text-white font-semibold hover:bg-purple-600 transition", children: confirmText }))] }))] }) }));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { AdsAlertDialog };
|