@headless-adminapp/fluent 0.0.17-alpha.7 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/App/App.d.ts +0 -1
  2. package/App/App.js +2 -4
  3. package/App/AppHeaderContianer.d.ts +5 -1
  4. package/App/AppHeaderContianer.js +43 -26
  5. package/App/AppLogo.js +15 -4
  6. package/App/AppUI.js +9 -1
  7. package/App/LayoutProvider.d.ts +7 -0
  8. package/App/LayoutProvider.js +17 -0
  9. package/App/NavigationContainer.d.ts +10 -1
  10. package/App/NavigationContainer.js +22 -22
  11. package/App/QuickActionItem.js +2 -2
  12. package/App/utils.js +3 -4
  13. package/CommandBar/Button.d.ts +2 -1
  14. package/CommandBar/Button.js +2 -2
  15. package/CommandBar/Divider.d.ts +2 -1
  16. package/CommandBar/Divider.js +2 -2
  17. package/CommandBar/IconButton.d.ts +2 -1
  18. package/CommandBar/IconButton.js +2 -2
  19. package/CommandBar/Label.d.ts +2 -1
  20. package/CommandBar/Label.js +2 -2
  21. package/CommandBar/MenuButton.d.ts +2 -1
  22. package/CommandBar/MenuButton.js +3 -3
  23. package/CommandBar/MenuItem.js +5 -4
  24. package/CommandBar/MenuItems.js +4 -4
  25. package/CommandBar/MenuList.js +5 -4
  26. package/CommandBar/Wrapper.d.ts +2 -2
  27. package/CommandBar/Wrapper.js +2 -2
  28. package/CommandBar/index.d.ts +6 -6
  29. package/DataGrid/ActionCell.d.ts +1 -1
  30. package/DataGrid/ActionCell.js +8 -4
  31. package/DataGrid/CustomizeColumns/AddColumns.js +35 -37
  32. package/DataGrid/CustomizeColumns/ColumnItem.js +8 -6
  33. package/DataGrid/CustomizeColumns/CustomizeColumns.d.ts +2 -2
  34. package/DataGrid/CustomizeColumns/CustomizeColumns.js +3 -6
  35. package/DataGrid/FormSubgridViewSelector.js +1 -5
  36. package/DataGrid/GridColumnHeader/ConditionValueControl.js +19 -25
  37. package/DataGrid/GridColumnHeader/FilterForm.js +9 -10
  38. package/DataGrid/GridColumnHeader/OperatorSelect.js +10 -3
  39. package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +22 -13
  40. package/DataGrid/GridColumnHeader/utils.js +10 -7
  41. package/DataGrid/GridHeaderDesktop.js +4 -5
  42. package/DataGrid/GridHeaderMobile.d.ts +5 -0
  43. package/DataGrid/GridHeaderMobile.js +29 -0
  44. package/DataGrid/GridListContainer.d.ts +12 -0
  45. package/DataGrid/GridListContainer.js +93 -0
  46. package/DataGrid/GridPaginationContainer.js +1 -2
  47. package/DataGrid/GridTableContainer.js +113 -77
  48. package/DataGrid/TableCell/TableCellBase.d.ts +2 -2
  49. package/DataGrid/TableCell/TableCellBase.js +6 -1
  50. package/DataGrid/TableCell/TableCellCheckbox.js +6 -5
  51. package/DataGrid/TableCell/TableCellChoice.d.ts +15 -0
  52. package/DataGrid/TableCell/TableCellChoice.js +30 -0
  53. package/DataGrid/TableCell/TableCellLink.d.ts +2 -1
  54. package/DataGrid/TableCell/TableCellLink.js +13 -5
  55. package/DataGrid/TableCell/TableCellText.js +9 -4
  56. package/DataGrid/types.d.ts +5 -0
  57. package/DataGrid/types.js +2 -0
  58. package/DataGrid/useTableColumns.d.ts +2 -3
  59. package/DataGrid/useTableColumns.js +297 -155
  60. package/DialogContainer/AlertDialog.js +3 -6
  61. package/DialogContainer/ConfirmDialog.js +5 -9
  62. package/DialogContainer/DialogContainer.js +2 -13
  63. package/DialogContainer/ErrorDialog.js +3 -6
  64. package/DialogContainer/PromptDialog.d.ts +13 -2
  65. package/DialogContainer/PromptDialog.js +44 -39
  66. package/Insights/CommandBarContainer.d.ts +1 -0
  67. package/Insights/CommandBarContainer.js +18 -0
  68. package/Insights/FilterBarContainer.d.ts +1 -0
  69. package/Insights/FilterBarContainer.js +99 -0
  70. package/Insights/Grid.d.ts +6 -0
  71. package/Insights/Grid.js +26 -0
  72. package/Insights/InsightsContainer.d.ts +1 -0
  73. package/Insights/InsightsContainer.js +35 -0
  74. package/Insights/WidgetChartContainer.d.ts +7 -0
  75. package/Insights/WidgetChartContainer.js +56 -0
  76. package/Insights/WidgetDataGridContainer.d.ts +4 -0
  77. package/Insights/WidgetDataGridContainer.js +80 -0
  78. package/Insights/WidgetTableContainer.d.ts +7 -0
  79. package/Insights/WidgetTableContainer.js +57 -0
  80. package/Insights/WidgetTileContainer.d.ts +7 -0
  81. package/Insights/WidgetTileContainer.js +24 -0
  82. package/Insights/WidgetTitleBar.d.ts +7 -0
  83. package/Insights/WidgetTitleBar.js +21 -0
  84. package/Insights/Widgets.d.ts +4 -0
  85. package/Insights/Widgets.js +57 -0
  86. package/Insights/charts/AreaChart.d.ts +5 -0
  87. package/Insights/charts/AreaChart.js +20 -0
  88. package/Insights/charts/BarChart.d.ts +5 -0
  89. package/Insights/charts/BarChart.js +20 -0
  90. package/Insights/charts/ComposedChart.d.ts +5 -0
  91. package/Insights/charts/ComposedChart.js +19 -0
  92. package/Insights/charts/CustomTooltipContent.d.ts +7 -0
  93. package/Insights/charts/CustomTooltipContent.js +25 -0
  94. package/Insights/charts/GaugeChart.d.ts +5 -0
  95. package/Insights/charts/GaugeChart.js +8 -0
  96. package/Insights/charts/LineChart.d.ts +5 -0
  97. package/Insights/charts/LineChart.js +21 -0
  98. package/Insights/charts/OhlcChart.d.ts +6 -0
  99. package/Insights/charts/OhlcChart.js +119 -0
  100. package/Insights/charts/PieChart.d.ts +5 -0
  101. package/Insights/charts/PieChart.js +54 -0
  102. package/Insights/charts/RadarChart.d.ts +5 -0
  103. package/Insights/charts/RadarChart.js +38 -0
  104. package/Insights/charts/ScatterChart.d.ts +5 -0
  105. package/Insights/charts/ScatterChart.js +81 -0
  106. package/Insights/charts/constants.d.ts +1 -0
  107. package/Insights/charts/constants.js +25 -0
  108. package/Insights/charts/formatters.d.ts +14 -0
  109. package/Insights/charts/formatters.js +186 -0
  110. package/Insights/charts/index.d.ts +4 -0
  111. package/Insights/charts/index.js +13 -0
  112. package/Insights/charts/renderers.d.ts +10 -0
  113. package/Insights/charts/renderers.js +64 -0
  114. package/Insights/hooks/useQueriesData.d.ts +7 -0
  115. package/Insights/hooks/useQueriesData.js +90 -0
  116. package/Insights/hooks/useWidgetDetail.d.ts +10 -0
  117. package/Insights/hooks/useWidgetDetail.js +39 -0
  118. package/OverflowCommandBar/OverflowCommandBar.js +1 -4
  119. package/OverflowCommandBar/OverflowMenu.js +5 -17
  120. package/OverflowCommandBar/render.js +3 -4
  121. package/OverflowCommandBar/utils.js +2 -3
  122. package/PageBoard/BoardColumn.d.ts +5 -0
  123. package/PageBoard/BoardColumn.js +9 -0
  124. package/PageBoard/BoardColumnCard.d.ts +12 -0
  125. package/PageBoard/BoardColumnCard.js +29 -0
  126. package/PageBoard/BoardColumnUI.d.ts +2 -0
  127. package/PageBoard/BoardColumnUI.js +76 -0
  128. package/PageBoard/BoardingColumnCardLoading.d.ts +1 -0
  129. package/PageBoard/BoardingColumnCardLoading.js +21 -0
  130. package/PageBoard/Header.d.ts +7 -0
  131. package/PageBoard/Header.js +31 -0
  132. package/PageBoard/PageBoard.d.ts +7 -0
  133. package/PageBoard/PageBoard.js +46 -0
  134. package/PageBoard/index.d.ts +1 -0
  135. package/PageBoard/index.js +5 -0
  136. package/PageCalendar/CalendarSection.d.ts +20 -0
  137. package/PageCalendar/CalendarSection.js +108 -0
  138. package/PageCalendar/EventDialog/AttributeController.d.ts +10 -0
  139. package/PageCalendar/EventDialog/AttributeController.js +17 -0
  140. package/PageCalendar/EventDialog/EventDialog.d.ts +25 -0
  141. package/PageCalendar/EventDialog/EventDialog.js +21 -0
  142. package/PageCalendar/EventDialog/EventFormBody.d.ts +18 -0
  143. package/PageCalendar/EventDialog/EventFormBody.js +69 -0
  144. package/PageCalendar/EventDialog/EventFormContent.d.ts +10 -0
  145. package/PageCalendar/EventDialog/EventFormContent.js +27 -0
  146. package/PageCalendar/EventDialog/types.d.ts +3 -0
  147. package/PageCalendar/EventDialog/types.js +2 -0
  148. package/PageCalendar/EventDialog/utils.d.ts +23 -0
  149. package/PageCalendar/EventDialog/utils.js +57 -0
  150. package/PageCalendar/Header.d.ts +8 -0
  151. package/PageCalendar/Header.js +35 -0
  152. package/PageCalendar/PageCalendar.d.ts +7 -0
  153. package/PageCalendar/PageCalendar.js +231 -0
  154. package/PageCalendar/TitleSelector.d.ts +10 -0
  155. package/PageCalendar/TitleSelector.js +73 -0
  156. package/PageCalendar/ViewSelector.d.ts +8 -0
  157. package/PageCalendar/ViewSelector.js +52 -0
  158. package/PageCalendar/baseEventAttributes.d.ts +35 -0
  159. package/PageCalendar/baseEventAttributes.js +38 -0
  160. package/PageCalendar/context.d.ts +20 -0
  161. package/PageCalendar/context.js +5 -0
  162. package/PageCalendar/hooks/index.d.ts +1 -0
  163. package/PageCalendar/hooks/index.js +17 -0
  164. package/PageCalendar/hooks/useConfig.d.ts +3 -0
  165. package/PageCalendar/hooks/useConfig.js +8 -0
  166. package/PageCalendar/index.d.ts +1 -0
  167. package/PageCalendar/index.js +5 -0
  168. package/PageCalendar/renderEventContent.d.ts +2 -0
  169. package/PageCalendar/renderEventContent.js +22 -0
  170. package/PageCalendar/types.d.ts +5 -0
  171. package/PageCalendar/types.js +9 -0
  172. package/PageCalendar/utils.d.ts +3 -0
  173. package/PageCalendar/utils.js +17 -0
  174. package/PageEntityForm/CommandContainer.js +9 -5
  175. package/PageEntityForm/PageCustomEntityForm.d.ts +15 -0
  176. package/PageEntityForm/PageCustomEntityForm.js +17 -0
  177. package/PageEntityForm/PageEntityFormDesktopContainer.js +42 -22
  178. package/PageEntityForm/ProcessFlow.d.ts +10 -0
  179. package/PageEntityForm/ProcessFlow.js +84 -0
  180. package/PageEntityForm/RecordAvatar.d.ts +2 -0
  181. package/PageEntityForm/RecordAvatar.js +83 -0
  182. package/PageEntityForm/RecordCard.d.ts +1 -1
  183. package/PageEntityForm/RecordCard.js +60 -53
  184. package/PageEntityForm/RecordCardLoading.d.ts +8 -0
  185. package/PageEntityForm/RecordCardLoading.js +24 -0
  186. package/PageEntityForm/RecordSetNavigatorContainer.js +1 -2
  187. package/PageEntityForm/RelatedViewSelector.d.ts +0 -2
  188. package/PageEntityForm/RelatedViewSelector.js +37 -11
  189. package/PageEntityForm/SectionContainer.d.ts +2 -2
  190. package/PageEntityForm/SectionContainer.js +77 -13
  191. package/PageEntityForm/StandardControl.d.ts +1 -22
  192. package/PageEntityForm/StandardControl.js +103 -117
  193. package/PageEntityForm/SubgridControl.d.ts +1 -0
  194. package/PageEntityForm/SubgridControl.js +4 -2
  195. package/PageEntityForm/UploadImageDialog.d.ts +12 -0
  196. package/PageEntityForm/UploadImageDialog.js +114 -0
  197. package/PageEntityView/FormSubgridContainer.js +5 -2
  198. package/PageEntityView/FormSubgridNotAvailableContainer.d.ts +2 -0
  199. package/PageEntityView/FormSubgridNotAvailableContainer.js +48 -0
  200. package/PageEntityView/PageEntityView.js +4 -1
  201. package/PageEntityView/PageEntityViewDesktopFrame.js +1 -0
  202. package/PageEntityView/PageEntityViewMobileContainer.d.ts +2 -0
  203. package/PageEntityView/PageEntityViewMobileContainer.js +14 -0
  204. package/PageEntityView/PageEntityViewStringContext.d.ts +2 -0
  205. package/PageEntityView/PageEntityViewStringContext.js +2 -0
  206. package/PageInsights/PageInsights.d.ts +9 -0
  207. package/PageInsights/PageInsights.js +25 -0
  208. package/PageInsights/index.d.ts +1 -0
  209. package/PageInsights/index.js +6 -0
  210. package/ToastNotificationContainer/index.js +1 -2
  211. package/componentStore.d.ts +2 -0
  212. package/componentStore.js +5 -0
  213. package/components/BodyLoading.d.ts +1 -1
  214. package/components/BodyLoading.js +13 -8
  215. package/components/DndProvider.d.ts +12 -0
  216. package/components/DndProvider.js +68 -0
  217. package/components/LoginForm.js +5 -21
  218. package/form/FormControl.js +19 -41
  219. package/form/controls/AttachmentControl.d.ts +27 -0
  220. package/form/controls/AttachmentControl.js +220 -0
  221. package/form/controls/AttachmentsControl.d.ts +6 -0
  222. package/form/controls/AttachmentsControl.js +35 -0
  223. package/form/controls/CurrencyControl.js +38 -6
  224. package/form/controls/DateControl.d.ts +1 -1
  225. package/form/controls/DateControl.js +15 -3
  226. package/form/controls/DateRangeControl.js +4 -6
  227. package/form/controls/DateTimeControl.d.ts +1 -1
  228. package/form/controls/DateTimeControl.js +107 -12
  229. package/form/controls/DecimalControl.d.ts +5 -0
  230. package/form/controls/DecimalControl.js +52 -0
  231. package/form/controls/DurationControl.d.ts +4 -0
  232. package/form/controls/DurationControl.js +209 -0
  233. package/form/controls/EmailControl.d.ts +1 -1
  234. package/form/controls/EmailControl.js +5 -5
  235. package/form/controls/IntegerControl.d.ts +4 -0
  236. package/form/controls/IntegerControl.js +25 -0
  237. package/form/controls/LookupControl.d.ts +1 -0
  238. package/form/controls/LookupControl.js +57 -13
  239. package/form/controls/MultiSelectControl.js +3 -3
  240. package/form/controls/MultiSelectLookupControl.js +16 -17
  241. package/form/controls/PasswordControl.js +1 -1
  242. package/form/controls/RichTextControl.d.ts +5 -0
  243. package/form/controls/RichTextControl.js +33 -0
  244. package/form/controls/SelectControl.js +4 -5
  245. package/form/controls/SwitchControl.d.ts +1 -1
  246. package/form/controls/SwitchControl.js +4 -2
  247. package/form/controls/TelephoneControl.d.ts +1 -1
  248. package/form/controls/TelephoneControl.js +26 -4
  249. package/form/controls/TextAreaControl.d.ts +1 -1
  250. package/form/controls/TextAreaControl.js +6 -6
  251. package/form/controls/TextControl.js +4 -4
  252. package/form/controls/UrlControl.d.ts +4 -0
  253. package/form/controls/UrlControl.js +16 -0
  254. package/form/controls/useLookupData.js +26 -41
  255. package/form/layout/FormSection/FormSection.js +10 -3
  256. package/form/layout/FormTab/FormTab.js +4 -4
  257. package/form/types.d.ts +2 -2
  258. package/package.json +17 -12
  259. package/styles.css +149 -0
  260. package/types/index.d.ts +18 -0
  261. package/utils/avatar.d.ts +2 -0
  262. package/utils/avatar.js +45 -0
  263. package/App/AppProvider.d.ts +0 -9
  264. package/App/AppProvider.js +0 -50
  265. package/DataGrid/ScrollbarWithMoreDataRequest.d.ts +0 -9
  266. package/DataGrid/ScrollbarWithMoreDataRequest.js +0 -33
  267. package/DataGrid/getAttributeFormattedValue.d.ts +0 -16
  268. package/DataGrid/getAttributeFormattedValue.js +0 -92
  269. package/form/controls/NumberControl.d.ts +0 -4
  270. package/form/controls/NumberControl.js +0 -16
@@ -0,0 +1,57 @@
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 hooks_1 = require("@headless-adminapp/app/hooks");
6
+ const insights_1 = require("@headless-adminapp/app/insights");
7
+ const mutable_1 = require("@headless-adminapp/app/mutable");
8
+ const widget_1 = require("@headless-adminapp/app/widget");
9
+ const react_1 = require("react");
10
+ const Grid_1 = require("./Grid");
11
+ const WidgetChartContainer_1 = require("./WidgetChartContainer");
12
+ const WidgetDataGridContainer_1 = require("./WidgetDataGridContainer");
13
+ const WidgetTableContainer_1 = require("./WidgetTableContainer");
14
+ const WidgetTileContainer_1 = require("./WidgetTileContainer");
15
+ const WidgetProvider = ({ children, widget, }) => {
16
+ const contextValue = (0, mutable_1.useCreateContextStore)({
17
+ widget,
18
+ data: widget.defaultData,
19
+ });
20
+ (0, react_1.useEffect)(() => {
21
+ contextValue.setValue({
22
+ widget,
23
+ data: widget.defaultData,
24
+ });
25
+ }, [contextValue, widget]);
26
+ return ((0, jsx_runtime_1.jsx)(widget_1.WidgetContext.Provider, { value: contextValue, children: children }));
27
+ };
28
+ function Widgets({ widgets, }) {
29
+ const isMobile = (0, hooks_1.useIsMobile)();
30
+ return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGrid, { children: widgets.map((widget, index) => {
31
+ return ((0, jsx_runtime_1.jsx)(Grid_1.WidgetGridItem, { row: widget.rows, column: isMobile ? 12 : widget.columns, children: (0, jsx_runtime_1.jsx)(WidgetProvider, { widget: widget, children: (0, jsx_runtime_1.jsx)(WidgetItem, {}) }) }, widget.title + String(index)));
32
+ }) }));
33
+ }
34
+ function WidgetItem() {
35
+ const insightState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
36
+ const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
37
+ const widget = widgetState.widget;
38
+ const content = typeof widget.content === 'function'
39
+ ? widget.content(insightState, widgetState)
40
+ : widget.content;
41
+ if (content.type === 'tile') {
42
+ return (0, jsx_runtime_1.jsx)(WidgetTileContainer_1.WidgetTileContainer, { content: content });
43
+ }
44
+ if (content.type === 'chart') {
45
+ return (0, jsx_runtime_1.jsx)(WidgetChartContainer_1.WidgetChartContainer, { content: content });
46
+ }
47
+ if (content.type === 'grid') {
48
+ return (0, jsx_runtime_1.jsx)(WidgetDataGridContainer_1.WidgetDataGridContainer, { content: content });
49
+ }
50
+ if (content.type === 'table') {
51
+ return (0, jsx_runtime_1.jsx)(WidgetTableContainer_1.WidgetTableContainer, { content: content });
52
+ }
53
+ if (content.type === 'custom') {
54
+ return (0, jsx_runtime_1.jsx)(content.Component, {});
55
+ }
56
+ return null;
57
+ }
@@ -0,0 +1,5 @@
1
+ import { AreaChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function AreaChart({ dataset, chartInfo, }: {
3
+ dataset: any[];
4
+ chartInfo: AreaChartInfo;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ import { BarChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function BarChart({ dataset, chartInfo, }: Readonly<{
3
+ dataset: any[];
4
+ chartInfo: BarChartInfo;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BarChart = BarChart;
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 BarChart({ dataset, chartInfo, }) {
11
+ const xAxis = chartInfo.xAxis;
12
+ const yAxis = chartInfo.yAxis;
13
+ const bars = chartInfo.bars;
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.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderBars)(bars, 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
+ }
@@ -0,0 +1,5 @@
1
+ import { ComposedChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function ComposedChart({ dataset, chartInfo, }: {
3
+ dataset: any[];
4
+ chartInfo: ComposedChartInfo;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComposedChart = ComposedChart;
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 ComposedChart({ dataset, chartInfo, }) {
11
+ const xAxis = chartInfo.xAxis;
12
+ const yAxis = chartInfo.yAxis;
13
+ const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
14
+ const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
15
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis, !!chartInfo.bars?.length), (0, renderers_1.renderLines)(chartInfo.lines ?? [], dataset), (0, renderers_1.renderAreas)(chartInfo.areas ?? [], dataset), (0, renderers_1.renderBars)(chartInfo.bars ?? [], dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
16
+ stroke: react_components_1.tokens.colorNeutralBackground6,
17
+ opacity: 0.5,
18
+ }, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
19
+ }
@@ -0,0 +1,7 @@
1
+ export declare const CustomTooltipContent: ({ active, payload, label, xAxisFormatter, yAxisFormatter, }: {
2
+ active?: boolean;
3
+ payload?: any[];
4
+ label: string;
5
+ xAxisFormatter: (value: unknown) => string;
6
+ yAxisFormatter: (value: unknown) => string;
7
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomTooltipContent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
6
+ const CustomTooltipContent = ({ active, payload, label, xAxisFormatter, yAxisFormatter, }) => {
7
+ if (!active || !payload?.length) {
8
+ return null;
9
+ }
10
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
11
+ display: 'flex',
12
+ flexDirection: 'column',
13
+ boxShadow: react_components_1.tokens.shadow16,
14
+ backgroundColor: react_components_1.tokens.colorNeutralBackground1,
15
+ padding: 8,
16
+ borderRadius: 4,
17
+ gap: 4,
18
+ }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxisFormatter(label) }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
19
+ width: 8,
20
+ height: 8,
21
+ background: item.color,
22
+ borderRadius: 4,
23
+ } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisFormatter(item.value) })] }, item.name + String(index)))) })] }));
24
+ };
25
+ exports.CustomTooltipContent = CustomTooltipContent;
@@ -0,0 +1,5 @@
1
+ import { GaugeChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function GaugeChart(_props: {
3
+ dataset: any[];
4
+ chartInfo: GaugeChartInfo;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GaugeChart = GaugeChart;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
+ function GaugeChart(_props) {
7
+ return (0, jsx_runtime_1.jsx)("div", { children: "Not supported yet" });
8
+ }
@@ -0,0 +1,5 @@
1
+ import { LineChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function LineChart({ dataset, chartInfo, }: Readonly<{
3
+ dataset: any[];
4
+ chartInfo: LineChartInfo;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LineChart = LineChart;
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 LineChart({ dataset, chartInfo, }) {
11
+ const xAxis = chartInfo.xAxis;
12
+ const yAxis = chartInfo.yAxis;
13
+ const lines = chartInfo.lines;
14
+ const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
15
+ const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
16
+ console.log('dataset', dataset, chartInfo);
17
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderLines)(lines, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
18
+ stroke: react_components_1.tokens.colorNeutralBackground6,
19
+ opacity: 0.5,
20
+ }, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
21
+ }
@@ -0,0 +1,6 @@
1
+ import { DateAxisTickInterval, OhlcChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare const barSizeInTime: (interval: DateAxisTickInterval) => number;
3
+ export declare function OhlcChart({ dataset, chartInfo, }: Readonly<{
4
+ dataset: any[];
5
+ chartInfo: OhlcChartInfo;
6
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.barSizeInTime = void 0;
4
+ exports.OhlcChart = OhlcChart;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_components_1 = require("@fluentui/react-components");
7
+ const insights_1 = require("@headless-adminapp/core/experience/insights");
8
+ const react_1 = require("react");
9
+ const recharts_1 = require("recharts");
10
+ const formatters_1 = require("./formatters");
11
+ const renderers_1 = require("./renderers");
12
+ const barSizeInTime = (interval) => {
13
+ switch (interval) {
14
+ case insights_1.DateAxisTickInterval.Minute:
15
+ return 60000 * 0.6;
16
+ case insights_1.DateAxisTickInterval.Hour:
17
+ return 3600000 * 0.6;
18
+ case insights_1.DateAxisTickInterval.Day:
19
+ return 86400000 * 0.6;
20
+ case insights_1.DateAxisTickInterval.Week:
21
+ return 604800000 * 0.6;
22
+ case insights_1.DateAxisTickInterval.Month:
23
+ return 2628000000 * 0.6;
24
+ case insights_1.DateAxisTickInterval.Year:
25
+ return 31540000000 * 0.6;
26
+ default:
27
+ return 60000 * 0.6;
28
+ }
29
+ };
30
+ exports.barSizeInTime = barSizeInTime;
31
+ function OhlcChart({ dataset, chartInfo, }) {
32
+ const bar = chartInfo.bars[0];
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ const data = dataset[bar.dataIndex ?? 0];
35
+ const domain = (0, react_1.useMemo)(() => {
36
+ if (chartInfo.yAxis.domain &&
37
+ typeof chartInfo.yAxis.domain[0] === 'number' &&
38
+ typeof chartInfo.yAxis.domain[1] === 'number') {
39
+ return chartInfo.yAxis.domain;
40
+ }
41
+ const dataMin = Math.min(...data.map((entry) => entry[bar.low.dataKey]), ...data.map((entry) => entry[bar.open.dataKey]), ...data.map((entry) => entry[bar.close.dataKey]), ...data.map((entry) => entry[bar.high.dataKey]));
42
+ const dataMax = Math.max(...data.map((entry) => entry[bar.low.dataKey]), ...data.map((entry) => entry[bar.open.dataKey]), ...data.map((entry) => entry[bar.close.dataKey]), ...data.map((entry) => entry[bar.high.dataKey]));
43
+ return [dataMin, dataMax];
44
+ }, [bar, chartInfo.yAxis.domain, data]);
45
+ const xAxis = chartInfo.xAxis;
46
+ const xAxisFormatter = (0, formatters_1.createAxisFormatter)(xAxis.tick);
47
+ const xAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(chartInfo.xAxis.tick);
48
+ const yAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(chartInfo.yAxis.tick);
49
+ console.log('temp.data', dataset, chartInfo);
50
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { data: data, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)({
51
+ ...chartInfo.yAxis,
52
+ domain,
53
+ }), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxis.dataKey, name: xAxis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10, padding: "gap", axisLine: {
54
+ stroke: react_components_1.tokens.colorNeutralBackground6,
55
+ }, fontSize: react_components_1.tokens.fontSizeBase100, tick: {
56
+ fill: react_components_1.tokens.colorNeutralForeground1,
57
+ opacity: 0.5,
58
+ }, scale: xAxis.tick.type === 'time' ? 'time' : 'auto', type: xAxis.tick.type === 'category' ? 'category' : 'number', domain: xAxis.domain, height: 16 }), (0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", data: data, markerWidth: 1, width: 1, strokeWidth: 1,
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ shape: (props) => renderShape(props, {
61
+ bar,
62
+ chartInfo,
63
+ }) }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
64
+ stroke: react_components_1.tokens.colorNeutralBackground6,
65
+ opacity: 0.5,
66
+ }, content: ({ active, payload }) => {
67
+ if (!active || !payload?.length) {
68
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
69
+ }
70
+ return ((0, jsx_runtime_1.jsx)(OhclTooltipContent, { payload: payload[0], bar: bar, xAxisFormatter: xAxisLongFormatter, yAxisFormatter: yAxisLongFormatter }));
71
+ } })] }) }));
72
+ }
73
+ function OhclTooltipContent({ payload, bar, xAxisFormatter, yAxisFormatter, }) {
74
+ const items = [];
75
+ items.push({
76
+ name: bar.open.dataLabel,
77
+ value: payload.payload[bar.open.dataKey],
78
+ });
79
+ items.push({
80
+ name: bar.high.dataLabel,
81
+ value: payload.payload[bar.high.dataKey],
82
+ });
83
+ items.push({
84
+ name: bar.low.dataLabel,
85
+ value: payload.payload[bar.low.dataKey],
86
+ });
87
+ items.push({
88
+ name: bar.close.dataLabel,
89
+ value: payload.payload[bar.close.dataKey],
90
+ });
91
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
92
+ display: 'flex',
93
+ flexDirection: 'column',
94
+ boxShadow: react_components_1.tokens.shadow16,
95
+ backgroundColor: react_components_1.tokens.colorNeutralBackground1,
96
+ padding: 8,
97
+ borderRadius: 4,
98
+ gap: 4,
99
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxisFormatter(payload.value) }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), items.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisFormatter(item.value) })] }, item.name + String(index))))] }) }));
100
+ }
101
+ function renderShape(props, { chartInfo, bar, }) {
102
+ const { x, width, payload, yAxis, xAxis } = props;
103
+ const xValue = payload[xAxis.dataKey];
104
+ const open = payload[bar.open.dataKey];
105
+ const close = payload[bar.close.dataKey];
106
+ const high = payload[bar.high.dataKey];
107
+ const low = payload[bar.low.dataKey];
108
+ const color = open < close
109
+ ? bar.colors?.[0] ?? react_components_1.tokens.colorPaletteGreenForeground1
110
+ : bar.colors?.[1] ?? react_components_1.tokens.colorPaletteRedForeground1;
111
+ const xPosition = xAxis.scale(xValue);
112
+ let xWidth = 30;
113
+ if (chartInfo.xAxis.tick.type === 'time' && chartInfo.xAxis.tick.interval) {
114
+ xWidth =
115
+ xAxis.scale(xValue + (0, exports.barSizeInTime)(chartInfo.xAxis.tick.interval)) -
116
+ xPosition;
117
+ }
118
+ return ((0, jsx_runtime_1.jsxs)("g", { children: [(0, jsx_runtime_1.jsx)(recharts_1.Rectangle, { x: x + width / 2, y: yAxis.scale(high), width: 1, height: yAxis.scale(low) - yAxis.scale(high), fill: color, stroke: color, strokeWidth: 1 }), (0, jsx_runtime_1.jsx)(recharts_1.Rectangle, { x: xPosition - xWidth / 2, y: Math.min(yAxis.scale(open), yAxis.scale(close)), width: xWidth, height: Math.abs(yAxis.scale(close) - yAxis.scale(open)), fill: color, stroke: color, strokeWidth: 1 })] }));
119
+ }
@@ -0,0 +1,5 @@
1
+ import { PieChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function PieChart({ dataset, chartInfo, }: Readonly<{
3
+ dataset: any[];
4
+ chartInfo: PieChartInfo;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PieChart = PieChart;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ const react_components_1 = require("@fluentui/react-components");
7
+ const recharts_1 = require("recharts");
8
+ const constants_1 = require("./constants");
9
+ const formatters_1 = require("./formatters");
10
+ function PieChart({ dataset, chartInfo, }) {
11
+ const RADIAN = Math.PI / 180;
12
+ const renderCustomizedLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, percent, }) => {
13
+ const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
14
+ const x = cx + radius * Math.cos(-midAngle * RADIAN);
15
+ const y = cy + radius * Math.sin(-midAngle * RADIAN);
16
+ if (percent < 0.05) {
17
+ return null;
18
+ }
19
+ return ((0, jsx_runtime_1.jsx)("text", { x: x, y: y, fill: "white", textAnchor: x > cx ? 'start' : 'end', dominantBaseline: "central", fontSize: react_components_1.tokens.fontSizeBase100, children: `${(percent * 100).toFixed(0)}%` }));
20
+ };
21
+ const item = chartInfo.pie[0];
22
+ const nameFormatter = (0, formatters_1.createLongAxisFormatter)(item.nameTick);
23
+ const valueFormatter = (0, formatters_1.createLongAxisFormatter)(item.dataTick);
24
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.PieChart, { children: [(0, jsx_runtime_1.jsx)(recharts_1.Pie, { data: dataset[item.dataIndex ?? 0], cx: "50%", cy: "50%", labelLine: false, label: renderCustomizedLabel, outerRadius: 80, dataKey: item.dataKey, nameKey: item.nameKey, children: dataset[item.dataIndex ?? 0].map((entry, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Cell, { fill: item.colorKey && entry[item.colorKey]
25
+ ? entry[item.colorKey]
26
+ : (item.colors ?? constants_1.defaultColors)[index % (item.colors ?? constants_1.defaultColors).length] }, 'cell-' + String(index)))) }), chartInfo.showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { align: "right", layout: "vertical", verticalAlign: "top", wrapperStyle: {
27
+ fontSize: react_components_1.tokens.fontSizeBase100,
28
+ fontFamily: react_components_1.tokens.fontFamilyBase,
29
+ overflow: 'auto',
30
+ top: 5,
31
+ bottom: 5,
32
+ } })), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
33
+ stroke: react_components_1.tokens.colorNeutralBackground6,
34
+ opacity: 0.5,
35
+ }, content: ({ payload }) => renderTooltipContent({
36
+ payload,
37
+ nameFormatter,
38
+ valueFormatter,
39
+ }) })] }) }));
40
+ }
41
+ function renderTooltipContent({ payload, nameFormatter, valueFormatter, }) {
42
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
43
+ display: 'flex',
44
+ flexDirection: 'column',
45
+ boxShadow: react_components_1.tokens.shadow16,
46
+ backgroundColor: react_components_1.tokens.colorNeutralBackground1,
47
+ padding: 8,
48
+ borderRadius: 4,
49
+ gap: 4,
50
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload?.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: {
51
+ color: react_components_1.tokens.colorNeutralForeground4,
52
+ marginLeft: 8,
53
+ }, children: nameFormatter(item.name) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: valueFormatter(item.value) })] }, index))) }) }));
54
+ }
@@ -0,0 +1,5 @@
1
+ import { RadarChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function RadarChart({ dataset, chartInfo, }: Readonly<{
3
+ dataset: any[];
4
+ chartInfo: RadarChartInfo;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RadarChart = RadarChart;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ const react_components_1 = require("@fluentui/react-components");
7
+ const recharts_1 = require("recharts");
8
+ const formatters_1 = require("./formatters");
9
+ function RadarChart({ dataset, chartInfo, }) {
10
+ const data = dataset[0];
11
+ const radar = chartInfo.radar[0];
12
+ const nameFormatter = (0, formatters_1.createLongAxisFormatter)(radar.nameTick);
13
+ const valueFormatter = (0, formatters_1.createLongAxisFormatter)(radar.dataTick);
14
+ const tickFormatter = (0, formatters_1.createAxisFormatter)(radar.dataTick);
15
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.RadarChart, { cx: "50%", cy: "50%", outerRadius: "80%", data: data, children: [(0, jsx_runtime_1.jsx)(recharts_1.PolarGrid, { stroke: react_components_1.tokens.colorNeutralBackground6, opacity: 0.5 }), (0, jsx_runtime_1.jsx)(recharts_1.PolarAngleAxis, { dataKey: radar.nameKey, fontSize: react_components_1.tokens.fontSizeBase100, tickFormatter: nameFormatter }), (0, jsx_runtime_1.jsx)(recharts_1.PolarRadiusAxis, { fontSize: react_components_1.tokens.fontSizeBase100, tickFormatter: tickFormatter }), (0, jsx_runtime_1.jsx)(recharts_1.Radar, { dataKey: radar.dataKey, stroke: radar.color ?? '#8884d8', fill: radar.color ?? '#8884d8', fillOpacity: 0.6 }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
16
+ stroke: react_components_1.tokens.colorNeutralBackground6,
17
+ opacity: 0.5,
18
+ }, content: ({ payload }) => renderTooltipContent({
19
+ payload,
20
+ nameFormatter,
21
+ valueFormatter,
22
+ radar,
23
+ }) })] }) }));
24
+ }
25
+ function renderTooltipContent({ payload, nameFormatter, valueFormatter, radar, }) {
26
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
27
+ display: 'flex',
28
+ flexDirection: 'column',
29
+ boxShadow: react_components_1.tokens.shadow16,
30
+ backgroundColor: react_components_1.tokens.colorNeutralBackground1,
31
+ padding: 8,
32
+ borderRadius: 4,
33
+ gap: 4,
34
+ }, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload?.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: {
35
+ color: react_components_1.tokens.colorNeutralForeground4,
36
+ marginLeft: 8,
37
+ }, children: nameFormatter(item.payload[radar.nameKey]) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: valueFormatter(item.value) })] }, index))) }) }));
38
+ }
@@ -0,0 +1,5 @@
1
+ import { ScatterChartInfo } from '@headless-adminapp/core/experience/insights';
2
+ export declare function ScatterChart({ dataset, chartInfo, }: Readonly<{
3
+ dataset: any[];
4
+ chartInfo: ScatterChartInfo;
5
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScatterChart = ScatterChart;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_components_1 = require("@fluentui/react-components");
6
+ const react_1 = require("react");
7
+ const recharts_1 = require("recharts");
8
+ const constants_1 = require("./constants");
9
+ const formatters_1 = require("./formatters");
10
+ const renderers_1 = require("./renderers");
11
+ function ScatterChart({ dataset, chartInfo, }) {
12
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(chartInfo.xAxis), (0, renderers_1.renderYAxis)(chartInfo.yAxis), (0, jsx_runtime_1.jsx)(recharts_1.ZAxis, { type: "number", dataKey: chartInfo.zAxis.dataKey, range: chartInfo.zAxis.range, name: chartInfo.zAxis.name }), chartInfo.scatters.map((scatter, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", name: scatter.dataLabel, data: dataset[scatter.dataIndex ?? 0], dataKey: scatter.dataKey, fill: scatter.color ?? constants_1.defaultColors[index] }, index))), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: false, content: (props) => {
13
+ if (!props.active || !props.payload?.length) {
14
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
15
+ }
16
+ return ((0, jsx_runtime_1.jsx)(ScatterTooltipContent, { active: props.active, payload: props.payload, chartInfo: chartInfo, dataset: dataset }));
17
+ } })] }) }));
18
+ }
19
+ const ScatterTooltipContent = (props) => {
20
+ const chartInfo = props.chartInfo;
21
+ const dataset = props.dataset;
22
+ const xAxis = chartInfo.xAxis;
23
+ const yAxis = chartInfo.yAxis;
24
+ const zAxis = chartInfo.zAxis;
25
+ const xPayload = props.payload[0];
26
+ const yPayload = props.payload[1];
27
+ const xValue = xPayload.value;
28
+ const yValue = yPayload.value;
29
+ const findKey = xValue + ':' + yValue;
30
+ const items = (0, react_1.useMemo)(() => {
31
+ const _items = [];
32
+ if (!xAxis.dataKey || !yAxis.dataKey || !zAxis.dataKey) {
33
+ return _items;
34
+ }
35
+ const datasetDict = dataset.map((data) => {
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ return data.reduce((acc, entry) => {
38
+ const key = entry[xAxis.dataKey] + ':' + entry[yAxis.dataKey];
39
+ acc[key] = entry;
40
+ return acc;
41
+ }, {});
42
+ });
43
+ for (let i = 0; i < chartInfo.scatters.length; i++) {
44
+ const scatter = chartInfo.scatters[i];
45
+ const zValue = datasetDict[scatter.dataIndex ?? 0]?.[findKey]?.[zAxis.dataKey];
46
+ if (zValue === undefined) {
47
+ continue;
48
+ }
49
+ _items.push({
50
+ name: scatter.dataLabel,
51
+ value: zValue,
52
+ color: scatter.color ?? constants_1.defaultColors[i],
53
+ });
54
+ }
55
+ return _items;
56
+ }, [
57
+ chartInfo.scatters,
58
+ dataset,
59
+ findKey,
60
+ xAxis.dataKey,
61
+ yAxis.dataKey,
62
+ zAxis.dataKey,
63
+ ]);
64
+ const xAxisFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
65
+ const yAxisFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
66
+ const zAxisFormatter = (0, formatters_1.createLongAxisFormatter)(zAxis.tick);
67
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
68
+ display: 'flex',
69
+ flexDirection: 'column',
70
+ boxShadow: react_components_1.tokens.shadow16,
71
+ backgroundColor: react_components_1.tokens.colorNeutralBackground1,
72
+ padding: 8,
73
+ borderRadius: 4,
74
+ gap: 4,
75
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxis.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: xAxisFormatter(xValue) })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxis.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: yAxisFormatter(yValue) })] }), (0, jsx_runtime_1.jsx)(react_components_1.Divider, { style: { opacity: 0.2 } }), items.map((item, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
76
+ width: 8,
77
+ height: 8,
78
+ background: item.color,
79
+ borderRadius: 4,
80
+ } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: zAxisFormatter(item.value) })] }, index)))] }) }));
81
+ };
@@ -0,0 +1 @@
1
+ export declare const defaultColors: string[];
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultColors = void 0;
4
+ exports.defaultColors = [
5
+ '#0088FE',
6
+ '#00C49F',
7
+ '#FFBB28',
8
+ '#FF8042',
9
+ '#0088FE',
10
+ '#00C49F',
11
+ '#FFBB28',
12
+ '#FF8042',
13
+ '#0088FE',
14
+ '#00C49F',
15
+ '#FFBB28',
16
+ '#FF8042',
17
+ '#0088FE',
18
+ '#00C49F',
19
+ '#FFBB28',
20
+ '#FF8042',
21
+ '#0088FE',
22
+ '#00C49F',
23
+ '#FFBB28',
24
+ '#FF8042',
25
+ ];
@@ -0,0 +1,14 @@
1
+ import { AllAxisTick } from '@headless-adminapp/core/experience/insights';
2
+ interface FormatNumberOptions {
3
+ digit?: number;
4
+ minDigit?: number;
5
+ maxDigit?: number;
6
+ }
7
+ export declare const formatCurrencyWithSuffix: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
8
+ export declare const formatDate: (input: Date | string | number | undefined | null, format: string) => string;
9
+ export declare const formatCurrency: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
10
+ export declare const formatNumber: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
11
+ export declare function createAxisFormatter(tick: AllAxisTick): (value: number) => string;
12
+ export type Formatter = (value: unknown) => string;
13
+ export declare function createLongAxisFormatter(tick: AllAxisTick): Formatter;
14
+ export {};