@pdfme/ui 4.2.5-dev.3 → 4.2.5-dev.4

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.
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { SchemaForUI } from '@pdfme/common';
3
3
  import type { SidebarProps } from '../../../../types';
4
- type DetailViewProps = Pick<SidebarProps, 'size' | 'schemas' | 'pageSize' | 'changeSchemas' | 'activeElements' | 'deselectSchema'> & {
4
+ type DetailViewProps = Pick<SidebarProps, 'size' | 'schemas' | 'schemasList' | 'pageSize' | 'changeSchemas' | 'activeElements' | 'deselectSchema'> & {
5
5
  activeSchema: SchemaForUI;
6
6
  };
7
7
  declare const _default: React.MemoExoticComponent<(props: DetailViewProps) => React.JSX.Element>;
@@ -7,6 +7,7 @@ export type SidebarProps = {
7
7
  pageSize: Size;
8
8
  activeElements: HTMLElement[];
9
9
  schemas: SchemaForUI[];
10
+ schemasList: SchemaForUI[][];
10
11
  onSortEnd: (sortedSchemas: SchemaForUI[]) => void;
11
12
  onEdit: (id: string) => void;
12
13
  onEditEnd: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "4.2.5-dev.3",
3
+ "version": "4.2.5-dev.4",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@ import { InternalNamePath, ValidateErrorEntity } from "rc-field-form/es/interfac
14
14
  const { Text } = Typography;
15
15
 
16
16
  type DetailViewProps = Pick<SidebarProps,
17
- 'size' | 'schemas' | 'pageSize' | 'changeSchemas' | 'activeElements' | 'deselectSchema'
17
+ 'size' | 'schemas' | 'schemasList' | 'pageSize' | 'changeSchemas' | 'activeElements' | 'deselectSchema'
18
18
  > & {
19
19
  activeSchema: SchemaForUI;
20
20
  };
@@ -22,7 +22,7 @@ type DetailViewProps = Pick<SidebarProps,
22
22
  const DetailView = (props: DetailViewProps) => {
23
23
  const { token } = theme.useToken();
24
24
 
25
- const { size, schemas, changeSchemas, deselectSchema, activeSchema } = props;
25
+ const { size, schemasList, changeSchemas, deselectSchema, activeSchema } = props;
26
26
  const form = useForm();
27
27
 
28
28
  const i18n = useContext(I18nContext);
@@ -74,14 +74,16 @@ const DetailView = (props: DetailViewProps) => {
74
74
 
75
75
  useEffect(() => {
76
76
  uniqueSchemaKey.current = (value: string): boolean => {
77
- for (const s of Object.values(schemas)) {
78
- if (s.key === value && s.id !== activeSchema.id) {
79
- return false;
77
+ for (const page of schemasList) {
78
+ for (const s of Object.values(page)) {
79
+ if (s.key === value && s.id !== activeSchema.id) {
80
+ return false;
81
+ }
80
82
  }
81
83
  }
82
84
  return true;
83
85
  };
84
- }, [schemas, activeSchema]);
86
+ }, [schemasList, activeSchema]);
85
87
 
86
88
  const uniqueSchemaKey = useRef((value: string): boolean => true);
87
89
 
@@ -218,9 +220,11 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
218
220
  };
219
221
 
220
222
  if (typeof activePropPanelSchema === 'function') {
223
+ const { schemasList: _, ...propPanelProps } = props;
224
+
221
225
  const apps =
222
226
  activePropPanelSchema({
223
- ...props,
227
+ ...propPanelProps,
224
228
  options,
225
229
  theme: token,
226
230
  i18n: i18n as (key: keyof Dict | string) => string,
@@ -163,9 +163,9 @@ const TemplateEditor = ({
163
163
  const pageSize = pageSizes[pageCursor];
164
164
 
165
165
  const newSchemaKey = (prefix: string) => {
166
- let keyNum = schemasList[pageCursor].length + 1;
166
+ let keyNum = schemasList.reduce((acc, page) => acc + page.length, 0);
167
167
  let newKey = prefix + keyNum;
168
- while (schemasList[pageCursor].find((s) => s.key === newKey)) {
168
+ while (schemasList.some(page => page.find((s) => s.key === newKey))) {
169
169
  keyNum++;
170
170
  newKey = prefix + keyNum;
171
171
  }
@@ -298,6 +298,7 @@ const TemplateEditor = ({
298
298
  size={size}
299
299
  pageSize={pageSizes[pageCursor] ?? []}
300
300
  activeElements={activeElements}
301
+ schemasList={schemasList}
301
302
  schemas={schemasList[pageCursor] ?? []}
302
303
  changeSchemas={changeSchemas}
303
304
  onSortEnd={onSortEnd}
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ export type SidebarProps = {
8
8
  pageSize: Size;
9
9
  activeElements: HTMLElement[];
10
10
  schemas: SchemaForUI[];
11
+ schemasList: SchemaForUI[][];
11
12
  onSortEnd: (sortedSchemas: SchemaForUI[]) => void;
12
13
  onEdit: (id: string) => void;
13
14
  onEditEnd: () => void;