ui-soxo-bootstrap-core 2.6.46-dev.3 → 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.
|
@@ -15,11 +15,12 @@ import { PDFDocument, StandardFonts, rgb } from 'pdf-lib';
|
|
|
15
15
|
// import * as XLSX from 'xlsx-js-style';
|
|
16
16
|
// Import saveAs from file-saver to trigger file download in browser
|
|
17
17
|
import { saveAs } from 'file-saver';
|
|
18
|
-
import {
|
|
18
|
+
import { Dropdown, Form, Input, Menu, Modal, Radio, message } from 'antd';
|
|
19
19
|
import { DownOutlined, FileExcelFilled, FilePdfFilled, MailFilled, DownloadOutlined } from '@ant-design/icons';
|
|
20
20
|
import { Trans } from 'react-i18next';
|
|
21
21
|
import { CoreScripts } from '../../../../models';
|
|
22
22
|
import './generic-list.scss';
|
|
23
|
+
import { Button } from '../../../elements';
|
|
23
24
|
|
|
24
25
|
const normalizeScriptId = (value) => {
|
|
25
26
|
if (value === undefined || value === null || value === '') return value;
|
|
@@ -142,10 +143,22 @@ export const ExportReactCSV = ({
|
|
|
142
143
|
const sanitizeValue = (value) => {
|
|
143
144
|
if (value === undefined || value === null) return '';
|
|
144
145
|
if (typeof value === 'object') return JSON.stringify(value);
|
|
145
|
-
|
|
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');
|
|
146
149
|
};
|
|
147
150
|
|
|
148
|
-
const getTextWidth = (text, textFont, 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);
|
|
149
162
|
|
|
150
163
|
const splitLongWord = (word, maxWidth, textFont, size) => {
|
|
151
164
|
const characters = Array.from(word);
|
|
@@ -222,7 +235,7 @@ export const ExportReactCSV = ({
|
|
|
222
235
|
const compactColumn = label === '#' || ['slno', 'sl no'].includes(label.toLowerCase());
|
|
223
236
|
const minWidth = compactColumn ? 28 : 36;
|
|
224
237
|
const values = [label, ...sampleRows.map((row) => sanitizeValue(row[header.key]))];
|
|
225
|
-
const longestValueWidth = values.reduce((maxWidth, value) => Math.max(maxWidth,
|
|
238
|
+
const longestValueWidth = values.reduce((maxWidth, value) => Math.max(maxWidth, getMaxLineWidth(value, font, fontSize)), 0);
|
|
226
239
|
const longestWordWidth = values.reduce((maxWidth, value) => {
|
|
227
240
|
const words = value.split(/\s+/).filter(Boolean);
|
|
228
241
|
return words.reduce((wordMaxWidth, word) => Math.max(wordMaxWidth, getTextWidth(word, font, fontSize)), maxWidth);
|