Socket
Socket
Sign inDemoInstall

@uiw/react-month-picker

Package Overview
Dependencies
25
Maintainers
2
Versions
172
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @uiw/react-month-picker

MonthPicker component


Version published
Weekly downloads
226
increased by12.44%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

MonthPicker 月份选择器

Buy me a coffee Open in unpkg NPM Downloads npm version

模态对话框。

import { MonthPicker } from 'uiw';
// or
import MonthPicker from '@uiw/react-month-picker';

基础用法

import React from 'react';
import { MonthPicker, Row, Col } from 'uiw';

export default function Demo() {
  const [formatDate, setFormatDate] = React.useState('2019/04')
  function onChange(date, formatDate) {
    setFormatDate(formatDate)
  }
  return (
    <Row gutter={10}>
      <Col style={{ width: 200 }} fixed>
        <MonthPicker size="large" onChange={onChange} placeholder="Select month" />
      </Col>
      <Col style={{ width: 200 }} fixed>
        <MonthPicker disabled value={formatDate} placeholder="Select month" />
      </Col>
    </Row>
  )
}

在表单中使用

import React from 'react';
import { Form, MonthPicker, Notify, Row, Col, Button } from 'uiw';

export default function Demo() {
  return (
    <div>
      <Form
        onSubmit={({initial, current}) => {
          if(current.date) {
            Notify.success({
              title: '提交成功!',
              description: `表单提交时间成功,时间为:${current.date}`,
            });
          } else {
            Notify.error({
              title: '提交失败!',
              description: `表单提交时间成功,时间为:${current.date},将自动填充初始化值!`,
            });
          }
          console.log('-->>', initial, current);
        }}
        fields={{
          date: {
            labelClassName: 'fieldLabel',
            labelFor: 'date-inline',
            children: <MonthPicker id="date-inline" />
          },
        }}
      >
        {({ fields, state, canSubmit }) => {
          return (
            <Row gutter={10}>
              <Col style={{ width: 200 }} fixed>{fields.date}</Col>
              <Col>
                <Button disabled={!canSubmit()} type="primary" htmlType="submit">提交</Button>
              </Col>
            </Row>
          )
        }}
      </Form>
    </div>
  )
}

Props

参数说明类型默认值
value初始时间值Date-
placeholder输入框提示文字String-
allowClear是否显示清除按钮Booleantrue
format格式化时间,规则查看 formatter 文档StringYYYY/MM/DD
onChange选择一天时调用。Function(Date, formatDate)-
popoverProps将参数传递给内部 <Popover> 组件Object-
pickerCaptionProps将参数传递给内部 <DatePicker> PickerCaption 组件PickerCaptionProps-
disabled组件 <Input> 的属性,禁用日历Boolean-

更多属性文档请参考 <Input>

Keywords

FAQs

Last updated on 29 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc