99 DroppableProvided ,
1010 DroppableStateSnapshot ,
1111} from "react-beautiful-dnd" ;
12- import { CollectionUtils } from "andculturecode-javascript-core" ;
12+ import { CollectionUtils , StringUtils } from "andculturecode-javascript-core" ;
1313import uuid from "uuid" ;
1414import {
1515 ListBoxProps ,
@@ -38,7 +38,7 @@ const COMPONENT_CLASS = `${ListBoxBaseClassName} c-drag-and-drop-list-box`;
3838// #region Interfaces
3939// -------------------------------------------------------------------------------------------------
4040
41- export interface DragAndDropListBoxProps < T extends any >
41+ export interface DragAndDropListBoxProps < T extends string | number = string >
4242 extends Omit < ListBoxProps < T > , "children" | "items" > {
4343 droppableId : string ;
4444 items : Array < ListBoxItem < T > > ;
@@ -51,14 +51,14 @@ export interface DragAndDropListBoxProps<T extends any>
5151// #region Component
5252// -------------------------------------------------------------------------------------------------
5353
54- const DragAndDropListBox = < T extends any > (
54+ export const DragAndDropListBox = < T extends string | number = string > (
5555 props : DragAndDropListBoxProps < T >
5656) : ReactElement < ListBoxProps < T > > | null => {
5757 const items = props . items ;
5858 const hasItems = CollectionUtils . hasValues ( items ) ;
5959
6060 // Short-circuit if no items in collection
61- if ( items != null && ! hasItems ) {
61+ if ( ! hasItems ) {
6262 if ( props . hideWhenNoItems ) {
6363 return null ;
6464 }
@@ -118,7 +118,7 @@ const DragAndDropListBox = <T extends any>(
118118 < React . Fragment >
119119 { itemProps . items . map ( ( item : ListBoxItem < T > , index : number ) => (
120120 < Draggable
121- draggableId = { ` ${ item . id } ` }
121+ draggableId = { item . id . toString ( ) }
122122 index = { index }
123123 key = { uuid . v4 ( ) } >
124124 { (
@@ -128,19 +128,19 @@ const DragAndDropListBox = <T extends any>(
128128 < div
129129 { ...provided . draggableProps }
130130 { ...provided . dragHandleProps }
131- ref = { provided . innerRef }
132131 className = { `${ ListBoxItemClassName } ${ cssIsDragging (
133132 snapshot
134133 ) } `}
134+ ref = { provided . innerRef }
135135 style = { provided . draggableProps . style } >
136136 < div className = "-drag-handle" >
137137 < Icon
138- type = { Icons . DragAndDrop }
139138 size = { IconSizes . Large }
139+ type = { Icons . DragAndDrop }
140140 />
141141 </ div >
142142 { // if
143- item . label != null && (
143+ StringUtils . hasValue ( item . label ) && (
144144 < div
145145 className = { `${ ListBoxItemClassName } __label` } >
146146 { item . label }
@@ -153,7 +153,6 @@ const DragAndDropListBox = <T extends any>(
153153 { // if
154154 props . onActionClick != null && (
155155 < Button
156- type = { ButtonTypes . Button }
157156 cssClassName = { `${ ListBoxItemClassName } __action` }
158157 onClick = { ( ) =>
159158 props . onActionClick ! (
@@ -162,7 +161,8 @@ const DragAndDropListBox = <T extends any>(
162161 )
163162 }
164163 size = { ButtonSizes . Small }
165- style = { ButtonStyles . TertiaryAlt } >
164+ style = { ButtonStyles . TertiaryAlt }
165+ type = { ButtonTypes . Button } >
166166 { props . actionText ?? "Action" }
167167 </ Button >
168168 ) }
@@ -187,10 +187,10 @@ const DragAndDropListBox = <T extends any>(
187187 ) => (
188188 < div
189189 { ...provided . droppableProps }
190- ref = { provided . innerRef }
191190 className = { `${ COMPONENT_CLASS } ${ cssIsDragging (
192191 snapshot
193- ) } `} >
192+ ) } `}
193+ ref = { provided . innerRef } >
194194 { // if
195195 hasItems && < DraggableItemList items = { items } /> }
196196 { provided . placeholder }
@@ -202,11 +202,3 @@ const DragAndDropListBox = <T extends any>(
202202} ;
203203
204204// #endregion Component
205-
206- // -------------------------------------------------------------------------------------------------
207- // #region Exports
208- // -------------------------------------------------------------------------------------------------
209-
210- export default DragAndDropListBox ;
211-
212- // #endregion Exports
0 commit comments