@pdfme/ui 5.5.2 → 5.5.3-dev.2

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.
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { Divider } from 'antd';
3
+
4
+ export const SIDEBAR_H_PADDING_PX = 16;
5
+ export const SIDEBAR_V_PADDING_PX = 8;
6
+ export const SIDEBAR_HEADER_HEIGHT = 60;
7
+
8
+ type SectionProps = {
9
+ children: React.ReactNode;
10
+ };
11
+ type SidebarFrameProps = SectionProps & {
12
+ className?: string;
13
+ };
14
+
15
+ export const SidebarFrame = ({ children, className }: SidebarFrameProps) => (
16
+ <div
17
+ className={className}
18
+ style={{
19
+ height: '100%',
20
+ display: 'flex',
21
+ flex: 1,
22
+ flexDirection: 'column',
23
+ }}
24
+ >
25
+ {children}
26
+ </div>
27
+ );
28
+
29
+ export const SidebarHeader = ({ children }: SectionProps) => (
30
+ <div
31
+ style={{
32
+ position: 'relative',
33
+ minHeight: SIDEBAR_HEADER_HEIGHT,
34
+ display: 'flex',
35
+ flexShrink: 0,
36
+ flexDirection: 'column',
37
+ justifyContent: 'center',
38
+ padding: `${SIDEBAR_V_PADDING_PX}px ${SIDEBAR_H_PADDING_PX}px 0`,
39
+ }}
40
+ >
41
+ <div style={{ minHeight: 40, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
42
+ {children}
43
+ </div>
44
+ <Divider style={{ marginTop: `${SIDEBAR_V_PADDING_PX}px`, marginBottom: 0 }} />
45
+ </div>
46
+ );
47
+
48
+ export const SidebarBody = ({ children }: SectionProps) => (
49
+ <div
50
+ style={{
51
+ flex: 1,
52
+ minHeight: 0,
53
+ overflowY: 'auto',
54
+ overflowX: 'hidden',
55
+ padding: `${SIDEBAR_V_PADDING_PX}px ${SIDEBAR_H_PADDING_PX}px`,
56
+ }}
57
+ >
58
+ {children}
59
+ </div>
60
+ );
61
+
62
+ export const SidebarFooter = ({ children }: SectionProps) => (
63
+ <div
64
+ style={{
65
+ display: 'flex',
66
+ flexShrink: 0,
67
+ alignItems: 'center',
68
+ justifyContent: 'flex-end',
69
+ gap: `${SIDEBAR_V_PADDING_PX}px`,
70
+ padding: `${SIDEBAR_H_PADDING_PX}px`,
71
+ }}
72
+ >
73
+ {children}
74
+ </div>
75
+ );
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, forwardRef, ReactNode, Ref, useEffect } from 'react';
2
2
  import { Size } from '@pdfme/common';
3
3
  import { FontContext } from '../contexts.js';
4
- import { BACKGROUND_COLOR } from '../constants.js';
4
+ import { BACKGROUND_COLOR, DESIGNER_CLASSNAME } from '../constants.js';
5
5
  import Spinner from './Spinner.js';
6
6
 
7
7
  type Props = { size: Size; scale: number; children: ReactNode };
@@ -29,8 +29,8 @@ const Root = ({ size, scale, children }: Props, ref: Ref<HTMLDivElement>) => {
29
29
  }, [font]);
30
30
 
31
31
  return (
32
- <div ref={ref} style={{ position: 'relative', background: BACKGROUND_COLOR, ...size }}>
33
- <div style={{ margin: '0 auto', ...size }}>{scale === 0 ? <Spinner /> : children}</div>
32
+ <div className={DESIGNER_CLASSNAME + 'root'} ref={ref} style={{ position: 'relative', background: BACKGROUND_COLOR, ...size }}>
33
+ <div className={DESIGNER_CLASSNAME + 'background'} style={{ margin: '0 auto', ...size }}>{scale === 0 ? <Spinner /> : children}</div>
34
34
  </div>
35
35
  );
36
36
  };
package/src/constants.ts CHANGED
@@ -15,3 +15,7 @@ export const RIGHT_SIDEBAR_WIDTH = 400;
15
15
  export const BACKGROUND_COLOR = 'rgb(74, 74, 74)';
16
16
 
17
17
  export const DEFAULT_MAX_ZOOM = 2;
18
+
19
+ export const DESIGNER_CLASSNAME = 'pdfme-designer-';
20
+
21
+ export const UI_CLASSNAME = 'pdfme-ui-';
package/src/helper.ts CHANGED
@@ -420,9 +420,6 @@ export const getPagesScrollTopByIndex = (pageSizes: Size[], index: number, scale
420
420
  .reduce((acc, cur) => acc + (cur.height * ZOOM + RULER_HEIGHT * scale) * scale, 0);
421
421
  };
422
422
 
423
- export const getSidebarContentHeight = (sidebarHeight: number) =>
424
- sidebarHeight - RULER_HEIGHT - RULER_HEIGHT / 2 - 30;
425
-
426
423
  const handlePositionSizeChange = (
427
424
  schema: SchemaForUI,
428
425
  key: string,