@@ -8,6 +8,7 @@ import ClayIcon from '@clayui/icon';
88import ClayLayout from '@clayui/layout' ;
99import ClayList from '@clayui/list' ;
1010import ClaySticker from '@clayui/sticker' ;
11+ import { ClayTooltipProvider } from '@clayui/tooltip' ;
1112import classNames from 'classnames' ;
1213import { getObjectValueFromPath } from 'frontend-js-web' ;
1314import React , { forwardRef , useContext } from 'react' ;
@@ -25,7 +26,6 @@ import {
2526 IView ,
2627} from '../../utils/types' ;
2728import ViewsContext from '../ViewsContext' ;
28- import Tooltip , { ClayTooltipProvider } from '@clayui/tooltip' ;
2929
3030const Title = ( {
3131 item,
@@ -57,12 +57,14 @@ const ListItem = forwardRef<HTMLLIElement, any>(
5757 (
5858 {
5959 className,
60+ clayListItemProps,
6061 item,
6162 items,
6263 onItemSelectionChange,
6364 schema,
6465 } : {
6566 className : string ;
67+ clayListItemProps : Object ;
6668 item : any ;
6769 items : any [ ] ;
6870 onItemSelectionChange : Function ;
@@ -78,8 +80,16 @@ const ListItem = forwardRef<HTMLLIElement, any>(
7880 selectionType,
7981 } = useContext ( FrontendDataSetContext ) ;
8082
81- const { description, image, sticker, symbol, title, titleRenderer} =
82- schema ;
83+ const {
84+ description,
85+ image,
86+ isItemValid,
87+ sticker,
88+ symbol,
89+ title,
90+ titleRenderer,
91+ tooltipText,
92+ } = schema ;
8393
8494 const SelectionInput =
8595 selectionType === 'single' ? ClayRadio : ClayCheckbox ;
@@ -94,14 +104,14 @@ const ListItem = forwardRef<HTMLLIElement, any>(
94104 active : selectedItemsValue ?. includes ( itemId ) ,
95105 } ) ,
96106 flex : true ,
107+ ...clayListItemProps ,
97108 } ;
98109
110+ const itemValid = isItemValid && item [ isItemValid ] === true ;
111+
99112 return (
100- < ClayList . Item
101- { ...props }
102- ref = { ref }
103- >
104- { ! selectable ? (
113+ < ClayList . Item { ...props } ref = { ref } >
114+ { selectable && (
105115 < ClayList . ItemField className = "justify-content-center selection-control" >
106116 < SelectionInput
107117 checked = {
@@ -117,9 +127,29 @@ const ListItem = forwardRef<HTMLLIElement, any>(
117127 value = { itemId }
118128 />
119129 </ ClayList . ItemField >
120- ) :
121- < ClayList . ItemField className = "justify-content-center selection-control" > </ ClayList . ItemField >
122- }
130+ ) }
131+
132+ { isItemValid && item [ isItemValid ] === false && tooltipText && (
133+ < ClayList . ItemField >
134+ < ClayTooltipProvider >
135+ < span title = { item [ tooltipText ] } >
136+ < ClaySticker displayType = "warning" >
137+ < ClayIcon symbol = "exclamation-circle" />
138+ </ ClaySticker >
139+ </ span >
140+ </ ClayTooltipProvider >
141+ </ ClayList . ItemField >
142+ ) }
143+
144+ { isItemValid && item [ isItemValid ] === true && (
145+ < ClayList . ItemField >
146+ < ClayTooltipProvider >
147+ < ClaySticker displayType = "unstyled" >
148+ < ClayIcon symbol = "catalog" />
149+ </ ClaySticker >
150+ </ ClayTooltipProvider >
151+ </ ClayList . ItemField >
152+ ) }
123153
124154 { image && item [ image ] ? (
125155 < ClayList . ItemField >
@@ -133,25 +163,22 @@ const ListItem = forwardRef<HTMLLIElement, any>(
133163 item [ symbol ] && (
134164 < ClayList . ItemField >
135165 < ClayTooltipProvider >
136- < span
137- className = "ml-1 text-secondary"
138- data-tooltip-align = "top"
139- title = { Liferay . Language . get (
140- 'no-visualization-modes-has-been-defined'
141- ) }
166+ < span
167+ className = "ml-1 text-secondary"
168+ data-tooltip-align = "top"
169+ title = { Liferay . Language . get (
170+ 'no-visualization-modes-has-been-defined'
171+ ) }
172+ >
173+ < ClaySticker
174+ { ...( sticker && item [ sticker ] ) }
142175 >
143- < ClaySticker { ...( sticker && item [ sticker ] ) } >
144- { item [ symbol ] && (
145- < ClayIcon symbol = { item [ symbol ] } />
146- ) }
147-
148- </ ClaySticker >
149- </ span >
150-
151-
152- </ ClayTooltipProvider >
153-
154-
176+ { item [ symbol ] && (
177+ < ClayIcon symbol = { item [ symbol ] } />
178+ ) }
179+ </ ClaySticker >
180+ </ span >
181+ </ ClayTooltipProvider >
155182 </ ClayList . ItemField >
156183 )
157184 ) }
@@ -178,28 +205,30 @@ const ListItem = forwardRef<HTMLLIElement, any>(
178205 ) }
179206 </ ClayList . ItemField >
180207
181- < ClayList . ItemField >
182- { ( itemsActions || item . actionDropdownItems ) && (
208+ { ( itemsActions || item . actionDropdownItems ) && (
209+ < ClayList . ItemField >
183210 < Actions
184211 actions = { itemsActions || item . actionDropdownItems }
185212 itemData = { item }
186213 itemId = { itemId }
187214 items = { items }
188215 onItemSelectionChange = { onItemSelectionChange }
189216 />
190- ) }
191- </ ClayList . ItemField >
217+ </ ClayList . ItemField >
218+ ) }
192219 </ ClayList . Item >
193220 ) ;
194221 }
195222) ;
196223
197224const ListItemOptionalDropTarget = ( {
225+ clayListItemProps,
198226 item,
199227 items,
200228 onItemSelectionChange,
201229 schema,
202230} : {
231+ clayListItemProps ?: object ;
203232 item : any ;
204233 items : any [ ] ;
205234 onItemSelectionChange : Function ;
@@ -213,10 +242,11 @@ const ListItemOptionalDropTarget = ({
213242
214243 const props = {
215244 className,
245+ clayListItemProps,
216246 item,
217247 items,
218248 onItemSelectionChange,
219- ref :dropRef ,
249+ ref : dropRef ,
220250 schema,
221251 } ;
222252
0 commit comments