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

react-area-linkage

v3.0.0

Published

React area linkage

Downloads

521

Readme

npm-version license

react-area-linkage

省市区联动选择,组合数据来源:area-data

Installation

Install the pkg with npm:

// v3之前的版本
npm i --save react-area-linkage

// v3及之后的版本
npm i --save react-area-linkage area-data

or yarn

// v3之前的版本
yarn add react-area-linkage

// v3及之后的版本
yarn add react-area-linkage area-data

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import { pca, pcaa } from 'area-data'; // v3 or higher
import 'react-area-linkage/dist/index.css'; // v2 or higher
import { AreaSelect, AreaCascader } from 'react-area-linkage';

// basic
<AreaSelect onChange={this.selectedChange} data={pca} />
<AreaCascader onChange={this.selectedChange} data={pcaa}/>

//setting
<AreaSelect type='all' level={2} data={pcaa} onChange={this.selectedChange} />
<AreaCascader type='all' onChange={this.selectedChange} level={1} data={pcaa} />

More demo to visit here.

On Demand Import

version >= 2.0.0

安装 babel-plugin-on-demand-import:

npm i babel-plugin-on-demand-import -D

修改 .babelrc:

{
    // ...
    "plugins": [
        ["on-demand-import" {
            "libraryName": "react-area-linkage",
            "libraryPath": "dist/lib"
        }]
    ]
}
import 'react-area-linkage/dist/index.css'; // v2 or higher
import pcaa from 'area-data/pcaa';
// Only import AreaCascader component
import { AreaCascader } from 'react-area-linkage';

<AreaCascader onChange={this.selectedChange} level={2} data={pcaa}></AreaCascader>

// Only import AreaSelect component
import { AreaSelect } from 'react-area-linkage'; 

<AreaSelect onChange={this.selectedChange} level={1} data={pcaa}></AreaSelect>

属性

area-select 组件

| 参数 | 类型 | 可选值 | 默认值 | 说明 | | :--: | :--: | :--: | :--: | :--: | | type | String | all/code/text | code | 设置返回的数据格式 | | placeholders | Array | - | [] | 设置 placeholder text | | level | Number | 0/1/2 | 1 | 设置联动层级(0-只选省份/1-省市联动/2-省市区联动) | | size | String | small/medium/large | medium | 设置输入框的大小 | | defaultArea | Array | - | [] | 设置默认值(值类型数据需统一,要么全是文本,要么全是区域代码) | | onChange | Function | - | - | 选择项改变时的回调 | | disabled | Boolean | - | false | 是否禁用 | | data | Object | - | - | 地区数据(v3需要传入) |

v2 仅支持省市区联动,即 v2 不再支持 level 的值为 3

area-cascader 组件

| 参数 | 类型 | 可选值 | 默认值 | 说明 | | :--: | :--: | :--: | :--: | :--: | | type | String | all/code/text | code | 设置返回的数据格式 | | placeholder | String | - | '' | 设置 placeholder text | | level | Number | 0/1 | 0 | 设置联动层级(0-省市联动/1-省市区联动) | | size | String | small/medium/large | medium | 设置输入框的大小 | | defaultArea | Array | - | [] | 设置默认值(值类型数据需统一,要么全是文本,要么全是区域代码) | | onChange | Function | - | - | 选择项改变时的回调 | | disabled | Boolean | - | false | 是否禁用 | | separator | String | - | '/' | 显示选中文本的分隔符 | | data | Object | - | - | 地区数据(v3需要传入) |

Related Project

License

MIT.