Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

266 строки
10 KiB

  1. import React, { Component } from 'react';
  2. import memoizeOne from 'memoize-one';
  3. import '@emotion/core';
  4. import 'react-dom';
  5. import 'prop-types';
  6. import '../../dist/utils-711604ed.esm.js';
  7. import { x as exportedEqual, w as defaultComponents } from '../../dist/index-52626178.esm.js';
  8. import '@emotion/css';
  9. import 'react-input-autosize';
  10. import { Transition, TransitionGroup } from 'react-transition-group';
  11. 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; }
  12. // strip transition props off before spreading onto select component
  13. // note we need to be explicit about innerRef for flow
  14. var AnimatedInput = function AnimatedInput(WrappedComponent) {
  15. return function (_ref) {
  16. var inProp = _ref.in,
  17. onExited = _ref.onExited,
  18. appear = _ref.appear,
  19. enter = _ref.enter,
  20. exit = _ref.exit,
  21. props = _objectWithoutPropertiesLoose(_ref, ["in", "onExited", "appear", "enter", "exit"]);
  22. return React.createElement(WrappedComponent, props);
  23. };
  24. };
  25. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  26. function _extends() { _extends = Object.assign || 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); }
  27. function _objectWithoutPropertiesLoose$1(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; }
  28. var Fade = function Fade(_ref) {
  29. var Tag = _ref.component,
  30. _ref$duration = _ref.duration,
  31. duration = _ref$duration === void 0 ? 1 : _ref$duration,
  32. inProp = _ref.in,
  33. onExited = _ref.onExited,
  34. props = _objectWithoutPropertiesLoose$1(_ref, ["component", "duration", "in", "onExited"]);
  35. var transition = {
  36. entering: {
  37. opacity: 0
  38. },
  39. entered: {
  40. opacity: 1,
  41. transition: "opacity " + duration + "ms"
  42. },
  43. exiting: {
  44. opacity: 0
  45. },
  46. exited: {
  47. opacity: 0
  48. }
  49. };
  50. return React.createElement(Transition, {
  51. mountOnEnter: true,
  52. unmountOnExit: true,
  53. in: inProp,
  54. timeout: duration
  55. }, function (state) {
  56. var innerProps = {
  57. style: _extends({}, transition[state])
  58. };
  59. return React.createElement(Tag, _extends({
  60. innerProps: innerProps
  61. }, props));
  62. });
  63. }; // ==============================
  64. // Collapse Transition
  65. // ==============================
  66. var collapseDuration = 260;
  67. // wrap each MultiValue with a collapse transition; decreases width until
  68. // finally removing from DOM
  69. var Collapse =
  70. /*#__PURE__*/
  71. function (_Component) {
  72. _inheritsLoose(Collapse, _Component);
  73. function Collapse() {
  74. var _this;
  75. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  76. args[_key] = arguments[_key];
  77. }
  78. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  79. _this.duration = collapseDuration;
  80. _this.rafID = void 0;
  81. _this.state = {
  82. width: 'auto'
  83. };
  84. _this.transition = {
  85. exiting: {
  86. width: 0,
  87. transition: "width " + _this.duration + "ms ease-out"
  88. },
  89. exited: {
  90. width: 0
  91. }
  92. };
  93. _this.getWidth = function (ref) {
  94. if (ref && isNaN(_this.state.width)) {
  95. /*
  96. Here we're invoking requestAnimationFrame with a callback invoking our
  97. call to getBoundingClientRect and setState in order to resolve an edge case
  98. around portalling. Certain portalling solutions briefly remove children from the DOM
  99. before appending them to the target node. This is to avoid us trying to call getBoundingClientrect
  100. while the Select component is in this state.
  101. */
  102. // cannot use `offsetWidth` because it is rounded
  103. _this.rafID = window.requestAnimationFrame(function () {
  104. var _ref$getBoundingClien = ref.getBoundingClientRect(),
  105. width = _ref$getBoundingClien.width;
  106. _this.setState({
  107. width: width
  108. });
  109. });
  110. }
  111. };
  112. _this.getStyle = function (width) {
  113. return {
  114. overflow: 'hidden',
  115. whiteSpace: 'nowrap',
  116. width: width
  117. };
  118. };
  119. _this.getTransition = function (state) {
  120. return _this.transition[state];
  121. };
  122. return _this;
  123. }
  124. var _proto = Collapse.prototype;
  125. _proto.componentWillUnmount = function componentWillUnmount() {
  126. if (this.rafID) {
  127. window.cancelAnimationFrame(this.rafID);
  128. }
  129. } // width must be calculated; cannot transition from `undefined` to `number`
  130. ;
  131. _proto.render = function render() {
  132. var _this2 = this;
  133. var _this$props = this.props,
  134. children = _this$props.children,
  135. inProp = _this$props.in;
  136. var width = this.state.width;
  137. return React.createElement(Transition, {
  138. enter: false,
  139. mountOnEnter: true,
  140. unmountOnExit: true,
  141. in: inProp,
  142. timeout: this.duration
  143. }, function (state) {
  144. var style = _extends({}, _this2.getStyle(width), _this2.getTransition(state));
  145. return React.createElement("div", {
  146. ref: _this2.getWidth,
  147. style: style
  148. }, children);
  149. });
  150. };
  151. return Collapse;
  152. }(Component);
  153. function _extends$1() { _extends$1 = Object.assign || 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$1.apply(this, arguments); }
  154. function _objectWithoutPropertiesLoose$2(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; }
  155. var AnimatedMultiValue = function AnimatedMultiValue(WrappedComponent) {
  156. return function (_ref) {
  157. var inProp = _ref.in,
  158. onExited = _ref.onExited,
  159. props = _objectWithoutPropertiesLoose$2(_ref, ["in", "onExited"]);
  160. return React.createElement(Collapse, {
  161. in: inProp,
  162. onExited: onExited
  163. }, React.createElement(WrappedComponent, _extends$1({
  164. cropWithEllipsis: inProp
  165. }, props)));
  166. };
  167. };
  168. function _extends$2() { _extends$2 = Object.assign || 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$2.apply(this, arguments); }
  169. var AnimatedPlaceholder = function AnimatedPlaceholder(WrappedComponent) {
  170. return function (props) {
  171. return React.createElement(Fade, _extends$2({
  172. component: WrappedComponent,
  173. duration: props.isMulti ? collapseDuration : 1
  174. }, props));
  175. };
  176. };
  177. function _extends$3() { _extends$3 = Object.assign || 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$3.apply(this, arguments); }
  178. var AnimatedSingleValue = function AnimatedSingleValue(WrappedComponent) {
  179. return function (props) {
  180. return React.createElement(Fade, _extends$3({
  181. component: WrappedComponent
  182. }, props));
  183. };
  184. };
  185. function _extends$4() { _extends$4 = Object.assign || 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$4.apply(this, arguments); }
  186. // make ValueContainer a transition group
  187. var AnimatedValueContainer = function AnimatedValueContainer(WrappedComponent) {
  188. return function (props) {
  189. return React.createElement(TransitionGroup, _extends$4({
  190. component: WrappedComponent
  191. }, props));
  192. };
  193. };
  194. function _extends$5() { _extends$5 = Object.assign || 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$5.apply(this, arguments); }
  195. function _objectWithoutPropertiesLoose$3(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; }
  196. var makeAnimated = function makeAnimated(externalComponents) {
  197. if (externalComponents === void 0) {
  198. externalComponents = {};
  199. }
  200. var components = defaultComponents({
  201. components: externalComponents
  202. });
  203. var Input = components.Input,
  204. MultiValue = components.MultiValue,
  205. Placeholder = components.Placeholder,
  206. SingleValue = components.SingleValue,
  207. ValueContainer = components.ValueContainer,
  208. rest = _objectWithoutPropertiesLoose$3(components, ["Input", "MultiValue", "Placeholder", "SingleValue", "ValueContainer"]);
  209. return _extends$5({
  210. Input: AnimatedInput(Input),
  211. MultiValue: AnimatedMultiValue(MultiValue),
  212. Placeholder: AnimatedPlaceholder(Placeholder),
  213. SingleValue: AnimatedSingleValue(SingleValue),
  214. ValueContainer: AnimatedValueContainer(ValueContainer)
  215. }, rest);
  216. };
  217. var AnimatedComponents = makeAnimated();
  218. var Input = AnimatedComponents.Input;
  219. var MultiValue = AnimatedComponents.MultiValue;
  220. var Placeholder = AnimatedComponents.Placeholder;
  221. var SingleValue = AnimatedComponents.SingleValue;
  222. var ValueContainer = AnimatedComponents.ValueContainer;
  223. var index = memoizeOne(makeAnimated, exportedEqual);
  224. export default index;
  225. export { Input, MultiValue, Placeholder, SingleValue, ValueContainer };