cynx-lib 1.3.68 → 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.
@@ -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>
@@ -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,72 @@
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: 36,
24
+ height: 20,
25
+ radius: 6,
26
+ }
27
+ );
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
+
35
+ const bg = computed(() => {
36
+ if (props.color) return props.color;
37
+ const key = (props.status || "").toUpperCase().trim();
38
+ return STATUS_COLORS[key] || "transparent";
39
+ });
40
+
41
+ const boxWidth = computed(() =>
42
+ typeof props.width === "number" ? `${props.width}px` : props.width
43
+ );
44
+ const boxHeight = computed(() =>
45
+ typeof props.height === "number" ? `${props.height}px` : props.height
46
+ );
47
+ const borderRadius = computed(() =>
48
+ typeof props.radius === "number" ? `${props.radius}px` : props.radius
49
+ );
50
+ </script>
51
+
52
+ <template>
53
+ <span
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"
56
+ :style="{
57
+ width: boxWidth,
58
+ height: boxHeight,
59
+ borderRadius: borderRadius,
60
+ backgroundColor: bg,
61
+ }"
62
+ >
63
+ {{ status }}
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>
71
+ <span v-else class="text-slate-400 select-none">-</span>
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
@@ -14,6 +14,10 @@ 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 CircularProgress from "./components/CircularProgress.vue";
19
+ import StatusTag from "./components/StatusTag.vue";
20
+ import InfoBadge from "./components/InfoBadge.vue";
17
21
  import { XTable, XThead, XTbody, XTr, XTh, XTd } from "./components/XTable.vue";
18
22
  import { useAutoSkeletonRows } from "./composables/useAutoSkeletonRows";
19
23
 
@@ -33,6 +37,10 @@ export {
33
37
  Drawer,
34
38
  Toggle,
35
39
  DatePicker,
40
+ LinearProgress,
41
+ CircularProgress,
42
+ StatusTag,
43
+ InfoBadge,
36
44
  XTable,
37
45
  XThead,
38
46
  XTbody,
@@ -58,6 +66,10 @@ export default {
58
66
  Drawer,
59
67
  Toggle,
60
68
  DatePicker,
69
+ LinearProgress,
70
+ CircularProgress,
71
+ StatusTag,
72
+ InfoBadge,
61
73
  XTable,
62
74
  XThead,
63
75
  XTbody,