@pdfme/ui 5.5.2-dev.1 → 5.5.2-dev.3

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.
@@ -7,3 +7,5 @@ export declare const LEFT_SIDEBAR_WIDTH = 45;
7
7
  export declare const RIGHT_SIDEBAR_WIDTH = 400;
8
8
  export declare const BACKGROUND_COLOR = "rgb(74, 74, 74)";
9
9
  export declare const DEFAULT_MAX_ZOOM = 2;
10
+ export declare const DESIGNER_CLASSNAME = "pdfme-designer-";
11
+ export declare const UI_CLASSNAME = "pdfme-ui-";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.5.2-dev.1",
3
+ "version": "5.5.2-dev.3",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -8,6 +8,7 @@ import type { MenuProps } from 'antd';
8
8
  import { theme, Typography, Button, Dropdown } from 'antd';
9
9
  import { I18nContext } from '../contexts.js';
10
10
  import { useMaxZoom } from '../helper.js';
11
+ import { UI_CLASSNAME } from '../constants.js';
11
12
 
12
13
  const { Text } = Typography;
13
14
 
@@ -29,6 +30,7 @@ const Zoom = ({ zoomLevel, setZoomLevel, style }: ZoomProps) => {
29
30
  return (
30
31
  <div style={{ display: 'flex', alignItems: 'center' }}>
31
32
  <Button
33
+ className={UI_CLASSNAME + 'zoom-out'}
32
34
  type="text"
33
35
  disabled={minZoom >= nextZoomOut}
34
36
  onClick={() => setZoomLevel(nextZoomOut)}
@@ -38,6 +40,7 @@ const Zoom = ({ zoomLevel, setZoomLevel, style }: ZoomProps) => {
38
40
  {Math.round(zoomLevel * 100)}%
39
41
  </Text>
40
42
  <Button
43
+ className={UI_CLASSNAME + 'zoom-in'}
41
44
  type="text"
42
45
  disabled={maxZoom < nextZoomIn}
43
46
  onClick={() => setZoomLevel(nextZoomIn)}
@@ -57,13 +60,14 @@ type PagerProps = {
57
60
  const Pager = ({ pageCursor, pageNum, setPageCursor, style }: PagerProps) => {
58
61
  return (
59
62
  <div style={{ display: 'flex', alignItems: 'center' }}>
60
- <Button type="text" disabled={pageCursor <= 0} onClick={() => setPageCursor(pageCursor - 1)}>
63
+ <Button className={UI_CLASSNAME + 'page-prev'} type="text" disabled={pageCursor <= 0} onClick={() => setPageCursor(pageCursor - 1)}>
61
64
  <ChevronLeft size={16} color={style.textStyle.color} />
62
65
  </Button>
63
66
  <Text strong style={style.textStyle}>
64
67
  {pageCursor + 1}/{pageNum}
65
68
  </Text>
66
69
  <Button
70
+ className={UI_CLASSNAME + 'page-next'}
67
71
  type="text"
68
72
  disabled={pageCursor + 1 >= pageNum}
69
73
  onClick={() => setPageCursor(pageCursor + 1)}
@@ -80,7 +84,7 @@ type ContextMenuProps = {
80
84
  };
81
85
  const ContextMenu = ({ items, style }: ContextMenuProps) => (
82
86
  <Dropdown menu={{ items }} placement="top" arrow trigger={['click']}>
83
- <Button type="text">
87
+ <Button className={UI_CLASSNAME + 'context-menu'} type="text">
84
88
  <Ellipsis size={16} color={style.textStyle.color} />
85
89
  </Button>
86
90
  </Dropdown>
@@ -139,6 +143,7 @@ const CtlBar = (props: CtlBarProps) => {
139
143
  return (
140
144
  <div style={{ position: 'absolute', top: 'auto', bottom: '6%', width: size.width }}>
141
145
  <div
146
+ className={UI_CLASSNAME + 'control-bar'}
142
147
  style={{
143
148
  display: 'flex',
144
149
  alignItems: 'center',
@@ -155,14 +160,18 @@ const CtlBar = (props: CtlBarProps) => {
155
160
  }}
156
161
  >
157
162
  {pageNum > 1 && (
158
- <Pager
159
- style={{ textStyle }}
160
- pageCursor={pageCursor}
161
- pageNum={pageNum}
162
- setPageCursor={setPageCursor}
163
- />
163
+ <div className={UI_CLASSNAME + 'pager'}>
164
+ <Pager
165
+ style={{ textStyle }}
166
+ pageCursor={pageCursor}
167
+ pageNum={pageNum}
168
+ setPageCursor={setPageCursor}
169
+ />
170
+ </div>
164
171
  )}
165
- <Zoom style={{ textStyle }} zoomLevel={zoomLevel} setZoomLevel={setZoomLevel} />
172
+ <div className={UI_CLASSNAME + 'zoom'}>
173
+ <Zoom style={{ textStyle }} zoomLevel={zoomLevel} setZoomLevel={setZoomLevel} />
174
+ </div>
166
175
  {contextMenuItems.length > 0 && (
167
176
  <ContextMenu items={contextMenuItems} style={{ textStyle }} />
168
177
  )}
@@ -22,9 +22,9 @@ import {
22
22
  } from '@pdfme/common';
23
23
  import { PluginsRegistry } from '../../../contexts.js';
24
24
  import { X } from 'lucide-react';
25
- import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
25
+ import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../../constants.js';
26
26
  import { usePrevious } from '../../../hooks.js';
27
- import { uuid, round, flatten } from '../../../helper.js';
27
+ import { round, flatten, uuid } from '../../../helper.js';
28
28
  import Paper from '../../Paper.js';
29
29
  import Renderer from '../../Renderer.js';
30
30
  import Selecto from './Selecto.js';
@@ -52,6 +52,7 @@ const DeleteButton = ({ activeElements: aes }: { activeElements: HTMLElement[] }
52
52
  return (
53
53
  <Button
54
54
  id={DELETE_BTN_ID}
55
+ className={DESIGNER_CLASSNAME + 'delete-button'}
55
56
  style={{
56
57
  position: 'absolute',
57
58
  zIndex: 1,
@@ -350,6 +351,7 @@ const Canvas = (props: Props, ref: Ref<HTMLDivElement>) => {
350
351
 
351
352
  return (
352
353
  <div
354
+ className={DESIGNER_CLASSNAME + 'canvas'}
353
355
  style={{
354
356
  position: 'relative',
355
357
  overflow: 'auto',
@@ -4,7 +4,7 @@ import { theme, Button } from 'antd';
4
4
  import { useDraggable } from '@dnd-kit/core';
5
5
  import { CSS } from '@dnd-kit/utilities';
6
6
  import Renderer from '../Renderer.js';
7
- import { LEFT_SIDEBAR_WIDTH } from '../../constants.js';
7
+ import { LEFT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../constants.js';
8
8
  import { setFontNameRecursively } from '../../helper';
9
9
  import { OptionsContext, PluginsRegistry } from '../../contexts.js';
10
10
  import PluginIcon from './PluginIcon.js';
@@ -83,6 +83,7 @@ const LeftSidebar = ({
83
83
 
84
84
  return (
85
85
  <div
86
+ className={DESIGNER_CLASSNAME + 'left-sidebar'}
86
87
  style={{
87
88
  left: 0,
88
89
  right: 0,
@@ -98,9 +99,12 @@ const LeftSidebar = ({
98
99
  {pluginsRegistry.entries().map(([label, plugin]) => {
99
100
  if (!plugin?.propPanel.defaultSchema) return null;
100
101
 
102
+ const pluginType = plugin.propPanel.defaultSchema.type;
103
+
101
104
  return (
102
105
  <Draggable key={label} scale={scale} basePdf={basePdf} plugin={plugin}>
103
106
  <Button
107
+ className={DESIGNER_CLASSNAME + 'plugin-' + pluginType}
104
108
  onMouseDown={() => setIsDragging(true)}
105
109
  style={{ width: 35, height: 35, marginTop: '0.25rem', padding: '0.25rem' }}
106
110
  >
@@ -1,6 +1,7 @@
1
1
  import { Space, Button, Form } from 'antd';
2
2
  import React from 'react';
3
3
  import type { PropPanelWidgetProps } from '@pdfme/common';
4
+ import { DESIGNER_CLASSNAME } from '../../../../constants.js';
4
5
  import {
5
6
  AlignStartVertical,
6
7
  AlignStartHorizontal,
@@ -213,6 +214,7 @@ const AlignWidget = (props: PropPanelWidgetProps) => {
213
214
  <Space.Compact>
214
215
  {layoutBtns.map((btn) => (
215
216
  <Button
217
+ className={DESIGNER_CLASSNAME + 'align-' + btn.id}
216
218
  key={btn.id}
217
219
  style={{ padding: 7 }}
218
220
  disabled={activeElements.length <= 2 && ['vertical', 'horizontal'].includes(btn.id)}
@@ -13,6 +13,7 @@ import type { SidebarProps } from '../../../../types.js';
13
13
  import { Menu } from 'lucide-react';
14
14
  import { I18nContext, PluginsRegistry, OptionsContext } from '../../../../contexts.js';
15
15
  import { getSidebarContentHeight, debounce } from '../../../../helper.js';
16
+ import { DESIGNER_CLASSNAME } from '../../../../constants.js';
16
17
  import { theme, Typography, Button, Divider } from 'antd';
17
18
  import AlignWidget from './AlignWidget.js';
18
19
  import WidgetRenderer from './WidgetRenderer.js';
@@ -423,9 +424,10 @@ const DetailView = (props: DetailViewProps) => {
423
424
  }
424
425
 
425
426
  return (
426
- <div>
427
+ <div className={DESIGNER_CLASSNAME + 'detail-view'}>
427
428
  <div style={{ height: 40, display: 'flex', alignItems: 'center' }}>
428
429
  <Button
430
+ className={DESIGNER_CLASSNAME + 'back-button'}
429
431
  style={{
430
432
  position: 'absolute',
431
433
  zIndex: 100,
@@ -1,6 +1,6 @@
1
1
  import React, { useContext, useState } from 'react';
2
2
  import type { SidebarProps } from '../../../../types.js';
3
- import { RIGHT_SIDEBAR_WIDTH } from '../../../../constants.js';
3
+ import { RIGHT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../../../constants.js';
4
4
  import { I18nContext } from '../../../../contexts.js';
5
5
  import { getSidebarContentHeight } from '../../../../helper.js';
6
6
  import { theme, Input, Typography, Divider, Button } from 'antd';
@@ -60,7 +60,7 @@ const ListView = (
60
60
  };
61
61
 
62
62
  return (
63
- <div>
63
+ <div className={DESIGNER_CLASSNAME + 'list-view'}>
64
64
  <div style={{ height: headHeight, display: 'flex', alignItems: 'center' }}>
65
65
  <Text strong style={{ textAlign: 'center', width: '100%' }}>
66
66
  {i18n('fieldsList')}
@@ -99,16 +99,16 @@ const ListView = (
99
99
  >
100
100
  {isBulkUpdateFieldNamesMode ? (
101
101
  <>
102
- <Button size="small" type="text" onClick={commitBulk}>
102
+ <Button className={DESIGNER_CLASSNAME + 'bulk-commit'} size="small" type="text" onClick={commitBulk}>
103
103
  <u> {i18n('commitBulkUpdateFieldName')}</u>
104
104
  </Button>
105
105
  <span style={{ margin: '0 1rem' }}>/</span>
106
- <Button size="small" type="text" onClick={() => setIsBulkUpdateFieldNamesMode(false)}>
106
+ <Button className={DESIGNER_CLASSNAME + 'bulk-cancel'} size="small" type="text" onClick={() => setIsBulkUpdateFieldNamesMode(false)}>
107
107
  <u> {i18n('cancel')}</u>
108
108
  </Button>
109
109
  </>
110
110
  ) : (
111
- <Button size="small" type="text" onClick={startBulk}>
111
+ <Button className={DESIGNER_CLASSNAME + 'bulk-update'} size="small" type="text" onClick={startBulk}>
112
112
  <u> {i18n('bulkUpdateFieldName')}</u>
113
113
  </Button>
114
114
  )}
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { theme, Button } from 'antd';
3
3
  import type { SidebarProps } from '../../../types.js';
4
- import { RIGHT_SIDEBAR_WIDTH } from '../../../constants.js';
4
+ import { RIGHT_SIDEBAR_WIDTH, DESIGNER_CLASSNAME } from '../../../constants.js';
5
5
  import { ArrowLeft, ArrowRight } from 'lucide-react';
6
6
  import ListView from './ListView/index.js';
7
7
  import DetailView from './DetailView/index.js';
@@ -21,6 +21,7 @@ const Sidebar = (props: SidebarProps) => {
21
21
 
22
22
  return (
23
23
  <div
24
+ className={DESIGNER_CLASSNAME + 'right-sidebar'}
24
25
  style={{
25
26
  position: 'absolute',
26
27
  right: 0,
@@ -31,6 +32,7 @@ const Sidebar = (props: SidebarProps) => {
31
32
  >
32
33
  <div>
33
34
  <Button
35
+ className={DESIGNER_CLASSNAME + 'sidebar-toggle'}
34
36
  style={{
35
37
  position: 'absolute',
36
38
  display: 'flex',
@@ -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-';