hazo_pdf 1.6.6 → 1.6.7

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/README.md CHANGED
@@ -924,7 +924,8 @@ You can override any or all of these on a per-highlight basis.
924
924
  | `doc_data` | `Record<string, unknown>` | `undefined` | General document data to display in the File Info sidepanel. Shown in the "Document Data" section. Can contain any structured data from extraction (strings, numbers, arrays, objects). |
925
925
  | `highlight_fields_info` | `HighlightFieldInfo[]` | `undefined` | Array of highlighted/extracted fields to display with special styling. Shown in the "Highlighted Fields" section with field count. Each item has `field_name` (converted to Title Case) and `value` (displayed string). |
926
926
  | `file_metadata` | `FileMetadataInput` | `undefined` | Legacy format: Array of file metadata items with filename matching. Each item has `filename` (to match current file) and `file_data` (flexible JSON object with string fields or table arrays). See [File Info Sidepanel](#file-info-sidepanel) section for details. |
927
- | `show_file_info_button` | `boolean` | `true` | Show file info sidepanel button in toolbar. Button only appears when at least one of: `doc_data`, `highlight_fields_info`, or `file_metadata` is provided. |
927
+ | `extractions` | `ExtractionEntry[]` | `undefined` | Extraction entries from hazo_files `file_data.raw_data`. Each entry has `id?`, `extracted_at?` (ISO timestamp), `source?` (e.g., "autofill"), and `data` (key-value pairs). Shown in a collapsible "Extractions" section. |
928
+ | `show_file_info_button` | `boolean` | `true` | Show file info sidepanel button in toolbar. Button only appears when at least one of: `doc_data`, `highlight_fields_info`, `file_metadata`, or `extractions` is provided. |
928
929
 
929
930
  ##### Custom Stamps
930
931
 
@@ -1002,7 +1003,7 @@ Props for managing multiple PDF files. Mutually exclusive with `url` prop.
1002
1003
  | `on_upload` | `(file: File, converted_pdf?: Uint8Array) => Promise<UploadResult>` | `undefined` | Callback for file upload. Receives original file and optional converted PDF (for non-PDF files). Must return `{ success: boolean, file_id?: string, url?: string, error?: string }`. |
1003
1004
  | `on_files_change` | `(files: FileItem[]) => void` | `undefined` | Callback when files array changes (file added, deleted, or reordered). |
1004
1005
  | `direct_upload` | `boolean` | `false` | When `true`, clicking "+ Add file" opens the native file picker directly (1-click). The button also accepts drag & drop. When `false` (default), clicking shows a dropzone modal first (2-click). Can also be set via `file_upload.direct_upload` in INI config. |
1005
- | `enable_popout` | `boolean` | `false` | Enable popout to new tab feature. Shows popout button in toolbar. |
1006
+ | `enable_popout` | `boolean` | `false` | Enable popout to new tab feature. Shows "Open in new tab" and "Download" buttons in toolbar. In single-file mode, opens the PDF URL directly; in multi-file mode, uses sessionStorage-based popout. |
1006
1007
  | `popout_route` | `string` | `'/pdf-viewer'` | Route path for popout viewer. Used to construct new tab URL. |
1007
1008
  | `on_popout` | `(context: PopoutContext) => void` | `undefined` | Custom popout handler. Overrides default sessionStorage behavior. Receives context with file info and annotations. |
1008
1009
  | `viewer_title` | `string` | `undefined` | Title for the viewer (shown in dialog mode or popout window). |
@@ -2199,7 +2200,8 @@ function CompleteSidepanelExample() {
2199
2200
  1. **Extracted Data** (from `file_metadata`) - if provided
2200
2201
  2. **Document Data** (from `doc_data`) - if provided
2201
2202
  3. **Highlighted Fields** (from `highlight_fields_info`) - if provided
2202
- 4. **File System Info** - filename and path
2203
+ 4. **Extractions** (from `extractions`) - if provided, collapsible entries with source/timestamp
2204
+ 5. **File System Info** - filename and path
2203
2205
 
2204
2206
  ### Integration with Data Extraction
2205
2207
 
@@ -2047,7 +2047,8 @@ var FileInfoSidepanel = ({
2047
2047
  file_metadata,
2048
2048
  current_filename,
2049
2049
  doc_data,
2050
- highlight_fields_info
2050
+ highlight_fields_info,
2051
+ extractions
2051
2052
  }) => {
2052
2053
  const [expanded_tables, setExpandedTables] = useState7(/* @__PURE__ */ new Set());
2053
2054
  const resize_ref = useRef8(null);
@@ -2116,6 +2117,7 @@ var FileInfoSidepanel = ({
2116
2117
  const has_file_info = item !== null;
2117
2118
  const has_doc_data = doc_data && Object.keys(doc_data).length > 0;
2118
2119
  const has_highlight_info = highlight_fields_info && highlight_fields_info.length > 0;
2120
+ const has_extractions = extractions && extractions.length > 0;
2119
2121
  return /* @__PURE__ */ jsxs7(Fragment4, { children: [
2120
2122
  !is_open && /* @__PURE__ */ jsx8(
2121
2123
  "button",
@@ -2213,7 +2215,74 @@ var FileInfoSidepanel = ({
2213
2215
  /* @__PURE__ */ jsx8("span", { className: "cls_file_metadata_field_value cls_highlight_value", children: field.value })
2214
2216
  ] }, idx)) })
2215
2217
  ] }),
2216
- (has_extracted_data || has_doc_data || has_highlight_info) && has_file_info && /* @__PURE__ */ jsx8("div", { className: "cls_file_info_divider" }),
2218
+ has_extractions && /* @__PURE__ */ jsxs7("div", { className: "cls_file_info_extractions_section", children: [
2219
+ (has_extracted_data || has_doc_data || has_highlight_info) && /* @__PURE__ */ jsx8("div", { className: "cls_file_info_divider" }),
2220
+ /* @__PURE__ */ jsxs7("div", { className: "cls_file_info_section_header", children: [
2221
+ "Extractions (",
2222
+ extractions.length,
2223
+ ")"
2224
+ ] }),
2225
+ extractions.map((entry, idx) => {
2226
+ const entry_key = entry.id || `extraction_${idx}`;
2227
+ const is_expanded = expanded_tables.has(entry_key);
2228
+ const timestamp = entry.extracted_at ? new Date(entry.extracted_at).toLocaleString() : void 0;
2229
+ const data_entries = Object.entries(entry.data);
2230
+ return /* @__PURE__ */ jsxs7("div", { className: "cls_file_metadata_table_section", children: [
2231
+ /* @__PURE__ */ jsxs7(
2232
+ "button",
2233
+ {
2234
+ type: "button",
2235
+ onClick: () => toggle_table(entry_key),
2236
+ className: "cls_file_metadata_table_header",
2237
+ "aria-expanded": is_expanded,
2238
+ children: [
2239
+ /* @__PURE__ */ jsx8("span", { className: "cls_file_metadata_table_name", children: entry.source || `Extraction ${idx + 1}` }),
2240
+ timestamp && /* @__PURE__ */ jsx8("span", { className: "cls_file_metadata_table_count", children: timestamp }),
2241
+ is_expanded ? /* @__PURE__ */ jsx8(ChevronUp2, { className: "cls_file_metadata_table_icon", size: 16 }) : /* @__PURE__ */ jsx8(ChevronDown3, { className: "cls_file_metadata_table_icon", size: 16 })
2242
+ ]
2243
+ }
2244
+ ),
2245
+ is_expanded && /* @__PURE__ */ jsx8("div", { className: "cls_file_metadata_fields", children: data_entries.map(([key, value]) => {
2246
+ if (is_table(value)) {
2247
+ const table_key = `${entry_key}_${key}`;
2248
+ const table_expanded = expanded_tables.has(table_key);
2249
+ return /* @__PURE__ */ jsxs7("div", { className: "cls_file_metadata_table_section", children: [
2250
+ /* @__PURE__ */ jsxs7(
2251
+ "button",
2252
+ {
2253
+ type: "button",
2254
+ onClick: () => toggle_table(table_key),
2255
+ className: "cls_file_metadata_table_header",
2256
+ "aria-expanded": table_expanded,
2257
+ children: [
2258
+ /* @__PURE__ */ jsx8("span", { className: "cls_file_metadata_table_name", children: format_field_name(key) }),
2259
+ /* @__PURE__ */ jsxs7("span", { className: "cls_file_metadata_table_count", children: [
2260
+ "(",
2261
+ value.length,
2262
+ " ",
2263
+ value.length === 1 ? "item" : "items",
2264
+ ")"
2265
+ ] }),
2266
+ table_expanded ? /* @__PURE__ */ jsx8(ChevronUp2, { className: "cls_file_metadata_table_icon", size: 16 }) : /* @__PURE__ */ jsx8(ChevronDown3, { className: "cls_file_metadata_table_icon", size: 16 })
2267
+ ]
2268
+ }
2269
+ ),
2270
+ table_expanded && /* @__PURE__ */ jsx8("div", { className: "cls_file_metadata_table_content", children: value.map((row, row_index) => /* @__PURE__ */ jsx8("div", { className: "cls_file_metadata_table_row", children: /* @__PURE__ */ jsx8("table", { className: "cls_file_metadata_row_table", children: /* @__PURE__ */ jsx8("tbody", { children: Object.entries(row).map(([field_name, field_value]) => /* @__PURE__ */ jsxs7("tr", { className: "cls_file_metadata_row_tr", children: [
2271
+ /* @__PURE__ */ jsx8("td", { className: "cls_file_metadata_row_label", children: format_field_name(field_name) }),
2272
+ /* @__PURE__ */ jsx8("td", { className: "cls_file_metadata_row_value", children: field_value })
2273
+ ] }, field_name)) }) }) }, row_index)) })
2274
+ ] }, key);
2275
+ }
2276
+ const display_value = typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value ?? "");
2277
+ return /* @__PURE__ */ jsxs7("div", { className: "cls_file_metadata_field", children: [
2278
+ /* @__PURE__ */ jsx8("span", { className: "cls_file_metadata_field_label", children: format_field_name(key) }),
2279
+ /* @__PURE__ */ jsx8("span", { className: "cls_file_metadata_field_value", children: display_value })
2280
+ ] }, key);
2281
+ }) })
2282
+ ] }, entry_key);
2283
+ })
2284
+ ] }),
2285
+ (has_extracted_data || has_doc_data || has_highlight_info || has_extractions) && has_file_info && /* @__PURE__ */ jsx8("div", { className: "cls_file_info_divider" }),
2217
2286
  has_file_info && item && /* @__PURE__ */ jsxs7("div", { className: "cls_file_info_system_section", children: [
2218
2287
  /* @__PURE__ */ jsx8("div", { className: "cls_file_info_section_header", children: "File" }),
2219
2288
  /* @__PURE__ */ jsxs7("div", { className: "cls_file_info_properties", children: [
@@ -2227,7 +2296,7 @@ var FileInfoSidepanel = ({
2227
2296
  ] })
2228
2297
  ] })
2229
2298
  ] }),
2230
- !has_extracted_data && !has_doc_data && !has_highlight_info && !has_file_info && /* @__PURE__ */ jsx8("div", { className: "cls_file_info_no_data", children: "No file information available" })
2299
+ !has_extracted_data && !has_doc_data && !has_highlight_info && !has_extractions && !has_file_info && /* @__PURE__ */ jsx8("div", { className: "cls_file_info_no_data", children: "No file information available" })
2231
2300
  ] })
2232
2301
  ] })
2233
2302
  ]
@@ -4531,6 +4600,7 @@ var PdfViewer = forwardRef(({
4531
4600
  // File info sidepanel data props
4532
4601
  doc_data,
4533
4602
  highlight_fields_info,
4603
+ extractions,
4534
4604
  // Auto-highlight props
4535
4605
  auto_highlight_enabled,
4536
4606
  auto_highlight_options,
@@ -5222,6 +5292,12 @@ ${suffix_line}`;
5222
5292
  return { updatedRow, allData };
5223
5293
  };
5224
5294
  const handle_popout = useCallback5(() => {
5295
+ if (!is_multi_file_mode) {
5296
+ if (effective_url) {
5297
+ window.open(effective_url, "_blank");
5298
+ }
5299
+ return;
5300
+ }
5225
5301
  if (!files || files.length === 0) {
5226
5302
  pdf_logger.warn("No files to popout");
5227
5303
  return;
@@ -5242,7 +5318,7 @@ ${suffix_line}`;
5242
5318
  } catch (err) {
5243
5319
  pdf_logger.error("Failed to popout", { error: err });
5244
5320
  }
5245
- }, [files, current_file, viewer_title, on_popout, popout_route]);
5321
+ }, [is_multi_file_mode, effective_url, files, current_file, viewer_title, on_popout, popout_route]);
5246
5322
  useEffect10(() => {
5247
5323
  const should_auto_highlight = auto_highlight_enabled !== false && // Default true
5248
5324
  highlight_fields_info && highlight_fields_info.length > 0 && pdf_document;
@@ -5888,7 +5964,7 @@ ${suffix_line}`;
5888
5964
  children: /* @__PURE__ */ jsx15(PanelRight, { className: "cls_pdf_viewer_toolbar_icon", size: 16 })
5889
5965
  }
5890
5966
  ) }),
5891
- (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info) && toolbar_config.toolbar_show_file_info_button && /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsx15(
5967
+ (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info || extractions && extractions.length > 0) && toolbar_config.toolbar_show_file_info_button && /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsx15(
5892
5968
  "button",
5893
5969
  {
5894
5970
  type: "button",
@@ -5914,27 +5990,57 @@ ${suffix_line}`;
5914
5990
  children: /* @__PURE__ */ jsx15(Info, { className: "cls_pdf_viewer_toolbar_icon", size: 16 })
5915
5991
  }
5916
5992
  ) }),
5917
- is_multi_file_mode && enable_popout && /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsx15(
5918
- "button",
5919
- {
5920
- type: "button",
5921
- onClick: handle_popout,
5922
- className: "cls_pdf_viewer_toolbar_button",
5923
- "aria-label": "Open in new tab",
5924
- title: "Open in new tab",
5925
- style: {
5926
- backgroundColor: toolbar_config.toolbar_button_background_color,
5927
- color: toolbar_config.toolbar_button_text_color
5928
- },
5929
- onMouseEnter: (e) => {
5930
- e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color_hover;
5931
- },
5932
- onMouseLeave: (e) => {
5933
- e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color;
5934
- },
5935
- children: /* @__PURE__ */ jsx15(ExternalLink, { className: "cls_pdf_viewer_toolbar_icon", size: 16 })
5936
- }
5937
- ) }),
5993
+ enable_popout && /* @__PURE__ */ jsxs14("div", { className: "cls_pdf_viewer_toolbar_group", children: [
5994
+ /* @__PURE__ */ jsx15(
5995
+ "button",
5996
+ {
5997
+ type: "button",
5998
+ onClick: handle_popout,
5999
+ className: "cls_pdf_viewer_toolbar_button",
6000
+ "aria-label": "Open in new tab",
6001
+ title: "Open in new tab",
6002
+ style: {
6003
+ backgroundColor: toolbar_config.toolbar_button_background_color,
6004
+ color: toolbar_config.toolbar_button_text_color
6005
+ },
6006
+ onMouseEnter: (e) => {
6007
+ e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color_hover;
6008
+ },
6009
+ onMouseLeave: (e) => {
6010
+ e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color;
6011
+ },
6012
+ children: /* @__PURE__ */ jsx15(ExternalLink, { className: "cls_pdf_viewer_toolbar_icon", size: 16 })
6013
+ }
6014
+ ),
6015
+ /* @__PURE__ */ jsx15(
6016
+ "button",
6017
+ {
6018
+ type: "button",
6019
+ onClick: handle_download,
6020
+ disabled: downloading || !pdf_document,
6021
+ className: cn(
6022
+ "cls_pdf_viewer_toolbar_button",
6023
+ (downloading || !pdf_document) && "cls_pdf_viewer_toolbar_button_disabled"
6024
+ ),
6025
+ "aria-label": "Download PDF",
6026
+ title: downloading ? "Downloading..." : "Download PDF",
6027
+ style: {
6028
+ backgroundColor: toolbar_config.toolbar_button_background_color,
6029
+ color: toolbar_config.toolbar_button_text_color,
6030
+ opacity: downloading || !pdf_document ? toolbar_config.toolbar_button_disabled_opacity : 1
6031
+ },
6032
+ onMouseEnter: (e) => {
6033
+ if (!(downloading || !pdf_document)) {
6034
+ e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color_hover;
6035
+ }
6036
+ },
6037
+ onMouseLeave: (e) => {
6038
+ e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color;
6039
+ },
6040
+ children: /* @__PURE__ */ jsx15(Download, { className: "cls_pdf_viewer_toolbar_icon", size: 16 })
6041
+ }
6042
+ )
6043
+ ] }),
5938
6044
  on_close && /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsx15(
5939
6045
  "button",
5940
6046
  {
@@ -5962,7 +6068,7 @@ ${suffix_line}`;
5962
6068
  const any_sidepanel_open = sidepanel_open || file_info_sidepanel_open;
5963
6069
  const total_sidepanel_width = (sidepanel_open ? sidepanel_width : 0) + (file_info_sidepanel_open ? file_info_sidepanel_width : 0);
5964
6070
  const has_metadata_sidepanel = sidepanel_metadata_enabled && metadata_input;
5965
- const has_file_info_sidepanel = (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info) && toolbar_config.toolbar_show_file_info_button;
6071
+ const has_file_info_sidepanel = (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info || extractions && extractions.length > 0) && toolbar_config.toolbar_show_file_info_button;
5966
6072
  const any_sidepanel_available = has_metadata_sidepanel || has_file_info_sidepanel;
5967
6073
  return /* @__PURE__ */ jsxs14("div", { className: cn("cls_pdf_viewer_content_wrapper", any_sidepanel_open && "cls_pdf_viewer_content_wrapper_with_sidepanel"), children: [
5968
6074
  any_sidepanel_available && !any_sidepanel_open && /* @__PURE__ */ jsxs14(
@@ -6061,7 +6167,7 @@ ${suffix_line}`;
6061
6167
  on_width_change: handle_sidepanel_width_change
6062
6168
  }
6063
6169
  ),
6064
- (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info) && /* @__PURE__ */ jsx15(
6170
+ (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info || extractions && extractions.length > 0) && /* @__PURE__ */ jsx15(
6065
6171
  FileInfoSidepanel,
6066
6172
  {
6067
6173
  is_open: file_info_sidepanel_open,
@@ -6083,7 +6189,8 @@ ${suffix_line}`;
6083
6189
  file_metadata,
6084
6190
  current_filename: current_file?.name || display_filename || (url ? url.split("/").pop() || "" : ""),
6085
6191
  doc_data,
6086
- highlight_fields_info
6192
+ highlight_fields_info,
6193
+ extractions
6087
6194
  }
6088
6195
  )
6089
6196
  ] });
@@ -6293,4 +6400,4 @@ export {
6293
6400
  PdfViewer,
6294
6401
  pdf_viewer_default
6295
6402
  };
6296
- //# sourceMappingURL=chunk-LQTYLVBH.js.map
6403
+ //# sourceMappingURL=chunk-TJBBE34D.js.map