Skip to content

Commit

Permalink
feat: added 'as' prop to Carousel (fix: #3509) (#3514)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored and taion committed Mar 7, 2019
1 parent 9b8627f commit a25d03c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"invariant": "^2.2.3",
"keycode": "^2.1.2",
"popper.js": "^1.14.6",
"prop-types": "^15.6.2",
"prop-types": "^15.7.2",
"prop-types-extra": "^1.1.0",
"react-context-toolbox": "^2.0.2",
"react-overlays": "^1.0.0",
Expand Down
7 changes: 5 additions & 2 deletions src/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const propTypes = {
* @default 'carousel'
*/
bsPrefix: PropTypes.string,
as: PropTypes.elementType,

/**
* Enables animation on the Carousel as it transitions between slides.
Expand Down Expand Up @@ -101,6 +102,7 @@ const propTypes = {
};

const defaultProps = {
as: 'div',
slide: true,
fade: false,
interval: 5000,
Expand Down Expand Up @@ -421,6 +423,7 @@ class Carousel extends React.Component {

render() {
const {
as: Component,
bsPrefix,
slide,
fade,
Expand Down Expand Up @@ -451,7 +454,7 @@ class Carousel extends React.Component {

return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div
<Component
{...props}
className={classNames(
className,
Expand Down Expand Up @@ -491,7 +494,7 @@ class Carousel extends React.Component {
nextIcon,
nextLabel,
})}
</div>
</Component>
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions types/components/Carousel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import CarouselItem from './CarouselItem';
import CarouselCaption from './CarouselCaption';

import { ReplaceProps, SelectCallback } from './helpers';
import { ReplaceProps, SelectCallback, BsPrefixComponent } from './helpers';

export interface CarouselProps {
bsPrefix?: string;
Expand All @@ -24,9 +24,9 @@ export interface CarouselProps {
nextLabel?: string;
}

declare class Carousel extends React.Component<
ReplaceProps<'div', CarouselProps>
> {
declare class Carousel<
As extends React.ReactType = 'div'
> extends BsPrefixComponent<As, CarouselProps> {
static Item: typeof CarouselItem;
static Caption: typeof CarouselCaption;
}
Expand Down
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9514,6 +9514,15 @@ prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.5.9,
loose-envify "^1.3.1"
object-assign "^4.1.1"

prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
dependencies:
loose-envify "^1.4.0"
object-assign "^4.1.1"
react-is "^16.8.1"

proxy-addr@~2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.4.tgz#ecfc733bf22ff8c6f407fa275327b9ab67e48b93"
Expand Down Expand Up @@ -9830,6 +9839,11 @@ react-is@^16.6.1, react-is@^16.6.3:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.3.tgz#d2d7462fcfcbe6ec0da56ad69047e47e56e7eac0"
integrity sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA==

react-is@^16.8.1:
version "16.8.3"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.3.tgz#4ad8b029c2a718fc0cfc746c8d4e1b7221e5387d"
integrity sha512-Y4rC1ZJmsxxkkPuMLwvKvlL1Zfpbcu+Bf4ZigkHup3v9EfdYhAlWAaVyA19olXq2o2mGn0w+dFKvk3pVVlYcIA==

react-lifecycles-compat@^3.0.0, react-lifecycles-compat@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
Expand Down

0 comments on commit a25d03c

Please sign in to comment.