@flux-ui/statistics 3.0.0-next.74 → 3.0.0-next.75
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/component/FluxStatisticsLegend.vue.d.ts +7 -1
- package/dist/composable/index.d.ts +2 -0
- package/dist/composable/useLegendVariant.d.ts +3 -0
- package/dist/index.css +38 -0
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/component/FluxStatisticsLegend.vue +23 -3
- package/src/component/FluxStatisticsLegendItem.vue +9 -2
- package/src/composable/index.ts +2 -0
- package/src/composable/useLegendVariant.ts +5 -0
- package/src/css/Legend.module.scss +45 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flux-ui/statistics",
|
|
3
3
|
"description": "Statistics components for the Flux UI library.",
|
|
4
|
-
"version": "3.0.0-next.
|
|
4
|
+
"version": "3.0.0-next.75",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/basmilius",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@basmilius/common": "^3.40.0",
|
|
53
53
|
"@basmilius/utils": "^3.40.0",
|
|
54
|
-
"@flux-ui/components": "3.0.0-next.
|
|
55
|
-
"@flux-ui/internals": "3.0.0-next.
|
|
56
|
-
"@flux-ui/types": "3.0.0-next.
|
|
54
|
+
"@flux-ui/components": "3.0.0-next.75",
|
|
55
|
+
"@flux-ui/internals": "3.0.0-next.75",
|
|
56
|
+
"@flux-ui/types": "3.0.0-next.75",
|
|
57
57
|
"clsx": "^2.1.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="
|
|
2
|
+
<div :class="containerClass">
|
|
3
3
|
<slot v-if="hasSlot"/>
|
|
4
4
|
<FluxStatisticsLegendItem
|
|
5
5
|
v-else
|
|
@@ -18,17 +18,37 @@
|
|
|
18
18
|
<script
|
|
19
19
|
lang="ts"
|
|
20
20
|
setup>
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import type { FluxDirection } from '@flux-ui/types';
|
|
22
|
+
import { clsx } from 'clsx';
|
|
23
|
+
import { computed, inject, provide, toRef, useSlots } from 'vue';
|
|
24
|
+
import { FluxStatisticsChartLegendInjectionKey, type FluxStatisticsLegendVariant, FluxStatisticsLegendVariantInjectionKey } from '~flux/statistics/composable';
|
|
23
25
|
import FluxStatisticsLegendItem from './FluxStatisticsLegendItem.vue';
|
|
24
26
|
import $style from '~flux/statistics/css/Legend.module.scss';
|
|
25
27
|
|
|
28
|
+
const {
|
|
29
|
+
direction = 'horizontal',
|
|
30
|
+
variant = 'detailed'
|
|
31
|
+
} = defineProps<{
|
|
32
|
+
readonly direction?: FluxDirection;
|
|
33
|
+
readonly variant?: FluxStatisticsLegendVariant;
|
|
34
|
+
}>();
|
|
35
|
+
|
|
26
36
|
const slots = useSlots();
|
|
27
37
|
const legendContext = inject(FluxStatisticsChartLegendInjectionKey, null);
|
|
28
38
|
|
|
29
39
|
const hasSlot = computed(() => !!slots.default);
|
|
30
40
|
const autoItems = computed(() => legendContext?.items.value ?? []);
|
|
31
41
|
|
|
42
|
+
const containerClass = computed(() => {
|
|
43
|
+
if (variant === 'compact') {
|
|
44
|
+
return clsx($style.statisticsLegendCompact, direction === 'vertical' ? $style.isVertical : $style.isHorizontal);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return $style.statisticsLegend;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
provide(FluxStatisticsLegendVariantInjectionKey, toRef(() => variant));
|
|
51
|
+
|
|
32
52
|
function onItemMouseEnter(index: number): void {
|
|
33
53
|
if (legendContext) {
|
|
34
54
|
legendContext.hoveredIndex.value = index;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="clsx(
|
|
3
|
+
:class="clsx(
|
|
4
|
+
variant === 'compact' ? $style.statisticsLegendItemCompact : $style.statisticsLegendItem,
|
|
5
|
+
variant !== 'compact' && isHovered && $style.isHovered
|
|
6
|
+
)"
|
|
4
7
|
:style="{
|
|
5
8
|
'--color': colorValue
|
|
6
9
|
}">
|
|
@@ -34,7 +37,8 @@
|
|
|
34
37
|
import { FluxIcon } from '@flux-ui/components';
|
|
35
38
|
import type { FluxColor, FluxIconName } from '@flux-ui/types';
|
|
36
39
|
import { clsx } from 'clsx';
|
|
37
|
-
import { computed } from 'vue';
|
|
40
|
+
import { computed, inject } from 'vue';
|
|
41
|
+
import { FluxStatisticsLegendVariantInjectionKey } from '~flux/statistics/composable';
|
|
38
42
|
import $style from '~flux/statistics/css/Legend.module.scss';
|
|
39
43
|
|
|
40
44
|
const {
|
|
@@ -47,6 +51,9 @@
|
|
|
47
51
|
readonly value?: string | number;
|
|
48
52
|
}>();
|
|
49
53
|
|
|
54
|
+
const variantRef = inject(FluxStatisticsLegendVariantInjectionKey, null);
|
|
55
|
+
const variant = computed(() => variantRef?.value ?? 'detailed');
|
|
56
|
+
|
|
50
57
|
const colorValue = computed(() => {
|
|
51
58
|
if (!color) {
|
|
52
59
|
return;
|
package/src/composable/index.ts
CHANGED
|
@@ -10,3 +10,5 @@ export type { UseChartSlicesSetupReturn } from './useChartSlicesSetup';
|
|
|
10
10
|
export { useChartSlicesSetup } from './useChartSlicesSetup';
|
|
11
11
|
export type { EChartsInstance, EChartsOption, UseEChartsReturn } from './useECharts';
|
|
12
12
|
export { useECharts } from './useECharts';
|
|
13
|
+
export type { FluxStatisticsLegendVariant } from './useLegendVariant';
|
|
14
|
+
export { FluxStatisticsLegendVariantInjectionKey } from './useLegendVariant';
|
|
@@ -68,3 +68,48 @@
|
|
|
68
68
|
content: '';
|
|
69
69
|
border-top: 1px dashed var(--surface-stroke);
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
.statisticsLegendCompact {
|
|
73
|
+
display: flex;
|
|
74
|
+
user-select: none;
|
|
75
|
+
|
|
76
|
+
&.isHorizontal {
|
|
77
|
+
flex-flow: row wrap;
|
|
78
|
+
gap: 12px 18px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&.isVertical {
|
|
82
|
+
flex-flow: column;
|
|
83
|
+
gap: 12px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.statisticsLegendItemCompact {
|
|
88
|
+
--color: var(--primary-600);
|
|
89
|
+
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
flex-flow: row nowrap;
|
|
93
|
+
gap: 6px;
|
|
94
|
+
font-size: 14px;
|
|
95
|
+
line-height: 1;
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
|
|
98
|
+
.statisticsLegendItemColor {
|
|
99
|
+
margin: 0;
|
|
100
|
+
border-radius: var(--radius-full);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.statisticsLegendItemIcon {
|
|
104
|
+
margin: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.statisticsLegendItemLabel {
|
|
108
|
+
flex-grow: 0;
|
|
109
|
+
font-weight: 400;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.statisticsLegendItemValue {
|
|
113
|
+
margin-left: 0;
|
|
114
|
+
}
|
|
115
|
+
}
|