@windrun-huaiin/third-ui 26.0.0 → 27.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/dist/ai/ai-prompt-textarea.d.ts +72 -0
- package/dist/ai/ai-prompt-textarea.js +114 -0
- package/dist/ai/ai-prompt-textarea.mjs +112 -0
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/index.mjs +1 -0
- package/dist/clerk/clerk-provider-client.js +0 -1
- package/dist/clerk/clerk-provider-client.mjs +0 -1
- package/dist/clerk/fingerprint/fingerprint-client.js +0 -4
- package/dist/clerk/fingerprint/fingerprint-client.mjs +0 -4
- package/dist/clerk/fingerprint/use-fingerprint.js +0 -6
- package/dist/clerk/fingerprint/use-fingerprint.mjs +0 -6
- package/dist/clerk/signin-with-fingerprint-client.js +0 -9
- package/dist/clerk/signin-with-fingerprint-client.mjs +0 -9
- package/dist/clerk/signup-button-with-fingerprint-client.js +0 -16
- package/dist/clerk/signup-button-with-fingerprint-client.mjs +0 -16
- package/dist/clerk/signup-with-fingerprint-client.js +0 -9
- package/dist/clerk/signup-with-fingerprint-client.mjs +0 -9
- package/dist/fuma/base/custom-header.js +10 -8
- package/dist/fuma/base/custom-header.mjs +10 -8
- package/dist/fuma/base/custom-home-layout.d.ts +1 -0
- package/dist/fuma/base/index.d.ts +1 -0
- package/dist/fuma/base/index.js +4 -0
- package/dist/fuma/base/index.mjs +1 -0
- package/dist/fuma/base/nav-config.d.ts +10 -0
- package/dist/fuma/base/nav-config.js +32 -0
- package/dist/fuma/base/nav-config.mjs +28 -0
- package/dist/fuma/base/site-layout.d.ts +4 -0
- package/dist/fuma/base/site-layout.js +2 -2
- package/dist/fuma/base/site-layout.mjs +2 -2
- package/dist/fuma/fuma-page-genarator.d.ts +1 -1
- package/dist/fuma/fuma-page-genarator.js +60 -5
- package/dist/fuma/fuma-page-genarator.mjs +60 -5
- package/dist/fuma/llm-copy-handler.js +0 -9
- package/dist/fuma/llm-copy-handler.mjs +0 -9
- package/dist/fuma/mdx/index.d.ts +0 -1
- package/dist/fuma/mdx/index.js +0 -2
- package/dist/fuma/mdx/index.mjs +0 -1
- package/dist/fuma/mdx/suno-embed.js +3 -1
- package/dist/fuma/mdx/suno-embed.mjs +3 -1
- package/dist/fuma/mdx/toc-base.js +0 -1
- package/dist/fuma/mdx/toc-base.mjs +0 -1
- package/dist/fuma/server/features/widgets.js +5 -1
- package/dist/fuma/server/features/widgets.mjs +5 -1
- package/dist/lib/site-docs-helper.d.ts +51 -0
- package/dist/lib/site-docs-helper.js +68 -0
- package/dist/lib/site-docs-helper.mjs +66 -0
- package/dist/main/alert-dialog/index.js +14 -0
- package/dist/main/alert-dialog/index.mjs +5 -0
- package/dist/main/buttons/gradient-button.d.ts +20 -0
- package/dist/main/buttons/gradient-button.js +88 -0
- package/dist/main/buttons/gradient-button.mjs +86 -0
- package/dist/main/buttons/index.d.ts +3 -0
- package/dist/main/buttons/index.js +12 -0
- package/dist/main/buttons/index.mjs +4 -0
- package/dist/main/buttons/x-button.d.ts +39 -0
- package/dist/main/buttons/x-button.js +92 -0
- package/dist/main/buttons/x-button.mjs +90 -0
- package/dist/main/buttons/x-toggle-button.d.ts +32 -0
- package/dist/main/buttons/x-toggle-button.js +95 -0
- package/dist/main/buttons/x-toggle-button.mjs +74 -0
- package/dist/main/credit/credit-overview-client.js +3 -2
- package/dist/main/credit/credit-overview-client.mjs +3 -2
- package/dist/main/credit/index.d.ts +4 -0
- package/dist/main/credit/index.js +10 -0
- package/dist/main/credit/index.mjs +3 -0
- package/dist/main/credit/server.d.ts +2 -0
- package/dist/main/credit/server.js +7 -0
- package/dist/main/credit/server.mjs +1 -0
- package/dist/main/cta.js +4 -2
- package/dist/main/cta.mjs +4 -2
- package/dist/main/hero/index.d.ts +2 -0
- package/dist/main/hero/index.js +10 -0
- package/dist/main/hero/index.mjs +3 -0
- package/dist/main/home/server.d.ts +7 -0
- package/dist/main/home/server.js +19 -0
- package/dist/main/home/server.mjs +7 -0
- package/dist/main/index.d.ts +0 -15
- package/dist/main/index.js +0 -43
- package/dist/main/index.mjs +0 -21
- package/dist/main/loading/index.d.ts +1 -0
- package/dist/main/loading/index.js +9 -0
- package/dist/main/loading/index.mjs +2 -0
- package/dist/main/loading-frame/index.d.ts +1 -0
- package/dist/main/loading-frame/index.js +9 -0
- package/dist/main/loading-frame/index.mjs +2 -0
- package/dist/main/money-price/index.d.ts +4 -0
- package/dist/main/money-price/index.js +15 -0
- package/dist/main/money-price/index.mjs +4 -0
- package/dist/main/money-price/money-price-button.d.ts +1 -1
- package/dist/main/money-price/money-price-button.js +10 -7
- package/dist/main/money-price/money-price-button.mjs +10 -7
- package/dist/main/money-price/money-price-interactive.js +9 -8
- package/dist/main/money-price/money-price-interactive.mjs +9 -8
- package/dist/main/money-price/money-price-types.d.ts +1 -0
- package/dist/main/money-price/server.d.ts +5 -0
- package/dist/main/money-price/server.js +18 -0
- package/dist/main/money-price/server.mjs +4 -0
- package/package.json +54 -4
- package/src/ai/index.ts +1 -0
- package/src/clerk/clerk-provider-client.tsx +1 -3
- package/src/clerk/fingerprint/fingerprint-client.ts +0 -4
- package/src/clerk/fingerprint/use-fingerprint.ts +0 -6
- package/src/clerk/signin-with-fingerprint-client.tsx +0 -10
- package/src/clerk/signup-button-with-fingerprint-client.tsx +0 -17
- package/src/clerk/signup-with-fingerprint-client.tsx +0 -10
- package/src/fuma/base/custom-header.tsx +12 -8
- package/src/fuma/base/custom-home-layout.tsx +7 -4
- package/src/fuma/base/index.ts +1 -0
- package/src/fuma/base/nav-config.ts +81 -0
- package/src/fuma/base/site-layout.tsx +6 -0
- package/src/fuma/fuma-banner-suit.tsx +1 -1
- package/src/fuma/fuma-page-genarator.tsx +60 -7
- package/src/fuma/llm-copy-handler.ts +0 -11
- package/src/fuma/mdx/index.ts +0 -1
- package/src/fuma/mdx/suno-embed.tsx +1 -1
- package/src/fuma/mdx/toc-base.tsx +0 -1
- package/src/fuma/mdx/toc-footer-wrapper.tsx +2 -2
- package/src/fuma/server/features/widgets.tsx +1 -1
- package/src/lib/server.ts +1 -1
- package/src/{fuma/mdx → main/buttons}/gradient-button.tsx +10 -21
- package/src/main/buttons/index.ts +5 -0
- package/src/main/{x-button.tsx → buttons/x-button.tsx} +28 -42
- package/src/main/credit/credit-overview-client.tsx +1 -1
- package/src/main/credit/index.ts +11 -0
- package/src/main/credit/server.ts +7 -0
- package/src/main/cta.tsx +1 -1
- package/src/main/hero/index.ts +4 -0
- package/src/main/home/server.ts +7 -0
- package/src/main/index.ts +1 -20
- package/src/main/language-detector.tsx +0 -1
- package/src/main/loading/index.ts +3 -0
- package/src/main/loading-frame/index.ts +3 -0
- package/src/main/money-price/index.ts +18 -0
- package/src/main/money-price/money-price-button.tsx +12 -6
- package/src/main/money-price/money-price-interactive.tsx +17 -10
- package/src/main/money-price/money-price-types.ts +1 -0
- package/src/main/money-price/server.ts +22 -0
- package/dist/fuma/mdx/features.d.ts +0 -8
- package/dist/fuma/mdx/features.js +0 -92
- package/dist/fuma/mdx/features.mjs +0 -85
- package/dist/fuma/mdx/image-grid.d.ts +0 -6
- package/dist/fuma/mdx/image-grid.js +0 -17
- package/dist/fuma/mdx/image-grid.mjs +0 -15
- package/dist/fuma/mdx/image-zoom.d.ts +0 -22
- package/dist/fuma/mdx/image-zoom.js +0 -39
- package/dist/fuma/mdx/image-zoom.mjs +0 -37
- package/dist/fuma/mdx/markdown-component-map.d.ts +0 -3
- package/dist/fuma/mdx/markdown-component-map.js +0 -79
- package/dist/fuma/mdx/markdown-component-map.mjs +0 -77
- package/dist/fuma/mdx/math.d.ts +0 -17
- package/dist/fuma/mdx/math.js +0 -60
- package/dist/fuma/mdx/math.mjs +0 -57
- package/dist/fuma/mdx/mermaid.d.ts +0 -13
- package/dist/fuma/mdx/mermaid.js +0 -360
- package/dist/fuma/mdx/mermaid.mjs +0 -358
- package/dist/fuma/mdx/site-mdx-components.d.ts +0 -13
- package/dist/fuma/mdx/site-mdx-components.js +0 -19
- package/dist/fuma/mdx/site-mdx-components.mjs +0 -17
- package/dist/fuma/mdx/site-mdx-presets.d.ts +0 -13
- package/dist/fuma/mdx/site-mdx-presets.js +0 -49
- package/dist/fuma/mdx/site-mdx-presets.mjs +0 -45
- package/dist/fuma/server/optional-features.d.ts +0 -6
- package/dist/fuma/server/optional-features.js +0 -17
- package/dist/fuma/server/optional-features.mjs +0 -6
- package/dist/fuma/server/site-mdx-components.d.ts +0 -13
- package/dist/fuma/server/site-mdx-components.js +0 -18
- package/dist/fuma/server/site-mdx-components.mjs +0 -16
- package/dist/fuma/server/site-mdx-presets.d.ts +0 -195
- package/dist/fuma/server/site-mdx-presets.js +0 -55
- package/dist/fuma/server/site-mdx-presets.mjs +0 -52
- /package/src/{main → ai}/ai-prompt-textarea.tsx +0 -0
- /package/src/main/{x-toggle-button.tsx → buttons/x-toggle-button.tsx} +0 -0
package/dist/fuma/mdx/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
export { TrophyCard } from './trophy-card.mjs';
|
|
3
3
|
export { ZiaCard } from './zia-card.mjs';
|
|
4
|
-
export { GradientButton } from './gradient-button.mjs';
|
|
5
4
|
export { EditOnGitHub, LLMCopyButton, LastUpdatedDate } from './toc-base.mjs';
|
|
6
5
|
export { FumaGithubInfo } from './fuma-github-info.mjs';
|
|
7
6
|
export { ZiaFile, ZiaFolder } from './zia-file.mjs';
|
|
@@ -6,7 +6,9 @@ var React = require('react');
|
|
|
6
6
|
var utils = require('@windrun-huaiin/lib/utils');
|
|
7
7
|
var lib = require('@windrun-huaiin/base-ui/lib');
|
|
8
8
|
var snakeLoadingFrame = require('../../main/snake-loading-frame.js');
|
|
9
|
-
var gradientButton = require('
|
|
9
|
+
var gradientButton = require('../../main/buttons/gradient-button.js');
|
|
10
|
+
require('tslib');
|
|
11
|
+
require('@windrun-huaiin/base-ui/icons');
|
|
10
12
|
|
|
11
13
|
var _a;
|
|
12
14
|
const rawTimeoutSeconds = (_a = process.env.NEXT_PUBLIC_SUNO_EMBED_TIMEOUT_SECONDS) !== null && _a !== void 0 ? _a : '30';
|
|
@@ -4,7 +4,9 @@ import { useState, useRef, useEffect } from 'react';
|
|
|
4
4
|
import { cn } from '@windrun-huaiin/lib/utils';
|
|
5
5
|
import { themeSvgIconColor, themeBgColor } from '@windrun-huaiin/base-ui/lib';
|
|
6
6
|
import { SnakeLoadingFrame } from '../../main/snake-loading-frame.mjs';
|
|
7
|
-
import { GradientButton } from '
|
|
7
|
+
import { GradientButton } from '../../main/buttons/gradient-button.mjs';
|
|
8
|
+
import 'tslib';
|
|
9
|
+
import '@windrun-huaiin/base-ui/icons';
|
|
8
10
|
|
|
9
11
|
var _a;
|
|
10
12
|
const rawTimeoutSeconds = (_a = process.env.NEXT_PUBLIC_SUNO_EMBED_TIMEOUT_SECONDS) !== null && _a !== void 0 ? _a : '30';
|
|
@@ -4,7 +4,11 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var trophyCard = require('../../mdx/trophy-card.js');
|
|
6
6
|
var ziaCard = require('../../mdx/zia-card.js');
|
|
7
|
-
var gradientButton = require('
|
|
7
|
+
var gradientButton = require('../../../main/buttons/gradient-button.js');
|
|
8
|
+
require('tslib');
|
|
9
|
+
require('@windrun-huaiin/base-ui/icons');
|
|
10
|
+
require('@windrun-huaiin/base-ui/lib');
|
|
11
|
+
require('@windrun-huaiin/lib/utils');
|
|
8
12
|
var ziaFile = require('../../mdx/zia-file.js');
|
|
9
13
|
var sunoEmbed = require('../../mdx/suno-embed.js');
|
|
10
14
|
|
|
@@ -2,7 +2,11 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { lazy } from 'react';
|
|
3
3
|
import { TrophyCard } from '../../mdx/trophy-card.mjs';
|
|
4
4
|
import { ZiaCard } from '../../mdx/zia-card.mjs';
|
|
5
|
-
import { GradientButton } from '
|
|
5
|
+
import { GradientButton } from '../../../main/buttons/gradient-button.mjs';
|
|
6
|
+
import 'tslib';
|
|
7
|
+
import '@windrun-huaiin/base-ui/icons';
|
|
8
|
+
import '@windrun-huaiin/base-ui/lib';
|
|
9
|
+
import '@windrun-huaiin/lib/utils';
|
|
6
10
|
import { ZiaFolder, ZiaFile } from '../../mdx/zia-file.mjs';
|
|
7
11
|
import { SunoEmbed } from '../../mdx/suno-embed.mjs';
|
|
8
12
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { MDXComponents } from 'mdx/types';
|
|
2
|
+
import { createConfiguredLocalMdSourceFactory } from '@windrun-huaiin/fumadocs-local-md/server/source';
|
|
3
|
+
import { type FumaDocsCompilerFeatureOptions } from '@windrun-huaiin/fumadocs-local-md/presets/fuma-docs/base';
|
|
4
|
+
import { createCommonDocsSchema, createCommonMetaSchema } from './fuma-schema-check-util';
|
|
5
|
+
import { type SiteMdxFeatureComponents } from '../fuma/server/site-mdx-base';
|
|
6
|
+
type SourceFactory = ReturnType<typeof createConfiguredLocalMdSourceFactory>;
|
|
7
|
+
interface SiteDocsAppConfig {
|
|
8
|
+
i18n: {
|
|
9
|
+
defaultLocale: string;
|
|
10
|
+
locales: readonly string[];
|
|
11
|
+
localePrefixAsNeeded: boolean;
|
|
12
|
+
};
|
|
13
|
+
style: {
|
|
14
|
+
cdnBaseUrl?: string;
|
|
15
|
+
placeHolder: {
|
|
16
|
+
image?: string;
|
|
17
|
+
};
|
|
18
|
+
watermark?: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
text: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface CreateSiteDocsHelperOptions<SourceKey extends string> {
|
|
25
|
+
appConfig: SiteDocsAppConfig;
|
|
26
|
+
sourceKeys?: readonly SourceKey[];
|
|
27
|
+
sourceRootDir?: string;
|
|
28
|
+
appRoot?: string;
|
|
29
|
+
sourceFeatures?: FumaDocsCompilerFeatureOptions[];
|
|
30
|
+
mdxFeatures?: SiteMdxFeatureComponents[];
|
|
31
|
+
additionalComponents?: MDXComponents;
|
|
32
|
+
frontmatterSchema?: ReturnType<typeof createCommonDocsSchema>;
|
|
33
|
+
metaSchema?: ReturnType<typeof createCommonMetaSchema>;
|
|
34
|
+
}
|
|
35
|
+
export declare function createSiteDocsHelper<SourceKey extends string>(options: CreateSiteDocsHelperOptions<SourceKey>): {
|
|
36
|
+
i18n: I18nConfig;
|
|
37
|
+
buildConfig: any;
|
|
38
|
+
sourceFactory: any;
|
|
39
|
+
getContentSource: (sourceKey: SourceKey, overrides?: Parameters<SourceFactory["getCachedSource"]>[1]) => Promise<any>;
|
|
40
|
+
getMDXComponents: (components?: MDXComponents) => MDXComponents;
|
|
41
|
+
useMDXComponents: (components?: MDXComponents) => MDXComponents;
|
|
42
|
+
createSourceSharedConfig(): {
|
|
43
|
+
i18n: I18nConfig;
|
|
44
|
+
frontmatterSchema: import("zod").ZodObject<any, import("zod/v4/core").$strip>;
|
|
45
|
+
metaSchema: import("zod").ZodObject<any, import("zod/v4/core").$strip>;
|
|
46
|
+
sourceRootDir: string | undefined;
|
|
47
|
+
appRoot: string;
|
|
48
|
+
icon(icon: string | undefined): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var server = require('@windrun-huaiin/base-ui/components/server');
|
|
5
|
+
var source = require('@windrun-huaiin/fumadocs-local-md/server/source');
|
|
6
|
+
var base = require('@windrun-huaiin/fumadocs-local-md/presets/fuma-docs/base');
|
|
7
|
+
var fumaSchemaCheckUtil = require('./fuma-schema-check-util.js');
|
|
8
|
+
var siteMdxBase = require('../fuma/server/site-mdx-base.js');
|
|
9
|
+
|
|
10
|
+
function resolveLocalMdMode() {
|
|
11
|
+
var _a;
|
|
12
|
+
const enableDevRuntime = ((_a = process.env.LOCAL_MD_DEV_RUNTIME) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true';
|
|
13
|
+
if (process.env.NODE_ENV !== 'production' && enableDevRuntime) {
|
|
14
|
+
return 'runtime';
|
|
15
|
+
}
|
|
16
|
+
return 'build';
|
|
17
|
+
}
|
|
18
|
+
function createSiteDocsI18nConfig(appConfig) {
|
|
19
|
+
return {
|
|
20
|
+
defaultLanguage: appConfig.i18n.defaultLocale,
|
|
21
|
+
languages: appConfig.i18n.locales,
|
|
22
|
+
hideLocale: appConfig.i18n.localePrefixAsNeeded ? 'default-locale' : 'never',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createSiteDocsHelper(options) {
|
|
26
|
+
const { appConfig, sourceRootDir, appRoot = process.cwd(), sourceFeatures = [], mdxFeatures = [], additionalComponents, frontmatterSchema = fumaSchemaCheckUtil.createCommonDocsSchema(), metaSchema = fumaSchemaCheckUtil.createCommonMetaSchema(), } = options;
|
|
27
|
+
const i18n = createSiteDocsI18nConfig(appConfig);
|
|
28
|
+
const sharedConfig = {
|
|
29
|
+
i18n,
|
|
30
|
+
frontmatterSchema,
|
|
31
|
+
metaSchema,
|
|
32
|
+
sourceRootDir,
|
|
33
|
+
appRoot,
|
|
34
|
+
icon(icon) {
|
|
35
|
+
return server.getGlobalIcon(icon, true);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const buildConfig = Object.assign(Object.assign({}, sharedConfig), base.createFumaDocsBaseCompilerOptions({
|
|
39
|
+
features: sourceFeatures,
|
|
40
|
+
}));
|
|
41
|
+
const sourceFactory = source.createConfiguredLocalMdSourceFactory(sharedConfig);
|
|
42
|
+
const getMDXComponents = siteMdxBase.createSiteMdxComponents({
|
|
43
|
+
baseOptions: {
|
|
44
|
+
imageFallbackSrc: appConfig.style.placeHolder.image,
|
|
45
|
+
cdnBaseUrl: appConfig.style.cdnBaseUrl,
|
|
46
|
+
},
|
|
47
|
+
features: mdxFeatures,
|
|
48
|
+
additionalComponents: Object.assign(Object.assign({}, server.globalLucideIcons), additionalComponents),
|
|
49
|
+
});
|
|
50
|
+
function getContentSource(sourceKey, overrides) {
|
|
51
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return sourceFactory.getCachedSource(sourceKey, Object.assign({ mode: resolveLocalMdMode() }, overrides));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
i18n,
|
|
57
|
+
buildConfig,
|
|
58
|
+
sourceFactory,
|
|
59
|
+
getContentSource,
|
|
60
|
+
getMDXComponents,
|
|
61
|
+
useMDXComponents: getMDXComponents,
|
|
62
|
+
createSourceSharedConfig() {
|
|
63
|
+
return Object.assign({}, sharedConfig);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.createSiteDocsHelper = createSiteDocsHelper;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import { globalLucideIcons, getGlobalIcon } from '@windrun-huaiin/base-ui/components/server';
|
|
3
|
+
import { createConfiguredLocalMdSourceFactory } from '@windrun-huaiin/fumadocs-local-md/server/source';
|
|
4
|
+
import { createFumaDocsBaseCompilerOptions } from '@windrun-huaiin/fumadocs-local-md/presets/fuma-docs/base';
|
|
5
|
+
import { createCommonMetaSchema, createCommonDocsSchema } from './fuma-schema-check-util.mjs';
|
|
6
|
+
import { createSiteMdxComponents } from '../fuma/server/site-mdx-base.mjs';
|
|
7
|
+
|
|
8
|
+
function resolveLocalMdMode() {
|
|
9
|
+
var _a;
|
|
10
|
+
const enableDevRuntime = ((_a = process.env.LOCAL_MD_DEV_RUNTIME) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true';
|
|
11
|
+
if (process.env.NODE_ENV !== 'production' && enableDevRuntime) {
|
|
12
|
+
return 'runtime';
|
|
13
|
+
}
|
|
14
|
+
return 'build';
|
|
15
|
+
}
|
|
16
|
+
function createSiteDocsI18nConfig(appConfig) {
|
|
17
|
+
return {
|
|
18
|
+
defaultLanguage: appConfig.i18n.defaultLocale,
|
|
19
|
+
languages: appConfig.i18n.locales,
|
|
20
|
+
hideLocale: appConfig.i18n.localePrefixAsNeeded ? 'default-locale' : 'never',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createSiteDocsHelper(options) {
|
|
24
|
+
const { appConfig, sourceRootDir, appRoot = process.cwd(), sourceFeatures = [], mdxFeatures = [], additionalComponents, frontmatterSchema = createCommonDocsSchema(), metaSchema = createCommonMetaSchema(), } = options;
|
|
25
|
+
const i18n = createSiteDocsI18nConfig(appConfig);
|
|
26
|
+
const sharedConfig = {
|
|
27
|
+
i18n,
|
|
28
|
+
frontmatterSchema,
|
|
29
|
+
metaSchema,
|
|
30
|
+
sourceRootDir,
|
|
31
|
+
appRoot,
|
|
32
|
+
icon(icon) {
|
|
33
|
+
return getGlobalIcon(icon, true);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const buildConfig = Object.assign(Object.assign({}, sharedConfig), createFumaDocsBaseCompilerOptions({
|
|
37
|
+
features: sourceFeatures,
|
|
38
|
+
}));
|
|
39
|
+
const sourceFactory = createConfiguredLocalMdSourceFactory(sharedConfig);
|
|
40
|
+
const getMDXComponents = createSiteMdxComponents({
|
|
41
|
+
baseOptions: {
|
|
42
|
+
imageFallbackSrc: appConfig.style.placeHolder.image,
|
|
43
|
+
cdnBaseUrl: appConfig.style.cdnBaseUrl,
|
|
44
|
+
},
|
|
45
|
+
features: mdxFeatures,
|
|
46
|
+
additionalComponents: Object.assign(Object.assign({}, globalLucideIcons), additionalComponents),
|
|
47
|
+
});
|
|
48
|
+
function getContentSource(sourceKey, overrides) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return sourceFactory.getCachedSource(sourceKey, Object.assign({ mode: resolveLocalMdMode() }, overrides));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
i18n,
|
|
55
|
+
buildConfig,
|
|
56
|
+
sourceFactory,
|
|
57
|
+
getContentSource,
|
|
58
|
+
getMDXComponents,
|
|
59
|
+
useMDXComponents: getMDXComponents,
|
|
60
|
+
createSourceSharedConfig() {
|
|
61
|
+
return Object.assign({}, sharedConfig);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { createSiteDocsHelper };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var adsAlertDialog = require('./ads-alert-dialog.js');
|
|
5
|
+
var confirmDialog = require('./confirm-dialog.js');
|
|
6
|
+
var highPriorityConfirmDialog = require('./high-priority-confirm-dialog.js');
|
|
7
|
+
var infoDialog = require('./info-dialog.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.AdsAlertDialog = adsAlertDialog.AdsAlertDialog;
|
|
12
|
+
exports.ConfirmDialog = confirmDialog.ConfirmDialog;
|
|
13
|
+
exports.HighPriorityConfirmDialog = highPriorityConfirmDialog.HighPriorityConfirmDialog;
|
|
14
|
+
exports.InfoDialog = infoDialog.InfoDialog;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type GradientButtonVariant = 'default' | 'soft' | 'subtle';
|
|
3
|
+
export interface GradientButtonProps {
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
iconForcePosition?: 'left' | 'right';
|
|
7
|
+
align?: 'left' | 'center' | 'right';
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
iconClassName?: string;
|
|
11
|
+
href?: string;
|
|
12
|
+
openInNewTab?: boolean;
|
|
13
|
+
preserveReferrer?: boolean;
|
|
14
|
+
onClick?: () => void | Promise<void>;
|
|
15
|
+
loadingText?: React.ReactNode;
|
|
16
|
+
preventDoubleClick?: boolean;
|
|
17
|
+
variant?: GradientButtonVariant;
|
|
18
|
+
}
|
|
19
|
+
export declare function GradientButton({ title, icon, iconForcePosition, align, disabled, className, href, openInNewTab, preserveReferrer, onClick, loadingText, preventDoubleClick, iconClassName, variant, }: GradientButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var utils = require('@windrun-huaiin/lib/utils');
|
|
7
|
+
var icons = require('@windrun-huaiin/base-ui/icons');
|
|
8
|
+
var lib = require('@windrun-huaiin/base-ui/lib');
|
|
9
|
+
var Link = require('next/link');
|
|
10
|
+
var React = require('react');
|
|
11
|
+
|
|
12
|
+
function GradientButton({ title, icon, iconForcePosition, align = 'left', disabled = false, className = "", href, openInNewTab = true, preserveReferrer = false, onClick, loadingText, preventDoubleClick = true, iconClassName, variant = 'default', }) {
|
|
13
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
14
|
+
const actualLoadingText = loadingText || (title === null || title === void 0 ? void 0 : title.toString().trim()) || 'Loading...';
|
|
15
|
+
const defaultIconClass = "h-4 w-4";
|
|
16
|
+
const finalIconClass = utils.cn(variant === 'default' ? 'text-white' : lib.themeIconColor, iconClassName || defaultIconClass);
|
|
17
|
+
const getAlignmentClass = () => {
|
|
18
|
+
switch (align) {
|
|
19
|
+
case 'center':
|
|
20
|
+
return 'justify-center';
|
|
21
|
+
case 'right':
|
|
22
|
+
return 'justify-end';
|
|
23
|
+
default:
|
|
24
|
+
return 'justify-start';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const handleClick = (e) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (disabled || isLoading) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (onClick) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
if (preventDoubleClick) {
|
|
35
|
+
setIsLoading(true);
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
yield onClick();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error('GradientButton onClick error:', error);
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
if (preventDoubleClick) {
|
|
45
|
+
setIsLoading(false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const isDisabled = disabled || isLoading;
|
|
51
|
+
const displayTitle = isLoading ? actualLoadingText : title;
|
|
52
|
+
const iconProvided = icon !== undefined;
|
|
53
|
+
const iconNode = (() => {
|
|
54
|
+
if (isLoading) {
|
|
55
|
+
return jsxRuntime.jsx(icons.Loader2Icon, { className: utils.cn(finalIconClass, 'animate-spin') });
|
|
56
|
+
}
|
|
57
|
+
if (iconProvided) {
|
|
58
|
+
if (icon === null || icon === false) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (React.isValidElement(icon)) {
|
|
62
|
+
return React.cloneElement(icon, {
|
|
63
|
+
className: utils.cn(finalIconClass, icon.props.className),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return icon;
|
|
67
|
+
}
|
|
68
|
+
return jsxRuntime.jsx(icons.ArrowRightIcon, { className: utils.cn(finalIconClass) });
|
|
69
|
+
})();
|
|
70
|
+
const shouldRenderIcon = iconNode !== null && iconNode !== undefined;
|
|
71
|
+
const iconPosition = iconForcePosition !== null && iconForcePosition !== void 0 ? iconForcePosition : (onClick ? 'left' : 'right');
|
|
72
|
+
const buttonContent = iconPosition === 'left' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [shouldRenderIcon ? jsxRuntime.jsx("span", { children: iconNode }) : null, jsxRuntime.jsx("span", { className: utils.cn(shouldRenderIcon && 'ml-1'), children: displayTitle })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { children: displayTitle }), shouldRenderIcon ? jsxRuntime.jsx("span", { className: "ml-1", children: iconNode }) : null] }));
|
|
73
|
+
const alignmentClass = align === 'right'
|
|
74
|
+
? 'justify-end'
|
|
75
|
+
: align === 'center'
|
|
76
|
+
? 'justify-center'
|
|
77
|
+
: 'justify-start';
|
|
78
|
+
const baseButtonStyles = "inline-flex items-center gap-2 whitespace-nowrap h-11 px-8 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50";
|
|
79
|
+
const variantClassName = variant === 'soft'
|
|
80
|
+
? utils.cn(lib.themeBgColor, lib.themeIconColor, lib.themeBorderColor, 'border shadow-sm hover:shadow-md hover:brightness-95')
|
|
81
|
+
: variant === 'subtle'
|
|
82
|
+
? utils.cn(lib.themeMainBgColor, lib.themeIconColor, 'border border-neutral-200 shadow-sm hover:shadow-md hover:bg-neutral-50 dark:border-neutral-800 dark:hover:bg-neutral-800')
|
|
83
|
+
: utils.cn(lib.themeButtonGradientClass, lib.themeButtonGradientHoverClass, 'text-white shadow-lg hover:shadow-xl');
|
|
84
|
+
const buttonClassName = utils.cn(baseButtonStyles, variantClassName, 'text-base font-bold transition-all duration-300 rounded-full', alignmentClass, isDisabled && 'opacity-50 cursor-not-allowed', className);
|
|
85
|
+
return (jsxRuntime.jsx("div", { className: `flex flex-row gap-3 ${getAlignmentClass()}`, children: onClick ? (jsxRuntime.jsx("button", { type: "button", className: buttonClassName, onClick: handleClick, disabled: isDisabled, children: buttonContent })) : (jsxRuntime.jsx(Link, Object.assign({ href: href || "#", className: utils.cn(buttonClassName, "no-underline hover:no-underline") }, (openInNewTab ? { target: "_blank", rel: preserveReferrer ? 'noopener' : 'noopener noreferrer' } : {}), { onClick: isDisabled ? (e) => e.preventDefault() : undefined, "aria-disabled": isDisabled, children: buttonContent }))) }));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
exports.GradientButton = GradientButton;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __awaiter } from 'tslib';
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { cn } from '@windrun-huaiin/lib/utils';
|
|
5
|
+
import { Loader2Icon, ArrowRightIcon } from '@windrun-huaiin/base-ui/icons';
|
|
6
|
+
import { themeIconColor, themeBgColor, themeBorderColor, themeMainBgColor, themeButtonGradientClass, themeButtonGradientHoverClass } from '@windrun-huaiin/base-ui/lib';
|
|
7
|
+
import Link from 'next/link';
|
|
8
|
+
import React__default, { useState } from 'react';
|
|
9
|
+
|
|
10
|
+
function GradientButton({ title, icon, iconForcePosition, align = 'left', disabled = false, className = "", href, openInNewTab = true, preserveReferrer = false, onClick, loadingText, preventDoubleClick = true, iconClassName, variant = 'default', }) {
|
|
11
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
12
|
+
const actualLoadingText = loadingText || (title === null || title === void 0 ? void 0 : title.toString().trim()) || 'Loading...';
|
|
13
|
+
const defaultIconClass = "h-4 w-4";
|
|
14
|
+
const finalIconClass = cn(variant === 'default' ? 'text-white' : themeIconColor, iconClassName || defaultIconClass);
|
|
15
|
+
const getAlignmentClass = () => {
|
|
16
|
+
switch (align) {
|
|
17
|
+
case 'center':
|
|
18
|
+
return 'justify-center';
|
|
19
|
+
case 'right':
|
|
20
|
+
return 'justify-end';
|
|
21
|
+
default:
|
|
22
|
+
return 'justify-start';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const handleClick = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (disabled || isLoading) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (onClick) {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
if (preventDoubleClick) {
|
|
33
|
+
setIsLoading(true);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
yield onClick();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('GradientButton onClick error:', error);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
if (preventDoubleClick) {
|
|
43
|
+
setIsLoading(false);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const isDisabled = disabled || isLoading;
|
|
49
|
+
const displayTitle = isLoading ? actualLoadingText : title;
|
|
50
|
+
const iconProvided = icon !== undefined;
|
|
51
|
+
const iconNode = (() => {
|
|
52
|
+
if (isLoading) {
|
|
53
|
+
return jsx(Loader2Icon, { className: cn(finalIconClass, 'animate-spin') });
|
|
54
|
+
}
|
|
55
|
+
if (iconProvided) {
|
|
56
|
+
if (icon === null || icon === false) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (React__default.isValidElement(icon)) {
|
|
60
|
+
return React__default.cloneElement(icon, {
|
|
61
|
+
className: cn(finalIconClass, icon.props.className),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return icon;
|
|
65
|
+
}
|
|
66
|
+
return jsx(ArrowRightIcon, { className: cn(finalIconClass) });
|
|
67
|
+
})();
|
|
68
|
+
const shouldRenderIcon = iconNode !== null && iconNode !== undefined;
|
|
69
|
+
const iconPosition = iconForcePosition !== null && iconForcePosition !== void 0 ? iconForcePosition : (onClick ? 'left' : 'right');
|
|
70
|
+
const buttonContent = iconPosition === 'left' ? (jsxs(Fragment, { children: [shouldRenderIcon ? jsx("span", { children: iconNode }) : null, jsx("span", { className: cn(shouldRenderIcon && 'ml-1'), children: displayTitle })] })) : (jsxs(Fragment, { children: [jsx("span", { children: displayTitle }), shouldRenderIcon ? jsx("span", { className: "ml-1", children: iconNode }) : null] }));
|
|
71
|
+
const alignmentClass = align === 'right'
|
|
72
|
+
? 'justify-end'
|
|
73
|
+
: align === 'center'
|
|
74
|
+
? 'justify-center'
|
|
75
|
+
: 'justify-start';
|
|
76
|
+
const baseButtonStyles = "inline-flex items-center gap-2 whitespace-nowrap h-11 px-8 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50";
|
|
77
|
+
const variantClassName = variant === 'soft'
|
|
78
|
+
? cn(themeBgColor, themeIconColor, themeBorderColor, 'border shadow-sm hover:shadow-md hover:brightness-95')
|
|
79
|
+
: variant === 'subtle'
|
|
80
|
+
? cn(themeMainBgColor, themeIconColor, 'border border-neutral-200 shadow-sm hover:shadow-md hover:bg-neutral-50 dark:border-neutral-800 dark:hover:bg-neutral-800')
|
|
81
|
+
: cn(themeButtonGradientClass, themeButtonGradientHoverClass, 'text-white shadow-lg hover:shadow-xl');
|
|
82
|
+
const buttonClassName = cn(baseButtonStyles, variantClassName, 'text-base font-bold transition-all duration-300 rounded-full', alignmentClass, isDisabled && 'opacity-50 cursor-not-allowed', className);
|
|
83
|
+
return (jsx("div", { className: `flex flex-row gap-3 ${getAlignmentClass()}`, children: onClick ? (jsx("button", { type: "button", className: buttonClassName, onClick: handleClick, disabled: isDisabled, children: buttonContent })) : (jsx(Link, Object.assign({ href: href || "#", className: cn(buttonClassName, "no-underline hover:no-underline") }, (openInNewTab ? { target: "_blank", rel: preserveReferrer ? 'noopener' : 'noopener noreferrer' } : {}), { onClick: isDisabled ? (e) => e.preventDefault() : undefined, "aria-disabled": isDisabled, children: buttonContent }))) }));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { GradientButton };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var gradientButton = require('./gradient-button.js');
|
|
5
|
+
var xButton = require('./x-button.js');
|
|
6
|
+
var xToggleButton = require('./x-toggle-button.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.GradientButton = gradientButton.GradientButton;
|
|
11
|
+
exports.XButton = xButton.XButton;
|
|
12
|
+
exports.XToggleButton = xToggleButton.XToggleButton;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type XButtonVariant = 'default' | 'soft' | 'subtle';
|
|
3
|
+
interface BaseButtonConfig {
|
|
4
|
+
icon: ReactNode;
|
|
5
|
+
text: string;
|
|
6
|
+
onClick: () => void | Promise<void>;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface MenuItemConfig extends BaseButtonConfig {
|
|
10
|
+
tag?: {
|
|
11
|
+
text: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
};
|
|
14
|
+
splitTopBorder?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface SingleButtonProps {
|
|
17
|
+
type: 'single';
|
|
18
|
+
button: BaseButtonConfig;
|
|
19
|
+
loadingText?: string;
|
|
20
|
+
minWidth?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
iconClassName?: string;
|
|
23
|
+
variant?: XButtonVariant;
|
|
24
|
+
}
|
|
25
|
+
interface SplitButtonProps {
|
|
26
|
+
type: 'split';
|
|
27
|
+
mainButton: BaseButtonConfig;
|
|
28
|
+
menuItems: MenuItemConfig[];
|
|
29
|
+
loadingText?: string;
|
|
30
|
+
menuWidth?: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
mainButtonClassName?: string;
|
|
33
|
+
dropdownButtonClassName?: string;
|
|
34
|
+
iconClassName?: string;
|
|
35
|
+
variant?: XButtonVariant;
|
|
36
|
+
}
|
|
37
|
+
type xButtonProps = SingleButtonProps | SplitButtonProps;
|
|
38
|
+
export declare function XButton(props: xButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var icons = require('@windrun-huaiin/base-ui/icons');
|
|
8
|
+
var lib = require('@windrun-huaiin/base-ui/lib');
|
|
9
|
+
var utils = require('@windrun-huaiin/lib/utils');
|
|
10
|
+
|
|
11
|
+
function XButton(props) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
14
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
15
|
+
const menuRef = React.useRef(null);
|
|
16
|
+
const { iconClassName } = props;
|
|
17
|
+
const defaultIconClass = "w-5 h-5";
|
|
18
|
+
const variant = (_a = props.variant) !== null && _a !== void 0 ? _a : 'default';
|
|
19
|
+
const finalIconClass = utils.cn(variant === 'default' ? '' : lib.themeIconColor, iconClassName || defaultIconClass);
|
|
20
|
+
const loadingIconClass = utils.cn(finalIconClass, "mr-1 animate-spin");
|
|
21
|
+
const chevronIconClass = "w-6 h-6";
|
|
22
|
+
const renderIcon = (icon) => {
|
|
23
|
+
if (React.isValidElement(icon)) {
|
|
24
|
+
return React.cloneElement(icon, {
|
|
25
|
+
className: utils.cn(finalIconClass, icon.props.className),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return icon;
|
|
29
|
+
};
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (props.type === 'split') {
|
|
32
|
+
const handleClickOutside = (event) => {
|
|
33
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
34
|
+
setMenuOpen(false);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (menuOpen) {
|
|
38
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
39
|
+
}
|
|
40
|
+
return () => {
|
|
41
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}, [menuOpen, props.type]);
|
|
45
|
+
const handleButtonClick = (onClick) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (isLoading)
|
|
47
|
+
return;
|
|
48
|
+
setIsLoading(true);
|
|
49
|
+
try {
|
|
50
|
+
yield onClick();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('Button click error:', error);
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
setIsLoading(false);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const baseButtonClass = "flex items-center justify-center gap-2 px-4 py-2 text-sm font-semibold transition-colors";
|
|
60
|
+
const singleButtonVariantClass = variant === 'soft'
|
|
61
|
+
? utils.cn(lib.themeBgColor, lib.themeIconColor, lib.themeBorderColor, "border hover:brightness-95")
|
|
62
|
+
: variant === 'subtle'
|
|
63
|
+
? utils.cn(lib.themeMainBgColor, lib.themeIconColor, "border border-neutral-200 hover:bg-neutral-50 dark:border-neutral-800 dark:hover:bg-neutral-800")
|
|
64
|
+
: "bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-white hover:bg-neutral-300 dark:hover:bg-neutral-700";
|
|
65
|
+
const splitMainButtonVariantClass = variant === 'soft'
|
|
66
|
+
? utils.cn("bg-transparent hover:bg-black/5 dark:hover:bg-white/5", lib.themeIconColor)
|
|
67
|
+
: variant === 'subtle'
|
|
68
|
+
? utils.cn("bg-transparent hover:bg-neutral-50 dark:hover:bg-neutral-800", lib.themeIconColor)
|
|
69
|
+
: "bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-white hover:bg-neutral-300 dark:hover:bg-neutral-700";
|
|
70
|
+
const splitDropdownVariantClass = variant === 'soft'
|
|
71
|
+
? utils.cn("bg-transparent hover:bg-black/5 dark:hover:bg-white/5 sm:border-l", lib.themeIconColor, lib.themeBorderColor)
|
|
72
|
+
: variant === 'subtle'
|
|
73
|
+
? utils.cn("bg-transparent hover:bg-neutral-50 dark:hover:bg-neutral-800 sm:border-l", lib.themeIconColor, "border-neutral-200 dark:border-neutral-800")
|
|
74
|
+
: "bg-neutral-200 dark:bg-neutral-800 text-neutral-700 dark:text-white hover:bg-neutral-300 dark:hover:bg-neutral-700 sm:border-l sm:border-neutral-300 sm:dark:border-neutral-700";
|
|
75
|
+
const disabledClass = "opacity-60 cursor-not-allowed";
|
|
76
|
+
if (props.type === 'single') {
|
|
77
|
+
const { button, loadingText, minWidth = 'min-w-[110px]', className = '' } = props;
|
|
78
|
+
const isDisabled = button.disabled || isLoading;
|
|
79
|
+
const actualLoadingText = loadingText || ((_b = button.text) === null || _b === void 0 ? void 0 : _b.trim()) || 'Loading...';
|
|
80
|
+
return (jsxRuntime.jsx("button", { onClick: () => handleButtonClick(button.onClick), disabled: isDisabled, className: utils.cn("w-full sm:w-auto", minWidth, baseButtonClass, singleButtonVariantClass, "rounded-full", isDisabled && disabledClass, className), title: button.text, children: isLoading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(icons.Loader2Icon, { className: loadingIconClass }), jsxRuntime.jsx("span", { children: actualLoadingText })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderIcon(button.icon), jsxRuntime.jsx("span", { children: button.text })] })) }));
|
|
81
|
+
}
|
|
82
|
+
const { mainButton, menuItems, loadingText, menuWidth = 'w-full sm:w-40', className = '', mainButtonClassName = '', dropdownButtonClassName = '' } = props;
|
|
83
|
+
const isMainDisabled = mainButton.disabled || isLoading;
|
|
84
|
+
const actualLoadingText = loadingText || ((_c = mainButton.text) === null || _c === void 0 ? void 0 : _c.trim()) || 'Loading...';
|
|
85
|
+
return (jsxRuntime.jsxs("div", { className: utils.cn("relative flex flex-row items-stretch w-full sm:w-auto rounded-full gap-0", menuOpen && "z-90", className), children: [jsxRuntime.jsx("button", { onClick: () => handleButtonClick(mainButton.onClick), disabled: isMainDisabled, className: utils.cn("flex-1 min-w-0 sm:min-w-[100px] sm:flex-initial rounded-l-full", baseButtonClass, splitMainButtonVariantClass, isMainDisabled && disabledClass, mainButtonClassName), onMouseDown: e => { if (e.button === 2)
|
|
86
|
+
e.preventDefault(); }, title: mainButton.text, children: isLoading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(icons.Loader2Icon, { className: loadingIconClass }), jsxRuntime.jsx("span", { children: actualLoadingText })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderIcon(mainButton.icon), jsxRuntime.jsx("span", { children: mainButton.text })] })) }), jsxRuntime.jsx("button", { type: "button", onClick: () => setMenuOpen(!menuOpen), disabled: isLoading, className: utils.cn("w-12 rounded-r-full", baseButtonClass, splitDropdownVariantClass, isLoading && disabledClass, dropdownButtonClassName), "aria-label": "Open menu", children: jsxRuntime.jsx(icons.ChevronDownIcon, { className: utils.cn(chevronIconClass, menuOpen && "rotate-180", "transition-transform") }) }), menuOpen && (jsxRuntime.jsx("div", { ref: menuRef, className: utils.cn("absolute top-full right-0 mt-2 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg z-50 overflow-hidden", menuWidth), children: menuItems.map((item, index) => (jsxRuntime.jsxs("button", { type: "button", onClick: () => {
|
|
87
|
+
setMenuOpen(false);
|
|
88
|
+
handleButtonClick(item.onClick);
|
|
89
|
+
}, disabled: item.disabled || isLoading, className: utils.cn("w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-neutral-100 dark:hover:bg-neutral-700 transition-colors", item.disabled && disabledClass, item.splitTopBorder && "border-t border-neutral-200 dark:border-neutral-700"), children: [renderIcon(item.icon), jsxRuntime.jsx("span", { className: "flex-1", children: item.text }), item.tag && (jsxRuntime.jsx("span", { className: utils.cn("px-1.5 py-0.5 text-xs rounded", item.tag.color || "bg-blue-100 text-blue-800"), children: item.tag.text }))] }, index))) }))] }));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.XButton = XButton;
|