@embedpdf/svelte 0.0.0-stage → 3.0.0-next.16
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 +192 -0
- package/README.md +312 -2
- package/dist/actions/readers.svelte.d.ts +29 -0
- package/dist/actions/readers.svelte.js +55 -0
- package/dist/actions.d.ts +13 -0
- package/dist/actions.js +13 -0
- package/dist/anchored/Anchored.svelte +24 -0
- package/dist/anchored/Anchored.svelte.d.ts +4 -0
- package/dist/anchored/PlacedAnchored.svelte +97 -0
- package/dist/anchored/PlacedAnchored.svelte.d.ts +4 -0
- package/dist/anchored/context.d.ts +31 -0
- package/dist/anchored/context.js +36 -0
- package/dist/anchored/props.d.ts +29 -0
- package/dist/anchored/props.js +1 -0
- package/dist/anchored.d.ts +12 -0
- package/dist/anchored.js +2 -0
- package/dist/annotation/AnnotationChrome.svelte +173 -0
- package/dist/annotation/AnnotationChrome.svelte.d.ts +11 -0
- package/dist/annotation/AnnotationDraftMenu.svelte +27 -0
- package/dist/annotation/AnnotationDraftMenu.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationFrame.svelte +46 -0
- package/dist/annotation/AnnotationFrame.svelte.d.ts +15 -0
- package/dist/annotation/AnnotationLayer.svelte +241 -0
- package/dist/annotation/AnnotationLayer.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationLook.svelte +67 -0
- package/dist/annotation/AnnotationLook.svelte.d.ts +21 -0
- package/dist/annotation/AnnotationMenu.svelte +47 -0
- package/dist/annotation/AnnotationMenu.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationRotationBadge.svelte +52 -0
- package/dist/annotation/AnnotationRotationBadge.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationScene.svelte +27 -0
- package/dist/annotation/AnnotationScene.svelte.d.ts +7 -0
- package/dist/annotation/FreeTextBox.svelte +51 -0
- package/dist/annotation/FreeTextBox.svelte.d.ts +9 -0
- package/dist/annotation/NativeDrawing.svelte +61 -0
- package/dist/annotation/NativeDrawing.svelte.d.ts +10 -0
- package/dist/annotation/StampGhost.svelte +79 -0
- package/dist/annotation/StampGhost.svelte.d.ts +7 -0
- package/dist/annotation/chrome-paint.svelte.d.ts +30 -0
- package/dist/annotation/chrome-paint.svelte.js +27 -0
- package/dist/annotation/props.d.ts +181 -0
- package/dist/annotation/props.js +1 -0
- package/dist/annotation/readers.svelte.d.ts +59 -0
- package/dist/annotation/readers.svelte.js +136 -0
- package/dist/annotation/state.d.ts +18 -0
- package/dist/annotation/state.js +20 -0
- package/dist/annotation/text-box.svelte.d.ts +28 -0
- package/dist/annotation/text-box.svelte.js +87 -0
- package/dist/annotation.d.ts +32 -0
- package/dist/annotation.js +31 -0
- package/dist/attachment/readers.d.ts +23 -0
- package/dist/attachment/readers.js +21 -0
- package/dist/attachment.d.ts +13 -0
- package/dist/attachment.js +14 -0
- package/dist/commands/readers.svelte.d.ts +50 -0
- package/dist/commands/readers.svelte.js +83 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.js +9 -0
- package/dist/form/ButtonControl.svelte +38 -0
- package/dist/form/ButtonControl.svelte.d.ts +11 -0
- package/dist/form/ComboControl.svelte +52 -0
- package/dist/form/ComboControl.svelte.d.ts +11 -0
- package/dist/form/FieldPictures.svelte +145 -0
- package/dist/form/FieldPictures.svelte.d.ts +3 -0
- package/dist/form/FormFocusRing.svelte +25 -0
- package/dist/form/FormFocusRing.svelte.d.ts +8 -0
- package/dist/form/FormLayer.svelte +98 -0
- package/dist/form/FormLayer.svelte.d.ts +3 -0
- package/dist/form/ListControl.svelte +49 -0
- package/dist/form/ListControl.svelte.d.ts +11 -0
- package/dist/form/NativeListBox.svelte +57 -0
- package/dist/form/NativeListBox.svelte.d.ts +4 -0
- package/dist/form/SignatureControl.svelte +53 -0
- package/dist/form/SignatureControl.svelte.d.ts +11 -0
- package/dist/form/TextControl.svelte +107 -0
- package/dist/form/TextControl.svelte.d.ts +11 -0
- package/dist/form/ToggleControl.svelte +50 -0
- package/dist/form/ToggleControl.svelte.d.ts +11 -0
- package/dist/form/WidgetBox.svelte +82 -0
- package/dist/form/WidgetBox.svelte.d.ts +15 -0
- package/dist/form/props.d.ts +21 -0
- package/dist/form/props.js +1 -0
- package/dist/form/readers.svelte.d.ts +46 -0
- package/dist/form/readers.svelte.js +52 -0
- package/dist/form/widget.d.ts +16 -0
- package/dist/form/widget.js +20 -0
- package/dist/form.d.ts +11 -0
- package/dist/form.js +12 -0
- package/dist/history/readers.d.ts +22 -0
- package/dist/history/readers.js +21 -0
- package/dist/history.d.ts +10 -0
- package/dist/history.js +11 -0
- package/dist/i18n/readers.svelte.d.ts +32 -0
- package/dist/i18n/readers.svelte.js +30 -0
- package/dist/i18n.d.ts +8 -0
- package/dist/i18n.js +9 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/interaction/PagePointerSource.svelte +37 -0
- package/dist/interaction/PagePointerSource.svelte.d.ts +3 -0
- package/dist/interaction/readers.svelte.d.ts +26 -0
- package/dist/interaction/readers.svelte.js +47 -0
- package/dist/interaction.d.ts +11 -0
- package/dist/interaction.js +13 -0
- package/dist/link/LinkLayer.svelte +164 -0
- package/dist/link/LinkLayer.svelte.d.ts +4 -0
- package/dist/link/props.d.ts +17 -0
- package/dist/link/props.js +1 -0
- package/dist/link/readers.svelte.d.ts +18 -0
- package/dist/link/readers.svelte.js +38 -0
- package/dist/link.d.ts +11 -0
- package/dist/link.js +11 -0
- package/dist/measurement/readers.d.ts +44 -0
- package/dist/measurement/readers.js +46 -0
- package/dist/measurement.d.ts +12 -0
- package/dist/measurement.js +13 -0
- package/dist/metadata/readers.d.ts +22 -0
- package/dist/metadata/readers.js +22 -0
- package/dist/metadata.d.ts +12 -0
- package/dist/metadata.js +13 -0
- package/dist/outline/readers.d.ts +26 -0
- package/dist/outline/readers.js +22 -0
- package/dist/outline.d.ts +12 -0
- package/dist/outline.js +13 -0
- package/dist/page-edit/readers.d.ts +17 -0
- package/dist/page-edit/readers.js +18 -0
- package/dist/page-edit.d.ts +12 -0
- package/dist/page-edit.js +13 -0
- package/dist/page-view/PageView.svelte +192 -0
- package/dist/page-view/PageView.svelte.d.ts +4 -0
- package/dist/page-view/props.d.ts +32 -0
- package/dist/page-view/props.js +1 -0
- package/dist/page-view.d.ts +8 -0
- package/dist/page-view.js +7 -0
- package/dist/redaction/readers.d.ts +37 -0
- package/dist/redaction/readers.js +38 -0
- package/dist/redaction.d.ts +12 -0
- package/dist/redaction.js +13 -0
- package/dist/render/RenderLayer.svelte +116 -0
- package/dist/render/RenderLayer.svelte.d.ts +4 -0
- package/dist/render/TileImage.svelte +65 -0
- package/dist/render/TileImage.svelte.d.ts +11 -0
- package/dist/render/TilePlane.svelte +88 -0
- package/dist/render/TilePlane.svelte.d.ts +7 -0
- package/dist/render/props.d.ts +16 -0
- package/dist/render/props.js +1 -0
- package/dist/render/readers.svelte.d.ts +9 -0
- package/dist/render/readers.svelte.js +13 -0
- package/dist/render.d.ts +10 -0
- package/dist/render.js +10 -0
- package/dist/runtime/DocumentGate.svelte +26 -0
- package/dist/runtime/DocumentGate.svelte.d.ts +4 -0
- package/dist/runtime/DocumentScope.svelte +14 -0
- package/dist/runtime/DocumentScope.svelte.d.ts +4 -0
- package/dist/runtime/KernelProvider.svelte +33 -0
- package/dist/runtime/KernelProvider.svelte.d.ts +4 -0
- package/dist/runtime/SvgShapes.svelte +30 -0
- package/dist/runtime/SvgShapes.svelte.d.ts +8 -0
- package/dist/runtime/Viewer.svelte +130 -0
- package/dist/runtime/Viewer.svelte.d.ts +4 -0
- package/dist/runtime/binding.svelte.d.ts +33 -0
- package/dist/runtime/binding.svelte.js +71 -0
- package/dist/runtime/capability-handle.d.ts +6 -0
- package/dist/runtime/capability-handle.js +71 -0
- package/dist/runtime/dev.d.ts +10 -0
- package/dist/runtime/dev.js +23 -0
- package/dist/runtime/documents.svelte.d.ts +34 -0
- package/dist/runtime/documents.svelte.js +49 -0
- package/dist/runtime/page-layers.svelte.d.ts +20 -0
- package/dist/runtime/page-layers.svelte.js +40 -0
- package/dist/runtime/page.d.ts +10 -0
- package/dist/runtime/page.js +23 -0
- package/dist/runtime/props.d.ts +63 -0
- package/dist/runtime/props.js +1 -0
- package/dist/runtime/readers.svelte.d.ts +47 -0
- package/dist/runtime/readers.svelte.js +122 -0
- package/dist/runtime/state.svelte.d.ts +35 -0
- package/dist/runtime/state.svelte.js +90 -0
- package/dist/runtime/theme.d.ts +12 -0
- package/dist/runtime/theme.js +15 -0
- package/dist/runtime/values.svelte.d.ts +28 -0
- package/dist/runtime/values.svelte.js +51 -0
- package/dist/runtime.d.ts +26 -0
- package/dist/runtime.js +25 -0
- package/dist/search/SearchLayer.svelte +94 -0
- package/dist/search/SearchLayer.svelte.d.ts +4 -0
- package/dist/search/props.d.ts +11 -0
- package/dist/search/props.js +1 -0
- package/dist/search/readers.svelte.d.ts +41 -0
- package/dist/search/readers.svelte.js +40 -0
- package/dist/search.d.ts +11 -0
- package/dist/search.js +11 -0
- package/dist/selection/SelectionClipboard.svelte +35 -0
- package/dist/selection/SelectionClipboard.svelte.d.ts +4 -0
- package/dist/selection/SelectionHandles.svelte +192 -0
- package/dist/selection/SelectionHandles.svelte.d.ts +4 -0
- package/dist/selection/SelectionLayer.svelte +67 -0
- package/dist/selection/SelectionLayer.svelte.d.ts +3 -0
- package/dist/selection/SelectionMenu.svelte +36 -0
- package/dist/selection/SelectionMenu.svelte.d.ts +4 -0
- package/dist/selection/props.d.ts +26 -0
- package/dist/selection/props.js +1 -0
- package/dist/selection/readers.svelte.d.ts +31 -0
- package/dist/selection/readers.svelte.js +26 -0
- package/dist/selection.d.ts +16 -0
- package/dist/selection.js +18 -0
- package/dist/shell/readers.svelte.d.ts +40 -0
- package/dist/shell/readers.svelte.js +40 -0
- package/dist/shell/surface-focus.svelte.d.ts +16 -0
- package/dist/shell/surface-focus.svelte.js +33 -0
- package/dist/shell.d.ts +12 -0
- package/dist/shell.js +11 -0
- package/dist/signature/readers.svelte.d.ts +43 -0
- package/dist/signature/readers.svelte.js +46 -0
- package/dist/signature.d.ts +15 -0
- package/dist/signature.js +16 -0
- package/dist/stage/PageSurface.svelte +126 -0
- package/dist/stage/PageSurface.svelte.d.ts +18 -0
- package/dist/stage/Scrollbar.svelte +148 -0
- package/dist/stage/Scrollbar.svelte.d.ts +4 -0
- package/dist/stage/Stage.svelte +181 -0
- package/dist/stage/Stage.svelte.d.ts +4 -0
- package/dist/stage/StageScope.svelte +14 -0
- package/dist/stage/StageScope.svelte.d.ts +9 -0
- package/dist/stage/props.d.ts +71 -0
- package/dist/stage/props.js +1 -0
- package/dist/stage/readers.svelte.d.ts +39 -0
- package/dist/stage/readers.svelte.js +84 -0
- package/dist/stage/stage-scope.d.ts +18 -0
- package/dist/stage/stage-scope.js +35 -0
- package/dist/stage/two-way.svelte.d.ts +13 -0
- package/dist/stage/two-way.svelte.js +26 -0
- package/dist/stage.d.ts +17 -0
- package/dist/stage.js +15 -0
- package/dist/stamp/readers.svelte.d.ts +50 -0
- package/dist/stamp/readers.svelte.js +76 -0
- package/dist/stamp.d.ts +16 -0
- package/dist/stamp.js +18 -0
- package/dist/toolbar/DefaultCollapsed.svelte +39 -0
- package/dist/toolbar/DefaultCollapsed.svelte.d.ts +9 -0
- package/dist/toolbar/DefaultCommand.svelte +33 -0
- package/dist/toolbar/DefaultCommand.svelte.d.ts +8 -0
- package/dist/toolbar/DefaultGroupTrigger.svelte +39 -0
- package/dist/toolbar/DefaultGroupTrigger.svelte.d.ts +9 -0
- package/dist/toolbar/DefaultOverflowMenu.svelte +106 -0
- package/dist/toolbar/DefaultOverflowMenu.svelte.d.ts +9 -0
- package/dist/toolbar/DefaultOverflowTrigger.svelte +25 -0
- package/dist/toolbar/DefaultOverflowTrigger.svelte.d.ts +7 -0
- package/dist/toolbar/Measured.svelte +46 -0
- package/dist/toolbar/Measured.svelte.d.ts +11 -0
- package/dist/toolbar/NativeSlotSocket.svelte +43 -0
- package/dist/toolbar/NativeSlotSocket.svelte.d.ts +11 -0
- package/dist/toolbar/Toolbar.svelte +314 -0
- package/dist/toolbar/Toolbar.svelte.d.ts +4 -0
- package/dist/toolbar/paint.d.ts +3 -0
- package/dist/toolbar/paint.js +9 -0
- package/dist/toolbar/props.d.ts +48 -0
- package/dist/toolbar/props.js +1 -0
- package/dist/toolbar/strip.svelte.d.ts +14 -0
- package/dist/toolbar/strip.svelte.js +35 -0
- package/dist/toolbar/views.d.ts +14 -0
- package/dist/toolbar/views.js +1 -0
- package/dist/toolbar.d.ts +16 -0
- package/dist/toolbar.js +12 -0
- package/dist/view-manager/readers.d.ts +19 -0
- package/dist/view-manager/readers.js +17 -0
- package/dist/view-manager.d.ts +11 -0
- package/dist/view-manager.js +12 -0
- package/package.json +207 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The focus ring of a field, painted above the field's picture and its see-through native
|
|
3
|
+
control. An inset outline on the box itself would sit under an opaque child, so rectangular
|
|
4
|
+
checkboxes and dropdowns would look unfocused while they are active in the native Tab order.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { cssText, formFocusRingStyleOf } from '@embedpdf/web';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
visible,
|
|
11
|
+
color,
|
|
12
|
+
}: {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
/** The ring's CSS color: the form's `focus.color` setting, through its CSS variable. */
|
|
15
|
+
color: string;
|
|
16
|
+
} = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if visible}
|
|
20
|
+
<span
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
data-embedpdf-form-focus-ring=""
|
|
23
|
+
style={cssText(formFocusRingStyleOf(color))}
|
|
24
|
+
></span>
|
|
25
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
visible: boolean;
|
|
3
|
+
/** The ring's CSS color: the form's `focus.color` setting, through its CSS variable. */
|
|
4
|
+
color: string;
|
|
5
|
+
};
|
|
6
|
+
declare const FormFocusRing: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type FormFocusRing = ReturnType<typeof FormFocusRing>;
|
|
8
|
+
export default FormFocusRing;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The form's fields on one page, painted as the engine draws them (their values, borders and
|
|
3
|
+
fonts), with real HTML controls people fill them in with, with or without the annotation
|
|
4
|
+
plugin. While it's on the page, the `<RenderLayer>` leaves the fields out of the page's picture.
|
|
5
|
+
The controls add what people interact with on top of the pictures:
|
|
6
|
+
|
|
7
|
+
text → the picture at rest; focus shows an editor in the field's font.
|
|
8
|
+
toggle → the picture is the control; a click writes the toggled value.
|
|
9
|
+
combo → an invisible native <select> over the picture.
|
|
10
|
+
list → a visible native <select>: one surface owns the rows, the keyboard and the
|
|
11
|
+
scrolling.
|
|
12
|
+
button → a native click target over the picture that runs its action.
|
|
13
|
+
signature → "sign here", or the signed field's details, with the signature plugin.
|
|
14
|
+
|
|
15
|
+
The controls show while the active tool fills forms (the `pointer` and `pan` tools do), and
|
|
16
|
+
stand down in design mode, where fields are boxes you select and move. What the viewer draws itself (the
|
|
17
|
+
focus ring, the edge of a field without a border, the editor) takes its colors from the form
|
|
18
|
+
settings, which the `--epdf-form-*` CSS variables override. The colors, the field looks, the
|
|
19
|
+
boxes' and controls' styles, and the toggle, text-field and list-box policies are
|
|
20
|
+
`@embedpdf/web`'s, the same for every framework; every control keeps its presses from the
|
|
21
|
+
Stage below (`WidgetBox.svelte`).
|
|
22
|
+
-->
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
25
|
+
// Loading a page's widgets and listing them as controls are host reads.
|
|
26
|
+
import { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';
|
|
27
|
+
import { InteractionToken } from '@embedpdf/plugin-interaction/contract/host';
|
|
28
|
+
import { usePage } from '../runtime/page.js';
|
|
29
|
+
import { usePaintsPagePart } from '../runtime/page-layers.svelte.js';
|
|
30
|
+
import {
|
|
31
|
+
shallowArray,
|
|
32
|
+
useOptionalCapability,
|
|
33
|
+
useOptionalSelector,
|
|
34
|
+
} from '../runtime/readers.svelte.js';
|
|
35
|
+
import ButtonControl from './ButtonControl.svelte';
|
|
36
|
+
import ComboControl from './ComboControl.svelte';
|
|
37
|
+
import FieldPictures from './FieldPictures.svelte';
|
|
38
|
+
import ListControl from './ListControl.svelte';
|
|
39
|
+
import { useFormColors } from './readers.svelte.js';
|
|
40
|
+
import SignatureControl from './SignatureControl.svelte';
|
|
41
|
+
import TextControl from './TextControl.svelte';
|
|
42
|
+
import ToggleControl from './ToggleControl.svelte';
|
|
43
|
+
|
|
44
|
+
const NO_WIDGETS: readonly FormWidgetItem[] = Object.freeze([]);
|
|
45
|
+
|
|
46
|
+
const page = usePage();
|
|
47
|
+
const form = useOptionalCapability(FormHostToken);
|
|
48
|
+
// While it's here with the form plugin, the page's picture leaves the fields to it.
|
|
49
|
+
usePaintsPagePart(() => (form.current ? page.ref : null), 'formFields');
|
|
50
|
+
const colors = useFormColors();
|
|
51
|
+
const active = useOptionalSelector(
|
|
52
|
+
InteractionToken,
|
|
53
|
+
(interaction) => interaction.activeToolEnables('form-fill'),
|
|
54
|
+
false,
|
|
55
|
+
);
|
|
56
|
+
// The same list until a widget on this page changes.
|
|
57
|
+
const items = useOptionalSelector(
|
|
58
|
+
FormHostToken,
|
|
59
|
+
(lens) => lens.listWidgets(page.ref),
|
|
60
|
+
NO_WIDGETS,
|
|
61
|
+
shallowArray,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// The page's widgets are read when the layer comes to it.
|
|
65
|
+
$effect(() => {
|
|
66
|
+
const lens = form.current;
|
|
67
|
+
const ref = page.ref;
|
|
68
|
+
if (lens) void lens.ensureLoaded(ref);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* One control per widget of a field (a radio group has a widget per button), made again for
|
|
73
|
+
* another document: a text box keeps its field's editing policy for its life.
|
|
74
|
+
*/
|
|
75
|
+
const keyOf = (item: FormWidgetItem) =>
|
|
76
|
+
`${page.documentId}:${item.key}:${item.annotObjectNumber}`;
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div style="position: absolute; inset: 0; pointer-events: none">
|
|
80
|
+
<FieldPictures />
|
|
81
|
+
{#if active.current}
|
|
82
|
+
{#each items.current as item (keyOf(item))}
|
|
83
|
+
{#if item.control === 'text'}
|
|
84
|
+
<TextControl {item} colors={colors.current} />
|
|
85
|
+
{:else if item.control === 'toggle'}
|
|
86
|
+
<ToggleControl {item} colors={colors.current} />
|
|
87
|
+
{:else if item.control === 'choice' && item.kind === 'list'}
|
|
88
|
+
<ListControl {item} colors={colors.current} />
|
|
89
|
+
{:else if item.control === 'choice'}
|
|
90
|
+
<ComboControl {item} colors={colors.current} />
|
|
91
|
+
{:else if item.control === 'button'}
|
|
92
|
+
<ButtonControl {item} colors={colors.current} />
|
|
93
|
+
{:else if item.control === 'signature'}
|
|
94
|
+
<SignatureControl {item} colors={colors.current} />
|
|
95
|
+
{/if}
|
|
96
|
+
{/each}
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A list: a visible native `<select>` in the field's own look, the settings where it has none.
|
|
3
|
+
It draws its own border, so the box gets no edge.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
7
|
+
import { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';
|
|
8
|
+
import { cssText, listBoxControlStyleOf, rectInPixels } from '@embedpdf/web';
|
|
9
|
+
import type { FormColors } from '@embedpdf/web';
|
|
10
|
+
import { usePage } from '../runtime/page.js';
|
|
11
|
+
import { useCapability } from '../runtime/readers.svelte.js';
|
|
12
|
+
import FormFocusRing from './FormFocusRing.svelte';
|
|
13
|
+
import NativeListBox from './NativeListBox.svelte';
|
|
14
|
+
import { useWidgetActivation } from './widget.js';
|
|
15
|
+
import WidgetBox from './WidgetBox.svelte';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
item,
|
|
19
|
+
colors,
|
|
20
|
+
}: { item: Extract<FormWidgetItem, { control: 'choice' }>; colors: FormColors } = $props();
|
|
21
|
+
|
|
22
|
+
const page = usePage();
|
|
23
|
+
const form = useCapability(FormHostToken);
|
|
24
|
+
const activate = useWidgetActivation(() => item.annotationRef);
|
|
25
|
+
let focused = $state(false);
|
|
26
|
+
|
|
27
|
+
const listStyle = $derived(
|
|
28
|
+
cssText(listBoxControlStyleOf(item, rectInPixels(item.box, page.transform), colors)),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
async function select(values: string[]) {
|
|
32
|
+
await form.setValue(item.fieldRef, { selectedValues: values });
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<WidgetBox {item} {colors} edge={false} onclick={activate}>
|
|
37
|
+
<NativeListBox
|
|
38
|
+
ariaLabel={item.label}
|
|
39
|
+
disabled={item.disabled}
|
|
40
|
+
multi={item.multi}
|
|
41
|
+
options={item.options}
|
|
42
|
+
selected={item.selected}
|
|
43
|
+
onSelect={select}
|
|
44
|
+
onfocus={() => (focused = true)}
|
|
45
|
+
onblur={() => (focused = false)}
|
|
46
|
+
style={listStyle}
|
|
47
|
+
/>
|
|
48
|
+
<FormFocusRing visible={focused} color={colors.focus} />
|
|
49
|
+
</WidgetBox>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
2
|
+
import type { FormColors } from '@embedpdf/web';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
item: Extract<FormWidgetItem, {
|
|
5
|
+
control: 'choice';
|
|
6
|
+
}>;
|
|
7
|
+
colors: FormColors;
|
|
8
|
+
};
|
|
9
|
+
declare const ListControl: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type ListControl = ReturnType<typeof ListControl>;
|
|
11
|
+
export default ListControl;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A PDF list box needs one owner for its pixels, its hit-testing and its scrolling. A baked
|
|
3
|
+
picture with an invisible native select can't give that: the browser and the PDF would each
|
|
4
|
+
keep their own top visible row. So the list is a visible native `<select>`, never made again
|
|
5
|
+
(its scroll position is the user's), showing a choice at once while the engine write is on its
|
|
6
|
+
way and the engine's selection when that changes (`@embedpdf/web`'s
|
|
7
|
+
`createOptimisticSelection`).
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { untrack } from 'svelte';
|
|
11
|
+
import { createOptimisticSelection, isolateWheel } from '@embedpdf/web';
|
|
12
|
+
import type { NativeListBoxProps } from './props.js';
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
ariaLabel,
|
|
16
|
+
disabled,
|
|
17
|
+
multi,
|
|
18
|
+
options,
|
|
19
|
+
selected,
|
|
20
|
+
onSelect,
|
|
21
|
+
onfocus,
|
|
22
|
+
onblur,
|
|
23
|
+
style = '',
|
|
24
|
+
}: NativeListBoxProps = $props();
|
|
25
|
+
|
|
26
|
+
const selection = untrack(() => createOptimisticSelection(selected));
|
|
27
|
+
let shown = $state.raw(selection.get());
|
|
28
|
+
$effect(() => selection.subscribe(() => (shown = selection.get())));
|
|
29
|
+
// The engine's selection, each time the field gives a new one.
|
|
30
|
+
$effect(() => selection.setConfirmed(selected));
|
|
31
|
+
|
|
32
|
+
function onChange(event: Event & { currentTarget: HTMLSelectElement }) {
|
|
33
|
+
const values = Array.from(event.currentTarget.selectedOptions).map((option) => option.value);
|
|
34
|
+
selection.choose(values, onSelect);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The Stage pans or zooms on the wheel from an ancestor: stop it at the list, so the browser
|
|
38
|
+
// scrolls the list with the same wheel event.
|
|
39
|
+
const ownWheel = (element: HTMLElement) => isolateWheel(element);
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<select
|
|
43
|
+
{@attach ownWheel}
|
|
44
|
+
aria-label={ariaLabel}
|
|
45
|
+
multiple={multi}
|
|
46
|
+
size={Math.max(2, options.length)}
|
|
47
|
+
{disabled}
|
|
48
|
+
value={multi ? shown : (shown[0] ?? '')}
|
|
49
|
+
{onfocus}
|
|
50
|
+
{onblur}
|
|
51
|
+
onchange={onChange}
|
|
52
|
+
{style}
|
|
53
|
+
>
|
|
54
|
+
{#each options as option, index (index)}
|
|
55
|
+
<option value={option.value}>{option.label}</option>
|
|
56
|
+
{/each}
|
|
57
|
+
</select>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A signature field. With the signature plugin, an empty field is "sign here" (a click makes it
|
|
3
|
+
the target the next mark goes to), and a signed one asks your UI to show its details
|
|
4
|
+
(`onInspectionRequested`). Without the plugin, or for a read-only empty field, it is only its
|
|
5
|
+
picture.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
9
|
+
import { SignatureToken } from '@embedpdf/plugin-signature/contract';
|
|
10
|
+
import type { FormColors } from '@embedpdf/web';
|
|
11
|
+
import { useOptionalCapability, useOptionalSelector } from '../runtime/readers.svelte.js';
|
|
12
|
+
import { FILL } from './widget.js';
|
|
13
|
+
import WidgetBox from './WidgetBox.svelte';
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
item,
|
|
17
|
+
colors,
|
|
18
|
+
}: { item: Extract<FormWidgetItem, { control: 'signature' }>; colors: FormColors } = $props();
|
|
19
|
+
|
|
20
|
+
const signature = useOptionalCapability(SignatureToken);
|
|
21
|
+
// The signature plugin knows best whether it's signed (it reads again after every new
|
|
22
|
+
// version); the field's own value is the fallback.
|
|
23
|
+
const known = useOptionalSelector(
|
|
24
|
+
SignatureToken,
|
|
25
|
+
(plugin) => plugin.getSignature(item.fieldRef)?.signed ?? null,
|
|
26
|
+
null,
|
|
27
|
+
);
|
|
28
|
+
const signed = $derived(known.current ?? item.signed);
|
|
29
|
+
const actionable = $derived(signature.current !== null && (signed || !item.disabled));
|
|
30
|
+
|
|
31
|
+
function onClick() {
|
|
32
|
+
const plugin = signature.current;
|
|
33
|
+
if (!plugin) return;
|
|
34
|
+
if (signed) plugin.requestInspection(item.fieldRef);
|
|
35
|
+
else plugin.setTarget(item.fieldRef);
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<WidgetBox {item} {colors} style="cursor: {actionable ? 'pointer' : 'default'}">
|
|
40
|
+
{#if actionable}
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
aria-label={item.label}
|
|
44
|
+
data-signed={signed ? '' : undefined}
|
|
45
|
+
onclick={onClick}
|
|
46
|
+
style={FILL}
|
|
47
|
+
style:padding="0"
|
|
48
|
+
style:border="0"
|
|
49
|
+
style:background="transparent"
|
|
50
|
+
style:cursor="inherit"
|
|
51
|
+
></button>
|
|
52
|
+
{/if}
|
|
53
|
+
</WidgetBox>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
2
|
+
import type { FormColors } from '@embedpdf/web';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
item: Extract<FormWidgetItem, {
|
|
5
|
+
control: 'signature';
|
|
6
|
+
}>;
|
|
7
|
+
colors: FormColors;
|
|
8
|
+
};
|
|
9
|
+
declare const SignatureControl: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type SignatureControl = ReturnType<typeof SignatureControl>;
|
|
11
|
+
export default SignatureControl;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A text box: the field's picture at rest, an editor in the field's own font while focused. The
|
|
3
|
+
editor is always mounted, see-through at rest: the DOM is the focus manager, so Tab reaches
|
|
4
|
+
every field. Typing drafts (the plugin keeps the draft, so a download writes it), blur or Enter
|
|
5
|
+
commits, Escape puts the value back: `@embedpdf/web`'s `createTextFieldEditor`.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { untrack } from 'svelte';
|
|
9
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
10
|
+
// The draft calls are the host lens's.
|
|
11
|
+
import { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';
|
|
12
|
+
import {
|
|
13
|
+
createFontMounts,
|
|
14
|
+
createTextFieldEditor,
|
|
15
|
+
cssText,
|
|
16
|
+
rectInPixels,
|
|
17
|
+
textFieldEditorStyleOf,
|
|
18
|
+
} from '@embedpdf/web';
|
|
19
|
+
import type { FormColors } from '@embedpdf/web';
|
|
20
|
+
import { usePage } from '../runtime/page.js';
|
|
21
|
+
import { useCapability } from '../runtime/readers.svelte.js';
|
|
22
|
+
import { useWidgetActivation } from './widget.js';
|
|
23
|
+
import WidgetBox from './WidgetBox.svelte';
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
item,
|
|
27
|
+
colors,
|
|
28
|
+
}: { item: Extract<FormWidgetItem, { control: 'text' }>; colors: FormColors } = $props();
|
|
29
|
+
|
|
30
|
+
const page = usePage();
|
|
31
|
+
const form = useCapability(FormHostToken);
|
|
32
|
+
const activate = useWidgetActivation(() => item.annotationRef);
|
|
33
|
+
|
|
34
|
+
// One editing policy per field: the layer keys this control by its document, field and
|
|
35
|
+
// widget, so the field stays the same for the control's life.
|
|
36
|
+
const editor = untrack(() => createTextFieldEditor(form, item.fieldRef, item.value));
|
|
37
|
+
let editing = $state.raw(editor.getState());
|
|
38
|
+
$effect(() => editor.subscribe(() => (editing = editor.getState())));
|
|
39
|
+
// Take the field's value whenever it changes under us; the editor keeps what's typed until
|
|
40
|
+
// the edit ends.
|
|
41
|
+
$effect(() => editor.setValue(item.value));
|
|
42
|
+
|
|
43
|
+
// The text being typed, where the engine will draw it, in its face.
|
|
44
|
+
const layout = $derived(
|
|
45
|
+
item.annotationRef ? form.getTextEditorLayout(item.annotationRef, editing.draft) : null,
|
|
46
|
+
);
|
|
47
|
+
const mounts = createFontMounts();
|
|
48
|
+
$effect(() => () => mounts.release());
|
|
49
|
+
$effect(() => {
|
|
50
|
+
if (layout) mounts.mount([layout.program]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const editorStyle = $derived(
|
|
54
|
+
cssText(
|
|
55
|
+
textFieldEditorStyleOf(
|
|
56
|
+
item,
|
|
57
|
+
rectInPixels(item.box, page.transform),
|
|
58
|
+
colors,
|
|
59
|
+
editing.focused,
|
|
60
|
+
layout,
|
|
61
|
+
),
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
function onInput(event: Event & { currentTarget: HTMLInputElement | HTMLTextAreaElement }) {
|
|
66
|
+
editor.input(event.currentTarget.value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function onKeyDown(
|
|
70
|
+
event: KeyboardEvent & { currentTarget: HTMLInputElement | HTMLTextAreaElement },
|
|
71
|
+
) {
|
|
72
|
+
if (editor.keyDown(event.key, item.multiline)) event.currentTarget.blur();
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<!--
|
|
77
|
+
A click runs the widget's action too, as in Acrobat: the editor's focus click bubbles here, a
|
|
78
|
+
read-only field's lands here directly.
|
|
79
|
+
-->
|
|
80
|
+
<WidgetBox {item} {colors} onclick={activate}>
|
|
81
|
+
{#if item.multiline}
|
|
82
|
+
<textarea
|
|
83
|
+
value={editing.draft}
|
|
84
|
+
maxlength={item.maxLength ?? undefined}
|
|
85
|
+
aria-label={item.label}
|
|
86
|
+
disabled={item.disabled}
|
|
87
|
+
style={editorStyle}
|
|
88
|
+
onfocus={editor.focus}
|
|
89
|
+
oninput={onInput}
|
|
90
|
+
onblur={editor.blur}
|
|
91
|
+
onkeydown={onKeyDown}
|
|
92
|
+
></textarea>
|
|
93
|
+
{:else}
|
|
94
|
+
<input
|
|
95
|
+
type={item.password ? 'password' : 'text'}
|
|
96
|
+
value={editing.draft}
|
|
97
|
+
maxlength={item.maxLength ?? undefined}
|
|
98
|
+
aria-label={item.label}
|
|
99
|
+
disabled={item.disabled}
|
|
100
|
+
style={editorStyle}
|
|
101
|
+
onfocus={editor.focus}
|
|
102
|
+
oninput={onInput}
|
|
103
|
+
onblur={editor.blur}
|
|
104
|
+
onkeydown={onKeyDown}
|
|
105
|
+
/>
|
|
106
|
+
{/if}
|
|
107
|
+
</WidgetBox>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
2
|
+
import type { FormColors } from '@embedpdf/web';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
item: Extract<FormWidgetItem, {
|
|
5
|
+
control: 'text';
|
|
6
|
+
}>;
|
|
7
|
+
colors: FormColors;
|
|
8
|
+
};
|
|
9
|
+
declare const TextControl: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type TextControl = ReturnType<typeof TextControl>;
|
|
11
|
+
export default TextControl;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
A checkbox or a radio button: the field's picture is the control, so the box itself takes the
|
|
3
|
+
role, the tab stop and the keys. A click, Space or Enter writes the toggled value, then runs
|
|
4
|
+
the widget's action (Acrobat's order: `@embedpdf/web`'s `pressToggle`).
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
8
|
+
// The value write and the activation go through the host lens, like the rest of the layer.
|
|
9
|
+
import { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';
|
|
10
|
+
import { pressToggle } from '@embedpdf/web';
|
|
11
|
+
import type { FormColors } from '@embedpdf/web';
|
|
12
|
+
import { useCapability } from '../runtime/readers.svelte.js';
|
|
13
|
+
import FormFocusRing from './FormFocusRing.svelte';
|
|
14
|
+
import { useWidgetActivation } from './widget.js';
|
|
15
|
+
import WidgetBox from './WidgetBox.svelte';
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
item,
|
|
19
|
+
colors,
|
|
20
|
+
}: { item: Extract<FormWidgetItem, { control: 'toggle' }>; colors: FormColors } = $props();
|
|
21
|
+
|
|
22
|
+
const form = useCapability(FormHostToken);
|
|
23
|
+
const activate = useWidgetActivation(() => item.annotationRef);
|
|
24
|
+
let focused = $state(false);
|
|
25
|
+
|
|
26
|
+
// The value first, then the widget's action.
|
|
27
|
+
const press = () => pressToggle(form, item, activate);
|
|
28
|
+
|
|
29
|
+
function onKeyDown(event: KeyboardEvent) {
|
|
30
|
+
if (event.key !== ' ' && event.key !== 'Enter') return;
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
press();
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<WidgetBox
|
|
37
|
+
{item}
|
|
38
|
+
{colors}
|
|
39
|
+
role={item.kind === 'checkbox' ? 'checkbox' : 'radio'}
|
|
40
|
+
aria-checked={item.checked}
|
|
41
|
+
aria-label={item.label}
|
|
42
|
+
tabindex={item.disabled ? -1 : 0}
|
|
43
|
+
onclick={press}
|
|
44
|
+
onkeydown={onKeyDown}
|
|
45
|
+
onfocus={() => (focused = true)}
|
|
46
|
+
onblur={() => (focused = false)}
|
|
47
|
+
style="cursor: {item.disabled ? 'default' : 'pointer'}; outline: none"
|
|
48
|
+
>
|
|
49
|
+
<FormFocusRing visible={focused} color={colors.focus} />
|
|
50
|
+
</WidgetBox>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
2
|
+
import type { FormColors } from '@embedpdf/web';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
item: Extract<FormWidgetItem, {
|
|
5
|
+
control: 'toggle';
|
|
6
|
+
}>;
|
|
7
|
+
colors: FormColors;
|
|
8
|
+
};
|
|
9
|
+
declare const ToggleControl: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type ToggleControl = ReturnType<typeof ToggleControl>;
|
|
11
|
+
export default ToggleControl;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The positioned box every control of `<FormLayer>` sits in: where the widget is on the page, the
|
|
3
|
+
widget's event surface (it always takes the pointer; the control inside gates the edits), and
|
|
4
|
+
the edge a field without a border of its own gets, so people see where to fill in.
|
|
5
|
+
`edge={false}` leaves the edge out for controls that draw their own (a list box) or never have
|
|
6
|
+
one (a button). Every other attribute (a role, a tab stop, keys) goes on the box itself: a
|
|
7
|
+
checkbox's box is its control.
|
|
8
|
+
|
|
9
|
+
The box keeps every press that starts in it from the page below. The Stage listens natively on
|
|
10
|
+
an ancestor, and a press reaching it would start the active tool's gesture or end an edit as a
|
|
11
|
+
click outside; Svelte hands `onpointerdown` to the app's root, after the Stage saw the press,
|
|
12
|
+
so the box stops it with a native listener (`isolatePointerDown`). The widget's pointer and
|
|
13
|
+
focus events (its `/AA` actions: enter, exit, down, up, focus, blur) go to the form plugin from
|
|
14
|
+
native listeners on the same box (`bindWidgetEvents`), never the control inside: "may edit this
|
|
15
|
+
field" and "may receive PDF action events" are different rights, and a session that may not
|
|
16
|
+
fill still sees hover tooltips. That `pointerdown` listener sits on the element that stops the
|
|
17
|
+
press, so the stopped press still reaches the field's "mouse down" action. Focus is
|
|
18
|
+
`focusin`/`focusout`, so a control's own blur (where a text field starts its commit) runs
|
|
19
|
+
before the box sends "blur", and a blur script sees the committed value.
|
|
20
|
+
-->
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import type { Snippet } from 'svelte';
|
|
23
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
24
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
25
|
+
// The widget's PDF events go to the plugin's host lens.
|
|
26
|
+
import { FormToken as FormHostToken } from '@embedpdf/plugin-form/contract/host';
|
|
27
|
+
import {
|
|
28
|
+
bindWidgetEvents,
|
|
29
|
+
cssText,
|
|
30
|
+
isolatePointerDown,
|
|
31
|
+
rectInPixels,
|
|
32
|
+
widgetBoxStyleOf,
|
|
33
|
+
} from '@embedpdf/web';
|
|
34
|
+
import type { FormColors } from '@embedpdf/web';
|
|
35
|
+
import { usePage } from '../runtime/page.js';
|
|
36
|
+
import { useCapability } from '../runtime/readers.svelte.js';
|
|
37
|
+
|
|
38
|
+
let {
|
|
39
|
+
item,
|
|
40
|
+
colors,
|
|
41
|
+
edge = true,
|
|
42
|
+
style = '',
|
|
43
|
+
children,
|
|
44
|
+
...rest
|
|
45
|
+
}: {
|
|
46
|
+
item: FormWidgetItem;
|
|
47
|
+
colors: FormColors;
|
|
48
|
+
edge?: boolean;
|
|
49
|
+
/** More style for the box, after its own place. */
|
|
50
|
+
style?: string;
|
|
51
|
+
children?: Snippet;
|
|
52
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'children'> = $props();
|
|
53
|
+
|
|
54
|
+
const page = usePage();
|
|
55
|
+
const form = useCapability(FormHostToken);
|
|
56
|
+
// The box's own place and edge, then the control's additions (a cursor, an outline).
|
|
57
|
+
const boxStyle = $derived(
|
|
58
|
+
[
|
|
59
|
+
cssText(widgetBoxStyleOf(item, rectInPixels(item.box, page.transform), colors, { edge })),
|
|
60
|
+
style,
|
|
61
|
+
]
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.join('; '),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
function eventSurface(box: HTMLElement): () => void {
|
|
67
|
+
const release = isolatePointerDown(box);
|
|
68
|
+
const unbind = bindWidgetEvents(box, (event) => {
|
|
69
|
+
// Read at the event: a widget the engine has just placed gets its address later.
|
|
70
|
+
const { fieldRef, annotationRef } = item;
|
|
71
|
+
if (annotationRef) form.notifyWidgetEvent(fieldRef, annotationRef, event);
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
release();
|
|
75
|
+
unbind();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<div {@attach eventSurface} {...rest} style={boxStyle}>
|
|
81
|
+
{@render children?.()}
|
|
82
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { FormWidgetItem } from '@embedpdf/plugin-form';
|
|
4
|
+
import type { FormColors } from '@embedpdf/web';
|
|
5
|
+
type $$ComponentProps = {
|
|
6
|
+
item: FormWidgetItem;
|
|
7
|
+
colors: FormColors;
|
|
8
|
+
edge?: boolean;
|
|
9
|
+
/** More style for the box, after its own place. */
|
|
10
|
+
style?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'style' | 'children'>;
|
|
13
|
+
declare const WidgetBox: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type WidgetBox = ReturnType<typeof WidgetBox>;
|
|
15
|
+
export default WidgetBox;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The props of the form layer's own parts. */
|
|
2
|
+
import type { FocusEventHandler } from 'svelte/elements';
|
|
3
|
+
/** One row of a list box: what it shows, and the value it stands for. */
|
|
4
|
+
export interface NativeListBoxOption {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
/** The props of the list box `<FormLayer>` draws over a list field. */
|
|
9
|
+
export interface NativeListBoxProps {
|
|
10
|
+
ariaLabel: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
multi: boolean;
|
|
13
|
+
options: readonly NativeListBoxOption[];
|
|
14
|
+
/** The engine's selection: the list shows it whenever it changes. */
|
|
15
|
+
selected: readonly string[];
|
|
16
|
+
/** Write the chosen values; a promise that rejects puts the engine's selection back. */
|
|
17
|
+
onSelect(values: string[]): void | Promise<unknown>;
|
|
18
|
+
onfocus?: FocusEventHandler<HTMLSelectElement>;
|
|
19
|
+
onblur?: FocusEventHandler<HTMLSelectElement>;
|
|
20
|
+
style?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|