dp-widgets-framework 1.3.8 → 1.4.0
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/index.esm.js +19 -19
- package/dist/index.js +19 -19
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -17652,7 +17652,6 @@ function DataGrid({ title, data, className }) {
|
|
|
17652
17652
|
var _a;
|
|
17653
17653
|
const { columns, rows, units, grouped = false, grouping } = data;
|
|
17654
17654
|
const [expandedGroups, setExpandedGroups] = useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
|
|
17655
|
-
console.log('units==>', units);
|
|
17656
17655
|
const toggleGroup = (groupValue) => {
|
|
17657
17656
|
const newExpanded = new Set(expandedGroups);
|
|
17658
17657
|
if (newExpanded.has(groupValue)) {
|
|
@@ -17663,19 +17662,25 @@ function DataGrid({ title, data, className }) {
|
|
|
17663
17662
|
}
|
|
17664
17663
|
setExpandedGroups(newExpanded);
|
|
17665
17664
|
};
|
|
17665
|
+
const formatWithCommas = (value) => {
|
|
17666
|
+
if (value == null || value === "")
|
|
17667
|
+
return "";
|
|
17668
|
+
let str = value.toString().trim();
|
|
17669
|
+
let num = Number(str);
|
|
17670
|
+
if (isNaN(num))
|
|
17671
|
+
return str;
|
|
17672
|
+
let [integer, decimal] = str.split(".");
|
|
17673
|
+
integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
17674
|
+
return decimal ? `${integer}.${decimal}` : integer;
|
|
17675
|
+
};
|
|
17666
17676
|
const formatValueWithUnit = (value, columnIndex) => {
|
|
17667
17677
|
if (value === null || value === undefined)
|
|
17668
17678
|
return "—";
|
|
17669
17679
|
const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
|
|
17670
17680
|
// Format the value with commas if it's a number or numeric string
|
|
17671
17681
|
let valueStr;
|
|
17672
|
-
|
|
17673
|
-
|
|
17674
|
-
}
|
|
17675
|
-
else {
|
|
17676
|
-
const numValue = parseFloat(String(value));
|
|
17677
|
-
valueStr = !isNaN(numValue) ? numValue.toLocaleString() : String(value);
|
|
17678
|
-
}
|
|
17682
|
+
valueStr = formatWithCommas(value);
|
|
17683
|
+
console.log('value==>', valueStr, unit);
|
|
17679
17684
|
// If no unit or unit length > 3, return value only
|
|
17680
17685
|
if (!unit || unit.length > 3) {
|
|
17681
17686
|
return valueStr;
|
|
@@ -17723,12 +17728,12 @@ function DataGrid({ title, data, className }) {
|
|
|
17723
17728
|
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
17724
17729
|
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
17725
17730
|
? "bg-white"
|
|
17726
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
17731
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900 whitespace-nowrap", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
17727
17732
|
}) })] }));
|
|
17728
17733
|
};
|
|
17729
17734
|
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
17730
17735
|
? "bg-white"
|
|
17731
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
|
|
17736
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900 whitespace-nowrap", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
|
|
17732
17737
|
return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
|
|
17733
17738
|
color: "#0F172A"
|
|
17734
17739
|
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
|
|
@@ -39999,22 +40004,17 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
39999
40004
|
return true;
|
|
40000
40005
|
})
|
|
40001
40006
|
.map((widget) => {
|
|
40002
|
-
|
|
40007
|
+
widget.type === "text";
|
|
40003
40008
|
return {
|
|
40004
40009
|
i: widget.id,
|
|
40005
40010
|
x: widget.position_x,
|
|
40006
40011
|
y: widget.position_y,
|
|
40007
40012
|
w: widget.width,
|
|
40008
|
-
h:
|
|
40009
|
-
? (isEditing ? widget.height : Math.max(widget.height - 1, 1))
|
|
40010
|
-
: widget.height,
|
|
40013
|
+
h: widget.height,
|
|
40011
40014
|
minW: 0,
|
|
40012
|
-
minH:
|
|
40013
|
-
maxH: isText ? widget.height : undefined,
|
|
40015
|
+
minH: 1,
|
|
40014
40016
|
isResizable: isEditing,
|
|
40015
|
-
resizeHandles:
|
|
40016
|
-
? ["w", "e"] // only horizontal
|
|
40017
|
-
: ["sw", "nw", "se", "ne"],
|
|
40017
|
+
resizeHandles: ["sw", "nw", "se", "ne"],
|
|
40018
40018
|
};
|
|
40019
40019
|
});
|
|
40020
40020
|
};
|
package/dist/index.js
CHANGED
|
@@ -17679,7 +17679,6 @@ function DataGrid({ title, data, className }) {
|
|
|
17679
17679
|
var _a;
|
|
17680
17680
|
const { columns, rows, units, grouped = false, grouping } = data;
|
|
17681
17681
|
const [expandedGroups, setExpandedGroups] = React.useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
|
|
17682
|
-
console.log('units==>', units);
|
|
17683
17682
|
const toggleGroup = (groupValue) => {
|
|
17684
17683
|
const newExpanded = new Set(expandedGroups);
|
|
17685
17684
|
if (newExpanded.has(groupValue)) {
|
|
@@ -17690,19 +17689,25 @@ function DataGrid({ title, data, className }) {
|
|
|
17690
17689
|
}
|
|
17691
17690
|
setExpandedGroups(newExpanded);
|
|
17692
17691
|
};
|
|
17692
|
+
const formatWithCommas = (value) => {
|
|
17693
|
+
if (value == null || value === "")
|
|
17694
|
+
return "";
|
|
17695
|
+
let str = value.toString().trim();
|
|
17696
|
+
let num = Number(str);
|
|
17697
|
+
if (isNaN(num))
|
|
17698
|
+
return str;
|
|
17699
|
+
let [integer, decimal] = str.split(".");
|
|
17700
|
+
integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
17701
|
+
return decimal ? `${integer}.${decimal}` : integer;
|
|
17702
|
+
};
|
|
17693
17703
|
const formatValueWithUnit = (value, columnIndex) => {
|
|
17694
17704
|
if (value === null || value === undefined)
|
|
17695
17705
|
return "—";
|
|
17696
17706
|
const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
|
|
17697
17707
|
// Format the value with commas if it's a number or numeric string
|
|
17698
17708
|
let valueStr;
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
}
|
|
17702
|
-
else {
|
|
17703
|
-
const numValue = parseFloat(String(value));
|
|
17704
|
-
valueStr = !isNaN(numValue) ? numValue.toLocaleString() : String(value);
|
|
17705
|
-
}
|
|
17709
|
+
valueStr = formatWithCommas(value);
|
|
17710
|
+
console.log('value==>', valueStr, unit);
|
|
17706
17711
|
// If no unit or unit length > 3, return value only
|
|
17707
17712
|
if (!unit || unit.length > 3) {
|
|
17708
17713
|
return valueStr;
|
|
@@ -17750,12 +17755,12 @@ function DataGrid({ title, data, className }) {
|
|
|
17750
17755
|
return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
|
|
17751
17756
|
})() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
17752
17757
|
? "bg-white"
|
|
17753
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
17758
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900 whitespace-nowrap", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
|
|
17754
17759
|
}) })] }));
|
|
17755
17760
|
};
|
|
17756
17761
|
const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
|
|
17757
17762
|
? "bg-white"
|
|
17758
|
-
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
|
|
17763
|
+
: "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900 whitespace-nowrap", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
|
|
17759
17764
|
return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
|
|
17760
17765
|
color: "#0F172A"
|
|
17761
17766
|
}, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
|
|
@@ -40026,22 +40031,17 @@ function WidgetDashboard({ pageId, isEditing, selectedWidget = null, onWidgetSel
|
|
|
40026
40031
|
return true;
|
|
40027
40032
|
})
|
|
40028
40033
|
.map((widget) => {
|
|
40029
|
-
|
|
40034
|
+
widget.type === "text";
|
|
40030
40035
|
return {
|
|
40031
40036
|
i: widget.id,
|
|
40032
40037
|
x: widget.position_x,
|
|
40033
40038
|
y: widget.position_y,
|
|
40034
40039
|
w: widget.width,
|
|
40035
|
-
h:
|
|
40036
|
-
? (isEditing ? widget.height : Math.max(widget.height - 1, 1))
|
|
40037
|
-
: widget.height,
|
|
40040
|
+
h: widget.height,
|
|
40038
40041
|
minW: 0,
|
|
40039
|
-
minH:
|
|
40040
|
-
maxH: isText ? widget.height : undefined,
|
|
40042
|
+
minH: 1,
|
|
40041
40043
|
isResizable: isEditing,
|
|
40042
|
-
resizeHandles:
|
|
40043
|
-
? ["w", "e"] // only horizontal
|
|
40044
|
-
: ["sw", "nw", "se", "ne"],
|
|
40044
|
+
resizeHandles: ["sw", "nw", "se", "ne"],
|
|
40045
40045
|
};
|
|
40046
40046
|
});
|
|
40047
40047
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dp-widgets-framework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -136,4 +136,4 @@
|
|
|
136
136
|
"tailwindcss": "^3.3.0",
|
|
137
137
|
"typescript": "^5"
|
|
138
138
|
}
|
|
139
|
-
}
|
|
139
|
+
}
|