react-iiif-vault 0.9.16 → 0.9.19
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/.build/types/context/AnnotationPageContext.d.ts +5 -0
- package/.build/types/context/ResourceContext.d.ts +1 -0
- package/.build/types/hooks/useAnnotationPage.d.ts +8 -0
- package/.build/types/hooks/usePaintables.d.ts +1 -0
- package/.build/types/hooks/usePaintingAnnotations.d.ts +1 -0
- package/.build/types/hooks/useRenderingStrategy.d.ts +1 -0
- package/.build/types/index.d.ts +2 -0
- package/dist/bundle/cjs/index.js +4 -4
- package/dist/bundle/cjs/index.js.map +1 -1
- package/dist/bundle/esm/index.mjs +38 -4
- package/dist/bundle/esm/index.mjs.map +1 -1
- package/dist/canvas-panel/cjs/canvas-panel.js +5 -5
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
- package/dist/canvas-panel/esm/canvas-panel.mjs +11 -3
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
- package/dist/index.umd.js +20 -20
- package/dist/index.umd.js.map +1 -1
- package/dist/react17/cjs/index.js +5 -5
- package/dist/react17/cjs/index.js.map +1 -1
- package/dist/react17/esm/index.mjs +38 -4
- package/dist/react17/esm/index.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -132,7 +132,8 @@ const defaultResourceContext = {
|
|
|
132
132
|
manifest: void 0,
|
|
133
133
|
range: void 0,
|
|
134
134
|
canvas: void 0,
|
|
135
|
-
annotation: void 0
|
|
135
|
+
annotation: void 0,
|
|
136
|
+
annotationPage: void 0
|
|
136
137
|
};
|
|
137
138
|
const ResourceReactContext = React__default.createContext(defaultResourceContext);
|
|
138
139
|
const useResourceContext = () => {
|
|
@@ -1302,8 +1303,11 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
|
|
|
1302
1303
|
let choice = null;
|
|
1303
1304
|
const items = [];
|
|
1304
1305
|
for (const annotation of paintingAnnotations) {
|
|
1305
|
-
const bodies = vault.get(annotation.body);
|
|
1306
|
+
const bodies = vault.get(annotation.body, { skipSelfReturn: false });
|
|
1306
1307
|
for (const unknownBody of bodies) {
|
|
1308
|
+
if (!unknownBody) {
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1307
1311
|
const [body, { selector }] = parseSpecificResource(unknownBody);
|
|
1308
1312
|
const type = (body.type || "unknown").toLowerCase();
|
|
1309
1313
|
if (type === "choice") {
|
|
@@ -1559,11 +1563,15 @@ function useLoadImageService() {
|
|
|
1559
1563
|
return [loadImageService, imageServiceStatus];
|
|
1560
1564
|
}
|
|
1561
1565
|
function usePaintingAnnotations(options = {}) {
|
|
1566
|
+
const annotation = useAnnotation();
|
|
1562
1567
|
const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
|
|
1563
1568
|
return useVaultSelector((state, vault) => {
|
|
1564
1569
|
if (!canvas) {
|
|
1565
1570
|
return [];
|
|
1566
1571
|
}
|
|
1572
|
+
if (annotation && options.enableSingleAnnotation) {
|
|
1573
|
+
return [annotation];
|
|
1574
|
+
}
|
|
1567
1575
|
const annotationPages = vault.get(canvas.items);
|
|
1568
1576
|
const flatAnnotations = [];
|
|
1569
1577
|
for (const page of annotationPages) {
|
|
@@ -1574,7 +1582,7 @@ function usePaintingAnnotations(options = {}) {
|
|
|
1574
1582
|
}
|
|
1575
1583
|
function usePaintables(options, deps = []) {
|
|
1576
1584
|
const vault = useVault();
|
|
1577
|
-
const paintingAnnotations = usePaintingAnnotations();
|
|
1585
|
+
const paintingAnnotations = usePaintingAnnotations({ enableSingleAnnotation: options == null ? void 0 : options.enableSingleAnnotation });
|
|
1578
1586
|
const [enabledChoices, setEnabledChoices] = useState((options == null ? void 0 : options.defaultChoices) || []);
|
|
1579
1587
|
const paintables = useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
|
|
1580
1588
|
const makeChoice = useCallback((id, { deselectOthers = true, deselect = false } = {}) => {
|
|
@@ -3008,6 +3016,17 @@ function AnnotationContext({
|
|
|
3008
3016
|
children
|
|
3009
3017
|
});
|
|
3010
3018
|
}
|
|
3019
|
+
function AnnotationPageContext({
|
|
3020
|
+
annotationPage,
|
|
3021
|
+
children
|
|
3022
|
+
}) {
|
|
3023
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
3024
|
+
value: {
|
|
3025
|
+
annotationPage
|
|
3026
|
+
},
|
|
3027
|
+
children
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3011
3030
|
function CollectionContext({
|
|
3012
3031
|
collection,
|
|
3013
3032
|
children
|
|
@@ -3019,6 +3038,21 @@ function CollectionContext({
|
|
|
3019
3038
|
children
|
|
3020
3039
|
});
|
|
3021
3040
|
}
|
|
3041
|
+
function useAnnotationPage(options = {}, deps = []) {
|
|
3042
|
+
const { id, selector } = options;
|
|
3043
|
+
const ctx = useResourceContext();
|
|
3044
|
+
const annotationPageId = id ? id : ctx.annotationPage;
|
|
3045
|
+
const annotationPage = useVaultSelector((s) => annotationPageId ? s.iiif.entities.AnnotationPage[annotationPageId] : void 0, [annotationPageId]);
|
|
3046
|
+
return useMemo(() => {
|
|
3047
|
+
if (!annotationPage) {
|
|
3048
|
+
return void 0;
|
|
3049
|
+
}
|
|
3050
|
+
if (selector) {
|
|
3051
|
+
return selector(annotationPage);
|
|
3052
|
+
}
|
|
3053
|
+
return annotationPage;
|
|
3054
|
+
}, [annotationPage, ...deps]);
|
|
3055
|
+
}
|
|
3022
3056
|
function useAnnotationsAtTime(time, options = {}) {
|
|
3023
3057
|
const allAnnotations = usePaintingAnnotations(options);
|
|
3024
3058
|
return allAnnotations;
|
|
@@ -3177,5 +3211,5 @@ function useStyleHelper() {
|
|
|
3177
3211
|
const vault = useVault();
|
|
3178
3212
|
return useMemo(() => createStylesHelper(vault), [vault]);
|
|
3179
3213
|
}
|
|
3180
|
-
export { AnnotationContext, CanvasContext, CanvasPanel, CanvasPortal, CollectionContext, ContextBridge, ImageServiceLoaderContext, InnerViewerProvider, ManifestContext, MediaPlayerProvider, OverlayPortalContext, PortalContext, RangeContext, ReactVaultContext, ResourceProvider, ResourceReactContext, SimpleViewerProvider, SimpleViewerReactContext, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, emptyActions, emptyStrategy, expandTarget, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getImageStrategy, getManifestSequence, getPaintables, getParsedTargetSelector, getVisibleCanvasesFromCanvasId, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCanvasSequence, useCanvasSubset, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
|
|
3214
|
+
export { AnnotationContext, AnnotationPageContext, CanvasContext, CanvasPanel, CanvasPortal, CollectionContext, ContextBridge, ImageServiceLoaderContext, InnerViewerProvider, ManifestContext, MediaPlayerProvider, OverlayPortalContext, PortalContext, RangeContext, ReactVaultContext, ResourceProvider, ResourceReactContext, SimpleViewerProvider, SimpleViewerReactContext, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, emptyActions, emptyStrategy, expandTarget, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getImageStrategy, getManifestSequence, getPaintables, getParsedTargetSelector, getVisibleCanvasesFromCanvasId, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPage, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCanvasSequence, useCanvasSubset, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
|
|
3181
3215
|
//# sourceMappingURL=index.mjs.map
|