@@ -57,8 +57,8 @@ const TagsControl = codeControl<Array<string> | string>(
5757{ expectedType :"string | Array<string>" , codeType :"JSON" }
5858) ;
5959
60- function getTagColor ( tagText : any , tagOptions :any [ ] ) {
61- const foundOption = tagOptions . find ( ( option : { label : any ; } ) => option . label === tagText ) ;
60+ function getTagColor ( tagText : string , tagOptions :TagOption [ ] ) : string | undefined {
61+ const foundOption = tagOptions . find ( option => option . label === tagText ) ;
6262if ( foundOption ) {
6363if ( foundOption . colorType === "preset" ) {
6464return foundOption . presetColor ;
@@ -73,10 +73,10 @@ function getTagColor(tagText : any, tagOptions: any[]) {
7373return colors [ index ] ;
7474}
7575
76- function getTagStyle ( tagText :any , tagOptions :any [ ] ) {
77- const foundOption = tagOptions . find ( ( option : { label : any ; } ) => option . label === tagText ) ;
76+ function getTagStyle ( tagText :string , tagOptions :TagOption [ ] ) : React . CSSProperties {
77+ const foundOption = tagOptions . find ( option => option . label === tagText ) ;
7878if ( foundOption ) {
79- const style :any = { } ;
79+ const style :React . CSSProperties = { } ;
8080
8181// Handle color styling
8282if ( foundOption . colorType === "custom" ) {
@@ -113,11 +113,23 @@ function getTagStyle(tagText: any, tagOptions: any[]) {
113113return { } ;
114114}
115115
116- function getTagIcon ( tagText :any , tagOptions :any [ ] ) {
116+ function getTagIcon ( tagText :string , tagOptions :TagOption [ ] ) : React . ReactNode | undefined {
117117const foundOption = tagOptions . find ( option => option . label === tagText ) ;
118118return foundOption ?foundOption . icon :undefined ;
119119}
120120
121+ // Utility function to process comma-separated tags into individual tags
122+ function processTagItems ( tagItems :string [ ] ) :string [ ] {
123+ const result :string [ ] = [ ] ;
124+ tagItems . forEach ( ( item ) => {
125+ if ( item . split ( "," ) [ 1 ] ) {
126+ item . split ( "," ) . forEach ( ( tag ) => result . push ( tag ) ) ;
127+ }
128+ result . push ( item ) ;
129+ } ) ;
130+ return result ;
131+ }
132+
121133const childrenMap = {
122134text :TagsControl ,
123135tagColors :ColoredTagOptionControl ,
@@ -128,11 +140,25 @@ const getBaseValue: ColumnTypeViewFn<typeof childrenMap, string | string[], stri
128140props
129141) => props . text ;
130142
143+ interface TagOption {
144+ label :string ;
145+ colorType ?:"preset" | "custom" ;
146+ presetColor ?:string ;
147+ color ?:string ;
148+ textColor ?:string ;
149+ border ?:string ;
150+ radius ?:string ;
151+ margin ?:string ;
152+ padding ?:string ;
153+ icon ?:React . ReactNode ;
154+ onEvent ?:( eventType :string ) => void ;
155+ }
156+
131157type TagEditPropsType = {
132158value :string | string [ ] ;
133159onChange :( value :string | string [ ] ) => void ;
134160onChangeEnd :( ) => void ;
135- tagOptions :any [ ] ;
161+ tagOptions :TagOption [ ] ;
136162} ;
137163
138164export const Wrapper = styled . div `
@@ -240,16 +266,7 @@ export const TagStyled = styled(Tag)`
240266
241267const TagEdit = React . memo ( ( props :TagEditPropsType ) => {
242268const defaultTags = useContext ( TagsContext ) ;
243- const [ tags , setTags ] = useState ( ( ) => {
244- const result :string [ ] = [ ] ;
245- defaultTags . forEach ( ( item ) => {
246- if ( item . split ( "," ) [ 1 ] ) {
247- item . split ( "," ) . forEach ( ( tag ) => result . push ( tag ) ) ;
248- }
249- result . push ( item ) ;
250- } ) ;
251- return result ;
252- } ) ;
269+ const [ tags , setTags ] = useState ( ( ) => processTagItems ( defaultTags ) ) ;
253270const [ open , setOpen ] = useState ( false ) ;
254271const mountedRef = useRef ( true ) ;
255272
@@ -268,24 +285,16 @@ const TagEdit = React.memo((props: TagEditPropsType) => {
268285// Update tags when defaultTags changes
269286useEffect ( ( ) => {
270287if ( ! mountedRef . current ) return ;
271-
272- const result :string [ ] = [ ] ;
273- defaultTags . forEach ( ( item ) => {
274- if ( item . split ( "," ) [ 1 ] ) {
275- item . split ( "," ) . forEach ( ( tag ) => result . push ( tag ) ) ;
276- }
277- result . push ( item ) ;
278- } ) ;
279- setTags ( result ) ;
288+ setTags ( processTagItems ( defaultTags ) ) ;
280289} , [ defaultTags ] ) ;
281290
282291const handleSearch = useCallback ( ( value :string ) => {
283292if ( ! mountedRef . current ) return ;
284293
285294if ( defaultTags . findIndex ( ( item ) => item . includes ( value ) ) < 0 ) {
286- setTags ( [ ...defaultTags , value ] ) ;
295+ setTags ( [ ...processTagItems ( defaultTags ) , value ] ) ;
287296} else {
288- setTags ( defaultTags ) ;
297+ setTags ( processTagItems ( defaultTags ) ) ;
289298}
290299props . onChange ( value ) ;
291300} , [ defaultTags , props . onChange ] ) ;
@@ -426,17 +435,15 @@ export const ColumnTagsComp = (function () {
426435const tagStyle = getTagStyle ( tagText , tagOptions ) ;
427436
428437return (
429- < React . Fragment key = { `${ tag . split ( ' ' ) . join ( '_' ) } -${ index } ` } >
430- < TagStyled
431- color = { tagColor }
432- icon = { tagIcon }
433- key = { index }
434- style = { tagStyle }
435- onClick = { ( e ) => handleTagClick ( e , tagText ) }
436- >
437- { tagText }
438- </ TagStyled >
439- </ React . Fragment >
438+ < TagStyled
439+ key = { `${ tagText . split ( ' ' ) . join ( '_' ) } -${ index } ` }
440+ color = { tagColor }
441+ icon = { tagIcon }
442+ style = { tagStyle }
443+ onClick = { ( e ) => handleTagClick ( e , tagText ) }
444+ >
445+ { tagText }
446+ </ TagStyled >
440447) ;
441448} ) ;
442449return (