@pdfme/ui 1.0.0-beta.5 → 1.0.0-beta.9

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 (102) 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 +4 -1
  25. package/dist/types/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +6 -0
  26. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TextPropEditor.d.ts +4 -1
  27. package/dist/types/{ui/src/components → components}/Designer/Sidebar/DetailView/TypeAndKeyEditor.d.ts +4 -1
  28. package/dist/types/components/Designer/Sidebar/DetailView/index.d.ts +6 -0
  29. package/dist/types/components/Designer/Sidebar/ListView/Item.d.ts +25 -0
  30. package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableContainer.d.ts +3 -0
  31. package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableItem.d.ts +14 -0
  32. package/dist/types/{ui/src/components/Designer/Sidebar/ListView.d.ts → components/Designer/Sidebar/ListView/index.d.ts} +2 -2
  33. package/dist/types/{ui/src/components → components}/Designer/Sidebar/index.d.ts +2 -7
  34. package/dist/types/{ui/src/components → components}/Designer/index.d.ts +0 -1
  35. package/dist/types/{ui/src/components → components}/Divider.d.ts +0 -0
  36. package/dist/types/{ui/src/components → components}/Error.d.ts +0 -1
  37. package/dist/types/{ui/src/components → components}/Paper.d.ts +0 -0
  38. package/dist/types/{ui/src/components → components}/Preview/Pager/Page.d.ts +0 -1
  39. package/dist/types/{ui/src/components → components}/Preview/Pager/Unit.d.ts +0 -1
  40. package/dist/types/{ui/src/components → components}/Preview/index.d.ts +0 -1
  41. package/dist/types/{ui/src/components → components}/Root.d.ts +0 -0
  42. package/dist/types/{ui/src/components → components}/Schemas/BarcodeSchema.d.ts +0 -0
  43. package/dist/types/{ui/src/components → components}/Schemas/ImageSchema.d.ts +0 -0
  44. package/dist/types/{ui/src/components → components}/Schemas/SchemaUI.d.ts +0 -0
  45. package/dist/types/{ui/src/components → components}/Schemas/TextSchema.d.ts +0 -0
  46. package/dist/types/{ui/src/components → components}/Spinner.d.ts +0 -0
  47. package/dist/types/{ui/src/constants.d.ts → constants.d.ts} +1 -0
  48. package/dist/types/{ui/src/contexts.d.ts → contexts.d.ts} +1 -1
  49. package/dist/types/{ui/src/helper.d.ts → helper.d.ts} +1 -1
  50. package/dist/types/{ui/src/hooks.d.ts → hooks.d.ts} +1 -0
  51. package/dist/types/{ui/src/i18n.d.ts → i18n.d.ts} +4 -2
  52. package/dist/types/{ui/src/index.d.ts → index.d.ts} +0 -0
  53. package/package.json +13 -11
  54. package/src/Designer.tsx +2 -1
  55. package/src/Form.tsx +1 -0
  56. package/src/Viewer.tsx +1 -0
  57. package/src/assets/icons/align-horizontal-center.svg +1 -0
  58. package/src/assets/icons/align-horizontal-left.svg +1 -0
  59. package/src/assets/icons/align-horizontal-right.svg +1 -0
  60. package/src/assets/icons/align-vertical-bottom.svg +1 -0
  61. package/src/assets/icons/align-vertical-middle.svg +1 -0
  62. package/src/assets/icons/align-vertical-top.svg +1 -0
  63. package/src/assets/icons/close.svg +4 -0
  64. package/src/assets/icons/horizontal-distribute.svg +1 -0
  65. package/src/assets/icons/vertical-distribute.svg +1 -0
  66. package/src/assets/imageExample.png +0 -0
  67. package/src/class.ts +5 -6
  68. package/src/components/Designer/Main/Moveable.tsx +1 -1
  69. package/src/components/Designer/Main/index.tsx +21 -15
  70. package/src/components/Designer/Sidebar/DetailView/ExampleInputEditor.tsx +28 -6
  71. package/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.tsx +115 -24
  72. package/src/components/Designer/Sidebar/DetailView/TextPropEditor.tsx +36 -6
  73. package/src/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.tsx +14 -6
  74. package/src/components/Designer/Sidebar/DetailView/index.tsx +19 -14
  75. package/src/components/Designer/Sidebar/ListView/Item.tsx +113 -0
  76. package/src/components/Designer/Sidebar/ListView/SelectableSortableContainer.tsx +162 -0
  77. package/src/components/Designer/Sidebar/ListView/SelectableSortableItem.tsx +78 -0
  78. package/src/components/Designer/Sidebar/ListView/index.tsx +118 -0
  79. package/src/components/Designer/Sidebar/index.tsx +26 -12
  80. package/src/components/Designer/index.tsx +12 -24
  81. package/src/components/Paper.tsx +1 -3
  82. package/src/components/Preview/Pager/Page.tsx +1 -1
  83. package/src/components/Preview/Pager/Unit.tsx +1 -1
  84. package/src/components/Preview/index.tsx +3 -4
  85. package/src/components/Root.tsx +2 -7
  86. package/src/components/Schemas/BarcodeSchema.tsx +37 -22
  87. package/src/components/Schemas/ImageSchema.tsx +71 -66
  88. package/src/components/Schemas/TextSchema.tsx +1 -1
  89. package/src/constants.ts +2 -0
  90. package/src/helper.ts +42 -37
  91. package/src/hooks.ts +11 -0
  92. package/src/i18n.ts +10 -7
  93. package/tsconfig.json +1 -1
  94. package/webpack.config.js +0 -18
  95. package/dist/types/common/src/constants.d.ts +0 -6
  96. package/dist/types/common/src/helper.d.ts +0 -15
  97. package/dist/types/common/src/index.d.ts +0 -6
  98. package/dist/types/common/src/schema.d.ts +0 -3613
  99. package/dist/types/common/src/type.d.ts +0 -64
  100. package/dist/types/ui/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +0 -3
  101. package/dist/types/ui/src/components/Designer/Sidebar/DetailView/index.d.ts +0 -3
  102. package/src/components/Designer/Sidebar/ListView.tsx +0 -180
@@ -1,64 +0,0 @@
1
- import { z } from 'zod';
2
- import { Lang, Size, Alignment, BarcodeSchemaType, SchemaType, CommonSchema as _CommonSchema, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, PreviewReactProps, DesignerProps, DesignerReactProps } from './schema';
3
- declare type CommonSchema = z.infer<typeof _CommonSchema>;
4
- export declare const schemaTypes: readonly ["text", "image", "qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14", "upca", "upce"];
5
- export declare const isTextSchema: (arg: CommonSchema) => arg is {
6
- rotate?: number | undefined;
7
- alignment?: "left" | "center" | "right" | undefined;
8
- fontSize?: number | undefined;
9
- fontName?: string | undefined;
10
- fontColor?: string | undefined;
11
- backgroundColor?: string | undefined;
12
- characterSpacing?: number | undefined;
13
- lineHeight?: number | undefined;
14
- type: "text";
15
- position: {
16
- x: number;
17
- y: number;
18
- };
19
- width: number;
20
- height: number;
21
- };
22
- export declare const isImageSchema: (arg: CommonSchema) => arg is {
23
- rotate?: number | undefined;
24
- type: "image";
25
- position: {
26
- x: number;
27
- y: number;
28
- };
29
- width: number;
30
- height: number;
31
- };
32
- export declare const isBarcodeSchema: (arg: CommonSchema) => arg is {
33
- rotate?: number | undefined;
34
- type: "qrcode" | "japanpost" | "ean13" | "ean8" | "code39" | "code128" | "nw7" | "itf14" | "upca" | "upce";
35
- position: {
36
- x: number;
37
- y: number;
38
- };
39
- width: number;
40
- height: number;
41
- };
42
- export declare type Lang = z.infer<typeof Lang>;
43
- export declare type Size = z.infer<typeof Size>;
44
- export declare type Alignment = z.infer<typeof Alignment>;
45
- export declare type SchemaType = z.infer<typeof SchemaType>;
46
- export declare type BarCodeType = z.infer<typeof BarcodeSchemaType>;
47
- export declare type TextSchema = z.infer<typeof TextSchema>;
48
- export declare type ImageSchema = z.infer<typeof ImageSchema>;
49
- export declare type BarcodeSchema = z.infer<typeof BarcodeSchema>;
50
- export declare type Schema = z.infer<typeof Schema>;
51
- export declare type SchemaForUI = z.infer<typeof SchemaForUI>;
52
- export declare type Font = z.infer<typeof Font>;
53
- export declare type BasePdf = z.infer<typeof BasePdf>;
54
- export declare type Template = z.infer<typeof Template>;
55
- export declare type CommonProps = z.infer<typeof CommonProps>;
56
- export declare type GeneratorOptions = z.infer<typeof GeneratorOptions>;
57
- export declare type GenerateProps = z.infer<typeof GenerateProps>;
58
- export declare type UIOptions = z.infer<typeof UIOptions>;
59
- export declare type UIProps = z.infer<typeof UIProps>;
60
- export declare type PreviewProps = z.infer<typeof PreviewProps>;
61
- export declare type PreviewReactProps = z.infer<typeof PreviewReactProps>;
62
- export declare type DesignerProps = z.infer<typeof DesignerProps>;
63
- export declare type DesignerReactProps = z.infer<typeof DesignerReactProps>;
64
- export {};
@@ -1,3 +0,0 @@
1
- import { SidebarProps } from '..';
2
- declare const PositionAndSizeEditor: (props: Pick<SidebarProps, 'pageSize' | 'changeSchemas' | 'activeSchema'>) => JSX.Element;
3
- export default PositionAndSizeEditor;
@@ -1,3 +0,0 @@
1
- import { SidebarProps } from '..';
2
- declare const DetailView: (props: Pick<SidebarProps, 'schemas' | 'pageSize' | 'changeSchemas' | 'activeSchema'>) => JSX.Element;
3
- export default DetailView;
@@ -1,180 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
3
- import { SchemaForUI, Size } from '@pdfme/common';
4
- import { ZOOM, RULER_HEIGHT } from '../../../constants';
5
- import { I18nContext } from '../../../contexts';
6
- import Divider from '../../Divider';
7
- import dragIcon from '../../../assets/icons/drag.svg';
8
- import warningIcon from '../../../assets/icons/warning.svg';
9
- import { SidebarProps } from '.';
10
-
11
- const isTouchable = () => true;
12
-
13
- const DragHandle = SortableHandle(() => (
14
- <button style={{ padding: 0, background: 'none', border: 'none', display: 'flex' }}>
15
- <img style={{ cursor: 'grab' }} src={dragIcon} width={15} alt="Drag icon" />
16
- </button>
17
- ));
18
-
19
- const SortableItem = SortableElement(
20
- (props: { schemas: SchemaForUI[]; schema: SchemaForUI; onEdit: (id: string) => void }) => {
21
- const { schemas, schema, onEdit } = props;
22
- const i18n = useContext(I18nContext);
23
-
24
- const sc = schema;
25
- let status: '' | 'is-warning' | 'is-danger' = '';
26
- if (!sc.key) {
27
- status = 'is-warning';
28
- } else if (schemas.find((s) => sc.key && s.key === sc.key && s.id !== sc.id)) {
29
- status = 'is-danger';
30
- }
31
-
32
- const touchable = isTouchable();
33
-
34
- const getTitle = () => {
35
- if (status === 'is-warning') {
36
- return i18n('plsInputName');
37
- }
38
- if (status === 'is-danger') {
39
- return i18n('fieldMustUniq');
40
- }
41
-
42
- return i18n('edit');
43
- };
44
-
45
- return (
46
- <div
47
- key={sc.id}
48
- style={{
49
- paddingLeft: 5,
50
- display: 'flex',
51
- alignItems: 'center',
52
- justifyContent: 'space-between',
53
- }}
54
- >
55
- <DragHandle />
56
- <button
57
- disabled={!touchable}
58
- className={`${status}`}
59
- style={{
60
- padding: 5,
61
- margin: 5,
62
- width: '100%',
63
- display: 'flex',
64
- background: 'none',
65
- border: 'none',
66
- textAlign: 'left',
67
- cursor: 'pointer',
68
- }}
69
- onClick={() => onEdit(sc.id)}
70
- title={getTitle()}
71
- >
72
- <span
73
- style={{
74
- marginRight: '1rem',
75
- width: 180,
76
- overflow: 'hidden',
77
- whiteSpace: 'nowrap',
78
- textOverflow: 'ellipsis',
79
- }}
80
- >
81
- {status === '' ? (
82
- sc.key
83
- ) : (
84
- <span style={{ display: 'flex', alignItems: 'center' }}>
85
- <img
86
- alt="Warning icon"
87
- src={warningIcon}
88
- width={15}
89
- style={{ marginRight: '0.5rem' }}
90
- />
91
- {status === 'is-warning' ? i18n('noKeyName') : sc.key}
92
- {status === 'is-danger' ? i18n('notUniq') : ''}
93
- </span>
94
- )}
95
- </span>
96
- </button>
97
- </div>
98
- );
99
- }
100
- );
101
-
102
- const SortableList = SortableContainer(
103
- (props: {
104
- schemas: SchemaForUI[];
105
- onEdit: (id: string) => void;
106
- size: Size;
107
- hoveringSchemaId: string | null;
108
- onChangeHoveringSchemaId: (id: string | null) => void;
109
- }) => {
110
- const { schemas, onEdit, size, hoveringSchemaId, onChangeHoveringSchemaId } = props;
111
- const i18n = useContext(I18nContext);
112
-
113
- return (
114
- <div style={{ maxHeight: size.height - RULER_HEIGHT * ZOOM - 125, overflowY: 'auto' }}>
115
- {schemas.length > 0 ? (
116
- schemas.map((s, i) => (
117
- <div
118
- key={s.id}
119
- style={{
120
- border: `1px solid ${s.id === hoveringSchemaId ? '#18a0fb' : 'transparent'}`,
121
- }}
122
- onMouseEnter={() => onChangeHoveringSchemaId(s.id)}
123
- onMouseLeave={() => onChangeHoveringSchemaId(null)}
124
- >
125
- <SortableItem
126
- disabled={!isTouchable()}
127
- index={i}
128
- schemas={schemas}
129
- schema={s}
130
- onEdit={onEdit}
131
- />
132
- </div>
133
- ))
134
- ) : (
135
- <p style={{ textAlign: 'center' }}>{i18n('plsAddNewField')}</p>
136
- )}
137
- </div>
138
- );
139
- }
140
- );
141
-
142
- const ListView = (
143
- props: Pick<
144
- SidebarProps,
145
- 'schemas' | 'onSortEnd' | 'onEdit' | 'size' | 'hoveringSchemaId' | 'onChangeHoveringSchemaId'
146
- >
147
- ) => {
148
- const { schemas, onSortEnd, onEdit, size, hoveringSchemaId, onChangeHoveringSchemaId } = props;
149
- const i18n = useContext(I18nContext);
150
-
151
- return (
152
- <aside>
153
- <div style={{ height: 40, display: 'flex', alignItems: 'center' }}>
154
- <p style={{ textAlign: 'center', width: '100%', fontWeight: 'bold' }}>
155
- {i18n('fieldsList')}
156
- </p>
157
- </div>
158
- <Divider />
159
- <SortableList
160
- size={size}
161
- hoveringSchemaId={hoveringSchemaId}
162
- onChangeHoveringSchemaId={onChangeHoveringSchemaId}
163
- updateBeforeSortStart={(node: any) => {
164
- if (node.node.style) {
165
- node.node.style.zIndex = '9999';
166
- }
167
- }}
168
- useDragHandle
169
- axis="y"
170
- lockAxis="y"
171
- schemas={schemas}
172
- onSortEnd={onSortEnd}
173
- onEdit={onEdit}
174
- />
175
- <Divider />
176
- </aside>
177
- );
178
- };
179
-
180
- export default ListView;