npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

field-map-vue

v2.1.11

Published

本组件基于vue和svg,实现了字段映射的连线交互

Downloads

25

Readme

介绍

本组件基于vue和svg,实现了字段映射的连线交互

基本用法

截图

<template>
  <div class="filed-map">
    <mapVue
      ref="mappingNameRef"
      v-model:edges="edges"
      :height="300"
      :input-list="inputList"
      :output-list="outputList"
      :secondary-list="['a']"
    >
    </mapVue>
  </div>
</template>

<script setup lang="ts">
import mapVue from "./components/draw-line";
import { ref, watch } from "vue";

type Edge = { source: string; target: string };
type Edges = Edge[];

const inputList = ref(["a", "b"]);
const outputList = ref(["b", "a"]);
const mappingNameRef = ref();
const edges = ref<Edges>([]);
watch(
  () => edges.value,
  () => {
    console.log(
      "%c [ data-change ]-57",
      "font-size:13px; background:pink; color:#bf2c9f;",
      edges.value
    );
  },
  {
    deep: true,
  }
);
</script>

<style></style>

通过双向绑定的变量 edges来获取连线后的映射关系。

API

types

Field: {id: string, value: string}

props

|参数名|描述|类型|默认值| |--|--|--|--| |edges(v-model)|核心变量,通过该变量获取连线后的映射关系。应固定为ref变量 且初始值为[]|{source: string,target:string}[]|[]| |inputList|左边(source)所展示的列表|Field[]|[]| |outputList|右边(target)所展示的列表|Field[]|[]| |defaultEdges|如果已存在线,需通过此变量进行传递|{source: string,target:string}[]|[]| |height|整体高度,也可在class中进行修改|number|200| |secondaryList|含有二级映射的source列表|string[]|[]| |monogamy|一对一映射,如果需要多对多映射,将该属性设置为false|boolean|true| |init|是否进行初始化。不常用,只有在modal框等特殊情况下需要用到。|boolean|true| |autoSort|自动将有连接关系的线排在上面。|boolean|false|

events

|方法名|描述|参数| |--|--|--| |showSecondaryMapping|在点击二级映射的按钮后触发的事件|edge: {source: string,target:string}|

Methods

|方法名|描述|参数|返回值| |--|--|:--:|:--:| |mappingSameName|同名映射|-|-| |mappingSameRow|同行映射|-|-| |clearMap|清除所有连线|-|-| |drawLines|根据edges进行画线|-|-| |reSort|排版,有连接关系的排在上面|-|-|

slots

|插槽名|描述|参数| |--|--|:--:| |left-content|左边列表的展现形式,可使用插槽自定义|data: string| |right-content|右边列表的展现形式,可使用插槽自定义|data: string| |secondary-icon|二级映射按钮样式|-|

在Modal框中使用

问题

由于arco-design的Modal框在打开时,有一个从小到大的动画。如果初始化时有线需要绘制,会导致线的位置不正确。

解决方法

1.取消动画

截图

将arco-design的modal动画名设置为空,动画会消失,线的位置回归正常。

缺点是弹出的动画效果会消失。

2.父组件调用方法绘制

  • 将组件的init属性传递为false截图
  • 在modal组件的动画结束回调中调用绘制方法截图