@zenuinebit/barcode-react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZenuineBit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,10 @@
1
- # Temporary Holding Version
1
+ # @zenuinebit/barcode-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ```tsx
4
+ import { Barcode } from "@zenuinebit/barcode-react";
5
+
6
+ <Barcode value="INV-2026-0001" />
7
+ <Barcode value="590123412345" format="ean13" />
8
+ ```
9
+
10
+ React component for [`@zenuinebit/barcode`](../barcode). It throws on values the format cannot encode (non-ASCII for Code 128, wrong length or check digit for EAN-13), so wrap it in an error boundary when the input is user-supplied.
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Barcode: () => Barcode
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_react = require("react");
27
+ var import_barcode = require("@zenuinebit/barcode");
28
+ var import_jsx_runtime = require("react/jsx-runtime");
29
+ function Barcode({ value, format = "code128", title, className, style, ...options }) {
30
+ const { moduleWidth, height, margin, color, background } = options;
31
+ const svg = (0, import_react.useMemo)(
32
+ () => (0, import_barcode.toSVG)(value, format, { moduleWidth, height, margin, color, background }),
33
+ [value, format, moduleWidth, height, margin, color, background]
34
+ );
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
36
+ "span",
37
+ {
38
+ role: "img",
39
+ "aria-label": title ?? value,
40
+ className,
41
+ style: { display: "inline-block", lineHeight: 0, ...style },
42
+ dangerouslySetInnerHTML: { __html: svg }
43
+ }
44
+ );
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ Barcode
49
+ });
@@ -0,0 +1,16 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties } from 'react';
3
+ import { BarcodeOptions, BarcodeFormat } from '@zenuinebit/barcode';
4
+ export { BarcodeFormat, BarcodeOptions } from '@zenuinebit/barcode';
5
+
6
+ interface BarcodeProps extends BarcodeOptions {
7
+ value: string;
8
+ format?: BarcodeFormat;
9
+ title?: string;
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ }
13
+ /** Renders a Code 128 or EAN-13 barcode. Invalid values throw, so wrap in an error boundary if input is user-supplied. */
14
+ declare function Barcode({ value, format, title, className, style, ...options }: BarcodeProps): react.JSX.Element;
15
+
16
+ export { Barcode, type BarcodeProps };
@@ -0,0 +1,16 @@
1
+ import * as react from 'react';
2
+ import { CSSProperties } from 'react';
3
+ import { BarcodeOptions, BarcodeFormat } from '@zenuinebit/barcode';
4
+ export { BarcodeFormat, BarcodeOptions } from '@zenuinebit/barcode';
5
+
6
+ interface BarcodeProps extends BarcodeOptions {
7
+ value: string;
8
+ format?: BarcodeFormat;
9
+ title?: string;
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ }
13
+ /** Renders a Code 128 or EAN-13 barcode. Invalid values throw, so wrap in an error boundary if input is user-supplied. */
14
+ declare function Barcode({ value, format, title, className, style, ...options }: BarcodeProps): react.JSX.Element;
15
+
16
+ export { Barcode, type BarcodeProps };
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ // src/index.tsx
2
+ import { useMemo } from "react";
3
+ import { toSVG } from "@zenuinebit/barcode";
4
+ import { jsx } from "react/jsx-runtime";
5
+ function Barcode({ value, format = "code128", title, className, style, ...options }) {
6
+ const { moduleWidth, height, margin, color, background } = options;
7
+ const svg = useMemo(
8
+ () => toSVG(value, format, { moduleWidth, height, margin, color, background }),
9
+ [value, format, moduleWidth, height, margin, color, background]
10
+ );
11
+ return /* @__PURE__ */ jsx(
12
+ "span",
13
+ {
14
+ role: "img",
15
+ "aria-label": title ?? value,
16
+ className,
17
+ style: { display: "inline-block", lineHeight: 0, ...style },
18
+ dangerouslySetInnerHTML: { __html: svg }
19
+ }
20
+ );
21
+ }
22
+ export {
23
+ Barcode
24
+ };
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@zenuinebit/barcode-react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "React component for Code 128 and EAN-13 barcodes.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "sideEffects": false,
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "dependencies": {
25
+ "@zenuinebit/barcode": "^0.1.0"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=18"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^18.3.0",
32
+ "@types/react-dom": "^18.3.0",
33
+ "react": "^18.3.1",
34
+ "react-dom": "^18.3.1"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup src/index.tsx --format esm,cjs --dts --clean",
38
+ "test": "vitest run",
39
+ "typecheck": "tsc --noEmit"
40
+ }
6
41
  }