UNPKG

3.25 kBJavaScriptView Raw
1var _excluded = ["direction", "onClickHandler", "cssModule", "directionText", "className"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5import React from 'react';
6import PropTypes from 'prop-types';
7import classNames from 'classnames';
8import { mapToCssModules } from './utils';
9function CarouselControl(props) {
10 var direction = props.direction,
11 onClickHandler = props.onClickHandler,
12 cssModule = props.cssModule,
13 directionText = props.directionText,
14 className = props.className,
15 attributes = _objectWithoutProperties(props, _excluded);
16 var anchorClasses = mapToCssModules(classNames(className, "carousel-control-".concat(direction)), cssModule);
17 var iconClasses = mapToCssModules(classNames("carousel-control-".concat(direction, "-icon")), cssModule);
18 var screenReaderClasses = mapToCssModules(classNames('visually-hidden'), cssModule);
19 return (
20 /*#__PURE__*/
21 // We need to disable this linting rule to use an `<a>` instead of
22 // `<button>` because that's what the Bootstrap examples require:
23 // https://getbootstrap.com/docs/4.5/components/carousel/#with-controls
24 // eslint-disable-next-line jsx-a11y/anchor-is-valid
25 React.createElement("a", _extends({}, attributes, {
26 className: anchorClasses,
27 style: {
28 cursor: 'pointer'
29 },
30 role: "button",
31 tabIndex: "0",
32 onClick: function onClick(e) {
33 e.preventDefault();
34 onClickHandler();
35 }
36 }), /*#__PURE__*/React.createElement("span", {
37 className: iconClasses,
38 "aria-hidden": "true"
39 }), /*#__PURE__*/React.createElement("span", {
40 className: screenReaderClasses
41 }, directionText || direction))
42 );
43}
44CarouselControl.propTypes = {
45 /** Set the direction of control button */
46 direction: PropTypes.oneOf(['prev', 'next']).isRequired,
47 /** Function to be triggered on click */
48 onClickHandler: PropTypes.func.isRequired,
49 /** Change underlying component's CSS base class name */
50 cssModule: PropTypes.object,
51 /** Screen reader text */
52 directionText: PropTypes.string,
53 /** Add custom class */
54 className: PropTypes.string
55};
56export default CarouselControl;
\No newline at end of file