@pdfme/ui 1.0.0-beta.3 → 1.0.0-beta.8

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 (88) hide show
  1. package/coverage/clover.xml +6 -0
  2. package/coverage/coverage-final.json +1 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +87 -0
  5. package/coverage/lcov-report/favicon.png +0 -0
  6. package/coverage/lcov-report/index.html +101 -0
  7. package/coverage/lcov-report/prettify.css +1 -0
  8. package/coverage/lcov-report/prettify.js +2 -0
  9. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  10. package/coverage/lcov-report/sorter.js +196 -0
  11. package/coverage/lcov.info +0 -0
  12. package/dist/index.js +1 -1
  13. package/dist/index.js.LICENSE.txt +3 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/types/{ui/src/Designer.d.ts → Designer.d.ts} +0 -0
  16. package/dist/types/{ui/src/Form.d.ts → Form.d.ts} +0 -0
  17. package/dist/types/{ui/src/Viewer.d.ts → Viewer.d.ts} +0 -0
  18. package/dist/types/{ui/src/class.d.ts → class.d.ts} +1 -1
  19. package/dist/types/{ui/src/components → components}/Designer/Main/Guides.d.ts +0 -0
  20. package/dist/types/{ui/src/components → components}/Designer/Main/Mask.d.ts +0 -0
  21. package/dist/types/{ui/src/components → components}/Designer/Main/Moveable.d.ts +1 -1
  22. package/dist/types/{ui/src/components → components}/Designer/Main/Selecto.d.ts +0 -0
  23. package/dist/types/{ui/src/components → components}/Designer/Main/index.d.ts +0 -0
  24. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/ExampleInputEditor.d.ts +0 -0
  25. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +0 -0
  26. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TextPropEditor.d.ts +0 -0
  27. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TypeAndKeyEditor.d.ts +0 -0
  28. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/index.d.ts +0 -0
  29. package/dist/types/components/Designer/Sidebar/ListView.d.ts +3 -0
  30. package/dist/types/{ui/src/components → components}/Designer/Sidebar/index.d.ts +1 -0
  31. package/dist/types/{ui/src/components → components}/Designer/index.d.ts +0 -1
  32. package/dist/types/{ui/src/components → components}/Divider.d.ts +0 -0
  33. package/dist/types/{ui/src/components → components}/Error.d.ts +0 -1
  34. package/dist/types/{ui/src/components → components}/Paper.d.ts +0 -0
  35. package/dist/types/{ui/src/components → components}/Preview/Pager/Page.d.ts +0 -0
  36. package/dist/types/{ui/src/components → components}/Preview/Pager/Unit.d.ts +0 -0
  37. package/dist/types/{ui/src/components → components}/Preview/index.d.ts +0 -1
  38. package/dist/types/{ui/src/components → components}/Root.d.ts +0 -0
  39. package/dist/types/{ui/src/components → components}/Schemas/BarcodeSchema.d.ts +0 -0
  40. package/dist/types/{ui/src/components → components}/Schemas/ImageSchema.d.ts +0 -0
  41. package/dist/types/{ui/src/components → components}/Schemas/SchemaUI.d.ts +0 -0
  42. package/dist/types/{ui/src/components → components}/Schemas/TextSchema.d.ts +0 -0
  43. package/dist/types/{ui/src/components → components}/Spinner.d.ts +0 -0
  44. package/dist/types/{ui/src/constants.d.ts → constants.d.ts} +1 -0
  45. package/dist/types/contexts.d.ts +7 -0
  46. package/dist/types/{ui/src/helper.d.ts → helper.d.ts} +0 -0
  47. package/dist/types/{ui/src/hooks.d.ts → hooks.d.ts} +0 -0
  48. package/dist/types/{ui/src/i18n.d.ts → i18n.d.ts} +0 -1
  49. package/dist/types/index.d.ts +6 -0
  50. package/package.json +11 -6
  51. package/src/Designer.tsx +2 -1
  52. package/src/Form.tsx +1 -0
  53. package/src/Viewer.tsx +1 -0
  54. package/src/assets/icons/close.svg +4 -0
  55. package/src/assets/imageExample.png +0 -0
  56. package/src/class.ts +5 -6
  57. package/src/components/Designer/Main/Moveable.tsx +1 -1
  58. package/src/components/Designer/Main/index.tsx +6 -8
  59. package/src/components/Designer/Sidebar/DetailView/ExampleInputEditor.tsx +24 -5
  60. package/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.tsx +12 -4
  61. package/src/components/Designer/Sidebar/DetailView/TextPropEditor.tsx +32 -5
  62. package/src/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.tsx +12 -4
  63. package/src/components/Designer/Sidebar/DetailView/index.tsx +15 -13
  64. package/src/components/Designer/Sidebar/ListView.tsx +47 -25
  65. package/src/components/Designer/Sidebar/index.tsx +9 -7
  66. package/src/components/Designer/index.tsx +5 -3
  67. package/src/components/Paper.tsx +1 -3
  68. package/src/components/Preview/Pager/Page.tsx +1 -1
  69. package/src/components/Preview/Pager/Unit.tsx +1 -1
  70. package/src/components/Preview/index.tsx +3 -4
  71. package/src/components/Root.tsx +2 -7
  72. package/src/components/Schemas/BarcodeSchema.tsx +37 -22
  73. package/src/components/Schemas/ImageSchema.tsx +71 -66
  74. package/src/components/Schemas/TextSchema.tsx +1 -1
  75. package/src/constants.ts +2 -0
  76. package/src/helper.ts +31 -27
  77. package/src/i18n.ts +0 -2
  78. package/src/index.ts +5 -41
  79. package/tsconfig.json +2 -1
  80. package/webpack.config.js +0 -18
  81. package/dist/types/common/src/constants.d.ts +0 -6
  82. package/dist/types/common/src/helper.d.ts +0 -15
  83. package/dist/types/common/src/index.d.ts +0 -4
  84. package/dist/types/common/src/schema.d.ts +0 -3613
  85. package/dist/types/common/src/type.d.ts +0 -64
  86. package/dist/types/ui/src/components/Designer/Sidebar/ListView.d.ts +0 -3
  87. package/dist/types/ui/src/contexts.d.ts +0 -7
  88. package/dist/types/ui/src/index.d.ts +0 -5
File without changes
File without changes
@@ -7,7 +7,7 @@ export declare abstract class BaseUIClass {
7
7
  private readonly font;
8
8
  private readonly setSize;
9
9
  constructor(props: UIProps);
10
- protected getI18n(): (key: "type" | "select" | "field" | "fieldName" | "require" | "uniq" | "inputExample" | "edit" | "plsSelect" | "plsInputName" | "plsAddNewField" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "previewWarnMsg" | "previewErrMsg" | "goToFirst" | "goToPrevious" | "goToNext" | "goToEnd" | "errorOccurred") => string;
10
+ protected getI18n(): (key: "type" | "field" | "fieldName" | "require" | "uniq" | "inputExample" | "edit" | "plsSelect" | "plsInputName" | "plsAddNewField" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "previewWarnMsg" | "previewErrMsg" | "goToFirst" | "goToPrevious" | "goToNext" | "goToEnd" | "errorOccurred") => string;
11
11
  protected getFont(): Record<string, {
12
12
  fallback?: boolean | undefined;
13
13
  subset?: boolean | undefined;
@@ -25,7 +25,7 @@ declare type Props = {
25
25
  onResizeGroupEnd: ((e: OnResizeGroupEnd) => void) & (({ targets }: {
26
26
  targets: (HTMLElement | SVGElement)[];
27
27
  }) => void);
28
- onClick: ((e: OnClick) => void) & (() => void);
28
+ onClick: (e: OnClick) => void;
29
29
  };
30
30
  declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<any>>;
31
31
  export default _default;
@@ -0,0 +1,3 @@
1
+ import { SidebarProps } from '.';
2
+ declare const ListView: (props: Pick<SidebarProps, 'scale' | 'schemas' | 'onSortEnd' | 'onEdit' | 'size' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId'>) => JSX.Element;
3
+ export default ListView;
@@ -1,5 +1,6 @@
1
1
  import { SchemaForUI, Size } from '@pdfme/common';
2
2
  export declare type SidebarProps = {
3
+ scale: number;
3
4
  height: number;
4
5
  hoveringSchemaId: string | null;
5
6
  onChangeHoveringSchemaId: (id: string | null) => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { DesignerReactProps, Template } from '@pdfme/common';
3
2
  declare const TemplateEditor: ({ template, size, onSaveTemplate, onChangeTemplate, }: {
4
3
  options?: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Size } from '@pdfme/common';
3
2
  declare const Error: ({ size, error }: {
4
3
  size: Size;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { PreviewReactProps } from '@pdfme/common';
3
2
  declare const Preview: ({ template, inputs, size, onChangeInput }: PreviewReactProps) => JSX.Element;
4
3
  export default Preview;
@@ -3,3 +3,4 @@ export declare const DESTROYED_ERR_MSG = "this instance is already destroyed";
3
3
  export declare const ZOOM = 3.7795275591;
4
4
  export declare const SELECTABLE_CLASSNAME = "selectable";
5
5
  export declare const RULER_HEIGHT = 30;
6
+ export declare const SIDEBAR_WIDTH = 300;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const I18nContext: import("react").Context<(key: "type" | "field" | "fieldName" | "require" | "uniq" | "inputExample" | "edit" | "plsSelect" | "plsInputName" | "plsAddNewField" | "fieldMustUniq" | "notUniq" | "noKeyName" | "fieldsList" | "addNewField" | "editField" | "previewWarnMsg" | "previewErrMsg" | "goToFirst" | "goToPrevious" | "goToNext" | "goToEnd" | "errorOccurred") => string>;
3
+ export declare const FontContext: import("react").Context<Record<string, {
4
+ fallback?: boolean | undefined;
5
+ subset?: boolean | undefined;
6
+ data: ArrayBuffer | Uint8Array;
7
+ }>>;
File without changes
File without changes
@@ -23,7 +23,6 @@ declare const dictEn: {
23
23
  goToPrevious: string;
24
24
  goToNext: string;
25
25
  goToEnd: string;
26
- select: string;
27
26
  errorOccurred: string;
28
27
  };
29
28
  export declare const curriedI18n: (lang: Lang) => (key: keyof DictEn) => string;
@@ -0,0 +1,6 @@
1
+ import Designer from './Designer';
2
+ import Form from './Form';
3
+ import Viewer from './Viewer';
4
+ export { Designer, Viewer, Form };
5
+ export type { Lang, Size, Alignment, SchemaType, BarCodeType, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, } from '@pdfme/common';
6
+ export { BLANK_PDF, isTextSchema, isImageSchema, isBarcodeSchema, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, validateBarcodeInput, } from '@pdfme/common';
package/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.8",
4
4
  "author": "hand-dot",
5
5
  "license": "MIT",
6
6
  "description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
7
7
  "homepage": "https://pdfme.com",
8
- "repository": "git@github.com:pdfme/pdfme.git",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git@github.com:pdfme/pdfme.git"
11
+ },
9
12
  "bugs": {
10
13
  "url": "https://github.com/pdfme/pdfme/issues"
11
14
  },
12
15
  "main": "dist/index.js",
13
- "module": "src/index.ts",
16
+ "module": "dist/index.js",
14
17
  "types": "dist/types/index.d.ts",
15
18
  "engines": {
16
19
  "node": ">=14"
17
20
  },
18
21
  "scripts": {
19
- "develop": "webpack-dev-server --mode development",
22
+ "develop": "webpack --watch --mode development",
20
23
  "build": "NODE_ENV=production webpack --mode production",
21
24
  "clean": "rimraf dist",
22
25
  "lint": "tsc --noEmit",
@@ -26,7 +29,7 @@
26
29
  "prune": "ts-prune src"
27
30
  },
28
31
  "dependencies": {
29
- "@pdfme/common": "^1.0.0-beta",
32
+ "@pdfme/common": "^1.0.0-beta.8",
30
33
  "@scena/react-guides": "^0.16.0",
31
34
  "hotkeys-js": "^3.8.7",
32
35
  "pdfjs-dist": "^2.12.313",
@@ -46,7 +49,6 @@
46
49
  "@types/react-dom": "^17.0.9",
47
50
  "eslint-plugin-react": "^7.28.0",
48
51
  "eslint-plugin-react-hooks": "^4.3.0",
49
- "html-webpack-plugin": "^5.3.2",
50
52
  "jest-canvas-mock": "^2.3.1",
51
53
  "process": "^0.11.10"
52
54
  },
@@ -76,5 +78,8 @@
76
78
  "**/*.test.ts",
77
79
  "**/*.test.tsx"
78
80
  ]
81
+ },
82
+ "publishConfig": {
83
+ "access": "public"
79
84
  }
80
85
  }
package/src/Designer.tsx CHANGED
@@ -5,6 +5,7 @@ import { BaseUIClass } from './class';
5
5
  import { DESTROYED_ERR_MSG } from './constants';
6
6
  import { I18nContext, FontContext } from './contexts';
7
7
  import DesignerComponent from './components/Designer';
8
+ import { cloneDeep } from './helper';
8
9
 
9
10
  class Designer extends BaseUIClass {
10
11
  private onSaveTemplateCallback?: (template: Template) => void;
@@ -26,7 +27,7 @@ class Designer extends BaseUIClass {
26
27
 
27
28
  public updateTemplate(template: Template) {
28
29
  if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
29
- this.template = template;
30
+ this.template = cloneDeep(template);
30
31
  if (this.onChangeTemplateCallback) {
31
32
  this.onChangeTemplateCallback(template);
32
33
  }
package/src/Form.tsx CHANGED
@@ -11,6 +11,7 @@ class Form extends PreviewUI {
11
11
 
12
12
  constructor(props: PreviewProps) {
13
13
  super(props);
14
+ this.render();
14
15
  }
15
16
 
16
17
  public onChangeInput(cb: (arg: { index: number; value: string; key: string }) => void) {
package/src/Viewer.tsx CHANGED
@@ -9,6 +9,7 @@ import Preview from './components/Preview';
9
9
  class Viewer extends PreviewUI {
10
10
  constructor(props: PreviewProps) {
11
11
  super(props);
12
+ this.render();
12
13
  }
13
14
 
14
15
  protected render() {
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
2
+ <path d="M0 0h24v24H0V0z" fill="none" />
3
+ <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
4
+ </svg>
Binary file
package/src/class.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import ReactDOM from 'react-dom';
2
2
  import { curriedI18n } from './i18n';
3
3
  import { DESTROYED_ERR_MSG, DEFAULT_LANG } from './constants';
4
- import { debounce, flatten } from './helper';
4
+ import { debounce, flatten, cloneDeep } from './helper';
5
5
  import {
6
6
  Template,
7
7
  Size,
@@ -76,7 +76,7 @@ export abstract class BaseUIClass {
76
76
  const { domContainer, template, options } = props;
77
77
  const { lang, font } = options || {};
78
78
  this.domContainer = domContainer;
79
- this.template = generateColumnsAndSampledataIfNeeded(template);
79
+ this.template = generateColumnsAndSampledataIfNeeded(cloneDeep(template));
80
80
  this.size = {
81
81
  height: this.domContainer.clientHeight || window.innerHeight,
82
82
  width: this.domContainer.clientWidth || window.innerWidth,
@@ -107,7 +107,7 @@ export abstract class BaseUIClass {
107
107
 
108
108
  public updateTemplate(template: Template) {
109
109
  if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
110
- this.template = template;
110
+ this.template = cloneDeep(template);
111
111
  this.render();
112
112
  }
113
113
 
@@ -127,8 +127,7 @@ export abstract class PreviewUI extends BaseUIClass {
127
127
  super(props);
128
128
  checkPreviewProps(props);
129
129
 
130
- this.inputs = props.inputs;
131
- this.render();
130
+ this.inputs = cloneDeep(props.inputs);
132
131
  }
133
132
 
134
133
  public getInputs() {
@@ -139,7 +138,7 @@ export abstract class PreviewUI extends BaseUIClass {
139
138
 
140
139
  public setInputs(inputs: { [key: string]: string }[]) {
141
140
  if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
142
- this.inputs = inputs;
141
+ this.inputs = cloneDeep(inputs);
143
142
  this.render();
144
143
  }
145
144
 
@@ -25,7 +25,7 @@ type Props = {
25
25
  (({ target }: { target: HTMLElement | SVGElement }) => void);
26
26
  onResizeGroupEnd: ((e: OnResizeGroupEnd) => void) &
27
27
  (({ targets }: { targets: (HTMLElement | SVGElement)[] }) => void);
28
- onClick: ((e: OnClick) => void) & (() => void);
28
+ onClick: (e: OnClick) => void;
29
29
  };
30
30
 
31
31
  const _Moveable = (
@@ -7,7 +7,7 @@ import React, {
7
7
  forwardRef,
8
8
  useCallback,
9
9
  } from 'react';
10
- import { OnDrag, OnResize } from 'react-moveable';
10
+ import { OnDrag, OnResize, OnClick } from 'react-moveable';
11
11
  import { SchemaForUI, Size } from '@pdfme/common';
12
12
  import { ZOOM, RULER_HEIGHT } from '../../../constants';
13
13
  import { usePrevious } from '../../../hooks';
@@ -39,7 +39,7 @@ const DeleteButton = ({ activeElements: aes }: { activeElements: HTMLElement[] }
39
39
  color: 'white',
40
40
  border: 'none',
41
41
  fontWeight: 'bold',
42
- borderRadius: 3,
42
+ borderRadius: 2,
43
43
  background: 'rgb(68, 170, 255)',
44
44
  }}
45
45
  >
@@ -201,15 +201,13 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
201
201
  const getGuideLines = (guides: GuidesInterface[], index: number) =>
202
202
  guides[index] && guides[index].getGuides().map((g) => g * ZOOM);
203
203
 
204
- const onClickMoveable = () => {
204
+ const onClickMoveable = (e: OnClick) => {
205
+ e.inputEvent.stopPropagation();
205
206
  setEditing(true);
206
207
  const ic = inputRef.current;
207
208
  if (!ic) return;
208
- ic.disabled = false;
209
209
  ic.focus();
210
- if (ic.type === 'file') {
211
- ic.click();
212
- } else {
210
+ if (ic.type !== 'file') {
213
211
  ic.setSelectionRange(ic.value.length, ic.value.length);
214
212
  }
215
213
  };
@@ -298,7 +296,7 @@ const Main = (props: Props, ref: Ref<HTMLDivElement>) => {
298
296
  )}
299
297
  renderSchema={({ schema }) => (
300
298
  <SchemaUI
301
- key={schema.key}
299
+ key={schema.id}
302
300
  schema={schema}
303
301
  onChangeHoveringSchemaId={onChangeHoveringSchemaId}
304
302
  editable={editing && activeElements.map((ae) => ae.id).includes(schema.id)}
@@ -2,6 +2,7 @@ import React, { useContext } from 'react';
2
2
  import { readFiles } from '../../../../helper';
3
3
  import { I18nContext } from '../../../../contexts';
4
4
  import { SidebarProps } from '..';
5
+ import closeIcon from '../../../../assets/icons/close.svg';
5
6
 
6
7
  const ExampleInputEditor = (props: Pick<SidebarProps, 'changeSchemas' | 'activeSchema'>) => {
7
8
  const { changeSchemas, activeSchema } = props;
@@ -9,25 +10,40 @@ const ExampleInputEditor = (props: Pick<SidebarProps, 'changeSchemas' | 'activeS
9
10
 
10
11
  return (
11
12
  <div>
12
- <label style={{ marginBottom: 0 }}>{i18n('inputExample')}</label>
13
+ <label>{i18n('inputExample')}</label>
13
14
  {activeSchema.type === 'image' ? (
14
- <div style={{ position: 'relative', textAlign: 'center' }}>
15
+ <div style={{ position: 'relative' }}>
15
16
  {activeSchema.data ? (
16
17
  <div style={{ margin: '0 auto' }}>
17
18
  <button
18
- style={{ position: 'absolute', top: 0, left: 0 }}
19
+ style={{
20
+ position: 'absolute',
21
+ top: 0,
22
+ left: 0,
23
+ display: 'flex',
24
+ justifyContent: 'center',
25
+ alignItems: 'center',
26
+ color: '#333',
27
+ background: '#f2f2f2',
28
+ cursor: 'pointer',
29
+ borderRadius: 2,
30
+ border: '1px solid #767676',
31
+ height: 20,
32
+ width: 20,
33
+ }}
19
34
  aria-label="close"
20
35
  onClick={() =>
21
36
  changeSchemas([{ key: 'data', value: '', schemaId: activeSchema.id }])
22
37
  }
23
38
  >
24
- x
39
+ <img src={closeIcon} alt="Close icon" width={10} />
25
40
  </button>
26
41
  <img style={{ maxHeight: 180 }} src={activeSchema.data} alt="Input Example" />
27
42
  </div>
28
43
  ) : (
29
44
  <label>
30
45
  <input
46
+ style={{ color: '#333', background: 'none' }}
31
47
  onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
32
48
  const { files } = e.target;
33
49
  readFiles(files, 'dataURL').then((result) => {
@@ -50,7 +66,10 @@ const ExampleInputEditor = (props: Pick<SidebarProps, 'changeSchemas' | 'activeS
50
66
  }
51
67
  style={{
52
68
  width: '100%',
53
- backgroundColor: activeSchema.data ? '#fff' : '#ffa19b',
69
+ border: '1px solid #767676',
70
+ borderRadius: 2,
71
+ color: '#333',
72
+ background: activeSchema.data ? 'none' : '#ffa19b',
54
73
  }}
55
74
  value={activeSchema.data}
56
75
  />
@@ -7,6 +7,14 @@ const inputSetStyle: React.CSSProperties = {
7
7
  alignItems: 'center',
8
8
  };
9
9
 
10
+ const inputStyle: React.CSSProperties = {
11
+ width: 70,
12
+ border: '1px solid #767676',
13
+ borderRadius: 2,
14
+ color: '#333',
15
+ background: 'none',
16
+ };
17
+
10
18
  const PositionAndSizeEditor = (
11
19
  props: Pick<SidebarProps, 'pageSize' | 'changeSchemas' | 'activeSchema'>
12
20
  ) => {
@@ -24,7 +32,7 @@ const PositionAndSizeEditor = (
24
32
  <div style={inputSetStyle}>
25
33
  <label style={{ width: 17 }}>X</label>
26
34
  <input
27
- style={{ width: 70 }}
35
+ style={inputStyle}
28
36
  type="number"
29
37
  onChange={(e) => {
30
38
  const value = Number(e.target.value);
@@ -39,7 +47,7 @@ const PositionAndSizeEditor = (
39
47
  <div style={inputSetStyle}>
40
48
  <label style={{ width: 17 }}>Y</label>
41
49
  <input
42
- style={{ width: 70 }}
50
+ style={inputStyle}
43
51
  type="number"
44
52
  onChange={(e) => {
45
53
  const value = Number(e.target.value);
@@ -63,7 +71,7 @@ const PositionAndSizeEditor = (
63
71
  <div style={inputSetStyle}>
64
72
  <label style={{ width: 17 }}>W</label>
65
73
  <input
66
- style={{ width: 70 }}
74
+ style={inputStyle}
67
75
  type="number"
68
76
  onChange={(e) => {
69
77
  const value = Number(e.target.value);
@@ -78,7 +86,7 @@ const PositionAndSizeEditor = (
78
86
  <div style={inputSetStyle}>
79
87
  <label style={{ width: 17 }}>H</label>
80
88
  <input
81
- style={{ width: 70 }}
89
+ style={inputStyle}
82
90
  type="number"
83
91
  onChange={(e) => {
84
92
  const value = Number(e.target.value);
@@ -4,9 +4,20 @@ import {
4
4
  DEFAULT_FONT_SIZE,
5
5
  DEFAULT_LINE_HEIGHT,
6
6
  DEFAULT_CHARACTER_SPACING,
7
+ DEFAULT_FONT_COLOR,
7
8
  } from '@pdfme/common';
8
9
  import { FontContext } from '../../../../contexts';
9
10
  import { SidebarProps } from '..';
11
+ import closeIcon from '../../../../assets/icons/close.svg';
12
+
13
+ const inputStyle = {
14
+ width: '90%',
15
+ color: '#333',
16
+ background: 'none',
17
+ borderRadius: 2,
18
+ border: '1px solid #767676',
19
+ };
20
+ const selectStyle = inputStyle;
10
21
 
11
22
  const NumberInputSet = (props: {
12
23
  width: string;
@@ -19,7 +30,7 @@ const NumberInputSet = (props: {
19
30
  return (
20
31
  <div style={{ width }}>
21
32
  <label>{label}</label>
22
- <input style={{ width: '100%' }} onChange={onChange} value={value} type="number" />
33
+ <input style={inputStyle} onChange={onChange} value={value} type="number" />
23
34
  </div>
24
35
  );
25
36
  };
@@ -36,8 +47,20 @@ const ColorInputSet = (props: {
36
47
  <div style={{ width: '45%' }}>
37
48
  <label>{label}</label>
38
49
  <div style={{ display: 'flex' }}>
39
- <input onChange={onChange} value={value} type="color" style={{ width: '100%' }} />
40
- <button onClick={onClear}>X</button>
50
+ <input onChange={onChange} value={value || '#ffffff'} type="color" style={inputStyle} />
51
+ <button
52
+ onClick={onClear}
53
+ style={{
54
+ display: 'flex',
55
+ background: 'none',
56
+ alignItems: 'center',
57
+ borderRadius: 2,
58
+ border: '1px solid #767676',
59
+ cursor: 'pointer',
60
+ }}
61
+ >
62
+ <img src={closeIcon} width={10} alt="Close icon" />
63
+ </button>
41
64
  </div>
42
65
  </div>
43
66
  );
@@ -54,7 +77,7 @@ const SelectSet = (props: {
54
77
  return (
55
78
  <div style={{ width: '45%' }}>
56
79
  <label>{label}:</label>
57
- <select style={{ width: '100%' }} onChange={onChange} value={value}>
80
+ <select style={selectStyle} onChange={onChange} value={value}>
58
81
  {options.map((o) => (
59
82
  <option key={o} value={o}>
60
83
  {o}
@@ -80,6 +103,7 @@ const TextPropEditor = (props: Pick<SidebarProps, 'changeSchemas' | 'activeSchem
80
103
  display: 'flex',
81
104
  alignItems: 'center',
82
105
  justifyContent: 'space-between',
106
+ marginBottom: '0.25rem',
83
107
  }}
84
108
  >
85
109
  <SelectSet
@@ -105,6 +129,7 @@ const TextPropEditor = (props: Pick<SidebarProps, 'changeSchemas' | 'activeSchem
105
129
  display: 'flex',
106
130
  alignItems: 'center',
107
131
  justifyContent: 'space-between',
132
+ marginBottom: '0.25rem',
108
133
  }}
109
134
  >
110
135
  <NumberInputSet
@@ -154,7 +179,9 @@ const TextPropEditor = (props: Pick<SidebarProps, 'changeSchemas' | 'activeSchem
154
179
  changeSchemas([{ key: 'fontColor', value: e.target.value, schemaId: activeSchema.id }])
155
180
  }
156
181
  onClear={() =>
157
- changeSchemas([{ key: 'fontColor', value: '', schemaId: activeSchema.id }])
182
+ changeSchemas([
183
+ { key: 'fontColor', value: DEFAULT_FONT_COLOR, schemaId: activeSchema.id },
184
+ ])
158
185
  }
159
186
  />
160
187
 
@@ -37,7 +37,13 @@ const TypeAndKeyEditor = (
37
37
  <div>
38
38
  <label style={{ marginBottom: 0 }}>{i18n('type')}</label>
39
39
  <select
40
- style={{ width: '100%' }}
40
+ style={{
41
+ width: '100%',
42
+ border: '1px solid #767676',
43
+ borderRadius: 2,
44
+ color: '#333',
45
+ background: 'none',
46
+ }}
41
47
  onChange={(e) =>
42
48
  changeSchemas([{ key: 'type', value: e.target.value, schemaId: activeSchema.id }])
43
49
  }
@@ -50,7 +56,7 @@ const TypeAndKeyEditor = (
50
56
  ))}
51
57
  </select>
52
58
  </div>
53
- <div style={{ width: '100%' }}>
59
+ <div>
54
60
  <label style={{ marginBottom: 0 }}>
55
61
  {i18n('fieldName')}
56
62
  <u style={{ fontSize: '0.7rem' }}>
@@ -65,9 +71,11 @@ const TypeAndKeyEditor = (
65
71
  changeSchemas([{ key: 'key', value: e.target.value, schemaId: activeSchema.id }])
66
72
  }
67
73
  style={{
68
- borderRadius: 2,
74
+ width: '100%',
69
75
  border: '1px solid #767676',
70
- backgroundColor: hasSameKey || blankKey ? '#ffa19b' : '#fff',
76
+ borderRadius: 2,
77
+ color: '#333',
78
+ background: hasSameKey || blankKey ? '#ffa19b' : 'none',
71
79
  }}
72
80
  value={activeSchema.key}
73
81
  />
@@ -14,25 +14,27 @@ const DetailView = (
14
14
  const i18n = useContext(I18nContext);
15
15
 
16
16
  return (
17
- <aside>
17
+ <div>
18
18
  <div style={{ height: 40, display: 'flex', alignItems: 'center' }}>
19
19
  <p style={{ textAlign: 'center', width: '100%', fontWeight: 'bold' }}>
20
20
  {i18n('editField')}
21
21
  </p>
22
22
  </div>
23
23
  <Divider />
24
- <TypeAndKeyEditor {...props} />
25
- <Divider />
26
- <PositionAndSizeEditor {...props} />
27
- <Divider />
28
- {activeSchema.type === 'text' && (
29
- <>
30
- <TextPropEditor {...props} />
31
- <Divider />
32
- </>
33
- )}
34
- <ExampleInputEditor {...props} />
35
- </aside>
24
+ <div style={{ fontSize: '0.9rem' }}>
25
+ <TypeAndKeyEditor {...props} />
26
+ <Divider />
27
+ <PositionAndSizeEditor {...props} />
28
+ <Divider />
29
+ {activeSchema.type === 'text' && (
30
+ <>
31
+ <TextPropEditor {...props} />
32
+ <Divider />
33
+ </>
34
+ )}
35
+ <ExampleInputEditor {...props} />
36
+ </div>
37
+ </div>
36
38
  );
37
39
  };
38
40