cynx-lib 1.3.69 → 1.3.70
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/package.json +1 -1
- package/vue/components/CircularProgress.vue +383 -0
- package/vue/components/InfoBadge.vue +223 -0
- package/vue/components/StatusTag.vue +18 -6
- package/vue/index.d.ts +6 -0
- package/vue/index.js +6 -0
package/package.json
CHANGED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, onMounted, onBeforeUnmount, watch } from "vue";
|
|
3
|
+
|
|
4
|
+
const SIZES: Record<string, { svg: number; stroke: number; fontSize: string }> = {
|
|
5
|
+
xs: { svg: 48, stroke: 4, fontSize: ".7rem" },
|
|
6
|
+
sm: { svg: 64, stroke: 5, fontSize: ".85rem" },
|
|
7
|
+
md: { svg: 80, stroke: 6, fontSize: "1rem" },
|
|
8
|
+
lg: { svg: 100, stroke: 7, fontSize: "1.15rem" },
|
|
9
|
+
xl: { svg: 120, stroke: 8, fontSize: "1.3rem" },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface CircularSegment {
|
|
13
|
+
value: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const props = withDefaults(
|
|
19
|
+
defineProps<{
|
|
20
|
+
value?: number;
|
|
21
|
+
segments?: CircularSegment[];
|
|
22
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
23
|
+
customSize?: number;
|
|
24
|
+
color?: string;
|
|
25
|
+
trackColor?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
centerText?: string | number;
|
|
28
|
+
showPercent?: boolean;
|
|
29
|
+
animated?: boolean;
|
|
30
|
+
rounded?: boolean;
|
|
31
|
+
indeterminate?: boolean;
|
|
32
|
+
speed?: number;
|
|
33
|
+
strokeWidth?: number;
|
|
34
|
+
gap?: number;
|
|
35
|
+
className?: string;
|
|
36
|
+
style?: Record<string, any>;
|
|
37
|
+
}>(),
|
|
38
|
+
{
|
|
39
|
+
value: 0,
|
|
40
|
+
size: "md",
|
|
41
|
+
color: "var(--blue, #2782e4)",
|
|
42
|
+
trackColor: "var(--bd2, #e0e0e4)",
|
|
43
|
+
label: "",
|
|
44
|
+
showPercent: true,
|
|
45
|
+
animated: true,
|
|
46
|
+
rounded: true,
|
|
47
|
+
indeterminate: false,
|
|
48
|
+
speed: 1,
|
|
49
|
+
gap: 4,
|
|
50
|
+
className: "",
|
|
51
|
+
style: () => ({}),
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const base = computed(() => SIZES[props.size] || SIZES.md);
|
|
56
|
+
const svg = computed(() => props.customSize || base.value.svg);
|
|
57
|
+
const stroke = computed(() =>
|
|
58
|
+
props.strokeWidth ??
|
|
59
|
+
(props.customSize ? Math.max(3, svg.value * 0.06) : base.value.stroke)
|
|
60
|
+
);
|
|
61
|
+
const fontSize = computed(() =>
|
|
62
|
+
props.customSize
|
|
63
|
+
? `${Math.max(11, svg.value * 0.13)}px`
|
|
64
|
+
: base.value.fontSize
|
|
65
|
+
);
|
|
66
|
+
const cx = computed(() => svg.value / 2);
|
|
67
|
+
const cy = computed(() => svg.value / 2);
|
|
68
|
+
const r = computed(() => (svg.value - stroke.value) / 2);
|
|
69
|
+
const c = computed(() => 2 * Math.PI * r.value);
|
|
70
|
+
const pct = computed(() => Math.min(100, Math.max(0, props.value || 0)));
|
|
71
|
+
const BIG = computed(() => c.value * 4);
|
|
72
|
+
const isRounded = computed(() => props.rounded !== false);
|
|
73
|
+
const cap = computed(() => (isRounded.value ? "round" : "butt"));
|
|
74
|
+
|
|
75
|
+
const userGap = computed(() =>
|
|
76
|
+
props.gap !== undefined
|
|
77
|
+
? props.gap
|
|
78
|
+
: isRounded.value
|
|
79
|
+
? c.value * 0.05
|
|
80
|
+
: c.value * 0.03
|
|
81
|
+
);
|
|
82
|
+
const capOverrun = computed(() => (isRounded.value ? stroke.value : 0));
|
|
83
|
+
const gapSize = computed(() => userGap.value + capOverrun.value);
|
|
84
|
+
const total = computed(() => c.value - 2 * gapSize.value);
|
|
85
|
+
|
|
86
|
+
const isFull = computed(() => pct.value >= 100);
|
|
87
|
+
const isEmpty = computed(() => pct.value <= 0);
|
|
88
|
+
|
|
89
|
+
const hasSegments = computed(
|
|
90
|
+
() => Array.isArray(props.segments) && props.segments.length > 0
|
|
91
|
+
);
|
|
92
|
+
const rawSum = computed(() =>
|
|
93
|
+
hasSegments.value
|
|
94
|
+
? props.segments!.reduce((sum, s) => sum + (Number(s.value) || 0), 0)
|
|
95
|
+
: 0
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const indDash = computed(() => {
|
|
99
|
+
if (isEmpty.value) return `0,${BIG.value}`;
|
|
100
|
+
if (isFull.value) return `${c.value + stroke.value * 2},${BIG.value}`;
|
|
101
|
+
const activeLen = (pct.value / 100) * total.value;
|
|
102
|
+
return `${activeLen},${BIG.value}`;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const indOffset = computed(() => 0);
|
|
106
|
+
|
|
107
|
+
const trackDash = computed(() => {
|
|
108
|
+
if (isEmpty.value) return `${c.value},${BIG.value}`;
|
|
109
|
+
if (isFull.value) return `0,${BIG.value}`;
|
|
110
|
+
const activeLen = (pct.value / 100) * total.value;
|
|
111
|
+
const inactiveLen = total.value - activeLen;
|
|
112
|
+
return `${inactiveLen},${BIG.value}`;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const trackOffset = computed(() => {
|
|
116
|
+
if (isEmpty.value || isFull.value) return 0;
|
|
117
|
+
const activeLen = (pct.value / 100) * total.value;
|
|
118
|
+
return -(activeLen + gapSize.value);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const indOpacity = computed(() => (isEmpty.value ? 0 : 1));
|
|
122
|
+
|
|
123
|
+
const computedSegments = computed(() => {
|
|
124
|
+
if (!hasSegments.value || rawSum.value <= 0) return [];
|
|
125
|
+
const activeSegs = props.segments!.filter(
|
|
126
|
+
(seg) => (Number(seg.value) || 0) > 0
|
|
127
|
+
);
|
|
128
|
+
const segCount = activeSegs.length;
|
|
129
|
+
if (segCount === 0) return [];
|
|
130
|
+
|
|
131
|
+
const gapPx = props.gap !== undefined ? props.gap : 4;
|
|
132
|
+
const overrun = isRounded.value ? stroke.value : 0;
|
|
133
|
+
const gapArc = segCount > 1 ? gapPx + overrun : 0;
|
|
134
|
+
const availableC = Math.max(0, c.value - segCount * gapArc);
|
|
135
|
+
|
|
136
|
+
let accumulatedArc = isRounded.value ? stroke.value / 2 : 0;
|
|
137
|
+
|
|
138
|
+
return activeSegs.map((seg, idx) => {
|
|
139
|
+
const val = Number(seg.value) || 0;
|
|
140
|
+
const segLen = (val / rawSum.value) * availableC;
|
|
141
|
+
const currentOffset = accumulatedArc;
|
|
142
|
+
accumulatedArc += segLen + gapArc;
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
key: idx,
|
|
146
|
+
val,
|
|
147
|
+
color: seg.color || props.color,
|
|
148
|
+
label: seg.label,
|
|
149
|
+
strokeDasharray: `${Math.max(0.1, segLen).toFixed(2)}, ${BIG.value}`,
|
|
150
|
+
strokeDashoffset: (-currentOffset).toFixed(2),
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const gRef = ref<SVGGElement | null>(null);
|
|
156
|
+
const indRef = ref<SVGCircleElement | null>(null);
|
|
157
|
+
const trackRef = ref<SVGCircleElement | null>(null);
|
|
158
|
+
let raf: number | null = null;
|
|
159
|
+
|
|
160
|
+
const startIndeterminate = () => {
|
|
161
|
+
if (raf) cancelAnimationFrame(raf);
|
|
162
|
+
if (!props.indeterminate) return;
|
|
163
|
+
|
|
164
|
+
const capRad = (180 / Math.PI) * (stroke.value / r.value) / 2;
|
|
165
|
+
const gapRad = (180 / Math.PI) * (gapSize.value / r.value);
|
|
166
|
+
const gapArcLen = ((capRad + gapRad) / 360) * c.value;
|
|
167
|
+
let angle = -90;
|
|
168
|
+
let arcFrac = 0.45;
|
|
169
|
+
let arcDir = 1;
|
|
170
|
+
let lastTime = performance.now();
|
|
171
|
+
|
|
172
|
+
function tick(now: number) {
|
|
173
|
+
const dt = (now - lastTime) / 16.67;
|
|
174
|
+
lastTime = now;
|
|
175
|
+
angle = (angle + 3.6 * props.speed * dt) % 360;
|
|
176
|
+
arcFrac += 0.006 * arcDir * props.speed * dt;
|
|
177
|
+
if (arcFrac >= 0.72) {
|
|
178
|
+
arcFrac = 0.72;
|
|
179
|
+
arcDir = -1;
|
|
180
|
+
}
|
|
181
|
+
if (arcFrac <= 0.18) {
|
|
182
|
+
arcFrac = 0.18;
|
|
183
|
+
arcDir = 1;
|
|
184
|
+
}
|
|
185
|
+
const indLen = c.value * arcFrac;
|
|
186
|
+
const trackLen = Math.max(0, c.value - indLen - gapArcLen * 2);
|
|
187
|
+
|
|
188
|
+
if (gRef.value) gRef.value.style.transform = `rotate(${angle}deg)`;
|
|
189
|
+
if (indRef.value)
|
|
190
|
+
indRef.value.setAttribute("stroke-dasharray", `${indLen.toFixed(2)},9999`);
|
|
191
|
+
if (trackRef.value) {
|
|
192
|
+
trackRef.value.setAttribute(
|
|
193
|
+
"stroke-dasharray",
|
|
194
|
+
`${trackLen.toFixed(2)},9999`
|
|
195
|
+
);
|
|
196
|
+
trackRef.value.setAttribute(
|
|
197
|
+
"stroke-dashoffset",
|
|
198
|
+
`${(-(indLen + gapArcLen)).toFixed(2)}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
raf = requestAnimationFrame(tick);
|
|
202
|
+
}
|
|
203
|
+
raf = requestAnimationFrame(tick);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
onMounted(() => {
|
|
207
|
+
if (props.indeterminate) startIndeterminate();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
watch(
|
|
211
|
+
() => [props.indeterminate, props.speed, c.value, stroke.value, r.value, gapSize.value],
|
|
212
|
+
() => {
|
|
213
|
+
if (props.indeterminate) {
|
|
214
|
+
startIndeterminate();
|
|
215
|
+
} else if (raf) {
|
|
216
|
+
cancelAnimationFrame(raf);
|
|
217
|
+
raf = null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
onBeforeUnmount(() => {
|
|
223
|
+
if (raf) cancelAnimationFrame(raf);
|
|
224
|
+
});
|
|
225
|
+
</script>
|
|
226
|
+
|
|
227
|
+
<template>
|
|
228
|
+
<div
|
|
229
|
+
:class="className"
|
|
230
|
+
:style="{
|
|
231
|
+
display: 'inline-flex',
|
|
232
|
+
flexDirection: 'column',
|
|
233
|
+
alignItems: 'center',
|
|
234
|
+
gap: '4px',
|
|
235
|
+
...style,
|
|
236
|
+
}"
|
|
237
|
+
>
|
|
238
|
+
<div :style="{ position: 'relative', width: `${svg}px`, height: `${svg}px` }">
|
|
239
|
+
<svg
|
|
240
|
+
:width="svg"
|
|
241
|
+
:height="svg"
|
|
242
|
+
:viewBox="`0 0 ${svg} ${svg}`"
|
|
243
|
+
>
|
|
244
|
+
<template v-if="indeterminate">
|
|
245
|
+
<g ref="gRef" :style="{ transformOrigin: `${cx}px ${cy}px` }">
|
|
246
|
+
<circle
|
|
247
|
+
ref="trackRef"
|
|
248
|
+
:cx="cx"
|
|
249
|
+
:cy="cy"
|
|
250
|
+
:r="r"
|
|
251
|
+
fill="none"
|
|
252
|
+
:stroke="trackColor"
|
|
253
|
+
:stroke-width="stroke"
|
|
254
|
+
:stroke-linecap="cap"
|
|
255
|
+
/>
|
|
256
|
+
<circle
|
|
257
|
+
ref="indRef"
|
|
258
|
+
:cx="cx"
|
|
259
|
+
:cy="cy"
|
|
260
|
+
:r="r"
|
|
261
|
+
fill="none"
|
|
262
|
+
:stroke="color"
|
|
263
|
+
:stroke-width="stroke"
|
|
264
|
+
:stroke-linecap="cap"
|
|
265
|
+
/>
|
|
266
|
+
</g>
|
|
267
|
+
</template>
|
|
268
|
+
|
|
269
|
+
<template v-else-if="hasSegments">
|
|
270
|
+
<circle
|
|
271
|
+
v-if="rawSum <= 0 || computedSegments.length === 0"
|
|
272
|
+
:cx="cx"
|
|
273
|
+
:cy="cy"
|
|
274
|
+
:r="r"
|
|
275
|
+
fill="none"
|
|
276
|
+
:stroke="trackColor"
|
|
277
|
+
:stroke-width="stroke"
|
|
278
|
+
/>
|
|
279
|
+
<template v-else>
|
|
280
|
+
<circle
|
|
281
|
+
v-for="seg in computedSegments"
|
|
282
|
+
:key="seg.key"
|
|
283
|
+
:cx="cx"
|
|
284
|
+
:cy="cy"
|
|
285
|
+
:r="r"
|
|
286
|
+
fill="none"
|
|
287
|
+
:stroke="seg.color"
|
|
288
|
+
:stroke-width="stroke"
|
|
289
|
+
:stroke-linecap="cap"
|
|
290
|
+
:stroke-dasharray="seg.strokeDasharray"
|
|
291
|
+
:stroke-dashoffset="seg.strokeDashoffset"
|
|
292
|
+
:style="{
|
|
293
|
+
transform: 'rotate(-90deg)',
|
|
294
|
+
transformOrigin: '50% 50%',
|
|
295
|
+
transition: animated
|
|
296
|
+
? 'stroke-dasharray .5s cubic-bezier(0.4,0,0.2,1), stroke-dashoffset .5s cubic-bezier(0.4,0,0.2,1)'
|
|
297
|
+
: 'none',
|
|
298
|
+
}"
|
|
299
|
+
>
|
|
300
|
+
<title v-if="seg.label">{{ `${seg.label}: ${seg.val}` }}</title>
|
|
301
|
+
</circle>
|
|
302
|
+
</template>
|
|
303
|
+
</template>
|
|
304
|
+
|
|
305
|
+
<template v-else>
|
|
306
|
+
<circle
|
|
307
|
+
:cx="cx"
|
|
308
|
+
:cy="cy"
|
|
309
|
+
:r="r"
|
|
310
|
+
fill="none"
|
|
311
|
+
:stroke="trackColor"
|
|
312
|
+
:stroke-width="stroke"
|
|
313
|
+
:stroke-linecap="cap"
|
|
314
|
+
:stroke-dasharray="trackDash"
|
|
315
|
+
:stroke-dashoffset="trackOffset"
|
|
316
|
+
:style="{
|
|
317
|
+
transform: 'rotate(-90deg)',
|
|
318
|
+
transformOrigin: '50% 50%',
|
|
319
|
+
transition: animated
|
|
320
|
+
? 'stroke-dasharray .5s cubic-bezier(0.4,0,0.2,1), stroke-dashoffset .5s cubic-bezier(0.4,0,0.2,1)'
|
|
321
|
+
: 'none',
|
|
322
|
+
}"
|
|
323
|
+
/>
|
|
324
|
+
<circle
|
|
325
|
+
:cx="cx"
|
|
326
|
+
:cy="cy"
|
|
327
|
+
:r="r"
|
|
328
|
+
fill="none"
|
|
329
|
+
:stroke="color"
|
|
330
|
+
:stroke-width="stroke"
|
|
331
|
+
:stroke-linecap="cap"
|
|
332
|
+
:stroke-dasharray="indDash"
|
|
333
|
+
:stroke-dashoffset="indOffset"
|
|
334
|
+
:style="{
|
|
335
|
+
transform: 'rotate(-90deg)',
|
|
336
|
+
transformOrigin: '50% 50%',
|
|
337
|
+
opacity: indOpacity,
|
|
338
|
+
transition: animated
|
|
339
|
+
? 'stroke-dasharray .5s cubic-bezier(0.4,0,0.2,1), opacity .2s'
|
|
340
|
+
: 'none',
|
|
341
|
+
}"
|
|
342
|
+
/>
|
|
343
|
+
</template>
|
|
344
|
+
</svg>
|
|
345
|
+
|
|
346
|
+
<div
|
|
347
|
+
v-if="$slots.default || (showPercent && !indeterminate)"
|
|
348
|
+
:style="{
|
|
349
|
+
position: 'absolute',
|
|
350
|
+
inset: 0,
|
|
351
|
+
display: 'flex',
|
|
352
|
+
alignItems: 'center',
|
|
353
|
+
justifyContent: 'center',
|
|
354
|
+
fontSize: fontSize,
|
|
355
|
+
fontWeight: 600,
|
|
356
|
+
color: 'var(--primary-text, #0f172a)',
|
|
357
|
+
fontVariantNumeric: 'tabular-nums',
|
|
358
|
+
}"
|
|
359
|
+
>
|
|
360
|
+
<slot>
|
|
361
|
+
{{
|
|
362
|
+
centerText !== undefined
|
|
363
|
+
? centerText
|
|
364
|
+
: hasSegments
|
|
365
|
+
? rawSum
|
|
366
|
+
: `${Math.round(pct)}%`
|
|
367
|
+
}}
|
|
368
|
+
</slot>
|
|
369
|
+
</div>
|
|
370
|
+
</div>
|
|
371
|
+
|
|
372
|
+
<span
|
|
373
|
+
v-if="label"
|
|
374
|
+
:style="{
|
|
375
|
+
fontSize: '.6rem',
|
|
376
|
+
color: 'var(--muted, #797b8d)',
|
|
377
|
+
fontWeight: 500,
|
|
378
|
+
}"
|
|
379
|
+
>
|
|
380
|
+
{{ label }}
|
|
381
|
+
</span>
|
|
382
|
+
</div>
|
|
383
|
+
</template>
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useSlots } from "vue";
|
|
3
|
+
|
|
4
|
+
export interface InfoBadgeItem {
|
|
5
|
+
id?: string | number;
|
|
6
|
+
key?: string | number;
|
|
7
|
+
icon?: any;
|
|
8
|
+
label?: string | number;
|
|
9
|
+
value?: string | number;
|
|
10
|
+
color?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
dot?: boolean;
|
|
13
|
+
onClick?: (e: MouseEvent) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SIZES: Record<string, any> = {
|
|
17
|
+
xs: {
|
|
18
|
+
height: "24px",
|
|
19
|
+
padding: "0 8px",
|
|
20
|
+
fontSize: "10px",
|
|
21
|
+
iconSize: 12,
|
|
22
|
+
dotSize: ".65rem",
|
|
23
|
+
sepHeight: "10px",
|
|
24
|
+
gap: "6px",
|
|
25
|
+
borderRadius: "var(--radxs, 6px)",
|
|
26
|
+
},
|
|
27
|
+
sm: {
|
|
28
|
+
height: "28px",
|
|
29
|
+
padding: "0 10px",
|
|
30
|
+
fontSize: "11px",
|
|
31
|
+
iconSize: 13,
|
|
32
|
+
dotSize: ".7rem",
|
|
33
|
+
sepHeight: "12px",
|
|
34
|
+
gap: "8px",
|
|
35
|
+
borderRadius: "var(--rads, 8px)",
|
|
36
|
+
},
|
|
37
|
+
md: {
|
|
38
|
+
height: "32px",
|
|
39
|
+
padding: "0 12px",
|
|
40
|
+
fontSize: "12px",
|
|
41
|
+
iconSize: 14,
|
|
42
|
+
dotSize: ".75rem",
|
|
43
|
+
sepHeight: "14px",
|
|
44
|
+
gap: "10px",
|
|
45
|
+
borderRadius: "var(--rad, 10px)",
|
|
46
|
+
},
|
|
47
|
+
lg: {
|
|
48
|
+
height: "36px",
|
|
49
|
+
padding: "0 14px",
|
|
50
|
+
fontSize: "13px",
|
|
51
|
+
iconSize: 16,
|
|
52
|
+
dotSize: ".8rem",
|
|
53
|
+
sepHeight: "16px",
|
|
54
|
+
gap: "12px",
|
|
55
|
+
borderRadius: "var(--rad, 10px)",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const VARIANTS: Record<string, any> = {
|
|
60
|
+
default: {
|
|
61
|
+
background: "var(--surface, #ffffff)",
|
|
62
|
+
border: "1px solid var(--border, #d7d8e0)",
|
|
63
|
+
boxShadow: "var(--shadow, 0 1px 2px rgba(0, 0, 0, 0.05))",
|
|
64
|
+
},
|
|
65
|
+
surface: {
|
|
66
|
+
background: "var(--surface, #ffffff)",
|
|
67
|
+
border: "1px solid var(--border, #d7d8e0)",
|
|
68
|
+
boxShadow: "var(--shadow, 0 1px 2px rgba(0, 0, 0, 0.05))",
|
|
69
|
+
},
|
|
70
|
+
flat: {
|
|
71
|
+
background: "var(--grey-1, #f5f5f8)",
|
|
72
|
+
border: "1px solid var(--border, #d7d8e0)",
|
|
73
|
+
boxShadow: "none",
|
|
74
|
+
},
|
|
75
|
+
ghost: {
|
|
76
|
+
background: "transparent",
|
|
77
|
+
border: "1px solid var(--border, #d7d8e0)",
|
|
78
|
+
boxShadow: "none",
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const props = withDefaults(
|
|
83
|
+
defineProps<{
|
|
84
|
+
items?: InfoBadgeItem[];
|
|
85
|
+
icon?: any;
|
|
86
|
+
label?: string | number;
|
|
87
|
+
value?: string | number;
|
|
88
|
+
color?: string;
|
|
89
|
+
title?: string;
|
|
90
|
+
dot?: boolean;
|
|
91
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
92
|
+
variant?: "default" | "surface" | "flat" | "ghost";
|
|
93
|
+
}>(),
|
|
94
|
+
{
|
|
95
|
+
items: undefined,
|
|
96
|
+
icon: undefined,
|
|
97
|
+
label: undefined,
|
|
98
|
+
value: undefined,
|
|
99
|
+
color: undefined,
|
|
100
|
+
title: undefined,
|
|
101
|
+
dot: true,
|
|
102
|
+
size: "sm",
|
|
103
|
+
variant: "default",
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const emit = defineEmits<{
|
|
108
|
+
(e: "click", event: MouseEvent): void;
|
|
109
|
+
}>();
|
|
110
|
+
|
|
111
|
+
const slots = useSlots();
|
|
112
|
+
const sz = computed(() => SIZES[props.size] || SIZES.sm);
|
|
113
|
+
const vr = computed(() => VARIANTS[props.variant] || VARIANTS.default);
|
|
114
|
+
|
|
115
|
+
const resolvedItems = computed<InfoBadgeItem[]>(() => {
|
|
116
|
+
if (Array.isArray(props.items) && props.items.length > 0) {
|
|
117
|
+
return props.items;
|
|
118
|
+
}
|
|
119
|
+
if (props.icon != null || props.value != null || props.label != null) {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
icon: props.icon,
|
|
123
|
+
label: props.label,
|
|
124
|
+
value: props.value,
|
|
125
|
+
color: props.color,
|
|
126
|
+
title: props.title,
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
return [];
|
|
131
|
+
});
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<template>
|
|
135
|
+
<div
|
|
136
|
+
class="inline-flex items-center box-border select-none"
|
|
137
|
+
:style="{
|
|
138
|
+
height: sz.height,
|
|
139
|
+
padding: sz.padding,
|
|
140
|
+
borderRadius: sz.borderRadius,
|
|
141
|
+
background: vr.background,
|
|
142
|
+
border: vr.border,
|
|
143
|
+
boxShadow: vr.boxShadow,
|
|
144
|
+
gap: sz.gap,
|
|
145
|
+
}"
|
|
146
|
+
:title="title"
|
|
147
|
+
@click="(e) => emit('click', e)"
|
|
148
|
+
>
|
|
149
|
+
<slot v-if="slots.default" />
|
|
150
|
+
<template v-else>
|
|
151
|
+
<template v-for="(it, idx) in resolvedItems" :key="it.id || it.key || idx">
|
|
152
|
+
<div
|
|
153
|
+
v-if="idx > 0"
|
|
154
|
+
:style="{
|
|
155
|
+
width: '1px',
|
|
156
|
+
height: sz.sepHeight,
|
|
157
|
+
background: 'var(--border, #d7d8e0)',
|
|
158
|
+
flexShrink: 0,
|
|
159
|
+
}"
|
|
160
|
+
/>
|
|
161
|
+
<div
|
|
162
|
+
class="inline-flex items-center"
|
|
163
|
+
:style="{
|
|
164
|
+
gap: '5px',
|
|
165
|
+
cursor: it.onClick ? 'pointer' : 'inherit',
|
|
166
|
+
}"
|
|
167
|
+
:title="it.title"
|
|
168
|
+
@click="it.onClick"
|
|
169
|
+
>
|
|
170
|
+
<span
|
|
171
|
+
v-if="it.icon"
|
|
172
|
+
class="inline-flex items-center justify-center flex-shrink-0"
|
|
173
|
+
:style="{
|
|
174
|
+
color: it.color || 'inherit',
|
|
175
|
+
}"
|
|
176
|
+
>
|
|
177
|
+
<component
|
|
178
|
+
:is="it.icon"
|
|
179
|
+
v-if="typeof it.icon === 'object' || typeof it.icon === 'function'"
|
|
180
|
+
:size="sz.iconSize"
|
|
181
|
+
/>
|
|
182
|
+
<template v-else>{{ it.icon }}</template>
|
|
183
|
+
</span>
|
|
184
|
+
|
|
185
|
+
<span
|
|
186
|
+
v-if="it.label !== undefined && it.label !== null"
|
|
187
|
+
:style="{
|
|
188
|
+
fontSize: sz.fontSize,
|
|
189
|
+
fontWeight: 600,
|
|
190
|
+
color: (it.color && it.color !== 'inherit') ? it.color : 'var(--primary-text, #0f111c)',
|
|
191
|
+
}"
|
|
192
|
+
>
|
|
193
|
+
{{ it.label }}
|
|
194
|
+
</span>
|
|
195
|
+
|
|
196
|
+
<span
|
|
197
|
+
v-if="(it.dot !== undefined ? it.dot : dot) && (it.icon || it.label) && it.value !== undefined && it.value !== null"
|
|
198
|
+
:style="{
|
|
199
|
+
fontSize: sz.dotSize,
|
|
200
|
+
color: 'var(--muted, #9b9daa)',
|
|
201
|
+
lineHeight: 1,
|
|
202
|
+
}"
|
|
203
|
+
>
|
|
204
|
+
•
|
|
205
|
+
</span>
|
|
206
|
+
|
|
207
|
+
<span
|
|
208
|
+
v-if="it.value !== undefined && it.value !== null"
|
|
209
|
+
:style="{
|
|
210
|
+
fontSize: sz.fontSize,
|
|
211
|
+
fontWeight: 600,
|
|
212
|
+
color: 'var(--primary-text, #0f111c)',
|
|
213
|
+
fontVariantNumeric: 'tabular-nums',
|
|
214
|
+
lineHeight: 1,
|
|
215
|
+
}"
|
|
216
|
+
>
|
|
217
|
+
{{ it.value }}
|
|
218
|
+
</span>
|
|
219
|
+
</div>
|
|
220
|
+
</template>
|
|
221
|
+
</template>
|
|
222
|
+
</div>
|
|
223
|
+
</template>
|
|
@@ -20,16 +20,22 @@ const props = withDefaults(
|
|
|
20
20
|
}>(),
|
|
21
21
|
{
|
|
22
22
|
status: "",
|
|
23
|
-
width:
|
|
24
|
-
height:
|
|
23
|
+
width: 36,
|
|
24
|
+
height: 20,
|
|
25
25
|
radius: 6,
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
+
const isPrimaryStatus = computed(() => {
|
|
30
|
+
if (props.color) return true;
|
|
31
|
+
const key = (props.status || "").toUpperCase().trim();
|
|
32
|
+
return Boolean(STATUS_COLORS[key]);
|
|
33
|
+
});
|
|
34
|
+
|
|
29
35
|
const bg = computed(() => {
|
|
30
36
|
if (props.color) return props.color;
|
|
31
|
-
const key = (props.status || "").toUpperCase();
|
|
32
|
-
return STATUS_COLORS[key] || "
|
|
37
|
+
const key = (props.status || "").toUpperCase().trim();
|
|
38
|
+
return STATUS_COLORS[key] || "transparent";
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
const boxWidth = computed(() =>
|
|
@@ -45,8 +51,8 @@ const borderRadius = computed(() =>
|
|
|
45
51
|
|
|
46
52
|
<template>
|
|
47
53
|
<span
|
|
48
|
-
v-if="status"
|
|
49
|
-
class="inline-flex items-center justify-center text-[11px] font-
|
|
54
|
+
v-if="status && isPrimaryStatus"
|
|
55
|
+
class="inline-flex items-center justify-center text-[11px] font-bold text-white tracking-wide select-none shadow-sm flex-shrink-0"
|
|
50
56
|
:style="{
|
|
51
57
|
width: boxWidth,
|
|
52
58
|
height: boxHeight,
|
|
@@ -56,5 +62,11 @@ const borderRadius = computed(() =>
|
|
|
56
62
|
>
|
|
57
63
|
{{ status }}
|
|
58
64
|
</span>
|
|
65
|
+
<span
|
|
66
|
+
v-else-if="status"
|
|
67
|
+
class="text-[12px] font-semibold text-[var(--primary-text,inherit)] select-none truncate"
|
|
68
|
+
>
|
|
69
|
+
{{ status }}
|
|
70
|
+
</span>
|
|
59
71
|
<span v-else class="text-slate-400 select-none">-</span>
|
|
60
72
|
</template>
|
package/vue/index.d.ts
CHANGED
|
@@ -51,7 +51,13 @@ export declare const Table: DefineComponent<any, any, any>;
|
|
|
51
51
|
export declare const Pagination: DefineComponent<any, any, any>;
|
|
52
52
|
export declare const Skeleton: DefineComponent<any, any, any>;
|
|
53
53
|
export declare const Modal: DefineComponent<any, any, any>;
|
|
54
|
+
export declare const Drawer: DefineComponent<any, any, any>;
|
|
54
55
|
export declare const Toggle: DefineComponent<any, any, any>;
|
|
56
|
+
export declare const DatePicker: DefineComponent<any, any, any>;
|
|
57
|
+
export declare const LinearProgress: DefineComponent<any, any, any>;
|
|
58
|
+
export declare const CircularProgress: DefineComponent<any, any, any>;
|
|
59
|
+
export declare const StatusTag: DefineComponent<any, any, any>;
|
|
60
|
+
export declare const InfoBadge: DefineComponent<any, any, any>;
|
|
55
61
|
export declare const XTable: DefineComponent<any, any, any>;
|
|
56
62
|
export declare const XThead: DefineComponent<any, any, any>;
|
|
57
63
|
export declare const XTbody: DefineComponent<any, any, any>;
|
package/vue/index.js
CHANGED
|
@@ -15,7 +15,9 @@ import Drawer from "./components/Drawer.vue";
|
|
|
15
15
|
import Toggle from "./components/Toggle.vue";
|
|
16
16
|
import DatePicker from "./components/DatePicker.vue";
|
|
17
17
|
import LinearProgress from "./components/LinearProgress.vue";
|
|
18
|
+
import CircularProgress from "./components/CircularProgress.vue";
|
|
18
19
|
import StatusTag from "./components/StatusTag.vue";
|
|
20
|
+
import InfoBadge from "./components/InfoBadge.vue";
|
|
19
21
|
import { XTable, XThead, XTbody, XTr, XTh, XTd } from "./components/XTable.vue";
|
|
20
22
|
import { useAutoSkeletonRows } from "./composables/useAutoSkeletonRows";
|
|
21
23
|
|
|
@@ -36,7 +38,9 @@ export {
|
|
|
36
38
|
Toggle,
|
|
37
39
|
DatePicker,
|
|
38
40
|
LinearProgress,
|
|
41
|
+
CircularProgress,
|
|
39
42
|
StatusTag,
|
|
43
|
+
InfoBadge,
|
|
40
44
|
XTable,
|
|
41
45
|
XThead,
|
|
42
46
|
XTbody,
|
|
@@ -63,7 +67,9 @@ export default {
|
|
|
63
67
|
Toggle,
|
|
64
68
|
DatePicker,
|
|
65
69
|
LinearProgress,
|
|
70
|
+
CircularProgress,
|
|
66
71
|
StatusTag,
|
|
72
|
+
InfoBadge,
|
|
67
73
|
XTable,
|
|
68
74
|
XThead,
|
|
69
75
|
XTbody,
|