UNPKG

@darthmaim/react-barcode

Version:
16 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Barcode = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const barcode_1 = require("@darthmaim/barcode"); const Barcode = ({ value, height = 70, width, flat = false }) => { const encoded = (0, barcode_1.encode)(value); let left = 0; return ((0, jsx_runtime_1.jsx)("svg", Object.assign({ viewBox: `0 0 ${encoded.width} 70`, height: height, width: width, textAnchor: "middle", dominantBaseline: "bottom", fontSize: 11, fontFamily: "monospace", shapeRendering: "crispedges" }, { children: encoded.groups.map((group, index) => { const groupElement = (group.type !== 'quietZone' || group.text) && ((0, jsx_runtime_1.jsxs)("g", { children: [group.type !== 'quietZone' && group.data.split('').map((bar, index) => bar === '1' ? ((0, jsx_runtime_1.jsx)("rect", { x: left + index, y: 0, width: 1, height: group.type === 'marker' && !flat ? 66 : 60 }, index)) : null), group.text && ((0, jsx_runtime_1.jsx)("text", Object.assign({ x: left + group.width / 2, y: 69 }, { children: group.text })))] }, index)); left += group.width; return groupElement; }) }))); }; exports.Barcode = Barcode; //# sourceMappingURL=index.js.map