1- import {
2- BoolCodeControl ,
3- ButtonEventHandlerControl ,
4- InputLikeStyle ,
5- NameConfig ,
6- Section ,
7- UICompBuilder ,
8- hiddenPropertyView ,
9- sectionNames ,
10- showDataLoadingIndicatorsPropertyView ,
11- styleControl ,
12- withExposingConfigs
13- } from "@lowcoder-ee/index.sdk" ;
141import styled from "styled-components" ;
152import React , { useContext } from "react" ;
16- import { trans } from "i18n" ;
173import { Tag } from "antd" ;
184import { EditorContext } from "comps/editorState" ;
195import { PresetStatusColorTypes } from "antd/es/_util/colors" ;
206import { hashToNum } from "util/stringUtils" ;
217import { TagsCompOptionsControl } from "comps/controls/optionsControl" ;
228import { useCompClickEventHandler } from "@lowcoder-ee/comps/utils/useCompClickEventHandler" ;
9+ import { styleControl } from "@lowcoder-ee/comps/controls/styleControl" ;
10+ import { ButtonEventHandlerControl } from "@lowcoder-ee/comps/controls/eventHandlerControl" ;
11+ import { InputLikeStyle } from "@lowcoder-ee/comps/controls/styleControlConstants" ;
12+ import { BoolCodeControl } from "@lowcoder-ee/comps/controls/codeControl" ;
13+ import { UICompBuilder } from "@lowcoder-ee/comps/generators/uiCompBuilder" ;
14+ import { Section , sectionNames } from "lowcoder-design" ;
15+ import { NameConfig } from "@lowcoder-ee/comps/generators/withExposing" ;
16+ import { hiddenPropertyView , showDataLoadingIndicatorsPropertyView } from "@lowcoder-ee/comps/utils/propertyUtils" ;
17+ import { withExposingConfigs } from "@lowcoder-ee/comps/generators/withExposing" ;
2318
2419const colors = PresetStatusColorTypes ;
2520
2621// These functions are used for individual tag styling
2722function getTagColor ( tagText :any , tagOptions :any [ ] ) {
2823const foundOption = tagOptions . find ( ( option :{ label :any ; } ) => option . label === tagText ) ;
2924if ( foundOption ) {
30- if ( foundOption . colorType === "preset" ) {
25+ if ( foundOption . colorType === "default" ) {
26+ return undefined ;
27+ } else if ( foundOption . colorType === "preset" ) {
3128return foundOption . presetColor ;
3229} else if ( foundOption . colorType === "custom" ) {
3330return undefined ;
@@ -40,20 +37,32 @@ function getTagColor(tagText : any, tagOptions: any[]) {
4037
4138const getTagStyle = ( tagText :any , tagOptions :any [ ] , baseStyle :any = { } ) => {
4239const foundOption = tagOptions . find ( ( option :{ label :any ; } ) => option . label === tagText ) ;
40+
4341if ( 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+
4451const style :any = { ...baseStyle } ;
4552
4653if ( foundOption . colorType === "custom" ) {
4754style . backgroundColor = foundOption . color ;
4855style . color = foundOption . textColor ;
49- style . border = `1px solid${ foundOption . color } ` ;
5056}
5157
52- if ( foundOption . border ) {
53- style . borderColor = foundOption . border ;
54- if ( ! foundOption . colorType || foundOption . colorType !== "custom" ) {
55- style . border = `1px solid${ foundOption . border } ` ;
56- }
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" ;
5766}
5867
5968if ( foundOption . radius ) {
@@ -68,33 +77,36 @@ const getTagStyle = (tagText: any, tagOptions: any[], baseStyle: any = {}) => {
6877style . padding = foundOption . padding ;
6978}
7079
80+ if ( foundOption . width ) {
81+ style . width = foundOption . width ;
82+ }
83+
7184return style ;
7285}
73- return baseStyle ;
74- } ;
7586
76- function getTagIcon ( tagText :any , tagOptions :any [ ] ) {
77- const foundOption = tagOptions . find ( option => option . label === tagText ) ;
78- return foundOption ?foundOption . icon :undefined ;
79- }
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+ } ;
8093
8194const multiTags = ( function ( ) {
8295
83- const StyledTag = styled ( Tag ) < { $style :any , $bordered : boolean , $ customStyle :any } > `
96+ const StyledTag = styled ( Tag ) < { $style :any , $customStyle :any } > `
8497 display: flex;
8598 justify-content: center;
8699 align-items: center;
87- width: 100%;
100+ min-width: fit-content;
101+ width:${ ( props ) => props . $customStyle ?. width || 'auto' } ;
102+ max-width: 100px;
88103 background:${ ( props ) => props . $customStyle ?. backgroundColor || props . $style ?. background } ;
89104 color:${ ( props ) => props . $customStyle ?. color || props . $style ?. text } ;
90105 border-radius:${ ( props ) => props . $customStyle ?. borderRadius || props . $style ?. borderRadius } ;
91- border:${ ( props ) => {
92- if ( props . $customStyle ?. border ) return props . $customStyle . border ;
93- return props . $bordered ?`${ props . $style ?. borderStyle } ${ props . $style ?. borderWidth } ${ props . $style ?. border } ` :'none' ;
94- } } ;
106+ border:${ ( props ) => props . $customStyle ?. border || props . $style ?. border || '1px solid #d9d9d9' } ;
95107 padding:${ ( props ) => props . $customStyle ?. padding || props . $style ?. padding } ;
96108 margin:${ ( props ) => props . $customStyle ?. margin || props . $style ?. margin } ;
97- font-size:${ ( props ) => props . $style ?. textSize } ;
109+ font-size:${ ( props ) => props . $style ?. textSize || '8px' } ;
98110 font-weight:${ ( props ) => props . $style ?. fontWeight } ;
99111 cursor: pointer;
100112 ` ;
@@ -109,8 +121,6 @@ const multiTags = (function () {
109121options :TagsCompOptionsControl ,
110122style :styleControl ( InputLikeStyle , 'style' ) ,
111123onEvent :ButtonEventHandlerControl ,
112- borderless :BoolCodeControl ,
113- enableIndividualStyling :BoolCodeControl ,
114124} ;
115125
116126return new UICompBuilder ( childrenMap , ( props ) => {
@@ -120,20 +130,18 @@ const multiTags = (function () {
120130< StyledTagContainer >
121131{ props . options . map ( ( tag , index ) => {
122132
123- // Use individual styling only if enableIndividualStyling is true
124- const tagColor = props . enableIndividualStyling ?getTagColor ( tag . label , props . options ) :undefined ;
125- const tagIcon = props . enableIndividualStyling ?getTagIcon ( tag . label , props . options ) :tag . icon ;
126- 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 ) ;
127136
128137return (
129138< StyledTag
130139key = { `tag-${ index } ` }
131140$style = { props . style }
132- $bordered = { ! props . borderless }
133141$customStyle = { tagStyle }
134142icon = { tagIcon }
135143color = { tagColor }
136- onClick = { ( ) => handleClickEvent ( ) }
144+ onClick = { handleClickEvent }
137145>
138146{ tag . label }
139147</ StyledTag >
@@ -145,7 +153,7 @@ const multiTags = (function () {
145153. setPropertyViewFn ( ( children :any ) => {
146154return (
147155< >
148- < Section name = "Basic" >
156+ < Section name = { sectionNames . basic } >
149157{ children . options . propertyView ( { } ) }
150158</ Section >
151159
@@ -161,11 +169,6 @@ const multiTags = (function () {
161169useContext ( EditorContext ) . editorModeStatus
162170) && (
163171< Section name = { sectionNames . style } >
164- { children . enableIndividualStyling . propertyView ( {
165- label :trans ( "style.individualStyling" ) ,
166- tooltip :trans ( "style.individualStylingTooltip" )
167- } ) }
168- { children . borderless . propertyView ( { label :trans ( "style.borderless" ) } ) }
169172{ children . style . getPropertyView ( ) }
170173</ Section >
171174) }