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

@kne/form-info

v0.1.0

Published

构建一个更加美观的form表单组件

Downloads

150

Readme

form-info

描述

构建一个更加美观的form表单组件

安装

npm i --save @kne/form-info

示例(全屏)

示例代码

  • Form
  • 这里填写示例说明
  • _FormInfo(@kne/current-lib_form-info),antd(antd),(@kne/current-lib_form-info/dist/index.css)
const {default: FormInfo, List, TableList, MultiField, Form, Input, TextArea, SubmitButton, ResetButton} = _FormInfo;
const {Flex} = antd;

const BaseExample = () => {
    return <Form>
        <FormInfo title="标题" subtitle="附标题" list={[<Input name="field_1" label="字段1" rule="REQ"/>,
            <Input name="field_2" label="字段2" rule="REQ"/>,
            <Input name="field_3" hidden label="隐藏字段" rule="REQ"/>,
            <MultiField name="field_4" label="字段4" rule="REQ" field={Input} block/>,
            <TextArea name="description" label="描述" block/>]}/>
        <List title="列表" name="list-1" itemTitle={({index}) => `项目${index + 1}`}
              list={[<Input name="field_1" label="字段1" rule="REQ"/>, <Input name="field_2" label="字段2" rule="REQ"/>,
                  <TextArea name="description" label="描述" block/>]}/>
        <List title="复杂列表" name="list-2" itemTitle={({index}) => `项目${index + 1}`} important
              list={[<Input name="field_1" label="字段1" rule="REQ"/>, <Input name="field_2" label="字段2" rule="REQ"/>,
                  <TextArea name="description" label="描述" block/>,
                  <List title="子级列表" itemTitle={({index}) => `子级项目${index + 1}`}
                        list={[<Input name="field_1" label="字段1" rule="REQ"/>,
                            <Input name="field_2" label="字段2" rule="REQ"/>,
                            <TextArea name="description" label="描述" block/>]} block/>]}/>
        <TableList title="表格列表" name="list-3" itemTitle={({index}) => `项目${index + 1}`}
                   list={[<Input name="field_1" label="字段1" rule="REQ"/>,
                       <Input name="field_2" label="字段2" rule="REQ"/>,
                       <Input name="description" label="描述" block/>]}/>
        <Flex justify="center" gap={8}>
            <SubmitButton>提交</SubmitButton>
            <ResetButton>重置</ResetButton>
        </Flex>
    </Form>;
};

render(<BaseExample/>);
  • FormModal
  • 这里填写示例说明
  • _FormInfo(@kne/current-lib_form-info),antd(antd),(@kne/current-lib_form-info/dist/index.css)
const {default: FormInfo, FormModal, List, Input, TextArea} = _FormInfo;
const {useState} = React;
const {Button} = antd;

const BaseExample = () => {
    const [open, onOpenChange] = useState(false);
    return <>
        <Button onClick={() => {
            onOpenChange(true);
        }}>打开Form弹窗</Button>
        <FormModal formProps={{
            data: {name: '张三'}
        }} open={open} onCancel={() => {
            onOpenChange(false);
        }}>
            <FormInfo title="基本信息" column={1} list={[<Input name="name" label="姓名" rule="REQ"/>,
                <Input name="phone" label="电话" rule="REQ TEL"/>, <TextArea name="description" label="描述" block/>]}/>
            <List title="工作经历" list={[<Input name="name" label="姓名" rule="REQ"/>,
                <Input name="phone" label="电话" rule="REQ TEL"/>, <TextArea name="description" label="描述" block/>]}/>
        </FormModal>
    </>;
};

render(<BaseExample/>);
  • FormSteps
  • 这里填写示例说明
  • _FormInfo(@kne/current-lib_form-info),antd(antd),(@kne/current-lib_form-info/dist/index.css)
const {default: FormInfo, FormSteps, List, Input, TextArea, SubmitButton, CancelButton} = _FormInfo;
const {Flex, Divider} = antd;
const BaseExample = () => {
    return <Flex vertical>
        <FormSteps items={[{
            title: '表单1',
            formProps: {},
            children: <FormInfo title="基本信息" list={[<Input name="name" label="姓名" rule="REQ"/>,
                <Input name="phone" label="电话" rule="REQ TEL"/>, <TextArea name="description" label="描述" block/>,
                <Flex block justify="center" gap={8}>
                    <SubmitButton>提交</SubmitButton>
                    <CancelButton>取消</CancelButton>
                </Flex>]}/>
        }, {
            title: '表单2', formProps: {}, children: <>
                <List title="工作经历" list={[<Input name="name" label="姓名" rule="REQ"/>,
                    <Input name="phone" label="电话" rule="REQ TEL"/>,
                    <TextArea name="description" label="描述" block/>]}/>
                <Flex justify="center" gap={8}>
                    <SubmitButton>提交</SubmitButton>
                    <CancelButton>取消</CancelButton>
                </Flex>
            </>
        }]}/>
        <Divider/>
        <FormSteps direction="vertical" items={[{
            title: '表单1',
            formProps: {},
            children: <FormInfo title="基本信息" list={[<Input name="name" label="姓名" rule="REQ"/>,
                <Input name="phone" label="电话" rule="REQ TEL"/>, <TextArea name="description" label="描述" block/>,
                <Flex block justify="center" gap={8}>
                    <SubmitButton>提交</SubmitButton>
                    <CancelButton>取消</CancelButton>
                </Flex>]}/>
        }, {
            title: '表单2', formProps: {}, children: <>
                <List title="工作经历" list={[<Input name="name" label="姓名" rule="REQ"/>,
                    <Input name="phone" label="电话" rule="REQ TEL"/>,
                    <TextArea name="description" label="描述" block/>]}/>
                <Flex justify="center" gap={8}>
                    <SubmitButton>提交</SubmitButton>
                    <CancelButton>取消</CancelButton>
                </Flex>
            </>
        }]}/>
    </Flex>
};

render(<BaseExample/>);
  • FormStepsModal
  • 这里填写示例说明
  • _FormInfo(@kne/current-lib_form-info),antd(antd),(@kne/current-lib_form-info/dist/index.css)
const {default: FormInfo, FormStepsModal, List, Input, TextArea, SubmitButton, CancelButton} = _FormInfo;
const {Flex, Button} = antd;
const {useState} = React;

const BaseExample = () => {
    const [open, onOpenChange] = useState(false);
    return <>
        <Button onClick={() => {
            onOpenChange(true);
        }}>打开StepsForm弹窗</Button>
        <FormStepsModal modalProps={{open, title: '多步骤表单', onCancel: () => onOpenChange(false)}} items={[{
            title: '表单1',
            formProps: {
                data: {
                    phone: '10929299202'
                }
            },
            children: <FormInfo title="基本信息" list={[<Input name="name" label="姓名" rule="REQ"/>,
                <Input name="phone" label="电话" rule="REQ TEL"/>, <TextArea name="description" label="描述" block/>]}/>
        }, {
            title: '表单2',
            formProps: {
                data: {
                    phone: '11939388383'
                }
            },
            children: <List title="工作经历" list={[<Input name="name" label="姓名" rule="REQ"/>,
                <Input name="phone" label="电话" rule="REQ TEL"/>, <TextArea name="description" label="描述" block/>]}/>
        }]}/>
    </>;

    return <Flex vertical>
        <FormSteps/>
    </Flex>
};

render(<BaseExample/>);

API

| 属性名 | 说明 | 类型 | 默认值 | |-----|----|----|-----| | | | | |