@makolabs/ripple 0.0.1-dev.30 → 0.0.1-dev.32
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/dist/charts/Chart.svelte +47 -42
- package/dist/charts/Chart.svelte.d.ts +1 -1
- package/dist/index.d.ts +18 -9
- package/dist/index.js +10 -5
- package/dist/variants.d.ts +11 -1
- package/dist/variants.js +17 -0
- package/package.json +1 -1
package/dist/charts/Chart.svelte
CHANGED
|
@@ -26,7 +26,13 @@
|
|
|
26
26
|
} from 'echarts/components';
|
|
27
27
|
// @ts-expect-error - ECharts types are not available
|
|
28
28
|
import { SVGRenderer } from 'echarts/renderers';
|
|
29
|
-
import
|
|
29
|
+
import {
|
|
30
|
+
type ChartProps,
|
|
31
|
+
type ChartColorString,
|
|
32
|
+
type ChartColors,
|
|
33
|
+
type SeriesConfig
|
|
34
|
+
} from '../index.js';
|
|
35
|
+
import { defaultChartColors } from '../variants.js';
|
|
30
36
|
|
|
31
37
|
// @ts-expect-error - ECharts types are not available
|
|
32
38
|
echarts.use([
|
|
@@ -104,31 +110,52 @@
|
|
|
104
110
|
let chart: echarts.ECharts;
|
|
105
111
|
let resizeObserver: ResizeObserver;
|
|
106
112
|
|
|
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
113
|
const chartColors: ChartColors = { ...defaultChartColors, ...colors };
|
|
114
|
+
const baseColors = [
|
|
115
|
+
chartColors.health,
|
|
116
|
+
chartColors.other,
|
|
117
|
+
chartColors.property,
|
|
118
|
+
chartColors.auto,
|
|
119
|
+
chartColors.life,
|
|
120
|
+
chartColors.default
|
|
121
|
+
];
|
|
117
122
|
|
|
118
123
|
function getColor(color?: ChartColorString): string | undefined {
|
|
119
124
|
return color ? chartColors[color as keyof ChartColors] || color : undefined;
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
function getAreaStyle(seriesConfig: SeriesConfig<any>) {
|
|
128
|
+
if (!seriesConfig.color) return undefined;
|
|
129
|
+
const baseLinearAreaStyle = {
|
|
130
|
+
type: 'linear',
|
|
131
|
+
x: 0,
|
|
132
|
+
y: 0,
|
|
133
|
+
x2: 0,
|
|
134
|
+
y2: 1
|
|
135
|
+
};
|
|
136
|
+
const color = getColor(seriesConfig.color);
|
|
137
|
+
const opacity = seriesConfig.areaOpacity || 0.2;
|
|
138
|
+
const opacityHex = Math.floor(opacity * 255)
|
|
139
|
+
.toString(16)
|
|
140
|
+
.padStart(2, '0');
|
|
141
|
+
return {
|
|
142
|
+
color: {
|
|
143
|
+
...baseLinearAreaStyle,
|
|
144
|
+
colorStops: [
|
|
145
|
+
{
|
|
146
|
+
offset: 0,
|
|
147
|
+
color: color + opacityHex
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
offset: 1,
|
|
151
|
+
color: color + '00'
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
131
157
|
|
|
158
|
+
function getSeriesColors(count: number): string[] {
|
|
132
159
|
let colors = [...baseColors];
|
|
133
160
|
while (colors.length < count) {
|
|
134
161
|
const index = colors.length % baseColors.length;
|
|
@@ -228,29 +255,7 @@
|
|
|
228
255
|
color: getColor(seriesConfig.color),
|
|
229
256
|
type: seriesConfig.lineStyle?.type || 'solid'
|
|
230
257
|
},
|
|
231
|
-
areaStyle: seriesConfig
|
|
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
|
|
258
|
+
areaStyle: getAreaStyle(seriesConfig)
|
|
254
259
|
}),
|
|
255
260
|
|
|
256
261
|
...(actualType === 'bar' && {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import { Color, Size } from './variants.js';
|
|
2
|
-
|
|
1
|
+
import { ChartColor, Color, Size } from './variants.js';
|
|
2
|
+
/**
|
|
3
|
+
* Size System:
|
|
4
|
+
* - Size.*: Component dimensions (XS, SM, BASE, LG, XL, XXL)
|
|
5
|
+
*/
|
|
3
6
|
export type VariantSizes = (typeof Size)[keyof typeof Size];
|
|
4
|
-
export
|
|
7
|
+
export type VariantColors = (typeof Color)[keyof typeof Color];
|
|
8
|
+
/**
|
|
9
|
+
* Color System:
|
|
10
|
+
* - Color.*: UI component colors (buttons, text, backgrounds)
|
|
11
|
+
* Options: DEFAULT, PRIMARY, SECONDARY, INFO, SUCCESS, WARNING, DANGER
|
|
12
|
+
* - ChartColor.*: Chart-specific colors, only supported within series configurations (lines, areas, bars)
|
|
13
|
+
* Options: HEALTH, PROPERTY, AUTO, LIFE, OTHER, DEFAULT
|
|
14
|
+
* - ChartColors: Record type mapping ChartColor enum to string values
|
|
15
|
+
*/
|
|
16
|
+
export { Color, Size, ChartColor };
|
|
5
17
|
import type { ClassValue } from 'tailwind-variants';
|
|
6
18
|
import type { Snippet } from 'svelte';
|
|
7
19
|
import type { Component } from 'svelte';
|
|
@@ -336,13 +348,10 @@ export { modal } from './modal/modal.js';
|
|
|
336
348
|
export { drawer } from './drawer/drawer.js';
|
|
337
349
|
export { selectTV } from './elements/dropdown/select.js';
|
|
338
350
|
export { breadcrumbs } from './header/breadcrumbs.js';
|
|
351
|
+
export type ChartColorKey = keyof typeof ChartColor;
|
|
352
|
+
export type ChartColorValue = typeof ChartColor[ChartColorKey];
|
|
339
353
|
export type ChartColors = {
|
|
340
|
-
|
|
341
|
-
property: string;
|
|
342
|
-
auto: string;
|
|
343
|
-
life: string;
|
|
344
|
-
other: string;
|
|
345
|
-
default: string;
|
|
354
|
+
[K in ChartColorValue]: string;
|
|
346
355
|
};
|
|
347
356
|
export type ChartType = 'line' | 'bar' | 'horizontal-bar' | 'pie';
|
|
348
357
|
export type ChartColorString = `#${string}` | keyof ChartColors;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { Color, Size } from './variants.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ChartColor, Color, Size } from './variants.js';
|
|
2
|
+
/**
|
|
3
|
+
* Color System:
|
|
4
|
+
* - Color.*: UI component colors (buttons, text, backgrounds)
|
|
5
|
+
* Options: DEFAULT, PRIMARY, SECONDARY, INFO, SUCCESS, WARNING, DANGER
|
|
6
|
+
* - ChartColor.*: Chart-specific colors, only supported within series configurations (lines, areas, bars)
|
|
7
|
+
* Options: HEALTH, PROPERTY, AUTO, LIFE, OTHER, DEFAULT
|
|
8
|
+
* - ChartColors: Record type mapping ChartColor enum to string values
|
|
9
|
+
*/
|
|
10
|
+
export { Color, Size, ChartColor };
|
|
6
11
|
// Helper utilities
|
|
7
12
|
export { tv, cn } from './helper/cls.js';
|
|
8
13
|
export { isRouteActive } from './helper/nav.svelte.js';
|
package/dist/variants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { VariantColors, VariantSizes } from './index.js';
|
|
1
|
+
import type { ChartColors, VariantColors, VariantSizes } from './index.js';
|
|
2
2
|
export declare const Color: {
|
|
3
3
|
DEFAULT: string;
|
|
4
4
|
PRIMARY: string;
|
|
@@ -16,5 +16,15 @@ export declare const Size: {
|
|
|
16
16
|
XL: string;
|
|
17
17
|
XXL: string;
|
|
18
18
|
};
|
|
19
|
+
export declare const ChartColor: {
|
|
20
|
+
readonly HEALTH: "health";
|
|
21
|
+
readonly PROPERTY: "property";
|
|
22
|
+
readonly AUTO: "auto";
|
|
23
|
+
readonly LIFE: "life";
|
|
24
|
+
readonly OTHER: "other";
|
|
25
|
+
readonly DEFAULT: "default";
|
|
26
|
+
};
|
|
27
|
+
export declare const defaultChartColors: ChartColors;
|
|
19
28
|
export declare const colors: VariantColors[];
|
|
20
29
|
export declare const sizes: VariantSizes[];
|
|
30
|
+
export declare const chartColors: ("default" | "health" | "property" | "auto" | "life" | "other")[];
|
package/dist/variants.js
CHANGED
|
@@ -15,5 +15,22 @@ export const Size = {
|
|
|
15
15
|
XL: 'xl',
|
|
16
16
|
XXL: '2xl'
|
|
17
17
|
};
|
|
18
|
+
export const ChartColor = {
|
|
19
|
+
HEALTH: 'health',
|
|
20
|
+
PROPERTY: 'property',
|
|
21
|
+
AUTO: 'auto',
|
|
22
|
+
LIFE: 'life',
|
|
23
|
+
OTHER: 'other',
|
|
24
|
+
DEFAULT: 'default'
|
|
25
|
+
};
|
|
26
|
+
export const defaultChartColors = {
|
|
27
|
+
[ChartColor.HEALTH]: '#1F69FF',
|
|
28
|
+
[ChartColor.PROPERTY]: '#2D9D78',
|
|
29
|
+
[ChartColor.AUTO]: '#E8A317',
|
|
30
|
+
[ChartColor.LIFE]: '#E34974',
|
|
31
|
+
[ChartColor.OTHER]: '#7B3FE4',
|
|
32
|
+
[ChartColor.DEFAULT]: '#6B7280'
|
|
33
|
+
};
|
|
18
34
|
export const colors = Object.values(Color);
|
|
19
35
|
export const sizes = Object.values(Size);
|
|
36
|
+
export const chartColors = Object.values(ChartColor);
|