@@ -21,22 +21,22 @@ export interface ColorFieldProps extends Omit<TextFieldProps, "invisibleCharacte
2121 /**
2222 * What color weights should be included in the set of allowed colors.
2323 */
24- colorWeightFilter ?: ColorWeight [ ] ;
24+ includeColorWeight ?: ColorWeight [ ] ;
2525 /**
2626 * What palette groups should be included in the set of allowed colors.
2727 */
28- paletteGroupFilter ?: PaletteGroup [ ] ;
28+ includePaletteGroup ?: PaletteGroup [ ] ;
2929}
3030
3131/**
3232 * Color input field that provides resets from the configured color palette.
33- * Use `colorWeightFilter ` and `paletteGroupFilter ` to filter them.
33+ * Use `includeColorWeight ` and `includePaletteGroup ` to filter them.
3434 */
3535export const ColorField = ( {
3636 className = "" ,
3737 allowCustomColor = false ,
38- colorWeightFilter = [ 100 , 300 , 700 , 900 ] ,
39- paletteGroupFilter = [ "layout" ] ,
38+ includeColorWeight = [ 100 , 300 , 700 , 900 ] , // on default, we only include color weights that can have enough contrasts to black/white
39+ includePaletteGroup = [ "layout" ] ,
4040 defaultValue,
4141 value,
4242 onChange,
@@ -49,19 +49,19 @@ export const ColorField = ({
4949 let allowedPaletteColors , disableNativePicker , disabled ;
5050 const updateConfig = ( ) => {
5151 allowedPaletteColors = utils . getEnabledColorPropertiesFromPalette ( {
52- includePaletteGroup : paletteGroupFilter ,
53- includeColorWeight : colorWeightFilter ,
52+ includePaletteGroup : includePaletteGroup ,
53+ includeColorWeight : includeColorWeight ,
5454 minimalColorDistance : 0 , // we use all allowed colors, and do not check distances between them
5555 } ) ;
5656
5757 disableNativePicker =
58- colorWeightFilter . length > 0 && paletteGroupFilter . length > 0 && allowedPaletteColors . length > 0 ;
58+ includeColorWeight . length > 0 && includePaletteGroup . length > 0 && allowedPaletteColors . length > 0 ;
5959 disabled = ( ! disableNativePicker && ! allowCustomColor ) || otherTextFieldProps . disabled ;
6060 } ;
6161 updateConfig ( ) ;
6262 React . useEffect ( ( ) => {
6363 updateConfig ( ) ;
64- } , [ allowCustomColor , colorWeightFilter , paletteGroupFilter , otherTextFieldProps ] ) ;
64+ } , [ allowCustomColor , includeColorWeight , includePaletteGroup , otherTextFieldProps ] ) ;
6565
6666 React . useEffect ( ( ) => {
6767 setColorValue ( defaultValue || value || "#000000" ) ;
@@ -124,7 +124,7 @@ export const ColorField = ({
124124 < FieldSet >
125125 < TagList
126126 className = { `${ eccgui } -colorfield__palette ${ eccgui } -colorfield__palette--${
127- colorWeightFilter . length >= 3 ? colorWeightFilter . length * 2 : "8"
127+ includeColorWeight . length >= 3 ? includeColorWeight . length * 2 : "8"
128128 } col`}
129129 >
130130 { allowedPaletteColors ! . map ( ( color : [ string , string ] , idx : number ) => [
@@ -146,7 +146,7 @@ export const ColorField = ({
146146 </ Tooltip >
147147 </ RadioButton > ,
148148 // Looks like we cannot force some type of line break in the tag list via CSS only
149- ( idx + 1 ) % ( colorWeightFilter . length >= 3 ? colorWeightFilter . length * 2 : 8 ) ===
149+ ( idx + 1 ) % ( includeColorWeight . length >= 3 ? includeColorWeight . length * 2 : 8 ) ===
150150 0 && (
151151 < >
152152 < br className = { `${ eccgui } -colorfield__palette-linebreak` } />
@@ -167,7 +167,7 @@ export const ColorField = ({
167167
168168type calculateColorHashValueProps = Pick <
169169 ColorFieldProps ,
170- "allowCustomColor" | "colorWeightFilter " | "paletteGroupFilter "
170+ "allowCustomColor" | "includeColorWeight " | "includePaletteGroup "
171171> ;
172172
173173/**
@@ -178,17 +178,17 @@ ColorField.calculateColorHashValue = (
178178 text : string ,
179179 options : calculateColorHashValueProps = {
180180 allowCustomColor : false ,
181- colorWeightFilter : [ 100 , 300 , 700 , 900 ] ,
182- paletteGroupFilter : [ "layout" ] ,
181+ includeColorWeight : [ 100 , 300 , 700 , 900 ] ,
182+ includePaletteGroup : [ "layout" ] ,
183183 }
184184) => {
185185 const hash = utils . textToColorHash ( {
186186 text,
187187 options : {
188188 returnValidColorsDirectly : options . allowCustomColor as boolean ,
189189 enabledColors : utils . getEnabledColorsFromPalette ( {
190- includePaletteGroup : options . paletteGroupFilter ,
191- includeColorWeight : options . colorWeightFilter ,
190+ includePaletteGroup : options . includePaletteGroup ,
191+ includeColorWeight : options . includeColorWeight ,
192192 minimalColorDistance : 0 ,
193193 } ) ,
194194 } ,
0 commit comments