No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

277 líneas
11 KiB

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