| 8525 | var _tsxCreateElement = require("tsx-create-element"); |
| 8526 | var _controls = require("./controls"); |
| 8527 | const LegendView = (props)=>{ |
| 8528 | const rows = []; |
| 8529 | const addRow = (row, i)=>{ |
| 8530 | const fn = symbolMap[row.symbol.shape]; |
| 8531 | let jsx; |
| 8532 | if (fn) jsx = fn(row.symbol); |
| 8533 | else jsx = (0, _tsxCreateElement.createElement)("span", null, "x"); |
| 8534 | rows.push({ |
| 8535 | cells: [ |
| 8536 | { |
| 8537 | className: "symbol", |
| 8538 | content: jsx |
| 8539 | }, |
| 8540 | { |
| 8541 | className: "label", |
| 8542 | content: row.label, |
| 8543 | title: row.label |
| 8544 | } |
| 8545 | ] |
| 8546 | }); |
| 8547 | }; |
| 8548 | var sorted = Object.keys(props.legend.rows).sort((a, b)=>+a - +b); |
| 8549 | sorted.forEach((i)=>addRow(props.legend.rows[i], +i)); |
| 8550 | if (sorted.length) return (0, _tsxCreateElement.createElement)((0, _controls.Table), { |
| 8551 | rows: rows, |
| 8552 | rowClassName: "legend-row", |
| 8553 | onRowClick: (e, i)=>props.onClick(e, props.legend, i) |
| 8554 | }, props.legend.title !== undefined && (0, _tsxCreateElement.createElement)("tr", { |
| 8555 | tabIndex: props.onClick ? 0 : -1, |
| 8556 | onClick: (e)=>props.onClick(e, props.legend, null), |
| 8557 | onKeyUp: (e)=>{ |
| 8558 | if (e.key === (0, _controls.KeyCodes).ENTER && props.onClick) props.onClick(e, props.legend, null); |
| 8559 | } |
| 8560 | }, (0, _tsxCreateElement.createElement)("th", { |
| 8561 | colSpan: 2 |
| 8562 | }, props.legend.title))); |
| 8563 | }; |
| 8564 | const symbolMap = { |
| 8565 | square: function(symbol) { |
| 8566 | return (0, _tsxCreateElement.createElement)("div", { |