@bit.rhplus/ui.grid 0.0.93 → 0.0.95

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.
@@ -119,17 +119,31 @@ declare class ColumnBuilder {
119
119
  * @param {Object} ...restProps - Další AG Grid vlastnosti sloupce
120
120
  * @returns {ColumnBuilder} Instance pro chaining
121
121
  */
122
- addLinkColumn({ onClick, linkStyle, hoverStyle, cellAlign, editable, overviewToggle, color, bgColor, colorField, bgColorField, ...restProps }: {
123
- onClick: Function;
124
- linkStyle: Object | Function;
125
- hoverStyle: Object | Function;
122
+ /**
123
+ * Přidá sloupec s odkazem (link) - Používá extrahovaný LinkRenderer.
124
+ * Optimalizovaná implementace s extrahovaným rendererem pro lepší výkon.
125
+ * @param {Object} config - Konfigurace link sloupce
126
+ * @param {string} [config.cellAlign='left'] - Horizontální zarovnání obsahu ('left', 'center', 'right')
127
+ * @param {Function} [config.onClick] - Callback funkce při kliku na link
128
+ * @param {Object|Function} [config.linkStyle] - CSS styl pro link nebo funkce vracející styl
129
+ * @param {Object|Function} [config.hoverStyle] - CSS styl pro hover stav nebo funkce vracející styl
130
+ * @param {boolean} [config.overviewToggle=false] - Příznak zda aktivovat overview toggle funkčnost
131
+ * @param {boolean} [config.editable=false] - Editovatelnost buňky
132
+ * @param {Function} [config.visibleGetter] - Funkce určující viditelnost linku
133
+ * @param {boolean} [config.showOnGroup=false] - Zobrazit link i v group řádcích
134
+ * @param {Object} config.restProps - Další AG-Grid colDef parametry
135
+ * @returns {ColumnBuilder} Instance pro fluent API
136
+ */
137
+ addLinkColumn({ cellAlign, onClick, linkStyle, hoverStyle, overviewToggle, editable, visibleGetter, showOnGroup, contentTooltip, tooltipField, tooltipInteraction, tooltipShowDelay, color, bgColor, colorField, bgColorField, ...restProps }: {
126
138
  cellAlign?: string | undefined;
127
- editable: boolean;
139
+ onClick?: Function | undefined;
140
+ linkStyle?: Object | Function | undefined;
141
+ hoverStyle?: Object | Function | undefined;
128
142
  overviewToggle?: boolean | undefined;
129
- color: string | Function;
130
- bgColor: string | Function;
131
- colorField: string;
132
- bgColorField: string;
143
+ editable?: boolean | undefined;
144
+ visibleGetter?: Function | undefined;
145
+ showOnGroup?: boolean | undefined;
146
+ restProps: Object;
133
147
  }): ColumnBuilder;
134
148
  /**
135
149
  * Helper metoda pro přidání overview link sloupce s přednastavenými hodnotami.
@@ -171,17 +185,25 @@ declare class ColumnBuilder {
171
185
  * @param {Object} ...restProps - Další AG Grid vlastnosti sloupce
172
186
  * @returns {ColumnBuilder} Instance pro chaining
173
187
  */
174
- addObjectColumn({ contentTooltip, tooltipField, tooltipInteraction, tooltipShowDelay, editable, onEditClick, color, bgColor, colorField, bgColorField, ...restProps }: {
175
- contentTooltip: boolean;
176
- tooltipField: string;
177
- tooltipInteraction: boolean;
178
- tooltipShowDelay?: number | undefined;
179
- editable: boolean;
180
- onEditClick: Function;
181
- color: string | Function;
182
- bgColor: string | Function;
183
- colorField: string;
184
- bgColorField: string;
188
+ /**
189
+ * Přidá sloupec pro zobrazení objektů - Používá extrahovaný ObjectRenderer.
190
+ * Optimalizovaná implementace s extrahovaným rendererem pro lepší výkon.
191
+ * @param {Object} config - Konfigurace object sloupce
192
+ * @param {boolean} [config.editable=false] - Příznak zda je buňka editovatelná s edit tlačítkem
193
+ * @param {Function} [config.onEditClick] - Callback funkce při kliku na edit tlačítko
194
+ * @param {Function} [config.visibleGetter] - Funkce určující viditelnost objektu
195
+ * @param {boolean} [config.showOnGroup=false] - Zobrazit objekt i v group řádcích
196
+ * @param {string|Function} [config.displayField] - Název pole nebo funkce pro získání zobrazované hodnoty
197
+ * @param {Object} config.restProps - Další AG-Grid colDef parametry
198
+ * @returns {ColumnBuilder} Instance pro fluent API
199
+ */
200
+ addObjectColumn({ editable, onEditClick, visibleGetter, showOnGroup, displayField, contentTooltip, tooltipField, tooltipInteraction, tooltipShowDelay, color, bgColor, colorField, bgColorField, ...restProps }: {
201
+ editable?: boolean | undefined;
202
+ onEditClick?: Function | undefined;
203
+ visibleGetter?: Function | undefined;
204
+ showOnGroup?: boolean | undefined;
205
+ displayField?: string | Function | undefined;
206
+ restProps: Object;
185
207
  }): ColumnBuilder;
186
208
  /**
187
209
  * Přidá sloupec pro zobrazení ikon s podporou badge (číselného označení).
@@ -17,99 +17,6 @@ import { ActionIcon } from './Icons';
17
17
  import { CircleHelp, Check, X } from 'lucide-react';
18
18
  // Globální cache pro názvy zemí (sdílená napříč všemi instancemi ColumnBuilder)
19
19
  const COUNTRY_NAMES_CACHE = {};
20
- /**
21
- * Custom React hook pro zpracování interakcí s link buňkou v AG Grid.
22
- * Obsluhuje hover efekty, kliky a přepínání overview módu.
23
- * @param {Object} params - AG Grid parametry buňky
24
- * @param {Function} onClick - Callback funkce při kliku na link
25
- * @param {Object|Function} linkStyle - CSS styl pro link nebo funkce vracející styl
26
- * @param {Object|Function} hoverStyle - CSS styl pro hover stav nebo funkce vracející styl
27
- * @param {boolean} overviewToggle - Příznak zda aktivovat overview toggle funkčnost
28
- * @returns {Object} Objekt s handlry a styly pro link buňku
29
- */
30
- const useLinkCellRenderer = (params, onClick, linkStyle, hoverStyle, overviewToggle) => {
31
- const [isHovered, setIsHovered] = React.useState(false);
32
- const handleMouseEnter = React.useCallback(() => {
33
- setIsHovered(true);
34
- }, []);
35
- const handleMouseLeave = React.useCallback(() => {
36
- setIsHovered(false);
37
- }, []);
38
- const handleClick = React.useCallback((event) => {
39
- event.stopPropagation();
40
- if (overviewToggle && params.api) {
41
- params.api.dispatchEvent({
42
- type: 'overviewToggle',
43
- data: params.data,
44
- params,
45
- });
46
- }
47
- if (onClick) {
48
- onClick(params);
49
- }
50
- }, [onClick, overviewToggle, params]);
51
- // Přesunuto do useMemo, aby se vytvořilo pouze jednou
52
- const defaultLinkStyle = React.useMemo(() => ({
53
- color: '#1a73e8',
54
- textDecoration: 'none',
55
- cursor: 'pointer',
56
- }), []);
57
- // Přesunuto do useMemo, aby se vytvořilo pouze jednou
58
- const defaultHoverStyle = React.useMemo(() => ({
59
- textDecoration: 'underline',
60
- }), []);
61
- const computedLinkStyle = React.useMemo(() => ({
62
- ...defaultLinkStyle,
63
- ...(typeof linkStyle === 'function'
64
- ? linkStyle(params)
65
- : linkStyle || {}),
66
- }), [linkStyle, params, defaultLinkStyle]);
67
- const computedHoverStyle = React.useMemo(() => ({
68
- ...defaultLinkStyle,
69
- ...computedLinkStyle,
70
- ...defaultHoverStyle,
71
- ...(typeof hoverStyle === 'function'
72
- ? hoverStyle(params)
73
- : hoverStyle || {}),
74
- }), [computedLinkStyle, hoverStyle, params, defaultLinkStyle, defaultHoverStyle]);
75
- return {
76
- isHovered,
77
- handleMouseEnter,
78
- handleMouseLeave,
79
- handleClick,
80
- computedLinkStyle,
81
- computedHoverStyle,
82
- };
83
- };
84
- /**
85
- * Custom React hook pro zpracování interakcí s object buňkou v AG Grid.
86
- * Poskytuje funkcionalitu pro editovatelné objekty s hover efekty a edit tlačítkem.
87
- * @param {Object} params - AG Grid parametry buňky
88
- * @param {boolean} editable - Příznak zda je buňka editovatelná
89
- * @param {Function} onEditClick - Callback funkce při kliku na edit tlačítko
90
- * @returns {Object} Objekt s handlry pro object buňku
91
- */
92
- const useObjectCellRenderer = (params, editable, onEditClick) => {
93
- const [isHovered, setIsHovered] = React.useState(false);
94
- const handleMouseEnter = React.useCallback(() => {
95
- setIsHovered(true);
96
- }, []);
97
- const handleMouseLeave = React.useCallback(() => {
98
- setIsHovered(false);
99
- }, []);
100
- const handleEditClick = React.useCallback((event) => {
101
- event.stopPropagation();
102
- if (onEditClick) {
103
- onEditClick(params);
104
- }
105
- }, [onEditClick, params]);
106
- return {
107
- isHovered,
108
- handleMouseEnter,
109
- handleMouseLeave,
110
- handleEditClick,
111
- };
112
- };
113
20
  /**
114
21
  * Custom React hook pro detekci hover stavu řádku v AG Grid.
115
22
  * Používá MutationObserver pro sledování CSS tříd řádků a detekci hover stavu.
@@ -327,28 +234,37 @@ class ColumnBuilder {
327
234
  * @param {Object} ...restProps - Další AG Grid vlastnosti sloupce
328
235
  * @returns {ColumnBuilder} Instance pro chaining
329
236
  */
330
- addLinkColumn({ onClick, linkStyle, hoverStyle, cellAlign = 'left', editable, overviewToggle = false, color, bgColor, colorField, bgColorField, ...restProps }) {
331
- // Vytvořím komponentu pro cell renderer, která používá hook
332
- const LinkCellRenderer = React.memo((params) => {
333
- const { isHovered, handleMouseEnter, handleMouseLeave, handleClick, computedLinkStyle, computedHoverStyle, } = useLinkCellRenderer(params, onClick, linkStyle, hoverStyle, overviewToggle);
334
- return (_jsx("div", { className: "link-cell-container", style: {
335
- width: '100%',
336
- height: '100%',
337
- display: 'flex',
338
- alignItems: 'center',
339
- }, children: _jsx("span", { onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: isHovered ? computedHoverStyle : computedLinkStyle, role: "button", tabIndex: 0, onKeyPress: (event) => {
340
- if (event.key === 'Enter' || event.key === ' ') {
341
- handleClick(event);
342
- }
343
- }, children: params.value }) }));
344
- });
345
- // Používáme funkci, která vrátí React komponentu
346
- const cellRenderer = (params) => {
347
- return _jsx(LinkCellRenderer, { ...params });
348
- };
237
+ /**
238
+ * Přidá sloupec s odkazem (link) - Používá extrahovaný LinkRenderer.
239
+ * Optimalizovaná implementace s extrahovaným rendererem pro lepší výkon.
240
+ * @param {Object} config - Konfigurace link sloupce
241
+ * @param {string} [config.cellAlign='left'] - Horizontální zarovnání obsahu ('left', 'center', 'right')
242
+ * @param {Function} [config.onClick] - Callback funkce při kliku na link
243
+ * @param {Object|Function} [config.linkStyle] - CSS styl pro link nebo funkce vracející styl
244
+ * @param {Object|Function} [config.hoverStyle] - CSS styl pro hover stav nebo funkce vracející styl
245
+ * @param {boolean} [config.overviewToggle=false] - Příznak zda aktivovat overview toggle funkčnost
246
+ * @param {boolean} [config.editable=false] - Editovatelnost buňky
247
+ * @param {Function} [config.visibleGetter] - Funkce určující viditelnost linku
248
+ * @param {boolean} [config.showOnGroup=false] - Zobrazit link i v group řádcích
249
+ * @param {Object} config.restProps - Další AG-Grid colDef parametry
250
+ * @returns {ColumnBuilder} Instance pro fluent API
251
+ */
252
+ addLinkColumn({ cellAlign = 'left', onClick, linkStyle, hoverStyle, overviewToggle = false, editable = false, visibleGetter, showOnGroup = false, contentTooltip, tooltipField, tooltipInteraction, tooltipShowDelay, color, bgColor, colorField, bgColorField, ...restProps }) {
349
253
  __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_addPreparedColumn).call(this, {
350
254
  cellAlign,
351
- cellRenderer,
255
+ cellRenderer: 'linkRenderer',
256
+ cellRendererParams: {
257
+ onClick,
258
+ linkStyle,
259
+ hoverStyle,
260
+ overviewToggle,
261
+ visibleGetter,
262
+ showOnGroup,
263
+ },
264
+ contentTooltip,
265
+ tooltipField,
266
+ tooltipInteraction,
267
+ tooltipShowDelay,
352
268
  editable: __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_resolveEditable).call(this, editable),
353
269
  overviewToggle,
354
270
  color,
@@ -403,38 +319,32 @@ class ColumnBuilder {
403
319
  * @param {Object} ...restProps - Další AG Grid vlastnosti sloupce
404
320
  * @returns {ColumnBuilder} Instance pro chaining
405
321
  */
406
- addObjectColumn({ contentTooltip, tooltipField, tooltipInteraction, tooltipShowDelay = 100, editable, onEditClick, color, bgColor, colorField, bgColorField, ...restProps }) {
407
- // Vytvořím komponentu pro cell renderer, která používá hook
408
- const ObjectCellRenderer = React.memo((params) => {
409
- const { isHovered, handleMouseEnter, handleMouseLeave, handleEditClick } = useObjectCellRenderer(params, editable, onEditClick);
410
- return (_jsxs("div", { className: "object-cell-container", style: {
411
- position: 'relative',
412
- width: '100%',
413
- height: '100%',
414
- display: 'flex',
415
- alignItems: 'center',
416
- }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [_jsx("div", { style: { flexGrow: 1 }, children: params.value }), isHovered && editable && (_jsx("button", { className: "edit-object-button", style: {
417
- position: 'absolute',
418
- right: '4px',
419
- background: 'transparent',
420
- border: 'none',
421
- cursor: 'pointer',
422
- padding: '4px',
423
- display: 'flex',
424
- alignItems: 'center',
425
- justifyContent: 'center',
426
- }, onClick: handleEditClick, title: "Upravit", children: _jsx("span", { style: { fontSize: '16px' }, children: "\u22EE" }) }))] }));
427
- });
428
- // Používáme funkci, která vrátí React komponentu
429
- const cellRenderer = (params) => {
430
- return _jsx(ObjectCellRenderer, { ...params });
431
- };
322
+ /**
323
+ * Přidá sloupec pro zobrazení objektů - Používá extrahovaný ObjectRenderer.
324
+ * Optimalizovaná implementace s extrahovaným rendererem pro lepší výkon.
325
+ * @param {Object} config - Konfigurace object sloupce
326
+ * @param {boolean} [config.editable=false] - Příznak zda je buňka editovatelná s edit tlačítkem
327
+ * @param {Function} [config.onEditClick] - Callback funkce při kliku na edit tlačítko
328
+ * @param {Function} [config.visibleGetter] - Funkce určující viditelnost objektu
329
+ * @param {boolean} [config.showOnGroup=false] - Zobrazit objekt i v group řádcích
330
+ * @param {string|Function} [config.displayField] - Název pole nebo funkce pro získání zobrazované hodnoty
331
+ * @param {Object} config.restProps - Další AG-Grid colDef parametry
332
+ * @returns {ColumnBuilder} Instance pro fluent API
333
+ */
334
+ addObjectColumn({ editable = false, onEditClick, visibleGetter, showOnGroup = false, displayField, contentTooltip, tooltipField, tooltipInteraction, tooltipShowDelay, color, bgColor, colorField, bgColorField, ...restProps }) {
432
335
  __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_addPreparedColumn).call(this, {
336
+ cellRenderer: 'objectRenderer',
337
+ cellRendererParams: {
338
+ editable,
339
+ onEditClick,
340
+ visibleGetter,
341
+ showOnGroup,
342
+ displayField,
343
+ },
433
344
  contentTooltip,
434
345
  tooltipField,
435
346
  tooltipInteraction,
436
347
  tooltipShowDelay,
437
- cellRenderer,
438
348
  editable: __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_resolveEditable).call(this, editable),
439
349
  color,
440
350
  bgColor,
@@ -602,19 +512,47 @@ class ColumnBuilder {
602
512
  * @returns {ColumnBuilder} Instance pro chaining
603
513
  */
604
514
  addCountryColumn({ countryCode, countryCodeField, displayType = 'name', language = 'cs', flagPosition = 'left', flagSize = 24, textGap = 8, cellAlign = 'left', getCountryName, color, bgColor, colorField, bgColorField, ...restProps }) {
515
+ // Memoizovaná CountryFlag sub-komponenta s lazy loading a error handling
516
+ const CountryFlag = React.memo(({ code, size }) => {
517
+ const [hasError, setHasError] = React.useState(false);
518
+ const flagUrl = React.useMemo(() => {
519
+ if (!code)
520
+ return null;
521
+ return `https://flagcdn.com/w40/${code.toLowerCase()}.png`;
522
+ }, [code]);
523
+ const handleError = React.useCallback(() => {
524
+ setHasError(true);
525
+ }, []);
526
+ React.useEffect(() => {
527
+ setHasError(false);
528
+ }, [flagUrl]);
529
+ const flagStyle = React.useMemo(() => ({
530
+ width: `${size}px`,
531
+ height: `${size}px`,
532
+ borderRadius: '50%',
533
+ objectFit: 'cover',
534
+ flexShrink: 0,
535
+ }), [size]);
536
+ if (hasError || !flagUrl)
537
+ return null;
538
+ return (_jsx("img", { src: flagUrl, alt: `${code} flag`, style: flagStyle, loading: "lazy", onError: handleError }));
539
+ });
540
+ CountryFlag.displayName = 'CountryFlag';
605
541
  const CountryCellRenderer = React.memo((params) => {
606
542
  const [countryName, setCountryName] = React.useState(null);
607
543
  const [isLoading, setIsLoading] = React.useState(false);
608
544
  // Získání kódu země
609
- const code = countryCodeField
610
- ? getValueByPath(params.data, countryCodeField)
611
- : (typeof countryCode === 'function' ? countryCode(params) : countryCode);
612
- if (!code)
613
- return null;
614
- const upperCode = code.toUpperCase();
615
- const cacheKey = `${upperCode}_${language}`;
545
+ const code = React.useMemo(() => {
546
+ return countryCodeField
547
+ ? getValueByPath(params.data, countryCodeField)
548
+ : (typeof countryCode === 'function' ? countryCode(params) : countryCode);
549
+ }, [params.data, params.value]);
550
+ const upperCode = React.useMemo(() => code ? code.toUpperCase() : null, [code]);
551
+ const cacheKey = React.useMemo(() => upperCode ? `${upperCode}_${language}` : null, [upperCode, language]);
616
552
  // Načtení názvu země z REST Countries API
617
553
  React.useEffect(() => {
554
+ if (!upperCode || !cacheKey)
555
+ return;
618
556
  if (displayType !== 'name')
619
557
  return;
620
558
  if (getCountryName)
@@ -625,14 +563,14 @@ class ColumnBuilder {
625
563
  return;
626
564
  }
627
565
  setIsLoading(true);
628
- // REST Countries API: https://restcountries.com/v3.1/alpha/{code}
566
+ // REST Countries API
629
567
  fetch(`https://restcountries.com/v3.1/alpha/${upperCode}`)
630
568
  .then(response => response.json())
631
569
  .then(data => {
632
570
  if (data && data[0]) {
633
571
  // Získání překladu podle jazyka
634
572
  const translations = data[0].translations;
635
- let name = data[0].name.common; // fallback na anglický název
573
+ let name = data[0].name.common;
636
574
  if (language === 'cs' && translations?.ces) {
637
575
  name = translations.ces.common;
638
576
  }
@@ -647,58 +585,59 @@ class ColumnBuilder {
647
585
  setCountryName(name);
648
586
  }
649
587
  })
650
- .catch((error) => {
651
- console.error('Error fetching country:', error);
588
+ .catch(() => {
652
589
  // V případě chyby použijeme kód země
653
590
  setCountryName(upperCode);
654
591
  })
655
592
  .finally(() => {
656
593
  setIsLoading(false);
657
594
  });
658
- }, [upperCode, cacheKey, displayType, getCountryName, params.value, language]);
659
- // Získání názvu země
660
- let displayText = upperCode;
661
- if (displayType === 'name') {
662
- if (getCountryName) {
663
- displayText = getCountryName(code, params);
664
- }
665
- else if (countryName) {
666
- displayText = countryName;
667
- }
668
- else if (isLoading) {
669
- displayText = '...';
670
- }
671
- else if (params.value) {
672
- displayText = params.value;
595
+ }, [upperCode, cacheKey, displayType, getCountryName]);
596
+ // Memoizovaný displayText
597
+ const displayText = React.useMemo(() => {
598
+ if (!upperCode)
599
+ return '';
600
+ if (displayType === 'name') {
601
+ if (getCountryName) {
602
+ return getCountryName(code, params);
603
+ }
604
+ if (countryName) {
605
+ return countryName;
606
+ }
607
+ if (isLoading) {
608
+ return '...';
609
+ }
610
+ if (params.value) {
611
+ return params.value;
612
+ }
673
613
  }
674
- }
675
- // URL veřejného API pro vlajky (flagcdn.com)
676
- const flagUrl = `https://flagcdn.com/w40/${upperCode.toLowerCase()}.png`;
677
- const flagStyle = {
678
- width: `${flagSize}px`,
679
- height: `${flagSize}px`,
680
- borderRadius: '50%',
681
- objectFit: 'cover',
682
- flexShrink: 0,
683
- };
684
- const containerStyle = {
614
+ return upperCode;
615
+ }, [upperCode, displayType, getCountryName, code, params, countryName, isLoading]);
616
+ // Memoizovaný containerStyle
617
+ const containerStyle = React.useMemo(() => ({
685
618
  display: 'flex',
686
619
  alignItems: 'center',
687
- justifyContent: cellAlign === 'center' ? 'center' : cellAlign === 'right' ? 'flex-end' : 'flex-start',
620
+ justifyContent: cellAlign === 'center' ? 'center' :
621
+ cellAlign === 'right' ? 'flex-end' :
622
+ 'flex-start',
688
623
  width: '100%',
689
624
  height: '100%',
690
625
  gap: `${textGap}px`,
691
626
  flexDirection: flagPosition === 'right' ? 'row-reverse' : 'row',
692
- };
693
- return (_jsxs("div", { style: containerStyle, children: [_jsx("img", { src: flagUrl, alt: `${upperCode} flag`, style: flagStyle, onError: (e) => {
694
- e.target.style.display = 'none';
695
- } }), _jsx("span", { children: displayText })] }));
627
+ }), [cellAlign, textGap, flagPosition]);
628
+ if (!code)
629
+ return null;
630
+ return (_jsxs("div", { style: containerStyle, children: [_jsx(CountryFlag, { code: upperCode, size: flagSize }), _jsx("span", { children: displayText })] }));
696
631
  });
632
+ CountryCellRenderer.displayName = 'CountryCellRenderer';
697
633
  const cellRenderer = (params) => {
698
634
  return _jsx(CountryCellRenderer, { ...params });
699
635
  };
700
636
  __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_addPreparedColumn).call(this, {
701
637
  cellRenderer,
638
+ cellRendererParams: {
639
+ deferRender: true, // AG-Grid deferred rendering pro optimalizaci výkonu při scrollování
640
+ },
702
641
  color,
703
642
  bgColor,
704
643
  colorField,
@@ -730,46 +669,57 @@ class ColumnBuilder {
730
669
  * @returns {ColumnBuilder} Instance pro chaining
731
670
  */
732
671
  addBooleanColumn({ visibleFalse = true, visibleTrue = true, cellAlign = 'center', visibleGetter = () => true, defaultIcon = true, defaultIconColor = '#898989', size = 16, colorTrue = 'green', colorFalse = 'red', showOnGroup = false, editable, color, bgColor, colorField, bgColorField, ...restProps }) {
672
+ // Konstanty mimo komponentu pro lepší výkon
673
+ const ICON_STYLE = {
674
+ display: 'inline-block',
675
+ height: '100%',
676
+ };
677
+ // Memoizovaná Icon sub-komponenta
678
+ const Icon = React.memo(({ innerValue, size, colorTrue, colorFalse, visibleTrue, visibleFalse, defaultIcon, defaultIconColor }) => {
679
+ if (innerValue === undefined || innerValue === null) {
680
+ if (defaultIcon) {
681
+ return _jsx(CircleHelp, { size: size, color: defaultIconColor, style: ICON_STYLE });
682
+ }
683
+ return null;
684
+ }
685
+ if ((!visibleFalse && !innerValue) || (!visibleTrue && innerValue)) {
686
+ return null;
687
+ }
688
+ if (innerValue) {
689
+ return _jsx(Check, { size: size, color: colorTrue, style: ICON_STYLE });
690
+ }
691
+ return _jsx(X, { size: size, color: colorFalse, style: ICON_STYLE });
692
+ });
693
+ Icon.displayName = 'BooleanIcon';
733
694
  // Create a React component for boolean cell renderer
734
695
  const BooleanCellRenderer = React.memo((params) => {
735
696
  const { data, value } = params;
736
- const visibleResult = visibleGetter ? visibleGetter(data) : true;
737
- const Icon = ({ innerValue, ...iconProps }) => {
738
- if (innerValue === undefined || innerValue === null) {
739
- if (defaultIcon)
740
- return _jsx(CircleHelp, { size: size, color: defaultIconColor, ...iconProps });
741
- }
742
- if ((!visibleFalse && !innerValue) ||
743
- (!visibleTrue && (innerValue))) {
744
- return _jsx("div", {});
745
- }
746
- if (innerValue)
747
- return _jsx(Check, { size: size, color: colorTrue, ...iconProps });
748
- return _jsx(X, { size: size, color: colorFalse, ...iconProps });
749
- };
750
- const showCondition = () => {
697
+ const visibleResult = React.useMemo(() => visibleGetter ? visibleGetter(data) : true, [data]);
698
+ const showCondition = React.useMemo(() => {
751
699
  const newItem = (data && data._rh_plus_ag_grid_new_item) || false;
752
700
  return !newItem && (showOnGroup || !!data) && visibleResult;
753
- };
754
- if (!showCondition())
701
+ }, [data, visibleResult]);
702
+ const containerStyle = React.useMemo(() => ({
703
+ width: '100%',
704
+ display: 'flex',
705
+ justifyContent: cellAlign ?? 'center',
706
+ alignItems: 'center',
707
+ height: '100%',
708
+ }), [cellAlign]);
709
+ if (!showCondition)
755
710
  return null;
756
- return (_jsx("span", { style: {
757
- width: '100%',
758
- display: 'flex',
759
- justifyContent: cellAlign,
760
- alignItems: 'center',
761
- height: '100%',
762
- }, children: _jsx(Icon, { style: {
763
- display: 'inline-block',
764
- height: '100%',
765
- }, innerValue: value, visibleTrue: visibleTrue, visibleFalse: visibleFalse }) }));
711
+ return (_jsx("span", { style: containerStyle, children: _jsx(Icon, { innerValue: value, size: size, colorTrue: colorTrue, colorFalse: colorFalse, visibleTrue: visibleTrue, visibleFalse: visibleFalse, defaultIcon: defaultIcon, defaultIconColor: defaultIconColor }) }));
766
712
  });
713
+ BooleanCellRenderer.displayName = 'BooleanCellRenderer';
767
714
  // Use the function that returns React component
768
715
  const cellRenderer = (params) => {
769
716
  return _jsx(BooleanCellRenderer, { ...params });
770
717
  };
771
718
  __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_addPreparedColumn).call(this, {
772
719
  cellRenderer,
720
+ cellRendererParams: {
721
+ deferRender: true, // AG-Grid deferred rendering pro optimalizaci výkonu při scrollování
722
+ },
773
723
  editable: __classPrivateFieldGet(this, _ColumnBuilder_instances, "m", _ColumnBuilder_resolveEditable).call(this, editable),
774
724
  color,
775
725
  bgColor,
@@ -1095,6 +1045,9 @@ class ColumnBuilder {
1095
1045
  filter: false,
1096
1046
  resizable: false,
1097
1047
  cellRenderer: ActionDropdownRenderer,
1048
+ cellRendererParams: {
1049
+ deferRender: true, // AG-Grid deferred rendering pro optimalizaci výkonu při scrollování
1050
+ },
1098
1051
  cellClass: 'action-button-cell-observer',
1099
1052
  ...restProps,
1100
1053
  });