@licklist/design 0.78.28 → 0.78.29

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 (125) hide show
  1. package/dist/assets/Trend-Down.svg.js +16 -0
  2. package/dist/assets/Trend-Up.svg.js +16 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +10 -0
  6. package/dist/v2/components/Button/Button.d.ts +8 -4
  7. package/dist/v2/components/Button/Button.d.ts.map +1 -1
  8. package/dist/v2/components/Button/index.d.ts +2 -2
  9. package/dist/v2/components/Button/index.d.ts.map +1 -1
  10. package/dist/v2/components/Checkbox/Checkbox.d.ts +9 -0
  11. package/dist/v2/components/Checkbox/Checkbox.d.ts.map +1 -0
  12. package/dist/v2/components/Checkbox/index.d.ts +3 -0
  13. package/dist/v2/components/Checkbox/index.d.ts.map +1 -0
  14. package/dist/v2/components/FormField/FormField.d.ts +10 -0
  15. package/dist/v2/components/FormField/FormField.d.ts.map +1 -0
  16. package/dist/v2/components/FormField/index.d.ts +3 -0
  17. package/dist/v2/components/FormField/index.d.ts.map +1 -0
  18. package/dist/v2/components/NewInput/NewInput.d.ts +20 -0
  19. package/dist/v2/components/NewInput/NewInput.d.ts.map +1 -0
  20. package/dist/v2/components/NewInput/index.d.ts +2 -0
  21. package/dist/v2/components/NewInput/index.d.ts.map +1 -0
  22. package/dist/v2/components/NewPageHeader/NewPageHeader.d.ts +10 -0
  23. package/dist/v2/components/NewPageHeader/NewPageHeader.d.ts.map +1 -0
  24. package/dist/v2/components/NewPageHeader/index.d.ts +2 -0
  25. package/dist/v2/components/NewPageHeader/index.d.ts.map +1 -0
  26. package/dist/v2/components/SectionHeader/SectionHeader.d.ts +8 -0
  27. package/dist/v2/components/SectionHeader/SectionHeader.d.ts.map +1 -0
  28. package/dist/v2/components/SectionHeader/index.d.ts +3 -0
  29. package/dist/v2/components/SectionHeader/index.d.ts.map +1 -0
  30. package/dist/v2/components/Select/Select.js +128 -0
  31. package/dist/v2/components/Select/Select.scss.js +6 -0
  32. package/dist/v2/components/WYSIWYGEditor/Icons.d.ts +16 -0
  33. package/dist/v2/components/WYSIWYGEditor/Icons.d.ts.map +1 -0
  34. package/dist/v2/components/WYSIWYGEditor/WYSIWYGEditor.d.ts +14 -0
  35. package/dist/v2/components/WYSIWYGEditor/WYSIWYGEditor.d.ts.map +1 -0
  36. package/dist/v2/components/WYSIWYGEditor/index.d.ts +3 -0
  37. package/dist/v2/components/WYSIWYGEditor/index.d.ts.map +1 -0
  38. package/dist/v2/components/index.d.ts +22 -0
  39. package/dist/v2/components/index.d.ts.map +1 -0
  40. package/dist/v2/dashboard-analytics/blog-posts/Blog.js +103 -0
  41. package/dist/v2/dashboard-analytics/blog-posts/Blog.scss.js +6 -0
  42. package/dist/v2/dashboard-analytics/chart/Chart.js +733 -0
  43. package/dist/v2/dashboard-analytics/chart/Chart.scss.js +6 -0
  44. package/dist/v2/dashboard-analytics/dashboard/Dashboard.js +270 -0
  45. package/dist/v2/dashboard-analytics/dashboard/Dashboard.scss.js +6 -0
  46. package/dist/v2/dashboard-analytics/metric-card/MetricCard.js +65 -0
  47. package/dist/v2/dashboard-analytics/metric-card/MetricCard.scss.js +6 -0
  48. package/dist/v2/dashboard-analytics/venue-card/VenueCard.js +50 -0
  49. package/dist/v2/dashboard-analytics/venue-card/VenueCard.scss.js +6 -0
  50. package/dist/v2/dashboard-analytics/venue-closed-card/VenueClosedCard.js +48 -0
  51. package/dist/v2/dashboard-analytics/venue-closed-card/VenueClosedCard.scss.js +6 -0
  52. package/dist/v2/icons/index.js +61 -1
  53. package/dist/v2/index.d.ts +3 -1
  54. package/dist/v2/index.d.ts.map +1 -1
  55. package/dist/v2/navigation/DashboardLayout/TopNavigation.scss.js +1 -1
  56. package/dist/v2/pages/Settings/SettingsPage.d.ts +13 -0
  57. package/dist/v2/pages/Settings/SettingsPage.d.ts.map +1 -0
  58. package/dist/v2/pages/Settings/SettingsPage.js +88 -0
  59. package/dist/v2/pages/Settings/SettingsPage.scss.js +6 -0
  60. package/dist/v2/pages/Settings/SettingsTabs.d.ts +14 -0
  61. package/dist/v2/pages/Settings/SettingsTabs.d.ts.map +1 -0
  62. package/dist/v2/pages/Settings/SettingsTabs.js +29 -0
  63. package/dist/v2/pages/Settings/SettingsTabs.scss.js +6 -0
  64. package/dist/v2/pages/Settings/components/SidebarCustomisation.js +283 -0
  65. package/dist/v2/pages/Settings/components/SidebarCustomisation.scss.js +6 -0
  66. package/dist/v2/pages/Settings/components/SidebarNavItem.d.ts +19 -0
  67. package/dist/v2/pages/Settings/components/SidebarNavItem.d.ts.map +1 -0
  68. package/dist/v2/pages/Settings/components/SidebarNavItem.js +41 -0
  69. package/dist/v2/pages/Settings/components/SidebarNavItem.scss.js +6 -0
  70. package/dist/v2/pages/Settings/components/index.d.ts +5 -0
  71. package/dist/v2/pages/Settings/components/index.d.ts.map +1 -0
  72. package/dist/v2/pages/Settings/index.d.ts +7 -0
  73. package/dist/v2/pages/Settings/index.d.ts.map +1 -0
  74. package/package.json +3 -3
  75. package/src/index.ts +3 -1
  76. package/src/v2/components/Alert/Alert.scss +3 -3
  77. package/src/v2/components/Button/Button.tsx +34 -12
  78. package/src/v2/components/Button/index.ts +2 -2
  79. package/src/v2/components/Checkbox/Checkbox.scss +211 -0
  80. package/src/v2/components/Checkbox/Checkbox.stories.tsx +316 -0
  81. package/src/v2/components/Checkbox/Checkbox.tsx +106 -0
  82. package/src/v2/components/Checkbox/index.ts +3 -0
  83. package/src/v2/components/FormField/FormField.scss +87 -0
  84. package/src/v2/components/FormField/FormField.stories.tsx +71 -0
  85. package/src/v2/components/FormField/FormField.tsx +37 -0
  86. package/src/v2/components/FormField/index.ts +3 -0
  87. package/src/v2/components/NewInput/NewInput.stories.tsx +433 -0
  88. package/src/v2/components/NewInput/NewInput.tsx +96 -0
  89. package/src/v2/components/NewInput/index.ts +1 -0
  90. package/src/v2/components/NewPageHeader/NewPageHeader.scss +47 -0
  91. package/src/v2/components/NewPageHeader/NewPageHeader.stories.tsx +44 -0
  92. package/src/v2/components/NewPageHeader/NewPageHeader.tsx +35 -0
  93. package/src/v2/components/NewPageHeader/index.ts +1 -0
  94. package/src/v2/components/SectionHeader/SectionHeader.scss +11 -0
  95. package/src/v2/components/SectionHeader/SectionHeader.tsx +15 -0
  96. package/src/v2/components/SectionHeader/index.ts +2 -0
  97. package/src/v2/components/Select/Select.scss +5 -5
  98. package/src/v2/components/WYSIWYGEditor/Icons.tsx +93 -0
  99. package/src/v2/components/WYSIWYGEditor/WYSIWYGEditor.scss +310 -0
  100. package/src/v2/components/WYSIWYGEditor/WYSIWYGEditor.stories.tsx +252 -0
  101. package/src/v2/components/WYSIWYGEditor/WYSIWYGEditor.tsx +393 -0
  102. package/src/v2/components/WYSIWYGEditor/index.ts +3 -0
  103. package/src/v2/components/index.ts +37 -0
  104. package/src/v2/index.ts +10 -2
  105. package/src/v2/navigation/DashboardLayout/TopNavigation.scss +1 -0
  106. package/src/v2/pages/Settings/SettingsContentPlaceholder.scss +24 -0
  107. package/src/v2/pages/Settings/SettingsPage.scss +52 -0
  108. package/src/v2/pages/Settings/SettingsPage.tsx +46 -0
  109. package/src/v2/pages/Settings/SettingsTabs.scss +44 -0
  110. package/src/v2/pages/Settings/SettingsTabs.tsx +36 -0
  111. package/src/v2/pages/Settings/components/SidebarCustomisation.stories.tsx +48 -0
  112. package/src/v2/pages/Settings/components/SidebarNavItem.scss +76 -0
  113. package/src/v2/pages/Settings/components/SidebarNavItem.stories.tsx +50 -0
  114. package/src/v2/pages/Settings/components/SidebarNavItem.tsx +52 -0
  115. package/src/v2/pages/Settings/components/index.ts +5 -0
  116. package/src/v2/pages/Settings/index.ts +8 -0
  117. package/src/v2/styles/components/Button.scss +51 -53
  118. package/src/v2/styles/form/Layout.scss +15 -0
  119. package/src/v2/styles/form/NewInput.scss +83 -53
  120. package/src/v2/styles/index.scss +1 -0
  121. package/src/v2/styles/tokens/_colors.scss +6 -6
  122. package/src/v2/styles/tokens/_typography.scss +2 -2
  123. package/dist/v2/navigation/icons/index.d.ts +0 -12
  124. package/dist/v2/navigation/icons/index.d.ts.map +0 -1
  125. package/src/v2/navigation/icons/index.tsx +0 -72
@@ -0,0 +1,733 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import React__default from 'react';
3
+ import { ResponsiveContainer, AreaChart, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Area } from 'recharts';
4
+ import { TrendingUp, TrendingDown } from 'lucide-react';
5
+ import './Chart.scss.js';
6
+
7
+ function _array_like_to_array(arr, len) {
8
+ if (len == null || len > arr.length) len = arr.length;
9
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
10
+ return arr2;
11
+ }
12
+ function _array_with_holes(arr) {
13
+ if (Array.isArray(arr)) return arr;
14
+ }
15
+ function _array_without_holes(arr) {
16
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
17
+ }
18
+ function _iterable_to_array(iter) {
19
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
20
+ }
21
+ function _iterable_to_array_limit(arr, i) {
22
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
23
+ if (_i == null) return;
24
+ var _arr = [];
25
+ var _n = true;
26
+ var _d = false;
27
+ var _s, _e;
28
+ try {
29
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
30
+ _arr.push(_s.value);
31
+ if (i && _arr.length === i) break;
32
+ }
33
+ } catch (err) {
34
+ _d = true;
35
+ _e = err;
36
+ } finally{
37
+ try {
38
+ if (!_n && _i["return"] != null) _i["return"]();
39
+ } finally{
40
+ if (_d) throw _e;
41
+ }
42
+ }
43
+ return _arr;
44
+ }
45
+ function _non_iterable_rest() {
46
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
+ }
48
+ function _non_iterable_spread() {
49
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
50
+ }
51
+ function _sliced_to_array(arr, i) {
52
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
53
+ }
54
+ function _to_consumable_array(arr) {
55
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
56
+ }
57
+ function _unsupported_iterable_to_array(o, minLen) {
58
+ if (!o) return;
59
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
60
+ var n = Object.prototype.toString.call(o).slice(8, -1);
61
+ if (n === "Object" && o.constructor) n = o.constructor.name;
62
+ if (n === "Map" || n === "Set") return Array.from(n);
63
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
64
+ }
65
+ var Chart = function(param) {
66
+ var title = param.title, subtitle = param.subtitle, data = param.data, _param_isRevenue = param.isRevenue, isRevenue = _param_isRevenue === void 0 ? false : _param_isRevenue, _param_className = param.className, className = _param_className === void 0 ? '' : _param_className, _param_period = param.period, period = _param_period === void 0 ? 'today' : _param_period; param.bookingType; var tmp = param.isFullWidth, propIsFullWidth = tmp === void 0 ? false : tmp, _param_isLoading = param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, _param_isRefreshing = param.isRefreshing, isRefreshing = _param_isRefreshing === void 0 ? false : _param_isRefreshing;
67
+ var _Math;
68
+ var _React_useState = _sliced_to_array(React__default.useState(0), 2), animationKey = _React_useState[0], setAnimationKey = _React_useState[1];
69
+ var _React_useState1 = _sliced_to_array(React__default.useState(false), 2), isAnimating = _React_useState1[0], setIsAnimating = _React_useState1[1];
70
+ var _React_useState2 = _sliced_to_array(React__default.useState(0), 2), forceResize = _React_useState2[0], setForceResize = _React_useState2[1];
71
+ var prevDataRef = React__default.useRef(data);
72
+ var prevPeriodRef = React__default.useRef(period);
73
+ React__default.useEffect(function() {
74
+ var dataChanged = JSON.stringify(prevDataRef.current) !== JSON.stringify(data);
75
+ var periodChanged = prevPeriodRef.current !== period;
76
+ if (dataChanged || periodChanged) {
77
+ setIsAnimating(true);
78
+ setAnimationKey(function(prev) {
79
+ return prev + 1;
80
+ });
81
+ if (periodChanged) {
82
+ setForceResize(function(prev) {
83
+ return prev + 1;
84
+ });
85
+ prevPeriodRef.current = period;
86
+ }
87
+ prevDataRef.current = data;
88
+ var timer = setTimeout(function() {
89
+ setIsAnimating(false);
90
+ }, 800);
91
+ return function() {
92
+ return clearTimeout(timer);
93
+ };
94
+ }
95
+ }, [
96
+ data,
97
+ period
98
+ ]);
99
+ var _React_useState3 = _sliced_to_array(React__default.useState(false), 2), isMobile = _React_useState3[0], setIsMobile = _React_useState3[1];
100
+ var _React_useState4 = _sliced_to_array(React__default.useState(false), 2), isTablet = _React_useState4[0], setIsTablet = _React_useState4[1];
101
+ var _React_useState5 = _sliced_to_array(React__default.useState(false), 2), detectedFullWidth = _React_useState5[0], setDetectedFullWidth = _React_useState5[1];
102
+ var _React_useState6 = _sliced_to_array(React__default.useState({
103
+ width: 0,
104
+ height: 0
105
+ }), 2); _React_useState6[0]; var setDimensions = _React_useState6[1];
106
+ var chartRef = React__default.useRef(null);
107
+ var isFullWidth = propIsFullWidth || detectedFullWidth;
108
+ React__default.useEffect(function() {
109
+ var checkScreenSize = function() {
110
+ setIsMobile(window.innerWidth < 480);
111
+ setIsTablet(window.innerWidth >= 480 && window.innerWidth < 768);
112
+ if (chartRef.current) {
113
+ var rect = chartRef.current.getBoundingClientRect();
114
+ setDimensions({
115
+ width: rect.width,
116
+ height: rect.height
117
+ });
118
+ }
119
+ };
120
+ checkScreenSize();
121
+ window.addEventListener('resize', checkScreenSize);
122
+ return function() {
123
+ return window.removeEventListener('resize', checkScreenSize);
124
+ };
125
+ }, []);
126
+ var useChartRecalculation = function() {
127
+ var forceRecalculation = React__default.useCallback(function() {
128
+ if (chartRef.current) {
129
+ var resizeObserver = new ResizeObserver(function() {});
130
+ resizeObserver.observe(chartRef.current);
131
+ setTimeout(function() {
132
+ resizeObserver.disconnect();
133
+ }, 100);
134
+ setTimeout(function() {
135
+ window.dispatchEvent(new Event('resize'));
136
+ }, 50);
137
+ }
138
+ }, []);
139
+ return forceRecalculation;
140
+ };
141
+ var forceRecalculation = useChartRecalculation();
142
+ React__default.useEffect(function() {
143
+ forceRecalculation();
144
+ }, [
145
+ period,
146
+ forceRecalculation
147
+ ]);
148
+ React__default.useEffect(function() {
149
+ if (propIsFullWidth !== undefined) return;
150
+ var checkChartWidth = function() {
151
+ if (chartRef.current) {
152
+ var chartWidth = chartRef.current.offsetWidth;
153
+ var viewportWidth = window.innerWidth;
154
+ var isWide = chartWidth > viewportWidth * 0.65;
155
+ setDetectedFullWidth(isWide);
156
+ }
157
+ };
158
+ var timeoutId = setTimeout(checkChartWidth, 100);
159
+ window.addEventListener('resize', checkChartWidth);
160
+ var resizeObserver = new ResizeObserver(function() {
161
+ setTimeout(checkChartWidth, 50);
162
+ });
163
+ if (chartRef.current) {
164
+ resizeObserver.observe(chartRef.current);
165
+ }
166
+ return function() {
167
+ clearTimeout(timeoutId);
168
+ window.removeEventListener('resize', checkChartWidth);
169
+ resizeObserver.disconnect();
170
+ };
171
+ }, [
172
+ propIsFullWidth,
173
+ forceResize
174
+ ]);
175
+ React__default.useEffect(function() {
176
+ if (chartRef.current) {
177
+ var resizeEvent = new Event('resize');
178
+ window.dispatchEvent(resizeEvent);
179
+ var currentRef = chartRef.current;
180
+ var display = currentRef.style.display;
181
+ currentRef.style.display = 'none';
182
+ currentRef.offsetHeight;
183
+ currentRef.style.display = display;
184
+ setTimeout(function() {
185
+ var rect = currentRef.getBoundingClientRect();
186
+ setDimensions({
187
+ width: rect.width,
188
+ height: rect.height
189
+ });
190
+ }, 10);
191
+ }
192
+ }, [
193
+ period,
194
+ forceResize,
195
+ animationKey
196
+ ]);
197
+ var processedData = React__default.useMemo(function() {
198
+ var transformXAxisForPeriod = function(data, period) {
199
+ if (period === 'week') {
200
+ var days = [
201
+ 'Mon',
202
+ 'Tue',
203
+ 'Wed',
204
+ 'Thu',
205
+ 'Fri',
206
+ 'Sat',
207
+ 'Sun'
208
+ ];
209
+ return days.map(function(day, index) {
210
+ var hourIndex = index * 3;
211
+ var dayData = data[hourIndex] || {
212
+ time: '',
213
+ value: 0,
214
+ participants: 0
215
+ };
216
+ return {
217
+ time: day,
218
+ value: dayData.value,
219
+ participants: dayData.participants || 0
220
+ };
221
+ });
222
+ }
223
+ if (isFullWidth) {
224
+ if (data.length > 8) {
225
+ return data.length <= 24 ? data : data.filter(function(_, index) {
226
+ return index % 2 === 0;
227
+ });
228
+ }
229
+ return data;
230
+ }
231
+ if (period === 'today' && data.length > 12) {
232
+ return data.filter(function(_, index) {
233
+ return index % 3 === 0;
234
+ });
235
+ }
236
+ return data;
237
+ };
238
+ var transformed = transformXAxisForPeriod(data, period);
239
+ var months = [
240
+ 'Jan',
241
+ 'Feb',
242
+ 'Mar',
243
+ 'Apr',
244
+ 'May',
245
+ 'Jun',
246
+ 'Jul',
247
+ 'Aug',
248
+ 'Sep',
249
+ 'Oct',
250
+ 'Nov',
251
+ 'Dec'
252
+ ];
253
+ var isMonthlyData = transformed.some(function(item) {
254
+ return months.some(function(month) {
255
+ return item.time.includes(month);
256
+ });
257
+ });
258
+ if (isMonthlyData) {
259
+ var last12Months = transformed.slice(-12);
260
+ return last12Months;
261
+ }
262
+ return transformed;
263
+ }, [
264
+ data,
265
+ period,
266
+ isFullWidth
267
+ ]);
268
+ var maxValue = (_Math = Math).max.apply(_Math, _to_consumable_array(processedData.map(function(d) {
269
+ return d.value;
270
+ })));
271
+ var yAxisMax;
272
+ var yAxisMin = 0;
273
+ var calculateOptimalScale = function(max) {
274
+ if (max === 0) return isRevenue ? 10 : 5;
275
+ var bufferedMax = max * (isRevenue ? 1.15 : 1.1);
276
+ if (isRevenue) {
277
+ if (bufferedMax <= 1) return 1;
278
+ if (bufferedMax <= 2) return 2;
279
+ if (bufferedMax <= 5) return 5;
280
+ if (bufferedMax <= 10) return 10;
281
+ if (bufferedMax <= 20) return 20;
282
+ if (bufferedMax <= 25) return 25;
283
+ if (bufferedMax <= 50) return 50;
284
+ if (bufferedMax <= 100) return 100;
285
+ if (bufferedMax <= 250) return 250;
286
+ if (bufferedMax <= 500) return 500;
287
+ if (bufferedMax <= 1000) return 1000;
288
+ var magnitude = Math.pow(10, Math.floor(Math.log10(bufferedMax)));
289
+ var normalized = bufferedMax / magnitude;
290
+ if (normalized <= 1) return magnitude;
291
+ if (normalized <= 2) return 2 * magnitude;
292
+ if (normalized <= 2.5) return 2.5 * magnitude;
293
+ if (normalized <= 5) return 5 * magnitude;
294
+ return 10 * magnitude;
295
+ } else {
296
+ if (bufferedMax <= 1) return 2;
297
+ if (bufferedMax <= 2) return 3;
298
+ if (bufferedMax <= 3) return 4;
299
+ if (bufferedMax <= 5) return 6;
300
+ if (bufferedMax <= 8) return 10;
301
+ if (bufferedMax <= 12) return 15;
302
+ if (bufferedMax <= 20) return 25;
303
+ if (bufferedMax <= 40) return 50;
304
+ if (bufferedMax <= 80) return 100;
305
+ var magnitude1 = Math.pow(10, Math.floor(Math.log10(bufferedMax)));
306
+ var normalized1 = bufferedMax / magnitude1;
307
+ if (normalized1 <= 1) return magnitude1;
308
+ if (normalized1 <= 2) return 2 * magnitude1;
309
+ if (normalized1 <= 5) return 5 * magnitude1;
310
+ return 10 * magnitude1;
311
+ }
312
+ };
313
+ yAxisMax = calculateOptimalScale(maxValue);
314
+ var getTickInterval = function(max) {
315
+ var targetTickCount = 5;
316
+ if (isRevenue) {
317
+ if (max <= 1) return 0.25;
318
+ if (max <= 2) return 0.5;
319
+ if (max <= 5) return 1;
320
+ if (max <= 10) return 2;
321
+ if (max <= 20) return 5;
322
+ if (max <= 25) return 5;
323
+ if (max <= 50) return 10;
324
+ if (max <= 100) return 20;
325
+ if (max <= 250) return 50;
326
+ if (max <= 500) return 100;
327
+ if (max <= 1000) return 200;
328
+ var roughInterval = max / targetTickCount;
329
+ var magnitude = Math.pow(10, Math.floor(Math.log10(roughInterval)));
330
+ var normalized = roughInterval / magnitude;
331
+ if (normalized <= 1) return magnitude;
332
+ if (normalized <= 2) return 2 * magnitude;
333
+ if (normalized <= 2.5) return 2.5 * magnitude;
334
+ if (normalized <= 5) return 5 * magnitude;
335
+ return 10 * magnitude;
336
+ } else {
337
+ if (max <= 2) return 1;
338
+ if (max <= 3) return 1;
339
+ if (max <= 6) return 2;
340
+ if (max <= 10) return 2;
341
+ if (max <= 15) return 3;
342
+ if (max <= 25) return 5;
343
+ if (max <= 50) return 10;
344
+ if (max <= 100) return 20;
345
+ var roughInterval1 = max / targetTickCount;
346
+ var magnitude1 = Math.pow(10, Math.floor(Math.log10(roughInterval1)));
347
+ var normalized1 = roughInterval1 / magnitude1;
348
+ if (normalized1 <= 1) return magnitude1;
349
+ if (normalized1 <= 2) return 2 * magnitude1;
350
+ if (normalized1 <= 5) return 5 * magnitude1;
351
+ return 10 * magnitude1;
352
+ }
353
+ };
354
+ var tickInterval = getTickInterval(yAxisMax);
355
+ var ticks = [];
356
+ for(var i = yAxisMin; i <= yAxisMax; i += tickInterval){
357
+ var tick = Math.round(i * 100) / 100;
358
+ ticks.push(tick);
359
+ }
360
+ if (ticks[ticks.length - 1] > yAxisMax) {
361
+ ticks.pop();
362
+ }
363
+ if (ticks[ticks.length - 1] < yAxisMax) {
364
+ ticks.push(yAxisMax);
365
+ }
366
+ var getXAxisInterval = function(dataLength) {
367
+ var isMonthly = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, isWeekly = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false, isHourly = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
368
+ if (isMobile) {
369
+ if (isFullWidth) {
370
+ if (dataLength <= 6) return 0;
371
+ if (dataLength <= 10) return 1;
372
+ return Math.floor(dataLength / 5);
373
+ }
374
+ if (isMonthly && dataLength <= 12) return 2;
375
+ if (isWeekly && dataLength <= 7) return 0;
376
+ if (isHourly && dataLength <= 12) return 3;
377
+ if (dataLength <= 4) return 0;
378
+ if (dataLength <= 7) return 1;
379
+ if (dataLength <= 12) return 2;
380
+ return Math.floor(dataLength / 3);
381
+ }
382
+ if (isTablet) {
383
+ if (isFullWidth) {
384
+ if (isMonthly && dataLength <= 12) return 0;
385
+ if (isWeekly && dataLength <= 7) return 0;
386
+ if (isHourly && dataLength <= 16) return 0;
387
+ if (dataLength <= 10) return 0;
388
+ if (dataLength <= 20) return 1;
389
+ return Math.floor(dataLength / 10);
390
+ }
391
+ if (isMonthly && dataLength <= 12) return 0;
392
+ if (isWeekly && dataLength <= 7) return 0;
393
+ if (isHourly && dataLength <= 12) return 1;
394
+ if (dataLength <= 4) return 0;
395
+ if (dataLength <= 7) return 0;
396
+ if (dataLength <= 12) return 1;
397
+ return Math.floor(dataLength / 5);
398
+ }
399
+ if (isFullWidth) {
400
+ if (isMonthly && dataLength <= 12) return 0;
401
+ if (isWeekly && dataLength <= 7) return 0;
402
+ if (isHourly && dataLength <= 24) return 1;
403
+ if (dataLength <= 10) return 0;
404
+ if (dataLength <= 20) return 1;
405
+ return Math.floor(dataLength / 12);
406
+ }
407
+ if (isMonthly && dataLength <= 12) return 0;
408
+ if (isWeekly && dataLength <= 7) return 0;
409
+ if (isHourly && dataLength <= 12) return 1;
410
+ if (dataLength <= 4) return 0;
411
+ if (dataLength <= 7) return 0;
412
+ if (dataLength <= 12) return 2;
413
+ return Math.floor(dataLength / 6);
414
+ };
415
+ var months = [
416
+ 'Jan',
417
+ 'Feb',
418
+ 'Mar',
419
+ 'Apr',
420
+ 'May',
421
+ 'Jun',
422
+ 'Jul',
423
+ 'Aug',
424
+ 'Sep',
425
+ 'Oct',
426
+ 'Nov',
427
+ 'Dec'
428
+ ];
429
+ var days = [
430
+ 'Mon',
431
+ 'Tue',
432
+ 'Wed',
433
+ 'Thu',
434
+ 'Fri',
435
+ 'Sat',
436
+ 'Sun'
437
+ ];
438
+ var isMonthlyData = processedData.some(function(item) {
439
+ return months.some(function(month) {
440
+ return item.time.includes(month);
441
+ });
442
+ });
443
+ var isWeeklyData = processedData.some(function(item) {
444
+ return days.some(function(day) {
445
+ return item.time === day;
446
+ });
447
+ });
448
+ var isHourlyData = processedData.some(function(item) {
449
+ return item.time.includes(':');
450
+ });
451
+ var xAxisInterval = getXAxisInterval(processedData.length, isMonthlyData, isWeeklyData, isHourlyData);
452
+ var getCurrentTimeReference = function() {
453
+ if (subtitle && subtitle.includes('Yesterday')) return null;
454
+ var now = new Date();
455
+ if (subtitle === 'Today') {
456
+ return "".concat(now.getHours().toString().padStart(2, '0'), ":00");
457
+ }
458
+ if (subtitle && subtitle.includes(' - ') && (subtitle.includes('Mon') || subtitle.includes('Tue') || subtitle.includes('Wed') || subtitle.includes('Thu') || subtitle.includes('Fri') || subtitle.includes('Sat') || subtitle.includes('Sun'))) {
459
+ var dayNames = [
460
+ 'Mon',
461
+ 'Tue',
462
+ 'Wed',
463
+ 'Thu',
464
+ 'Fri',
465
+ 'Sat',
466
+ 'Sun'
467
+ ];
468
+ return dayNames[now.getDay() === 0 ? 6 : now.getDay() - 1];
469
+ }
470
+ if (subtitle && /^[A-Z][a-z]+ \d{4}$/.test(subtitle)) {
471
+ var dayOfMonth = now.getDate();
472
+ var weekNumber = Math.ceil(dayOfMonth / 7);
473
+ var weekStart = (weekNumber - 1) * 7 + 1;
474
+ var weekEnd = Math.min(weekNumber * 7, new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate());
475
+ var formatOrdinal = function(n) {
476
+ var suffix = n % 10 === 1 && n !== 11 ? 'st' : n % 10 === 2 && n !== 12 ? 'nd' : n % 10 === 3 && n !== 13 ? 'rd' : 'th';
477
+ return "".concat(n).concat(suffix);
478
+ };
479
+ return "".concat(formatOrdinal(weekStart), " - ").concat(formatOrdinal(weekEnd));
480
+ }
481
+ if (subtitle && /^\d{4}$/.test(subtitle)) {
482
+ var months = [
483
+ 'Jan',
484
+ 'Feb',
485
+ 'Mar',
486
+ 'Apr',
487
+ 'May',
488
+ 'Jun',
489
+ 'Jul',
490
+ 'Aug',
491
+ 'Sep',
492
+ 'Oct',
493
+ 'Nov',
494
+ 'Dec'
495
+ ];
496
+ return months[now.getMonth()];
497
+ }
498
+ return null;
499
+ };
500
+ var currentTimeRef = getCurrentTimeReference();
501
+ var CustomTooltip = function(param) {
502
+ var active = param.active, payload = param.payload, label = param.label;
503
+ if (active && payload && payload.length) {
504
+ var currentValue = payload[0].value;
505
+ var currentIndex = processedData.findIndex(function(d) {
506
+ return d.time === label;
507
+ });
508
+ var trend = null;
509
+ if (currentIndex >= 0 && currentIndex > 0) {
510
+ var prevValue = processedData[currentIndex - 1].value;
511
+ var prevTime = processedData[currentIndex - 1].time;
512
+ var change = currentValue - prevValue;
513
+ if (typeof prevValue === 'number' && typeof currentValue === 'number') {
514
+ var previousValue = prevValue === 0 ? 0.1 : Math.abs(prevValue);
515
+ var percentChange = change / previousValue * 100;
516
+ if (!isNaN(percentChange) && isFinite(percentChange)) {
517
+ trend = {
518
+ change: change,
519
+ percentChange: Math.abs(percentChange).toFixed(1),
520
+ isPositive: change > 0,
521
+ isEqual: change === 0,
522
+ comparisonText: "vs ".concat(prevTime),
523
+ previousValue: prevValue
524
+ };
525
+ }
526
+ }
527
+ }
528
+ var formatValue = function(value) {
529
+ if (isRevenue) {
530
+ return "\xa3".concat(value.toLocaleString("en-GB", {
531
+ minimumFractionDigits: 2,
532
+ maximumFractionDigits: 2
533
+ }));
534
+ }
535
+ return value.toLocaleString();
536
+ };
537
+ return /*#__PURE__*/ jsxs("div", {
538
+ className: "chart__tooltip",
539
+ children: [
540
+ /*#__PURE__*/ jsx("div", {
541
+ className: "chart__tooltip-label",
542
+ children: label
543
+ }),
544
+ /*#__PURE__*/ jsx("div", {
545
+ className: "chart__tooltip-value",
546
+ children: isRevenue ? formatValue(currentValue) : "".concat(currentValue, " ").concat(currentValue === 1 ? 'Booking' : 'Bookings')
547
+ }),
548
+ !isRevenue && payload && payload[0] && payload[0].payload.participants !== undefined && /*#__PURE__*/ jsxs("div", {
549
+ className: "chart__tooltip-participants",
550
+ children: [
551
+ payload[0].payload.participants,
552
+ " people"
553
+ ]
554
+ }),
555
+ trend && !trend.isEqual && /*#__PURE__*/ jsx("div", {
556
+ className: "chart__tooltip-trend ".concat(trend.isEqual ? 'neutral' : trend.isPositive ? 'positive' : 'negative'),
557
+ children: /*#__PURE__*/ jsxs("div", {
558
+ className: "chart__tooltip-trend-content",
559
+ children: [
560
+ trend.isPositive ? /*#__PURE__*/ jsx(TrendingUp, {
561
+ size: 12,
562
+ className: "chart__tooltip-trend-icon"
563
+ }) : /*#__PURE__*/ jsx(TrendingDown, {
564
+ size: 12,
565
+ className: "chart__tooltip-trend-icon"
566
+ }),
567
+ /*#__PURE__*/ jsx("span", {
568
+ className: "chart__tooltip-trend-value",
569
+ children: (trend.isPositive ? '+' : '') + (isRevenue ? "\xa3".concat(Math.abs(trend.change).toFixed(2)) : "".concat(trend.change, " ").concat(Math.abs(trend.change) === 1 ? 'Booking' : 'Bookings'))
570
+ })
571
+ ]
572
+ })
573
+ }),
574
+ trend && !trend.isEqual && /*#__PURE__*/ jsx("div", {
575
+ className: "chart__tooltip-comparison",
576
+ children: trend.comparisonText
577
+ })
578
+ ]
579
+ });
580
+ }
581
+ return null;
582
+ };
583
+ return /*#__PURE__*/ jsxs("section", {
584
+ ref: chartRef,
585
+ className: "chart ".concat(className, " ").concat(isLoading || isAnimating ? 'chart--loading' : '', " ").concat(isRefreshing ? 'chart--refreshing' : '').trim(),
586
+ "data-full-width": isFullWidth,
587
+ children: [
588
+ /*#__PURE__*/ jsxs("header", {
589
+ className: "chart__header",
590
+ children: [
591
+ /*#__PURE__*/ jsxs("h2", {
592
+ className: "chart__title",
593
+ children: [
594
+ title,
595
+ isRefreshing && !isLoading && /*#__PURE__*/ jsx("span", {
596
+ className: "chart__title-refresh-indicator",
597
+ children: "⟳"
598
+ })
599
+ ]
600
+ }),
601
+ /*#__PURE__*/ jsx("p", {
602
+ className: "chart__subtitle",
603
+ children: subtitle
604
+ })
605
+ ]
606
+ }),
607
+ /*#__PURE__*/ jsxs("div", {
608
+ className: "chart__container",
609
+ children: [
610
+ isLoading && /*#__PURE__*/ jsx("div", {
611
+ className: "chart__loading-overlay",
612
+ children: /*#__PURE__*/ jsx("div", {
613
+ className: "chart__loading-spinner"
614
+ })
615
+ }),
616
+ /*#__PURE__*/ jsx("div", {
617
+ className: "chart__wrapper ".concat(isAnimating ? 'chart__wrapper--recalculating' : ''),
618
+ children: /*#__PURE__*/ jsx(ResponsiveContainer, {
619
+ width: "100%",
620
+ height: "100%",
621
+ debounce: 1,
622
+ children: /*#__PURE__*/ jsxs(AreaChart, {
623
+ data: processedData,
624
+ margin: {
625
+ top: 10,
626
+ right: 10,
627
+ left: 10,
628
+ bottom: 16
629
+ },
630
+ children: [
631
+ /*#__PURE__*/ jsx("defs", {
632
+ children: /*#__PURE__*/ jsxs("linearGradient", {
633
+ id: "chartGradient",
634
+ x1: "0",
635
+ y1: "0",
636
+ x2: "0",
637
+ y2: "1",
638
+ children: [
639
+ /*#__PURE__*/ jsx("stop", {
640
+ offset: "0%",
641
+ stopColor: "#1F9AB5",
642
+ stopOpacity: 0.5
643
+ }),
644
+ /*#__PURE__*/ jsx("stop", {
645
+ offset: "100%",
646
+ stopColor: "#1F9AB5",
647
+ stopOpacity: 0
648
+ })
649
+ ]
650
+ })
651
+ }),
652
+ /*#__PURE__*/ jsx(CartesianGrid, {
653
+ strokeDasharray: "3 3",
654
+ stroke: "#E8E9EF"
655
+ }),
656
+ /*#__PURE__*/ jsx(XAxis, {
657
+ dataKey: "time",
658
+ type: "category",
659
+ axisLine: false,
660
+ tickLine: false,
661
+ tick: {
662
+ fontSize: isMobile ? 9 : isTablet ? 10 : 11,
663
+ fill: '#626A90'
664
+ },
665
+ tickMargin: isMobile ? 5 : 10,
666
+ interval: xAxisInterval
667
+ }),
668
+ /*#__PURE__*/ jsx(YAxis, {
669
+ domain: [
670
+ yAxisMin,
671
+ yAxisMax
672
+ ],
673
+ ticks: ticks,
674
+ axisLine: false,
675
+ tickLine: false,
676
+ tick: {
677
+ fontSize: isMobile ? 9 : isTablet ? 10 : 11,
678
+ fill: '#626A90'
679
+ },
680
+ tickFormatter: function(value) {
681
+ if (isRevenue) {
682
+ return isMobile ? "\xa3".concat(Math.round(value)) : "\xa3".concat(value);
683
+ }
684
+ return value.toString();
685
+ },
686
+ tickMargin: isMobile ? 3 : 5,
687
+ width: isMobile ? 30 : isTablet ? 35 : 40
688
+ }),
689
+ /*#__PURE__*/ jsx(Tooltip, {
690
+ content: CustomTooltip
691
+ }),
692
+ currentTimeRef && /*#__PURE__*/ jsx(ReferenceLine, {
693
+ x: currentTimeRef,
694
+ stroke: "#7C3AED",
695
+ strokeWidth: 2,
696
+ strokeDasharray: "6 4"
697
+ }),
698
+ /*#__PURE__*/ jsx(Area, {
699
+ type: "monotone",
700
+ dataKey: "value",
701
+ stroke: "#1F9AB5",
702
+ strokeWidth: isMobile ? 1.5 : 2,
703
+ fill: "url(#chartGradient)",
704
+ dot: {
705
+ fill: '#1F9AB5',
706
+ strokeWidth: 0,
707
+ r: isMobile ? 3 : isTablet ? 3.5 : 4,
708
+ fillOpacity: 1
709
+ },
710
+ activeDot: {
711
+ r: isMobile ? 5 : isTablet ? 5.5 : 6,
712
+ stroke: '#1F9AB5',
713
+ strokeWidth: 2,
714
+ fill: '#fff',
715
+ fillOpacity: 1,
716
+ strokeOpacity: 1
717
+ },
718
+ animationBegin: 0,
719
+ animationDuration: 800,
720
+ animationEasing: "ease-out",
721
+ isAnimationActive: true
722
+ })
723
+ ]
724
+ }, "chart-".concat(animationKey, "-").concat(forceResize))
725
+ }, "responsive-".concat(animationKey, "-").concat(forceResize))
726
+ })
727
+ ]
728
+ })
729
+ ]
730
+ });
731
+ };
732
+
733
+ export { Chart };