ui-soxo-bootstrap-core 2.6.46-dev.4 → 2.6.46-dev.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.
@@ -143,10 +143,22 @@ export const ExportReactCSV = ({
143
143
  const sanitizeValue = (value) => {
144
144
  if (value === undefined || value === null) return '';
145
145
  if (typeof value === 'object') return JSON.stringify(value);
146
- return String(value);
146
+ // Normalize all line-ending variants (CRLF/CR) to LF so a lone "\r"
147
+ // never reaches pdf-lib's WinAnsi encoder, which cannot encode it.
148
+ return String(value).replace(/\r\n|\r/g, '\n');
147
149
  };
148
150
 
149
- const getTextWidth = (text, textFont, size) => textFont.widthOfTextAtSize(sanitizeValue(text), size);
151
+ const getTextWidth = (text, textFont, size) => {
152
+ const sanitized = sanitizeValue(text);
153
+ // widthOfTextAtSize measures a single line; strip any remaining
154
+ // newlines defensively so multi-line values never crash the encoder.
155
+ return textFont.widthOfTextAtSize(sanitized.replace(/\n/g, ' '), size);
156
+ };
157
+
158
+ const getMaxLineWidth = (value, textFont, size) =>
159
+ sanitizeValue(value)
160
+ .split('\n')
161
+ .reduce((maxWidth, line) => Math.max(maxWidth, textFont.widthOfTextAtSize(line, size)), 0);
150
162
 
151
163
  const splitLongWord = (word, maxWidth, textFont, size) => {
152
164
  const characters = Array.from(word);
@@ -223,7 +235,7 @@ export const ExportReactCSV = ({
223
235
  const compactColumn = label === '#' || ['slno', 'sl no'].includes(label.toLowerCase());
224
236
  const minWidth = compactColumn ? 28 : 36;
225
237
  const values = [label, ...sampleRows.map((row) => sanitizeValue(row[header.key]))];
226
- const longestValueWidth = values.reduce((maxWidth, value) => Math.max(maxWidth, getTextWidth(value, font, fontSize)), 0);
238
+ const longestValueWidth = values.reduce((maxWidth, value) => Math.max(maxWidth, getMaxLineWidth(value, font, fontSize)), 0);
227
239
  const longestWordWidth = values.reduce((maxWidth, value) => {
228
240
  const words = value.split(/\s+/).filter(Boolean);
229
241
  return words.reduce((wordMaxWidth, word) => Math.max(wordMaxWidth, getTextWidth(word, font, fontSize)), maxWidth);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-soxo-bootstrap-core",
3
- "version": "2.6.46-dev.4",
3
+ "version": "2.6.46-dev.5",
4
4
  "description": "All the Core Components for you to start",
5
5
  "keywords": [
6
6
  "all in one"