@headless-adminapp/fluent 0.0.17-alpha.34 → 0.0.17-alpha.37
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/DataGrid/useTableColumns.js +9 -4
- package/Insights/CommandBarContainer.d.ts +1 -0
- package/Insights/CommandBarContainer.js +15 -0
- package/Insights/FilterBarContainer.d.ts +1 -0
- package/Insights/FilterBarContainer.js +107 -0
- package/Insights/Grid.d.ts +6 -0
- package/Insights/Grid.js +26 -0
- package/Insights/InsightsContainer.d.ts +1 -0
- package/Insights/InsightsContainer.js +35 -0
- package/Insights/WidgetChartContainer.d.ts +7 -0
- package/Insights/WidgetChartContainer.js +56 -0
- package/Insights/WidgetDataGridContainer.d.ts +4 -0
- package/Insights/WidgetDataGridContainer.js +68 -0
- package/Insights/WidgetTableContainer.d.ts +7 -0
- package/Insights/WidgetTableContainer.js +58 -0
- package/Insights/WidgetTileContainer.d.ts +7 -0
- package/Insights/WidgetTileContainer.js +25 -0
- package/Insights/WidgetTitleBar.d.ts +7 -0
- package/Insights/WidgetTitleBar.js +22 -0
- package/Insights/Widgets.d.ts +4 -0
- package/Insights/Widgets.js +55 -0
- package/Insights/charts/AreaChart.d.ts +5 -0
- package/Insights/charts/AreaChart.js +20 -0
- package/Insights/charts/BarChart.d.ts +5 -0
- package/Insights/charts/BarChart.js +21 -0
- package/Insights/charts/ComposedChart.d.ts +5 -0
- package/Insights/charts/ComposedChart.js +20 -0
- package/Insights/charts/CustomTooltipContent.d.ts +7 -0
- package/Insights/charts/CustomTooltipContent.js +25 -0
- package/Insights/charts/GaugeChart.d.ts +5 -0
- package/Insights/charts/GaugeChart.js +8 -0
- package/Insights/charts/LineChart.d.ts +5 -0
- package/Insights/charts/LineChart.js +21 -0
- package/Insights/charts/OhlcChart.d.ts +6 -0
- package/Insights/charts/OhlcChart.js +114 -0
- package/Insights/charts/PieChart.d.ts +5 -0
- package/Insights/charts/PieChart.js +53 -0
- package/Insights/charts/RadarChart.d.ts +5 -0
- package/Insights/charts/RadarChart.js +33 -0
- package/Insights/charts/ScatterChart.d.ts +5 -0
- package/Insights/charts/ScatterChart.js +85 -0
- package/Insights/charts/constants.d.ts +1 -0
- package/Insights/charts/constants.js +25 -0
- package/Insights/charts/formatters.d.ts +14 -0
- package/Insights/charts/formatters.js +188 -0
- package/Insights/charts/index.d.ts +4 -0
- package/Insights/charts/index.js +11 -0
- package/Insights/charts/renderers.d.ts +10 -0
- package/Insights/charts/renderers.js +65 -0
- package/Insights/hooks/useQueriesData.d.ts +7 -0
- package/Insights/hooks/useQueriesData.js +92 -0
- package/Insights/hooks/useWidgetDetail.d.ts +10 -0
- package/Insights/hooks/useWidgetDetail.js +33 -0
- package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
- package/PageInsights/PageInsights.d.ts +9 -0
- package/PageInsights/PageInsights.js +25 -0
- package/PageInsights/index.d.ts +1 -0
- package/PageInsights/index.js +6 -0
- package/components/BodyLoading.js +12 -8
- package/package.json +3 -2
|
@@ -16,6 +16,7 @@ const utils_1 = require("@headless-adminapp/app/utils");
|
|
|
16
16
|
const app_1 = require("@headless-adminapp/core/experience/app");
|
|
17
17
|
const react_table_1 = require("@tanstack/react-table");
|
|
18
18
|
const react_1 = require("react");
|
|
19
|
+
const componentStore_1 = require("../componentStore");
|
|
19
20
|
const GridColumnHeader_1 = require("../DataGrid/GridColumnHeader");
|
|
20
21
|
const TableCell_1 = require("../DataGrid/TableCell");
|
|
21
22
|
const TableCellLink_1 = require("../DataGrid/TableCell/TableCellLink");
|
|
@@ -207,6 +208,13 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
207
208
|
dateFormat: dateFormats.short,
|
|
208
209
|
timezone,
|
|
209
210
|
})) !== null && _c !== void 0 ? _c : '';
|
|
211
|
+
if (column.component) {
|
|
212
|
+
const Component = componentStore_1.componentStore.getComponent(column.component);
|
|
213
|
+
if (!Component) {
|
|
214
|
+
throw new Error(`Component with name ${column.component} not found`);
|
|
215
|
+
}
|
|
216
|
+
return ((0, jsx_runtime_1.jsx)(Component, { column: column, schema: schema, record: info.row.original, value: value, attribute: attribute, formattedValue: formattedValue }));
|
|
217
|
+
}
|
|
210
218
|
if (schema.primaryAttribute === column.name) {
|
|
211
219
|
const path = routeResolver({
|
|
212
220
|
logicalName: schema.logicalName,
|
|
@@ -254,10 +262,7 @@ function useTableColumns({ disableSelection, disableContextMenu, disableColumnRe
|
|
|
254
262
|
recordSetSetter,
|
|
255
263
|
routeResolver,
|
|
256
264
|
router,
|
|
257
|
-
schema
|
|
258
|
-
schema.idAttribute,
|
|
259
|
-
schema.logicalName,
|
|
260
|
-
schema.primaryAttribute,
|
|
265
|
+
schema,
|
|
261
266
|
schemaStore,
|
|
262
267
|
setSorting,
|
|
263
268
|
timezone,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CommandBarContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandBarContainer = CommandBarContainer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const command_1 = require("@headless-adminapp/app/command");
|
|
6
|
+
const hooks_1 = require("@headless-adminapp/app/command/hooks");
|
|
7
|
+
const insights_1 = require("@headless-adminapp/app/insights");
|
|
8
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
9
|
+
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
10
|
+
function CommandBarContainer() {
|
|
11
|
+
const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
|
|
12
|
+
const insightExpereince = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (x) => x.experience);
|
|
13
|
+
const transformedCommands = (0, command_1.useCommands)([insightExpereince.commands], Object.assign(Object.assign({}, baseCommandHandleContext), { primaryControl: {} }));
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { flex: 1, flexShrink: 0, overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: transformedCommands }) }));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FilterBarContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FilterBarContainer = FilterBarContainer;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
15
|
+
const hooks_1 = require("@headless-adminapp/app/dialog/hooks");
|
|
16
|
+
const insights_1 = require("@headless-adminapp/app/insights");
|
|
17
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
18
|
+
const utils_1 = require("@headless-adminapp/app/utils");
|
|
19
|
+
const icons_1 = require("@headless-adminapp/icons");
|
|
20
|
+
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
21
|
+
function FilterBarContainer() {
|
|
22
|
+
const openPromptDialog = (0, hooks_1.useOpenPromptDialog)();
|
|
23
|
+
const insightsState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
24
|
+
const insightExpereince = insightsState.experience;
|
|
25
|
+
const setValue = (0, mutable_1.useContextSetValue)(insights_1.InsightsContext);
|
|
26
|
+
const handleOpenPromptDialog = () => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const attributes = insightExpereince.filters.reduce((acc, item) => {
|
|
28
|
+
acc[item.logicalName] =
|
|
29
|
+
insightsState.experience.attributes[item.logicalName];
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
const defaultValues = insightExpereince.filters.reduce((acc, item) => {
|
|
33
|
+
acc[item.logicalName] = insightsState.data[item.logicalName];
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
const result = yield openPromptDialog({
|
|
37
|
+
attributes,
|
|
38
|
+
defaultValues,
|
|
39
|
+
title: 'Modify filter',
|
|
40
|
+
allowDismiss: true,
|
|
41
|
+
});
|
|
42
|
+
if (!result) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setValue({
|
|
46
|
+
data: result,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
const filterCommandItems = insightExpereince.filters
|
|
50
|
+
.map((item) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const logicalName = item.logicalName;
|
|
53
|
+
const value = insightsState.data[logicalName];
|
|
54
|
+
const attribute = insightsState.experience.attributes[logicalName];
|
|
55
|
+
if (!item.showInFilterBar) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (!attribute || !value) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (item.allowQuickFilter) {
|
|
62
|
+
return {
|
|
63
|
+
type: 'button',
|
|
64
|
+
Icon: item.Icon,
|
|
65
|
+
text: (0, utils_1.getAttributeFormattedValue)(attribute, value, { maxCount: 2 }),
|
|
66
|
+
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var _a;
|
|
68
|
+
const result = yield openPromptDialog({
|
|
69
|
+
allowDismiss: true,
|
|
70
|
+
attributes: {
|
|
71
|
+
[logicalName]: attribute,
|
|
72
|
+
},
|
|
73
|
+
defaultValues: {
|
|
74
|
+
[logicalName]: value,
|
|
75
|
+
},
|
|
76
|
+
title: (_a = item.quickFilterTitle) !== null && _a !== void 0 ? _a : attribute.label,
|
|
77
|
+
});
|
|
78
|
+
if (!result) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setValue({
|
|
82
|
+
data: Object.assign(Object.assign({}, insightsState.data), { [logicalName]: result[logicalName] }),
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
type: 'label',
|
|
89
|
+
Icon: item.Icon,
|
|
90
|
+
text: ((_a = item.beforeContent) !== null && _a !== void 0 ? _a : '') +
|
|
91
|
+
(0, utils_1.getAttributeFormattedValue)(attribute, value, { maxCount: 2 }),
|
|
92
|
+
};
|
|
93
|
+
})
|
|
94
|
+
.filter(Boolean);
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
96
|
+
display: 'flex',
|
|
97
|
+
flex: 1,
|
|
98
|
+
flexShrink: 0,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
overflow: 'hidden',
|
|
101
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
102
|
+
display: 'flex',
|
|
103
|
+
flex: 1,
|
|
104
|
+
overflow: 'hidden',
|
|
105
|
+
flexShrink: 0,
|
|
106
|
+
}, children: (0, jsx_runtime_1.jsx)(OverflowCommandBar_1.OverflowCommandBar, { commands: [filterCommandItems], align: "end", beforeDivider: true }) }), insightExpereince.filters.length > 0 && ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "primary", icon: (0, jsx_runtime_1.jsx)(icons_1.Icons.Filter, { size: 16 }), onClick: handleOpenPromptDialog, style: { flexShrink: 0, marginInline: 8 }, children: "Filter" }))] }));
|
|
107
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export declare function WidgetGrid({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function WidgetGridItem({ column, row, children, }: PropsWithChildren<{
|
|
4
|
+
column?: number;
|
|
5
|
+
row?: number;
|
|
6
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
package/Insights/Grid.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetGrid = WidgetGrid;
|
|
4
|
+
exports.WidgetGridItem = WidgetGridItem;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
7
|
+
function WidgetGrid({ children }) {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
9
|
+
padding: react_components_1.tokens.spacingHorizontalM,
|
|
10
|
+
width: '100%',
|
|
11
|
+
// flex: 1,
|
|
12
|
+
display: 'grid',
|
|
13
|
+
gridTemplateColumns: '1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr',
|
|
14
|
+
rowGap: react_components_1.tokens.spacingVerticalM,
|
|
15
|
+
columnGap: react_components_1.tokens.spacingHorizontalM,
|
|
16
|
+
}, children: children }));
|
|
17
|
+
}
|
|
18
|
+
function WidgetGridItem({ column, row, children, }) {
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column',
|
|
22
|
+
gridColumn: column ? `span ${column}` : undefined,
|
|
23
|
+
gridRow: row ? `span ${row}` : undefined,
|
|
24
|
+
height: row ? 100 * row + 12 * (row - 1) : 100,
|
|
25
|
+
}, children: children }));
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InsightsContainer(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightsContainer = InsightsContainer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const ScrollView_1 = require("@headless-adminapp/app/components/ScrollView");
|
|
7
|
+
const insights_1 = require("@headless-adminapp/app/insights");
|
|
8
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
9
|
+
const CommandBarContainer_1 = require("./CommandBarContainer");
|
|
10
|
+
const FilterBarContainer_1 = require("./FilterBarContainer");
|
|
11
|
+
const Widgets_1 = require("./Widgets");
|
|
12
|
+
function InsightsContainer() {
|
|
13
|
+
const insightsState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
14
|
+
const insightExpereince = insightsState.experience;
|
|
15
|
+
const titleButton = ((0, jsx_runtime_1.jsx)(react_components_1.Button, { appearance: "subtle", style: { pointerEvents: 'auto' }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Subtitle2, { style: { color: react_components_1.tokens.colorNeutralForeground1 }, children: insightExpereince.title }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground2 }, children: insightExpereince.subtitle })] }) }));
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
flex: 1,
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground2,
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { padding: 12 }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
23
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
24
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
25
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
26
|
+
display: 'flex',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
minHeight: 40,
|
|
29
|
+
}, children: [(0, jsx_runtime_1.jsx)(CommandBarContainer_1.CommandBarContainer, {}), (0, jsx_runtime_1.jsx)(FilterBarContainer_1.FilterBarContainer, {})] }) }), (0, jsx_runtime_1.jsx)("div", { style: { padding: 12 }, children: insightsState.insightLookup.length > 0 ? ((0, jsx_runtime_1.jsxs)(react_components_1.Menu, { children: [(0, jsx_runtime_1.jsx)(react_components_1.MenuTrigger, { disableButtonEnhancement: true, children: titleButton }), (0, jsx_runtime_1.jsx)(react_components_1.MenuPopover, { children: (0, jsx_runtime_1.jsx)(react_components_1.MenuList, { children: insightsState.insightLookup.map((insight) => ((0, jsx_runtime_1.jsx)(react_components_1.MenuItem, { onClick: () => insightsState.onInsightSelect(insight.id), children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: insight.title }), (0, jsx_runtime_1.jsx)(react_components_1.Caption2, { style: { color: react_components_1.tokens.colorNeutralForeground2 }, children: insight.subtitle })] }) }, insight.id))) }) })] })) : (titleButton) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
flex: 1,
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
}, children: (0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { children: (0, jsx_runtime_1.jsx)(Widgets_1.Widgets, { widgets: insightExpereince.widgets }) }) })] }));
|
|
35
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChartWidgetExperience } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface WidgetChartContainerProps {
|
|
4
|
+
content: ChartWidgetExperience;
|
|
5
|
+
}
|
|
6
|
+
export declare const WidgetChartContainer: FC<WidgetChartContainerProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetChartContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const BodyLoading_1 = require("../components/BodyLoading");
|
|
7
|
+
const AreaChart_1 = require("./charts/AreaChart");
|
|
8
|
+
const BarChart_1 = require("./charts/BarChart");
|
|
9
|
+
const ComposedChart_1 = require("./charts/ComposedChart");
|
|
10
|
+
const GaugeChart_1 = require("./charts/GaugeChart");
|
|
11
|
+
const LineChart_1 = require("./charts/LineChart");
|
|
12
|
+
const OhlcChart_1 = require("./charts/OhlcChart");
|
|
13
|
+
const PieChart_1 = require("./charts/PieChart");
|
|
14
|
+
const RadarChart_1 = require("./charts/RadarChart");
|
|
15
|
+
const ScatterChart_1 = require("./charts/ScatterChart");
|
|
16
|
+
const useWidgetDetail_1 = require("./hooks/useWidgetDetail");
|
|
17
|
+
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
18
|
+
function getChartComponent(type
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
) {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'line':
|
|
23
|
+
return LineChart_1.LineChart;
|
|
24
|
+
case 'area':
|
|
25
|
+
return AreaChart_1.AreaChart;
|
|
26
|
+
case 'bar':
|
|
27
|
+
return BarChart_1.BarChart;
|
|
28
|
+
case 'composed':
|
|
29
|
+
return ComposedChart_1.ComposedChart;
|
|
30
|
+
case 'scatter':
|
|
31
|
+
return ScatterChart_1.ScatterChart;
|
|
32
|
+
case 'pie':
|
|
33
|
+
return PieChart_1.PieChart;
|
|
34
|
+
case 'radar':
|
|
35
|
+
return RadarChart_1.RadarChart;
|
|
36
|
+
case 'gauge':
|
|
37
|
+
return GaugeChart_1.GaugeChart;
|
|
38
|
+
case 'ohlc':
|
|
39
|
+
return OhlcChart_1.OhlcChart;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const WidgetChartContainer = ({ content, }) => {
|
|
43
|
+
const { transformedCommands, dataset, isPending, isFetching, widget } = (0, useWidgetDetail_1.useWidgetDetail)(content);
|
|
44
|
+
const info = content.chart;
|
|
45
|
+
const type = info.chart.type;
|
|
46
|
+
const ChartComponent = getChartComponent(type);
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flex: 1,
|
|
50
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
51
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
52
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: widget.title, commands: transformedCommands }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, position: 'relative' }, children: [!isPending && ((0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', inset: 0 }, children: (0, jsx_runtime_1.jsx)(ChartComponent, { dataset: dataset, chartInfo: info.chart }) })), (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isFetching })] })] }));
|
|
55
|
+
};
|
|
56
|
+
exports.WidgetChartContainer = WidgetChartContainer;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetDataGridContainer = WidgetDataGridContainer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const command_1 = require("@headless-adminapp/app/command");
|
|
7
|
+
const hooks_1 = require("@headless-adminapp/app/command/hooks");
|
|
8
|
+
const DataGridProvider_1 = require("@headless-adminapp/app/datagrid/DataGridProvider");
|
|
9
|
+
const hooks_2 = require("@headless-adminapp/app/datagrid/hooks");
|
|
10
|
+
const hooks_3 = require("@headless-adminapp/app/metadata/hooks");
|
|
11
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
12
|
+
const widget_1 = require("@headless-adminapp/app/widget");
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const DataGrid_1 = require("../DataGrid");
|
|
15
|
+
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
16
|
+
function WidgetDataGridContainer({ content, }) {
|
|
17
|
+
const logicalName = content.logicalName;
|
|
18
|
+
const schema = (0, hooks_3.useSchema)(logicalName);
|
|
19
|
+
const { view } = (0, hooks_3.useExperienceView)(logicalName);
|
|
20
|
+
if (!view) {
|
|
21
|
+
return (0, jsx_runtime_1.jsx)("div", { children: "Loading..." });
|
|
22
|
+
}
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flex: 1,
|
|
26
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
27
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
28
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
29
|
+
// padding: tokens.spacingHorizontalM,
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
}, children: (0, jsx_runtime_1.jsx)(DataGridProvider_1.DataGridProvider, { schema: schema, view: view, views: [], onChangeView: () => { }, commands: [], allowViewSelection: false, maxRecords: content.maxRecords, extraFilter: content.filter, children: (0, jsx_runtime_1.jsx)(FormSubgridContainer, { content: content }) }) }));
|
|
32
|
+
}
|
|
33
|
+
const FormSubgridContainer = ({ content, }) => {
|
|
34
|
+
const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
|
|
35
|
+
const primaryControl = (0, hooks_2.useGridControlContext)();
|
|
36
|
+
const widgetSetValue = (0, mutable_1.useContextSetValue)(widget_1.WidgetContext);
|
|
37
|
+
const updateStateValue = (0, react_1.useCallback)(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
(value) => {
|
|
40
|
+
widgetSetValue((state) => (Object.assign(Object.assign({}, state), { data: Object.assign(Object.assign({}, state.data), value) })));
|
|
41
|
+
}, [widgetSetValue]);
|
|
42
|
+
const transformedCommands = (0, command_1.useCommands)([content.commands], Object.assign(Object.assign({}, baseCommandHandleContext), { primaryControl: Object.assign(Object.assign({}, primaryControl), { updateStateValue }) }));
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flex: 1,
|
|
46
|
+
flexDirection: 'column',
|
|
47
|
+
// gap: 8,
|
|
48
|
+
// backgroundColor: tokens.colorNeutralBackground2,
|
|
49
|
+
// padding: 2,
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: "Recent transactions", commands: transformedCommands }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
52
|
+
// gap: 12,
|
|
53
|
+
flex: 1,
|
|
54
|
+
display: 'flex',
|
|
55
|
+
flexDirection: 'column',
|
|
56
|
+
// overflow: 'hidden',
|
|
57
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
58
|
+
flex: 1,
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flexDirection: 'column',
|
|
61
|
+
marginTop: 8,
|
|
62
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
63
|
+
gap: 16,
|
|
64
|
+
display: 'flex',
|
|
65
|
+
flexDirection: 'column',
|
|
66
|
+
flex: 1,
|
|
67
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, display: 'flex', minHeight: 300 }, children: (0, jsx_runtime_1.jsx)(DataGrid_1.GridTableContainer, { disableColumnSort: true, disableColumnFilter: true, disableSelection: true, disableContextMenu: true }) }) }) }) })] }));
|
|
68
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TableWidgetExperience } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface WidgetTableContainerProps {
|
|
4
|
+
content: TableWidgetExperience;
|
|
5
|
+
}
|
|
6
|
+
export declare const WidgetTableContainer: FC<WidgetTableContainerProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetTableContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const utils_1 = require("@headless-adminapp/app/utils");
|
|
7
|
+
const BodyLoading_1 = require("../components/BodyLoading");
|
|
8
|
+
const useWidgetDetail_1 = require("./hooks/useWidgetDetail");
|
|
9
|
+
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
10
|
+
const WidgetTableContainer = ({ content, }) => {
|
|
11
|
+
const { transformedCommands, dataset, isPending, isFetching, widget } = (0, useWidgetDetail_1.useWidgetDetail)(content);
|
|
12
|
+
const info = content.table;
|
|
13
|
+
const data = dataset[0];
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flex: 1,
|
|
17
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
18
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
19
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: widget.title, commands: transformedCommands }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1, position: 'relative', overflow: 'auto' }, children: [!isPending && ((0, jsx_runtime_1.jsxs)(react_components_1.Table, { style: {
|
|
23
|
+
borderCollapse: 'collapse',
|
|
24
|
+
width: '100%',
|
|
25
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_components_1.TableHeader, { style: {
|
|
26
|
+
position: 'sticky',
|
|
27
|
+
top: 0,
|
|
28
|
+
background: react_components_1.tokens.colorNeutralBackground3,
|
|
29
|
+
zIndex: 2,
|
|
30
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.TableRow, { style: {
|
|
31
|
+
position: 'sticky',
|
|
32
|
+
top: 0,
|
|
33
|
+
minWidth: 'calc(100% - 16px)',
|
|
34
|
+
}, children: info.columns.map((column, index) => {
|
|
35
|
+
const attribute = info.attributes[column];
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableHeaderCell, { style: {
|
|
37
|
+
minWidth: 32,
|
|
38
|
+
flexShrink: 0,
|
|
39
|
+
flex: 1,
|
|
40
|
+
position: 'sticky',
|
|
41
|
+
background: react_components_1.tokens.colorNeutralBackground3,
|
|
42
|
+
borderBottom: `${react_components_1.tokens.strokeWidthThin} solid ${react_components_1.tokens.colorNeutralStroke3}`,
|
|
43
|
+
}, children: attribute.label }, index));
|
|
44
|
+
}) }) }), (0, jsx_runtime_1.jsx)(react_components_1.TableBody, { children: data.map((row, index) => ((0, jsx_runtime_1.jsx)(react_components_1.TableRow, { children: info.columns.map((column) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const attribute = info.attributes[column];
|
|
47
|
+
const value = row[column];
|
|
48
|
+
const formattedValue = (_a = (0, utils_1.getAttributeFormattedValue)(attribute, value)) !== null && _a !== void 0 ? _a : '';
|
|
49
|
+
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
50
|
+
case 'money':
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(react_components_1.TableCell, { children: formattedValue }, column));
|
|
52
|
+
case 'lookup':
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return (0, jsx_runtime_1.jsx)(react_components_1.TableCell, { children: formattedValue }, column);
|
|
56
|
+
}) }, index))) })] })), (0, jsx_runtime_1.jsx)(BodyLoading_1.BodyLoading, { loading: isFetching })] })] }));
|
|
57
|
+
};
|
|
58
|
+
exports.WidgetTableContainer = WidgetTableContainer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TileWidgetExperience } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
interface WidgetTileContainerProps {
|
|
4
|
+
content: TileWidgetExperience;
|
|
5
|
+
}
|
|
6
|
+
export declare const WidgetTileContainer: FC<WidgetTileContainerProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.WidgetTileContainer = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
7
|
+
const WidgetTitleBar_1 = require("./WidgetTitleBar");
|
|
8
|
+
const useWidgetDetail_1 = require("./hooks/useWidgetDetail");
|
|
9
|
+
const WidgetTileContainer = ({ content, }) => {
|
|
10
|
+
const { transformedCommands, widget } = (0, useWidgetDetail_1.useWidgetDetail)(content);
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flex: 1,
|
|
14
|
+
background: react_components_1.tokens.colorNeutralBackground1,
|
|
15
|
+
boxShadow: react_components_1.tokens.shadow2,
|
|
16
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
17
|
+
flexDirection: 'column',
|
|
18
|
+
}, children: [(0, jsx_runtime_1.jsx)(WidgetTitleBar_1.WidgetTitleBar, { title: widget.title, commands: transformedCommands }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flex: 1 }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
19
|
+
flex: 1,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
paddingInline: 16,
|
|
23
|
+
}, children: (0, jsx_runtime_1.jsx)(react_components_1.Title2, { children: "Not supported yet" }) }) })] }));
|
|
24
|
+
};
|
|
25
|
+
exports.WidgetTileContainer = WidgetTileContainer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommandItemState } from '@headless-adminapp/app/command';
|
|
2
|
+
interface WidgetTitleBarProps {
|
|
3
|
+
title: string;
|
|
4
|
+
commands: CommandItemState[][];
|
|
5
|
+
}
|
|
6
|
+
export declare function WidgetTitleBar({ title, commands }: WidgetTitleBarProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WidgetTitleBar = WidgetTitleBar;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
9
|
+
const locale_1 = require("@headless-adminapp/app/locale");
|
|
10
|
+
const CommandBar_1 = __importDefault(require("../CommandBar"));
|
|
11
|
+
const OverflowCommandBar_1 = require("../OverflowCommandBar");
|
|
12
|
+
function WidgetTitleBar({ title, commands }) {
|
|
13
|
+
var _a;
|
|
14
|
+
const { language } = (0, locale_1.useLocale)();
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
paddingInline: 16,
|
|
18
|
+
paddingBlock: 8,
|
|
19
|
+
height: 40,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Body1Strong, { children: title }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }), ((_a = commands === null || commands === void 0 ? void 0 : commands[0]) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((0, jsx_runtime_1.jsx)("div", { style: { marginRight: -20 }, children: (0, jsx_runtime_1.jsx)(CommandBar_1.default.Wrapper, { children: commands[0].map((command, index) => (0, OverflowCommandBar_1.renderCommandItem)(index, command, language)) }) }))] }) }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }) })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Widgets = Widgets;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const insights_1 = require("@headless-adminapp/app/insights");
|
|
6
|
+
const mutable_1 = require("@headless-adminapp/app/mutable");
|
|
7
|
+
const widget_1 = require("@headless-adminapp/app/widget");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const Grid_1 = require("./Grid");
|
|
10
|
+
const WidgetChartContainer_1 = require("./WidgetChartContainer");
|
|
11
|
+
const WidgetDataGridContainer_1 = require("./WidgetDataGridContainer");
|
|
12
|
+
const WidgetTableContainer_1 = require("./WidgetTableContainer");
|
|
13
|
+
const WidgetTileContainer_1 = require("./WidgetTileContainer");
|
|
14
|
+
const WidgetProvider = ({ children, widget, }) => {
|
|
15
|
+
const contextValue = (0, mutable_1.useCreateContextStore)({
|
|
16
|
+
widget,
|
|
17
|
+
data: widget.defaultData,
|
|
18
|
+
});
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
contextValue.setValue({
|
|
21
|
+
widget,
|
|
22
|
+
data: widget.defaultData,
|
|
23
|
+
});
|
|
24
|
+
}, [widget]);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(widget_1.WidgetContext.Provider, { value: contextValue, children: children }));
|
|
26
|
+
};
|
|
27
|
+
function Widgets({ widgets, }) {
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGrid, { children: widgets.map((widget, index) => {
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGridItem, { row: widget.rows, column: widget.columns, children: (0, jsx_runtime_1.jsx)(WidgetProvider, { widget: widget, children: (0, jsx_runtime_1.jsx)(WidgetItem, {}) }) }, index));
|
|
30
|
+
}) }));
|
|
31
|
+
}
|
|
32
|
+
function WidgetItem() {
|
|
33
|
+
const insightState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
|
|
34
|
+
const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
|
|
35
|
+
const widget = widgetState.widget;
|
|
36
|
+
const content = typeof widget.content === 'function'
|
|
37
|
+
? widget.content(insightState, widgetState)
|
|
38
|
+
: widget.content;
|
|
39
|
+
if (content.type === 'tile') {
|
|
40
|
+
return (0, jsx_runtime_1.jsx)(WidgetTileContainer_1.WidgetTileContainer, { content: content });
|
|
41
|
+
}
|
|
42
|
+
if (content.type === 'chart') {
|
|
43
|
+
return (0, jsx_runtime_1.jsx)(WidgetChartContainer_1.WidgetChartContainer, { content: content });
|
|
44
|
+
}
|
|
45
|
+
if (content.type === 'grid') {
|
|
46
|
+
return (0, jsx_runtime_1.jsx)(WidgetDataGridContainer_1.WidgetDataGridContainer, { content: content });
|
|
47
|
+
}
|
|
48
|
+
if (content.type === 'table') {
|
|
49
|
+
return (0, jsx_runtime_1.jsx)(WidgetTableContainer_1.WidgetTableContainer, { content: content });
|
|
50
|
+
}
|
|
51
|
+
if (content.type === 'custom') {
|
|
52
|
+
return (0, jsx_runtime_1.jsx)(content.Component, {});
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AreaChart = AreaChart;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_components_1 = require("@fluentui/react-components");
|
|
6
|
+
const recharts_1 = require("recharts");
|
|
7
|
+
const CustomTooltipContent_1 = require("./CustomTooltipContent");
|
|
8
|
+
const formatters_1 = require("./formatters");
|
|
9
|
+
const renderers_1 = require("./renderers");
|
|
10
|
+
function AreaChart({ dataset, chartInfo, }) {
|
|
11
|
+
const xAxis = chartInfo.xAxis;
|
|
12
|
+
const yAxis = chartInfo.yAxis;
|
|
13
|
+
const areas = chartInfo.areas;
|
|
14
|
+
const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
|
|
15
|
+
const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderAreas)(areas, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
|
|
17
|
+
stroke: react_components_1.tokens.colorNeutralBackground6,
|
|
18
|
+
opacity: 0.5,
|
|
19
|
+
}, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
|
|
20
|
+
}
|