Skip to content
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

[Pagination] Add TypeScript types #19933

Merged
merged 22 commits into from
Mar 11, 2020
Merged

[Pagination] Add TypeScript types #19933

merged 22 commits into from
Mar 11, 2020

Conversation

pvdstel
Copy link
Contributor

@pvdstel pvdstel commented Mar 2, 2020

We're currently experimenting with the Pagination component, and we think it's a really nice component. Since we use TypeScript mainly, we would really like this component to have a TypeScript interface as well.

This pull request would add:

  • types for the Pagination component;
  • types for the PaginationItem component;
  • types for the usePagination function.

I have attempted to create these type definitions such that they closely resemble those of existing components. For Pagination and PaginationItem, the prop types are based on the propTypes defined below the components. For usePagination, I have assumed these types based on the Pagination and PaginationItem props.

@oliviertassinari oliviertassinari added the component: pagination This is the name of the generic UI component, not the React module! label Mar 2, 2020
@mui-pr-bot
Copy link

mui-pr-bot commented Mar 2, 2020

Details of bundle changes.

Comparing: 91fa13b...4ef9bea

Details of page changes
bundle Size Change Size Gzip Change Gzip
/api-docs/pagination ▲ +20 B (+0.32% ) 6.18 kB -- -1 B
/_error -- 1.96 kB -- -1 B
/api-docs/alert-title -- 2.43 kB -- -1 B
/api-docs/alert -- 7.64 kB -- -1 B
/api-docs/app-bar -- 5.15 kB -- -1 B
/api-docs/autocomplete -- 17.8 kB -- -1 B
/api-docs/avatar-group -- 2.83 kB -- -1 B
/api-docs/avatar -- 4.73 kB -- -1 B
/api-docs/backdrop -- 3.28 kB -- -1 B
/api-docs/badge -- 7.09 kB -- -1 B
/api-docs/bottom-navigation-action -- 4.23 kB -- -1 B
/api-docs/bottom-navigation -- 3.5 kB -- -1 B
/api-docs/breadcrumbs -- 4.38 kB -- -1 B
/api-docs/button-base -- 5.91 kB -- -1 B
/api-docs/button-group -- 8.73 kB -- -1 B
/api-docs/button -- 10.1 kB -- -1 B
/api-docs/card-action-area -- 3.12 kB -- -1 B
/api-docs/card-actions -- 2.83 kB -- -1 B
/api-docs/card-content -- 2.71 kB -- -1 B
/api-docs/card-header -- 4.54 kB -- -1 B
/api-docs/card-media -- 3.5 kB -- -1 B
/api-docs/card -- 2.75 kB -- -1 B
/api-docs/checkbox -- 6.47 kB -- -1 B
/api-docs/chip -- 9.8 kB -- -1 B
/api-docs/circular-progress -- 5.69 kB -- -1 B
/api-docs/click-away-listener -- 2.46 kB -- -1 B
/api-docs/collapse -- 4.77 kB -- -1 B
/api-docs/container -- 4.7 kB -- -1 B
/api-docs/css-baseline -- 2.43 kB -- -1 B
/api-docs/dialog-actions -- 2.86 kB -- -1 B
/api-docs/dialog-content-text -- 2.77 kB -- -1 B
/api-docs/dialog-content -- 2.83 kB -- -1 B
/api-docs/dialog-title -- 2.78 kB -- -1 B
/api-docs/dialog -- 9.59 kB -- -1 B
/api-docs/divider -- 4.58 kB -- -1 B
/api-docs/drawer -- 6.44 kB -- -1 B
/api-docs/expansion-panel-actions -- 3 kB -- -1 B
/api-docs/expansion-panel-details -- 2.65 kB -- -1 B
/api-docs/expansion-panel-summary -- 4.01 kB -- -1 B
/api-docs/expansion-panel -- 4.62 kB -- -1 B
/api-docs/fab -- 5.77 kB -- -1 B
/api-docs/fade -- 2.41 kB -- -1 B
/api-docs/filled-input -- 9.89 kB -- -1 B
/api-docs/form-control-label -- 4.98 kB -- -1 B
/api-docs/form-control -- 6.05 kB -- -1 B
/api-docs/form-group -- 2.99 kB -- -1 B
/api-docs/form-helper-text -- 5.08 kB -- -1 B
/api-docs/form-label -- 4.83 kB -- -1 B
/api-docs/grid-list-tile-bar -- 5.06 kB -- -1 B
/api-docs/grid-list-tile -- 3.81 kB -- -1 B
/api-docs/grid-list -- 3.27 kB -- -1 B
/api-docs/grid -- 13.3 kB -- -1 B
/api-docs/grow -- 2.55 kB -- -1 B
/api-docs/hidden -- 4.41 kB -- -1 B
/api-docs/icon-button -- 5.57 kB -- -1 B
/api-docs/icon -- 4.66 kB -- -1 B
/api-docs/input-adornment -- 4.82 kB -- -1 B
/api-docs/input-base -- 10.5 kB -- -1 B
/api-docs/input-label -- 5.87 kB -- -1 B
/api-docs/input -- 9.37 kB -- -1 B
/api-docs/linear-progress -- 6.76 kB -- -1 B
/api-docs/link -- 4.71 kB -- -1 B
/api-docs/list-item-avatar -- 2.84 kB -- -1 B
/api-docs/list-item-icon -- 2.87 kB -- -1 B
/api-docs/list-item-secondary-action -- 2.74 kB -- -1 B
/api-docs/list-item-text -- 4.58 kB -- -1 B
/api-docs/list-item -- 6.79 kB -- -1 B
/api-docs/list-subheader -- 4.45 kB -- -1 B
/api-docs/list -- 3.77 kB -- -1 B
/api-docs/menu-item -- 3.67 kB -- -1 B
/api-docs/menu-list -- 2.86 kB -- -1 B
/api-docs/menu -- 5.96 kB -- -1 B
/api-docs/mobile-stepper -- 5.01 kB -- -1 B
/api-docs/modal -- 6.22 kB -- -1 B
/api-docs/native-select -- 5.43 kB -- -1 B
/api-docs/no-ssr -- 2.1 kB -- -1 B
/api-docs/outlined-input -- 10.2 kB -- -1 B
/api-docs/pagination-item -- 6.41 kB -- -1 B
/api-docs/paper -- 6.13 kB -- -1 B
/api-docs/popover -- 8.25 kB -- -1 B
/api-docs/popper -- 4.6 kB -- -1 B
/api-docs/portal -- 2.26 kB -- -1 B
/api-docs/radio-group -- 2.49 kB -- -1 B
/api-docs/radio -- 5.72 kB -- -1 B
/api-docs/rating -- 7.85 kB -- -1 B
/api-docs/root-ref -- 2.29 kB -- -1 B
/api-docs/scoped-css-baseline -- 2.56 kB -- -1 B
/api-docs/select -- 9.18 kB -- -1 B
/api-docs/skeleton -- 4.22 kB -- -1 B
/api-docs/slide -- 2.82 kB -- -1 B
/api-docs/slider -- 11.4 kB -- -1 B
/api-docs/snackbar-content -- 3.38 kB -- -1 B
/api-docs/snackbar -- 8.38 kB -- -1 B
/api-docs/speed-dial-action -- 5.25 kB -- -1 B
/api-docs/speed-dial-icon -- 3.56 kB -- -1 B
/api-docs/speed-dial -- 6.53 kB -- -1 B
/api-docs/step-button -- 3.46 kB -- -1 B
/api-docs/step-connector -- 3.9 kB -- -1 B
/api-docs/step-content -- 3.72 kB -- -1 B
/api-docs/step-icon -- 3.56 kB -- -1 B
/api-docs/step-label -- 5.26 kB -- -1 B
/api-docs/step -- 3.87 kB -- -1 B
/api-docs/stepper -- 4.22 kB -- -1 B
/api-docs/svg-icon -- 5.96 kB -- -1 B
/api-docs/swipeable-drawer -- 4.51 kB -- -1 B
/api-docs/switch -- 7.16 kB -- -1 B
/api-docs/tab -- 5.45 kB -- -1 B
/api-docs/table-body -- 2.71 kB -- -1 B
/api-docs/table-cell -- 6.03 kB -- -1 B
/api-docs/table-container -- 2.75 kB -- -1 B
/api-docs/table-footer -- 2.74 kB -- -1 B
/api-docs/table-head -- 2.71 kB -- -1 B
/api-docs/table-pagination -- 7.76 kB -- -1 B
/api-docs/table-row -- 3.77 kB -- -1 B
/api-docs/table-sort-label -- 4.23 kB -- -1 B
/api-docs/table -- 3.51 kB -- -1 B
/api-docs/tabs -- 7.38 kB -- -1 B
/api-docs/text-field -- 9.35 kB -- -1 B
/api-docs/textarea-autosize -- 1.85 kB -- -1 B
/api-docs/toggle-button-group -- 4.12 kB -- -1 B
/api-docs/toggle-button -- 4.41 kB -- -1 B
/api-docs/toolbar -- 3.53 kB -- -1 B
/api-docs/tooltip -- 8.66 kB -- -1 B
/api-docs/tree-item -- 4.62 kB -- -1 B
/api-docs/tree-view -- 5.12 kB -- -1 B
/api-docs/typography -- 10.1 kB -- -1 B
/api-docs/zoom -- 2.47 kB -- -1 B
/blog/2019-developer-survey-results -- 29.4 kB -- -1 B
/blog/2019 -- 23.4 kB -- -1 B
/blog/april-2019-update -- 20.7 kB -- -1 B
/blog/august-2019-update -- 18.6 kB -- -1 B
/blog/december-2019-update -- 19.6 kB -- -1 B
/blog/july-2019-update -- 18.4 kB -- -1 B
/blog/june-2019-update -- 18.3 kB -- -1 B
/blog/march-2019-update -- 19.3 kB -- -1 B
/blog/material-ui-v1-is-out -- 30.2 kB -- -1 B
/blog/material-ui-v4-is-out -- 38.9 kB -- -1 B
/blog/may-2019-update -- 18.8 kB -- -1 B
/blog/november-2019-update -- 20.2 kB -- -1 B
/blog/october-2019-update -- 19.6 kB -- -1 B
/blog/september-2019-update -- 19.9 kB -- -1 B
/company/about -- 18 kB -- -1 B
/company/contact -- 17.2 kB -- -1 B
/company/jobs -- 17.2 kB -- -1 B
/company/software-engineer -- 26.4 kB -- -1 B
/components/about-the-lab -- 22.7 kB -- -1 B
/components/alert -- 64 kB -- -1 B
/components/app-bar -- 159 kB -- -1 B
/components/autocomplete -- 642 kB -- -1 B
/components/avatars -- 50.3 kB -- -1 B
/components/backdrop -- 13.1 kB -- -1 B
/components/badges -- 69.2 kB -- -1 B
/components/bottom-navigation -- 26 kB -- -1 B
/components/box -- 39.9 kB -- -1 B
/components/breadcrumbs -- 90.7 kB -- -1 B
/components/button-group -- 38 kB -- -1 B
/components/buttons -- 102 kB -- -1 B
/components/cards -- 78.7 kB -- -1 B
/components/checkboxes -- 78.5 kB -- -1 B
/components/chips -- 102 kB -- -1 B
/components/click-away-listener -- 13.1 kB -- -1 B
/components/container -- 16.3 kB -- -1 B
/components/css-baseline -- 25.8 kB -- -1 B
/components/dialogs -- 229 kB -- -1 B
/components/dividers -- 57.1 kB -- -1 B
/components/drawers -- 217 kB -- -1 B
/components/expansion-panels -- 105 kB -- -1 B
/components/floating-action-button -- 74.2 kB -- -1 B
/components/grid-list -- 58.6 kB -- -1 B
/components/grid -- 154 kB -- -1 B
/components/hidden -- 58.5 kB -- -1 B
/components/icons -- 118 kB -- -1 B
/components/links -- 29.8 kB -- -1 B
/components/lists -- 153 kB -- -1 B
/components/material-icons -- 2.31 MB -- -1 B
/components/menus -- 104 kB -- -1 B
/components/modal -- 95.7 kB -- -1 B
/components/no-ssr -- 21.9 kB -- -1 B
/components/pagination -- 60.8 kB -- -1 B
/components/paper -- 13.2 kB -- -1 B
/components/pickers -- 188 kB -- -1 B
/components/popover -- 78 kB -- -1 B
/components/popper -- 164 kB -- -1 B
/components/portal -- 13.3 kB -- -1 B
/components/progress -- 105 kB -- -1 B
/components/radio-buttons -- 69.6 kB -- -1 B
/components/rating -- 50.5 kB -- -1 B
/components/selects -- 181 kB -- -1 B
/components/skeleton -- 47.7 kB -- -1 B
/components/slider -- 121 kB -- -1 B
/components/snackbars -- 113 kB -- -1 B
/components/speed-dial -- 64.4 kB -- -1 B
/components/steppers -- 214 kB -- -1 B
/components/switches -- 80.2 kB -- -1 B
/components/tables -- 708 kB -- -1 B
/components/tabs -- 155 kB -- -1 B
/components/text-fields -- 298 kB -- -1 B
/components/textarea-autosize -- 13.4 kB -- -1 B
/components/toggle-button -- 63.7 kB -- -1 B
/components/tooltips -- 88.8 kB -- -1 B
/components/transfer-list -- 47.4 kB -- -1 B
/components/transitions -- 64.3 kB -- -1 B
/components/tree-view -- 110 kB -- -1 B
/components/typography -- 48 kB -- -1 B
/components/use-media-query -- 86.4 kB -- -1 B
/customization/breakpoints -- 95.3 kB -- -1 B
/customization/color -- 111 kB -- -1 B
/customization/components -- 195 kB -- -1 B
/customization/default-theme -- 38.2 kB -- -1 B
/customization/density -- 54.1 kB -- -1 B
/customization/globals -- 22.9 kB -- -1 B
/customization/palette -- 78.9 kB -- -1 B
/customization/spacing -- 12.9 kB -- -1 B
/customization/theming -- 82 kB -- -1 B
/customization/typography -- 453 kB -- -1 B
/customization/z-index -- 11.4 kB -- -1 B
/discover-more/backers -- 7.38 kB -- -1 B
/discover-more/changelog -- 3.66 kB -- -1 B
/discover-more/languages -- 10.2 kB -- -1 B
/discover-more/related-projects -- 51.7 kB -- -1 B
/discover-more/roadmap -- 8.7 kB -- -1 B
/discover-more/showcase -- 83.7 kB -- -1 B
/discover-more/team -- 23 kB -- -1 B
/discover-more/vision -- 22.2 kB -- -1 B
/getting-started/example-projects -- 36.4 kB -- -1 B
/getting-started/faq -- 176 kB -- -1 B
/getting-started/installation -- 30.8 kB -- -1 B
/getting-started/learn -- 37.6 kB -- -1 B
/getting-started/support -- 77.1 kB -- -1 B
/getting-started/supported-components -- 76.6 kB -- -1 B
/getting-started/supported-platforms -- 25.9 kB -- -1 B
/getting-started/templates -- 33.1 kB -- -1 B
/getting-started/templates/album -- 9.35 kB -- -1 B
/getting-started/templates/blog -- 34.3 kB -- -1 B
/getting-started/templates/checkout -- 55.9 kB -- -1 B
/getting-started/templates/dashboard -- 400 kB -- -1 B
/getting-started/templates/pricing -- 11.4 kB -- -1 B
/getting-started/templates/sign-in-side -- 47.6 kB -- -1 B
/getting-started/templates/sign-in -- 47.2 kB -- -1 B
/getting-started/templates/sign-up -- 47.6 kB -- -1 B
/getting-started/templates/sticky-footer -- 1.79 kB -- -1 B
/getting-started/usage -- 34.6 kB -- -1 B
/guides/api -- 73.8 kB -- -1 B
/guides/composition -- 112 kB -- -1 B
/guides/flow -- 7.02 kB -- -1 B
/guides/interoperability -- 195 kB -- -1 B
/guides/localization -- 107 kB -- -1 B
/guides/migration-v0x -- 52.3 kB -- -1 B
/guides/migration-v3 -- 141 kB -- -1 B
/guides/minimizing-bundle-size -- 75.1 kB -- -1 B
/guides/responsive-ui -- 15.1 kB -- -1 B
/guides/right-to-left -- 59.2 kB -- -1 B
/guides/server-rendering -- 59.6 kB -- -1 B
/guides/testing -- 54 kB -- -1 B
/guides/typescript -- 100 kB -- -1 B
/performance/table-component -- 1.06 kB -- -1 B
/performance/table-emotion -- 26.1 kB -- -1 B
/performance/table-hook -- 1.14 kB -- -1 B
/performance/table-mui -- 6.09 kB -- -1 B
/performance/table-raw -- 854 B -- -1 B
/performance/table-styled-components -- 32.3 kB -- -1 B
/premium-themes/onepirate -- 60.4 kB -- -1 B
/premium-themes/onepirate/forgot-password -- 79.9 kB -- -1 B
/premium-themes/onepirate/privacy -- 73.4 kB -- -1 B
/premium-themes/onepirate/sign-in -- 80.3 kB -- -1 B
/premium-themes/onepirate/sign-up -- 80.4 kB -- -1 B
/premium-themes/onepirate/terms -- 96.2 kB -- -1 B
/premium-themes/paperbase -- 64.5 kB -- -1 B
/styles/advanced -- 254 kB -- -1 B
/styles/api -- 136 kB -- -1 B
/styles/basics -- 107 kB -- -1 B
/system/api -- 91.9 kB -- -1 B
/system/basics -- 167 kB -- -1 B
/system/borders -- 34.9 kB -- -1 B
/system/display -- 55.3 kB -- -1 B
/system/flexbox -- 64.8 kB -- -1 B
/system/palette -- 27.7 kB -- -1 B
/system/positions -- 15.7 kB -- -1 B
/system/shadows -- 15.7 kB -- -1 B
/system/sizing -- 24.1 kB -- -1 B
/system/spacing -- 47.5 kB -- -1 B
/system/typography -- 41 kB -- -1 B
/versions -- 102 kB -- -1 B
bundle Size Change Size Gzip Change Gzip
@material-ui/core -- 360 kB -- 98.8 kB
@material-ui/core[umd] -- 318 kB -- 92.1 kB
@material-ui/lab -- 199 kB -- 59 kB
@material-ui/styles -- 51.4 kB -- 15.4 kB
@material-ui/system -- 16.5 kB -- 4.31 kB
Alert -- 86.6 kB -- 27.3 kB
AlertTitle -- 67.5 kB -- 21.2 kB
AppBar -- 67.4 kB -- 21.1 kB
Autocomplete -- 134 kB -- 42.2 kB
Avatar -- 68.5 kB -- 21.7 kB
AvatarGroup -- 65.7 kB -- 20.6 kB
Backdrop -- 71.2 kB -- 22 kB
Badge -- 68.7 kB -- 21.3 kB
BottomNavigation -- 65.7 kB -- 20.6 kB
BottomNavigationAction -- 78.8 kB -- 24.9 kB
Box -- 72.3 kB -- 21.8 kB
Breadcrumbs -- 83.6 kB -- 26.5 kB
Button -- 83 kB -- 25.4 kB
ButtonBase -- 77.3 kB -- 24.2 kB
ButtonGroup -- 86.5 kB -- 26.6 kB
Card -- 66.2 kB -- 20.7 kB
CardActionArea -- 78.4 kB -- 24.8 kB
CardActions -- 65.4 kB -- 20.5 kB
CardContent -- 65.3 kB -- 20.4 kB
CardHeader -- 68.4 kB -- 21.5 kB
CardMedia -- 65.7 kB -- 20.6 kB
Checkbox -- 85.4 kB -- 27 kB
Chip -- 85.8 kB -- 26.3 kB
CircularProgress -- 67.4 kB -- 21.2 kB
ClickAwayListener -- 3.84 kB -- 1.54 kB
Collapse -- 71.3 kB -- 22.1 kB
colorManipulator -- 3.88 kB -- 1.52 kB
Container -- 66.5 kB -- 20.8 kB
CssBaseline -- 65.3 kB -- 20.5 kB
Dialog -- 86.2 kB -- 26.9 kB
DialogActions -- 65.4 kB -- 20.5 kB
DialogContent -- 65.6 kB -- 20.5 kB
DialogContentText -- 67.4 kB -- 21.1 kB
DialogTitle -- 67.6 kB -- 21.2 kB
Divider -- 66 kB -- 20.7 kB
docs:/_app -- 781 kB -- -1 B
Drawer -- 87.9 kB -- 26.8 kB
ExpansionPanel -- 74.9 kB -- 23.5 kB
ExpansionPanelActions -- 65.4 kB -- 20.5 kB
ExpansionPanelDetails -- 65.3 kB -- 20.4 kB
ExpansionPanelSummary -- 81.4 kB -- 25.7 kB
Fab -- 80.1 kB -- 24.9 kB
Fade -- 27.1 kB -- 9.05 kB
FilledInput -- 76.9 kB -- 23.9 kB
FormControl -- 67.7 kB -- 21.1 kB
FormControlLabel -- 68.8 kB -- 21.6 kB
FormGroup -- 65.4 kB -- 20.5 kB
FormHelperText -- 66.7 kB -- 20.7 kB
FormLabel -- 66.8 kB -- 20.7 kB
Grid -- 68.4 kB -- 21.4 kB
GridList -- 65.8 kB -- 20.6 kB
GridListTile -- 67.1 kB -- 21 kB
GridListTileBar -- 66.6 kB -- 20.8 kB
Grow -- 27.7 kB -- 9.26 kB
Hidden -- 69.3 kB -- 21.7 kB
Icon -- 66.1 kB -- 20.7 kB
IconButton -- 79.4 kB -- 24.8 kB
Input -- 75.9 kB -- 23.7 kB
InputAdornment -- 68.4 kB -- 21.6 kB
InputBase -- 74 kB -- 23.2 kB
InputLabel -- 68.6 kB -- 21.2 kB
LinearProgress -- 68.7 kB -- 21.2 kB
Link -- 69.9 kB -- 22.1 kB
List -- 65.7 kB -- 20.5 kB
ListItem -- 80.3 kB -- 25.1 kB
ListItemAvatar -- 65.4 kB -- 20.5 kB
ListItemIcon -- 65.5 kB -- 20.5 kB
ListItemSecondaryAction -- 65.4 kB -- 20.5 kB
ListItemText -- 68.3 kB -- 21.5 kB
ListSubheader -- 66.1 kB -- 20.8 kB
Menu -- 91.8 kB -- 28.3 kB
MenuItem -- 81.4 kB -- 25.4 kB
MenuList -- 69.3 kB -- 21.7 kB
MobileStepper -- 71.2 kB -- 22.3 kB
Modal -- 14.3 kB -- 5.04 kB
NativeSelect -- 80.1 kB -- 25.3 kB
NoSsr -- 2.17 kB -- 1.03 kB
OutlinedInput -- 77.9 kB -- 24.3 kB
Pagination -- 87.6 kB -- 27 kB
PaginationItem -- 84 kB -- 25.9 kB
Paper -- 65.7 kB -- 20.5 kB
Popover -- 86.2 kB -- 26.7 kB
Popper -- 28.8 kB -- 10.3 kB
Portal -- 2.87 kB -- 1.29 kB
Radio -- 86.4 kB -- 27.3 kB
RadioGroup -- 67.1 kB -- 20.9 kB
Rating -- 73.7 kB -- 23.7 kB
RootRef -- 4.21 kB -- 1.64 kB
ScopedCssBaseline -- 66.2 kB -- 20.7 kB
Select -- 119 kB -- 35.3 kB
Skeleton -- 66.3 kB -- 20.9 kB
Slide -- 29.1 kB -- 9.78 kB
Slider -- 79.1 kB -- 25.2 kB
Snackbar -- 78.6 kB -- 24.5 kB
SnackbarContent -- 66.9 kB -- 21 kB
SpeedDial -- 89.4 kB -- 28.3 kB
SpeedDialAction -- 121 kB -- 38.4 kB
SpeedDialIcon -- 67.9 kB -- 21.3 kB
Step -- 66 kB -- 20.7 kB
StepButton -- 85.5 kB -- 27 kB
StepConnector -- 66.1 kB -- 20.8 kB
StepContent -- 72.5 kB -- 22.6 kB
StepIcon -- 67.9 kB -- 21.2 kB
StepLabel -- 71.9 kB -- 22.3 kB
Stepper -- 68.2 kB -- 21.5 kB
styles/createMuiTheme -- 20.9 kB -- 7.27 kB
SvgIcon -- 66.4 kB -- 20.7 kB
SwipeableDrawer -- 95.3 kB -- 29.9 kB
Switch -- 84.6 kB -- 26.6 kB
Tab -- 79.6 kB -- 25.3 kB
Table -- 65.9 kB -- 20.6 kB
TableBody -- 65.4 kB -- 20.5 kB
TableCell -- 67.4 kB -- 21.2 kB
TableContainer -- 65.3 kB -- 20.4 kB
TableFooter -- 65.5 kB -- 20.5 kB
TableHead -- 65.4 kB -- 20.5 kB
TablePagination -- 145 kB -- 42.7 kB
TableRow -- 65.8 kB -- 20.6 kB
TableSortLabel -- 80.6 kB -- 25.5 kB
Tabs -- 88.6 kB -- 28.3 kB
TextareaAutosize -- 5.19 kB -- 2.17 kB
TextField -- 127 kB -- 37.4 kB
ToggleButton -- 79.4 kB -- 25.1 kB
ToggleButtonGroup -- 66.5 kB -- 20.9 kB
Toolbar -- 65.7 kB -- 20.6 kB
Tooltip -- 105 kB -- 33.1 kB
TreeItem -- 78.5 kB -- 24.8 kB
TreeView -- 71.5 kB -- 22.4 kB
Typography -- 67 kB -- 20.9 kB
useAutocomplete -- 15 kB -- 5.39 kB
useMediaQuery -- 2.56 kB -- 1.06 kB
Zoom -- 27.1 kB -- 9.18 kB

Generated by 🚫 dangerJS against 4ef9bea

@pvdstel
Copy link
Contributor Author

pvdstel commented Mar 2, 2020

test_static is failing on CircleCI. Should the string union types be sorted alphabetically, and should the documentation be added to the type definitions (in tsdoc form) as well?

@eps1lon
Copy link
Member

eps1lon commented Mar 2, 2020

@pvdstel You can click on the "Details" link in the checks tab to find out the issue.

@pvdstel
Copy link
Contributor Author

pvdstel commented Mar 2, 2020

Managed to get this working. I had to actually 'use' page and onChange in Pagination for the props to be generated. The script did not work for PaginationItem -- it simply gave a NoComponent status there.

@oliviertassinari oliviertassinari changed the title [Pagination] Add TypeScript types for Pagination, PaginationItem, usePagination [Pagination] Add TypeScript types Mar 2, 2020
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, next we will be able to migrate the demos to TypeScript :).

@mbrookes
Copy link
Member

mbrookes commented Mar 2, 2020

Not sure where this is coming from:

#!/bin/bash -eo pipefail
git diff --exit-code
diff --git a/packages/material-ui-lab/src/Pagination/Pagination.js b/packages/material-ui-lab/src/Pagination/Pagination.js
index e46344594..dc573d439 100644
--- a/packages/material-ui-lab/src/Pagination/Pagination.js
+++ b/packages/material-ui-lab/src/Pagination/Pagination.js
@@ -89,6 +89,10 @@ Pagination.propTypes = {
    */
   boundaryCount: PropTypes.number,
   /**
+   * The content of the component.
+   */
+  children: PropTypes.node,
+  /**
    * Override or extend the styles applied to the component.
    * See [CSS API](#css) below for more details.
    */

Exited with code exit status 1
CircleCI received exit code 1

@pvdstel
Copy link
Contributor Author

pvdstel commented Mar 2, 2020

Pagination currently has a children prop because of React.HTMLAttributes. The proptypes script picks up on that and adds the prop, which then becomes a CI failure. We could not use the default HTML attributes, but I'm not sure if that's desirable.

@mbrookes
Copy link
Member

mbrookes commented Mar 2, 2020

Ah, thanks! (As you'll have probably gathered from the absence of type definitions for this component, TypeScript is not my thing, although I should probably do something about that sooner or later. Not a first – I ignored CSS for a long time after it was first added to browsers! 😆)

Odd that you had to 'use' page and onChange for them to be added, but children is added regardless.

@eps1lon Thoughts?

@pvdstel
Copy link
Contributor Author

pvdstel commented Mar 2, 2020

6f4b0c9 (most recent commit) should remove the children prop from the component. I'm not sure if this is the best way to go about it though. Feel free to revert it if it's a bad idea.

@mbrookes generateProptypes.ts has a hardcoded check for children -- if it appears in the TypeScript prop type, it will unconditionally emit it (or so it seems).

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to Pagination.js seem unrelated. If you changed the runtime behavior please open a new PR with tests.

*
* For localization purposes, you can use the provided [translations](/guides/localization/).
*
* @param {string} [type = page] The link or button type to format ('page' | 'first' | 'last' | 'next' | 'previous').
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the types in the jsdoc? They duplicate the TS types and conflict in this case. It's also not clear when type can be undefined while also having a default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought that syntax somehow implied an optional argument. Will fix it in a sec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remove the types from the jsdoc here. These docs are copied to the JS component by yarn proptypes --disable-cache, and then the yarn docs:api command will fail because there is no type annotation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into adding support for this upstream, the parsing of basic types is complete but I stopped after a limited search for a JSDoc -> AST -> JSDoc lib failed.

packages/material-ui-lab/src/Pagination/Pagination.d.ts Outdated Show resolved Hide resolved
@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Mar 3, 2020
@mbrookes
Copy link
Member

mbrookes commented Mar 5, 2020

Now that the children prop has been removed, it seems that removing it from the type definition would be appropriate again

It is removed?

The proptypes script also removes the @defaults though

Yeah, but oddly only in CI... it doesn't create any changes when running it locally. 🤷‍♂

(as well as a merge conflict marker).

Yep, I missed a merge conflict when merging master. Already fixed.

@merceyz
Copy link
Member

merceyz commented Mar 5, 2020

That sounds off. Why would it do static analysis of the implementation? Shouldn't it only consider the typescript types and generate propTypes from that?
#19933 (comment)

I fully agree that it should not be doing static analysis there, but I've tried several times by now, and it's exactly what's happening on my end.
#19933 (comment)

@eps1lon @pvdstel The reason it does static analysis of the implementation is explained here #16521 (comment)

@pvdstel
Copy link
Contributor Author

pvdstel commented Mar 5, 2020

@mbrookes

It is removed?

The children prop was removed from the type definitions in 6f4b0c9, but that commit was reversed by 44a5e15. So now it's still here (in the typings, which proptypes then processes to a React proptype). What is the best course of action? Re-apply the commit, or do we revert the reversion? 🤔

Yeah, but oddly only in CI... it doesn't create any changes when running it locally. 🤷‍♂

I do get the same behavior, but the CI runs it as yarn proptypes --disable-cache. When I run it with that flag, it removes the @default doc tags on my end (and adds children for now).

Pagination now extends UsePagination;
inherited props have been removed.
| <span class="prop-name">hideNextButton</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, hide the next-page button. |
| <span class="prop-name">hidePrevButton</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, hide the previous-page button. |
| <span class="prop-name">onChange</span> | <span class="prop-type">func</span> | | Callback fired when the page is changed.<br><br>**Signature:**<br>`function(event: object, page: number) => void`<br>*event:* The event source of the callback.<br>*page:* The page selected. |
| <span class="prop-name">page</span> | <span class="prop-type">number</span> | | The current page. |
| <span class="prop-name">renderItem</span> | <span class="prop-type">func</span> | <span class="prop-default">item => &lt;PaginationItem {...item} /></span> | Render the item.<br><br>**Signature:**<br>`function(params: object) => ReactNode`<br>*params:* The props to spread on a PaginationItem. |
| <span class="prop-name">renderItem</span> | <span class="prop-type">func</span> | <span class="prop-default">item => &lt;PaginationItem {...item} /></span> | The pagination item component to render.<br><br>**Signature:**<br>`function(params: object) => ReactNode`<br>*params:* The props to spread on the component. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a component e.g. you couldn't use hooks inside it. Please make sure the documentation does not change in this PR (unless it's just typos).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation changes were requested here and here. I'll undo them for now, so that this change can be made in a separate PR.

@mbrookes
Copy link
Member

mbrookes commented Mar 6, 2020

So now it's still here (in the typings

Sorry, you're right. ("Too many cooks..." Edit: Specifically referring to myself here!)

@pvdstel
Copy link
Contributor Author

pvdstel commented Mar 11, 2020

Hi, any updates here? Should anything be done before it can be merged?

@eps1lon eps1lon merged commit 51b2b92 into mui:master Mar 11, 2020
@eps1lon
Copy link
Member

eps1lon commented Mar 11, 2020

@pvdstel Much appreciated, thanks. Fell under the radar since we're a bit stretched at the moment.

@pvdstel pvdstel deleted the pagination-types branch March 15, 2020 17:22
EsoterikStare pushed a commit to EsoterikStare/material-ui that referenced this pull request Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pagination This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants