3.2.2 • Published 2 months ago

amis-widget v3.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

amis-widget

开发amis自定义组件的工具集(支持react、vue2.0和jQuery技术栈)

  • 提供注册amis组件和amis-editor插件的方法;
  • 目前支持的技术栈:jQuery、vue2、react,vue3.0技术栈在vue3-amis-widget中支持;
  • 支持的amis渲染器类型:renderer(amis普通渲染器)、formitem(amis表单渲染器)、options(amis表单控件渲染器)。

提供的方法

  • registerRendererByType: 根据type类型注册 amis普通渲染器、amis表单渲染器、amis表单控件渲染器
  • registerAmisEditorPlugin: 注册 amis-editor 插件

amis-widget 3.0 版本依赖说明

  • 2.0 版本支持 amis 和 amis-editor 的任何版本;
  • 3.0.0 以上版本需要 amis 2.5.2-beta.0 以上版本, amis-editor 5.2.1-beta.32 以上版本。

在线Demo

点击访问在线Demo

快速使用

npm install --save amis-widget

注册amis组件

import { registerRendererByType } from 'amis-widget';
class MyReactSelect extends React.PureComponent {
  constructor() {
    super();
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(event) {
    // 调用amis onToggle 方法,变更选择器表单项值
    const {onToggle, options} = this.props;
    const option = options.find(o => o.value === event.target.value);
    if (onToggle) {
      onToggle(option);
    }
  }

  render() {
    // 获取表单项 value 和 options 属性
    const {label, options, title} = this.props;

    return (
      <div className="react-select">
        <span>
          {label}:
        </span>
        <select onChange={this.handleChange} title={title}>
          {options.map(option => (
            <option key={option.value} value={option.value}>
              {option.label}
            </option>
          ))}
        </select>
      </div>

    );
  }
}
// 注册amis普通渲染器
registerRendererByType(MyReactSelect, {
  type: 'react-select',
  usage: 'renderer', // formitem: amis表单渲染器、options: amis表单控件渲染器
  weight: 100,
  framework: 'react' // 技术栈类型
});

export default MyReactSelect;

注册amis-editor插件

import { registerAmisEditorPlugin } from 'amis-widget';

class ReactSelectPlugin {
  rendererName = 'react-select'; // 对应的amis渲染器
  $schema = '/schemas/UnkownSchema.json';
  name = 'react-select';
  description = 'react-select';
  tags = ['展示']; // 自定义组件分类
  icon = 'fa fa-file-code-o';
  order = 100; // 组件面板中的展示优先级,越小越靠前展示
  scaffold = { // 插入到页面时需要
    type: 'react-select',
    label: 'react-select',
    name: 'react-select',
    options: [
      {
        label: 'A',
        value: 'a'
      },
      {
        label: 'B',
        value: 'b'
      },
      {
        label: 'C',
        value: 'c'
      }
    ]
  };
  previewSchema = { // 组件面板预览时需要
    type: 'react-select',
    label: 'react-select',
    options: [
      {
        label: 'A',
        value: 'a'
      },
      {
        label: 'B',
        value: 'b'
      },
      {
        label: 'C',
        value: 'c'
      }
    ]
  };
  panelTitle = '下拉框'; // 右侧属性面板Title
  panelBody = [ // 右侧属性面板配置项
    {
      type: 'input-text',
      name: 'label',
      label: 'label',
      value: 'react-select'
    },
    {
      type: 'textarea',
      name: 'title',
      label: 'hover title',
      value: '点击下拉选择数值'
    },
    {
      type: 'tpl',
      tpl: '备注:可根据变量 \\${amisUser} 获取用户数据。'
    }
  ];
}
// 注册一个amis-editor插件(仅页面设计器需要,会在自定义组件面板中展示)
registerAmisEditorPlugin(ReactSelectPlugin);

export default ReactSelectPlugin;
amis-component-plugin@infinitebrahmanuniverse/nolb-ami@colys/amis-renderer-widget@everything-registry/sub-chunk-1126container-custom-widget-templatereact-custom-luckyreact-custom-export-wordreact-custom-drug_imgreact-custom-widget-templatereact-custom-widget-template-l2react-custom-widget-template-l3react-custon-mapsreact-custom-commontsreact-ljhreact-widget-devreact-mxflllgis-map-componentexcel-json-tj-parserexcel-tj-parserreact-custom-excel-parsercustom-excel-parserreact-custom-excel-tj-parseryifengjiexie-vue2-amis-custom-widget-test1chenmins-vue-custom-widget-template@dj-luban/aisuda-standard-componentdatav-react-custom-widget-templatedatav-react-ts-custom-widget-templatei18n-react-custom-widget-templatesuda-order-tablesuda-table-ordersuda-table-orderv2suda-table-orderv3suda-table-orderv4suda-table-orderv5suda-table-orderv6suda-table-orderv7suda-table-orderv8suda-table-orderv9test-loader-amis-npm-componenttest-loader-npm-componenttest-amis-vue2-libitsccn-lowcode-widgetsjerry-vue2-custom-componentjiajia-vue-info-cardty-progresstriman-vue2-amis-custom-widgetvue-custom-widget-templatevue2-amis-custom-widgetvue2-amis-custom-widget-testvue2-amis-custom-widget2vue2-amis-mindeditor-widgetvue2-amis-text-widgetvue2-amis-widget-suda-test@zalastax/nolb-amiwebwangjiajia_multiple-custom-widget-templatewebwangjiajia_react-ts-custom-widget-templatewebwangjiajia_vue-container-custom-widget-templatewebwangjiajia_vue-info-cardwebwangjiajia_vue-info-card-interfacewebwangjiajia_vue-uploadvue-amis-testvue-aside-navvue-aside-nav-test1vue2-info-mapvue-container-custom-widget-templatevue-magnifying-lens@webwangjiajia/vue-info-cardyang-amis-vue2multiple-custom-widget-templatemultiple-custom-widget-template-betamultiple-custom-widget-template-testamis-custom-widget-1amis-custom-widget-demo1yunli-amisexcel-json-parserorder-new-table
3.2.2

2 months ago

3.2.1

6 months ago

3.2.0

11 months ago

3.1.0

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.8

1 year ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.0

1 year ago

3.0.2-beta.2

1 year ago

3.0.2-beta.1

1 year ago

3.0.9

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.1

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.3

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.3.8

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.15

2 years ago

1.0.13

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago