1 line
4.4 KiB
JSON
1 line
4.4 KiB
JSON
|
{"ast":null,"code":"import _objectSpread2 from \"@babel/runtime/helpers/esm/objectSpread\";\nimport _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/esm/assertThisInitialized\";\nimport _inheritsLoose from \"@babel/runtime/helpers/esm/inheritsLoose\";\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { Transition } from 'react-transition-group';\nimport { mapToCssModules, TransitionTimeouts, TransitionStatuses, tagPropType } from './utils';\n\nvar CarouselItem = /*#__PURE__*/function (_React$Component) {\n _inheritsLoose(CarouselItem, _React$Component);\n\n function CarouselItem(props) {\n var _this;\n\n _this = _React$Component.call(this, props) || this;\n _this.state = {\n startAnimation: false\n };\n _this.onEnter = _this.onEnter.bind(_assertThisInitialized(_this));\n _this.onEntering = _this.onEntering.bind(_assertThisInitialized(_this));\n _this.onExit = _this.onExit.bind(_assertThisInitialized(_this));\n _this.onExiting = _this.onExiting.bind(_assertThisInitialized(_this));\n _this.onExited = _this.onExited.bind(_assertThisInitialized(_this));\n return _this;\n }\n\n var _proto = CarouselItem.prototype;\n\n _proto.onEnter = function onEnter(node, isAppearing) {\n this.setState({\n startAnimation: false\n });\n this.props.onEnter(node, isAppearing);\n };\n\n _proto.onEntering = function onEntering(node, isAppearing) {\n // getting this variable triggers a reflow\n var offsetHeight = node.offsetHeight;\n this.setState({\n startAnimation: true\n });\n this.props.onEntering(node, isAppearing);\n return offsetHeight;\n };\n\n _proto.onExit = function onExit(node) {\n this.setState({\n startAnimation: false\n });\n this.props.onExit(node);\n };\n\n _proto.onExiting = function onExiting(node) {\n this.setState({\n startAnimation: true\n });\n node.dispatchEvent(new CustomEvent('slide.bs.carousel'));\n this.props.onExiting(node);\n };\n\n _proto.onExited = function onExited(node) {\n node.dispatchEvent(new CustomEvent('slid.bs.carousel'));\n this.props.onExited(node);\n };\n\n _proto.render = function render() {\n var _this2 = this;\n\n var _this$props = this.props,\n isIn = _this$props.in,\n children = _this$props.children,\n cssModule = _this$props.cssModule,\n slide = _this$props.slide,\n Tag = _this$props.tag,\n className = _this$props.className,\n transitionProps = _objectWithoutPropertiesLoose(_this$props, [\"in\", \"children\", \"cssModule\", \"slide\", \"tag\", \"className\"]);\n\n return React.createElement(Transition, _extends({}, transitionProps, {\n enter: slide,\n exit: slide,\n in: isIn,\n onEnter: this.onEnter,\n onEntering: this.onEntering,\n onExit: this.onExit,\n onExiting: this.onExiting,\n onExited: this.onExited\n }), function (status) {\n var direction = _this2.context.direction;\n var isActive = status === TransitionStatuses.ENTERED || status === TransitionStatuses.EXITING;\n var directionClassName = (status === TransitionStatuses.ENTERING || status === TransitionStatuses.EXITING) && _this2.state.startAnimation && (direction === 'right' ? 'carousel-item-left' : 'carousel-item-right');\n var orderClassName = status === TransitionStatuses.ENTERING && (direction === 'right' ? 'carousel-item-next' : 'carousel-item-prev');\n var itemClasses = mapToCssModules(classNames(className, 'carousel-item', isActive && 'active', directionClassName, orderClassName), cssModule);\n return React.createElement(Tag, {\n className: itemClasses\n }, children);\n });\n };\n\n return CarouselItem;\n}(React.Component);\n\nCarouselItem.propTypes = _objectSpread2({}, Transition.propTypes, {\n tag: tagPropType,\n in: PropTypes.bool,\
|