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 = () => {
|
|
@@ -1307,8 +1308,11 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
|
|
|
1307
1308
|
let choice = null;
|
|
1308
1309
|
const items = [];
|
|
1309
1310
|
for (const annotation of paintingAnnotations) {
|
|
1310
|
-
const bodies = vault.get(annotation.body);
|
|
1311
|
+
const bodies = vault.get(annotation.body, { skipSelfReturn: false });
|
|
1311
1312
|
for (const unknownBody of bodies) {
|
|
1313
|
+
if (!unknownBody) {
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1312
1316
|
const [body, { selector }] = parseSpecificResource(unknownBody);
|
|
1313
1317
|
const type = (body.type || "unknown").toLowerCase();
|
|
1314
1318
|
if (type === "choice") {
|
|
@@ -1564,11 +1568,15 @@ function useLoadImageService() {
|
|
|
1564
1568
|
return [loadImageService, imageServiceStatus];
|
|
1565
1569
|
}
|
|
1566
1570
|
function usePaintingAnnotations(options = {}) {
|
|
1571
|
+
const annotation = useAnnotation();
|
|
1567
1572
|
const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
|
|
1568
1573
|
return useVaultSelector((state, vault) => {
|
|
1569
1574
|
if (!canvas) {
|
|
1570
1575
|
return [];
|
|
1571
1576
|
}
|
|
1577
|
+
if (annotation && options.enableSingleAnnotation) {
|
|
1578
|
+
return [annotation];
|
|
1579
|
+
}
|
|
1572
1580
|
const annotationPages = vault.get(canvas.items);
|
|
1573
1581
|
const flatAnnotations = [];
|
|
1574
1582
|
for (const page of annotationPages) {
|
|
@@ -1579,7 +1587,7 @@ function usePaintingAnnotations(options = {}) {
|
|
|
1579
1587
|
}
|
|
1580
1588
|
function usePaintables(options, deps = []) {
|
|
1581
1589
|
const vault = useVault();
|
|
1582
|
-
const paintingAnnotations = usePaintingAnnotations();
|
|
1590
|
+
const paintingAnnotations = usePaintingAnnotations({ enableSingleAnnotation: options == null ? void 0 : options.enableSingleAnnotation });
|
|
1583
1591
|
const [enabledChoices, setEnabledChoices] = useState((options == null ? void 0 : options.defaultChoices) || []);
|
|
1584
1592
|
const paintables = useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
|
|
1585
1593
|
const makeChoice = useCallback((id, { deselectOthers = true, deselect = false } = {}) => {
|
|
@@ -3013,6 +3021,17 @@ function AnnotationContext({
|
|
|
3013
3021
|
children
|
|
3014
3022
|
});
|
|
3015
3023
|
}
|
|
3024
|
+
function AnnotationPageContext({
|
|
3025
|
+
annotationPage,
|
|
3026
|
+
children
|
|
3027
|
+
}) {
|
|
3028
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
3029
|
+
value: {
|
|
3030
|
+
annotationPage
|
|
3031
|
+
},
|
|
3032
|
+
children
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3016
3035
|
function CollectionContext({
|
|
3017
3036
|
collection,
|
|
3018
3037
|
children
|
|
@@ -3024,6 +3043,21 @@ function CollectionContext({
|
|
|
3024
3043
|
children
|
|
3025
3044
|
});
|
|
3026
3045
|
}
|
|
3046
|
+
function useAnnotationPage(options = {}, deps = []) {
|
|
3047
|
+
const { id, selector } = options;
|
|
3048
|
+
const ctx = useResourceContext();
|
|
3049
|
+
const annotationPageId = id ? id : ctx.annotationPage;
|
|
3050
|
+
const annotationPage = useVaultSelector((s) => annotationPageId ? s.iiif.entities.AnnotationPage[annotationPageId] : void 0, [annotationPageId]);
|
|
3051
|
+
return useMemo(() => {
|
|
3052
|
+
if (!annotationPage) {
|
|
3053
|
+
return void 0;
|
|
3054
|
+
}
|
|
3055
|
+
if (selector) {
|
|
3056
|
+
return selector(annotationPage);
|
|
3057
|
+
}
|
|
3058
|
+
return annotationPage;
|
|
3059
|
+
}, [annotationPage, ...deps]);
|
|
3060
|
+
}
|
|
3027
3061
|
function useAnnotationsAtTime(time, options = {}) {
|
|
3028
3062
|
const allAnnotations = usePaintingAnnotations(options);
|
|
3029
3063
|
return allAnnotations;
|
|
@@ -3182,5 +3216,5 @@ function useStyleHelper() {
|
|
|
3182
3216
|
const vault = useVault();
|
|
3183
3217
|
return useMemo(() => createStylesHelper(vault), [vault]);
|
|
3184
3218
|
}
|
|
3185
|
-
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 };
|
|
3219
|
+
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 };
|
|
3186
3220
|
//# sourceMappingURL=index.mjs.map
|