@saasmakers/ui 0.1.71 → 0.1.72
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.
- package/app/composables/useChartist.ts +37 -26
- package/app/types/global.d.ts +1 -1
- package/nuxt.config.ts +2 -2
- package/package.json +1 -2
- package/uno.config.ts +3 -2
|
@@ -1,36 +1,42 @@
|
|
|
1
|
+
import type { AreaDrawEvent, BarChartOptions, BarDrawEvent, BaseChart, DrawEvent, LineDrawEvent, Options } from 'chartist'
|
|
2
|
+
import { easings } from 'chartist'
|
|
3
|
+
|
|
1
4
|
export default function useChartist() {
|
|
5
|
+
type EasingType = keyof typeof easings | number[]
|
|
6
|
+
|
|
2
7
|
const progressiveLinePlugin = (params: {
|
|
3
8
|
animateArea?: boolean
|
|
4
9
|
delay?: number
|
|
5
10
|
duration?: number
|
|
6
|
-
easing?:
|
|
11
|
+
easing?: EasingType
|
|
7
12
|
stagger?: number
|
|
8
13
|
} = {}) => {
|
|
9
14
|
const {
|
|
10
15
|
animateArea = true,
|
|
11
16
|
delay = 0,
|
|
12
17
|
duration = 500,
|
|
13
|
-
easing =
|
|
18
|
+
easing = easings.easeOutQuart,
|
|
14
19
|
stagger = 0,
|
|
15
20
|
} = params
|
|
16
21
|
|
|
17
|
-
return (chart:
|
|
18
|
-
chart.on('draw', (ctx:
|
|
22
|
+
return (chart: BaseChart) => {
|
|
23
|
+
chart.on('draw', (ctx: DrawEvent) => {
|
|
19
24
|
const begin = delay + (stagger ? stagger * (ctx.seriesIndex ?? 0) : 0)
|
|
20
25
|
|
|
21
26
|
// Animation for line charts
|
|
22
27
|
if (ctx.type === 'line') {
|
|
23
|
-
const
|
|
28
|
+
const lineCtx = ctx as LineDrawEvent
|
|
29
|
+
const node = lineCtx.element.getNode<SVGPathElement>()
|
|
24
30
|
const length = node.getTotalLength()
|
|
25
31
|
|
|
26
32
|
// Set the stroke dasharray and dashoffset
|
|
27
|
-
|
|
33
|
+
lineCtx.element.attr({
|
|
28
34
|
'stroke-dasharray': `${length}px ${length}px`,
|
|
29
35
|
'stroke-dashoffset': `${length}px`,
|
|
30
36
|
})
|
|
31
37
|
|
|
32
38
|
// Animate the stroke dashoffset to 0
|
|
33
|
-
|
|
39
|
+
lineCtx.element.animate({
|
|
34
40
|
'stroke-dashoffset': {
|
|
35
41
|
begin,
|
|
36
42
|
dur: duration,
|
|
@@ -42,67 +48,72 @@ export default function useChartist() {
|
|
|
42
48
|
}, false)
|
|
43
49
|
|
|
44
50
|
// Clean up the dash attributes after it finishes
|
|
45
|
-
const total = delay + duration + (stagger ? stagger * (
|
|
51
|
+
const total = delay + duration + (stagger ? stagger * (lineCtx.seriesIndex ?? 0) : 0)
|
|
46
52
|
|
|
47
53
|
window.setTimeout(() => {
|
|
48
|
-
|
|
49
|
-
'stroke-dasharray':
|
|
50
|
-
'stroke-dashoffset':
|
|
54
|
+
lineCtx.element.attr({
|
|
55
|
+
'stroke-dasharray': undefined,
|
|
56
|
+
'stroke-dashoffset': undefined,
|
|
51
57
|
})
|
|
52
58
|
}, total + 30)
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
// Animation for area charts
|
|
56
62
|
if (animateArea && ctx.type === 'area') {
|
|
57
|
-
ctx
|
|
63
|
+
const areaCtx = ctx as AreaDrawEvent
|
|
64
|
+
|
|
65
|
+
areaCtx.element.animate({
|
|
58
66
|
// eslint-disable-next-line id-length -- SVG path attribute
|
|
59
67
|
d: {
|
|
60
68
|
begin,
|
|
61
69
|
dur: duration,
|
|
62
70
|
easing,
|
|
63
71
|
fill: 'freeze',
|
|
64
|
-
from:
|
|
72
|
+
from: areaCtx.path
|
|
65
73
|
.clone()
|
|
66
74
|
.scale(1, 0)
|
|
67
|
-
.translate(0,
|
|
75
|
+
.translate(0, areaCtx.chartRect.height())
|
|
68
76
|
.stringify(),
|
|
69
|
-
to:
|
|
77
|
+
to: areaCtx.path.stringify(),
|
|
70
78
|
},
|
|
71
79
|
}, false)
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
// Animation for bar charts
|
|
75
83
|
if (ctx.type === 'bar') {
|
|
76
|
-
const
|
|
84
|
+
const barCtx = ctx as BarDrawEvent
|
|
85
|
+
// Access private options property via type assertion
|
|
86
|
+
const chartOptions = (chart as unknown as { options?: Options & Partial<BarChartOptions> }).options
|
|
87
|
+
const horizontal = !!(chartOptions as BarChartOptions | undefined)?.horizontalBars
|
|
77
88
|
|
|
78
89
|
// For vertical bars, y1 is baseline, y2 is top. For horizontal, x1 is baseline, x2 is end.
|
|
79
|
-
const from = horizontal ?
|
|
80
|
-
const to = horizontal ?
|
|
90
|
+
const from = horizontal ? barCtx.x1 : barCtx.y1
|
|
91
|
+
const to = horizontal ? barCtx.x2 : barCtx.y2
|
|
81
92
|
|
|
82
93
|
// Start collapsed at baseline
|
|
83
94
|
if (horizontal) {
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
barCtx.element.attr({ x2: from })
|
|
96
|
+
barCtx.element.animate({
|
|
86
97
|
x2: {
|
|
87
98
|
begin,
|
|
88
99
|
dur: duration,
|
|
89
100
|
easing,
|
|
90
101
|
fill: 'freeze',
|
|
91
|
-
from,
|
|
92
|
-
to,
|
|
102
|
+
from: String(from),
|
|
103
|
+
to: String(to),
|
|
93
104
|
},
|
|
94
105
|
}, false)
|
|
95
106
|
}
|
|
96
107
|
else {
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
barCtx.element.attr({ y2: from })
|
|
109
|
+
barCtx.element.animate({
|
|
99
110
|
y2: {
|
|
100
111
|
begin,
|
|
101
112
|
dur: duration,
|
|
102
113
|
easing,
|
|
103
114
|
fill: 'freeze',
|
|
104
|
-
from,
|
|
105
|
-
to,
|
|
115
|
+
from: String(from),
|
|
116
|
+
to: String(to),
|
|
106
117
|
},
|
|
107
118
|
}, false)
|
|
108
119
|
}
|
package/app/types/global.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type * as Fields from './fields'
|
|
|
5
5
|
declare module '@vue/runtime-core' {
|
|
6
6
|
interface ComponentCustomProperties {
|
|
7
7
|
vHotkey?: Record<string, (event?: KeyboardEvent | MouseEvent) => void>
|
|
8
|
-
vTooltip?: Record<string,
|
|
8
|
+
vTooltip?: Record<string, unknown> | string
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasmakers/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.72",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Reusable Nuxt UI components for SaaS Makers projects",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"@nuxtjs/robots": "5.5.6",
|
|
35
35
|
"@nuxtjs/sitemap": "7.4.7",
|
|
36
36
|
"@pinia/nuxt": "0.11.2",
|
|
37
|
-
"@types/chartist": "1.0.4",
|
|
38
37
|
"@unocss/nuxt": "66.5.4",
|
|
39
38
|
"@unocss/reset": "66.5.10",
|
|
40
39
|
"@vuelidate/core": "2.0.3",
|
package/uno.config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Preset } from 'unocss'
|
|
1
2
|
import { defineConfig, presetWind3 } from 'unocss'
|
|
2
3
|
|
|
3
|
-
export const presets = [presetWind3()]
|
|
4
|
+
export const presets: Preset[] = [presetWind3()]
|
|
4
5
|
|
|
5
6
|
export const rules: Array<[string, Record<string, string>]> = [
|
|
6
7
|
[
|
|
@@ -185,7 +186,7 @@ export const theme = {
|
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
export default defineConfig({
|
|
188
|
-
presets
|
|
189
|
+
presets,
|
|
189
190
|
rules,
|
|
190
191
|
theme,
|
|
191
192
|
})
|