webviewer-ui-builder 0.0.0-stage → 0.3.0

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.
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=new Set(["presetButton","customButton","statefulButton","flyoutPanel"]),E=new Set(["rubberStampPanel","signatureListPanel","stylePanel"]),N=8,p="activateTool:",g="divider",T="tabPanel",M=new Set(["top","bottom","left","right"]),A={outlinePanel:"outlinesPanel",thumbnailPanel:"thumbnailsPanel",bookmarkPanel:"bookmarksPanel"},_=new Set(["annotationPopup","textPopup","contextMenuPopup"]),f=new Set(["outlinesPanel","signaturePanel","bookmarksPanel","fileAttachmentPanel","thumbnailsPanel","layersPanel","textEditingPanel","changeListPanel","stylePanel","redactionPanel","searchPanel","notesPanel","indexPanel","tabPanel","signatureListPanel","rubberStampPanel","portfolioPanel","formFieldPanel"]),c={VIEW_NAVIGATION:"View & Navigation",MARKUP_TEXT:"Text Markup",DRAWING_SHAPES:"Drawing & Shapes",INSERT_SIGS:"Signatures & Inserts",MEASUREMENT:"Measurement",FORMS_REDACT:"Forms & Redaction"},x=[{key:"PAN",toolName:"Pan",label:"Pan",title:"Pan document view",icon:"icon-header-pan",category:c.VIEW_NAVIGATION,defaultId:"panButton"},{key:"TEXT_SELECT",toolName:"AnnotationEdit",label:"Select Text",title:"Select and copy text",icon:"icon-header-select-line",category:c.VIEW_NAVIGATION,defaultId:"selectToolButton"},{key:"MARQUEE",toolName:"MarqueeZoomTool",label:"Marquee Zoom",title:"Drag to zoom into an area",icon:"icon-header-zoom-marquee",category:c.VIEW_NAVIGATION,defaultId:"marqueeZoomButton"},{key:"CROP",toolName:"CropPage",label:"Crop Page",title:"Crop page dimensions",icon:"ic_crop_black_24px",category:c.VIEW_NAVIGATION,defaultId:"cropToolButton"},{key:"SNIPPING",toolName:"SnippingTool",label:"Snipping Tool",title:"Snip an area of the document",icon:"ic_snipping_black_24px",category:c.VIEW_NAVIGATION,defaultId:"snippingToolButton"},{key:"CONTENT_EDIT",toolName:"ContentEditTool",label:"Edit Content",title:"Edit PDF text and paragraph content",icon:"ic_edit_page_24px",category:c.VIEW_NAVIGATION,defaultId:"contentEditButton"},{key:"ADD_PARAGRAPH",toolName:"AddParagraphTool",label:"Add Paragraph",title:"Add paragraph to PDF content",icon:"ic-paragraph",category:c.VIEW_NAVIGATION,defaultId:"addParagraphToolGroupButton"},{key:"ADD_IMAGE_CONTENT",toolName:"AddImageContentTool",label:"Add Image Content",title:"Add inline image to PDF body",icon:"icon-tool-image-line",category:c.VIEW_NAVIGATION,defaultId:"addImageContentToolGroupButton"},{key:"HIGHLIGHT",toolName:"AnnotationCreateTextHighlight",label:"Highlight",title:"Highlight text",icon:"icon-tool-text-manipulation-highlight",category:c.MARKUP_TEXT,defaultId:"highlightButton"},{key:"UNDERLINE",toolName:"AnnotationCreateTextUnderline",label:"Underline",title:"Underline text",icon:"icon-tool-text-manipulation-underline",category:c.MARKUP_TEXT,defaultId:"underlineButton"},{key:"STRIKEOUT",toolName:"AnnotationCreateTextStrikeout",label:"Strikeout",title:"Strike out text",icon:"icon-text-strikeout",category:c.MARKUP_TEXT,defaultId:"strikeoutButton"},{key:"SQUIGGLY",toolName:"AnnotationCreateTextSquiggly",label:"Squiggly",title:"Squiggly underline",icon:"icon-tool-text-manipulation-squiggly",category:c.MARKUP_TEXT,defaultId:"squigglyButton"},{key:"FREEHAND_HIGHLIGHT",toolName:"AnnotationCreateFreeHandHighlight",label:"Freehand Highlight",title:"Draw freehand highlight",icon:"icon-tool-pen-highlight",category:c.MARKUP_TEXT,defaultId:"freeHandHighlightButton"},{key:"MARK_INSERT_TEXT",toolName:"AnnotationCreateMarkInsertText",label:"Insert Text Mark",title:"Mark text insertion location",icon:"ic-insert text",category:c.MARKUP_TEXT,defaultId:"markInsertTextToolButton"},{key:"MARK_REPLACE_TEXT",toolName:"AnnotationCreateMarkReplaceText",label:"Replace Text Mark",title:"Mark text for replacement",icon:"ic-replace text",category:c.MARKUP_TEXT,defaultId:"markReplaceTextToolButton"},{key:"FREEHAND",toolName:"AnnotationCreateFreeHand",label:"Pencil",title:"Draw freehand ink",icon:"icon-tool-pen-line",category:c.DRAWING_SHAPES,defaultId:"freeHandButton"},{key:"RECTANGLE",toolName:"AnnotationCreateRectangle",label:"Rectangle",title:"Draw rectangle",icon:"icon-tool-shape-rectangle",category:c.DRAWING_SHAPES,defaultId:"rectangleButton"},{key:"ELLIPSE",toolName:"AnnotationCreateEllipse",label:"Ellipse",title:"Draw ellipse or circle",icon:"icon-tool-shape-oval",category:c.DRAWING_SHAPES,defaultId:"ellipseButton"},{key:"LINE",toolName:"AnnotationCreateLine",label:"Line",title:"Draw straight line",icon:"icon-tool-shape-line",category:c.DRAWING_SHAPES,defaultId:"lineButton"},{key:"ARROW",toolName:"AnnotationCreateArrow",label:"Arrow",title:"Draw pointer arrow",icon:"icon-tool-shape-arrow",category:c.DRAWING_SHAPES,defaultId:"arrowButton"},{key:"POLYGON",toolName:"AnnotationCreatePolygon",label:"Polygon",title:"Draw multi-sided polygon",icon:"icon-tool-shape-polygon",category:c.DRAWING_SHAPES,defaultId:"polygonButton"},{key:"POLYLINE",toolName:"AnnotationCreatePolyline",label:"Polyline",title:"Draw connected lines",icon:"icon-tool-shape-polyline",category:c.DRAWING_SHAPES,defaultId:"polylineButton"},{key:"ARC",toolName:"AnnotationCreateArc",label:"Arc",title:"Draw an arc curve",icon:"icon-tool-arc",category:c.DRAWING_SHAPES,defaultId:"arcToolButton"},{key:"POLYGON_CLOUD",toolName:"AnnotationCreatePolygonCloud",label:"Cloud",title:"Draw cloud polygon markup",icon:"icon-tool-shape-cloud",category:c.DRAWING_SHAPES,defaultId:"cloudToolButton"},{key:"ERASER",toolName:"AnnotationEraserTool",label:"Eraser",title:"Erase ink drawings",icon:"icon-operation-eraser",category:c.DRAWING_SHAPES,defaultId:"eraserButton"},{key:"SIGNATURE",toolName:"AnnotationCreateSignature",label:"Signature",title:"Place or create signature",icon:"icon-tool-signature",category:c.INSERT_SIGS,defaultId:"signatureToolButton"},{key:"STICKY_NOTE",toolName:"AnnotationCreateSticky",label:"Sticky Note",title:"Place a sticky comment note",icon:"icon-tool-comment-line",category:c.INSERT_SIGS,defaultId:"stickyToolButton"},{key:"FREE_TEXT",toolName:"AnnotationCreateFreeText",label:"Text Box",title:"Insert text box",icon:"icon-tool-text-free-text",category:c.INSERT_SIGS,defaultId:"freeTextButton"},{key:"CALLOUT",toolName:"AnnotationCreateCallout",label:"Callout",title:"Insert callout box with pointer",icon:"icon-tool-callout-line",category:c.INSERT_SIGS,defaultId:"calloutButton"},{key:"RUBBER_STAMP",toolName:"AnnotationCreateRubberStamp",label:"Rubber Stamp",title:"Place rubber stamps (Approved, Draft, etc.)",icon:"icon-tool-stamp-line",category:c.INSERT_SIGS,defaultId:"rubberStampToolButton"},{key:"IMAGE_STAMP",toolName:"AnnotationCreateStamp",label:"Image Stamp",title:"Insert an image as a stamp",icon:"icon-tool-image-line",category:c.INSERT_SIGS,defaultId:"stampToolButton"},{key:"FILE_ATTACHMENT",toolName:"AnnotationCreateFileAttachment",label:"File Attachment",title:"Attach a file to the document",icon:"ic_fileattachment_24px",category:c.INSERT_SIGS,defaultId:"fileAttachmentButton"},{key:"DATE_FREETEXT",toolName:"AnnotationCreateDateFreeText",label:"Date Text Box",title:"Insert text box with date picker",icon:"icon-tool-fill-and-sign-calendar",category:c.INSERT_SIGS,defaultId:"calendarToolButton"},{key:"CROSS_STAMP",toolName:"AnnotationCreateCrossStamp",label:"Cross Stamp (X)",title:"Place cross / X mark stamp",icon:"icon-tool-cross-stamp",category:c.INSERT_SIGS,defaultId:"crossStampToolButton"},{key:"CHECK_STAMP",toolName:"AnnotationCreateCheckStamp",label:"Checkmark Stamp",title:"Place checkmark stamp",icon:"icon-tool-check-stamp",category:c.INSERT_SIGS,defaultId:"checkStampToolButton"},{key:"DOT_STAMP",toolName:"AnnotationCreateDotStamp",label:"Dot Stamp",title:"Place dot mark stamp",icon:"icon-tool-dot-stamp",category:c.INSERT_SIGS,defaultId:"dotStampToolButton"},{key:"DISTANCE_MEASUREMENT",toolName:"AnnotationCreateDistanceMeasurement",label:"Distance Measure",title:"Measure distance between two points",icon:"icon-tool-measurement-distance-line",category:c.MEASUREMENT,defaultId:"distanceMeasurementButton"},{key:"PERIMETER_MEASUREMENT",toolName:"AnnotationCreatePerimeterMeasurement",label:"Perimeter Measure",title:"Measure perimeter length",icon:"icon-tool-measurement-perimeter",category:c.MEASUREMENT,defaultId:"perimeterMeasurementButton"},{key:"AREA_MEASUREMENT",toolName:"AnnotationCreateAreaMeasurement",label:"Area Measure",title:"Measure area of a region",icon:"icon-tool-measurement-area-polygon-line",category:c.MEASUREMENT,defaultId:"areaMeasurementButton"},{key:"ARC_MEASUREMENT",toolName:"AnnotationCreateArcMeasurement",label:"Arc Measure",title:"Measure arc length and angle",icon:"icon-tool-measurement-arc",category:c.MEASUREMENT,defaultId:"arcMeasurementToolButton"},{key:"RECTANGULAR_AREA_MEASUREMENT",toolName:"AnnotationCreateRectangularAreaMeasurement",label:"Rect Area Measure",title:"Measure rectangular area",icon:"ic_annotation_rectangular_area_black_24px",category:c.MEASUREMENT,defaultId:"rectangularAreaMeasurementToolButton"},{key:"CLOUDY_RECTANGULAR_AREA_MEASUREMENT",toolName:"AnnotationCreateCloudyRectangularAreaMeasurement",label:"Cloudy Area Measure",title:"Measure cloudy rectangular area",icon:"ic_annotation_cloudy_rectangular_area_black_24px",category:c.MEASUREMENT,defaultId:"cloudyRectangleAreaToolGroupButton"},{key:"ELLIPSE_MEASUREMENT",toolName:"AnnotationCreateEllipseMeasurement",label:"Ellipse Measure",title:"Measure elliptical area",icon:"ic_annotation_ellipse_area_black",category:c.MEASUREMENT,defaultId:"ellipseMeasurementToolButton"},{key:"COUNT_MEASUREMENT",toolName:"AnnotationCreateCountMeasurement",label:"Count Measure",title:"Count items and place count marks",icon:"ic_check_black_24px",category:c.MEASUREMENT,defaultId:"countMeasurementToolButton"},{key:"CALIBRATION_MEASUREMENT",toolName:"AnnotationCreateCalibrationMeasurement",label:"Calibrate Measurement",title:"Calibrate measurement scale",icon:"calibrate",category:c.MEASUREMENT,defaultId:"calibrationMeasurementButton"},{key:"REDACTION",toolName:"AnnotationCreateRedaction",label:"Mark for Redaction",title:"Mark text or areas for permanent redaction",icon:"icon-tool-select-area-redaction",category:c.FORMS_REDACT,defaultId:"redactionButton"},{key:"TEXT_FORM_FIELD",toolName:"TextFormFieldCreateTool",label:"Text Form Field",title:"Create text input form field",icon:"icon-form-field-text",category:c.FORMS_REDACT,defaultId:"textFieldButton"},{key:"DATE_PICKER_FORM_FIELD",toolName:"DatePickerFormFieldCreateTool",label:"Date Form Field",title:"Create date picker form field",icon:"icon-tool-fill-and-sign-calendar",category:c.FORMS_REDACT,defaultId:"datePickerFieldButton"},{key:"SIGNATURE_FORM_FIELD",toolName:"SignatureFormFieldCreateTool",label:"Signature Form Field",title:"Create signature form field",icon:"icon-form-field-signature",category:c.FORMS_REDACT,defaultId:"signatureFieldButton"},{key:"CHECK_BOX_FIELD",toolName:"CheckBoxFormFieldCreateTool",label:"Checkbox Form Field",title:"Create checkbox form field",icon:"icon-form-field-checkbox",category:c.FORMS_REDACT,defaultId:"checkboxFieldButton"},{key:"RADIO_FORM_FIELD",toolName:"RadioButtonFormFieldCreateTool",label:"Radio Button Field",title:"Create radio button form field",icon:"icon-form-field-radiobutton",category:c.FORMS_REDACT,defaultId:"radioFieldButton"},{key:"LIST_BOX_FIELD",toolName:"ListBoxFormFieldCreateTool",label:"List Box Field",title:"Create list box form field",icon:"icon-form-field-listbox",category:c.FORMS_REDACT,defaultId:"listBoxFieldButton"},{key:"COMBO_BOX_FIELD",toolName:"ComboBoxFormFieldCreateTool",label:"Combo Box Field",title:"Create combo box dropdown field",icon:"icon-form-field-combobox",category:c.FORMS_REDACT,defaultId:"comboBoxFieldButton"}],R=[{id:"thumbnailsPanel",render:"thumbnailsPanel",name:"Page Thumbnails",defaultLocation:"left",toggleIcon:"icon-panel-thumbnail-line",toggleLabel:"Thumbnails",toggleTitle:"Toggle Thumbnails panel",category:"Standard"},{id:"notesPanel",render:"notesPanel",name:"Notes & Comments",defaultLocation:"right",toggleIcon:"icon-header-chat-line",toggleLabel:"Comments",toggleTitle:"Toggle Comments / Notes panel",category:"Standard"},{id:"searchPanel",render:"searchPanel",name:"Search Panel",defaultLocation:"right",toggleIcon:"icon-header-search",toggleLabel:"Search",toggleTitle:"Toggle Search panel",category:"Standard"},{id:"outlinesPanel",render:"outlinesPanel",name:"Document Outlines",defaultLocation:"left",toggleIcon:"icon-panel-outlines",toggleLabel:"Outlines",toggleTitle:"Toggle Table of Contents / Outlines",category:"Standard"},{id:"bookmarksPanel",render:"bookmarksPanel",name:"User Bookmarks",defaultLocation:"left",toggleIcon:"ic-bookmark",toggleLabel:"Bookmarks",toggleTitle:"Toggle Bookmarks panel",category:"Standard"},{id:"signaturePanel",render:"signaturePanel",name:"Digital Signatures",defaultLocation:"left",toggleIcon:"icon-tool-signature",toggleLabel:"Digital Signatures",toggleTitle:"Toggle Digital Signatures panel",category:"Standard"},{id:"signatureListPanel",render:"signatureListPanel",name:"Saved Signatures",defaultLocation:"left",toggleIcon:"icon-tool-signature",toggleLabel:"Signatures",toggleTitle:"Toggle Saved Signatures panel",category:"Standard"},{id:"stylePanel",render:"stylePanel",name:"Annotation Style Panel",defaultLocation:"left",toggleIcon:"icon-style-panel-toggle",toggleLabel:"Style",toggleTitle:"Toggle Style panel",category:"Standard"},{id:"rubberStampPanel",render:"rubberStampPanel",name:"Rubber Stamps",defaultLocation:"left",toggleIcon:"icon-tool-stamp-line",toggleLabel:"Stamps",toggleTitle:"Toggle Rubber Stamps panel",category:"Standard"},{id:"layersPanel",render:"layersPanel",name:"PDF Layers",defaultLocation:"left",toggleIcon:"ic-layer",toggleLabel:"Layers",toggleTitle:"Toggle Layers panel",category:"Specialized"},{id:"fileAttachmentPanel",render:"fileAttachmentPanel",name:"File Attachments",defaultLocation:"left",toggleIcon:"ic_fileattachment_24px",toggleLabel:"Attachments",toggleTitle:"Toggle File Attachments panel",category:"Specialized"},{id:"redactionPanel",render:"redactionPanel",name:"Redaction Manager",defaultLocation:"right",toggleIcon:"icon-redact-panel",toggleLabel:"Redaction",toggleTitle:"Toggle Redactions panel",category:"Specialized"},{id:"textEditingPanel",render:"textEditingPanel",name:"Content & Text Editing",defaultLocation:"right",toggleIcon:"icon-content-edit",toggleLabel:"Text Editing",toggleTitle:"Toggle Text Editing panel",category:"Specialized"},{id:"changeListPanel",render:"changeListPanel",name:"Track Changes / Compare",defaultLocation:"right",toggleIcon:"icon-header-compare",toggleLabel:"Changes",toggleTitle:"Toggle Track Changes panel",category:"Specialized"},{id:"portfolioPanel",render:"portfolioPanel",name:"PDF Portfolio",defaultLocation:"left",toggleIcon:"icon-pdf-portfolio",toggleLabel:"Portfolio",toggleTitle:"Toggle Portfolio panel",category:"Specialized"},{id:"indexPanel",render:"indexPanel",name:"Form Fields Index",defaultLocation:"left",toggleIcon:"icon-index-panel-list",toggleLabel:"Form Index",toggleTitle:"Toggle Form Fields Index panel",category:"Specialized"},{id:"formFieldPanel",render:"formFieldPanel",name:"Form Field Properties",defaultLocation:"right",toggleIcon:"icon-edit-form-field",toggleLabel:"Form Properties",toggleTitle:"Toggle Form Field Properties panel",category:"Specialized"}],B=new Set(["stylePanel","redactionPanel"]),L={thumbnailsPanel:"Thumbnails",outlinesPanel:"Table of Contents",bookmarksPanel:"Bookmarks",searchPanel:"Search",fileAttachmentPanel:"Attachments",textEditingPanel:"Text Editing",changeListPanel:"Track Changes"};R.filter(o=>!B.has(o.id)).map(o=>({id:o.id,render:o.render,name:L[o.id]||o.name,icon:o.toggleIcon}));const h=[{id:"annotationPopup",name:"Annotation Popup",description:"Opens when an annotation is selected.",defaultItems:[{dataElement:"viewFileButton",label:"View File Attachment",context:"File Attachment"},{dataElement:"annotationCommentButton",label:"Comment / Reply",context:"Standard"},{dataElement:"annotationStyleEditButton",label:"Style (Color/Stroke)",context:"Standard"},{dataElement:"annotationDateEditButton",label:"Edit Date",context:"Date Annotation"},{dataElement:"annotationRedactButton",label:"Apply Redaction",context:"Redaction"},{dataElement:"annotationCropButton",label:"Apply Crop",context:"Crop Tool"},{dataElement:"annotationContentEditButton",label:"Edit Text Content",context:"FreeText"},{dataElement:"annotationClearSignatureButton",label:"Clear Signature",context:"Signature"},{dataElement:"annotationGroupButton",label:"Group Annotations",context:"Multi-select"},{dataElement:"annotationUngroupButton",label:"Ungroup Annotations",context:"Multi-select"},{dataElement:"formFieldEditButton",label:"Edit Form Field",context:"Form Field"},{dataElement:"calibratePopupButton",label:"Calibrate Measurement",context:"Measurement"},{dataElement:"linkButton",label:"Add / Edit Link",context:"Standard"},{dataElement:"fileAttachmentDownload",label:"Download Attachment",context:"File Attachment"},{dataElement:"annotationDeleteButton",label:"Delete Annotation",context:"Standard"},{dataElement:"playSoundButton",label:"Play Sound",context:"Sound Annotation"},{dataElement:"openAlignmentButton",label:"Alignment Options",context:"Multi-select"}]},{id:"textPopup",name:"Text Popup",description:"Opens when text in the document is selected.",defaultItems:[{dataElement:"copyTextButton",label:"Copy Text",context:"Text Selection"},{dataElement:"textHighlightToolButton",label:"Highlight Text",context:"Text Markup"},{dataElement:"textUnderlineToolButton",label:"Underline Text",context:"Text Markup"},{dataElement:"textSquigglyToolButton",label:"Squiggly Text",context:"Text Markup"},{dataElement:"textStrikeoutToolButton",label:"Strikeout Text",context:"Text Markup"},{dataElement:"textRedactToolButton",label:"Redact Selected Text",context:"Redaction Enabled"},{dataElement:"linkButton",label:"Add Link",context:"Text Selection"}]},{id:"contextMenuPopup",name:"Context Menu Popup",description:"Opens when right-clicking on the document canvas.",defaultItems:[{dataElement:"panToolButton",label:"Pan Tool",context:"Canvas Right-Click"},{dataElement:"stickyToolButton",label:"Sticky Note",context:"Canvas Right-Click"},{dataElement:"highlightToolButton",label:"Highlight",context:"Canvas Right-Click"},{dataElement:"freeHandToolButton",label:"Freehand Pencil",context:"Canvas Right-Click"},{dataElement:"freeHandHighlightToolButton",label:"Freehand Highlight",context:"Canvas Right-Click"},{dataElement:"freeTextToolButton",label:"Free Text",context:"Canvas Right-Click"},{dataElement:"markInsertTextToolButton",label:"Insert Text Mark",context:"Canvas Right-Click"},{dataElement:"markReplaceTextToolButton",label:"Replace Text Mark",context:"Canvas Right-Click"}]}],F=new Set(["textHighlightToolButton","textUnderlineToolButton","textSquigglyToolButton","textStrikeoutToolButton","textRedactToolButton","panToolButton","stickyToolButton","highlightToolButton","freeHandToolButton","freeHandHighlightToolButton","freeTextToolButton","markInsertTextToolButton","markReplaceTextToolButton"]);(()=>{const o=new Map;for(const l of h)for(const a of l.defaultItems)!F.has(a.dataElement)&&!o.has(a.dataElement)&&o.set(a.dataElement,{dataElement:a.dataElement,label:a.label,context:a.context});return Array.from(o.values())})();const O=Object.fromEntries(h.map(o=>[o.id,o.defaultItems.map(({dataElement:l})=>({dataElement:l}))])),D=new Set(Object.values(O||{}).flatMap(o=>(o||[]).map(l=>l.dataElement))),U=new Set(["customButton","toggleButton","toolGroupToggleButton","presetButton","toolButton"]),w=new Set(["left","right","start","end"]),y=o=>typeof o=="string"&&A[o]?A[o]:o,G=o=>(o==null?void 0:o.type)==="toggleButton"?o.toggleElement||o.element:null;function S(o){if(!o||o.type!=="toolButton")return o;const l=o.toolName||o.dataElement;return{...o,type:"customButton",toolName:l,label:o.label||o.title||l,title:o.title||o.label||l,onClick:`${p}${l}`}}function I(o,l,a=0,n=new Set){if(!o||!Array.isArray(o.children))return o;if(a>=N)return{...o,children:[]};const e=[];for(const t of o.children){if(t&&typeof t=="object"){e.push(t);continue}const u=l[t];if(!u||n.has(t))continue;const i=new Set(n).add(t);e.push(I({...u,dataElement:u.dataElement||t},l,a+1,i))}return{...o,children:e}}function $(o,l){const a={};for(const[n,e]of Object.entries(o.modularComponents||{})){if(!e||typeof e!="object")continue;if(!e.type||typeof e.type!="string"){l.push(`Skipping component '${n}' because it lacks a valid 'type'.`);continue}const t={...e,dataElement:e.dataElement||n};delete t.store,t.type==="toggleElementButton"||t.type==="toggleButton"?(t.type="toggleButton",!t.toggleElement&&t.element&&(t.toggleElement=t.element)):t.type==="button"?t.type="customButton":(t.type==="mainMenu"||t.type==="menuButton")&&(t.type="toggleButton",t.toggleElement=t.toggleElement||"MainMenuFlyout",(!t.img||t.img==="icon-header-menu")&&(t.img="ic-hamburger-menu"),t.title=t.title||"Menu"),t.type==="presetButton"&&t.onClick===""&&delete t.onClick,U.has(t.type)&&t.icon&&!t.img&&(t.img=t.icon),t.img==="icon-header-menu"&&(t.img="ic-hamburger-menu"),t.icon==="icon-header-menu"&&(t.icon="ic-hamburger-menu"),t.type==="customButton"&&t.toolName&&(t.onClick||(t.onClick=`${p}${t.toolName}`),t.label=t.label||t.title||t.toolName,t.title=t.title||t.label||t.toolName),t.type==="label"&&(t.label=t.label||t.title||n),t.type==="ribbonItem"&&(Array.isArray(t.groupedItems)||(t.groupedItems=[]),t.title||(t.title=t.label||n),t.toolbarGroup||(t.toolbarGroup=n)),(t.type==="ribbonGroup"||t.type==="groupedItems")&&!Array.isArray(t.items)&&(t.items=[]),t.type==="toolGroupToggleButton"&&Array.isArray(t.groupedItems)&&(t.groupedItems=t.groupedItems[0]||""),a[n]=t}for(const n of Object.values(a))Array.isArray(n.items)&&(n.items=n.items.filter(e=>e===g||!!a[e])),n.type==="toolGroupToggleButton"?typeof n.groupedItems=="string"&&n.groupedItems&&!a[n.groupedItems]&&l.push(`ToolGroupToggleButton '${n.dataElement}' targets groupedItems '${n.groupedItems}', which is not defined in modularComponents.`):Array.isArray(n.groupedItems)&&(n.groupedItems=n.groupedItems.filter(e=>!!a[e]));return a}function v(o,l){const a={};for(const[n,e]of Object.entries(o.modularHeaders||{})){if(!e||typeof e!="object")continue;const t=String(n).toLowerCase();if(t==="view"||t==="toolbargroup-view")continue;const u={...e,dataElement:e.dataElement||n};u.placement&&!M.has(String(u.placement).toLowerCase())&&(u.placement="top"),u.items=Array.isArray(u.items)?u.items.filter(i=>i===g||!!l[i]):[],a[n]=u}return a}function H(o,l){const a={};for(const[n,e]of Object.entries(o.panels||{})){if(!e||typeof e!="object")continue;const t=String(e.location||"").toLowerCase(),u=w.has(t)?t:"left",i=y(e.render||n),r=typeof e.render=="string"&&e.render.trim().length>0&&!f.has(i)&&(!!e.title||e.render!==n);if(!f.has(i)&&typeof i!="function"&&!r){l.push(`Skipping invalid panel '${n}' with unsupported render '${i}'.`);continue}r&&l.push(`Panel '${n}' uses custom render function '${i}'. Pass '${i}' in functionMap when calling UI.importModularComponents(config, functionMap).`);const d=n==="outlinePanel"?"outlinesPanel":n,s={...e,dataElement:d,location:u,render:i};i===T&&(s.panelsList=Array.isArray(s.panelsList)?s.panelsList.filter(m=>m&&typeof m=="object"&&m.render).map(m=>({...m,render:y(m.render)})):[]),a[d]=s}for(const n of Object.values(a))n.render!==T||!Array.isArray(n.panelsList)||(n.panelsList=n.panelsList.filter(e=>a[e.render]?!0:f.has(e.render)?(a[e.render]={dataElement:e.render,render:e.render,location:n.location||"left"},!0):(l.push(`TabPanel '${n.dataElement}': dropped unknown sub-panel '${e.render}' from panelsList.`),!1)));return a}function K(o,l,a){const n={};for(const[e,t]of Object.entries(o.flyouts||{})){if(!t||typeof t!="object")continue;const u=[];for(const i of Array.isArray(t.items)?t.items:[]){if(i==null){a.push(`Flyout '${e}': dropped null/empty item.`);continue}if(i===g){u.push(g);continue}if(typeof i=="object"){const s=y(i.render);s&&E.has(s)?u.push({dataElement:i.dataElement||`${s}Item`,render:s}):a.push(i.render?`Flyout '${e}': dropped panel render '${i.render}' (only rubberStampPanel, signatureListPanel, and stylePanel can be rendered inside a flyout).`:`Flyout '${e}': dropped invalid object item without a supported render property.`);continue}let r=l[i];if(!r){a.push(`Flyout '${e}': dropped unknown item '${i}'.`);continue}if(r.type===g){u.push(g);continue}const d=y(r.render);if(r.type==="flyoutPanel"||d&&E.has(d)){d&&E.has(d)?u.push({dataElement:r.dataElement||i,render:d}):a.push(`Flyout '${e}': dropped panel '${i}' with unsupported render '${d}' (only rubberStampPanel, signatureListPanel, and stylePanel are supported).`),delete l[i];continue}if(r.type==="toolButton"&&(r=S(r),l[i]=r),r.type==="customButton"&&typeof r.onClick=="string"&&r.onClick.startsWith(p)&&a.push(`Flyout '${e}': '${i}' uses customButton action '${r.onClick}' (WebViewer rejects toolButton in flyouts). Pass functionMap to UI.importModularComponents(config, functionMap) when using exported JSON.`),r.type==="toggleButton"||r.type==="toggleElementButton"){a.push(`Flyout '${e}': dropped toggle button '${i}' (toggle buttons are only supported in headers and ribbon tabs; WebViewer does not support toggleElement inside flyouts).`);continue}if(!b.has(r.type)){a.push(`Flyout '${e}': dropped '${i}' (type '${r.type}' is not allowed in flyouts).`);continue}u.push(i)}n[e]={...t,dataElement:e,items:u}}return n}function j(o,l){const a={...o};for(const[n,e]of Object.entries(a)){if(!Array.isArray(e.children))continue;const t=I(e,a),u=i=>i.map(r=>r.type==="toolButton"?S(r):r).filter(r=>r.type==="toggleButton"||r.type==="toggleElementButton"?(l.push(`Component '${n}': dropped submenu child '${r.dataElement}' (toggle buttons are only supported in headers and ribbon tabs; WebViewer does not support toggleElement inside submenus).`),!1):b.has(r.type)?!0:(l.push(`Component '${n}': dropped submenu child '${r.dataElement}' (type '${r.type}' not allowed).`),!1)).map(r=>Array.isArray(r.children)?{...r,children:u(r.children)}:r);a[n]={...t,children:u(t.children)}}return a}function W(o,l){var n;if(!o.popups||typeof o.popups!="object")return;if(Array.isArray(o.popups)){l.push("Ignoring invalid 'popups' property (expected an object).");return}const a={};for(const[e,t]of Object.entries(o.popups)){if(!_.has(e)){l.push(`Skipping unknown popup '${e}' in popups.`);continue}if(!Array.isArray(t)){l.push(`Skipping popup '${e}' because its value is not an array.`);continue}const u=[];for(const i of t){const r=(typeof i=="string"?i:(i==null?void 0:i.dataElement)||"").trim();if(!r){l.push(`Popup '${e}': dropped invalid item (each item must have a 'dataElement').`);continue}const d=typeof i=="object"&&i!==null?i:{};if(d.type==="popupAction"||!d.type&&D.has(r)){u.push({dataElement:r});continue}const m=(n=o.modularComponents)==null?void 0:n[r];u.push(m?{...m,...d,dataElement:r}:{...d,dataElement:r})}a[e]=u}return Object.keys(a).length>0?a:void 0}function V(o,l){const a=new Set([...Object.keys(o.flyouts),...Object.keys(o.panels),...Object.keys(o.modularComponents),...Object.keys(o.modularHeaders)]);for(const[n,e]of Object.entries(o.modularComponents)){const t=G(e);t&&!a.has(t)&&l.push(`Toggle '${n}' targets '${t}', which is not defined in this config (may be a built-in element).`)}}function z(o,l){const a=new Set;return o.map(n=>{const e=typeof n=="string"?n:n==null?void 0:n.dataElement;if(!e||!a.has(e))return e&&a.add(e),n;const t=l[e];if(!t)return n;let u=1,i=`${e}__sdk_dup_${u}`;for(;l[i];)u+=1,i=`${e}__sdk_dup_${u}`;return l[i]={...t,dataElement:i},typeof n=="string"?i:{...n,dataElement:i}})}function X(o){if(!o||typeof o!="object")return;const l=o.modularComponents||{},a=[...Object.values(l),...Object.values(o.modularHeaders||{}),...Object.values(o.flyouts||{})];for(const n of a)Array.isArray(n==null?void 0:n.items)&&(n.items=z(n.items,l))}function P(o={},{forViewer:l=!1}={}){const a=[],n=$(o,a),e=v(o,n),t=H(o,a),u=K(o,n,a),i=j(n,a),r=W(o,a),d={...o,modularComponents:i,modularHeaders:e,panels:t,flyouts:u,...r!==void 0?{popups:r}:{}};return r===void 0&&"popups"in d&&delete d.popups,V(d,a),l&&X(d),{config:d,warnings:a}}function C(o={}){const l=[],a=new Set,n=e=>{!e||typeof e!="object"||(typeof e.onClick=="string"&&e.onClick.length>0&&!a.has(e.onClick)&&(a.add(e.onClick),e.onClick.startsWith(p)?l.push({kind:"tool",actionKey:e.onClick,toolName:e.onClick.slice(p.length),dataElement:e.dataElement}):l.push({kind:"onClick",actionKey:e.onClick,dataElement:e.dataElement})),e.type==="customElement"&&typeof e.render=="string"&&e.render.length>0&&!a.has(e.render)&&(a.add(e.render),l.push({kind:"customElement",actionKey:e.render,dataElement:e.dataElement,label:e.title||e.dataElement||e.render})),Array.isArray(e.children)&&e.children.forEach(n))};Object.values(o.modularComponents||{}).forEach(n);for(const[e,t]of Object.entries(o.panels||{}))t&&typeof t.render=="string"&&t.render.length>0&&!f.has(t.render)&&!a.has(t.render)&&(a.add(t.render),l.push({kind:"customPanel",actionKey:t.render,dataElement:e,title:t.title||e}));return l}function k(o={},l=null){const a={},n=e=>()=>{var u,i,r;const t=l||(typeof window<"u"?window.viewerInstance:null);if(t)try{const d=(u=t.Core)==null?void 0:u.documentViewer,s=(i=d==null?void 0:d.getTool)==null?void 0:i.call(d,e);s&&(d!=null&&d.setToolMode)?d.setToolMode(s):(r=t.UI)!=null&&r.setToolMode&&t.UI.setToolMode(e)}catch(d){console.warn(`Failed to activate tool '${e}':`,d)}};for(const e of x)e.toolName&&(a[`${p}${e.toolName}`]=n(e.toolName));for(const e of C(o))a[e.actionKey]||(e.kind==="tool"&&e.toolName?a[e.actionKey]=n(e.toolName):e.kind==="onClick"?a[e.actionKey]=()=>{console.info(`[WebViewer UI Builder] Custom button action '${e.actionKey}' triggered.`)}:e.kind==="customElement"?a[e.actionKey]=t=>{const u=document.createElement("div");return u.style.padding="4px 8px",u.style.fontSize="12px",u.style.whiteSpace="nowrap",u.textContent=typeof t=="string"&&t?t:e.label,u}:e.kind==="customPanel"&&(a[e.actionKey]=()=>{const t=document.createElement("div");return t.style.padding="16px",t.textContent=`Custom Panel: ${e.title} (${e.actionKey})`,t}));return a}function q(o={}){const l=C(o);if(l.length===0)return{entries:[],snippet:""};const n=`const functionMap = {
2
+ ${l.map(e=>e.kind==="tool"?` '${e.actionKey}': () => {
3
+ const { documentViewer } = instance.Core;
4
+ documentViewer.setToolMode(documentViewer.getTool('${e.toolName}'));
5
+ },`:e.kind==="customElement"?` '${e.actionKey}': (args) => {
6
+ const element = document.createElement('div');
7
+ element.innerText = args || '${e.dataElement||e.actionKey}';
8
+ return element;
9
+ },`:e.kind==="customPanel"?` '${e.actionKey}': () => {
10
+ const div = document.createElement('div');
11
+ div.innerHTML = 'Custom panel (${e.dataElement||e.actionKey})';
12
+ return div;
13
+ },`:` '${e.actionKey}': () => {
14
+ // Custom onClick handler for '${e.dataElement||e.actionKey}'
15
+ },`).join(`
16
+ `)}
17
+ };
18
+
19
+ instance.UI.importModularComponents(config, functionMap);`;return{entries:l,snippet:n}}function Y(o,l,{customHandlers:a={},forViewer:n=!0}={}){var r;if(!((r=o==null?void 0:o.UI)!=null&&r.importModularComponents))throw new Error("[webviewer-ui-builder] applyModularConfig requires an initialized Apryse WebViewer instance (v11.8+ with Modular UI).");const{config:e,warnings:t}=P(l,{forViewer:n}),i={...k(e,o),...a};return o.UI.importModularComponents(e,i),{config:e,functionMap:i,warnings:t}}exports.applyModularConfig=Y;exports.buildFunctionMap=k;exports.getRequiredFunctionMapInfo=q;exports.prepareConfigForImport=P;
@@ -0,0 +1,50 @@
1
+ export type ModularUIConfig = Record<string, any>;
2
+
3
+ export type FunctionMap = Record<string, (...args: any[]) => any>;
4
+
5
+ export interface ApplyModularConfigOptions {
6
+ /** Custom action or renderer functions merged on top of generated tool activators. */
7
+ customHandlers?: FunctionMap;
8
+ /** Whether to apply viewer-specific import normalization (default: true). */
9
+ forViewer?: boolean;
10
+ }
11
+
12
+ export interface ApplyModularConfigResult {
13
+ config: ModularUIConfig;
14
+ functionMap: FunctionMap;
15
+ warnings: string[];
16
+ }
17
+
18
+ export interface FunctionMapEntry {
19
+ actionKey: string;
20
+ kind: 'tool' | 'onClick' | 'customElement' | 'customPanel';
21
+ toolName?: string;
22
+ dataElement?: string;
23
+ label?: string;
24
+ title?: string;
25
+ }
26
+
27
+ export interface RequiredFunctionMapInfo {
28
+ entries: FunctionMapEntry[];
29
+ snippet: string;
30
+ }
31
+
32
+ export declare function applyModularConfig(
33
+ instance: any,
34
+ config: ModularUIConfig,
35
+ options?: ApplyModularConfigOptions,
36
+ ): ApplyModularConfigResult;
37
+
38
+ export declare function prepareConfigForImport(
39
+ config: ModularUIConfig,
40
+ options?: { forViewer?: boolean },
41
+ ): { config: ModularUIConfig; warnings: string[] };
42
+
43
+ export declare function buildFunctionMap(
44
+ config?: ModularUIConfig,
45
+ viewerInstance?: any,
46
+ ): FunctionMap;
47
+
48
+ export declare function getRequiredFunctionMapInfo(
49
+ config?: ModularUIConfig,
50
+ ): RequiredFunctionMapInfo;