react-iiif-vault 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -5,6 +5,9 @@ import React__default, { ReactNode, FunctionComponent, RefObject } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { InternationalString, ImageService, ImageSize, AuthProbeService2, Auth2LocationResource, Auth2SubstituteResource, AuthAccessService2, AuthAccessTokenService2, AuthAccessToken2, SearchServiceQueryParams, SearchServiceSearchResponse, SearchService as SearchService$1, SearchServiceAutocomplete, Reference, Annotation } from '@iiif/presentation-3';
7
7
  import { RegionParameter, RotationParameter, SizeParameter, ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@atlas-viewer/iiif-image-api';
8
+ import * as polygon_editor from 'polygon-editor';
9
+ import { RenderState, InputShape, SlowState } from 'polygon-editor';
10
+ import { BoxStyle, Preset } from '@atlas-viewer/atlas';
8
11
  import * as zustand_vanilla from 'zustand/vanilla';
9
12
  import { StoreApi } from 'zustand/vanilla';
10
13
  import { Vault, VaultOptions, NormalizedEntity, IIIFStore } from '@iiif/helpers/vault';
@@ -12,7 +15,8 @@ import * as zustand from 'zustand';
12
15
  import * as _iiif_helpers from '@iiif/helpers';
13
16
  import { Paintables } from '@iiif/helpers';
14
17
  import { CanvasNormalized, AnnotationNormalized, AnnotationPageNormalized, CollectionNormalized, ManifestNormalized, RangeNormalized } from '@iiif/presentation-3-normalized';
15
- import { Preset } from '@atlas-viewer/atlas';
18
+ import * as mitt from 'mitt';
19
+ import { Handler } from 'mitt';
16
20
  import { R as RenderingStrategy } from './useRenderingStrategy-Xj9yQm4y.cjs';
17
21
  export { e as AnnotationPageDescription, A as AudioSequence, C as ComplexTimelineStrategy, E as EmptyStrategy, j as ImageServiceLoaderType, I as ImageWithOptionalService, M as MediaStrategy, h as Single3DModelStrategy, b as SingleAudio, a as SingleImageStrategy, c as SingleVideo, d as SingleYouTubeVideo, S as StrategyActions, T as TextualContentStrategy, U as UnknownStrategy, k as UseRenderingStrategy, l as UseRenderingStrategyOptions, V as VideoSequence, i as get3dStrategy, g as getImageStrategy, f as getTextualContentStrategy, u as useLoadImageService, m as useRenderingStrategy } from './useRenderingStrategy-Xj9yQm4y.cjs';
18
22
  export { emptyActions, emptyStrategy, getParsedTargetSelector, getRenderingStrategy, parseSpecificResource, unknownResponse, unsupportedStrategy } from './utils.cjs';
@@ -138,6 +142,177 @@ interface SingleCanvasThumbnailProps {
138
142
  }
139
143
  declare function SingleCanvasThumbnail(props: SingleCanvasThumbnailProps): react_jsx_runtime.JSX.Element;
140
144
 
145
+ interface SvgEditorOptions {
146
+ image: {
147
+ height: number;
148
+ width: number;
149
+ };
150
+ currentShape: InputShape | null;
151
+ onChange: (e: InputShape) => void;
152
+ hideShapeLines?: boolean;
153
+ }
154
+ declare function useSvgEditor(options: SvgEditorOptions, deps: any[]): {
155
+ helper: {
156
+ draw: {
157
+ enable(): void;
158
+ disable(): void;
159
+ toggle(): void;
160
+ };
161
+ state: RenderState;
162
+ modifiers: {
163
+ reset(): void;
164
+ getForType(type: string | null): Record<string, string>;
165
+ set(modifier: string): void;
166
+ unset(modifier: string): void;
167
+ };
168
+ stamps: {
169
+ set(selectedStamp: InputShape | null): void;
170
+ clear(): void;
171
+ square(): void;
172
+ triangle(): void;
173
+ pentagon(): void;
174
+ hexagon(): void;
175
+ };
176
+ key: {
177
+ down(key: string): true | undefined;
178
+ up(key: string): void;
179
+ };
180
+ setScale: (scale: number) => void;
181
+ clock: {
182
+ set: (renderFunc: polygon_editor.RenderFunc) => void;
183
+ start: (renderFunc?: polygon_editor.RenderFunc | undefined, setStateFunc?: polygon_editor.SetState | undefined) => void;
184
+ stop: () => void;
185
+ step: (deltaTime?: number | undefined) => void;
186
+ };
187
+ pointer: (pointers: ([number, number] | [number, number, number, number, number, number])[]) => void;
188
+ blur: () => void;
189
+ pointerDown: () => void;
190
+ pointerUp: () => void;
191
+ setShape: (shape: InputShape | null) => void;
192
+ modes: {
193
+ toggleLineBoxMode: () => void;
194
+ toggleLineMode: () => void;
195
+ enableLineMode(): void;
196
+ disableLineMode(): void;
197
+ enableLineBoxMode(): void;
198
+ disableLineBoxMode(): void;
199
+ };
200
+ label: (type: string | null) => string;
201
+ };
202
+ state: SlowState;
203
+ isAddingPoint: boolean;
204
+ isSplitting: boolean;
205
+ isStamping: boolean | null;
206
+ isHoveringPoint: boolean;
207
+ transitionDirection: string | null;
208
+ transitionRotate: boolean;
209
+ defs: react_jsx_runtime.JSX.Element;
210
+ editor: react_jsx_runtime.JSX.Element | null;
211
+ };
212
+
213
+ type HelperType$1 = ReturnType<typeof useSvgEditor>['helper'];
214
+ type StateType$1 = ReturnType<typeof useSvgEditor>['state'];
215
+ interface RenderSvgEditorControlsProps {
216
+ helper: HelperType$1;
217
+ state: StateType$1;
218
+ showShapes: boolean;
219
+ classNames?: Partial<{
220
+ button: string;
221
+ }>;
222
+ enabled?: {
223
+ draw?: boolean;
224
+ polygon?: boolean;
225
+ line?: boolean;
226
+ lineBox?: boolean;
227
+ square?: boolean;
228
+ triangle?: boolean;
229
+ hexagon?: boolean;
230
+ circle?: boolean;
231
+ delete?: boolean;
232
+ };
233
+ icons?: Partial<{
234
+ DrawIcon: ReactNode;
235
+ PolygonIcon: ReactNode;
236
+ LineIcon: ReactNode;
237
+ LineBoxIcon: ReactNode;
238
+ ShapesIcon: ReactNode;
239
+ SquareIcon: ReactNode;
240
+ TriangleIcon: ReactNode;
241
+ HexagonIcon: ReactNode;
242
+ CircleIcon: ReactNode;
243
+ DeleteForeverIcon: ReactNode;
244
+ }>;
245
+ }
246
+ declare function RenderSvgEditorControls({ helper, showShapes, state, enabled, classNames, icons, }: RenderSvgEditorControlsProps): react_jsx_runtime.JSX.Element;
247
+
248
+ declare const svgThemes: ({
249
+ name: string;
250
+ outer: {
251
+ borderWidth: number;
252
+ borderColor: string;
253
+ };
254
+ inner: {
255
+ borderWidth: number;
256
+ borderColor: string;
257
+ };
258
+ } | {
259
+ name: string;
260
+ outer: {
261
+ borderWidth: string;
262
+ borderColor: string;
263
+ };
264
+ inner: {
265
+ borderWidth: string;
266
+ borderColor: string;
267
+ };
268
+ } | {
269
+ name: string;
270
+ outer: {
271
+ borderWidth: string;
272
+ borderColor: string;
273
+ };
274
+ inner: {
275
+ borderWidth?: undefined;
276
+ borderColor?: undefined;
277
+ };
278
+ })[];
279
+ type HelperType = ReturnType<typeof useSvgEditor>['helper'];
280
+ type StateType = ReturnType<typeof useSvgEditor>['state'];
281
+ type SvgTheme = {
282
+ name?: string;
283
+ outer: BoxStyle;
284
+ inner: BoxStyle;
285
+ };
286
+ interface CreateCustomShapeProps {
287
+ image: {
288
+ width: number;
289
+ height: number;
290
+ };
291
+ shape?: any;
292
+ updateShape: any;
293
+ theme?: {
294
+ name?: string;
295
+ outer: BoxStyle;
296
+ inner: BoxStyle;
297
+ };
298
+ controlsHtmlId?: string;
299
+ renderControls?: (helper: HelperType, state: StateType, showShapes: boolean) => any;
300
+ }
301
+ declare function CreateCustomShape(props: CreateCustomShapeProps): react_jsx_runtime.JSX.Element;
302
+
303
+ interface PolygonSelectorProps {
304
+ id: string;
305
+ polygon: InputShape;
306
+ annotationBucket?: string;
307
+ isHighlighted?: boolean;
308
+ updatePolygon?: (shape: InputShape) => void;
309
+ readOnly?: boolean;
310
+ theme?: SvgTheme;
311
+ controlsHtmlId?: string;
312
+ renderControls?: CreateCustomShapeProps['renderControls'];
313
+ }
314
+ declare function PolygonSelector(props: PolygonSelectorProps): react_jsx_runtime.JSX.Element | null;
315
+
141
316
  declare function AnnotationContext({ annotation, children }: {
142
317
  annotation: string;
143
318
  children: ReactNode;
@@ -409,6 +584,106 @@ declare function useViewerPreset(): Preset | null | undefined;
409
584
  declare const ImageServiceLoaderContext: React__default.Context<ImageServiceLoader>;
410
585
  declare function useImageServiceLoader(): ImageServiceLoader;
411
586
 
587
+ type SelectorHelperEventTypes = 'click' | 'hover' | 'selector-updated' | 'highlight' | 'clear-highlight' | 'zoom-to' | 'event-listener' | 'remove-event-listener' | 'image-preview-request';
588
+ declare function SelectorControllerProvider({ children }: {
589
+ children: ReactNode;
590
+ }): react_jsx_runtime.JSX.Element;
591
+ declare function useSelectorEmitter(): mitt.Emitter<Record<mitt.EventType, unknown>>;
592
+ declare function useSelectorEvents(id: string): {
593
+ controller: {
594
+ withSelector(selectorId: string): {
595
+ on<T extends {
596
+ selectorId: string;
597
+ } = any>(type: SelectorHelperEventTypes, handler: Handler<T>): () => void;
598
+ emit<T_1 = any>(type: SelectorHelperEventTypes, event: T_1): void;
599
+ };
600
+ on<T_2 extends {
601
+ selectorId: string;
602
+ } = any>(type: SelectorHelperEventTypes, handler: Handler<T_2>): () => void;
603
+ emit<T_3 extends {
604
+ selectorId: string;
605
+ } = any>(type: SelectorHelperEventTypes, event: T_3): void;
606
+ };
607
+ onClick: (e?: {
608
+ x: number;
609
+ y: number;
610
+ width: number;
611
+ height: number;
612
+ }) => void;
613
+ onHover: (e?: {
614
+ x: number;
615
+ y: number;
616
+ width: number;
617
+ height: number;
618
+ }) => void;
619
+ isHighlighted: boolean;
620
+ };
621
+ declare function useSelectorController(): {
622
+ withSelector(selectorId: string): {
623
+ on<T extends {
624
+ selectorId: string;
625
+ } = any>(type: SelectorHelperEventTypes, handler: Handler<T>): () => void;
626
+ emit<T_1 = any>(type: SelectorHelperEventTypes, event: T_1): void;
627
+ };
628
+ on<T_2 extends {
629
+ selectorId: string;
630
+ } = any>(type: SelectorHelperEventTypes, handler: Handler<T_2>): () => void;
631
+ emit<T_3 extends {
632
+ selectorId: string;
633
+ } = any>(type: SelectorHelperEventTypes, event: T_3): void;
634
+ };
635
+ declare function useSelectorHelper(): {
636
+ withSelector(selectorId: string): {
637
+ highlight(): void;
638
+ clearHighlight(): void;
639
+ zoomTo(): void;
640
+ addEventListener(name: string, callback: () => void): () => void;
641
+ getImagePreview(): Promise<any>;
642
+ on<T extends {
643
+ selectorId: string;
644
+ } = any>(type: SelectorHelperEventTypes, handler: Handler<T>): () => void;
645
+ };
646
+ highlight(selectorId: string): void;
647
+ clearHighlight(selectorId: string): void;
648
+ zoomTo(selectorId: string): void;
649
+ addEventListener(selectorId: string, name: string, callback: () => void): () => void;
650
+ getImagePreview(selectorId: string): Promise<any>;
651
+ on<T_1 extends {
652
+ selectorId: string;
653
+ } = any>(type: SelectorHelperEventTypes, handler: Handler<T_1>): () => void;
654
+ };
655
+
656
+ interface AnnotationStyles {
657
+ id: number;
658
+ name: string;
659
+ creator?: {
660
+ id: number;
661
+ name: string;
662
+ };
663
+ createdAt: Date;
664
+ theme: {
665
+ default: AnnotationThemeDefinition;
666
+ hidden: AnnotationThemeDefinition;
667
+ highlighted: AnnotationThemeDefinition;
668
+ } & Record<string, AnnotationThemeDefinition>;
669
+ }
670
+ type AnnotationThemeDefinition = BoxStyle & {
671
+ hidden?: boolean;
672
+ interactive?: boolean;
673
+ hotspot?: boolean;
674
+ hotspotSize?: 'lg' | 'md' | 'sm';
675
+ };
676
+ declare function getDefaultAnnotationStyles(): AnnotationStyles['theme'];
677
+ declare function useAnnotationStyles(): {
678
+ default: AnnotationThemeDefinition;
679
+ hidden: AnnotationThemeDefinition;
680
+ highlighted: AnnotationThemeDefinition;
681
+ } & Record<string, AnnotationThemeDefinition>;
682
+ declare function AnnotationStyleProvider({ theme, children, }: {
683
+ theme?: AnnotationStyles['theme'];
684
+ children: React.ReactNode;
685
+ }): react_jsx_runtime.JSX.Element;
686
+
412
687
  declare function getVideoStrategy(canvas: CanvasNormalized, paintables: Paintables): RenderingStrategy;
413
688
 
414
689
  declare function useAnnotation(options?: {
@@ -617,6 +892,57 @@ declare function VirtualAnnotationProvider({ children }: {
617
892
  children: any;
618
893
  }): react_jsx_runtime.JSX.Element;
619
894
 
895
+ declare function usePolygonHelper(data: any, render: (t: any, s: any) => void, commitShape: (shape: InputShape) => void): {
896
+ state: SlowState;
897
+ helper: {
898
+ draw: {
899
+ enable(): void;
900
+ disable(): void;
901
+ toggle(): void;
902
+ };
903
+ state: polygon_editor.RenderState;
904
+ modifiers: {
905
+ reset(): void;
906
+ getForType(type: string | null): Record<string, string>;
907
+ set(modifier: string): void;
908
+ unset(modifier: string): void;
909
+ };
910
+ stamps: {
911
+ set(selectedStamp: InputShape | null): void;
912
+ clear(): void;
913
+ square(): void;
914
+ triangle(): void;
915
+ pentagon(): void;
916
+ hexagon(): void;
917
+ };
918
+ key: {
919
+ down(key: string): true | undefined;
920
+ up(key: string): void;
921
+ };
922
+ setScale: (scale: number) => void;
923
+ clock: {
924
+ set: (renderFunc: polygon_editor.RenderFunc) => void;
925
+ start: (renderFunc?: polygon_editor.RenderFunc | undefined, setStateFunc?: polygon_editor.SetState | undefined) => void;
926
+ stop: () => void;
927
+ step: (deltaTime?: number | undefined) => void;
928
+ };
929
+ pointer: (pointers: ([number, number] | [number, number, number, number, number, number])[]) => void;
930
+ blur: () => void;
931
+ pointerDown: () => void;
932
+ pointerUp: () => void;
933
+ setShape: (shape: InputShape | null) => void;
934
+ modes: {
935
+ toggleLineBoxMode: () => void;
936
+ toggleLineMode: () => void;
937
+ enableLineMode(): void;
938
+ disableLineMode(): void;
939
+ enableLineBoxMode(): void;
940
+ disableLineBoxMode(): void;
941
+ };
942
+ label: (type: string | null) => string;
943
+ };
944
+ };
945
+
620
946
  declare function flattenAnnotationPageIds({ canvas, manifest, all, canvases, }: {
621
947
  manifest?: ManifestNormalized;
622
948
  canvas?: CanvasNormalized;
@@ -624,11 +950,16 @@ declare function flattenAnnotationPageIds({ canvas, manifest, all, canvases, }:
624
950
  all?: boolean;
625
951
  }): string[];
626
952
 
953
+ declare function TranslationProvider(props: {
954
+ translations: Record<string, string>;
955
+ children: ReactNode;
956
+ }): react_jsx_runtime.JSX.Element;
627
957
  declare function LanguageProvider(props: {
628
958
  language: string;
629
959
  children: ReactNode;
630
960
  }): react_jsx_runtime.JSX.Element;
631
961
  declare function useIIIFLanguage(): string;
962
+ declare function useTranslations(): Record<string, string>;
632
963
  type LanguageStringProps = {
633
964
  [key: string]: any;
634
965
  } & {
@@ -638,8 +969,8 @@ type LanguageStringProps = {
638
969
  };
639
970
  declare function LanguageString({ as: Component, language, children, viewingDirection, ...props }: LanguageStringProps): react_jsx_runtime.JSX.Element;
640
971
  declare const useClosestLanguage: (getLanguages: () => string[], deps?: any[]) => string | undefined;
641
- declare function useLocaleString(inputText: InternationalString | string | null | undefined, defaultText?: string, separator?: string): readonly [string, string | undefined];
642
- declare function useCreateLocaleString(): (inputText: InternationalString | string | null | undefined, defaultText?: string, separator?: string) => string;
972
+ declare function useLocaleString(inputText: InternationalString | string | null | undefined, defaultText?: string, separator?: string, translations?: Record<string, string>): readonly [string, string | undefined];
973
+ declare function useCreateLocaleString(): (inputText: InternationalString | string | null | undefined, defaultText?: string, separator?: string, translations?: Record<string, string>) => string;
643
974
  type LocaleStringProps = {
644
975
  as?: string | React__default.FC<any>;
645
976
  defaultText?: string;
@@ -719,4 +1050,4 @@ declare function findAllCanvasesInRange(vault: Vault, range: RangeNormalized): A
719
1050
  declare function findManifestSelectedRange(vault: Vault, manifest: ManifestNormalized, canvasId: string): null | RangeNormalized;
720
1051
  declare function findSelectedRange(vault: Vault, range: RangeNormalized, canvasId: string): null | RangeNormalized;
721
1052
 
722
- export { AnnotationContext, AnnotationPageContext, Auth, type AuthAccessState, type AuthContextActions, type AuthContextCurrentActions, type AuthContextState, AuthProvider, AuthProvider_Old, AuthRContext, AuthReactContext, AuthReactContextActions, type AuthState, CanvasAnnotations, CanvasContext, CollectionContext, CombinedMetadata, ContextBridge, Image, type ImageProps, ImageServiceLoaderContext, type ImageServiceRequestOptions, InnerViewerProvider, LanguageProvider, LanguageString, LocaleString, ManifestContext, ManifestMetadata, type MediaPlayerActions, MediaPlayerProvider, type MediaPlayerState, Metadata, type MetadataProps, type ProbeStore, RangeContext, ReactVaultContext, RenderingStrategy, type ResourceContextType, ResourceProvider, ResourceReactContext, type ResourceRequestOptions, SequenceThumbnails, SimpleViewerContext, SimpleViewerProps, SimpleViewerProvider, SimpleViewerReactContext, SingleCanvasThumbnail, type VaultActivatedAnnotation, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, authDetailsForResource, createAuthStateStore, createProbe, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getManifestSequence, getVideoStrategy, getVisibleCanvasesFromCanvasId, hasAuth, makeAccessServiceRequest, makeAccessTokenRequest, useAnnotation, useAnnotationPage, useAnnotationPageManager, useAnnotationsAtTime, useAuthActions, useAuthActions_old, useAuthService, useAuthService_old, useAuthStore, useAuthToken, useAuthToken_old, useAuthTokens, useAuthTokens_old, useCanvas, useCanvasClock, useCanvasSequence, useCanvasSubset, useClosestLanguage, useCollection, useContextBridge, useCreateLocaleString, useCurrentAuth, useCurrentAuth_old, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useIIIFLanguage, useImage, useImageService, useImageServiceLoader, useImageTile, useIsAuthEnabled, useLocaleString, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
1053
+ export { AnnotationContext, AnnotationPageContext, AnnotationStyleProvider, type AnnotationStyles, type AnnotationThemeDefinition, Auth, type AuthAccessState, type AuthContextActions, type AuthContextCurrentActions, type AuthContextState, AuthProvider, AuthProvider_Old, AuthRContext, AuthReactContext, AuthReactContextActions, type AuthState, CanvasAnnotations, CanvasContext, CollectionContext, CombinedMetadata, ContextBridge, CreateCustomShape, type CreateCustomShapeProps, Image, type ImageProps, ImageServiceLoaderContext, type ImageServiceRequestOptions, InnerViewerProvider, LanguageProvider, LanguageString, LocaleString, ManifestContext, ManifestMetadata, type MediaPlayerActions, MediaPlayerProvider, type MediaPlayerState, Metadata, type MetadataProps, PolygonSelector, type PolygonSelectorProps, type ProbeStore, RangeContext, ReactVaultContext, RenderSvgEditorControls, RenderingStrategy, type ResourceContextType, ResourceProvider, ResourceReactContext, type ResourceRequestOptions, SelectorControllerProvider, type SelectorHelperEventTypes, SequenceThumbnails, SimpleViewerContext, SimpleViewerProps, SimpleViewerProvider, SimpleViewerReactContext, SingleCanvasThumbnail, type SvgTheme, TranslationProvider, type VaultActivatedAnnotation, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, authDetailsForResource, createAuthStateStore, createProbe, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getDefaultAnnotationStyles, getManifestSequence, getVideoStrategy, getVisibleCanvasesFromCanvasId, hasAuth, makeAccessServiceRequest, makeAccessTokenRequest, svgThemes, useAnnotation, useAnnotationPage, useAnnotationPageManager, useAnnotationStyles, useAnnotationsAtTime, useAuthActions, useAuthActions_old, useAuthService, useAuthService_old, useAuthStore, useAuthToken, useAuthToken_old, useAuthTokens, useAuthTokens_old, useCanvas, useCanvasClock, useCanvasSequence, useCanvasSubset, useClosestLanguage, useCollection, useContextBridge, useCreateLocaleString, useCurrentAuth, useCurrentAuth_old, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useIIIFLanguage, useImage, useImageService, useImageServiceLoader, useImageTile, useIsAuthEnabled, useLocaleString, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, usePolygonHelper, useRange, useResourceContext, useResourceEvents, useResources, useSearchService, useSelectorController, useSelectorEmitter, useSelectorEvents, useSelectorHelper, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useSvgEditor, useThumbnail, useTranslations, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };