@erpsquad/common 1.8.96 → 1.8.98
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/_virtual/index/index.esm3.js +2 -4
- package/dist/_virtual/index/index.esm3.js.map +1 -1
- package/dist/_virtual/index/index.esm4.js +3 -3
- package/dist/_virtual/index/index.esm5.js +4 -2
- package/dist/_virtual/index/index.esm5.js.map +1 -1
- package/dist/_virtual/index/index3.js +1 -1
- package/dist/_virtual/index/index4.js +1 -1
- package/dist/_virtual/index/index5.js +1 -1
- package/dist/components/material-table/components/inline-edit-fields/index.esm.js.map +1 -1
- package/dist/components/material-table/components/inline-edit-fields/index.js.map +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.esm.js +1 -1
- package/dist/node_modules/@asseinfo/react-kanban/dist/index/index.js +1 -1
- package/dist/node_modules/@mui/system/colorManipulator/index.esm.js +2 -2
- package/dist/node_modules/@mui/system/colorManipulator/index.js +1 -1
- package/dist/style.css +66 -66
- package/dist/utils/common-utility/index.esm.js +13 -7
- package/dist/utils/common-utility/index.esm.js.map +1 -1
- package/dist/utils/common-utility/index.js +5 -5
- package/dist/utils/common-utility/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { DefaultAggregation } from "../../components/material-table/components/d
|
|
|
6
6
|
import { Chip } from "../../components/chip/chip/index.esm.js";
|
|
7
7
|
import _ from "lodash";
|
|
8
8
|
import { images } from "../../images/index.esm.js";
|
|
9
|
-
import { defaultCurrencyFormat, defaultCurrencySymbol, formatAmount } from "../common/index.esm.js";
|
|
9
|
+
import { defaultCurrencyFormat, toFixedWithNumbers, defaultCurrencySymbol, formatAmount } from "../common/index.esm.js";
|
|
10
10
|
import { ValueField } from "../../components/value-field/value-field/index.esm.js";
|
|
11
11
|
import { formatLabel } from "../format-text/index.esm.js";
|
|
12
12
|
import { generateRouteWithId } from "../route-utils/index.esm.js";
|
|
@@ -122,8 +122,11 @@ const transformTableColumns = ({
|
|
|
122
122
|
...column,
|
|
123
123
|
header: translationFn ? translationFn(column.header) : column.header,
|
|
124
124
|
Cell: ({ renderedCellValue, row }) => {
|
|
125
|
-
var _a, _b, _c;
|
|
125
|
+
var _a, _b, _c, _d;
|
|
126
126
|
let v = renderedCellValue;
|
|
127
|
+
if (typeof v === "number" && v && ((_a = String(v)) == null ? void 0 : _a.includes("."))) {
|
|
128
|
+
return v = toFixedWithNumbers(v);
|
|
129
|
+
}
|
|
127
130
|
const columnType = column.type || (column.header === "Amount" || column.header === "Rate" ? "currency" : void 0);
|
|
128
131
|
switch (columnType) {
|
|
129
132
|
case "formattedString":
|
|
@@ -132,13 +135,13 @@ const transformTableColumns = ({
|
|
|
132
135
|
case "date":
|
|
133
136
|
v = formatDate(
|
|
134
137
|
renderedCellValue,
|
|
135
|
-
((
|
|
138
|
+
((_b = column.editProperties) == null ? void 0 : _b.dateFormat) || "DD-MM-YYYY"
|
|
136
139
|
);
|
|
137
140
|
break;
|
|
138
141
|
case "datetime":
|
|
139
142
|
v = formatDate(
|
|
140
143
|
renderedCellValue,
|
|
141
|
-
((
|
|
144
|
+
((_c = column.editProperties) == null ? void 0 : _c.dateFormat) || "DD-MM-YYYY hh:mm A"
|
|
142
145
|
);
|
|
143
146
|
break;
|
|
144
147
|
case "currency":
|
|
@@ -175,18 +178,18 @@ const transformTableColumns = ({
|
|
|
175
178
|
{
|
|
176
179
|
type: "normal",
|
|
177
180
|
sx: (theme) => {
|
|
178
|
-
var _a2, _b2, _c2,
|
|
181
|
+
var _a2, _b2, _c2, _d2;
|
|
179
182
|
return {
|
|
180
183
|
...renderedCellValue ? {
|
|
181
184
|
backgroundColor: (_a2 = theme.palette) == null ? void 0 : _a2.theme.tertiary4[200],
|
|
182
185
|
color: (_b2 = theme.palette) == null ? void 0 : _b2.theme.tertiary4[900]
|
|
183
186
|
} : {
|
|
184
187
|
backgroundColor: (_c2 = theme.palette) == null ? void 0 : _c2.theme.tertiary6[200],
|
|
185
|
-
color: (
|
|
188
|
+
color: (_d2 = theme.palette) == null ? void 0 : _d2.theme.tertiary6[900]
|
|
186
189
|
}
|
|
187
190
|
};
|
|
188
191
|
},
|
|
189
|
-
label: /* @__PURE__ */ jsx(Typography, { type: "s4", weight: "medium", color: "inherit", children: ((
|
|
192
|
+
label: /* @__PURE__ */ jsx(Typography, { type: "s4", weight: "medium", color: "inherit", children: ((_d = column == null ? void 0 : column.typeBooleanLabels) == null ? void 0 : _d[renderedCellValue]) || "-" })
|
|
190
193
|
}
|
|
191
194
|
);
|
|
192
195
|
break;
|
|
@@ -197,6 +200,9 @@ const transformTableColumns = ({
|
|
|
197
200
|
case "custom_link":
|
|
198
201
|
v = customizeValue == null ? void 0 : customizeValue(row, column.accessorKey, renderedCellValue);
|
|
199
202
|
break;
|
|
203
|
+
case "toFixed":
|
|
204
|
+
v = toFixedWithNumbers(renderedCellValue);
|
|
205
|
+
break;
|
|
200
206
|
}
|
|
201
207
|
if (redirectionPathWithId && column.type != "custom_link") {
|
|
202
208
|
const id = row.original[idField || "id"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/utils/common-utility.tsx"],"sourcesContent":["\nimport React from 'react';\n\nimport { Box } from '@mui/material';\n/* eslint-disable no-mixed-spaces-and-tabs */\nimport Typography from '../components/typography/typography';\nimport { Document } from '../components/icons';\nimport { MaterialTableColumnProps, TypeBooleanLabels } from '../components/material-table/material-table';\nimport { TFunction } from 'i18next';\nimport { formatDate } from './dateFormat';\nimport { MRT_Row, MRT_RowData } from 'material-react-table';\nimport { Link } from 'react-router-dom';\nimport DefaultAggregation from '../components/material-table/components/default-aggregation';\nimport Chip from '../components/chip/chip';\nimport _ from 'lodash';\nimport images from '../assets/images';\nimport { formatAmount } from \"./common\";\nimport { defaultCurrencyFormat } from './common';\n\nimport { defaultCurrencySymbol } from './common';\nimport ValueField from '../components/value-field/value-field';\nimport { formatLabel } from './format-text';\nimport { generateRouteWithId } from './route-utils';\nconst downloadFile = async (url, fileName) => {\n\ttry {\n\t\t\t// Fetch the file from the provided URL\n\t\t\tconst response = await fetch(url);\n\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Failed to fetch file: ${response.statusText}`);\n\t\t\t}\n\n\t\t\t// Convert the response to a blob\n\t\t\tconst blob = await response.blob();\n\n\t\t\t// Create a temporary URL for the blob\n\t\t\tconst blobUrl = window.URL.createObjectURL(blob);\n\n\t\t\t// Create a link element\n\t\t\tconst link = document.createElement('a');\n\t\t\tlink.href = blobUrl;\n\t\t\tlink.download = fileName || 'downloaded-file'; // Fallback filename if none provided\n\n\t\t\t// Append link to the body, trigger click, and remove it\n\t\t\tdocument.body.appendChild(link);\n\t\t\tlink.click();\n\t\t\tdocument.body.removeChild(link);\n\n\t\t\t// Revoke the blob URL to free up memory\n\t\t\twindow.URL.revokeObjectURL(blobUrl);\n\t} catch (error) {\n\t\t\tconsole.error('Error downloading file:', error);\n\t\t\tthrow error; // Re-throw to allow caller to handle the error\n\t}\n};\n\nexport const getFileNamesFromUrlsAsLink = (fileUrls: string | string[], mode?: string) => {\n\tconst fUrls = fileUrls\n\t\t? Array.isArray(fileUrls)\n\t\t\t? fileUrls\n\t\t\t: [fileUrls]\n\t\t: [];\n\n\tif (fUrls && fUrls.length) {\n\t\treturn (\n\t\t\t<Box\n\t\t\t\tdisplay='flex'\n\t\t\t\tgap={1}\n\t\t\t\tmb={1}\n\t\t\t\talignItems='center'\n\t\t\t\tflexDirection='column'>\n\t\t\t\t{fUrls.map((url) => {\n\t\t\t\t\tconst fileName = url.substring(url.lastIndexOf('/') + 1);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Typography\n\t\t\t\t\t\t\ttype='s3'\n\t\t\t\t\t\t\tweight='medium'\n\t\t\t\t\t\t\tcolor='#246DFF'\n\t\t\t\t\t\t\tsx={{ textDecoration: 'underline', textUnderlineOffset: '3px', cursor:'pointer' }}\n\t\t\t\t\t\t\tnoWrap \n\t\t\t\t\t\t\tonClick={() => mode === 'add' ? undefined : downloadFile(url, fileName)}>\n\t\t\t\t\t\t\t{fileName}\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Box>\n\t\t);\n\t}\n\n\treturn null;\n};\n\nexport const getFileNamesFromUrls = (fileUrls: string[]) => {\n\tif (!fileUrls) return null;\n\n\tif (!fileUrls?.filter(Boolean)?.length) return null;\n\n\treturn fileUrls?.filter(Boolean)?.map((url) => {\n\t\tconst fileName = url?.substring(url?.lastIndexOf('/') + 1) || '';\n\t\treturn (\n\t\t\t<Box display='flex' gap={1} mb={1} alignItems='center'>\n\t\t\t\t<Document fontSize='small' />\n\t\t\t\t<Typography\n\t\t\t\t\ttype='s3'\n\t\t\t\t\tweight='medium'\n\t\t\t\t\tcolor={'theme.secondary.1000'}\n\t\t\t\t\tsx={{cursor: 'pointer'}}\n\t\t\t\t\tnoWrap onClick={() => downloadFile(url, fileName)}>\n\t\t\t\t\t{fileName}\n\t\t\t\t</Typography>\n\t\t\t</Box>\n\t\t);\n\t});\n};\n\nexport type CurrencySymbolFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type StatusClassesFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type RedirectionLinkFn = (row: MRT_Row<MRT_RowData>) => string;\n\nexport interface ITransformTableColumns {\n\tcolumns: MaterialTableColumnProps[];\n\tcurrencySymbol?: string | CurrencySymbolFn;\n\ttranslationFn?: TFunction<'translation', undefined>;\n\tenableFooter?: boolean;\n\tredirectionLink?: string | RedirectionLinkFn;\n\tredirectionLinkState?: (row: MRT_Row<MRT_RowData>) => void;\n\tredirectionPathWithId?: string;\n\tidField?: string;\n\tcustomizeValue?: (row: MRT_Row<MRT_RowData>, columnAccessorKey?: string, value?: any) => any;\n\tstatusClasses?: string | StatusClassesFn;\n\trows: any[];\n\tcurrencyFormat?: boolean\n}\n\nconst jsonArrayToString = (json: any) => {\n\tif (!json) return '';\n\n\ttry {\n\t\treturn JSON.parse(json)?.join(', ');\n\t} catch (error) {\n\t\treturn '';\n\t}\n};\nconst getStatusClass = (status: any) => {\n\tif (typeof status === 'string') {\n\t\treturn status?.toLowerCase()?.replace(' ', '');\n\t} else if (typeof status === 'number') {\n\t\treturn status ? 'enabled' : 'disabled';\n\t}\n};\n\nexport const transformTableColumns = ({\n\tcolumns = [],\n\tcurrencySymbol,\n\ttranslationFn = undefined,\n\tenableFooter = false,\n\tredirectionLink = '',\n\tredirectionLinkState = undefined,\n\tredirectionPathWithId = '',\n\tidField = 'id',\n\tstatusClasses = '',\n\trows = [],\n\tcustomizeValue = undefined,\n\tcurrencyFormat\n}: ITransformTableColumns) => {\n\tconst currencyFormatData = currencyFormat ? currencyFormat : defaultCurrencyFormat()\n\n\treturn columns.map((column) => ({\n\t\t...column,\n\t\theader: translationFn ? translationFn(column.header) : column.header,\n\t\tCell: ({ renderedCellValue, row }: any) => {\n\t\t\tlet v = renderedCellValue;\n\t\t\tconst columnType = column.type || (column.header === \"Amount\" || column.header === \"Rate\" ? \"currency\" : undefined);\n\t\t\tswitch (columnType) {\n\t\t\t\tcase 'formattedString':\n\t\t\t\t\tv = formatLabel(renderedCellValue) || '-';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'date':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'datetime':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY hh:mm A'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'currency':\n\t\t\t\tcase 'amount':{\n\t\t\t\t\tconst cs =column?.showDefaultCurrency? defaultCurrencySymbol(): currencySymbol instanceof Function ? currencySymbol(row) : (currencySymbol || defaultCurrencySymbol());\n\t\t\t\t\tv = renderedCellValue || renderedCellValue == 0\n\t\t\t\t\t\t? `${formatAmount(renderedCellValue,currencyFormatData,'before',cs)||'-'}`\n\t\t\t\t\t\t: null;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\tcase 'status':\n\t\t\t\tcase 'enum':\n\t\t\t\tcase 'array':\n\t\t\t\t\t{\n\t\t\t\t\t\tv = renderedCellValue || renderedCellValue === 0 ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{Array.isArray(renderedCellValue) ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{renderedCellValue?.length ? <Box sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>\n\t\t\t\t\t\t\t\t\t{renderedCellValue.map((rcv) => (\n\t\t\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\t\t\tclassName={column.custom_class?column?.custom_class:(typeof rcv === 'string' ? rcv : '')}\n\t\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{typeof rcv === 'object' ? _.get(rcv, column?.typeArrayAccessorKey||'', '') : rcv}\n\t\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</Box> : '-'}\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcolumn.custom_class?column?.custom_class:\n\t\t\t\t\t\t\t\t\t\t(statusClasses instanceof Function\n\t\t\t\t\t\t\t\t\t\t\t? statusClasses(row)\n\t\t\t\t\t\t\t\t\t\t\t: `${statusClasses}${getStatusClass(renderedCellValue)}`)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t{renderedCellValue}\n\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t'-'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'boolean':\n\t\t\t\t\tv = (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t// active={Boolean(renderedCellValue)}\n\t\t\t\t\t\t\t// inActive={Boolean(!renderedCellValue)}\n\t\t\t\t\t\t\tsx={(theme) => ({\n\t\t\t\t\t\t\t\t\t...(renderedCellValue ? \n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary4[200],\n\t\t\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary4[900]\n\t\t\t\t\t\t\t\t\t\t\t} :\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary6[200],\n\t\t\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary6[900]\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t{column?.typeBooleanLabels?.[renderedCellValue as keyof TypeBooleanLabels] || '-'}\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'jsonArray':\n\t\t\t\t\tv = jsonArrayToString(renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'custom':\n\t\t\t\tcase 'custom_link':\n\t\t\t\t\tv = customizeValue?.(row, column.accessorKey, renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// If redirectionPathWithId is provided, use it for URL parameter-based navigation\n\t\t\tif (redirectionPathWithId && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField||'id'];\n\t\t\t\tif (id) {\n\t\t\t\t\tconst path = redirectionPathWithId instanceof Function ? generateRouteWithId(redirectionPathWithId(row),id?.toString()) : generateRouteWithId(redirectionPathWithId,id?.toString());\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Link to={path}>\n\t\t\t\t\t\t\t{v}\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fall back to the existing redirection logic\n\t\t\telse if (redirectionLink && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField||'id'];\n\t\t\t\tconst path = redirectionLink instanceof Function ? generateRouteWithId(redirectionLink(row),id?.toString()) : generateRouteWithId(redirectionLink,id?.toString());\n\t\t\t\treturn (\n\t\t\t\t\t<Link to={path} \n\t\t\t\t\t\tstate={redirectionLinkState?.(row)}>\n\t\t\t\t\t\t{v}\n\t\t\t\t\t</Link>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn v;\n\t\t},\n\t\t...(Boolean(enableFooter) && {\n\t\t\tFooter: ({ column }) => (\n\t\t\t\t<DefaultAggregation data={rows} column={String(column.id)} />\n\t\t\t)\n\t\t})\n\t}));\n};\n\nexport const renderEmptyRowsFallback = (text:string) => (\n\t<Box className='no-data'>\n\t\t<img src={images.common.tableNoData} />\n\t\t<Typography type='s3' weight='medium' color='theme.secondary.1000'>\n\t\t\t{text}\n\t\t</Typography>\n\t</Box>\n)\n\n/* eslint-disable no-mixed-spaces-and-tabs */\nexport const renderValueField = (label: string, value: any, t: any, formatFn?: (val: any) => string) => {\n\treturn (\n\t <ValueField key={label} label={t?.(label)}>\n\t\t{formatFn ? formatFn(value) : value ?? '-'}\n\t </ValueField>\n\t);\n };\n"],"names":["_a","_b","_c","column"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAM,eAAe,OAAO,KAAK,aAAa;AAC7C,MAAI;AAEF,UAAM,WAAW,MAAM,MAAM,GAAG;AAChC,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,yBAAyB,SAAS,UAAU,EAAE;AAAA,IAChE;AAGA,UAAM,OAAO,MAAM,SAAS,KAAA;AAG5B,UAAM,UAAU,OAAO,IAAI,gBAAgB,IAAI;AAG/C,UAAM,OAAO,SAAS,cAAc,GAAG;AACvC,SAAK,OAAO;AACZ,SAAK,WAAW,YAAY;AAG5B,aAAS,KAAK,YAAY,IAAI;AAC9B,SAAK,MAAA;AACL,aAAS,KAAK,YAAY,IAAI;AAG9B,WAAO,IAAI,gBAAgB,OAAO;AAAA,EACpC,SAAS,OAAO;AACd,YAAQ,MAAM,2BAA2B,KAAK;AAC9C,UAAM;AAAA,EACR;AACD;AAEO,MAAM,6BAA6B,CAAC,UAA6B,SAAkB;AACzF,QAAM,QAAQ,WACX,MAAM,QAAQ,QAAQ,IACrB,WACA,CAAC,QAAQ,IACV,CAAA;AAEH,MAAI,SAAS,MAAM,QAAQ;AAC1B,WACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,SAAQ;AAAA,QACR,KAAK;AAAA,QACL,IAAI;AAAA,QACJ,YAAW;AAAA,QACX,eAAc;AAAA,QACb,UAAA,MAAM,IAAI,CAAC,QAAQ;AACnB,gBAAM,WAAW,IAAI,UAAU,IAAI,YAAY,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EACC;AACH;AAEO,MAAM,0BAA0B,CAAC,SACvC,qBAAC,KAAA,EAAI,WAAU,WACd,UAAA;AAAA,EAAA,oBAAC,OAAA,EAAI,KAAK,OAAO,OAAO,aAAa;AAAA,EACrC,oBAAC,cAAW,MAAK,MAAK,QAAO,UAAS,OAAM,wBAC1C,UAAA,KAAA,CACF;AAAA,EAAA,CACD;AAIM,MAAM,mBAAmB,CAAC,OAAe,OAAY,GAAQ,aAAoC;AACvG,SACE,oBAAC,YAAA,EAAuB,OAAO,uBAAI,QACnC,UAAA,WAAW,SAAS,KAAK,IAAI,SAAS,IAAA,GADrB,KAEjB;AAED;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/utils/common-utility.tsx"],"sourcesContent":["\nimport React from 'react';\n\nimport { Box } from '@mui/material';\n/* eslint-disable no-mixed-spaces-and-tabs */\nimport Typography from '../components/typography/typography';\nimport { Document } from '../components/icons';\nimport { MaterialTableColumnProps, TypeBooleanLabels } from '../components/material-table/material-table';\nimport { TFunction } from 'i18next';\nimport { formatDate } from './dateFormat';\nimport { MRT_Row, MRT_RowData } from 'material-react-table';\nimport { Link } from 'react-router-dom';\nimport DefaultAggregation from '../components/material-table/components/default-aggregation';\nimport Chip from '../components/chip/chip';\nimport _ from 'lodash';\nimport images from '../assets/images';\nimport { formatAmount, toFixedWithNumbers } from \"./common\";\nimport { defaultCurrencyFormat } from './common';\n\nimport { defaultCurrencySymbol } from './common';\nimport ValueField from '../components/value-field/value-field';\nimport { formatLabel } from './format-text';\nimport { generateRouteWithId } from './route-utils';\nconst downloadFile = async (url, fileName) => {\n\ttry {\n\t\t// Fetch the file from the provided URL\n\t\tconst response = await fetch(url);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to fetch file: ${response.statusText}`);\n\t\t}\n\n\t\t// Convert the response to a blob\n\t\tconst blob = await response.blob();\n\n\t\t// Create a temporary URL for the blob\n\t\tconst blobUrl = window.URL.createObjectURL(blob);\n\n\t\t// Create a link element\n\t\tconst link = document.createElement('a');\n\t\tlink.href = blobUrl;\n\t\tlink.download = fileName || 'downloaded-file'; // Fallback filename if none provided\n\n\t\t// Append link to the body, trigger click, and remove it\n\t\tdocument.body.appendChild(link);\n\t\tlink.click();\n\t\tdocument.body.removeChild(link);\n\n\t\t// Revoke the blob URL to free up memory\n\t\twindow.URL.revokeObjectURL(blobUrl);\n\t} catch (error) {\n\t\tconsole.error('Error downloading file:', error);\n\t\tthrow error; // Re-throw to allow caller to handle the error\n\t}\n};\n\nexport const getFileNamesFromUrlsAsLink = (fileUrls: string | string[], mode?: string) => {\n\tconst fUrls = fileUrls\n\t\t? Array.isArray(fileUrls)\n\t\t\t? fileUrls\n\t\t\t: [fileUrls]\n\t\t: [];\n\n\tif (fUrls && fUrls.length) {\n\t\treturn (\n\t\t\t<Box\n\t\t\t\tdisplay='flex'\n\t\t\t\tgap={1}\n\t\t\t\tmb={1}\n\t\t\t\talignItems='center'\n\t\t\t\tflexDirection='column'>\n\t\t\t\t{fUrls.map((url) => {\n\t\t\t\t\tconst fileName = url.substring(url.lastIndexOf('/') + 1);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Typography\n\t\t\t\t\t\t\ttype='s3'\n\t\t\t\t\t\t\tweight='medium'\n\t\t\t\t\t\t\tcolor='#246DFF'\n\t\t\t\t\t\t\tsx={{ textDecoration: 'underline', textUnderlineOffset: '3px', cursor: 'pointer' }}\n\t\t\t\t\t\t\tnoWrap\n\t\t\t\t\t\t\tonClick={() => mode === 'add' ? undefined : downloadFile(url, fileName)}>\n\t\t\t\t\t\t\t{fileName}\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Box>\n\t\t);\n\t}\n\n\treturn null;\n};\n\nexport const getFileNamesFromUrls = (fileUrls: string[]) => {\n\tif (!fileUrls) return null;\n\n\tif (!fileUrls?.filter(Boolean)?.length) return null;\n\n\treturn fileUrls?.filter(Boolean)?.map((url) => {\n\t\tconst fileName = url?.substring(url?.lastIndexOf('/') + 1) || '';\n\t\treturn (\n\t\t\t<Box display='flex' gap={1} mb={1} alignItems='center'>\n\t\t\t\t<Document fontSize='small' />\n\t\t\t\t<Typography\n\t\t\t\t\ttype='s3'\n\t\t\t\t\tweight='medium'\n\t\t\t\t\tcolor={'theme.secondary.1000'}\n\t\t\t\t\tsx={{ cursor: 'pointer' }}\n\t\t\t\t\tnoWrap onClick={() => downloadFile(url, fileName)}>\n\t\t\t\t\t{fileName}\n\t\t\t\t</Typography>\n\t\t\t</Box>\n\t\t);\n\t});\n};\n\nexport type CurrencySymbolFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type StatusClassesFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type RedirectionLinkFn = (row: MRT_Row<MRT_RowData>) => string;\n\nexport interface ITransformTableColumns {\n\tcolumns: MaterialTableColumnProps[];\n\tcurrencySymbol?: string | CurrencySymbolFn;\n\ttranslationFn?: TFunction<'translation', undefined>;\n\tenableFooter?: boolean;\n\tredirectionLink?: string | RedirectionLinkFn;\n\tredirectionLinkState?: (row: MRT_Row<MRT_RowData>) => void;\n\tredirectionPathWithId?: string;\n\tidField?: string;\n\tcustomizeValue?: (row: MRT_Row<MRT_RowData>, columnAccessorKey?: string, value?: any) => any;\n\tstatusClasses?: string | StatusClassesFn;\n\trows: any[];\n\tcurrencyFormat?: boolean\n}\n\nconst jsonArrayToString = (json: any) => {\n\tif (!json) return '';\n\n\ttry {\n\t\treturn JSON.parse(json)?.join(', ');\n\t} catch (error) {\n\t\treturn '';\n\t}\n};\nconst getStatusClass = (status: any) => {\n\tif (typeof status === 'string') {\n\t\treturn status?.toLowerCase()?.replace(' ', '');\n\t} else if (typeof status === 'number') {\n\t\treturn status ? 'enabled' : 'disabled';\n\t}\n};\n\nexport const transformTableColumns = ({\n\tcolumns = [],\n\tcurrencySymbol,\n\ttranslationFn = undefined,\n\tenableFooter = false,\n\tredirectionLink = '',\n\tredirectionLinkState = undefined,\n\tredirectionPathWithId = '',\n\tidField = 'id',\n\tstatusClasses = '',\n\trows = [],\n\tcustomizeValue = undefined,\n\tcurrencyFormat\n}: ITransformTableColumns) => {\n\tconst currencyFormatData = currencyFormat ? currencyFormat : defaultCurrencyFormat()\n\n\treturn columns.map((column) => ({\n\t\t...column,\n\t\theader: translationFn ? translationFn(column.header) : column.header,\n\t\tCell: ({ renderedCellValue, row }: any) => {\n\t\t\tlet v = renderedCellValue;\n\t\t\tif (typeof v === 'number' && v && String(v)?.includes('.')) {\n\t\t\t\treturn v = toFixedWithNumbers(v)\n\t\t\t}\n\t\t\tconst columnType = column.type || (column.header === \"Amount\" || column.header === \"Rate\" ? \"currency\" : undefined);\n\t\t\tswitch (columnType) {\n\t\t\t\tcase 'formattedString':\n\t\t\t\t\tv = formatLabel(renderedCellValue) || '-';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'date':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'datetime':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY hh:mm A'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'currency':\n\t\t\t\tcase 'amount': {\n\t\t\t\t\tconst cs = column?.showDefaultCurrency ? defaultCurrencySymbol() : currencySymbol instanceof Function ? currencySymbol(row) : (currencySymbol || defaultCurrencySymbol());\n\t\t\t\t\tv = renderedCellValue || renderedCellValue == 0\n\t\t\t\t\t\t? `${formatAmount(renderedCellValue, currencyFormatData, 'before', cs) || '-'}`\n\t\t\t\t\t\t: null;\n\n\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'status':\n\t\t\t\tcase 'enum':\n\t\t\t\tcase 'array':\n\t\t\t\t\t{\n\t\t\t\t\t\tv = renderedCellValue || renderedCellValue === 0 ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{Array.isArray(renderedCellValue) ? (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{renderedCellValue?.length ? <Box sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>\n\t\t\t\t\t\t\t\t\t\t\t{renderedCellValue.map((rcv) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName={column.custom_class ? column?.custom_class : (typeof rcv === 'string' ? rcv : '')}\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{typeof rcv === 'object' ? _.get(rcv, column?.typeArrayAccessorKey || '', '') : rcv}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t\t</Box> : '-'}\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\tcolumn.custom_class ? column?.custom_class :\n\t\t\t\t\t\t\t\t\t\t\t\t(statusClasses instanceof Function\n\t\t\t\t\t\t\t\t\t\t\t\t\t? statusClasses(row)\n\t\t\t\t\t\t\t\t\t\t\t\t\t: `${statusClasses}${getStatusClass(renderedCellValue)}`)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={\n\n\t\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderedCellValue}\n\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t'-'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'boolean':\n\t\t\t\t\tv = (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t// active={Boolean(renderedCellValue)}\n\t\t\t\t\t\t\t// inActive={Boolean(!renderedCellValue)}\n\t\t\t\t\t\t\tsx={(theme) => ({\n\t\t\t\t\t\t\t\t...(renderedCellValue ?\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary4[200],\n\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary4[900]\n\t\t\t\t\t\t\t\t\t} :\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary6[200],\n\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary6[900]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t{column?.typeBooleanLabels?.[renderedCellValue as keyof TypeBooleanLabels] || '-'}\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'jsonArray':\n\t\t\t\t\tv = jsonArrayToString(renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'custom':\n\t\t\t\tcase 'custom_link':\n\t\t\t\t\tv = customizeValue?.(row, column.accessorKey, renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'toFixed':\n\t\t\t\t\tv = toFixedWithNumbers(renderedCellValue)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// If redirectionPathWithId is provided, use it for URL parameter-based navigation\n\t\t\tif (redirectionPathWithId && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField || 'id'];\n\t\t\t\tif (id) {\n\t\t\t\t\tconst path = redirectionPathWithId instanceof Function ? generateRouteWithId(redirectionPathWithId(row), id?.toString()) : generateRouteWithId(redirectionPathWithId, id?.toString());\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Link to={path}>\n\t\t\t\t\t\t\t{v}\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fall back to the existing redirection logic\n\t\t\telse if (redirectionLink && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField || 'id'];\n\t\t\t\tconst path = redirectionLink instanceof Function ? generateRouteWithId(redirectionLink(row), id?.toString()) : generateRouteWithId(redirectionLink, id?.toString());\n\t\t\t\treturn (\n\t\t\t\t\t<Link to={path}\n\t\t\t\t\t\tstate={redirectionLinkState?.(row)}>\n\t\t\t\t\t\t{v}\n\t\t\t\t\t</Link>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn v;\n\t\t},\n\t\t...(Boolean(enableFooter) && {\n\t\t\tFooter: ({ column }) => (\n\t\t\t\t<DefaultAggregation data={rows} column={String(column.id)} />\n\t\t\t)\n\t\t})\n\t}));\n};\n\nexport const renderEmptyRowsFallback = (text: string) => (\n\t<Box className='no-data'>\n\t\t<img src={images.common.tableNoData} />\n\t\t<Typography type='s3' weight='medium' color='theme.secondary.1000'>\n\t\t\t{text}\n\t\t</Typography>\n\t</Box>\n)\n\n/* eslint-disable no-mixed-spaces-and-tabs */\nexport const renderValueField = (label: string, value: any, t: any, formatFn?: (val: any) => string) => {\n\treturn (\n\t\t<ValueField key={label} label={t?.(label)}>\n\t\t\t{formatFn ? formatFn(value) : value ?? '-'}\n\t\t</ValueField>\n\t);\n};\n"],"names":["_a","_b","_c","_d","column"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAM,eAAe,OAAO,KAAK,aAAa;AAC7C,MAAI;AAEH,UAAM,WAAW,MAAM,MAAM,GAAG;AAChC,QAAI,CAAC,SAAS,IAAI;AACjB,YAAM,IAAI,MAAM,yBAAyB,SAAS,UAAU,EAAE;AAAA,IAC/D;AAGA,UAAM,OAAO,MAAM,SAAS,KAAA;AAG5B,UAAM,UAAU,OAAO,IAAI,gBAAgB,IAAI;AAG/C,UAAM,OAAO,SAAS,cAAc,GAAG;AACvC,SAAK,OAAO;AACZ,SAAK,WAAW,YAAY;AAG5B,aAAS,KAAK,YAAY,IAAI;AAC9B,SAAK,MAAA;AACL,aAAS,KAAK,YAAY,IAAI;AAG9B,WAAO,IAAI,gBAAgB,OAAO;AAAA,EACnC,SAAS,OAAO;AACf,YAAQ,MAAM,2BAA2B,KAAK;AAC9C,UAAM;AAAA,EACP;AACD;AAEO,MAAM,6BAA6B,CAAC,UAA6B,SAAkB;AACzF,QAAM,QAAQ,WACX,MAAM,QAAQ,QAAQ,IACrB,WACA,CAAC,QAAQ,IACV,CAAA;AAEH,MAAI,SAAS,MAAM,QAAQ;AAC1B,WACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,SAAQ;AAAA,QACR,KAAK;AAAA,QACL,IAAI;AAAA,QACJ,YAAW;AAAA,QACX,eAAc;AAAA,QACb,UAAA,MAAM,IAAI,CAAC,QAAQ;AACnB,gBAAM,WAAW,IAAI,UAAU,IAAI,YAAY,GAAG,IAAI,CAAC;AACvD,iBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACA,MAAK;AAAA,cACL,QA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,cACV,oBAAC,oBAAA,EAAmB,MAAM,MAAM,QAAQ,OAAOA,QAAO,EAAE,EAAA,CAAG;AAAA,IAAA;AAAA,EAE7D,EACC;AACH;AAEO,MAAM,0BAA0B,CAAC,SACvC,qBAAC,KAAA,EAAI,WAAU,WACd,UAAA;AAAA,EAAA,oBAAC,OAAA,EAAI,KAAK,OAAO,OAAO,aAAa;AAAA,EACrC,oBAAC,cAAW,MAAK,MAAK,QAAO,UAAS,OAAM,wBAC1C,UAAA,KAAA,CACF;AAAA,EAAA,CACD;AAIM,MAAM,mBAAmB,CAAC,OAAe,OAAY,GAAQ,aAAoC;AACvG,SACC,oBAAC,YAAA,EAAuB,OAAO,uBAAI,QACjC,UAAA,WAAW,SAAS,KAAK,IAAI,SAAS,IAAA,GADvB,KAEjB;AAEF;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../components/typography/typography/index.js"),r=require("../dateFormat/index.js"),o=require("react-router-dom"),n=require("../../components/material-table/components/default-aggregation/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../components/typography/typography/index.js"),r=require("../dateFormat/index.js"),o=require("react-router-dom"),n=require("../../components/material-table/components/default-aggregation/index.js"),i=require("../../components/chip/chip/index.js"),l=require("lodash"),a=require("../../images/index.js"),s=require("../common/index.js"),d=require("../../components/value-field/value-field/index.js"),u=require("../format-text/index.js"),c=require("../route-utils/index.js"),m=require("../../node_modules/@mui/material/Box/Box/index.js"),p=require("../../components/icons/document/index.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=/* @__PURE__ */h(l);const x=async(e,t)=>{try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch file: ${r.statusText}`);const o=await r.blob(),n=window.URL.createObjectURL(o),i=document.createElement("a");i.href=n,i.download=t||"downloaded-file",document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n)}catch(r){throw r}},f=e=>{var t;return"string"==typeof e?null==(t=null==e?void 0:e.toLowerCase())?void 0:t.replace(" ",""):"number"==typeof e?e?"enabled":"disabled":void 0};exports.getFileNamesFromUrls=r=>{var o,n;return r&&(null==(o=null==r?void 0:r.filter(Boolean))?void 0:o.length)?null==(n=null==r?void 0:r.filter(Boolean))?void 0:n.map(r=>{const o=(null==r?void 0:r.substring((null==r?void 0:r.lastIndexOf("/"))+1))||"";/* @__PURE__ */
|
|
2
2
|
return e.jsxs(m.default,{display:"flex",gap:1,mb:1,alignItems:"center",children:[
|
|
3
3
|
/* @__PURE__ */e.jsx(p.Document,{fontSize:"small"}),
|
|
4
4
|
/* @__PURE__ */e.jsx(t.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",sx:{cursor:"pointer"},noWrap:!0,onClick:()=>x(r,o),children:o})]})}):null},exports.getFileNamesFromUrlsAsLink=(r,o)=>{const n=r?Array.isArray(r)?r:[r]:[];return n&&n.length?/* @__PURE__ */e.jsx(m.default,{display:"flex",gap:1,mb:1,alignItems:"center",flexDirection:"column",children:n.map(r=>{const n=r.substring(r.lastIndexOf("/")+1);/* @__PURE__ */
|
|
5
5
|
return e.jsx(t.Typography,{type:"s3",weight:"medium",color:"#246DFF",sx:{textDecoration:"underline",textUnderlineOffset:"3px",cursor:"pointer"},noWrap:!0,onClick:()=>"add"===o?void 0:x(r,n),children:n})})}):null},exports.renderEmptyRowsFallback=r=>/* @__PURE__ */e.jsxs(m.default,{className:"no-data",children:[
|
|
6
|
-
/* @__PURE__ */e.jsx("img",{src:
|
|
7
|
-
/* @__PURE__ */e.jsx(t.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:r})]}),exports.renderValueField=(t,r,o,n)=>/* @__PURE__ */e.jsx(d.ValueField,{label:null==o?void 0:o(t),children:n?n(r):r??"-"},t),exports.transformTableColumns=({columns:
|
|
8
|
-
return e.jsx(o.Link,{to:r,children:
|
|
9
|
-
return e.jsx(o.Link,{to:r,state:null==x?void 0:x(d),children:
|
|
6
|
+
/* @__PURE__ */e.jsx("img",{src:a.images.common.tableNoData}),
|
|
7
|
+
/* @__PURE__ */e.jsx(t.Typography,{type:"s3",weight:"medium",color:"theme.secondary.1000",children:r})]}),exports.renderValueField=(t,r,o,n)=>/* @__PURE__ */e.jsx(d.ValueField,{label:null==o?void 0:o(t),children:n?n(r):r??"-"},t),exports.transformTableColumns=({columns:l=[],currencySymbol:a,translationFn:d,enableFooter:p=!1,redirectionLink:h="",redirectionLinkState:x,redirectionPathWithId:g="",idField:b="id",statusClasses:v="",rows:j=[],customizeValue:F,currencyFormat:k})=>{const w=k||s.defaultCurrencyFormat();return l.map(l=>({...l,header:d?d(l.header):l.header,Cell:({renderedCellValue:n,row:d})=>{var p,j,k,C;let q=n;if("number"==typeof q&&q&&(null==(p=String(q))?void 0:p.includes(".")))return s.toFixedWithNumbers(q);switch(l.type||("Amount"===l.header||"Rate"===l.header?"currency":void 0)){case"formattedString":q=u.formatLabel(n)||"-";break;case"date":q=r.formatDate(n,(null==(j=l.editProperties)?void 0:j.dateFormat)||"DD-MM-YYYY");break;case"datetime":q=r.formatDate(n,(null==(k=l.editProperties)?void 0:k.dateFormat)||"DD-MM-YYYY hh:mm A");break;case"currency":case"amount":{const e=(null==l?void 0:l.showDefaultCurrency)?s.defaultCurrencySymbol():a instanceof Function?a(d):a||s.defaultCurrencySymbol();q=n||0==n?`${s.formatAmount(n,w,"before",e)||"-"}`:null}break;case"status":case"enum":case"array":q=n||0===n?/* @__PURE__ */e.jsx(e.Fragment,{children:Array.isArray(n)?/* @__PURE__ */e.jsx(e.Fragment,{children:(null==n?void 0:n.length)?/* @__PURE__ */e.jsx(m.default,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:n.map(r=>/* @__PURE__ */e.jsx(i.Chip,{type:"normal",className:l.custom_class?null==l?void 0:l.custom_class:"string"==typeof r?r:"",label:/* @__PURE__ */e.jsx(t.Typography,{type:"s4",weight:"medium",color:"inherit",children:"object"==typeof r?y.default.get(r,(null==l?void 0:l.typeArrayAccessorKey)||"",""):r})}))}):"-"}):/* @__PURE__ */e.jsx(i.Chip,{type:"normal",className:l.custom_class?null==l?void 0:l.custom_class:v instanceof Function?v(d):`${v}${f(n)}`,label:/* @__PURE__ */e.jsx(t.Typography,{type:"s4",weight:"medium",color:"inherit",children:n})})}):"-";break;case"boolean":q=/* @__PURE__ */e.jsx(i.Chip,{type:"normal",sx:e=>{var t,r,o,i;return{...n?{backgroundColor:null==(t=e.palette)?void 0:t.theme.tertiary4[200],color:null==(r=e.palette)?void 0:r.theme.tertiary4[900]}:{backgroundColor:null==(o=e.palette)?void 0:o.theme.tertiary6[200],color:null==(i=e.palette)?void 0:i.theme.tertiary6[900]}}},label:/* @__PURE__ */e.jsx(t.Typography,{type:"s4",weight:"medium",color:"inherit",children:(null==(C=null==l?void 0:l.typeBooleanLabels)?void 0:C[n])||"-"})});break;case"jsonArray":q=(e=>{var t;if(!e)return"";try{return null==(t=JSON.parse(e))?void 0:t.join(", ")}catch(r){return""}})(n);break;case"custom":case"custom_link":q=null==F?void 0:F(d,l.accessorKey,n);break;case"toFixed":q=s.toFixedWithNumbers(n)}if(g&&"custom_link"!=l.type){const t=d.original[b||"id"];if(t){const r=g instanceof Function?c.generateRouteWithId(g(d),null==t?void 0:t.toString()):c.generateRouteWithId(g,null==t?void 0:t.toString());/* @__PURE__ */
|
|
8
|
+
return e.jsx(o.Link,{to:r,children:q})}}else if(h&&"custom_link"!=l.type){const t=d.original[b||"id"],r=h instanceof Function?c.generateRouteWithId(h(d),null==t?void 0:t.toString()):c.generateRouteWithId(h,null==t?void 0:t.toString());/* @__PURE__ */
|
|
9
|
+
return e.jsx(o.Link,{to:r,state:null==x?void 0:x(d),children:q})}return q},...Boolean(p)&&{Footer:({column:t})=>/* @__PURE__ */e.jsx(n.DefaultAggregation,{data:j,column:String(t.id)})}}))};
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/common-utility.tsx"],"sourcesContent":["\nimport React from 'react';\n\nimport { Box } from '@mui/material';\n/* eslint-disable no-mixed-spaces-and-tabs */\nimport Typography from '../components/typography/typography';\nimport { Document } from '../components/icons';\nimport { MaterialTableColumnProps, TypeBooleanLabels } from '../components/material-table/material-table';\nimport { TFunction } from 'i18next';\nimport { formatDate } from './dateFormat';\nimport { MRT_Row, MRT_RowData } from 'material-react-table';\nimport { Link } from 'react-router-dom';\nimport DefaultAggregation from '../components/material-table/components/default-aggregation';\nimport Chip from '../components/chip/chip';\nimport _ from 'lodash';\nimport images from '../assets/images';\nimport { formatAmount } from \"./common\";\nimport { defaultCurrencyFormat } from './common';\n\nimport { defaultCurrencySymbol } from './common';\nimport ValueField from '../components/value-field/value-field';\nimport { formatLabel } from './format-text';\nimport { generateRouteWithId } from './route-utils';\nconst downloadFile = async (url, fileName) => {\n\ttry {\n\t\t\t// Fetch the file from the provided URL\n\t\t\tconst response = await fetch(url);\n\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Failed to fetch file: ${response.statusText}`);\n\t\t\t}\n\n\t\t\t// Convert the response to a blob\n\t\t\tconst blob = await response.blob();\n\n\t\t\t// Create a temporary URL for the blob\n\t\t\tconst blobUrl = window.URL.createObjectURL(blob);\n\n\t\t\t// Create a link element\n\t\t\tconst link = document.createElement('a');\n\t\t\tlink.href = blobUrl;\n\t\t\tlink.download = fileName || 'downloaded-file'; // Fallback filename if none provided\n\n\t\t\t// Append link to the body, trigger click, and remove it\n\t\t\tdocument.body.appendChild(link);\n\t\t\tlink.click();\n\t\t\tdocument.body.removeChild(link);\n\n\t\t\t// Revoke the blob URL to free up memory\n\t\t\twindow.URL.revokeObjectURL(blobUrl);\n\t} catch (error) {\n\t\t\tconsole.error('Error downloading file:', error);\n\t\t\tthrow error; // Re-throw to allow caller to handle the error\n\t}\n};\n\nexport const getFileNamesFromUrlsAsLink = (fileUrls: string | string[], mode?: string) => {\n\tconst fUrls = fileUrls\n\t\t? Array.isArray(fileUrls)\n\t\t\t? fileUrls\n\t\t\t: [fileUrls]\n\t\t: [];\n\n\tif (fUrls && fUrls.length) {\n\t\treturn (\n\t\t\t<Box\n\t\t\t\tdisplay='flex'\n\t\t\t\tgap={1}\n\t\t\t\tmb={1}\n\t\t\t\talignItems='center'\n\t\t\t\tflexDirection='column'>\n\t\t\t\t{fUrls.map((url) => {\n\t\t\t\t\tconst fileName = url.substring(url.lastIndexOf('/') + 1);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Typography\n\t\t\t\t\t\t\ttype='s3'\n\t\t\t\t\t\t\tweight='medium'\n\t\t\t\t\t\t\tcolor='#246DFF'\n\t\t\t\t\t\t\tsx={{ textDecoration: 'underline', textUnderlineOffset: '3px', cursor:'pointer' }}\n\t\t\t\t\t\t\tnoWrap \n\t\t\t\t\t\t\tonClick={() => mode === 'add' ? undefined : downloadFile(url, fileName)}>\n\t\t\t\t\t\t\t{fileName}\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Box>\n\t\t);\n\t}\n\n\treturn null;\n};\n\nexport const getFileNamesFromUrls = (fileUrls: string[]) => {\n\tif (!fileUrls) return null;\n\n\tif (!fileUrls?.filter(Boolean)?.length) return null;\n\n\treturn fileUrls?.filter(Boolean)?.map((url) => {\n\t\tconst fileName = url?.substring(url?.lastIndexOf('/') + 1) || '';\n\t\treturn (\n\t\t\t<Box display='flex' gap={1} mb={1} alignItems='center'>\n\t\t\t\t<Document fontSize='small' />\n\t\t\t\t<Typography\n\t\t\t\t\ttype='s3'\n\t\t\t\t\tweight='medium'\n\t\t\t\t\tcolor={'theme.secondary.1000'}\n\t\t\t\t\tsx={{cursor: 'pointer'}}\n\t\t\t\t\tnoWrap onClick={() => downloadFile(url, fileName)}>\n\t\t\t\t\t{fileName}\n\t\t\t\t</Typography>\n\t\t\t</Box>\n\t\t);\n\t});\n};\n\nexport type CurrencySymbolFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type StatusClassesFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type RedirectionLinkFn = (row: MRT_Row<MRT_RowData>) => string;\n\nexport interface ITransformTableColumns {\n\tcolumns: MaterialTableColumnProps[];\n\tcurrencySymbol?: string | CurrencySymbolFn;\n\ttranslationFn?: TFunction<'translation', undefined>;\n\tenableFooter?: boolean;\n\tredirectionLink?: string | RedirectionLinkFn;\n\tredirectionLinkState?: (row: MRT_Row<MRT_RowData>) => void;\n\tredirectionPathWithId?: string;\n\tidField?: string;\n\tcustomizeValue?: (row: MRT_Row<MRT_RowData>, columnAccessorKey?: string, value?: any) => any;\n\tstatusClasses?: string | StatusClassesFn;\n\trows: any[];\n\tcurrencyFormat?: boolean\n}\n\nconst jsonArrayToString = (json: any) => {\n\tif (!json) return '';\n\n\ttry {\n\t\treturn JSON.parse(json)?.join(', ');\n\t} catch (error) {\n\t\treturn '';\n\t}\n};\nconst getStatusClass = (status: any) => {\n\tif (typeof status === 'string') {\n\t\treturn status?.toLowerCase()?.replace(' ', '');\n\t} else if (typeof status === 'number') {\n\t\treturn status ? 'enabled' : 'disabled';\n\t}\n};\n\nexport const transformTableColumns = ({\n\tcolumns = [],\n\tcurrencySymbol,\n\ttranslationFn = undefined,\n\tenableFooter = false,\n\tredirectionLink = '',\n\tredirectionLinkState = undefined,\n\tredirectionPathWithId = '',\n\tidField = 'id',\n\tstatusClasses = '',\n\trows = [],\n\tcustomizeValue = undefined,\n\tcurrencyFormat\n}: ITransformTableColumns) => {\n\tconst currencyFormatData = currencyFormat ? currencyFormat : defaultCurrencyFormat()\n\n\treturn columns.map((column) => ({\n\t\t...column,\n\t\theader: translationFn ? translationFn(column.header) : column.header,\n\t\tCell: ({ renderedCellValue, row }: any) => {\n\t\t\tlet v = renderedCellValue;\n\t\t\tconst columnType = column.type || (column.header === \"Amount\" || column.header === \"Rate\" ? \"currency\" : undefined);\n\t\t\tswitch (columnType) {\n\t\t\t\tcase 'formattedString':\n\t\t\t\t\tv = formatLabel(renderedCellValue) || '-';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'date':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'datetime':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY hh:mm A'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'currency':\n\t\t\t\tcase 'amount':{\n\t\t\t\t\tconst cs =column?.showDefaultCurrency? defaultCurrencySymbol(): currencySymbol instanceof Function ? currencySymbol(row) : (currencySymbol || defaultCurrencySymbol());\n\t\t\t\t\tv = renderedCellValue || renderedCellValue == 0\n\t\t\t\t\t\t? `${formatAmount(renderedCellValue,currencyFormatData,'before',cs)||'-'}`\n\t\t\t\t\t\t: null;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t\tcase 'status':\n\t\t\t\tcase 'enum':\n\t\t\t\tcase 'array':\n\t\t\t\t\t{\n\t\t\t\t\t\tv = renderedCellValue || renderedCellValue === 0 ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{Array.isArray(renderedCellValue) ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{renderedCellValue?.length ? <Box sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>\n\t\t\t\t\t\t\t\t\t{renderedCellValue.map((rcv) => (\n\t\t\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\t\t\tclassName={column.custom_class?column?.custom_class:(typeof rcv === 'string' ? rcv : '')}\n\t\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{typeof rcv === 'object' ? _.get(rcv, column?.typeArrayAccessorKey||'', '') : rcv}\n\t\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</Box> : '-'}\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcolumn.custom_class?column?.custom_class:\n\t\t\t\t\t\t\t\t\t\t(statusClasses instanceof Function\n\t\t\t\t\t\t\t\t\t\t\t? statusClasses(row)\n\t\t\t\t\t\t\t\t\t\t\t: `${statusClasses}${getStatusClass(renderedCellValue)}`)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t{renderedCellValue}\n\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t'-'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'boolean':\n\t\t\t\t\tv = (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t// active={Boolean(renderedCellValue)}\n\t\t\t\t\t\t\t// inActive={Boolean(!renderedCellValue)}\n\t\t\t\t\t\t\tsx={(theme) => ({\n\t\t\t\t\t\t\t\t\t...(renderedCellValue ? \n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary4[200],\n\t\t\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary4[900]\n\t\t\t\t\t\t\t\t\t\t\t} :\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary6[200],\n\t\t\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary6[900]\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t{column?.typeBooleanLabels?.[renderedCellValue as keyof TypeBooleanLabels] || '-'}\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'jsonArray':\n\t\t\t\t\tv = jsonArrayToString(renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'custom':\n\t\t\t\tcase 'custom_link':\n\t\t\t\t\tv = customizeValue?.(row, column.accessorKey, renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// If redirectionPathWithId is provided, use it for URL parameter-based navigation\n\t\t\tif (redirectionPathWithId && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField||'id'];\n\t\t\t\tif (id) {\n\t\t\t\t\tconst path = redirectionPathWithId instanceof Function ? generateRouteWithId(redirectionPathWithId(row),id?.toString()) : generateRouteWithId(redirectionPathWithId,id?.toString());\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Link to={path}>\n\t\t\t\t\t\t\t{v}\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fall back to the existing redirection logic\n\t\t\telse if (redirectionLink && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField||'id'];\n\t\t\t\tconst path = redirectionLink instanceof Function ? generateRouteWithId(redirectionLink(row),id?.toString()) : generateRouteWithId(redirectionLink,id?.toString());\n\t\t\t\treturn (\n\t\t\t\t\t<Link to={path} \n\t\t\t\t\t\tstate={redirectionLinkState?.(row)}>\n\t\t\t\t\t\t{v}\n\t\t\t\t\t</Link>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn v;\n\t\t},\n\t\t...(Boolean(enableFooter) && {\n\t\t\tFooter: ({ column }) => (\n\t\t\t\t<DefaultAggregation data={rows} column={String(column.id)} />\n\t\t\t)\n\t\t})\n\t}));\n};\n\nexport const renderEmptyRowsFallback = (text:string) => (\n\t<Box className='no-data'>\n\t\t<img src={images.common.tableNoData} />\n\t\t<Typography type='s3' weight='medium' color='theme.secondary.1000'>\n\t\t\t{text}\n\t\t</Typography>\n\t</Box>\n)\n\n/* eslint-disable no-mixed-spaces-and-tabs */\nexport const renderValueField = (label: string, value: any, t: any, formatFn?: (val: any) => string) => {\n\treturn (\n\t <ValueField key={label} label={t?.(label)}>\n\t\t{formatFn ? formatFn(value) : value ?? '-'}\n\t </ValueField>\n\t);\n };\n"],"names":["downloadFile","async","url","fileName","response","fetch","ok","Error","statusText","blob","blobUrl","window","URL","createObjectURL","link","document","createElement","href","download","body","appendChild","click","removeChild","revokeObjectURL","error","getStatusClass","status","_a","toLowerCase","replace","fileUrls","filter","Boolean","length","_b","map","substring","lastIndexOf","jsxs","Box","display","gap","mb","alignItems","children","jsx","Document","fontSize","Typography","type","weight","color","sx","cursor","noWrap","onClick","mode","fUrls","Array","isArray","flexDirection","textDecoration","textUnderlineOffset","text","className","src","images","common","tableNoData","label","value","t","formatFn","ValueField","columns","currencySymbol","translationFn","enableFooter","redirectionLink","redirectionLinkState","redirectionPathWithId","idField","statusClasses","rows","customizeValue","currencyFormat","currencyFormatData","defaultCurrencyFormat","column","header","Cell","renderedCellValue","row","v","formatLabel","formatDate","editProperties","dateFormat","cs","showDefaultCurrency","defaultCurrencySymbol","Function","formatAmount","Fragment","flexWrap","rcv","Chip","custom_class","_","get","typeArrayAccessorKey","theme","backgroundColor","palette","tertiary4","_c","tertiary6","_d","typeBooleanLabels","json","JSON","parse","join","jsonArrayToString","accessorKey","id","original","path","generateRouteWithId","toString","Link","to","state","Footer","DefaultAggregation","data","String"],"mappings":"myBAuBA,MAAMA,EAAeC,MAAOC,EAAKC,KAChC,IAEE,MAAMC,QAAiBC,MAAMH,GAC7B,IAAKE,EAASE,GACZ,MAAM,IAAIC,MAAM,yBAAyBH,EAASI,cAIpD,MAAMC,QAAaL,EAASK,OAGtBC,EAAUC,OAAOC,IAAIC,gBAAgBJ,GAGrCK,EAAOC,SAASC,cAAc,KACpCF,EAAKG,KAAOP,EACZI,EAAKI,SAAWf,GAAY,kBAG5BY,SAASI,KAAKC,YAAYN,GAC1BA,EAAKO,QACLN,SAASI,KAAKG,YAAYR,GAG1BH,OAAOC,IAAIW,gBAAgBb,EAC7B,OAASc,GAEP,MAAMA,CACR,GA0FKC,EAAkBC,UACvB,MAAsB,iBAAXA,EACH,OAAAC,EAAA,MAAAD,OAAA,EAAAA,EAAQE,oBAAR,EAAAD,EAAuBE,QAAQ,IAAK,IACf,iBAAXH,EACVA,EAAS,UAAY,gBAD7B,gCAtDoCI,YACpC,OAAKA,IAEA,OAAAH,EAAA,MAAAG,OAAA,EAAAA,EAAUC,OAAOC,eAAjB,EAAAL,EAA2BM,QAEzB,OAAAC,mBAAUH,OAAOC,eAAjB,EAAAE,EAA2BC,IAAKjC,IACtC,MAAMC,GAAW,MAAAD,OAAA,EAAAA,EAAKkC,WAAU,MAAAlC,OAAA,EAAAA,EAAKmC,YAAY,MAAO,KAAM;AAC9D,OACCC,OAACC,EAAAA,S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B,IACC,OAAO,OAAA5F,EAAA6F,KAAKC,MAAMF,aAAOG,KAAK,KAC/B,OAASlG,GACR,MAAO,EACR,GAkIQmG,CAAkBhC,GACtB,MACD,IAAK,SACL,IAAK,cACJE,EAAI,MAAAT,OAAA,EAAAA,EAAiBQ,EAAKJ,EAAOoC,YAAajC,GAKhD,GAAIX,GAAwC,eAAfQ,EAAOvC,KAAuB,CAC1D,MAAM4E,EAAKjC,EAAIkC,SAAS7C,GAAS,MACjC,GAAI4C,EAAI,CACP,MAAME,EAAO/C,aAAiCqB,SAAW2B,EAAAA,oBAAoBhD,EAAsBY,GAAK,MAAAiC,OAAA,EAAAA,EAAII,YAAcD,EAAAA,oBAAoBhD,QAAsB6C,WAAII;AACxK,OACCpF,EAAAA,IAACqF,EAAAA,KAAA,CAAKC,GAAIJ,EACRnF,SAAAiD,GAGJ,CACD,MAAA,GAESf,GAAkC,eAAfU,EAAOvC,KAAuB,CACzD,MAAM4E,EAAKjC,EAAIkC,SAAS7C,GAAS,MAC3B8C,EAAOjD,aAA2BuB,SAAW2B,EAAAA,oBAAoBlD,EAAgBc,GAAK,MAAAiC,OAAA,EAAAA,EAAII,YAAcD,EAAAA,oBAAoBlD,QAAgB+C,WAAII;AACtJ,OACCpF,EAAAA,IAACqF,EAAAA,KAAA,CAAKC,GAAIJ,EACTK,MAAO,MAAArD,OAAA,EAAAA,EAAuBa,GAC7BhD,SAAAiD,GAGJ,CACA,OAAOA,MAEJ7D,QAAQ6C,IAAiB,CAC5BwD,OAAQ,EAAG7C,OAAAA,sBACV3C,IAACyF,EAAAA,mBAAA,CAAmBC,KAAMpD,EAAMK,OAAQgD,OAAOhD,EAAOqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/common-utility.tsx"],"sourcesContent":["\nimport React from 'react';\n\nimport { Box } from '@mui/material';\n/* eslint-disable no-mixed-spaces-and-tabs */\nimport Typography from '../components/typography/typography';\nimport { Document } from '../components/icons';\nimport { MaterialTableColumnProps, TypeBooleanLabels } from '../components/material-table/material-table';\nimport { TFunction } from 'i18next';\nimport { formatDate } from './dateFormat';\nimport { MRT_Row, MRT_RowData } from 'material-react-table';\nimport { Link } from 'react-router-dom';\nimport DefaultAggregation from '../components/material-table/components/default-aggregation';\nimport Chip from '../components/chip/chip';\nimport _ from 'lodash';\nimport images from '../assets/images';\nimport { formatAmount, toFixedWithNumbers } from \"./common\";\nimport { defaultCurrencyFormat } from './common';\n\nimport { defaultCurrencySymbol } from './common';\nimport ValueField from '../components/value-field/value-field';\nimport { formatLabel } from './format-text';\nimport { generateRouteWithId } from './route-utils';\nconst downloadFile = async (url, fileName) => {\n\ttry {\n\t\t// Fetch the file from the provided URL\n\t\tconst response = await fetch(url);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`Failed to fetch file: ${response.statusText}`);\n\t\t}\n\n\t\t// Convert the response to a blob\n\t\tconst blob = await response.blob();\n\n\t\t// Create a temporary URL for the blob\n\t\tconst blobUrl = window.URL.createObjectURL(blob);\n\n\t\t// Create a link element\n\t\tconst link = document.createElement('a');\n\t\tlink.href = blobUrl;\n\t\tlink.download = fileName || 'downloaded-file'; // Fallback filename if none provided\n\n\t\t// Append link to the body, trigger click, and remove it\n\t\tdocument.body.appendChild(link);\n\t\tlink.click();\n\t\tdocument.body.removeChild(link);\n\n\t\t// Revoke the blob URL to free up memory\n\t\twindow.URL.revokeObjectURL(blobUrl);\n\t} catch (error) {\n\t\tconsole.error('Error downloading file:', error);\n\t\tthrow error; // Re-throw to allow caller to handle the error\n\t}\n};\n\nexport const getFileNamesFromUrlsAsLink = (fileUrls: string | string[], mode?: string) => {\n\tconst fUrls = fileUrls\n\t\t? Array.isArray(fileUrls)\n\t\t\t? fileUrls\n\t\t\t: [fileUrls]\n\t\t: [];\n\n\tif (fUrls && fUrls.length) {\n\t\treturn (\n\t\t\t<Box\n\t\t\t\tdisplay='flex'\n\t\t\t\tgap={1}\n\t\t\t\tmb={1}\n\t\t\t\talignItems='center'\n\t\t\t\tflexDirection='column'>\n\t\t\t\t{fUrls.map((url) => {\n\t\t\t\t\tconst fileName = url.substring(url.lastIndexOf('/') + 1);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Typography\n\t\t\t\t\t\t\ttype='s3'\n\t\t\t\t\t\t\tweight='medium'\n\t\t\t\t\t\t\tcolor='#246DFF'\n\t\t\t\t\t\t\tsx={{ textDecoration: 'underline', textUnderlineOffset: '3px', cursor: 'pointer' }}\n\t\t\t\t\t\t\tnoWrap\n\t\t\t\t\t\t\tonClick={() => mode === 'add' ? undefined : downloadFile(url, fileName)}>\n\t\t\t\t\t\t\t{fileName}\n\t\t\t\t\t\t</Typography>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</Box>\n\t\t);\n\t}\n\n\treturn null;\n};\n\nexport const getFileNamesFromUrls = (fileUrls: string[]) => {\n\tif (!fileUrls) return null;\n\n\tif (!fileUrls?.filter(Boolean)?.length) return null;\n\n\treturn fileUrls?.filter(Boolean)?.map((url) => {\n\t\tconst fileName = url?.substring(url?.lastIndexOf('/') + 1) || '';\n\t\treturn (\n\t\t\t<Box display='flex' gap={1} mb={1} alignItems='center'>\n\t\t\t\t<Document fontSize='small' />\n\t\t\t\t<Typography\n\t\t\t\t\ttype='s3'\n\t\t\t\t\tweight='medium'\n\t\t\t\t\tcolor={'theme.secondary.1000'}\n\t\t\t\t\tsx={{ cursor: 'pointer' }}\n\t\t\t\t\tnoWrap onClick={() => downloadFile(url, fileName)}>\n\t\t\t\t\t{fileName}\n\t\t\t\t</Typography>\n\t\t\t</Box>\n\t\t);\n\t});\n};\n\nexport type CurrencySymbolFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type StatusClassesFn = (row: MRT_Row<MRT_RowData>) => string;\nexport type RedirectionLinkFn = (row: MRT_Row<MRT_RowData>) => string;\n\nexport interface ITransformTableColumns {\n\tcolumns: MaterialTableColumnProps[];\n\tcurrencySymbol?: string | CurrencySymbolFn;\n\ttranslationFn?: TFunction<'translation', undefined>;\n\tenableFooter?: boolean;\n\tredirectionLink?: string | RedirectionLinkFn;\n\tredirectionLinkState?: (row: MRT_Row<MRT_RowData>) => void;\n\tredirectionPathWithId?: string;\n\tidField?: string;\n\tcustomizeValue?: (row: MRT_Row<MRT_RowData>, columnAccessorKey?: string, value?: any) => any;\n\tstatusClasses?: string | StatusClassesFn;\n\trows: any[];\n\tcurrencyFormat?: boolean\n}\n\nconst jsonArrayToString = (json: any) => {\n\tif (!json) return '';\n\n\ttry {\n\t\treturn JSON.parse(json)?.join(', ');\n\t} catch (error) {\n\t\treturn '';\n\t}\n};\nconst getStatusClass = (status: any) => {\n\tif (typeof status === 'string') {\n\t\treturn status?.toLowerCase()?.replace(' ', '');\n\t} else if (typeof status === 'number') {\n\t\treturn status ? 'enabled' : 'disabled';\n\t}\n};\n\nexport const transformTableColumns = ({\n\tcolumns = [],\n\tcurrencySymbol,\n\ttranslationFn = undefined,\n\tenableFooter = false,\n\tredirectionLink = '',\n\tredirectionLinkState = undefined,\n\tredirectionPathWithId = '',\n\tidField = 'id',\n\tstatusClasses = '',\n\trows = [],\n\tcustomizeValue = undefined,\n\tcurrencyFormat\n}: ITransformTableColumns) => {\n\tconst currencyFormatData = currencyFormat ? currencyFormat : defaultCurrencyFormat()\n\n\treturn columns.map((column) => ({\n\t\t...column,\n\t\theader: translationFn ? translationFn(column.header) : column.header,\n\t\tCell: ({ renderedCellValue, row }: any) => {\n\t\t\tlet v = renderedCellValue;\n\t\t\tif (typeof v === 'number' && v && String(v)?.includes('.')) {\n\t\t\t\treturn v = toFixedWithNumbers(v)\n\t\t\t}\n\t\t\tconst columnType = column.type || (column.header === \"Amount\" || column.header === \"Rate\" ? \"currency\" : undefined);\n\t\t\tswitch (columnType) {\n\t\t\t\tcase 'formattedString':\n\t\t\t\t\tv = formatLabel(renderedCellValue) || '-';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'date':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'datetime':\n\t\t\t\t\tv = formatDate(\n\t\t\t\t\t\trenderedCellValue,\n\t\t\t\t\t\tcolumn.editProperties?.dateFormat || 'DD-MM-YYYY hh:mm A'\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'currency':\n\t\t\t\tcase 'amount': {\n\t\t\t\t\tconst cs = column?.showDefaultCurrency ? defaultCurrencySymbol() : currencySymbol instanceof Function ? currencySymbol(row) : (currencySymbol || defaultCurrencySymbol());\n\t\t\t\t\tv = renderedCellValue || renderedCellValue == 0\n\t\t\t\t\t\t? `${formatAmount(renderedCellValue, currencyFormatData, 'before', cs) || '-'}`\n\t\t\t\t\t\t: null;\n\n\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'status':\n\t\t\t\tcase 'enum':\n\t\t\t\tcase 'array':\n\t\t\t\t\t{\n\t\t\t\t\t\tv = renderedCellValue || renderedCellValue === 0 ? (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{Array.isArray(renderedCellValue) ? (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{renderedCellValue?.length ? <Box sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>\n\t\t\t\t\t\t\t\t\t\t\t{renderedCellValue.map((rcv) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName={column.custom_class ? column?.custom_class : (typeof rcv === 'string' ? rcv : '')}\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{typeof rcv === 'object' ? _.get(rcv, column?.typeArrayAccessorKey || '', '') : rcv}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t\t</Box> : '-'}\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t\tcolumn.custom_class ? column?.custom_class :\n\t\t\t\t\t\t\t\t\t\t\t\t(statusClasses instanceof Function\n\t\t\t\t\t\t\t\t\t\t\t\t\t? statusClasses(row)\n\t\t\t\t\t\t\t\t\t\t\t\t\t: `${statusClasses}${getStatusClass(renderedCellValue)}`)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={\n\n\t\t\t\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderedCellValue}\n\t\t\t\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t'-'\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'boolean':\n\t\t\t\t\tv = (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\ttype='normal'\n\t\t\t\t\t\t\t// active={Boolean(renderedCellValue)}\n\t\t\t\t\t\t\t// inActive={Boolean(!renderedCellValue)}\n\t\t\t\t\t\t\tsx={(theme) => ({\n\t\t\t\t\t\t\t\t...(renderedCellValue ?\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary4[200],\n\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary4[900]\n\t\t\t\t\t\t\t\t\t} :\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tbackgroundColor: theme.palette?.theme.tertiary6[200],\n\t\t\t\t\t\t\t\t\t\tcolor: theme.palette?.theme.tertiary6[900]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t<Typography type='s4' weight='medium' color={'inherit'}>\n\t\t\t\t\t\t\t\t\t{column?.typeBooleanLabels?.[renderedCellValue as keyof TypeBooleanLabels] || '-'}\n\t\t\t\t\t\t\t\t</Typography>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'jsonArray':\n\t\t\t\t\tv = jsonArrayToString(renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'custom':\n\t\t\t\tcase 'custom_link':\n\t\t\t\t\tv = customizeValue?.(row, column.accessorKey, renderedCellValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'toFixed':\n\t\t\t\t\tv = toFixedWithNumbers(renderedCellValue)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// If redirectionPathWithId is provided, use it for URL parameter-based navigation\n\t\t\tif (redirectionPathWithId && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField || 'id'];\n\t\t\t\tif (id) {\n\t\t\t\t\tconst path = redirectionPathWithId instanceof Function ? generateRouteWithId(redirectionPathWithId(row), id?.toString()) : generateRouteWithId(redirectionPathWithId, id?.toString());\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Link to={path}>\n\t\t\t\t\t\t\t{v}\n\t\t\t\t\t\t</Link>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Fall back to the existing redirection logic\n\t\t\telse if (redirectionLink && column.type != 'custom_link') {\n\t\t\t\tconst id = row.original[idField || 'id'];\n\t\t\t\tconst path = redirectionLink instanceof Function ? generateRouteWithId(redirectionLink(row), id?.toString()) : generateRouteWithId(redirectionLink, id?.toString());\n\t\t\t\treturn (\n\t\t\t\t\t<Link to={path}\n\t\t\t\t\t\tstate={redirectionLinkState?.(row)}>\n\t\t\t\t\t\t{v}\n\t\t\t\t\t</Link>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn v;\n\t\t},\n\t\t...(Boolean(enableFooter) && {\n\t\t\tFooter: ({ column }) => (\n\t\t\t\t<DefaultAggregation data={rows} column={String(column.id)} />\n\t\t\t)\n\t\t})\n\t}));\n};\n\nexport const renderEmptyRowsFallback = (text: string) => (\n\t<Box className='no-data'>\n\t\t<img src={images.common.tableNoData} />\n\t\t<Typography type='s3' weight='medium' color='theme.secondary.1000'>\n\t\t\t{text}\n\t\t</Typography>\n\t</Box>\n)\n\n/* eslint-disable no-mixed-spaces-and-tabs */\nexport const renderValueField = (label: string, value: any, t: any, formatFn?: (val: any) => string) => {\n\treturn (\n\t\t<ValueField key={label} label={t?.(label)}>\n\t\t\t{formatFn ? formatFn(value) : value ?? '-'}\n\t\t</ValueField>\n\t);\n};\n"],"names":["downloadFile","async","url","fileName","response","fetch","ok","Error","statusText","blob","blobUrl","window","URL","createObjectURL","link","document","createElement","href","download","body","appendChild","click","removeChild","revokeObjectURL","error","getStatusClass","status","_a","toLowerCase","replace","fileUrls","filter","Boolean","length","_b","map","substring","lastIndexOf","jsxs","Box","display","gap","mb","alignItems","children","jsx","Document","fontSize","Typography","type","weight","color","sx","cursor","noWrap","onClick","mode","fUrls","Array","isArray","flexDirection","textDecoration","textUnderlineOffset","text","className","src","images","common","tableNoData","label","value","t","formatFn","ValueField","columns","currencySymbol","translationFn","enableFooter","redirectionLink","redirectionLinkState","redirectionPathWithId","idField","statusClasses","rows","customizeValue","currencyFormat","currencyFormatData","defaultCurrencyFormat","column","header","Cell","renderedCellValue","row","v","includes","toFixedWithNumbers","formatLabel","formatDate","editProperties","dateFormat","_c","cs","showDefaultCurrency","defaultCurrencySymbol","Function","formatAmount","Fragment","flexWrap","rcv","Chip","custom_class","_","get","typeArrayAccessorKey","theme","backgroundColor","palette","tertiary4","tertiary6","_d","typeBooleanLabels","json","JSON","parse","join","jsonArrayToString","accessorKey","id","original","path","generateRouteWithId","toString","Link","to","state","Footer","DefaultAggregation","data","String"],"mappings":"myBAuBA,MAAMA,EAAeC,MAAOC,EAAKC,KAChC,IAEC,MAAMC,QAAiBC,MAAMH,GAC7B,IAAKE,EAASE,GACb,MAAM,IAAIC,MAAM,yBAAyBH,EAASI,cAInD,MAAMC,QAAaL,EAASK,OAGtBC,EAAUC,OAAOC,IAAIC,gBAAgBJ,GAGrCK,EAAOC,SAASC,cAAc,KACpCF,EAAKG,KAAOP,EACZI,EAAKI,SAAWf,GAAY,kBAG5BY,SAASI,KAAKC,YAAYN,GAC1BA,EAAKO,QACLN,SAASI,KAAKG,YAAYR,GAG1BH,OAAOC,IAAIW,gBAAgBb,EAC5B,OAASc,GAER,MAAMA,CACP,GA0FKC,EAAkBC,UACvB,MAAsB,iBAAXA,EACH,OAAAC,EAAA,MAAAD,OAAA,EAAAA,EAAQE,oBAAR,EAAAD,EAAuBE,QAAQ,IAAK,IACf,iBAAXH,EACVA,EAAS,UAAY,gBAD7B,gCAtDoCI,YACpC,OAAKA,IAEA,OAAAH,EAAA,MAAAG,OAAA,EAAAA,EAAUC,OAAOC,eAAjB,EAAAL,EAA2BM,QAEzB,OAAAC,mBAAUH,OAAOC,eAAjB,EAAAE,EAA2BC,IAAKjC,IACtC,MAAMC,GAAW,MAAAD,OAAA,EAAAA,EAAKkC,WAAU,MAAAlC,OAAA,EAAAA,EAAKmC,YAAY,MAAO,KAAM;AAC9D,OACCC,OAACC,EAAAA,SAAIC,QAAQ,OAAOC,IA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