@multiplatform.one/components 7.65.0 → 7.65.2
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/Alert/index.cjs +26 -5
- package/dist/cjs/Alert/index.native.js +26 -5
- package/dist/cjs/Alert/index.native.js.map +1 -1
- package/dist/cjs/images/Image/framing.cjs +29 -0
- package/dist/cjs/images/Image/framing.native.js +32 -0
- package/dist/cjs/images/Image/framing.native.js.map +1 -0
- package/dist/cjs/images/Image/shared.cjs +2 -2
- package/dist/cjs/images/Image/shared.native.js +2 -2
- package/dist/cjs/images/Image/shared.native.js.map +1 -1
- package/dist/cjs/views/Dashboard.cjs +16 -131
- package/dist/cjs/views/Dashboard.native.js +16 -131
- package/dist/cjs/views/Dashboard.native.js.map +1 -1
- package/dist/cjs/views/List.cjs +14 -189
- package/dist/cjs/views/List.native.js +14 -193
- package/dist/cjs/views/List.native.js.map +1 -1
- package/dist/cjs/views/ListGroup.cjs +181 -0
- package/dist/cjs/views/ListGroup.native.js +194 -0
- package/dist/cjs/views/ListGroup.native.js.map +1 -0
- package/dist/cjs/views/ListRow.cjs +266 -0
- package/dist/cjs/views/ListRow.native.js +274 -0
- package/dist/cjs/views/ListRow.native.js.map +1 -0
- package/dist/cjs/views/ShortcutCard.cjs +100 -0
- package/dist/cjs/views/ShortcutCard.native.js +104 -0
- package/dist/cjs/views/ShortcutCard.native.js.map +1 -0
- package/dist/cjs/views/index.cjs +3 -0
- package/dist/cjs/views/index.native.js +3 -0
- package/dist/cjs/views/index.native.js.map +1 -1
- package/dist/cjs/views/widgetChrome.cjs +93 -0
- package/dist/cjs/views/widgetChrome.native.js +95 -0
- package/dist/cjs/views/widgetChrome.native.js.map +1 -0
- package/dist/esm/Alert/index.mjs +27 -6
- package/dist/esm/Alert/index.mjs.map +1 -1
- package/dist/esm/Alert/index.native.js +27 -6
- package/dist/esm/Alert/index.native.js.map +1 -1
- package/dist/esm/images/Image/framing.mjs +4 -0
- package/dist/esm/images/Image/framing.mjs.map +1 -0
- package/dist/esm/images/Image/framing.native.js +4 -0
- package/dist/esm/images/Image/framing.native.js.map +1 -0
- package/dist/esm/images/Image/shared.mjs +2 -2
- package/dist/esm/images/Image/shared.mjs.map +1 -1
- package/dist/esm/images/Image/shared.native.js +2 -2
- package/dist/esm/images/Image/shared.native.js.map +1 -1
- package/dist/esm/views/Dashboard.mjs +6 -121
- package/dist/esm/views/Dashboard.mjs.map +1 -1
- package/dist/esm/views/Dashboard.native.js +6 -121
- package/dist/esm/views/Dashboard.native.js.map +1 -1
- package/dist/esm/views/List.mjs +8 -186
- package/dist/esm/views/List.mjs.map +1 -1
- package/dist/esm/views/List.native.js +8 -190
- package/dist/esm/views/List.native.js.map +1 -1
- package/dist/esm/views/ListGroup.mjs +144 -0
- package/dist/esm/views/ListGroup.mjs.map +1 -0
- package/dist/esm/views/ListGroup.native.js +154 -0
- package/dist/esm/views/ListGroup.native.js.map +1 -0
- package/dist/esm/views/ListRow.mjs +234 -0
- package/dist/esm/views/ListRow.mjs.map +1 -0
- package/dist/esm/views/ListRow.native.js +239 -0
- package/dist/esm/views/ListRow.native.js.map +1 -0
- package/dist/esm/views/ShortcutCard.mjs +75 -0
- package/dist/esm/views/ShortcutCard.mjs.map +1 -0
- package/dist/esm/views/ShortcutCard.native.js +76 -0
- package/dist/esm/views/ShortcutCard.native.js.map +1 -0
- package/dist/esm/views/index.mjs +2 -2
- package/dist/esm/views/index.mjs.map +1 -1
- package/dist/esm/views/index.native.js +2 -2
- package/dist/esm/views/index.native.js.map +1 -1
- package/dist/esm/views/widgetChrome.mjs +66 -0
- package/dist/esm/views/widgetChrome.mjs.map +1 -0
- package/dist/esm/views/widgetChrome.native.js +65 -0
- package/dist/esm/views/widgetChrome.native.js.map +1 -0
- package/dist/jsx/Alert/index.mjs +27 -6
- package/dist/jsx/Alert/index.mjs.map +1 -1
- package/dist/jsx/Alert/index.native.js +26 -5
- package/dist/jsx/Alert/index.native.js.map +1 -1
- package/dist/jsx/feedback/NotifyHost.native.js +1 -1
- package/dist/jsx/formLayouts/PreferencePanel.native.js +1 -1
- package/dist/jsx/images/Image/framing.mjs +4 -0
- package/dist/jsx/images/Image/framing.mjs.map +1 -0
- package/dist/jsx/images/Image/framing.native.js +32 -0
- package/dist/jsx/images/Image/framing.native.js.map +1 -0
- package/dist/jsx/images/Image/shared.mjs +2 -2
- package/dist/jsx/images/Image/shared.mjs.map +1 -1
- package/dist/jsx/images/Image/shared.native.js +2 -2
- package/dist/jsx/images/Image/shared.native.js.map +1 -1
- package/dist/jsx/index.native.js +1 -1
- package/dist/jsx/layouts/AsyncBoundary.native.js +1 -1
- package/dist/jsx/layouts/AsyncBoundary.native.js.map +1 -1
- package/dist/jsx/views/Dashboard.mjs +6 -121
- package/dist/jsx/views/Dashboard.mjs.map +1 -1
- package/dist/jsx/views/Dashboard.native.js +16 -131
- package/dist/jsx/views/Dashboard.native.js.map +1 -1
- package/dist/jsx/views/List.mjs +8 -186
- package/dist/jsx/views/List.mjs.map +1 -1
- package/dist/jsx/views/List.native.js +14 -193
- package/dist/jsx/views/List.native.js.map +1 -1
- package/dist/jsx/views/ListGroup.mjs +144 -0
- package/dist/jsx/views/ListGroup.mjs.map +1 -0
- package/dist/jsx/views/ListGroup.native.js +194 -0
- package/dist/jsx/views/ListGroup.native.js.map +1 -0
- package/dist/jsx/views/ListRow.mjs +234 -0
- package/dist/jsx/views/ListRow.mjs.map +1 -0
- package/dist/jsx/views/ListRow.native.js +274 -0
- package/dist/jsx/views/ListRow.native.js.map +1 -0
- package/dist/jsx/views/ShortcutCard.mjs +75 -0
- package/dist/jsx/views/ShortcutCard.mjs.map +1 -0
- package/dist/jsx/views/ShortcutCard.native.js +104 -0
- package/dist/jsx/views/ShortcutCard.native.js.map +1 -0
- package/dist/jsx/views/index.mjs +2 -2
- package/dist/jsx/views/index.mjs.map +1 -1
- package/dist/jsx/views/index.native.js +3 -0
- package/dist/jsx/views/index.native.js.map +1 -1
- package/dist/jsx/views/widgetChrome.mjs +66 -0
- package/dist/jsx/views/widgetChrome.mjs.map +1 -0
- package/dist/jsx/views/widgetChrome.native.js +95 -0
- package/dist/jsx/views/widgetChrome.native.js.map +1 -0
- package/package.json +9 -9
- package/src/Alert/Alert.spec.tsx +79 -0
- package/src/Alert/Alert.stories.tsx +32 -1
- package/src/Alert/index.tsx +54 -5
- package/src/images/Image/framing.ts +8 -0
- package/src/images/Image/shared.ts +2 -7
- package/src/overlayElevation.spec.tsx +3 -1
- package/src/views/Dashboard.tsx +5 -146
- package/src/views/Kanban.native.spec.tsx +2 -2
- package/src/views/List.tsx +22 -237
- package/src/views/ListGroup.spec.tsx +220 -0
- package/src/views/ListGroup.stories.tsx +83 -0
- package/src/views/ListGroup.tsx +189 -0
- package/src/views/ListRow.tsx +282 -0
- package/src/views/ShortcutCard.spec.tsx +40 -0
- package/src/views/ShortcutCard.stories.tsx +50 -1
- package/src/views/ShortcutCard.tsx +88 -0
- package/src/views/index.ts +6 -0
- package/src/views/widgetChrome.tsx +73 -0
- package/types/Alert/index.d.ts +9 -0
- package/types/Alert/index.d.ts.map +1 -1
- package/types/images/Image/framing.d.ts +7 -0
- package/types/images/Image/framing.d.ts.map +1 -0
- package/types/images/Image/shared.d.ts +1 -6
- package/types/images/Image/shared.d.ts.map +1 -1
- package/types/views/Dashboard.d.ts +2 -15
- package/types/views/Dashboard.d.ts.map +1 -1
- package/types/views/List.d.ts +3 -66
- package/types/views/List.d.ts.map +1 -1
- package/types/views/ListGroup.d.ts +43 -0
- package/types/views/ListGroup.d.ts.map +1 -0
- package/types/views/ListRow.d.ts +88 -0
- package/types/views/ListRow.d.ts.map +1 -0
- package/types/views/ShortcutCard.d.ts +26 -0
- package/types/views/ShortcutCard.d.ts.map +1 -0
- package/types/views/index.d.ts +1 -1
- package/types/views/index.d.ts.map +1 -1
- package/types/views/widgetChrome.d.ts +72 -0
- package/types/views/widgetChrome.d.ts.map +1 -0
|
@@ -27,14 +27,13 @@ __export(Dashboard_exports, {
|
|
|
27
27
|
KPICard: () => KPICard,
|
|
28
28
|
ListCard: () => ListCard,
|
|
29
29
|
ProgressCard: () => ProgressCard,
|
|
30
|
-
ShortcutCard: () => ShortcutCard,
|
|
30
|
+
ShortcutCard: () => import_ShortcutCard2.ShortcutCard,
|
|
31
31
|
aggregateData: () => aggregateData,
|
|
32
32
|
calculatePercentageChange: () => calculatePercentageChange,
|
|
33
33
|
calculateTrend: () => calculateTrend,
|
|
34
34
|
resolveTrendColor: () => resolveTrendColor
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(Dashboard_exports);
|
|
37
|
-
var import_theme = require("@multiplatform.one/theme");
|
|
38
37
|
var import_Meter = require("../Meter/index.cjs");
|
|
39
38
|
var import_ChartDataView = require("../charts/ChartDataView.cjs");
|
|
40
39
|
var import_BarChart = require("../charts/BarChart.cjs");
|
|
@@ -44,11 +43,14 @@ var import_Sparkline = require("../charts/Sparkline.cjs");
|
|
|
44
43
|
var import_componentColors = require("../componentColors.cjs");
|
|
45
44
|
var import_AsyncBoundary = require("../layouts/AsyncBoundary.cjs");
|
|
46
45
|
var import_surfaces = require("../surfaces.cjs");
|
|
47
|
-
var
|
|
46
|
+
var import_theme = require("@multiplatform.one/theme");
|
|
48
47
|
var import_react = require("react");
|
|
49
48
|
var import_i18n = require("../shared/i18n.cjs");
|
|
50
49
|
var import_tamagui = require("tamagui");
|
|
51
50
|
var import_ScrollView = require("../ScrollView/index.cjs");
|
|
51
|
+
var import_widgetChrome = require("./widgetChrome.cjs");
|
|
52
|
+
var import_ShortcutCard = require("./ShortcutCard.cjs");
|
|
53
|
+
var import_ShortcutCard2 = require("./ShortcutCard.cjs");
|
|
52
54
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
55
|
const SECTION_HEADING_TAGS = {
|
|
54
56
|
2: import_tamagui.H2,
|
|
@@ -57,18 +59,6 @@ const SECTION_HEADING_TAGS = {
|
|
|
57
59
|
5: import_tamagui.H5,
|
|
58
60
|
6: import_tamagui.H6
|
|
59
61
|
};
|
|
60
|
-
function splitNestedControl(nested) {
|
|
61
|
-
const {
|
|
62
|
-
px,
|
|
63
|
-
hitSlop,
|
|
64
|
-
...box
|
|
65
|
-
} = nested;
|
|
66
|
-
return {
|
|
67
|
-
px,
|
|
68
|
-
hitSlop,
|
|
69
|
-
box
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
62
|
function trendFill(color) {
|
|
73
63
|
if (color === import_componentColors.componentColors.semantic.success) return "$green4";
|
|
74
64
|
if (color === import_componentColors.componentColors.semantic.error) return "$red4";
|
|
@@ -79,55 +69,6 @@ function trendInk(color) {
|
|
|
79
69
|
if (color === import_componentColors.componentColors.semantic.error) return "$red12";
|
|
80
70
|
return color;
|
|
81
71
|
}
|
|
82
|
-
function useWidgetChrome(onPress) {
|
|
83
|
-
const resolved = (0, import_theme2.useResolvedKnobs)();
|
|
84
|
-
const {
|
|
85
|
-
knobProps,
|
|
86
|
-
control
|
|
87
|
-
} = resolved;
|
|
88
|
-
const nested = splitNestedControl(knobProps.nestedControl);
|
|
89
|
-
const interactive = onPress ? {
|
|
90
|
-
cursor: "pointer",
|
|
91
|
-
hoverStyle: control.hoverKnobProps,
|
|
92
|
-
pressStyle: control.pressKnobProps,
|
|
93
|
-
focusVisibleStyle: control.focusVisibleKnobProps,
|
|
94
|
-
onPress,
|
|
95
|
-
role: "button"
|
|
96
|
-
} : void 0;
|
|
97
|
-
return {
|
|
98
|
-
knobProps,
|
|
99
|
-
control,
|
|
100
|
-
nested,
|
|
101
|
-
interactive
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function NestedIconWell({
|
|
105
|
-
color,
|
|
106
|
-
box,
|
|
107
|
-
px,
|
|
108
|
-
radius,
|
|
109
|
-
children
|
|
110
|
-
}) {
|
|
111
|
-
const identity = (0, import_theme2.useChartPalette)().single;
|
|
112
|
-
const fill = color || identity;
|
|
113
|
-
const ink = (0, import_theme2.useReadableTextOn)(fill);
|
|
114
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
115
|
-
...box,
|
|
116
|
-
...radius,
|
|
117
|
-
alignItems: "center",
|
|
118
|
-
justifyContent: "center",
|
|
119
|
-
backgroundColor: fill,
|
|
120
|
-
...{
|
|
121
|
-
color: ink
|
|
122
|
-
},
|
|
123
|
-
overflow: "hidden",
|
|
124
|
-
"data-nested-px": px,
|
|
125
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.IconSlot, {
|
|
126
|
-
icon: children,
|
|
127
|
-
color: ink
|
|
128
|
-
})
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
72
|
function TrendPill({
|
|
132
73
|
symbol,
|
|
133
74
|
value,
|
|
@@ -178,7 +119,7 @@ function KPICard({
|
|
|
178
119
|
knobProps,
|
|
179
120
|
nested,
|
|
180
121
|
interactive
|
|
181
|
-
} = useWidgetChrome(onPress);
|
|
122
|
+
} = (0, import_widgetChrome.useWidgetChrome)(onPress);
|
|
182
123
|
const {
|
|
183
124
|
px,
|
|
184
125
|
box
|
|
@@ -191,13 +132,13 @@ function KPICard({
|
|
|
191
132
|
const hasDataView = Boolean(config.sparkline?.length);
|
|
192
133
|
const formatMetric = (0, import_react.useCallback)(num => {
|
|
193
134
|
if (config.format === "currency") {
|
|
194
|
-
return (0,
|
|
135
|
+
return (0, import_theme.formatCurrency)(num, {
|
|
195
136
|
symbol: config.currencySymbol || "$",
|
|
196
137
|
fractionDigits: "auto"
|
|
197
138
|
});
|
|
198
139
|
}
|
|
199
|
-
if (config.format === "percent") return (0,
|
|
200
|
-
return (0,
|
|
140
|
+
if (config.format === "percent") return (0, import_theme.formatPercent)(num);
|
|
141
|
+
return (0, import_theme.formatNumber)(num);
|
|
201
142
|
}, [config.format, config.currencySymbol]);
|
|
202
143
|
const formattedValue = (0, import_react.useMemo)(() => typeof config.value === "string" ? config.value : formatMetric(config.value), [config.value, formatMetric]);
|
|
203
144
|
const trendColor = (0, import_react.useMemo)(() => resolveTrendColor(config.trend, config.goodDirection, knobProps.textAccentColor), [config.trend, config.goodDirection, knobProps.textAccentColor]);
|
|
@@ -217,7 +158,7 @@ function KPICard({
|
|
|
217
158
|
color: knobProps.textAccentColor,
|
|
218
159
|
flex: 1,
|
|
219
160
|
children: config.title
|
|
220
|
-
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(NestedIconWell, {
|
|
161
|
+
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_widgetChrome.NestedIconWell, {
|
|
221
162
|
color: config.color,
|
|
222
163
|
box,
|
|
223
164
|
px,
|
|
@@ -325,7 +266,7 @@ function ChartCard({
|
|
|
325
266
|
}) {
|
|
326
267
|
const {
|
|
327
268
|
knobProps
|
|
328
|
-
} = (0,
|
|
269
|
+
} = (0, import_theme.useResolvedKnobs)();
|
|
329
270
|
const HeadingTag = SECTION_HEADING_TAGS[headingLevel];
|
|
330
271
|
const dataColors = config.colors ?? colors;
|
|
331
272
|
const showXAxis = config.showLabels !== false;
|
|
@@ -387,10 +328,10 @@ function ProgressCard({
|
|
|
387
328
|
}) {
|
|
388
329
|
const {
|
|
389
330
|
knobProps
|
|
390
|
-
} = useWidgetChrome();
|
|
331
|
+
} = (0, import_widgetChrome.useWidgetChrome)();
|
|
391
332
|
const max = config.max && config.max > 0 ? config.max : 100;
|
|
392
333
|
const pct = Math.max(0, Math.min(100, config.value / max * 100));
|
|
393
|
-
const label = config.format === "number" ? (0,
|
|
334
|
+
const label = config.format === "number" ? (0, import_theme.formatNumber)(config.value) : (0, import_theme.formatPercent)(Math.round(pct));
|
|
394
335
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_surfaces.Card, {
|
|
395
336
|
width: "100%",
|
|
396
337
|
elevation: knobProps.elevation,
|
|
@@ -407,62 +348,6 @@ function ProgressCard({
|
|
|
407
348
|
})
|
|
408
349
|
});
|
|
409
350
|
}
|
|
410
|
-
function ShortcutCard({
|
|
411
|
-
config,
|
|
412
|
-
...stackProps
|
|
413
|
-
}) {
|
|
414
|
-
const {
|
|
415
|
-
knobProps,
|
|
416
|
-
nested,
|
|
417
|
-
interactive
|
|
418
|
-
} = useWidgetChrome(config.onClick);
|
|
419
|
-
const {
|
|
420
|
-
px,
|
|
421
|
-
box,
|
|
422
|
-
hitSlop
|
|
423
|
-
} = nested;
|
|
424
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_surfaces.Card, {
|
|
425
|
-
width: "100%",
|
|
426
|
-
elevation: knobProps.elevation,
|
|
427
|
-
...knobProps.surface,
|
|
428
|
-
...interactive,
|
|
429
|
-
hitSlop: config.onClick ? hitSlop : void 0,
|
|
430
|
-
...stackProps,
|
|
431
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
432
|
-
alignItems: "center",
|
|
433
|
-
...knobProps.gap,
|
|
434
|
-
children: [config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(NestedIconWell, {
|
|
435
|
-
color: config.color,
|
|
436
|
-
box,
|
|
437
|
-
px,
|
|
438
|
-
radius: knobProps.borderRadius,
|
|
439
|
-
children: config.icon
|
|
440
|
-
}) : null, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.SizableText, {
|
|
441
|
-
size: knobProps.sizeToken,
|
|
442
|
-
...knobProps.heading,
|
|
443
|
-
flex: 1,
|
|
444
|
-
numberOfLines: 1,
|
|
445
|
-
children: config.title
|
|
446
|
-
}), config.count != null && config.count !== "" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
|
|
447
|
-
height: px,
|
|
448
|
-
minHeight: px,
|
|
449
|
-
maxHeight: px,
|
|
450
|
-
minWidth: px,
|
|
451
|
-
paddingHorizontal: "$2",
|
|
452
|
-
alignItems: "center",
|
|
453
|
-
justifyContent: "center",
|
|
454
|
-
backgroundColor: "$color4",
|
|
455
|
-
...knobProps.borderRadius,
|
|
456
|
-
"data-nested-px": px,
|
|
457
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
458
|
-
...knobProps.label,
|
|
459
|
-
color: knobProps.textAccentColor,
|
|
460
|
-
children: config.count
|
|
461
|
-
})
|
|
462
|
-
}) : null]
|
|
463
|
-
})
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
351
|
function ListCard({
|
|
467
352
|
config,
|
|
468
353
|
headingLevel = 2,
|
|
@@ -472,7 +357,7 @@ function ListCard({
|
|
|
472
357
|
knobProps,
|
|
473
358
|
nested,
|
|
474
359
|
control
|
|
475
|
-
} = useWidgetChrome();
|
|
360
|
+
} = (0, import_widgetChrome.useWidgetChrome)();
|
|
476
361
|
const {
|
|
477
362
|
px,
|
|
478
363
|
hitSlop
|
|
@@ -536,7 +421,7 @@ function DefaultWidget({
|
|
|
536
421
|
config: widget.progressConfig
|
|
537
422
|
}) : null;
|
|
538
423
|
case "shortcut":
|
|
539
|
-
return widget.shortcutConfig ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ShortcutCard, {
|
|
424
|
+
return widget.shortcutConfig ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ShortcutCard.ShortcutCard, {
|
|
540
425
|
config: widget.shortcutConfig
|
|
541
426
|
}) : null;
|
|
542
427
|
case "list":
|
|
@@ -569,7 +454,7 @@ function Dashboard({
|
|
|
569
454
|
const emptyMessage = emptyMessageProp ?? t("No widgets to display");
|
|
570
455
|
const {
|
|
571
456
|
knobProps
|
|
572
|
-
} = (0,
|
|
457
|
+
} = (0, import_theme.useResolvedKnobs)();
|
|
573
458
|
const gap = gapProp ?? 16;
|
|
574
459
|
const header = title || description ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
|
|
575
460
|
...knobProps.gap,
|
|
@@ -40,7 +40,7 @@ __export(Dashboard_exports, {
|
|
|
40
40
|
KPICard: () => KPICard,
|
|
41
41
|
ListCard: () => ListCard,
|
|
42
42
|
ProgressCard: () => ProgressCard,
|
|
43
|
-
ShortcutCard: () => ShortcutCard,
|
|
43
|
+
ShortcutCard: () => import_ShortcutCard2.ShortcutCard,
|
|
44
44
|
aggregateData: () => aggregateData,
|
|
45
45
|
calculatePercentageChange: () => calculatePercentageChange,
|
|
46
46
|
calculateTrend: () => calculateTrend,
|
|
@@ -48,7 +48,6 @@ __export(Dashboard_exports, {
|
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(Dashboard_exports);
|
|
50
50
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
-
var import_theme = require("@multiplatform.one/theme");
|
|
52
51
|
var import_Meter = require("../Meter");
|
|
53
52
|
var import_ChartDataView = require("../charts/ChartDataView.native.js");
|
|
54
53
|
var import_BarChart = require("../charts/BarChart.native.js");
|
|
@@ -58,11 +57,14 @@ var import_Sparkline = require("../charts/Sparkline.native.js");
|
|
|
58
57
|
var import_componentColors = require("../componentColors.native.js");
|
|
59
58
|
var import_AsyncBoundary = require("../layouts/AsyncBoundary.native.js");
|
|
60
59
|
var import_surfaces = require("../surfaces.native.js");
|
|
61
|
-
var
|
|
60
|
+
var import_theme = require("@multiplatform.one/theme");
|
|
62
61
|
var import_react = __toESM(require("react"));
|
|
63
62
|
var import_i18n = require("../shared/i18n.native.js");
|
|
64
63
|
var import_tamagui = require("tamagui");
|
|
65
64
|
var import_ScrollView = require("../ScrollView");
|
|
65
|
+
var import_widgetChrome = require("./widgetChrome.native.js");
|
|
66
|
+
var import_ShortcutCard = require("./ShortcutCard.native.js");
|
|
67
|
+
var import_ShortcutCard2 = require("./ShortcutCard.native.js");
|
|
66
68
|
var SECTION_HEADING_TAGS = {
|
|
67
69
|
2: import_tamagui.H2,
|
|
68
70
|
3: import_tamagui.H3,
|
|
@@ -70,18 +72,6 @@ var SECTION_HEADING_TAGS = {
|
|
|
70
72
|
5: import_tamagui.H5,
|
|
71
73
|
6: import_tamagui.H6
|
|
72
74
|
};
|
|
73
|
-
function splitNestedControl(nested) {
|
|
74
|
-
var {
|
|
75
|
-
px,
|
|
76
|
-
hitSlop,
|
|
77
|
-
...box
|
|
78
|
-
} = nested;
|
|
79
|
-
return {
|
|
80
|
-
px,
|
|
81
|
-
hitSlop,
|
|
82
|
-
box
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
75
|
function trendFill(color) {
|
|
86
76
|
if (color === import_componentColors.componentColors.semantic.success) return "$green4";
|
|
87
77
|
if (color === import_componentColors.componentColors.semantic.error) return "$red4";
|
|
@@ -92,54 +82,6 @@ function trendInk(color) {
|
|
|
92
82
|
if (color === import_componentColors.componentColors.semantic.error) return "$red12";
|
|
93
83
|
return color;
|
|
94
84
|
}
|
|
95
|
-
function useWidgetChrome(onPress) {
|
|
96
|
-
var resolved = (0, import_theme2.useResolvedKnobs)();
|
|
97
|
-
var {
|
|
98
|
-
knobProps,
|
|
99
|
-
control
|
|
100
|
-
} = resolved;
|
|
101
|
-
var nested = splitNestedControl(knobProps.nestedControl);
|
|
102
|
-
var interactive = onPress ? {
|
|
103
|
-
cursor: "pointer",
|
|
104
|
-
hoverStyle: control.hoverKnobProps,
|
|
105
|
-
pressStyle: control.pressKnobProps,
|
|
106
|
-
focusVisibleStyle: control.focusVisibleKnobProps,
|
|
107
|
-
onPress,
|
|
108
|
-
role: "button"
|
|
109
|
-
} : void 0;
|
|
110
|
-
return {
|
|
111
|
-
knobProps,
|
|
112
|
-
control,
|
|
113
|
-
nested,
|
|
114
|
-
interactive
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function NestedIconWell(param) {
|
|
118
|
-
var {
|
|
119
|
-
color,
|
|
120
|
-
box,
|
|
121
|
-
px,
|
|
122
|
-
radius,
|
|
123
|
-
children
|
|
124
|
-
} = param;
|
|
125
|
-
var identity = (0, import_theme2.useChartPalette)().single;
|
|
126
|
-
var fill = color || identity;
|
|
127
|
-
var ink = (0, import_theme2.useReadableTextOn)(fill);
|
|
128
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.YStack, {
|
|
129
|
-
...box,
|
|
130
|
-
...radius,
|
|
131
|
-
alignItems: "center",
|
|
132
|
-
justifyContent: "center",
|
|
133
|
-
backgroundColor: fill,
|
|
134
|
-
color: ink,
|
|
135
|
-
overflow: "hidden",
|
|
136
|
-
"data-nested-px": px,
|
|
137
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.IconSlot, {
|
|
138
|
-
icon: children,
|
|
139
|
-
color: ink
|
|
140
|
-
})
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
85
|
function TrendPill(param) {
|
|
144
86
|
var {
|
|
145
87
|
symbol,
|
|
@@ -193,7 +135,7 @@ function KPICard(param) {
|
|
|
193
135
|
knobProps,
|
|
194
136
|
nested,
|
|
195
137
|
interactive
|
|
196
|
-
} = useWidgetChrome(onPress);
|
|
138
|
+
} = (0, import_widgetChrome.useWidgetChrome)(onPress);
|
|
197
139
|
var {
|
|
198
140
|
px,
|
|
199
141
|
box
|
|
@@ -206,13 +148,13 @@ function KPICard(param) {
|
|
|
206
148
|
var hasDataView = Boolean((_config_sparkline = config.sparkline) === null || _config_sparkline === void 0 ? void 0 : _config_sparkline.length);
|
|
207
149
|
var formatMetric = (0, import_react.useCallback)(function (num) {
|
|
208
150
|
if (config.format === "currency") {
|
|
209
|
-
return (0,
|
|
151
|
+
return (0, import_theme.formatCurrency)(num, {
|
|
210
152
|
symbol: config.currencySymbol || "$",
|
|
211
153
|
fractionDigits: "auto"
|
|
212
154
|
});
|
|
213
155
|
}
|
|
214
|
-
if (config.format === "percent") return (0,
|
|
215
|
-
return (0,
|
|
156
|
+
if (config.format === "percent") return (0, import_theme.formatPercent)(num);
|
|
157
|
+
return (0, import_theme.formatNumber)(num);
|
|
216
158
|
}, [config.format, config.currencySymbol]);
|
|
217
159
|
var formattedValue = (0, import_react.useMemo)(function () {
|
|
218
160
|
return typeof config.value === "string" ? config.value : formatMetric(config.value);
|
|
@@ -238,7 +180,7 @@ function KPICard(param) {
|
|
|
238
180
|
color: knobProps.textAccentColor,
|
|
239
181
|
flex: 1,
|
|
240
182
|
children: config.title
|
|
241
|
-
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(NestedIconWell, {
|
|
183
|
+
}), config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_widgetChrome.NestedIconWell, {
|
|
242
184
|
color: config.color,
|
|
243
185
|
box,
|
|
244
186
|
px,
|
|
@@ -353,7 +295,7 @@ function ChartCard(param) {
|
|
|
353
295
|
var _config_colors;
|
|
354
296
|
var {
|
|
355
297
|
knobProps
|
|
356
|
-
} = (0,
|
|
298
|
+
} = (0, import_theme.useResolvedKnobs)();
|
|
357
299
|
var HeadingTag = SECTION_HEADING_TAGS[headingLevel];
|
|
358
300
|
var dataColors = (_config_colors = config.colors) !== null && _config_colors !== void 0 ? _config_colors : colors;
|
|
359
301
|
var showXAxis = config.showLabels !== false;
|
|
@@ -422,10 +364,10 @@ function ProgressCard(param) {
|
|
|
422
364
|
var _config_format;
|
|
423
365
|
var {
|
|
424
366
|
knobProps
|
|
425
|
-
} = useWidgetChrome();
|
|
367
|
+
} = (0, import_widgetChrome.useWidgetChrome)();
|
|
426
368
|
var max = config.max && config.max > 0 ? config.max : 100;
|
|
427
369
|
var pct = Math.max(0, Math.min(100, config.value / max * 100));
|
|
428
|
-
var label = config.format === "number" ? (0,
|
|
370
|
+
var label = config.format === "number" ? (0, import_theme.formatNumber)(config.value) : (0, import_theme.formatPercent)(Math.round(pct));
|
|
429
371
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_surfaces.Card, {
|
|
430
372
|
width: "100%",
|
|
431
373
|
elevation: knobProps.elevation,
|
|
@@ -442,63 +384,6 @@ function ProgressCard(param) {
|
|
|
442
384
|
})
|
|
443
385
|
});
|
|
444
386
|
}
|
|
445
|
-
function ShortcutCard(param) {
|
|
446
|
-
var {
|
|
447
|
-
config,
|
|
448
|
-
...stackProps
|
|
449
|
-
} = param;
|
|
450
|
-
var {
|
|
451
|
-
knobProps,
|
|
452
|
-
nested,
|
|
453
|
-
interactive
|
|
454
|
-
} = useWidgetChrome(config.onClick);
|
|
455
|
-
var {
|
|
456
|
-
px,
|
|
457
|
-
box,
|
|
458
|
-
hitSlop
|
|
459
|
-
} = nested;
|
|
460
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_surfaces.Card, {
|
|
461
|
-
width: "100%",
|
|
462
|
-
elevation: knobProps.elevation,
|
|
463
|
-
...knobProps.surface,
|
|
464
|
-
...interactive,
|
|
465
|
-
hitSlop: config.onClick ? hitSlop : void 0,
|
|
466
|
-
...stackProps,
|
|
467
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.XStack, {
|
|
468
|
-
alignItems: "center",
|
|
469
|
-
...knobProps.gap,
|
|
470
|
-
children: [config.icon ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(NestedIconWell, {
|
|
471
|
-
color: config.color,
|
|
472
|
-
box,
|
|
473
|
-
px,
|
|
474
|
-
radius: knobProps.borderRadius,
|
|
475
|
-
children: config.icon
|
|
476
|
-
}) : null, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.SizableText, {
|
|
477
|
-
size: knobProps.sizeToken,
|
|
478
|
-
...knobProps.heading,
|
|
479
|
-
flex: 1,
|
|
480
|
-
numberOfLines: 1,
|
|
481
|
-
children: config.title
|
|
482
|
-
}), config.count != null && config.count !== "" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
|
|
483
|
-
height: px,
|
|
484
|
-
minHeight: px,
|
|
485
|
-
maxHeight: px,
|
|
486
|
-
minWidth: px,
|
|
487
|
-
paddingHorizontal: "$2",
|
|
488
|
-
alignItems: "center",
|
|
489
|
-
justifyContent: "center",
|
|
490
|
-
backgroundColor: "$color4",
|
|
491
|
-
...knobProps.borderRadius,
|
|
492
|
-
"data-nested-px": px,
|
|
493
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.Text, {
|
|
494
|
-
...knobProps.label,
|
|
495
|
-
color: knobProps.textAccentColor,
|
|
496
|
-
children: config.count
|
|
497
|
-
})
|
|
498
|
-
}) : null]
|
|
499
|
-
})
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
387
|
function ListCard(param) {
|
|
503
388
|
var {
|
|
504
389
|
config,
|
|
@@ -509,7 +394,7 @@ function ListCard(param) {
|
|
|
509
394
|
knobProps,
|
|
510
395
|
nested,
|
|
511
396
|
control
|
|
512
|
-
} = useWidgetChrome();
|
|
397
|
+
} = (0, import_widgetChrome.useWidgetChrome)();
|
|
513
398
|
var {
|
|
514
399
|
px,
|
|
515
400
|
hitSlop
|
|
@@ -576,7 +461,7 @@ function DefaultWidget(param) {
|
|
|
576
461
|
config: widget.progressConfig
|
|
577
462
|
}) : null;
|
|
578
463
|
case "shortcut":
|
|
579
|
-
return widget.shortcutConfig ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ShortcutCard, {
|
|
464
|
+
return widget.shortcutConfig ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ShortcutCard.ShortcutCard, {
|
|
580
465
|
config: widget.shortcutConfig
|
|
581
466
|
}) : null;
|
|
582
467
|
case "list":
|
|
@@ -611,7 +496,7 @@ function Dashboard(param) {
|
|
|
611
496
|
var emptyMessage = emptyMessageProp !== null && emptyMessageProp !== void 0 ? emptyMessageProp : t("No widgets to display");
|
|
612
497
|
var {
|
|
613
498
|
knobProps
|
|
614
|
-
} = (0,
|
|
499
|
+
} = (0, import_theme.useResolvedKnobs)();
|
|
615
500
|
var gap = gapProp !== null && gapProp !== void 0 ? gapProp : 16;
|
|
616
501
|
var header = title || description ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_tamagui.YStack, {
|
|
617
502
|
...knobProps.gap,
|