@@ -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+ isItemInvalid,
87+ sticker,
88+ symbol,
89+ title,
90+ titleRenderer,
91+ tooltipText,
92+ } = schema ;
8393
8494 const SelectionInput =
8595 selectionType === 'single' ? ClayRadio : ClayCheckbox ;
@@ -94,32 +104,47 @@ const ListItem = forwardRef<HTMLLIElement, any>(
94104 active : selectedItemsValue ?. includes ( itemId ) ,
95105 } ) ,
96106 flex : true ,
107+ ...clayListItemProps
97108 } ;
98109
110+ const invalid =
111+ isItemInvalid && item [ isItemInvalid ] === true && tooltipText ;
112+
99113 return (
100- < ClayList . Item
101- { ...props }
102- ref = { ref }
103- >
104- { ! selectable ? (
114+ < ClayList . Item { ...props } ref = { ref } >
115+ { selectable && (
105116 < ClayList . ItemField className = "justify-content-center selection-control" >
106- < SelectionInput
107- checked = {
108- selectedItemsValue
109- ? selectedItemsValue
110- . map ( ( element ) => String ( element ) )
111- . includes ( String ( itemId ) )
112- : false
113- }
114- onChange = { ( ) => {
115- onItemSelectionChange ( item ) ;
116- } }
117- value = { itemId }
118- />
117+ < ClaySticker displayType = "unstyled" >
118+ < SelectionInput
119+ checked = {
120+ selectedItemsValue
121+ ? selectedItemsValue
122+ . map ( ( element ) =>
123+ String ( element )
124+ )
125+ . includes ( String ( itemId ) )
126+ : false
127+ }
128+ onChange = { ( ) => {
129+ onItemSelectionChange ( item ) ;
130+ } }
131+ value = { itemId }
132+ />
133+ </ ClaySticker >
134+ </ ClayList . ItemField >
135+ ) }
136+
137+ { invalid && (
138+ < ClayList . ItemField >
139+ < ClayTooltipProvider >
140+ < span title = { item [ tooltipText ] } >
141+ < ClaySticker displayType = "warning" >
142+ < ClayIcon symbol = "exclamation-circle" />
143+ </ ClaySticker >
144+ </ span >
145+ </ ClayTooltipProvider >
119146 </ ClayList . ItemField >
120- ) :
121- < ClayList . ItemField className = "justify-content-center selection-control" > </ ClayList . ItemField >
122- }
147+ ) }
123148
124149 { image && item [ image ] ? (
125150 < ClayList . ItemField >
@@ -160,7 +185,7 @@ const ListItem = forwardRef<HTMLLIElement, any>(
160185 className = "justify-content-center"
161186 expand
162187 onClick = { ( ) => {
163- if ( selectable ) {
188+ if ( selectable && ! invalid ) {
164189 onItemSelectionChange ( item , true ) ;
165190 }
166191 } }
@@ -178,28 +203,30 @@ const ListItem = forwardRef<HTMLLIElement, any>(
178203 ) }
179204 </ ClayList . ItemField >
180205
181- < ClayList . ItemField >
182- { ( itemsActions || item . actionDropdownItems ) && (
206+ { ( itemsActions || item . actionDropdownItems ) && (
207+ < ClayList . ItemField >
183208 < Actions
184209 actions = { itemsActions || item . actionDropdownItems }
185210 itemData = { item }
186211 itemId = { itemId }
187212 items = { items }
188213 onItemSelectionChange = { onItemSelectionChange }
189214 />
190- ) }
191- </ ClayList . ItemField >
215+ </ ClayList . ItemField >
216+ ) }
192217 </ ClayList . Item >
193218 ) ;
194219 }
195220) ;
196221
197222const ListItemOptionalDropTarget = ( {
223+ clayListItemProps,
198224 item,
199225 items,
200226 onItemSelectionChange,
201227 schema,
202228} : {
229+ clayListItemProps ?: object ,
203230 item : any ;
204231 items : any [ ] ;
205232 onItemSelectionChange : Function ;
@@ -213,10 +240,11 @@ const ListItemOptionalDropTarget = ({
213240
214241 const props = {
215242 className,
243+ clayListItemProps,
216244 item,
217245 items,
218246 onItemSelectionChange,
219- ref :dropRef ,
247+ ref : dropRef ,
220248 schema,
221249 } ;
222250
0 commit comments