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

el-form-maker

v1.0.5

Published

a lib about form base on element-ui

Downloads

2

Readme

el-form-maker

基于 element-ui 封装的表单生成器

  yarn add el-form-maker

目录

概要 el-form-maker 是基于element-ui封装的表单生成器,利用render写法封装灵活扩展性极高的组件,jsx的模板渲染解决了render重复嵌套问题,只需简单的配置即可快速生成表单

特点

  • 只需进行简单的配置,即可原子表单生成
  • 支持 ElFprm 的所有的API
  • 支持自定义组件渲染及其校验
  • 支持表单预览模式
  • 支持栅格布局

示例

栅格布局模式 02-2020

<template>
  <div class="demo1">
    <el-form-maker :options="options" label-width="180px" />
  </div>
</template>
<script>
const CustomComponent = {
  name: 'custom-componet',
  props: ['value'],
  watch: {
    value: function(val) {
      this.val = val
    }
  },
  data() {
    return {
      val: ''
    }
  },
  render(h) {
    return h('div', {}, [
      h('el-input', {
        style: {
          width: '40%'
        },
        props: {
          value: this.val
        },
        on: {
          input: val => {
            this.$emit('val', val)
          }
        }
      }),
      <span style="marginLeft:10px;">我是自定义组件</span>
    ])
  }
}

export default {
  name: 'demo1',
  data() {
    return {
      options: [
        {
          rowId: 1,
          type: 'input',
          prop: 'a',
          label: '第一行(1)',
          col: {
            span: 8
          }
        },
        {
          rowId: 1,
          type: 'select',
          prop: 'b',
          label: '第一行(2)',
          col: {
            span: 8
          },
          defaultValue: 1,
          options: [
            {
              label: '下拉1',
              value: 1
            },
            {
              label: '下拉2',
              value: 2
            }
          ]
        },
        {
          rowId: 2,
          component: CustomComponent,
          prop: 'c',
          label: '第二行(1)自定义组件',
          col: {
            span: 8
          }
        },
        {
          rowId: 2,
          type: 'radio-group',
          label: '第二行(2)',
          prop: 'd',
          col: {
            span: 8
          },
          defaultValue: '2',
          options: [
            {
              label: '单选1',
              value: '2'
            },
            {
              label: '单选2',
              value: '3'
            }
          ]
        }
      ]
    }
  }
}
</script>

预览模式 02-2020

  <template>
  <div class="demo1">
    <el-form-maker :options="options" label-width="180px" :isView="true" ref="elFormMaker" label-suffix=": " />
  </div>
</template>
<script>
const CustomComponent = {
  name: 'custom-componet',
  props: ['value'],
  watch: {
    value: function(val) {
      this.val = val
    }
  },
  data() {
    return {
      val: ''
    }
  },
  render(h) {
    return h('div', {}, [
      h('el-input', {
        style: {
          width: '40%'
        },
        props: {
          value: this.val
        },
        on: {
          input: val => {
            this.$emit('val', val)
          }
        }
      }),
      <span style="marginLeft:10px;">我是自定义组件</span>
    ])
  }
}

export default {
  name: 'demo1',
  data() {
    return {
      options: [
        {
          rowId: 1,
          type: 'input',
          prop: 'a',
          label: '第一行(1)',
          col: {
            span: 8
          }
        },
        {
          rowId: 1,
          type: 'select',
          prop: 'b',
          label: '第一行(2)',
          col: {
            span: 8
          },
          defaultValue: 1,
          options: [
            {
              label: '下拉1',
              value: 1
            },
            {
              label: '下拉2',
              value: 2
            }
          ],
          formatter: row => {
            const MAP = {
              1: '下拉1',
              2: '下拉2'
            }
            return MAP[row.b]
          }
        },
        {
          rowId: 2,
          component: CustomComponent,
          prop: 'c',
          label: '第二行(1)自定义组件',
          col: {
            span: 8
          },
          formatter: row => <span>{row.c}</span>
        },
        {
          rowId: 2,
          type: 'radio-group',
          label: '第二行(2)',
          prop: 'd',
          col: {
            span: 8
          },
          defaultValue: '1',
          options: [
            {
              label: '单选1',
              value: '1'
            },
            {
              label: '单选2',
              value: '2'
            }
          ],
          formatter: row => {
            const MAP = {
              1: '单选1',
              2: '单选2'
            }
            return MAP[row.d]
          }
        }
      ]
    }
  },
  async mounted() {
    await this.$nextTick()
    const {updateForm} = this.$refs.elFormMaker
    updateForm({
      a: '我是输入输入框的值',
      b: 1,
      c: '自定义的值',
      d: '1'
    })
  }
}
</script>