react-id-card-generator 1.0.15 → 1.0.17
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.
|
@@ -30,7 +30,59 @@ const IDCardGenerator = ({ template, data, side = 'front', scale = 1, className
|
|
|
30
30
|
// Render a single field
|
|
31
31
|
const renderField = (field) => {
|
|
32
32
|
const posStyle = styleUtils.positionToStyle(field.position);
|
|
33
|
-
|
|
33
|
+
let fieldStyle = styleUtils.fieldStyleToCSS(field.style);
|
|
34
|
+
// Determine flex direction and alignment for text fields
|
|
35
|
+
let flexDirection = 'column';
|
|
36
|
+
if (field.type === 'text' && field.style?.labelPosition === 'left')
|
|
37
|
+
flexDirection = 'row';
|
|
38
|
+
// Map verticalAlign and textAlign to flex properties
|
|
39
|
+
let justifyContent = 'flex-start';
|
|
40
|
+
let alignItems = 'flex-start';
|
|
41
|
+
if (field.type === 'text') {
|
|
42
|
+
const textAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';
|
|
43
|
+
const verticalAlign = field.style?.verticalAlign || 'top';
|
|
44
|
+
if (flexDirection === 'column') {
|
|
45
|
+
// For column: verticalAlign controls justifyContent (vertical), textAlign controls alignItems (horizontal)
|
|
46
|
+
if (verticalAlign === 'middle')
|
|
47
|
+
justifyContent = 'center';
|
|
48
|
+
else if (verticalAlign === 'bottom')
|
|
49
|
+
justifyContent = 'flex-end';
|
|
50
|
+
else
|
|
51
|
+
justifyContent = 'flex-start';
|
|
52
|
+
if (textAlign === 'center')
|
|
53
|
+
alignItems = 'center';
|
|
54
|
+
else if (textAlign === 'right')
|
|
55
|
+
alignItems = 'flex-end';
|
|
56
|
+
else
|
|
57
|
+
alignItems = 'flex-start';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// For row: don't set alignItems on container if individual alignments are specified
|
|
61
|
+
// Let labelAlignSelf and textAlignSelf handle it
|
|
62
|
+
if (field.style?.labelVerticalAlign || field.style?.textVerticalAlign) {
|
|
63
|
+
alignItems = undefined;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Fall back to general verticalAlign if individual ones aren't specified
|
|
67
|
+
if (verticalAlign === 'middle')
|
|
68
|
+
alignItems = 'center';
|
|
69
|
+
else if (verticalAlign === 'bottom')
|
|
70
|
+
alignItems = 'flex-end';
|
|
71
|
+
else
|
|
72
|
+
alignItems = 'flex-start';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Remove fontSize for label fields so text field font size does not affect them
|
|
77
|
+
if (field.type === 'label' && fieldStyle.fontSize) {
|
|
78
|
+
const { fontSize, ...rest } = fieldStyle;
|
|
79
|
+
fieldStyle = rest;
|
|
80
|
+
}
|
|
81
|
+
// Remove textTransform from container for text and label fields - applied directly to spans
|
|
82
|
+
if ((field.type === 'text' || field.type === 'label') && fieldStyle.textTransform) {
|
|
83
|
+
const { textTransform, ...rest } = fieldStyle;
|
|
84
|
+
fieldStyle = rest;
|
|
85
|
+
}
|
|
34
86
|
const combinedStyle = {
|
|
35
87
|
...posStyle,
|
|
36
88
|
...fieldStyle,
|
|
@@ -38,6 +90,10 @@ const IDCardGenerator = ({ template, data, side = 'front', scale = 1, className
|
|
|
38
90
|
boxSizing: 'border-box',
|
|
39
91
|
overflow: 'hidden',
|
|
40
92
|
cursor: editable ? 'pointer' : 'default',
|
|
93
|
+
display: field.type === 'text' ? 'flex' : undefined,
|
|
94
|
+
flexDirection: field.type === 'text' ? flexDirection : undefined,
|
|
95
|
+
justifyContent: field.type === 'text' ? justifyContent : undefined,
|
|
96
|
+
alignItems: field.type === 'text' ? alignItems : undefined,
|
|
41
97
|
};
|
|
42
98
|
const handleClick = (e) => {
|
|
43
99
|
if (onFieldClick) {
|
|
@@ -47,10 +103,86 @@ const IDCardGenerator = ({ template, data, side = 'front', scale = 1, className
|
|
|
47
103
|
};
|
|
48
104
|
const value = getFieldValue(field, data);
|
|
49
105
|
switch (field.type) {
|
|
50
|
-
case 'text':
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
106
|
+
case 'text': {
|
|
107
|
+
// Label style properties
|
|
108
|
+
let labelFontSize = field.style?.labelFontSize;
|
|
109
|
+
if (!labelFontSize || labelFontSize === '0.75em') {
|
|
110
|
+
labelFontSize = '12px';
|
|
111
|
+
}
|
|
112
|
+
else if (!labelFontSize.endsWith('px')) {
|
|
113
|
+
const num = parseFloat(labelFontSize);
|
|
114
|
+
if (!isNaN(num))
|
|
115
|
+
labelFontSize = num + 'px';
|
|
116
|
+
else
|
|
117
|
+
labelFontSize = '12px';
|
|
118
|
+
}
|
|
119
|
+
const labelFontWeight = field.style?.labelFontWeight || 'normal';
|
|
120
|
+
const labelColor = field.style?.labelColor || '#666666';
|
|
121
|
+
const labelTextTransform = field.style?.labelTextTransform || 'none';
|
|
122
|
+
const labelTextAlign = field.style?.labelTextAlign || 'left';
|
|
123
|
+
// Text/value style properties (separate from label)
|
|
124
|
+
const textFontSize = field.style?.textFontSize || field.style?.fontSize || '1em';
|
|
125
|
+
const textFontWeight = field.style?.textFontWeight || field.style?.fontWeight || 'normal';
|
|
126
|
+
const textColor = field.style?.textColor || field.style?.color || '#000000';
|
|
127
|
+
const textTextTransform = field.style?.textTransform || 'none';
|
|
128
|
+
const textTextAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';
|
|
129
|
+
// For row layout (label on left), use individual span alignment
|
|
130
|
+
if (field.style?.labelPosition === 'left') {
|
|
131
|
+
let labelAlignSelf = 'flex-start';
|
|
132
|
+
if (field.style?.labelVerticalAlign === 'middle')
|
|
133
|
+
labelAlignSelf = 'center';
|
|
134
|
+
else if (field.style?.labelVerticalAlign === 'bottom')
|
|
135
|
+
labelAlignSelf = 'flex-end';
|
|
136
|
+
let textAlignSelf = 'flex-start';
|
|
137
|
+
if (field.style?.textVerticalAlign === 'middle')
|
|
138
|
+
textAlignSelf = 'center';
|
|
139
|
+
else if (field.style?.textVerticalAlign === 'bottom')
|
|
140
|
+
textAlignSelf = 'flex-end';
|
|
141
|
+
const labelStyle = {
|
|
142
|
+
fontSize: labelFontSize,
|
|
143
|
+
fontWeight: labelFontWeight,
|
|
144
|
+
color: labelColor,
|
|
145
|
+
opacity: 0.7,
|
|
146
|
+
marginRight: 8,
|
|
147
|
+
alignSelf: labelAlignSelf,
|
|
148
|
+
whiteSpace: 'nowrap',
|
|
149
|
+
textTransform: labelTextTransform
|
|
150
|
+
};
|
|
151
|
+
const textStyle = {
|
|
152
|
+
textTransform: textTextTransform,
|
|
153
|
+
fontSize: textFontSize,
|
|
154
|
+
fontWeight: textFontWeight,
|
|
155
|
+
color: textColor,
|
|
156
|
+
alignSelf: textAlignSelf
|
|
157
|
+
};
|
|
158
|
+
return (jsxRuntime.jsxs("div", { id: field.id, style: combinedStyle, onClick: handleClick, className: "idcard-field idcard-field-text", children: [field.label && (jsxRuntime.jsx("span", { className: "idcard-field-label", style: labelStyle, children: field.label })), jsxRuntime.jsx("span", { style: { width: '100%', textAlign: textTextAlign }, children: jsxRuntime.jsx("span", { className: "idcard-field-value", style: textStyle, children: String(value || field.placeholder || '') }) })] }, field.id));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// For column layout (label on top), let container alignment handle positioning
|
|
162
|
+
const labelStyle = {
|
|
163
|
+
fontSize: labelFontSize,
|
|
164
|
+
fontWeight: labelFontWeight,
|
|
165
|
+
color: labelColor,
|
|
166
|
+
opacity: 0.7,
|
|
167
|
+
textTransform: labelTextTransform,
|
|
168
|
+
width: '100%',
|
|
169
|
+
textAlign: labelTextAlign
|
|
170
|
+
};
|
|
171
|
+
const textStyle = {
|
|
172
|
+
textTransform: textTextTransform,
|
|
173
|
+
fontSize: textFontSize,
|
|
174
|
+
fontWeight: textFontWeight,
|
|
175
|
+
color: textColor,
|
|
176
|
+
width: '100%',
|
|
177
|
+
textAlign: textTextAlign
|
|
178
|
+
};
|
|
179
|
+
return (jsxRuntime.jsxs("div", { id: field.id, style: combinedStyle, onClick: handleClick, className: "idcard-field idcard-field-text", children: [field.label && (jsxRuntime.jsx("span", { className: "idcard-field-label", style: labelStyle, children: field.label })), jsxRuntime.jsx("span", { className: "idcard-field-value", style: textStyle, children: String(value || field.placeholder || '') })] }, field.id));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
case 'label': {
|
|
183
|
+
const labelTextTransform = field.style?.labelTextTransform || 'none';
|
|
184
|
+
return (jsxRuntime.jsx("div", { id: field.id, style: combinedStyle, onClick: handleClick, className: "idcard-field idcard-field-label", children: jsxRuntime.jsx("span", { style: { textTransform: labelTextTransform }, children: field.staticText || field.label || '' }) }, field.id));
|
|
185
|
+
}
|
|
54
186
|
case 'image':
|
|
55
187
|
return (jsxRuntime.jsx("div", { id: field.id, style: combinedStyle, onClick: handleClick, children: value ? (jsxRuntime.jsx("img", { src: String(value), alt: field.label || 'Image', style: {
|
|
56
188
|
width: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDCardGenerator.js","sources":["../../../src/components/IDCardGenerator.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\nimport type { IDCardGeneratorProps, FieldMapping, IDCardData, IDCardTemplate } from '../types';\r\nimport { fieldStyleToCSS, positionToStyle } from '../utils/styleUtils';\r\nimport { generateQrCodeFromFields } from '../core/qrUtils';\r\n\r\n/**\r\n * IDCardGenerator - Renders a completed ID card\r\n * \r\n * Takes a template and user data, then renders the filled card.\r\n * This is the component used to display actual ID cards for individual users.\r\n * \r\n * Example:\r\n * ```tsx\r\n * <IDCardGenerator \r\n * template={myTemplate}\r\n * data={{ name: 'John Doe', photo: '...' }}\r\n * side=\"front\"\r\n * />\r\n * ```\r\n */\r\nexport const IDCardGenerator: React.FC<IDCardGeneratorProps> = ({\r\n template,\r\n data,\r\n side = 'front',\r\n scale = 1,\r\n className = '',\r\n style = {},\r\n onFieldClick,\r\n editable = false,\r\n}: IDCardGeneratorProps) => {\r\n // Get fields for the current side only\r\n const fieldsToRender = useMemo(() => {\r\n return template.fields.filter((field: FieldMapping) => field.side === side);\r\n }, [template.fields, side]);\r\n\r\n // Get background for current side\r\n const backgroundImage = side === 'front' ? template.backgrounds.front : template.backgrounds.back;\r\n\r\n // Render a single field\r\n const renderField = (field: FieldMapping) => {\r\n const posStyle = positionToStyle(field.position);\r\n const fieldStyle = fieldStyleToCSS(field.style);\r\n const combinedStyle: React.CSSProperties = {\r\n ...posStyle,\r\n ...fieldStyle,\r\n zIndex: field.zIndex || 1,\r\n boxSizing: 'border-box',\r\n overflow: 'hidden',\r\n cursor: editable ? 'pointer' : 'default',\r\n };\r\n\r\n const handleClick = (e: React.MouseEvent) => {\r\n if (onFieldClick) {\r\n e.stopPropagation();\r\n onFieldClick(field);\r\n }\r\n };\r\n\r\n const value = getFieldValue(field, data);\r\n\r\n switch (field.type) {\r\n case 'text':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-text\"\r\n >\r\n {field.label && (\r\n <span className=\"idcard-field-label\" style={{ fontSize: '0.8em', display: 'block' }}>\r\n {field.label}\r\n </span>\r\n )}\r\n <span className=\"idcard-field-value\">{String(value || field.placeholder || '')}</span>\r\n </div>\r\n );\r\n\r\n case 'label':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-label\"\r\n >\r\n {field.staticText || field.label || ''}\r\n </div>\r\n );\r\n\r\n case 'image':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n >\r\n {value ? (\r\n <img\r\n src={String(value)}\r\n alt={field.label || 'Image'}\r\n style={{\r\n width: '100%',\r\n display: 'block',\r\n }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#e0e0e0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n {field.label || 'Photo'}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n case 'qrcode':\r\n const qrDataUrl = field.qrFields\r\n ? generateQrCodeFromFields(data, field.qrFields, Math.min(field.position.width, field.position.height) * 2)\r\n : '';\r\n\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={{\r\n ...combinedStyle,\r\n backgroundColor: '#fff',\r\n }}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-qrcode\"\r\n >\r\n {qrDataUrl ? (\r\n <img\r\n src={qrDataUrl}\r\n alt=\"QR Code\"\r\n style={{ width: '100%', height: '100%' }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#f0f0f0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n QR Code\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n default:\r\n return null;\r\n }\r\n };\r\n\r\n // Card container style\r\n const cardStyle: React.CSSProperties = {\r\n width: Math.round(template.cardSize.width),\r\n height: Math.round(template.cardSize.height),\r\n position: 'relative',\r\n overflow: 'hidden',\r\n backgroundColor: '#fff',\r\n ...style,\r\n };\r\n\r\n return (\r\n <div\r\n id={side === 'front' ? 'idcardfront' : 'idcardback'}\r\n className={`idcard-container idcard-${side} ${className}`}\r\n style={cardStyle}\r\n >\r\n {/* Background */}\r\n {backgroundImage && (\r\n <img\r\n src={backgroundImage}\r\n alt={`${side} background`}\r\n style={{\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n width: `${Math.round(template.cardSize.width)}px`,\r\n height: `${Math.round(template.cardSize.height)}px`,\r\n zIndex: 0,\r\n }}\r\n />\r\n )}\r\n\r\n {/* Fields */}\r\n {fieldsToRender.map(renderField)}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * Get field value from data based on field configuration\r\n */\r\nfunction getFieldValue(field: FieldMapping, data: IDCardData): string | number | undefined {\r\n if (field.type === 'label') {\r\n return field.staticText;\r\n }\r\n\r\n const value = data[field.fieldKey];\r\n\r\n // Handle array values (like department)\r\n if (Array.isArray(value)) {\r\n return value[0];\r\n }\r\n\r\n return value as string | number | undefined;\r\n}\r\n\r\n"],"names":["useMemo","positionToStyle","fieldStyleToCSS","_jsxs","_jsx","generateQrCodeFromFields"],"mappings":";;;;;;;AAKA;;;;;;;;;;;;;;AAcG;AACI,MAAM,eAAe,GAAmC,CAAC,EAC9D,QAAQ,EACR,IAAI,EACJ,IAAI,GAAG,OAAO,EACd,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,EACV,YAAY,EACZ,QAAQ,GAAG,KAAK,GACK,KAAI;;AAEzB,IAAA,MAAM,cAAc,GAAGA,aAAO,CAAC,MAAK;AAClC,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAmB,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IAC7E,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;;IAG3B,MAAM,eAAe,GAAG,IAAI,KAAK,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI;;AAGjG,IAAA,MAAM,WAAW,GAAG,CAAC,KAAmB,KAAI;QAC1C,MAAM,QAAQ,GAAGC,0BAAe,CAAC,KAAK,CAAC,QAAQ,CAAC;QAChD,MAAM,UAAU,GAAGC,0BAAe,CAAC,KAAK,CAAC,KAAK,CAAC;AAC/C,QAAA,MAAM,aAAa,GAAwB;AACzC,YAAA,GAAG,QAAQ;AACX,YAAA,GAAG,UAAU;AACb,YAAA,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC;AACzB,YAAA,SAAS,EAAE,YAAY;AACvB,YAAA,QAAQ,EAAE,QAAQ;YAClB,M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AAE,CAAC;AACN,oBAAA,IAAI,EAAE,CAAC;AACP,oBAAA,KAAK,EAAE,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA,EAAA,CAAI;AACjD,oBAAA,MAAM,EAAE,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA,EAAA,CAAI;AACnD,oBAAA,MAAM,EAAE,CAAC;iBACV,EAAA,CACD,CACH,EAGA,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA,EAAA,CAC5B;AAEV;AAEA;;AAEG;AACH,SAAS,aAAa,CAAC,KAAmB,EAAE,IAAgB,EAAA;AAC1D,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,OAAO,KAAK,CAAC,UAAU;IACzB;IAEA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;AAGlC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,QAAA,OAAO,KAAK,CAAC,CAAC,CAAC;IACjB;AAEA,IAAA,OAAO,KAAoC;AAC7C;;;;"}
|
|
1
|
+
{"version":3,"file":"IDCardGenerator.js","sources":["../../../src/components/IDCardGenerator.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\nimport type { IDCardGeneratorProps, FieldMapping, IDCardData, IDCardTemplate } from '../types';\r\nimport { fieldStyleToCSS, positionToStyle } from '../utils/styleUtils';\r\nimport { generateQrCodeFromFields } from '../core/qrUtils';\r\n\r\n/**\r\n * IDCardGenerator - Renders a completed ID card\r\n * \r\n * Takes a template and user data, then renders the filled card.\r\n * This is the component used to display actual ID cards for individual users.\r\n * \r\n * Example:\r\n * ```tsx\r\n * <IDCardGenerator \r\n * template={myTemplate}\r\n * data={{ name: 'John Doe', photo: '...' }}\r\n * side=\"front\"\r\n * />\r\n * ```\r\n */\r\nexport const IDCardGenerator: React.FC<IDCardGeneratorProps> = ({\r\n template,\r\n data,\r\n side = 'front',\r\n scale = 1,\r\n className = '',\r\n style = {},\r\n onFieldClick,\r\n editable = false,\r\n}: IDCardGeneratorProps) => {\r\n // Get fields for the current side only\r\n const fieldsToRender = useMemo(() => {\r\n return template.fields.filter((field: FieldMapping) => field.side === side);\r\n }, [template.fields, side]);\r\n\r\n // Get background for current side\r\n const backgroundImage = side === 'front' ? template.backgrounds.front : template.backgrounds.back;\r\n\r\n // Render a single field\r\n const renderField = (field: FieldMapping) => {\r\n const posStyle = positionToStyle(field.position);\r\n let fieldStyle = fieldStyleToCSS(field.style);\r\n \r\n // Determine flex direction and alignment for text fields\r\n let flexDirection: 'column' | 'row' = 'column';\r\n if (field.type === 'text' && field.style?.labelPosition === 'left') flexDirection = 'row';\r\n\r\n // Map verticalAlign and textAlign to flex properties\r\n let justifyContent: 'flex-start' | 'center' | 'flex-end' = 'flex-start';\r\n let alignItems: 'flex-start' | 'center' | 'flex-end' | undefined = 'flex-start';\r\n if (field.type === 'text') {\r\n const textAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';\r\n const verticalAlign = field.style?.verticalAlign || 'top';\r\n \r\n if (flexDirection === 'column') {\r\n // For column: verticalAlign controls justifyContent (vertical), textAlign controls alignItems (horizontal)\r\n if (verticalAlign === 'middle') justifyContent = 'center';\r\n else if (verticalAlign === 'bottom') justifyContent = 'flex-end';\r\n else justifyContent = 'flex-start';\r\n \r\n if (textAlign === 'center') alignItems = 'center';\r\n else if (textAlign === 'right') alignItems = 'flex-end';\r\n else alignItems = 'flex-start';\r\n } else {\r\n // For row: don't set alignItems on container if individual alignments are specified\r\n // Let labelAlignSelf and textAlignSelf handle it\r\n if (field.style?.labelVerticalAlign || field.style?.textVerticalAlign) {\r\n alignItems = undefined;\r\n } else {\r\n // Fall back to general verticalAlign if individual ones aren't specified\r\n if (verticalAlign === 'middle') alignItems = 'center';\r\n else if (verticalAlign === 'bottom') alignItems = 'flex-end';\r\n else alignItems = 'flex-start';\r\n }\r\n }\r\n }\r\n\r\n // Remove fontSize for label fields so text field font size does not affect them\r\n if (field.type === 'label' && fieldStyle.fontSize) {\r\n const { fontSize, ...rest } = fieldStyle;\r\n fieldStyle = rest;\r\n }\r\n\r\n // Remove textTransform from container for text and label fields - applied directly to spans\r\n if ((field.type === 'text' || field.type === 'label') && fieldStyle.textTransform) {\r\n const { textTransform, ...rest } = fieldStyle;\r\n fieldStyle = rest;\r\n }\r\n\r\n const combinedStyle: React.CSSProperties = {\r\n ...posStyle,\r\n ...fieldStyle,\r\n zIndex: field.zIndex || 1,\r\n boxSizing: 'border-box',\r\n overflow: 'hidden',\r\n cursor: editable ? 'pointer' : 'default',\r\n display: field.type === 'text' ? 'flex' : undefined,\r\n flexDirection: field.type === 'text' ? flexDirection : undefined,\r\n justifyContent: field.type === 'text' ? justifyContent : undefined,\r\n alignItems: field.type === 'text' ? alignItems : undefined,\r\n };\r\n\r\n const handleClick = (e: React.MouseEvent) => {\r\n if (onFieldClick) {\r\n e.stopPropagation();\r\n onFieldClick(field);\r\n }\r\n };\r\n\r\n const value = getFieldValue(field, data);\r\n\r\n switch (field.type) {\r\n case 'text': {\r\n // Label style properties\r\n let labelFontSize = field.style?.labelFontSize;\r\n if (!labelFontSize || labelFontSize === '0.75em') {\r\n labelFontSize = '12px';\r\n } else if (!labelFontSize.endsWith('px')) {\r\n const num = parseFloat(labelFontSize);\r\n if (!isNaN(num)) labelFontSize = num + 'px';\r\n else labelFontSize = '12px';\r\n }\r\n const labelFontWeight = field.style?.labelFontWeight || 'normal';\r\n const labelColor = field.style?.labelColor || '#666666';\r\n const labelTextTransform = field.style?.labelTextTransform || 'none';\r\n const labelTextAlign = field.style?.labelTextAlign || 'left';\r\n \r\n // Text/value style properties (separate from label)\r\n const textFontSize = field.style?.textFontSize || field.style?.fontSize || '1em';\r\n const textFontWeight = field.style?.textFontWeight || field.style?.fontWeight || 'normal';\r\n const textColor = field.style?.textColor || field.style?.color || '#000000';\r\n const textTextTransform = field.style?.textTransform || 'none';\r\n const textTextAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';\r\n \r\n // For row layout (label on left), use individual span alignment\r\n if (field.style?.labelPosition === 'left') {\r\n let labelAlignSelf: React.CSSProperties['alignSelf'] = 'flex-start';\r\n if (field.style?.labelVerticalAlign === 'middle') labelAlignSelf = 'center';\r\n else if (field.style?.labelVerticalAlign === 'bottom') labelAlignSelf = 'flex-end';\r\n \r\n let textAlignSelf: React.CSSProperties['alignSelf'] = 'flex-start';\r\n if (field.style?.textVerticalAlign === 'middle') textAlignSelf = 'center';\r\n else if (field.style?.textVerticalAlign === 'bottom') textAlignSelf = 'flex-end';\r\n \r\n const labelStyle: React.CSSProperties = { \r\n fontSize: labelFontSize, \r\n fontWeight: labelFontWeight, \r\n color: labelColor, \r\n opacity: 0.7, \r\n marginRight: 8, \r\n alignSelf: labelAlignSelf, \r\n whiteSpace: 'nowrap', \r\n textTransform: labelTextTransform \r\n };\r\n \r\n const textStyle: React.CSSProperties = { \r\n textTransform: textTextTransform, \r\n fontSize: textFontSize, \r\n fontWeight: textFontWeight, \r\n color: textColor, \r\n alignSelf: textAlignSelf\r\n };\r\n \r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-text\"\r\n >\r\n {field.label && (\r\n <span className=\"idcard-field-label\" style={labelStyle}>\r\n {field.label}\r\n </span>\r\n )}\r\n <span style={{ width: '100%', textAlign: textTextAlign }}>\r\n <span className=\"idcard-field-value\" style={textStyle}>{String(value || field.placeholder || '')}</span>\r\n </span>\r\n </div>\r\n );\r\n } else {\r\n // For column layout (label on top), let container alignment handle positioning\r\n const labelStyle: React.CSSProperties = { \r\n fontSize: labelFontSize, \r\n fontWeight: labelFontWeight, \r\n color: labelColor, \r\n opacity: 0.7, \r\n textTransform: labelTextTransform,\r\n width: '100%',\r\n textAlign: labelTextAlign\r\n };\r\n \r\n const textStyle: React.CSSProperties = { \r\n textTransform: textTextTransform, \r\n fontSize: textFontSize, \r\n fontWeight: textFontWeight, \r\n color: textColor,\r\n width: '100%',\r\n textAlign: textTextAlign\r\n };\r\n \r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-text\"\r\n >\r\n {field.label && (\r\n <span className=\"idcard-field-label\" style={labelStyle}>\r\n {field.label}\r\n </span>\r\n )}\r\n <span className=\"idcard-field-value\" style={textStyle}>{String(value || field.placeholder || '')}</span>\r\n </div>\r\n );\r\n }\r\n }\r\n\r\n case 'label': {\r\n const labelTextTransform = field.style?.labelTextTransform || 'none';\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-label\"\r\n >\r\n <span style={{ textTransform: labelTextTransform }}>{field.staticText || field.label || ''}</span>\r\n </div>\r\n );\r\n }\r\n\r\n case 'image':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n >\r\n {value ? (\r\n <img\r\n src={String(value)}\r\n alt={field.label || 'Image'}\r\n style={{\r\n width: '100%',\r\n display: 'block',\r\n }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#e0e0e0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n {field.label || 'Photo'}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n case 'qrcode':\r\n const qrDataUrl = field.qrFields\r\n ? generateQrCodeFromFields(data, field.qrFields, Math.min(field.position.width, field.position.height) * 2)\r\n : '';\r\n\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={{\r\n ...combinedStyle,\r\n backgroundColor: '#fff',\r\n }}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-qrcode\"\r\n >\r\n {qrDataUrl ? (\r\n <img\r\n src={qrDataUrl}\r\n alt=\"QR Code\"\r\n style={{ width: '100%', height: '100%' }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#f0f0f0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n QR Code\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n default:\r\n return null;\r\n }\r\n };\r\n\r\n // Card container style\r\n const cardStyle: React.CSSProperties = {\r\n width: Math.round(template.cardSize.width),\r\n height: Math.round(template.cardSize.height),\r\n position: 'relative',\r\n overflow: 'hidden',\r\n backgroundColor: '#fff',\r\n ...style,\r\n };\r\n\r\n return (\r\n <div\r\n id={side === 'front' ? 'idcardfront' : 'idcardback'}\r\n className={`idcard-container idcard-${side} ${className}`}\r\n style={cardStyle}\r\n >\r\n {/* Background */}\r\n {backgroundImage && (\r\n <img\r\n src={backgroundImage}\r\n alt={`${side} background`}\r\n style={{\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n width: `${Math.round(template.cardSize.width)}px`,\r\n height: `${Math.round(template.cardSize.height)}px`,\r\n zIndex: 0,\r\n }}\r\n />\r\n )}\r\n\r\n {/* Fields */}\r\n {fieldsToRender.map(renderField)}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * Get field value from data based on field configuration\r\n */\r\nfunction getFieldValue(field: FieldMapping, data: IDCardData): string | number | undefined {\r\n if (field.type === 'label') {\r\n return field.staticText;\r\n }\r\n\r\n const value = data[field.fieldKey];\r\n\r\n // Handle array values (like department)\r\n if (Array.isArray(value)) {\r\n return value[0];\r\n }\r\n\r\n return value as string | number | undefined;\r\n}\r\n\r\n"],"names":["useMemo","positionToStyle","fieldStyleToCSS","_jsxs","_jsx","generateQrCodeFromFields"],"mappings":";;;;;;;AAKA;;;;;;;;;;;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QAAQ,EAAE,UAAU;AACpB,oBAAA,GAAG,EAAE,CAAC;AACN,oBAAA,IAAI,EAAE,CAAC;AACP,oBAAA,KAAK,EAAE,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA,EAAA,CAAI;AACjD,oBAAA,MAAM,EAAE,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA,EAAA,CAAI;AACnD,oBAAA,MAAM,EAAE,CAAC;iBACV,EAAA,CACD,CACH,EAGA,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA,EAAA,CAC5B;AAEV;AAEA;;AAEG;AACH,SAAS,aAAa,CAAC,KAAmB,EAAE,IAAgB,EAAA;AAC1D,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;QAC1B,OAAO,KAAK,CAAC,UAAU;IACzB;IAEA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;AAGlC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,QAAA,OAAO,KAAK,CAAC,CAAC,CAAC;IACjB;AAEA,IAAA,OAAO,KAAoC;AAC7C;;;;"}
|
|
@@ -28,7 +28,59 @@ const IDCardGenerator = ({ template, data, side = 'front', scale = 1, className
|
|
|
28
28
|
// Render a single field
|
|
29
29
|
const renderField = (field) => {
|
|
30
30
|
const posStyle = positionToStyle(field.position);
|
|
31
|
-
|
|
31
|
+
let fieldStyle = fieldStyleToCSS(field.style);
|
|
32
|
+
// Determine flex direction and alignment for text fields
|
|
33
|
+
let flexDirection = 'column';
|
|
34
|
+
if (field.type === 'text' && field.style?.labelPosition === 'left')
|
|
35
|
+
flexDirection = 'row';
|
|
36
|
+
// Map verticalAlign and textAlign to flex properties
|
|
37
|
+
let justifyContent = 'flex-start';
|
|
38
|
+
let alignItems = 'flex-start';
|
|
39
|
+
if (field.type === 'text') {
|
|
40
|
+
const textAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';
|
|
41
|
+
const verticalAlign = field.style?.verticalAlign || 'top';
|
|
42
|
+
if (flexDirection === 'column') {
|
|
43
|
+
// For column: verticalAlign controls justifyContent (vertical), textAlign controls alignItems (horizontal)
|
|
44
|
+
if (verticalAlign === 'middle')
|
|
45
|
+
justifyContent = 'center';
|
|
46
|
+
else if (verticalAlign === 'bottom')
|
|
47
|
+
justifyContent = 'flex-end';
|
|
48
|
+
else
|
|
49
|
+
justifyContent = 'flex-start';
|
|
50
|
+
if (textAlign === 'center')
|
|
51
|
+
alignItems = 'center';
|
|
52
|
+
else if (textAlign === 'right')
|
|
53
|
+
alignItems = 'flex-end';
|
|
54
|
+
else
|
|
55
|
+
alignItems = 'flex-start';
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// For row: don't set alignItems on container if individual alignments are specified
|
|
59
|
+
// Let labelAlignSelf and textAlignSelf handle it
|
|
60
|
+
if (field.style?.labelVerticalAlign || field.style?.textVerticalAlign) {
|
|
61
|
+
alignItems = undefined;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Fall back to general verticalAlign if individual ones aren't specified
|
|
65
|
+
if (verticalAlign === 'middle')
|
|
66
|
+
alignItems = 'center';
|
|
67
|
+
else if (verticalAlign === 'bottom')
|
|
68
|
+
alignItems = 'flex-end';
|
|
69
|
+
else
|
|
70
|
+
alignItems = 'flex-start';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Remove fontSize for label fields so text field font size does not affect them
|
|
75
|
+
if (field.type === 'label' && fieldStyle.fontSize) {
|
|
76
|
+
const { fontSize, ...rest } = fieldStyle;
|
|
77
|
+
fieldStyle = rest;
|
|
78
|
+
}
|
|
79
|
+
// Remove textTransform from container for text and label fields - applied directly to spans
|
|
80
|
+
if ((field.type === 'text' || field.type === 'label') && fieldStyle.textTransform) {
|
|
81
|
+
const { textTransform, ...rest } = fieldStyle;
|
|
82
|
+
fieldStyle = rest;
|
|
83
|
+
}
|
|
32
84
|
const combinedStyle = {
|
|
33
85
|
...posStyle,
|
|
34
86
|
...fieldStyle,
|
|
@@ -36,6 +88,10 @@ const IDCardGenerator = ({ template, data, side = 'front', scale = 1, className
|
|
|
36
88
|
boxSizing: 'border-box',
|
|
37
89
|
overflow: 'hidden',
|
|
38
90
|
cursor: editable ? 'pointer' : 'default',
|
|
91
|
+
display: field.type === 'text' ? 'flex' : undefined,
|
|
92
|
+
flexDirection: field.type === 'text' ? flexDirection : undefined,
|
|
93
|
+
justifyContent: field.type === 'text' ? justifyContent : undefined,
|
|
94
|
+
alignItems: field.type === 'text' ? alignItems : undefined,
|
|
39
95
|
};
|
|
40
96
|
const handleClick = (e) => {
|
|
41
97
|
if (onFieldClick) {
|
|
@@ -45,10 +101,86 @@ const IDCardGenerator = ({ template, data, side = 'front', scale = 1, className
|
|
|
45
101
|
};
|
|
46
102
|
const value = getFieldValue(field, data);
|
|
47
103
|
switch (field.type) {
|
|
48
|
-
case 'text':
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
104
|
+
case 'text': {
|
|
105
|
+
// Label style properties
|
|
106
|
+
let labelFontSize = field.style?.labelFontSize;
|
|
107
|
+
if (!labelFontSize || labelFontSize === '0.75em') {
|
|
108
|
+
labelFontSize = '12px';
|
|
109
|
+
}
|
|
110
|
+
else if (!labelFontSize.endsWith('px')) {
|
|
111
|
+
const num = parseFloat(labelFontSize);
|
|
112
|
+
if (!isNaN(num))
|
|
113
|
+
labelFontSize = num + 'px';
|
|
114
|
+
else
|
|
115
|
+
labelFontSize = '12px';
|
|
116
|
+
}
|
|
117
|
+
const labelFontWeight = field.style?.labelFontWeight || 'normal';
|
|
118
|
+
const labelColor = field.style?.labelColor || '#666666';
|
|
119
|
+
const labelTextTransform = field.style?.labelTextTransform || 'none';
|
|
120
|
+
const labelTextAlign = field.style?.labelTextAlign || 'left';
|
|
121
|
+
// Text/value style properties (separate from label)
|
|
122
|
+
const textFontSize = field.style?.textFontSize || field.style?.fontSize || '1em';
|
|
123
|
+
const textFontWeight = field.style?.textFontWeight || field.style?.fontWeight || 'normal';
|
|
124
|
+
const textColor = field.style?.textColor || field.style?.color || '#000000';
|
|
125
|
+
const textTextTransform = field.style?.textTransform || 'none';
|
|
126
|
+
const textTextAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';
|
|
127
|
+
// For row layout (label on left), use individual span alignment
|
|
128
|
+
if (field.style?.labelPosition === 'left') {
|
|
129
|
+
let labelAlignSelf = 'flex-start';
|
|
130
|
+
if (field.style?.labelVerticalAlign === 'middle')
|
|
131
|
+
labelAlignSelf = 'center';
|
|
132
|
+
else if (field.style?.labelVerticalAlign === 'bottom')
|
|
133
|
+
labelAlignSelf = 'flex-end';
|
|
134
|
+
let textAlignSelf = 'flex-start';
|
|
135
|
+
if (field.style?.textVerticalAlign === 'middle')
|
|
136
|
+
textAlignSelf = 'center';
|
|
137
|
+
else if (field.style?.textVerticalAlign === 'bottom')
|
|
138
|
+
textAlignSelf = 'flex-end';
|
|
139
|
+
const labelStyle = {
|
|
140
|
+
fontSize: labelFontSize,
|
|
141
|
+
fontWeight: labelFontWeight,
|
|
142
|
+
color: labelColor,
|
|
143
|
+
opacity: 0.7,
|
|
144
|
+
marginRight: 8,
|
|
145
|
+
alignSelf: labelAlignSelf,
|
|
146
|
+
whiteSpace: 'nowrap',
|
|
147
|
+
textTransform: labelTextTransform
|
|
148
|
+
};
|
|
149
|
+
const textStyle = {
|
|
150
|
+
textTransform: textTextTransform,
|
|
151
|
+
fontSize: textFontSize,
|
|
152
|
+
fontWeight: textFontWeight,
|
|
153
|
+
color: textColor,
|
|
154
|
+
alignSelf: textAlignSelf
|
|
155
|
+
};
|
|
156
|
+
return (jsxs("div", { id: field.id, style: combinedStyle, onClick: handleClick, className: "idcard-field idcard-field-text", children: [field.label && (jsx("span", { className: "idcard-field-label", style: labelStyle, children: field.label })), jsx("span", { style: { width: '100%', textAlign: textTextAlign }, children: jsx("span", { className: "idcard-field-value", style: textStyle, children: String(value || field.placeholder || '') }) })] }, field.id));
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// For column layout (label on top), let container alignment handle positioning
|
|
160
|
+
const labelStyle = {
|
|
161
|
+
fontSize: labelFontSize,
|
|
162
|
+
fontWeight: labelFontWeight,
|
|
163
|
+
color: labelColor,
|
|
164
|
+
opacity: 0.7,
|
|
165
|
+
textTransform: labelTextTransform,
|
|
166
|
+
width: '100%',
|
|
167
|
+
textAlign: labelTextAlign
|
|
168
|
+
};
|
|
169
|
+
const textStyle = {
|
|
170
|
+
textTransform: textTextTransform,
|
|
171
|
+
fontSize: textFontSize,
|
|
172
|
+
fontWeight: textFontWeight,
|
|
173
|
+
color: textColor,
|
|
174
|
+
width: '100%',
|
|
175
|
+
textAlign: textTextAlign
|
|
176
|
+
};
|
|
177
|
+
return (jsxs("div", { id: field.id, style: combinedStyle, onClick: handleClick, className: "idcard-field idcard-field-text", children: [field.label && (jsx("span", { className: "idcard-field-label", style: labelStyle, children: field.label })), jsx("span", { className: "idcard-field-value", style: textStyle, children: String(value || field.placeholder || '') })] }, field.id));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
case 'label': {
|
|
181
|
+
const labelTextTransform = field.style?.labelTextTransform || 'none';
|
|
182
|
+
return (jsx("div", { id: field.id, style: combinedStyle, onClick: handleClick, className: "idcard-field idcard-field-label", children: jsx("span", { style: { textTransform: labelTextTransform }, children: field.staticText || field.label || '' }) }, field.id));
|
|
183
|
+
}
|
|
52
184
|
case 'image':
|
|
53
185
|
return (jsx("div", { id: field.id, style: combinedStyle, onClick: handleClick, children: value ? (jsx("img", { src: String(value), alt: field.label || 'Image', style: {
|
|
54
186
|
width: '100%',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDCardGenerator.js","sources":["../../../src/components/IDCardGenerator.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\nimport type { IDCardGeneratorProps, FieldMapping, IDCardData, IDCardTemplate } from '../types';\r\nimport { fieldStyleToCSS, positionToStyle } from '../utils/styleUtils';\r\nimport { generateQrCodeFromFields } from '../core/qrUtils';\r\n\r\n/**\r\n * IDCardGenerator - Renders a completed ID card\r\n * \r\n * Takes a template and user data, then renders the filled card.\r\n * This is the component used to display actual ID cards for individual users.\r\n * \r\n * Example:\r\n * ```tsx\r\n * <IDCardGenerator \r\n * template={myTemplate}\r\n * data={{ name: 'John Doe', photo: '...' }}\r\n * side=\"front\"\r\n * />\r\n * ```\r\n */\r\nexport const IDCardGenerator: React.FC<IDCardGeneratorProps> = ({\r\n template,\r\n data,\r\n side = 'front',\r\n scale = 1,\r\n className = '',\r\n style = {},\r\n onFieldClick,\r\n editable = false,\r\n}: IDCardGeneratorProps) => {\r\n // Get fields for the current side only\r\n const fieldsToRender = useMemo(() => {\r\n return template.fields.filter((field: FieldMapping) => field.side === side);\r\n }, [template.fields, side]);\r\n\r\n // Get background for current side\r\n const backgroundImage = side === 'front' ? template.backgrounds.front : template.backgrounds.back;\r\n\r\n // Render a single field\r\n const renderField = (field: FieldMapping) => {\r\n const posStyle = positionToStyle(field.position);\r\n const fieldStyle = fieldStyleToCSS(field.style);\r\n const combinedStyle: React.CSSProperties = {\r\n ...posStyle,\r\n ...fieldStyle,\r\n zIndex: field.zIndex || 1,\r\n boxSizing: 'border-box',\r\n overflow: 'hidden',\r\n cursor: editable ? 'pointer' : 'default',\r\n };\r\n\r\n const handleClick = (e: React.MouseEvent) => {\r\n if (onFieldClick) {\r\n e.stopPropagation();\r\n onFieldClick(field);\r\n }\r\n };\r\n\r\n const value = getFieldValue(field, data);\r\n\r\n switch (field.type) {\r\n case 'text':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-text\"\r\n >\r\n {field.label && (\r\n <span className=\"idcard-field-label\" style={{ fontSize: '0.8em', display: 'block' }}>\r\n {field.label}\r\n </span>\r\n )}\r\n <span className=\"idcard-field-value\">{String(value || field.placeholder || '')}</span>\r\n </div>\r\n );\r\n\r\n case 'label':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-label\"\r\n >\r\n {field.staticText || field.label || ''}\r\n </div>\r\n );\r\n\r\n case 'image':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n >\r\n {value ? (\r\n <img\r\n src={String(value)}\r\n alt={field.label || 'Image'}\r\n style={{\r\n width: '100%',\r\n display: 'block',\r\n }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#e0e0e0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n {field.label || 'Photo'}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n case 'qrcode':\r\n const qrDataUrl = field.qrFields\r\n ? generateQrCodeFromFields(data, field.qrFields, Math.min(field.position.width, field.position.height) * 2)\r\n : '';\r\n\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={{\r\n ...combinedStyle,\r\n backgroundColor: '#fff',\r\n }}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-qrcode\"\r\n >\r\n {qrDataUrl ? (\r\n <img\r\n src={qrDataUrl}\r\n alt=\"QR Code\"\r\n style={{ width: '100%', height: '100%' }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#f0f0f0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n QR Code\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n default:\r\n return null;\r\n }\r\n };\r\n\r\n // Card container style\r\n const cardStyle: React.CSSProperties = {\r\n width: Math.round(template.cardSize.width),\r\n height: Math.round(template.cardSize.height),\r\n position: 'relative',\r\n overflow: 'hidden',\r\n backgroundColor: '#fff',\r\n ...style,\r\n };\r\n\r\n return (\r\n <div\r\n id={side === 'front' ? 'idcardfront' : 'idcardback'}\r\n className={`idcard-container idcard-${side} ${className}`}\r\n style={cardStyle}\r\n >\r\n {/* Background */}\r\n {backgroundImage && (\r\n <img\r\n src={backgroundImage}\r\n alt={`${side} background`}\r\n style={{\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n width: `${Math.round(template.cardSize.width)}px`,\r\n height: `${Math.round(template.cardSize.height)}px`,\r\n zIndex: 0,\r\n }}\r\n />\r\n )}\r\n\r\n {/* Fields */}\r\n {fieldsToRender.map(renderField)}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * Get field value from data based on field configuration\r\n */\r\nfunction getFieldValue(field: FieldMapping, data: IDCardData): string | number | undefined {\r\n if (field.type === 'label') {\r\n return field.staticText;\r\n }\r\n\r\n const value = data[field.fieldKey];\r\n\r\n // Handle array values (like department)\r\n if (Array.isArray(value)) {\r\n return value[0];\r\n }\r\n\r\n return value as string | number | undefined;\r\n}\r\n\r\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AAKA;;;;;;;;;;;;;;AAcG;AACI,MAAM,eAAe,GAAmC,CAAC,EAC9D,QAAQ,EACR,IAAI,EACJ,IAAI,GAAG,OAAO,EACd,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,EACV,YAAY,EACZ,QAAQ,GAAG,KAAK,GACK,KAAI;;AAEzB,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,MAAK;AAClC,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAmB,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IAC7E,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM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CAAC;IACjB;AAEA,IAAA,OAAO,KAAoC;AAC7C;;;;"}
|
|
1
|
+
{"version":3,"file":"IDCardGenerator.js","sources":["../../../src/components/IDCardGenerator.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\nimport type { IDCardGeneratorProps, FieldMapping, IDCardData, IDCardTemplate } from '../types';\r\nimport { fieldStyleToCSS, positionToStyle } from '../utils/styleUtils';\r\nimport { generateQrCodeFromFields } from '../core/qrUtils';\r\n\r\n/**\r\n * IDCardGenerator - Renders a completed ID card\r\n * \r\n * Takes a template and user data, then renders the filled card.\r\n * This is the component used to display actual ID cards for individual users.\r\n * \r\n * Example:\r\n * ```tsx\r\n * <IDCardGenerator \r\n * template={myTemplate}\r\n * data={{ name: 'John Doe', photo: '...' }}\r\n * side=\"front\"\r\n * />\r\n * ```\r\n */\r\nexport const IDCardGenerator: React.FC<IDCardGeneratorProps> = ({\r\n template,\r\n data,\r\n side = 'front',\r\n scale = 1,\r\n className = '',\r\n style = {},\r\n onFieldClick,\r\n editable = false,\r\n}: IDCardGeneratorProps) => {\r\n // Get fields for the current side only\r\n const fieldsToRender = useMemo(() => {\r\n return template.fields.filter((field: FieldMapping) => field.side === side);\r\n }, [template.fields, side]);\r\n\r\n // Get background for current side\r\n const backgroundImage = side === 'front' ? template.backgrounds.front : template.backgrounds.back;\r\n\r\n // Render a single field\r\n const renderField = (field: FieldMapping) => {\r\n const posStyle = positionToStyle(field.position);\r\n let fieldStyle = fieldStyleToCSS(field.style);\r\n \r\n // Determine flex direction and alignment for text fields\r\n let flexDirection: 'column' | 'row' = 'column';\r\n if (field.type === 'text' && field.style?.labelPosition === 'left') flexDirection = 'row';\r\n\r\n // Map verticalAlign and textAlign to flex properties\r\n let justifyContent: 'flex-start' | 'center' | 'flex-end' = 'flex-start';\r\n let alignItems: 'flex-start' | 'center' | 'flex-end' | undefined = 'flex-start';\r\n if (field.type === 'text') {\r\n const textAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';\r\n const verticalAlign = field.style?.verticalAlign || 'top';\r\n \r\n if (flexDirection === 'column') {\r\n // For column: verticalAlign controls justifyContent (vertical), textAlign controls alignItems (horizontal)\r\n if (verticalAlign === 'middle') justifyContent = 'center';\r\n else if (verticalAlign === 'bottom') justifyContent = 'flex-end';\r\n else justifyContent = 'flex-start';\r\n \r\n if (textAlign === 'center') alignItems = 'center';\r\n else if (textAlign === 'right') alignItems = 'flex-end';\r\n else alignItems = 'flex-start';\r\n } else {\r\n // For row: don't set alignItems on container if individual alignments are specified\r\n // Let labelAlignSelf and textAlignSelf handle it\r\n if (field.style?.labelVerticalAlign || field.style?.textVerticalAlign) {\r\n alignItems = undefined;\r\n } else {\r\n // Fall back to general verticalAlign if individual ones aren't specified\r\n if (verticalAlign === 'middle') alignItems = 'center';\r\n else if (verticalAlign === 'bottom') alignItems = 'flex-end';\r\n else alignItems = 'flex-start';\r\n }\r\n }\r\n }\r\n\r\n // Remove fontSize for label fields so text field font size does not affect them\r\n if (field.type === 'label' && fieldStyle.fontSize) {\r\n const { fontSize, ...rest } = fieldStyle;\r\n fieldStyle = rest;\r\n }\r\n\r\n // Remove textTransform from container for text and label fields - applied directly to spans\r\n if ((field.type === 'text' || field.type === 'label') && fieldStyle.textTransform) {\r\n const { textTransform, ...rest } = fieldStyle;\r\n fieldStyle = rest;\r\n }\r\n\r\n const combinedStyle: React.CSSProperties = {\r\n ...posStyle,\r\n ...fieldStyle,\r\n zIndex: field.zIndex || 1,\r\n boxSizing: 'border-box',\r\n overflow: 'hidden',\r\n cursor: editable ? 'pointer' : 'default',\r\n display: field.type === 'text' ? 'flex' : undefined,\r\n flexDirection: field.type === 'text' ? flexDirection : undefined,\r\n justifyContent: field.type === 'text' ? justifyContent : undefined,\r\n alignItems: field.type === 'text' ? alignItems : undefined,\r\n };\r\n\r\n const handleClick = (e: React.MouseEvent) => {\r\n if (onFieldClick) {\r\n e.stopPropagation();\r\n onFieldClick(field);\r\n }\r\n };\r\n\r\n const value = getFieldValue(field, data);\r\n\r\n switch (field.type) {\r\n case 'text': {\r\n // Label style properties\r\n let labelFontSize = field.style?.labelFontSize;\r\n if (!labelFontSize || labelFontSize === '0.75em') {\r\n labelFontSize = '12px';\r\n } else if (!labelFontSize.endsWith('px')) {\r\n const num = parseFloat(labelFontSize);\r\n if (!isNaN(num)) labelFontSize = num + 'px';\r\n else labelFontSize = '12px';\r\n }\r\n const labelFontWeight = field.style?.labelFontWeight || 'normal';\r\n const labelColor = field.style?.labelColor || '#666666';\r\n const labelTextTransform = field.style?.labelTextTransform || 'none';\r\n const labelTextAlign = field.style?.labelTextAlign || 'left';\r\n \r\n // Text/value style properties (separate from label)\r\n const textFontSize = field.style?.textFontSize || field.style?.fontSize || '1em';\r\n const textFontWeight = field.style?.textFontWeight || field.style?.fontWeight || 'normal';\r\n const textColor = field.style?.textColor || field.style?.color || '#000000';\r\n const textTextTransform = field.style?.textTransform || 'none';\r\n const textTextAlign = field.style?.textTextAlign || field.style?.textAlign || 'left';\r\n \r\n // For row layout (label on left), use individual span alignment\r\n if (field.style?.labelPosition === 'left') {\r\n let labelAlignSelf: React.CSSProperties['alignSelf'] = 'flex-start';\r\n if (field.style?.labelVerticalAlign === 'middle') labelAlignSelf = 'center';\r\n else if (field.style?.labelVerticalAlign === 'bottom') labelAlignSelf = 'flex-end';\r\n \r\n let textAlignSelf: React.CSSProperties['alignSelf'] = 'flex-start';\r\n if (field.style?.textVerticalAlign === 'middle') textAlignSelf = 'center';\r\n else if (field.style?.textVerticalAlign === 'bottom') textAlignSelf = 'flex-end';\r\n \r\n const labelStyle: React.CSSProperties = { \r\n fontSize: labelFontSize, \r\n fontWeight: labelFontWeight, \r\n color: labelColor, \r\n opacity: 0.7, \r\n marginRight: 8, \r\n alignSelf: labelAlignSelf, \r\n whiteSpace: 'nowrap', \r\n textTransform: labelTextTransform \r\n };\r\n \r\n const textStyle: React.CSSProperties = { \r\n textTransform: textTextTransform, \r\n fontSize: textFontSize, \r\n fontWeight: textFontWeight, \r\n color: textColor, \r\n alignSelf: textAlignSelf\r\n };\r\n \r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-text\"\r\n >\r\n {field.label && (\r\n <span className=\"idcard-field-label\" style={labelStyle}>\r\n {field.label}\r\n </span>\r\n )}\r\n <span style={{ width: '100%', textAlign: textTextAlign }}>\r\n <span className=\"idcard-field-value\" style={textStyle}>{String(value || field.placeholder || '')}</span>\r\n </span>\r\n </div>\r\n );\r\n } else {\r\n // For column layout (label on top), let container alignment handle positioning\r\n const labelStyle: React.CSSProperties = { \r\n fontSize: labelFontSize, \r\n fontWeight: labelFontWeight, \r\n color: labelColor, \r\n opacity: 0.7, \r\n textTransform: labelTextTransform,\r\n width: '100%',\r\n textAlign: labelTextAlign\r\n };\r\n \r\n const textStyle: React.CSSProperties = { \r\n textTransform: textTextTransform, \r\n fontSize: textFontSize, \r\n fontWeight: textFontWeight, \r\n color: textColor,\r\n width: '100%',\r\n textAlign: textTextAlign\r\n };\r\n \r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-text\"\r\n >\r\n {field.label && (\r\n <span className=\"idcard-field-label\" style={labelStyle}>\r\n {field.label}\r\n </span>\r\n )}\r\n <span className=\"idcard-field-value\" style={textStyle}>{String(value || field.placeholder || '')}</span>\r\n </div>\r\n );\r\n }\r\n }\r\n\r\n case 'label': {\r\n const labelTextTransform = field.style?.labelTextTransform || 'none';\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-label\"\r\n >\r\n <span style={{ textTransform: labelTextTransform }}>{field.staticText || field.label || ''}</span>\r\n </div>\r\n );\r\n }\r\n\r\n case 'image':\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={combinedStyle}\r\n onClick={handleClick}\r\n >\r\n {value ? (\r\n <img\r\n src={String(value)}\r\n alt={field.label || 'Image'}\r\n style={{\r\n width: '100%',\r\n display: 'block',\r\n }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#e0e0e0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n {field.label || 'Photo'}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n case 'qrcode':\r\n const qrDataUrl = field.qrFields\r\n ? generateQrCodeFromFields(data, field.qrFields, Math.min(field.position.width, field.position.height) * 2)\r\n : '';\r\n\r\n return (\r\n <div\r\n key={field.id}\r\n id={field.id}\r\n style={{\r\n ...combinedStyle,\r\n backgroundColor: '#fff',\r\n }}\r\n onClick={handleClick}\r\n className=\"idcard-field idcard-field-qrcode\"\r\n >\r\n {qrDataUrl ? (\r\n <img\r\n src={qrDataUrl}\r\n alt=\"QR Code\"\r\n style={{ width: '100%', height: '100%' }}\r\n />\r\n ) : (\r\n <div\r\n style={{\r\n width: '100%',\r\n height: '100%',\r\n backgroundColor: '#f0f0f0',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n fontSize: '10px',\r\n color: '#666',\r\n }}\r\n >\r\n QR Code\r\n </div>\r\n )}\r\n </div>\r\n );\r\n\r\n default:\r\n return null;\r\n }\r\n };\r\n\r\n // Card container style\r\n const cardStyle: React.CSSProperties = {\r\n width: Math.round(template.cardSize.width),\r\n height: Math.round(template.cardSize.height),\r\n position: 'relative',\r\n overflow: 'hidden',\r\n backgroundColor: '#fff',\r\n ...style,\r\n };\r\n\r\n return (\r\n <div\r\n id={side === 'front' ? 'idcardfront' : 'idcardback'}\r\n className={`idcard-container idcard-${side} ${className}`}\r\n style={cardStyle}\r\n >\r\n {/* Background */}\r\n {backgroundImage && (\r\n <img\r\n src={backgroundImage}\r\n alt={`${side} background`}\r\n style={{\r\n position: 'absolute',\r\n top: 0,\r\n left: 0,\r\n width: `${Math.round(template.cardSize.width)}px`,\r\n height: `${Math.round(template.cardSize.height)}px`,\r\n zIndex: 0,\r\n }}\r\n />\r\n )}\r\n\r\n {/* Fields */}\r\n {fieldsToRender.map(renderField)}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * Get field value from data based on field configuration\r\n */\r\nfunction getFieldValue(field: FieldMapping, data: IDCardData): string | number | undefined {\r\n if (field.type === 'label') {\r\n return field.staticText;\r\n }\r\n\r\n const value = data[field.fieldKey];\r\n\r\n // Handle array values (like department)\r\n if (Array.isArray(value)) {\r\n return value[0];\r\n }\r\n\r\n return value as string | number | undefined;\r\n}\r\n\r\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AAKA;;;;;;;;;;;;;;AAcG;AACI,MAAM,eAAe,GAAmC,CAAC,EAC9D,QAAQ,EACR,IAAI,EACJ,IAAI,GAAG,OAAO,EACd,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,EACV,YAAY,EACZ,QAAQ,GAAG,KAAK,GACK,KAAI;;AAEzB,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,MAAK;AAClC,QAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAmB,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;IAC7E,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;;IAG3B,MAAM,eAAe,GAAG,IAAI,KAAK,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI;;AAGjG,IAAA,MAAM,WAAW,GAAG,CAAC,KAAmB,KAAI;QAC1C,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC;QAChD,IAAI,UAAU,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC;;QAG7C,IAAI,aAAa,GAAqB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EA,IAAA,OAAO,KAAoC;AAC7C;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -483,6 +483,7 @@ declare function fieldStyleToCSS(style: FieldStyle | undefined): React.CSSProper
|
|
|
483
483
|
declare function mergeStyles(...styles: (React.CSSProperties | undefined)[]): React.CSSProperties;
|
|
484
484
|
/**
|
|
485
485
|
* Generate position styles from field position
|
|
486
|
+
* Rounds values to integers for better html2canvas compatibility
|
|
486
487
|
*/
|
|
487
488
|
declare function positionToStyle(position: {
|
|
488
489
|
x: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-id-card-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "A flexible React library for designing, configuring, and generating ID cards with drag-and-drop field positioning",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|