(params?: {
firstColumnLeftPadding?: number;
})
| 73 | }; |
| 74 | |
| 75 | export const createRenderChipCell = (params?: { |
| 76 | firstColumnLeftPadding?: number; |
| 77 | }): CustomRenderer<ChipCell> => ({ |
| 78 | kind: GridCellKind.Custom, |
| 79 | isMatch: (cell: CustomCell): cell is ChipCell => |
| 80 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 81 | (cell.data as any).kind === "chip-cell", |
| 82 | draw: (args, cell) => { |
| 83 | const { theme, rect, ctx } = args; |
| 84 | const { chips, color = "gray", variant } = cell.data; |
| 85 | |
| 86 | const chipGap = 8; |
| 87 | |
| 88 | const columnPadding = |
| 89 | typeof params?.firstColumnLeftPadding !== "undefined" && args.col === 1 |
| 90 | ? params.firstColumnLeftPadding |
| 91 | : getCellHorizontalPadding(); |
| 92 | |
| 93 | let chipLeft = rect.x + columnPadding; |
| 94 | |
| 95 | const interactables: Interactable[] = []; |
| 96 | |
| 97 | for (let i = 0; i < chips.length; i++) { |
| 98 | const { icon, iconFill, text = "", suffix, onClick } = chips[i] ?? {}; |
| 99 | |
| 100 | const { width, height, top } = drawChipWithIcon({ |
| 101 | args, |
| 102 | color, |
| 103 | text, |
| 104 | suffix, |
| 105 | left: chipLeft, |
| 106 | icon, |
| 107 | iconFill, |
| 108 | variant, |
| 109 | }); |
| 110 | |
| 111 | if (onClick) { |
| 112 | const arrowSpacing = 4; |
| 113 | const arrowLeft = chipLeft + width + arrowSpacing; |
| 114 | const arrowSize = 12; |
| 115 | |
| 116 | args.spriteManager.drawSprite( |
| 117 | "arrowUpRightRegular", |
| 118 | "normal", |
| 119 | ctx, |
| 120 | arrowLeft, |
| 121 | top + 6, |
| 122 | 12, |
| 123 | { |
| 124 | ...theme, |
| 125 | bgIconHeader: "white", |
| 126 | fgIconHeader: customColors.blue[70], |
| 127 | }, |
| 128 | ); |
| 129 | |
| 130 | interactables.push( |
| 131 | InteractableManager.createCellInteractable(args, { |
| 132 | id: generateUuid(), |
no test coverage detected