5.0 KiB
PropertyStack
Extends PropertyComposite
Properties
previewBoolean? Indicate if the layer should display a preview.layerSeparator(String | RegExp)? The separator used to split layer values.layerJoinString? Value used to join layer values.layerLabelFunction? Custom logic for creating layer labels.layerLabel: (layer) => { const values = layer.getValues(); return `A: ${values['prop-a']} B: ${values['prop-b']}`; }emptyValue(String | Function)? Empty value to apply when all layers are removed.// use simple string emptyValue: 'inherit', // or a function for a custom style object emptyValue: () => ({ color: 'unset', width: 'auto' }),
getLayers
Get all available layers.
hasLayers
Check if the property has layers.
Returns Boolean
getLayer
Get layer by index.
Parameters
indexNumber Layer index position. (optional, default0)
Examples
// Get the first layer
const layerFirst = property.getLayer(0);
// Get the last layer
const layers = this.getLayers();
const layerLast = property.getLayer(layers.length - 1);
Returns (Layer | null)
getSelectedLayer
Get selected layer.
selectLayer
Select layer. Without a selected layer any update made on inner properties has no effect.
Parameters
layerLayer Layer to select
Examples
const layer = property.getLayer(0);
property.selectLayer(layer);
selectLayerAt
Select layer by index.
Parameters
indexNumber Index of the layer to select. (optional, default0)
Examples
property.selectLayerAt(1);
moveLayer
Move layer by index.
Parameters
Examples
const layer = property.getLayer(1);
property.moveLayer(layer, 0);
addLayer
Add new layer to the stack.
Parameters
-
propsObject Custom property values to use in a new layer. (optional, default{}) -
optsObject Options (optional, default{})opts.atNumber? Position index (by default the layer will be appended at the end).
Examples
// Add new layer at the beginning of the stack with custom values
property.addLayer({ 'sub-prop1': 'value1', 'sub-prop2': 'value2' }, { at: 0 });
Returns Layer Added layer.
removeLayer
Remove layer.
Parameters
layerLayer Layer to remove.
Examples
const layer = property.getLayer(0);
property.removeLayer(layer);
Returns Layer Removed layer
removeLayerAt
Remove layer by index.
Parameters
indexNumber Index of the layer to remove (optional, default0)
Examples
property.removeLayerAt(0);
Returns (Layer | null) Removed layer
getLayerLabel
Get the layer label. The label can be customized with the layerLabel property.
Parameters
layerLayer
Examples
const layer = this.getLayer(1);
const label = this.getLayerLabel(layer);
Returns String
getStyleFromLayer
Get style object from the layer.
Parameters
Returns Object Style object
getStylePreview
Get preview style object from the layer.
If the property has preview: false the returned object will be empty.
Parameters
Returns Object Style object
getLayerSeparator
Get layer separator.
Returns RegExp
hasEmptyValue
Check if the property is with an empty value.
Returns Boolean