@topconsultnpm/sdkui-react-beta 6.17.26 → 6.17.28

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,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { LayoutModes, DcmtTypeListCacheService, PlatformObjectValidator, MetadataDataTypes, QueryOperators, DataListCacheService, MetadataDataDomains, SDK_Localizator, UserListCacheService } from '@topconsultnpm/sdk-ts-beta';
4
4
  import styled from 'styled-components';
@@ -14,6 +14,7 @@ import TMMetadataEditor, { useMetadataEditableList } from '../../editors/TMMetad
14
14
  import { colorOperator, StyledItemWrapper, StyledRowItem } from '../../query/TMQueryEditor';
15
15
  import { TMMidViewer } from '../../viewers/TMMidViewer';
16
16
  import { AdvancedMenuButtons } from '../../editors/TMMetadataValues';
17
+ import { useResizeObserver } from '../../../hooks/useResizeObserver';
17
18
  const StyledMetadataListItem = styled.div `
18
19
  padding: 5px;
19
20
  border-radius: 8px;
@@ -35,6 +36,15 @@ const TMSearchQueryEditor = ({ qd, dcmtTypesList = [], isExpertMode = SDKUI_Glob
35
36
  const [focusedTidMid, setFocusedTidMid] = useState();
36
37
  const deviceType = useDeviceType();
37
38
  let initialMaxItems = deviceType === DeviceType.MOBILE ? 8 : 12;
39
+ const [isCompactView, setIsCompactView] = useState(deviceType === DeviceType.MOBILE);
40
+ const { ref, width } = useResizeObserver();
41
+ useEffect(() => {
42
+ if (deviceType === DeviceType.MOBILE)
43
+ return;
44
+ if (width === 0)
45
+ return;
46
+ setIsCompactView(width < 340);
47
+ }, [width]);
38
48
  useEffect(() => {
39
49
  onFocusedMetadataChanged?.(focusedTidMid);
40
50
  }, [focusedTidMid]);
@@ -83,10 +93,10 @@ const TMSearchQueryEditor = ({ qd, dcmtTypesList = [], isExpertMode = SDKUI_Glob
83
93
  }
84
94
  }, [qd, onQdChanged]);
85
95
  const itemsToRender = qd?.where?.slice(0, showAllMdWhere ? qd.where.length : initialMaxItems) ?? [];
86
- return (_jsx(_Fragment, { children: deviceType === DeviceType.MOBILE ?
87
- _jsx("div", { style: { overflow: 'auto', display: 'flex', flexDirection: 'column', height: '100%', padding: '5px', gap: '5px' }, children: itemsToRender.map((wi, index) => (_jsx(WhereItemRow, { whereItem: wi, index: index, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, isSelected: false, isEditable: isEditableList(wi.mid), currentEditingMID: currentEditingMID, queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid === wi.mid)?.queryParams ?? [], onItemChange: handleWhereItemChanged, onItemSelect: handleItemSelect, onAdvancedMenuClick: handleAdvancedMenuClick, onCascadeRefreshDynDataLists: handleCascadeRefresh, onCascadeUpdateMIDs: handleCascadeUpdate, onHideMobileEditor: () => setCurrentEditingMID(0) }, `${wi.tid}_${wi.mid}_${index}`))) })
96
+ return (_jsx("div", { ref: ref, style: { width: '100%', minWidth: '100%', height: '100%', overflow: 'auto', display: 'flex', flexDirection: 'column' }, children: isCompactView ?
97
+ _jsx("div", { style: { overflow: 'auto', display: 'flex', flexDirection: 'column', height: '100%', padding: '5px', gap: '5px' }, children: itemsToRender.map((wi, index) => (_jsx(WhereItemRow, { whereItem: wi, index: index, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, isSelected: false, isEditable: isEditableList(wi.mid), currentEditingMID: currentEditingMID, queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid === wi.mid)?.queryParams ?? [], onItemChange: handleWhereItemChanged, onItemSelect: handleItemSelect, onAdvancedMenuClick: handleAdvancedMenuClick, onCascadeRefreshDynDataLists: handleCascadeRefresh, onCascadeUpdateMIDs: handleCascadeUpdate, onHideMobileEditor: () => setCurrentEditingMID(0), isCompactView: true }, `${wi.tid}_${wi.mid}_${index}`))) })
88
98
  :
89
- _jsx("div", { style: { display: 'grid', borderRadius: '8px', alignItems: 'center', overflow: 'auto', padding: '5px', gap: '8px', gridTemplateColumns: 'minmax(0, max-content) minmax(0, max-content) minmax(50%, 1fr) minmax(0, max-content)' }, children: itemsToRender.map((wi, index) => (_jsx(WhereItemRow, { whereItem: wi, index: index, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, isSelected: false, isEditable: isEditableList(wi.mid), currentEditingMID: currentEditingMID, queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid === wi.mid)?.queryParams ?? [], onItemChange: handleWhereItemChanged, onItemSelect: handleItemSelect, onAdvancedMenuClick: handleAdvancedMenuClick, onCascadeRefreshDynDataLists: handleCascadeRefresh, onCascadeUpdateMIDs: handleCascadeUpdate, onHideMobileEditor: () => setCurrentEditingMID(0) }, `${wi.tid}_${wi.mid}_${index}`))) }) }));
99
+ _jsx("div", { style: { display: 'grid', borderRadius: '8px', alignItems: 'center', overflow: 'auto', padding: '5px', gap: '8px', gridTemplateColumns: 'minmax(0, max-content) minmax(0, max-content) minmax(50%, 1fr) minmax(0, max-content)' }, children: itemsToRender.map((wi, index) => (_jsx(WhereItemRow, { whereItem: wi, index: index, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, isSelected: false, isEditable: isEditableList(wi.mid), currentEditingMID: currentEditingMID, queryParamsDynDataList: dynDataListsToBeRefreshed.find(o => o.mid === wi.mid)?.queryParams ?? [], onItemChange: handleWhereItemChanged, onItemSelect: handleItemSelect, onAdvancedMenuClick: handleAdvancedMenuClick, onCascadeRefreshDynDataLists: handleCascadeRefresh, onCascadeUpdateMIDs: handleCascadeUpdate, onHideMobileEditor: () => setCurrentEditingMID(0), isCompactView: false }, `${wi.tid}_${wi.mid}_${index}`))) }) }));
90
100
  };
91
101
  export default React.memo(TMSearchQueryEditor);
92
102
  const TMSearchWhereItemEditor = React.memo(({ whereItem, queryParamsDynDataList, index, isSelected, isEditableList, autoFocus, openChooserBySingleClick, onValueChanged, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs }) => {
@@ -246,8 +256,7 @@ const TMSearchWhereItemViewer = React.memo(({ isSelected = false, whereItem, sho
246
256
  // ? <>{numberOfOperands == 11 ? whereItem.value1?.split(',').map((item: string) => !item.startsWith("'") ? item : item.slice(1, -1)).join(",") : whereItem.value1}</>
247
257
  : _jsxs(_Fragment, { children: [displayMetadataValue(md, whereItem.value1, ""), numberOfOperands == 2 && (whereItem.value2 && whereItem.value2 != '' ? ` - ${displayMetadataValue(md, whereItem.value2, "")}` : ' - ?')] }) })] }));
248
258
  });
249
- const WhereItemRow = React.memo(({ whereItem, index, dcmtTypesList, isExpertMode, isSelected, isEditable, currentEditingMID, queryParamsDynDataList, onItemChange, onItemSelect, onAdvancedMenuClick, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs, onHideMobileEditor }) => {
250
- const deviceType = useDeviceType();
259
+ const WhereItemRow = React.memo(({ whereItem, index, dcmtTypesList, isExpertMode, isSelected, isEditable, currentEditingMID, queryParamsDynDataList, isCompactView, onItemChange, onItemSelect, onAdvancedMenuClick, onCascadeRefreshDynDataLists, onCascadeUpdateMIDs, onHideMobileEditor }) => {
251
260
  const dropDownMenuRef = useRef(null);
252
261
  // Trova il metadata descriptor per l'item corrente
253
262
  const md = useMemo(() => {
@@ -345,7 +354,7 @@ const WhereItemRow = React.memo(({ whereItem, index, dcmtTypesList, isExpertMode
345
354
  return whereItem.operator === getDefaultOperator(md.dataDomain, md.dataType) ? 'green' : TMColors.tertiary;
346
355
  };
347
356
  // --- Rendering ---
348
- if (deviceType === DeviceType.MOBILE) {
357
+ if (isCompactView) {
349
358
  return (_jsx(StyledMetadataListItem, { id: `wi-item-${whereItem.mid}`, onClick: () => onItemSelect(whereItem.tid, whereItem.mid), onFocus: () => onItemSelect(whereItem.tid, whereItem.mid), "$backgroundColor": !PlatformObjectValidator.WhereItemHasValues(whereItem) ? `${TMColors.primary}66` : 'rgba(236, 202, 156, 1)', "$hoverColor": !PlatformObjectValidator.WhereItemHasValues(whereItem) ? `${TMColors.primary}33` : 'rgba(236, 202, 156, .5)', children: _jsx(TMSearchWhereItemCard, { isSelected: isSelected, index: index, whereItem: whereItem, showEditor: currentEditingMID === whereItem.mid, isEditableList: isEditable, queryParamsDynDataList: queryParamsDynDataList, onWhereItemChange: onItemChange, onHideEditor: onHideMobileEditor, onCascadeRefreshDynDataLists: onCascadeRefreshDynDataLists, onCascadeUpdateMIDs: onCascadeUpdateMIDs }) }));
350
359
  }
351
360
  return (_jsxs(React.Fragment, { children: [_jsx("div", { id: `wi-item-${whereItem.mid}`, style: { gridColumn: 1 }, children: _jsx(TMMidViewer, { color: TMColors.primaryColor, isMetadataSelected: isSelected, showIcon: true, tid_mid: { tid: whereItem?.tid, mid: whereItem?.mid, aliasTID: whereItem?.alias } }) }), _jsx("div", { style: { gridColumn: 2, paddingLeft: '5px', paddingRight: '5px' }, children: _jsx(TMDropDownMenu, { backgroundColor: colorOperator, color: getOperatorColor(), items: queryOperatorsItems, content: _jsx(StyledItemWrapper, { children: LocalizeQueryOperators(whereItem.operator) }) }) }), _jsxs("div", { style: { gridColumn: 3, position: 'relative' }, onClick: () => onItemSelect(whereItem.tid, whereItem.mid), onFocus: () => onItemSelect(whereItem.tid, whereItem.mid), children: [_jsx(TMSearchWhereItemEditor, { isSelected: isSelected, openChooserBySingleClick: !isSelected, whereItem: whereItem, index: index, isEditableList: isEditable, queryParamsDynDataList: queryParamsDynDataList, onValueChanged: (values) => {
@@ -4,7 +4,7 @@ import { PlatformObjectValidator, WhereItem, SDK_Localizator, OrderByItem, Selec
4
4
  import styled from 'styled-components';
5
5
  import TMSearchQueryEditor from './TMSearchQueryEditor';
6
6
  import Toppy from '../../../assets/Toppy-generico.png';
7
- import { getDcmtTypesByQdAsync, SDKUI_Localizator, getQD, IconMenuVertical, IconAddCircleOutline, IconEdit, IconEasy, IconAdvanced, deepCompare, IconSearch, IconClear, getDefaultOperator, prepareQdForSearchAsync, IsParametricQuery, SDKUI_Globals, IconArrowRight, IconMenuCAArchive } from '../../../helper';
7
+ import { getDcmtTypesByQdAsync, SDKUI_Localizator, getQD, IconMenuVertical, IconAddCircleOutline, IconEdit, IconEasy, IconAdvanced, deepCompare, IconSearch, IconClear, getDefaultOperator, prepareQdForSearchAsync, IsParametricQuery, SDKUI_Globals, IconArrowRight, IconMenuCAArchive, getListMaxItems } from '../../../helper';
8
8
  import { useQueryParametersDialog } from '../../../hooks/useQueryParametersDialog';
9
9
  import { FormModes } from '../../../ts';
10
10
  import { TMColors } from '../../../utils/theme';
@@ -22,7 +22,6 @@ import { TMMetadataChooserForm } from '../../choosers/TMMetadataChooser';
22
22
  import TMQueryEditor from '../../query/TMQueryEditor';
23
23
  import TMSavedQueryForm from './TMSavedQueryForm';
24
24
  import { AdvancedMenuButtons } from '../../editors/TMMetadataValues';
25
- import TMShowAllOrMaxItemsButton from '../../base/TMShowAllOrMaxItemsButton';
26
25
  const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SDKUI_Globals.userSettings.advancedSettings.expertMode === 1, SQD, inputMids, onSearchCompleted, onSqdSaved, onBack, onClosePanel, allowMaximize = true, onMaximizePanel, onBackToResult, passToArchiveCallback }) => {
27
26
  const [confirmQueryParams, ConfirmQueryParamsDialog] = useQueryParametersDialog();
28
27
  const [qd, setQd] = useState();
@@ -272,6 +271,9 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
272
271
  }
273
272
  setQd({ ...qd, orderBy: newOrderBy });
274
273
  }, [qd, fromDTD?.metadata, SQD?.masterTID]);
274
+ const captionText = showAllMdWhere ? SDKUI_Localizator.ShowLess : SDKUI_Localizator.ShowAll;
275
+ let maxItems = getListMaxItems(deviceType ?? DeviceType.DESKTOP);
276
+ const diff = (qd?.where?.length ?? 0) - maxItems;
275
277
  return (_jsxs(_Fragment, { children: [_jsxs(TMPanel, { title: fromDTD?.nameLoc ?? SDKUI_Localizator.Search_Metadata, allowMaximize: allowMaximize, onMaximize: onMaximizePanel, onHeaderDoubleClick: onMaximizePanel, onBack: onBack, onActiveChanged: handlePanelActiveChanged, toolbar: _jsx(_Fragment, { children: (SQD && !showSqdForm) ?
276
278
  _jsx(TMDropDownMenu, { backgroundColor: 'white', borderRadius: '3px', content: _jsx(TMButton, { btnStyle: 'icon', caption: 'Altro', icon: _jsx(IconMenuVertical, { color: 'white' }), showTooltip: false, onClick: () => setIsQueryPanelActive(true) }), items: [
277
279
  ...(showBackToResultButton ? [{ icon: _jsx(IconArrowRight, {}), text: "Vai a risultato", onClick: () => { onBackToResult?.(); } }] : []),
@@ -286,8 +288,31 @@ const TMSearchQueryPanel = ({ fromDTD, showBackToResultButton, isExpertMode = SD
286
288
  : _jsx(_Fragment, {}) }), children: [_jsx(ConfirmQueryParamsDialog, {}), SQD
287
289
  ? _jsxs("div", { style: { height: '100%', width: '100%', position: 'relative', display: 'flex', flexDirection: 'column', gap: 5 }, children: [showAdvancedSearch
288
290
  ? _jsx(TMQueryEditor, { formMode: FormModes.Update, showToolbar: false, inputData: qd, validateSelect: true, showApply: false, onQDChanged: handleQdChanged })
289
- : _jsx(TMSearchQueryEditor, { qd: qd, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, showAllMdWhere: showAllMdWhere, onQdChanged: handleQdChanged, onFocusedMetadataChanged: setFocusedTidMid, onAdvancedMenuClick: handleAdvancedMenuClick }), _jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '80px', padding: '15px', position: 'relative' }, children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '8px' }, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, width: 'auto', caption: SDKUI_Localizator.Search, advancedColor: '#4A96D2', onClick: handleSearchButtonClick }), _jsx(TMButton, { btnStyle: 'advanced', advancedType: 'primary', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), width: 'auto', advancedColor: 'white', color: 'primaryOutline', onClick: clearFilters })] }), (!showAdvancedSearch && qd?.where && qd?.where?.length > initialMaxItems) &&
290
- _jsx(TMShowAllOrMaxItemsButton, { showAll: showAllMdWhere, dataSourceLength: qd?.where?.length, onClick: () => { setShowAllMdWhere(!showAllMdWhere); } })] }), showFiltersConfig &&
291
+ : _jsx(TMSearchQueryEditor, { qd: qd, dcmtTypesList: dcmtTypesList, isExpertMode: isExpertMode, showAllMdWhere: showAllMdWhere, onQdChanged: handleQdChanged, onFocusedMetadataChanged: setFocusedTidMid, onAdvancedMenuClick: handleAdvancedMenuClick }), _jsx("div", { style: { display: 'flex', justifyContent: 'center', alignItems: 'center', gap: '80px', padding: '15px', position: 'relative' }, children: _jsxs("div", { style: {
292
+ display: 'flex',
293
+ justifyContent: 'space-between',
294
+ alignItems: 'center',
295
+ flexWrap: 'wrap',
296
+ gap: '10px',
297
+ padding: '15px',
298
+ width: '100%',
299
+ boxSizing: 'border-box'
300
+ }, children: [_jsxs("div", { style: {
301
+ display: 'flex',
302
+ justifyContent: 'center',
303
+ alignItems: 'center',
304
+ gap: '10px',
305
+ flex: '1 1 auto',
306
+ minWidth: 0,
307
+ }, children: [_jsx(TMButton, { btnStyle: 'advanced', icon: _jsx(IconSearch, {}), showTooltip: false, width: 'auto', caption: SDKUI_Localizator.Search, advancedColor: '#4A96D2', onClick: handleSearchButtonClick }), _jsx(TMButton, { btnStyle: 'advanced', advancedType: 'primary', showTooltip: false, caption: SDKUI_Localizator.Clear, icon: _jsx(IconClear, {}), width: 'auto', advancedColor: 'white', color: 'primaryOutline', onClick: clearFilters })] }), (!showAdvancedSearch && qd?.where && qd.where.length > initialMaxItems) && (_jsx("div", { style: { flex: '0 0 auto' }, children: _jsx(TMButton, { width: '120px', btnStyle: isMobile ? 'icon' : 'advanced', advancedColor: TMColors.button_primary, caption: captionText, showTooltip: false, icon: isMobile ? (_jsx("div", { style: {
308
+ backgroundColor: TMColors.button_primary,
309
+ minWidth: '30px',
310
+ minHeight: '30px',
311
+ borderRadius: '10px',
312
+ display: 'flex',
313
+ alignItems: 'center',
314
+ justifyContent: 'center',
315
+ }, children: _jsx("p", { style: { color: 'white', margin: 0 }, children: showAllMdWhere ? `-${diff}` : `+${diff}` }) })) : (_jsx("p", { style: { color: 'white', margin: 0 }, children: showAllMdWhere ? `-${diff}` : `+${diff}` })), onClick: () => setShowAllMdWhere(!showAllMdWhere) }) }))] }) }), showFiltersConfig &&
291
316
  _jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.where?.map((w) => ({ tid: w.tid, mid: w.mid })), onClose: handleCloseFiltersConfig, onChoose: handleChooseFilters }), showOutputConfig &&
292
317
  _jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.select?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOutputConfig, onChoose: handleChooseOutput }), showOrderByConfig &&
293
318
  _jsx(TMMetadataChooserForm, { allowMultipleSelection: true, height: '500px', width: '600px', allowSysMetadata: true, qd: qd, selectedIDs: qd?.orderBy?.map((item) => ({ tid: item.tid, mid: item.mid })), onClose: handleCloseOrderByConfig, onChoose: handleChooseOrderBy })] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.17.26",
3
+ "version": "6.17.28",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",