@progress/kendo-react-barcodes 7.2.4-develop.2 → 7.2.4-develop.4
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/Barcode.js +8 -0
- package/Barcode.mjs +95 -0
- package/BarcodeContext.js +8 -0
- package/BarcodeContext.mjs +14 -0
- package/BaseBarcode.js +8 -0
- package/BaseBarcode.mjs +137 -0
- package/QRCode.js +8 -0
- package/QRCode.mjs +96 -0
- package/dist/cdn/js/kendo-react-barcodes.js +8 -5
- package/index.d.mts +418 -5
- package/index.d.ts +418 -10
- package/index.js +8 -5
- package/index.mjs +11 -333
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +3 -3
- package/store/reducer.js +8 -0
- package/store/reducer.mjs +24 -0
- package/store/store.js +8 -0
- package/store/store.mjs +20 -0
- package/utils/common.js +8 -0
- package/utils/common.mjs +29 -0
- package/Barcode.d.ts +0 -53
- package/BarcodeContext.d.ts +0 -16
- package/BarcodeProps.d.ts +0 -65
- package/BaseBarcode.d.ts +0 -79
- package/BaseBarcodeProps.d.ts +0 -48
- package/QRCode.d.ts +0 -53
- package/QRCodeProps.d.ts +0 -77
- package/common/barcodes.d.ts +0 -8
- package/package-metadata.d.ts +0 -9
- package/store/reducer.d.ts +0 -14
- package/store/store.d.ts +0 -29
- package/types/barcode-text.d.ts +0 -36
- package/types/barcode-type.d.ts +0 -8
- package/types/border.interface.d.ts +0 -22
- package/types/dash-type.interface.d.ts +0 -8
- package/types/margin.interface.d.ts +0 -25
- package/types/padding.interface.d.ts +0 -25
- package/types/qrcode-encoding.d.ts +0 -8
- package/types/qrcode-error-correction.d.ts +0 -13
- package/types/qrcode-overlay.d.ts +0 -29
- package/types/render-mode.d.ts +0 -12
- package/types.d.ts +0 -14
- package/utils/common.d.ts +0 -8
package/Barcode.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),i=require("./BaseBarcode.js"),u=require("@progress/kendo-charts"),o=require("@progress/kendo-drawing"),p=require("@progress/kendo-react-common");function d(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const a=d(c);class l extends a.Component{constructor(){super(...arguments),this._baseBarcode=null,this.getTarget=()=>this,this.deriveOptionsFromParent=e=>Object.assign({},e,{background:this.props.background,border:this.props.border,checksum:this.props.checksum,color:this.props.color,height:this.props.height,padding:this.props.padding,text:this.props.text,type:this.props.type,value:this.props.value,width:this.props.width})}get barcodeInstance(){return this._baseBarcode!==null?this._baseBarcode.barcodeInstance:null}get surface(){return this._baseBarcode!==null?this._baseBarcode.surface:null}get element(){return this._baseBarcode!==null?this._baseBarcode.element:null}render(){const{children:e,className:t,...s}=this.props;return a.createElement(i.BaseBarcode,{...s,deriveOptionsFromParent:this.deriveOptionsFromParent,ref:n=>this._baseBarcode=n,barcodeConstructor:u.Barcode,getTarget:this.getTarget,className:p.classNames("k-barcode",t)},e)}exportImage(e={}){return o.exportImage(this.exportVisual(),e)}exportSVG(e={}){return o.exportSVG(this.exportVisual(),e)}exportVisual(e){return this.barcodeInstance!==null?this.barcodeInstance.exportVisual(e):new o.Group}}exports.Barcode=l;
|
package/Barcode.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as r from "react";
|
|
10
|
+
import { BaseBarcode as a } from "./BaseBarcode.mjs";
|
|
11
|
+
import { Barcode as i } from "@progress/kendo-charts";
|
|
12
|
+
import { exportImage as n, exportSVG as p, Group as c } from "@progress/kendo-drawing";
|
|
13
|
+
import { classNames as u } from "@progress/kendo-react-common";
|
|
14
|
+
class g extends r.Component {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments), this._baseBarcode = null, this.getTarget = () => this, this.deriveOptionsFromParent = (e) => Object.assign({}, e, {
|
|
17
|
+
background: this.props.background,
|
|
18
|
+
border: this.props.border,
|
|
19
|
+
checksum: this.props.checksum,
|
|
20
|
+
color: this.props.color,
|
|
21
|
+
height: this.props.height,
|
|
22
|
+
padding: this.props.padding,
|
|
23
|
+
text: this.props.text,
|
|
24
|
+
type: this.props.type,
|
|
25
|
+
value: this.props.value,
|
|
26
|
+
width: this.props.width
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
get barcodeInstance() {
|
|
33
|
+
return this._baseBarcode !== null ? this._baseBarcode.barcodeInstance : null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The Drawing `Surface` of the Barcode.
|
|
37
|
+
*/
|
|
38
|
+
get surface() {
|
|
39
|
+
return this._baseBarcode !== null ? this._baseBarcode.surface : null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The DOM element of the Barcode.
|
|
43
|
+
*/
|
|
44
|
+
get element() {
|
|
45
|
+
return this._baseBarcode !== null ? this._baseBarcode.element : null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
render() {
|
|
51
|
+
const { children: e, className: t, ...s } = this.props;
|
|
52
|
+
return /* @__PURE__ */ r.createElement(
|
|
53
|
+
a,
|
|
54
|
+
{
|
|
55
|
+
...s,
|
|
56
|
+
deriveOptionsFromParent: this.deriveOptionsFromParent,
|
|
57
|
+
ref: (o) => this._baseBarcode = o,
|
|
58
|
+
barcodeConstructor: i,
|
|
59
|
+
getTarget: this.getTarget,
|
|
60
|
+
className: u("k-barcode", t)
|
|
61
|
+
},
|
|
62
|
+
e
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Exports the component as an image. The export operation is asynchronous and returns a promise.
|
|
67
|
+
*
|
|
68
|
+
* @param {ImageExportOptions} options - The parameters for the exported image.
|
|
69
|
+
* @returns {Promise<string>} - A promise that will be resolved with a PNG image encoded as a Data URI.
|
|
70
|
+
*/
|
|
71
|
+
exportImage(e = {}) {
|
|
72
|
+
return n(this.exportVisual(), e);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Exports the component as an SVG document. The export operation is asynchronous and returns a promise.
|
|
76
|
+
*
|
|
77
|
+
* @param options - The parameters for the exported file.
|
|
78
|
+
* @returns - A promise that will be resolved with an SVG document that is encoded as a Data URI.
|
|
79
|
+
*/
|
|
80
|
+
exportSVG(e = {}) {
|
|
81
|
+
return p(this.exportVisual(), e);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Exports a Barcode component as a Drawing `Scene`.
|
|
85
|
+
*
|
|
86
|
+
* @param {any} options - The parameters for the export operation.
|
|
87
|
+
* @returns {Group} - A promise that returns the root `Group` of the scene.
|
|
88
|
+
*/
|
|
89
|
+
exportVisual(e) {
|
|
90
|
+
return this.barcodeInstance !== null ? this.barcodeInstance.exportVisual(e) : new c();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
g as Barcode
|
|
95
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react");function a(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const l=a(c),r=l.createContext(null);r.displayName="BarcodeContext";exports.BarcodeContext=r;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
const t = e.createContext(null);
|
|
11
|
+
t.displayName = "BarcodeContext";
|
|
12
|
+
export {
|
|
13
|
+
t as BarcodeContext
|
|
14
|
+
};
|
package/BaseBarcode.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),a=require("prop-types"),b=require("./store/store.js"),v=require("./store/reducer.js"),m=require("./utils/common.js"),f=require("./BarcodeContext.js"),O=require("@progress/kendo-react-common"),C=require("./package-metadata.js");function I(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,t.get?t:{enumerable:!0,get:()=>n[r]})}}return e.default=n,Object.freeze(e)}const i=I(g),o=class o extends i.Component{constructor(e){super(e),this.barcodeInstance=null,this.surface=null,this._element=null,this.observersStore={},this.onWindowResize=()=>{this.barcodeInstance!==null&&(this.barcodeInstance.redraw(),this.trigger("render",{sender:this}))},O.validatePackage(C.packageMetadata),this.observersStore=b.default(v.observersReducer),this.contextValue={observersStore:this.observersStore}}get element(){return this._element}componentDidMount(){this.instantiateCoreBarcode(),window.addEventListener("resize",this.onWindowResize),this.trigger("render",{sender:this})}componentDidUpdate(e){const{children:r,deriveOptionsFromParent:t,getTarget:s,barcodeConstructor:w,className:P,renderAs:d,...l}=this.props,{children:y,deriveOptionsFromParent:S,getTarget:q,barcodeConstructor:R,className:N,renderAs:h,...u}=e;if(this.barcodeInstance!==null){const p=m.isOptionsChanged(u,l);(d||"svg")!==(h||"svg")?(this.barcodeInstance!==null&&(this.barcodeInstance.destroy(),this.barcodeInstance=null),this.instantiateCoreBarcode()):p&&this.refresh(),this.trigger("render",{sender:this})}}componentWillUnmount(){this.barcodeInstance!==null&&(this.barcodeInstance.destroy(),this.barcodeInstance=null),window.removeEventListener("resize",this.onWindowResize)}render(){const{style:e={},className:r,children:t}=this.props;return i.createElement(f.BarcodeContext.Provider,{value:this.contextValue},i.createElement("div",{style:e,ref:s=>this._element=s,className:r},t))}instantiateCoreBarcode(){const{barcodeConstructor:e}=this.props,r=this.getBarcodeOptions();this.barcodeInstance=new e(this.element,r,t=>{if(process.env.NODE_ENV!=="production")throw t;console.warn(t)})}refresh(){if(this.barcodeInstance!==null){const e=this.getBarcodeOptions();this.barcodeInstance.setOptions(e)}}getBarcodeOptions(){const{renderAs:e,deriveOptionsFromParent:r}=this.props;let t={renderAs:e};return r&&(t=r(t)),t}trigger(e,r){const t=this.observersStore.getState();for(let s=0;s<t.length;s++)t[s].trigger(e,r)}};o.propTypes={dir:a.string,renderAs:a.oneOf(["svg","canvas"])},o.defaultProps={renderAs:"svg"};let c=o;exports.BaseBarcode=c;
|
package/BaseBarcode.mjs
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as o from "react";
|
|
10
|
+
import i from "prop-types";
|
|
11
|
+
import m from "./store/store.mjs";
|
|
12
|
+
import { observersReducer as v } from "./store/reducer.mjs";
|
|
13
|
+
import { isOptionsChanged as g } from "./utils/common.mjs";
|
|
14
|
+
import { BarcodeContext as u } from "./BarcodeContext.mjs";
|
|
15
|
+
import { validatePackage as b } from "@progress/kendo-react-common";
|
|
16
|
+
import { packageMetadata as f } from "./package-metadata.mjs";
|
|
17
|
+
const n = class n extends o.Component {
|
|
18
|
+
constructor(e) {
|
|
19
|
+
super(e), this.barcodeInstance = null, this.surface = null, this._element = null, this.observersStore = {}, this.onWindowResize = () => {
|
|
20
|
+
this.barcodeInstance !== null && (this.barcodeInstance.redraw(), this.trigger("render", { sender: this }));
|
|
21
|
+
}, b(f), this.observersStore = m(v), this.contextValue = {
|
|
22
|
+
observersStore: this.observersStore
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
get element() {
|
|
29
|
+
return this._element;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
componentDidMount() {
|
|
35
|
+
this.instantiateCoreBarcode(), window.addEventListener("resize", this.onWindowResize), this.trigger("render", { sender: this });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
|
+
componentDidUpdate(e) {
|
|
41
|
+
const {
|
|
42
|
+
children: r,
|
|
43
|
+
deriveOptionsFromParent: t,
|
|
44
|
+
getTarget: s,
|
|
45
|
+
barcodeConstructor: O,
|
|
46
|
+
className: C,
|
|
47
|
+
renderAs: c,
|
|
48
|
+
...d
|
|
49
|
+
} = this.props, {
|
|
50
|
+
children: I,
|
|
51
|
+
deriveOptionsFromParent: w,
|
|
52
|
+
getTarget: P,
|
|
53
|
+
barcodeConstructor: S,
|
|
54
|
+
className: x,
|
|
55
|
+
renderAs: h,
|
|
56
|
+
...p
|
|
57
|
+
} = e;
|
|
58
|
+
if (this.barcodeInstance !== null) {
|
|
59
|
+
const l = g(p, d);
|
|
60
|
+
(c || "svg") !== (h || "svg") ? (this.barcodeInstance !== null && (this.barcodeInstance.destroy(), this.barcodeInstance = null), this.instantiateCoreBarcode()) : l && this.refresh(), this.trigger("render", { sender: this });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
componentWillUnmount() {
|
|
67
|
+
this.barcodeInstance !== null && (this.barcodeInstance.destroy(), this.barcodeInstance = null), window.removeEventListener("resize", this.onWindowResize);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
render() {
|
|
73
|
+
const { style: e = {}, className: r, children: t } = this.props;
|
|
74
|
+
return /* @__PURE__ */ o.createElement(u.Provider, { value: this.contextValue }, /* @__PURE__ */ o.createElement(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
style: e,
|
|
78
|
+
ref: (s) => this._element = s,
|
|
79
|
+
className: r
|
|
80
|
+
},
|
|
81
|
+
t
|
|
82
|
+
));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @hidden
|
|
86
|
+
*/
|
|
87
|
+
instantiateCoreBarcode() {
|
|
88
|
+
const { barcodeConstructor: e } = this.props, r = this.getBarcodeOptions();
|
|
89
|
+
this.barcodeInstance = new e(
|
|
90
|
+
this.element,
|
|
91
|
+
r,
|
|
92
|
+
(t) => {
|
|
93
|
+
if (process.env.NODE_ENV !== "production")
|
|
94
|
+
throw t;
|
|
95
|
+
console.warn(t);
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @hidden
|
|
101
|
+
*/
|
|
102
|
+
refresh() {
|
|
103
|
+
if (this.barcodeInstance !== null) {
|
|
104
|
+
const e = this.getBarcodeOptions();
|
|
105
|
+
this.barcodeInstance.setOptions(e);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @hidden
|
|
110
|
+
*/
|
|
111
|
+
getBarcodeOptions() {
|
|
112
|
+
const {
|
|
113
|
+
renderAs: e,
|
|
114
|
+
deriveOptionsFromParent: r
|
|
115
|
+
} = this.props;
|
|
116
|
+
let t = { renderAs: e };
|
|
117
|
+
return r && (t = r(t)), t;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @hidden
|
|
121
|
+
*/
|
|
122
|
+
trigger(e, r) {
|
|
123
|
+
const t = this.observersStore.getState();
|
|
124
|
+
for (let s = 0; s < t.length; s++)
|
|
125
|
+
t[s].trigger(e, r);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
n.propTypes = {
|
|
129
|
+
dir: i.string,
|
|
130
|
+
renderAs: i.oneOf(["svg", "canvas"])
|
|
131
|
+
}, n.defaultProps = {
|
|
132
|
+
renderAs: "svg"
|
|
133
|
+
};
|
|
134
|
+
let a = n;
|
|
135
|
+
export {
|
|
136
|
+
a as BaseBarcode
|
|
137
|
+
};
|
package/QRCode.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),c=require("./BaseBarcode.js"),u=require("@progress/kendo-charts"),o=require("@progress/kendo-drawing"),d=require("@progress/kendo-react-common");function l(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const n=l(i),p="#000",h="#fff",b="L";class g extends n.Component{constructor(){super(...arguments),this._baseBarcode=null,this.getTarget=()=>this,this.deriveOptionsFromParent=e=>Object.assign({},e,{background:this.props.background||h,border:this.props.border,color:this.props.color||p,encoding:this.props.encoding,errorCorrection:this.props.errorCorrection||b,overlay:this.props.overlay||{},padding:this.props.padding,renderAs:this.props.renderAs,size:this.props.size,value:this.props.value})}get barcodeInstance(){return this._baseBarcode!==null?this._baseBarcode.barcodeInstance:null}get surface(){return this._baseBarcode!==null?this._baseBarcode.surface:null}get element(){return this._baseBarcode!==null?this._baseBarcode.element:null}render(){const{children:e,className:t,...s}=this.props;return n.createElement(c.BaseBarcode,{...s,deriveOptionsFromParent:this.deriveOptionsFromParent,ref:a=>this._baseBarcode=a,barcodeConstructor:u.QRCode,getTarget:this.getTarget,className:d.classNames("k-qrcode",t)},e)}exportImage(e={}){return o.exportImage(this.exportVisual(),e)}exportSVG(e={}){return o.exportSVG(this.exportVisual(),e)}exportVisual(e){return this.barcodeInstance!==null?this.barcodeInstance.exportVisual(e):new o.Group}}exports.QRCode=g;
|
package/QRCode.mjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import { BaseBarcode as n } from "./BaseBarcode.mjs";
|
|
11
|
+
import { QRCode as a } from "@progress/kendo-charts";
|
|
12
|
+
import { exportImage as i, exportSVG as c, Group as p } from "@progress/kendo-drawing";
|
|
13
|
+
import { classNames as d } from "@progress/kendo-react-common";
|
|
14
|
+
const u = "#000", l = "#fff", h = "L";
|
|
15
|
+
class _ extends e.Component {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments), this._baseBarcode = null, this.getTarget = () => this, this.deriveOptionsFromParent = (r) => Object.assign({}, r, {
|
|
18
|
+
background: this.props.background || l,
|
|
19
|
+
border: this.props.border,
|
|
20
|
+
color: this.props.color || u,
|
|
21
|
+
encoding: this.props.encoding,
|
|
22
|
+
errorCorrection: this.props.errorCorrection || h,
|
|
23
|
+
overlay: this.props.overlay || {},
|
|
24
|
+
padding: this.props.padding,
|
|
25
|
+
renderAs: this.props.renderAs,
|
|
26
|
+
size: this.props.size,
|
|
27
|
+
value: this.props.value
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
get barcodeInstance() {
|
|
34
|
+
return this._baseBarcode !== null ? this._baseBarcode.barcodeInstance : null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The Drawing `Surface` of the Barcode.
|
|
38
|
+
*/
|
|
39
|
+
get surface() {
|
|
40
|
+
return this._baseBarcode !== null ? this._baseBarcode.surface : null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The DOM element of the Barcode.
|
|
44
|
+
*/
|
|
45
|
+
get element() {
|
|
46
|
+
return this._baseBarcode !== null ? this._baseBarcode.element : null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
render() {
|
|
52
|
+
const { children: r, className: t, ...s } = this.props;
|
|
53
|
+
return /* @__PURE__ */ e.createElement(
|
|
54
|
+
n,
|
|
55
|
+
{
|
|
56
|
+
...s,
|
|
57
|
+
deriveOptionsFromParent: this.deriveOptionsFromParent,
|
|
58
|
+
ref: (o) => this._baseBarcode = o,
|
|
59
|
+
barcodeConstructor: a,
|
|
60
|
+
getTarget: this.getTarget,
|
|
61
|
+
className: d("k-qrcode", t)
|
|
62
|
+
},
|
|
63
|
+
r
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Exports the component as an image. The export operation is asynchronous and returns a promise.
|
|
68
|
+
*
|
|
69
|
+
* @param {ImageExportOptions} options - The parameters for the exported image.
|
|
70
|
+
* @returns {Promise<string>} - A promise that will be resolved with a PNG image encoded as a Data URI.
|
|
71
|
+
*/
|
|
72
|
+
exportImage(r = {}) {
|
|
73
|
+
return i(this.exportVisual(), r);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Exports the component as an SVG document. The export operation is asynchronous and returns a promise.
|
|
77
|
+
*
|
|
78
|
+
* @param options - The parameters for the exported file.
|
|
79
|
+
* @returns - A promise that will be resolved with an SVG document that is encoded as a Data URI.
|
|
80
|
+
*/
|
|
81
|
+
exportSVG(r = {}) {
|
|
82
|
+
return c(this.exportVisual(), r);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Exports a Barcode component as a Drawing `Scene`.
|
|
86
|
+
*
|
|
87
|
+
* @param {any} options - The parameters for the export operation.
|
|
88
|
+
* @returns {Group} - A promise that returns the root `Group` of the scene.
|
|
89
|
+
*/
|
|
90
|
+
exportVisual(r) {
|
|
91
|
+
return this.barcodeInstance !== null ? this.barcodeInstance.exportVisual(r) : new p();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
_ as QRCode
|
|
96
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2024 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("@progress/kendo-react-common"),require("@progress/kendo-charts"),require("@progress/kendo-drawing")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","@progress/kendo-react-common","@progress/kendo-charts","@progress/kendo-drawing"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactBarcodes={},e.React,e.PropTypes,e.KendoReactCommon,e.KendoCharts,e.KendoDrawing)}(this,(function(e,t,r,s,n,o){"use strict";function a(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=a(t);const c=(e,t)=>{if(!t.type)return[];switch(t.type){case"add":return[...e,t.payload];case"remove":return e.filter((e=>e!==t.payload));default:return e}},d=e=>"object"==typeof e,l=(e,t)=>{if(Object.keys(e).length!==Object.keys(t).length)return!0;for(let r in e)if(e.hasOwnProperty(r)){const s=e[r],n=t[r];if(d(s)&&d(n)?l(s,n):s!==n)return!0}return!1},p=(e,t)=>{if(!e||!t||(e=[].concat(e),t=[].concat(t),e.length!==t.length))return!0;for(let r=0;r<e.length;r++)if(l(e[r],t[r]))return!0;return!1},h=i.createContext(null);h.displayName="BarcodeContext";const u={name:"@progress/kendo-react-barcodes",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},g=class extends i.Component{constructor(e){super(e),this.barcodeInstance=null,this.surface=null,this._element=null,this.observersStore={},this.onWindowResize=()=>{null!==this.barcodeInstance&&(this.barcodeInstance.redraw(),this.trigger("render",{sender:this}))},s.validatePackage(u),this.observersStore=(e=>{let t,r,n=[];const o=o=>{t=e(t,o),s.canUseDOM&&(window.clearTimeout(r),r=window.setTimeout((()=>n.forEach((e=>e()))),16.666666666666668))};return o({}),{getState:()=>t,dispatch:o,subscribe:e=>(n.push(e),()=>n=n.filter((t=>t!==e)))}})(c),this.contextValue={observersStore:this.observersStore}}get element(){return this._element}componentDidMount(){this.instantiateCoreBarcode(),window.addEventListener("resize",this.onWindowResize),this.trigger("render",{sender:this})}componentDidUpdate(e){const{children:t,deriveOptionsFromParent:r,getTarget:s,barcodeConstructor:n,className:o,renderAs:a,...i}=this.props,{children:c,deriveOptionsFromParent:d,getTarget:l,barcodeConstructor:h,className:u,renderAs:g,...b}=e;if(null!==this.barcodeInstance){const e=p(b,i);(a||"svg")!==(g||"svg")?(null!==this.barcodeInstance&&(this.barcodeInstance.destroy(),this.barcodeInstance=null),this.instantiateCoreBarcode()):e&&this.refresh(),this.trigger("render",{sender:this})}}componentWillUnmount(){null!==this.barcodeInstance&&(this.barcodeInstance.destroy(),this.barcodeInstance=null),window.removeEventListener("resize",this.onWindowResize)}render(){const{style:e={},className:t,children:r}=this.props;return i.createElement(h.Provider,{value:this.contextValue},i.createElement("div",{style:e,ref:e=>this._element=e,className:t},r))}instantiateCoreBarcode(){const{barcodeConstructor:e}=this.props,t=this.getBarcodeOptions();this.barcodeInstance=new e(this.element,t,(e=>{if("production"!==process.env.NODE_ENV)throw e;console.warn(e)}))}refresh(){if(null!==this.barcodeInstance){const e=this.getBarcodeOptions();this.barcodeInstance.setOptions(e)}}getBarcodeOptions(){const{renderAs:e,deriveOptionsFromParent:t}=this.props;let r={renderAs:e};return t&&(r=t(r)),r}trigger(e,t){const r=this.observersStore.getState();for(let s=0;s<r.length;s++)r[s].trigger(e,t)}};g.propTypes={dir:r.string,renderAs:r.oneOf(["svg","canvas"])},g.defaultProps={renderAs:"svg"};let b=g;class m extends i.Component{constructor(){super(...arguments),this._baseBarcode=null,this.getTarget=()=>this,this.deriveOptionsFromParent=e=>Object.assign({},e,{background:this.props.background,border:this.props.border,checksum:this.props.checksum,color:this.props.color,height:this.props.height,padding:this.props.padding,text:this.props.text,type:this.props.type,value:this.props.value,width:this.props.width})}get barcodeInstance(){return null!==this._baseBarcode?this._baseBarcode.barcodeInstance:null}get surface(){return null!==this._baseBarcode?this._baseBarcode.surface:null}get element(){return null!==this._baseBarcode?this._baseBarcode.element:null}render(){const{children:e,className:t,...r}=this.props;return i.createElement(b,{...r,deriveOptionsFromParent:this.deriveOptionsFromParent,ref:e=>this._baseBarcode=e,barcodeConstructor:n.Barcode,getTarget:this.getTarget,className:s.classNames("k-barcode",t)},e)}exportImage(e={}){return o.exportImage(this.exportVisual(),e)}exportSVG(e={}){return o.exportSVG(this.exportVisual(),e)}exportVisual(e){return null!==this.barcodeInstance?this.barcodeInstance.exportVisual(e):new o.Group}}class f extends i.Component{constructor(){super(...arguments),this._baseBarcode=null,this.getTarget=()=>this,this.deriveOptionsFromParent=e=>Object.assign({},e,{background:this.props.background||"#fff",border:this.props.border,color:this.props.color||"#000",encoding:this.props.encoding,errorCorrection:this.props.errorCorrection||"L",overlay:this.props.overlay||{},padding:this.props.padding,renderAs:this.props.renderAs,size:this.props.size,value:this.props.value})}get barcodeInstance(){return null!==this._baseBarcode?this._baseBarcode.barcodeInstance:null}get surface(){return null!==this._baseBarcode?this._baseBarcode.surface:null}get element(){return null!==this._baseBarcode?this._baseBarcode.element:null}render(){const{children:e,className:t,...r}=this.props;return i.createElement(b,{...r,deriveOptionsFromParent:this.deriveOptionsFromParent,ref:e=>this._baseBarcode=e,barcodeConstructor:n.QRCode,getTarget:this.getTarget,className:s.classNames("k-qrcode",t)},e)}exportImage(e={}){return o.exportImage(this.exportVisual(),e)}exportSVG(e={}){return o.exportSVG(this.exportVisual(),e)}exportVisual(e){return null!==this.barcodeInstance?this.barcodeInstance.exportVisual(e):new o.Group}}e.Barcode=m,e.QRCode=f}));
|