Class

Color

kiss.ui.Color(config)

The color field allows to pick a color and display its hexa color code.

Constructor

# new Color(config)

Its a Custom Web Component. Do not use the constructor directly with the new keyword. Instead, use one of the 3 following methods:

Create the Web Component and call its init method:

const myColorField = document.createElement("a-color").init(config)

Or use the shorthand for it:

const myColorField = createColorField({
 value: "#00aaee",
 height: "32px"
})

myColorField.render()
myColorField.getValue() // #00aaee
myColorField.setValue("#ff0000")
myColorField.getValue() // #ff0000

Or directly declare the config inside a container component:

const myPanel = createPanel({
  title: "My panel",
  items: [
      {
          type: "color",
          value: "#00aaee",
          width: "32px"
          height: "32px",
          hideCode: true
      }
  ]
})
myPanel.render()
Parameters:
Name Type Attributes Description
config object
value string <optional>

Initial color value

hideCode boolean <optional>

Set to true to hide the hexa color code

display string <optional>
width string <optional>
minWidth string <optional>
height string <optional>
padding string <optional>
margin string <optional>
border string <optional>
borderStyle string <optional>
borderWidth string <optional>
borderColor string <optional>
borderRadius string <optional>
boxShadow string <optional>
readOnly boolean <optional>

View Source client/ui/fields/color.js, line 34

this

Generated markup

<a-color class="a-color">
 <label class="field-label"></label>
 <div class="field-color-container">
     <div class="field-color-palette"></div>
     <div class="field-color-input"></div>
 </div>
</a-color

Methods

# getLabel() → {string}

Get the field label

View Source client/ui/fields/color.js, line 406

string

# getLabelPosition() → {string}

Get the label position

View Source client/ui/fields/color.js, line 451

"left" | "right" | "top"

string

# getValue() → {string}

Get the field value

View Source client/ui/fields/color.js, line 383

The field hex color value. Ex: #00aaee

string

# setFieldWidth(width)

Set the color selector field width

Parameters:
Name Type Description
width *

View Source client/ui/fields/color.js, line 428

this

# setInvalid()

Change the style when the field is invalid

View Source client/ui/fields/color.js, line 357

this

# setLabel(newLabel)

Set the field label

Parameters:
Name Type Description
newLabel string

View Source client/ui/fields/color.js, line 393

this

# setLabelPosition(position)

Set label position

Parameters:
Name Type Description
position string

"left" (default) | "right" | "top" | "bottom"

View Source client/ui/fields/color.js, line 461

this

# setLabelWidth(width)

Set the label width

Parameters:
Name Type Description
width *

View Source client/ui/fields/color.js, line 440

this

# setValid()

Remove the invalid style

View Source client/ui/fields/color.js, line 346

this

# setValue(color, rawUpdateopt)

Set the fieldl value

Parameters:
Name Type Attributes Description
color string

Hex color like #aa00ee

rawUpdate boolean <optional>

If true, it doesn't update the associated record and doesn't trigger "change" event

View Source client/ui/fields/color.js, line 277

this

# setWidth(width)

Set the field width

Parameters:
Name Type Description
width *

View Source client/ui/fields/color.js, line 416

this

# validate() → {boolean}

Validate the field value against validation rules

View Source client/ui/fields/color.js, line 330

boolean