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
palette string <optional>

Use "default" to use the default HTML5 color palette, otherwise it will use KissJS custom palette.

value string <optional>

Initial color value

hideCode boolean <optional>

Set to true to hide the hexa color code

display string <optional>
width number | string <optional>

A number (in pixels) or any valid CSS value

minWidth * <optional>

A number (in pixels) or any valid CSS value

labelWidth * <optional>

A number (in pixels) or any valid CSS value

height * <optional>

A number (in pixels) or any valid CSS value

fieldWidth * <optional>

A number (in pixels) or any valid CSS value

fieldHeight * <optional>

A number (in pixels) or any valid CSS value

colorWidth * <optional>

Color selector width

colorHeight * <optional>

Color selector height

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 40

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

# clearValue()

Clear the field value

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

this

# getLabel() → {string}

Get the field label

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

string

# getLabelPosition() → {string}

Get the label position

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

"left" | "right" | "top"

string

# getValue() → {string}

Get the field value

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

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 451

this

# setInvalid()

Change the style when the field is invalid

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

this

# setLabel(newLabel)

Set the field label

Parameters:
Name Type Description
newLabel string

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

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 484

this

# setLabelWidth(width)

Set the label width

Parameters:
Name Type Description
width *

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

this

# setValid()

Remove the invalid style

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

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 283

this

# setWidth(width)

Set the field width

Parameters:
Name Type Description
width *

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

this

# validate() → {boolean}

Validate the field value against validation rules

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

boolean