@headless-adminapp/fluent 0.0.17-alpha.52 → 0.0.17-alpha.53

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 (174) hide show
  1. package/App/App.js +7 -11
  2. package/App/AppHeaderContianer.js +38 -42
  3. package/App/AppLogo.js +8 -12
  4. package/App/AppStringContext.js +9 -13
  5. package/App/AppUI.js +11 -15
  6. package/App/LayoutProvider.js +11 -15
  7. package/App/NavigationContainer.js +25 -29
  8. package/App/QuickActionItem.js +5 -9
  9. package/App/index.js +1 -5
  10. package/App/utils.js +1 -4
  11. package/CommandBar/Button.js +14 -17
  12. package/CommandBar/Divider.js +6 -9
  13. package/CommandBar/IconButton.js +13 -16
  14. package/CommandBar/Label.js +8 -11
  15. package/CommandBar/MenuButton.js +17 -20
  16. package/CommandBar/MenuItem.js +15 -18
  17. package/CommandBar/MenuItems.js +8 -11
  18. package/CommandBar/MenuList.js +9 -12
  19. package/CommandBar/Wrapper.js +7 -10
  20. package/CommandBar/index.js +13 -15
  21. package/DataForm/SectionControl.js +4 -7
  22. package/DataGrid/ActionCell.js +11 -14
  23. package/DataGrid/CommandContainer.js +6 -10
  24. package/DataGrid/CustomizeColumns/AddColumns.js +34 -37
  25. package/DataGrid/CustomizeColumns/ColumnItem.js +19 -23
  26. package/DataGrid/CustomizeColumns/CustomizeColumns.js +36 -42
  27. package/DataGrid/CustomizeColumns/index.js +1 -5
  28. package/DataGrid/FormSubgridCommandContainer.js +13 -17
  29. package/DataGrid/FormSubgridViewSelector.js +18 -22
  30. package/DataGrid/GridColumnHeader/ConditionValueControl.js +14 -20
  31. package/DataGrid/GridColumnHeader/FilterForm.js +23 -27
  32. package/DataGrid/GridColumnHeader/OperatorSelect.js +13 -19
  33. package/DataGrid/GridColumnHeader/TableHeaderFilterCell.js +28 -32
  34. package/DataGrid/GridColumnHeader/index.js +1 -5
  35. package/DataGrid/GridColumnHeader/utils.js +2 -6
  36. package/DataGrid/GridHeaderContainer.js +4 -8
  37. package/DataGrid/GridHeaderDesktop.js +26 -30
  38. package/DataGrid/GridHeaderMobile.js +17 -21
  39. package/DataGrid/GridListContainer.js +39 -43
  40. package/DataGrid/GridPaginationContainer.js +12 -16
  41. package/DataGrid/GridTableContainer.js +74 -78
  42. package/DataGrid/TableCell/TableCellAction.js +11 -15
  43. package/DataGrid/TableCell/TableCellBase.js +4 -8
  44. package/DataGrid/TableCell/TableCellCheckbox.js +7 -10
  45. package/DataGrid/TableCell/TableCellChoice.js +11 -14
  46. package/DataGrid/TableCell/TableCellLink.d.ts +1 -1
  47. package/DataGrid/TableCell/TableCellLink.js +13 -12
  48. package/DataGrid/TableCell/TableCellText.js +7 -10
  49. package/DataGrid/TableCell/index.js +4 -20
  50. package/DataGrid/index.js +4 -11
  51. package/DataGrid/types.js +1 -2
  52. package/DataGrid/useTableColumns.js +139 -90
  53. package/DataGrid/utils.js +1 -5
  54. package/DialogContainer/AlertDialog.js +5 -8
  55. package/DialogContainer/ConfirmDialog.js +6 -9
  56. package/DialogContainer/DialogContainer.js +14 -18
  57. package/DialogContainer/ErrorDialog.js +9 -12
  58. package/DialogContainer/PromptDialog.js +30 -57
  59. package/DialogContainer/index.js +1 -5
  60. package/Insights/CommandBarContainer.js +11 -14
  61. package/Insights/FilterBarContainer.js +17 -20
  62. package/Insights/Grid.js +9 -13
  63. package/Insights/InsightsContainer.js +19 -22
  64. package/Insights/WidgetChartContainer.js +30 -34
  65. package/Insights/WidgetDataGridContainer.js +32 -35
  66. package/Insights/WidgetTableContainer.js +24 -28
  67. package/Insights/WidgetTileContainer.js +12 -16
  68. package/Insights/WidgetTitleBar.js +9 -15
  69. package/Insights/Widgets.js +25 -28
  70. package/Insights/charts/AreaChart.js +12 -15
  71. package/Insights/charts/BarChart.js +12 -15
  72. package/Insights/charts/ComposedChart.js +12 -15
  73. package/Insights/charts/CustomTooltipContent.js +8 -12
  74. package/Insights/charts/GaugeChart.js +3 -6
  75. package/Insights/charts/LineChart.js +12 -15
  76. package/Insights/charts/OhlcChart.js +36 -41
  77. package/Insights/charts/PieChart.js +23 -26
  78. package/Insights/charts/RadarChart.js +16 -19
  79. package/Insights/charts/ScatterChart.js +23 -26
  80. package/Insights/charts/constants.js +1 -4
  81. package/Insights/charts/formatters.js +17 -29
  82. package/Insights/charts/index.js +1 -2
  83. package/Insights/charts/renderers.js +25 -36
  84. package/Insights/hooks/useQueriesData.js +19 -25
  85. package/Insights/hooks/useWidgetDetail.js +13 -16
  86. package/OverflowCommandBar/OverflowCommandBar.js +12 -19
  87. package/OverflowCommandBar/OverflowMenu.js +16 -20
  88. package/OverflowCommandBar/OverflowMenuDivider.js +6 -10
  89. package/OverflowCommandBar/index.js +3 -9
  90. package/OverflowCommandBar/render.js +9 -15
  91. package/OverflowCommandBar/utils.js +1 -4
  92. package/PageBoard/BoardColumn.js +5 -8
  93. package/PageBoard/BoardColumnCard.js +12 -15
  94. package/PageBoard/BoardColumnUI.js +34 -38
  95. package/PageBoard/BoardingColumnCardLoading.js +10 -13
  96. package/PageBoard/Header.js +16 -20
  97. package/PageBoard/PageBoard.d.ts +1 -1
  98. package/PageBoard/PageBoard.js +26 -29
  99. package/PageBoard/index.js +1 -5
  100. package/PageEntityForm/CommandContainer.js +21 -25
  101. package/PageEntityForm/FormTabRelated.js +17 -20
  102. package/PageEntityForm/PageEntityForm.js +16 -20
  103. package/PageEntityForm/PageEntityFormDesktopContainer.js +68 -72
  104. package/PageEntityForm/PageEntityFormStringContext.js +5 -9
  105. package/PageEntityForm/ProcessFlow.js +21 -24
  106. package/PageEntityForm/RecordCard.js +21 -24
  107. package/PageEntityForm/RecordCardLoading.js +10 -13
  108. package/PageEntityForm/RecordSetNavigatorContainer.js +30 -34
  109. package/PageEntityForm/RelatedViewSelector.js +28 -31
  110. package/PageEntityForm/SectionContainer.js +25 -28
  111. package/PageEntityForm/StandardControl.d.ts +3 -3
  112. package/PageEntityForm/StandardControl.js +74 -81
  113. package/PageEntityForm/SubgridControl.js +20 -23
  114. package/PageEntityForm/index.js +1 -5
  115. package/PageEntityView/FormSubgridContainer.js +22 -26
  116. package/PageEntityView/PageEntityView.js +15 -19
  117. package/PageEntityView/PageEntityViewDesktopContainer.js +9 -13
  118. package/PageEntityView/PageEntityViewDesktopFrame.js +17 -21
  119. package/PageEntityView/PageEntityViewMobileContainer.js +9 -13
  120. package/PageEntityView/PageEntityViewStringContext.js +5 -9
  121. package/PageEntityView/index.js +1 -5
  122. package/PageInsights/PageInsights.js +9 -13
  123. package/PageInsights/index.js +1 -6
  124. package/ProgressIndicatorContainer/index.js +10 -14
  125. package/ToastNotificationContainer/index.js +14 -18
  126. package/componentStore.js +2 -5
  127. package/components/BodyLoading.js +7 -11
  128. package/components/DialogLogin.js +5 -8
  129. package/components/LoginForm.js +21 -47
  130. package/components/PageBroken.js +5 -8
  131. package/components/PageLoading.js +5 -8
  132. package/components/PageLogin.js +14 -17
  133. package/form/FormControl.js +39 -44
  134. package/form/FormControlLoading.js +4 -8
  135. package/form/controls/AttachmentControl.js +56 -60
  136. package/form/controls/AttachmentsControl.js +15 -19
  137. package/form/controls/CurrencyControl.js +10 -13
  138. package/form/controls/DateControl.js +18 -24
  139. package/form/controls/DateRangeControl.js +14 -20
  140. package/form/controls/DateTimeControl.js +39 -45
  141. package/form/controls/DecimalControl.js +8 -11
  142. package/form/controls/DurationControl.js +11 -15
  143. package/form/controls/EmailControl.js +7 -10
  144. package/form/controls/IntegerControl.js +4 -7
  145. package/form/controls/LookupControl.d.ts +1 -0
  146. package/form/controls/LookupControl.js +75 -38
  147. package/form/controls/MultiSelectControl.js +8 -11
  148. package/form/controls/MultiSelectLookupControl.js +40 -43
  149. package/form/controls/PasswordControl.js +8 -11
  150. package/form/controls/RichTextControl.js +5 -32
  151. package/form/controls/SelectControl.js +8 -11
  152. package/form/controls/SwitchControl.js +4 -7
  153. package/form/controls/TelephoneControl.js +7 -10
  154. package/form/controls/TextAreaControl.js +4 -7
  155. package/form/controls/TextControl.js +5 -8
  156. package/form/controls/UrlControl.js +7 -10
  157. package/form/controls/types.js +1 -2
  158. package/form/controls/useLookupData.js +14 -18
  159. package/form/layout/FormBody/FormBody.js +6 -10
  160. package/form/layout/FormBody/index.js +1 -17
  161. package/form/layout/FormSection/FormSection.js +18 -22
  162. package/form/layout/FormSection/FormSectionColumn.js +3 -7
  163. package/form/layout/FormSection/FormSectionLoading.js +1 -5
  164. package/form/layout/FormSection/index.js +1 -5
  165. package/form/layout/FormTab/FormTab.js +16 -20
  166. package/form/layout/FormTab/FormTabColumn.js +5 -9
  167. package/form/layout/FormTab/index.js +1 -5
  168. package/form/layout/TabContext.js +2 -5
  169. package/form/layout/index.js +3 -9
  170. package/form/types.js +1 -2
  171. package/package.json +3 -2
  172. package/types/index.js +1 -2
  173. package/utils/avatar.d.ts +2 -0
  174. package/utils/avatar.js +42 -0
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PieChart = PieChart;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
2
  /* 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, }) {
3
+ import { Caption1, tokens } from '@fluentui/react-components';
4
+ import { Cell, Legend, Pie, PieChart as PieChartInternal, ResponsiveContainer, Tooltip, } from 'recharts';
5
+ import { defaultColors } from './constants';
6
+ import { createLongAxisFormatter } from './formatters';
7
+ export function PieChart({ dataset, chartInfo, }) {
11
8
  var _a, _b;
12
9
  const RADIAN = Math.PI / 180;
13
10
  const renderCustomizedLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, percent, }) => {
@@ -17,24 +14,24 @@ function PieChart({ dataset, chartInfo, }) {
17
14
  if (percent < 0.05) {
18
15
  return null;
19
16
  }
20
- 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)}%` }));
17
+ return (_jsx("text", { x: x, y: y, fill: "white", textAnchor: x > cx ? 'start' : 'end', dominantBaseline: "central", fontSize: tokens.fontSizeBase100, children: `${(percent * 100).toFixed(0)}%` }));
21
18
  };
22
19
  const item = chartInfo.pie[0];
23
- const nameFormatter = (0, formatters_1.createLongAxisFormatter)(item.nameTick);
24
- const valueFormatter = (0, formatters_1.createLongAxisFormatter)(item.dataTick);
25
- 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[(_a = item.dataIndex) !== null && _a !== void 0 ? _a : 0], cx: "50%", cy: "50%", labelLine: false, label: renderCustomizedLabel, outerRadius: 80, dataKey: item.dataKey, nameKey: item.nameKey, children: dataset[(_b = item.dataIndex) !== null && _b !== void 0 ? _b : 0].map((entry, index) => {
20
+ const nameFormatter = createLongAxisFormatter(item.nameTick);
21
+ const valueFormatter = createLongAxisFormatter(item.dataTick);
22
+ return (_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(PieChartInternal, { children: [_jsx(Pie, { data: dataset[(_a = item.dataIndex) !== null && _a !== void 0 ? _a : 0], cx: "50%", cy: "50%", labelLine: false, label: renderCustomizedLabel, outerRadius: 80, dataKey: item.dataKey, nameKey: item.nameKey, children: dataset[(_b = item.dataIndex) !== null && _b !== void 0 ? _b : 0].map((entry, index) => {
26
23
  var _a, _b;
27
- return ((0, jsx_runtime_1.jsx)(recharts_1.Cell, { fill: item.colorKey && entry[item.colorKey]
24
+ return (_jsx(Cell, { fill: item.colorKey && entry[item.colorKey]
28
25
  ? entry[item.colorKey]
29
- : ((_a = item.colors) !== null && _a !== void 0 ? _a : constants_1.defaultColors)[index % ((_b = item.colors) !== null && _b !== void 0 ? _b : constants_1.defaultColors).length] }, 'cell-' + String(index)));
30
- }) }), chartInfo.showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { align: "right", layout: "vertical", verticalAlign: "top", wrapperStyle: {
31
- fontSize: react_components_1.tokens.fontSizeBase100,
32
- fontFamily: react_components_1.tokens.fontFamilyBase,
26
+ : ((_a = item.colors) !== null && _a !== void 0 ? _a : defaultColors)[index % ((_b = item.colors) !== null && _b !== void 0 ? _b : defaultColors).length] }, 'cell-' + String(index)));
27
+ }) }), chartInfo.showLegend && (_jsx(Legend, { align: "right", layout: "vertical", verticalAlign: "top", wrapperStyle: {
28
+ fontSize: tokens.fontSizeBase100,
29
+ fontFamily: tokens.fontFamilyBase,
33
30
  overflow: 'auto',
34
31
  top: 5,
35
32
  bottom: 5,
36
- } })), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
37
- stroke: react_components_1.tokens.colorNeutralBackground6,
33
+ } })), _jsx(Tooltip, { cursor: {
34
+ stroke: tokens.colorNeutralBackground6,
38
35
  opacity: 0.5,
39
36
  }, content: ({ payload }) => renderTooltipContent({
40
37
  payload,
@@ -43,16 +40,16 @@ function PieChart({ dataset, chartInfo, }) {
43
40
  }) })] }) }));
44
41
  }
45
42
  function renderTooltipContent({ payload, nameFormatter, valueFormatter, }) {
46
- return ((0, jsx_runtime_1.jsx)("div", { style: {
43
+ return (_jsx("div", { style: {
47
44
  display: 'flex',
48
45
  flexDirection: 'column',
49
- boxShadow: react_components_1.tokens.shadow16,
50
- backgroundColor: react_components_1.tokens.colorNeutralBackground1,
46
+ boxShadow: tokens.shadow16,
47
+ backgroundColor: tokens.colorNeutralBackground1,
51
48
  padding: 8,
52
49
  borderRadius: 4,
53
50
  gap: 4,
54
- }, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload === null || payload === void 0 ? void 0 : 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: {
55
- color: react_components_1.tokens.colorNeutralForeground4,
51
+ }, children: _jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload === null || payload === void 0 ? void 0 : payload.map((item, index) => (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(Caption1, { style: {
52
+ color: tokens.colorNeutralForeground4,
56
53
  marginLeft: 8,
57
- }, 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
+ }, children: nameFormatter(item.name) }), _jsx("div", { style: { flex: 1, minWidth: 50 } }), _jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: valueFormatter(item.value) })] }, index))) }) }));
58
55
  }
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RadarChart = RadarChart;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
2
  /* 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, }) {
3
+ import { Caption1, tokens } from '@fluentui/react-components';
4
+ import { PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart as RadarChartInternal, ResponsiveContainer, Tooltip, } from 'recharts';
5
+ import { createAxisFormatter, createLongAxisFormatter, } from './formatters';
6
+ export function RadarChart({ dataset, chartInfo, }) {
10
7
  var _a, _b;
11
8
  const data = dataset[0];
12
9
  const radar = chartInfo.radar[0];
13
- const nameFormatter = (0, formatters_1.createLongAxisFormatter)(radar.nameTick);
14
- const valueFormatter = (0, formatters_1.createLongAxisFormatter)(radar.dataTick);
15
- const tickFormatter = (0, formatters_1.createAxisFormatter)(radar.dataTick);
16
- 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: (_a = radar.color) !== null && _a !== void 0 ? _a : '#8884d8', fill: (_b = radar.color) !== null && _b !== void 0 ? _b : '#8884d8', fillOpacity: 0.6 }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
17
- stroke: react_components_1.tokens.colorNeutralBackground6,
10
+ const nameFormatter = createLongAxisFormatter(radar.nameTick);
11
+ const valueFormatter = createLongAxisFormatter(radar.dataTick);
12
+ const tickFormatter = createAxisFormatter(radar.dataTick);
13
+ return (_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(RadarChartInternal, { cx: "50%", cy: "50%", outerRadius: "80%", data: data, children: [_jsx(PolarGrid, { stroke: tokens.colorNeutralBackground6, opacity: 0.5 }), _jsx(PolarAngleAxis, { dataKey: radar.nameKey, fontSize: tokens.fontSizeBase100, tickFormatter: nameFormatter }), _jsx(PolarRadiusAxis, { fontSize: tokens.fontSizeBase100, tickFormatter: tickFormatter }), _jsx(Radar, { dataKey: radar.dataKey, stroke: (_a = radar.color) !== null && _a !== void 0 ? _a : '#8884d8', fill: (_b = radar.color) !== null && _b !== void 0 ? _b : '#8884d8', fillOpacity: 0.6 }), _jsx(Tooltip, { cursor: {
14
+ stroke: tokens.colorNeutralBackground6,
18
15
  opacity: 0.5,
19
16
  }, content: ({ payload }) => renderTooltipContent({
20
17
  payload,
@@ -24,16 +21,16 @@ function RadarChart({ dataset, chartInfo, }) {
24
21
  }) })] }) }));
25
22
  }
26
23
  function renderTooltipContent({ payload, nameFormatter, valueFormatter, radar, }) {
27
- return ((0, jsx_runtime_1.jsx)("div", { style: {
24
+ return (_jsx("div", { style: {
28
25
  display: 'flex',
29
26
  flexDirection: 'column',
30
- boxShadow: react_components_1.tokens.shadow16,
31
- backgroundColor: react_components_1.tokens.colorNeutralBackground1,
27
+ boxShadow: tokens.shadow16,
28
+ backgroundColor: tokens.colorNeutralBackground1,
32
29
  padding: 8,
33
30
  borderRadius: 4,
34
31
  gap: 4,
35
- }, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload === null || payload === void 0 ? void 0 : 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: {
36
- color: react_components_1.tokens.colorNeutralForeground4,
32
+ }, children: _jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: payload === null || payload === void 0 ? void 0 : payload.map((item, index) => (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(Caption1, { style: {
33
+ color: tokens.colorNeutralForeground4,
37
34
  marginLeft: 8,
38
- }, 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))) }) }));
35
+ }, children: nameFormatter(item.payload[radar.nameKey]) }), _jsx("div", { style: { flex: 1, minWidth: 50 } }), _jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: valueFormatter(item.value) })] }, index))) }) }));
39
36
  }
@@ -1,23 +1,20 @@
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) => {
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Caption1, Divider, tokens } from '@fluentui/react-components';
3
+ import { useMemo } from 'react';
4
+ import { ResponsiveContainer, Scatter, ScatterChart as ScatterChartInternal, Tooltip, ZAxis, } from 'recharts';
5
+ import { defaultColors } from './constants';
6
+ import { createLongAxisFormatter } from './formatters';
7
+ import { renderGrid, renderXAxis, renderYAxis } from './renderers';
8
+ export function ScatterChart({ dataset, chartInfo, }) {
9
+ return (_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ScatterChartInternal, { children: [renderGrid(), renderXAxis(chartInfo.xAxis), renderYAxis(chartInfo.yAxis), _jsx(ZAxis, { type: "number", dataKey: chartInfo.zAxis.dataKey, range: chartInfo.zAxis.range, name: chartInfo.zAxis.name }), chartInfo.scatters.map((scatter, index) => {
13
10
  var _a, _b;
14
- return ((0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", name: scatter.dataLabel, data: dataset[(_a = scatter.dataIndex) !== null && _a !== void 0 ? _a : 0], dataKey: scatter.dataKey, fill: (_b = scatter.color) !== null && _b !== void 0 ? _b : constants_1.defaultColors[index] }, index));
15
- }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: false, content: (props) => {
11
+ return (_jsx(Scatter, { yAxisId: "left", name: scatter.dataLabel, data: dataset[(_a = scatter.dataIndex) !== null && _a !== void 0 ? _a : 0], dataKey: scatter.dataKey, fill: (_b = scatter.color) !== null && _b !== void 0 ? _b : defaultColors[index] }, index));
12
+ }), _jsx(Tooltip, { cursor: false, content: (props) => {
16
13
  var _a;
17
14
  if (!props.active || !((_a = props.payload) === null || _a === void 0 ? void 0 : _a.length)) {
18
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
15
+ return _jsx(_Fragment, {});
19
16
  }
20
- return ((0, jsx_runtime_1.jsx)(ScatterTooltipContent, { active: props.active, payload: props.payload, chartInfo: chartInfo, dataset: dataset }));
17
+ return (_jsx(ScatterTooltipContent, { active: props.active, payload: props.payload, chartInfo: chartInfo, dataset: dataset }));
21
18
  } })] }) }));
22
19
  }
23
20
  const ScatterTooltipContent = (props) => {
@@ -31,7 +28,7 @@ const ScatterTooltipContent = (props) => {
31
28
  const xValue = xPayload.value;
32
29
  const yValue = yPayload.value;
33
30
  const findKey = xValue + ':' + yValue;
34
- const items = (0, react_1.useMemo)(() => {
31
+ const items = useMemo(() => {
35
32
  var _a, _b, _c, _d;
36
33
  const _items = [];
37
34
  if (!xAxis.dataKey || !yAxis.dataKey || !zAxis.dataKey) {
@@ -54,7 +51,7 @@ const ScatterTooltipContent = (props) => {
54
51
  _items.push({
55
52
  name: scatter.dataLabel,
56
53
  value: zValue,
57
- color: (_d = scatter.color) !== null && _d !== void 0 ? _d : constants_1.defaultColors[i],
54
+ color: (_d = scatter.color) !== null && _d !== void 0 ? _d : defaultColors[i],
58
55
  });
59
56
  }
60
57
  return _items;
@@ -66,21 +63,21 @@ const ScatterTooltipContent = (props) => {
66
63
  yAxis.dataKey,
67
64
  zAxis.dataKey,
68
65
  ]);
69
- const xAxisFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
70
- const yAxisFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
71
- const zAxisFormatter = (0, formatters_1.createLongAxisFormatter)(zAxis.tick);
72
- return ((0, jsx_runtime_1.jsx)("div", { style: {
66
+ const xAxisFormatter = createLongAxisFormatter(xAxis.tick);
67
+ const yAxisFormatter = createLongAxisFormatter(yAxis.tick);
68
+ const zAxisFormatter = createLongAxisFormatter(zAxis.tick);
69
+ return (_jsx("div", { style: {
73
70
  display: 'flex',
74
71
  flexDirection: 'column',
75
- boxShadow: react_components_1.tokens.shadow16,
76
- backgroundColor: react_components_1.tokens.colorNeutralBackground1,
72
+ boxShadow: tokens.shadow16,
73
+ backgroundColor: tokens.colorNeutralBackground1,
77
74
  padding: 8,
78
75
  borderRadius: 4,
79
76
  gap: 4,
80
- }, 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: {
77
+ }, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: xAxis.name }), _jsx("div", { style: { flex: 1, minWidth: 50 } }), _jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: xAxisFormatter(xValue) })] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: yAxis.name }), _jsx("div", { style: { flex: 1, minWidth: 50 } }), _jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: yAxisFormatter(yValue) })] }), _jsx(Divider, { style: { opacity: 0.2 } }), items.map((item, index) => (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("div", { style: {
81
78
  width: 8,
82
79
  height: 8,
83
80
  background: item.color,
84
81
  borderRadius: 4,
85
- } }), (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)))] }) }));
82
+ } }), _jsx(Caption1, { style: { color: tokens.colorNeutralForeground4, marginLeft: 8 }, children: item.name }), _jsx("div", { style: { flex: 1, minWidth: 50 } }), _jsx(Caption1, { style: { color: tokens.colorNeutralForeground4 }, children: zAxisFormatter(item.value) })] }, index)))] }) }));
86
83
  };
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultColors = void 0;
4
- exports.defaultColors = [
1
+ export const defaultColors = [
5
2
  '#0088FE',
6
3
  '#00C49F',
7
4
  '#FFBB28',
@@ -1,12 +1,4 @@
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.formatNumber = exports.formatCurrency = exports.formatDate = exports.formatCurrencyWithSuffix = void 0;
7
- exports.createAxisFormatter = createAxisFormatter;
8
- exports.createLongAxisFormatter = createLongAxisFormatter;
9
- const dayjs_1 = __importDefault(require("dayjs"));
1
+ import dayjs from 'dayjs';
10
2
  function extractNumberInfo(value) {
11
3
  const suffix = ['K', 'M', 'B', 'T'];
12
4
  if (value === null || value === undefined) {
@@ -28,7 +20,7 @@ function extractNumberInfo(value) {
28
20
  };
29
21
  }
30
22
  }
31
- const formatCurrencyWithSuffix = (input, digit = 2) => {
23
+ export const formatCurrencyWithSuffix = (input, digit = 2) => {
32
24
  const suffix = ['K', 'M', 'B', 'T'];
33
25
  if (input === null || input === undefined) {
34
26
  return '';
@@ -37,21 +29,19 @@ const formatCurrencyWithSuffix = (input, digit = 2) => {
37
29
  const sign = Math.sign(input);
38
30
  if (abs >= 1000) {
39
31
  const i = Math.floor(Math.log(abs) / Math.log(1000));
40
- return ((0, exports.formatCurrency)(sign * (abs / Math.pow(1000, i)), digit) + suffix[i - 1]);
32
+ return (formatCurrency(sign * (abs / Math.pow(1000, i)), digit) + suffix[i - 1]);
41
33
  }
42
34
  else {
43
- return (0, exports.formatCurrency)(input, digit);
35
+ return formatCurrency(input, digit);
44
36
  }
45
37
  };
46
- exports.formatCurrencyWithSuffix = formatCurrencyWithSuffix;
47
- const formatDate = (input, format) => {
38
+ export const formatDate = (input, format) => {
48
39
  if (!input) {
49
40
  return '';
50
41
  }
51
- return (0, dayjs_1.default)(new Date(input)).format(format);
42
+ return dayjs(new Date(input)).format(format);
52
43
  };
53
- exports.formatDate = formatDate;
54
- const formatCurrency = (input, digit = 2) => {
44
+ export const formatCurrency = (input, digit = 2) => {
55
45
  var _a, _b;
56
46
  if (input === null || input === undefined) {
57
47
  return '';
@@ -66,8 +56,7 @@ const formatCurrency = (input, digit = 2) => {
66
56
  });
67
57
  return formatter.format(input || 0);
68
58
  };
69
- exports.formatCurrency = formatCurrency;
70
- const formatNumber = (input, digit = 2) => {
59
+ export const formatNumber = (input, digit = 2) => {
71
60
  var _a, _b;
72
61
  if (input === null || input === undefined) {
73
62
  return '';
@@ -80,7 +69,6 @@ const formatNumber = (input, digit = 2) => {
80
69
  });
81
70
  return formatter.format(input || 0);
82
71
  };
83
- exports.formatNumber = formatNumber;
84
72
  const timeAxisFormats = {
85
73
  minute: 'mm',
86
74
  hour: 'HH',
@@ -114,11 +102,11 @@ const timeLongAxisFormats = {
114
102
  // };
115
103
  function createTimeAxisFormatter(format) {
116
104
  const formatString = timeAxisFormats[format];
117
- return (value) => (0, exports.formatDate)(new Date(value), formatString);
105
+ return (value) => formatDate(new Date(value), formatString);
118
106
  }
119
107
  function createFullTimeAxisFormatter(format) {
120
108
  const formatString = timeLongAxisFormats[format];
121
- return (value) => (0, exports.formatDate)(new Date(value), formatString);
109
+ return (value) => formatDate(new Date(value), formatString);
122
110
  }
123
111
  function createNumberAxisFormatter(options) {
124
112
  return (value) => {
@@ -126,12 +114,12 @@ function createNumberAxisFormatter(options) {
126
114
  if (!info) {
127
115
  return '';
128
116
  }
129
- return (0, exports.formatNumber)(info.value, options) + info.symbol;
117
+ return formatNumber(info.value, options) + info.symbol;
130
118
  };
131
119
  }
132
120
  function createLongNumberAxisFormatter(options) {
133
121
  return (value) => {
134
- return (0, exports.formatNumber)(value, options);
122
+ return formatNumber(value, options);
135
123
  };
136
124
  }
137
125
  function createCurrencyAxisFormatter() {
@@ -140,7 +128,7 @@ function createCurrencyAxisFormatter() {
140
128
  if (!info) {
141
129
  return '';
142
130
  }
143
- return (0, exports.formatCurrency)(info.value, 0) + info.symbol;
131
+ return formatCurrency(info.value, 0) + info.symbol;
144
132
  };
145
133
  }
146
134
  function createCategoryAxisFormatter(options) {
@@ -154,7 +142,7 @@ function createCategoryAxisFormatter(options) {
154
142
  return typeof value === 'string' ? value : String(value);
155
143
  };
156
144
  }
157
- function createAxisFormatter(tick) {
145
+ export function createAxisFormatter(tick) {
158
146
  switch (tick.type) {
159
147
  case 'time':
160
148
  return createTimeAxisFormatter(tick.format);
@@ -165,12 +153,12 @@ function createAxisFormatter(tick) {
165
153
  case 'category':
166
154
  return createCategoryAxisFormatter(tick.options);
167
155
  case 'weekday':
168
- return (value) => (0, dayjs_1.default)().day(value).format('ddd');
156
+ return (value) => dayjs().day(value).format('ddd');
169
157
  default:
170
158
  return (value) => String(value);
171
159
  }
172
160
  }
173
- function createLongAxisFormatter(tick) {
161
+ export function createLongAxisFormatter(tick) {
174
162
  switch (tick.type) {
175
163
  case 'time':
176
164
  return createFullTimeAxisFormatter(tick.format);
@@ -181,7 +169,7 @@ function createLongAxisFormatter(tick) {
181
169
  case 'category':
182
170
  return createCategoryAxisFormatter(tick.options);
183
171
  case 'weekday':
184
- return ((value) => (0, dayjs_1.default)().day(value).format('dddd'));
172
+ return ((value) => dayjs().day(value).format('dddd'));
185
173
  default:
186
174
  return (value) => String(value);
187
175
  }
@@ -1,7 +1,6 @@
1
- "use strict";
2
1
  /* eslint-disable unused-imports/no-unused-vars */
3
2
  // TODO: Remove eslint disable condition after finishing the implementation
4
- Object.defineProperty(exports, "__esModule", { value: true });
3
+ export {};
5
4
  // number format - decimal or currency
6
5
  // number format - number of decimals
7
6
  // number format - group it (K, M, B, T)
@@ -1,65 +1,54 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderXAxis = renderXAxis;
4
- exports.renderYAxis = renderYAxis;
5
- exports.renderGrid = renderGrid;
6
- exports.renderLine = renderLine;
7
- exports.renderLines = renderLines;
8
- exports.renderArea = renderArea;
9
- exports.renderAreas = renderAreas;
10
- exports.renderBar = renderBar;
11
- exports.renderBars = renderBars;
12
- const jsx_runtime_1 = require("react/jsx-runtime");
13
- const react_components_1 = require("@fluentui/react-components");
14
- const recharts_1 = require("recharts");
15
- const formatters_1 = require("./formatters");
16
- function renderXAxis(axis, forceCategory = false) {
17
- const xAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
18
- return ((0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: axis.dataKey, name: axis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10,
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { tokens } from '@fluentui/react-components';
3
+ import { Area, Bar, CartesianGrid, Line, XAxis as XAxisInternal, YAxis as YAxisInternal, } from 'recharts';
4
+ import { createAxisFormatter } from './formatters';
5
+ export function renderXAxis(axis, forceCategory = false) {
6
+ const xAxisFormatter = createAxisFormatter(axis.tick);
7
+ return (_jsx(XAxisInternal, { dataKey: axis.dataKey, name: axis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10,
19
8
  // padding={{ left: 10, right: 10 }}
20
9
  padding: "gap", axisLine: {
21
- stroke: react_components_1.tokens.colorNeutralBackground6,
22
- }, fontSize: react_components_1.tokens.fontSizeBase100, tick: {
23
- fill: react_components_1.tokens.colorNeutralForeground1,
10
+ stroke: tokens.colorNeutralBackground6,
11
+ }, fontSize: tokens.fontSizeBase100, tick: {
12
+ fill: tokens.colorNeutralForeground1,
24
13
  opacity: 0.5,
25
14
  }, scale: !forceCategory && axis.tick.type === 'time' ? 'time' : 'auto', type: forceCategory || axis.tick.type === 'category' ? 'category' : 'number', domain: axis.domain, height: 16 }));
26
15
  }
27
- function renderYAxis(axis) {
28
- const yAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
29
- return ((0, jsx_runtime_1.jsx)(recharts_1.YAxis, { yAxisId: "left", dataKey: axis.dataKey, tickFormatter: yAxisFormatter, name: axis.name, tickLine: false, fontSize: react_components_1.tokens.fontSizeBase100, axisLine: false, tickMargin: 0, minTickGap: 0, accentHeight: 0, width: 40, scale: "auto", type: "number", domain: axis.domain, tick: {
30
- fill: react_components_1.tokens.colorNeutralForeground1,
16
+ export function renderYAxis(axis) {
17
+ const yAxisFormatter = createAxisFormatter(axis.tick);
18
+ return (_jsx(YAxisInternal, { yAxisId: "left", dataKey: axis.dataKey, tickFormatter: yAxisFormatter, name: axis.name, tickLine: false, fontSize: tokens.fontSizeBase100, axisLine: false, tickMargin: 0, minTickGap: 0, accentHeight: 0, width: 40, scale: "auto", type: "number", domain: axis.domain, tick: {
19
+ fill: tokens.colorNeutralForeground1,
31
20
  opacity: 0.5,
32
21
  } }));
33
22
  }
34
- function renderGrid() {
35
- return ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { strokeDasharray: "8 4", vertical: false, strokeWidth: 0.2, stroke: react_components_1.tokens.colorNeutralBackground6 }));
23
+ export function renderGrid() {
24
+ return (_jsx(CartesianGrid, { strokeDasharray: "8 4", vertical: false, strokeWidth: 0.2, stroke: tokens.colorNeutralBackground6 }));
36
25
  }
37
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- function renderLine(line, dataset) {
27
+ export function renderLine(line, dataset) {
39
28
  var _a;
40
- return ((0, jsx_runtime_1.jsx)(recharts_1.Line, { yAxisId: 'left', type: line.curveType, data: dataset[(_a = line.dataIndex) !== null && _a !== void 0 ? _a : 0], dataKey: line.dataKey, name: line.dataLabel, stroke: line.color, strokeWidth: 2, dot: false, activeDot: {
29
+ return (_jsx(Line, { yAxisId: 'left', type: line.curveType, data: dataset[(_a = line.dataIndex) !== null && _a !== void 0 ? _a : 0], dataKey: line.dataKey, name: line.dataLabel, stroke: line.color, strokeWidth: 2, dot: false, activeDot: {
41
30
  stroke: line.color,
42
31
  } }, line.dataKey));
43
32
  }
44
33
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- function renderLines(lines, dataset) {
34
+ export function renderLines(lines, dataset) {
46
35
  return lines.map((line) => renderLine(line, dataset));
47
36
  }
48
37
  // eslint-disable-next-line unused-imports/no-unused-vars
49
- function renderArea(area, dataset) {
50
- return ((0, jsx_runtime_1.jsx)(recharts_1.Area, { yAxisId: 'left', type: area.curveType, dataKey: area.dataKey, name: area.dataLabel, stroke: area.color, fill: area.color, strokeWidth: 1, dot: false, activeDot: {
38
+ export function renderArea(area, dataset) {
39
+ return (_jsx(Area, { yAxisId: 'left', type: area.curveType, dataKey: area.dataKey, name: area.dataLabel, stroke: area.color, fill: area.color, strokeWidth: 1, dot: false, activeDot: {
51
40
  stroke: area.color,
52
41
  } }, area.dataKey));
53
42
  }
54
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- function renderAreas(areas, dataset) {
44
+ export function renderAreas(areas, dataset) {
56
45
  return areas.map((area) => renderArea(area, dataset));
57
46
  }
58
47
  // eslint-disable-next-line unused-imports/no-unused-vars
59
- function renderBar(bar, dataset) {
60
- return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { yAxisId: 'left', type: bar.curveType, dataKey: bar.dataKey, name: bar.dataLabel, stroke: bar.color, fill: bar.color, strokeWidth: 1, stackId: bar.stackId }, bar.dataKey));
48
+ export function renderBar(bar, dataset) {
49
+ return (_jsx(Bar, { yAxisId: 'left', type: bar.curveType, dataKey: bar.dataKey, name: bar.dataLabel, stroke: bar.color, fill: bar.color, strokeWidth: 1, stackId: bar.stackId }, bar.dataKey));
61
50
  }
62
51
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- function renderBars(bars, dataset) {
52
+ export function renderBars(bars, dataset) {
64
53
  return bars.map((bar) => renderBar(bar, dataset));
65
54
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,24 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.useQueriesData = useQueriesData;
16
- const insights_1 = require("@headless-adminapp/app/insights");
17
- const mutable_1 = require("@headless-adminapp/app/mutable");
18
- const transport_1 = require("@headless-adminapp/app/transport");
19
- const widget_1 = require("@headless-adminapp/app/widget");
20
- const transport_2 = require("@headless-adminapp/core/transport");
21
- const react_query_1 = require("@tanstack/react-query");
22
- const dayjs_1 = __importDefault(require("dayjs"));
23
- const react_1 = require("react");
24
- function useQueriesData(queries) {
25
- const dataService = (0, transport_1.useDataService)();
26
- const insightsState = (0, mutable_1.useContextSelector)(insights_1.InsightsContext, (state) => state);
27
- const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
28
- const resolvedQueries = (0, react_1.useMemo)(() => {
10
+ import { InsightsContext } from '@headless-adminapp/app/insights';
11
+ import { useContextSelector } from '@headless-adminapp/app/mutable';
12
+ import { useDataService } from '@headless-adminapp/app/transport';
13
+ import { WidgetContext } from '@headless-adminapp/app/widget';
14
+ import { AggregateAttributeFunction, } from '@headless-adminapp/core/transport';
15
+ import { useQueries } from '@tanstack/react-query';
16
+ import dayjs from 'dayjs';
17
+ import { useMemo } from 'react';
18
+ export function useQueriesData(queries) {
19
+ const dataService = useDataService();
20
+ const insightsState = useContextSelector(InsightsContext, (state) => state);
21
+ const widgetState = useContextSelector(WidgetContext, (state) => state);
22
+ const resolvedQueries = useMemo(() => {
29
23
  return queries.map((item) => {
30
24
  if (typeof item === 'function') {
31
25
  console.log('temp.item', item, item(insightsState, widgetState));
@@ -34,7 +28,7 @@ function useQueriesData(queries) {
34
28
  return item;
35
29
  });
36
30
  }, [queries, insightsState, widgetState]);
37
- const result = (0, react_query_1.useQueries)({
31
+ const result = useQueries({
38
32
  queries: resolvedQueries.map((item) => ({
39
33
  queryKey: ['insights', 'aggregate', item],
40
34
  queryFn: () => __awaiter(this, void 0, void 0, function* () {
@@ -57,7 +51,7 @@ function useQueriesData(queries) {
57
51
  const isPending = result.some((r) => r.isPending);
58
52
  const isFetching = result.some((r) => r.isFetching);
59
53
  const refetch = () => result.map((r) => r.refetch());
60
- const data = (0, react_1.useMemo)(() => {
54
+ const data = useMemo(() => {
61
55
  return result.map((r) => r.data);
62
56
  }, [result]);
63
57
  return { isPending, isFetching, dataset: data, refetch };
@@ -78,19 +72,19 @@ function getAttributeValueTransformer(attribute) {
78
72
  let transformer = undefined;
79
73
  if (attribute.type === 'date') {
80
74
  if (attribute.format) {
81
- transformer = (value) => (0, dayjs_1.default)(value, attribute.format)
75
+ transformer = (value) => dayjs(value, attribute.format)
82
76
  .toDate()
83
77
  .getTime();
84
78
  }
85
79
  else if (attribute.value.type === 'function') {
86
- if (attribute.value.value === transport_2.AggregateAttributeFunction.YearMonth) {
87
- transformer = (value) => (0, dayjs_1.default)(value, 'YYYY-MM')
80
+ if (attribute.value.value === AggregateAttributeFunction.YearMonth) {
81
+ transformer = (value) => dayjs(value, 'YYYY-MM')
88
82
  .toDate()
89
83
  .getTime();
90
84
  }
91
85
  }
92
86
  else {
93
- transformer = (value) => (0, dayjs_1.default)(value)
87
+ transformer = (value) => dayjs(value)
94
88
  .toDate()
95
89
  .getTime();
96
90
  }
@@ -1,24 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useWidgetDetail = useWidgetDetail;
4
- const command_1 = require("@headless-adminapp/app/command");
5
- const hooks_1 = require("@headless-adminapp/app/command/hooks");
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 useQueriesData_1 = require("./useQueriesData");
10
- function useWidgetDetail(widgetContent) {
11
- const widgetState = (0, mutable_1.useContextSelector)(widget_1.WidgetContext, (state) => state);
1
+ import { useCommands } from '@headless-adminapp/app/command';
2
+ import { useBaseCommandHandlerContext } from '@headless-adminapp/app/command/hooks';
3
+ import { useContextSelector, useContextSetValue, } from '@headless-adminapp/app/mutable';
4
+ import { WidgetContext } from '@headless-adminapp/app/widget';
5
+ import { useCallback } from 'react';
6
+ import { useQueriesData } from './useQueriesData';
7
+ export function useWidgetDetail(widgetContent) {
8
+ const widgetState = useContextSelector(WidgetContext, (state) => state);
12
9
  const widget = widgetState.widget;
13
- const widgetSetValue = (0, mutable_1.useContextSetValue)(widget_1.WidgetContext);
14
- const { dataset, isPending, isFetching, refetch } = (0, useQueriesData_1.useQueriesData)(widget.dataset);
15
- const baseCommandHandleContext = (0, hooks_1.useBaseCommandHandlerContext)();
16
- const updateStateValue = (0, react_1.useCallback)(
10
+ const widgetSetValue = useContextSetValue(WidgetContext);
11
+ const { dataset, isPending, isFetching, refetch } = useQueriesData(widget.dataset);
12
+ const baseCommandHandleContext = useBaseCommandHandlerContext();
13
+ const updateStateValue = useCallback(
17
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
15
  (value) => {
19
16
  widgetSetValue((state) => (Object.assign(Object.assign({}, state), { data: Object.assign(Object.assign({}, state.data), value) })));
20
17
  }, [widgetSetValue]);
21
- const transformedCommands = (0, command_1.useCommands)([widgetContent.commands], Object.assign(Object.assign({}, baseCommandHandleContext), { primaryControl: {
18
+ const transformedCommands = useCommands([widgetContent.commands], Object.assign(Object.assign({}, baseCommandHandleContext), { primaryControl: {
22
19
  refresh: refetch,
23
20
  updateStateValue,
24
21
  } }));