@embedpdf/plugin-form 2.10.0
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.
- package/LICENSE +21 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1789 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions.d.ts +33 -0
- package/dist/lib/form-plugin.d.ts +59 -0
- package/dist/lib/handlers/checkbox.handler.d.ts +3 -0
- package/dist/lib/handlers/combobox.handler.d.ts +3 -0
- package/dist/lib/handlers/index.d.ts +5 -0
- package/dist/lib/handlers/listbox.handler.d.ts +3 -0
- package/dist/lib/handlers/radio-button.handler.d.ts +3 -0
- package/dist/lib/handlers/text-field.handler.d.ts +3 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/reducer.d.ts +6 -0
- package/dist/lib/tools.d.ts +457 -0
- package/dist/lib/types.d.ts +98 -0
- package/dist/preact/adapter.d.ts +13 -0
- package/dist/preact/annotation.d.ts +1 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -0
- package/dist/preact/index.cjs.map +1 -0
- package/dist/preact/index.d.ts +1 -0
- package/dist/preact/index.js +1359 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/react/adapter.d.ts +6 -0
- package/dist/react/annotation.d.ts +1 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1358 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared/components/annotations/form-checkbox.d.ts +12 -0
- package/dist/shared/components/annotations/form-combobox.d.ts +12 -0
- package/dist/shared/components/annotations/form-listbox.d.ts +12 -0
- package/dist/shared/components/annotations/form-radio-button.d.ts +12 -0
- package/dist/shared/components/annotations/form-text-field.d.ts +12 -0
- package/dist/shared/components/fields/checkbox.d.ts +2 -0
- package/dist/shared/components/fields/combobox.d.ts +2 -0
- package/dist/shared/components/fields/listbox.d.ts +2 -0
- package/dist/shared/components/fields/push-button.d.ts +2 -0
- package/dist/shared/components/fields/radio-button.d.ts +2 -0
- package/dist/shared/components/fields/style.d.ts +6 -0
- package/dist/shared/components/fields/text.d.ts +2 -0
- package/dist/shared/components/fill-mode/combobox-fill-mode.d.ts +3 -0
- package/dist/shared/components/fill-mode/listbox-fill-mode.d.ts +3 -0
- package/dist/shared/components/fill-mode/push-button-fill-mode.d.ts +3 -0
- package/dist/shared/components/fill-mode/radio-button-fill-mode.d.ts +3 -0
- package/dist/shared/components/fill-mode/text-fill-mode.d.ts +3 -0
- package/dist/shared/components/fill-mode/toggle-fill-mode.d.ts +3 -0
- package/dist/shared/components/form-renderer-registration.d.ts +5 -0
- package/dist/shared/components/form-renderers.d.ts +9 -0
- package/dist/shared/components/index.d.ts +2 -0
- package/dist/shared/components/render-widget.d.ts +12 -0
- package/dist/shared/components/types.d.ts +42 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/use-form-widget-state.d.ts +12 -0
- package/dist/shared/hooks/use-form.d.ts +16 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared-preact/components/annotations/form-checkbox.d.ts +12 -0
- package/dist/shared-preact/components/annotations/form-combobox.d.ts +12 -0
- package/dist/shared-preact/components/annotations/form-listbox.d.ts +12 -0
- package/dist/shared-preact/components/annotations/form-radio-button.d.ts +12 -0
- package/dist/shared-preact/components/annotations/form-text-field.d.ts +12 -0
- package/dist/shared-preact/components/fields/checkbox.d.ts +2 -0
- package/dist/shared-preact/components/fields/combobox.d.ts +2 -0
- package/dist/shared-preact/components/fields/listbox.d.ts +2 -0
- package/dist/shared-preact/components/fields/push-button.d.ts +2 -0
- package/dist/shared-preact/components/fields/radio-button.d.ts +2 -0
- package/dist/shared-preact/components/fields/style.d.ts +6 -0
- package/dist/shared-preact/components/fields/text.d.ts +2 -0
- package/dist/shared-preact/components/fill-mode/combobox-fill-mode.d.ts +3 -0
- package/dist/shared-preact/components/fill-mode/listbox-fill-mode.d.ts +3 -0
- package/dist/shared-preact/components/fill-mode/push-button-fill-mode.d.ts +3 -0
- package/dist/shared-preact/components/fill-mode/radio-button-fill-mode.d.ts +3 -0
- package/dist/shared-preact/components/fill-mode/text-fill-mode.d.ts +3 -0
- package/dist/shared-preact/components/fill-mode/toggle-fill-mode.d.ts +3 -0
- package/dist/shared-preact/components/form-renderer-registration.d.ts +5 -0
- package/dist/shared-preact/components/form-renderers.d.ts +9 -0
- package/dist/shared-preact/components/index.d.ts +2 -0
- package/dist/shared-preact/components/render-widget.d.ts +12 -0
- package/dist/shared-preact/components/types.d.ts +42 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -0
- package/dist/shared-preact/hooks/use-form-widget-state.d.ts +12 -0
- package/dist/shared-preact/hooks/use-form.d.ts +16 -0
- package/dist/shared-preact/index.d.ts +4 -0
- package/dist/shared-react/components/annotations/form-checkbox.d.ts +12 -0
- package/dist/shared-react/components/annotations/form-combobox.d.ts +12 -0
- package/dist/shared-react/components/annotations/form-listbox.d.ts +12 -0
- package/dist/shared-react/components/annotations/form-radio-button.d.ts +12 -0
- package/dist/shared-react/components/annotations/form-text-field.d.ts +12 -0
- package/dist/shared-react/components/fields/checkbox.d.ts +2 -0
- package/dist/shared-react/components/fields/combobox.d.ts +2 -0
- package/dist/shared-react/components/fields/listbox.d.ts +2 -0
- package/dist/shared-react/components/fields/push-button.d.ts +2 -0
- package/dist/shared-react/components/fields/radio-button.d.ts +2 -0
- package/dist/shared-react/components/fields/style.d.ts +6 -0
- package/dist/shared-react/components/fields/text.d.ts +2 -0
- package/dist/shared-react/components/fill-mode/combobox-fill-mode.d.ts +3 -0
- package/dist/shared-react/components/fill-mode/listbox-fill-mode.d.ts +3 -0
- package/dist/shared-react/components/fill-mode/push-button-fill-mode.d.ts +3 -0
- package/dist/shared-react/components/fill-mode/radio-button-fill-mode.d.ts +3 -0
- package/dist/shared-react/components/fill-mode/text-fill-mode.d.ts +3 -0
- package/dist/shared-react/components/fill-mode/toggle-fill-mode.d.ts +3 -0
- package/dist/shared-react/components/form-renderer-registration.d.ts +5 -0
- package/dist/shared-react/components/form-renderers.d.ts +9 -0
- package/dist/shared-react/components/index.d.ts +2 -0
- package/dist/shared-react/components/render-widget.d.ts +12 -0
- package/dist/shared-react/components/types.d.ts +42 -0
- package/dist/shared-react/hooks/index.d.ts +1 -0
- package/dist/shared-react/hooks/use-form-widget-state.d.ts +12 -0
- package/dist/shared-react/hooks/use-form.d.ts +16 -0
- package/dist/shared-react/index.d.ts +4 -0
- package/dist/svelte/components/FormRendererRegistration.svelte.d.ts +18 -0
- package/dist/svelte/components/RenderWidget.svelte.d.ts +11 -0
- package/dist/svelte/components/annotations/FormCheckbox.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/FormCombobox.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/FormListbox.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/FormRadioButton.svelte.d.ts +5 -0
- package/dist/svelte/components/annotations/FormTextField.svelte.d.ts +5 -0
- package/dist/svelte/components/fields/ComboboxField.svelte.d.ts +4 -0
- package/dist/svelte/components/fields/ListboxField.svelte.d.ts +4 -0
- package/dist/svelte/components/fields/TextField.svelte.d.ts +4 -0
- package/dist/svelte/components/fill-mode/ComboboxFillMode.svelte.d.ts +5 -0
- package/dist/svelte/components/fill-mode/ListboxFillMode.svelte.d.ts +5 -0
- package/dist/svelte/components/fill-mode/RadioButtonFillMode.svelte.d.ts +5 -0
- package/dist/svelte/components/fill-mode/TextFillMode.svelte.d.ts +5 -0
- package/dist/svelte/components/fill-mode/ToggleFillMode.svelte.d.ts +5 -0
- package/dist/svelte/components/form-renderers.d.ts +9 -0
- package/dist/svelte/components/previews/CheckboxPreview.svelte.d.ts +9 -0
- package/dist/svelte/components/previews/ListboxPreview.svelte.d.ts +9 -0
- package/dist/svelte/components/previews/RadioButtonPreview.svelte.d.ts +9 -0
- package/dist/svelte/components/previews/TextFieldPreview.svelte.d.ts +9 -0
- package/dist/svelte/hooks/index.d.ts +2 -0
- package/dist/svelte/hooks/use-form-widget-state.svelte.d.ts +12 -0
- package/dist/svelte/hooks/use-form.svelte.d.ts +14 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +3 -0
- package/dist/svelte/index.js +1567 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/vue/components/annotations/form-checkbox.vue.d.ts +6 -0
- package/dist/vue/components/annotations/form-combobox.vue.d.ts +6 -0
- package/dist/vue/components/annotations/form-listbox.vue.d.ts +6 -0
- package/dist/vue/components/annotations/form-radio-button.vue.d.ts +6 -0
- package/dist/vue/components/annotations/form-text-field.vue.d.ts +6 -0
- package/dist/vue/components/fields/combobox-field.vue.d.ts +4 -0
- package/dist/vue/components/fields/listbox-field.vue.d.ts +4 -0
- package/dist/vue/components/fields/style.d.ts +6 -0
- package/dist/vue/components/fields/text-field.vue.d.ts +4 -0
- package/dist/vue/components/fill-mode/combobox-fill-mode.vue.d.ts +6 -0
- package/dist/vue/components/fill-mode/listbox-fill-mode.vue.d.ts +6 -0
- package/dist/vue/components/fill-mode/radio-button-fill-mode.vue.d.ts +6 -0
- package/dist/vue/components/fill-mode/text-fill-mode.vue.d.ts +6 -0
- package/dist/vue/components/fill-mode/toggle-fill-mode.vue.d.ts +6 -0
- package/dist/vue/components/form-renderer-registration.vue.d.ts +13 -0
- package/dist/vue/components/form-renderers.d.ts +3 -0
- package/dist/vue/components/previews/checkbox-preview.vue.d.ts +10 -0
- package/dist/vue/components/previews/listbox-preview.vue.d.ts +10 -0
- package/dist/vue/components/previews/radio-button-preview.vue.d.ts +10 -0
- package/dist/vue/components/previews/text-field-preview.vue.d.ts +10 -0
- package/dist/vue/components/render-widget.vue.d.ts +15 -0
- package/dist/vue/hooks/index.d.ts +2 -0
- package/dist/vue/hooks/use-form-widget-state.d.ts +12 -0
- package/dist/vue/hooks/use-form.d.ts +12 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +3 -0
- package/dist/vue/index.js +1643 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { PdfAnnotationObject, PdfAnnotationSubtype, PDF_FORM_FIELD_TYPE, PDF_FORM_FIELD_FLAG, PdfWidgetAnnoObject, PdfStandardFont } from '@embedpdf/models';
|
|
2
|
+
export declare const formTextFieldTool: {
|
|
3
|
+
id: "formTextField";
|
|
4
|
+
name: string;
|
|
5
|
+
labelKey: string;
|
|
6
|
+
categories: string[];
|
|
7
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
8
|
+
interaction: {
|
|
9
|
+
exclusive: false;
|
|
10
|
+
cursor: string;
|
|
11
|
+
isDraggable: true;
|
|
12
|
+
isResizable: true;
|
|
13
|
+
isRotatable: false;
|
|
14
|
+
isGroupDraggable: true;
|
|
15
|
+
isGroupResizable: false;
|
|
16
|
+
isGroupRotatable: false;
|
|
17
|
+
};
|
|
18
|
+
defaults: {
|
|
19
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
20
|
+
fontFamily: PdfStandardFont.Helvetica;
|
|
21
|
+
fontSize: number;
|
|
22
|
+
fontColor: string;
|
|
23
|
+
strokeColor: string;
|
|
24
|
+
color: string;
|
|
25
|
+
strokeWidth: number;
|
|
26
|
+
field: {
|
|
27
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
28
|
+
name: string;
|
|
29
|
+
alternateName: string;
|
|
30
|
+
value: string;
|
|
31
|
+
type: PDF_FORM_FIELD_TYPE.TEXTFIELD;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
behavior: {
|
|
35
|
+
useAppearanceStream: false;
|
|
36
|
+
};
|
|
37
|
+
clickBehavior: {
|
|
38
|
+
enabled: true;
|
|
39
|
+
defaultSize: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
45
|
+
};
|
|
46
|
+
export declare const formCheckboxTool: {
|
|
47
|
+
id: "formCheckbox";
|
|
48
|
+
name: string;
|
|
49
|
+
labelKey: string;
|
|
50
|
+
categories: string[];
|
|
51
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
52
|
+
interaction: {
|
|
53
|
+
exclusive: false;
|
|
54
|
+
cursor: string;
|
|
55
|
+
isDraggable: true;
|
|
56
|
+
isResizable: true;
|
|
57
|
+
isRotatable: false;
|
|
58
|
+
isGroupDraggable: true;
|
|
59
|
+
isGroupResizable: false;
|
|
60
|
+
isGroupRotatable: false;
|
|
61
|
+
};
|
|
62
|
+
defaults: {
|
|
63
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
64
|
+
strokeColor: string;
|
|
65
|
+
color: string;
|
|
66
|
+
strokeWidth: number;
|
|
67
|
+
field: {
|
|
68
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
69
|
+
name: string;
|
|
70
|
+
alternateName: string;
|
|
71
|
+
value: string;
|
|
72
|
+
type: PDF_FORM_FIELD_TYPE.CHECKBOX;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
behavior: {
|
|
76
|
+
useAppearanceStream: false;
|
|
77
|
+
};
|
|
78
|
+
clickBehavior: {
|
|
79
|
+
enabled: true;
|
|
80
|
+
defaultSize: {
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
86
|
+
};
|
|
87
|
+
export declare const formRadioButtonTool: {
|
|
88
|
+
id: "formRadioButton";
|
|
89
|
+
name: string;
|
|
90
|
+
labelKey: string;
|
|
91
|
+
categories: string[];
|
|
92
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
93
|
+
interaction: {
|
|
94
|
+
exclusive: false;
|
|
95
|
+
cursor: string;
|
|
96
|
+
isDraggable: true;
|
|
97
|
+
isResizable: true;
|
|
98
|
+
isRotatable: false;
|
|
99
|
+
lockAspectRatio: true;
|
|
100
|
+
isGroupDraggable: true;
|
|
101
|
+
isGroupResizable: false;
|
|
102
|
+
isGroupRotatable: false;
|
|
103
|
+
};
|
|
104
|
+
defaults: {
|
|
105
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
106
|
+
strokeColor: string;
|
|
107
|
+
color: string;
|
|
108
|
+
strokeWidth: number;
|
|
109
|
+
field: {
|
|
110
|
+
flag: number;
|
|
111
|
+
name: string;
|
|
112
|
+
alternateName: string;
|
|
113
|
+
value: string;
|
|
114
|
+
type: PDF_FORM_FIELD_TYPE.RADIOBUTTON;
|
|
115
|
+
options: never[];
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
behavior: {
|
|
119
|
+
useAppearanceStream: false;
|
|
120
|
+
};
|
|
121
|
+
clickBehavior: {
|
|
122
|
+
enabled: true;
|
|
123
|
+
defaultSize: {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
129
|
+
};
|
|
130
|
+
export declare const formComboboxTool: {
|
|
131
|
+
id: "formCombobox";
|
|
132
|
+
name: string;
|
|
133
|
+
labelKey: string;
|
|
134
|
+
categories: string[];
|
|
135
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
136
|
+
interaction: {
|
|
137
|
+
exclusive: false;
|
|
138
|
+
cursor: string;
|
|
139
|
+
isDraggable: true;
|
|
140
|
+
isResizable: true;
|
|
141
|
+
isRotatable: false;
|
|
142
|
+
isGroupDraggable: true;
|
|
143
|
+
isGroupResizable: false;
|
|
144
|
+
isGroupRotatable: false;
|
|
145
|
+
};
|
|
146
|
+
defaults: {
|
|
147
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
148
|
+
fontFamily: PdfStandardFont.Helvetica;
|
|
149
|
+
fontSize: number;
|
|
150
|
+
fontColor: string;
|
|
151
|
+
strokeColor: string;
|
|
152
|
+
color: string;
|
|
153
|
+
strokeWidth: number;
|
|
154
|
+
field: {
|
|
155
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
156
|
+
name: string;
|
|
157
|
+
alternateName: string;
|
|
158
|
+
value: string;
|
|
159
|
+
type: PDF_FORM_FIELD_TYPE.COMBOBOX;
|
|
160
|
+
options: ({
|
|
161
|
+
label: string;
|
|
162
|
+
isSelected: true;
|
|
163
|
+
} | {
|
|
164
|
+
label: string;
|
|
165
|
+
isSelected: false;
|
|
166
|
+
})[];
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
behavior: {
|
|
170
|
+
useAppearanceStream: false;
|
|
171
|
+
};
|
|
172
|
+
clickBehavior: {
|
|
173
|
+
enabled: true;
|
|
174
|
+
defaultSize: {
|
|
175
|
+
width: number;
|
|
176
|
+
height: number;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
180
|
+
};
|
|
181
|
+
export declare const formListboxTool: {
|
|
182
|
+
id: "formListbox";
|
|
183
|
+
name: string;
|
|
184
|
+
labelKey: string;
|
|
185
|
+
categories: string[];
|
|
186
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
187
|
+
interaction: {
|
|
188
|
+
exclusive: false;
|
|
189
|
+
cursor: string;
|
|
190
|
+
isDraggable: true;
|
|
191
|
+
isResizable: true;
|
|
192
|
+
isRotatable: false;
|
|
193
|
+
isGroupDraggable: true;
|
|
194
|
+
isGroupResizable: false;
|
|
195
|
+
isGroupRotatable: false;
|
|
196
|
+
};
|
|
197
|
+
defaults: {
|
|
198
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
199
|
+
fontFamily: PdfStandardFont.Helvetica;
|
|
200
|
+
fontSize: number;
|
|
201
|
+
fontColor: string;
|
|
202
|
+
strokeColor: string;
|
|
203
|
+
color: string;
|
|
204
|
+
strokeWidth: number;
|
|
205
|
+
field: {
|
|
206
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
207
|
+
name: string;
|
|
208
|
+
alternateName: string;
|
|
209
|
+
value: string;
|
|
210
|
+
type: PDF_FORM_FIELD_TYPE.LISTBOX;
|
|
211
|
+
options: ({
|
|
212
|
+
label: string;
|
|
213
|
+
isSelected: true;
|
|
214
|
+
} | {
|
|
215
|
+
label: string;
|
|
216
|
+
isSelected: false;
|
|
217
|
+
})[];
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
behavior: {
|
|
221
|
+
useAppearanceStream: false;
|
|
222
|
+
};
|
|
223
|
+
clickBehavior: {
|
|
224
|
+
enabled: true;
|
|
225
|
+
defaultSize: {
|
|
226
|
+
width: number;
|
|
227
|
+
height: number;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
231
|
+
};
|
|
232
|
+
export declare const formTools: ({
|
|
233
|
+
id: "formTextField";
|
|
234
|
+
name: string;
|
|
235
|
+
labelKey: string;
|
|
236
|
+
categories: string[];
|
|
237
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
238
|
+
interaction: {
|
|
239
|
+
exclusive: false;
|
|
240
|
+
cursor: string;
|
|
241
|
+
isDraggable: true;
|
|
242
|
+
isResizable: true;
|
|
243
|
+
isRotatable: false;
|
|
244
|
+
isGroupDraggable: true;
|
|
245
|
+
isGroupResizable: false;
|
|
246
|
+
isGroupRotatable: false;
|
|
247
|
+
};
|
|
248
|
+
defaults: {
|
|
249
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
250
|
+
fontFamily: PdfStandardFont.Helvetica;
|
|
251
|
+
fontSize: number;
|
|
252
|
+
fontColor: string;
|
|
253
|
+
strokeColor: string;
|
|
254
|
+
color: string;
|
|
255
|
+
strokeWidth: number;
|
|
256
|
+
field: {
|
|
257
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
258
|
+
name: string;
|
|
259
|
+
alternateName: string;
|
|
260
|
+
value: string;
|
|
261
|
+
type: PDF_FORM_FIELD_TYPE.TEXTFIELD;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
behavior: {
|
|
265
|
+
useAppearanceStream: false;
|
|
266
|
+
};
|
|
267
|
+
clickBehavior: {
|
|
268
|
+
enabled: true;
|
|
269
|
+
defaultSize: {
|
|
270
|
+
width: number;
|
|
271
|
+
height: number;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
275
|
+
} | {
|
|
276
|
+
id: "formCheckbox";
|
|
277
|
+
name: string;
|
|
278
|
+
labelKey: string;
|
|
279
|
+
categories: string[];
|
|
280
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
281
|
+
interaction: {
|
|
282
|
+
exclusive: false;
|
|
283
|
+
cursor: string;
|
|
284
|
+
isDraggable: true;
|
|
285
|
+
isResizable: true;
|
|
286
|
+
isRotatable: false;
|
|
287
|
+
isGroupDraggable: true;
|
|
288
|
+
isGroupResizable: false;
|
|
289
|
+
isGroupRotatable: false;
|
|
290
|
+
};
|
|
291
|
+
defaults: {
|
|
292
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
293
|
+
strokeColor: string;
|
|
294
|
+
color: string;
|
|
295
|
+
strokeWidth: number;
|
|
296
|
+
field: {
|
|
297
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
298
|
+
name: string;
|
|
299
|
+
alternateName: string;
|
|
300
|
+
value: string;
|
|
301
|
+
type: PDF_FORM_FIELD_TYPE.CHECKBOX;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
behavior: {
|
|
305
|
+
useAppearanceStream: false;
|
|
306
|
+
};
|
|
307
|
+
clickBehavior: {
|
|
308
|
+
enabled: true;
|
|
309
|
+
defaultSize: {
|
|
310
|
+
width: number;
|
|
311
|
+
height: number;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
315
|
+
} | {
|
|
316
|
+
id: "formRadioButton";
|
|
317
|
+
name: string;
|
|
318
|
+
labelKey: string;
|
|
319
|
+
categories: string[];
|
|
320
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
321
|
+
interaction: {
|
|
322
|
+
exclusive: false;
|
|
323
|
+
cursor: string;
|
|
324
|
+
isDraggable: true;
|
|
325
|
+
isResizable: true;
|
|
326
|
+
isRotatable: false;
|
|
327
|
+
lockAspectRatio: true;
|
|
328
|
+
isGroupDraggable: true;
|
|
329
|
+
isGroupResizable: false;
|
|
330
|
+
isGroupRotatable: false;
|
|
331
|
+
};
|
|
332
|
+
defaults: {
|
|
333
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
334
|
+
strokeColor: string;
|
|
335
|
+
color: string;
|
|
336
|
+
strokeWidth: number;
|
|
337
|
+
field: {
|
|
338
|
+
flag: number;
|
|
339
|
+
name: string;
|
|
340
|
+
alternateName: string;
|
|
341
|
+
value: string;
|
|
342
|
+
type: PDF_FORM_FIELD_TYPE.RADIOBUTTON;
|
|
343
|
+
options: never[];
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
behavior: {
|
|
347
|
+
useAppearanceStream: false;
|
|
348
|
+
};
|
|
349
|
+
clickBehavior: {
|
|
350
|
+
enabled: true;
|
|
351
|
+
defaultSize: {
|
|
352
|
+
width: number;
|
|
353
|
+
height: number;
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
357
|
+
} | {
|
|
358
|
+
id: "formCombobox";
|
|
359
|
+
name: string;
|
|
360
|
+
labelKey: string;
|
|
361
|
+
categories: string[];
|
|
362
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
363
|
+
interaction: {
|
|
364
|
+
exclusive: false;
|
|
365
|
+
cursor: string;
|
|
366
|
+
isDraggable: true;
|
|
367
|
+
isResizable: true;
|
|
368
|
+
isRotatable: false;
|
|
369
|
+
isGroupDraggable: true;
|
|
370
|
+
isGroupResizable: false;
|
|
371
|
+
isGroupRotatable: false;
|
|
372
|
+
};
|
|
373
|
+
defaults: {
|
|
374
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
375
|
+
fontFamily: PdfStandardFont.Helvetica;
|
|
376
|
+
fontSize: number;
|
|
377
|
+
fontColor: string;
|
|
378
|
+
strokeColor: string;
|
|
379
|
+
color: string;
|
|
380
|
+
strokeWidth: number;
|
|
381
|
+
field: {
|
|
382
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
383
|
+
name: string;
|
|
384
|
+
alternateName: string;
|
|
385
|
+
value: string;
|
|
386
|
+
type: PDF_FORM_FIELD_TYPE.COMBOBOX;
|
|
387
|
+
options: ({
|
|
388
|
+
label: string;
|
|
389
|
+
isSelected: true;
|
|
390
|
+
} | {
|
|
391
|
+
label: string;
|
|
392
|
+
isSelected: false;
|
|
393
|
+
})[];
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
behavior: {
|
|
397
|
+
useAppearanceStream: false;
|
|
398
|
+
};
|
|
399
|
+
clickBehavior: {
|
|
400
|
+
enabled: true;
|
|
401
|
+
defaultSize: {
|
|
402
|
+
width: number;
|
|
403
|
+
height: number;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
407
|
+
} | {
|
|
408
|
+
id: "formListbox";
|
|
409
|
+
name: string;
|
|
410
|
+
labelKey: string;
|
|
411
|
+
categories: string[];
|
|
412
|
+
matchScore: (a: PdfAnnotationObject) => 0 | 10;
|
|
413
|
+
interaction: {
|
|
414
|
+
exclusive: false;
|
|
415
|
+
cursor: string;
|
|
416
|
+
isDraggable: true;
|
|
417
|
+
isResizable: true;
|
|
418
|
+
isRotatable: false;
|
|
419
|
+
isGroupDraggable: true;
|
|
420
|
+
isGroupResizable: false;
|
|
421
|
+
isGroupRotatable: false;
|
|
422
|
+
};
|
|
423
|
+
defaults: {
|
|
424
|
+
type: PdfAnnotationSubtype.WIDGET;
|
|
425
|
+
fontFamily: PdfStandardFont.Helvetica;
|
|
426
|
+
fontSize: number;
|
|
427
|
+
fontColor: string;
|
|
428
|
+
strokeColor: string;
|
|
429
|
+
color: string;
|
|
430
|
+
strokeWidth: number;
|
|
431
|
+
field: {
|
|
432
|
+
flag: PDF_FORM_FIELD_FLAG.NONE;
|
|
433
|
+
name: string;
|
|
434
|
+
alternateName: string;
|
|
435
|
+
value: string;
|
|
436
|
+
type: PDF_FORM_FIELD_TYPE.LISTBOX;
|
|
437
|
+
options: ({
|
|
438
|
+
label: string;
|
|
439
|
+
isSelected: true;
|
|
440
|
+
} | {
|
|
441
|
+
label: string;
|
|
442
|
+
isSelected: false;
|
|
443
|
+
})[];
|
|
444
|
+
};
|
|
445
|
+
};
|
|
446
|
+
behavior: {
|
|
447
|
+
useAppearanceStream: false;
|
|
448
|
+
};
|
|
449
|
+
clickBehavior: {
|
|
450
|
+
enabled: true;
|
|
451
|
+
defaultSize: {
|
|
452
|
+
width: number;
|
|
453
|
+
height: number;
|
|
454
|
+
};
|
|
455
|
+
};
|
|
456
|
+
pointerHandler: import('@embedpdf/plugin-annotation').HandlerFactory<PdfWidgetAnnoObject>;
|
|
457
|
+
})[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { BasePluginConfig, EventHook } from '@embedpdf/core';
|
|
2
|
+
import { PDF_FORM_FIELD_TYPE, PdfErrorReason, PdfRenderPageAnnotationOptions, PdfTask, PdfWidgetAnnoField, PdfWidgetAnnoObject, PdfWidgetAnnoOption, Task } from '@embedpdf/models';
|
|
3
|
+
export interface FormPluginConfig extends BasePluginConfig {
|
|
4
|
+
}
|
|
5
|
+
export interface FieldGroupEntry {
|
|
6
|
+
annotationId: string;
|
|
7
|
+
pageIndex: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RenderWidgetOptions {
|
|
10
|
+
pageIndex: number;
|
|
11
|
+
annotation: PdfWidgetAnnoObject;
|
|
12
|
+
options?: PdfRenderPageAnnotationOptions;
|
|
13
|
+
}
|
|
14
|
+
export interface FormDocumentState {
|
|
15
|
+
selectedFieldId: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface FormState {
|
|
18
|
+
documents: Record<string, FormDocumentState>;
|
|
19
|
+
}
|
|
20
|
+
export interface FormStateChangeEvent {
|
|
21
|
+
documentId: string;
|
|
22
|
+
state: FormDocumentState;
|
|
23
|
+
}
|
|
24
|
+
export interface FieldValueChangeEvent {
|
|
25
|
+
documentId: string;
|
|
26
|
+
pageIndex: number;
|
|
27
|
+
annotationId: string;
|
|
28
|
+
widget: PdfWidgetAnnoObject;
|
|
29
|
+
}
|
|
30
|
+
export type RenameFieldResult = {
|
|
31
|
+
outcome: 'renamed';
|
|
32
|
+
} | {
|
|
33
|
+
outcome: 'no-op';
|
|
34
|
+
} | {
|
|
35
|
+
outcome: 'conflict';
|
|
36
|
+
targetAnnotationId: string;
|
|
37
|
+
fieldName: string;
|
|
38
|
+
};
|
|
39
|
+
export interface FormFieldInfo {
|
|
40
|
+
name: string;
|
|
41
|
+
type: PDF_FORM_FIELD_TYPE;
|
|
42
|
+
value: string;
|
|
43
|
+
readOnly: boolean;
|
|
44
|
+
options?: PdfWidgetAnnoOption[];
|
|
45
|
+
}
|
|
46
|
+
export interface FormReadyEvent {
|
|
47
|
+
documentId: string;
|
|
48
|
+
fields: FormFieldInfo[];
|
|
49
|
+
}
|
|
50
|
+
export interface FormScope {
|
|
51
|
+
getPageFormAnnoWidgets(pageIndex: number): PdfTask<PdfWidgetAnnoObject[]>;
|
|
52
|
+
setFormFieldValues(pageIndex: number, annotation: PdfWidgetAnnoObject, newField: PdfWidgetAnnoField): PdfTask<boolean>;
|
|
53
|
+
renameField(annotationId: string, name: string): PdfTask<RenameFieldResult>;
|
|
54
|
+
shareField(annotationId: string, targetAnnotationId: string): PdfTask<boolean>;
|
|
55
|
+
renderWidget(options: RenderWidgetOptions): Task<Blob, PdfErrorReason>;
|
|
56
|
+
selectField(annotationId: string): void;
|
|
57
|
+
deselectField(): void;
|
|
58
|
+
getSelectedFieldId(): string | null;
|
|
59
|
+
selectNextField(): void;
|
|
60
|
+
selectPreviousField(): void;
|
|
61
|
+
activateField(): void;
|
|
62
|
+
getState(): FormDocumentState;
|
|
63
|
+
/** Get all widget entries sharing the same logical field (including the given annotation) */
|
|
64
|
+
getFieldGroup(annotationId: string): FieldGroupEntry[];
|
|
65
|
+
/** Get sibling widget entries sharing the same logical field (excluding the given annotation) */
|
|
66
|
+
getFieldSiblings(annotationId: string): FieldGroupEntry[];
|
|
67
|
+
getFormValues(): Record<string, string>;
|
|
68
|
+
getFormFields(): FormFieldInfo[];
|
|
69
|
+
setFormValues(values: Record<string, string>): PdfTask<boolean>;
|
|
70
|
+
onStateChange: EventHook<FormDocumentState>;
|
|
71
|
+
onFieldValueChange: EventHook<FieldValueChangeEvent>;
|
|
72
|
+
onFormReady: EventHook<FormFieldInfo[]>;
|
|
73
|
+
}
|
|
74
|
+
export interface FormCapability {
|
|
75
|
+
getPageFormAnnoWidgets(pageIndex: number, documentId?: string): PdfTask<PdfWidgetAnnoObject[]>;
|
|
76
|
+
setFormFieldValues(pageIndex: number, annotation: PdfWidgetAnnoObject, newField: PdfWidgetAnnoField, documentId?: string): PdfTask<boolean>;
|
|
77
|
+
renameField(annotationId: string, name: string, documentId?: string): PdfTask<RenameFieldResult>;
|
|
78
|
+
shareField(annotationId: string, targetAnnotationId: string, documentId?: string): PdfTask<boolean>;
|
|
79
|
+
renderWidget(options: RenderWidgetOptions, documentId?: string): Task<Blob, PdfErrorReason>;
|
|
80
|
+
selectField(annotationId: string, documentId?: string): void;
|
|
81
|
+
deselectField(documentId?: string): void;
|
|
82
|
+
getSelectedFieldId(documentId?: string): string | null;
|
|
83
|
+
selectNextField(documentId?: string): void;
|
|
84
|
+
selectPreviousField(documentId?: string): void;
|
|
85
|
+
activateField(documentId?: string): void;
|
|
86
|
+
getState(documentId?: string): FormDocumentState;
|
|
87
|
+
/** Get all widget entries sharing the same logical field (including the given annotation) */
|
|
88
|
+
getFieldGroup(annotationId: string, documentId?: string): FieldGroupEntry[];
|
|
89
|
+
/** Get sibling widget entries sharing the same logical field (excluding the given annotation) */
|
|
90
|
+
getFieldSiblings(annotationId: string, documentId?: string): FieldGroupEntry[];
|
|
91
|
+
getFormValues(documentId?: string): Record<string, string>;
|
|
92
|
+
getFormFields(documentId?: string): FormFieldInfo[];
|
|
93
|
+
setFormValues(values: Record<string, string>, documentId?: string): PdfTask<boolean>;
|
|
94
|
+
forDocument(documentId: string): FormScope;
|
|
95
|
+
onStateChange: EventHook<FormStateChangeEvent>;
|
|
96
|
+
onFieldValueChange: EventHook<FieldValueChangeEvent>;
|
|
97
|
+
onFormReady: EventHook<FormReadyEvent>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Fragment } from 'preact';
|
|
2
|
+
export { useEffect, useRef, useState, useCallback, useMemo } from 'preact/hooks';
|
|
3
|
+
export type { ComponentChildren as ReactNode } from 'preact';
|
|
4
|
+
export type CSSProperties = import('preact').JSX.CSSProperties;
|
|
5
|
+
export type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<T extends EventTarget ? T : never>;
|
|
6
|
+
export type FormEvent<T extends EventTarget = Element> = import('preact').JSX.TargetedEvent<T, Event>;
|
|
7
|
+
export type MouseEvent<T = Element> = import('preact').JSX.TargetedMouseEvent<T extends EventTarget ? T : never>;
|
|
8
|
+
export declare const selectProps: (isMultiple: boolean, selectedValues: string[]) => {
|
|
9
|
+
value: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const optionProps: (isMultiple: boolean, selectedValues: string[], optionValue: string) => {
|
|
12
|
+
selected: boolean | undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/plugin-annotation/preact';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@embedpdf/core/preact';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-form"),n=require("@embedpdf/plugin-annotation/preact"),o=require("preact/jsx-runtime"),i=require("@embedpdf/models"),r=require("preact"),l=require("preact/hooks"),s=require("@embedpdf/core/preact"),a=(e,t,n)=>({selected:e?t.includes(n):void 0});function d({annotation:e,isSelected:t,scale:n,onClick:r,style:s}){const[a,d]=l.useState(!1),{object:u}=e,p=u.field,f=p.type===i.PDF_FORM_FIELD_TYPE.TEXTFIELD,b=f?p.value:"",g=f&&!!(p.flag&i.PDF_FORM_FIELD_FLAG.TEXT_COMB)&&!!p.maxLen,x=f&&!!(p.flag&i.PDF_FORM_FIELD_FLAG.TEXT_MULTIPLINE),h=f?p.maxLen:void 0,F=(u.strokeWidth??1)*n,v={fontSize:(u.fontSize??12)*n,...i.standardFontCssProperties(u.fontFamily),color:u.fontColor??"#000000",lineHeight:1.2};return o.jsx("div",{onPointerDown:t?void 0:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{position:"absolute",inset:0,background:u.color??"rgba(255, 255, 255, 0.9)",border:`${F}px solid ${u.strokeColor??"rgba(0, 0, 0, 0.2)"}`,outline:a||t?"1px solid rgba(66, 133, 244, 0.5)":"none",outlineOffset:-1,boxSizing:"border-box",pointerEvents:"auto",cursor:t?"move":"pointer",display:"flex",alignItems:x?"flex-start":"center",overflow:"hidden",...g?{}:{padding:`${F}px ${F}px`},...s},children:g&&h?o.jsx(c,{value:b??"",maxLen:h,scale:n,width:u.rect.size.width,fontStyle:v,strokeColor:u.strokeColor??"rgba(0, 0, 0, 0.2)"}):o.jsx("span",{style:{...v,display:"block",width:"100%",whiteSpace:x?"pre-wrap":"nowrap",wordBreak:x?"break-word":"normal",overflowWrap:x?"break-word":"normal",overflow:"hidden",textOverflow:x?"clip":"ellipsis"},children:b})})}function c({value:e,maxLen:t,scale:n,width:i,fontStyle:r,strokeColor:l}){const s=i*n/t,a=e.split("");return o.jsx("div",{style:{position:"relative",width:"100%",height:"100%"},children:Array.from({length:t}).map((e,n)=>o.jsx("span",{style:{position:"absolute",top:0,left:n*s,width:s,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderRight:n<t-1?`1px solid ${l}`:"none",boxSizing:"border-box",...r},children:a[n]||""},n))})}function u({annotation:e,isSelected:t,scale:n,onClick:r,style:s}){const[a,d]=l.useState(!1),{object:c}=e,u=i.isWidgetChecked(c);return o.jsx("div",{onPointerDown:t?void 0:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{position:"absolute",inset:0,background:c.color??"#FFFFFF",border:`${(c.strokeWidth??1)*n}px solid ${c.strokeColor??"#000000"}`,outline:a||t?"1px solid rgba(66, 133, 244, 0.5)":"none",outlineOffset:-1,boxSizing:"border-box",pointerEvents:"auto",cursor:t?"move":"pointer",display:"flex",alignItems:"center",justifyContent:"center",...s},children:u&&o.jsx("svg",{viewBox:"0 0 100 100",style:{width:"100%",height:"100%"},children:o.jsx("path",{d:"M28 48C27.45 50.21 29.45 63.13 30 67C30.55 69.21 34.58 72 39 72C44.52 71.45 76.55 32.55 76 32C77.1 31.45 76 25 76 25C74.34 22.24 68 25.45 68 26C68 26 43.55 53 43 53C41.34 53 40.55 41.1 40 40C33.37 36.69 29.1 45.79 28 48Z",fill:"#000000"})})})}function p({annotation:e,isSelected:t,scale:n,onClick:r,style:s}){const[a,d]=l.useState(!1),{object:c}=e,u=i.isWidgetChecked(c);return o.jsx("div",{onPointerDown:t?void 0:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{position:"absolute",inset:0,background:c.color??"#FFFFFF",border:`${(c.strokeWidth??1)*n}px solid ${c.strokeColor??"#000000"}`,borderRadius:"50%",outline:a||t?"1px solid rgba(66, 133, 244, 0.5)":"none",outlineOffset:-1,boxSizing:"border-box",pointerEvents:"auto",cursor:t?"move":"pointer",display:"flex",alignItems:"center",justifyContent:"center",...s},children:u&&o.jsx("div",{style:{width:"50%",height:"50%",borderRadius:"50%",background:"#000000"}})})}function f({annotation:e,isSelected:t,scale:n,onClick:r,style:s}){var a;const[d,c]=l.useState(!1),{object:u}=e,p=u.field,f=(null==(a=(p.type===i.PDF_FORM_FIELD_TYPE.COMBOBOX?p.options:[]).find(e=>e.isSelected))?void 0:a.label)??"",b=(u.strokeWidth??1)*n,g=(u.fontSize??12)*n;return o.jsxs("div",{onPointerDown:t?void 0:r,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{position:"absolute",inset:0,background:u.color??"#FFFFFF",border:`${b}px solid ${u.strokeColor??"#000000"}`,outline:d||t?"1px solid rgba(66, 133, 244, 0.5)":"none",outlineOffset:-1,boxSizing:"border-box",pointerEvents:"auto",cursor:t?"move":"pointer",display:"flex",alignItems:"center",overflow:"hidden",...s},children:[o.jsx("span",{style:{flex:1,padding:`0 ${4*n}px`,fontSize:g,...i.standardFontCssProperties(u.fontFamily),color:u.fontColor??"#000000",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f}),o.jsx("div",{style:{width:13*n,minWidth:13*n,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",borderLeft:`1px solid ${u.strokeColor??"#000000"}`},children:o.jsx("svg",{viewBox:"0 0 10 6",style:{width:8*n,height:5*n},fill:"currentColor",children:o.jsx("path",{d:"M0 0 L5 6 L10 0 Z"})})})]})}function b({annotation:e,isSelected:t,scale:n,onClick:r,style:s}){const[a,d]=l.useState(!1),{object:c}=e,u=c.field,p=u.type===i.PDF_FORM_FIELD_TYPE.LISTBOX?u.options:[],f=(c.strokeWidth??1)*n,b=(c.fontSize??12)*n,g=1.2*b;return o.jsx("div",{onPointerDown:t?void 0:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{position:"absolute",inset:0,background:c.color??"#FFFFFF",border:`${f}px solid ${c.strokeColor??"#000000"}`,outline:a||t?"1px solid rgba(66, 133, 244, 0.5)":"none",outlineOffset:-1,boxSizing:"border-box",pointerEvents:"auto",cursor:t?"move":"pointer",overflow:"hidden",display:"flex",flexDirection:"column",...s},children:p.map((e,t)=>o.jsx("div",{style:{padding:`0 ${4*n}px`,fontSize:b,lineHeight:`${g}px`,...i.standardFontCssProperties(c.fontFamily),color:e.isSelected?"#FFFFFF":c.fontColor??"#000000",background:e.isSelected?"rgba(0, 51, 113, 1)":"transparent",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label},t))})}const g=()=>s.useCapability(t.FormPlugin.id),x=e=>{var n;const{provides:o}=g(),[i,r]=l.useState((null==(n=null==o?void 0:o.forDocument(e))?void 0:n.getState())??{...t.initialDocumentState});return l.useEffect(()=>{if(!o)return;const t=o.forDocument(e);return r(t.getState()),t.onStateChange(e=>{r(e)})},[o,e]),i};function h(e){const{currentObject:t,scale:n,pageIndex:o}=e,r=t.field,{provides:s}=g(),[a,d]=l.useState(0),c=!!(r.flag&i.PDF_FORM_FIELD_FLAG.READONLY),u=l.useMemo(()=>null==s?void 0:s.forDocument(e.documentId),[s,e.documentId]);l.useEffect(()=>{if(u)return u.onFieldValueChange(e=>{e.annotationId===t.id&&d(e=>e+1)})},[u,t.id]);const p=l.useCallback(e=>{u&&u.setFormFieldValues(o,t,e)},[u,o,t]);return{annotation:t,field:r,scale:n,pageIndex:o,scope:u,handleChangeField:p,renderKey:a,isReadOnly:c}}function F({pageIndex:e,annotation:t,scaleFactor:n=1,renderKey:s=0,style:a,...d}){const{provides:c}=g(),[u,p]=l.useState(null),f=l.useRef(null),{width:b,height:x}=t.rect.size;return l.useEffect(()=>{if(!c)return;const o=c.renderWidget({pageIndex:e,annotation:t,options:{scaleFactor:n,dpr:window.devicePixelRatio}});return o.wait(e=>{const t=URL.createObjectURL(e);f.current&&URL.revokeObjectURL(f.current),f.current=t,p(t)},i.ignore),()=>{o.abort({code:i.PdfErrorCode.Cancelled,message:"canceled render task"})}},[e,n,c,t.id,b,x,s]),l.useEffect(()=>()=>{f.current&&(URL.revokeObjectURL(f.current),f.current=null)},[]),o.jsx(r.Fragment,{children:u&&o.jsx("img",{src:u,...d,style:{width:"100%",height:"100%",display:"block",...a||{}}})})}const v={position:"absolute",top:0,left:0,padding:0,margin:0,width:"100%",height:"100%",borderRadius:0,outline:"none",boxSizing:"border-box"},y=v,C={...v,cursor:"inherit"},m={...v,resize:"none",lineHeight:1.14},E={position:"relative",width:"100%",height:"100%",borderRadius:0,boxSizing:"border-box"},k={position:"absolute",top:0,left:0,width:"100%",height:"100%",opacity:0,padding:0,margin:0,border:"none",zIndex:1},I={position:"absolute",top:0,height:"100%",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},S={position:"absolute",top:"15%",height:"70%",width:1,backgroundColor:"black",pointerEvents:"none"};function w(e){const{inputRef:t,required:n,disabled:i,password:r,name:s,value:a,maxLen:d,cellWidth:c,chars:u,caretIndex:p,containerStyle:f,cellFontStyle:b,onFocus:g,onChange:x,onBlur:h}=e,[F,v]=l.useState(!0);l.useEffect(()=>{v(!0);const e=setInterval(()=>v(e=>!e),530);return()=>clearInterval(e)},[p]);const y=p<d;return o.jsxs("div",{style:f,children:[o.jsx("input",{ref:t,required:n,disabled:i,type:r?"password":"text",name:s,"aria-label":s,value:a,maxLength:d,onFocus:g,onChange:x,onBlur:h,style:k}),Array.from({length:d}).map((e,t)=>o.jsx("span",{style:{...I,...b,left:t*c,width:c},children:u[t]||""},t)),y&&o.jsx("span",{style:{...S,left:p*c+c/2,opacity:F?1:0}})]})}function R(e){const{annotation:t,isEditable:r,onChangeField:s,onFocus:a,onBlur:d,inputRef:c,scale:u,syncExternalValue:p=!0}=e,f=t.field,{flag:b}=f,g=f.name,x=f.value,[h,F]=l.useState(x);l.useEffect(()=>{p&&F(x)},[x,p]);const v=l.useCallback(e=>{const t=e.target.value;F(t),null==s||s({...f,value:t})},[s,f]),C=(t.strokeWidth??0)*u,k=i.standardFontCssProperties(t.fontFamily),{adjustedFontPx:I,wrapperStyle:S}=n.useIOSZoomPrevention(t.fontSize*u,!0),R=l.useMemo(()=>({backgroundColor:t.color??"transparent",borderStyle:"solid",borderColor:t.strokeColor??"transparent",borderWidth:C,color:t.fontColor,...k,fontSize:I,padding:`${C}px ${C}px`}),[t.color,t.strokeColor,t.fontColor,I,C,k]),j=!r||!!(b&i.PDF_FORM_FIELD_FLAG.READONLY),D=!!(b&i.PDF_FORM_FIELD_FLAG.REQUIRED),L=!!(b&i.PDF_FORM_FIELD_FLAG.TEXT_PASSWORD),O=!!(b&i.PDF_FORM_FIELD_FLAG.TEXT_MULTIPLINE),P=!!(b&i.PDF_FORM_FIELD_FLAG.TEXT_COMB),_=f.maxLen;if(P&&_){const e=t.rect.size.width*u/_,n=(h||"").split(""),i=n.length,r={...E,backgroundColor:t.color??"transparent",borderStyle:"solid",borderColor:t.strokeColor??"transparent",borderWidth:C},l={color:t.fontColor,...k,fontSize:I},s=o.jsx(w,{inputRef:c,required:D,disabled:j,password:L,name:g,value:h,maxLen:_,cellWidth:e,chars:n,caretIndex:i,containerStyle:r,cellFontStyle:l,onFocus:a,onChange:v,onBlur:d});return S?o.jsx("div",{style:S,children:s}):s}const z=O?o.jsx("textarea",{ref:c,required:D,disabled:j,name:g,"aria-label":g,value:h,maxLength:_,onFocus:a,onChange:v,onBlur:d,style:{...m,...R}}):o.jsx("input",{ref:c,required:D,disabled:j,type:L?"password":"text",name:g,"aria-label":g,value:h,maxLength:_,onFocus:a,onChange:v,onBlur:d,style:{...y,...R}});return S?o.jsx("div",{style:S,children:z}):z}function j(e){const{annotation:t,scale:n,pageIndex:i,scope:r,handleChangeField:s,renderKey:a,isReadOnly:d}=h(e),c=x(e.documentId),[u,p]=l.useState(!1),f=l.useRef(null),b=c.selectedFieldId===t.id;l.useEffect(()=>{b&&f.current&&document.activeElement!==f.current&&f.current.focus()},[b]);const g=l.useCallback(()=>{d||(null==r||r.selectField(t.id),p(!0))},[d,r,t.id]),v=l.useCallback(()=>{p(!1),(null==r?void 0:r.getSelectedFieldId())===t.id&&(null==r||r.deselectField())},[r,t.id]),y=l.useCallback(e=>{f.current=e},[]);return o.jsxs("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"relative",pointerEvents:"auto",outline:"none"},children:[o.jsx(F,{pageIndex:i,annotation:t,scaleFactor:n,renderKey:a,style:{position:"absolute",inset:0,pointerEvents:"none",visibility:u?"hidden":"visible"}}),o.jsx("div",{style:{position:"absolute",inset:0,zIndex:1,opacity:u?1:0},children:o.jsx(R,{annotation:t,scale:n,pageIndex:i,isEditable:!0,onChangeField:s,syncExternalValue:!u,onFocus:g,onBlur:v,inputRef:y})})]})}function D(e){const{annotation:t,field:n,scale:r,pageIndex:s,scope:a,handleChangeField:d,renderKey:c,isReadOnly:u}=h(e),p=x(e.documentId),f=l.useRef(null),b=p.selectedFieldId===t.id;l.useEffect(()=>{b&&f.current&&document.activeElement!==f.current&&f.current.focus()},[b]);const g=l.useCallback(()=>{if(u)return;const e=i.isWidgetChecked(t)?"Off":t.exportValue??"Yes";d({...n,value:e})},[u,t,n,d]),v=l.useCallback(()=>{u||(null==a||a.selectField(t.id),g())},[u,a,t.id,g]),y=l.useCallback(()=>{u||null==a||a.selectField(t.id)},[u,a,t.id]),C=l.useCallback(()=>{(null==a?void 0:a.getSelectedFieldId())===t.id&&(null==a||a.deselectField())},[a,t.id]),m=l.useCallback(e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),g())},[g]);return o.jsx("div",{ref:f,tabIndex:u?-1:0,onClick:v,onFocus:y,onBlur:C,onKeyDown:m,style:{width:"100%",height:"100%",overflow:"hidden",cursor:u?"default":"pointer",pointerEvents:"auto",outline:b?"2px solid rgba(66, 133, 244, 0.8)":"none",outlineOffset:-2},children:o.jsx(F,{pageIndex:s,annotation:t,scaleFactor:r,renderKey:c,style:{pointerEvents:"none"}})})}function L(e){const{annotation:t,field:n,scale:r,pageIndex:s,scope:a,handleChangeField:d,renderKey:c,isReadOnly:u}=h(e),p=x(e.documentId),f=l.useRef(null),b=p.selectedFieldId===t.id;l.useEffect(()=>{b&&f.current&&document.activeElement!==f.current&&f.current.focus()},[b]);const g=l.useCallback(()=>{u||!i.isWidgetChecked(t)&&t.exportValue&&d({...n,value:t.exportValue})},[u,t,n,d]),v=l.useCallback(()=>{u||(null==a||a.selectField(t.id),g())},[u,a,t.id,g]),y=l.useCallback(()=>{u||null==a||a.selectField(t.id)},[u,a,t.id]),C=l.useCallback(()=>{(null==a?void 0:a.getSelectedFieldId())===t.id&&(null==a||a.deselectField())},[a,t.id]),m=l.useCallback(e=>{" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),g())},[g]);return o.jsx("div",{ref:f,tabIndex:u?-1:0,onClick:v,onFocus:y,onBlur:C,onKeyDown:m,style:{width:"100%",height:"100%",overflow:"hidden",cursor:u?"default":"pointer",pointerEvents:"auto",outline:b?"2px solid rgba(66, 133, 244, 0.8)":"none",outlineOffset:-2},children:o.jsx(F,{pageIndex:s,annotation:t,scaleFactor:r,renderKey:c,style:{pointerEvents:"none"}})})}function O(e){const{annotation:t,isEditable:n,onChangeField:r,onBlur:s,inputRef:d}=e,c=t.field,{flag:u,options:p}=c,f=c.alternateName||c.name,b=!n||!!(u&i.PDF_FORM_FIELD_FLAG.READONLY),g=!!(u&i.PDF_FORM_FIELD_FLAG.REQUIRED),x=l.useCallback(e=>{const t=e.target,n=p.map((e,n)=>({...e,isSelected:n===t.selectedIndex}));null==r||r({...c,options:n})},[r,c,p]),h=p.filter(e=>e.isSelected).map(e=>e.label);return o.jsx("select",{ref:d,required:g,disabled:b,name:f,"aria-label":f,...(F=!1,v=h,{value:F?void 0:v[0]||""}),onChange:x,onBlur:s,style:{...C,opacity:0},children:p.map((e,t)=>o.jsx("option",{value:e.label,...a(!1,h,e.label),children:e.label},t))});var F,v}function P(e){const{annotation:t,scale:n,pageIndex:i,scope:r,handleChangeField:s,renderKey:a,isReadOnly:d}=h(e),c=x(e.documentId),u=l.useRef(null),p=l.useRef(null),f=c.selectedFieldId===t.id;l.useEffect(()=>{f&&u.current&&!u.current.contains(document.activeElement)&&(p.current??u.current).focus()},[f]);const b=l.useCallback(()=>{null==r||r.selectField(t.id)},[r,t.id]),g=l.useCallback(()=>{requestAnimationFrame(()=>{var e;(null==(e=u.current)?void 0:e.contains(document.activeElement))||(null==r?void 0:r.getSelectedFieldId())===t.id&&(null==r||r.deselectField())})},[r,t.id]),v=l.useCallback(e=>{p.current=e},[]);return o.jsxs("div",{ref:u,onFocus:b,onBlur:g,style:{width:"100%",height:"100%",overflow:"hidden",cursor:d?"default":"pointer",pointerEvents:"auto",outline:f?"2px solid rgba(66, 133, 244, 0.8)":"none",outlineOffset:-2},children:[o.jsx(F,{pageIndex:i,annotation:t,scaleFactor:n,renderKey:a,style:{pointerEvents:"none"}}),o.jsx(O,{annotation:t,scale:n,pageIndex:i,isEditable:!0,onChangeField:s,inputRef:v})]})}function _(e){const{annotation:t,isEditable:n,onChangeField:r,onBlur:s,inputRef:a,scale:d}=e,c=t.field,{flag:u,options:p}=c,f=!n||!!(u&i.PDF_FORM_FIELD_FLAG.READONLY),b=!!(u&i.PDF_FORM_FIELD_FLAG.CHOICE_MULTL_SELECT),g=(t.strokeWidth??0)*d,x=(t.fontSize??12)*d,h=1.2*x,F=i.standardFontCssProperties(t.fontFamily),v=l.useMemo(()=>({position:"absolute",top:0,left:0,width:"100%",height:"100%",background:t.color??"#FFFFFF",borderStyle:"solid",borderColor:t.strokeColor??"#000000",borderWidth:g,boxSizing:"border-box",overflow:"auto",display:"flex",flexDirection:"column",outline:"none"}),[t.color,t.strokeColor,g]),y=l.useCallback(e=>{if(f)return;const t=p.map((t,n)=>({...t,isSelected:b?n===e?!t.isSelected:t.isSelected:n===e}));null==r||r({...c,options:t})},[f,b,p,c,r]);return o.jsx("div",{ref:a,onBlur:s,style:v,children:p.map((e,n)=>o.jsx("div",{onClick:()=>y(n),style:{padding:`0 ${4*d}px`,fontSize:x,lineHeight:`${h}px`,...F,color:e.isSelected?"#FFFFFF":t.fontColor??"#000000",background:e.isSelected?"rgba(0, 51, 113, 1)":"transparent",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",cursor:f?"default":"pointer"},children:e.label},n))})}function z(e){const{annotation:t,scale:n,pageIndex:i,scope:r,handleChangeField:s,renderKey:a,isReadOnly:d}=h(e),c=x(e.documentId),[u,p]=l.useState(!1),f=l.useRef(null),b=c.selectedFieldId===t.id;l.useEffect(()=>{b&&f.current&&!f.current.contains(document.activeElement)&&f.current.focus()},[b]);const g=l.useCallback(()=>{d||(null==r||r.selectField(t.id),p(!0))},[d,r,t.id]),v=l.useCallback(()=>{requestAnimationFrame(()=>{var e;(null==(e=f.current)?void 0:e.contains(document.activeElement))||(p(!1),(null==r?void 0:r.getSelectedFieldId())===t.id&&(null==r||r.deselectField()))})},[r,t.id]);return o.jsxs("div",{ref:f,tabIndex:d?-1:0,onFocus:g,onBlur:v,style:{width:"100%",height:"100%",overflow:"hidden",cursor:d?"default":"pointer",pointerEvents:"auto",outline:b&&!u?"2px solid rgba(66, 133, 244, 0.8)":"none",outlineOffset:-2},children:[o.jsx(_,{annotation:t,scale:n,pageIndex:i,isEditable:!0,onChangeField:s}),!u&&o.jsx(F,{pageIndex:i,annotation:t,scaleFactor:n,renderKey:a,style:{pointerEvents:"none"}})]})}const M=[n.createRenderer({id:"formTextField",matches:e=>{var t;return e.type===i.PdfAnnotationSubtype.WIDGET&&(null==(t=e.field)?void 0:t.type)===i.PDF_FORM_FIELD_TYPE.TEXTFIELD},render:({annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r})=>o.jsx(d,{annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r}),renderPreview:({bounds:e,scale:t})=>o.jsx("div",{style:{position:"absolute",left:0,top:0,width:e.size.width*t,height:e.size.height*t,border:"1px dashed rgba(66, 133, 244, 0.6)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxSizing:"border-box",display:"flex",alignItems:"center",padding:`0 ${2*t}px`,overflow:"hidden"}}),interactionDefaults:{isDraggable:!1,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,renderLocked:e=>o.jsx(j,{...e})}),n.createRenderer({id:"formCheckbox",matches:e=>{var t;return e.type===i.PdfAnnotationSubtype.WIDGET&&(null==(t=e.field)?void 0:t.type)===i.PDF_FORM_FIELD_TYPE.CHECKBOX},render:({annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r})=>o.jsx(u,{annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r}),renderPreview:({bounds:e,scale:t})=>o.jsx("div",{style:{position:"absolute",left:0,top:0,width:e.size.width*t,height:e.size.height*t,border:"1px dashed rgba(66, 133, 244, 0.6)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}),interactionDefaults:{isDraggable:!1,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,renderLocked:e=>o.jsx(D,{...e})}),n.createRenderer({id:"formRadioButton",matches:e=>{var t;return e.type===i.PdfAnnotationSubtype.WIDGET&&(null==(t=e.field)?void 0:t.type)===i.PDF_FORM_FIELD_TYPE.RADIOBUTTON},render:({annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r})=>o.jsx(p,{annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r}),renderPreview:({bounds:e,scale:t})=>o.jsx("div",{style:{position:"absolute",left:0,top:0,width:e.size.width*t,height:e.size.height*t,border:"1px dashed rgba(66, 133, 244, 0.6)",backgroundColor:"rgba(255, 255, 255, 0.9)",borderRadius:"50%",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}),interactionDefaults:{isDraggable:!1,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,renderLocked:e=>o.jsx(L,{...e})}),n.createRenderer({id:"formCombobox",matches:e=>{var t;return e.type===i.PdfAnnotationSubtype.WIDGET&&(null==(t=e.field)?void 0:t.type)===i.PDF_FORM_FIELD_TYPE.COMBOBOX},render:({annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r})=>o.jsx(f,{annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r}),renderPreview:({bounds:e,scale:t})=>o.jsx("div",{style:{position:"absolute",left:0,top:0,width:e.size.width*t,height:e.size.height*t,border:"1px dashed rgba(66, 133, 244, 0.6)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxSizing:"border-box",display:"flex",alignItems:"center",padding:`0 ${2*t}px`,overflow:"hidden"}}),interactionDefaults:{isDraggable:!1,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,renderLocked:e=>o.jsx(P,{...e})}),n.createRenderer({id:"formListbox",matches:e=>{var t;return e.type===i.PdfAnnotationSubtype.WIDGET&&(null==(t=e.field)?void 0:t.type)===i.PDF_FORM_FIELD_TYPE.LISTBOX},render:({annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r})=>o.jsx(b,{annotation:e,isSelected:t,scale:n,pageIndex:i,onClick:r}),renderPreview:({bounds:e,scale:t})=>o.jsx("div",{style:{position:"absolute",left:0,top:0,width:e.size.width*t,height:e.size.height*t,border:"1px dashed rgba(66, 133, 244, 0.6)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxSizing:"border-box",display:"flex",flexDirection:"column",overflow:"hidden"}}),interactionDefaults:{isDraggable:!1,isResizable:!0,isRotatable:!1},useAppearanceStream:!1,renderLocked:e=>o.jsx(z,{...e})})];function T(){return n.useRegisterRenderers(M),null}const A=e.createPluginPackage(t.FormPluginPackage).addUtility(T).build();exports.FormPluginPackage=A,exports.FormRendererRegistration=T,exports.formRenderers=M,exports.useFormCapability=g,exports.useFormDocumentState=x,exports.useFormPlugin=()=>s.usePlugin(t.FormPlugin.id),Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|