@topconsultnpm/sdkui-react 6.20.0-dev3.4 → 6.20.0-dev3.5

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import styled from 'styled-components';
4
- import { IconFolderOpen, IconScanner, SDKUI_Localizator, formatBytes, IconClear, extensionHandler, IconCloseOutline, IconMenuVertical, TMCommandsContextMenu, IconEdit } from '../../../helper';
4
+ import { IconFolderOpen, IconScanner, SDKUI_Localizator, formatBytes, IconClear, extensionHandler, IconCloseOutline, IconMenuVertical, TMCommandsContextMenu, IconEdit, isPdfEditorAvailable } from '../../../helper';
5
5
  import usePreventFileDrop from '../../../hooks/usePreventFileDrop';
6
6
  import { FileExtensionHandler } from '../../../ts';
7
7
  import { TMColors } from '../../../utils/theme';
@@ -12,7 +12,6 @@ import TMTooltip from '../../base/TMTooltip';
12
12
  import { TMFileViewer, StyledHeaderIcon } from './TMDcmtPreview';
13
13
  import TMPanel from '../../base/TMPanel';
14
14
  import TMDragDropOverlay from './TMDragDropOverlay';
15
- import { LicenseModuleStatus, SDK_Globals } from '@topconsultnpm/sdk-ts';
16
15
  const TMFileUploader = ({ fromDTD, deviceType = DeviceType.DESKTOP, onClose, onFileUpload, openPdfEditor, onScanRequest, isRequired = false, defaultBlob = null, isResizingActive, showTMPanel = true, enableDragDropOverlay = false }) => {
17
16
  const [dragOver, setDragOver] = useState(false);
18
17
  const [uploadedFile, setUploadedFile] = useState(defaultBlob);
@@ -90,15 +89,14 @@ const TMFileUploader = ({ fromDTD, deviceType = DeviceType.DESKTOP, onClose, onF
90
89
  _jsx("div", { style: { backgroundColor: '#f6dbdb', padding: '5px 10px', borderRadius: 8, display: 'flex', alignItems: 'center', justifyContent: 'space-between', color: TMColors.error }, children: _jsxs("div", { children: [" ", 'Anteprima non disponibile.', fileExt && _jsx("b", { children: ` (*.${fileExt})` })] }) })] });
91
90
  const innerContent = (_jsxs("div", { style: { width: '100%', height: '100%', padding: '2px', display: 'flex', flexDirection: 'column', gap: 10 }, children: [enableDragDropOverlay && _jsx(TMDragDropOverlay, { handleFile: handleFile, refocusAfterFileInput: refocusAfterFileInput }), content] }));
92
91
  const toolbar = useMemo(() => {
93
- const isPdfEditorLicensed = SDK_Globals?.license?.dcmtArchiveLicenses?.[0]?.siX_60007?.status === LicenseModuleStatus.Licensed;
94
- return (_jsxs(_Fragment, { children: [(isPdfEditorLicensed && fileExt && fileExt.toLowerCase() === 'pdf') && (_jsx(TMCommandsContextMenu, { target: "#TMPanel-FileUploader-Commands-Header", menuItems: [
92
+ return (_jsxs(_Fragment, { children: [(isPdfEditorAvailable(fromDTD, fileExt) && openPdfEditor) && (_jsx(TMCommandsContextMenu, { target: "#TMPanel-FileUploader-Commands-Header", menuItems: [
95
93
  {
96
94
  icon: _jsx(IconEdit, {}),
97
95
  text: 'PDF Editor',
98
- onClick: () => openPdfEditor?.(fromDTD, uploadedFile, handleFile)
96
+ onClick: () => openPdfEditor(fromDTD, uploadedFile, handleFile)
99
97
  }
100
98
  ], showEvent: "click", children: _jsx(IconMenuVertical, { id: "TMPanel-FileUploader-Commands-Header", color: "white", cursor: "pointer" }) })), deviceType !== DeviceType.MOBILE && (_jsx(StyledHeaderIcon, { onClick: onClose, "$color": "white", children: _jsx(TMTooltip, { content: SDKUI_Localizator.Close, children: _jsx(IconCloseOutline, {}) }) }))] }));
101
- }, [deviceType, onClose]);
99
+ }, [deviceType, fromDTD, onClose]);
102
100
  return showTMPanel ? (_jsx(TMPanel, { ref: fileUploaderPanelRef, panelID: 'file-uploader-panel', title: SDKUI_Localizator.FileUpload, onBack: deviceType === DeviceType.MOBILE ? () => onClose?.() : undefined, toolbar: toolbar, children: innerContent })) : (innerContent);
103
101
  };
104
102
  const UploadContainer = styled.div `
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AccessLevels, AccessLevelsEx, AppModules, FileFormats, LayoutModes, SDK_Globals, DcmtTypeListCacheService, LicenseModuleStatus } from '@topconsultnpm/sdk-ts';
3
- import { IconActivity, IconArchiveDoc, IconBatchUpdate, IconCheckFile, IconCheckIn, IconCircleInfo, IconCloseCircle, IconConvertFilePdf, IconDelete, IconDotsVerticalCircleOutline, IconDownload, IconEdit, IconExportTo, IconFileDots, IconHide, IconInfo, IconMenuCAArchive, IconPlatform, IconPreview, IconRelation, IconSearch, IconShow, IconStar, IconSubstFile, IconUndo, IconUserGroupOutline, SDKUI_Localizator, searchResultToMetadataValues, IconSignaturePencil, IconArchiveMaster, IconArchiveDetail, IconDetailDcmts, isPdfEditorEnabled, IconPair, IconUnpair, IconSharedDcmt, IconShare, IconCopy, IconMoveToFolder, IconPin } from '../../../helper';
2
+ import { AccessLevels, AccessLevelsEx, AppModules, FileFormats, LayoutModes, SDK_Globals, DcmtTypeListCacheService } from '@topconsultnpm/sdk-ts';
3
+ import { IconActivity, IconArchiveDoc, IconBatchUpdate, IconCheckFile, IconCheckIn, IconCircleInfo, IconCloseCircle, IconConvertFilePdf, IconDelete, IconDotsVerticalCircleOutline, IconDownload, IconEdit, IconExportTo, IconFileDots, IconHide, IconInfo, IconMenuCAArchive, IconPlatform, IconPreview, IconRelation, IconSearch, IconShow, IconStar, IconSubstFile, IconUndo, IconUserGroupOutline, SDKUI_Localizator, searchResultToMetadataValues, IconSignaturePencil, IconArchiveMaster, IconArchiveDetail, IconDetailDcmts, IconPair, IconUnpair, IconSharedDcmt, IconShare, IconCopy, IconMoveToFolder, IconPin, isPdfEditorAvailable } from '../../../helper';
4
4
  import ShowAlert from '../../base/TMAlert';
5
5
  import { TMMessageBoxManager, ButtonNames, TMExceptionBoxManager } from '../../base/TMPopUp';
6
6
  import TMSpinner from '../../base/TMSpinner';
@@ -81,7 +81,6 @@ export const signatureInformationCallback = async (isMobile, inputDcmts) => {
81
81
  }
82
82
  };
83
83
  export const getCommandsMenuItems = (isMobile, dtd, allUsers, selectedItems, focusedItem, context, showFloatingBar, workingGroupContext, showSearch, setShowFloatingBar, openFormHandler, openSharedArchiveHandler, showSharedDcmtsHandler, downloadDcmtsAsync, runOperationAsync, onRefreshSearchAsync, onRefreshDataRowsAsync, onRefreshAfterAddDcmtToFavs, confirmFormat, confirmAttachments, openTaskFormHandler, openDetailDcmtsFormHandler, openMasterDcmtsFormHandler, openBatchUpdateFormHandler, openExportForm, handleToggleSearch, handleSignApprove, openSignSettingsForm, handleCheckOutOperationCallback, handleCheckInOperationCallback, showCheckoutInformationFormCallback, viewHistoryCallback, copyCheckoutPathToClipboardOperationCallback, openWGsCopyMoveForm, openCommentFormCallback, openEditPdf, openAddDocumentForm, passToArchiveCallback, archiveMasterDocuments, archiveDetailDocuments, hasMasterRelation, hasDetailRelation, canArchiveMasterRelation, canArchiveDetailRelation, pairManyToManyDocuments, hasManyToManyRelation, pinnedItemIds, onTogglePin) => {
84
- const isPdfEditorLicensed = SDK_Globals?.license?.dcmtArchiveLicenses?.[0]?.siX_60007?.status === LicenseModuleStatus.Licensed;
85
84
  const addPinIconToItems = (items) => {
86
85
  if (isMobile || !onTogglePin)
87
86
  return items;
@@ -102,10 +101,6 @@ export const getCommandsMenuItems = (isMobile, dtd, allUsers, selectedItems, foc
102
101
  return newItem;
103
102
  });
104
103
  };
105
- let pdfEditorAvailable = false;
106
- if (dtd && dtd.widgets && dtd.widgets.length > 0) {
107
- pdfEditorAvailable = isPdfEditorEnabled(dtd.widgets);
108
- }
109
104
  const addToFavoriteMenuItem = () => {
110
105
  return {
111
106
  id: 'fav',
@@ -735,7 +730,7 @@ export const getCommandsMenuItems = (isMobile, dtd, allUsers, selectedItems, foc
735
730
  duplicateDocumentMenuItem(),
736
731
  batchUpdateMenuItem(),
737
732
  passToArchive(),
738
- ...((isPdfEditorLicensed && pdfEditorAvailable && openEditPdf && getSelectedDcmtsOrFocused(selectedItems, focusedItem)?.[0]?.FILEEXT?.toLowerCase() === "pdf") ? [pdfEditorMenuItem(openEditPdf)] : []),
733
+ ...((isPdfEditorAvailable(dtd, getSelectedDcmtsOrFocused(selectedItems, focusedItem)?.[0]?.FILEEXT) && openEditPdf) ? [pdfEditorMenuItem(openEditPdf)] : []),
739
734
  ]
740
735
  },
741
736
  signatureMenuItem(),
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { FileItem } from '../components';
3
- import { AppModules, DataColumnDescriptor, PdGs, SearchResultDescriptor } from '@topconsultnpm/sdk-ts';
3
+ import { AppModules, DataColumnDescriptor, DcmtTypeDescriptor, PdGs, SearchResultDescriptor } from '@topconsultnpm/sdk-ts';
4
4
  export declare const getFileIcon: (fileExtension: string | undefined, fileCount: number | undefined, tooltipContent?: JSX.Element | string) => import("react/jsx-runtime").JSX.Element;
5
5
  export declare function formatBytes(bytes: number | undefined, decimalPlaces?: number): string;
6
6
  export interface RowData {
@@ -17,6 +17,8 @@ export declare const isWidgetEnabled: (widgetId: string, widgetsString: string)
17
17
  export declare const isSign4TopEnabled: (widgetsString: string) => boolean;
18
18
  export declare const isCreateCertificateEnabled: (widgetsString: string) => boolean;
19
19
  export declare const isPdfEditorEnabled: (widgetsString: string) => boolean;
20
+ /** Verifica se l'editor PDF è disponibile: richiede file PDF, licenza attiva e widget abilitato sul tipo documento. */
21
+ export declare const isPdfEditorAvailable: (fromDTD: DcmtTypeDescriptor | undefined, ext: string | undefined) => boolean;
20
22
  interface TabItemProps {
21
23
  $isSelected: boolean;
22
24
  }
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import styled from "styled-components";
3
3
  import { TMTooltip } from '../components';
4
4
  import { IconCADossier, IconKey, IconMenuCAWorkingGroups } from './TMIcons';
5
- import { AppModules, DataListCacheService, MetadataDataDomains, PdGs } from '@topconsultnpm/sdk-ts';
5
+ import { AppModules, DataListCacheService, LicenseModuleStatus, MetadataDataDomains, PdGs, SDK_Globals } from '@topconsultnpm/sdk-ts';
6
6
  import { SDKUI_Localizator } from './SDKUI_Localizator';
7
7
  const StyledIconFileContainer = styled.div `
8
8
  height: 22px;
@@ -178,6 +178,15 @@ export const isCreateCertificateEnabled = (widgetsString) => {
178
178
  export const isPdfEditorEnabled = (widgetsString) => {
179
179
  return isWidgetEnabled(PDF_EDITOR_ID, widgetsString);
180
180
  };
181
+ /** Verifica se l'editor PDF è disponibile: richiede file PDF, licenza attiva e widget abilitato sul tipo documento. */
182
+ export const isPdfEditorAvailable = (fromDTD, ext) => {
183
+ if (fromDTD === undefined || !fromDTD.widgets || !ext)
184
+ return false;
185
+ if (ext.toLowerCase() !== "pdf")
186
+ return false;
187
+ const isPdfEditorLicensed = SDK_Globals?.license?.dcmtArchiveLicenses?.[0]?.siX_60007?.status === LicenseModuleStatus.Licensed;
188
+ return isPdfEditorLicensed && isPdfEditorEnabled(fromDTD.widgets);
189
+ };
181
190
  export const StyledTabItem = styled.div `
182
191
  display: flex;
183
192
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev3.4",
3
+ "version": "6.20.0-dev3.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",