@visactor/vrender-components
Version:
components library for dp visualization
43 lines (37 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.getRichTextAttribute = exports.mergeRowAttrs = void 0;
const vutils_1 = require("@visactor/vutils"), mergeRowAttrs = (target, ...sources) => {
const shapeList = [ target.shape, ...sources.map((s => null == s ? void 0 : s.shape)) ], keyList = [ target.key, ...sources.map((s => null == s ? void 0 : s.key)) ], valueList = [ target.value, ...sources.map((s => null == s ? void 0 : s.value)) ];
return (0, vutils_1.merge)(target, ...sources, {
shape: shapeList.every(vutils_1.isNil) ? void 0 : (0, vutils_1.merge)({}, ...shapeList),
key: keyList.every(vutils_1.isNil) ? void 0 : (0, vutils_1.merge)({}, ...keyList),
value: valueList.every(vutils_1.isNil) ? void 0 : (0, vutils_1.merge)({}, ...valueList)
});
};
exports.mergeRowAttrs = mergeRowAttrs;
const getRichTextAttribute = attr => {
const {width: width, height: height, wordBreak: wordBreak = "break-word", textAlign: textAlign, textBaseline: textBaseline, text: text} = attr;
return Array.isArray(text) ? {
width: width,
height: height,
wordBreak: wordBreak,
textAlign: textAlign,
textBaseline: textBaseline,
singleLine: !1,
textConfig: (0, vutils_1.array)(text).map((text => Object.assign(Object.assign({}, attr), {
text: text
})))
} : {
width: width,
height: height,
wordBreak: wordBreak,
textAlign: textAlign,
textBaseline: textBaseline,
singleLine: !1,
textConfig: null == text ? void 0 : text.text
};
};
exports.getRichTextAttribute = getRichTextAttribute;
//# sourceMappingURL=util.js.map