UNPKG

react-konva-grid

Version:

Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets

46 lines 2.21 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Cell = exports.CellRenderer = void 0; const react_1 = __importStar(require("react")); const react_konva_1 = require("react-konva"); /** * Default cell component * @param props */ const Cell = react_1.memo((props) => { const { x, y, width, height, value, fill = "white", strokeWidth = 0.5, stroke = "#aaa", align = "center", verticalAlign = "middle", textColor = "#333", padding = 5, fontFamily = "Arial, sans-serif", fontSize = 12, onClick, children, } = props; return (react_1.default.createElement(react_konva_1.Group, { onClick: onClick }, react_1.default.createElement(react_konva_1.Rect, { x: x, y: y, height: height, width: width, fill: fill, stroke: stroke, strokeWidth: strokeWidth, shadowForStrokeEnabled: false }), react_1.default.createElement(react_konva_1.Text, { x: x, y: y, height: height, width: width, text: value, fill: textColor, verticalAlign: verticalAlign, align: align, fontFamily: fontFamily, fontSize: fontSize, padding: padding }), children)); }); exports.Cell = Cell; /** * Default CellRenderer * @param props */ const CellRenderer = (props) => { return react_1.default.createElement(Cell, Object.assign({}, props)); }; exports.CellRenderer = CellRenderer; exports.default = CellRenderer; //# sourceMappingURL=Cell.js.map