11import styled from "styled-components" ;
22import React , { useContext } from "react" ;
3- import { trans } from "i18n" ;
43import { Tag } from "antd" ;
54import { EditorContext } from "comps/editorState" ;
65import { PresetStatusColorTypes } from "antd/es/_util/colors" ;
@@ -23,7 +22,9 @@ const colors = PresetStatusColorTypes;
2322function getTagColor ( tagText :any , tagOptions :any [ ] ) {
2423const foundOption = tagOptions . find ( ( option :{ label :any ; } ) => option . label === tagText ) ;
2524if ( foundOption ) {
26- if ( foundOption . colorType === "preset" ) {
25+ if ( foundOption . colorType === "default" ) {
26+ return undefined ;
27+ } else if ( foundOption . colorType === "preset" ) {
2728return foundOption . presetColor ;
2829} else if ( foundOption . colorType === "custom" ) {
2930return undefined ;
@@ -36,20 +37,32 @@ function getTagColor(tagText : any, tagOptions: any[]) {
3637
3738const getTagStyle = ( tagText :any , tagOptions :any [ ] , baseStyle :any = { } ) => {
3839const foundOption = tagOptions . find ( ( option :{ label :any ; } ) => option . label === tagText ) ;
40+
3941if ( foundOption ) {
42+ // If colorType is "default", use ONLY component styles
43+ if ( foundOption . colorType === "default" ) {
44+ const style :any = { ...baseStyle } ;
45+ if ( baseStyle . borderWidth && baseStyle . border && baseStyle . borderStyle ) {
46+ style . border = `${ baseStyle . borderWidth } ${ baseStyle . borderStyle } ${ baseStyle . border } ` ;
47+ }
48+ return style ;
49+ }
50+
4051const style :any = { ...baseStyle } ;
4152
4253if ( foundOption . colorType === "custom" ) {
4354style . backgroundColor = foundOption . color ;
4455style . color = foundOption . textColor ;
45- style . border = `1px solid${ foundOption . color } ` ;
4656}
4757
48- if ( foundOption . border ) {
49- style . borderColor = foundOption . border ;
50- if ( ! foundOption . colorType || foundOption . colorType !== "custom" ) {
51- style . border = `1px solid${ foundOption . border } ` ;
52- }
58+ let borderStyle = foundOption . borderStyle || "none" ;
59+ let borderWidth = foundOption . borderWidth || "0px" ;
60+ let borderColor = foundOption . border || "none" ;
61+
62+ if ( borderStyle !== "none" ) {
63+ style . border = `${ borderWidth } ${ borderStyle } ${ borderColor } ` ;
64+ } else {
65+ style . border = "none" ;
5366}
5467
5568if ( foundOption . radius ) {
@@ -64,33 +77,36 @@ const getTagStyle = (tagText: any, tagOptions: any[], baseStyle: any = {}) => {
6477style . padding = foundOption . padding ;
6578}
6679
80+ if ( foundOption . width ) {
81+ style . width = foundOption . width ;
82+ }
83+
6784return style ;
6885}
69- return baseStyle ;
70- } ;
7186
72- function getTagIcon ( tagText :any , tagOptions :any [ ] ) {
73- const foundOption = tagOptions . find ( option => option . label === tagText ) ;
74- return foundOption ?foundOption . icon :undefined ;
75- }
87+ const style :any = { ...baseStyle } ;
88+ if ( baseStyle . borderWidth && baseStyle . border && baseStyle . borderStyle ) {
89+ style . border = `${ baseStyle . borderWidth } ${ baseStyle . borderStyle } ${ baseStyle . border } ` ;
90+ }
91+ return style ;
92+ } ;
7693
7794const multiTags = ( function ( ) {
7895
79- const StyledTag = styled ( Tag ) < { $style :any , $bordered : boolean , $ customStyle :any } > `
96+ const StyledTag = styled ( Tag ) < { $style :any , $customStyle :any } > `
8097 display: flex;
8198 justify-content: center;
8299 align-items: center;
83- width: 100%;
100+ min-width: fit-content;
101+ width:${ ( props ) => props . $customStyle ?. width || 'auto' } ;
102+ max-width: 100px;
84103 background:${ ( props ) => props . $customStyle ?. backgroundColor || props . $style ?. background } ;
85104 color:${ ( props ) => props . $customStyle ?. color || props . $style ?. text } ;
86105 border-radius:${ ( props ) => props . $customStyle ?. borderRadius || props . $style ?. borderRadius } ;
87- border:${ ( props ) => {
88- if ( props . $customStyle ?. border ) return props . $customStyle . border ;
89- return props . $bordered ?`${ props . $style ?. borderStyle } ${ props . $style ?. borderWidth } ${ props . $style ?. border } ` :'none' ;
90- } } ;
106+ border:${ ( props ) => props . $customStyle ?. border || props . $style ?. border || '1px solid #d9d9d9' } ;
91107 padding:${ ( props ) => props . $customStyle ?. padding || props . $style ?. padding } ;
92108 margin:${ ( props ) => props . $customStyle ?. margin || props . $style ?. margin } ;
93- font-size:${ ( props ) => props . $style ?. textSize } ;
109+ font-size:${ ( props ) => props . $style ?. textSize || '8px' } ;
94110 font-weight:${ ( props ) => props . $style ?. fontWeight } ;
95111 cursor: pointer;
96112 ` ;
@@ -105,8 +121,6 @@ const multiTags = (function () {
105121options :TagsCompOptionsControl ,
106122style :styleControl ( InputLikeStyle , 'style' ) ,
107123onEvent :ButtonEventHandlerControl ,
108- borderless :BoolCodeControl ,
109- enableIndividualStyling :BoolCodeControl ,
110124} ;
111125
112126return new UICompBuilder ( childrenMap , ( props ) => {
@@ -116,16 +130,14 @@ const multiTags = (function () {
116130< StyledTagContainer >
117131{ props . options . map ( ( tag , index ) => {
118132
119- // Use individual styling only if enableIndividualStyling is true
120- const tagColor = props . enableIndividualStyling ?getTagColor ( tag . label , props . options ) :undefined ;
121- const tagIcon = props . enableIndividualStyling ?getTagIcon ( tag . label , props . options ) :tag . icon ;
122- const tagStyle = props . enableIndividualStyling ?getTagStyle ( tag . label , props . options , props . style ) :{ } ;
133+ const tagColor = getTagColor ( tag . label , props . options ) ;
134+ const tagIcon = tag . icon ;
135+ const tagStyle = getTagStyle ( tag . label , props . options , props . style ) ;
123136
124137return (
125138< StyledTag
126139key = { `tag-${ index } ` }
127140$style = { props . style }
128- $bordered = { ! props . borderless }
129141$customStyle = { tagStyle }
130142icon = { tagIcon }
131143color = { tagColor }
@@ -157,11 +169,6 @@ const multiTags = (function () {
157169useContext ( EditorContext ) . editorModeStatus
158170) && (
159171< Section name = { sectionNames . style } >
160- { children . enableIndividualStyling . propertyView ( {
161- label :trans ( "style.individualStyling" ) ,
162- tooltip :trans ( "style.individualStylingTooltip" )
163- } ) }
164- { children . borderless . propertyView ( { label :trans ( "style.borderless" ) } ) }
165172{ children . style . getPropertyView ( ) }
166173</ Section >
167174) }