@agilant/toga-blox 1.0.99 → 1.0.100
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/utils/formaTableData.js +17 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* into the library's expected fields (`type: "STATUS"`, `type: "CURRENCY"`, etc.).
|
|
5
5
|
*/
|
|
6
6
|
function transformBackendConfig(backendConfig) {
|
|
7
|
+
console.log("[LIB] transformBackendConfig input:", backendConfig);
|
|
7
8
|
const finalConfig = {
|
|
8
9
|
key: backendConfig.key,
|
|
9
10
|
type: backendConfig.type ?? "DEFAULT",
|
|
@@ -28,6 +29,7 @@ function transformBackendConfig(backendConfig) {
|
|
|
28
29
|
if (backendConfig.hasRightImage) {
|
|
29
30
|
finalConfig.rightImage = "https://example.com/placeholder.png";
|
|
30
31
|
}
|
|
32
|
+
console.log("[LIB] transformBackendConfig output:", finalConfig);
|
|
31
33
|
return finalConfig;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
@@ -45,16 +47,21 @@ function formatTableData(columnTitles, accessors, columnConfigs, renderers = {})
|
|
|
45
47
|
*/
|
|
46
48
|
function renderCellContent(config) {
|
|
47
49
|
return ({ value }) => {
|
|
50
|
+
// Log to see which type we ended up with, and what the cell value is
|
|
51
|
+
console.log("[LIB] renderCellContent -> config.type:", config.type, "value:", value);
|
|
48
52
|
// 1. Check icons/images
|
|
49
53
|
if (config.leftIcon && renderers.renderIcon) {
|
|
54
|
+
console.log("[LIB] using leftIcon:", config.leftIcon);
|
|
50
55
|
const icon = (_jsx("div", { className: "pr-2", children: renderers.renderIcon(config.leftIcon, "solid") }));
|
|
51
56
|
return renderContent(config, value, icon, "left");
|
|
52
57
|
}
|
|
53
58
|
if (config.rightIcon && renderers.renderIcon) {
|
|
59
|
+
console.log("[LIB] using rightIcon:", config.rightIcon);
|
|
54
60
|
const icon = (_jsx("div", { className: "pl-2", children: renderers.renderIcon(config.rightIcon, "solid") }));
|
|
55
61
|
return renderContent(config, value, icon, "right");
|
|
56
62
|
}
|
|
57
63
|
if (config.leftImage && renderers.renderImage) {
|
|
64
|
+
console.log("[LIB] using leftImage:", config.leftImage);
|
|
58
65
|
const image = (_jsx("div", { className: "pr-2", children: renderers.renderImage({
|
|
59
66
|
imageUrl: config.leftImage,
|
|
60
67
|
altText: "Image",
|
|
@@ -64,6 +71,7 @@ function formatTableData(columnTitles, accessors, columnConfigs, renderers = {})
|
|
|
64
71
|
return renderContent(config, value, image, "left");
|
|
65
72
|
}
|
|
66
73
|
if (config.rightImage && renderers.renderImage) {
|
|
74
|
+
console.log("[LIB] using rightImage:", config.rightImage);
|
|
67
75
|
const image = (_jsx("div", { className: "pl-2", children: renderers.renderImage({
|
|
68
76
|
imageUrl: config.rightImage,
|
|
69
77
|
altText: "Image",
|
|
@@ -75,17 +83,23 @@ function formatTableData(columnTitles, accessors, columnConfigs, renderers = {})
|
|
|
75
83
|
// 2. Check type
|
|
76
84
|
switch (config.type) {
|
|
77
85
|
case "STATUS":
|
|
86
|
+
console.log("[LIB] checking STATUS case, value:", value);
|
|
78
87
|
if (renderers.renderStatus && typeof value === "string") {
|
|
88
|
+
console.log("[LIB] calling renderers.renderStatus!");
|
|
79
89
|
return renderContent(config, value, renderers.renderStatus(value));
|
|
80
90
|
}
|
|
81
91
|
break;
|
|
82
92
|
case "CURRENCY":
|
|
93
|
+
console.log("[LIB] checking CURRENCY case, value:", value);
|
|
83
94
|
if (renderers.renderCurrency && typeof value === "string") {
|
|
95
|
+
console.log("[LIB] calling renderers.renderCurrency!");
|
|
84
96
|
const formatted = renderers.renderCurrency(value);
|
|
85
97
|
return renderContent(config, formatted);
|
|
86
98
|
}
|
|
87
99
|
break;
|
|
88
100
|
// Add other types if needed
|
|
101
|
+
default:
|
|
102
|
+
console.log("[LIB] type is:", config.type, "falling back to raw text");
|
|
89
103
|
}
|
|
90
104
|
// 3. Otherwise, raw text
|
|
91
105
|
return (_jsx("div", { style: { display: "flex", alignItems: "center" }, children: typeof value === "string" ? _jsx("p", { children: value }) : value }));
|
|
@@ -107,14 +121,17 @@ function formatTableData(columnTitles, accessors, columnConfigs, renderers = {})
|
|
|
107
121
|
key,
|
|
108
122
|
type: "DEFAULT",
|
|
109
123
|
};
|
|
124
|
+
console.log("[LIB] rawBackendConfig for", key, ":", rawBackendConfig);
|
|
110
125
|
// 2) Convert booleans => library fields
|
|
111
126
|
const config = transformBackendConfig(rawBackendConfig);
|
|
127
|
+
console.log("[LIB] final config for", key, ":", config);
|
|
112
128
|
return {
|
|
113
129
|
Header: title,
|
|
114
130
|
accessor,
|
|
115
131
|
Cell: ({ value }) => renderCellContent(config)({ value }),
|
|
116
132
|
};
|
|
117
133
|
});
|
|
134
|
+
console.log("[LIB] final columns:", columns);
|
|
118
135
|
return columns;
|
|
119
136
|
}
|
|
120
137
|
/**
|