Skip to content

Commit c0afb67

Browse files
authored
feat: Migrate to TypeScript, build with tsdx and update Storybook (#45)
* refactor: Start rewrite of the library with tsdx * feat: migrate code to TypeScript Except for the locales, the code was updated to use TypeScript * build: use older version of rollup-plugin-copy for now * refactor: remove unused file and add default value for prop readOnly * fix(types): picking props from Dayzed and Form.Input that are accepted * chore(examples): install latest version of Storybook * docs(readme): remove TypeScript from the roadmap * chore: fix deploy of Storybook on Now * chore: add lint script to package.json * build: lock versions of packages in package.json * test(utils): bring back tests for utils * build: fix lint script, Jest config and add validate script * chore: remove @types packages for react and react-dom from devDependencies this may cause an error when compiling Storybook since they are also installed by Storybook's types * fix(datepicker): remove duplicate key on defaultProps * build(css): output single CSS file with the current name * ci(travis): run TravisCI on branch develop * ci(travis): only execute after_success script on branch master * docs: update typings on README and in the code * build: add prebuild script to remove dist folder * refactor: simplify export and fix a few types
1 parent cfc0010 commit c0afb67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5611
-9749
lines changed

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
extends: [
3+
'react-app',
4+
'prettier/@typescript-eslint',
5+
'plugin:prettier/recommended',
6+
],
7+
rules: {
8+
'@typescript-eslint/consistent-type-assertions': 0,
9+
},
10+
};

.gitignore

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
coverage/
2-
dist/
3-
node_modules/
4-
storybook-static/
1+
coverage
2+
dist
3+
node_modules
54
package-lock.json
65
*.log
7-
.eslintcache
6+
.DS_Store
7+
.cache
8+
.rts2_cache_cjs
9+
.rts2_cache_esm
10+
.rts2_cache_umd

.nowignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
README.md
2+
package-lock.json

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';

.storybook/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { configure } from '@storybook/react';
2+
3+
// automatically import all files ending in *.stories.tsx
4+
configure(require.context('../stories', true, /\.stories\.tsx$/), module);

.storybook/webpack.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = ({ config }) => {
2+
config.module.rules.push({
3+
test: /\.(ts|tsx)$/,
4+
use: [{ loader: require.resolve('awesome-typescript-loader') }],
5+
});
6+
7+
config.resolve.extensions.push('.ts', '.tsx');
8+
9+
return config;
10+
};

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ notifications:
77
node_js: '8'
88
install: npm install
99
script: npm run validate
10-
after_success: npx semantic-release
10+
after_success: test $TRAVIS_BRANCH = "master" && test $TRAVIS_PULL_REQUEST = "false" && npx semantic-release
1111
branches:
12-
only: master
12+
only:
13+
- develop
14+
- master

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,20 @@ More examples [here](https://react-semantic-ui-datepickers.now.sh).
6969

7070
### Own Props
7171

72-
| property | type | required | default | description |
73-
| -------------------- | ------------------- | -------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
74-
| clearable | boolean | no | true | Allows the user to clear the value |
75-
| format | string | no | 'YYYY-MM-DD' | Specifies how the date will be formatted using the [date-fns' format](https://date-fns.org/v1.29.0/docs/format) |
76-
| keepOpenOnClear | boolean | no | false | Keeps the datepicker open (or opens it if it's closed) when the clear icon is clicked |
77-
| keepOpenOnSelect | boolean | no | false | Keeps the datepicker open when a date is selected |
78-
| locale | object | no | [en-US](https://github.com/arthurdenner/react-semantic-ui-datepickers/blob/master/src/locales/en-US.js) | Object with the labels to be used on the library PS: Feel free to submit PR's with more locales! |
79-
| onDateChange | function | yes | | Callback fired when the value changes |
80-
| type | string | no | basic | Type of input to render. Available options: 'basic' and 'range' |
81-
| filterDate | function | no | () => true | Function that receives each date and returns a boolean to indicate whether it is enabled or not |
82-
| selected | Date, arrayOf(Date) | no | | Default date selected |
83-
| pointing | string | no | 'left' | Location to render the component around input. Available options: 'left', 'right', 'top left', 'top right' |
84-
| clearOnSameDateClick | boolean | no | true | Controls whether the datepicker's state resets if the same date is selected in succession. |
72+
| property | type | required | default | description |
73+
| -------------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
74+
| allowOnlyNumbers | boolean | no | true | Allows the user enter only numbers |
75+
| clearOnSameDateClick | boolean | no | true | Controls whether the datepicker's state resets if the same date is selected in succession. |
76+
| clearable | boolean | no | true | Allows the user to clear the value |
77+
| filterDate | function | no | () => true | Function that receives each date and returns a boolean to indicate whether it is enabled or not |
78+
| format | string | no | 'YYYY-MM-DD' | Specifies how the date will be formatted using the [date-fns' format](https://date-fns.org/v1.29.0/docs/format) |
79+
| keepOpenOnClear | boolean | no | false | Keeps the datepicker open (or opens it if it's closed) when the clear icon is clicked |
80+
| keepOpenOnSelect | boolean | no | false | Keeps the datepicker open when a date is selected |
81+
| locale | object | no | [en-US](https://github.com/arthurdenner/react-semantic-ui-datepickers/blob/master/src/locales/en-US.js) | Object with the labels to be used on the library PS: Feel free to submit PR's with more locales! |
82+
| onBlur | function | no | () => {} | Callback fired when the input loses focus |
83+
| onDateChange | function | yes | | Callback fired when the value changes |
84+
| pointing | string | no | 'left' | Location to render the component around input. Available options: 'left', 'right', 'top left', 'top right' |
85+
| type | string | no | basic | Type of input to render. Available options: 'basic' and 'range' |
8586

8687
### Form.Input Props
8788

@@ -118,15 +119,14 @@ In order to customize the elements, you can override the styles of the classes b
118119
- clndr-cell-selected
119120
- clndr-cell-other-month
120121

121-
> If you think this way of customizing is not a good idea, feel free to open a issue suggesting something else. This was the simplest solution I thought.
122+
> 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.
122123
123124
## Roadmap
124125

125126
- Improve accessibility
126127
> @donysukardi did some work on accessibility in the BaseDatePicker, but I couldn't get it working correcly. Feel free to help on this!
127128
- Add more tests (including e2e)
128129
> The current threshold is pretty useless 😕
129-
- Add TypeScript definitions (or migrate to TypeScript)
130130
131131
> Feel free to open issues and/or create PRs to improve other aspects of the library!
132132
File renamed without changes.

0 commit comments

Comments
 (0)