Skip to content

issues#176 fix and minor improvements #786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
module.exports = {
stories: ['../stories/**/*.stories.tsx'],
addons: ['@storybook/addon-knobs', '@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-storysource'],
addons: [
'@storybook/addon-controls',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-storysource',
],
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
typescript: {
check: true, // type-check stories during Storybook build
}
},
};
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ yarn add react-semantic-ui-datepickers
```jsx
import React, { useState } from 'react';
import SemanticDatepicker from 'react-semantic-ui-datepickers';
import { ptBR } from 'react-semantic-ui-datepickers/dist/locales';
import 'react-semantic-ui-datepickers/dist/react-semantic-ui-datepickers.css';

const AppWithBasic = () => {
Expand All @@ -63,7 +64,7 @@ const AppWithRangeAndInPortuguese = () => {
const [currentRange, setNewRange] = useState([]);
const onChange = (event, data) => setNewRange(data.value);

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

Expand All @@ -73,29 +74,29 @@ More examples [here](https://react-semantic-ui-datepickers.now.sh).

### Own Props

| property | type | required | default | description |
| -------------------- | ------------------------------------------------------------- | -------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowOnlyNumbers | boolean | no | true | Allows the user enter only numbers |
| autoComplete | string | no | -- | Specifies if the input should have autocomplete enabled |
| clearIcon | SemanticICONS \| React.ReactElement | no | 'close' | An [icon from semantic-ui-react](https://react.semantic-ui.com/elements/icon/) or a custom component. The custom component will get two props: `data-testid` and `onClick`. |
| clearOnSameDateClick | boolean | no | true | Controls whether the datepicker's state resets if the same date is selected in succession. |
| clearable | boolean | no | true | Allows the user to clear the value |
| datePickerOnly | boolean | no | false | Allows the date to be selected only via the date picker and disables the text input |
| filterDate | function | no | (date) => true | Function that receives each date and returns a boolean to indicate whether it is enabled or not |
| format | string | no | 'YYYY-MM-DD' | Specifies how to format the date using the [date-fns' format](https://date-fns.org/v2.24.0/docs/format) |
| formatOptions | [options](https://date-fns.org/v2.24.0/docs/format#arguments) | no | -- | Specifies the options to format the date using the [date-fns' format](https://date-fns.org/v2.24.0/docs/format) |
| icon | SemanticICONS \| React.ReactElement | no | 'calendar' | An [icon from semantic-ui-react](https://react.semantic-ui.com/elements/icon/) or a custom component. The custom component will get two props: `data-testid` and `onClick`. |
| inline | boolean | no | false | Uses an inline variant, without the input and the features related to it, e.g. clearable datepicker |
| keepOpenOnClear | boolean | no | false | Keeps the datepicker open (or opens it if it's closed) when the clear icon is clicked |
| keepOpenOnSelect | boolean | no | false | Keeps the datepicker open when a date is selected |
| locale | string | no | 'en-US' | Filename of the locale to be used. PS: Feel free to submit PR's with more locales! |
| onBlur | function | no | (event) => {} | Callback fired when the input loses focus |
| onFocus | function | no | (event) => {} | Callback fired when the input gets focused focus |
| onChange | function | no | (event, data) => {} | Callback fired when the value changes |
| pointing | string | no | 'left' | Location to render the component around input. Available options: 'left', 'right', 'top left', 'top right' |
| showToday | boolean | no | true | Hides the "Today" button if false |
| type | string | no | basic | Type of input to render. Available options: 'basic' and 'range' |
| value | Date\|Date[] | no | -- | The value of the datepicker |
| property | type | required | default | description |
| -------------------- | ------------------------------------------------------------- | -------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowOnlyNumbers | boolean | no | true | Allows the user enter only numbers |
| autoComplete | string | no | -- | Specifies if the input should have autocomplete enabled |
| clearIcon | SemanticICONS \| React.ReactElement | no | 'close' | An [icon from semantic-ui-react](https://react.semantic-ui.com/elements/icon/) or a custom component. The custom component will get two props: `data-testid` and `onClick`. |
| clearOnSameDateClick | boolean | no | true | Controls whether the datepicker's state resets if the same date is selected in succession. |
| clearable | boolean | no | true | Allows the user to clear the value |
| datePickerOnly | boolean | no | false | Allows the date to be selected only via the date picker and disables the text input |
| filterDate | function | no | (date) => true | Function that receives each date and returns a boolean to indicate whether it is enabled or not |
| format | string | no | 'YYYY-MM-DD' | Specifies how to format the date using the [date-fns' format](https://date-fns.org/v2.24.0/docs/format) |
| formatOptions | [options](https://date-fns.org/v2.24.0/docs/format#arguments) | no | -- | Specifies the options to format the date using the [date-fns' format](https://date-fns.org/v2.24.0/docs/format) |
| icon | SemanticICONS \| React.ReactElement | no | 'calendar' | An [icon from semantic-ui-react](https://react.semantic-ui.com/elements/icon/) or a custom component. The custom component will get two props: `data-testid` and `onClick`. |
| inline | boolean | no | false | Uses an inline variant, without the input and the features related to it, e.g. clearable datepicker |
| keepOpenOnClear | boolean | no | false | Keeps the datepicker open (or opens it if it's closed) when the clear icon is clicked |
| keepOpenOnSelect | boolean | no | false | Keeps the datepicker open when a date is selected |
| locale | object | no | en-US.json | Ready object from '[react-semantic-ui-datepickers/dist/locales](./dist/locales/index.js)' or custom object according to [template](./dist/locales/en-US.json). PS: Feel free to submit PR's with more locales! |
| onBlur | function | no | (event) => {} | Callback fired when the input loses focus |
| onFocus | function | no | (event) => {} | Callback fired when the input gets focused focus |
| onChange | function | no | (event, data) => {} | Callback fired when the value changes |
| pointing | string | no | 'left' | Location to render the component around input. Available options: 'left', 'right', 'top left', 'top right' |
| showToday | boolean | no | true | Hides the "Today" button if false |
| type | string | no | basic | Type of input to render. Available options: 'basic' and 'range' |
| value | Date\|Date[] | no | -- | The value of the datepicker |

### Form.Input Props

Expand Down
64 changes: 31 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,57 +36,55 @@
"dependencies": {
"@date-fns/upgrade": "1.0.3",
"classnames": "2.3.1",
"date-fns": "2.28.0",
"dayzed": "3.2.2",
"date-fns": "2.29.2",
"dayzed": "3.2.3",
"format-string-by-pattern": "1.2.2",
"react-fast-compare": "3.2.0"
},
"devDependencies": {
"@babel/core": "7.17.8",
"@storybook/addon-essentials": "6.4.22",
"@babel/core": "7.18.10",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@storybook/addon-controls": "6.5.10",
"@storybook/addon-essentials": "6.5.10",
"@storybook/addon-info": "5.3.21",
"@storybook/addon-knobs": "6.4.0",
"@storybook/addon-links": "6.4.22",
"@storybook/addon-storysource": "6.4.17",
"@storybook/addons": "6.4.19",
"@storybook/react": "6.4.19",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.4",
"@testing-library/user-event": "13.5.0",
"@storybook/addon-links": "6.5.10",
"@storybook/addon-storysource": "6.5.10",
"@storybook/addons": "6.5.10",
"@storybook/react": "6.5.10",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.3.0",
"@testing-library/user-event": "14.4.3",
"@tsconfig/create-react-app": "1.0.2",
"@tsconfig/recommended": "1.0.1",
"@types/react": "17.0.43",
"@types/react-dom": "17.0.14",
"autoprefixer": "10.4.5",
"babel-loader": "8.2.3",
"cssnano": "5.1.7",
"dts-cli": "1.4.0",
"eslint-config-react-app": "7.0.0",
"eslint-plugin-prettier": "4.0.0",
"husky": "7.0.4",
"jest-transform-css": "4.0.0",
"postcss": "8.4.12",
"@types/react": "18.0.17",
"@types/react-dom": "18.0.6",
"autoprefixer": "10.4.8",
"babel-loader": "8.2.5",
"cssnano": "5.1.13",
"dts-cli": "1.6.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-prettier": "4.2.1",
"husky": "8.0.1",
"jest-transform-css": "4.0.1",
"postcss": "8.4.16",
"pretty-quick": "3.1.3",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-is": "18.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-is": "18.2.0",
"rimraf": "3.0.2",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-postcss": "4.0.2",
"semantic-ui-css": "2.4.1",
"semantic-ui-react": "2.1.2",
"semantic-ui-react": "2.1.3",
"timekeeper": "2.2.0",
"tslib": "2.3.1",
"typescript": "4.6.4"
"ts-jest": "28.0.8",
"tslib": "2.4.0",
"typescript": "4.7.4"
},
"peerDependencies": {
"react": "^16.8 || ^17.0 || ^18.0",
"semantic-ui-react": ">=0.75.0"
},
"resolutions": {
"@babel/plugin-proposal-class-properties": "7.14.5",
"handlebars": "4.5.0"
},
"jest": {
"globals": {
"ts-jest": {
Expand Down
Loading