@zerohive/hive-viewer 1.0.0 → 1.0.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
@@ -24,7 +24,9 @@ interface DocumentViewerProps {
24
24
  fileType?: SupportedFileType;
25
25
  mode?: DocumentMode;
26
26
  allowSigning?: boolean;
27
+ disableSigning?: boolean;
27
28
  defaultLayout?: PageLayout;
29
+ defaultShowThumbnails?: boolean;
28
30
  headerComponent?: React.ReactNode;
29
31
  footerComponent?: React.ReactNode;
30
32
  enableHeaderFooterToggle?: boolean;
package/dist/index.d.ts CHANGED
@@ -24,7 +24,9 @@ interface DocumentViewerProps {
24
24
  fileType?: SupportedFileType;
25
25
  mode?: DocumentMode;
26
26
  allowSigning?: boolean;
27
+ disableSigning?: boolean;
27
28
  defaultLayout?: PageLayout;
29
+ defaultShowThumbnails?: boolean;
28
30
  headerComponent?: React.ReactNode;
29
31
  footerComponent?: React.ReactNode;
30
32
  enableHeaderFooterToggle?: boolean;
package/dist/index.js CHANGED
@@ -1088,7 +1088,7 @@ function Toolbar(props) {
1088
1088
  }
1089
1089
  }
1090
1090
  ),
1091
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1091
+ !props.disableSigning && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1092
1092
  "button",
1093
1093
  {
1094
1094
  className: `hv-btn hv-btn-primary ${props.showSignatures ? "ring-2 ring-indigo-300" : ""}`,
@@ -1109,11 +1109,33 @@ var import_lucide_react2 = require("lucide-react");
1109
1109
  var import_react7 = require("react");
1110
1110
  var import_jsx_runtime8 = require("react/jsx-runtime");
1111
1111
  function SignaturePanel(props) {
1112
- const { isOpen, onClose, onSelectSignature } = props;
1113
- const [signatures, setSignatures] = (0, import_react7.useState)([]);
1112
+ const {
1113
+ isOpen,
1114
+ onClose,
1115
+ onSelectSignature,
1116
+ externalSignatures = [],
1117
+ onSignRequest
1118
+ } = props;
1119
+ const [localSignatures, setLocalSignatures] = (0, import_react7.useState)([]);
1114
1120
  const [showModal, setShowModal] = (0, import_react7.useState)(false);
1121
+ const signatures = [...externalSignatures, ...localSignatures];
1115
1122
  const canvasRef = (0, import_react7.useRef)(null);
1116
1123
  const [isDrawing, setIsDrawing] = (0, import_react7.useState)(false);
1124
+ const handleCreateClick = async () => {
1125
+ if (onSignRequest) {
1126
+ try {
1127
+ const newSig = await onSignRequest();
1128
+ if (newSig) {
1129
+ setLocalSignatures((prev) => [...prev, newSig]);
1130
+ onSelectSignature(newSig);
1131
+ }
1132
+ } catch (err) {
1133
+ console.error("Custom sign request failed", err);
1134
+ }
1135
+ } else {
1136
+ openCreateModal();
1137
+ }
1138
+ };
1117
1139
  const openCreateModal = () => {
1118
1140
  setShowModal(true);
1119
1141
  setTimeout(() => {
@@ -1133,7 +1155,7 @@ function SignaturePanel(props) {
1133
1155
  signedBy: "Me",
1134
1156
  dateSigned: (/* @__PURE__ */ new Date()).toISOString()
1135
1157
  };
1136
- setSignatures([...signatures, newSig]);
1158
+ setLocalSignatures([...localSignatures, newSig]);
1137
1159
  setShowModal(false);
1138
1160
  onSelectSignature(newSig);
1139
1161
  };
@@ -1189,7 +1211,7 @@ function SignaturePanel(props) {
1189
1211
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1190
1212
  "button",
1191
1213
  {
1192
- onClick: openCreateModal,
1214
+ onClick: handleCreateClick,
1193
1215
  className: "hv-btn",
1194
1216
  style: {
1195
1217
  width: "100%",
@@ -1204,63 +1226,75 @@ function SignaturePanel(props) {
1204
1226
  ]
1205
1227
  }
1206
1228
  ),
1207
- signatures.map((sig) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1208
- "div",
1209
- {
1210
- className: "hv-thumb-item",
1211
- style: {
1212
- position: "relative",
1213
- padding: "12px",
1214
- background: "var(--hv-bg)",
1215
- borderRadius: "8px",
1216
- border: "1px solid var(--hv-border)"
1229
+ signatures.map((sig, idx) => {
1230
+ const isLocal = localSignatures.some((s) => s.id === sig.id);
1231
+ const showDelete = isLocal;
1232
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1233
+ "div",
1234
+ {
1235
+ className: "hv-thumb-item",
1236
+ style: {
1237
+ position: "relative",
1238
+ padding: "12px",
1239
+ background: "var(--hv-bg)",
1240
+ borderRadius: "8px",
1241
+ border: "1px solid var(--hv-border)"
1242
+ },
1243
+ onClick: () => onSelectSignature(sig),
1244
+ children: [
1245
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1246
+ "img",
1247
+ {
1248
+ src: sig.signatureImageUrl,
1249
+ alt: "Signature",
1250
+ style: { height: "40px", objectFit: "contain" }
1251
+ }
1252
+ ),
1253
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1254
+ "div",
1255
+ {
1256
+ style: {
1257
+ fontSize: "11px",
1258
+ color: "var(--hv-muted)",
1259
+ marginTop: "4px",
1260
+ textAlign: "center"
1261
+ },
1262
+ children: [
1263
+ sig.signedBy || "User",
1264
+ " \u2022",
1265
+ " ",
1266
+ new Date(sig.dateSigned).toLocaleDateString(),
1267
+ sig.comment && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs text-gray-500 mt-1 italic", children: sig.comment })
1268
+ ]
1269
+ }
1270
+ ),
1271
+ showDelete && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1272
+ "button",
1273
+ {
1274
+ onClick: (e) => {
1275
+ e.stopPropagation();
1276
+ setLocalSignatures(
1277
+ localSignatures.filter((s) => s.id !== sig.id)
1278
+ );
1279
+ },
1280
+ className: "hv-btn",
1281
+ style: {
1282
+ position: "absolute",
1283
+ top: "4px",
1284
+ right: "4px",
1285
+ padding: "4px",
1286
+ color: "#ef4444",
1287
+ border: "none",
1288
+ background: "white"
1289
+ },
1290
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Trash2, { size: 12 })
1291
+ }
1292
+ )
1293
+ ]
1217
1294
  },
1218
- onClick: () => onSelectSignature(sig),
1219
- children: [
1220
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1221
- "img",
1222
- {
1223
- src: sig.signatureImageUrl,
1224
- alt: "Signature",
1225
- style: { height: "40px", objectFit: "contain" }
1226
- }
1227
- ),
1228
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1229
- "div",
1230
- {
1231
- style: {
1232
- fontSize: "11px",
1233
- color: "var(--hv-muted)",
1234
- marginTop: "4px",
1235
- textAlign: "center"
1236
- },
1237
- children: new Date(sig.dateSigned).toLocaleDateString()
1238
- }
1239
- ),
1240
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1241
- "button",
1242
- {
1243
- onClick: (e) => {
1244
- e.stopPropagation();
1245
- setSignatures(signatures.filter((s) => s.id !== sig.id));
1246
- },
1247
- className: "hv-btn",
1248
- style: {
1249
- position: "absolute",
1250
- top: "4px",
1251
- right: "4px",
1252
- padding: "4px",
1253
- color: "#ef4444",
1254
- border: "none",
1255
- background: "white"
1256
- },
1257
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.Trash2, { size: 12 })
1258
- }
1259
- )
1260
- ]
1261
- },
1262
- sig.id
1263
- ))
1295
+ sig.id || idx
1296
+ );
1297
+ })
1264
1298
  ] })
1265
1299
  ]
1266
1300
  }
@@ -1391,7 +1425,9 @@ function DocumentViewer(props) {
1391
1425
  const [layout, setLayout] = (0, import_react8.useState)(
1392
1426
  props.defaultLayout ?? "single"
1393
1427
  );
1394
- const [showThumbnails, setShowThumbnails] = (0, import_react8.useState)(true);
1428
+ const [showThumbnails, setShowThumbnails] = (0, import_react8.useState)(
1429
+ props.defaultShowThumbnails ?? true
1430
+ );
1395
1431
  const [showSignatures, setShowSignatures] = (0, import_react8.useState)(false);
1396
1432
  const [resolved, setResolved] = (0, import_react8.useState)(null);
1397
1433
  const [loading, setLoading] = (0, import_react8.useState)(true);
@@ -1504,7 +1540,8 @@ function DocumentViewer(props) {
1504
1540
  showThumbnails,
1505
1541
  onToggleThumbnails: () => setShowThumbnails(!showThumbnails),
1506
1542
  showSignatures,
1507
- onToggleSignatures: () => setShowSignatures(!showSignatures)
1543
+ onToggleSignatures: () => setShowSignatures(!showSignatures),
1544
+ disableSigning: props.disableSigning
1508
1545
  }
1509
1546
  ),
1510
1547
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hv-shell", children: [
@@ -1523,7 +1560,9 @@ function DocumentViewer(props) {
1523
1560
  {
1524
1561
  isOpen: showSignatures,
1525
1562
  onClose: () => setShowSignatures(false),
1526
- onSelectSignature: handleSignatureSelect
1563
+ onSelectSignature: handleSignatureSelect,
1564
+ externalSignatures: props.signatures,
1565
+ onSignRequest: props.onSignRequest
1527
1566
  }
1528
1567
  )
1529
1568
  ] })