@topconsultnpm/sdkui-react 6.20.0-dev1.34 → 6.20.0-dev1.36

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.
@@ -32,8 +32,8 @@ export interface TMDataGridProps<T> extends IDataGridOptions {
32
32
  pageSize?: TMDataGridPageSize;
33
33
  /** Configures the search panel position in the toolbar */
34
34
  searchPanelToolbarPosition?: 'before' | 'default';
35
- /** if visible, set focus on SearchPanel */
36
- searchPanelFocusStarting?: boolean;
35
+ /** Trigger to set focus on SearchPanel (only if visible) - change the number to trigger focus */
36
+ searchPanelFocusTrigger?: number;
37
37
  /** Show the header filter */
38
38
  showHeaderFilter?: boolean;
39
39
  /** Show the filter panel */
@@ -17,7 +17,7 @@ const TMDataGrid = React.forwardRef((props, ref) => {
17
17
  // main properties
18
18
  keyExpr = 'id', dataSource, focusedRowEnabled = true, hoverStateEnabled = true, focusedRowKey, selectedRowKeys = [],
19
19
  // custom options
20
- dataColumns = [], pageSize = TMDataGridPageSize.Large, showHeaderFilter = true, showFilterPanel = true, showHeaderColumnChooser = false, showLoadPanel = true, showSearchPanel = true, searchPanelToolbarPosition = 'before', searchPanelFocusStarting = false, counterConfig = { show: false, items: new Map() }, onHasFiltersChange, customContextMenuItems,
20
+ dataColumns = [], pageSize = TMDataGridPageSize.Large, showHeaderFilter = true, showFilterPanel = true, showHeaderColumnChooser = false, showLoadPanel = true, showSearchPanel = true, searchPanelToolbarPosition = 'before', searchPanelFocusTrigger = 0, counterConfig = { show: false, items: new Map() }, onHasFiltersChange, customContextMenuItems,
21
21
  // events and callbacks
22
22
  onSelectionChanged, onFocusedRowChanged, onRowDblClick, onRowClick, onCellClick, onCellDblClick, onOptionChanged, onContentReady, onContextMenuPreparing, onInitialized, onEditorPreparing, onCellPrepared, onRowPrepared, onRowUpdating, onRowExpanded, onRowCollapsed, onRowUpdated, onSaved, onEditCanceled, onEditingStart, onEditingChange, customizeColumns, onKeyDown, scrolling = { mode: 'standard', useNative: SDKUI_Globals.userSettings?.themeSettings.gridSettings.useNativeScrollbar === 1 }, paging = { enabled: true, pageSize: pageSize }, pager = { visible: true, showInfo: true, showNavigationButtons: true }, selection = { mode: 'multiple', showCheckBoxesMode: "always", selectAllMode: "allPages" }, sorting, summary, stateStoring, grouping, groupPanel, filterRow, headerFilter, editing, rowDragging, masterDetail,
23
23
  // other properties
@@ -39,6 +39,17 @@ const TMDataGrid = React.forwardRef((props, ref) => {
39
39
  const count = getRecordCount(dataSource);
40
40
  setTotalRecordCount(count);
41
41
  }, [dataSource]);
42
+ // Handle search panel focus when trigger changes
43
+ useEffect(() => {
44
+ if (!searchPanelFocusTrigger || searchPanelFocusTrigger <= 0 || !showSearchPanel || !internalRef.current)
45
+ return;
46
+ setTimeout(() => {
47
+ const searchInput = internalRef.current?.instance().element().querySelector('.dx-datagrid-search-panel input');
48
+ if (searchInput) {
49
+ searchInput.focus();
50
+ }
51
+ }, 100);
52
+ }, [searchPanelFocusTrigger, showSearchPanel]);
42
53
  // Handle custom context menu (only when customContextMenuItems is provided)
43
54
  useEffect(() => {
44
55
  if (!customContextMenuItems || !gridContainerRef.current)
@@ -258,10 +269,9 @@ const TMDataGrid = React.forwardRef((props, ref) => {
258
269
  return;
259
270
  // Update state with the current number of visible rows in the DataGrid
260
271
  setVisibleItemsCount(internalRef.current.instance()?.getVisibleRows()?.length ?? 0);
261
- // Focusing SearchPanel
262
- if (showSearchPanel && searchPanelFocusStarting) {
272
+ // Focusing SearchPanel on content ready
273
+ if (showSearchPanel && searchPanelFocusTrigger && searchPanelFocusTrigger > 0) {
263
274
  // Use a small delay to ensure the DOM is fully rendered before trying to focus
264
- // This can prevent issues with the focus not being set correctly
265
275
  setTimeout(() => {
266
276
  const searchInput = internalRef.current?.instance().element().querySelector('.dx-datagrid-search-panel input');
267
277
  if (searchInput) {
@@ -269,7 +279,7 @@ const TMDataGrid = React.forwardRef((props, ref) => {
269
279
  }
270
280
  }, 100);
271
281
  }
272
- }, [onContentReady]);
282
+ }, [onContentReady, showSearchPanel, searchPanelFocusTrigger]);
273
283
  const onOptionChangedCallback = useCallback((e) => {
274
284
  // Assicurati che component esista
275
285
  const grid = e.component;
@@ -11,8 +11,9 @@ import TMRecentsManager from '../../grids/TMRecentsManager';
11
11
  import { SearchResultContext } from '../../../ts';
12
12
  import { useDeviceType, DeviceType } from '../../base/TMDeviceProvider';
13
13
  import { StyledMultiViewPanel } from '../../base/Styled';
14
- import { TMPanelManagerProvider, useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
14
+ import { useTMPanelManagerContext } from '../../layout/panelManager/TMPanelManagerContext';
15
15
  import TMPanelManagerContainer from '../../layout/panelManager/TMPanelManagerContainer';
16
+ import { TMPanelManagerWithPersistenceProvider } from '../../layout/panelManager/TMPanelManagerWithPersistenceProvider';
16
17
  var TMSearchViews;
17
18
  (function (TMSearchViews) {
18
19
  TMSearchViews[TMSearchViews["Search"] = 0] = "Search";
@@ -141,15 +142,16 @@ const TMSearch = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTask
141
142
  console.error("Error refreshing search:", error);
142
143
  }
143
144
  };
144
- const isMobile = deviceType === DeviceType.TABLET || deviceType === DeviceType.MOBILE;
145
+ const isMobile = deviceType === DeviceType.MOBILE;
146
+ const isTabletOrMobile = deviceType === DeviceType.TABLET || deviceType === DeviceType.MOBILE;
145
147
  // --- JSX WRAPPERS ---
146
- const tmTreeSelectorElement = useMemo(() => _jsx(TMTreeSelectorWrapper, { isMobile: isMobile, onSelectedTIDChanged: (tid) => {
148
+ const tmTreeSelectorElement = useMemo(() => _jsx(TMTreeSelectorWrapper, { isMobile: isTabletOrMobile, onSelectedTIDChanged: (tid) => {
147
149
  setCurrentTID(tid);
148
150
  if (tid && mruTIDs.includes(tid))
149
151
  setCurrentMruTID(tid);
150
152
  else
151
153
  setCurrentMruTID(0);
152
- } }), [isMobile, mruTIDs]);
154
+ } }), [isTabletOrMobile, mruTIDs]);
153
155
  const tmRecentsManagerElement = useMemo(() => _jsx(TMRecentsManagerWrapper, { mruTIDs: mruTIDs, currentMruTID: currentMruTID, deviceType: deviceType, onSelectedTID: (tid) => {
154
156
  setCurrentMruTID(tid);
155
157
  setCurrentTID(tid);
@@ -180,6 +182,29 @@ const TMSearch = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTask
180
182
  }, onDeleted: (sqd) => onSQDDeleted(sqd, sqd.id == currentSQD?.id ? filteredByTIDSQDs.find(o => o.id == 1) : currentSQD, setSQDAsync) }) }) : _jsx(_Fragment, {}), _jsx(Item, { title: SDKUI_Localizator.AllFemale, children: _jsx(TMSavedQuerySelectorWrapper, { allowShowSearch: true, items: allSQDs, manageDefault: false, onItemClick: (sqd) => {
181
183
  onSQDItemClick(sqd, setSQDAsync);
182
184
  }, onDeleted: (sqd) => onSQDDeleted(sqd, sqd.id == currentSQD?.id ? undefined : currentSQD, setSQDAsync) }) })] }), [currentSQDMode, currentTID, currentSQD, fromDTD, filteredByTIDSQDs, allSQDs]);
185
+ // Returns the current panelLayout from user settings, falling back to an empty object if not present.
186
+ const getPanelLayoutSetting = () => {
187
+ return SDKUI_Globals.userSettings.searchSettings.panelLayout ?? {};
188
+ };
189
+ // Checks whether a persisted panel layout exists and is not empty.
190
+ const hasSavedLayout = () => {
191
+ const panelLayout = getPanelLayoutSetting();
192
+ return Object.keys(panelLayout).length > 0;
193
+ };
194
+ // Persists the current panel states into user settings. Each panel must contain: visible, width and height.
195
+ const persistPanelStates = (state) => {
196
+ if (!state || Object.keys(state).length === 0)
197
+ return;
198
+ SDKUI_Globals.userSettings.searchSettings.panelLayout = {
199
+ ...state
200
+ };
201
+ };
202
+ // Retrieves the persisted panel layout. Returns undefined on mobile devices.
203
+ const getPersistedPanelStates = () => {
204
+ if (isMobile)
205
+ return undefined;
206
+ return getPanelLayoutSetting();
207
+ };
183
208
  // --- PANEL DEFINITIONS ---
184
209
  const allInitialPanelVisibility = {
185
210
  'TMTreeSelector': true,
@@ -219,7 +244,7 @@ const TMSearch = ({ allTasks = [], getAllTasks, deleteTaskByIdsCallback, addTask
219
244
  toolbarOptions: { icon: _jsx(IconSavedQuery, { fontSize: 24 }), visible: true, orderNumber: 4, isActive: allInitialPanelVisibility['TMSavedQuerySelector'] }
220
245
  }
221
246
  ], [tmTreeSelectorElement, showSearchResults, tmRecentsManagerElement, tmSearchQueryPanelElement, tmSavedQuerySelectorElement, fromDTD, mruTIDs]);
222
- return (_jsxs(_Fragment, { children: [showSearchResults ? _jsx(StyledMultiViewPanel, { "$isVisible": currentSearchView === TMSearchViews.Search, children: _jsx(TMPanelManagerProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: initialPanelDimensions, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'TMRecentsManager', children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", showToolbar: true, minPanelSizePx: !isMobile ? 250 : 150 }) }) }) : tmSearchQueryPanelElement, showSearchResults && _jsx(TMSearchResult, { isVisible: isVisible && currentSearchView === TMSearchViews.Result, context: SearchResultContext.METADATA_SEARCH, searchResults: searchResult, floatingActionConfig: floatingActionConfig, onRefreshAfterAddDcmtToFavs: onRefreshAfterAddDcmtToFavs, openInOffice: openInOffice, onRefreshSearchAsync: onRefreshSearchAsync, onClose: () => { onlyShowSearchQueryPanel ? setShowSearchResults(false) : setCurrentSearchView(TMSearchViews.Search); }, onFileOpened: onFileOpened, onTaskCreateRequest: onTaskCreateRequest, openWGsCopyMoveForm: openWGsCopyMoveForm, openEditPdf: openEditPdf, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, passToArchiveCallback: passToArchiveCallback, onSelectedTIDChanged: onCurrentTIDChangedCallback, showTodoDcmtForm: showTodoDcmtForm, onReferenceClick: onReferenceClick, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers })] }));
247
+ return (_jsxs(_Fragment, { children: [showSearchResults ? _jsx(StyledMultiViewPanel, { "$isVisible": currentSearchView === TMSearchViews.Search, children: _jsx(TMPanelManagerWithPersistenceProvider, { panels: initialPanels, initialVisibility: allInitialPanelVisibility, defaultDimensions: initialPanelDimensions, initialDimensions: initialPanelDimensions, initialMobilePanelId: 'TMRecentsManager', isPersistenceEnabled: !isMobile ? hasSavedLayout() : false, persistPanelStates: !isMobile ? (state) => persistPanelStates(state) : undefined, persistedPanelStates: getPersistedPanelStates(), children: _jsx(TMPanelManagerContainer, { panels: initialPanels, direction: "horizontal", showToolbar: true, minPanelSizePx: !isMobile ? 250 : 150 }) }) }) : tmSearchQueryPanelElement, showSearchResults && _jsx(TMSearchResult, { isVisible: isVisible && currentSearchView === TMSearchViews.Result, context: SearchResultContext.METADATA_SEARCH, searchResults: searchResult, floatingActionConfig: floatingActionConfig, onRefreshAfterAddDcmtToFavs: onRefreshAfterAddDcmtToFavs, openInOffice: openInOffice, onRefreshSearchAsync: onRefreshSearchAsync, onClose: () => { onlyShowSearchQueryPanel ? setShowSearchResults(false) : setCurrentSearchView(TMSearchViews.Search); }, onFileOpened: onFileOpened, onTaskCreateRequest: onTaskCreateRequest, openWGsCopyMoveForm: openWGsCopyMoveForm, openEditPdf: openEditPdf, openS4TViewer: openS4TViewer, onOpenS4TViewerRequest: onOpenS4TViewerRequest, passToArchiveCallback: passToArchiveCallback, onSelectedTIDChanged: onCurrentTIDChangedCallback, showTodoDcmtForm: showTodoDcmtForm, onReferenceClick: onReferenceClick, allTasks: allTasks, getAllTasks: getAllTasks, deleteTaskByIdsCallback: deleteTaskByIdsCallback, addTaskCallback: addTaskCallback, editTaskCallback: editTaskCallback, handleNavigateToWGs: handleNavigateToWGs, handleNavigateToDossiers: handleNavigateToDossiers })] }));
223
248
  };
224
249
  export default TMSearch;
225
250
  const TMTreeSelectorWrapper = ({ isMobile, onSelectedTIDChanged }) => {
@@ -88,7 +88,7 @@ const TMChooserForm = ({ children, title, allowMultipleSelection = false, allowA
88
88
  }, [manageUseLocalizedName, summaryItems]);
89
89
  return (_jsx(TMModal, { title: renderTitle(), width: width ?? '550px', height: height ?? '600px', toolbar: _jsx(ToolbarButtons, {}), onClose: onClose, children: children ??
90
90
  filteredItems.length > 0
91
- ? _jsx(TMDataGrid, { dataSource: filteredItems, keyExpr: keyName, dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, searchPanelFocusStarting: true, headerFilter: { visible: true }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single', showCheckBoxesMode: 'always', selectAllMode: 'allPages' }, grouping: allowGrouping ? { autoExpandAll: false, expandMode: 'rowClick' } : undefined, summary: customSummary, showFilterPanel: showFilterPanel, onFocusedRowChanged: handleFocusedRowChange, onSelectionChanged: handleSelectionChanged, onRowDblClick: handleRowDoubleClick })
91
+ ? _jsx(TMDataGrid, { dataSource: filteredItems, keyExpr: keyName, dataColumns: dataColumns, focusedRowKey: focusedRowKey, selectedRowKeys: selectedRowKeys, searchPanelFocusTrigger: 1, headerFilter: { visible: true }, selection: { mode: allowMultipleSelection ? 'multiple' : 'single', showCheckBoxesMode: 'always', selectAllMode: 'allPages' }, grouping: allowGrouping ? { autoExpandAll: false, expandMode: 'rowClick' } : undefined, summary: customSummary, showFilterPanel: showFilterPanel, onFocusedRowChanged: handleFocusedRowChange, onSelectionChanged: handleSelectionChanged, onRowDblClick: handleRowDoubleClick })
92
92
  : _jsx(TMLayoutContainer, { gap: 30, alignItems: 'center', justifyContent: 'center', children: _jsx(TMLayoutItem, { children: _jsx("p", { style: { height: "100%", color: TMColors.primaryColor, fontSize: "1.5rem", display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: SDKUI_Localizator.NoDataToDisplay }) }) }) }));
93
93
  };
94
94
  export default TMChooserForm;
@@ -55,6 +55,13 @@ export declare class SearchSettings {
55
55
  defaultTree: number;
56
56
  previewThreshold: number;
57
57
  floatingMenuBar: FloatingMenuBarSettings;
58
+ panelLayout: {
59
+ [id: string]: {
60
+ visible: boolean;
61
+ width: string;
62
+ height: string;
63
+ };
64
+ };
58
65
  }
59
66
  export declare class FloatingMenuBarSettings {
60
67
  orientation: 'horizontal' | 'vertical';
@@ -99,6 +99,7 @@ export class SearchSettings {
99
99
  this.defaultTree = -1;
100
100
  this.previewThreshold = 500; // KB
101
101
  this.floatingMenuBar = new FloatingMenuBarSettings();
102
+ this.panelLayout = {};
102
103
  }
103
104
  }
104
105
  export class FloatingMenuBarSettings {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.20.0-dev1.34",
3
+ "version": "6.20.0-dev1.36",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",