@multiplatform.one/components 9.0.2 → 9.0.4
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/cjs/Chip/index.cjs +4 -3
- package/dist/cjs/Chip/index.native.js +4 -3
- package/dist/cjs/Chip/index.native.js.map +1 -1
- package/dist/cjs/images/RemoteArt/svgMarkup.cjs +36 -28
- package/dist/cjs/images/RemoteArt/svgMarkup.native.js +66 -58
- package/dist/cjs/images/RemoteArt/svgMarkup.native.js.map +1 -1
- package/dist/cjs/views/Dashboard.cjs +123 -67
- package/dist/cjs/views/Dashboard.native.js +131 -66
- package/dist/cjs/views/Dashboard.native.js.map +1 -1
- package/dist/cjs/views/FilePreview.cjs +91 -48
- package/dist/cjs/views/FilePreview.native.js +98 -54
- package/dist/cjs/views/FilePreview.native.js.map +1 -1
- package/dist/cjs/views/ListGroup.cjs +66 -51
- package/dist/cjs/views/ListGroup.native.js +70 -55
- package/dist/cjs/views/ListGroup.native.js.map +1 -1
- package/dist/esm/Chip/index.mjs +4 -3
- package/dist/esm/Chip/index.mjs.map +1 -1
- package/dist/esm/Chip/index.native.js +4 -3
- package/dist/esm/Chip/index.native.js.map +1 -1
- package/dist/esm/images/RemoteArt/svgMarkup.mjs +36 -28
- package/dist/esm/images/RemoteArt/svgMarkup.mjs.map +1 -1
- package/dist/esm/images/RemoteArt/svgMarkup.native.js +66 -58
- package/dist/esm/images/RemoteArt/svgMarkup.native.js.map +1 -1
- package/dist/esm/views/Dashboard.mjs +123 -67
- package/dist/esm/views/Dashboard.mjs.map +1 -1
- package/dist/esm/views/Dashboard.native.js +131 -66
- package/dist/esm/views/Dashboard.native.js.map +1 -1
- package/dist/esm/views/FilePreview.mjs +91 -48
- package/dist/esm/views/FilePreview.mjs.map +1 -1
- package/dist/esm/views/FilePreview.native.js +98 -54
- package/dist/esm/views/FilePreview.native.js.map +1 -1
- package/dist/esm/views/ListGroup.mjs +66 -51
- package/dist/esm/views/ListGroup.mjs.map +1 -1
- package/dist/esm/views/ListGroup.native.js +70 -55
- package/dist/esm/views/ListGroup.native.js.map +1 -1
- package/dist/jsx/Chip/index.mjs +4 -3
- package/dist/jsx/Chip/index.mjs.map +1 -1
- package/dist/jsx/Chip/index.native.js +4 -3
- package/dist/jsx/Chip/index.native.js.map +1 -1
- package/dist/jsx/images/RemoteArt/svgMarkup.mjs +36 -28
- package/dist/jsx/images/RemoteArt/svgMarkup.mjs.map +1 -1
- package/dist/jsx/images/RemoteArt/svgMarkup.native.js +66 -58
- package/dist/jsx/images/RemoteArt/svgMarkup.native.js.map +1 -1
- package/dist/jsx/views/Dashboard.mjs +123 -67
- package/dist/jsx/views/Dashboard.mjs.map +1 -1
- package/dist/jsx/views/Dashboard.native.js +131 -66
- package/dist/jsx/views/Dashboard.native.js.map +1 -1
- package/dist/jsx/views/FilePreview.mjs +91 -48
- package/dist/jsx/views/FilePreview.mjs.map +1 -1
- package/dist/jsx/views/FilePreview.native.js +98 -54
- package/dist/jsx/views/FilePreview.native.js.map +1 -1
- package/dist/jsx/views/ListGroup.mjs +66 -51
- package/dist/jsx/views/ListGroup.mjs.map +1 -1
- package/dist/jsx/views/ListGroup.native.js +70 -55
- package/dist/jsx/views/ListGroup.native.js.map +1 -1
- package/package.json +7 -7
- package/src/Chip/index.tsx +2 -1
- package/src/images/RemoteArt/svgMarkup.ts +56 -41
- package/src/views/Dashboard.tsx +145 -77
- package/src/views/FilePreview.tsx +84 -46
- package/src/views/ListGroup.tsx +86 -53
- package/types/Chip/index.d.ts.map +1 -1
- package/types/views/Dashboard.d.ts.map +1 -1
- package/types/views/FilePreview.d.ts.map +1 -1
- package/types/views/ListGroup.d.ts.map +1 -1
|
@@ -103,6 +103,106 @@ function resolveTrendColor(trend, goodDirection, neutral) {
|
|
|
103
103
|
if (!goodDirection || goodDirection === "none") return neutral;
|
|
104
104
|
return trend === goodDirection ? import_componentColors.componentColors.semantic.success : import_componentColors.componentColors.semantic.error;
|
|
105
105
|
}
|
|
106
|
+
function formatKpiMetric(num, format, currencySymbol) {
|
|
107
|
+
if (format === "currency") {
|
|
108
|
+
return (0, import_theme.formatCurrency)(num, {
|
|
109
|
+
symbol: currencySymbol || "$",
|
|
110
|
+
fractionDigits: "auto"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (format === "percent") return (0, import_theme.formatPercent)(num);
|
|
114
|
+
return (0, import_theme.formatNumber)(num);
|
|
115
|
+
}
|
|
116
|
+
function kpiValueText(value, formatMetric) {
|
|
117
|
+
if (value === null) return "\u2014";
|
|
118
|
+
if (typeof value === "string") return value;
|
|
119
|
+
return formatMetric(value);
|
|
120
|
+
}
|
|
121
|
+
function trendGlyph(trend) {
|
|
122
|
+
if (trend === "up") return "\u2191";
|
|
123
|
+
if (trend === "down") return "\u2193";
|
|
124
|
+
return "\u2014";
|
|
125
|
+
}
|
|
126
|
+
function activateOnKey(event) {
|
|
127
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
if (!event.repeat) event.currentTarget.click();
|
|
130
|
+
}
|
|
131
|
+
function kpiNavigationProps(id, onPress) {
|
|
132
|
+
if (!import_tamagui.isWeb) return {};
|
|
133
|
+
return {
|
|
134
|
+
"data-mpo-kpi-navigation": id,
|
|
135
|
+
tabIndex: onPress ? 0 : void 0,
|
|
136
|
+
onKeyDown: onPress ? activateOnKey : void 0
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function keepSize(width, height) {
|
|
140
|
+
return previous => previous.width === width && previous.height === height ? previous : {
|
|
141
|
+
width,
|
|
142
|
+
height
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function hasKpiDataView(config) {
|
|
146
|
+
return config.value !== null && Boolean(config.sparkline?.length);
|
|
147
|
+
}
|
|
148
|
+
function KpiHeader({
|
|
149
|
+
config,
|
|
150
|
+
knobProps,
|
|
151
|
+
box,
|
|
152
|
+
px,
|
|
153
|
+
hasDataView,
|
|
154
|
+
actionSize,
|
|
155
|
+
onHeight
|
|
156
|
+
}) {
|
|
157
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
158
|
+
justifyContent: "space-between",
|
|
159
|
+
alignItems: "center",
|
|
160
|
+
...knobProps.gap,
|
|
161
|
+
onLayout: hasDataView ? event => onHeight(event.nativeEvent.layout.height) : void 0,
|
|
162
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
163
|
+
...knobProps.label,
|
|
164
|
+
color: knobProps.textAccentColor,
|
|
165
|
+
flex: 1,
|
|
166
|
+
children: config.title
|
|
167
|
+
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_widgetChrome.NestedIconWell, {
|
|
168
|
+
color: config.color,
|
|
169
|
+
box,
|
|
170
|
+
px,
|
|
171
|
+
radius: knobProps.borderRadius,
|
|
172
|
+
children: config.icon
|
|
173
|
+
}) : null, hasDataView ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
174
|
+
width: actionSize.width,
|
|
175
|
+
height: actionSize.height,
|
|
176
|
+
pointerEvents: "none"
|
|
177
|
+
}) : null]
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function KpiStatus({
|
|
181
|
+
status,
|
|
182
|
+
knobProps
|
|
183
|
+
}) {
|
|
184
|
+
if (!status) return null;
|
|
185
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
186
|
+
...knobProps.label,
|
|
187
|
+
color: knobProps.textAccentColor,
|
|
188
|
+
"data-kpi-status": "",
|
|
189
|
+
children: status
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function KpiSparkline({
|
|
193
|
+
config,
|
|
194
|
+
unread,
|
|
195
|
+
px,
|
|
196
|
+
formatMetric
|
|
197
|
+
}) {
|
|
198
|
+
if (unread || !config.sparkline || config.sparkline.length === 0) return null;
|
|
199
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Sparkline.Sparkline, {
|
|
200
|
+
data: config.sparkline,
|
|
201
|
+
height: px,
|
|
202
|
+
title: config.title,
|
|
203
|
+
valueFormatter: formatMetric
|
|
204
|
+
});
|
|
205
|
+
}
|
|
106
206
|
function KPICard({
|
|
107
207
|
config,
|
|
108
208
|
...stackProps
|
|
@@ -129,51 +229,21 @@ function KPICard({
|
|
|
129
229
|
height: 44
|
|
130
230
|
});
|
|
131
231
|
const [dataHeaderHeight, setDataHeaderHeight] = (0, import_react.useState)(44);
|
|
132
|
-
const hasDataView =
|
|
133
|
-
const formatMetric = (0, import_react.useCallback)(num =>
|
|
134
|
-
if (config.format === "currency") {
|
|
135
|
-
return (0, import_theme.formatCurrency)(num, {
|
|
136
|
-
symbol: config.currencySymbol || "$",
|
|
137
|
-
fractionDigits: "auto"
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (config.format === "percent") return (0, import_theme.formatPercent)(num);
|
|
141
|
-
return (0, import_theme.formatNumber)(num);
|
|
142
|
-
}, [config.format, config.currencySymbol]);
|
|
232
|
+
const hasDataView = hasKpiDataView(config);
|
|
233
|
+
const formatMetric = (0, import_react.useCallback)(num => formatKpiMetric(num, config.format, config.currencySymbol), [config.format, config.currencySymbol]);
|
|
143
234
|
const unread = config.value === null;
|
|
144
|
-
const formattedValue = (0, import_react.useMemo)(() =>
|
|
145
|
-
if (config.value === null) return "\u2014";
|
|
146
|
-
if (typeof config.value === "string") return config.value;
|
|
147
|
-
return formatMetric(config.value);
|
|
148
|
-
}, [config.value, formatMetric]);
|
|
235
|
+
const formattedValue = (0, import_react.useMemo)(() => kpiValueText(config.value, formatMetric), [config.value, formatMetric]);
|
|
149
236
|
const trendColor = (0, import_react.useMemo)(() => resolveTrendColor(config.trend, config.goodDirection, knobProps.textAccentColor), [config.trend, config.goodDirection, knobProps.textAccentColor]);
|
|
150
|
-
const trendSymbol = (0, import_react.useMemo)(() =>
|
|
151
|
-
if (config.trend === "up") return "\u2191";
|
|
152
|
-
if (config.trend === "down") return "\u2193";
|
|
153
|
-
return "\u2014";
|
|
154
|
-
}, [config.trend]);
|
|
237
|
+
const trendSymbol = (0, import_react.useMemo)(() => trendGlyph(config.trend), [config.trend]);
|
|
155
238
|
const content = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
156
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
flex: 1,
|
|
165
|
-
children: config.title
|
|
166
|
-
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_widgetChrome.NestedIconWell, {
|
|
167
|
-
color: config.color,
|
|
168
|
-
box,
|
|
169
|
-
px,
|
|
170
|
-
radius: knobProps.borderRadius,
|
|
171
|
-
children: config.icon
|
|
172
|
-
}) : null, hasDataView ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
173
|
-
width: dataActionSize.width,
|
|
174
|
-
height: dataActionSize.height,
|
|
175
|
-
pointerEvents: "none"
|
|
176
|
-
}) : null]
|
|
239
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(KpiHeader, {
|
|
240
|
+
config,
|
|
241
|
+
knobProps,
|
|
242
|
+
box,
|
|
243
|
+
px,
|
|
244
|
+
hasDataView,
|
|
245
|
+
actionSize: dataActionSize,
|
|
246
|
+
onHeight: setDataHeaderHeight
|
|
177
247
|
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
178
248
|
fontSize: "$8",
|
|
179
249
|
color: unread ? "$color11" : "$color",
|
|
@@ -186,17 +256,15 @@ function KPICard({
|
|
|
186
256
|
"data-kpi-reading": unread ? "none" : "measured"
|
|
187
257
|
},
|
|
188
258
|
children: formattedValue
|
|
189
|
-
}),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
valueFormatter: formatMetric
|
|
199
|
-
}) : null, !unread && (config.trend || config.trendValue) && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
259
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(KpiStatus, {
|
|
260
|
+
status: config.status,
|
|
261
|
+
knobProps
|
|
262
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(KpiSparkline, {
|
|
263
|
+
config,
|
|
264
|
+
unread,
|
|
265
|
+
px,
|
|
266
|
+
formatMetric
|
|
267
|
+
}), !unread && (config.trend || config.trendValue) && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
200
268
|
gap: "$2",
|
|
201
269
|
alignItems: "center",
|
|
202
270
|
flexWrap: "wrap",
|
|
@@ -242,16 +310,7 @@ function KPICard({
|
|
|
242
310
|
...knobProps.containerRadius,
|
|
243
311
|
...interactive,
|
|
244
312
|
focusable: Boolean(onPress),
|
|
245
|
-
...(
|
|
246
|
-
"data-mpo-kpi-navigation": config.id,
|
|
247
|
-
tabIndex: onPress ? 0 : void 0,
|
|
248
|
-
onKeyDown: onPress ? event => {
|
|
249
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
250
|
-
event.preventDefault();
|
|
251
|
-
if (!event.repeat) event.currentTarget.click();
|
|
252
|
-
}
|
|
253
|
-
} : void 0
|
|
254
|
-
} : {}),
|
|
313
|
+
...kpiNavigationProps(config.id, onPress),
|
|
255
314
|
children: content
|
|
256
315
|
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
257
316
|
position: "absolute",
|
|
@@ -264,10 +323,7 @@ function KPICard({
|
|
|
264
323
|
width,
|
|
265
324
|
height
|
|
266
325
|
} = event.nativeEvent.layout;
|
|
267
|
-
setDataActionSize(
|
|
268
|
-
width,
|
|
269
|
-
height
|
|
270
|
-
});
|
|
326
|
+
setDataActionSize(keepSize(width, height));
|
|
271
327
|
},
|
|
272
328
|
children: action
|
|
273
329
|
})]
|
|
@@ -117,12 +117,119 @@ function resolveTrendColor(trend, goodDirection, neutral) {
|
|
|
117
117
|
if (!goodDirection || goodDirection === "none") return neutral;
|
|
118
118
|
return trend === goodDirection ? import_componentColors.componentColors.semantic.success : import_componentColors.componentColors.semantic.error;
|
|
119
119
|
}
|
|
120
|
+
function formatKpiMetric(num, format, currencySymbol) {
|
|
121
|
+
if (format === "currency") {
|
|
122
|
+
return (0, import_theme.formatCurrency)(num, {
|
|
123
|
+
symbol: currencySymbol || "$",
|
|
124
|
+
fractionDigits: "auto"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (format === "percent") return (0, import_theme.formatPercent)(num);
|
|
128
|
+
return (0, import_theme.formatNumber)(num);
|
|
129
|
+
}
|
|
130
|
+
function kpiValueText(value, formatMetric) {
|
|
131
|
+
if (value === null) return "\u2014";
|
|
132
|
+
if (typeof value === "string") return value;
|
|
133
|
+
return formatMetric(value);
|
|
134
|
+
}
|
|
135
|
+
function trendGlyph(trend) {
|
|
136
|
+
if (trend === "up") return "\u2191";
|
|
137
|
+
if (trend === "down") return "\u2193";
|
|
138
|
+
return "\u2014";
|
|
139
|
+
}
|
|
140
|
+
function activateOnKey(event) {
|
|
141
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
if (!event.repeat) event.currentTarget.click();
|
|
144
|
+
}
|
|
145
|
+
function kpiNavigationProps(id, onPress) {
|
|
146
|
+
if (!import_tamagui.isWeb) return {};
|
|
147
|
+
return {
|
|
148
|
+
"data-mpo-kpi-navigation": id,
|
|
149
|
+
tabIndex: onPress ? 0 : void 0,
|
|
150
|
+
onKeyDown: onPress ? activateOnKey : void 0
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function keepSize(width, height) {
|
|
154
|
+
return function (previous) {
|
|
155
|
+
return previous.width === width && previous.height === height ? previous : {
|
|
156
|
+
width,
|
|
157
|
+
height
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function hasKpiDataView(config) {
|
|
162
|
+
var _config_sparkline;
|
|
163
|
+
return config.value !== null && Boolean((_config_sparkline = config.sparkline) === null || _config_sparkline === void 0 ? void 0 : _config_sparkline.length);
|
|
164
|
+
}
|
|
165
|
+
function KpiHeader(param) {
|
|
166
|
+
var {
|
|
167
|
+
config,
|
|
168
|
+
knobProps,
|
|
169
|
+
box,
|
|
170
|
+
px,
|
|
171
|
+
hasDataView,
|
|
172
|
+
actionSize,
|
|
173
|
+
onHeight
|
|
174
|
+
} = param;
|
|
175
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
176
|
+
justifyContent: "space-between",
|
|
177
|
+
alignItems: "center",
|
|
178
|
+
...knobProps.gap,
|
|
179
|
+
onLayout: hasDataView ? function (event) {
|
|
180
|
+
return onHeight(event.nativeEvent.layout.height);
|
|
181
|
+
} : void 0,
|
|
182
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
183
|
+
...knobProps.label,
|
|
184
|
+
color: knobProps.textAccentColor,
|
|
185
|
+
flex: 1,
|
|
186
|
+
children: config.title
|
|
187
|
+
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_widgetChrome.NestedIconWell, {
|
|
188
|
+
color: config.color,
|
|
189
|
+
box,
|
|
190
|
+
px,
|
|
191
|
+
radius: knobProps.borderRadius,
|
|
192
|
+
children: config.icon
|
|
193
|
+
}) : null, hasDataView ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
194
|
+
width: actionSize.width,
|
|
195
|
+
height: actionSize.height,
|
|
196
|
+
pointerEvents: "none"
|
|
197
|
+
}) : null]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function KpiStatus(param) {
|
|
201
|
+
var {
|
|
202
|
+
status,
|
|
203
|
+
knobProps
|
|
204
|
+
} = param;
|
|
205
|
+
if (!status) return null;
|
|
206
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
207
|
+
...knobProps.label,
|
|
208
|
+
color: knobProps.textAccentColor,
|
|
209
|
+
"data-kpi-status": "",
|
|
210
|
+
children: status
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function KpiSparkline(param) {
|
|
214
|
+
var {
|
|
215
|
+
config,
|
|
216
|
+
unread,
|
|
217
|
+
px,
|
|
218
|
+
formatMetric
|
|
219
|
+
} = param;
|
|
220
|
+
if (unread || !config.sparkline || config.sparkline.length === 0) return null;
|
|
221
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Sparkline.Sparkline, {
|
|
222
|
+
data: config.sparkline,
|
|
223
|
+
height: px,
|
|
224
|
+
title: config.title,
|
|
225
|
+
valueFormatter: formatMetric
|
|
226
|
+
});
|
|
227
|
+
}
|
|
120
228
|
function KPICard(param) {
|
|
121
229
|
var {
|
|
122
230
|
config,
|
|
123
231
|
...stackProps
|
|
124
232
|
} = param;
|
|
125
|
-
var _config_sparkline;
|
|
126
233
|
var {
|
|
127
234
|
t
|
|
128
235
|
} = (0, import_i18n.useTranslation)();
|
|
@@ -145,55 +252,29 @@ function KPICard(param) {
|
|
|
145
252
|
height: 44
|
|
146
253
|
});
|
|
147
254
|
var [dataHeaderHeight, setDataHeaderHeight] = (0, import_react.useState)(44);
|
|
148
|
-
var hasDataView =
|
|
255
|
+
var hasDataView = hasKpiDataView(config);
|
|
149
256
|
var formatMetric = (0, import_react.useCallback)(function (num) {
|
|
150
|
-
|
|
151
|
-
return (0, import_theme.formatCurrency)(num, {
|
|
152
|
-
symbol: config.currencySymbol || "$",
|
|
153
|
-
fractionDigits: "auto"
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
if (config.format === "percent") return (0, import_theme.formatPercent)(num);
|
|
157
|
-
return (0, import_theme.formatNumber)(num);
|
|
257
|
+
return formatKpiMetric(num, config.format, config.currencySymbol);
|
|
158
258
|
}, [config.format, config.currencySymbol]);
|
|
159
259
|
var unread = config.value === null;
|
|
160
260
|
var formattedValue = (0, import_react.useMemo)(function () {
|
|
161
|
-
|
|
162
|
-
if (typeof config.value === "string") return config.value;
|
|
163
|
-
return formatMetric(config.value);
|
|
261
|
+
return kpiValueText(config.value, formatMetric);
|
|
164
262
|
}, [config.value, formatMetric]);
|
|
165
263
|
var trendColor = (0, import_react.useMemo)(function () {
|
|
166
264
|
return resolveTrendColor(config.trend, config.goodDirection, knobProps.textAccentColor);
|
|
167
265
|
}, [config.trend, config.goodDirection, knobProps.textAccentColor]);
|
|
168
266
|
var trendSymbol = (0, import_react.useMemo)(function () {
|
|
169
|
-
|
|
170
|
-
if (config.trend === "down") return "\u2193";
|
|
171
|
-
return "\u2014";
|
|
267
|
+
return trendGlyph(config.trend);
|
|
172
268
|
}, [config.trend]);
|
|
173
269
|
var content = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
174
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
...knobProps.label,
|
|
183
|
-
color: knobProps.textAccentColor,
|
|
184
|
-
flex: 1,
|
|
185
|
-
children: config.title
|
|
186
|
-
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_widgetChrome.NestedIconWell, {
|
|
187
|
-
color: config.color,
|
|
188
|
-
box,
|
|
189
|
-
px,
|
|
190
|
-
radius: knobProps.borderRadius,
|
|
191
|
-
children: config.icon
|
|
192
|
-
}) : null, hasDataView ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
193
|
-
width: dataActionSize.width,
|
|
194
|
-
height: dataActionSize.height,
|
|
195
|
-
pointerEvents: "none"
|
|
196
|
-
}) : null]
|
|
270
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(KpiHeader, {
|
|
271
|
+
config,
|
|
272
|
+
knobProps,
|
|
273
|
+
box,
|
|
274
|
+
px,
|
|
275
|
+
hasDataView,
|
|
276
|
+
actionSize: dataActionSize,
|
|
277
|
+
onHeight: setDataHeaderHeight
|
|
197
278
|
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
198
279
|
fontSize: "$8",
|
|
199
280
|
color: unread ? "$color11" : "$color",
|
|
@@ -206,17 +287,15 @@ function KPICard(param) {
|
|
|
206
287
|
"data-kpi-reading": unread ? "none" : "measured"
|
|
207
288
|
},
|
|
208
289
|
children: formattedValue
|
|
209
|
-
}),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
valueFormatter: formatMetric
|
|
219
|
-
}) : null, !unread && (config.trend || config.trendValue) && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
290
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(KpiStatus, {
|
|
291
|
+
status: config.status,
|
|
292
|
+
knobProps
|
|
293
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(KpiSparkline, {
|
|
294
|
+
config,
|
|
295
|
+
unread,
|
|
296
|
+
px,
|
|
297
|
+
formatMetric
|
|
298
|
+
}), !unread && (config.trend || config.trendValue) && /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
220
299
|
gap: "$2",
|
|
221
300
|
alignItems: "center",
|
|
222
301
|
flexWrap: "wrap",
|
|
@@ -264,16 +343,7 @@ function KPICard(param) {
|
|
|
264
343
|
...knobProps.containerRadius,
|
|
265
344
|
...interactive,
|
|
266
345
|
focusable: Boolean(onPress),
|
|
267
|
-
...(
|
|
268
|
-
"data-mpo-kpi-navigation": config.id,
|
|
269
|
-
tabIndex: onPress ? 0 : void 0,
|
|
270
|
-
onKeyDown: onPress ? function (event) {
|
|
271
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
272
|
-
event.preventDefault();
|
|
273
|
-
if (!event.repeat) event.currentTarget.click();
|
|
274
|
-
}
|
|
275
|
-
} : void 0
|
|
276
|
-
} : {}),
|
|
346
|
+
...kpiNavigationProps(config.id, onPress),
|
|
277
347
|
children: content
|
|
278
348
|
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
279
349
|
position: "absolute",
|
|
@@ -286,12 +356,7 @@ function KPICard(param) {
|
|
|
286
356
|
width,
|
|
287
357
|
height
|
|
288
358
|
} = event.nativeEvent.layout;
|
|
289
|
-
setDataActionSize(
|
|
290
|
-
return previous.width === width && previous.height === height ? previous : {
|
|
291
|
-
width,
|
|
292
|
-
height
|
|
293
|
-
};
|
|
294
|
-
});
|
|
359
|
+
setDataActionSize(keepSize(width, height));
|
|
295
360
|
},
|
|
296
361
|
children: action
|
|
297
362
|
})]
|