react-jsbarcode 0.2.3 → 0.4.1

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/Readme.md CHANGED
@@ -11,6 +11,10 @@
11
11
 
12
12
  This is a [React](https://reactjs.org) component wrapping up [jsbarcode](<[https://](https://github.com/lindell/JsBarcode)>). Written as a React functional component using React hooks. <ReactBarcode />
13
13
 
14
+ ## CodeSandbox Demo
15
+
16
+ [![Edit react-jsbarcode](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-jsbarcode-2659g?fontsize=14&hidenavigation=1&theme=dark)
17
+
14
18
  ## Installation
15
19
 
16
20
  using NPM
@@ -25,25 +29,31 @@ using yarn
25
29
  yarn add react-jsbarcode
26
30
  ```
27
31
 
32
+ using PNPM
33
+
34
+ ```bash
35
+ pnpm add react-jsbarcode
36
+ ```
37
+
28
38
  ## Usage
29
39
 
30
40
  - Basic usage
31
41
 
32
42
  ```tsx
33
- import ReactBarcode from 'react-jsbarcode';
43
+ import Barcode from 'react-jsbarcode';
34
44
 
35
45
  const App = () => {
36
- return <ReactBarcode value="ABC123" />;
46
+ return <Barcode value="ABC123" />;
37
47
  };
38
48
  ```
39
49
 
40
50
  - Advanced usage
41
51
 
42
52
  ```tsx
43
- import ReactBarcode from 'react-jsbarcode';
53
+ import Barcode from 'react-jsbarcode';
44
54
 
45
55
  const App = () => {
46
- return <ReactBarcode value="ABC123" options={{ format: 'code128' }} renderer="svg" />;
56
+ return <Barcode value="ABC123" options={{ format: 'code128' }} renderer="svg" />;
47
57
  };
48
58
  ```
49
59
 
@@ -52,3 +62,5 @@ For all options refer jsbarcode [wiki](https://github.com/lindell/JsBarcode/wiki
52
62
  ### Renderers
53
63
 
54
64
  JSBarcode supports rendering to SVG, image and canvas. Default renderer is 'svg'.
65
+
66
+ [![Edit react-jsbarcode](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-jsbarcode-2659g?fontsize=14&hidenavigation=1&theme=dark)
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ /// <reference types="react" />
2
2
  import { Options } from 'jsbarcode';
3
3
  export declare const enum Renderer {
4
4
  svg = "svg",
package/lib/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import * as React from 'react';
2
+ import { useRef, useEffect } from 'react';
3
3
 
4
4
  var barcodes = {};
5
5
 
@@ -3332,17 +3332,17 @@ if (typeof jQuery !== 'undefined') {
3332
3332
  var JsBarcode_1 = JsBarcode;
3333
3333
 
3334
3334
  const ReactBarcode = ({ style, className, value, options, renderer = "svg" }) => {
3335
- const containerRef = React.useRef(null);
3336
- React.useEffect(() => {
3335
+ const containerRef = useRef(null);
3336
+ useEffect(() => {
3337
3337
  JsBarcode_1(containerRef.current, value, options);
3338
3338
  }, [value, options, renderer]);
3339
3339
  switch (renderer) {
3340
3340
  case 'canvas':
3341
- return jsx("canvas", { ref: containerRef, style: style, className: className }, void 0);
3341
+ return jsx("canvas", { ref: containerRef, style: style, className: className });
3342
3342
  case 'image':
3343
- return jsx("img", { ref: containerRef, alt: "barcode", style: style, className: className }, void 0);
3343
+ return jsx("img", { ref: containerRef, alt: "barcode", style: style, className: className });
3344
3344
  default:
3345
- return jsx("svg", { ref: containerRef, style: style, className: className }, void 0);
3345
+ return jsx("svg", { ref: containerRef, style: style, className: className });
3346
3346
  }
3347
3347
  };
3348
3348