@embedpdf/plugin-form 2.15.0 → 3.0.0-next.1

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 (175) hide show
  1. package/LICENSE +192 -21
  2. package/dist/index.cjs +1416 -2
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +277 -0
  5. package/dist/index.d.ts +277 -1
  6. package/dist/index.js +1398 -1779
  7. package/dist/index.js.map +1 -1
  8. package/package.json +24 -61
  9. package/dist/lib/actions.d.ts +0 -33
  10. package/dist/lib/form-plugin.d.ts +0 -59
  11. package/dist/lib/handlers/checkbox.handler.d.ts +0 -3
  12. package/dist/lib/handlers/combobox.handler.d.ts +0 -3
  13. package/dist/lib/handlers/index.d.ts +0 -5
  14. package/dist/lib/handlers/listbox.handler.d.ts +0 -3
  15. package/dist/lib/handlers/radio-button.handler.d.ts +0 -3
  16. package/dist/lib/handlers/text-field.handler.d.ts +0 -3
  17. package/dist/lib/index.d.ts +0 -10
  18. package/dist/lib/manifest.d.ts +0 -4
  19. package/dist/lib/reducer.d.ts +0 -6
  20. package/dist/lib/tools.d.ts +0 -457
  21. package/dist/lib/types.d.ts +0 -98
  22. package/dist/preact/adapter.d.ts +0 -13
  23. package/dist/preact/annotation.d.ts +0 -1
  24. package/dist/preact/core.d.ts +0 -1
  25. package/dist/preact/index.cjs +0 -2
  26. package/dist/preact/index.cjs.map +0 -1
  27. package/dist/preact/index.d.ts +0 -1
  28. package/dist/preact/index.js +0 -1359
  29. package/dist/preact/index.js.map +0 -1
  30. package/dist/react/adapter.d.ts +0 -6
  31. package/dist/react/annotation.d.ts +0 -1
  32. package/dist/react/core.d.ts +0 -1
  33. package/dist/react/index.cjs +0 -2
  34. package/dist/react/index.cjs.map +0 -1
  35. package/dist/react/index.d.ts +0 -1
  36. package/dist/react/index.js +0 -1358
  37. package/dist/react/index.js.map +0 -1
  38. package/dist/shared/components/annotations/form-checkbox.d.ts +0 -12
  39. package/dist/shared/components/annotations/form-combobox.d.ts +0 -12
  40. package/dist/shared/components/annotations/form-listbox.d.ts +0 -12
  41. package/dist/shared/components/annotations/form-radio-button.d.ts +0 -12
  42. package/dist/shared/components/annotations/form-text-field.d.ts +0 -12
  43. package/dist/shared/components/fields/checkbox.d.ts +0 -2
  44. package/dist/shared/components/fields/combobox.d.ts +0 -2
  45. package/dist/shared/components/fields/listbox.d.ts +0 -2
  46. package/dist/shared/components/fields/push-button.d.ts +0 -2
  47. package/dist/shared/components/fields/radio-button.d.ts +0 -2
  48. package/dist/shared/components/fields/style.d.ts +0 -6
  49. package/dist/shared/components/fields/text.d.ts +0 -2
  50. package/dist/shared/components/fill-mode/combobox-fill-mode.d.ts +0 -3
  51. package/dist/shared/components/fill-mode/listbox-fill-mode.d.ts +0 -3
  52. package/dist/shared/components/fill-mode/push-button-fill-mode.d.ts +0 -3
  53. package/dist/shared/components/fill-mode/radio-button-fill-mode.d.ts +0 -3
  54. package/dist/shared/components/fill-mode/text-fill-mode.d.ts +0 -3
  55. package/dist/shared/components/fill-mode/toggle-fill-mode.d.ts +0 -3
  56. package/dist/shared/components/form-renderer-registration.d.ts +0 -5
  57. package/dist/shared/components/form-renderers.d.ts +0 -9
  58. package/dist/shared/components/index.d.ts +0 -2
  59. package/dist/shared/components/render-widget.d.ts +0 -12
  60. package/dist/shared/components/types.d.ts +0 -42
  61. package/dist/shared/hooks/index.d.ts +0 -1
  62. package/dist/shared/hooks/use-form-widget-state.d.ts +0 -12
  63. package/dist/shared/hooks/use-form.d.ts +0 -16
  64. package/dist/shared/index.d.ts +0 -4
  65. package/dist/shared-preact/components/annotations/form-checkbox.d.ts +0 -12
  66. package/dist/shared-preact/components/annotations/form-combobox.d.ts +0 -12
  67. package/dist/shared-preact/components/annotations/form-listbox.d.ts +0 -12
  68. package/dist/shared-preact/components/annotations/form-radio-button.d.ts +0 -12
  69. package/dist/shared-preact/components/annotations/form-text-field.d.ts +0 -12
  70. package/dist/shared-preact/components/fields/checkbox.d.ts +0 -2
  71. package/dist/shared-preact/components/fields/combobox.d.ts +0 -2
  72. package/dist/shared-preact/components/fields/listbox.d.ts +0 -2
  73. package/dist/shared-preact/components/fields/push-button.d.ts +0 -2
  74. package/dist/shared-preact/components/fields/radio-button.d.ts +0 -2
  75. package/dist/shared-preact/components/fields/style.d.ts +0 -6
  76. package/dist/shared-preact/components/fields/text.d.ts +0 -2
  77. package/dist/shared-preact/components/fill-mode/combobox-fill-mode.d.ts +0 -3
  78. package/dist/shared-preact/components/fill-mode/listbox-fill-mode.d.ts +0 -3
  79. package/dist/shared-preact/components/fill-mode/push-button-fill-mode.d.ts +0 -3
  80. package/dist/shared-preact/components/fill-mode/radio-button-fill-mode.d.ts +0 -3
  81. package/dist/shared-preact/components/fill-mode/text-fill-mode.d.ts +0 -3
  82. package/dist/shared-preact/components/fill-mode/toggle-fill-mode.d.ts +0 -3
  83. package/dist/shared-preact/components/form-renderer-registration.d.ts +0 -5
  84. package/dist/shared-preact/components/form-renderers.d.ts +0 -9
  85. package/dist/shared-preact/components/index.d.ts +0 -2
  86. package/dist/shared-preact/components/render-widget.d.ts +0 -12
  87. package/dist/shared-preact/components/types.d.ts +0 -42
  88. package/dist/shared-preact/hooks/index.d.ts +0 -1
  89. package/dist/shared-preact/hooks/use-form-widget-state.d.ts +0 -12
  90. package/dist/shared-preact/hooks/use-form.d.ts +0 -16
  91. package/dist/shared-preact/index.d.ts +0 -4
  92. package/dist/shared-react/components/annotations/form-checkbox.d.ts +0 -12
  93. package/dist/shared-react/components/annotations/form-combobox.d.ts +0 -12
  94. package/dist/shared-react/components/annotations/form-listbox.d.ts +0 -12
  95. package/dist/shared-react/components/annotations/form-radio-button.d.ts +0 -12
  96. package/dist/shared-react/components/annotations/form-text-field.d.ts +0 -12
  97. package/dist/shared-react/components/fields/checkbox.d.ts +0 -2
  98. package/dist/shared-react/components/fields/combobox.d.ts +0 -2
  99. package/dist/shared-react/components/fields/listbox.d.ts +0 -2
  100. package/dist/shared-react/components/fields/push-button.d.ts +0 -2
  101. package/dist/shared-react/components/fields/radio-button.d.ts +0 -2
  102. package/dist/shared-react/components/fields/style.d.ts +0 -6
  103. package/dist/shared-react/components/fields/text.d.ts +0 -2
  104. package/dist/shared-react/components/fill-mode/combobox-fill-mode.d.ts +0 -3
  105. package/dist/shared-react/components/fill-mode/listbox-fill-mode.d.ts +0 -3
  106. package/dist/shared-react/components/fill-mode/push-button-fill-mode.d.ts +0 -3
  107. package/dist/shared-react/components/fill-mode/radio-button-fill-mode.d.ts +0 -3
  108. package/dist/shared-react/components/fill-mode/text-fill-mode.d.ts +0 -3
  109. package/dist/shared-react/components/fill-mode/toggle-fill-mode.d.ts +0 -3
  110. package/dist/shared-react/components/form-renderer-registration.d.ts +0 -5
  111. package/dist/shared-react/components/form-renderers.d.ts +0 -9
  112. package/dist/shared-react/components/index.d.ts +0 -2
  113. package/dist/shared-react/components/render-widget.d.ts +0 -12
  114. package/dist/shared-react/components/types.d.ts +0 -42
  115. package/dist/shared-react/hooks/index.d.ts +0 -1
  116. package/dist/shared-react/hooks/use-form-widget-state.d.ts +0 -12
  117. package/dist/shared-react/hooks/use-form.d.ts +0 -16
  118. package/dist/shared-react/index.d.ts +0 -4
  119. package/dist/svelte/components/FormRendererRegistration.svelte.d.ts +0 -18
  120. package/dist/svelte/components/RenderWidget.svelte.d.ts +0 -11
  121. package/dist/svelte/components/annotations/FormCheckbox.svelte.d.ts +0 -5
  122. package/dist/svelte/components/annotations/FormCombobox.svelte.d.ts +0 -5
  123. package/dist/svelte/components/annotations/FormListbox.svelte.d.ts +0 -5
  124. package/dist/svelte/components/annotations/FormRadioButton.svelte.d.ts +0 -5
  125. package/dist/svelte/components/annotations/FormTextField.svelte.d.ts +0 -5
  126. package/dist/svelte/components/fields/ComboboxField.svelte.d.ts +0 -4
  127. package/dist/svelte/components/fields/ListboxField.svelte.d.ts +0 -4
  128. package/dist/svelte/components/fields/TextField.svelte.d.ts +0 -4
  129. package/dist/svelte/components/fill-mode/ComboboxFillMode.svelte.d.ts +0 -5
  130. package/dist/svelte/components/fill-mode/ListboxFillMode.svelte.d.ts +0 -5
  131. package/dist/svelte/components/fill-mode/RadioButtonFillMode.svelte.d.ts +0 -5
  132. package/dist/svelte/components/fill-mode/TextFillMode.svelte.d.ts +0 -5
  133. package/dist/svelte/components/fill-mode/ToggleFillMode.svelte.d.ts +0 -5
  134. package/dist/svelte/components/form-renderers.d.ts +0 -9
  135. package/dist/svelte/components/previews/CheckboxPreview.svelte.d.ts +0 -9
  136. package/dist/svelte/components/previews/ListboxPreview.svelte.d.ts +0 -9
  137. package/dist/svelte/components/previews/RadioButtonPreview.svelte.d.ts +0 -9
  138. package/dist/svelte/components/previews/TextFieldPreview.svelte.d.ts +0 -9
  139. package/dist/svelte/hooks/index.d.ts +0 -2
  140. package/dist/svelte/hooks/use-form-widget-state.svelte.d.ts +0 -12
  141. package/dist/svelte/hooks/use-form.svelte.d.ts +0 -14
  142. package/dist/svelte/index.cjs +0 -2
  143. package/dist/svelte/index.cjs.map +0 -1
  144. package/dist/svelte/index.d.ts +0 -3
  145. package/dist/svelte/index.js +0 -1592
  146. package/dist/svelte/index.js.map +0 -1
  147. package/dist/vue/components/annotations/form-checkbox.vue.d.ts +0 -6
  148. package/dist/vue/components/annotations/form-combobox.vue.d.ts +0 -6
  149. package/dist/vue/components/annotations/form-listbox.vue.d.ts +0 -6
  150. package/dist/vue/components/annotations/form-radio-button.vue.d.ts +0 -6
  151. package/dist/vue/components/annotations/form-text-field.vue.d.ts +0 -6
  152. package/dist/vue/components/fields/combobox-field.vue.d.ts +0 -4
  153. package/dist/vue/components/fields/listbox-field.vue.d.ts +0 -4
  154. package/dist/vue/components/fields/style.d.ts +0 -6
  155. package/dist/vue/components/fields/text-field.vue.d.ts +0 -4
  156. package/dist/vue/components/fill-mode/combobox-fill-mode.vue.d.ts +0 -6
  157. package/dist/vue/components/fill-mode/listbox-fill-mode.vue.d.ts +0 -6
  158. package/dist/vue/components/fill-mode/radio-button-fill-mode.vue.d.ts +0 -6
  159. package/dist/vue/components/fill-mode/text-fill-mode.vue.d.ts +0 -6
  160. package/dist/vue/components/fill-mode/toggle-fill-mode.vue.d.ts +0 -6
  161. package/dist/vue/components/form-renderer-registration.vue.d.ts +0 -13
  162. package/dist/vue/components/form-renderers.d.ts +0 -3
  163. package/dist/vue/components/previews/checkbox-preview.vue.d.ts +0 -10
  164. package/dist/vue/components/previews/listbox-preview.vue.d.ts +0 -10
  165. package/dist/vue/components/previews/radio-button-preview.vue.d.ts +0 -10
  166. package/dist/vue/components/previews/text-field-preview.vue.d.ts +0 -10
  167. package/dist/vue/components/render-widget.vue.d.ts +0 -15
  168. package/dist/vue/hooks/index.d.ts +0 -2
  169. package/dist/vue/hooks/use-form-widget-state.d.ts +0 -12
  170. package/dist/vue/hooks/use-form.d.ts +0 -12
  171. package/dist/vue/index.cjs +0 -2
  172. package/dist/vue/index.cjs.map +0 -1
  173. package/dist/vue/index.d.ts +0 -3
  174. package/dist/vue/index.js +0 -1643
  175. package/dist/vue/index.js.map +0 -1
@@ -1,1592 +0,0 @@
1
- import { createPluginPackage } from "@embedpdf/core";
2
- import { initialDocumentState, FormPlugin, FormPluginPackage as FormPluginPackage$1 } from "@embedpdf/plugin-form";
3
- export * from "@embedpdf/plugin-form";
4
- import "svelte/internal/disclose-version";
5
- import "svelte/internal/flags/legacy";
6
- import * as $ from "svelte/internal/client";
7
- import { onMount } from "svelte";
8
- import { useIOSZoomPrevention, createRenderer, getRendererRegistry } from "@embedpdf/plugin-annotation/svelte";
9
- import { PDF_FORM_FIELD_TYPE, PDF_FORM_FIELD_FLAG, standardFontCssProperties, isWidgetChecked, ignore, PdfErrorCode, PdfAnnotationSubtype } from "@embedpdf/models";
10
- import { deepToRaw } from "@embedpdf/utils/svelte";
11
- import { useCapability, usePlugin } from "@embedpdf/core/svelte";
12
- var root_2$1 = $.from_html(`<span> </span>`);
13
- var root_1$7 = $.from_html(`<div style="position: relative; width: 100%; height: 100%;"></div>`);
14
- var root_3$1 = $.from_html(`<span> </span>`);
15
- var root$f = $.from_html(`<div><!></div>`);
16
- function FormTextField($$anchor, $$props) {
17
- $.push($$props, true);
18
- let isHovered = $.state(false);
19
- const object = $.derived(() => $$props.currentObject);
20
- const field = $.derived(() => $.get(object).field);
21
- const isTextField = $.derived(() => $.get(field).type === PDF_FORM_FIELD_TYPE.TEXTFIELD);
22
- const value = $.derived(() => $.get(isTextField) ? $.get(field).value : "");
23
- const isComb = $.derived(() => $.get(isTextField) && !!($.get(field).flag & PDF_FORM_FIELD_FLAG.TEXT_COMB) && !!$.get(field).maxLen);
24
- const isMultiline = $.derived(() => $.get(isTextField) && !!($.get(field).flag & PDF_FORM_FIELD_FLAG.TEXT_MULTIPLINE));
25
- const maxLen = $.derived(() => $.get(isTextField) ? $.get(field).maxLen : void 0);
26
- const borderWidth = $.derived(() => ($.get(object).strokeWidth ?? 1) * $$props.scale);
27
- const fontCss = $.derived(() => standardFontCssProperties($.get(object).fontFamily));
28
- const fontSize = $.derived(() => ($.get(object).fontSize ?? 12) * $$props.scale);
29
- const fontColor = $.derived(() => $.get(object).fontColor ?? "#000000");
30
- const cellWidth = $.derived(() => $.get(isComb) && $.get(maxLen) ? $.get(object).rect.size.width * $$props.scale / $.get(maxLen) : 0);
31
- const chars = $.derived(() => ($.get(value) ?? "").split(""));
32
- var div = root$f();
33
- div.__pointerdown = (e) => {
34
- var _a;
35
- if (!$$props.isSelected) (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
36
- };
37
- let styles;
38
- var node = $.child(div);
39
- {
40
- var consequent = ($$anchor2) => {
41
- var div_1 = root_1$7();
42
- $.each(div_1, 21, () => Array.from({ length: $.get(maxLen) }), $.index, ($$anchor3, _, i) => {
43
- var span = root_2$1();
44
- let styles_1;
45
- var text = $.child(span, true);
46
- $.reset(span);
47
- $.template_effect(() => {
48
- styles_1 = $.set_style(span, "", styles_1, {
49
- position: "absolute",
50
- top: "0",
51
- left: `${i * $.get(cellWidth)}px`,
52
- width: `${$.get(cellWidth) ?? ""}px`,
53
- height: "100%",
54
- display: "flex",
55
- "align-items": "center",
56
- "justify-content": "center",
57
- "border-right": i < $.get(maxLen) - 1 ? `1px solid ${$.get(object).strokeColor ?? "rgba(0, 0, 0, 0.2)"}` : "none",
58
- "box-sizing": "border-box",
59
- "font-size": `${$.get(fontSize) ?? ""}px`,
60
- "font-family": $.get(fontCss).fontFamily,
61
- "font-weight": $.get(fontCss).fontWeight,
62
- "font-style": $.get(fontCss).fontStyle,
63
- color: $.get(fontColor),
64
- "line-height": "1.2"
65
- });
66
- $.set_text(text, $.get(chars)[i] || "");
67
- });
68
- $.append($$anchor3, span);
69
- });
70
- $.reset(div_1);
71
- $.append($$anchor2, div_1);
72
- };
73
- var alternate = ($$anchor2) => {
74
- var span_1 = root_3$1();
75
- let styles_2;
76
- var text_1 = $.child(span_1, true);
77
- $.reset(span_1);
78
- $.template_effect(() => {
79
- styles_2 = $.set_style(span_1, "", styles_2, {
80
- "font-size": `${$.get(fontSize) ?? ""}px`,
81
- "font-family": $.get(fontCss).fontFamily,
82
- "font-weight": $.get(fontCss).fontWeight,
83
- "font-style": $.get(fontCss).fontStyle,
84
- color: $.get(fontColor),
85
- "line-height": "1.2",
86
- display: "block",
87
- width: "100%",
88
- "white-space": $.get(isMultiline) ? "pre-wrap" : "nowrap",
89
- "word-break": $.get(isMultiline) ? "break-word" : "normal",
90
- "overflow-wrap": $.get(isMultiline) ? "break-word" : "normal",
91
- overflow: "hidden",
92
- "text-overflow": $.get(isMultiline) ? "clip" : "ellipsis"
93
- });
94
- $.set_text(text_1, $.get(value));
95
- });
96
- $.append($$anchor2, span_1);
97
- };
98
- $.if(node, ($$render) => {
99
- if ($.get(isComb) && $.get(maxLen)) $$render(consequent);
100
- else $$render(alternate, false);
101
- });
102
- }
103
- $.reset(div);
104
- $.template_effect(() => styles = $.set_style(div, "", styles, {
105
- position: "absolute",
106
- inset: "0",
107
- background: $.get(object).color ?? "rgba(255, 255, 255, 0.9)",
108
- border: `${$.get(borderWidth) ?? ""}px solid ${$.get(object).strokeColor ?? "rgba(0, 0, 0, 0.2)" ?? ""}`,
109
- outline: $.get(isHovered) || $$props.isSelected ? "1px solid rgba(66, 133, 244, 0.5)" : "none",
110
- "outline-offset": "-1px",
111
- "box-sizing": "border-box",
112
- "pointer-events": "auto",
113
- cursor: $$props.isSelected ? "move" : "pointer",
114
- display: "flex",
115
- "align-items": $.get(isMultiline) ? "flex-start" : "center",
116
- overflow: "hidden",
117
- padding: !$.get(isComb) ? `${$.get(borderWidth)}px ${$.get(borderWidth)}px` : void 0
118
- }));
119
- $.event("mouseenter", div, () => $.set(isHovered, true));
120
- $.event("mouseleave", div, () => $.set(isHovered, false));
121
- $.append($$anchor, div);
122
- $.pop();
123
- }
124
- $.delegate(["pointerdown"]);
125
- var root_1$6 = $.from_svg(`<svg viewBox="0 0 100 100" style="width: 100%; height: 100%;"><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"></path></svg>`);
126
- var root$e = $.from_html(`<div><!></div>`);
127
- function FormCheckbox($$anchor, $$props) {
128
- $.push($$props, true);
129
- let isHovered = $.state(false);
130
- const object = $.derived(() => $$props.currentObject);
131
- const isChecked = $.derived(() => isWidgetChecked($.get(object)));
132
- const borderWidth = $.derived(() => ($.get(object).strokeWidth ?? 1) * $$props.scale);
133
- var div = root$e();
134
- div.__pointerdown = (e) => {
135
- var _a;
136
- if (!$$props.isSelected) (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
137
- };
138
- let styles;
139
- var node = $.child(div);
140
- {
141
- var consequent = ($$anchor2) => {
142
- var svg = root_1$6();
143
- $.append($$anchor2, svg);
144
- };
145
- $.if(node, ($$render) => {
146
- if ($.get(isChecked)) $$render(consequent);
147
- });
148
- }
149
- $.reset(div);
150
- $.template_effect(() => styles = $.set_style(div, "", styles, {
151
- position: "absolute",
152
- inset: "0",
153
- background: $.get(object).color ?? "#FFFFFF",
154
- border: `${$.get(borderWidth) ?? ""}px solid ${$.get(object).strokeColor ?? "#000000" ?? ""}`,
155
- outline: $.get(isHovered) || $$props.isSelected ? "1px solid rgba(66, 133, 244, 0.5)" : "none",
156
- "outline-offset": "-1px",
157
- "box-sizing": "border-box",
158
- "pointer-events": "auto",
159
- cursor: $$props.isSelected ? "move" : "pointer",
160
- display: "flex",
161
- "align-items": "center",
162
- "justify-content": "center"
163
- }));
164
- $.event("mouseenter", div, () => $.set(isHovered, true));
165
- $.event("mouseleave", div, () => $.set(isHovered, false));
166
- $.append($$anchor, div);
167
- $.pop();
168
- }
169
- $.delegate(["pointerdown"]);
170
- var root_1$5 = $.from_html(`<div></div>`);
171
- var root$d = $.from_html(`<div><!></div>`);
172
- function FormRadioButton($$anchor, $$props) {
173
- $.push($$props, true);
174
- let isHovered = $.state(false);
175
- const object = $.derived(() => $$props.currentObject);
176
- const isChecked = $.derived(() => isWidgetChecked($.get(object)));
177
- const borderWidth = $.derived(() => ($.get(object).strokeWidth ?? 1) * $$props.scale);
178
- var div = root$d();
179
- div.__pointerdown = (e) => {
180
- var _a;
181
- if (!$$props.isSelected) (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
182
- };
183
- let styles;
184
- var node = $.child(div);
185
- {
186
- var consequent = ($$anchor2) => {
187
- var div_1 = root_1$5();
188
- $.set_style(div_1, "", {}, {
189
- width: "50%",
190
- height: "50%",
191
- "border-radius": "50%",
192
- background: "#000000"
193
- });
194
- $.append($$anchor2, div_1);
195
- };
196
- $.if(node, ($$render) => {
197
- if ($.get(isChecked)) $$render(consequent);
198
- });
199
- }
200
- $.reset(div);
201
- $.template_effect(() => styles = $.set_style(div, "", styles, {
202
- position: "absolute",
203
- inset: "0",
204
- background: $.get(object).color ?? "#FFFFFF",
205
- border: `${$.get(borderWidth) ?? ""}px solid ${$.get(object).strokeColor ?? "#000000" ?? ""}`,
206
- "border-radius": "50%",
207
- outline: $.get(isHovered) || $$props.isSelected ? "1px solid rgba(66, 133, 244, 0.5)" : "none",
208
- "outline-offset": "-1px",
209
- "box-sizing": "border-box",
210
- "pointer-events": "auto",
211
- cursor: $$props.isSelected ? "move" : "pointer",
212
- display: "flex",
213
- "align-items": "center",
214
- "justify-content": "center"
215
- }));
216
- $.event("mouseenter", div, () => $.set(isHovered, true));
217
- $.event("mouseleave", div, () => $.set(isHovered, false));
218
- $.append($$anchor, div);
219
- $.pop();
220
- }
221
- $.delegate(["pointerdown"]);
222
- var root$c = $.from_html(`<div><span> </span> <div><svg viewBox="0 0 10 6" fill="currentColor"><path d="M0 0 L5 6 L10 0 Z"></path></svg></div></div>`);
223
- function FormCombobox($$anchor, $$props) {
224
- $.push($$props, true);
225
- let isHovered = $.state(false);
226
- const object = $.derived(() => $$props.currentObject);
227
- const field = $.derived(() => $.get(object).field);
228
- const options = $.derived(() => $.get(field).type === PDF_FORM_FIELD_TYPE.COMBOBOX ? $.get(field).options : []);
229
- const selectedLabel = $.derived(() => {
230
- var _a;
231
- return ((_a = $.get(options).find((o) => o.isSelected)) == null ? void 0 : _a.label) ?? "";
232
- });
233
- const borderWidth = $.derived(() => ($.get(object).strokeWidth ?? 1) * $$props.scale);
234
- const fontSize = $.derived(() => ($.get(object).fontSize ?? 12) * $$props.scale);
235
- const fontCss = $.derived(() => standardFontCssProperties($.get(object).fontFamily));
236
- var div = root$c();
237
- div.__pointerdown = (e) => {
238
- var _a;
239
- if (!$$props.isSelected) (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
240
- };
241
- let styles;
242
- var span = $.child(div);
243
- let styles_1;
244
- var text = $.child(span, true);
245
- $.reset(span);
246
- var div_1 = $.sibling(span, 2);
247
- let styles_2;
248
- var svg = $.child(div_1);
249
- $.reset(div_1);
250
- $.reset(div);
251
- $.template_effect(() => {
252
- styles = $.set_style(div, "", styles, {
253
- position: "absolute",
254
- inset: "0",
255
- background: $.get(object).color ?? "#FFFFFF",
256
- border: `${$.get(borderWidth) ?? ""}px solid ${$.get(object).strokeColor ?? "#000000" ?? ""}`,
257
- outline: $.get(isHovered) || $$props.isSelected ? "1px solid rgba(66, 133, 244, 0.5)" : "none",
258
- "outline-offset": "-1px",
259
- "box-sizing": "border-box",
260
- "pointer-events": "auto",
261
- cursor: $$props.isSelected ? "move" : "pointer",
262
- display: "flex",
263
- "align-items": "center",
264
- overflow: "hidden"
265
- });
266
- styles_1 = $.set_style(span, "", styles_1, {
267
- flex: "1",
268
- padding: `0 ${4 * $$props.scale}px`,
269
- "font-size": `${$.get(fontSize) ?? ""}px`,
270
- "font-family": $.get(fontCss).fontFamily,
271
- "font-weight": $.get(fontCss).fontWeight,
272
- "font-style": $.get(fontCss).fontStyle,
273
- color: $.get(object).fontColor ?? "#000000",
274
- "white-space": "nowrap",
275
- overflow: "hidden",
276
- "text-overflow": "ellipsis"
277
- });
278
- $.set_text(text, $.get(selectedLabel));
279
- styles_2 = $.set_style(div_1, "", styles_2, {
280
- width: `${13 * $$props.scale}px`,
281
- "min-width": `${13 * $$props.scale}px`,
282
- height: "100%",
283
- display: "flex",
284
- "align-items": "center",
285
- "justify-content": "center",
286
- "border-left": `1px solid ${$.get(object).strokeColor ?? "#000000" ?? ""}`
287
- });
288
- $.set_style(svg, `width: ${8 * $$props.scale}px; height: ${5 * $$props.scale}px;`);
289
- });
290
- $.event("mouseenter", div, () => $.set(isHovered, true));
291
- $.event("mouseleave", div, () => $.set(isHovered, false));
292
- $.append($$anchor, div);
293
- $.pop();
294
- }
295
- $.delegate(["pointerdown"]);
296
- var root_1$4 = $.from_html(`<div> </div>`);
297
- var root$b = $.from_html(`<div></div>`);
298
- function FormListbox($$anchor, $$props) {
299
- $.push($$props, true);
300
- let isHovered = $.state(false);
301
- const object = $.derived(() => $$props.currentObject);
302
- const field = $.derived(() => $.get(object).field);
303
- const options = $.derived(() => $.get(field).type === PDF_FORM_FIELD_TYPE.LISTBOX ? $.get(field).options : []);
304
- const borderWidth = $.derived(() => ($.get(object).strokeWidth ?? 1) * $$props.scale);
305
- const fontSize = $.derived(() => ($.get(object).fontSize ?? 12) * $$props.scale);
306
- const lineHeight = $.derived(() => $.get(fontSize) * 1.2);
307
- const fontCss = $.derived(() => standardFontCssProperties($.get(object).fontFamily));
308
- var div = root$b();
309
- div.__pointerdown = (e) => {
310
- var _a;
311
- if (!$$props.isSelected) (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
312
- };
313
- let styles;
314
- $.each(div, 21, () => $.get(options), $.index, ($$anchor2, opt) => {
315
- var div_1 = root_1$4();
316
- let styles_1;
317
- var text = $.child(div_1, true);
318
- $.reset(div_1);
319
- $.template_effect(() => {
320
- styles_1 = $.set_style(div_1, "", styles_1, {
321
- padding: `0 ${4 * $$props.scale}px`,
322
- "font-size": `${$.get(fontSize) ?? ""}px`,
323
- "line-height": `${$.get(lineHeight) ?? ""}px`,
324
- "font-family": $.get(fontCss).fontFamily,
325
- "font-weight": $.get(fontCss).fontWeight,
326
- "font-style": $.get(fontCss).fontStyle,
327
- color: $.get(opt).isSelected ? "#FFFFFF" : $.get(object).fontColor ?? "#000000",
328
- background: $.get(opt).isSelected ? "rgba(0, 51, 113, 1)" : "transparent",
329
- "white-space": "nowrap",
330
- overflow: "hidden",
331
- "text-overflow": "ellipsis"
332
- });
333
- $.set_text(text, $.get(opt).label);
334
- });
335
- $.append($$anchor2, div_1);
336
- });
337
- $.reset(div);
338
- $.template_effect(() => styles = $.set_style(div, "", styles, {
339
- position: "absolute",
340
- inset: "0",
341
- background: $.get(object).color ?? "#FFFFFF",
342
- border: `${$.get(borderWidth) ?? ""}px solid ${$.get(object).strokeColor ?? "#000000" ?? ""}`,
343
- outline: $.get(isHovered) || $$props.isSelected ? "1px solid rgba(66, 133, 244, 0.5)" : "none",
344
- "outline-offset": "-1px",
345
- "box-sizing": "border-box",
346
- "pointer-events": "auto",
347
- cursor: $$props.isSelected ? "move" : "pointer",
348
- overflow: "hidden",
349
- display: "flex",
350
- "flex-direction": "column"
351
- }));
352
- $.event("mouseenter", div, () => $.set(isHovered, true));
353
- $.event("mouseleave", div, () => $.set(isHovered, false));
354
- $.append($$anchor, div);
355
- $.pop();
356
- }
357
- $.delegate(["pointerdown"]);
358
- const useFormPlugin = () => usePlugin(FormPlugin.id);
359
- const useFormCapability = () => useCapability(FormPlugin.id);
360
- const useFormDocumentState = (getDocumentId) => {
361
- const formCapability = useFormCapability();
362
- let state = $.state($.proxy({ ...initialDocumentState }));
363
- const documentId = $.derived(getDocumentId);
364
- $.user_effect(() => {
365
- if (!formCapability.provides || !$.get(documentId)) {
366
- $.set(state, { ...initialDocumentState }, true);
367
- return;
368
- }
369
- const scope = formCapability.provides.forDocument($.get(documentId));
370
- $.set(state, scope.getState(), true);
371
- return scope.onStateChange((newState) => {
372
- $.set(state, newState, true);
373
- });
374
- });
375
- return {
376
- get state() {
377
- return $.get(state);
378
- }
379
- };
380
- };
381
- function useFormWidgetState(props) {
382
- const formCapability = useFormCapability();
383
- let renderKey = $.state(0);
384
- const scope = $.derived(() => {
385
- var _a;
386
- return ((_a = formCapability.provides) == null ? void 0 : _a.forDocument(props.documentId)) ?? null;
387
- });
388
- const annotation = $.derived(() => props.currentObject);
389
- const field = $.derived(() => $.get(annotation).field);
390
- const scale = $.derived(() => props.scale);
391
- const pageIndex = $.derived(() => props.pageIndex);
392
- const isReadOnly = $.derived(() => !!($.get(field).flag & PDF_FORM_FIELD_FLAG.READONLY));
393
- $.user_effect(() => {
394
- if (!$.get(scope)) return;
395
- const id = $.get(annotation).id;
396
- return $.get(scope).onFieldValueChange((event) => {
397
- if (event.annotationId === id) {
398
- $.update(renderKey);
399
- }
400
- });
401
- });
402
- function handleChangeField(newField) {
403
- if (!$.get(scope)) return;
404
- $.get(scope).setFormFieldValues($.get(pageIndex), deepToRaw($.get(annotation)), deepToRaw(newField));
405
- }
406
- return {
407
- get annotation() {
408
- return $.get(annotation);
409
- },
410
- get field() {
411
- return $.get(field);
412
- },
413
- get scale() {
414
- return $.get(scale);
415
- },
416
- get pageIndex() {
417
- return $.get(pageIndex);
418
- },
419
- get scope() {
420
- return $.get(scope);
421
- },
422
- handleChangeField,
423
- get renderKey() {
424
- return $.get(renderKey);
425
- },
426
- get isReadOnly() {
427
- return $.get(isReadOnly);
428
- }
429
- };
430
- }
431
- var root_1$3 = $.from_html(`<img alt=""/>`);
432
- function RenderWidget($$anchor, $$props) {
433
- $.push($$props, true);
434
- let scaleFactor = $.prop($$props, "scaleFactor", 3, 1), renderKey = $.prop($$props, "renderKey", 3, 0), style = $.prop($$props, "style", 3, "");
435
- const formCapability = useFormCapability();
436
- let imageUrl = $.state(null);
437
- let prevUrl = null;
438
- $.user_effect(() => {
439
- if (!formCapability.provides) return;
440
- const { width, height } = $$props.annotation.rect.size;
441
- $$props.annotation.id;
442
- const sf = scaleFactor();
443
- renderKey();
444
- const pi = $$props.pageIndex;
445
- const task = formCapability.provides.renderWidget({
446
- pageIndex: pi,
447
- annotation: deepToRaw($$props.annotation),
448
- options: { scaleFactor: sf, dpr: window.devicePixelRatio }
449
- });
450
- task.wait(
451
- (blob) => {
452
- const url = URL.createObjectURL(blob);
453
- if (prevUrl) {
454
- URL.revokeObjectURL(prevUrl);
455
- }
456
- prevUrl = url;
457
- $.set(imageUrl, url, true);
458
- },
459
- ignore
460
- );
461
- return () => {
462
- task.abort({
463
- code: PdfErrorCode.Cancelled,
464
- message: "canceled render task"
465
- });
466
- if (prevUrl) {
467
- URL.revokeObjectURL(prevUrl);
468
- prevUrl = null;
469
- }
470
- };
471
- });
472
- var fragment = $.comment();
473
- var node = $.first_child(fragment);
474
- {
475
- var consequent = ($$anchor2) => {
476
- var img = root_1$3();
477
- $.template_effect(() => {
478
- $.set_attribute(img, "src", $.get(imageUrl));
479
- $.set_style(img, `width: 100%; height: 100%; display: block; ${style() ?? ""}`);
480
- });
481
- $.append($$anchor2, img);
482
- };
483
- $.if(node, ($$render) => {
484
- if ($.get(imageUrl)) $$render(consequent);
485
- });
486
- }
487
- $.append($$anchor, fragment);
488
- $.pop();
489
- }
490
- var root_2 = $.from_html(`<span> </span>`);
491
- var root_3 = $.from_html(`<span></span>`);
492
- var root_1$2 = $.from_html(`<div><input/> <!> <!></div>`);
493
- var root_4 = $.from_html(`<textarea></textarea>`);
494
- var root_5 = $.from_html(`<input/>`);
495
- var root_7 = $.from_html(`<div><!></div>`);
496
- var root_11 = $.from_html(`<div><!></div>`);
497
- var root_14 = $.from_html(`<div><!></div>`);
498
- function TextField($$anchor, $$props) {
499
- $.push($$props, true);
500
- const combContent = ($$anchor2) => {
501
- var div = root_1$2();
502
- let styles;
503
- var input = $.child(div);
504
- $.remove_input_defaults(input);
505
- input.__input = changeValue;
506
- $.set_style(input, "", {}, {
507
- position: "absolute",
508
- top: "0",
509
- left: "0",
510
- width: "100%",
511
- height: "100%",
512
- opacity: "0",
513
- padding: "0",
514
- margin: "0",
515
- border: "none",
516
- "z-index": "1"
517
- });
518
- $.action(input, ($$node) => refAction == null ? void 0 : refAction($$node));
519
- var node_1 = $.sibling(input, 2);
520
- $.each(node_1, 17, () => Array.from({ length: $.get(maxLen) }), $.index, ($$anchor3, _, i) => {
521
- var span = root_2();
522
- let styles_1;
523
- var text = $.child(span, true);
524
- $.reset(span);
525
- $.template_effect(() => {
526
- styles_1 = $.set_style(span, "", styles_1, {
527
- position: "absolute",
528
- top: "0",
529
- height: "100%",
530
- display: "flex",
531
- "align-items": "center",
532
- "justify-content": "center",
533
- "pointer-events": "none",
534
- left: `${i * $.get(cellWidth)}px`,
535
- width: `${$.get(cellWidth) ?? ""}px`,
536
- color: $$props.annotation.fontColor,
537
- "font-family": $.get(fontCss).fontFamily,
538
- "font-weight": $.get(fontCss).fontWeight,
539
- "font-style": $.get(fontCss).fontStyle,
540
- "font-size": `${ios.adjustedFontPx ?? ""}px`
541
- });
542
- $.set_text(text, $.get(chars)[i] || "");
543
- });
544
- $.append($$anchor3, span);
545
- });
546
- var node_2 = $.sibling(node_1, 2);
547
- {
548
- var consequent = ($$anchor3) => {
549
- var span_1 = root_3();
550
- let styles_2;
551
- $.template_effect(() => styles_2 = $.set_style(span_1, "", styles_2, {
552
- position: "absolute",
553
- top: "15%",
554
- height: "70%",
555
- width: "1px",
556
- "background-color": "black",
557
- "pointer-events": "none",
558
- left: `${$.get(caretIndex) * $.get(cellWidth) + $.get(cellWidth) / 2}px`,
559
- opacity: $.get(caretVisible) ? 1 : 0
560
- }));
561
- $.append($$anchor3, span_1);
562
- };
563
- $.if(node_2, ($$render) => {
564
- if ($.get(caretIndex) < $.get(maxLen)) $$render(consequent);
565
- });
566
- }
567
- $.reset(div);
568
- $.template_effect(() => {
569
- styles = $.set_style(div, "", styles, {
570
- position: "relative",
571
- width: "100%",
572
- height: "100%",
573
- "border-radius": "0",
574
- "box-sizing": "border-box",
575
- "border-style": "solid",
576
- "background-color": $$props.annotation.color ?? "transparent",
577
- "border-color": $$props.annotation.strokeColor ?? "transparent",
578
- "border-width": `${$.get(bw) ?? ""}px`
579
- });
580
- input.required = $.get(isRequired);
581
- input.disabled = $.get(isDisabled);
582
- $.set_attribute(input, "type", $.get(isPassword) ? "password" : "text");
583
- $.set_attribute(input, "name", $.get(name));
584
- $.set_attribute(input, "aria-label", $.get(name));
585
- $.set_value(input, $.get(localValue));
586
- $.set_attribute(input, "maxlength", $.get(maxLen));
587
- });
588
- $.event("focus", input, function(...$$args) {
589
- var _a;
590
- (_a = $$props.onFocus) == null ? void 0 : _a.apply(this, $$args);
591
- });
592
- $.event("blur", input, function(...$$args) {
593
- var _a;
594
- (_a = $$props.onBlur) == null ? void 0 : _a.apply(this, $$args);
595
- });
596
- $.append($$anchor2, div);
597
- };
598
- const textareaContent = ($$anchor2) => {
599
- var textarea = root_4();
600
- $.remove_textarea_child(textarea);
601
- textarea.__input = changeValue;
602
- let styles_3;
603
- $.action(textarea, ($$node) => refAction == null ? void 0 : refAction($$node));
604
- $.template_effect(() => {
605
- textarea.required = $.get(isRequired);
606
- textarea.disabled = $.get(isDisabled);
607
- $.set_attribute(textarea, "name", $.get(name));
608
- $.set_attribute(textarea, "aria-label", $.get(name));
609
- $.set_value(textarea, $.get(localValue));
610
- $.set_attribute(textarea, "maxlength", $.get(maxLen));
611
- styles_3 = $.set_style(textarea, "", styles_3, {
612
- "background-color": $$props.annotation.color ?? "transparent",
613
- "border-color": $$props.annotation.strokeColor ?? "transparent",
614
- "border-width": `${$.get(bw) ?? ""}px`,
615
- color: $$props.annotation.fontColor,
616
- "font-family": $.get(fontCss).fontFamily,
617
- "font-weight": $.get(fontCss).fontWeight,
618
- "font-style": $.get(fontCss).fontStyle,
619
- "font-size": `${ios.adjustedFontPx ?? ""}px`,
620
- padding: `${$.get(bw) ?? ""}px`,
621
- position: "absolute",
622
- top: "0",
623
- left: "0",
624
- width: "100%",
625
- height: "100%",
626
- margin: "0",
627
- "border-radius": "0",
628
- outline: "none",
629
- "box-sizing": "border-box",
630
- "border-style": "solid",
631
- resize: "none",
632
- "line-height": "1.14"
633
- });
634
- });
635
- $.event("focus", textarea, function(...$$args) {
636
- var _a;
637
- (_a = $$props.onFocus) == null ? void 0 : _a.apply(this, $$args);
638
- });
639
- $.event("blur", textarea, function(...$$args) {
640
- var _a;
641
- (_a = $$props.onBlur) == null ? void 0 : _a.apply(this, $$args);
642
- });
643
- $.append($$anchor2, textarea);
644
- };
645
- const inputContent = ($$anchor2) => {
646
- var input_1 = root_5();
647
- $.remove_input_defaults(input_1);
648
- input_1.__input = changeValue;
649
- let styles_4;
650
- $.action(input_1, ($$node) => refAction == null ? void 0 : refAction($$node));
651
- $.template_effect(() => {
652
- input_1.required = $.get(isRequired);
653
- input_1.disabled = $.get(isDisabled);
654
- $.set_attribute(input_1, "type", $.get(isPassword) ? "password" : "text");
655
- $.set_attribute(input_1, "name", $.get(name));
656
- $.set_attribute(input_1, "aria-label", $.get(name));
657
- $.set_value(input_1, $.get(localValue));
658
- $.set_attribute(input_1, "maxlength", $.get(maxLen));
659
- styles_4 = $.set_style(input_1, "", styles_4, {
660
- "background-color": $$props.annotation.color ?? "transparent",
661
- "border-color": $$props.annotation.strokeColor ?? "transparent",
662
- "border-width": `${$.get(bw) ?? ""}px`,
663
- color: $$props.annotation.fontColor,
664
- "font-family": $.get(fontCss).fontFamily,
665
- "font-weight": $.get(fontCss).fontWeight,
666
- "font-style": $.get(fontCss).fontStyle,
667
- "font-size": `${ios.adjustedFontPx ?? ""}px`,
668
- padding: `${$.get(bw) ?? ""}px`,
669
- position: "absolute",
670
- top: "0",
671
- left: "0",
672
- width: "100%",
673
- height: "100%",
674
- margin: "0",
675
- "border-radius": "0",
676
- outline: "none",
677
- "box-sizing": "border-box",
678
- "border-style": "solid"
679
- });
680
- });
681
- $.event("focus", input_1, function(...$$args) {
682
- var _a;
683
- (_a = $$props.onFocus) == null ? void 0 : _a.apply(this, $$args);
684
- });
685
- $.event("blur", input_1, function(...$$args) {
686
- var _a;
687
- (_a = $$props.onBlur) == null ? void 0 : _a.apply(this, $$args);
688
- });
689
- $.append($$anchor2, input_1);
690
- };
691
- let syncExternalValue = $.prop($$props, "syncExternalValue", 3, true);
692
- const field = $.derived(() => $$props.annotation.field);
693
- const flag = $.derived(() => $.get(field).flag);
694
- const name = $.derived(() => $.get(field).name);
695
- const value = $.derived(() => $.get(field).value);
696
- let localValue = $.state($.proxy($.get(value)));
697
- $.user_effect(() => {
698
- if (!syncExternalValue()) return;
699
- $.set(localValue, $.get(value), true);
700
- });
701
- function changeValue(evt) {
702
- var _a;
703
- const newValue = evt.target.value;
704
- $.set(localValue, newValue, true);
705
- (_a = $$props.onChangeField) == null ? void 0 : _a.call($$props, { ...$.get(field), value: newValue });
706
- }
707
- const bw = $.derived(() => ($$props.annotation.strokeWidth ?? 0) * $$props.scale);
708
- const fontCss = $.derived(() => standardFontCssProperties($$props.annotation.fontFamily));
709
- const computedFontPx = $.derived(() => $$props.annotation.fontSize * $$props.scale);
710
- const ios = useIOSZoomPrevention(() => $.get(computedFontPx), () => true);
711
- const isDisabled = $.derived(() => !$$props.isEditable || !!($.get(flag) & PDF_FORM_FIELD_FLAG.READONLY));
712
- const isRequired = $.derived(() => !!($.get(flag) & PDF_FORM_FIELD_FLAG.REQUIRED));
713
- const isPassword = $.derived(() => !!($.get(flag) & PDF_FORM_FIELD_FLAG.TEXT_PASSWORD));
714
- const isMultipleLine = $.derived(() => !!($.get(flag) & PDF_FORM_FIELD_FLAG.TEXT_MULTIPLINE));
715
- const isComb = $.derived(() => !!($.get(flag) & PDF_FORM_FIELD_FLAG.TEXT_COMB));
716
- const maxLen = $.derived(() => $.get(field).maxLen);
717
- const cellWidth = $.derived(() => $.get(isComb) && $.get(maxLen) ? $$props.annotation.rect.size.width * $$props.scale / $.get(maxLen) : 0);
718
- const chars = $.derived(() => ($.get(localValue) || "").split(""));
719
- const caretIndex = $.derived(() => $.get(chars).length);
720
- let caretVisible = $.state(true);
721
- let caretInterval;
722
- $.user_effect(() => {
723
- $.get(caretIndex);
724
- $.set(caretVisible, true);
725
- clearInterval(caretInterval);
726
- caretInterval = setInterval(
727
- () => {
728
- $.set(caretVisible, !$.get(caretVisible));
729
- },
730
- 530
731
- );
732
- return () => clearInterval(caretInterval);
733
- });
734
- function refAction(node) {
735
- var _a;
736
- (_a = $$props.inputRef) == null ? void 0 : _a.call($$props, node);
737
- return { destroy: () => {
738
- var _a2;
739
- return (_a2 = $$props.inputRef) == null ? void 0 : _a2.call($$props, null);
740
- } };
741
- }
742
- var fragment = $.comment();
743
- var node_3 = $.first_child(fragment);
744
- {
745
- var consequent_2 = ($$anchor2) => {
746
- var fragment_1 = $.comment();
747
- var node_4 = $.first_child(fragment_1);
748
- {
749
- var consequent_1 = ($$anchor3) => {
750
- var div_1 = root_7();
751
- var node_5 = $.child(div_1);
752
- combContent(node_5);
753
- $.reset(div_1);
754
- $.template_effect(() => $.set_style(div_1, ios.wrapperStyle));
755
- $.append($$anchor3, div_1);
756
- };
757
- var alternate = ($$anchor3) => {
758
- combContent($$anchor3);
759
- };
760
- $.if(node_4, ($$render) => {
761
- if (ios.wrapperStyle) $$render(consequent_1);
762
- else $$render(alternate, false);
763
- });
764
- }
765
- $.append($$anchor2, fragment_1);
766
- };
767
- var alternate_4 = ($$anchor2) => {
768
- var fragment_3 = $.comment();
769
- var node_6 = $.first_child(fragment_3);
770
- {
771
- var consequent_4 = ($$anchor3) => {
772
- var fragment_4 = $.comment();
773
- var node_7 = $.first_child(fragment_4);
774
- {
775
- var consequent_3 = ($$anchor4) => {
776
- var div_2 = root_11();
777
- var node_8 = $.child(div_2);
778
- textareaContent(node_8);
779
- $.reset(div_2);
780
- $.template_effect(() => $.set_style(div_2, ios.wrapperStyle));
781
- $.append($$anchor4, div_2);
782
- };
783
- var alternate_1 = ($$anchor4) => {
784
- textareaContent($$anchor4);
785
- };
786
- $.if(node_7, ($$render) => {
787
- if (ios.wrapperStyle) $$render(consequent_3);
788
- else $$render(alternate_1, false);
789
- });
790
- }
791
- $.append($$anchor3, fragment_4);
792
- };
793
- var alternate_3 = ($$anchor3) => {
794
- var fragment_6 = $.comment();
795
- var node_9 = $.first_child(fragment_6);
796
- {
797
- var consequent_5 = ($$anchor4) => {
798
- var div_3 = root_14();
799
- var node_10 = $.child(div_3);
800
- inputContent(node_10);
801
- $.reset(div_3);
802
- $.template_effect(() => $.set_style(div_3, ios.wrapperStyle));
803
- $.append($$anchor4, div_3);
804
- };
805
- var alternate_2 = ($$anchor4) => {
806
- inputContent($$anchor4);
807
- };
808
- $.if(
809
- node_9,
810
- ($$render) => {
811
- if (ios.wrapperStyle) $$render(consequent_5);
812
- else $$render(alternate_2, false);
813
- },
814
- true
815
- );
816
- }
817
- $.append($$anchor3, fragment_6);
818
- };
819
- $.if(
820
- node_6,
821
- ($$render) => {
822
- if ($.get(isMultipleLine)) $$render(consequent_4);
823
- else $$render(alternate_3, false);
824
- },
825
- true
826
- );
827
- }
828
- $.append($$anchor2, fragment_3);
829
- };
830
- $.if(node_3, ($$render) => {
831
- if ($.get(isComb) && $.get(maxLen)) $$render(consequent_2);
832
- else $$render(alternate_4, false);
833
- });
834
- }
835
- $.append($$anchor, fragment);
836
- $.pop();
837
- }
838
- $.delegate(["input"]);
839
- var root$a = $.from_html(`<div style="width: 100%; height: 100%; overflow: hidden; position: relative; pointer-events: auto; outline: none;"><!> <div><!></div></div>`);
840
- function TextFillMode($$anchor, $$props) {
841
- $.push($$props, true);
842
- let props = $$rest_props_compat$4($$props, ["$$slots", "$$events", "$$legacy"]);
843
- const widgetState = useFormWidgetState(props);
844
- const formDocState = useFormDocumentState(() => $$props.documentId);
845
- let editing = $.state(false);
846
- let inputEl = null;
847
- const isFocused = $.derived(() => formDocState.state.selectedFieldId === widgetState.annotation.id);
848
- $.user_effect(() => {
849
- if ($.get(isFocused) && inputEl && document.activeElement !== inputEl) {
850
- inputEl.focus();
851
- }
852
- });
853
- function handleFocus() {
854
- var _a;
855
- if (widgetState.isReadOnly) return;
856
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
857
- $.set(editing, true);
858
- }
859
- function handleBlur() {
860
- var _a, _b;
861
- $.set(editing, false);
862
- if (((_a = widgetState.scope) == null ? void 0 : _a.getSelectedFieldId()) === widgetState.annotation.id) {
863
- (_b = widgetState.scope) == null ? void 0 : _b.deselectField();
864
- }
865
- }
866
- function handleInputRef(el) {
867
- inputEl = el;
868
- }
869
- var div = root$a();
870
- var node = $.child(div);
871
- {
872
- let $0 = $.derived(() => $.get(editing) ? "hidden" : "visible");
873
- RenderWidget(node, {
874
- get pageIndex() {
875
- return widgetState.pageIndex;
876
- },
877
- get annotation() {
878
- return widgetState.annotation;
879
- },
880
- get scaleFactor() {
881
- return widgetState.scale;
882
- },
883
- get renderKey() {
884
- return widgetState.renderKey;
885
- },
886
- get style() {
887
- return `position: absolute; inset: 0; pointer-events: none; visibility: ${$.get($0) ?? ""};`;
888
- }
889
- });
890
- }
891
- var div_1 = $.sibling(node, 2);
892
- var node_1 = $.child(div_1);
893
- {
894
- let $0 = $.derived(() => !$.get(editing));
895
- TextField(node_1, {
896
- get annotation() {
897
- return widgetState.annotation;
898
- },
899
- get scale() {
900
- return widgetState.scale;
901
- },
902
- get pageIndex() {
903
- return widgetState.pageIndex;
904
- },
905
- isEditable: true,
906
- get onChangeField() {
907
- return widgetState.handleChangeField;
908
- },
909
- get syncExternalValue() {
910
- return $.get($0);
911
- },
912
- onFocus: handleFocus,
913
- onBlur: handleBlur,
914
- inputRef: handleInputRef
915
- });
916
- }
917
- $.reset(div_1);
918
- $.reset(div);
919
- $.template_effect(() => $.set_style(div_1, `position: absolute; inset: 0; z-index: 1; opacity: ${$.get(editing) ? 1 : 0};`));
920
- $.append($$anchor, div);
921
- $.pop();
922
- }
923
- function $$rest_props_compat$4(props, exclude, name) {
924
- const set = exclude instanceof Set ? exclude : new Set(exclude);
925
- if (typeof set.includes !== "function") set.includes = Set.prototype.has.bind(set);
926
- return $.rest_props(props, set, name);
927
- }
928
- var root$9 = $.from_html(`<div><!></div>`);
929
- function ToggleFillMode($$anchor, $$props) {
930
- $.push($$props, true);
931
- let props = $$rest_props_compat$3($$props, ["$$slots", "$$events", "$$legacy"]);
932
- const widgetState = useFormWidgetState(props);
933
- const formDocState = useFormDocumentState(() => $$props.documentId);
934
- let wrapperEl;
935
- const isFocused = $.derived(() => formDocState.state.selectedFieldId === widgetState.annotation.id);
936
- $.user_effect(() => {
937
- if ($.get(isFocused) && wrapperEl && document.activeElement !== wrapperEl) {
938
- wrapperEl.focus();
939
- }
940
- });
941
- function toggle() {
942
- if (widgetState.isReadOnly) return;
943
- const checked = isWidgetChecked(widgetState.annotation);
944
- const newValue = checked ? "Off" : widgetState.annotation.exportValue ?? "Yes";
945
- widgetState.handleChangeField({ ...widgetState.field, value: newValue });
946
- }
947
- function handleClick() {
948
- var _a;
949
- if (widgetState.isReadOnly) return;
950
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
951
- toggle();
952
- }
953
- function handleFocus() {
954
- var _a;
955
- if (widgetState.isReadOnly) return;
956
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
957
- }
958
- function handleBlur() {
959
- var _a, _b;
960
- if (((_a = widgetState.scope) == null ? void 0 : _a.getSelectedFieldId()) === widgetState.annotation.id) {
961
- (_b = widgetState.scope) == null ? void 0 : _b.deselectField();
962
- }
963
- }
964
- function handleKeyDown(e) {
965
- if (e.key === " " || e.key === "Enter") {
966
- e.preventDefault();
967
- toggle();
968
- }
969
- }
970
- var div = root$9();
971
- div.__click = handleClick;
972
- div.__keydown = handleKeyDown;
973
- var node = $.child(div);
974
- RenderWidget(node, {
975
- get pageIndex() {
976
- return widgetState.pageIndex;
977
- },
978
- get annotation() {
979
- return widgetState.annotation;
980
- },
981
- get scaleFactor() {
982
- return widgetState.scale;
983
- },
984
- get renderKey() {
985
- return widgetState.renderKey;
986
- },
987
- style: "pointer-events: none;"
988
- });
989
- $.reset(div);
990
- $.bind_this(div, ($$value) => wrapperEl = $$value, () => wrapperEl);
991
- $.template_effect(() => {
992
- $.set_attribute(div, "tabindex", widgetState.isReadOnly ? -1 : 0);
993
- $.set_style(div, `width: 100%; height: 100%; overflow: hidden; cursor: ${widgetState.isReadOnly ? "default" : "pointer"}; pointer-events: auto; outline: ${$.get(isFocused) ? "2px solid rgba(66, 133, 244, 0.8)" : "none"}; outline-offset: -2px;`);
994
- });
995
- $.event("focus", div, handleFocus);
996
- $.event("blur", div, handleBlur);
997
- $.append($$anchor, div);
998
- $.pop();
999
- }
1000
- $.delegate(["click", "keydown"]);
1001
- function $$rest_props_compat$3(props, exclude, name) {
1002
- const set = exclude instanceof Set ? exclude : new Set(exclude);
1003
- if (typeof set.includes !== "function") set.includes = Set.prototype.has.bind(set);
1004
- return $.rest_props(props, set, name);
1005
- }
1006
- var root$8 = $.from_html(`<div><!></div>`);
1007
- function RadioButtonFillMode($$anchor, $$props) {
1008
- $.push($$props, true);
1009
- let props = $$rest_props_compat$2($$props, ["$$slots", "$$events", "$$legacy"]);
1010
- const widgetState = useFormWidgetState(props);
1011
- const formDocState = useFormDocumentState(() => $$props.documentId);
1012
- let wrapperEl;
1013
- const isFocused = $.derived(() => formDocState.state.selectedFieldId === widgetState.annotation.id);
1014
- $.user_effect(() => {
1015
- if ($.get(isFocused) && wrapperEl && document.activeElement !== wrapperEl) {
1016
- wrapperEl.focus();
1017
- }
1018
- });
1019
- function selectRadio() {
1020
- if (widgetState.isReadOnly) return;
1021
- if (!isWidgetChecked(widgetState.annotation) && widgetState.annotation.exportValue) {
1022
- widgetState.handleChangeField({
1023
- ...widgetState.field,
1024
- value: widgetState.annotation.exportValue
1025
- });
1026
- }
1027
- }
1028
- function handleClick() {
1029
- var _a;
1030
- if (widgetState.isReadOnly) return;
1031
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
1032
- selectRadio();
1033
- }
1034
- function handleFocus() {
1035
- var _a;
1036
- if (widgetState.isReadOnly) return;
1037
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
1038
- }
1039
- function handleBlur() {
1040
- var _a, _b;
1041
- if (((_a = widgetState.scope) == null ? void 0 : _a.getSelectedFieldId()) === widgetState.annotation.id) {
1042
- (_b = widgetState.scope) == null ? void 0 : _b.deselectField();
1043
- }
1044
- }
1045
- function handleKeyDown(e) {
1046
- if (e.key === " " || e.key === "Enter") {
1047
- e.preventDefault();
1048
- selectRadio();
1049
- }
1050
- }
1051
- var div = root$8();
1052
- div.__click = handleClick;
1053
- div.__keydown = handleKeyDown;
1054
- var node = $.child(div);
1055
- RenderWidget(node, {
1056
- get pageIndex() {
1057
- return widgetState.pageIndex;
1058
- },
1059
- get annotation() {
1060
- return widgetState.annotation;
1061
- },
1062
- get scaleFactor() {
1063
- return widgetState.scale;
1064
- },
1065
- get renderKey() {
1066
- return widgetState.renderKey;
1067
- },
1068
- style: "pointer-events: none;"
1069
- });
1070
- $.reset(div);
1071
- $.bind_this(div, ($$value) => wrapperEl = $$value, () => wrapperEl);
1072
- $.template_effect(() => {
1073
- $.set_attribute(div, "tabindex", widgetState.isReadOnly ? -1 : 0);
1074
- $.set_style(div, `width: 100%; height: 100%; overflow: hidden; cursor: ${widgetState.isReadOnly ? "default" : "pointer"}; pointer-events: auto; outline: ${$.get(isFocused) ? "2px solid rgba(66, 133, 244, 0.8)" : "none"}; outline-offset: -2px;`);
1075
- });
1076
- $.event("focus", div, handleFocus);
1077
- $.event("blur", div, handleBlur);
1078
- $.append($$anchor, div);
1079
- $.pop();
1080
- }
1081
- $.delegate(["click", "keydown"]);
1082
- function $$rest_props_compat$2(props, exclude, name) {
1083
- const set = exclude instanceof Set ? exclude : new Set(exclude);
1084
- if (typeof set.includes !== "function") set.includes = Set.prototype.has.bind(set);
1085
- return $.rest_props(props, set, name);
1086
- }
1087
- var root_1$1 = $.from_html(`<option> </option>`);
1088
- var root$7 = $.from_html(`<select></select>`);
1089
- function ComboboxField($$anchor, $$props) {
1090
- $.push($$props, true);
1091
- const field = $.derived(() => $$props.annotation.field);
1092
- const flag = $.derived(() => $.get(field).flag);
1093
- const options = $.derived(() => $.get(field).options);
1094
- const name = $.derived(() => $.get(field).alternateName || $.get(field).name);
1095
- const isDisabled = $.derived(() => !$$props.isEditable || !!($.get(flag) & PDF_FORM_FIELD_FLAG.READONLY));
1096
- const isRequired = $.derived(() => !!($.get(flag) & PDF_FORM_FIELD_FLAG.REQUIRED));
1097
- const selectedValue = $.derived(() => {
1098
- var _a;
1099
- return ((_a = $.get(options).find((o) => o.isSelected)) == null ? void 0 : _a.label) ?? "";
1100
- });
1101
- function handleChange(evt) {
1102
- var _a;
1103
- const select = evt.target;
1104
- const updatedOptions = $.get(options).map((opt, i) => ({ ...opt, isSelected: i === select.selectedIndex }));
1105
- (_a = $$props.onChangeField) == null ? void 0 : _a.call($$props, { ...$.get(field), options: updatedOptions });
1106
- }
1107
- function refAction(node) {
1108
- var _a;
1109
- (_a = $$props.inputRef) == null ? void 0 : _a.call($$props, node);
1110
- return { destroy: () => {
1111
- var _a2;
1112
- return (_a2 = $$props.inputRef) == null ? void 0 : _a2.call($$props, null);
1113
- } };
1114
- }
1115
- var select_1 = root$7();
1116
- select_1.__change = handleChange;
1117
- $.set_style(select_1, "", {}, {
1118
- position: "absolute",
1119
- inset: "0",
1120
- display: "block",
1121
- "z-index": "1",
1122
- width: "100%",
1123
- height: "100%",
1124
- "min-width": "100%",
1125
- "min-height": "100%",
1126
- padding: "0",
1127
- margin: "0",
1128
- border: "0",
1129
- "border-radius": "0",
1130
- background: "transparent",
1131
- outline: "none",
1132
- "box-sizing": "border-box",
1133
- appearance: "none",
1134
- "-webkit-appearance": "none",
1135
- "pointer-events": "auto",
1136
- cursor: "inherit",
1137
- opacity: "0"
1138
- });
1139
- $.each(select_1, 21, () => $.get(options), $.index, ($$anchor2, option) => {
1140
- var option_1 = root_1$1();
1141
- var text = $.child(option_1, true);
1142
- $.reset(option_1);
1143
- var option_1_value = {};
1144
- $.template_effect(() => {
1145
- $.set_text(text, $.get(option).label);
1146
- if (option_1_value !== (option_1_value = $.get(option).label)) {
1147
- option_1.value = (option_1.__value = $.get(option).label) ?? "";
1148
- }
1149
- });
1150
- $.append($$anchor2, option_1);
1151
- });
1152
- $.reset(select_1);
1153
- $.action(select_1, ($$node) => refAction == null ? void 0 : refAction($$node));
1154
- var select_1_value;
1155
- $.init_select(select_1);
1156
- $.template_effect(() => {
1157
- select_1.required = $.get(isRequired);
1158
- select_1.disabled = $.get(isDisabled);
1159
- $.set_attribute(select_1, "name", $.get(name));
1160
- $.set_attribute(select_1, "aria-label", $.get(name));
1161
- if (select_1_value !== (select_1_value = $.get(selectedValue))) {
1162
- select_1.value = (select_1.__value = $.get(selectedValue)) ?? "", $.select_option(select_1, $.get(selectedValue));
1163
- }
1164
- });
1165
- $.event("focus", select_1, function(...$$args) {
1166
- var _a;
1167
- (_a = $$props.onFocus) == null ? void 0 : _a.apply(this, $$args);
1168
- });
1169
- $.event("blur", select_1, function(...$$args) {
1170
- var _a;
1171
- (_a = $$props.onBlur) == null ? void 0 : _a.apply(this, $$args);
1172
- });
1173
- $.append($$anchor, select_1);
1174
- $.pop();
1175
- }
1176
- $.delegate(["change"]);
1177
- var root$6 = $.from_html(`<div><!> <!></div>`);
1178
- function ComboboxFillMode($$anchor, $$props) {
1179
- $.push($$props, true);
1180
- let props = $$rest_props_compat$1($$props, ["$$slots", "$$events", "$$legacy"]);
1181
- const widgetState = useFormWidgetState(props);
1182
- const formDocState = useFormDocumentState(() => $$props.documentId);
1183
- const comboboxAnnotation = $.derived(() => widgetState.annotation);
1184
- let wrapperEl;
1185
- let selectEl = null;
1186
- const isFocused = $.derived(() => formDocState.state.selectedFieldId === widgetState.annotation.id);
1187
- $.user_effect(() => {
1188
- if ($.get(isFocused) && selectEl && document.activeElement !== selectEl) {
1189
- selectEl.focus();
1190
- }
1191
- });
1192
- function handleFocus() {
1193
- var _a;
1194
- if (widgetState.isReadOnly) return;
1195
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
1196
- }
1197
- function handleBlur() {
1198
- requestAnimationFrame(() => {
1199
- var _a, _b;
1200
- if (wrapperEl == null ? void 0 : wrapperEl.contains(document.activeElement)) return;
1201
- if (((_a = widgetState.scope) == null ? void 0 : _a.getSelectedFieldId()) === widgetState.annotation.id) {
1202
- (_b = widgetState.scope) == null ? void 0 : _b.deselectField();
1203
- }
1204
- });
1205
- }
1206
- function selectInputRef(el) {
1207
- selectEl = el;
1208
- }
1209
- var div = root$6();
1210
- var node = $.child(div);
1211
- RenderWidget(node, {
1212
- get pageIndex() {
1213
- return widgetState.pageIndex;
1214
- },
1215
- get annotation() {
1216
- return widgetState.annotation;
1217
- },
1218
- get scaleFactor() {
1219
- return widgetState.scale;
1220
- },
1221
- get renderKey() {
1222
- return widgetState.renderKey;
1223
- },
1224
- style: "position: absolute; inset: 0; pointer-events: none;"
1225
- });
1226
- var node_1 = $.sibling(node, 2);
1227
- ComboboxField(node_1, {
1228
- get annotation() {
1229
- return $.get(comboboxAnnotation);
1230
- },
1231
- get scale() {
1232
- return widgetState.scale;
1233
- },
1234
- get pageIndex() {
1235
- return widgetState.pageIndex;
1236
- },
1237
- isEditable: true,
1238
- get onChangeField() {
1239
- return widgetState.handleChangeField;
1240
- },
1241
- onFocus: handleFocus,
1242
- onBlur: handleBlur,
1243
- inputRef: selectInputRef
1244
- });
1245
- $.reset(div);
1246
- $.bind_this(div, ($$value) => wrapperEl = $$value, () => wrapperEl);
1247
- $.template_effect(() => $.set_style(div, `width: 100%; height: 100%; overflow: hidden; position: relative; cursor: ${widgetState.isReadOnly ? "default" : "pointer"}; pointer-events: auto; outline: ${$.get(isFocused) ? "2px solid rgba(66, 133, 244, 0.8)" : "none"}; outline-offset: -2px;`));
1248
- $.append($$anchor, div);
1249
- $.pop();
1250
- }
1251
- function $$rest_props_compat$1(props, exclude, name) {
1252
- const set = exclude instanceof Set ? exclude : new Set(exclude);
1253
- if (typeof set.includes !== "function") set.includes = Set.prototype.has.bind(set);
1254
- return $.rest_props(props, set, name);
1255
- }
1256
- var root_1 = $.from_html(`<div role="option"> </div>`);
1257
- var root$5 = $.from_html(`<div></div>`);
1258
- function ListboxField($$anchor, $$props) {
1259
- $.push($$props, true);
1260
- const field = $.derived(() => $$props.annotation.field);
1261
- const flag = $.derived(() => $.get(field).flag);
1262
- const options = $.derived(() => $.get(field).options);
1263
- const isDisabled = $.derived(() => !$$props.isEditable || !!($.get(flag) & PDF_FORM_FIELD_FLAG.READONLY));
1264
- const isMultipleChoice = $.derived(() => !!($.get(flag) & PDF_FORM_FIELD_FLAG.CHOICE_MULTL_SELECT));
1265
- const bw = $.derived(() => ($$props.annotation.strokeWidth ?? 0) * $$props.scale);
1266
- const fontSize = $.derived(() => ($$props.annotation.fontSize ?? 12) * $$props.scale);
1267
- const lineHeight = $.derived(() => $.get(fontSize) * 1.2);
1268
- const fontCss = $.derived(() => standardFontCssProperties($$props.annotation.fontFamily));
1269
- function handleOptionClick(clickedIndex) {
1270
- var _a;
1271
- if ($.get(isDisabled)) return;
1272
- const updatedOptions = $.get(options).map((opt, i) => ({
1273
- ...opt,
1274
- isSelected: $.get(isMultipleChoice) ? i === clickedIndex ? !opt.isSelected : opt.isSelected : i === clickedIndex
1275
- }));
1276
- (_a = $$props.onChangeField) == null ? void 0 : _a.call($$props, { ...$.get(field), options: updatedOptions });
1277
- }
1278
- function refAction(node) {
1279
- var _a;
1280
- (_a = $$props.inputRef) == null ? void 0 : _a.call($$props, node);
1281
- return { destroy: () => {
1282
- var _a2;
1283
- return (_a2 = $$props.inputRef) == null ? void 0 : _a2.call($$props, null);
1284
- } };
1285
- }
1286
- var div = root$5();
1287
- let styles;
1288
- $.each(div, 21, () => $.get(options), $.index, ($$anchor2, opt, i) => {
1289
- var div_1 = root_1();
1290
- div_1.__click = () => handleOptionClick(i);
1291
- let styles_1;
1292
- var text = $.child(div_1, true);
1293
- $.reset(div_1);
1294
- $.template_effect(() => {
1295
- $.set_attribute(div_1, "aria-selected", $.get(opt).isSelected);
1296
- styles_1 = $.set_style(div_1, "", styles_1, {
1297
- padding: `0 ${4 * $$props.scale}px`,
1298
- "font-size": `${$.get(fontSize) ?? ""}px`,
1299
- "line-height": `${$.get(lineHeight) ?? ""}px`,
1300
- "font-family": $.get(fontCss).fontFamily,
1301
- "font-weight": $.get(fontCss).fontWeight,
1302
- "font-style": $.get(fontCss).fontStyle,
1303
- color: $.get(opt).isSelected ? "#FFFFFF" : $$props.annotation.fontColor ?? "#000000",
1304
- background: $.get(opt).isSelected ? "rgba(0, 51, 113, 1)" : "transparent",
1305
- "white-space": "nowrap",
1306
- overflow: "hidden",
1307
- "text-overflow": "ellipsis",
1308
- cursor: $.get(isDisabled) ? "default" : "pointer"
1309
- });
1310
- $.set_text(text, $.get(opt).label);
1311
- });
1312
- $.append($$anchor2, div_1);
1313
- });
1314
- $.reset(div);
1315
- $.action(div, ($$node) => refAction == null ? void 0 : refAction($$node));
1316
- $.template_effect(() => styles = $.set_style(div, "", styles, {
1317
- position: "absolute",
1318
- top: "0",
1319
- left: "0",
1320
- width: "100%",
1321
- height: "100%",
1322
- background: $$props.annotation.color ?? "#FFFFFF",
1323
- "border-style": "solid",
1324
- "border-color": $$props.annotation.strokeColor ?? "#000000",
1325
- "border-width": `${$.get(bw) ?? ""}px`,
1326
- "box-sizing": "border-box",
1327
- overflow: "auto",
1328
- display: "flex",
1329
- "flex-direction": "column",
1330
- outline: "none"
1331
- }));
1332
- $.event("blur", div, function(...$$args) {
1333
- var _a;
1334
- (_a = $$props.onBlur) == null ? void 0 : _a.apply(this, $$args);
1335
- });
1336
- $.append($$anchor, div);
1337
- $.pop();
1338
- }
1339
- $.delegate(["click"]);
1340
- var root$4 = $.from_html(`<div><!> <!></div>`);
1341
- function ListboxFillMode($$anchor, $$props) {
1342
- $.push($$props, true);
1343
- let props = $$rest_props_compat($$props, ["$$slots", "$$events", "$$legacy"]);
1344
- const widgetState = useFormWidgetState(props);
1345
- const formDocState = useFormDocumentState(() => $$props.documentId);
1346
- let editing = $.state(false);
1347
- let wrapperEl;
1348
- const isFocused = $.derived(() => formDocState.state.selectedFieldId === widgetState.annotation.id);
1349
- $.user_effect(() => {
1350
- if ($.get(isFocused) && wrapperEl && !wrapperEl.contains(document.activeElement)) {
1351
- wrapperEl.focus();
1352
- }
1353
- });
1354
- function handleFocus() {
1355
- var _a;
1356
- if (widgetState.isReadOnly) return;
1357
- (_a = widgetState.scope) == null ? void 0 : _a.selectField(widgetState.annotation.id);
1358
- $.set(editing, true);
1359
- }
1360
- function handleBlur() {
1361
- requestAnimationFrame(() => {
1362
- var _a, _b;
1363
- if (wrapperEl == null ? void 0 : wrapperEl.contains(document.activeElement)) return;
1364
- $.set(editing, false);
1365
- if (((_a = widgetState.scope) == null ? void 0 : _a.getSelectedFieldId()) === widgetState.annotation.id) {
1366
- (_b = widgetState.scope) == null ? void 0 : _b.deselectField();
1367
- }
1368
- });
1369
- }
1370
- var div = root$4();
1371
- var node = $.child(div);
1372
- ListboxField(node, {
1373
- get annotation() {
1374
- return widgetState.annotation;
1375
- },
1376
- get scale() {
1377
- return widgetState.scale;
1378
- },
1379
- get pageIndex() {
1380
- return widgetState.pageIndex;
1381
- },
1382
- isEditable: true,
1383
- get onChangeField() {
1384
- return widgetState.handleChangeField;
1385
- }
1386
- });
1387
- var node_1 = $.sibling(node, 2);
1388
- {
1389
- var consequent = ($$anchor2) => {
1390
- RenderWidget($$anchor2, {
1391
- get pageIndex() {
1392
- return widgetState.pageIndex;
1393
- },
1394
- get annotation() {
1395
- return widgetState.annotation;
1396
- },
1397
- get scaleFactor() {
1398
- return widgetState.scale;
1399
- },
1400
- get renderKey() {
1401
- return widgetState.renderKey;
1402
- },
1403
- style: "pointer-events: none;"
1404
- });
1405
- };
1406
- $.if(node_1, ($$render) => {
1407
- if (!$.get(editing)) $$render(consequent);
1408
- });
1409
- }
1410
- $.reset(div);
1411
- $.bind_this(div, ($$value) => wrapperEl = $$value, () => wrapperEl);
1412
- $.template_effect(() => {
1413
- $.set_attribute(div, "tabindex", widgetState.isReadOnly ? -1 : 0);
1414
- $.set_style(div, `width: 100%; height: 100%; overflow: hidden; cursor: ${widgetState.isReadOnly ? "default" : "pointer"}; pointer-events: auto; outline: ${$.get(isFocused) && !$.get(editing) ? "2px solid rgba(66, 133, 244, 0.8)" : "none"}; outline-offset: -2px;`);
1415
- });
1416
- $.event("focus", div, handleFocus);
1417
- $.event("blur", div, handleBlur);
1418
- $.append($$anchor, div);
1419
- $.pop();
1420
- }
1421
- function $$rest_props_compat(props, exclude, name) {
1422
- const set = exclude instanceof Set ? exclude : new Set(exclude);
1423
- if (typeof set.includes !== "function") set.includes = Set.prototype.has.bind(set);
1424
- return $.rest_props(props, set, name);
1425
- }
1426
- var root$3 = $.from_html(`<div></div>`);
1427
- function TextFieldPreview($$anchor, $$props) {
1428
- $.push($$props, true);
1429
- var div = root$3();
1430
- let styles;
1431
- $.template_effect(() => styles = $.set_style(div, "", styles, {
1432
- position: "absolute",
1433
- left: "0",
1434
- top: "0",
1435
- width: `${$$props.bounds.size.width * $$props.scale}px`,
1436
- height: `${$$props.bounds.size.height * $$props.scale}px`,
1437
- border: "1px dashed rgba(66, 133, 244, 0.6)",
1438
- "background-color": "rgba(255, 255, 255, 0.9)",
1439
- "box-sizing": "border-box",
1440
- display: "flex",
1441
- "align-items": "center",
1442
- padding: `0 ${2 * $$props.scale}px`,
1443
- overflow: "hidden"
1444
- }));
1445
- $.append($$anchor, div);
1446
- $.pop();
1447
- }
1448
- var root$2 = $.from_html(`<div></div>`);
1449
- function CheckboxPreview($$anchor, $$props) {
1450
- $.push($$props, true);
1451
- var div = root$2();
1452
- let styles;
1453
- $.template_effect(() => styles = $.set_style(div, "", styles, {
1454
- position: "absolute",
1455
- left: "0",
1456
- top: "0",
1457
- width: `${$$props.bounds.size.width * $$props.scale}px`,
1458
- height: `${$$props.bounds.size.height * $$props.scale}px`,
1459
- border: "1px dashed rgba(66, 133, 244, 0.6)",
1460
- "background-color": "rgba(255, 255, 255, 0.9)",
1461
- "box-sizing": "border-box",
1462
- display: "flex",
1463
- "align-items": "center",
1464
- "justify-content": "center"
1465
- }));
1466
- $.append($$anchor, div);
1467
- $.pop();
1468
- }
1469
- var root$1 = $.from_html(`<div></div>`);
1470
- function RadioButtonPreview($$anchor, $$props) {
1471
- $.push($$props, true);
1472
- var div = root$1();
1473
- let styles;
1474
- $.template_effect(() => styles = $.set_style(div, "", styles, {
1475
- position: "absolute",
1476
- left: "0",
1477
- top: "0",
1478
- width: `${$$props.bounds.size.width * $$props.scale}px`,
1479
- height: `${$$props.bounds.size.height * $$props.scale}px`,
1480
- border: "1px dashed rgba(66, 133, 244, 0.6)",
1481
- "background-color": "rgba(255, 255, 255, 0.9)",
1482
- "border-radius": "50%",
1483
- "box-sizing": "border-box",
1484
- display: "flex",
1485
- "align-items": "center",
1486
- "justify-content": "center"
1487
- }));
1488
- $.append($$anchor, div);
1489
- $.pop();
1490
- }
1491
- var root = $.from_html(`<div></div>`);
1492
- function ListboxPreview($$anchor, $$props) {
1493
- $.push($$props, true);
1494
- var div = root();
1495
- let styles;
1496
- $.template_effect(() => styles = $.set_style(div, "", styles, {
1497
- position: "absolute",
1498
- left: "0",
1499
- top: "0",
1500
- width: `${$$props.bounds.size.width * $$props.scale}px`,
1501
- height: `${$$props.bounds.size.height * $$props.scale}px`,
1502
- border: "1px dashed rgba(66, 133, 244, 0.6)",
1503
- "background-color": "rgba(255, 255, 255, 0.9)",
1504
- "box-sizing": "border-box",
1505
- display: "flex",
1506
- "flex-direction": "column",
1507
- overflow: "hidden"
1508
- }));
1509
- $.append($$anchor, div);
1510
- $.pop();
1511
- }
1512
- const formRenderers = [
1513
- createRenderer({
1514
- id: "formTextField",
1515
- matches: (a) => {
1516
- var _a;
1517
- return a.type === PdfAnnotationSubtype.WIDGET && ((_a = a.field) == null ? void 0 : _a.type) === PDF_FORM_FIELD_TYPE.TEXTFIELD;
1518
- },
1519
- component: FormTextField,
1520
- renderPreview: TextFieldPreview,
1521
- interactionDefaults: { isDraggable: false, isResizable: true, isRotatable: false },
1522
- useAppearanceStream: false,
1523
- renderLocked: TextFillMode
1524
- }),
1525
- createRenderer({
1526
- id: "formCheckbox",
1527
- matches: (a) => {
1528
- var _a;
1529
- return a.type === PdfAnnotationSubtype.WIDGET && ((_a = a.field) == null ? void 0 : _a.type) === PDF_FORM_FIELD_TYPE.CHECKBOX;
1530
- },
1531
- component: FormCheckbox,
1532
- renderPreview: CheckboxPreview,
1533
- interactionDefaults: { isDraggable: false, isResizable: true, isRotatable: false },
1534
- useAppearanceStream: false,
1535
- renderLocked: ToggleFillMode
1536
- }),
1537
- createRenderer({
1538
- id: "formRadioButton",
1539
- matches: (a) => {
1540
- var _a;
1541
- return a.type === PdfAnnotationSubtype.WIDGET && ((_a = a.field) == null ? void 0 : _a.type) === PDF_FORM_FIELD_TYPE.RADIOBUTTON;
1542
- },
1543
- component: FormRadioButton,
1544
- renderPreview: RadioButtonPreview,
1545
- interactionDefaults: { isDraggable: false, isResizable: true, isRotatable: false },
1546
- useAppearanceStream: false,
1547
- renderLocked: RadioButtonFillMode
1548
- }),
1549
- createRenderer({
1550
- id: "formCombobox",
1551
- matches: (a) => {
1552
- var _a;
1553
- return a.type === PdfAnnotationSubtype.WIDGET && ((_a = a.field) == null ? void 0 : _a.type) === PDF_FORM_FIELD_TYPE.COMBOBOX;
1554
- },
1555
- component: FormCombobox,
1556
- renderPreview: TextFieldPreview,
1557
- interactionDefaults: { isDraggable: false, isResizable: true, isRotatable: false },
1558
- useAppearanceStream: false,
1559
- renderLocked: ComboboxFillMode
1560
- }),
1561
- createRenderer({
1562
- id: "formListbox",
1563
- matches: (a) => {
1564
- var _a;
1565
- return a.type === PdfAnnotationSubtype.WIDGET && ((_a = a.field) == null ? void 0 : _a.type) === PDF_FORM_FIELD_TYPE.LISTBOX;
1566
- },
1567
- component: FormListbox,
1568
- renderPreview: ListboxPreview,
1569
- interactionDefaults: { isDraggable: false, isResizable: true, isRotatable: false },
1570
- useAppearanceStream: false,
1571
- renderLocked: ListboxFillMode
1572
- })
1573
- ];
1574
- function FormRendererRegistration($$anchor, $$props) {
1575
- $.push($$props, false);
1576
- const registry = getRendererRegistry();
1577
- onMount(() => {
1578
- if (!registry) return;
1579
- return registry.register(formRenderers);
1580
- });
1581
- $.init();
1582
- $.pop();
1583
- }
1584
- const FormPluginPackage = createPluginPackage(FormPluginPackage$1).addUtility(FormRendererRegistration).build();
1585
- export {
1586
- FormPluginPackage,
1587
- useFormCapability,
1588
- useFormDocumentState,
1589
- useFormPlugin,
1590
- useFormWidgetState
1591
- };
1592
- //# sourceMappingURL=index.js.map