@topconsultnpm/sdkui-react-beta 6.6.74 → 6.6.75

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.
@@ -12,6 +12,8 @@ interface ListProps<T> {
12
12
  };
13
13
  orderBy?: string;
14
14
  grouping?: string;
15
+ showId?: boolean;
16
+ showSearch?: boolean;
15
17
  onScrollChange?: (e: {
16
18
  x: number;
17
19
  y: number;
@@ -21,5 +23,5 @@ interface ListProps<T> {
21
23
  onItemDblClick?: (item: T) => void;
22
24
  itemTemplate?: (item: T) => JSX.Element;
23
25
  }
24
- declare const TMListView: <T>({ grouping, orderBy, id, onScrollChange, scroll, searchKeys, searchable, itemTemplate, customColor, dataSource, exprKey, onSelectionChanged, onItemClick, onItemDblClick, selectedItem }: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
26
+ declare const TMListView: <T>({ showId, showSearch, grouping, orderBy, id, onScrollChange, scroll, searchKeys, searchable, itemTemplate, customColor, dataSource, exprKey, onSelectionChanged, onItemClick, onItemDblClick, selectedItem }: ListProps<T>) => import("react/jsx-runtime").JSX.Element;
25
27
  export default TMListView;
@@ -6,16 +6,17 @@ import TMContextMenu, { useTMContextMenu } from './TMContextMenu';
6
6
  import { IconApply, IconCloseCircle, IconColumns, IconDown, IconHide, IconShow, IconUp, IconVisible } from '../../helper/TMIcons';
7
7
  import { TMSearchBar } from '../sidebar/TMHeader';
8
8
  import TMTooltip from './TMTooltip';
9
+ import { SDKUI_Localizator } from '../../helper';
9
10
  const StyledListItem = styled.div ` width: 100%; height: max-content; border-bottom: 1px solid #e5e5e5; background-color: ${props => props.$isSelected ? props.$color ? `${props.$color}99` : '#00000030' : 'transparent'} ; color: ${props => props.$isSelected ? props.$color ? 'white' : '#000000' : '#000000'} ; &:hover{ background-color: ${props => props.$color ? props.$isSelected ? `${props.$color}99` : `${props.$color}40` : props.$isSelected ? '#00000030' : '#00000010'};} `;
10
11
  const StyledListViewContainer = styled.div ` position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; width: 100%; height: 100%; `;
11
12
  const StyledSearchContainer = styled.div ` width: 100%; height: max-content; padding: 5px; border-bottom: 1px solid #e5e5e5; display: flex; align-items: center; gap: 10px; `;
12
13
  const StyledListViewFooter = styled.div ` background-color: ${props => props.$bgColor}; width: 100%; height: 25px; padding: 5px 15px; border-top: 1px solid #e5e5e5; display: flex; align-items: center; gap: 10px; `;
13
- const TMListView = ({ grouping = '', orderBy, id, onScrollChange, scroll, searchKeys = [], searchable = false, itemTemplate, customColor, dataSource = [], exprKey = 'id', onSelectionChanged, onItemClick, onItemDblClick, selectedItem }) => {
14
+ const TMListView = ({ showId, showSearch, grouping = '', orderBy, id, onScrollChange, scroll, searchKeys = [], searchable = false, itemTemplate, customColor, dataSource = [], exprKey = 'id', onSelectionChanged, onItemClick, onItemDblClick, selectedItem }) => {
14
15
  const listRef = useRef(null);
15
16
  const contRef = useRef(null);
16
17
  const orderRef = useRef(null);
17
- const [showId, setShowId] = useState(false);
18
- const [showSearch, setShowSearch] = useState(searchable);
18
+ const [localShowId, setLocalShowId] = useState(false);
19
+ const [localShowSearch, setLocalShowSearch] = useState(searchable);
19
20
  const [searchValue, setSearchValue] = useState('');
20
21
  const [currentDataSource, setCurrentDataSource] = useState(dataSource);
21
22
  const [keys, setKeys] = useState(searchKeys);
@@ -105,9 +106,9 @@ const TMListView = ({ grouping = '', orderBy, id, onScrollChange, scroll, search
105
106
  }
106
107
  }
107
108
  }, [searchValue, keys, orderedBy, dataSource]);
108
- useEffect(() => { if (!showSearch) {
109
+ useEffect(() => { if (!localShowSearch) {
109
110
  setSearchValue('');
110
- } }, [showSearch]);
111
+ } }, [localShowSearch]);
111
112
  // order logic
112
113
  useEffect(() => { if (orderedBy.length > 0) {
113
114
  setCurrentDataSource(orderByKey(currentDataSource));
@@ -200,7 +201,7 @@ const TMListView = ({ grouping = '', orderBy, id, onScrollChange, scroll, search
200
201
  if (searchKeys.length > 0) {
201
202
  for (let key of searchKeys) {
202
203
  arr.push({
203
- disabled: !showId && key === exprKey,
204
+ disabled: !localShowId && key === exprKey,
204
205
  isSelected: key === orderedBy,
205
206
  onItemClick: () => { setOrderedBy(key); setShowOrderOptions(false); },
206
207
  icon: _jsx(IconColumns, { fontSize: 16 }),
@@ -223,8 +224,8 @@ const TMListView = ({ grouping = '', orderBy, id, onScrollChange, scroll, search
223
224
  }
224
225
  // map memo
225
226
  const memoList = useMemo(() => currentDataSource.map((data, index) => {
226
- return (_jsx(StyledListItem, { "$isSelected": isSelected(data), "$color": customColor, onClick: () => { onSelectionChanged && onSelectionChanged(data); onItemClick && onItemClick(data); }, onDoubleClick: () => onItemDblClick && onItemDblClick(data), children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-start', justifyContent: 'flex-start', gap: 5, padding: '5px 5px' }, children: [showId && _jsxs("p", { style: { color: isSelected(data) ? 'white' : 'black', backgroundColor: `${customColor}20`, width: '100%', padding: '2px 5px', borderRadius: '5px', height: 'max-content', textAlign: 'left' }, children: [" ", exprKey + ' : ' + data[exprKey], " "] }), _jsxs("div", { style: { width: '100%', height: '100%' }, children: [" ", itemTemplate ? itemTemplate(data) : _jsx("div", {})] })] }) }, index));
227
- }), [currentDataSource, selectedItem, showId, customColor]);
227
+ return (_jsx(StyledListItem, { "$isSelected": isSelected(data), "$color": customColor, onClick: () => { onSelectionChanged && onSelectionChanged(data); onItemClick && onItemClick(data); }, onDoubleClick: () => onItemDblClick && onItemDblClick(data), children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-start', justifyContent: 'flex-start', gap: 5, padding: '5px 5px' }, children: [localShowId && _jsxs("p", { style: { color: isSelected(data) ? 'white' : 'black', backgroundColor: `${customColor}20`, width: '100%', padding: '2px 5px', borderRadius: '5px', height: 'max-content', textAlign: 'left' }, children: [" ", exprKey + ' : ' + data[exprKey], " "] }), _jsxs("div", { style: { width: '100%', height: '100%' }, children: [" ", itemTemplate ? itemTemplate(data) : _jsx("div", {})] })] }) }, index));
228
+ }), [currentDataSource, selectedItem, localShowId, customColor]);
228
229
  const groupedMemoList = useMemo(() => groupKeys.map((key, index) => {
229
230
  const groupingText = () => {
230
231
  if (grouping === 'objectClass') {
@@ -244,11 +245,11 @@ const TMListView = ({ grouping = '', orderBy, id, onScrollChange, scroll, search
244
245
  return key;
245
246
  }
246
247
  };
247
- return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-start', width: '100%', height: 'max-content' }, children: [_jsx("div", { style: { borderBottom: `1px solid ${customColor}20`, display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '5px', width: '100%', backgroundColor: `${customColor}30` }, children: _jsxs("div", { style: { width: '100%', height: 'max-content', display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 10 }, children: [_jsx("p", { children: groupingText() }), _jsx("div", { style: { width: '16px', height: '16px', display: 'flex', alignItems: 'center', justifyContent: 'center', backgroundColor: customColor, color: 'white', boxShadow: '1px 1px 2px #00000020', borderRadius: '30px', fontWeight: 'bold' }, children: groupByKey(currentDataSource, grouping)[key].length })] }), _jsxs("div", { style: { cursor: 'pointer' }, onClick: () => { let arr = [...openList]; arr[index] = !arr[index]; setOpenList(arr); }, children: [" ", openList[index] ? _jsx(IconUp, { fontSize: 12 }) : _jsx(IconDown, { fontSize: 12 }), " "] })] }) }), openList[index] && _jsx("div", { style: { width: '100%', height: '100%' }, children: groupByKey(currentDataSource, grouping)[key].map((data, index2) => (_jsx(StyledListItem, { "$isSelected": data === selectedItem, "$color": customColor, onClick: () => { onSelectionChanged && onSelectionChanged(data); onItemClick && onItemClick(data); }, onDoubleClick: () => { onItemDblClick && onItemDblClick(data); }, children: _jsxs("div", { style: { width: '100%', height: 'max-content', display: 'flex', flexDirection: 'column', padding: '5px 5px' }, children: [showId && _jsxs("p", { style: { color: data === selectedItem ? 'white' : 'black', backgroundColor: `${customColor}20`, width: '100%', padding: '2px 5px', borderRadius: '5px', height: 'max-content', textAlign: 'left' }, children: [" ", 'ID: ' + data.id, " "] }), _jsxs("div", { style: { width: '100%', height: '100%' }, children: [" ", itemTemplate ? itemTemplate(data) : _jsx("div", {})] })] }) }, index2))) })] }, index));
248
- }), [currentDataSource, selectedItem, showId, customColor, openList, grouping]);
248
+ return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', alignItems: 'flex-start', width: '100%', height: 'max-content' }, children: [_jsx("div", { style: { borderBottom: `1px solid ${customColor}20`, display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '5px', width: '100%', backgroundColor: `${customColor}30` }, children: _jsxs("div", { style: { width: '100%', height: 'max-content', display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 10 }, children: [_jsx("p", { children: groupingText() }), _jsx("div", { style: { width: '16px', height: '16px', display: 'flex', alignItems: 'center', justifyContent: 'center', backgroundColor: customColor, color: 'white', boxShadow: '1px 1px 2px #00000020', borderRadius: '30px', fontWeight: 'bold' }, children: groupByKey(currentDataSource, grouping)[key].length })] }), _jsxs("div", { style: { cursor: 'pointer' }, onClick: () => { let arr = [...openList]; arr[index] = !arr[index]; setOpenList(arr); }, children: [" ", openList[index] ? _jsx(IconUp, { fontSize: 12 }) : _jsx(IconDown, { fontSize: 12 }), " "] })] }) }), openList[index] && _jsx("div", { style: { width: '100%', height: '100%' }, children: groupByKey(currentDataSource, grouping)[key].map((data, index2) => (_jsx(StyledListItem, { "$isSelected": data === selectedItem, "$color": customColor, onClick: () => { onSelectionChanged && onSelectionChanged(data); onItemClick && onItemClick(data); }, onDoubleClick: () => { onItemDblClick && onItemDblClick(data); }, children: _jsxs("div", { style: { width: '100%', height: 'max-content', display: 'flex', flexDirection: 'column', padding: '5px 5px' }, children: [localShowId && _jsxs("p", { style: { color: data === selectedItem ? 'white' : 'black', backgroundColor: `${customColor}20`, width: '100%', padding: '2px 5px', borderRadius: '5px', height: 'max-content', textAlign: 'left' }, children: [" ", 'ID: ' + data.id, " "] }), _jsxs("div", { style: { width: '100%', height: '100%' }, children: [" ", itemTemplate ? itemTemplate(data) : _jsx("div", {})] })] }) }, index2))) })] }, index));
249
+ }), [currentDataSource, selectedItem, localShowId, customColor, openList, grouping]);
249
250
  // List height
250
251
  const listHeight = () => {
251
- if (showSearch) {
252
+ if (localShowSearch) {
252
253
  if (showOrderMenu || searchValue.length > 0) {
253
254
  return 'calc(100% - 55px)';
254
255
  }
@@ -262,19 +263,49 @@ const TMListView = ({ grouping = '', orderBy, id, onScrollChange, scroll, search
262
263
  else
263
264
  return '100%';
264
265
  };
265
- return (_jsxs(StyledListViewContainer, { ref: contRef, onContextMenu: openContextMenu, children: [show &&
266
- _jsx(TMContextMenu, { coords: coords, items: grouping.length === 0 ?
267
- [
268
- { icon: showSearch ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }), onItemClick: () => { setShowSearch(!showSearch); }, text: showSearch ? 'Nascondi ricerca' : 'Mostra ricerca' },
269
- { icon: showId ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }), onItemClick: () => { setShowId(!showId); }, text: showId ? 'Nascondi ' + exprKey : 'Mostra ' + exprKey },
270
- { icon: showOrderMenu ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }), disabled: searchKeys.length === 0, onItemClick: () => { setShowOrderMenu(!showOrderMenu); }, text: showOrderMenu ? 'Nascondi menu di ordinamento' : 'Mostra menu di ordinamento' },
271
- ] :
272
- [
273
- { icon: showSearch ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }), onItemClick: () => { setShowSearch(!showSearch); }, text: showSearch ? 'Nascondi ricerca' : 'Mostra ricerca' },
274
- { icon: showId ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }), onItemClick: () => { setShowId(!showId); }, text: showId ? 'Nascondi ' + exprKey : 'Mostra ' + exprKey },
275
- ] }), showOrderOptions &&
276
- _jsx(TMContextMenu, { items: orderMenuItems(), coords: { x: orderRef.current?.getBoundingClientRect().left, y: orderRef.current?.getBoundingClientRect().top - (searchKeys.length * 30) - 10 } }), showSearch &&
277
- _jsx(StyledSearchContainer, { children: _jsxs(StyledSearchContainer, { children: [_jsx(TMSearchBar, { marginLeft: '0px', maxWidth: '300px', searchValue: searchValue, onSearchValueChanged: (e) => setSearchValue(e) }), _jsx(TMTooltip, { content: 'Nascondi ricerca', children: _jsx(IconCloseCircle, { style: { cursor: 'pointer' }, color: 'red', fontSize: 14, onClick: () => { setSearchValue(''); setShowSearch(false); } }) })] }) }), _jsx("div", { ref: listRef, onClick: () => setIsFocused(true), style: { width: '100%', overflow: 'auto', height: listHeight() }, children: currentDataSource.length > 0 ?
266
+ useEffect(() => {
267
+ if (showId === undefined)
268
+ return;
269
+ setLocalShowId(showId);
270
+ }, [showId]);
271
+ useEffect(() => {
272
+ if (showSearch === undefined)
273
+ return;
274
+ setLocalShowSearch(showSearch);
275
+ }, [showSearch]);
276
+ const generateContextMenuItems = (localShowSearch, localShowId, showOrderMenu, grouping, searchKeys) => {
277
+ const items = [];
278
+ // Add search menu item only if showSearch prop is undefined
279
+ if (showSearch === undefined) {
280
+ items.push({
281
+ icon: localShowSearch ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }),
282
+ onItemClick: () => setLocalShowSearch(!localShowSearch),
283
+ text: localShowSearch ? SDKUI_Localizator.HideSearch : SDKUI_Localizator.ShowSearch
284
+ });
285
+ }
286
+ // Add ID menu item only if showId prop is undefined
287
+ if (showId === undefined) {
288
+ items.push({
289
+ icon: localShowId ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }),
290
+ onItemClick: () => setLocalShowId(!localShowId),
291
+ text: localShowId ? SDKUI_Localizator.ID_Hide : SDKUI_Localizator.ID_Show,
292
+ });
293
+ }
294
+ // Add order menu item only if grouping length is zero
295
+ if (grouping.length === 0) {
296
+ items.push({
297
+ icon: showOrderMenu ? _jsx(IconHide, { fontSize: 16 }) : _jsx(IconShow, { fontSize: 16 }),
298
+ disabled: searchKeys.length === 0,
299
+ onItemClick: () => setShowOrderMenu(!showOrderMenu),
300
+ text: showOrderMenu ? 'Nascondi menu di ordinamento' : 'Mostra menu di ordinamento'
301
+ });
302
+ }
303
+ return items;
304
+ };
305
+ const contextMenuItems = generateContextMenuItems(localShowSearch, localShowId, showOrderMenu, grouping, searchKeys);
306
+ return (_jsxs(StyledListViewContainer, { ref: contRef, onContextMenu: openContextMenu, children: [(show && contextMenuItems.length > 0) && _jsx(TMContextMenu, { coords: coords, items: contextMenuItems }), showOrderOptions &&
307
+ _jsx(TMContextMenu, { items: orderMenuItems(), coords: { x: orderRef.current?.getBoundingClientRect().left, y: orderRef.current?.getBoundingClientRect().top - (searchKeys.length * 30) - 10 } }), localShowSearch &&
308
+ _jsx(StyledSearchContainer, { children: _jsxs(StyledSearchContainer, { children: [_jsx(TMSearchBar, { marginLeft: '0px', maxWidth: '300px', searchValue: searchValue, onSearchValueChanged: (e) => setSearchValue(e) }), _jsx(TMTooltip, { content: 'Nascondi ricerca', children: _jsx(IconCloseCircle, { style: { cursor: 'pointer' }, color: 'red', fontSize: 14, onClick: () => { setSearchValue(''); setLocalShowSearch(false); } }) })] }) }), _jsx("div", { ref: listRef, onClick: () => setIsFocused(true), style: { width: '100%', overflow: 'auto', height: listHeight() }, children: currentDataSource.length > 0 ?
278
309
  grouping.length === 0 ? memoList : groupedMemoList :
279
310
  searchValue.length > 0 ? _jsx("div", { style: { width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: "No data found" }) :
280
311
  _jsx("div", { style: { width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }, children: "No data" }) }), (searchValue.length > 0 || showOrderMenu) &&
@@ -222,4 +222,6 @@ export declare class SDKUI_Localizator {
222
222
  static get UpdateInProgress(): "Aktualisierung läuft" | "Update in progress" | "Mise à jour en cours" | "Atualização em andamento" | "Aggiornamento in corso";
223
223
  static get Updating(): "Aktualisieren" | "Actualizar" | "updating" | "Mise à jour" | "Atualizar" | "aggiornamento";
224
224
  static get WelcomeTo(): "Willkommen bei {{0}}" | "Welcome to {{0}}" | "Bienvenido a {{0}}" | "Bienvenue sur {{0}}" | "Bem-vindo à {{0}}" | "Benvenuto su {{0}}";
225
+ static get ShowSearch(): "Suche anzeigen" | "Show search" | "Mostrar búsqueda" | "Afficher la recherche" | "Mostrar pesquisa" | "Mostra ricerca";
226
+ static get HideSearch(): "Suche ausblenden" | "Hide search" | "Ocultar búsqueda" | "Masquer la recherche" | "Ocultar pesquisa" | "Nascondi ricerca";
225
227
  }
@@ -2170,4 +2170,24 @@ export class SDKUI_Localizator {
2170
2170
  default: return "Benvenuto su {{0}}";
2171
2171
  }
2172
2172
  }
2173
+ static get ShowSearch() {
2174
+ switch (this._cultureID) {
2175
+ case CultureIDs.De_DE: return "Suche anzeigen";
2176
+ case CultureIDs.En_US: return "Show search";
2177
+ case CultureIDs.Es_ES: return "Mostrar búsqueda";
2178
+ case CultureIDs.Fr_FR: return "Afficher la recherche";
2179
+ case CultureIDs.Pt_PT: return "Mostrar pesquisa";
2180
+ default: return "Mostra ricerca";
2181
+ }
2182
+ }
2183
+ static get HideSearch() {
2184
+ switch (this._cultureID) {
2185
+ case CultureIDs.De_DE: return "Suche ausblenden";
2186
+ case CultureIDs.En_US: return "Hide search";
2187
+ case CultureIDs.Es_ES: return "Ocultar búsqueda";
2188
+ case CultureIDs.Fr_FR: return "Masquer la recherche";
2189
+ case CultureIDs.Pt_PT: return "Ocultar pesquisa";
2190
+ default: return "Nascondi ricerca";
2191
+ }
2192
+ }
2173
2193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.6.74",
3
+ "version": "6.6.75",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",