40 lines
1020 B
TypeScript
40 lines
1020 B
TypeScript
import type { CellRendererProps } from 'tui-grid/types/renderer';
|
|
|
|
export class ConditionIconButtonRenderer {
|
|
el: HTMLElement;
|
|
|
|
constructor(props: CellRendererProps) {
|
|
const { options } = props.columnInfo.renderer;
|
|
const data = props.grid.getRow(props.rowKey);
|
|
|
|
if (options?.condition(data)) {
|
|
const el = document.createElement('a');
|
|
// @ts-ignore
|
|
const { icon } = options;
|
|
el.innerHTML = `
|
|
<svg focusable="false" data-icon="${icon.name}" width="1em" height="2em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896">
|
|
<path d="${icon.icon.children[0].attrs.d}" />
|
|
</svg>
|
|
`;
|
|
el.className = 'ant-btn ant-btn-primary';
|
|
el.onclick = () => options?.onClick(data);
|
|
|
|
this.el = el;
|
|
} else {
|
|
this.el = document.createElement('span');
|
|
}
|
|
}
|
|
|
|
beforeDestroy(): void {}
|
|
|
|
focused(): void {}
|
|
|
|
getElement(): Element {
|
|
return this.el;
|
|
}
|
|
|
|
mounted(parent: HTMLElement): void {}
|
|
|
|
render(props: CellRendererProps): void {}
|
|
}
|