@manifest-editor/shell 1.3.0 → 1.3.1

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
@@ -851,7 +851,7 @@ declare function PanelError(props: {
851
851
  resetErrorBoundary: () => void;
852
852
  }): react_jsx_runtime.JSX.Element;
853
853
 
854
- declare function PreviewButton({ downloadEnabled, fileName, }: {
854
+ declare function PreviewButton({ downloadEnabled, fileName }: {
855
855
  downloadEnabled?: boolean;
856
856
  fileName?: string;
857
857
  }): react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -851,7 +851,7 @@ declare function PanelError(props: {
851
851
  resetErrorBoundary: () => void;
852
852
  }): react_jsx_runtime.JSX.Element;
853
853
 
854
- declare function PreviewButton({ downloadEnabled, fileName, }: {
854
+ declare function PreviewButton({ downloadEnabled, fileName }: {
855
855
  downloadEnabled?: boolean;
856
856
  fileName?: string;
857
857
  }): react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -464,6 +464,7 @@ import { createContext as createContext5, memo, useContext as useContext5, useEf
464
464
 
465
465
  // src/PreviewContext/PreviewContext.hooks.ts
466
466
  import { useMemo as useMemo4 } from "react";
467
+ import { useVault } from "react-iiif-vault";
467
468
 
468
469
  // src/PreviewContext/previews/ExternalManifestUrlPreview.ts
469
470
  var ExternalManifestUrlPreview = class {
@@ -637,7 +638,6 @@ var IIIFPreviewService = class {
637
638
  };
638
639
 
639
640
  // src/PreviewContext/PreviewContext.hooks.ts
640
- import { useVault } from "react-iiif-vault";
641
641
  function usePreviewActions(state, dispatch, handlers, previews, setPreviews) {
642
642
  const resource = useAppResource();
643
643
  const instanceId = useAppResourceInstance();
@@ -709,8 +709,8 @@ function usePreviewActions(state, dispatch, handlers, previews, setPreviews) {
709
709
  async function selectPreview(id) {
710
710
  const selectedHandler = handlerMap[id];
711
711
  if (selectedHandler && instanceId) {
712
- await activatePreview(id);
713
712
  dispatch({ type: "selectPreview", payload: id });
713
+ await activatePreview(id);
714
714
  }
715
715
  }
716
716
  async function getPreviewLink() {
@@ -762,13 +762,13 @@ function usePreviewActions(state, dispatch, handlers, previews, setPreviews) {
762
762
  dispatch({ type: "activatePreview", payload: contextualPreview.id });
763
763
  } else {
764
764
  Object.assign(context, existing?.data || {});
765
- dispatch({ type: "activatePreview", payload: id });
765
+ dispatch({ type: "activatePreview", payload: existing.id });
766
766
  }
767
767
  }
768
768
  const created = await selectedHandler.createPreview(instanceId, resource, vault, context);
769
769
  if (created) {
770
770
  previewActions.setPreview(created);
771
- dispatch({ type: "activatePreview", payload: id });
771
+ dispatch({ type: "activatePreview", payload: created.id });
772
772
  }
773
773
  }
774
774
  }
@@ -1083,20 +1083,13 @@ var ButtonEmpty = styled3.div`
1083
1083
 
1084
1084
  // src/PreviewButton/PreviewButton.tsx
1085
1085
  import { Fragment, jsx as jsx8, jsxs as jsxs2 } from "react/jsx-runtime";
1086
- function PreviewButton({
1087
- downloadEnabled,
1088
- fileName
1089
- }) {
1086
+ function PreviewButton({ downloadEnabled, fileName }) {
1090
1087
  const { active, configs, actions, selected } = usePreviewContext();
1091
1088
  const vault = useVault2();
1092
1089
  const config = useConfig();
1093
1090
  const resource = useAppResource();
1094
- const configsToShow = configs.filter(
1095
- (c) => c.type === "external-manifest-preview"
1096
- );
1097
- const { isOpen, buttonProps, itemProps } = useDropdownMenu(
1098
- configsToShow.length
1099
- );
1091
+ const configsToShow = configs.filter((c) => c.type === "external-manifest-preview");
1092
+ const { isOpen, buttonProps, itemProps } = useDropdownMenu(configsToShow.length);
1100
1093
  if (configsToShow.length === 0) {
1101
1094
  return /* @__PURE__ */ jsx8(ButtonEmpty, { children: "Preview not available" });
1102
1095
  }
@@ -1108,17 +1101,9 @@ function PreviewButton({
1108
1101
  label: "Download manifest",
1109
1102
  getData: () => {
1110
1103
  if (config.export && config.export.version === 2) {
1111
- return JSON.stringify(
1112
- vault.toPresentation2(resource),
1113
- null,
1114
- 2
1115
- );
1104
+ return JSON.stringify(vault.toPresentation2(resource), null, 2);
1116
1105
  }
1117
- return JSON.stringify(
1118
- vault.toPresentation3(resource),
1119
- null,
1120
- 2
1121
- );
1106
+ return JSON.stringify(vault.toPresentation3(resource), null, 2);
1122
1107
  }
1123
1108
  }
1124
1109
  ) }) : null,
@@ -1133,7 +1118,6 @@ function PreviewButton({
1133
1118
  const found = configs.find((c) => c.id === defaultPreviewId);
1134
1119
  if (found) {
1135
1120
  actions.selectPreview(found.id);
1136
- actions.updatePreviews();
1137
1121
  return;
1138
1122
  }
1139
1123
  }
@@ -1148,29 +1132,17 @@ function PreviewButton({
1148
1132
  /* @__PURE__ */ jsx8(MenuContainer, { $open: isOpen, children: configsToShow.map((config2, key) => {
1149
1133
  const inactive = active.indexOf(config2.id) === -1;
1150
1134
  return /* @__PURE__ */ jsxs2(MenuItem, { ...itemProps[key], children: [
1151
- /* @__PURE__ */ jsx8(
1152
- MenuItemStatus,
1153
- {
1154
- $status: inactive ? "available" : config2.id === selected ? "active" : "configured"
1155
- }
1156
- ),
1135
+ /* @__PURE__ */ jsx8(MenuItemStatus, { $status: inactive ? "available" : config2.id === selected ? "active" : "configured" }),
1157
1136
  /* @__PURE__ */ jsx8(
1158
1137
  MenuItemLabel,
1159
1138
  {
1160
1139
  onClick: () => {
1161
1140
  actions.selectPreview(config2.id);
1162
- actions.updatePreviews();
1163
1141
  },
1164
1142
  children: config2.label
1165
1143
  }
1166
1144
  ),
1167
- !inactive ? /* @__PURE__ */ jsx8(
1168
- MenuItemClose,
1169
- {
1170
- onClick: () => actions.deletePreview(config2.id),
1171
- children: /* @__PURE__ */ jsx8(CloseIcon, {})
1172
- }
1173
- ) : null
1145
+ !inactive ? /* @__PURE__ */ jsx8(MenuItemClose, { onClick: () => actions.deletePreview(config2.id), children: /* @__PURE__ */ jsx8(CloseIcon, {}) }) : null
1174
1146
  ] }, config2.id);
1175
1147
  }) })
1176
1148
  ] })