@milaboratories/uikit 2.2.37 → 2.2.38
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/CHANGELOG.md +7 -0
- package/dist/pl-uikit.js +3115 -2645
- package/dist/pl-uikit.umd.cjs +6 -6
- package/dist/src/colors/__tests__/colors.spec.d.ts +1 -0
- package/dist/src/colors/color.d.ts +44 -0
- package/dist/src/colors/gradient.d.ts +69 -0
- package/dist/src/colors/index.d.ts +3 -0
- package/dist/src/colors/palette.d.ts +55 -0
- package/dist/src/components/PlChartStackedBar/Legends.vue.d.ts +10 -0
- package/dist/src/components/PlChartStackedBar/PlChartStackedBar.vue.d.ts +6 -0
- package/dist/src/components/PlChartStackedBar/StackedRow.vue.d.ts +8 -0
- package/dist/src/components/PlChartStackedBar/index.d.ts +2 -0
- package/dist/src/components/PlChartStackedBar/types.d.ts +29 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/colors/__tests__/colors.spec.ts +27 -0
- package/src/colors/color.ts +80 -0
- package/src/colors/gradient.ts +136 -0
- package/src/colors/index.ts +3 -0
- package/src/colors/palette.ts +283 -0
- package/src/components/PlChartStackedBar/Legends.vue +87 -0
- package/src/components/PlChartStackedBar/PlChartStackedBar.vue +45 -0
- package/src/components/PlChartStackedBar/StackedRow.vue +132 -0
- package/src/components/PlChartStackedBar/index.ts +3 -0
- package/src/components/PlChartStackedBar/types.ts +34 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { tapIf } from '@milaboratories/helpers';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
|
+
import type { PlChartStackedBarSegment } from './types';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
value: PlChartStackedBarSegment[];
|
|
8
|
+
height?: number;
|
|
9
|
+
showFractionInLabel?: boolean;
|
|
10
|
+
}>();
|
|
11
|
+
|
|
12
|
+
const style = computed(() => ({
|
|
13
|
+
height: '100%',
|
|
14
|
+
minHeight: '82px',
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const parts = computed(() => {
|
|
18
|
+
const parts = props.value || [];
|
|
19
|
+
const total = parts.reduce((res, it) => res + it.value, 0);
|
|
20
|
+
return parts.map((p) => {
|
|
21
|
+
const fraction = (p.value / total) * 100;
|
|
22
|
+
const fractionString = ((p.value / total) * 100).toFixed(1);
|
|
23
|
+
const label = tapIf(p.label, (label) => {
|
|
24
|
+
if (props.showFractionInLabel) {
|
|
25
|
+
return `${label} ${fractionString}%`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return label;
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
color: p.color.toString(),
|
|
32
|
+
description: p.description,
|
|
33
|
+
fraction,
|
|
34
|
+
label,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div
|
|
42
|
+
:class="[$style.component]" :style="style"
|
|
43
|
+
>
|
|
44
|
+
<div :class="$style.track">
|
|
45
|
+
<div
|
|
46
|
+
v-for="(v, i) in [0, 25, 50, 75, 100]"
|
|
47
|
+
:key="i"
|
|
48
|
+
:style="`left: ${v}%`"
|
|
49
|
+
:data-content="`${v}%`"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
<div :class="$style.container">
|
|
53
|
+
<div v-if="!parts.length" :class="$style.notReady">Not ready</div>
|
|
54
|
+
<div
|
|
55
|
+
v-for="(p, i) in parts"
|
|
56
|
+
:key="i"
|
|
57
|
+
:title.prop="p.description ?? p.label"
|
|
58
|
+
:style="{
|
|
59
|
+
width: `${p.fraction}%`,
|
|
60
|
+
backgroundColor: p.color
|
|
61
|
+
}"
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<style lang="scss" module>
|
|
68
|
+
.component {
|
|
69
|
+
height: auto;
|
|
70
|
+
position: relative;
|
|
71
|
+
overflow: visible;
|
|
72
|
+
border: 1px solid green;
|
|
73
|
+
|
|
74
|
+
border: 1px solid var(--txt-01);
|
|
75
|
+
padding: 12px 6px;
|
|
76
|
+
border-radius: 0;
|
|
77
|
+
margin-bottom: 24px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.container {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: row;
|
|
83
|
+
gap: 1px;
|
|
84
|
+
width: 100%;
|
|
85
|
+
height: 100%;
|
|
86
|
+
align-items: center;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
> div {
|
|
89
|
+
height: 100%;
|
|
90
|
+
display: flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.track {
|
|
96
|
+
position: absolute;
|
|
97
|
+
top: 0;
|
|
98
|
+
left: 6px;
|
|
99
|
+
right: 6px;
|
|
100
|
+
bottom: 0;
|
|
101
|
+
/* z-index: 1; */
|
|
102
|
+
> div {
|
|
103
|
+
height: 100%;
|
|
104
|
+
position: absolute;
|
|
105
|
+
bottom: 0;
|
|
106
|
+
border-left: 1px solid #e1e3eb;
|
|
107
|
+
&::after {
|
|
108
|
+
position: absolute;
|
|
109
|
+
content: attr(data-content);
|
|
110
|
+
left: 0;
|
|
111
|
+
bottom: -24px;
|
|
112
|
+
transform: translateX(-50%);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.notReady {
|
|
118
|
+
color: var(--txt-03) !important;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.component .notReady {
|
|
122
|
+
font-size: larger;
|
|
123
|
+
font-weight: bolder;
|
|
124
|
+
color: var(--txt-mask);
|
|
125
|
+
margin-left: 24px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.component .container {
|
|
129
|
+
position: relative;
|
|
130
|
+
z-index: 1;
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Color } from '@/colors';
|
|
2
|
+
|
|
3
|
+
export type PlChartStackedBarSegment = {
|
|
4
|
+
value: number;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
color: string | Color;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type PlChartStackedBarSettings = {
|
|
11
|
+
/**
|
|
12
|
+
* The title of the chart.
|
|
13
|
+
* This will be displayed at the top of the chart, if provided.
|
|
14
|
+
*/
|
|
15
|
+
title?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The data to be displayed in the chart.
|
|
19
|
+
* Each entry represents a segment of a stacked bar.
|
|
20
|
+
*/
|
|
21
|
+
data: PlChartStackedBarSegment[];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The maximum number of legends displayed in a single column.
|
|
25
|
+
* Defaults to 5 if not specified.
|
|
26
|
+
*/
|
|
27
|
+
maxLegendsInColumn?: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether to show legends for the chart.
|
|
31
|
+
* Defaults to `true` if not specified.
|
|
32
|
+
*/
|
|
33
|
+
showLegends?: boolean;
|
|
34
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -60,6 +60,10 @@ export * from './components/PlMaskIcon24';
|
|
|
60
60
|
export * from './components/PlIcon16';
|
|
61
61
|
export * from './components/PlIcon24';
|
|
62
62
|
|
|
63
|
+
export * from './components/PlChartStackedBar';
|
|
64
|
+
|
|
65
|
+
export * from './colors';
|
|
66
|
+
|
|
63
67
|
// @TODO review (may be private)
|
|
64
68
|
import DropdownListItem from './components/DropdownListItem.vue';
|
|
65
69
|
|