react-ai-renderer 0.1.16 → 0.1.18

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/index.d.ts CHANGED
@@ -1,5 +1,28 @@
1
1
  import React from 'react';
2
2
 
3
+ /**
4
+ * 骨架图配置接口
5
+ */
6
+ interface SkeletonConfig {
7
+ /** 自定义骨架图组件 */
8
+ component?: React.ComponentType<SkeletonProps>;
9
+ /** 自定义骨架图元素 */
10
+ element?: React.ReactElement;
11
+ /** 自定义骨架图生成函数 */
12
+ generator?: (props: SkeletonProps) => React.ReactElement;
13
+ /** 是否启用自动生成 */
14
+ autoGenerate?: boolean;
15
+ }
16
+ /**
17
+ * 骨架图组件的属性
18
+ */
19
+ interface SkeletonProps {
20
+ componentName: string;
21
+ componentData?: ComponentData$1;
22
+ props?: Record<string, any>;
23
+ style?: React.CSSProperties;
24
+ }
25
+
3
26
  interface ComponentData$1 {
4
27
  type: "text" | "component";
5
28
  value: string;
@@ -22,6 +45,8 @@ interface ComponentHandler extends BaseComponentHandler {
22
45
  onRender?: (item: ComponentData$1, scope: any) => void;
23
46
  /** 自定义加载组件,可以是 React 组件、React 元素、字符串、布尔值或返回 React 元素的函数 */
24
47
  loader?: React.ComponentType<any> | React.ReactElement | string | boolean | ((componentName: string) => React.ReactElement);
48
+ /** 骨架图配置,用于在加载时显示骨架图。如果未提供且 loader 也未提供,将自动根据组件名称生成骨架图 */
49
+ skeleton?: SkeletonConfig;
25
50
  /** 组件的显示标签,用于在占位组件中显示 */
26
51
  label?: string;
27
52
  }
@@ -33,6 +58,8 @@ interface EnhancedComponentConfig {
33
58
  label?: string;
34
59
  /** 自定义加载组件,可以是 React 组件、React 元素、字符串、布尔值或返回 React 元素的函数 */
35
60
  loader?: React.ComponentType<any> | React.ReactElement | string | boolean | ((componentName: string) => React.ReactElement);
61
+ /** 骨架图配置,用于在加载时显示骨架图。如果未提供且 loader 也未提供,将自动根据组件名称生成骨架图 */
62
+ skeleton?: SkeletonConfig;
36
63
  /** 组件渲染完成后的钩子 */
37
64
  onRenderFinished?: (item: ComponentData$1, scope: any) => void;
38
65
  /** 组件渲染过程中的钩子 */
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ import RemarkGfm from 'remark-gfm';
8
8
  import { run, compile } from '@mdx-js/mdx';
9
9
  import RehypeKatex from 'rehype-katex';
10
10
  import RehypeHighlight from 'rehype-highlight';
11
- import RehypeRaw from 'rehype-raw';
12
11
 
13
12
  // SSR 兼容性 polyfill
14
13
  // 这个文件确保在服务端渲染时不会因为访问 document 而报错
@@ -764,7 +763,8 @@ var MDXStreamingParser = /** @class */function () {
764
763
  return "\"".concat(inner, "\"");
765
764
  });
766
765
  // 2. 为对象键名添加引号(如果还没有引号)
767
- jsonValue = jsonValue.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/g, '$1"$2":');
766
+ // 修复:使用 \p{L} 匹配 Unicode 字母(包括中文),使用 u 标志
767
+ jsonValue = jsonValue.replace(/([{,]\s*)([\p{L}_$][\p{L}\p{N}_$]*)\s*:/gu, '$1"$2":');
768
768
  // 3. 处理属性值中的模板字符串
769
769
  jsonValue = jsonValue.replace(/`([^`]*)`/g, function (match, p1) {
770
770
  return JSON.stringify(p1);
@@ -58337,13 +58337,13 @@ function renderText(textContent, scope, registeredComponents) {
58337
58337
  children: textContent,
58338
58338
  components: registeredComponents,
58339
58339
  remarkPlugins: [RemarkMath, RemarkGfm, RemarkBreaks],
58340
- rehypePlugins: [RehypeRaw, RehypeKatex, [RehypeHighlight, {
58340
+ rehypePlugins: [RehypeKatex, [RehypeHighlight, {
58341
58341
  detect: false,
58342
58342
  ignoreMissing: true,
58343
58343
  plainText: ['mermaid'] // 将mermaid作为纯文本处理,避免被错误高亮
58344
58344
  }]],
58345
58345
  remarkRehypeOptions: {
58346
- allowDangerousHtml: true // 允许处理 HTML 标签
58346
+ allowDangerousHtml: false // 允许处理 HTML 标签
58347
58347
  }
58348
58348
  })];
58349
58349
  });
@@ -58603,10 +58603,523 @@ function MdxLayout(_a) {
58603
58603
  });
58604
58604
  }
58605
58605
 
58606
+ function generateSkeletonByComponentName(componentName, props, style) {
58607
+ var _a, _b;
58608
+ var baseStyle = __assign({
58609
+ borderRadius: '8px',
58610
+ backgroundColor: '#f3f4f6'
58611
+ }, style);
58612
+ // 根据组件名称模式匹配生成不同的骨架图
58613
+ var name = componentName.toLowerCase();
58614
+ // 图表类组件
58615
+ if (name.includes('chart') || name.includes('graph') || name.includes('plot')) {
58616
+ return /*#__PURE__*/jsxs("div", {
58617
+ style: __assign(__assign({}, baseStyle), {
58618
+ padding: '24px',
58619
+ minHeight: (props === null || props === void 0 ? void 0 : props.height) ? "".concat(props.height, "px") : '300px',
58620
+ display: 'flex',
58621
+ flexDirection: 'column',
58622
+ gap: '12px'
58623
+ }),
58624
+ children: [/*#__PURE__*/jsxs("div", {
58625
+ style: {
58626
+ display: 'flex',
58627
+ justifyContent: 'space-between',
58628
+ alignItems: 'center',
58629
+ marginBottom: '8px'
58630
+ },
58631
+ children: [/*#__PURE__*/jsx("div", {
58632
+ style: {
58633
+ width: '120px',
58634
+ height: '20px',
58635
+ backgroundColor: '#e5e7eb',
58636
+ borderRadius: '4px'
58637
+ }
58638
+ }), /*#__PURE__*/jsx("div", {
58639
+ style: {
58640
+ width: '80px',
58641
+ height: '16px',
58642
+ backgroundColor: '#e5e7eb',
58643
+ borderRadius: '4px'
58644
+ }
58645
+ })]
58646
+ }), /*#__PURE__*/jsx("div", {
58647
+ style: {
58648
+ flex: 1,
58649
+ display: 'flex',
58650
+ alignItems: 'flex-end',
58651
+ gap: '8px',
58652
+ height: '200px'
58653
+ },
58654
+ children: Array.from({
58655
+ length: 8
58656
+ }).map(function (_, i) {
58657
+ return /*#__PURE__*/jsx("div", {
58658
+ style: {
58659
+ flex: 1,
58660
+ height: "".concat(Math.random() * 60 + 40, "%"),
58661
+ backgroundColor: '#d1d5db',
58662
+ borderRadius: '4px 4px 0 0',
58663
+ animation: 'pulse 1.5s ease-in-out infinite',
58664
+ animationDelay: "".concat(i * 0.1, "s")
58665
+ }
58666
+ }, i);
58667
+ })
58668
+ }), /*#__PURE__*/jsx("div", {
58669
+ style: {
58670
+ display: 'flex',
58671
+ gap: '12px',
58672
+ marginTop: '8px'
58673
+ },
58674
+ children: Array.from({
58675
+ length: 3
58676
+ }).map(function (_, i) {
58677
+ return /*#__PURE__*/jsxs("div", {
58678
+ style: {
58679
+ display: 'flex',
58680
+ alignItems: 'center',
58681
+ gap: '6px'
58682
+ },
58683
+ children: [/*#__PURE__*/jsx("div", {
58684
+ style: {
58685
+ width: '12px',
58686
+ height: '12px',
58687
+ backgroundColor: '#d1d5db',
58688
+ borderRadius: '2px'
58689
+ }
58690
+ }), /*#__PURE__*/jsx("div", {
58691
+ style: {
58692
+ width: '60px',
58693
+ height: '12px',
58694
+ backgroundColor: '#e5e7eb',
58695
+ borderRadius: '2px'
58696
+ }
58697
+ })]
58698
+ }, i);
58699
+ })
58700
+ }), /*#__PURE__*/jsx("style", {
58701
+ children: "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "
58702
+ })]
58703
+ });
58704
+ }
58705
+ // 表格类组件
58706
+ if (name.includes('table') || name.includes('grid')) {
58707
+ var rowCount_1 = (props === null || props === void 0 ? void 0 : props.rows) || 5;
58708
+ var colCount_1 = (props === null || props === void 0 ? void 0 : props.columns) || 4;
58709
+ return /*#__PURE__*/jsxs("div", {
58710
+ style: __assign(__assign({}, baseStyle), {
58711
+ padding: '16px',
58712
+ overflow: 'hidden'
58713
+ }),
58714
+ children: [/*#__PURE__*/jsxs("div", {
58715
+ style: {
58716
+ marginBottom: '12px'
58717
+ },
58718
+ children: [/*#__PURE__*/jsx("div", {
58719
+ style: {
58720
+ width: '150px',
58721
+ height: '20px',
58722
+ backgroundColor: '#e5e7eb',
58723
+ borderRadius: '4px',
58724
+ marginBottom: '8px'
58725
+ }
58726
+ }), /*#__PURE__*/jsx("div", {
58727
+ style: {
58728
+ width: '200px',
58729
+ height: '16px',
58730
+ backgroundColor: '#e5e7eb',
58731
+ borderRadius: '4px'
58732
+ }
58733
+ })]
58734
+ }), /*#__PURE__*/jsxs("div", {
58735
+ style: {
58736
+ border: '1px solid #e5e7eb',
58737
+ borderRadius: '4px',
58738
+ overflow: 'hidden'
58739
+ },
58740
+ children: [/*#__PURE__*/jsx("div", {
58741
+ style: {
58742
+ display: 'grid',
58743
+ gridTemplateColumns: "repeat(".concat(colCount_1, ", 1fr)"),
58744
+ backgroundColor: '#f9fafb',
58745
+ borderBottom: '1px solid #e5e7eb'
58746
+ },
58747
+ children: Array.from({
58748
+ length: colCount_1
58749
+ }).map(function (_, i) {
58750
+ return /*#__PURE__*/jsx("div", {
58751
+ style: {
58752
+ padding: '12px',
58753
+ borderRight: i < colCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58754
+ },
58755
+ children: /*#__PURE__*/jsx("div", {
58756
+ style: {
58757
+ width: '80%',
58758
+ height: '16px',
58759
+ backgroundColor: '#d1d5db',
58760
+ borderRadius: '2px'
58761
+ }
58762
+ })
58763
+ }, i);
58764
+ })
58765
+ }), Array.from({
58766
+ length: rowCount_1
58767
+ }).map(function (_, rowIndex) {
58768
+ return /*#__PURE__*/jsx("div", {
58769
+ style: {
58770
+ display: 'grid',
58771
+ gridTemplateColumns: "repeat(".concat(colCount_1, ", 1fr)"),
58772
+ borderBottom: rowIndex < rowCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58773
+ },
58774
+ children: Array.from({
58775
+ length: colCount_1
58776
+ }).map(function (_, colIndex) {
58777
+ return /*#__PURE__*/jsx("div", {
58778
+ style: {
58779
+ padding: '12px',
58780
+ borderRight: colIndex < colCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58781
+ },
58782
+ children: /*#__PURE__*/jsx("div", {
58783
+ style: {
58784
+ width: "".concat(Math.random() * 40 + 60, "%"),
58785
+ height: '14px',
58786
+ backgroundColor: '#e5e7eb',
58787
+ borderRadius: '2px'
58788
+ }
58789
+ })
58790
+ }, colIndex);
58791
+ })
58792
+ }, rowIndex);
58793
+ })]
58794
+ })]
58795
+ });
58796
+ }
58797
+ // 卡片类组件
58798
+ if (name.includes('card')) {
58799
+ return /*#__PURE__*/jsxs("div", {
58800
+ style: __assign(__assign({}, baseStyle), {
58801
+ padding: '20px',
58802
+ minHeight: '200px'
58803
+ }),
58804
+ children: [/*#__PURE__*/jsx("div", {
58805
+ style: {
58806
+ width: '60%',
58807
+ height: '24px',
58808
+ backgroundColor: '#e5e7eb',
58809
+ borderRadius: '4px',
58810
+ marginBottom: '16px'
58811
+ }
58812
+ }), /*#__PURE__*/jsx("div", {
58813
+ style: {
58814
+ width: '100%',
58815
+ height: '16px',
58816
+ backgroundColor: '#e5e7eb',
58817
+ borderRadius: '4px',
58818
+ marginBottom: '8px'
58819
+ }
58820
+ }), /*#__PURE__*/jsx("div", {
58821
+ style: {
58822
+ width: '90%',
58823
+ height: '16px',
58824
+ backgroundColor: '#e5e7eb',
58825
+ borderRadius: '4px',
58826
+ marginBottom: '8px'
58827
+ }
58828
+ }), /*#__PURE__*/jsx("div", {
58829
+ style: {
58830
+ width: '70%',
58831
+ height: '16px',
58832
+ backgroundColor: '#e5e7eb',
58833
+ borderRadius: '4px',
58834
+ marginBottom: '16px'
58835
+ }
58836
+ }), /*#__PURE__*/jsxs("div", {
58837
+ style: {
58838
+ display: 'flex',
58839
+ gap: '8px',
58840
+ marginTop: '16px'
58841
+ },
58842
+ children: [/*#__PURE__*/jsx("div", {
58843
+ style: {
58844
+ width: '80px',
58845
+ height: '32px',
58846
+ backgroundColor: '#d1d5db',
58847
+ borderRadius: '4px'
58848
+ }
58849
+ }), /*#__PURE__*/jsx("div", {
58850
+ style: {
58851
+ width: '80px',
58852
+ height: '32px',
58853
+ backgroundColor: '#d1d5db',
58854
+ borderRadius: '4px'
58855
+ }
58856
+ })]
58857
+ })]
58858
+ });
58859
+ }
58860
+ // 列表类组件
58861
+ if (name.includes('list') || name.includes('todo')) {
58862
+ var itemCount_1 = ((_a = props === null || props === void 0 ? void 0 : props.items) === null || _a === void 0 ? void 0 : _a.length) || (props === null || props === void 0 ? void 0 : props.count) || 3;
58863
+ return /*#__PURE__*/jsx("div", {
58864
+ style: __assign(__assign({}, baseStyle), {
58865
+ padding: '16px'
58866
+ }),
58867
+ children: Array.from({
58868
+ length: itemCount_1
58869
+ }).map(function (_, i) {
58870
+ return /*#__PURE__*/jsxs("div", {
58871
+ style: {
58872
+ display: 'flex',
58873
+ alignItems: 'center',
58874
+ gap: '12px',
58875
+ marginBottom: i < itemCount_1 - 1 ? '12px' : '0',
58876
+ paddingBottom: i < itemCount_1 - 1 ? '12px' : '0',
58877
+ borderBottom: i < itemCount_1 - 1 ? '1px solid #e5e7eb' : 'none'
58878
+ },
58879
+ children: [/*#__PURE__*/jsx("div", {
58880
+ style: {
58881
+ width: '20px',
58882
+ height: '20px',
58883
+ backgroundColor: '#d1d5db',
58884
+ borderRadius: '4px',
58885
+ flexShrink: 0
58886
+ }
58887
+ }), /*#__PURE__*/jsxs("div", {
58888
+ style: {
58889
+ flex: 1
58890
+ },
58891
+ children: [/*#__PURE__*/jsx("div", {
58892
+ style: {
58893
+ width: "".concat(Math.random() * 30 + 60, "%"),
58894
+ height: '16px',
58895
+ backgroundColor: '#e5e7eb',
58896
+ borderRadius: '4px',
58897
+ marginBottom: '6px'
58898
+ }
58899
+ }), /*#__PURE__*/jsx("div", {
58900
+ style: {
58901
+ width: "".concat(Math.random() * 40 + 40, "%"),
58902
+ height: '14px',
58903
+ backgroundColor: '#e5e7eb',
58904
+ borderRadius: '4px'
58905
+ }
58906
+ })]
58907
+ })]
58908
+ }, i);
58909
+ })
58910
+ });
58911
+ }
58912
+ // 表单类组件
58913
+ if (name.includes('form') || name.includes('input') || name.includes('select')) {
58914
+ var fieldCount_1 = ((_b = props === null || props === void 0 ? void 0 : props.fields) === null || _b === void 0 ? void 0 : _b.length) || 3;
58915
+ return /*#__PURE__*/jsxs("div", {
58916
+ style: __assign(__assign({}, baseStyle), {
58917
+ padding: '20px'
58918
+ }),
58919
+ children: [Array.from({
58920
+ length: fieldCount_1
58921
+ }).map(function (_, i) {
58922
+ return /*#__PURE__*/jsxs("div", {
58923
+ style: {
58924
+ marginBottom: i < fieldCount_1 - 1 ? '20px' : '0'
58925
+ },
58926
+ children: [/*#__PURE__*/jsx("div", {
58927
+ style: {
58928
+ width: '100px',
58929
+ height: '14px',
58930
+ backgroundColor: '#e5e7eb',
58931
+ borderRadius: '2px',
58932
+ marginBottom: '8px'
58933
+ }
58934
+ }), /*#__PURE__*/jsx("div", {
58935
+ style: {
58936
+ width: '100%',
58937
+ height: '40px',
58938
+ backgroundColor: '#f3f4f6',
58939
+ border: '1px solid #e5e7eb',
58940
+ borderRadius: '4px'
58941
+ }
58942
+ })]
58943
+ }, i);
58944
+ }), /*#__PURE__*/jsxs("div", {
58945
+ style: {
58946
+ display: 'flex',
58947
+ gap: '12px',
58948
+ marginTop: '20px'
58949
+ },
58950
+ children: [/*#__PURE__*/jsx("div", {
58951
+ style: {
58952
+ width: '100px',
58953
+ height: '36px',
58954
+ backgroundColor: '#d1d5db',
58955
+ borderRadius: '4px'
58956
+ }
58957
+ }), /*#__PURE__*/jsx("div", {
58958
+ style: {
58959
+ width: '100px',
58960
+ height: '36px',
58961
+ backgroundColor: '#e5e7eb',
58962
+ borderRadius: '4px'
58963
+ }
58964
+ })]
58965
+ })]
58966
+ });
58967
+ }
58968
+ // 图片/媒体类组件
58969
+ if (name.includes('image') || name.includes('img') || name.includes('video') || name.includes('media')) {
58970
+ return /*#__PURE__*/jsx("div", {
58971
+ style: __assign(__assign({}, baseStyle), {
58972
+ padding: '16px',
58973
+ display: 'flex',
58974
+ alignItems: 'center',
58975
+ justifyContent: 'center',
58976
+ minHeight: (props === null || props === void 0 ? void 0 : props.height) ? "".concat(props.height, "px") : '200px'
58977
+ }),
58978
+ children: /*#__PURE__*/jsx("div", {
58979
+ style: {
58980
+ width: '100%',
58981
+ height: '100%',
58982
+ backgroundColor: '#e5e7eb',
58983
+ borderRadius: '8px',
58984
+ display: 'flex',
58985
+ alignItems: 'center',
58986
+ justifyContent: 'center'
58987
+ },
58988
+ children: /*#__PURE__*/jsx("div", {
58989
+ style: {
58990
+ width: '48px',
58991
+ height: '48px',
58992
+ backgroundColor: '#d1d5db',
58993
+ borderRadius: '50%',
58994
+ display: 'flex',
58995
+ alignItems: 'center',
58996
+ justifyContent: 'center'
58997
+ },
58998
+ children: /*#__PURE__*/jsx("div", {
58999
+ style: {
59000
+ width: '24px',
59001
+ height: '24px',
59002
+ backgroundColor: '#9ca3af',
59003
+ borderRadius: '4px'
59004
+ }
59005
+ })
59006
+ })
59007
+ })
59008
+ });
59009
+ }
59010
+ // 默认骨架图
59011
+ return /*#__PURE__*/jsxs("div", {
59012
+ style: __assign(__assign({}, baseStyle), {
59013
+ padding: '24px',
59014
+ minHeight: '120px',
59015
+ display: 'flex',
59016
+ flexDirection: 'column',
59017
+ gap: '12px',
59018
+ alignItems: 'center',
59019
+ justifyContent: 'center'
59020
+ }),
59021
+ children: [/*#__PURE__*/jsxs("div", {
59022
+ style: {
59023
+ width: '100%',
59024
+ maxWidth: '400px'
59025
+ },
59026
+ children: [/*#__PURE__*/jsx("div", {
59027
+ style: {
59028
+ width: '60%',
59029
+ height: '20px',
59030
+ backgroundColor: '#e5e7eb',
59031
+ borderRadius: '4px',
59032
+ marginBottom: '12px'
59033
+ }
59034
+ }), /*#__PURE__*/jsx("div", {
59035
+ style: {
59036
+ width: '100%',
59037
+ height: '16px',
59038
+ backgroundColor: '#e5e7eb',
59039
+ borderRadius: '4px',
59040
+ marginBottom: '8px'
59041
+ }
59042
+ }), /*#__PURE__*/jsx("div", {
59043
+ style: {
59044
+ width: '90%',
59045
+ height: '16px',
59046
+ backgroundColor: '#e5e7eb',
59047
+ borderRadius: '4px',
59048
+ marginBottom: '8px'
59049
+ }
59050
+ }), /*#__PURE__*/jsx("div", {
59051
+ style: {
59052
+ width: '75%',
59053
+ height: '16px',
59054
+ backgroundColor: '#e5e7eb',
59055
+ borderRadius: '4px'
59056
+ }
59057
+ })]
59058
+ }), /*#__PURE__*/jsxs("div", {
59059
+ style: {
59060
+ display: 'flex',
59061
+ gap: '8px',
59062
+ marginTop: '12px'
59063
+ },
59064
+ children: [/*#__PURE__*/jsx("div", {
59065
+ style: {
59066
+ width: '60px',
59067
+ height: '32px',
59068
+ backgroundColor: '#d1d5db',
59069
+ borderRadius: '4px'
59070
+ }
59071
+ }), /*#__PURE__*/jsx("div", {
59072
+ style: {
59073
+ width: '60px',
59074
+ height: '32px',
59075
+ backgroundColor: '#d1d5db',
59076
+ borderRadius: '4px'
59077
+ }
59078
+ })]
59079
+ })]
59080
+ });
59081
+ }
59082
+ /**
59083
+ * 创建骨架图组件
59084
+ */
59085
+ function createSkeletonComponent(componentName, componentData, skeletonConfig, style) {
59086
+ // 如果提供了自定义骨架图组件
59087
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.component) {
59088
+ var SkeletonComponent = skeletonConfig.component;
59089
+ return /*#__PURE__*/jsx(SkeletonComponent, {
59090
+ componentName: componentName,
59091
+ componentData: componentData,
59092
+ props: componentData === null || componentData === void 0 ? void 0 : componentData.props,
59093
+ style: style
59094
+ });
59095
+ }
59096
+ // 如果提供了自定义骨架图元素
59097
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.element) {
59098
+ return skeletonConfig.element;
59099
+ }
59100
+ // 如果提供了自定义生成函数
59101
+ if (skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.generator) {
59102
+ return skeletonConfig.generator({
59103
+ componentName: componentName,
59104
+ componentData: componentData,
59105
+ props: componentData === null || componentData === void 0 ? void 0 : componentData.props,
59106
+ style: style
59107
+ });
59108
+ }
59109
+ // 如果启用了自动生成,或者没有提供任何配置
59110
+ if ((skeletonConfig === null || skeletonConfig === void 0 ? void 0 : skeletonConfig.autoGenerate) !== false) {
59111
+ return generateSkeletonByComponentName(componentName, componentData === null || componentData === void 0 ? void 0 : componentData.props, style);
59112
+ }
59113
+ // 默认返回空
59114
+ return /*#__PURE__*/jsx(React__default.Fragment, {});
59115
+ }
59116
+
58606
59117
  var ComponentPlaceholder = function (_a) {
58607
59118
  var componentName = _a.componentName,
58608
59119
  style = _a.style,
58609
- loader = _a.loader;
59120
+ loader = _a.loader,
59121
+ skeleton = _a.skeleton,
59122
+ componentData = _a.componentData;
58610
59123
  // 如果有自定义加载内容,优先使用
58611
59124
  if (loader) {
58612
59125
  // 如果是布尔值 true,使用默认样式
@@ -58658,6 +59171,19 @@ var ComponentPlaceholder = function (_a) {
58658
59171
  }
58659
59172
  }
58660
59173
  }
59174
+ // 如果没有 loader,尝试使用骨架图
59175
+ if (skeleton || !loader) {
59176
+ try {
59177
+ var skeletonElement = createSkeletonComponent(componentName, componentData, skeleton, style);
59178
+ // 如果骨架图生成成功且不是空元素,使用骨架图
59179
+ if (skeletonElement && /*#__PURE__*/React__default.isValidElement(skeletonElement)) {
59180
+ return skeletonElement;
59181
+ }
59182
+ } catch (e) {
59183
+ // 如果骨架图生成失败,继续使用默认占位内容
59184
+ console.warn('Failed to generate skeleton:', e);
59185
+ }
59186
+ }
58661
59187
  // 默认占位内容
58662
59188
  return /*#__PURE__*/jsxs("div", {
58663
59189
  style: __assign({