cynx-lib 1.3.68 → 1.3.69

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.
@@ -0,0 +1,268 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, onMounted, onBeforeUnmount, watch } from "vue";
3
+
4
+ const SIZES: Record<string, { height: number; fontSize: string }> = {
5
+ xs: { height: 4, fontSize: ".68rem" },
6
+ sm: { height: 5, fontSize: ".75rem" },
7
+ md: { height: 6, fontSize: ".82rem" },
8
+ lg: { height: 8, fontSize: ".9rem" },
9
+ xl: { height: 10, fontSize: "1rem" },
10
+ };
11
+
12
+ interface Segment {
13
+ value: number;
14
+ color?: string;
15
+ label?: string;
16
+ }
17
+
18
+ const props = withDefaults(
19
+ defineProps<{
20
+ value?: number;
21
+ segments?: Segment[];
22
+ size?: "xs" | "sm" | "md" | "lg" | "xl";
23
+ customSize?: number;
24
+ color?: string;
25
+ trackColor?: string;
26
+ label?: string;
27
+ showPercent?: boolean;
28
+ animated?: boolean;
29
+ rounded?: boolean;
30
+ indeterminate?: boolean;
31
+ speed?: number;
32
+ height?: number | string;
33
+ gap?: number | string;
34
+ labelGap?: number | string;
35
+ className?: string;
36
+ style?: Record<string, any>;
37
+ }>(),
38
+ {
39
+ value: 0,
40
+ size: "md",
41
+ color: "var(--blue, #3b82f6)",
42
+ trackColor: "var(--bd2, #e0e0e4)",
43
+ label: "",
44
+ showPercent: true,
45
+ animated: true,
46
+ rounded: true,
47
+ indeterminate: false,
48
+ speed: 1,
49
+ gap: 5,
50
+ labelGap: 2,
51
+ className: "",
52
+ style: () => ({}),
53
+ }
54
+ );
55
+
56
+ const base = computed(() => SIZES[props.size] || SIZES.md);
57
+ const barHeight = computed(() => {
58
+ if (props.height != null) {
59
+ return typeof props.height === "number" ? `${props.height}px` : props.height;
60
+ }
61
+ if (props.customSize != null) {
62
+ return `${props.customSize}px`;
63
+ }
64
+ return `${base.value.height}px`;
65
+ });
66
+
67
+ const barHeightNum = computed(() => {
68
+ if (typeof props.height === "number") return props.height;
69
+ if (typeof props.height === "string" && props.height.endsWith("px")) {
70
+ return parseFloat(props.height) || base.value.height;
71
+ }
72
+ if (props.customSize != null) return props.customSize;
73
+ return base.value.height;
74
+ });
75
+
76
+ const fontSize = computed(() => {
77
+ if (props.customSize) {
78
+ return `${Math.max(11, props.customSize * 1.6)}px`;
79
+ }
80
+ return base.value.fontSize;
81
+ });
82
+
83
+ const pct = computed(() => Math.min(100, Math.max(0, props.value || 0)));
84
+ const radius = computed(() => (props.rounded ? `${barHeightNum.value / 2}px` : "0px"));
85
+ const transitionStyle = computed(() =>
86
+ props.animated ? "flex .5s cubic-bezier(0.4,0,0.2,1)" : "none"
87
+ );
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 gapStyle = computed(() =>
99
+ typeof props.gap === "number" ? `${props.gap}px` : props.gap
100
+ );
101
+ const labelGapStyle = computed(() =>
102
+ typeof props.labelGap === "number" ? `${props.labelGap}px` : props.labelGap
103
+ );
104
+
105
+ const barRef = ref<HTMLElement | null>(null);
106
+ let raf: number | null = null;
107
+
108
+ const startIndeterminate = () => {
109
+ if (raf) cancelAnimationFrame(raf);
110
+ if (!props.indeterminate || !barRef.value) return;
111
+ let pos = -40;
112
+ let direction = 1;
113
+ let lastTime = performance.now();
114
+
115
+ function tick(now: number) {
116
+ const dt = (now - lastTime) / 16.67;
117
+ lastTime = now;
118
+ pos += direction * 1.2 * props.speed * dt;
119
+ if (pos > 100) {
120
+ pos = 100;
121
+ direction = -1;
122
+ }
123
+ if (pos < -40) {
124
+ pos = -40;
125
+ direction = 1;
126
+ }
127
+ if (barRef.value) {
128
+ barRef.value.style.left = pos + "%";
129
+ barRef.value.style.width = "40%";
130
+ }
131
+ raf = requestAnimationFrame(tick);
132
+ }
133
+ raf = requestAnimationFrame(tick);
134
+ };
135
+
136
+ onMounted(() => {
137
+ if (props.indeterminate) startIndeterminate();
138
+ });
139
+
140
+ watch(
141
+ () => [props.indeterminate, props.speed],
142
+ () => {
143
+ if (props.indeterminate) {
144
+ startIndeterminate();
145
+ } else if (raf) {
146
+ cancelAnimationFrame(raf);
147
+ raf = null;
148
+ }
149
+ }
150
+ );
151
+
152
+ onBeforeUnmount(() => {
153
+ if (raf) cancelAnimationFrame(raf);
154
+ });
155
+ </script>
156
+
157
+ <template>
158
+ <div
159
+ :class="className"
160
+ :style="{
161
+ display: 'inline-flex',
162
+ flexDirection: 'column',
163
+ gap: labelGapStyle,
164
+ width: '100%',
165
+ ...style,
166
+ }"
167
+ >
168
+ <div
169
+ v-if="label || showPercent"
170
+ style="display: flex; justify-content: space-between; align-items: baseline"
171
+ >
172
+ <span
173
+ v-if="label"
174
+ :style="{
175
+ fontSize: fontSize,
176
+ fontWeight: 600,
177
+ color: 'var(--primary-text, #1a1a2e)',
178
+ }"
179
+ >
180
+ {{ label }}
181
+ </span>
182
+ <span
183
+ v-if="showPercent && !indeterminate && !hasSegments"
184
+ :style="{
185
+ fontSize: fontSize,
186
+ fontWeight: 600,
187
+ color: 'var(--muted, #9ca3af)',
188
+ fontVariantNumeric: 'tabular-nums',
189
+ marginLeft: label ? 0 : 'auto',
190
+ }"
191
+ >
192
+ {{ Math.round(pct) }}%
193
+ </span>
194
+ </div>
195
+
196
+ <div
197
+ :style="{
198
+ height: barHeight,
199
+ borderRadius: radius,
200
+ background: 'transparent',
201
+ position: 'relative',
202
+ display: 'flex',
203
+ gap: gapStyle,
204
+ overflow: 'hidden',
205
+ }"
206
+ >
207
+ <template v-if="indeterminate">
208
+ <div
209
+ :style="{
210
+ flex: 1,
211
+ borderRadius: radius,
212
+ background: trackColor,
213
+ }"
214
+ />
215
+ <div
216
+ ref="barRef"
217
+ :style="{
218
+ position: 'absolute',
219
+ top: 0,
220
+ height: '100%',
221
+ width: '40%',
222
+ borderRadius: radius,
223
+ background: color,
224
+ opacity: 0.85,
225
+ }"
226
+ />
227
+ </template>
228
+
229
+ <template v-else-if="hasSegments && rawSum > 0">
230
+ <template v-for="(seg, idx) in segments" :key="idx">
231
+ <div
232
+ v-if="Number(seg.value) > 0"
233
+ :title="seg.label ? `${seg.label}: ${seg.value}` : undefined"
234
+ :style="{
235
+ flex: (Number(seg.value) / rawSum) * 100,
236
+ height: '100%',
237
+ borderRadius: radius,
238
+ background: seg.color || color,
239
+ transition: transitionStyle,
240
+ }"
241
+ />
242
+ </template>
243
+ </template>
244
+
245
+ <template v-else>
246
+ <div
247
+ ref="barRef"
248
+ :style="{
249
+ flex: pct > 0 ? pct : 0,
250
+ minWidth: pct > 0 ? `${barHeightNum}px` : 0,
251
+ borderRadius: radius,
252
+ background: color,
253
+ transition: transitionStyle,
254
+ }"
255
+ />
256
+ <div
257
+ v-if="pct < 100"
258
+ :style="{
259
+ flex: 100 - pct,
260
+ borderRadius: radius,
261
+ background: trackColor,
262
+ transition: transitionStyle,
263
+ }"
264
+ />
265
+ </template>
266
+ </div>
267
+ </div>
268
+ </template>
@@ -715,7 +715,7 @@ const handleItemClick = (item, event) => {
715
715
 
716
716
  .cynx-sidebar__brand-subtitle {
717
717
  font-size: 0.64rem;
718
- font-weight: 500;
718
+ font-weight: 600;
719
719
  }
720
720
 
721
721
  .cynx-sidebar__toggle-btn {
@@ -821,7 +821,7 @@ const handleItemClick = (item, event) => {
821
821
  align-items: center;
822
822
  border-radius: var(--rads, 8px);
823
823
  font-size: 0.82rem;
824
- font-weight: 500;
824
+ font-weight: 600;
825
825
  border: none;
826
826
  text-decoration: none;
827
827
  cursor: pointer;
@@ -868,7 +868,8 @@ const handleItemClick = (item, event) => {
868
868
  font-size: 0.68rem;
869
869
  padding: 1px 6px;
870
870
  border-radius: var(--radxs, 4px);
871
- font-family: var(--mono, monospace);
871
+ font-family: var(--sans, inherit);
872
+ font-weight: 600;
872
873
  background: var(--grey-1, #fafafa);
873
874
  color: var(--muted, #71717a);
874
875
  border: 1px solid var(--border-light, #f4f4f5);
@@ -0,0 +1,60 @@
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
4
+ const STATUS_COLORS: Record<string, string> = {
5
+ DR: "var(--drive, #28C76F)",
6
+ SB: "var(--break, #FFB200)",
7
+ ON: "var(--shift, #0F60FF)",
8
+ OFF: "#8B909A",
9
+ PC: "#8B909A",
10
+ YM: "var(--shift, #0F60FF)",
11
+ };
12
+
13
+ const props = withDefaults(
14
+ defineProps<{
15
+ status?: string | null;
16
+ color?: string;
17
+ width?: number | string;
18
+ height?: number | string;
19
+ radius?: number | string;
20
+ }>(),
21
+ {
22
+ status: "",
23
+ width: 44,
24
+ height: 24,
25
+ radius: 6,
26
+ }
27
+ );
28
+
29
+ const bg = computed(() => {
30
+ if (props.color) return props.color;
31
+ const key = (props.status || "").toUpperCase();
32
+ return STATUS_COLORS[key] || "#8B909A";
33
+ });
34
+
35
+ const boxWidth = computed(() =>
36
+ typeof props.width === "number" ? `${props.width}px` : props.width
37
+ );
38
+ const boxHeight = computed(() =>
39
+ typeof props.height === "number" ? `${props.height}px` : props.height
40
+ );
41
+ const borderRadius = computed(() =>
42
+ typeof props.radius === "number" ? `${props.radius}px` : props.radius
43
+ );
44
+ </script>
45
+
46
+ <template>
47
+ <span
48
+ v-if="status"
49
+ class="inline-flex items-center justify-center text-[11px] font-extrabold text-white tracking-wide select-none shadow-sm flex-shrink-0"
50
+ :style="{
51
+ width: boxWidth,
52
+ height: boxHeight,
53
+ borderRadius: borderRadius,
54
+ backgroundColor: bg,
55
+ }"
56
+ >
57
+ {{ status }}
58
+ </span>
59
+ <span v-else class="text-slate-400 select-none">-</span>
60
+ </template>
package/vue/index.js CHANGED
@@ -14,6 +14,8 @@ import Modal from "./components/Modal.vue";
14
14
  import Drawer from "./components/Drawer.vue";
15
15
  import Toggle from "./components/Toggle.vue";
16
16
  import DatePicker from "./components/DatePicker.vue";
17
+ import LinearProgress from "./components/LinearProgress.vue";
18
+ import StatusTag from "./components/StatusTag.vue";
17
19
  import { XTable, XThead, XTbody, XTr, XTh, XTd } from "./components/XTable.vue";
18
20
  import { useAutoSkeletonRows } from "./composables/useAutoSkeletonRows";
19
21
 
@@ -33,6 +35,8 @@ export {
33
35
  Drawer,
34
36
  Toggle,
35
37
  DatePicker,
38
+ LinearProgress,
39
+ StatusTag,
36
40
  XTable,
37
41
  XThead,
38
42
  XTbody,
@@ -58,6 +62,8 @@ export default {
58
62
  Drawer,
59
63
  Toggle,
60
64
  DatePicker,
65
+ LinearProgress,
66
+ StatusTag,
61
67
  XTable,
62
68
  XThead,
63
69
  XTbody,