2.17.2 β€’ Published 1 year ago

react-semantic-ui-datepickers v2.17.2

Weekly downloads
3,520
License
MIT
Repository
github
Last release
1 year ago

πŸ“† react-semantic-ui-datepickers

Datepickers built with Semantic UI for React and Dayzed

version MIT License All Contributors

Overview

Semantic UI for React doesn't have a datepicker and the best solutions don't fit with its design. This library tries to solve this problem providing a component that can act as a basic or range datepicker.

It supports most props of Form.Input and Dayzed components. Check the supported props section for more information.

Table of Contents

Installation

npm install --save react-semantic-ui-datepickers
yarn add react-semantic-ui-datepickers

This package also depends on react and semantic-ui-react. Please make sure you have them installed as well.

Usage

import React, { useState } from 'react';
import SemanticDatepicker from 'react-semantic-ui-datepickers';
import 'react-semantic-ui-datepickers/dist/react-semantic-ui-datepickers.css';

const AppWithBasic = () => {
  const [currentDate, setNewDate] = useState(null);
  const onChange = (event, data) => setNewDate(data.value);

  return <SemanticDatepicker onChange={onChange} />;
};

const AppWithRangeAndInPortuguese = () => {
  const [currentRange, setNewRange] = useState([]);
  const onChange = (event, data) => setNewRange(data.value);

  return <SemanticDatepicker locale="pt-BR" onChange={onChange} type="range" />;
};

More examples here.

Supported Props

Own Props

propertytyperequireddefaultdescription
allowOnlyNumbersbooleannotrueAllows the user enter only numbers
autoCompletestringno--Specifies if the input should have autocomplete enabled
clearIconSemanticICONS | React.ReactElementno'close'An icon from semantic-ui-react or a custom component. The custom component will get two props: data-testid and onClick.
clearOnSameDateClickbooleannotrueControls whether the datepicker's state resets if the same date is selected in succession.
clearablebooleannotrueAllows the user to clear the value
datePickerOnlybooleannofalseAllows the date to be selected only via the date picker and disables the text input
filterDatefunctionno(date) => trueFunction that receives each date and returns a boolean to indicate whether it is enabled or not
formatstringno'YYYY-MM-DD'Specifies how to format the date using the date-fns' format
formatOptionsoptionsno--Specifies the options to format the date using the date-fns' format
iconSemanticICONS | React.ReactElementno'calendar'An icon from semantic-ui-react or a custom component. The custom component will get two props: data-testid and onClick.
inlinebooleannofalseUses an inline variant, without the input and the features related to it, e.g. clearable datepicker
keepOpenOnClearbooleannofalseKeeps the datepicker open (or opens it if it's closed) when the clear icon is clicked
keepOpenOnSelectbooleannofalseKeeps the datepicker open when a date is selected
localestringno'en-US'Filename of the locale to be used. PS: Feel free to submit PR's with more locales!
onBlurfunctionno(event) => {}Callback fired when the input loses focus
onFocusfunctionno(event) => {}Callback fired when the input gets focused focus
onChangefunctionno(event, data) => {}Callback fired when the value changes
pointingstringno'left'Location to render the component around input. Available options: 'left', 'right', 'top left', 'top right'
showTodaybooleannotrueHides the "Today" button if false
typestringnobasicType of input to render. Available options: 'basic' and 'range'
valueDate|Date[]no--The value of the datepicker

Form.Input Props

  • autoComplete
  • className
  • disabled
  • error
  • iconPosition
  • id
  • inverted
  • label
  • loading
  • name
  • placeholder
  • size
  • transparent
  • readOnly

Dayzed Props

  • date
  • maxDate
  • minDate
  • firstDayOfWeek
  • showOutsideDays
  • selected

Customization

In order to customize the elements, you can override the styles of the classes below:

  • clndr-cell
  • clndr-cell-today
  • clndr-cell-inrange
  • clndr-cell-disabled
  • clndr-cell-selected
  • clndr-cell-other-month

If you think this way of customizing is not a good idea, feel free to open an issue suggesting something else. This was the simplest solution I thought.

Roadmap

  • Add more tests (including e2e)

Feel free to open issues and/or create PRs to improve other aspects of the library!

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT

2.17.2

1 year ago

2.17.0

2 years ago

2.17.1

2 years ago

2.15.2

2 years ago

2.15.1

2 years ago

2.15.1-beta.1

2 years ago

2.16.1

2 years ago

2.16.2

2 years ago

2.16.0

2 years ago

2.15.0

3 years ago

2.14.0

3 years ago

2.13.2

3 years ago

2.13.2-beta.1

3 years ago

2.13.1

3 years ago

2.13.0

3 years ago

2.13.0-beta.1

3 years ago

2.12.1-beta.1

3 years ago

2.12.0

3 years ago

2.11.0

3 years ago

2.10.0

4 years ago

2.9.1

4 years ago

2.9.0

4 years ago

2.8.1-beta.0

4 years ago

2.8.0

4 years ago

2.8.0-beta.0

4 years ago

2.7.0

4 years ago

2.7.0-beta.0

4 years ago

2.6.2

4 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.3

4 years ago

2.5.2

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.6.0-beta.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.12.0

5 years ago

1.11.1

5 years ago

1.11.0

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

0.0.0

5 years ago

1.9.0

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago