1 | var _excluded = ["items", "activeIndex", "cssModule", "onClickHandler", "className"];
|
2 | function _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); }
|
3 | function _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; }
|
4 | function _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; }
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import classNames from 'classnames';
|
8 | import { mapToCssModules } from './utils';
|
9 | function CarouselIndicators(props) {
|
10 | var items = props.items,
|
11 | activeIndex = props.activeIndex,
|
12 | cssModule = props.cssModule,
|
13 | onClickHandler = props.onClickHandler,
|
14 | className = props.className,
|
15 | attributes = _objectWithoutProperties(props, _excluded);
|
16 | var listClasses = mapToCssModules(classNames(className, 'carousel-indicators'), cssModule);
|
17 | var indicators = items.map(function (item, idx) {
|
18 | var indicatorClasses = mapToCssModules(classNames({
|
19 | active: activeIndex === idx
|
20 | }), cssModule);
|
21 | return React.createElement("button", {
|
22 | "aria-label": item.caption,
|
23 | "data-bs-target": true,
|
24 | type: "button",
|
25 | key: "".concat(item.key || Object.values(item).join('')),
|
26 | onClick: function onClick(e) {
|
27 | e.preventDefault();
|
28 | onClickHandler(idx);
|
29 | },
|
30 | className: indicatorClasses
|
31 | });
|
32 | });
|
33 | return React.createElement("div", _extends({
|
34 | className: listClasses
|
35 | }, attributes), indicators);
|
36 | }
|
37 | CarouselIndicators.propTypes = {
|
38 |
|
39 | activeIndex: PropTypes.number.isRequired,
|
40 |
|
41 | className: PropTypes.string,
|
42 |
|
43 | cssModule: PropTypes.object,
|
44 |
|
45 | items: PropTypes.array.isRequired,
|
46 |
|
47 | onClickHandler: PropTypes.func.isRequired
|
48 | };
|
49 | export default CarouselIndicators; |
\ | No newline at end of file |