@makolabs/ripple 0.0.1-dev.7 → 0.0.1-dev.9

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 (114) hide show
  1. package/README.md +393 -53
  2. package/dist/button/Button.svelte +5 -3
  3. package/dist/button/Button.svelte.d.ts +1 -1
  4. package/dist/button/button.d.ts +40 -63
  5. package/dist/button/button.js +15 -14
  6. package/dist/charts/Chart.svelte +533 -0
  7. package/dist/charts/Chart.svelte.d.ts +4 -0
  8. package/dist/drawer/Drawer.svelte +13 -2
  9. package/dist/drawer/Drawer.svelte.d.ts +1 -1
  10. package/dist/drawer/drawer.d.ts +0 -17
  11. package/dist/elements/alert/Alert.svelte +53 -0
  12. package/dist/elements/alert/Alert.svelte.d.ts +4 -0
  13. package/dist/elements/badge/Badge.svelte +13 -5
  14. package/dist/elements/badge/Badge.svelte.d.ts +1 -1
  15. package/dist/elements/badge/badge.d.ts +0 -12
  16. package/dist/elements/dropdown/Dropdown.svelte +32 -37
  17. package/dist/elements/dropdown/Dropdown.svelte.d.ts +1 -1
  18. package/dist/elements/dropdown/Select.svelte +143 -59
  19. package/dist/elements/dropdown/Select.svelte.d.ts +1 -1
  20. package/dist/elements/dropdown/dropdown.d.ts +34 -57
  21. package/dist/elements/dropdown/dropdown.js +10 -4
  22. package/dist/elements/dropdown/select.d.ts +34 -54
  23. package/dist/elements/dropdown/select.js +22 -14
  24. package/dist/elements/file-upload/FileUpload.svelte +213 -0
  25. package/dist/elements/file-upload/FileUpload.svelte.d.ts +4 -0
  26. package/dist/elements/progress/Progress.svelte +87 -0
  27. package/dist/elements/progress/Progress.svelte.d.ts +4 -0
  28. package/dist/elements/timeline/Timeline.svelte +92 -0
  29. package/dist/elements/timeline/Timeline.svelte.d.ts +7 -0
  30. package/dist/forms/Checkbox.svelte +54 -0
  31. package/dist/forms/Checkbox.svelte.d.ts +4 -0
  32. package/dist/forms/DateRange.svelte +493 -0
  33. package/dist/forms/DateRange.svelte.d.ts +4 -0
  34. package/dist/forms/Form.svelte +39 -0
  35. package/dist/forms/Form.svelte.d.ts +4 -0
  36. package/dist/forms/Input.svelte +86 -0
  37. package/dist/forms/Input.svelte.d.ts +4 -0
  38. package/dist/forms/NumberInput.svelte +159 -0
  39. package/dist/forms/NumberInput.svelte.d.ts +4 -0
  40. package/dist/forms/RadioInputs.svelte +64 -0
  41. package/dist/forms/RadioInputs.svelte.d.ts +4 -0
  42. package/dist/forms/RadioPill.svelte +66 -0
  43. package/dist/forms/RadioPill.svelte.d.ts +4 -0
  44. package/dist/forms/Slider.svelte +342 -0
  45. package/dist/forms/Slider.svelte.d.ts +4 -0
  46. package/dist/forms/Tags.svelte +181 -0
  47. package/dist/forms/Tags.svelte.d.ts +4 -0
  48. package/dist/forms/Toggle.svelte +132 -0
  49. package/dist/forms/Toggle.svelte.d.ts +4 -0
  50. package/dist/forms/slider.d.ts +143 -0
  51. package/dist/forms/slider.js +62 -0
  52. package/dist/header/Breadcrumbs.svelte +2 -1
  53. package/dist/header/Breadcrumbs.svelte.d.ts +1 -1
  54. package/dist/header/PageHeader.svelte +2 -2
  55. package/dist/header/PageHeader.svelte.d.ts +1 -1
  56. package/dist/header/breadcrumbs.d.ts +20 -14
  57. package/dist/header/breadcrumbs.js +6 -0
  58. package/dist/header/pageheaders.d.ts +1 -1
  59. package/dist/helper/date.d.ts +7 -0
  60. package/dist/helper/date.js +15 -0
  61. package/dist/index.d.ts +742 -9
  62. package/dist/index.js +59 -16
  63. package/dist/layout/card/Card.svelte +5 -8
  64. package/dist/layout/card/Card.svelte.d.ts +1 -1
  65. package/dist/layout/card/StatsCard.svelte +116 -87
  66. package/dist/layout/card/card.d.ts +22 -33
  67. package/dist/layout/card/card.js +9 -8
  68. package/dist/layout/card/stats-card.d.ts +23 -25
  69. package/dist/layout/card/stats-card.js +13 -13
  70. package/dist/layout/navbar/navbar.d.ts +0 -23
  71. package/dist/layout/sidebar/NavGroup.svelte +25 -44
  72. package/dist/layout/sidebar/NavGroup.svelte.d.ts +1 -1
  73. package/dist/layout/sidebar/NavItem.svelte +1 -1
  74. package/dist/layout/sidebar/NavItem.svelte.d.ts +1 -1
  75. package/dist/layout/sidebar/Sidebar.svelte +20 -26
  76. package/dist/layout/sidebar/Sidebar.svelte.d.ts +1 -1
  77. package/dist/layout/table/table.d.ts +1 -1
  78. package/dist/layout/tabs/tabs.d.ts +1 -1
  79. package/dist/modal/Modal.svelte +2 -1
  80. package/dist/modal/Modal.svelte.d.ts +1 -1
  81. package/dist/modal/modal.d.ts +0 -23
  82. package/dist/sonner/sonner.svelte +13 -0
  83. package/dist/sonner/sonner.svelte.d.ts +4 -0
  84. package/dist/types/variants.d.ts +1 -21
  85. package/dist/types/variants.js +1 -19
  86. package/dist/variants.d.ts +20 -0
  87. package/dist/variants.js +19 -0
  88. package/package.json +6 -2
  89. package/dist/button/index.d.ts +0 -1
  90. package/dist/button/index.js +0 -1
  91. package/dist/drawer/index.d.ts +0 -2
  92. package/dist/drawer/index.js +0 -1
  93. package/dist/elements/badge/index.d.ts +0 -2
  94. package/dist/elements/badge/index.js +0 -2
  95. package/dist/elements/dropdown/index.d.ts +0 -3
  96. package/dist/elements/dropdown/index.js +0 -2
  97. package/dist/header/index.d.ts +0 -4
  98. package/dist/header/index.js +0 -2
  99. package/dist/layout/card/index.d.ts +0 -4
  100. package/dist/layout/card/index.js +0 -2
  101. package/dist/layout/index.d.ts +0 -5
  102. package/dist/layout/index.js +0 -5
  103. package/dist/layout/navbar/index.d.ts +0 -2
  104. package/dist/layout/navbar/index.js +0 -2
  105. package/dist/layout/sidebar/index.d.ts +0 -2
  106. package/dist/layout/sidebar/index.js +0 -1
  107. package/dist/layout/sidebar/sidebar.d.ts +0 -46
  108. package/dist/layout/sidebar/sidebar.js +0 -1
  109. package/dist/layout/table/index.d.ts +0 -3
  110. package/dist/layout/table/index.js +0 -2
  111. package/dist/layout/tabs/index.d.ts +0 -3
  112. package/dist/layout/tabs/index.js +0 -3
  113. package/dist/modal/index.d.ts +0 -1
  114. package/dist/modal/index.js +0 -1
@@ -1,4 +1,5 @@
1
- import { tv } from '../helper/cls.js';
1
+ import { tv } from 'tailwind-variants';
2
+ import { Color, Size } from '../variants.js';
2
3
  export const buttonVariants = tv({
3
4
  base: `
4
5
  inline-flex items-center justify-center font-medium transition-colors focus-visible:outline-none
@@ -12,21 +13,21 @@ export const buttonVariants = tv({
12
13
  link: 'bg-transparent underline-offset-4 hover:underline shadow-none'
13
14
  },
14
15
  color: {
15
- default: 'bg-default-900 text-white hover:bg-default-800 focus-visible:ring-default-500',
16
- primary: 'bg-primary-600 text-white hover:bg-primary-700 focus-visible:ring-primary-500',
17
- secondary: 'bg-secondary-600 text-white hover:bg-secondary-700 focus-visible:ring-secondary-500',
18
- info: 'bg-info-600 text-white hover:bg-info-700 focus-visible:ring-info-500',
19
- success: 'bg-success-600 text-white hover:bg-success-700 focus-visible:ring-success-500',
20
- warning: 'bg-warning-600 text-white hover:bg-warning-700 focus-visible:ring-warning-500',
21
- danger: 'bg-danger-600 text-white hover:bg-danger-700 focus-visible:ring-danger-500'
16
+ [Color.DEFAULT]: 'bg-default-900 text-white hover:bg-default-800 focus-visible:ring-default-500',
17
+ [Color.PRIMARY]: 'bg-primary-600 text-white hover:bg-primary-700 focus-visible:ring-primary-500',
18
+ [Color.SECONDARY]: 'bg-secondary-600 text-white hover:bg-secondary-700 focus-visible:ring-secondary-500',
19
+ [Color.INFO]: 'bg-info-600 text-white hover:bg-info-700 focus-visible:ring-info-500',
20
+ [Color.SUCCESS]: 'bg-success-600 text-white hover:bg-success-700 focus-visible:ring-success-500',
21
+ [Color.WARNING]: 'bg-warning-600 text-white hover:bg-warning-700 focus-visible:ring-warning-500',
22
+ [Color.DANGER]: 'bg-danger-600 text-white hover:bg-danger-700 focus-visible:ring-danger-500'
22
23
  },
23
24
  size: {
24
- xs: 'h-7 px-2 text-xs',
25
- sm: 'h-8 px-3 text-sm',
26
- base: 'h-9 px-4 text-sm',
27
- lg: 'h-10 px-5 text-base',
28
- xl: 'h-12 px-6 text-lg',
29
- '2xl': 'h-14 px-8 text-xl'
25
+ [Size.XS]: 'h-7 px-2 text-xs',
26
+ [Size.SM]: 'h-8 px-3 text-sm',
27
+ [Size.BASE]: 'h-9 px-4 text-sm',
28
+ [Size.LG]: 'h-10 px-5 text-base',
29
+ [Size.XL]: 'h-12 px-6 text-lg',
30
+ [Size.XXL]: 'h-14 px-8 text-xl'
30
31
  },
31
32
  rounded: {
32
33
  none: 'rounded-none',
@@ -0,0 +1,533 @@
1
+ <script lang="ts">
2
+ import { onMount, onDestroy, tick } from 'svelte';
3
+ import { cn } from '../helper/cls.js';
4
+ import * as echarts from 'echarts/core';
5
+ // @ts-expect-error - ECharts types are not available
6
+ import { LineChart, BarChart, PieChart } from 'echarts/charts';
7
+ import {
8
+ // @ts-expect-error - ECharts types are not available
9
+ GridComponent,
10
+ // @ts-expect-error - ECharts types are not available
11
+ TooltipComponent,
12
+ // @ts-expect-error - ECharts types are not available
13
+ TitleComponent,
14
+ // @ts-expect-error - ECharts types are not available
15
+ LegendComponent,
16
+ // @ts-expect-error - ECharts types are not available
17
+ DataZoomComponent,
18
+ // @ts-expect-error - ECharts types are not available
19
+ ToolboxComponent,
20
+ // @ts-expect-error - ECharts types are not available
21
+ MarkLineComponent,
22
+ // @ts-expect-error - ECharts types are not available
23
+ MarkPointComponent,
24
+ // @ts-expect-error - ECharts types are not available
25
+ GraphicComponent
26
+ } from 'echarts/components';
27
+ // @ts-expect-error - ECharts types are not available
28
+ import { SVGRenderer } from 'echarts/renderers';
29
+ import type { ChartProps, ChartColors, ChartColorString } from '../index.js';
30
+
31
+ // @ts-expect-error - ECharts types are not available
32
+ echarts.use([
33
+ LineChart,
34
+ BarChart,
35
+ PieChart,
36
+ GridComponent,
37
+ TooltipComponent,
38
+ TitleComponent,
39
+ LegendComponent,
40
+ DataZoomComponent,
41
+ ToolboxComponent,
42
+ MarkLineComponent,
43
+ MarkPointComponent,
44
+ SVGRenderer,
45
+ GraphicComponent
46
+ ]);
47
+
48
+ let {
49
+ data = [],
50
+ config,
51
+ height = '400px',
52
+ width = '100%',
53
+ class: className = '',
54
+ colors = {},
55
+ onpointclick,
56
+ onchartrender
57
+ }: ChartProps<any> = $props();
58
+
59
+ const theme = 'light';
60
+ const AnimationDuration = 1200;
61
+
62
+ const xAxis = $derived(config.xAxis);
63
+ const yAxis = $derived(config.yAxis);
64
+ const series = $derived(config.series);
65
+
66
+ const grid = $derived(
67
+ config.grid || {
68
+ horizontal: true,
69
+ vertical: false,
70
+ containLabel: true
71
+ }
72
+ );
73
+ const legend = $derived({
74
+ show: true,
75
+ position: 'top',
76
+ orient: 'horizontal',
77
+ ...(config.legend || {})
78
+ });
79
+ const tooltip = $derived(
80
+ config.tooltip || {
81
+ show: true,
82
+ trigger: 'axis',
83
+ formatter: undefined
84
+ }
85
+ );
86
+ const toolbox = $derived(
87
+ config.toolbox || {
88
+ show: false,
89
+ features: {
90
+ saveAsImage: true,
91
+ dataView: false,
92
+ dataZoom: false,
93
+ magicType: true,
94
+ restore: true
95
+ }
96
+ }
97
+ );
98
+
99
+ // Check if we have a pie/donut chart
100
+ const hasPieChart = $derived(series.some((s) => s.type === 'pie'));
101
+
102
+ let chartContainer: HTMLDivElement;
103
+ // @ts-expect-error - ECharts types are not available
104
+ let chart: echarts.ECharts;
105
+ let resizeObserver: ResizeObserver;
106
+
107
+ const defaultChartColors: ChartColors = {
108
+ health: '#1F69FF',
109
+ property: '#2D9D78',
110
+ auto: '#E8A317',
111
+ life: '#E34974',
112
+ other: '#7B3FE4',
113
+ default: '#6B7280'
114
+ };
115
+
116
+ const chartColors: ChartColors = { ...defaultChartColors, ...colors };
117
+
118
+ function getColor(color?: ChartColorString): string | undefined {
119
+ return color ? chartColors[color as keyof ChartColors] || color : undefined;
120
+ }
121
+
122
+ function getSeriesColors(count: number): string[] {
123
+ const baseColors = [
124
+ chartColors.health,
125
+ chartColors.other,
126
+ chartColors.property,
127
+ chartColors.auto,
128
+ chartColors.life,
129
+ chartColors.default
130
+ ];
131
+
132
+ let colors = [...baseColors];
133
+ while (colors.length < count) {
134
+ const index = colors.length % baseColors.length;
135
+ const baseColor = baseColors[index];
136
+ const r = parseInt(baseColor.slice(1, 3), 16);
137
+ const g = parseInt(baseColor.slice(3, 5), 16);
138
+ const b = parseInt(baseColor.slice(5, 7), 16);
139
+ const factor = 0.8 + (colors.length / baseColors.length) * 0.4;
140
+ const newColor = `#${Math.min(255, Math.floor(r * factor))
141
+ .toString(16)
142
+ .padStart(2, '0')}${Math.min(255, Math.floor(g * factor))
143
+ .toString(16)
144
+ .padStart(2, '0')}${Math.min(255, Math.floor(b * factor))
145
+ .toString(16)
146
+ .padStart(2, '0')}`;
147
+ colors.push(newColor);
148
+ }
149
+
150
+ return colors.slice(0, count);
151
+ }
152
+
153
+ function formatValue(value: any, format?: (value: any) => string, unit?: string): string {
154
+ if (format) {
155
+ return format(value);
156
+ }
157
+
158
+ if (unit) {
159
+ return `${value}${unit}`;
160
+ }
161
+
162
+ return String(value);
163
+ }
164
+
165
+ function configureSeries(): any[] {
166
+ return series.map((seriesConfig) => {
167
+ const seriesType = seriesConfig.type || 'line';
168
+
169
+ if (seriesType === 'pie') {
170
+ const pieData = data.map((item) => ({
171
+ value: item[seriesConfig.dataKey],
172
+ name: item[xAxis?.dataKey] || item.label
173
+ }));
174
+
175
+ return {
176
+ name: seriesConfig.name || seriesConfig.dataKey,
177
+ type: 'pie',
178
+ radius: seriesConfig.radius || ['0%', '70%'],
179
+ avoidLabelOverlap: true,
180
+ itemStyle: {
181
+ borderRadius: 4,
182
+ borderWidth: 2,
183
+ borderColor: '#fff',
184
+ color: getColor(seriesConfig.color)
185
+ },
186
+ label: {
187
+ show: seriesConfig.showLabel !== undefined ? seriesConfig.showLabel : true
188
+ },
189
+ labelLine: {
190
+ show: seriesConfig.showLabel !== undefined ? seriesConfig.showLabel : true
191
+ },
192
+ data: pieData,
193
+ animation: true,
194
+ animationDuration: AnimationDuration,
195
+ emphasis: seriesConfig.emphasis || { focus: 'series' }
196
+ };
197
+ }
198
+
199
+ const isHorizontalBar = seriesType === 'horizontal-bar';
200
+ const actualType = isHorizontalBar ? 'bar' : seriesType;
201
+
202
+ const seriesData = data.map((item) => ({
203
+ value: item[seriesConfig.dataKey],
204
+ name: item[xAxis.dataKey]
205
+ }));
206
+
207
+ const barSeriesCount = series.filter(
208
+ (s) => s.type === 'bar' || s.type === 'horizontal-bar'
209
+ ).length;
210
+
211
+ return {
212
+ name: seriesConfig.name || seriesConfig.dataKey,
213
+ type: actualType,
214
+ yAxisIndex: seriesConfig.yAxisIndex || 0,
215
+ data: seriesData,
216
+ stack: seriesConfig.stack,
217
+ color: getColor(seriesConfig.color),
218
+ emphasis: seriesConfig.emphasis || { focus: 'series' },
219
+ animation: true,
220
+ animationDuration: AnimationDuration,
221
+
222
+ ...(actualType === 'line' && {
223
+ smooth: seriesConfig.smooth !== undefined ? seriesConfig.smooth : true,
224
+ showSymbol: seriesConfig.showSymbol !== undefined ? seriesConfig.showSymbol : true,
225
+ symbolSize: 6,
226
+ lineStyle: {
227
+ width: seriesConfig.lineWidth || 2,
228
+ color: getColor(seriesConfig.color),
229
+ type: seriesConfig.lineStyle?.type || 'solid'
230
+ },
231
+ areaStyle: seriesConfig.showArea
232
+ ? {
233
+ color: {
234
+ type: 'linear',
235
+ x: 0,
236
+ y: 0,
237
+ x2: 0,
238
+ y2: 1,
239
+ colorStops: [
240
+ {
241
+ offset: 0,
242
+ color:
243
+ getColor(seriesConfig.color) +
244
+ Math.floor((seriesConfig.areaOpacity || 0.2) * 255).toString(16)
245
+ },
246
+ {
247
+ offset: 1,
248
+ color: getColor(seriesConfig.color) + '00'
249
+ }
250
+ ]
251
+ }
252
+ }
253
+ : undefined
254
+ }),
255
+
256
+ ...(actualType === 'bar' && {
257
+ name: seriesConfig.name || seriesConfig.dataKey,
258
+ type: actualType,
259
+ yAxisIndex: seriesConfig.yAxisIndex || 0,
260
+ data: seriesData,
261
+ stack: null,
262
+ barWidth:
263
+ seriesConfig.barWidth ||
264
+ (barSeriesCount > 3 ? '15%' : barSeriesCount > 1 ? '25%' : '60%'),
265
+ barCategoryGap: '20%',
266
+ barGap: '10%',
267
+ color: getColor(seriesConfig.color),
268
+ itemStyle: {
269
+ color: getColor(seriesConfig.color),
270
+ borderRadius: [4, 4, 0, 0],
271
+ opacity: seriesConfig.opacity || 1
272
+ }
273
+ }),
274
+
275
+ label: {
276
+ show: seriesConfig.showLabel || false,
277
+ position: actualType === 'line' ? 'top' : 'inside',
278
+ // @ts-expect-error - ECharts types are not available
279
+ formatter: (params) => {
280
+ const yAxisIndex = seriesConfig.yAxisIndex || 0;
281
+ const axisConfig = yAxis[yAxisIndex];
282
+ return formatValue(params.value, axisConfig.format, axisConfig.unit);
283
+ }
284
+ }
285
+ };
286
+ });
287
+ }
288
+
289
+ function defaultFormatter(params: any) {
290
+ if (Array.isArray(params)) {
291
+ const item = params[0];
292
+ let html = `<div style="font-weight: bold; margin-bottom: 5px;">${item.name}</div>`;
293
+
294
+ params.forEach((param) => {
295
+ const seriesItem = series.find(
296
+ (s) => s.name === param.seriesName || s.dataKey === param.seriesName
297
+ );
298
+
299
+ if (seriesItem?.type === 'pie') {
300
+ html += `<div style="display: flex; align-items: center; margin: 3px 0;">
301
+ <span style="display: inline-block; width: 10px; height: 10px; background: ${param.color}; border-radius: 50%; margin-right: 5px;"></span>
302
+ <span>${param.seriesName}: ${param.value} (${param.percent}%)</span>
303
+ </div>`;
304
+ } else {
305
+ const yAxisIndex = seriesItem?.yAxisIndex || 0;
306
+ const axisConfig = yAxis[yAxisIndex];
307
+ const formattedValue = formatValue(param.value, axisConfig.format, axisConfig.unit);
308
+
309
+ html += `<div style="display: flex; align-items: center; margin: 3px 0;">
310
+ <span style="display: inline-block; width: 10px; height: 10px; background: ${param.color}; border-radius: 50%; margin-right: 5px;"></span>
311
+ <span>${param.seriesName}: ${formattedValue}</span>
312
+ </div>`;
313
+ }
314
+ });
315
+
316
+ return html;
317
+ } else {
318
+ if (params.seriesType === 'pie') {
319
+ return `${params.name}: ${params.value} (${params.percent}%)`;
320
+ }
321
+
322
+ const seriesItem = series.find(
323
+ (s) => s.name === params.seriesName || s.dataKey === params.seriesName
324
+ );
325
+ const yAxisIndex = seriesItem?.yAxisIndex || 0;
326
+ const axisConfig = yAxis[yAxisIndex];
327
+ const formattedValue = formatValue(params.value, axisConfig.format, axisConfig.unit);
328
+
329
+ return `${params.seriesName}: ${formattedValue}`;
330
+ }
331
+ }
332
+
333
+ function updateChart() {
334
+ if (!chart || !data || !series) return;
335
+
336
+ const colorPalette = getSeriesColors(series.length);
337
+
338
+ if (hasPieChart) {
339
+ // Configure for pie chart
340
+ const pieOptions = {
341
+ color: colorPalette,
342
+
343
+ tooltip: {
344
+ show: tooltip.show,
345
+ trigger: 'item',
346
+ formatter: tooltip.formatter || '{b}: {c} ({d}%)'
347
+ },
348
+
349
+ legend: {
350
+ show: legend.show,
351
+ type: 'scroll',
352
+ orient: legend.orient,
353
+ ...(legend.position === 'top' && { top: 0, left: 'center' }),
354
+ ...(legend.position === 'bottom' && { bottom: 0, left: 'center' }),
355
+ ...(legend.position === 'left' && { left: 0, top: 'middle' }),
356
+ ...(legend.position === 'right' && { right: 0, top: 'middle' })
357
+ },
358
+
359
+ series: configureSeries()
360
+ };
361
+
362
+ // Add center text if specified in the first pie series
363
+ const pieSeriesWithCenterText = series.find((s) => s.type === 'pie' && s.centerText);
364
+ if (pieSeriesWithCenterText?.centerText) {
365
+ // @ts-expect-error - ECharts types are not available
366
+ pieOptions.graphic = {
367
+ elements: [
368
+ {
369
+ type: 'text',
370
+ left: 'center',
371
+ top: 'center',
372
+ style: {
373
+ text: pieSeriesWithCenterText.centerText,
374
+ fontSize: 20,
375
+ fontWeight: 'bold'
376
+ }
377
+ }
378
+ ]
379
+ };
380
+ }
381
+
382
+ chart.setOption(pieOptions, true);
383
+ } else {
384
+ // Regular chart configuration
385
+ const categories = data.map((item) => item[xAxis.dataKey]);
386
+
387
+ const options = {
388
+ color: colorPalette,
389
+
390
+ tooltip: {
391
+ show: tooltip.show,
392
+ trigger: tooltip.trigger,
393
+ formatter: tooltip.formatter || defaultFormatter
394
+ },
395
+
396
+ legend: {
397
+ show: legend.show,
398
+ type: 'scroll',
399
+ orient: legend.orient,
400
+ ...(legend.position === 'top' && { top: 0, left: 'center' }),
401
+ ...(legend.position === 'bottom' && { bottom: 0, left: 'center' }),
402
+ ...(legend.position === 'left' && { left: 0, top: 'middle' }),
403
+ ...(legend.position === 'right' && { right: 0, top: 'middle' })
404
+ },
405
+
406
+ grid: {
407
+ top: legend.position === 'top' ? '15%' : grid.top || '10%',
408
+ right: grid.right || '3%',
409
+ bottom: legend.position === 'bottom' ? '15%' : grid.bottom || '10%',
410
+ left: grid.left || '3%',
411
+ containLabel: grid.containLabel !== undefined ? grid.containLabel : true
412
+ },
413
+
414
+ xAxis: {
415
+ type: 'category',
416
+ data: categories,
417
+ axisLabel: {
418
+ ...(xAxis.tick && {
419
+ fontSize: xAxis.tick.fontSize,
420
+ rotate: xAxis.tick.rotate,
421
+ interval: xAxis.tick.interval
422
+ }),
423
+ formatter: xAxis.format || '{value}'
424
+ },
425
+ name: xAxis.label,
426
+ nameLocation: 'middle',
427
+ nameGap: 30,
428
+ splitLine: {
429
+ show: grid.vertical || false
430
+ }
431
+ },
432
+
433
+ yAxis: yAxis.map((axis, index) => ({
434
+ type: 'value',
435
+ name: axis.label,
436
+ nameLocation: 'middle',
437
+ nameGap: 50,
438
+ nameRotate: 90,
439
+ position: axis.position || (index === 0 ? 'left' : 'right'),
440
+ min: axis.min,
441
+ max: axis.max,
442
+ axisLine: {
443
+ show: true,
444
+ lineStyle: {
445
+ color: getColor(axis.color)
446
+ }
447
+ },
448
+ axisLabel: {
449
+ // @ts-expect-error - ECharts types are not available
450
+ formatter: (value) => formatValue(value, axis.format, axis.unit)
451
+ },
452
+ splitLine: {
453
+ show: index === 0 ? grid.horizontal || true : false
454
+ }
455
+ })),
456
+
457
+ toolbox: toolbox.show
458
+ ? {
459
+ feature: {
460
+ ...(toolbox.features?.saveAsImage && { saveAsImage: {} }),
461
+ ...(toolbox.features?.dataView && { dataView: { readOnly: false } }),
462
+ ...(toolbox.features?.dataZoom && { dataZoom: { yAxisIndex: 'none' } }),
463
+ ...(toolbox.features?.magicType && {
464
+ magicType: { type: ['line', 'bar', 'stack'] }
465
+ }),
466
+ ...(toolbox.features?.restore && { restore: {} })
467
+ }
468
+ }
469
+ : undefined,
470
+
471
+ series: configureSeries()
472
+ };
473
+
474
+ chart.setOption(options, true);
475
+ }
476
+
477
+ if (onchartrender) {
478
+ onchartrender({
479
+ detail: {
480
+ chart,
481
+ options: chart.getOption()
482
+ }
483
+ });
484
+ }
485
+ }
486
+
487
+ onMount(() => {
488
+ // @ts-expect-error - ECharts types are not available
489
+ chart = echarts.init(chartContainer, theme);
490
+
491
+ // Instantly triggering resizes disables animation, hence the timeout
492
+ setTimeout(() => {
493
+ resizeObserver = new ResizeObserver(() => {
494
+ chart?.resize();
495
+ });
496
+ resizeObserver.observe(chartContainer);
497
+ }, AnimationDuration);
498
+
499
+ updateChart();
500
+ // @ts-expect-error - ECharts types are not available
501
+ chart.on('click', (params) => {
502
+ if (onpointclick) {
503
+ onpointclick({
504
+ detail: {
505
+ seriesIndex: params.seriesIndex,
506
+ dataIndex: params.dataIndex,
507
+ seriesName: params.seriesName,
508
+ name: params.name,
509
+ value: params.value,
510
+ originalData: data[params.dataIndex]
511
+ }
512
+ });
513
+ }
514
+ });
515
+ });
516
+
517
+ $effect(() => {
518
+ if (chart && data && series) {
519
+ updateChart();
520
+ }
521
+ });
522
+
523
+ onDestroy(() => {
524
+ resizeObserver?.disconnect();
525
+ chart?.dispose();
526
+ });
527
+ </script>
528
+
529
+ <div
530
+ class={cn('advanced-chart', className)}
531
+ style="height: {height}; width: {width}"
532
+ bind:this={chartContainer}
533
+ ></div>
@@ -0,0 +1,4 @@
1
+ import type { ChartProps } from '../index.js';
2
+ declare const Chart: import("svelte").Component<ChartProps<any>, {}, "">;
3
+ type Chart = ReturnType<typeof Chart>;
4
+ export default Chart;
@@ -4,7 +4,8 @@
4
4
  import { fade, fly } from 'svelte/transition';
5
5
  import { quintOut } from 'svelte/easing';
6
6
  import { cn } from '../helper/cls.js';
7
- import { drawer, type DrawerProps } from './drawer.js';
7
+ import { drawer } from './drawer.js';
8
+ import type { DrawerProps } from '../index.js';
8
9
 
9
10
  let {
10
11
  open = $bindable(false),
@@ -14,12 +15,14 @@
14
15
  size = 'sm',
15
16
  children,
16
17
  header,
18
+ footer,
17
19
  class: className = '',
18
20
  backdropclass: backdropClassName = '',
19
21
  contentclass: contentClassName = '',
20
22
  headerclass: headerClassName = '',
21
23
  bodyclass: bodyClassName = '',
22
- titleclass: titleClassName = ''
24
+ titleclass: titleClassName = '',
25
+ footerclass: footerClassName = ''
23
26
  }: DrawerProps = $props();
24
27
 
25
28
  let drawerElement: HTMLDivElement | undefined = $state();
@@ -50,6 +53,7 @@
50
53
  const bodyClass = $derived(cn(body(), bodyClassName));
51
54
  const titleClasses = $derived(cn(titleClass(), titleClassName));
52
55
  const closeButtonClasses = $derived(cn(closeButton(), ''));
56
+ const footerClass = $derived(cn(footerVClass(), 'mt-auto', footerClassName));
53
57
 
54
58
  function handleBackdropClick(e: MouseEvent) {
55
59
  if (e.target === e.currentTarget) {
@@ -206,6 +210,13 @@
206
210
  {@render children()}
207
211
  {/if}
208
212
  </div>
213
+
214
+ <!-- Add footer section -->
215
+ {#if footer}
216
+ <div class={footerClass}>
217
+ {@render footer()}
218
+ </div>
219
+ {/if}
209
220
  </div>
210
221
  </div>
211
222
  {/key}
@@ -1,4 +1,4 @@
1
- import { type DrawerProps } from './drawer.js';
1
+ import type { DrawerProps } from '../index.js';
2
2
  declare const Drawer: import("svelte").Component<DrawerProps, {}, "open">;
3
3
  type Drawer = ReturnType<typeof Drawer>;
4
4
  export default Drawer;
@@ -1,5 +1,3 @@
1
- import type { VariantSizes } from '../types/variants.js';
2
- import type { Snippet } from 'svelte';
3
1
  export declare const drawer: import("tailwind-variants").TVReturnType<{
4
2
  open: {
5
3
  true: {
@@ -160,18 +158,3 @@ export declare const drawer: import("tailwind-variants").TVReturnType<{
160
158
  title: string;
161
159
  closeButton: string;
162
160
  }, undefined, unknown, unknown, undefined>>;
163
- export type DrawerProps = {
164
- open?: boolean;
165
- onclose?: () => void;
166
- title?: string;
167
- position?: keyof typeof drawer.variants.position;
168
- size?: VariantSizes;
169
- class?: string;
170
- backdropclass?: string;
171
- contentclass?: string;
172
- headerclass?: string;
173
- bodyclass?: string;
174
- titleclass?: string;
175
- children?: Snippet;
176
- header?: Snippet;
177
- };