datastake-daf 0.6.475 → 0.6.477

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.
@@ -12672,7 +12672,7 @@ async function captureComponentsAsImages(components, options = {
12672
12672
  component,
12673
12673
  width = '100%',
12674
12674
  height = 'auto',
12675
- delay = 100
12675
+ delay = 200
12676
12676
  }) => {
12677
12677
  const container = document.createElement('div');
12678
12678
  container.style.position = 'absolute';
@@ -12686,8 +12686,17 @@ async function captureComponentsAsImages(components, options = {
12686
12686
  try {
12687
12687
  const root = client.createRoot(container);
12688
12688
  root.render(component);
12689
+
12690
+ // Wait for render and styled-components CSS injection
12689
12691
  await new Promise(resolve => setTimeout(resolve, delay));
12690
- const dataUrl = await htmlToImage.toPng(container, options);
12692
+
12693
+ // Capture the actual component (first child), not the wrapper
12694
+ const element = container.firstChild || container;
12695
+ const dataUrl = await htmlToImage.toPng(element, {
12696
+ ...options,
12697
+ backgroundColor: null,
12698
+ pixelRatio: 2
12699
+ });
12691
12700
  root.unmount();
12692
12701
  document.body.removeChild(container);
12693
12702
  return dataUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.475",
3
+ "version": "0.6.477",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -37,7 +37,7 @@ export async function captureComponentsAsImages(
37
37
  const targets = Array.isArray(components) ? components : [components];
38
38
 
39
39
  const captures = await Promise.all(
40
- targets.map(async ({ component, width = '100%', height = 'auto', delay = 100 }) => {
40
+ targets.map(async ({ component, width = '100%', height = 'auto', delay = 200 }) => {
41
41
  const container = document.createElement('div');
42
42
  container.style.position = 'absolute';
43
43
  container.style.opacity = '0';
@@ -53,9 +53,16 @@ export async function captureComponentsAsImages(
53
53
  const root = createRoot(container);
54
54
  root.render(component);
55
55
 
56
+ // Wait for render and styled-components CSS injection
56
57
  await new Promise(resolve => setTimeout(resolve, delay));
57
58
 
58
- const dataUrl = await toPng(container, options);
59
+ // Capture the actual component (first child), not the wrapper
60
+ const element = container.firstChild || container;
61
+ const dataUrl = await toPng(element, {
62
+ ...options,
63
+ backgroundColor: null,
64
+ pixelRatio: 2
65
+ });
59
66
 
60
67
  root.unmount();
61
68
  document.body.removeChild(container);