@megha-ui/react 1.2.68 → 1.2.70

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.
@@ -27,6 +27,7 @@ export interface Column {
27
27
  export interface DataRow {
28
28
  [key: string]: {
29
29
  value: string | number;
30
+ displayValue?: string | number;
30
31
  html?: any;
31
32
  className?: string;
32
33
  shouldRender?: boolean;
@@ -112,11 +112,13 @@ const GridRow = ({ item, rowStyle, cellStyle, rowHeight, bulkSelect, selectedRow
112
112
  const cellData = item[column.key];
113
113
  const cellValue = cellData && Object.keys(cellData).includes("html")
114
114
  ? cellData === null || cellData === void 0 ? void 0 : cellData.html
115
- : cellData && Object.keys(cellData).includes("value")
116
- ? cellData === null || cellData === void 0 ? void 0 : cellData.value
117
- : cellData
118
- ? cellData
119
- : "";
115
+ : cellData && Object.keys(cellData).includes("displayValue")
116
+ ? cellData === null || cellData === void 0 ? void 0 : cellData.displayValue
117
+ : cellData && Object.keys(cellData).includes("value")
118
+ ? cellData === null || cellData === void 0 ? void 0 : cellData.value
119
+ : cellData
120
+ ? cellData
121
+ : "";
120
122
  const cellUrl = cellData === null || cellData === void 0 ? void 0 : cellData.url;
121
123
  const isHidden = column.overflowHidden;
122
124
  if (!column.hidden && groupBy !== column.key) {
package/dist/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export { default as Textarea } from "./components/textarea";
13
13
  export { default as TextEditor } from "./components/texteditor";
14
14
  export { default as Toggle } from "./components/toggle";
15
15
  export { Tabs, Tab, TabList, TabPanel } from "./components/tabs";
16
+ export { formatValue } from "./services/commonService";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TabPanel = exports.TabList = exports.Tab = exports.Tabs = exports.Toggle = exports.TextEditor = exports.Textarea = exports.TextInput = exports.Text = exports.Modal = exports.Loader = exports.Grid = exports.Dropdown = exports.DateInput = exports.Checkbox = exports.Card = exports.Button = exports.Block = void 0;
6
+ exports.formatValue = exports.TabPanel = exports.TabList = exports.Tab = exports.Tabs = exports.Toggle = exports.TextEditor = exports.Textarea = exports.TextInput = exports.Text = exports.Modal = exports.Loader = exports.Grid = exports.Dropdown = exports.DateInput = exports.Checkbox = exports.Card = exports.Button = exports.Block = void 0;
7
7
  var block_1 = require("./components/block");
8
8
  Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return __importDefault(block_1).default; } });
9
9
  var button_1 = require("./components/button");
@@ -37,3 +37,5 @@ Object.defineProperty(exports, "Tabs", { enumerable: true, get: function () { re
37
37
  Object.defineProperty(exports, "Tab", { enumerable: true, get: function () { return tabs_1.Tab; } });
38
38
  Object.defineProperty(exports, "TabList", { enumerable: true, get: function () { return tabs_1.TabList; } });
39
39
  Object.defineProperty(exports, "TabPanel", { enumerable: true, get: function () { return tabs_1.TabPanel; } });
40
+ var commonService_1 = require("./services/commonService");
41
+ Object.defineProperty(exports, "formatValue", { enumerable: true, get: function () { return commonService_1.formatValue; } });
@@ -0,0 +1,3 @@
1
+ export declare const formatValue: (value: string | number, type?: string, locale?: string, options?: {
2
+ currency: string;
3
+ }) => string | number;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatValue = void 0;
4
+ // Function to format numbers
5
+ const formatNumber = (value, locale = "en-US", options = {}) => {
6
+ const formatter = new Intl.NumberFormat(locale, options);
7
+ return formatter.format(value);
8
+ };
9
+ // Function to format dates
10
+ const formatDate = (date, locale = "en-US", options = {}) => {
11
+ const formatter = new Intl.DateTimeFormat(locale, options);
12
+ return formatter.format(date);
13
+ };
14
+ // Function to format currency
15
+ const formatCurrency = (value, locale = "en-US", currency = "USD", options = {}) => {
16
+ const formatter = new Intl.NumberFormat(locale, Object.assign({ style: "currency", currency: currency }, options));
17
+ return formatter.format(value);
18
+ };
19
+ // Dynamic formatter function
20
+ const formatValue = (value, type = "number", locale = "sv-SE", options = {
21
+ currency: "SEK",
22
+ }) => {
23
+ if (type === "number") {
24
+ const num = parseFloat(value.toString());
25
+ return formatNumber(num, locale, options);
26
+ }
27
+ else if (type === "date") {
28
+ const date = new Date(value);
29
+ return formatDate(date, locale, options);
30
+ }
31
+ else if (type === "currency" && typeof value === "number") {
32
+ return formatCurrency(value, locale, options.currency, options);
33
+ }
34
+ else {
35
+ return value;
36
+ }
37
+ };
38
+ exports.formatValue = formatValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.68",
3
+ "version": "1.2.70",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",