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

choose-modal-list

v0.0.3

Published

```javascript import { Button, Form, Input } from "antd"; import React, { useRef } from "react"; import { FormChooseList } from "./index"; import { DeleteOutlined } from "@ant-design/icons"; import { Space } from "antd";

Downloads

7

Readme

#demo

import { Button, Form, Input } from "antd";
import React, { useRef } from "react";
import { FormChooseList } from "./index";
import { DeleteOutlined } from "@ant-design/icons";
import { Space } from "antd";

import "antd/dist/antd.less";
import "./test.less";

const totalCount = ((Math.random() * 100) | 0) + 1;

async function request(params) {
  const { pageSize, pageNo, name } = params;
  const start = (pageNo - 1) * pageSize;
  if (name) {
    return {
      rows: [{ name: "搜索到的结果", id: 9999 }],
      pageNo: 1,
      totalCount: 1,
      pageSize,
    };
  }
  return {
    rows: [...Array(pageSize).keys()].map((i, index) => ({
      name: `name${start + index + 1}`,
      id: start + index + 1,
    })),
    pageNo,
    totalCount,
    pageSize,
  };
}

function Test() {
  const columns = [
    {
      title: "名称",
      dataIndex: "name",
    },
  ];

  const [form] = Form.useForm();
  const chooseList1 = useRef();
  return (
    <div>
      <Form
        form={form}
        initialValues={{
          test3: [
            { id: 3, name: "name3" },
            { id: 4, name: "name4" },
          ],
          test4: [{ id: 3, name: "name3" }],
          test5: [{ id: 3, name: "name3" }],
          test6: [
            { id: 3, name: "name3" },
            { id: 4, name: "name4" },
          ],
        }}
      >
        <Form.Item name="test1" label="单选 关闭后保存最后的搜索状态">
          <FormChooseList
            chooseForm={{
              columns,
              formItem: (
                <div style={{ padding: 20 }}>
                  <Input.Search
                    placeholder="输入名称"
                    onSearch={(e) => {
                      chooseList1.current.getList({ name: e });
                    }}
                  />
                </div>
              ),
              saveForm: true,
            }}
            keyword="id"
            labelWorld="name"
            requestFun={request}
            chooseRef={chooseList1}
          >
            <Button>选择</Button>
          </FormChooseList>
        </Form.Item>
        <Form.Item name="test2" label="多选">
          <FormChooseList
            chooseForm={{
              columns,
              disabledList: [{ name: "name5", id: 5 }],
              saveForm: true,
              title: "这里是主标题",
              subTitle: "这里是已选多少的副标题",
              formList: [{ name: "name", label: "输入name" }],
            }}
            keyword="id"
            labelWorld="name"
            requestFun={request}
            type="checkbox"
          >
            <Button>选择</Button>
          </FormChooseList>
        </Form.Item>
        <Form.Item name="test3" label="有默认值多选 回显重新渲染">
          <FormChooseList
            chooseForm={{
              columns,
              selectItemRender: (detail) => {
                return (
                  <div key={detail.id} style={{ lineHeight: "18px" }}>
                    <p>这里是重新渲染的Item</p>
                    <p>{detail.name}</p>
                  </div>
                );
              },
            }}
            keyword="id"
            labelWorld="name"
            requestFun={request}
            type="checkbox"
            renderItem={(detail) => {
              return (
                <div key={detail.id}>
                  <Space size={10}>
                    {detail.name}
                    <DeleteOutlined
                      onClick={() => {
                        const list = form.getFieldValue("test3") || [];
                        form.setFieldsValue({
                          test3: list.filter((i) => i.id !== detail.id),
                        });
                      }}
                    />
                  </Space>
                </div>
              );
            }}
          >
            <Button>选择</Button>
          </FormChooseList>
        </Form.Item>
        <Form.Item name="test4" label="有默认值单选">
          <FormChooseList
            chooseForm={{ columns }}
            keyword="id"
            labelWorld="name"
            requestFun={request}
            type="radio"
          >
            <Button>选择</Button>
          </FormChooseList>
        </Form.Item>
        <Form.Item name="test5" label="有默认值单选 禁用">
          <FormChooseList
            chooseForm={{ columns }}
            keyword="id"
            labelWorld="name"
            requestFun={request}
            type="radio"
            readonly
          >
            <Button>选择</Button>
          </FormChooseList>
        </Form.Item>
        <Form.Item name="test6" label="有默认值多选禁用">
          <FormChooseList
            chooseForm={{ columns }}
            keyword="id"
            labelWorld="name"
            requestFun={request}
            type="checkout"
            disabled
          >
            <Button>选择</Button>
          </FormChooseList>
        </Form.Item>
      </Form>
    </div>
  );
}

export default Test;

0.0.2: 2022-08-25 22:19:13 更新内容: 解决样式没有引入的问题