import util from '../../util.js'; import _ from 'lodash'; import Q from 'q'; export default { type: 'charset', definedProperties: { _anchor: { get: function() { var box = this.container.getBBox(), matrix = this.transform().localMatrix; return { ax: box.x, ax2: box.x2, ay: matrix.y(0, this.partContainer.getBBox().cy) }; } } }, _render() { this.partContainer = this.container.group(); return Q.all(_.map(this.elements, part => { return part.render(this.partContainer.group()); })) .then(() => { util.spaceVertically(this.elements, { padding: 5 }); return this.renderLabeledBox(this.label, this.partContainer, { padding: 5 }); }); }, setup() { this.label = (this.properties.invert.textValue === '^') ? 'None of:' : 'One of:'; this.elements = _.unique(this.properties.parts.elements, part => { if (part.literal) { return part.literal; } else { return part.textValue; } }); } };