es-grid-template
Version:
es-grid-template
48 lines • 1.92 kB
JavaScript
import React from 'react';
import styled from 'styled-components';
import { icons } from "../../common-views";
import { internals } from "../../internals";
import { makeRecursiveMapper } from "../../utils";
const HeaderCellWithTips = styled.div.withConfig({
displayName: "HeaderCellWithTips",
componentId: "es-grid-template__sc-dlllyl-0"
})(["display:flex;align-items:center;.tip-icon-wrapper{margin-left:2px;}.tip-icon{display:flex;fill:currentColor;}"]);
export function tips() {
return function tipsSteap(pipeline) {
const Balloon = pipeline.ctx.components.Balloon;
const Tooltip = pipeline.ctx.components.Tooltip;
if (Balloon == null && Tooltip == null) {
throw new Error('使用 tips 之前需要通过 pipeline context 设置 components.Balloon / components.Tooltip');
}
return pipeline.mapColumns(makeRecursiveMapper(col => {
if (!col.features?.tips) {
return col;
}
const justifyContent = col.textAlign === 'right' ? 'flex-end' : col.textAlign === 'center' ? 'center' : 'flex-start';
return {
...col,
title: /*#__PURE__*/React.createElement(HeaderCellWithTips, {
style: {
justifyContent
}
}, internals.safeRenderHeader(col), Balloon ?
/*#__PURE__*/
// fusion/hippo
React.createElement(Balloon, {
closable: false,
trigger: /*#__PURE__*/React.createElement("div", {
className: "tip-icon-wrapper"
}, /*#__PURE__*/React.createElement(icons.Info, {
className: "tip-icon"
}))
}, col.features.tips) : /*#__PURE__*/React.createElement(Tooltip, {
title: col.features.tips
}, /*#__PURE__*/React.createElement("div", {
className: "tip-icon-wrapper"
}, /*#__PURE__*/React.createElement(icons.Info, {
className: "tip-icon"
}))))
};
}));
};
}