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

labelFontSize string <optional>

Any valid CSS value

labelFontWeight string <optional>

Any valid CSS value

labelColor string <optional>

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>
record object <optional>

The record to bind the field to. This will automatically update the record when the field value changes, and the field will listen to database changes on the record.

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

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 325

this

# getLabel() → {string}

Get the field label

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

string

# getLabelPosition() → {string}

Get the label position

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

"left" | "right" | "top"

string

# getValue() → {string}

Get the field value

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

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 457

this

# setInvalid()

Change the style when the field is invalid

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

this

# setLabel(newLabel)

Set the field label

Parameters:
Name Type Description
newLabel string

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

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 490

this

# setLabelWidth(width)

Set the label width

Parameters:
Name Type Description
width *

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

this

# setValid()

Remove the invalid style

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

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 289

this

# setWidth(width)

Set the field width

Parameters:
Name Type Description
width *

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

this

# validate() → {boolean}

Validate the field value against validation rules

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

boolean
new Color

Methods