@tenancy.nz/feature-ui 1.10.6 → 1.10.8

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 (43) hide show
  1. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.cjs +15 -4
  2. package/dist/cjs/components/BackButton.cjs +18 -0
  3. package/dist/cjs/components/ConfirmButton.cjs +91 -0
  4. package/dist/cjs/components/ContactCard.cjs +71 -0
  5. package/dist/cjs/components/ContactCardHeader.cjs +17 -22
  6. package/dist/cjs/components/ContactMethod.cjs +111 -0
  7. package/dist/cjs/components/DeleteIconButton.cjs +17 -0
  8. package/dist/cjs/components/DownloadIconButton.cjs +17 -0
  9. package/dist/cjs/components/EditIconButton.cjs +17 -0
  10. package/dist/cjs/components/LogoutButton.cjs +17 -0
  11. package/dist/cjs/components/OpenInNewIconButton.cjs +17 -0
  12. package/dist/cjs/components/ScrollTopButton.cjs +2 -1
  13. package/dist/cjs/index.cjs +20 -10
  14. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +14 -5
  15. package/dist/esm/components/BackButton.js +14 -0
  16. package/dist/esm/components/ConfirmButton.js +87 -0
  17. package/dist/esm/components/ContactCard.js +68 -0
  18. package/dist/esm/components/ContactCardHeader.js +18 -23
  19. package/dist/esm/components/ContactMethod.js +107 -0
  20. package/dist/esm/components/DeleteIconButton.js +13 -0
  21. package/dist/esm/components/DownloadIconButton.js +13 -0
  22. package/dist/esm/components/EditIconButton.js +13 -0
  23. package/dist/esm/components/LogoutButton.js +13 -0
  24. package/dist/esm/components/OpenInNewIconButton.js +13 -0
  25. package/dist/esm/components/ScrollTopButton.js +2 -1
  26. package/dist/esm/index.js +10 -5
  27. package/package.json +5 -7
  28. package/dist/cjs/components/AnalyticsSection.cjs +0 -186
  29. package/dist/cjs/components/BookingChart.cjs +0 -128
  30. package/dist/cjs/components/BookingChart.styled.cjs +0 -48
  31. package/dist/cjs/components/ChartLegend.cjs +0 -63
  32. package/dist/cjs/components/analytics-doughnut-chart.cjs +0 -116
  33. package/dist/cjs/components/doughnut-chart.cjs +0 -130
  34. package/dist/cjs/components/pdf-analytics-section.cjs +0 -173
  35. package/dist/cjs/utils/helpers/general.cjs +0 -10
  36. package/dist/esm/components/AnalyticsSection.js +0 -182
  37. package/dist/esm/components/BookingChart.js +0 -124
  38. package/dist/esm/components/BookingChart.styled.js +0 -42
  39. package/dist/esm/components/ChartLegend.js +0 -59
  40. package/dist/esm/components/analytics-doughnut-chart.js +0 -112
  41. package/dist/esm/components/doughnut-chart.js +0 -126
  42. package/dist/esm/components/pdf-analytics-section.js +0 -169
  43. package/dist/esm/utils/helpers/general.js +0 -8
@@ -1,182 +0,0 @@
1
- import React from 'react';
2
- import { uid } from 'react-uid';
3
- import Stack from '@mui/material/Stack';
4
- import useMediaQuery from '@mui/material/useMediaQuery';
5
- import { Paper, Text, Grid } from '@tenancy.nz/ui';
6
- import AnalyticsBox from './AnalyticsBox.js';
7
- import AnalyticsDoughnutChart from './analytics-doughnut-chart.js';
8
-
9
- function AnalyticsSection(_ref) {
10
- var viewingsCount = _ref.viewingsCount,
11
- bookingsCount = _ref.bookingsCount,
12
- attendeesCount = _ref.attendeesCount,
13
- cancellationsCount = _ref.cancellationsCount,
14
- applicationsCount = _ref.applicationsCount,
15
- averageRent = _ref.averageRent,
16
- textUsage = _ref.textUsage,
17
- agreementsCount = _ref.agreementsCount,
18
- agreementsFinalisedCount = _ref.agreementsFinalisedCount,
19
- filterDaysCount = _ref.filterDaysCount,
20
- allHouseEnquiriesCount = _ref.allHouseEnquiriesCount,
21
- bookMeEnquiriesCount = _ref.bookMeEnquiriesCount,
22
- oneRoofEnquiriesCount = _ref.oneRoofEnquiriesCount,
23
- realestateEnquiriesCount = _ref.realestateEnquiriesCount,
24
- tradeMeEnquiriesCount = _ref.tradeMeEnquiriesCount,
25
- manualEnquiryCount = _ref.manualEnquiryCount,
26
- websiteEnquiriesCount = _ref.websiteEnquiriesCount,
27
- allHouseBookingsCount = _ref.allHouseBookingsCount,
28
- bookMeBookingsCount = _ref.bookMeBookingsCount,
29
- oneRoofBookingsCount = _ref.oneRoofBookingsCount,
30
- realestateBookingsCount = _ref.realestateBookingsCount,
31
- tradeMeBookingsCount = _ref.tradeMeBookingsCount,
32
- manualBookingsCount = _ref.manualBookingsCount,
33
- websiteBookingsCount = _ref.websiteBookingsCount,
34
- _ref$outlinedItems = _ref.outlinedItems,
35
- outlinedItems = _ref$outlinedItems === void 0 ? false : _ref$outlinedItems;
36
- var isXlUp = useMediaQuery(function (theme) {
37
- return theme.breakpoints.up("xl");
38
- });
39
- var stats = [{
40
- label: "Viewings",
41
- value: viewingsCount
42
- }, {
43
- label: "Bookings",
44
- value: bookingsCount
45
- }, {
46
- label: "Attendees",
47
- value: attendeesCount
48
- }, {
49
- label: "Cancellations",
50
- value: cancellationsCount
51
- }, {
52
- label: "Applications",
53
- value: applicationsCount
54
- }, {
55
- label: "Average Rent",
56
- value: "$".concat(averageRent)
57
- }, {
58
- label: "Text Usage Total",
59
- value: textUsage
60
- }];
61
- return /* @__PURE__ */React.createElement(Stack, {
62
- gap: 6
63
- }, /* @__PURE__ */React.createElement(Stack, {
64
- flexDirection: "row",
65
- gap: 6,
66
- flexWrap: "wrap",
67
- alignItems: "stretch"
68
- }, /* @__PURE__ */React.createElement(Paper, {
69
- outlined: outlinedItems,
70
- inset: "medium",
71
- overflow: false,
72
- sx: {
73
- width: "100%",
74
- minWidth: {
75
- lg: "456px"
76
- },
77
- flex: {
78
- xs: "0 0 100%",
79
- md: 1
80
- },
81
- alignItems: "center",
82
- justifyContent: "center",
83
- display: "flex"
84
- }
85
- }, /* @__PURE__ */React.createElement(AnalyticsDoughnutChart, {
86
- tradeMeCount: tradeMeEnquiriesCount,
87
- bookMeCount: bookMeEnquiriesCount,
88
- manualCount: manualEnquiryCount,
89
- allhouseCount: allHouseEnquiriesCount,
90
- oneRoofCount: oneRoofEnquiriesCount,
91
- realEstateCount: realestateEnquiriesCount,
92
- websiteCount: websiteEnquiriesCount,
93
- heading: "Number of enquiries"
94
- })), /* @__PURE__ */React.createElement(Paper, {
95
- outlined: outlinedItems,
96
- inset: "medium",
97
- overflow: false,
98
- sx: {
99
- width: "100%",
100
- minWidth: {
101
- lg: "456px"
102
- },
103
- flex: {
104
- xs: "0 0 100%",
105
- md: 1
106
- },
107
- alignItems: "center",
108
- justifyContent: "center",
109
- display: "flex"
110
- }
111
- }, /* @__PURE__ */React.createElement(AnalyticsDoughnutChart, {
112
- tradeMeCount: tradeMeBookingsCount,
113
- bookMeCount: bookMeBookingsCount,
114
- manualCount: manualBookingsCount,
115
- allhouseCount: allHouseBookingsCount,
116
- oneRoofCount: oneRoofBookingsCount,
117
- realEstateCount: realestateBookingsCount,
118
- websiteCount: websiteBookingsCount,
119
- heading: "Number of bookings"
120
- })), /* @__PURE__ */React.createElement(Stack, {
121
- gap: {
122
- xs: 3,
123
- md: 6
124
- },
125
- justifyContent: "space-between",
126
- sx: {
127
- flexDirection: {
128
- xs: "row",
129
- lg: "column"
130
- },
131
- flex: {
132
- sm: "0 0 100%",
133
- lg: "0 0 284px"
134
- }
135
- }
136
- }, /* @__PURE__ */React.createElement(AnalyticsBox, {
137
- outlined: outlinedItems,
138
- label: /* @__PURE__ */React.createElement("strong", null, "Converted Properties"),
139
- amount: agreementsCount,
140
- width: "100%",
141
- height: isXlUp ? "157px" : "auto",
142
- text: /* @__PURE__ */React.createElement(Text, {
143
- as: "span",
144
- variant: "inherit"
145
- }, "Properties that have had a viewing in the last", " ", /* @__PURE__ */React.createElement("strong", null, filterDaysCount), " days where an agreement has been ", /* @__PURE__ */React.createElement("strong", null, "created"))
146
- }), /* @__PURE__ */React.createElement(AnalyticsBox, {
147
- outlined: outlinedItems,
148
- label: /* @__PURE__ */React.createElement("strong", null, "Converted Properties"),
149
- amount: agreementsFinalisedCount,
150
- width: "100%",
151
- height: isXlUp ? "157px" : "auto",
152
- text: /* @__PURE__ */React.createElement(Text, {
153
- as: "span",
154
- variant: "inherit"
155
- }, "Properties that have had a viewing in the last", " ", /* @__PURE__ */React.createElement("strong", null, " ", filterDaysCount), " days where an agreement has been ", /* @__PURE__ */React.createElement("strong", null, "finalised"))
156
- })), /* @__PURE__ */React.createElement(Grid, {
157
- container: true,
158
- spacing: {
159
- xs: 3,
160
- md: 6
161
- }
162
- }, stats.map(function (stat, i) {
163
- return /* @__PURE__ */React.createElement(Grid, {
164
- item: true,
165
- key: uid(stat, i),
166
- flex: {
167
- lg: 1
168
- },
169
- xs: 6,
170
- sm: 3,
171
- md: 2
172
- }, /* @__PURE__ */React.createElement(AnalyticsBox, {
173
- outlined: outlinedItems,
174
- label: stat.label,
175
- amount: stat.value,
176
- width: "100%",
177
- height: isXlUp ? "157px" : "124px"
178
- }));
179
- }))));
180
- }
181
-
182
- export { AnalyticsSection as default };
@@ -1,124 +0,0 @@
1
- import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import React, { useMemo } from 'react';
3
- import { Box } from '@tenancy.nz/ui';
4
- import { Chart } from 'primereact/chart.js';
5
- import { StyledBookingChartStack, StyledBookingChartLegend, StyledBookingChartButton } from './BookingChart.styled.js';
6
-
7
- var defaultOptions = {
8
- scaleFontColor: "black",
9
- legend: {
10
- display: false
11
- },
12
- plugins: {
13
- datalabels: {
14
- align: "centre",
15
- font: {
16
- weight: "700",
17
- size: 12,
18
- family: "Montserrat, sans-serif"
19
- },
20
- display: function display(ctx) {
21
- return ctx.dataset.data[ctx.dataIndex] > 0;
22
- }
23
- }
24
- },
25
- scales: {
26
- xAxes: [{
27
- gridLines: {
28
- labelString: "Date",
29
- display: false
30
- },
31
- ticks: {
32
- fontSize: 13,
33
- family: "Montserrat, sans-serif",
34
- fontWeight: "bold"
35
- },
36
- stacked: true
37
- }],
38
- yAxes: [{
39
- scaleLabel: {
40
- display: true,
41
- labelString: "Total bookings",
42
- fontFamily: "Montserrat, sans-serif",
43
- fontSize: 13,
44
- fontStyle: "600"
45
- },
46
- ticks: {
47
- min: 0,
48
- stepSize: 5,
49
- fontSize: 13,
50
- fontWeight: 500
51
- },
52
- gridLines: {
53
- display: false
54
- },
55
- stacked: true
56
- }]
57
- }
58
- };
59
- function BookingChart(_ref) {
60
- var data = _ref.data,
61
- labels = _ref.labels,
62
- _ref$mode = _ref.mode,
63
- mode = _ref$mode === void 0 ? "day" : _ref$mode,
64
- _ref$options = _ref.options,
65
- options = _ref$options === void 0 ? {} : _ref$options,
66
- _ref$onModeChange = _ref.onModeChange,
67
- onModeChange = _ref$onModeChange === void 0 ? void 0 : _ref$onModeChange;
68
- var legends = useMemo(function () {
69
- return data.map(function (_ref2) {
70
- var label = _ref2.label,
71
- backgroundColor = _ref2.backgroundColor;
72
- return [label, backgroundColor];
73
- }).filter(function (_ref3, i, items) {
74
- var _ref4 = _slicedToArray(_ref3, 1),
75
- label = _ref4[0];
76
- return items.findIndex(function (_ref5) {
77
- var _ref6 = _slicedToArray(_ref5, 1),
78
- l = _ref6[0];
79
- return l === label;
80
- }) === i;
81
- });
82
- }, [data]);
83
- return /* @__PURE__ */React.createElement(Box, {
84
- display: "flex",
85
- direction: "column",
86
- gap: "16px",
87
- width: "100%"
88
- }, legends.length > 0 && /* @__PURE__ */React.createElement(StyledBookingChartStack, null, legends.map(function (_ref7) {
89
- var _ref8 = _slicedToArray(_ref7, 2),
90
- label = _ref8[0],
91
- backgroundColor = _ref8[1];
92
- return /* @__PURE__ */React.createElement(StyledBookingChartLegend, {
93
- key: label,
94
- color: backgroundColor
95
- }, label);
96
- })), /* @__PURE__ */React.createElement(Box, {
97
- sx: {
98
- position: "relative",
99
- width: "100%",
100
- overflow: "hidden"
101
- }
102
- }, /* @__PURE__ */React.createElement(Chart, {
103
- type: "bar",
104
- data: {
105
- labels: labels,
106
- datasets: data
107
- },
108
- options: _objectSpread2(_objectSpread2({}, defaultOptions), options)
109
- })), onModeChange && /* @__PURE__ */React.createElement(StyledBookingChartStack, null, /* @__PURE__ */React.createElement(StyledBookingChartButton, {
110
- onClick: onModeChange,
111
- active: mode === "day",
112
- value: "day"
113
- }, "Day"), /* @__PURE__ */React.createElement(StyledBookingChartButton, {
114
- onClick: onModeChange,
115
- active: mode === "week",
116
- value: "week"
117
- }, "Week"), /* @__PURE__ */React.createElement(StyledBookingChartButton, {
118
- onClick: onModeChange,
119
- active: mode === "month",
120
- value: "month"
121
- }, "Month")));
122
- }
123
-
124
- export { BookingChart as default };
@@ -1,42 +0,0 @@
1
- import { taggedTemplateLiteral as _taggedTemplateLiteral } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { css } from '@emotion/react';
3
- import styled from '@emotion/styled';
4
-
5
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
6
- var StyledBookingChartStack = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 0;\n margin: 0;\n list-style: none;\n font-size: 12px;\n justify-content: center;\n color: #000;\n width: 100%;\n"])));
7
- var StyledBookingChartLegend = styled("span", {
8
- shouldForwardProp: function shouldForwardProp(prop) {
9
- return !["color"].includes(prop);
10
- }
11
- })(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 6px;\n\n &::before {\n content: '';\n display: inline-flex;\n width: 32px;\n height: 18px;\n background-color: ", ";\n border-radius: 4px;\n }\n"])), function (props) {
12
- return props.color;
13
- });
14
- var StyledBookingChartButton = styled("button", {
15
- shouldForwardProp: function shouldForwardProp(prop) {
16
- return !["color"].includes(prop);
17
- }
18
- })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n && {\n font-weight: 500;\n display: flex;\n align-items: center;\n padding: 6px 10px;\n font-size: 14px;\n border-radius: 4px;\n font-family: inherit;\n color: ", ";\n border: 1px solid ", ";\n box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);\n background-color: ", ";\n cursor: pointer;\n\n &:hover {\n background-color: ", ";\n }\n }\n"])), function (_ref) {
19
- var theme = _ref.theme;
20
- return theme.palette.primary.main;
21
- }, function (_ref2) {
22
- var theme = _ref2.theme;
23
- return theme.palette.primary.main;
24
- }, function (_ref3) {
25
- var active = _ref3.active,
26
- theme = _ref3.theme;
27
- return active ? "#CEF3ED" : theme.palette.background.paper;
28
- }, function (_ref4) {
29
- var active = _ref4.active,
30
- theme = _ref4.theme;
31
- return !active ? theme.palette.grey[100] : null;
32
- });
33
- var StyledPropertyDetailsBox = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n width: 100%;\n align-items: flex-start;\n padding: 16px 24px 16px 20px;\n flex-direction: column;\n\n ", "\n\n @media print {\n flex-direction: row;\n align-items: center;\n }\n"])), function (_ref5) {
34
- var theme = _ref5.theme;
35
- return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", " {\n flex-direction: row;\n align-items: center;\n }\n "])), theme.breakpoints.up("sm"));
36
- });
37
- var StyledPropertyAmenitiesBox = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding-right: 25px;\n display: flex;\n flex-direction: column;\n margin-top: 5px;\n\n gap: 18px;\n min-width: 170px;\n height: 100%;\n justify-content: space-between;\n\n ", "\n\n @media print {\n align-items: flex-end;\n }\n"])), function (_ref6) {
38
- var theme = _ref6.theme;
39
- return "\n @media (min-width: ".concat(theme.breakpoints.values.md, "px) {\n align-items: flex-end;\n }\n ");
40
- });
41
-
42
- export { StyledBookingChartButton, StyledBookingChartLegend, StyledBookingChartStack, StyledPropertyAmenitiesBox, StyledPropertyDetailsBox };
@@ -1,59 +0,0 @@
1
- import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import React from 'react';
3
- import Stack from '@mui/material/Stack';
4
- import { Box, Text } from '@tenancy.nz/ui';
5
-
6
- function ChartLegend(_ref) {
7
- var _ref$color = _ref.color,
8
- color = _ref$color === void 0 ? void 0 : _ref$color,
9
- _ref$count = _ref.count,
10
- count = _ref$count === void 0 ? void 0 : _ref$count,
11
- label = _ref.label,
12
- _ref$sx = _ref.sx,
13
- sx = _ref$sx === void 0 ? {} : _ref$sx;
14
- return /* @__PURE__ */React.createElement(Stack, {
15
- flexDirection: "row",
16
- alignItems: "center",
17
- gap: 1.5,
18
- sx: _objectSpread2(_objectSpread2({}, sx), {}, {
19
- userSelect: "none",
20
- fontSize: {
21
- xs: "8px",
22
- md: "12px"
23
- }
24
- })
25
- }, /* @__PURE__ */React.createElement(Box, {
26
- bgcolor: color || "#D9D9D9",
27
- sx: {
28
- width: {
29
- xs: "20px",
30
- md: "32px"
31
- },
32
- height: {
33
- xs: "12px",
34
- md: "18px"
35
- },
36
- borderRadius: {
37
- xs: "2px",
38
- md: "4px"
39
- }
40
- }
41
- }), /* @__PURE__ */React.createElement(Box, {
42
- xs: {
43
- minWidth: {
44
- xs: "20px",
45
- md: "24px"
46
- }
47
- }
48
- }, count !== void 0 && count >= 0 && /* @__PURE__ */React.createElement(Text, {
49
- align: "center",
50
- weight: "700",
51
- variant: "inherit"
52
- }, count)), typeof label !== "string" ? label : /* @__PURE__ */React.createElement(Text, {
53
- weight: "500",
54
- variant: "inherit",
55
- color: "primary"
56
- }, label));
57
- }
58
-
59
- export { ChartLegend as default };
@@ -1,112 +0,0 @@
1
- import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import React from 'react';
3
- import DoughnutChart from './doughnut-chart.js';
4
- import PartnerLogo from './partner-logo.js';
5
- import { parseChartCount } from '../utils/helpers/general.js';
6
-
7
- var _excluded = ["bookMeCount", "oneRoofCount", "realEstateCount", "tradeMeCount", "manualCount", "websiteCount", "heading"];
8
- function AnalyticsDoughnutChart(_ref) {
9
- var _ref$bookMeCount = _ref.bookMeCount,
10
- bookMeCount = _ref$bookMeCount === void 0 ? 0 : _ref$bookMeCount,
11
- _ref$oneRoofCount = _ref.oneRoofCount,
12
- oneRoofCount = _ref$oneRoofCount === void 0 ? 0 : _ref$oneRoofCount,
13
- _ref$realEstateCount = _ref.realEstateCount,
14
- realEstateCount = _ref$realEstateCount === void 0 ? 0 : _ref$realEstateCount,
15
- _ref$tradeMeCount = _ref.tradeMeCount,
16
- tradeMeCount = _ref$tradeMeCount === void 0 ? 0 : _ref$tradeMeCount,
17
- _ref$manualCount = _ref.manualCount,
18
- manualCount = _ref$manualCount === void 0 ? 0 : _ref$manualCount,
19
- _ref$websiteCount = _ref.websiteCount,
20
- websiteCount = _ref$websiteCount === void 0 ? 0 : _ref$websiteCount,
21
- _ref$heading = _ref.heading,
22
- heading = _ref$heading === void 0 ? void 0 : _ref$heading,
23
- rest = _objectWithoutProperties(_ref, _excluded);
24
- var data = [{
25
- color: "#0CC1A3",
26
- count: parseChartCount(bookMeCount),
27
- slug: "bookme",
28
- title: "Tenant Portal"
29
- },
30
- // {
31
- // color: '#000000',
32
- // count: parseChartCount(allhouseCount),
33
- // slug: 'allhouse',
34
- // title: 'Allhouse',
35
- // logo: (
36
- // <PartnerLogo
37
- // name="allhouse"
38
- // width={{xs: '48px', md: '59px'}}
39
- // height={{xs: '12px', md: '14px'}}
40
- // />
41
- // ),
42
- // },
43
- {
44
- color: "#FF8500",
45
- count: parseChartCount(oneRoofCount),
46
- slug: "oneroof",
47
- title: "OneRoof",
48
- logo: /* @__PURE__ */React.createElement(PartnerLogo, {
49
- name: "oneroof",
50
- width: {
51
- xs: "52px",
52
- md: "66px"
53
- },
54
- height: {
55
- xs: "",
56
- md: "12px"
57
- }
58
- })
59
- }, {
60
- color: "#0098FF",
61
- count: parseChartCount(realEstateCount),
62
- slug: "realestate",
63
- title: "realestate.co.nz",
64
- logo: /* @__PURE__ */React.createElement(PartnerLogo, {
65
- name: "realestate",
66
- width: {
67
- xs: "72px",
68
- md: "92px"
69
- },
70
- height: {
71
- xs: "12px",
72
- md: "14px"
73
- }
74
- })
75
- }, {
76
- color: "#4854D3",
77
- count: parseChartCount(tradeMeCount),
78
- slug: "trademe",
79
- title: "Trade Me",
80
- logo: /* @__PURE__ */React.createElement(PartnerLogo, {
81
- name: "trademe",
82
- width: {
83
- xs: "64px",
84
- md: "90px"
85
- },
86
- height: {
87
- xs: "12px",
88
- md: "12px"
89
- }
90
- })
91
- }, {
92
- color: "#6D6D6D",
93
- count: parseChartCount(websiteCount),
94
- slug: "website",
95
- title: "Office Website"
96
- }, {
97
- color: "#D9D9D9",
98
- count: parseChartCount(manualCount),
99
- slug: "manual",
100
- title: "Manually Generated"
101
- }];
102
- return /* @__PURE__ */React.createElement(DoughnutChart, _objectSpread2({
103
- data: data,
104
- heading: heading,
105
- size: {
106
- xs: "100px",
107
- md: "165px"
108
- }
109
- }, rest));
110
- }
111
-
112
- export { AnalyticsDoughnutChart as default };
@@ -1,126 +0,0 @@
1
- import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import React from 'react';
3
- import { uid } from 'react-uid';
4
- import Stack from '@mui/material/Stack';
5
- import { Heading, Box } from '@tenancy.nz/ui';
6
- import { Chart } from 'primereact/chart.js';
7
- import ChartLegend from './ChartLegend.js';
8
-
9
- function DoughnutChart(_ref) {
10
- var data = _ref.data,
11
- _ref$heading = _ref.heading,
12
- heading = _ref$heading === void 0 ? void 0 : _ref$heading,
13
- _ref$chartProps = _ref.chartProps,
14
- chartProps = _ref$chartProps === void 0 ? {} : _ref$chartProps,
15
- _ref$size = _ref.size,
16
- size = _ref$size === void 0 ? "164px" : _ref$size;
17
- if (!Array.isArray(data) || data.length === 0) {
18
- return null;
19
- }
20
- var chartLabels = data.map(function (d) {
21
- return d.title;
22
- });
23
- var chartValues = data.map(function (d) {
24
- return d.count;
25
- });
26
- var chartColors = data.map(function (d) {
27
- return d.color;
28
- });
29
- return /* @__PURE__ */React.createElement(Stack, {
30
- sx: {
31
- position: "relative"
32
- },
33
- alignItems: "center",
34
- gap: 4
35
- }, heading && /* @__PURE__ */React.createElement(Heading, {
36
- as: "h4",
37
- color: "primary"
38
- }, heading), /* @__PURE__ */React.createElement(Stack, {
39
- flexDirection: "row",
40
- gap: {
41
- xs: 4,
42
- md: 12
43
- },
44
- alignItems: "center"
45
- }, /* @__PURE__ */React.createElement(Box, {
46
- overflow: "hidden",
47
- position: "relative",
48
- maxWidth: "100%",
49
- sx: {
50
- width: size,
51
- height: size,
52
- "&& > canvas": {
53
- width: "100%",
54
- height: "100%"
55
- }
56
- }
57
- }, /* @__PURE__ */React.createElement(Chart, _objectSpread2({
58
- type: "doughnut",
59
- data: {
60
- labels: chartLabels,
61
- datasets: [{
62
- data: chartValues,
63
- backgroundColor: chartColors,
64
- hoverBackgroundColor: chartColors,
65
- borderWidth: 0
66
- }]
67
- },
68
- options: {
69
- responsive: true,
70
- maintainAspectRatio: false,
71
- cutoutPercentage: 64,
72
- legend: {
73
- display: false
74
- },
75
- animation: {
76
- duration: 0
77
- },
78
- tooltips: {
79
- backgroundColor: "#0E0044",
80
- titleFontColor: "#fff",
81
- bodyFontColor: "#fff",
82
- xPadding: 8,
83
- yPadding: 8,
84
- bodyFontFamily: "Montserrat, sans-serif",
85
- bodyFontStyle: "semibold",
86
- bodyFontSize: 14,
87
- borderColor: "transparent",
88
- callbacks: {
89
- labelColor: function labelColor(tooltipItem, chart) {
90
- var dataset = chart.config.data.datasets[tooltipItem.datasetIndex];
91
- var color = dataset.backgroundColor[tooltipItem.index];
92
- return {
93
- borderColor: color,
94
- backgroundColor: color,
95
- borderWidth: 0,
96
- borderRadius: 5
97
- };
98
- },
99
- label: function label(_ref2) {
100
- var index = _ref2.index;
101
- return " ".concat(chartLabels[index], ": ").concat(parseInt(String(chartValues[index]), 10));
102
- }
103
- }
104
- }
105
- },
106
- style: {
107
- width: "100%",
108
- height: "100%"
109
- }
110
- }, chartProps))), /* @__PURE__ */React.createElement(Stack, {
111
- gap: 2
112
- }, data.map(function (item) {
113
- var color = item.color,
114
- count = item.count,
115
- title = item.title,
116
- logo = item.logo;
117
- return /* @__PURE__ */React.createElement(ChartLegend, {
118
- key: uid(item),
119
- color: color,
120
- count: parseInt(String(count), 10),
121
- label: logo || title
122
- });
123
- }))));
124
- }
125
-
126
- export { DoughnutChart as default };