@tenancy.nz/feature-ui 1.0.1 → 1.0.7

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 (39) hide show
  1. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.cjs +134 -0
  2. package/dist/cjs/components/AgentDetailsCard.cjs +80 -42
  3. package/dist/cjs/components/AnalyticsBox.cjs +46 -46
  4. package/dist/cjs/components/AnalyticsSection.cjs +148 -196
  5. package/dist/cjs/components/BookingChart.cjs +96 -94
  6. package/dist/cjs/components/BookingChart.styled.cjs +32 -86
  7. package/dist/cjs/components/BookingTable.cjs +39 -30
  8. package/dist/cjs/components/BookingTableRow.cjs +90 -46
  9. package/dist/cjs/components/BookingTableRow.styled.cjs +13 -34
  10. package/dist/cjs/components/BookingTableRowHeader.cjs +54 -15
  11. package/dist/cjs/components/BookingTableRowSkeleton.cjs +85 -18
  12. package/dist/cjs/components/CheckedIcon.cjs +11 -5
  13. package/dist/cjs/components/EnquiriesDoughnutChart.cjs +128 -151
  14. package/dist/cjs/components/GridList.cjs +59 -66
  15. package/dist/cjs/components/Hidden.cjs +4 -1
  16. package/dist/cjs/components/IconLabel.cjs +34 -26
  17. package/dist/cjs/components/NotesCard.cjs +48 -20
  18. package/dist/cjs/components/PropertyCard.cjs +130 -122
  19. package/dist/cjs/components/PropertyCard.styled.cjs +14 -66
  20. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +120 -0
  21. package/dist/esm/components/AgentDetailsCard.js +80 -42
  22. package/dist/esm/components/AnalyticsBox.js +46 -46
  23. package/dist/esm/components/AnalyticsSection.js +148 -196
  24. package/dist/esm/components/BookingChart.js +97 -95
  25. package/dist/esm/components/BookingChart.styled.js +32 -86
  26. package/dist/esm/components/BookingTable.js +39 -30
  27. package/dist/esm/components/BookingTableRow.js +90 -46
  28. package/dist/esm/components/BookingTableRow.styled.js +13 -34
  29. package/dist/esm/components/BookingTableRowHeader.js +54 -15
  30. package/dist/esm/components/BookingTableRowSkeleton.js +85 -18
  31. package/dist/esm/components/CheckedIcon.js +11 -5
  32. package/dist/esm/components/EnquiriesDoughnutChart.js +128 -151
  33. package/dist/esm/components/GridList.js +59 -66
  34. package/dist/esm/components/Hidden.js +4 -1
  35. package/dist/esm/components/IconLabel.js +34 -26
  36. package/dist/esm/components/NotesCard.js +48 -20
  37. package/dist/esm/components/PropertyCard.js +130 -122
  38. package/dist/esm/components/PropertyCard.styled.js +14 -66
  39. package/package.json +5 -5
@@ -1,54 +1,54 @@
1
1
  "use strict";
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import 'react';
2
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
3
+ import React from 'react';
4
4
  import { Paper, Box, Heading, Text } from '@tenancy.nz/ui';
5
5
 
6
- function AnalyticsBox({
7
- width,
8
- minWidth,
9
- maxWidth,
10
- height,
11
- border,
12
- label,
13
- amount,
14
- text,
15
- ...rest
16
- }) {
17
- return /* @__PURE__ */ jsx(
18
- Paper,
19
- {
20
- ...rest,
21
- sx: {
22
- maxWidth,
23
- width,
24
- minWidth,
25
- border,
26
- height: height || "100%",
27
- display: "flex",
28
- alignItems: "center",
29
- justifyContent: "center",
30
- padding: "16px"
6
+ var _excluded = ["width", "minWidth", "maxWidth", "height", "border", "label", "amount", "text"];
7
+ function AnalyticsBox(_ref) {
8
+ var width = _ref.width,
9
+ minWidth = _ref.minWidth,
10
+ maxWidth = _ref.maxWidth,
11
+ height = _ref.height,
12
+ border = _ref.border,
13
+ label = _ref.label,
14
+ amount = _ref.amount,
15
+ text = _ref.text,
16
+ rest = _objectWithoutProperties(_ref, _excluded);
17
+ return /* @__PURE__ */React.createElement(Paper, _objectSpread2(_objectSpread2({}, rest), {}, {
18
+ sx: {
19
+ maxWidth: maxWidth,
20
+ width: width,
21
+ minWidth: minWidth,
22
+ border: border,
23
+ height: height || "100%",
24
+ display: "flex",
25
+ alignItems: "center",
26
+ justifyContent: "center",
27
+ padding: "16px"
28
+ }
29
+ }), /* @__PURE__ */React.createElement(Box, null, /* @__PURE__ */React.createElement(Heading, {
30
+ align: "center",
31
+ weight: "700",
32
+ as: "h3",
33
+ gutterBottom: true
34
+ }, amount), /* @__PURE__ */React.createElement(Text, {
35
+ align: "center",
36
+ weight: "400",
37
+ variant: "body2"
38
+ }, label), text && /* @__PURE__ */React.createElement(Text, {
39
+ align: "center",
40
+ weight: "400",
41
+ sx: {
42
+ fontSize: {
43
+ xs: 8,
44
+ sm: 10,
45
+ xl: 14
31
46
  },
32
- children: /* @__PURE__ */ jsxs(Box, { children: [
33
- /* @__PURE__ */ jsx(Heading, { align: "center", weight: "700", as: "h3", gutterBottom: true, children: amount }),
34
- /* @__PURE__ */ jsx(Text, { align: "center", weight: "400", variant: "body2", children: label }),
35
- text && /* @__PURE__ */ jsx(
36
- Text,
37
- {
38
- align: "center",
39
- weight: "400",
40
- sx: {
41
- fontSize: { xs: 8, sm: 10, xl: 14 },
42
- lineHeight: "15.6px",
43
- maxWidth: "366px",
44
- mt: "8px"
45
- },
46
- children: text
47
- }
48
- )
49
- ] })
47
+ lineHeight: "15.6px",
48
+ maxWidth: "366px",
49
+ mt: "8px"
50
50
  }
51
- );
51
+ }, text)));
52
52
  }
53
53
 
54
54
  export { AnalyticsBox as default };
@@ -1,205 +1,157 @@
1
1
  "use strict";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import 'react';
2
+ import React from 'react';
4
3
  import { useMediaQuery, Box, Paper, Text } from '@tenancy.nz/ui';
5
4
  import AnalyticsBox from './AnalyticsBox.js';
6
5
  import EnquiriesDoughnutChart from './EnquiriesDoughnutChart.js';
7
6
 
8
- function AnalyticsSection({
9
- viewingsCount,
10
- bookingsCount,
11
- attendeesCount,
12
- cancellationsCount,
13
- applicationsCount,
14
- averageRent,
15
- textUsage,
16
- tradeMeEnquiriesCount,
17
- bookMeEnquiriesCount,
18
- manualEnquiryCount,
19
- agreementsCount,
20
- agreementsFinalisedCount,
21
- filterDaysCount
22
- }) {
23
- const isXlUp = useMediaQuery((theme) => theme.breakpoints.up("xl"));
24
- return /* @__PURE__ */ jsxs(
25
- Box,
26
- {
27
- display: "flex",
28
- align: "stretch",
29
- direction: { xs: "column-reverse", mlg: "row" },
30
- gap: "27px",
31
- children: [
32
- /* @__PURE__ */ jsx(Box, { width: "100%", maxWidth: { xs: "100%", mob: "340px", xl: "463px" }, children: /* @__PURE__ */ jsx(Paper, { style: { width: "100%", position: "relative", height: "100%" }, children: /* @__PURE__ */ jsx(Box, { mt: "20px", height: "100%", children: /* @__PURE__ */ jsx(
33
- EnquiriesDoughnutChart,
34
- {
35
- tradeMeEnquiriesCount,
36
- bookMeEnquiriesCount,
37
- manualEnquiryCount
38
- }
39
- ) }) }) }),
40
- /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsxs(Box, { display: "flex", direction: "row", width: "100%", gap: 6, children: [
41
- /* @__PURE__ */ jsxs(Box, { flex: 3, children: [
42
- /* @__PURE__ */ jsxs(Box, { display: "flex", gap: 6, children: [
43
- /* @__PURE__ */ jsx(
44
- AnalyticsBox,
45
- {
46
- label: "Viewings",
47
- amount: viewingsCount,
48
- width: "100%",
49
- height: isXlUp ? "157px" : "125px"
50
- }
51
- ),
52
- /* @__PURE__ */ jsx(
53
- AnalyticsBox,
54
- {
55
- label: "Bookings",
56
- amount: bookingsCount,
57
- width: "100%",
58
- height: isXlUp ? "157px" : "125px"
59
- }
60
- ),
61
- /* @__PURE__ */ jsx(
62
- AnalyticsBox,
63
- {
64
- label: "Attendees",
65
- amount: attendeesCount,
66
- width: "100%",
67
- border: "3px solid #6FD3C0",
68
- height: isXlUp ? "157px" : "125px"
69
- }
70
- )
71
- ] }),
72
- /* @__PURE__ */ jsxs(Box, { display: "flex", width: "100%", gap: 6, mt: 6, children: [
73
- /* @__PURE__ */ jsx(
74
- AnalyticsBox,
75
- {
76
- label: "Converted Properties",
77
- amount: agreementsCount,
78
- width: "100%",
79
- height: isXlUp ? "157px" : "125px",
80
- text: /* @__PURE__ */ jsxs(Box, { as: "span", maxWidth: "276px", children: [
81
- "Properties that have had a viewing in the last",
82
- " ",
83
- /* @__PURE__ */ jsx(
84
- Text,
85
- {
86
- as: "span",
87
- display: "inline",
88
- weight: "700",
89
- fontSize: "inherit",
90
- children: filterDaysCount
91
- }
92
- ),
93
- " ",
94
- "days where an agreement has been",
95
- " ",
96
- /* @__PURE__ */ jsx(
97
- Text,
98
- {
99
- as: "span",
100
- display: "inline",
101
- weight: "700",
102
- fontSize: "inherit",
103
- children: "created"
104
- }
105
- )
106
- ] })
107
- }
108
- ),
109
- /* @__PURE__ */ jsx(
110
- AnalyticsBox,
111
- {
112
- label: "Converted Properties",
113
- amount: agreementsFinalisedCount,
114
- width: "100%",
115
- height: isXlUp ? "157px" : "125px",
116
- text: /* @__PURE__ */ jsxs(Box, { as: "span", maxWidth: "276px", children: [
117
- "Properties that have had a viewing in the last",
118
- " ",
119
- /* @__PURE__ */ jsx(
120
- Text,
121
- {
122
- as: "span",
123
- display: "inline",
124
- weight: "700",
125
- fontSize: "inherit",
126
- children: filterDaysCount
127
- }
128
- ),
129
- " ",
130
- "days where an agreement has been",
131
- " ",
132
- /* @__PURE__ */ jsx(
133
- Text,
134
- {
135
- as: "span",
136
- display: "inline",
137
- weight: "700",
138
- fontSize: "inherit",
139
- children: "finalised"
140
- }
141
- )
142
- ] })
143
- }
144
- )
145
- ] })
146
- ] }),
147
- /* @__PURE__ */ jsxs(Box, { flex: 2, children: [
148
- /* @__PURE__ */ jsxs(Box, { display: "flex", gap: 6, children: [
149
- /* @__PURE__ */ jsx(
150
- AnalyticsBox,
151
- {
152
- label: "Cancellations",
153
- amount: cancellationsCount,
154
- width: "100%",
155
- border: "3px solid #ED0D8D",
156
- height: isXlUp ? "157px" : "125px"
157
- }
158
- ),
159
- /* @__PURE__ */ jsx(
160
- AnalyticsBox,
161
- {
162
- label: "Applications",
163
- amount: applicationsCount,
164
- width: "100%",
165
- border: "3px solid #F5C440",
166
- height: isXlUp ? "157px" : "125px"
167
- }
168
- )
169
- ] }),
170
- /* @__PURE__ */ jsxs(Box, { display: "flex", gap: 6, mt: 6, children: [
171
- /* @__PURE__ */ jsx(
172
- AnalyticsBox,
173
- {
174
- label: /* @__PURE__ */ jsxs("span", { children: [
175
- "Average",
176
- /* @__PURE__ */ jsx("br", {}),
177
- " Rent"
178
- ] }),
179
- amount: averageRent,
180
- width: "100%",
181
- height: isXlUp ? "157px" : "125px"
182
- }
183
- ),
184
- /* @__PURE__ */ jsx(
185
- AnalyticsBox,
186
- {
187
- label: /* @__PURE__ */ jsxs("span", { children: [
188
- "Text Usage",
189
- /* @__PURE__ */ jsx("br", {}),
190
- " Total"
191
- ] }),
192
- amount: textUsage,
193
- width: "100%",
194
- height: isXlUp ? "157px" : "125px"
195
- }
196
- )
197
- ] })
198
- ] })
199
- ] }) })
200
- ]
7
+ function AnalyticsSection(_ref) {
8
+ var viewingsCount = _ref.viewingsCount,
9
+ bookingsCount = _ref.bookingsCount,
10
+ attendeesCount = _ref.attendeesCount,
11
+ cancellationsCount = _ref.cancellationsCount,
12
+ applicationsCount = _ref.applicationsCount,
13
+ averageRent = _ref.averageRent,
14
+ textUsage = _ref.textUsage,
15
+ tradeMeEnquiriesCount = _ref.tradeMeEnquiriesCount,
16
+ bookMeEnquiriesCount = _ref.bookMeEnquiriesCount,
17
+ manualEnquiryCount = _ref.manualEnquiryCount,
18
+ agreementsCount = _ref.agreementsCount,
19
+ agreementsFinalisedCount = _ref.agreementsFinalisedCount,
20
+ filterDaysCount = _ref.filterDaysCount;
21
+ var isXlUp = useMediaQuery(function (theme) {
22
+ return theme.breakpoints.up("xl");
23
+ });
24
+ return /* @__PURE__ */React.createElement(Box, {
25
+ display: "flex",
26
+ align: "stretch",
27
+ direction: {
28
+ xs: "column-reverse",
29
+ mlg: "row"
30
+ },
31
+ gap: "27px"
32
+ }, /* @__PURE__ */React.createElement(Box, {
33
+ width: "100%",
34
+ maxWidth: {
35
+ xs: "100%",
36
+ mob: "340px",
37
+ xl: "463px"
201
38
  }
202
- );
39
+ }, /* @__PURE__ */React.createElement(Paper, {
40
+ style: {
41
+ width: "100%",
42
+ position: "relative",
43
+ height: "100%"
44
+ }
45
+ }, /* @__PURE__ */React.createElement(Box, {
46
+ mt: "20px",
47
+ height: "100%"
48
+ }, /* @__PURE__ */React.createElement(EnquiriesDoughnutChart, {
49
+ tradeMeEnquiriesCount: tradeMeEnquiriesCount,
50
+ bookMeEnquiriesCount: bookMeEnquiriesCount,
51
+ manualEnquiryCount: manualEnquiryCount
52
+ })))), /* @__PURE__ */React.createElement(Box, {
53
+ width: "100%"
54
+ }, /* @__PURE__ */React.createElement(Box, {
55
+ display: "flex",
56
+ direction: "row",
57
+ width: "100%",
58
+ gap: 6
59
+ }, /* @__PURE__ */React.createElement(Box, {
60
+ flex: 3
61
+ }, /* @__PURE__ */React.createElement(Box, {
62
+ display: "flex",
63
+ gap: 6
64
+ }, /* @__PURE__ */React.createElement(AnalyticsBox, {
65
+ label: "Viewings",
66
+ amount: viewingsCount,
67
+ width: "100%",
68
+ height: isXlUp ? "157px" : "125px"
69
+ }), /* @__PURE__ */React.createElement(AnalyticsBox, {
70
+ label: "Bookings",
71
+ amount: bookingsCount,
72
+ width: "100%",
73
+ height: isXlUp ? "157px" : "125px"
74
+ }), /* @__PURE__ */React.createElement(AnalyticsBox, {
75
+ label: "Attendees",
76
+ amount: attendeesCount,
77
+ width: "100%",
78
+ border: "3px solid #6FD3C0",
79
+ height: isXlUp ? "157px" : "125px"
80
+ })), /* @__PURE__ */React.createElement(Box, {
81
+ display: "flex",
82
+ width: "100%",
83
+ gap: 6,
84
+ mt: 6
85
+ }, /* @__PURE__ */React.createElement(AnalyticsBox, {
86
+ label: "Converted Properties",
87
+ amount: agreementsCount,
88
+ width: "100%",
89
+ height: isXlUp ? "157px" : "125px",
90
+ text: /* @__PURE__ */React.createElement(Box, {
91
+ as: "span",
92
+ maxWidth: "276px"
93
+ }, "Properties that have had a viewing in the last", " ", /* @__PURE__ */React.createElement(Text, {
94
+ as: "span",
95
+ display: "inline",
96
+ weight: "700",
97
+ fontSize: "inherit"
98
+ }, filterDaysCount), " ", "days where an agreement has been", " ", /* @__PURE__ */React.createElement(Text, {
99
+ as: "span",
100
+ display: "inline",
101
+ weight: "700",
102
+ fontSize: "inherit"
103
+ }, "created"))
104
+ }), /* @__PURE__ */React.createElement(AnalyticsBox, {
105
+ label: "Converted Properties",
106
+ amount: agreementsFinalisedCount,
107
+ width: "100%",
108
+ height: isXlUp ? "157px" : "125px",
109
+ text: /* @__PURE__ */React.createElement(Box, {
110
+ as: "span",
111
+ maxWidth: "276px"
112
+ }, "Properties that have had a viewing in the last", " ", /* @__PURE__ */React.createElement(Text, {
113
+ as: "span",
114
+ display: "inline",
115
+ weight: "700",
116
+ fontSize: "inherit"
117
+ }, filterDaysCount), " ", "days where an agreement has been", " ", /* @__PURE__ */React.createElement(Text, {
118
+ as: "span",
119
+ display: "inline",
120
+ weight: "700",
121
+ fontSize: "inherit"
122
+ }, "finalised"))
123
+ }))), /* @__PURE__ */React.createElement(Box, {
124
+ flex: 2
125
+ }, /* @__PURE__ */React.createElement(Box, {
126
+ display: "flex",
127
+ gap: 6
128
+ }, /* @__PURE__ */React.createElement(AnalyticsBox, {
129
+ label: "Cancellations",
130
+ amount: cancellationsCount,
131
+ width: "100%",
132
+ border: "3px solid #ED0D8D",
133
+ height: isXlUp ? "157px" : "125px"
134
+ }), /* @__PURE__ */React.createElement(AnalyticsBox, {
135
+ label: "Applications",
136
+ amount: applicationsCount,
137
+ width: "100%",
138
+ border: "3px solid #F5C440",
139
+ height: isXlUp ? "157px" : "125px"
140
+ })), /* @__PURE__ */React.createElement(Box, {
141
+ display: "flex",
142
+ gap: 6,
143
+ mt: 6
144
+ }, /* @__PURE__ */React.createElement(AnalyticsBox, {
145
+ label: /* @__PURE__ */React.createElement("span", null, "Average", /* @__PURE__ */React.createElement("br", null), " Rent"),
146
+ amount: averageRent,
147
+ width: "100%",
148
+ height: isXlUp ? "157px" : "125px"
149
+ }), /* @__PURE__ */React.createElement(AnalyticsBox, {
150
+ label: /* @__PURE__ */React.createElement("span", null, "Text Usage", /* @__PURE__ */React.createElement("br", null), " Total"),
151
+ amount: textUsage,
152
+ width: "100%",
153
+ height: isXlUp ? "157px" : "125px"
154
+ }))))));
203
155
  }
204
156
 
205
157
  export { AnalyticsSection as default };
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useMemo } from 'react';
2
+ import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
3
+ import React, { useMemo } from 'react';
4
4
  import { Box } from '@tenancy.nz/ui';
5
5
  import { Chart } from 'primereact/chart';
6
6
  import { StyledBookingChartStack, StyledBookingChartLegend, StyledBookingChartButton } from './BookingChart.styled.js';
7
7
 
8
- const defaultOptions = {
8
+ var defaultOptions = {
9
9
  scaleFontColor: "black",
10
10
  legend: {
11
11
  display: false
@@ -18,103 +18,105 @@ const defaultOptions = {
18
18
  size: 12,
19
19
  family: "Montserrat, sans-serif"
20
20
  },
21
- display: (ctx) => ctx.dataset.data[ctx.dataIndex] > 0
21
+ display: function display(ctx) {
22
+ return ctx.dataset.data[ctx.dataIndex] > 0;
23
+ }
22
24
  }
23
25
  },
24
26
  scales: {
25
- xAxes: [
26
- {
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
- ],
39
- yAxes: [
40
- {
41
- scaleLabel: {
42
- display: true,
43
- labelString: "Total bookings",
44
- fontFamily: "Montserrat, sans-serif",
45
- fontSize: 13,
46
- fontStyle: "600"
47
- },
48
- ticks: {
49
- min: 0,
50
- stepSize: 5,
51
- fontSize: 13,
52
- fontWeight: 500
53
- },
54
- gridLines: {
55
- display: false
56
- },
57
- stacked: true
58
- }
59
- ]
27
+ xAxes: [{
28
+ gridLines: {
29
+ labelString: "Date",
30
+ display: false
31
+ },
32
+ ticks: {
33
+ fontSize: 13,
34
+ family: "Montserrat, sans-serif",
35
+ fontWeight: "bold"
36
+ },
37
+ stacked: true
38
+ }],
39
+ yAxes: [{
40
+ scaleLabel: {
41
+ display: true,
42
+ labelString: "Total bookings",
43
+ fontFamily: "Montserrat, sans-serif",
44
+ fontSize: 13,
45
+ fontStyle: "600"
46
+ },
47
+ ticks: {
48
+ min: 0,
49
+ stepSize: 5,
50
+ fontSize: 13,
51
+ fontWeight: 500
52
+ },
53
+ gridLines: {
54
+ display: false
55
+ },
56
+ stacked: true
57
+ }]
60
58
  }
61
59
  };
62
- function BookingChart({
63
- data,
64
- labels,
65
- mode = "day",
66
- options = {},
67
- onModeChange = void 0
68
- }) {
69
- const legends = useMemo(
70
- () => data.map(({ label, backgroundColor }) => [label, backgroundColor]).filter(
71
- ([label], i, items) => items.findIndex(([l]) => l === label) === i
72
- ),
73
- [data]
74
- );
75
- return /* @__PURE__ */ jsxs(Box, { display: "flex", direction: "column", gap: "16px", width: "100%", children: [
76
- legends.length > 0 && /* @__PURE__ */ jsx(StyledBookingChartStack, { children: legends.map(([label, backgroundColor]) => /* @__PURE__ */ jsx(StyledBookingChartLegend, { color: backgroundColor, children: label }, label)) }),
77
- /* @__PURE__ */ jsx(Box, { width: "100%", overflow: "hidden", children: /* @__PURE__ */ jsx(
78
- Chart,
79
- {
80
- type: "bar",
81
- data: {
82
- labels,
83
- datasets: data
84
- },
85
- options: { ...defaultOptions, ...options }
86
- }
87
- ) }),
88
- onModeChange && /* @__PURE__ */ jsxs(StyledBookingChartStack, { children: [
89
- /* @__PURE__ */ jsx(
90
- StyledBookingChartButton,
91
- {
92
- onClick: onModeChange,
93
- active: mode === "day",
94
- value: "day",
95
- children: "Day"
96
- }
97
- ),
98
- /* @__PURE__ */ jsx(
99
- StyledBookingChartButton,
100
- {
101
- onClick: onModeChange,
102
- active: mode === "week",
103
- value: "week",
104
- children: "Week"
105
- }
106
- ),
107
- /* @__PURE__ */ jsx(
108
- StyledBookingChartButton,
109
- {
110
- onClick: onModeChange,
111
- active: mode === "month",
112
- value: "month",
113
- children: "Month"
114
- }
115
- )
116
- ] })
117
- ] });
60
+ function BookingChart(_ref) {
61
+ var data = _ref.data,
62
+ labels = _ref.labels,
63
+ _ref$mode = _ref.mode,
64
+ mode = _ref$mode === void 0 ? "day" : _ref$mode,
65
+ _ref$options = _ref.options,
66
+ options = _ref$options === void 0 ? {} : _ref$options,
67
+ _ref$onModeChange = _ref.onModeChange,
68
+ onModeChange = _ref$onModeChange === void 0 ? void 0 : _ref$onModeChange;
69
+ var legends = useMemo(function () {
70
+ return data.map(function (_ref2) {
71
+ var label = _ref2.label,
72
+ backgroundColor = _ref2.backgroundColor;
73
+ return [label, backgroundColor];
74
+ }).filter(function (_ref3, i, items) {
75
+ var _ref4 = _slicedToArray(_ref3, 1),
76
+ label = _ref4[0];
77
+ return items.findIndex(function (_ref5) {
78
+ var _ref6 = _slicedToArray(_ref5, 1),
79
+ l = _ref6[0];
80
+ return l === label;
81
+ }) === i;
82
+ });
83
+ }, [data]);
84
+ return /* @__PURE__ */React.createElement(Box, {
85
+ display: "flex",
86
+ direction: "column",
87
+ gap: "16px",
88
+ width: "100%"
89
+ }, legends.length > 0 && /* @__PURE__ */React.createElement(StyledBookingChartStack, null, legends.map(function (_ref7) {
90
+ var _ref8 = _slicedToArray(_ref7, 2),
91
+ label = _ref8[0],
92
+ backgroundColor = _ref8[1];
93
+ return /* @__PURE__ */React.createElement(StyledBookingChartLegend, {
94
+ key: label,
95
+ color: backgroundColor
96
+ }, label);
97
+ })), /* @__PURE__ */React.createElement(Box, {
98
+ width: "100%",
99
+ overflow: "hidden"
100
+ }, /* @__PURE__ */React.createElement(Chart, {
101
+ type: "bar",
102
+ data: {
103
+ labels: labels,
104
+ datasets: data
105
+ },
106
+ options: _objectSpread2(_objectSpread2({}, defaultOptions), options)
107
+ })), onModeChange && /* @__PURE__ */React.createElement(StyledBookingChartStack, null, /* @__PURE__ */React.createElement(StyledBookingChartButton, {
108
+ onClick: onModeChange,
109
+ active: mode === "day",
110
+ value: "day"
111
+ }, "Day"), /* @__PURE__ */React.createElement(StyledBookingChartButton, {
112
+ onClick: onModeChange,
113
+ active: mode === "week",
114
+ value: "week"
115
+ }, "Week"), /* @__PURE__ */React.createElement(StyledBookingChartButton, {
116
+ onClick: onModeChange,
117
+ active: mode === "month",
118
+ value: "month"
119
+ }, "Month")));
118
120
  }
119
121
 
120
122
  export { BookingChart as default };