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-native-cascade-select

v0.0.4

Published

react native cascade select

Downloads

13

Readme

介绍

使用react native scrollView封装,在一组预设数据中进行选择,e.g. 省市区选择。

安装

npm install react-native-cascade-select

API

属性|说明|类型|默认值 ---|---|---|--- data | 数据源| Array<{name:string, sub: Array<{name:string, sub: Array}>}>|[] value | 值, 格式是[value1, value2, value3], 对应数据源的相应级层value| Array|[0,0,0] visible|是否显示面板|Boolean|false cols | 列数 | number|3 onChange | 选中后的回调| (val:Array): void|无 onSelectChange | 每列数据选择变化后的回调函数| (row, column): void|无 okText | 确认文本| String|确定 dismissText | 取消文本| String|取消 onOk | 点击确认时执行的回调| (e, value): void|无 onDismiss | 点击取消时执行的回调| (e): void|无 title | 大标题| String|无

效果

image

用法

import { AppRegistry, View, Button } from "react-native";
import React, { Component } from "react";
import Cascade from "react-native-cascade-select";

import city from "./city.json";
const cols = 3;

export default class Index extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      value: [0, 0, 0]
    };
  }

  onChange(val) {
    console.log("array-------->", val);
  }

  onSelectChange(row, column) {
    console.log("第几列-------->", row);
    console.log("第几行-------->", column);
  }

  onOk(e, value) {
    this.setState({ visible: false, value: value });
    console.log("ok-------->", e);
  }

  onDismiss(e) {
    this.setState({ visible: false });
    console.log("dismiss-------->", e);
  }

  render() {
    return (
      <View>
        <Button
          onPress={() => this.setState({ visible: !this.state.visible })}
          title="点我"
        />
        <Cascade
          visible={this.state.visible}
          data={city}
          cols={cols}
          okText="确认"
          dismissText="取消"
          title="选择地区"
          value={this.state.value}
          onChange={val => this.onChange(val)}
          onSelectChange={(row, column) => this.onSelectChange(row, column)}
          onOk={(e, value) => this.onOk(e, value)}
          onDismiss={e => this.onDismiss(e)}
        />
      </View>
    );
  }
}

AppRegistry.registerComponent("Test", () => Index);