v-nuxt-ui 0.2.7 → 0.2.9

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/module.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "dependencies": [
8
8
  "@nuxt/ui"
9
9
  ],
10
- "version": "0.2.7",
10
+ "version": "0.2.9",
11
11
  "builder": {
12
12
  "@nuxt/module-builder": "1.0.2",
13
13
  "unbuild": "3.6.1"
@@ -1,12 +1,12 @@
1
+ import type { FlowColorRole } from '#v/constants';
1
2
  type __VLS_Props = {
2
3
  /** Tailwind 颜色名 (e.g. 'red', 'blue'),空字符串表示默认 */
3
4
  chip?: string;
4
- /** 色阶 (默认 500) */
5
- shade?: number;
6
5
  /** 是否选中 */
7
6
  selected?: boolean;
8
7
  /** 标题提示 */
9
8
  title?: string;
9
+ colorRole?: FlowColorRole;
10
10
  };
11
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  click: () => any;
@@ -1,18 +1,19 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { useColorMode } from "@vueuse/core";
4
+ import { resolveFlowColor } from "#v/constants";
4
5
  const props = defineProps({
5
6
  chip: { type: String, required: false },
6
- shade: { type: Number, required: false },
7
7
  selected: { type: Boolean, required: false },
8
- title: { type: String, required: false }
8
+ title: { type: String, required: false },
9
+ colorRole: { type: null, required: false }
9
10
  });
10
11
  defineEmits(["click"]);
11
12
  const colorMode = useColorMode();
12
13
  const backgroundStyle = computed(() => {
13
- if (!props.chip || props.chip === "primary") return void 0;
14
- const shade = props.shade ?? (colorMode.value === "dark" ? 400 : 500);
15
- return `background-color: var(--color-${props.chip}-${shade})`;
14
+ if (!props.chip) return void 0;
15
+ const varName = resolveFlowColor(props.chip, props.colorRole ?? "border", colorMode.value === "dark");
16
+ return `background-color: ${varName}`;
16
17
  });
17
18
  </script>
18
19
 
@@ -1,12 +1,12 @@
1
+ import type { FlowColorRole } from '#v/constants';
1
2
  type __VLS_Props = {
2
3
  /** Tailwind 颜色名 (e.g. 'red', 'blue'),空字符串表示默认 */
3
4
  chip?: string;
4
- /** 色阶 (默认 500) */
5
- shade?: number;
6
5
  /** 是否选中 */
7
6
  selected?: boolean;
8
7
  /** 标题提示 */
9
8
  title?: string;
9
+ colorRole?: FlowColorRole;
10
10
  };
11
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  click: () => any;
@@ -42,6 +42,7 @@ const {
42
42
  edgePathType,
43
43
  edgeAnimated,
44
44
  edgeStrokeType,
45
+ edgeColorOpacity,
45
46
  effectiveEdgeColor,
46
47
  effectiveEdgeLabelColor,
47
48
  effectiveNodeBorderColor
@@ -114,7 +115,8 @@ const markersToRender = computed(() => {
114
115
  const edgeStyle = computed(() => {
115
116
  const base = {
116
117
  ...props.style,
117
- stroke: strokeColor.value
118
+ stroke: strokeColor.value,
119
+ opacity: edgeColorOpacity.value / 100
118
120
  };
119
121
  if (edgeAnimated.value) {
120
122
  const strokeOpt = FLOW_EDGE_STROKE_TYPES.find((t) => t.type === edgeStrokeType.value);
@@ -55,6 +55,7 @@ const {
55
55
  edgeStrokeType,
56
56
  edgePathType,
57
57
  edgeColor,
58
+ edgeColorOpacity,
58
59
  edgeLabelColor,
59
60
  nodeShowBorder,
60
61
  nodeBorderWidth,
@@ -126,7 +127,8 @@ watchEffect(() => {
126
127
  edge.style = {
127
128
  strokeWidth: edgeStrokeWidth.value,
128
129
  ...dasharray ? { strokeDasharray: dasharray } : {},
129
- ...effectiveEdgeColor.value ? { stroke: effectiveEdgeColor.value } : {}
130
+ ...effectiveEdgeColor.value ? { stroke: effectiveEdgeColor.value } : {},
131
+ opacity: edgeColorOpacity.value / 100
130
132
  };
131
133
  edge.markerStart = void 0;
132
134
  edge.markerEnd = void 0;
@@ -209,7 +211,8 @@ const defaultEdgeOptions = computed(() => {
209
211
  style: {
210
212
  strokeWidth: edgeStrokeWidth.value,
211
213
  ...dasharray ? { strokeDasharray: dasharray } : {},
212
- ...effectiveEdgeColor.value ? { stroke: effectiveEdgeColor.value } : {}
214
+ ...effectiveEdgeColor.value ? { stroke: effectiveEdgeColor.value } : {},
215
+ opacity: edgeColorOpacity.value / 100
213
216
  },
214
217
  // Markers are handled by FlowEdge custom SVG markers
215
218
  markerStart: void 0,
@@ -273,6 +276,7 @@ const isValidConnection = () => true;
273
276
  :edge-marker-end="edgeMarkerEnd"
274
277
  :edge-animated="edgeAnimated"
275
278
  :edge-color="edgeColor"
279
+ :edge-color-opacity="edgeColorOpacity"
276
280
  :edge-label-color="edgeLabelColor"
277
281
  :node-show-border="nodeShowBorder"
278
282
  :node-border-width="nodeBorderWidth"
@@ -290,6 +294,7 @@ const isValidConnection = () => true;
290
294
  :on-edge-marker-end-change="(v) => edgeMarkerEnd = v"
291
295
  :on-toggle-edge-animated="() => edgeAnimated = !edgeAnimated"
292
296
  :on-edge-color-change="(v) => edgeColor = v"
297
+ :on-edge-color-opacity-change="(v) => edgeColorOpacity = v"
293
298
  :on-edge-label-color-change="(v) => edgeLabelColor = v"
294
299
  :on-toggle-node-show-border="() => nodeShowBorder = !nodeShowBorder"
295
300
  :on-node-border-width-change="(v) => nodeBorderWidth = v"
@@ -47,18 +47,20 @@ const showBorder = computed(() => props.data.showBorder !== false);
47
47
  @mouseleave="isHoveredLocal = false"
48
48
  @dblclick="data.onEdit?.()"
49
49
  >
50
- <!-- Connection handles:仅在可编辑模式下渲染 -->
51
- <template v-if="editable">
52
- <Handle
53
- v-for="handle in activeHandles"
54
- :id="`${handle.id}`"
55
- :key="`${handle.id}`"
56
- type="source"
57
- :position="handle.position"
58
- :style="handleStyle(handle)"
59
- @mousedown.stop
60
- />
61
- </template>
50
+ <!-- Connection handles:始终渲染以确保 edge 连接点正确,非编辑模式下隐藏且禁用交互 -->
51
+ <Handle
52
+ v-for="handle in activeHandles"
53
+ :id="`${handle.id}`"
54
+ :key="`${handle.id}`"
55
+ type="source"
56
+ :position="handle.position"
57
+ :connectable="editable"
58
+ :style="{
59
+ ...handleStyle(handle),
60
+ ...editable ? {} : { opacity: 0, pointerEvents: 'none', width: '1px', height: '1px' }
61
+ }"
62
+ @mousedown.stop
63
+ />
62
64
 
63
65
  <!-- content -->
64
66
  <div class="flex items-center justify-center gap-2 w-full">
@@ -10,6 +10,7 @@ type __VLS_Props = {
10
10
  edgeMarkerStart?: FlowArrowType;
11
11
  edgeMarkerEnd?: FlowArrowType;
12
12
  edgeAnimated?: boolean;
13
+ edgeColorOpacity?: number;
13
14
  edgeColor?: string;
14
15
  edgeLabelColor?: string;
15
16
  editable?: boolean;
@@ -34,6 +35,7 @@ type __VLS_Props = {
34
35
  onEdgeMarkerStartChange?: (type: FlowArrowType) => void;
35
36
  onEdgeMarkerEndChange?: (type: FlowArrowType) => void;
36
37
  onToggleEdgeAnimated?: () => void;
38
+ onEdgeColorOpacityChange?: (opacity: number) => void;
37
39
  onEdgeColorChange?: (color: string) => void;
38
40
  onEdgeLabelColorChange?: (color: string) => void;
39
41
  onToggleNodeShowBorder?: () => void;
@@ -25,6 +25,7 @@ defineProps({
25
25
  edgeMarkerStart: { type: String, required: false },
26
26
  edgeMarkerEnd: { type: String, required: false },
27
27
  edgeAnimated: { type: Boolean, required: false },
28
+ edgeColorOpacity: { type: Number, required: false },
28
29
  edgeColor: { type: String, required: false },
29
30
  edgeLabelColor: { type: String, required: false },
30
31
  editable: { type: Boolean, required: false },
@@ -46,6 +47,7 @@ defineProps({
46
47
  onEdgeMarkerStartChange: { type: Function, required: false },
47
48
  onEdgeMarkerEndChange: { type: Function, required: false },
48
49
  onToggleEdgeAnimated: { type: Function, required: false },
50
+ onEdgeColorOpacityChange: { type: Function, required: false },
49
51
  onEdgeColorChange: { type: Function, required: false },
50
52
  onEdgeLabelColorChange: { type: Function, required: false },
51
53
  onToggleNodeShowBorder: { type: Function, required: false },
@@ -138,7 +140,7 @@ function getStrokeDasharray(value) {
138
140
  v-for="opt in FLOW_COLORS"
139
141
  :key="opt.color"
140
142
  :chip="opt.chip"
141
- :shade="500"
143
+ color-role="border"
142
144
  :selected="unifiedColor === opt.color"
143
145
  :title="opt.chip || 'default'"
144
146
  @click="onUnifiedColorChange?.(opt.color)"
@@ -199,7 +201,7 @@ function getStrokeDasharray(value) {
199
201
  v-for="opt in FLOW_COLORS"
200
202
  :key="opt.color"
201
203
  :chip="opt.chip"
202
- :shade="500"
204
+ color-role="border"
203
205
  :selected="nodeBorderColor === opt.color"
204
206
  :title="opt.chip || 'default'"
205
207
  @click="onNodeBorderColorChange?.(opt.color)"
@@ -218,7 +220,7 @@ function getStrokeDasharray(value) {
218
220
  v-for="opt in FLOW_COLORS"
219
221
  :key="opt.color"
220
222
  :chip="opt.chip"
221
- :shade="50"
223
+ color-role="bg"
222
224
  :selected="nodeBgColor === opt.color"
223
225
  :title="opt.chip || 'default'"
224
226
  @click="onNodeBgColorChange?.(opt.color)"
@@ -252,7 +254,7 @@ function getStrokeDasharray(value) {
252
254
  v-for="opt in FLOW_COLORS"
253
255
  :key="opt.color"
254
256
  :chip="opt.chip"
255
- :shade="600"
257
+ color-role="font"
256
258
  :selected="nodeFontColor === opt.color"
257
259
  :title="opt.chip || 'default'"
258
260
  @click="onNodeFontColorChange?.(opt.color)"
@@ -297,7 +299,7 @@ function getStrokeDasharray(value) {
297
299
  v-for="opt in FLOW_COLORS"
298
300
  :key="opt.color"
299
301
  :chip="opt.chip"
300
- :shade="500"
302
+ color-role="border"
301
303
  :selected="nodeHandleColor === opt.color"
302
304
  :title="opt.chip || 'default'"
303
305
  @click="onNodeHandleColorChange?.(opt.color)"
@@ -550,6 +552,19 @@ function getStrokeDasharray(value) {
550
552
  </div>
551
553
  </FlowToolbarItemWrapper>
552
554
 
555
+ <!-- 颜色透明度 -->
556
+ <FlowToolbarItemWrapper label="颜色透明度">
557
+ <USlider
558
+ :model-value="edgeColorOpacity ?? 100"
559
+ :min="0"
560
+ :max="100"
561
+ :step="5"
562
+ size="sm"
563
+ class="flex-1"
564
+ @update:model-value="(v) => onEdgeColorOpacityChange?.(v ?? 100)"
565
+ />
566
+ </FlowToolbarItemWrapper>
567
+
553
568
  <!-- 连接线颜色 -->
554
569
  <div :class="{ 'opacity-40 pointer-events-none': isUnifiedMode }">
555
570
  <FlowToolbarItemWrapper label="连接线颜色">
@@ -558,7 +573,7 @@ function getStrokeDasharray(value) {
558
573
  v-for="opt in FLOW_COLORS"
559
574
  :key="opt.color"
560
575
  :chip="opt.chip"
561
- :shade="500"
576
+ color-role="border"
562
577
  :selected="edgeColor === opt.color"
563
578
  :title="opt.chip || 'default'"
564
579
  @click="onEdgeColorChange?.(opt.color)"
@@ -577,7 +592,7 @@ function getStrokeDasharray(value) {
577
592
  v-for="opt in FLOW_COLORS"
578
593
  :key="opt.color"
579
594
  :chip="opt.chip"
580
- :shade="600"
595
+ color-role="font"
581
596
  :selected="edgeLabelColor === opt.color"
582
597
  :title="opt.chip || 'default'"
583
598
  @click="onEdgeLabelColorChange?.(opt.color)"
@@ -10,6 +10,7 @@ type __VLS_Props = {
10
10
  edgeMarkerStart?: FlowArrowType;
11
11
  edgeMarkerEnd?: FlowArrowType;
12
12
  edgeAnimated?: boolean;
13
+ edgeColorOpacity?: number;
13
14
  edgeColor?: string;
14
15
  edgeLabelColor?: string;
15
16
  editable?: boolean;
@@ -34,6 +35,7 @@ type __VLS_Props = {
34
35
  onEdgeMarkerStartChange?: (type: FlowArrowType) => void;
35
36
  onEdgeMarkerEndChange?: (type: FlowArrowType) => void;
36
37
  onToggleEdgeAnimated?: () => void;
38
+ onEdgeColorOpacityChange?: (opacity: number) => void;
37
39
  onEdgeColorChange?: (color: string) => void;
38
40
  onEdgeLabelColorChange?: (color: string) => void;
39
41
  onToggleNodeShowBorder?: () => void;
@@ -9,6 +9,7 @@ export interface FlowEdgeStylesState {
9
9
  strokeType: FlowEdgeStrokeType;
10
10
  pathType: FlowEdgePathType;
11
11
  color: string;
12
+ colorOpacity: number;
12
13
  labelColor: string;
13
14
  }
14
15
  /** 节点样式存储结构 */
@@ -49,6 +50,7 @@ export declare function useFlowStyles(): {
49
50
  edgeStrokeType: WritableComputedRef<FlowEdgeStrokeType, FlowEdgeStrokeType>;
50
51
  edgePathType: WritableComputedRef<FlowEdgePathType, FlowEdgePathType>;
51
52
  edgeColor: WritableComputedRef<string, string>;
53
+ edgeColorOpacity: WritableComputedRef<number, number>;
52
54
  edgeLabelColor: WritableComputedRef<string, string>;
53
55
  nodeShowBorder: WritableComputedRef<boolean, boolean>;
54
56
  nodeBorderWidth: WritableComputedRef<number, number>;
@@ -10,6 +10,7 @@ const EDGE_DEFAULTS = {
10
10
  strokeType: "solid",
11
11
  pathType: "smoothstep",
12
12
  color: "",
13
+ colorOpacity: 100,
13
14
  labelColor: ""
14
15
  };
15
16
  const NODE_DEFAULTS = {
@@ -74,6 +75,7 @@ export function useFlowStyles() {
74
75
  const edgeStrokeType = useField(edgeStore, "strokeType");
75
76
  const edgePathType = useField(edgeStore, "pathType");
76
77
  const edgeColor = useField(edgeStore, "color");
78
+ const edgeColorOpacity = useField(edgeStore, "colorOpacity");
77
79
  const edgeLabelColor = useField(edgeStore, "labelColor");
78
80
  const nodeShowBorder = useField(nodeStore, "showBorder");
79
81
  const nodeBorderWidth = useField(nodeStore, "borderWidth");
@@ -117,6 +119,7 @@ export function useFlowStyles() {
117
119
  edgeStrokeType,
118
120
  edgePathType,
119
121
  edgeColor,
122
+ edgeColorOpacity,
120
123
  edgeLabelColor,
121
124
  // 节点(原始自定义值,用于 UI 绑定)
122
125
  nodeShowBorder,
@@ -58,7 +58,8 @@ const FLOW_COLOR_NAMES = [
58
58
  "purple",
59
59
  "fuchsia",
60
60
  "pink",
61
- "rose"
61
+ "rose",
62
+ "neutral"
62
63
  ];
63
64
  export const FLOW_COLORS = [
64
65
  { color: "primary", chip: "primary" },
@@ -72,7 +73,7 @@ export const FLOW_SHADE_MAP = {
72
73
  export function resolveFlowColor(name, role, isDark) {
73
74
  if (!name) return "";
74
75
  const shade = FLOW_SHADE_MAP[role][isDark ? "dark" : "light"];
75
- if (name === "primary") {
76
+ if (name === "primary" || name === "neutral") {
76
77
  return `var(--ui-color-${name}-${shade})`;
77
78
  }
78
79
  return `var(--color-${name}-${shade})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v-nuxt-ui",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Veken UI Component Library - Reusable Nuxt UI components, composables, and utilities for enterprise applications",
5
5
  "type": "module",
6
6
  "style": "./dist/runtime/index.css",