@makolabs/ripple 0.0.1-dev.30 → 0.0.1-dev.31
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 +4 -7
- package/dist/index.js +5 -1
- 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,4 +1,4 @@
|
|
|
1
|
-
import { Color, Size } from './variants.js';
|
|
1
|
+
import { ChartColor, Color, Size } from './variants.js';
|
|
2
2
|
export type VariantColors = (typeof Color)[keyof typeof Color];
|
|
3
3
|
export type VariantSizes = (typeof Size)[keyof typeof Size];
|
|
4
4
|
export { Color, Size };
|
|
@@ -336,13 +336,10 @@ export { modal } from './modal/modal.js';
|
|
|
336
336
|
export { drawer } from './drawer/drawer.js';
|
|
337
337
|
export { selectTV } from './elements/dropdown/select.js';
|
|
338
338
|
export { breadcrumbs } from './header/breadcrumbs.js';
|
|
339
|
+
export type ChartColorKey = keyof typeof ChartColor;
|
|
340
|
+
export type ChartColorValue = typeof ChartColor[ChartColorKey];
|
|
339
341
|
export type ChartColors = {
|
|
340
|
-
|
|
341
|
-
property: string;
|
|
342
|
-
auto: string;
|
|
343
|
-
life: string;
|
|
344
|
-
other: string;
|
|
345
|
-
default: string;
|
|
342
|
+
[K in ChartColorValue]: string;
|
|
346
343
|
};
|
|
347
344
|
export type ChartType = 'line' | 'bar' | 'horizontal-bar' | 'pie';
|
|
348
345
|
export type ChartColorString = `#${string}` | keyof ChartColors;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { Color, Size } from './variants.js';
|
|
1
|
+
import { ChartColor, Color, Size } from './variants.js';
|
|
2
2
|
/*
|
|
3
3
|
All colors and sizes, will be assign via this enum, else it will be considered against the convention
|
|
4
|
+
Color is a type that maps the Color enum values to their corresponding string values.
|
|
5
|
+
Color Usage: Color.DEFAULT, Color.PRIMARY, Color.SECONDARY, Color.INFO, Color.SUCCESS, Color.WARNING, Color.DANGER
|
|
6
|
+
Size is a type that maps the Size enum values to their corresponding string values.
|
|
7
|
+
Size Usage: Size.XS, Size.SM, Size.BASE, Size.LG, Size.XL, Size.XXL
|
|
4
8
|
*/
|
|
5
9
|
export { Color, Size };
|
|
6
10
|
// Helper utilities
|
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);
|