@mapples/ui 1.0.3 → 1.0.5
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/dist/components/form/FormView/FormView.d.ts +46 -0
- package/dist/components/form/FormView/FormView.d.ts.map +1 -0
- package/dist/components/form/FormView/FormView.js +38 -0
- package/dist/components/form/FormView/FormView.js.map +1 -0
- package/dist/components/form/FormView/index.d.ts +4 -0
- package/dist/components/form/FormView/index.d.ts.map +1 -0
- package/dist/components/form/FormView/index.js +4 -0
- package/dist/components/form/FormView/index.js.map +1 -0
- package/dist/components/form/FormView/schematics.d.ts +3 -0
- package/dist/components/form/FormView/schematics.d.ts.map +1 -0
- package/dist/components/form/FormView/schematics.js +6 -0
- package/dist/components/form/FormView/schematics.js.map +1 -0
- package/dist/components/form/SubmitButton/SubmitButton.d.ts +43 -0
- package/dist/components/form/SubmitButton/SubmitButton.d.ts.map +1 -0
- package/dist/components/form/SubmitButton/SubmitButton.js +35 -0
- package/dist/components/form/SubmitButton/SubmitButton.js.map +1 -0
- package/dist/components/form/SubmitButton/index.d.ts +5 -0
- package/dist/components/form/SubmitButton/index.d.ts.map +1 -0
- package/dist/components/form/SubmitButton/index.js +5 -0
- package/dist/components/form/SubmitButton/index.js.map +1 -0
- package/dist/components/form/SubmitButton/schematics.d.ts +11 -0
- package/dist/components/form/SubmitButton/schematics.d.ts.map +1 -0
- package/dist/components/form/SubmitButton/schematics.js +14 -0
- package/dist/components/form/SubmitButton/schematics.js.map +1 -0
- package/dist/components/form/TextField/TextField.d.ts +35 -0
- package/dist/components/form/TextField/TextField.d.ts.map +1 -0
- package/dist/components/form/TextField/TextField.js +36 -0
- package/dist/components/form/TextField/TextField.js.map +1 -0
- package/dist/components/form/TextField/index.d.ts +4 -0
- package/dist/components/form/TextField/index.d.ts.map +1 -0
- package/dist/components/form/TextField/index.js +4 -0
- package/dist/components/form/TextField/index.js.map +1 -0
- package/dist/components/form/TextField/schematics.d.ts +3 -0
- package/dist/components/form/TextField/schematics.d.ts.map +1 -0
- package/dist/components/form/TextField/schematics.js +6 -0
- package/dist/components/form/TextField/schematics.js.map +1 -0
- package/dist/components/form/index.d.ts +8 -0
- package/dist/components/form/index.d.ts.map +1 -0
- package/dist/components/form/index.js +8 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/form/schematics.d.ts +3 -0
- package/dist/components/form/schematics.d.ts.map +1 -0
- package/dist/components/form/schematics.js +9 -0
- package/dist/components/form/schematics.js.map +1 -0
- package/dist/components/media/BarCode/BarCode.d.ts +78 -0
- package/dist/components/media/BarCode/BarCode.d.ts.map +1 -0
- package/dist/components/media/BarCode/BarCode.js +127 -0
- package/dist/components/media/BarCode/BarCode.js.map +1 -0
- package/dist/components/media/BarCode/BarCodeEncoder.d.ts +56 -0
- package/dist/components/media/BarCode/BarCodeEncoder.d.ts.map +1 -0
- package/dist/components/media/BarCode/BarCodeEncoder.js +112 -0
- package/dist/components/media/BarCode/BarCodeEncoder.js.map +1 -0
- package/dist/components/media/BarCode/index.d.ts +4 -0
- package/dist/components/media/BarCode/index.d.ts.map +1 -0
- package/dist/components/media/BarCode/index.js +4 -0
- package/dist/components/media/BarCode/index.js.map +1 -0
- package/dist/components/media/BarCode/schematics.d.ts +3 -0
- package/dist/components/media/BarCode/schematics.d.ts.map +1 -0
- package/dist/components/media/BarCode/schematics.js +6 -0
- package/dist/components/media/BarCode/schematics.js.map +1 -0
- package/dist/components/media/Image/Image.d.ts +2 -0
- package/dist/components/media/Image/Image.d.ts.map +1 -1
- package/dist/components/media/Image/Image.js +24 -5
- package/dist/components/media/Image/Image.js.map +1 -1
- package/dist/components/media/QRCode/QRCode.d.ts +83 -0
- package/dist/components/media/QRCode/QRCode.d.ts.map +1 -0
- package/dist/components/media/QRCode/QRCode.js +42 -0
- package/dist/components/media/QRCode/QRCode.js.map +1 -0
- package/dist/components/media/QRCode/index.d.ts +4 -0
- package/dist/components/media/QRCode/index.d.ts.map +1 -0
- package/dist/components/media/QRCode/index.js +4 -0
- package/dist/components/media/QRCode/index.js.map +1 -0
- package/dist/components/media/QRCode/schematics.d.ts +3 -0
- package/dist/components/media/QRCode/schematics.d.ts.map +1 -0
- package/dist/components/media/QRCode/schematics.js +6 -0
- package/dist/components/media/QRCode/schematics.js.map +1 -0
- package/dist/components/media/index.d.ts +4 -0
- package/dist/components/media/index.d.ts.map +1 -1
- package/dist/components/media/index.js +4 -0
- package/dist/components/media/index.js.map +1 -1
- package/dist/components/media/schematics.d.ts.map +1 -1
- package/dist/components/media/schematics.js +4 -0
- package/dist/components/media/schematics.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { StyledView, Styler, } from '@mapples/style';
|
|
3
|
+
import Svg, { Rect } from 'react-native-svg';
|
|
4
|
+
import BarcodeEncoder from './BarCodeEncoder';
|
|
5
|
+
/**
|
|
6
|
+
* Generates barcode pattern using BarcodeEncoder
|
|
7
|
+
* Returns the encoded data and dimensions
|
|
8
|
+
*/
|
|
9
|
+
const generateBarcodeData = (value, format = 'CODE128', barWidth = 2) => {
|
|
10
|
+
if (!value)
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
// Use BarcodeEncoder to encode the value
|
|
14
|
+
const encoded = BarcodeEncoder.encode(value, format, {});
|
|
15
|
+
if (!encoded) {
|
|
16
|
+
console.warn('Failed to encode barcode value');
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const bars = [];
|
|
20
|
+
let x = 0;
|
|
21
|
+
// Handle array response (EAN13, EAN8, UPC)
|
|
22
|
+
if (Array.isArray(encoded)) {
|
|
23
|
+
// Concatenate all segment data strings
|
|
24
|
+
for (const segment of encoded) {
|
|
25
|
+
if (segment && segment.data) {
|
|
26
|
+
for (let i = 0; i < segment.data.length; i++) {
|
|
27
|
+
const digit = segment.data[i];
|
|
28
|
+
if (digit === '1') {
|
|
29
|
+
bars.push({ x, width: barWidth });
|
|
30
|
+
}
|
|
31
|
+
x += barWidth;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Handle single object response (CODE128, CODE39, etc.)
|
|
38
|
+
if (encoded.data) {
|
|
39
|
+
for (let i = 0; i < encoded.data.length; i++) {
|
|
40
|
+
const digit = encoded.data[i];
|
|
41
|
+
if (digit === '1') {
|
|
42
|
+
bars.push({ x, width: barWidth });
|
|
43
|
+
}
|
|
44
|
+
x += barWidth;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
bars,
|
|
50
|
+
totalWidth: x,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
55
|
+
console.error(`Error generating barcode (format: ${format}, value: ${value}):`, errorMessage);
|
|
56
|
+
// Log available formats for debugging
|
|
57
|
+
try {
|
|
58
|
+
const availableFormats = BarcodeEncoder.getAvailableFormats();
|
|
59
|
+
console.log('Available barcode formats:', availableFormats);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Ignore if getAvailableFormats fails
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Renders barcode bars from barcode data
|
|
69
|
+
*/
|
|
70
|
+
const renderBarcodeBars = (bars, height, foregroundColor) => {
|
|
71
|
+
return bars.map((bar, index) => (<Rect key={index} x={bar.x} y={0} width={bar.width} height={height} fill={foregroundColor}/>));
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A customizable barcode component with built-in styling support.
|
|
75
|
+
*
|
|
76
|
+
* The BarCode component renders a barcode using BarcodeEncoder for generation
|
|
77
|
+
* and react-native-svg for rendering. It supports customizable styling
|
|
78
|
+
* through the @mapples/style system.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* <BarCode
|
|
83
|
+
* value="123456789"
|
|
84
|
+
* height={100}
|
|
85
|
+
* width={2}
|
|
86
|
+
* styled={{
|
|
87
|
+
* style: {
|
|
88
|
+
* width: 300,
|
|
89
|
+
* height: 100,
|
|
90
|
+
* alignItems: 'center',
|
|
91
|
+
* justifyContent: 'center',
|
|
92
|
+
* },
|
|
93
|
+
* }}
|
|
94
|
+
* />
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
const BarCode = forwardRef(({ styled, value = '', height = 100, width = 2, backgroundColor = 'transparent', foregroundColor = '#000000', format = 'CODE128', ...props }, ref) => {
|
|
100
|
+
const { styleSvg, ...styledProps } = styled || {};
|
|
101
|
+
const barcodeData = useMemo(() => generateBarcodeData(value, format, width), [value, format, width]);
|
|
102
|
+
const bars = useMemo(() => {
|
|
103
|
+
if (!barcodeData)
|
|
104
|
+
return [];
|
|
105
|
+
return renderBarcodeBars(barcodeData.bars, height, foregroundColor);
|
|
106
|
+
}, [barcodeData, height, foregroundColor]);
|
|
107
|
+
const svgStyle = useMemo(() => {
|
|
108
|
+
const flattened = styleSvg ? Styler.flatten(styleSvg) : {};
|
|
109
|
+
return {
|
|
110
|
+
backgroundColor,
|
|
111
|
+
...flattened,
|
|
112
|
+
};
|
|
113
|
+
}, [styleSvg, backgroundColor]);
|
|
114
|
+
if (!barcodeData || bars.length === 0) {
|
|
115
|
+
return (<StyledView ref={ref} styled={styledProps} {...props}>
|
|
116
|
+
{/* Empty state - no barcode to display */}
|
|
117
|
+
</StyledView>);
|
|
118
|
+
}
|
|
119
|
+
return (<StyledView ref={ref} styled={styledProps} {...props}>
|
|
120
|
+
<Svg width={barcodeData.totalWidth} height={height} viewBox={`0 0 ${barcodeData.totalWidth} ${height}`} style={svgStyle}>
|
|
121
|
+
{bars}
|
|
122
|
+
</Svg>
|
|
123
|
+
</StyledView>);
|
|
124
|
+
});
|
|
125
|
+
BarCode.displayName = 'BarCode';
|
|
126
|
+
export default BarCode;
|
|
127
|
+
//# sourceMappingURL=BarCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarCode.js","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmC,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAGL,UAAU,EACV,MAAM,GAEP,MAAM,gBAAgB,CAAC;AAExB,OAAO,GAAG,EAAE,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAEvD,OAAO,cAAsC,MAAM,kBAAkB,CAAC;AA6BtE;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAC1B,KAAa,EACb,SAAwB,SAAS,EACjC,WAAmB,CAAC,EAIb,EAAE;IACT,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,IAAI,CAAC;QACH,yCAAyC;QACzC,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAmC,EAAE,CAAC;QAChD,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,2CAA2C;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,uCAAuC;YACvC,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;gBAC9B,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;oBAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,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|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported barcode formats
|
|
3
|
+
*/
|
|
4
|
+
export type BarcodeFormat = 'CODE128' | 'CODE39' | 'EAN13' | 'EAN8' | 'UPC' | 'ITF14' | 'MSI' | 'pharmacode' | 'codabar';
|
|
5
|
+
/**
|
|
6
|
+
* Options for barcode encoding
|
|
7
|
+
*/
|
|
8
|
+
export interface BarcodeEncodeOptions {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Encoded barcode segment (used for EAN13, EAN8, UPC)
|
|
13
|
+
*/
|
|
14
|
+
export interface EncodedBarcodeSegment {
|
|
15
|
+
/** Binary string representation where '1' = bar, '0' = space */
|
|
16
|
+
data: string;
|
|
17
|
+
/** Optional text for this segment */
|
|
18
|
+
text?: string;
|
|
19
|
+
/** Optional segment-specific options */
|
|
20
|
+
options?: {
|
|
21
|
+
height?: number | null;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Encoded barcode data structure
|
|
27
|
+
* Can be a single object (CODE128, CODE39) or array of segments (EAN13, EAN8, UPC)
|
|
28
|
+
*/
|
|
29
|
+
export type EncodedBarcode = {
|
|
30
|
+
/** The original text value */
|
|
31
|
+
text: string;
|
|
32
|
+
/** Binary string representation where '1' = bar, '0' = space */
|
|
33
|
+
data: string;
|
|
34
|
+
} | EncodedBarcodeSegment[];
|
|
35
|
+
/**
|
|
36
|
+
* Barcode encoder class that wraps jsbarcode functionality
|
|
37
|
+
*/
|
|
38
|
+
declare class BarcodeEncoder {
|
|
39
|
+
/**
|
|
40
|
+
* Encodes text into a barcode binary pattern
|
|
41
|
+
*
|
|
42
|
+
* @param text - The text value to encode
|
|
43
|
+
* @param format - The barcode format to use
|
|
44
|
+
* @param options - Additional encoding options
|
|
45
|
+
* @returns Encoded barcode data with text and binary pattern (or array of segments for EAN/UPC)
|
|
46
|
+
* @throws Error if text is invalid, format is not supported, or encoding fails
|
|
47
|
+
*/
|
|
48
|
+
encode(text: string, format: BarcodeFormat, options?: BarcodeEncodeOptions): EncodedBarcode;
|
|
49
|
+
/**
|
|
50
|
+
* Gets list of available barcode formats
|
|
51
|
+
*/
|
|
52
|
+
getAvailableFormats(): string[];
|
|
53
|
+
}
|
|
54
|
+
declare const _default: BarcodeEncoder;
|
|
55
|
+
export default _default;
|
|
56
|
+
//# sourceMappingURL=BarCodeEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarCodeEncoder.d.ts","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCodeEncoder.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,GACN,KAAK,GACL,OAAO,GACP,KAAK,GACL,YAAY,GACZ,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IACE,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd,GACD,qBAAqB,EAAE,CAAC;AA0D5B;;GAEG;AACH,cAAM,cAAc;IAClB;;;;;;;;OAQG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,oBAAyB,GACjC,cAAc;IA6DjB;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE;CAGhC;;AAED,wBAAoC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @ts-expect-error - jsbarcode/src/barcodes doesn't have type definitions
|
|
2
|
+
import barcodes from 'jsbarcode/src/barcodes';
|
|
3
|
+
/**
|
|
4
|
+
* Maps format names to jsbarcode format names
|
|
5
|
+
* Some formats might have different names in jsbarcode
|
|
6
|
+
*/
|
|
7
|
+
const FORMAT_MAP = {
|
|
8
|
+
CODE128: 'CODE128',
|
|
9
|
+
CODE39: 'CODE39',
|
|
10
|
+
EAN13: 'EAN13',
|
|
11
|
+
EAN8: 'EAN8',
|
|
12
|
+
UPC: 'UPC', // jsbarcode uses 'UPC' not 'UPC-A'
|
|
13
|
+
ITF14: 'ITF14', // jsbarcode uses 'ITF14' not 'ITF'
|
|
14
|
+
MSI: 'MSI',
|
|
15
|
+
pharmacode: 'pharmacode',
|
|
16
|
+
codabar: 'codabar',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Tries to find the correct format name in jsbarcode
|
|
20
|
+
* Handles case variations and common aliases
|
|
21
|
+
*/
|
|
22
|
+
const findFormat = (format, barcodes) => {
|
|
23
|
+
const mappedFormat = FORMAT_MAP[format];
|
|
24
|
+
if (barcodes[mappedFormat]) {
|
|
25
|
+
return mappedFormat;
|
|
26
|
+
}
|
|
27
|
+
const formatLower = format.toLowerCase();
|
|
28
|
+
for (const key in barcodes) {
|
|
29
|
+
if (key.toLowerCase() === formatLower) {
|
|
30
|
+
return key;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Try common aliases
|
|
34
|
+
const aliases = {
|
|
35
|
+
UPC: ['UPC-A', 'UPCA'],
|
|
36
|
+
ITF14: ['ITF', 'ITF-14'],
|
|
37
|
+
EAN13: ['EAN-13', 'EAN_13'],
|
|
38
|
+
EAN8: ['EAN-8', 'EAN_8'],
|
|
39
|
+
};
|
|
40
|
+
const formatAliases = aliases[format];
|
|
41
|
+
if (formatAliases) {
|
|
42
|
+
for (const alias of formatAliases) {
|
|
43
|
+
if (barcodes[alias]) {
|
|
44
|
+
return alias;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Barcode encoder class that wraps jsbarcode functionality
|
|
52
|
+
*/
|
|
53
|
+
class BarcodeEncoder {
|
|
54
|
+
/**
|
|
55
|
+
* Encodes text into a barcode binary pattern
|
|
56
|
+
*
|
|
57
|
+
* @param text - The text value to encode
|
|
58
|
+
* @param format - The barcode format to use
|
|
59
|
+
* @param options - Additional encoding options
|
|
60
|
+
* @returns Encoded barcode data with text and binary pattern (or array of segments for EAN/UPC)
|
|
61
|
+
* @throws Error if text is invalid, format is not supported, or encoding fails
|
|
62
|
+
*/
|
|
63
|
+
encode(text, format, options = {}) {
|
|
64
|
+
// Find the correct format name in jsbarcode
|
|
65
|
+
const jsbarcodeFormat = findFormat(format, barcodes);
|
|
66
|
+
if (!jsbarcodeFormat) {
|
|
67
|
+
const availableFormats = Object.keys(barcodes).join(', ');
|
|
68
|
+
throw new Error(`Barcode format "${format}" not found. Available formats: ${availableFormats}`);
|
|
69
|
+
}
|
|
70
|
+
const Encoder = barcodes[jsbarcodeFormat];
|
|
71
|
+
if (text.length === 0) {
|
|
72
|
+
throw new Error('Barcode value must be a non-empty string');
|
|
73
|
+
}
|
|
74
|
+
let encoder;
|
|
75
|
+
try {
|
|
76
|
+
encoder = new Encoder(text, options);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
80
|
+
throw new Error(`Invalid barcode format: ${errorMessage}`);
|
|
81
|
+
}
|
|
82
|
+
if (!encoder.valid()) {
|
|
83
|
+
throw new Error('Invalid barcode for selected format.');
|
|
84
|
+
}
|
|
85
|
+
const encoded = encoder.encode();
|
|
86
|
+
// Handle array response (EAN13, EAN8, UPC)
|
|
87
|
+
if (Array.isArray(encoded)) {
|
|
88
|
+
// Validate array structure
|
|
89
|
+
if (!encoded.every((segment) => segment &&
|
|
90
|
+
typeof segment === 'object' &&
|
|
91
|
+
typeof segment.data === 'string')) {
|
|
92
|
+
throw new Error('Invalid barcode data structure');
|
|
93
|
+
}
|
|
94
|
+
return encoded;
|
|
95
|
+
}
|
|
96
|
+
// Handle single object response (CODE128, CODE39, etc.)
|
|
97
|
+
if (encoded &&
|
|
98
|
+
typeof encoded === 'object' &&
|
|
99
|
+
typeof encoded.data === 'string') {
|
|
100
|
+
return encoded;
|
|
101
|
+
}
|
|
102
|
+
throw new Error('Failed to encode barcode data');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Gets list of available barcode formats
|
|
106
|
+
*/
|
|
107
|
+
getAvailableFormats() {
|
|
108
|
+
return Object.keys(barcodes);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export default new BarcodeEncoder();
|
|
112
|
+
//# sourceMappingURL=BarCodeEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarCodeEncoder.js","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCodeEncoder.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAmD9C;;;GAGG;AACH,MAAM,UAAU,GAAkC;IAChD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK,EAAE,mCAAmC;IAC/C,KAAK,EAAE,OAAO,EAAE,mCAAmC;IACnD,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,MAAqB,EAC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ChC,CAAC;YACD,OAAO,OAAyC,CAAC;QACnD,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;CACF;AAED,eAAe,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/media/BarCode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/media/BarCode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematics.d.ts","sourceRoot":"","sources":["../../../../src/components/media/BarCode/schematics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD,eAAO,MAAM,gBAAgB,EAAE,mBAG9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematics.js","sourceRoot":"","sources":["../../../../src/components/media/BarCode/schematics.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,MAAM,gBAAgB,GAAwB;IACnD,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,OAAO;CACnB,CAAC"}
|
|
@@ -12,6 +12,7 @@ export type ImageProps = PropsWithChildren<Omit<WithStyledProps<ExpoImageProps>,
|
|
|
12
12
|
styled?: StyledProps<ViewProps> & {
|
|
13
13
|
/** Image-specific styling */
|
|
14
14
|
styleImage?: StyledProp<ImageStyle>;
|
|
15
|
+
styledImageProps?: StyledProps<ExpoImageProps>;
|
|
15
16
|
};
|
|
16
17
|
/** Alternative data source for the image */
|
|
17
18
|
dataSource?: string;
|
|
@@ -48,6 +49,7 @@ declare const Image: import("react").ForwardRefExoticComponent<Omit<WithStyledPr
|
|
|
48
49
|
styled?: StyledProps<ViewProps> & {
|
|
49
50
|
/** Image-specific styling */
|
|
50
51
|
styleImage?: StyledProp<ImageStyle>;
|
|
52
|
+
styledImageProps?: StyledProps<ExpoImageProps>;
|
|
51
53
|
};
|
|
52
54
|
/** Alternative data source for the image */
|
|
53
55
|
dataSource?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/components/media/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAEL,UAAU,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../src/components/media/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAEL,UAAU,EACV,WAAW,EAIX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAsB,UAAU,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,iBAAiB,CACxC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,GAAG;IAChD,qEAAqE;IACrE,MAAM,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG;QAChC,6BAA6B;QAC7B,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QACpC,gBAAgB,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;KAChD,CAAC;IACF,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CACF,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,KAAK;IAxCP,qEAAqE;aAC5D,WAAW,CAAC,SAAS,CAAC,GAAG;QAChC,6BAA6B;QAC7B,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QACpC,gBAAgB,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;KAChD;IACD,4CAA4C;iBAC/B,MAAM;;;2CAyDtB,CAAC;AAkBF,eAAe,KAAK,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import { styled, StyledView, } from '@mapples/style';
|
|
2
|
+
import { styled, StyledView, Styler, Typography, } from '@mapples/style';
|
|
3
3
|
import { Image as ExpoImage } from 'expo-image';
|
|
4
4
|
const StyledExpoImage = styled(ExpoImage);
|
|
5
5
|
/**
|
|
@@ -29,12 +29,31 @@ const StyledExpoImage = styled(ExpoImage);
|
|
|
29
29
|
*
|
|
30
30
|
* @public
|
|
31
31
|
*/
|
|
32
|
-
const Image = forwardRef(({ styled, source,
|
|
33
|
-
const { styleImage, ...styledProps } = styled || {};
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const Image = forwardRef(({ styled, source, dataSource, alt, ...props }, ref) => {
|
|
33
|
+
const { styleImage, styledImageProps, ...styledProps } = styled || {};
|
|
34
|
+
const image = dataSource || source;
|
|
35
|
+
return (<StyledView ref={ref} styled={styledProps}>
|
|
36
|
+
{!!image ? (<StyledExpoImage source={image} styled={{ style: styleImage, ...(styledImageProps || {}) }} {...props}/>) : (<StyledView styled={{ style: styler.imagePlaceholder }}>
|
|
37
|
+
<Typography style={styler.imagePlaceholderText}>
|
|
38
|
+
{alt || 'IMAGE'}
|
|
39
|
+
</Typography>
|
|
40
|
+
</StyledView>)}
|
|
36
41
|
</StyledView>);
|
|
37
42
|
});
|
|
38
43
|
Image.displayName = 'Image';
|
|
44
|
+
const styler = Styler.create({
|
|
45
|
+
imagePlaceholder: {
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: '100%',
|
|
48
|
+
backgroundColor: '#eee',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
},
|
|
52
|
+
imagePlaceholderText: {
|
|
53
|
+
fontSize: 24,
|
|
54
|
+
fontWeight: 'bold',
|
|
55
|
+
color: '#fafafa',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
39
58
|
export default Image;
|
|
40
59
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/components/media/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EACL,MAAM,EAGN,UAAU,GAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,IAAI,SAAS,EAAgC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/components/media/Image/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EACL,MAAM,EAGN,UAAU,EACV,MAAM,EACN,UAAU,GAEX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,IAAI,SAAS,EAAgC,MAAM,YAAY,CAAC;AAqB9E,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,KAAK,GAAG,UAAU,CACtB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAA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H,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { StyledProp, StyledProps, WithStyledProps } from '@mapples/style';
|
|
3
|
+
import { View, ViewProps } from 'react-native';
|
|
4
|
+
import { SvgProps } from 'react-native-svg';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the QRCode component.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type QRCodeProps = PropsWithChildren<Omit<WithStyledProps<ViewProps>, 'styled'> & {
|
|
11
|
+
/** Styling configuration for the QR code container and SVG */
|
|
12
|
+
styled?: StyledProps<ViewProps> & {
|
|
13
|
+
/** SVG-specific styling */
|
|
14
|
+
styleSvg?: StyledProp<SvgProps>;
|
|
15
|
+
};
|
|
16
|
+
/** The value to encode as a QR code */
|
|
17
|
+
value?: string;
|
|
18
|
+
/** Size of the QR code (width and height) */
|
|
19
|
+
size?: number;
|
|
20
|
+
/** Background color of the QR code */
|
|
21
|
+
backgroundColor?: string;
|
|
22
|
+
/** Foreground color of the QR code */
|
|
23
|
+
color?: string;
|
|
24
|
+
/** Error correction level */
|
|
25
|
+
ecl?: 'L' | 'M' | 'Q' | 'H';
|
|
26
|
+
/** Logo to display in the center of the QR code */
|
|
27
|
+
logo?: string;
|
|
28
|
+
/** Size of the logo */
|
|
29
|
+
logoSize?: number;
|
|
30
|
+
/** Margin around the QR code */
|
|
31
|
+
quietZone?: number;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* A customizable QR code component with built-in styling support.
|
|
35
|
+
*
|
|
36
|
+
* The QRCode component renders a QR code using react-native-svg.
|
|
37
|
+
* It supports customizable styling through the @mapples/style system.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <QRCode
|
|
42
|
+
* value="https://example.com"
|
|
43
|
+
* size={200}
|
|
44
|
+
* styled={{
|
|
45
|
+
* style: {
|
|
46
|
+
* width: 200,
|
|
47
|
+
* height: 200,
|
|
48
|
+
* alignItems: 'center',
|
|
49
|
+
* justifyContent: 'center',
|
|
50
|
+
* },
|
|
51
|
+
* }}
|
|
52
|
+
* />
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
declare const QRCode: import("react").ForwardRefExoticComponent<Omit<WithStyledProps<ViewProps>, "styled"> & {
|
|
58
|
+
/** Styling configuration for the QR code container and SVG */
|
|
59
|
+
styled?: StyledProps<ViewProps> & {
|
|
60
|
+
/** SVG-specific styling */
|
|
61
|
+
styleSvg?: StyledProp<SvgProps>;
|
|
62
|
+
};
|
|
63
|
+
/** The value to encode as a QR code */
|
|
64
|
+
value?: string;
|
|
65
|
+
/** Size of the QR code (width and height) */
|
|
66
|
+
size?: number;
|
|
67
|
+
/** Background color of the QR code */
|
|
68
|
+
backgroundColor?: string;
|
|
69
|
+
/** Foreground color of the QR code */
|
|
70
|
+
color?: string;
|
|
71
|
+
/** Error correction level */
|
|
72
|
+
ecl?: "L" | "M" | "Q" | "H";
|
|
73
|
+
/** Logo to display in the center of the QR code */
|
|
74
|
+
logo?: string;
|
|
75
|
+
/** Size of the logo */
|
|
76
|
+
logoSize?: number;
|
|
77
|
+
/** Margin around the QR code */
|
|
78
|
+
quietZone?: number;
|
|
79
|
+
} & {
|
|
80
|
+
children?: import("react").ReactNode | undefined;
|
|
81
|
+
} & import("react").RefAttributes<View>>;
|
|
82
|
+
export default QRCode;
|
|
83
|
+
//# sourceMappingURL=QRCode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QRCode.d.ts","sourceRoot":"","sources":["../../../../src/components/media/QRCode/QRCode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,UAAU,EACV,WAAW,EAGX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OA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BAAuB;eACZ,MAAM;IACjB,gCAAgC;gBACpB,MAAM;;;wCAsErB,CAAC;AAGF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { StyledView, Styler, } from '@mapples/style';
|
|
3
|
+
import QRCodeSvg from 'react-native-qrcode-svg';
|
|
4
|
+
/**
|
|
5
|
+
* A customizable QR code component with built-in styling support.
|
|
6
|
+
*
|
|
7
|
+
* The QRCode component renders a QR code using react-native-svg.
|
|
8
|
+
* It supports customizable styling through the @mapples/style system.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <QRCode
|
|
13
|
+
* value="https://example.com"
|
|
14
|
+
* size={200}
|
|
15
|
+
* styled={{
|
|
16
|
+
* style: {
|
|
17
|
+
* width: 200,
|
|
18
|
+
* height: 200,
|
|
19
|
+
* alignItems: 'center',
|
|
20
|
+
* justifyContent: 'center',
|
|
21
|
+
* },
|
|
22
|
+
* }}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
const QRCode = forwardRef(({ styled, value = '', size = 200, backgroundColor = '#FFFFFF', color = '#000000', ecl = 'M', logo, logoSize, quietZone, ...props }, ref) => {
|
|
29
|
+
const { styleSvg, ...styledProps } = styled || {};
|
|
30
|
+
const svgStyle = useMemo(() => {
|
|
31
|
+
const flattened = styleSvg ? Styler.flatten(styleSvg) : {};
|
|
32
|
+
return {
|
|
33
|
+
...flattened,
|
|
34
|
+
};
|
|
35
|
+
}, [styleSvg]);
|
|
36
|
+
return (<StyledView ref={ref} styled={styledProps} {...props}>
|
|
37
|
+
{value && (<QRCodeSvg value={value} size={size} color={color} backgroundColor={backgroundColor} ecl={ecl} logo={logo ? { uri: logo } : undefined} logoSize={logoSize} quietZone={quietZone}/>)}
|
|
38
|
+
</StyledView>);
|
|
39
|
+
});
|
|
40
|
+
QRCode.displayName = 'QRCode';
|
|
41
|
+
export default QRCode;
|
|
42
|
+
//# sourceMappingURL=QRCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QRCode.js","sourceRoot":"","sources":["../../../../src/components/media/QRCode/QRCode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,OAAO,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAGL,UAAU,EACV,MAAM,GAEP,MAAM,gBAAgB,CAAC;AAExB,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAkChD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,GAAG,UAAU,CACvB,CACE,EACE,MAAM,EACN,KAAK,GAAG,EAAE,EACV,IAAI,GAAG,GAAG,EACV,eAAe,GAAG,SAAS,EAC3B,KAAK,GAAG,SAAS,EACjB,GAAG,GAAG,GAAG,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IAElD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO;YACL,GAAI,SAAqC;SAC1C,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,CACnD;QAAA,CAAC,KAAK,IAAI,CACR,CAAC,SAAS,CACR,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,IAAI,CAAC,CAAC,IAAI,CAAC,CACX,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CACvC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,SAAS,CAAC,CAAC,SAAS,CAAC,EACrB,CACH,CACH;MAAA,EAAE,UAAU,CAAC,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AACF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;AAE9B,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/media/QRCode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,cAAc,UAAU,CAAC;AAEzB,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/media/QRCode/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,cAAc,UAAU,CAAC;AAEzB,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematics.d.ts","sourceRoot":"","sources":["../../../../src/components/media/QRCode/schematics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD,eAAO,MAAM,eAAe,EAAE,mBAG7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schematics.js","sourceRoot":"","sources":["../../../../src/components/media/QRCode/schematics.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAwB;IAClD,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,MAAM;CAClB,CAAC"}
|
|
@@ -4,5 +4,9 @@ export { default as Image } from './Image';
|
|
|
4
4
|
export * from './Image';
|
|
5
5
|
export { default as Icon } from './Icon';
|
|
6
6
|
export * from './Icon';
|
|
7
|
+
export { default as BarCode } from './BarCode';
|
|
8
|
+
export * from './BarCode';
|
|
9
|
+
export { default as QRCode } from './QRCode';
|
|
10
|
+
export * from './QRCode';
|
|
7
11
|
export * from './schematics';
|
|
8
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,cAAc,UAAU,CAAC;AAEzB,cAAc,cAAc,CAAC"}
|
|
@@ -4,5 +4,9 @@ export { default as Image } from './Image';
|
|
|
4
4
|
export * from './Image';
|
|
5
5
|
export { default as Icon } from './Icon';
|
|
6
6
|
export * from './Icon';
|
|
7
|
+
export { default as BarCode } from './BarCode';
|
|
8
|
+
export * from './BarCode';
|
|
9
|
+
export { default as QRCode } from './QRCode';
|
|
10
|
+
export * from './QRCode';
|
|
7
11
|
export * from './schematics';
|
|
8
12
|
//# sourceMappingURL=index.js.map
|