@saasmakers/ui 0.1.70 → 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.
@@ -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?: any
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 = (window as any)?.Chartist?.Svg?.Easing?.easeOutQuart,
18
+ easing = easings.easeOutQuart,
14
19
  stagger = 0,
15
20
  } = params
16
21
 
17
- return (chart: any) => {
18
- chart.on('draw', (ctx: any) => {
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 node: SVGPathElement = ctx.element._node
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
- ctx.element.attr({
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
- ctx.element.animate({
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 * (ctx.seriesIndex ?? 0) : 0)
51
+ const total = delay + duration + (stagger ? stagger * (lineCtx.seriesIndex ?? 0) : 0)
46
52
 
47
53
  window.setTimeout(() => {
48
- ctx.element.attr({
49
- 'stroke-dasharray': null,
50
- 'stroke-dashoffset': null,
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.element.animate({
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: ctx.path
72
+ from: areaCtx.path
65
73
  .clone()
66
74
  .scale(1, 0)
67
- .translate(0, ctx.chartRect.height())
75
+ .translate(0, areaCtx.chartRect.height())
68
76
  .stringify(),
69
- to: ctx.path.stringify(),
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 horizontal = !!chart.options?.horizontalBars
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 ? ctx.x1 : ctx.y1
80
- const to = horizontal ? ctx.x2 : ctx.y2
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
- ctx.element.attr({ x2: from })
85
- ctx.element.animate({
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
- ctx.element.attr({ y2: from })
98
- ctx.element.animate({
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
  }
@@ -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, any> | string
8
+ vTooltip?: Record<string, unknown> | string
9
9
  }
10
10
  }
11
11
 
package/nuxt.config.ts CHANGED
@@ -116,8 +116,8 @@ export default defineNuxtConfig({
116
116
 
117
117
  unocss: {
118
118
  nuxtLayers: true,
119
- presets: uno.presets as any,
120
- rules: uno.rules as any,
119
+ presets: uno.presets,
120
+ rules: uno.rules,
121
121
  theme: uno.theme,
122
122
  },
123
123
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
3
  "type": "module",
4
- "version": "0.1.70",
4
+ "version": "0.1.72",
5
5
  "private": false,
6
6
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
7
7
  "license": "MIT",
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: [presetWind3()] as any,
189
+ presets,
189
190
  rules,
190
191
  theme,
191
192
  })