pptx-react-viewer 3.8.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{AiChatPanel-A5DCEHTO.mjs → AiChatPanel-BQSUE2OO.mjs} +4 -4
  3. package/dist/AiChatPanel-BQSUE2OO.mjs.br +0 -0
  4. package/dist/AiChatPanel-BQSUE2OO.mjs.gz +0 -0
  5. package/dist/{AiChatPanel-XLQM4BQJ.js → AiChatPanel-NSVSBJC7.js} +25 -25
  6. package/dist/AiChatPanel-NSVSBJC7.js.br +0 -0
  7. package/dist/AiChatPanel-NSVSBJC7.js.gz +0 -0
  8. package/dist/{Area3DChartScene-5CMEMIBI.mjs → Area3DChartScene-2FQHPGNE.mjs} +21 -4
  9. package/dist/Area3DChartScene-2FQHPGNE.mjs.br +0 -0
  10. package/dist/Area3DChartScene-2FQHPGNE.mjs.gz +0 -0
  11. package/dist/{Area3DChartScene-RZ3V3WOR.js → Area3DChartScene-V3W2V7N5.js} +21 -4
  12. package/dist/Area3DChartScene-V3W2V7N5.js.br +0 -0
  13. package/dist/Area3DChartScene-V3W2V7N5.js.gz +0 -0
  14. package/dist/{Bar3DChartScene-KHCQ6TEC.js → Bar3DChartScene-55XMAUC7.js} +21 -4
  15. package/dist/Bar3DChartScene-55XMAUC7.js.br +0 -0
  16. package/dist/Bar3DChartScene-55XMAUC7.js.gz +0 -0
  17. package/dist/{Bar3DChartScene-H3MYUJKV.mjs → Bar3DChartScene-PSJEVANA.mjs} +21 -4
  18. package/dist/Bar3DChartScene-PSJEVANA.mjs.br +0 -0
  19. package/dist/Bar3DChartScene-PSJEVANA.mjs.gz +0 -0
  20. package/dist/{Line3DChartScene-QEACF3U3.js → Line3DChartScene-5KACYRSQ.js} +21 -4
  21. package/dist/Line3DChartScene-5KACYRSQ.js.br +0 -0
  22. package/dist/Line3DChartScene-5KACYRSQ.js.gz +0 -0
  23. package/dist/{Line3DChartScene-YFRPJHDX.mjs → Line3DChartScene-BUVNUFNO.mjs} +21 -4
  24. package/dist/Line3DChartScene-BUVNUFNO.mjs.br +0 -0
  25. package/dist/Line3DChartScene-BUVNUFNO.mjs.gz +0 -0
  26. package/dist/{Model3DScene-QQWKGJ3T.js → Model3DScene-6U6TN36M.js} +2 -2
  27. package/dist/Model3DScene-6U6TN36M.js.br +0 -0
  28. package/dist/Model3DScene-6U6TN36M.js.gz +0 -0
  29. package/dist/{Model3DScene-O24KP723.mjs → Model3DScene-REKMR2L6.mjs} +1 -1
  30. package/dist/{Model3DScene-O24KP723.mjs.br → Model3DScene-REKMR2L6.mjs.br} +0 -0
  31. package/dist/Model3DScene-REKMR2L6.mjs.gz +0 -0
  32. package/dist/{PieChart3DScene-CI6CW22C.mjs → PieChart3DScene-4L2VVIUJ.mjs} +15 -4
  33. package/dist/PieChart3DScene-4L2VVIUJ.mjs.br +0 -0
  34. package/dist/PieChart3DScene-4L2VVIUJ.mjs.gz +0 -0
  35. package/dist/{PieChart3DScene-L3MHKQHW.js → PieChart3DScene-MV3JF7EM.js} +15 -4
  36. package/dist/PieChart3DScene-MV3JF7EM.js.br +0 -0
  37. package/dist/PieChart3DScene-MV3JF7EM.js.gz +0 -0
  38. package/dist/{SmartArt3DScene-ZO3KFDI2.js → SmartArt3DScene-BK7QN3WT.js} +85 -23
  39. package/dist/SmartArt3DScene-BK7QN3WT.js.br +0 -0
  40. package/dist/SmartArt3DScene-BK7QN3WT.js.gz +0 -0
  41. package/dist/{SmartArt3DScene-XCFVGCXE.mjs → SmartArt3DScene-ODKCGJBO.mjs} +85 -23
  42. package/dist/SmartArt3DScene-ODKCGJBO.mjs.br +0 -0
  43. package/dist/SmartArt3DScene-ODKCGJBO.mjs.gz +0 -0
  44. package/dist/{SurfaceChart3DScene-JUXRC3K2.mjs → SurfaceChart3DScene-ARE7OBFI.mjs} +19 -4
  45. package/dist/SurfaceChart3DScene-ARE7OBFI.mjs.br +0 -0
  46. package/dist/SurfaceChart3DScene-ARE7OBFI.mjs.gz +0 -0
  47. package/dist/{SurfaceChart3DScene-5IER6VFW.js → SurfaceChart3DScene-SFIOK3G3.js} +19 -4
  48. package/dist/SurfaceChart3DScene-SFIOK3G3.js.br +0 -0
  49. package/dist/SurfaceChart3DScene-SFIOK3G3.js.gz +0 -0
  50. package/dist/{chunk-SN5EUDIT.js → chunk-2Q2NFPXA.js} +81834 -57577
  51. package/dist/chunk-2Q2NFPXA.js.br +0 -0
  52. package/dist/chunk-2Q2NFPXA.js.gz +0 -0
  53. package/dist/chunk-DNR6CH6I.js +30 -0
  54. package/dist/chunk-DNR6CH6I.js.br +0 -0
  55. package/dist/chunk-DNR6CH6I.js.gz +0 -0
  56. package/dist/{chunk-4222CHFH.js → chunk-DZ3HWACD.js} +3763 -2551
  57. package/dist/chunk-DZ3HWACD.js.br +0 -0
  58. package/dist/chunk-DZ3HWACD.js.gz +0 -0
  59. package/dist/{chunk-DE3S3UHX.js → chunk-FHOUTYMB.js} +536 -448
  60. package/dist/chunk-FHOUTYMB.js.br +0 -0
  61. package/dist/chunk-FHOUTYMB.js.gz +0 -0
  62. package/dist/{chunk-UPJW34YG.mjs → chunk-HJZA3O3S.mjs} +103 -16
  63. package/dist/chunk-HJZA3O3S.mjs.br +0 -0
  64. package/dist/chunk-HJZA3O3S.mjs.gz +0 -0
  65. package/dist/{chunk-F5NPGNMA.js → chunk-HYUPPQJW.js} +6168 -1929
  66. package/dist/chunk-HYUPPQJW.js.br +0 -0
  67. package/dist/chunk-HYUPPQJW.js.gz +0 -0
  68. package/dist/{chunk-PFPKBNNZ.mjs → chunk-KWHURCVT.mjs} +1771 -559
  69. package/dist/chunk-KWHURCVT.mjs.br +0 -0
  70. package/dist/chunk-KWHURCVT.mjs.gz +0 -0
  71. package/dist/{chunk-RHWQKZLB.mjs → chunk-M6GIPAY4.mjs} +23 -7
  72. package/dist/chunk-M6GIPAY4.mjs.br +0 -0
  73. package/dist/chunk-M6GIPAY4.mjs.gz +0 -0
  74. package/dist/{chunk-RNP5HP4L.mjs → chunk-T4ZRSRQZ.mjs} +6164 -1925
  75. package/dist/chunk-T4ZRSRQZ.mjs.br +0 -0
  76. package/dist/chunk-T4ZRSRQZ.mjs.gz +0 -0
  77. package/dist/chunk-T6GFCLSM.mjs +27 -0
  78. package/dist/chunk-T6GFCLSM.mjs.br +4 -0
  79. package/dist/chunk-T6GFCLSM.mjs.gz +0 -0
  80. package/dist/{chunk-FRZIBZTE.mjs → chunk-TAGG5YNA.mjs} +76 -1
  81. package/dist/chunk-TAGG5YNA.mjs.br +0 -0
  82. package/dist/chunk-TAGG5YNA.mjs.gz +0 -0
  83. package/dist/{chunk-6IMB5DNJ.mjs → chunk-UKPGYJ7G.mjs} +90204 -65968
  84. package/dist/chunk-UKPGYJ7G.mjs.br +0 -0
  85. package/dist/chunk-UKPGYJ7G.mjs.gz +0 -0
  86. package/dist/{chunk-QWA5YEIZ.js → chunk-XW46A7DN.js} +194 -178
  87. package/dist/chunk-XW46A7DN.js.br +0 -0
  88. package/dist/chunk-XW46A7DN.js.gz +0 -0
  89. package/dist/{chunk-L3ZIBQEB.js → chunk-Y6GG2OOW.js} +76 -1
  90. package/dist/chunk-Y6GG2OOW.js.br +0 -0
  91. package/dist/chunk-Y6GG2OOW.js.gz +0 -0
  92. package/dist/i18n.js +4 -4
  93. package/dist/i18n.js.br +0 -0
  94. package/dist/i18n.js.gz +0 -0
  95. package/dist/i18n.mjs +1 -1
  96. package/dist/i18n.mjs.br +0 -0
  97. package/dist/i18n.mjs.gz +0 -0
  98. package/dist/index-CGKutKk1.d.ts.map +1 -1
  99. package/dist/index.d.ts +616 -99
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +47 -47
  102. package/dist/index.js.br +0 -0
  103. package/dist/index.js.gz +0 -0
  104. package/dist/index.mjs +6 -6
  105. package/dist/index.mjs.br +0 -0
  106. package/dist/index.mjs.gz +0 -0
  107. package/dist/internals.d.ts +657 -86
  108. package/dist/internals.d.ts.map +1 -1
  109. package/dist/internals.js +79 -79
  110. package/dist/internals.js.br +0 -0
  111. package/dist/internals.js.gz +0 -0
  112. package/dist/internals.mjs +4 -4
  113. package/dist/internals.mjs.br +0 -0
  114. package/dist/internals.mjs.gz +0 -0
  115. package/dist/pptx-viewer.css +1 -1
  116. package/dist/pptx-viewer.css.br +0 -0
  117. package/dist/pptx-viewer.css.gz +0 -0
  118. package/dist/{useViewerBuildingBlocks-C8F_4Pzb.d.ts → useViewerBuildingBlocks-FbK-4ORi.d.ts} +2 -1
  119. package/dist/useViewerBuildingBlocks-FbK-4ORi.d.ts.map +1 -0
  120. package/dist/viewer/index.d.ts +545 -48
  121. package/dist/viewer/index.d.ts.map +1 -1
  122. package/dist/viewer/index.js +27 -27
  123. package/dist/viewer/index.js.br +0 -0
  124. package/dist/viewer/index.js.gz +0 -0
  125. package/dist/viewer/index.mjs +6 -6
  126. package/dist/viewer/index.mjs.br +0 -0
  127. package/dist/viewer/index.mjs.gz +0 -0
  128. package/package.json +9 -9
  129. package/dist/AiChatPanel-A5DCEHTO.mjs.br +0 -0
  130. package/dist/AiChatPanel-A5DCEHTO.mjs.gz +0 -0
  131. package/dist/AiChatPanel-XLQM4BQJ.js.br +0 -0
  132. package/dist/AiChatPanel-XLQM4BQJ.js.gz +0 -0
  133. package/dist/Area3DChartScene-5CMEMIBI.mjs.br +0 -0
  134. package/dist/Area3DChartScene-5CMEMIBI.mjs.gz +0 -0
  135. package/dist/Area3DChartScene-RZ3V3WOR.js.br +0 -0
  136. package/dist/Area3DChartScene-RZ3V3WOR.js.gz +0 -0
  137. package/dist/Bar3DChartScene-H3MYUJKV.mjs.br +0 -0
  138. package/dist/Bar3DChartScene-H3MYUJKV.mjs.gz +0 -0
  139. package/dist/Bar3DChartScene-KHCQ6TEC.js.br +0 -0
  140. package/dist/Bar3DChartScene-KHCQ6TEC.js.gz +0 -0
  141. package/dist/Line3DChartScene-QEACF3U3.js.br +0 -0
  142. package/dist/Line3DChartScene-QEACF3U3.js.gz +0 -0
  143. package/dist/Line3DChartScene-YFRPJHDX.mjs.br +0 -0
  144. package/dist/Line3DChartScene-YFRPJHDX.mjs.gz +0 -0
  145. package/dist/Model3DScene-O24KP723.mjs.gz +0 -0
  146. package/dist/Model3DScene-QQWKGJ3T.js.br +0 -0
  147. package/dist/Model3DScene-QQWKGJ3T.js.gz +0 -0
  148. package/dist/PieChart3DScene-CI6CW22C.mjs.br +0 -0
  149. package/dist/PieChart3DScene-CI6CW22C.mjs.gz +0 -0
  150. package/dist/PieChart3DScene-L3MHKQHW.js.br +0 -0
  151. package/dist/PieChart3DScene-L3MHKQHW.js.gz +0 -0
  152. package/dist/SmartArt3DScene-XCFVGCXE.mjs.br +0 -0
  153. package/dist/SmartArt3DScene-XCFVGCXE.mjs.gz +0 -0
  154. package/dist/SmartArt3DScene-ZO3KFDI2.js.br +0 -0
  155. package/dist/SmartArt3DScene-ZO3KFDI2.js.gz +0 -0
  156. package/dist/SurfaceChart3DScene-5IER6VFW.js.br +0 -0
  157. package/dist/SurfaceChart3DScene-5IER6VFW.js.gz +0 -0
  158. package/dist/SurfaceChart3DScene-JUXRC3K2.mjs.br +0 -0
  159. package/dist/SurfaceChart3DScene-JUXRC3K2.mjs.gz +0 -0
  160. package/dist/chunk-4222CHFH.js.br +0 -0
  161. package/dist/chunk-4222CHFH.js.gz +0 -0
  162. package/dist/chunk-6IMB5DNJ.mjs.br +0 -0
  163. package/dist/chunk-6IMB5DNJ.mjs.gz +0 -0
  164. package/dist/chunk-DE3S3UHX.js.br +0 -0
  165. package/dist/chunk-DE3S3UHX.js.gz +0 -0
  166. package/dist/chunk-F5NPGNMA.js.br +0 -0
  167. package/dist/chunk-F5NPGNMA.js.gz +0 -0
  168. package/dist/chunk-FRZIBZTE.mjs.br +0 -0
  169. package/dist/chunk-FRZIBZTE.mjs.gz +0 -0
  170. package/dist/chunk-L3ZIBQEB.js.br +0 -0
  171. package/dist/chunk-L3ZIBQEB.js.gz +0 -0
  172. package/dist/chunk-PFPKBNNZ.mjs.br +0 -0
  173. package/dist/chunk-PFPKBNNZ.mjs.gz +0 -0
  174. package/dist/chunk-QWA5YEIZ.js.br +0 -0
  175. package/dist/chunk-QWA5YEIZ.js.gz +0 -0
  176. package/dist/chunk-RHWQKZLB.mjs.br +0 -0
  177. package/dist/chunk-RHWQKZLB.mjs.gz +0 -0
  178. package/dist/chunk-RNP5HP4L.mjs.br +0 -0
  179. package/dist/chunk-RNP5HP4L.mjs.gz +0 -0
  180. package/dist/chunk-SN5EUDIT.js.br +0 -0
  181. package/dist/chunk-SN5EUDIT.js.gz +0 -0
  182. package/dist/chunk-UPJW34YG.mjs.br +0 -0
  183. package/dist/chunk-UPJW34YG.mjs.gz +0 -0
  184. package/dist/useViewerBuildingBlocks-C8F_4Pzb.d.ts.map +0 -1
@@ -1,22 +1,30 @@
1
- import { mountPieChart3D } from './chunk-6IMB5DNJ.mjs';
1
+ import { useStableChart3DInteraction, useLatestRef } from './chunk-T6GFCLSM.mjs';
2
+ import { mountPieChart3D } from './chunk-UKPGYJ7G.mjs';
2
3
  import './chunk-XGB3TDIC.mjs';
3
4
  import { useRef, useEffect } from 'react';
4
5
  import { jsx } from 'react/jsx-runtime';
5
6
 
6
- function PieChart3DScene({ options }) {
7
+ function PieChart3DScene({
8
+ options,
9
+ interaction,
10
+ selectedPart = null
11
+ }) {
7
12
  const containerRef = useRef(null);
8
13
  const handleRef = useRef(null);
14
+ const stableInteraction = useStableChart3DInteraction(interaction);
15
+ const selectedPartRef = useLatestRef(selectedPart);
9
16
  useEffect(() => {
10
17
  const container = containerRef.current;
11
18
  if (!container) {
12
19
  return;
13
20
  }
14
21
  let disposed = false;
15
- void mountPieChart3D(container, options).then((handle) => {
22
+ void mountPieChart3D(container, options, stableInteraction).then((handle) => {
16
23
  if (disposed) {
17
24
  handle.dispose();
18
25
  } else {
19
26
  handleRef.current = handle;
27
+ handle.setSelectedPart(selectedPartRef.current);
20
28
  }
21
29
  return void 0;
22
30
  });
@@ -25,10 +33,13 @@ function PieChart3DScene({ options }) {
25
33
  handleRef.current?.dispose();
26
34
  handleRef.current = null;
27
35
  };
28
- }, [options]);
36
+ }, [options, stableInteraction]);
29
37
  useEffect(() => {
30
38
  handleRef.current?.resize(options.width, options.height);
31
39
  }, [options.width, options.height]);
40
+ useEffect(() => {
41
+ handleRef.current?.setSelectedPart(selectedPart);
42
+ }, [selectedPart]);
32
43
  return /* @__PURE__ */ jsx(
33
44
  "div",
34
45
  {
@@ -1,24 +1,32 @@
1
1
  'use strict';
2
2
 
3
- var chunkSN5EUDIT_js = require('./chunk-SN5EUDIT.js');
3
+ var chunkDNR6CH6I_js = require('./chunk-DNR6CH6I.js');
4
+ var chunk2Q2NFPXA_js = require('./chunk-2Q2NFPXA.js');
4
5
  require('./chunk-4VNS5WPM.js');
5
6
  var react = require('react');
6
7
  var jsxRuntime = require('react/jsx-runtime');
7
8
 
8
- function PieChart3DScene({ options }) {
9
+ function PieChart3DScene({
10
+ options,
11
+ interaction,
12
+ selectedPart = null
13
+ }) {
9
14
  const containerRef = react.useRef(null);
10
15
  const handleRef = react.useRef(null);
16
+ const stableInteraction = chunkDNR6CH6I_js.useStableChart3DInteraction(interaction);
17
+ const selectedPartRef = chunkDNR6CH6I_js.useLatestRef(selectedPart);
11
18
  react.useEffect(() => {
12
19
  const container = containerRef.current;
13
20
  if (!container) {
14
21
  return;
15
22
  }
16
23
  let disposed = false;
17
- void chunkSN5EUDIT_js.mountPieChart3D(container, options).then((handle) => {
24
+ void chunk2Q2NFPXA_js.mountPieChart3D(container, options, stableInteraction).then((handle) => {
18
25
  if (disposed) {
19
26
  handle.dispose();
20
27
  } else {
21
28
  handleRef.current = handle;
29
+ handle.setSelectedPart(selectedPartRef.current);
22
30
  }
23
31
  return void 0;
24
32
  });
@@ -27,10 +35,13 @@ function PieChart3DScene({ options }) {
27
35
  handleRef.current?.dispose();
28
36
  handleRef.current = null;
29
37
  };
30
- }, [options]);
38
+ }, [options, stableInteraction]);
31
39
  react.useEffect(() => {
32
40
  handleRef.current?.resize(options.width, options.height);
33
41
  }, [options.width, options.height]);
42
+ react.useEffect(() => {
43
+ handleRef.current?.setSelectedPart(selectedPart);
44
+ }, [selectedPart]);
34
45
  return /* @__PURE__ */ jsxRuntime.jsx(
35
46
  "div",
36
47
  {
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var chunkDNR6CH6I_js = require('./chunk-DNR6CH6I.js');
3
4
  var chunk6C2WYLZY_js = require('./chunk-6C2WYLZY.js');
4
5
  var chunkB4QYQLZU_js = require('./chunk-B4QYQLZU.js');
5
6
  require('./chunk-4VNS5WPM.js');
@@ -28,10 +29,17 @@ function wrapLines(ctx, text, maxWidth) {
28
29
  lines.push(line);
29
30
  return lines;
30
31
  }
31
- function makeTextTexture(text, color, fontSize, footW, footH) {
32
+ function resolveEmphasisFont(color, emphasis) {
33
+ const weight = emphasis?.bold === void 0 ? "600" : emphasis.bold ? "700" : "400";
34
+ const italic = emphasis?.italic ? "italic " : "";
35
+ const scale = typeof emphasis?.fontScale === "number" && Number.isFinite(emphasis.fontScale) && emphasis.fontScale > 0 ? emphasis.fontScale : 1;
36
+ return { weight, italic, color: emphasis?.color ?? color, scale };
37
+ }
38
+ function makeTextTexture(text, color, fontSize, footW, footH, emphasis) {
32
39
  if (typeof document === "undefined" || !text.trim() || footW <= 0 || footH <= 0) {
33
40
  return null;
34
41
  }
42
+ const { weight, italic, color: effectiveColor, scale } = resolveEmphasisFont(color, emphasis);
35
43
  const worldWidth = footW * FILL;
36
44
  const worldHeight = footH * FILL;
37
45
  const canvas = document.createElement("canvas");
@@ -43,10 +51,11 @@ function makeTextTexture(text, color, fontSize, footW, footH) {
43
51
  }
44
52
  const family = "system-ui, -apple-system, Segoe UI, Roboto, sans-serif";
45
53
  const maxTextWidth = canvas.width * 0.94;
46
- let px = Math.max(6, fontSize) * SUPERSAMPLE;
54
+ const fontString = (px2) => `${italic}${weight} ${px2}px ${family}`;
55
+ let px = Math.max(6, fontSize) * scale * SUPERSAMPLE;
47
56
  let lines = [];
48
57
  for (let attempt = 0; attempt < 12; attempt++) {
49
- ctx.font = `600 ${px}px ${family}`;
58
+ ctx.font = fontString(px);
50
59
  lines = wrapLines(ctx, text, maxTextWidth);
51
60
  const lineHeight2 = px * 1.2;
52
61
  if (lines.length * lineHeight2 <= canvas.height * 0.96 || px <= 6 * SUPERSAMPLE) {
@@ -55,15 +64,25 @@ function makeTextTexture(text, color, fontSize, footW, footH) {
55
64
  px *= 0.88;
56
65
  }
57
66
  ctx.clearRect(0, 0, canvas.width, canvas.height);
58
- ctx.fillStyle = color;
67
+ ctx.fillStyle = effectiveColor;
59
68
  ctx.textAlign = "center";
60
69
  ctx.textBaseline = "middle";
61
- ctx.font = `600 ${px}px ${family}`;
70
+ ctx.font = fontString(px);
62
71
  const lineHeight = px * 1.2;
63
72
  const blockHeight = lines.length * lineHeight;
64
73
  const startY = canvas.height / 2 - blockHeight / 2 + lineHeight / 2;
65
74
  for (let i = 0; i < lines.length; i++) {
66
- ctx.fillText(lines[i], canvas.width / 2, startY + i * lineHeight);
75
+ const y = startY + i * lineHeight;
76
+ ctx.fillText(lines[i], canvas.width / 2, y);
77
+ if (emphasis?.underline) {
78
+ const w = ctx.measureText(lines[i]).width;
79
+ ctx.strokeStyle = effectiveColor;
80
+ ctx.lineWidth = Math.max(1, px * 0.06);
81
+ ctx.beginPath();
82
+ ctx.moveTo(canvas.width / 2 - w / 2, y + px * 0.32);
83
+ ctx.lineTo(canvas.width / 2 + w / 2, y + px * 0.32);
84
+ ctx.stroke();
85
+ }
67
86
  }
68
87
  const texture = new chunkB4QYQLZU_js.CanvasTexture(canvas);
69
88
  texture.colorSpace = chunkB4QYQLZU_js.SRGBColorSpace;
@@ -123,13 +142,20 @@ function addBlock(group, disposables, m) {
123
142
  }
124
143
  return geo;
125
144
  }
126
- function addLabel(group, disposables, m) {
145
+ function buildLabelPlane(m, textStyle) {
127
146
  if (!m.text) {
128
- return;
147
+ return null;
129
148
  }
130
- const tex = makeTextTexture(m.text, m.textColor, m.fontSize, m.halfWidth * 2, m.halfHeight * 2);
149
+ const tex = makeTextTexture(
150
+ m.text,
151
+ m.textColor,
152
+ m.fontSize,
153
+ m.halfWidth * 2,
154
+ m.halfHeight * 2,
155
+ textStyle
156
+ );
131
157
  if (!tex) {
132
- return;
158
+ return null;
133
159
  }
134
160
  const planeGeo = new chunkB4QYQLZU_js.PlaneGeometry(tex.worldWidth, tex.worldHeight);
135
161
  const planeMaterial = new chunkB4QYQLZU_js.MeshBasicMaterial({
@@ -142,8 +168,7 @@ function addLabel(group, disposables, m) {
142
168
  const offset = new chunkB4QYQLZU_js.Vector3(0, 0, m.depth + m.bevel + 0.4).applyEuler(euler);
143
169
  plane.position.set(m.position.x + offset.x, m.position.y + offset.y, m.position.z + offset.z);
144
170
  plane.rotation.copy(euler);
145
- group.add(plane);
146
- disposables.push(planeGeo, planeMaterial, tex.texture);
171
+ return { plane, disposables: [planeGeo, planeMaterial, tex.texture] };
147
172
  }
148
173
  function addConnectors(group, disposables, model) {
149
174
  for (const c of model.connectors) {
@@ -160,20 +185,48 @@ function addConnectors(group, disposables, model) {
160
185
  disposables.push(geo, material);
161
186
  }
162
187
  }
163
- function buildMeshGroup(model) {
164
- const group = new chunkB4QYQLZU_js.Group();
165
- const disposables = [];
166
- for (const m of model.meshes) {
167
- addBlock(group, disposables, m);
168
- addLabel(group, disposables, m);
188
+ function clearLabel(group, entry) {
189
+ if (entry.plane) {
190
+ group.remove(entry.plane);
169
191
  }
170
- addConnectors(group, disposables, model);
192
+ for (const d of entry.disposables) {
193
+ d.dispose();
194
+ }
195
+ entry.plane = null;
196
+ entry.disposables = [];
197
+ }
198
+ function buildMeshGroup(model, textStyle) {
199
+ const group = new chunkB4QYQLZU_js.Group();
200
+ const blockDisposables = [];
201
+ const labelEntries = model.meshes.map((m) => {
202
+ addBlock(group, blockDisposables, m);
203
+ const built = buildLabelPlane(m, textStyle);
204
+ if (built) {
205
+ group.add(built.plane);
206
+ }
207
+ return { node: m, plane: built?.plane ?? null, disposables: built?.disposables ?? [] };
208
+ });
209
+ addConnectors(group, blockDisposables, model);
171
210
  return {
172
211
  group,
212
+ setTextStyle(style) {
213
+ for (const entry of labelEntries) {
214
+ clearLabel(group, entry);
215
+ const built = buildLabelPlane(entry.node, style);
216
+ if (built) {
217
+ group.add(built.plane);
218
+ entry.plane = built.plane;
219
+ entry.disposables = built.disposables;
220
+ }
221
+ }
222
+ },
173
223
  dispose() {
174
- for (const d of disposables) {
224
+ for (const d of blockDisposables) {
175
225
  d.dispose();
176
226
  }
227
+ for (const entry of labelEntries) {
228
+ clearLabel(group, entry);
229
+ }
177
230
  }
178
231
  };
179
232
  }
@@ -245,7 +298,7 @@ function mountSmartArt3D(canvas, model, width, height, options = {}) {
245
298
  const fill = new chunkB4QYQLZU_js.DirectionalLight(16777215, 0.3);
246
299
  fill.position.set(cx - radius, cy - radius * 0.6, cz + dist * 0.6);
247
300
  scene.add(fill);
248
- const built = buildMeshGroup(model);
301
+ const built = buildMeshGroup(model, options.textStyle);
249
302
  scene.add(built.group);
250
303
  let controls = null;
251
304
  const enableControls = (on) => {
@@ -286,6 +339,9 @@ function mountSmartArt3D(canvas, model, width, height, options = {}) {
286
339
  setInteractive(on) {
287
340
  enableControls(on);
288
341
  },
342
+ setTextStyle(style) {
343
+ built.setTextStyle(style);
344
+ },
289
345
  dispose() {
290
346
  disposed = true;
291
347
  cancelAnimationFrame(frame);
@@ -299,17 +355,20 @@ function SmartArt3DScene({
299
355
  model,
300
356
  width,
301
357
  height,
302
- interactive
358
+ interactive,
359
+ textStyle
303
360
  }) {
304
361
  const canvasRef = react.useRef(null);
305
362
  const handleRef = react.useRef(null);
363
+ const textStyleRef = chunkDNR6CH6I_js.useLatestRef(textStyle);
306
364
  react.useEffect(() => {
307
365
  const canvas = canvasRef.current;
308
366
  if (!canvas) {
309
367
  return;
310
368
  }
311
369
  const handle = mountSmartArt3D(canvas, model, width, height, {
312
- interactive
370
+ interactive,
371
+ textStyle: textStyleRef.current
313
372
  });
314
373
  handleRef.current = handle;
315
374
  return () => {
@@ -323,6 +382,9 @@ function SmartArt3DScene({
323
382
  react.useEffect(() => {
324
383
  handleRef.current?.setInteractive(interactive);
325
384
  }, [interactive]);
385
+ react.useEffect(() => {
386
+ handleRef.current?.setTextStyle(textStyle);
387
+ }, [textStyle]);
326
388
  return /* @__PURE__ */ jsxRuntime.jsx(
327
389
  "canvas",
328
390
  {
@@ -1,3 +1,4 @@
1
+ import { useLatestRef } from './chunk-T6GFCLSM.mjs';
1
2
  import { OrbitControls } from './chunk-3CBDTD46.mjs';
2
3
  import { WebGLRenderer, Scene, Color, PerspectiveCamera, AmbientLight, DirectionalLight, Group, MeshStandardMaterial, Mesh, EdgesGeometry, LineBasicMaterial, LineSegments, PlaneGeometry, MeshBasicMaterial, Euler, Vector3, BufferGeometry, Line, Shape, ExtrudeGeometry, CanvasTexture, SRGBColorSpace, LinearFilter, RepeatWrapping } from './chunk-XBMKFZVP.mjs';
3
4
  import './chunk-XGB3TDIC.mjs';
@@ -26,10 +27,17 @@ function wrapLines(ctx, text, maxWidth) {
26
27
  lines.push(line);
27
28
  return lines;
28
29
  }
29
- function makeTextTexture(text, color, fontSize, footW, footH) {
30
+ function resolveEmphasisFont(color, emphasis) {
31
+ const weight = emphasis?.bold === void 0 ? "600" : emphasis.bold ? "700" : "400";
32
+ const italic = emphasis?.italic ? "italic " : "";
33
+ const scale = typeof emphasis?.fontScale === "number" && Number.isFinite(emphasis.fontScale) && emphasis.fontScale > 0 ? emphasis.fontScale : 1;
34
+ return { weight, italic, color: emphasis?.color ?? color, scale };
35
+ }
36
+ function makeTextTexture(text, color, fontSize, footW, footH, emphasis) {
30
37
  if (typeof document === "undefined" || !text.trim() || footW <= 0 || footH <= 0) {
31
38
  return null;
32
39
  }
40
+ const { weight, italic, color: effectiveColor, scale } = resolveEmphasisFont(color, emphasis);
33
41
  const worldWidth = footW * FILL;
34
42
  const worldHeight = footH * FILL;
35
43
  const canvas = document.createElement("canvas");
@@ -41,10 +49,11 @@ function makeTextTexture(text, color, fontSize, footW, footH) {
41
49
  }
42
50
  const family = "system-ui, -apple-system, Segoe UI, Roboto, sans-serif";
43
51
  const maxTextWidth = canvas.width * 0.94;
44
- let px = Math.max(6, fontSize) * SUPERSAMPLE;
52
+ const fontString = (px2) => `${italic}${weight} ${px2}px ${family}`;
53
+ let px = Math.max(6, fontSize) * scale * SUPERSAMPLE;
45
54
  let lines = [];
46
55
  for (let attempt = 0; attempt < 12; attempt++) {
47
- ctx.font = `600 ${px}px ${family}`;
56
+ ctx.font = fontString(px);
48
57
  lines = wrapLines(ctx, text, maxTextWidth);
49
58
  const lineHeight2 = px * 1.2;
50
59
  if (lines.length * lineHeight2 <= canvas.height * 0.96 || px <= 6 * SUPERSAMPLE) {
@@ -53,15 +62,25 @@ function makeTextTexture(text, color, fontSize, footW, footH) {
53
62
  px *= 0.88;
54
63
  }
55
64
  ctx.clearRect(0, 0, canvas.width, canvas.height);
56
- ctx.fillStyle = color;
65
+ ctx.fillStyle = effectiveColor;
57
66
  ctx.textAlign = "center";
58
67
  ctx.textBaseline = "middle";
59
- ctx.font = `600 ${px}px ${family}`;
68
+ ctx.font = fontString(px);
60
69
  const lineHeight = px * 1.2;
61
70
  const blockHeight = lines.length * lineHeight;
62
71
  const startY = canvas.height / 2 - blockHeight / 2 + lineHeight / 2;
63
72
  for (let i = 0; i < lines.length; i++) {
64
- ctx.fillText(lines[i], canvas.width / 2, startY + i * lineHeight);
73
+ const y = startY + i * lineHeight;
74
+ ctx.fillText(lines[i], canvas.width / 2, y);
75
+ if (emphasis?.underline) {
76
+ const w = ctx.measureText(lines[i]).width;
77
+ ctx.strokeStyle = effectiveColor;
78
+ ctx.lineWidth = Math.max(1, px * 0.06);
79
+ ctx.beginPath();
80
+ ctx.moveTo(canvas.width / 2 - w / 2, y + px * 0.32);
81
+ ctx.lineTo(canvas.width / 2 + w / 2, y + px * 0.32);
82
+ ctx.stroke();
83
+ }
65
84
  }
66
85
  const texture = new CanvasTexture(canvas);
67
86
  texture.colorSpace = SRGBColorSpace;
@@ -121,13 +140,20 @@ function addBlock(group, disposables, m) {
121
140
  }
122
141
  return geo;
123
142
  }
124
- function addLabel(group, disposables, m) {
143
+ function buildLabelPlane(m, textStyle) {
125
144
  if (!m.text) {
126
- return;
145
+ return null;
127
146
  }
128
- const tex = makeTextTexture(m.text, m.textColor, m.fontSize, m.halfWidth * 2, m.halfHeight * 2);
147
+ const tex = makeTextTexture(
148
+ m.text,
149
+ m.textColor,
150
+ m.fontSize,
151
+ m.halfWidth * 2,
152
+ m.halfHeight * 2,
153
+ textStyle
154
+ );
129
155
  if (!tex) {
130
- return;
156
+ return null;
131
157
  }
132
158
  const planeGeo = new PlaneGeometry(tex.worldWidth, tex.worldHeight);
133
159
  const planeMaterial = new MeshBasicMaterial({
@@ -140,8 +166,7 @@ function addLabel(group, disposables, m) {
140
166
  const offset = new Vector3(0, 0, m.depth + m.bevel + 0.4).applyEuler(euler);
141
167
  plane.position.set(m.position.x + offset.x, m.position.y + offset.y, m.position.z + offset.z);
142
168
  plane.rotation.copy(euler);
143
- group.add(plane);
144
- disposables.push(planeGeo, planeMaterial, tex.texture);
169
+ return { plane, disposables: [planeGeo, planeMaterial, tex.texture] };
145
170
  }
146
171
  function addConnectors(group, disposables, model) {
147
172
  for (const c of model.connectors) {
@@ -158,20 +183,48 @@ function addConnectors(group, disposables, model) {
158
183
  disposables.push(geo, material);
159
184
  }
160
185
  }
161
- function buildMeshGroup(model) {
162
- const group = new Group();
163
- const disposables = [];
164
- for (const m of model.meshes) {
165
- addBlock(group, disposables, m);
166
- addLabel(group, disposables, m);
186
+ function clearLabel(group, entry) {
187
+ if (entry.plane) {
188
+ group.remove(entry.plane);
167
189
  }
168
- addConnectors(group, disposables, model);
190
+ for (const d of entry.disposables) {
191
+ d.dispose();
192
+ }
193
+ entry.plane = null;
194
+ entry.disposables = [];
195
+ }
196
+ function buildMeshGroup(model, textStyle) {
197
+ const group = new Group();
198
+ const blockDisposables = [];
199
+ const labelEntries = model.meshes.map((m) => {
200
+ addBlock(group, blockDisposables, m);
201
+ const built = buildLabelPlane(m, textStyle);
202
+ if (built) {
203
+ group.add(built.plane);
204
+ }
205
+ return { node: m, plane: built?.plane ?? null, disposables: built?.disposables ?? [] };
206
+ });
207
+ addConnectors(group, blockDisposables, model);
169
208
  return {
170
209
  group,
210
+ setTextStyle(style) {
211
+ for (const entry of labelEntries) {
212
+ clearLabel(group, entry);
213
+ const built = buildLabelPlane(entry.node, style);
214
+ if (built) {
215
+ group.add(built.plane);
216
+ entry.plane = built.plane;
217
+ entry.disposables = built.disposables;
218
+ }
219
+ }
220
+ },
171
221
  dispose() {
172
- for (const d of disposables) {
222
+ for (const d of blockDisposables) {
173
223
  d.dispose();
174
224
  }
225
+ for (const entry of labelEntries) {
226
+ clearLabel(group, entry);
227
+ }
175
228
  }
176
229
  };
177
230
  }
@@ -243,7 +296,7 @@ function mountSmartArt3D(canvas, model, width, height, options = {}) {
243
296
  const fill = new DirectionalLight(16777215, 0.3);
244
297
  fill.position.set(cx - radius, cy - radius * 0.6, cz + dist * 0.6);
245
298
  scene.add(fill);
246
- const built = buildMeshGroup(model);
299
+ const built = buildMeshGroup(model, options.textStyle);
247
300
  scene.add(built.group);
248
301
  let controls = null;
249
302
  const enableControls = (on) => {
@@ -284,6 +337,9 @@ function mountSmartArt3D(canvas, model, width, height, options = {}) {
284
337
  setInteractive(on) {
285
338
  enableControls(on);
286
339
  },
340
+ setTextStyle(style) {
341
+ built.setTextStyle(style);
342
+ },
287
343
  dispose() {
288
344
  disposed = true;
289
345
  cancelAnimationFrame(frame);
@@ -297,17 +353,20 @@ function SmartArt3DScene({
297
353
  model,
298
354
  width,
299
355
  height,
300
- interactive
356
+ interactive,
357
+ textStyle
301
358
  }) {
302
359
  const canvasRef = useRef(null);
303
360
  const handleRef = useRef(null);
361
+ const textStyleRef = useLatestRef(textStyle);
304
362
  useEffect(() => {
305
363
  const canvas = canvasRef.current;
306
364
  if (!canvas) {
307
365
  return;
308
366
  }
309
367
  const handle = mountSmartArt3D(canvas, model, width, height, {
310
- interactive
368
+ interactive,
369
+ textStyle: textStyleRef.current
311
370
  });
312
371
  handleRef.current = handle;
313
372
  return () => {
@@ -321,6 +380,9 @@ function SmartArt3DScene({
321
380
  useEffect(() => {
322
381
  handleRef.current?.setInteractive(interactive);
323
382
  }, [interactive]);
383
+ useEffect(() => {
384
+ handleRef.current?.setTextStyle(textStyle);
385
+ }, [textStyle]);
324
386
  return /* @__PURE__ */ jsx(
325
387
  "canvas",
326
388
  {
@@ -1,24 +1,33 @@
1
- import { mountSurfaceChart3D } from './chunk-6IMB5DNJ.mjs';
1
+ import { useStableChart3DInteraction, useLatestRef } from './chunk-T6GFCLSM.mjs';
2
+ import { mountSurfaceChart3D } from './chunk-UKPGYJ7G.mjs';
2
3
  import './chunk-XGB3TDIC.mjs';
3
4
  import { useRef, useEffect } from 'react';
4
5
  import { jsx } from 'react/jsx-runtime';
5
6
 
6
7
  function SurfaceChart3DScene({
7
- options
8
+ options,
9
+ interaction,
10
+ selectedPart = null,
11
+ textStyle
8
12
  }) {
9
13
  const containerRef = useRef(null);
10
14
  const handleRef = useRef(null);
15
+ const stableInteraction = useStableChart3DInteraction(interaction);
16
+ const selectedPartRef = useLatestRef(selectedPart);
17
+ const textStyleRef = useLatestRef(textStyle);
11
18
  useEffect(() => {
12
19
  const container = containerRef.current;
13
20
  if (!container) {
14
21
  return;
15
22
  }
16
23
  let disposed = false;
17
- void mountSurfaceChart3D(container, options).then((handle) => {
24
+ void mountSurfaceChart3D(container, options, stableInteraction).then((handle) => {
18
25
  if (disposed) {
19
26
  handle.dispose();
20
27
  } else {
21
28
  handleRef.current = handle;
29
+ handle.setSelectedPart(selectedPartRef.current);
30
+ handle.setTextStyle(textStyleRef.current);
22
31
  }
23
32
  return void 0;
24
33
  });
@@ -27,10 +36,16 @@ function SurfaceChart3DScene({
27
36
  handleRef.current?.dispose();
28
37
  handleRef.current = null;
29
38
  };
30
- }, [options]);
39
+ }, [options, stableInteraction]);
31
40
  useEffect(() => {
32
41
  handleRef.current?.resize(options.width, options.height);
33
42
  }, [options.width, options.height]);
43
+ useEffect(() => {
44
+ handleRef.current?.setSelectedPart(selectedPart);
45
+ }, [selectedPart]);
46
+ useEffect(() => {
47
+ handleRef.current?.setTextStyle(textStyle);
48
+ }, [textStyle]);
34
49
  return /* @__PURE__ */ jsx(
35
50
  "div",
36
51
  {
@@ -1,26 +1,35 @@
1
1
  'use strict';
2
2
 
3
- var chunkSN5EUDIT_js = require('./chunk-SN5EUDIT.js');
3
+ var chunkDNR6CH6I_js = require('./chunk-DNR6CH6I.js');
4
+ var chunk2Q2NFPXA_js = require('./chunk-2Q2NFPXA.js');
4
5
  require('./chunk-4VNS5WPM.js');
5
6
  var react = require('react');
6
7
  var jsxRuntime = require('react/jsx-runtime');
7
8
 
8
9
  function SurfaceChart3DScene({
9
- options
10
+ options,
11
+ interaction,
12
+ selectedPart = null,
13
+ textStyle
10
14
  }) {
11
15
  const containerRef = react.useRef(null);
12
16
  const handleRef = react.useRef(null);
17
+ const stableInteraction = chunkDNR6CH6I_js.useStableChart3DInteraction(interaction);
18
+ const selectedPartRef = chunkDNR6CH6I_js.useLatestRef(selectedPart);
19
+ const textStyleRef = chunkDNR6CH6I_js.useLatestRef(textStyle);
13
20
  react.useEffect(() => {
14
21
  const container = containerRef.current;
15
22
  if (!container) {
16
23
  return;
17
24
  }
18
25
  let disposed = false;
19
- void chunkSN5EUDIT_js.mountSurfaceChart3D(container, options).then((handle) => {
26
+ void chunk2Q2NFPXA_js.mountSurfaceChart3D(container, options, stableInteraction).then((handle) => {
20
27
  if (disposed) {
21
28
  handle.dispose();
22
29
  } else {
23
30
  handleRef.current = handle;
31
+ handle.setSelectedPart(selectedPartRef.current);
32
+ handle.setTextStyle(textStyleRef.current);
24
33
  }
25
34
  return void 0;
26
35
  });
@@ -29,10 +38,16 @@ function SurfaceChart3DScene({
29
38
  handleRef.current?.dispose();
30
39
  handleRef.current = null;
31
40
  };
32
- }, [options]);
41
+ }, [options, stableInteraction]);
33
42
  react.useEffect(() => {
34
43
  handleRef.current?.resize(options.width, options.height);
35
44
  }, [options.width, options.height]);
45
+ react.useEffect(() => {
46
+ handleRef.current?.setSelectedPart(selectedPart);
47
+ }, [selectedPart]);
48
+ react.useEffect(() => {
49
+ handleRef.current?.setTextStyle(textStyle);
50
+ }, [textStyle]);
36
51
  return /* @__PURE__ */ jsxRuntime.jsx(
37
52
  "div",
38
53
  {