@bit.rhplus/ag-grid 0.0.81 → 0.0.82
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.
- package/BulkEdit/BulkEditDatePicker.jsx +305 -305
- package/BulkEdit/BulkEditInput.jsx +81 -81
- package/BulkEdit/BulkEditPopover.jsx +310 -310
- package/BulkEdit/BulkEditSelect.jsx +106 -106
- package/Renderers/ImageRenderer.jsx +103 -103
- package/Renderers/LinkRenderer.jsx +133 -133
- package/Renderers/ObjectRenderer.jsx +140 -140
- package/Renderers/StateRenderer.jsx +148 -148
- package/dist/BulkEdit/BulkEditDatePicker.js +35 -35
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/index.jsx +1 -0
- package/package.json +5 -5
- /package/dist/{preview-1768486452196.js → preview-1768559621799.js} +0 -0
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { createMemoComparison } from '@bit.rhplus/react-memo';
|
|
4
|
-
|
|
5
|
-
// Style constants
|
|
6
|
-
const CONTAINER_STYLE = {
|
|
7
|
-
position: 'relative',
|
|
8
|
-
width: '100%',
|
|
9
|
-
height: '100%',
|
|
10
|
-
display: 'flex',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const CONTENT_STYLE = {
|
|
15
|
-
flexGrow: 1,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const BUTTON_STYLE = {
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
right: '4px',
|
|
21
|
-
background: 'transparent',
|
|
22
|
-
border: 'none',
|
|
23
|
-
cursor: 'pointer',
|
|
24
|
-
padding: '4px',
|
|
25
|
-
display: 'flex',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
justifyContent: 'center',
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const BUTTON_ICON_STYLE = {
|
|
31
|
-
fontSize: '16px',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Memoizovaný EditButton sub-komponenta
|
|
35
|
-
const EditButton = React.memo(({ onClick, title = 'Upravit' }) => (
|
|
36
|
-
<button
|
|
37
|
-
className="edit-object-button"
|
|
38
|
-
style={BUTTON_STYLE}
|
|
39
|
-
onClick={onClick}
|
|
40
|
-
title={title}
|
|
41
|
-
>
|
|
42
|
-
<span style={BUTTON_ICON_STYLE}>⋮</span>
|
|
43
|
-
</button>
|
|
44
|
-
));
|
|
45
|
-
|
|
46
|
-
EditButton.displayName = 'EditButton';
|
|
47
|
-
|
|
48
|
-
function ObjectRenderer(props) {
|
|
49
|
-
const {
|
|
50
|
-
value,
|
|
51
|
-
data,
|
|
52
|
-
colDef: { objectRendererParams = {} } = {},
|
|
53
|
-
} = props;
|
|
54
|
-
|
|
55
|
-
const {
|
|
56
|
-
editable = false,
|
|
57
|
-
onEditClick,
|
|
58
|
-
showOnGroup = false,
|
|
59
|
-
visibleGetter,
|
|
60
|
-
displayField,
|
|
61
|
-
} = objectRendererParams;
|
|
62
|
-
|
|
63
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
64
|
-
|
|
65
|
-
const handleMouseEnter = React.useCallback(() => {
|
|
66
|
-
setIsHovered(true);
|
|
67
|
-
}, []);
|
|
68
|
-
|
|
69
|
-
const handleMouseLeave = React.useCallback(() => {
|
|
70
|
-
setIsHovered(false);
|
|
71
|
-
}, []);
|
|
72
|
-
|
|
73
|
-
const handleEditClick = React.useCallback(
|
|
74
|
-
(event) => {
|
|
75
|
-
event.stopPropagation();
|
|
76
|
-
if (onEditClick) {
|
|
77
|
-
onEditClick(props);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
[onEditClick, props]
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const visibleResult = React.useMemo(() =>
|
|
84
|
-
visibleGetter ? visibleGetter(data) : true,
|
|
85
|
-
[visibleGetter, data]
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const showCondition = React.useMemo(() => {
|
|
89
|
-
const newItem = (data && data._rh_plus_ag_grid_new_item) || false;
|
|
90
|
-
return !newItem && (showOnGroup || !!data) && visibleResult;
|
|
91
|
-
}, [data, showOnGroup, visibleResult]);
|
|
92
|
-
|
|
93
|
-
const displayValue = React.useMemo(() => {
|
|
94
|
-
if (!value) return null;
|
|
95
|
-
|
|
96
|
-
if (displayField) {
|
|
97
|
-
if (typeof displayField === 'function') {
|
|
98
|
-
return displayField({ data, value, props });
|
|
99
|
-
}
|
|
100
|
-
if (typeof displayField === 'string') {
|
|
101
|
-
return value[displayField] || value;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (typeof value === 'object' && value !== null) {
|
|
106
|
-
return value.name || value.title || value.label || JSON.stringify(value);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return value;
|
|
110
|
-
}, [value, displayField, data, props]);
|
|
111
|
-
|
|
112
|
-
if (!showCondition) return null;
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div
|
|
116
|
-
className="object-cell-container"
|
|
117
|
-
style={CONTAINER_STYLE}
|
|
118
|
-
onMouseEnter={handleMouseEnter}
|
|
119
|
-
onMouseLeave={handleMouseLeave}
|
|
120
|
-
>
|
|
121
|
-
<div style={CONTENT_STYLE}>{displayValue}</div>
|
|
122
|
-
{isHovered && editable && (
|
|
123
|
-
<EditButton onClick={handleEditClick} />
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
ObjectRenderer.displayName = 'ObjectRenderer';
|
|
130
|
-
|
|
131
|
-
// React.memo optimalizace pro AG-Grid renderer
|
|
132
|
-
// ✅ PERFORMANCE FIX: colDef NESMÍ být v kritických props!
|
|
133
|
-
const arePropsEqual = createMemoComparison(
|
|
134
|
-
['value', 'data'],
|
|
135
|
-
['colDef'],
|
|
136
|
-
false,
|
|
137
|
-
'ObjectRenderer'
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
export default React.memo(ObjectRenderer, arePropsEqual);
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createMemoComparison } from '@bit.rhplus/react-memo';
|
|
4
|
+
|
|
5
|
+
// Style constants
|
|
6
|
+
const CONTAINER_STYLE = {
|
|
7
|
+
position: 'relative',
|
|
8
|
+
width: '100%',
|
|
9
|
+
height: '100%',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const CONTENT_STYLE = {
|
|
15
|
+
flexGrow: 1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const BUTTON_STYLE = {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
right: '4px',
|
|
21
|
+
background: 'transparent',
|
|
22
|
+
border: 'none',
|
|
23
|
+
cursor: 'pointer',
|
|
24
|
+
padding: '4px',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const BUTTON_ICON_STYLE = {
|
|
31
|
+
fontSize: '16px',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Memoizovaný EditButton sub-komponenta
|
|
35
|
+
const EditButton = React.memo(({ onClick, title = 'Upravit' }) => (
|
|
36
|
+
<button
|
|
37
|
+
className="edit-object-button"
|
|
38
|
+
style={BUTTON_STYLE}
|
|
39
|
+
onClick={onClick}
|
|
40
|
+
title={title}
|
|
41
|
+
>
|
|
42
|
+
<span style={BUTTON_ICON_STYLE}>⋮</span>
|
|
43
|
+
</button>
|
|
44
|
+
));
|
|
45
|
+
|
|
46
|
+
EditButton.displayName = 'EditButton';
|
|
47
|
+
|
|
48
|
+
function ObjectRenderer(props) {
|
|
49
|
+
const {
|
|
50
|
+
value,
|
|
51
|
+
data,
|
|
52
|
+
colDef: { objectRendererParams = {} } = {},
|
|
53
|
+
} = props;
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
editable = false,
|
|
57
|
+
onEditClick,
|
|
58
|
+
showOnGroup = false,
|
|
59
|
+
visibleGetter,
|
|
60
|
+
displayField,
|
|
61
|
+
} = objectRendererParams;
|
|
62
|
+
|
|
63
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
64
|
+
|
|
65
|
+
const handleMouseEnter = React.useCallback(() => {
|
|
66
|
+
setIsHovered(true);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
69
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
70
|
+
setIsHovered(false);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const handleEditClick = React.useCallback(
|
|
74
|
+
(event) => {
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
if (onEditClick) {
|
|
77
|
+
onEditClick(props);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[onEditClick, props]
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const visibleResult = React.useMemo(() =>
|
|
84
|
+
visibleGetter ? visibleGetter(data) : true,
|
|
85
|
+
[visibleGetter, data]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const showCondition = React.useMemo(() => {
|
|
89
|
+
const newItem = (data && data._rh_plus_ag_grid_new_item) || false;
|
|
90
|
+
return !newItem && (showOnGroup || !!data) && visibleResult;
|
|
91
|
+
}, [data, showOnGroup, visibleResult]);
|
|
92
|
+
|
|
93
|
+
const displayValue = React.useMemo(() => {
|
|
94
|
+
if (!value) return null;
|
|
95
|
+
|
|
96
|
+
if (displayField) {
|
|
97
|
+
if (typeof displayField === 'function') {
|
|
98
|
+
return displayField({ data, value, props });
|
|
99
|
+
}
|
|
100
|
+
if (typeof displayField === 'string') {
|
|
101
|
+
return value[displayField] || value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (typeof value === 'object' && value !== null) {
|
|
106
|
+
return value.name || value.title || value.label || JSON.stringify(value);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return value;
|
|
110
|
+
}, [value, displayField, data, props]);
|
|
111
|
+
|
|
112
|
+
if (!showCondition) return null;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div
|
|
116
|
+
className="object-cell-container"
|
|
117
|
+
style={CONTAINER_STYLE}
|
|
118
|
+
onMouseEnter={handleMouseEnter}
|
|
119
|
+
onMouseLeave={handleMouseLeave}
|
|
120
|
+
>
|
|
121
|
+
<div style={CONTENT_STYLE}>{displayValue}</div>
|
|
122
|
+
{isHovered && editable && (
|
|
123
|
+
<EditButton onClick={handleEditClick} />
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
ObjectRenderer.displayName = 'ObjectRenderer';
|
|
130
|
+
|
|
131
|
+
// React.memo optimalizace pro AG-Grid renderer
|
|
132
|
+
// ✅ PERFORMANCE FIX: colDef NESMÍ být v kritických props!
|
|
133
|
+
const arePropsEqual = createMemoComparison(
|
|
134
|
+
['value', 'data'],
|
|
135
|
+
['colDef'],
|
|
136
|
+
false,
|
|
137
|
+
'ObjectRenderer'
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
export default React.memo(ObjectRenderer, arePropsEqual);
|
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { createMemoComparison } from '@bit.rhplus/react-memo';
|
|
4
|
-
|
|
5
|
-
// Helper function moved outside component
|
|
6
|
-
function getValueByPath(obj, path) {
|
|
7
|
-
if (!obj || !path) return null;
|
|
8
|
-
return path.split('.').reduce((o, k) => (o && o[k] !== undefined) ? o[k] : null, obj);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function StateRenderer(props) {
|
|
12
|
-
const { data, value, colDef: { stateRendererParams = {} } = {} } = props;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!stateRendererParams) return null;
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
visibleGetter = () => true,
|
|
19
|
-
cellAlign = 'center',
|
|
20
|
-
bgColor, // Barva pozadí nebo funkce vracející barvu
|
|
21
|
-
color, // Barva textu nebo funkce vracející barvu (nový název)
|
|
22
|
-
textColor, // Barva textu (starý název - zpětná kompatibilita)
|
|
23
|
-
bgColorField, // Název pole obsahujícího barvu pozadí
|
|
24
|
-
colorField, // Název pole obsahujícího barvu textu (nový název)
|
|
25
|
-
textColorField, // Název pole obsahujícího barvu textu (starý název - zpětná kompatibilita)
|
|
26
|
-
displayField, // Pole pro zobrazení textu
|
|
27
|
-
minWidth = 80, // Minimální šířka kruhového pozadí
|
|
28
|
-
fontSize = 12, // Velikost fontu
|
|
29
|
-
showOnGroup = false, // Zda zobrazit na skupinových řádcích
|
|
30
|
-
} = stateRendererParams;
|
|
31
|
-
|
|
32
|
-
// Použít nový název s fallbackem na starý pro zpětnou kompatibilitu
|
|
33
|
-
const finalColor = color || textColor || 'white';
|
|
34
|
-
const finalColorField = colorField || textColorField;
|
|
35
|
-
|
|
36
|
-
const visibleResult = React.useMemo(() =>
|
|
37
|
-
visibleGetter ? visibleGetter(data) : true,
|
|
38
|
-
[visibleGetter, data]
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const computedBgColor = React.useMemo(() => {
|
|
42
|
-
// Priorita: bgColorField (hodnota z dat) -> bgColor (funkce nebo string)
|
|
43
|
-
if (bgColorField && data) {
|
|
44
|
-
const fieldValue = getValueByPath(data, bgColorField);
|
|
45
|
-
if (fieldValue) return fieldValue;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!bgColor) return '#666'; // default barva
|
|
49
|
-
|
|
50
|
-
// Pokud je bgColor funkce, zavolej ji s daty
|
|
51
|
-
if (typeof bgColor === 'function') {
|
|
52
|
-
return bgColor({ data, value, props });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Pokud je bgColor string/hodnota
|
|
56
|
-
return bgColor;
|
|
57
|
-
}, [bgColor, bgColorField, data, value, props]);
|
|
58
|
-
|
|
59
|
-
const computedTextColor = React.useMemo(() => {
|
|
60
|
-
// Priorita: colorField/textColorField (hodnota z dat) -> color/textColor (funkce nebo string)
|
|
61
|
-
if (finalColorField && data) {
|
|
62
|
-
const fieldValue = getValueByPath(data, finalColorField);
|
|
63
|
-
if (fieldValue) return fieldValue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!finalColor) return 'white'; // default barva
|
|
67
|
-
|
|
68
|
-
// Pokud je finalColor funkce, zavolej ji s daty
|
|
69
|
-
if (typeof finalColor === 'function') {
|
|
70
|
-
return finalColor({ data, value, props });
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Pokud je finalColor string/hodnota
|
|
74
|
-
return finalColor;
|
|
75
|
-
}, [finalColor, finalColorField, data, value, props]);
|
|
76
|
-
|
|
77
|
-
const displayText = React.useMemo(() => {
|
|
78
|
-
if (displayField) {
|
|
79
|
-
// Pokud je displayField funkce
|
|
80
|
-
if (typeof displayField === 'function') {
|
|
81
|
-
return displayField({ data, value, props });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Pokud je displayField string (název pole)
|
|
85
|
-
if (typeof displayField === 'string') {
|
|
86
|
-
return data?.[displayField] || value;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Fallback na value
|
|
91
|
-
return value || '';
|
|
92
|
-
}, [displayField, data, value, props]);
|
|
93
|
-
|
|
94
|
-
const showCondition = React.useMemo(() => {
|
|
95
|
-
const newItem = (data && data._rh_plus_ag_grid_new_item) || false;
|
|
96
|
-
return !newItem && (showOnGroup || !!data) && visibleResult;
|
|
97
|
-
}, [data, showOnGroup, visibleResult]);
|
|
98
|
-
|
|
99
|
-
if (!showCondition) return null;
|
|
100
|
-
|
|
101
|
-
// Pokud nemáme text k zobrazení, nevrací nic
|
|
102
|
-
if (!displayText) return null;
|
|
103
|
-
|
|
104
|
-
const containerStyle = React.useMemo(() => ({
|
|
105
|
-
width: '100%',
|
|
106
|
-
display: 'flex',
|
|
107
|
-
justifyContent: cellAlign === 'center' ? 'center' : cellAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
108
|
-
alignItems: 'center',
|
|
109
|
-
height: '100%',
|
|
110
|
-
}), [cellAlign]);
|
|
111
|
-
|
|
112
|
-
const badgeStyle = React.useMemo(() => ({
|
|
113
|
-
backgroundColor: computedBgColor,
|
|
114
|
-
color: computedTextColor,
|
|
115
|
-
borderRadius: '20px',
|
|
116
|
-
padding: '2px 8px',
|
|
117
|
-
minWidth: `${minWidth}px`,
|
|
118
|
-
fontSize: `${fontSize}px`,
|
|
119
|
-
fontWeight: '500',
|
|
120
|
-
textAlign: 'center',
|
|
121
|
-
display: 'inline-block',
|
|
122
|
-
whiteSpace: 'nowrap',
|
|
123
|
-
overflow: 'hidden',
|
|
124
|
-
textOverflow: 'ellipsis',
|
|
125
|
-
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.1)',
|
|
126
|
-
lineHeight: '1.2',
|
|
127
|
-
height: 'auto',
|
|
128
|
-
}), [computedBgColor, computedTextColor, minWidth, fontSize]);
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<div style={containerStyle}>
|
|
132
|
-
<span style={badgeStyle}>
|
|
133
|
-
{displayText}
|
|
134
|
-
</span>
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// React.memo optimalizace pro AG-Grid renderer
|
|
140
|
-
// ✅ PERFORMANCE FIX: colDef NESMÍ být v kritických props!
|
|
141
|
-
const arePropsEqual = createMemoComparison(
|
|
142
|
-
['value', 'data'],
|
|
143
|
-
['colDef'],
|
|
144
|
-
false,
|
|
145
|
-
'StateRenderer'
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
export default React.memo(StateRenderer, arePropsEqual);
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createMemoComparison } from '@bit.rhplus/react-memo';
|
|
4
|
+
|
|
5
|
+
// Helper function moved outside component
|
|
6
|
+
function getValueByPath(obj, path) {
|
|
7
|
+
if (!obj || !path) return null;
|
|
8
|
+
return path.split('.').reduce((o, k) => (o && o[k] !== undefined) ? o[k] : null, obj);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function StateRenderer(props) {
|
|
12
|
+
const { data, value, colDef: { stateRendererParams = {} } = {} } = props;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if (!stateRendererParams) return null;
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
visibleGetter = () => true,
|
|
19
|
+
cellAlign = 'center',
|
|
20
|
+
bgColor, // Barva pozadí nebo funkce vracející barvu
|
|
21
|
+
color, // Barva textu nebo funkce vracející barvu (nový název)
|
|
22
|
+
textColor, // Barva textu (starý název - zpětná kompatibilita)
|
|
23
|
+
bgColorField, // Název pole obsahujícího barvu pozadí
|
|
24
|
+
colorField, // Název pole obsahujícího barvu textu (nový název)
|
|
25
|
+
textColorField, // Název pole obsahujícího barvu textu (starý název - zpětná kompatibilita)
|
|
26
|
+
displayField, // Pole pro zobrazení textu
|
|
27
|
+
minWidth = 80, // Minimální šířka kruhového pozadí
|
|
28
|
+
fontSize = 12, // Velikost fontu
|
|
29
|
+
showOnGroup = false, // Zda zobrazit na skupinových řádcích
|
|
30
|
+
} = stateRendererParams;
|
|
31
|
+
|
|
32
|
+
// Použít nový název s fallbackem na starý pro zpětnou kompatibilitu
|
|
33
|
+
const finalColor = color || textColor || 'white';
|
|
34
|
+
const finalColorField = colorField || textColorField;
|
|
35
|
+
|
|
36
|
+
const visibleResult = React.useMemo(() =>
|
|
37
|
+
visibleGetter ? visibleGetter(data) : true,
|
|
38
|
+
[visibleGetter, data]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const computedBgColor = React.useMemo(() => {
|
|
42
|
+
// Priorita: bgColorField (hodnota z dat) -> bgColor (funkce nebo string)
|
|
43
|
+
if (bgColorField && data) {
|
|
44
|
+
const fieldValue = getValueByPath(data, bgColorField);
|
|
45
|
+
if (fieldValue) return fieldValue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!bgColor) return '#666'; // default barva
|
|
49
|
+
|
|
50
|
+
// Pokud je bgColor funkce, zavolej ji s daty
|
|
51
|
+
if (typeof bgColor === 'function') {
|
|
52
|
+
return bgColor({ data, value, props });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Pokud je bgColor string/hodnota
|
|
56
|
+
return bgColor;
|
|
57
|
+
}, [bgColor, bgColorField, data, value, props]);
|
|
58
|
+
|
|
59
|
+
const computedTextColor = React.useMemo(() => {
|
|
60
|
+
// Priorita: colorField/textColorField (hodnota z dat) -> color/textColor (funkce nebo string)
|
|
61
|
+
if (finalColorField && data) {
|
|
62
|
+
const fieldValue = getValueByPath(data, finalColorField);
|
|
63
|
+
if (fieldValue) return fieldValue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!finalColor) return 'white'; // default barva
|
|
67
|
+
|
|
68
|
+
// Pokud je finalColor funkce, zavolej ji s daty
|
|
69
|
+
if (typeof finalColor === 'function') {
|
|
70
|
+
return finalColor({ data, value, props });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Pokud je finalColor string/hodnota
|
|
74
|
+
return finalColor;
|
|
75
|
+
}, [finalColor, finalColorField, data, value, props]);
|
|
76
|
+
|
|
77
|
+
const displayText = React.useMemo(() => {
|
|
78
|
+
if (displayField) {
|
|
79
|
+
// Pokud je displayField funkce
|
|
80
|
+
if (typeof displayField === 'function') {
|
|
81
|
+
return displayField({ data, value, props });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Pokud je displayField string (název pole)
|
|
85
|
+
if (typeof displayField === 'string') {
|
|
86
|
+
return data?.[displayField] || value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Fallback na value
|
|
91
|
+
return value || '';
|
|
92
|
+
}, [displayField, data, value, props]);
|
|
93
|
+
|
|
94
|
+
const showCondition = React.useMemo(() => {
|
|
95
|
+
const newItem = (data && data._rh_plus_ag_grid_new_item) || false;
|
|
96
|
+
return !newItem && (showOnGroup || !!data) && visibleResult;
|
|
97
|
+
}, [data, showOnGroup, visibleResult]);
|
|
98
|
+
|
|
99
|
+
if (!showCondition) return null;
|
|
100
|
+
|
|
101
|
+
// Pokud nemáme text k zobrazení, nevrací nic
|
|
102
|
+
if (!displayText) return null;
|
|
103
|
+
|
|
104
|
+
const containerStyle = React.useMemo(() => ({
|
|
105
|
+
width: '100%',
|
|
106
|
+
display: 'flex',
|
|
107
|
+
justifyContent: cellAlign === 'center' ? 'center' : cellAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
height: '100%',
|
|
110
|
+
}), [cellAlign]);
|
|
111
|
+
|
|
112
|
+
const badgeStyle = React.useMemo(() => ({
|
|
113
|
+
backgroundColor: computedBgColor,
|
|
114
|
+
color: computedTextColor,
|
|
115
|
+
borderRadius: '20px',
|
|
116
|
+
padding: '2px 8px',
|
|
117
|
+
minWidth: `${minWidth}px`,
|
|
118
|
+
fontSize: `${fontSize}px`,
|
|
119
|
+
fontWeight: '500',
|
|
120
|
+
textAlign: 'center',
|
|
121
|
+
display: 'inline-block',
|
|
122
|
+
whiteSpace: 'nowrap',
|
|
123
|
+
overflow: 'hidden',
|
|
124
|
+
textOverflow: 'ellipsis',
|
|
125
|
+
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.1)',
|
|
126
|
+
lineHeight: '1.2',
|
|
127
|
+
height: 'auto',
|
|
128
|
+
}), [computedBgColor, computedTextColor, minWidth, fontSize]);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<div style={containerStyle}>
|
|
132
|
+
<span style={badgeStyle}>
|
|
133
|
+
{displayText}
|
|
134
|
+
</span>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// React.memo optimalizace pro AG-Grid renderer
|
|
140
|
+
// ✅ PERFORMANCE FIX: colDef NESMÍ být v kritických props!
|
|
141
|
+
const arePropsEqual = createMemoComparison(
|
|
142
|
+
['value', 'data'],
|
|
143
|
+
['colDef'],
|
|
144
|
+
false,
|
|
145
|
+
'StateRenderer'
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
export default React.memo(StateRenderer, arePropsEqual);
|
|
@@ -8,41 +8,41 @@ import 'dayjs/locale/cs';
|
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
import Holidays from 'date-holidays';
|
|
10
10
|
dayjs.locale('cs');
|
|
11
|
-
const CalendarContainer = styled.div `
|
|
12
|
-
display: flex;
|
|
13
|
-
gap: 8px;
|
|
14
|
-
margin-bottom: 12px;
|
|
15
|
-
width: 900px;
|
|
16
|
-
justify-content: space-between;
|
|
17
|
-
|
|
18
|
-
.ant-picker-calendar {
|
|
19
|
-
max-width: 260px;
|
|
20
|
-
flex: 1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.ant-picker-calendar-header {
|
|
24
|
-
padding: 8px 12px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.ant-picker-cell-selected .ant-picker-cell-inner {
|
|
28
|
-
background: transparent !important;
|
|
29
|
-
color: inherit !important;
|
|
30
|
-
font-weight: normal !important;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.ant-picker-cell-disabled {
|
|
34
|
-
pointer-events: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.ant-picker-cell-disabled .ant-picker-cell-inner {
|
|
38
|
-
color: rgba(0, 0, 0, 0.25) !important;
|
|
39
|
-
background: transparent !important;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.ant-picker-cell:not(.ant-picker-cell-in-view) .ant-picker-cell-inner {
|
|
43
|
-
color: rgba(0, 0, 0, 0.25) !important;
|
|
44
|
-
background: transparent !important;
|
|
45
|
-
}
|
|
11
|
+
const CalendarContainer = styled.div `
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 8px;
|
|
14
|
+
margin-bottom: 12px;
|
|
15
|
+
width: 900px;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
|
|
18
|
+
.ant-picker-calendar {
|
|
19
|
+
max-width: 260px;
|
|
20
|
+
flex: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ant-picker-calendar-header {
|
|
24
|
+
padding: 8px 12px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ant-picker-cell-selected .ant-picker-cell-inner {
|
|
28
|
+
background: transparent !important;
|
|
29
|
+
color: inherit !important;
|
|
30
|
+
font-weight: normal !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.ant-picker-cell-disabled {
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ant-picker-cell-disabled .ant-picker-cell-inner {
|
|
38
|
+
color: rgba(0, 0, 0, 0.25) !important;
|
|
39
|
+
background: transparent !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ant-picker-cell:not(.ant-picker-cell-in-view) .ant-picker-cell-inner {
|
|
43
|
+
color: rgba(0, 0, 0, 0.25) !important;
|
|
44
|
+
background: transparent !important;
|
|
45
|
+
}
|
|
46
46
|
`;
|
|
47
47
|
const BulkEditDatePicker = ({ value, onChange, onSubmit, onCancel, loading, format = 'DD.MM.YYYY', showTime = false, }) => {
|
|
48
48
|
const today = dayjs();
|
package/dist/index.js
CHANGED
|
@@ -740,6 +740,7 @@ const AgGrid = React.forwardRef((props, ref) => {
|
|
|
740
740
|
allGridPropsRef.current.gridId = props.gridId;
|
|
741
741
|
allGridPropsRef.current.id = props.id;
|
|
742
742
|
allGridPropsRef.current.gridName = props.gridName;
|
|
743
|
+
allGridPropsRef.current.getContextMenuItems = props.getContextMenuItems;
|
|
743
744
|
// ✅ Detekovat změny které VYŽADUJÍ re-render AG Gridu
|
|
744
745
|
React.useEffect(() => {
|
|
745
746
|
const rowDataChanged = prevRowDataRef.current !== props.rowData;
|