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

@lingxiteam/dsl

v2.1.1

Published

灵犀低代码平台DSL操作库,一切皆Node。

Downloads

898

Readme

@lingxiteam/dsl

灵犀低代码平台DSL操作库,一切皆Node。除get开头方法外,一切方法皆可链式调用。示例如下:

DSLCore?.query(compId)
        .setProps(props)
        .setStyle(props)
        .appendSetEvents(event);

1. 安装

yarn add @lingxiteam/dsl

2. 使用


import { DSLProvider } from '@lingxiteam/dsl';

interface EditorProps {}

const Editor: FC<EditorProps> = props => {
  const [json, setJson] = React.useState<any>();

  useEffect(() => {
    setTimeout(() => {
      setJson(data);
    }, 2000);
  }, []);

  return (
    <DSLProvider json={json}>
      <EditorView />
    </DSLProvider>
  );
};

export default Editor;

3. 操作Node

import { useDSLSelect } from '@lingxiteam/dsl';

interface CanvasProps {}

const Canvas: FC<CanvasProps> = props => {
  const { DSLCore } = useDSLSelect();

  // 设置当前选中节点
  DSLCore?.setCurrent(comp.id);

  // 获取根节点
  DSLCore?.document.rootNode;

  // 获取节点子组件
  DSLCore?.document.rootNode?.children();

  // 查询节点
  const node = DSLCore?.query(compId);

  // Node节点的增删改查操作...
  node.appendChild({
    id: '',
    compName: '',
    components: [],
    compLib: ''
    ...
  });

  node.insertChild(0, {
    id: '',
    compName: '',
    components: [],
    compLib: ''
    ...
  });

  node.insertChildBeforeById(compId, getNode());
  
  ...

  // 移除节点
  node.remove();

  // 删除所有子元素
  node.removeAllChildren();
  
  // 支持移动组件 
  node.moveTo();

  // 设置属性、样式、自定义样式、数据源、自定义函数、事件等
  node.setProps();
  node.setStyle();
  node.setCustomStyle();
  node.appendDataSource();
  node.updateDataSourceByIndex();
  node.deleteDataSourceByIndex();
  node.deleteDataSourceById();
  node.appendCustomFunctions();
  node.updateCustomFunctionsByIndex();
  node.updateCustomFunctionsByEventCode();
  node.deleteCustomFunctionsByEventCode();
  node.deleteCustomFunctionsByIndex();

  // 以上函数只是简单列举,内部提供了更多使用方法。详见下表格

  return (
    <div className="canvas" />
  );
};

4. API

4.1 DSLQuery

单例方法,全局只有一个DSLQuery类。等于useDSLSelect类中的DSLCore。一般情况下无需使用本类方法。

| 方法 | 说明 | 类型 | 默认值 | 参数必填 | | ---- | ---- | ---- | ---- | ---- | | init(e: JSONType): this | 初始化方法,传入JSON数据,一般不用主动调用,默认会通过DSLProvider传入。| (e: JSONType) => this | - | 是 | | reset(e): this | 重置方法,默认恢复到init初始化状态 | () => this | - | 无参数 | | clear(e): this | 清除QSLQuery,主要给恢复、回退功能使用 | () => this | - | 无参数 | | query(id:string): DSLNode | RootNode | 根据id查询Node节点 | (id: string) => DSLNode | RootNode | - | 是 | | toJSON() => JSONType | 转换成JSON数据 | () => JSONType|null | - | 否 |

4.2 DSLDocument

文档类,用来管理NODE节点。可通过 DSLCore.document 获得。

4.3 DSLNode

具体操作可在项目中直接查看属性,或者使用开发过程中的提示功能。如下图所示。

提示效果

提示1

接口定义

查看图片

具体Demo可查看 github