-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
import {
FigspecFrameViewer as FigspecFrameViewerElement,
FigspecFileViewer as FigspecFileViewerElement,
} from "@figspec/components";
import { createComponent } from "@lit-labs/react";
import * as React from "react";
import type { ForwardRefExoticComponent, RefAttributes } from "react";
export type FigspecPreferences = FigspecFileViewerElement["preferences"];
// Frame viewer
type FigspecFrameViewerElementProps =
// Required props
Pick<
FigspecFrameViewerElement,
// Element props
"apiResponse" | "renderedImage"
> &
// Optional props
Partial<
Pick<
FigspecFrameViewerElement,
// HTML attributes
| "id"
| "className"
| "style"
// Element attributes (will be converted to kebab-case)
| "link"
| "preferences"
>
>;
interface FigspecFrameViewerEvents {
onNodeSelect?(ev: CustomEvent<{ selectedNode: unknown | null }>): void;
onPreferencesUpdate?(
ev: CustomEvent<{ preferences: FigspecPreferences }>
): void;
}
export type FigspecFrameViewerProps = FigspecFrameViewerElementProps &
FigspecFrameViewerEvents;
// NOTE: These exported components are casted with `as unknown as ...` in order not to break
// typings accidentally. `as unknown` is required because a component created by
// `createComponent` has `RefAttributes<unknown>`, which is incompatible with existing
// type signature (and breaks ref typings). Also the explicit props definition prevents
// every properties turns into optional.
export const FigspecFrameViewer = createComponent({
react: React,
tagName: "figspec-frame-viewer",
elementClass: FigspecFrameViewerElement,
events: {
onNodeSelect: "nodeselect",
onPreferencesUpdate: "preferencesupdate",
},
}) as unknown as ForwardRefExoticComponent<
FigspecFrameViewerProps & RefAttributes<FigspecFrameViewerElement>
>;
// File viewer
type FigspecFileViewerElementProps =
// Required props
Pick<
FigspecFileViewerElement,
// Element props
"apiResponse" | "renderedImages"
> &
// Optional props
Partial<
Pick<
FigspecFileViewerElement,
// HTML attributes
| "id"
| "className"
| "style"
// Element attributes (will be converted to kebab-case)
| "link"
| "preferences"
>
>;
interface FigspecFileViewerEvents {
onNodeSelect?(ev: CustomEvent<{ selectedNode: unknown | null }>): void;
onPreferencesUpdate?(
ev: CustomEvent<{ preferences: FigspecPreferences }>
): void;
}
export type FigspecFileViewerProps = FigspecFileViewerElementProps &
FigspecFileViewerEvents;
export const FigspecFileViewer = createComponent({
react: React,
tagName: "figspec-file-viewer",
elementClass: FigspecFileViewerElement,
events: {
onNodeSelect: "nodeselect",
onPreferencesUpdate: "preferencesupdate",
},
}) as unknown as ForwardRefExoticComponent<
FigspecFileViewerProps & RefAttributes<FigspecFileViewerElement>
>;