@progress/kendo-react-barcodes 4.14.0-dev.202112141254
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.md +11 -0
- package/NOTICE.txt +78 -0
- package/README.md +59 -0
- package/about.md +3 -0
- package/dist/cdn/js/kendo-react-barcodes.js +1 -0
- package/dist/es/Barcode.d.ts +49 -0
- package/dist/es/Barcode.js +146 -0
- package/dist/es/BarcodeContext.d.ts +12 -0
- package/dist/es/BarcodeContext.js +6 -0
- package/dist/es/BarcodeProps.d.ts +61 -0
- package/dist/es/BarcodeProps.js +0 -0
- package/dist/es/BaseBarcode.d.ts +75 -0
- package/dist/es/BaseBarcode.js +179 -0
- package/dist/es/BaseBarcodeProps.d.ts +41 -0
- package/dist/es/BaseBarcodeProps.js +0 -0
- package/dist/es/QRCode.d.ts +49 -0
- package/dist/es/QRCode.js +149 -0
- package/dist/es/QRCodeProps.d.ts +73 -0
- package/dist/es/QRCodeProps.js +0 -0
- package/dist/es/common/barcodes.d.ts +4 -0
- package/dist/es/common/barcodes.js +0 -0
- package/dist/es/main.d.ts +6 -0
- package/dist/es/main.js +3 -0
- package/dist/es/package-metadata.d.ts +5 -0
- package/dist/es/package-metadata.js +11 -0
- package/dist/es/store/reducer.d.ts +10 -0
- package/dist/es/store/reducer.js +41 -0
- package/dist/es/store/store.d.ts +25 -0
- package/dist/es/store/store.js +28 -0
- package/dist/es/types/barcode-text.d.ts +32 -0
- package/dist/es/types/barcode-text.js +0 -0
- package/dist/es/types/barcode-type.d.ts +4 -0
- package/dist/es/types/barcode-type.js +0 -0
- package/dist/es/types/border.interface.d.ts +18 -0
- package/dist/es/types/border.interface.js +0 -0
- package/dist/es/types/dash-type.interface.d.ts +4 -0
- package/dist/es/types/dash-type.interface.js +0 -0
- package/dist/es/types/margin.interface.d.ts +21 -0
- package/dist/es/types/margin.interface.js +0 -0
- package/dist/es/types/padding.interface.d.ts +21 -0
- package/dist/es/types/padding.interface.js +0 -0
- package/dist/es/types/qrcode-encoding.d.ts +4 -0
- package/dist/es/types/qrcode-encoding.js +0 -0
- package/dist/es/types/qrcode-error-correction.d.ts +9 -0
- package/dist/es/types/qrcode-error-correction.js +0 -0
- package/dist/es/types/qrcode-overlay.d.ts +25 -0
- package/dist/es/types/qrcode-overlay.js +0 -0
- package/dist/es/types/render-mode.d.ts +8 -0
- package/dist/es/types/render-mode.js +0 -0
- package/dist/es/types.d.ts +10 -0
- package/dist/es/types.js +0 -0
- package/dist/es/utils/common.d.ts +4 -0
- package/dist/es/utils/common.js +39 -0
- package/dist/npm/Barcode.d.ts +49 -0
- package/dist/npm/Barcode.js +148 -0
- package/dist/npm/BarcodeContext.d.ts +12 -0
- package/dist/npm/BarcodeContext.js +8 -0
- package/dist/npm/BarcodeProps.d.ts +61 -0
- package/dist/npm/BarcodeProps.js +2 -0
- package/dist/npm/BaseBarcode.d.ts +75 -0
- package/dist/npm/BaseBarcode.js +181 -0
- package/dist/npm/BaseBarcodeProps.d.ts +41 -0
- package/dist/npm/BaseBarcodeProps.js +2 -0
- package/dist/npm/QRCode.d.ts +49 -0
- package/dist/npm/QRCode.js +151 -0
- package/dist/npm/QRCodeProps.d.ts +73 -0
- package/dist/npm/QRCodeProps.js +2 -0
- package/dist/npm/common/barcodes.d.ts +4 -0
- package/dist/npm/common/barcodes.js +2 -0
- package/dist/npm/main.d.ts +6 -0
- package/dist/npm/main.js +6 -0
- package/dist/npm/package-metadata.d.ts +5 -0
- package/dist/npm/package-metadata.js +13 -0
- package/dist/npm/store/reducer.d.ts +10 -0
- package/dist/npm/store/reducer.js +44 -0
- package/dist/npm/store/store.d.ts +25 -0
- package/dist/npm/store/store.js +30 -0
- package/dist/npm/types/barcode-text.d.ts +32 -0
- package/dist/npm/types/barcode-text.js +2 -0
- package/dist/npm/types/barcode-type.d.ts +4 -0
- package/dist/npm/types/barcode-type.js +2 -0
- package/dist/npm/types/border.interface.d.ts +18 -0
- package/dist/npm/types/border.interface.js +2 -0
- package/dist/npm/types/dash-type.interface.d.ts +4 -0
- package/dist/npm/types/dash-type.interface.js +2 -0
- package/dist/npm/types/margin.interface.d.ts +21 -0
- package/dist/npm/types/margin.interface.js +2 -0
- package/dist/npm/types/padding.interface.d.ts +21 -0
- package/dist/npm/types/padding.interface.js +2 -0
- package/dist/npm/types/qrcode-encoding.d.ts +4 -0
- package/dist/npm/types/qrcode-encoding.js +2 -0
- package/dist/npm/types/qrcode-error-correction.d.ts +9 -0
- package/dist/npm/types/qrcode-error-correction.js +2 -0
- package/dist/npm/types/qrcode-overlay.d.ts +25 -0
- package/dist/npm/types/qrcode-overlay.js +2 -0
- package/dist/npm/types/render-mode.d.ts +8 -0
- package/dist/npm/types/render-mode.js +2 -0
- package/dist/npm/types.d.ts +10 -0
- package/dist/npm/types.js +2 -0
- package/dist/npm/utils/common.d.ts +4 -0
- package/dist/npm/utils/common.js +41 -0
- package/dist/systemjs/kendo-react-barcodes.js +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
27
|
+
var t = {};
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
29
|
+
t[p] = s[p];
|
|
30
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
31
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
return t;
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
var React = require("react");
|
|
37
|
+
var BaseBarcode_1 = require("./BaseBarcode");
|
|
38
|
+
var kendo_charts_1 = require("@progress/kendo-charts");
|
|
39
|
+
var kendo_drawing_1 = require("@progress/kendo-drawing");
|
|
40
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
41
|
+
/**
|
|
42
|
+
* Represents the KendoReact Barcode component.
|
|
43
|
+
*/
|
|
44
|
+
var Barcode = /** @class */ (function (_super) {
|
|
45
|
+
__extends(Barcode, _super);
|
|
46
|
+
function Barcode() {
|
|
47
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
48
|
+
_this.getTarget = function () {
|
|
49
|
+
return _this;
|
|
50
|
+
};
|
|
51
|
+
_this.deriveOptionsFromParent = function (options) {
|
|
52
|
+
return Object.assign({}, options, {
|
|
53
|
+
background: _this.props.background,
|
|
54
|
+
border: _this.props.border,
|
|
55
|
+
checksum: _this.props.checksum,
|
|
56
|
+
color: _this.props.color,
|
|
57
|
+
height: _this.props.height,
|
|
58
|
+
padding: _this.props.padding,
|
|
59
|
+
text: _this.props.text,
|
|
60
|
+
type: _this.props.type,
|
|
61
|
+
value: _this.props.value,
|
|
62
|
+
width: _this.props.width
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
Object.defineProperty(Barcode.prototype, "barcodeInstance", {
|
|
68
|
+
/**
|
|
69
|
+
* @hidden
|
|
70
|
+
*/
|
|
71
|
+
get: function () {
|
|
72
|
+
if (this._baseBarcode !== null) {
|
|
73
|
+
return this._baseBarcode.barcodeInstance;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
},
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(Barcode.prototype, "surface", {
|
|
81
|
+
/**
|
|
82
|
+
* The Drawing `Surface` of the Barcode.
|
|
83
|
+
*/
|
|
84
|
+
get: function () {
|
|
85
|
+
if (this._baseBarcode !== null) {
|
|
86
|
+
return this._baseBarcode.surface;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
},
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(Barcode.prototype, "element", {
|
|
94
|
+
/**
|
|
95
|
+
* The DOM element of the Barcode.
|
|
96
|
+
*/
|
|
97
|
+
get: function () {
|
|
98
|
+
if (this._baseBarcode !== null) {
|
|
99
|
+
return this._baseBarcode.element;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
},
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* @hidden
|
|
108
|
+
*/
|
|
109
|
+
Barcode.prototype.render = function () {
|
|
110
|
+
var _this = this;
|
|
111
|
+
var _a = this.props, children = _a.children, className = _a.className, baseBarcodeProps = __rest(_a, ["children", "className"]);
|
|
112
|
+
return (React.createElement(BaseBarcode_1.BaseBarcode, __assign({}, baseBarcodeProps, { deriveOptionsFromParent: this.deriveOptionsFromParent, ref: function (baseBarcode) { return _this._baseBarcode = baseBarcode; }, barcodeConstructor: kendo_charts_1.Barcode, getTarget: this.getTarget, className: kendo_react_common_1.classNames('k-barcode', className) }), children));
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Exports the component as an image. The export operation is asynchronous and returns a promise.
|
|
116
|
+
*
|
|
117
|
+
* @param {ImageExportOptions} options - The parameters for the exported image.
|
|
118
|
+
* @returns {Promise<string>} - A promise that will be resolved with a PNG image encoded as a Data URI.
|
|
119
|
+
*/
|
|
120
|
+
Barcode.prototype.exportImage = function (options) {
|
|
121
|
+
if (options === void 0) { options = {}; }
|
|
122
|
+
return kendo_drawing_1.exportImage(this.exportVisual(), options);
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Exports the component as an SVG document. The export operation is asynchronous and returns a promise.
|
|
126
|
+
*
|
|
127
|
+
* @param options - The parameters for the exported file.
|
|
128
|
+
* @returns - A promise that will be resolved with an SVG document that is encoded as a Data URI.
|
|
129
|
+
*/
|
|
130
|
+
Barcode.prototype.exportSVG = function (options) {
|
|
131
|
+
if (options === void 0) { options = {}; }
|
|
132
|
+
return kendo_drawing_1.exportSVG(this.exportVisual(), options);
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Exports a Barcode component as a Drawing `Scene`.
|
|
136
|
+
*
|
|
137
|
+
* @param {any} options - The parameters for the export operation.
|
|
138
|
+
* @returns {Group} - A promise that returns the root `Group` of the scene.
|
|
139
|
+
*/
|
|
140
|
+
Barcode.prototype.exportVisual = function (options) {
|
|
141
|
+
if (this.barcodeInstance !== null) {
|
|
142
|
+
return this.barcodeInstance.exportVisual(options);
|
|
143
|
+
}
|
|
144
|
+
return new kendo_drawing_1.Group();
|
|
145
|
+
};
|
|
146
|
+
return Barcode;
|
|
147
|
+
}(React.Component));
|
|
148
|
+
exports.Barcode = Barcode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Store } from './store/store';
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export interface BarcodeContextType {
|
|
7
|
+
observersStore: Store;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
export declare const BarcodeContext: React.Context<BarcodeContextType>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseBarcodeProps } from './BaseBarcodeProps';
|
|
2
|
+
import { BarcodeText, BarcodeType, Border, Padding } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the props of the [KendoReact Barcode component]({% slug overview_barcode_barcodes %}).
|
|
5
|
+
*/
|
|
6
|
+
export interface BarcodeProps extends BaseBarcodeProps {
|
|
7
|
+
/**
|
|
8
|
+
* The background color of the Barcode. Accepts a valid CSS color string, including hex and rgb.
|
|
9
|
+
*
|
|
10
|
+
* @default "white"
|
|
11
|
+
*/
|
|
12
|
+
background?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The border of the Barcode.
|
|
15
|
+
*/
|
|
16
|
+
border?: Border;
|
|
17
|
+
/**
|
|
18
|
+
* If set to `true`, the Barcode will display the checksum digit next to the value in the text area.
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
checksum?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The color of the Barcode. Accepts a valid CSS color string, including hex and rgb.
|
|
25
|
+
*
|
|
26
|
+
* @default "black"
|
|
27
|
+
*/
|
|
28
|
+
color?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The height of the Barcode in pixels.
|
|
31
|
+
*
|
|
32
|
+
* The Barcode dimensions can also be set through regular CSS styling.
|
|
33
|
+
*/
|
|
34
|
+
height?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The padding of the Barcode. A numeric value sets all paddings.
|
|
37
|
+
*
|
|
38
|
+
* @default 0
|
|
39
|
+
*/
|
|
40
|
+
padding?: Padding | number;
|
|
41
|
+
/**
|
|
42
|
+
* The Barcode text label configuration.
|
|
43
|
+
*/
|
|
44
|
+
text?: BarcodeText;
|
|
45
|
+
/**
|
|
46
|
+
* The symbology (encoding) the Barcode will use.
|
|
47
|
+
*
|
|
48
|
+
* @default "Code39"
|
|
49
|
+
*/
|
|
50
|
+
type: BarcodeType | string;
|
|
51
|
+
/**
|
|
52
|
+
* The value of the Barcode.
|
|
53
|
+
*/
|
|
54
|
+
value: number | string;
|
|
55
|
+
/**
|
|
56
|
+
* The width of the Barcode in pixels.
|
|
57
|
+
*
|
|
58
|
+
* The Barcode dimensions can also be set through regular CSS styling.
|
|
59
|
+
*/
|
|
60
|
+
width?: number;
|
|
61
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import { Surface } from '@progress/kendo-drawing';
|
|
4
|
+
import { BaseBarcodePrivateProps } from './BaseBarcodeProps';
|
|
5
|
+
import { BarcodeContextType } from './BarcodeContext';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare class BaseBarcode extends React.Component<BaseBarcodePrivateProps, {}> {
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
static propTypes: {
|
|
14
|
+
dir: PropTypes.Requireable<string>;
|
|
15
|
+
renderAs: PropTypes.Requireable<string>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
static defaultProps: {
|
|
21
|
+
renderAs: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
barcodeInstance: any | null;
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
surface: Surface;
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
readonly element: HTMLDivElement;
|
|
35
|
+
protected _element: HTMLDivElement | null;
|
|
36
|
+
protected contextValue: BarcodeContextType;
|
|
37
|
+
protected observersStore: any;
|
|
38
|
+
constructor(props: BaseBarcodePrivateProps);
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
componentDidMount(): void;
|
|
43
|
+
/**
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
componentDidUpdate(prevProps: any): void;
|
|
47
|
+
/**
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
componentWillUnmount(): void;
|
|
51
|
+
/**
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
render(): any;
|
|
55
|
+
/**
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
instantiateCoreBarcode(): void;
|
|
59
|
+
/**
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
refresh(): void;
|
|
63
|
+
/**
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
getBarcodeOptions(): any;
|
|
67
|
+
/**
|
|
68
|
+
* @hidden
|
|
69
|
+
*/
|
|
70
|
+
trigger(name: string, e: any): void;
|
|
71
|
+
/**
|
|
72
|
+
* @hidden
|
|
73
|
+
*/
|
|
74
|
+
onWindowResize: () => void;
|
|
75
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
16
|
+
var t = {};
|
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
18
|
+
t[p] = s[p];
|
|
19
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
20
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
|
|
21
|
+
t[p[i]] = s[p[i]];
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
var React = require("react");
|
|
26
|
+
var PropTypes = require("prop-types");
|
|
27
|
+
var store_1 = require("./store/store");
|
|
28
|
+
var reducer_1 = require("./store/reducer");
|
|
29
|
+
var common_1 = require("./utils/common");
|
|
30
|
+
var BarcodeContext_1 = require("./BarcodeContext");
|
|
31
|
+
var kendo_react_common_1 = require("@progress/kendo-react-common");
|
|
32
|
+
var package_metadata_1 = require("./package-metadata");
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
36
|
+
var BaseBarcode = /** @class */ (function (_super) {
|
|
37
|
+
__extends(BaseBarcode, _super);
|
|
38
|
+
function BaseBarcode(props) {
|
|
39
|
+
var _this = _super.call(this, props) || this;
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
43
|
+
_this.barcodeInstance = null;
|
|
44
|
+
_this._element = null;
|
|
45
|
+
_this.observersStore = {};
|
|
46
|
+
/* DOM event handlers */
|
|
47
|
+
/**
|
|
48
|
+
* @hidden
|
|
49
|
+
*/
|
|
50
|
+
_this.onWindowResize = function () {
|
|
51
|
+
if (_this.barcodeInstance !== null) {
|
|
52
|
+
_this.barcodeInstance.redraw();
|
|
53
|
+
_this.trigger('render', { sender: _this });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
kendo_react_common_1.validatePackage(package_metadata_1.packageMetadata);
|
|
57
|
+
_this.observersStore = store_1.default(reducer_1.observersReducer);
|
|
58
|
+
_this.contextValue = {
|
|
59
|
+
observersStore: _this.observersStore
|
|
60
|
+
};
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
Object.defineProperty(BaseBarcode.prototype, "element", {
|
|
64
|
+
/**
|
|
65
|
+
* @hidden
|
|
66
|
+
*/
|
|
67
|
+
get: function () {
|
|
68
|
+
return this._element;
|
|
69
|
+
},
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
BaseBarcode.prototype.componentDidMount = function () {
|
|
77
|
+
this.instantiateCoreBarcode();
|
|
78
|
+
window.addEventListener('resize', this.onWindowResize);
|
|
79
|
+
this.trigger('render', { sender: this });
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
BaseBarcode.prototype.componentDidUpdate = function (prevProps) {
|
|
85
|
+
var _a = this.props, children = _a.children, deriveOptionsFromParent = _a.deriveOptionsFromParent, getTarget = _a.getTarget, barcodeConstructor = _a.barcodeConstructor, className = _a.className, renderAs = _a.renderAs, currentOthers = __rest(_a, ["children", "deriveOptionsFromParent", "getTarget", "barcodeConstructor", "className", "renderAs"]);
|
|
86
|
+
var prevChildren = prevProps.children, prevDeriveOptionsFromParent = prevProps.deriveOptionsFromParent, prevGetTarget = prevProps.getTarget, prevBarcodeConstructor = prevProps.barcodeConstructor, prevClassName = prevProps.className, prevRenderAs = prevProps.renderAs, prevOthers = __rest(prevProps, ["children", "deriveOptionsFromParent", "getTarget", "barcodeConstructor", "className", "renderAs"]);
|
|
87
|
+
if (this.barcodeInstance !== null) {
|
|
88
|
+
var optionsChanged = common_1.isOptionsChanged(prevOthers, currentOthers);
|
|
89
|
+
if ((renderAs || 'svg') !== (prevRenderAs || 'svg')) {
|
|
90
|
+
if (this.barcodeInstance !== null) {
|
|
91
|
+
this.barcodeInstance.destroy();
|
|
92
|
+
this.barcodeInstance = null;
|
|
93
|
+
}
|
|
94
|
+
this.instantiateCoreBarcode();
|
|
95
|
+
}
|
|
96
|
+
else if (optionsChanged) {
|
|
97
|
+
this.refresh();
|
|
98
|
+
}
|
|
99
|
+
this.trigger('render', { sender: this });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* @hidden
|
|
104
|
+
*/
|
|
105
|
+
BaseBarcode.prototype.componentWillUnmount = function () {
|
|
106
|
+
if (this.barcodeInstance !== null) {
|
|
107
|
+
this.barcodeInstance.destroy();
|
|
108
|
+
this.barcodeInstance = null;
|
|
109
|
+
}
|
|
110
|
+
window.removeEventListener('resize', this.onWindowResize);
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* @hidden
|
|
114
|
+
*/
|
|
115
|
+
BaseBarcode.prototype.render = function () {
|
|
116
|
+
var _this = this;
|
|
117
|
+
var _a = this.props, _b = _a.style, style = _b === void 0 ? {} : _b, className = _a.className, children = _a.children;
|
|
118
|
+
return (React.createElement(BarcodeContext_1.BarcodeContext.Provider, { value: this.contextValue },
|
|
119
|
+
React.createElement("div", { style: style, ref: function (el) { return _this._element = el; }, className: className }, children)));
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* @hidden
|
|
123
|
+
*/
|
|
124
|
+
BaseBarcode.prototype.instantiateCoreBarcode = function () {
|
|
125
|
+
var barcodeConstructor = this.props.barcodeConstructor;
|
|
126
|
+
var barcodeOptions = this.getBarcodeOptions();
|
|
127
|
+
this.barcodeInstance = new barcodeConstructor(this.element, barcodeOptions, function (error) {
|
|
128
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.warn(error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* @hidden
|
|
138
|
+
*/
|
|
139
|
+
BaseBarcode.prototype.refresh = function () {
|
|
140
|
+
if (this.barcodeInstance !== null) {
|
|
141
|
+
var barcodeOptions = this.getBarcodeOptions();
|
|
142
|
+
this.barcodeInstance.setOptions(barcodeOptions);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* @hidden
|
|
147
|
+
*/
|
|
148
|
+
BaseBarcode.prototype.getBarcodeOptions = function () {
|
|
149
|
+
var _a = this.props, renderAs = _a.renderAs, deriveOptionsFromParent = _a.deriveOptionsFromParent;
|
|
150
|
+
var barcodeOptions = { renderAs: renderAs };
|
|
151
|
+
if (deriveOptionsFromParent) {
|
|
152
|
+
// Add options from parent - required by TS
|
|
153
|
+
barcodeOptions = deriveOptionsFromParent(barcodeOptions);
|
|
154
|
+
}
|
|
155
|
+
return barcodeOptions;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* @hidden
|
|
159
|
+
*/
|
|
160
|
+
BaseBarcode.prototype.trigger = function (name, e) {
|
|
161
|
+
var observers = this.observersStore.getState();
|
|
162
|
+
for (var idx = 0; idx < observers.length; idx++) {
|
|
163
|
+
observers[idx].trigger(name, e);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* @hidden
|
|
168
|
+
*/
|
|
169
|
+
BaseBarcode.propTypes = {
|
|
170
|
+
dir: PropTypes.string,
|
|
171
|
+
renderAs: PropTypes.oneOf(['svg', 'canvas'])
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* @hidden
|
|
175
|
+
*/
|
|
176
|
+
BaseBarcode.defaultProps = {
|
|
177
|
+
renderAs: 'svg'
|
|
178
|
+
};
|
|
179
|
+
return BaseBarcode;
|
|
180
|
+
}(React.Component));
|
|
181
|
+
exports.BaseBarcode = BaseBarcode;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Barcodes } from './common/barcodes';
|
|
3
|
+
import { RenderMode } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export interface BaseBarcodePrivateProps extends BaseBarcodeProps {
|
|
8
|
+
/**
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
deriveOptionsFromParent?: (options: any) => any;
|
|
12
|
+
/**
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
barcodeConstructor: any;
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
getTarget: () => Barcodes;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseBarcodeProps {
|
|
25
|
+
/**
|
|
26
|
+
* The styles that are applied to the component.
|
|
27
|
+
*/
|
|
28
|
+
style?: React.CSSProperties;
|
|
29
|
+
/**
|
|
30
|
+
* Sets additional CSS classes to the component.
|
|
31
|
+
*/
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the preferred rendering engine.
|
|
35
|
+
*
|
|
36
|
+
* The supported values are:
|
|
37
|
+
* - `"svg"`—If available, renders the component as an inline `svg` element.
|
|
38
|
+
* - `"canvas"`—If available, renders the component as a `canvas` element.
|
|
39
|
+
*/
|
|
40
|
+
renderAs?: RenderMode;
|
|
41
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { QRCodeProps } from './QRCodeProps';
|
|
3
|
+
import { Surface } from '@progress/kendo-drawing';
|
|
4
|
+
import { Group, ImageExportOptions, SVGExportOptions } from '@progress/kendo-drawing';
|
|
5
|
+
/**
|
|
6
|
+
* Represents the KendoReact QRCode component.
|
|
7
|
+
*/
|
|
8
|
+
export declare class QRCode extends React.Component<QRCodeProps, {}> {
|
|
9
|
+
private _baseBarcode;
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
readonly barcodeInstance: any;
|
|
14
|
+
/**
|
|
15
|
+
* The Drawing `Surface` of the Barcode.
|
|
16
|
+
*/
|
|
17
|
+
readonly surface: Surface | null;
|
|
18
|
+
/**
|
|
19
|
+
* The DOM element of the Barcode.
|
|
20
|
+
*/
|
|
21
|
+
readonly element: HTMLDivElement | null;
|
|
22
|
+
/**
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
render(): any;
|
|
26
|
+
/**
|
|
27
|
+
* Exports the component as an image. The export operation is asynchronous and returns a promise.
|
|
28
|
+
*
|
|
29
|
+
* @param {ImageExportOptions} options - The parameters for the exported image.
|
|
30
|
+
* @returns {Promise<string>} - A promise that will be resolved with a PNG image encoded as a Data URI.
|
|
31
|
+
*/
|
|
32
|
+
exportImage(options?: ImageExportOptions): Promise<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Exports the component as an SVG document. The export operation is asynchronous and returns a promise.
|
|
35
|
+
*
|
|
36
|
+
* @param options - The parameters for the exported file.
|
|
37
|
+
* @returns - A promise that will be resolved with an SVG document that is encoded as a Data URI.
|
|
38
|
+
*/
|
|
39
|
+
exportSVG(options?: SVGExportOptions): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Exports a Barcode component as a Drawing `Scene`.
|
|
42
|
+
*
|
|
43
|
+
* @param {any} options - The parameters for the export operation.
|
|
44
|
+
* @returns {Group} - A promise that returns the root `Group` of the scene.
|
|
45
|
+
*/
|
|
46
|
+
exportVisual(options?: any): Group;
|
|
47
|
+
private getTarget;
|
|
48
|
+
private deriveOptionsFromParent;
|
|
49
|
+
}
|