@bigbinary/neeto-molecules 4.1.48 → 4.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1099 @@
1
+ 'use strict';
2
+
3
+ var _extends = require('@babel/runtime/helpers/esm/extends');
4
+ var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/esm/objectWithoutPropertiesLoose');
5
+ var _inheritsLoose = require('@babel/runtime/helpers/esm/inheritsLoose');
6
+ var index = require('./index-JY2zVpnv.js');
7
+ var React = require('react');
8
+ var ReactDOM = require('react-dom');
9
+
10
+ /**
11
+ * Checks if a given element has a CSS class.
12
+ *
13
+ * @param element the element
14
+ * @param className the CSS class name
15
+ */
16
+ function hasClass(element, className) {
17
+ if (element.classList) return !!className && element.classList.contains(className);
18
+ return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
19
+ }
20
+
21
+ /**
22
+ * Adds a CSS class to a given element.
23
+ *
24
+ * @param element the element
25
+ * @param className the CSS class name
26
+ */
27
+
28
+ function addClass(element, className) {
29
+ if (element.classList) element.classList.add(className);else if (!hasClass(element, className)) if (typeof element.className === 'string') element.className = element.className + " " + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + " " + className);
30
+ }
31
+
32
+ function replaceClassName(origClass, classToRemove) {
33
+ return origClass.replace(new RegExp("(^|\\s)" + classToRemove + "(?:\\s|$)", 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
34
+ }
35
+ /**
36
+ * Removes a CSS class from a given element.
37
+ *
38
+ * @param element the element
39
+ * @param className the CSS class name
40
+ */
41
+
42
+
43
+ function removeClass$1(element, className) {
44
+ if (element.classList) {
45
+ element.classList.remove(className);
46
+ } else if (typeof element.className === 'string') {
47
+ element.className = replaceClassName(element.className, className);
48
+ } else {
49
+ element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
50
+ }
51
+ }
52
+
53
+ var config = {
54
+ disabled: false
55
+ };
56
+
57
+ var timeoutsShape = process.env.NODE_ENV !== 'production' ? index.PropTypes.oneOfType([index.PropTypes.number, index.PropTypes.shape({
58
+ enter: index.PropTypes.number,
59
+ exit: index.PropTypes.number,
60
+ appear: index.PropTypes.number
61
+ }).isRequired]) : null;
62
+ var classNamesShape = process.env.NODE_ENV !== 'production' ? index.PropTypes.oneOfType([index.PropTypes.string, index.PropTypes.shape({
63
+ enter: index.PropTypes.string,
64
+ exit: index.PropTypes.string,
65
+ active: index.PropTypes.string
66
+ }), index.PropTypes.shape({
67
+ enter: index.PropTypes.string,
68
+ enterDone: index.PropTypes.string,
69
+ enterActive: index.PropTypes.string,
70
+ exit: index.PropTypes.string,
71
+ exitDone: index.PropTypes.string,
72
+ exitActive: index.PropTypes.string
73
+ })]) : null;
74
+
75
+ var TransitionGroupContext = React.createContext(null);
76
+
77
+ var forceReflow = function forceReflow(node) {
78
+ return node.scrollTop;
79
+ };
80
+
81
+ var UNMOUNTED = 'unmounted';
82
+ var EXITED = 'exited';
83
+ var ENTERING = 'entering';
84
+ var ENTERED = 'entered';
85
+ var EXITING = 'exiting';
86
+ /**
87
+ * The Transition component lets you describe a transition from one component
88
+ * state to another _over time_ with a simple declarative API. Most commonly
89
+ * it's used to animate the mounting and unmounting of a component, but can also
90
+ * be used to describe in-place transition states as well.
91
+ *
92
+ * ---
93
+ *
94
+ * **Note**: `Transition` is a platform-agnostic base component. If you're using
95
+ * transitions in CSS, you'll probably want to use
96
+ * [`CSSTransition`](https://reactcommunity.org/react-transition-group/css-transition)
97
+ * instead. It inherits all the features of `Transition`, but contains
98
+ * additional features necessary to play nice with CSS transitions (hence the
99
+ * name of the component).
100
+ *
101
+ * ---
102
+ *
103
+ * By default the `Transition` component does not alter the behavior of the
104
+ * component it renders, it only tracks "enter" and "exit" states for the
105
+ * components. It's up to you to give meaning and effect to those states. For
106
+ * example we can add styles to a component when it enters or exits:
107
+ *
108
+ * ```jsx
109
+ * import { Transition } from 'react-transition-group';
110
+ *
111
+ * const duration = 300;
112
+ *
113
+ * const defaultStyle = {
114
+ * transition: `opacity ${duration}ms ease-in-out`,
115
+ * opacity: 0,
116
+ * }
117
+ *
118
+ * const transitionStyles = {
119
+ * entering: { opacity: 1 },
120
+ * entered: { opacity: 1 },
121
+ * exiting: { opacity: 0 },
122
+ * exited: { opacity: 0 },
123
+ * };
124
+ *
125
+ * const Fade = ({ in: inProp }) => (
126
+ * <Transition in={inProp} timeout={duration}>
127
+ * {state => (
128
+ * <div style={{
129
+ * ...defaultStyle,
130
+ * ...transitionStyles[state]
131
+ * }}>
132
+ * I'm a fade Transition!
133
+ * </div>
134
+ * )}
135
+ * </Transition>
136
+ * );
137
+ * ```
138
+ *
139
+ * There are 4 main states a Transition can be in:
140
+ * - `'entering'`
141
+ * - `'entered'`
142
+ * - `'exiting'`
143
+ * - `'exited'`
144
+ *
145
+ * Transition state is toggled via the `in` prop. When `true` the component
146
+ * begins the "Enter" stage. During this stage, the component will shift from
147
+ * its current transition state, to `'entering'` for the duration of the
148
+ * transition and then to the `'entered'` stage once it's complete. Let's take
149
+ * the following example (we'll use the
150
+ * [useState](https://reactjs.org/docs/hooks-reference.html#usestate) hook):
151
+ *
152
+ * ```jsx
153
+ * function App() {
154
+ * const [inProp, setInProp] = useState(false);
155
+ * return (
156
+ * <div>
157
+ * <Transition in={inProp} timeout={500}>
158
+ * {state => (
159
+ * // ...
160
+ * )}
161
+ * </Transition>
162
+ * <button onClick={() => setInProp(true)}>
163
+ * Click to Enter
164
+ * </button>
165
+ * </div>
166
+ * );
167
+ * }
168
+ * ```
169
+ *
170
+ * When the button is clicked the component will shift to the `'entering'` state
171
+ * and stay there for 500ms (the value of `timeout`) before it finally switches
172
+ * to `'entered'`.
173
+ *
174
+ * When `in` is `false` the same thing happens except the state moves from
175
+ * `'exiting'` to `'exited'`.
176
+ */
177
+
178
+ var Transition = /*#__PURE__*/function (_React$Component) {
179
+ _inheritsLoose(Transition, _React$Component);
180
+
181
+ function Transition(props, context) {
182
+ var _this;
183
+
184
+ _this = _React$Component.call(this, props, context) || this;
185
+ var parentGroup = context; // In the context of a TransitionGroup all enters are really appears
186
+
187
+ var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
188
+ var initialStatus;
189
+ _this.appearStatus = null;
190
+
191
+ if (props.in) {
192
+ if (appear) {
193
+ initialStatus = EXITED;
194
+ _this.appearStatus = ENTERING;
195
+ } else {
196
+ initialStatus = ENTERED;
197
+ }
198
+ } else {
199
+ if (props.unmountOnExit || props.mountOnEnter) {
200
+ initialStatus = UNMOUNTED;
201
+ } else {
202
+ initialStatus = EXITED;
203
+ }
204
+ }
205
+
206
+ _this.state = {
207
+ status: initialStatus
208
+ };
209
+ _this.nextCallback = null;
210
+ return _this;
211
+ }
212
+
213
+ Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
214
+ var nextIn = _ref.in;
215
+
216
+ if (nextIn && prevState.status === UNMOUNTED) {
217
+ return {
218
+ status: EXITED
219
+ };
220
+ }
221
+
222
+ return null;
223
+ } // getSnapshotBeforeUpdate(prevProps) {
224
+ // let nextStatus = null
225
+ // if (prevProps !== this.props) {
226
+ // const { status } = this.state
227
+ // if (this.props.in) {
228
+ // if (status !== ENTERING && status !== ENTERED) {
229
+ // nextStatus = ENTERING
230
+ // }
231
+ // } else {
232
+ // if (status === ENTERING || status === ENTERED) {
233
+ // nextStatus = EXITING
234
+ // }
235
+ // }
236
+ // }
237
+ // return { nextStatus }
238
+ // }
239
+ ;
240
+
241
+ var _proto = Transition.prototype;
242
+
243
+ _proto.componentDidMount = function componentDidMount() {
244
+ this.updateStatus(true, this.appearStatus);
245
+ };
246
+
247
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
248
+ var nextStatus = null;
249
+
250
+ if (prevProps !== this.props) {
251
+ var status = this.state.status;
252
+
253
+ if (this.props.in) {
254
+ if (status !== ENTERING && status !== ENTERED) {
255
+ nextStatus = ENTERING;
256
+ }
257
+ } else {
258
+ if (status === ENTERING || status === ENTERED) {
259
+ nextStatus = EXITING;
260
+ }
261
+ }
262
+ }
263
+
264
+ this.updateStatus(false, nextStatus);
265
+ };
266
+
267
+ _proto.componentWillUnmount = function componentWillUnmount() {
268
+ this.cancelNextCallback();
269
+ };
270
+
271
+ _proto.getTimeouts = function getTimeouts() {
272
+ var timeout = this.props.timeout;
273
+ var exit, enter, appear;
274
+ exit = enter = appear = timeout;
275
+
276
+ if (timeout != null && typeof timeout !== 'number') {
277
+ exit = timeout.exit;
278
+ enter = timeout.enter; // TODO: remove fallback for next major
279
+
280
+ appear = timeout.appear !== undefined ? timeout.appear : enter;
281
+ }
282
+
283
+ return {
284
+ exit: exit,
285
+ enter: enter,
286
+ appear: appear
287
+ };
288
+ };
289
+
290
+ _proto.updateStatus = function updateStatus(mounting, nextStatus) {
291
+ if (mounting === void 0) {
292
+ mounting = false;
293
+ }
294
+
295
+ if (nextStatus !== null) {
296
+ // nextStatus will always be ENTERING or EXITING.
297
+ this.cancelNextCallback();
298
+
299
+ if (nextStatus === ENTERING) {
300
+ if (this.props.unmountOnExit || this.props.mountOnEnter) {
301
+ var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM.findDOMNode(this); // https://github.com/reactjs/react-transition-group/pull/749
302
+ // With unmountOnExit or mountOnEnter, the enter animation should happen at the transition between `exited` and `entering`.
303
+ // To make the animation happen, we have to separate each rendering and avoid being processed as batched.
304
+
305
+ if (node) forceReflow(node);
306
+ }
307
+
308
+ this.performEnter(mounting);
309
+ } else {
310
+ this.performExit();
311
+ }
312
+ } else if (this.props.unmountOnExit && this.state.status === EXITED) {
313
+ this.setState({
314
+ status: UNMOUNTED
315
+ });
316
+ }
317
+ };
318
+
319
+ _proto.performEnter = function performEnter(mounting) {
320
+ var _this2 = this;
321
+
322
+ var enter = this.props.enter;
323
+ var appearing = this.context ? this.context.isMounting : mounting;
324
+
325
+ var _ref2 = this.props.nodeRef ? [appearing] : [ReactDOM.findDOMNode(this), appearing],
326
+ maybeNode = _ref2[0],
327
+ maybeAppearing = _ref2[1];
328
+
329
+ var timeouts = this.getTimeouts();
330
+ var enterTimeout = appearing ? timeouts.appear : timeouts.enter; // no enter animation skip right to ENTERED
331
+ // if we are mounting and running this it means appear _must_ be set
332
+
333
+ if (!mounting && !enter || config.disabled) {
334
+ this.safeSetState({
335
+ status: ENTERED
336
+ }, function () {
337
+ _this2.props.onEntered(maybeNode);
338
+ });
339
+ return;
340
+ }
341
+
342
+ this.props.onEnter(maybeNode, maybeAppearing);
343
+ this.safeSetState({
344
+ status: ENTERING
345
+ }, function () {
346
+ _this2.props.onEntering(maybeNode, maybeAppearing);
347
+
348
+ _this2.onTransitionEnd(enterTimeout, function () {
349
+ _this2.safeSetState({
350
+ status: ENTERED
351
+ }, function () {
352
+ _this2.props.onEntered(maybeNode, maybeAppearing);
353
+ });
354
+ });
355
+ });
356
+ };
357
+
358
+ _proto.performExit = function performExit() {
359
+ var _this3 = this;
360
+
361
+ var exit = this.props.exit;
362
+ var timeouts = this.getTimeouts();
363
+ var maybeNode = this.props.nodeRef ? undefined : ReactDOM.findDOMNode(this); // no exit animation skip right to EXITED
364
+
365
+ if (!exit || config.disabled) {
366
+ this.safeSetState({
367
+ status: EXITED
368
+ }, function () {
369
+ _this3.props.onExited(maybeNode);
370
+ });
371
+ return;
372
+ }
373
+
374
+ this.props.onExit(maybeNode);
375
+ this.safeSetState({
376
+ status: EXITING
377
+ }, function () {
378
+ _this3.props.onExiting(maybeNode);
379
+
380
+ _this3.onTransitionEnd(timeouts.exit, function () {
381
+ _this3.safeSetState({
382
+ status: EXITED
383
+ }, function () {
384
+ _this3.props.onExited(maybeNode);
385
+ });
386
+ });
387
+ });
388
+ };
389
+
390
+ _proto.cancelNextCallback = function cancelNextCallback() {
391
+ if (this.nextCallback !== null) {
392
+ this.nextCallback.cancel();
393
+ this.nextCallback = null;
394
+ }
395
+ };
396
+
397
+ _proto.safeSetState = function safeSetState(nextState, callback) {
398
+ // This shouldn't be necessary, but there are weird race conditions with
399
+ // setState callbacks and unmounting in testing, so always make sure that
400
+ // we can cancel any pending setState callbacks after we unmount.
401
+ callback = this.setNextCallback(callback);
402
+ this.setState(nextState, callback);
403
+ };
404
+
405
+ _proto.setNextCallback = function setNextCallback(callback) {
406
+ var _this4 = this;
407
+
408
+ var active = true;
409
+
410
+ this.nextCallback = function (event) {
411
+ if (active) {
412
+ active = false;
413
+ _this4.nextCallback = null;
414
+ callback(event);
415
+ }
416
+ };
417
+
418
+ this.nextCallback.cancel = function () {
419
+ active = false;
420
+ };
421
+
422
+ return this.nextCallback;
423
+ };
424
+
425
+ _proto.onTransitionEnd = function onTransitionEnd(timeout, handler) {
426
+ this.setNextCallback(handler);
427
+ var node = this.props.nodeRef ? this.props.nodeRef.current : ReactDOM.findDOMNode(this);
428
+ var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
429
+
430
+ if (!node || doesNotHaveTimeoutOrListener) {
431
+ setTimeout(this.nextCallback, 0);
432
+ return;
433
+ }
434
+
435
+ if (this.props.addEndListener) {
436
+ var _ref3 = this.props.nodeRef ? [this.nextCallback] : [node, this.nextCallback],
437
+ maybeNode = _ref3[0],
438
+ maybeNextCallback = _ref3[1];
439
+
440
+ this.props.addEndListener(maybeNode, maybeNextCallback);
441
+ }
442
+
443
+ if (timeout != null) {
444
+ setTimeout(this.nextCallback, timeout);
445
+ }
446
+ };
447
+
448
+ _proto.render = function render() {
449
+ var status = this.state.status;
450
+
451
+ if (status === UNMOUNTED) {
452
+ return null;
453
+ }
454
+
455
+ var _this$props = this.props,
456
+ children = _this$props.children;
457
+ _this$props.in;
458
+ _this$props.mountOnEnter;
459
+ _this$props.unmountOnExit;
460
+ _this$props.appear;
461
+ _this$props.enter;
462
+ _this$props.exit;
463
+ _this$props.timeout;
464
+ _this$props.addEndListener;
465
+ _this$props.onEnter;
466
+ _this$props.onEntering;
467
+ _this$props.onEntered;
468
+ _this$props.onExit;
469
+ _this$props.onExiting;
470
+ _this$props.onExited;
471
+ _this$props.nodeRef;
472
+ var childProps = _objectWithoutPropertiesLoose(_this$props, ["children", "in", "mountOnEnter", "unmountOnExit", "appear", "enter", "exit", "timeout", "addEndListener", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "nodeRef"]);
473
+
474
+ return (
475
+ /*#__PURE__*/
476
+ // allows for nested Transitions
477
+ React.createElement(TransitionGroupContext.Provider, {
478
+ value: null
479
+ }, typeof children === 'function' ? children(status, childProps) : React.cloneElement(React.Children.only(children), childProps))
480
+ );
481
+ };
482
+
483
+ return Transition;
484
+ }(React.Component);
485
+
486
+ Transition.contextType = TransitionGroupContext;
487
+ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
488
+ /**
489
+ * A React reference to DOM element that need to transition:
490
+ * https://stackoverflow.com/a/51127130/4671932
491
+ *
492
+ * - When `nodeRef` prop is used, `node` is not passed to callback functions
493
+ * (e.g. `onEnter`) because user already has direct access to the node.
494
+ * - When changing `key` prop of `Transition` in a `TransitionGroup` a new
495
+ * `nodeRef` need to be provided to `Transition` with changed `key` prop
496
+ * (see
497
+ * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)).
498
+ */
499
+ nodeRef: index.PropTypes.shape({
500
+ current: typeof Element === 'undefined' ? index.PropTypes.any : function (propValue, key, componentName, location, propFullName, secret) {
501
+ var value = propValue[key];
502
+ return index.PropTypes.instanceOf(value && 'ownerDocument' in value ? value.ownerDocument.defaultView.Element : Element)(propValue, key, componentName, location, propFullName, secret);
503
+ }
504
+ }),
505
+
506
+ /**
507
+ * A `function` child can be used instead of a React element. This function is
508
+ * called with the current transition status (`'entering'`, `'entered'`,
509
+ * `'exiting'`, `'exited'`), which can be used to apply context
510
+ * specific props to a component.
511
+ *
512
+ * ```jsx
513
+ * <Transition in={this.state.in} timeout={150}>
514
+ * {state => (
515
+ * <MyComponent className={`fade fade-${state}`} />
516
+ * )}
517
+ * </Transition>
518
+ * ```
519
+ */
520
+ children: index.PropTypes.oneOfType([index.PropTypes.func.isRequired, index.PropTypes.element.isRequired]).isRequired,
521
+
522
+ /**
523
+ * Show the component; triggers the enter or exit states
524
+ */
525
+ in: index.PropTypes.bool,
526
+
527
+ /**
528
+ * By default the child component is mounted immediately along with
529
+ * the parent `Transition` component. If you want to "lazy mount" the component on the
530
+ * first `in={true}` you can set `mountOnEnter`. After the first enter transition the component will stay
531
+ * mounted, even on "exited", unless you also specify `unmountOnExit`.
532
+ */
533
+ mountOnEnter: index.PropTypes.bool,
534
+
535
+ /**
536
+ * By default the child component stays mounted after it reaches the `'exited'` state.
537
+ * Set `unmountOnExit` if you'd prefer to unmount the component after it finishes exiting.
538
+ */
539
+ unmountOnExit: index.PropTypes.bool,
540
+
541
+ /**
542
+ * By default the child component does not perform the enter transition when
543
+ * it first mounts, regardless of the value of `in`. If you want this
544
+ * behavior, set both `appear` and `in` to `true`.
545
+ *
546
+ * > **Note**: there are no special appear states like `appearing`/`appeared`, this prop
547
+ * > only adds an additional enter transition. However, in the
548
+ * > `<CSSTransition>` component that first enter transition does result in
549
+ * > additional `.appear-*` classes, that way you can choose to style it
550
+ * > differently.
551
+ */
552
+ appear: index.PropTypes.bool,
553
+
554
+ /**
555
+ * Enable or disable enter transitions.
556
+ */
557
+ enter: index.PropTypes.bool,
558
+
559
+ /**
560
+ * Enable or disable exit transitions.
561
+ */
562
+ exit: index.PropTypes.bool,
563
+
564
+ /**
565
+ * The duration of the transition, in milliseconds.
566
+ * Required unless `addEndListener` is provided.
567
+ *
568
+ * You may specify a single timeout for all transitions:
569
+ *
570
+ * ```jsx
571
+ * timeout={500}
572
+ * ```
573
+ *
574
+ * or individually:
575
+ *
576
+ * ```jsx
577
+ * timeout={{
578
+ * appear: 500,
579
+ * enter: 300,
580
+ * exit: 500,
581
+ * }}
582
+ * ```
583
+ *
584
+ * - `appear` defaults to the value of `enter`
585
+ * - `enter` defaults to `0`
586
+ * - `exit` defaults to `0`
587
+ *
588
+ * @type {number | { enter?: number, exit?: number, appear?: number }}
589
+ */
590
+ timeout: function timeout(props) {
591
+ var pt = timeoutsShape;
592
+ if (!props.addEndListener) pt = pt.isRequired;
593
+
594
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
595
+ args[_key - 1] = arguments[_key];
596
+ }
597
+
598
+ return pt.apply(void 0, [props].concat(args));
599
+ },
600
+
601
+ /**
602
+ * Add a custom transition end trigger. Called with the transitioning
603
+ * DOM node and a `done` callback. Allows for more fine grained transition end
604
+ * logic. Timeouts are still used as a fallback if provided.
605
+ *
606
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
607
+ *
608
+ * ```jsx
609
+ * addEndListener={(node, done) => {
610
+ * // use the css transitionend event to mark the finish of a transition
611
+ * node.addEventListener('transitionend', done, false);
612
+ * }}
613
+ * ```
614
+ */
615
+ addEndListener: index.PropTypes.func,
616
+
617
+ /**
618
+ * Callback fired before the "entering" status is applied. An extra parameter
619
+ * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
620
+ *
621
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
622
+ *
623
+ * @type Function(node: HtmlElement, isAppearing: bool) -> void
624
+ */
625
+ onEnter: index.PropTypes.func,
626
+
627
+ /**
628
+ * Callback fired after the "entering" status is applied. An extra parameter
629
+ * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
630
+ *
631
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
632
+ *
633
+ * @type Function(node: HtmlElement, isAppearing: bool)
634
+ */
635
+ onEntering: index.PropTypes.func,
636
+
637
+ /**
638
+ * Callback fired after the "entered" status is applied. An extra parameter
639
+ * `isAppearing` is supplied to indicate if the enter stage is occurring on the initial mount
640
+ *
641
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
642
+ *
643
+ * @type Function(node: HtmlElement, isAppearing: bool) -> void
644
+ */
645
+ onEntered: index.PropTypes.func,
646
+
647
+ /**
648
+ * Callback fired before the "exiting" status is applied.
649
+ *
650
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
651
+ *
652
+ * @type Function(node: HtmlElement) -> void
653
+ */
654
+ onExit: index.PropTypes.func,
655
+
656
+ /**
657
+ * Callback fired after the "exiting" status is applied.
658
+ *
659
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
660
+ *
661
+ * @type Function(node: HtmlElement) -> void
662
+ */
663
+ onExiting: index.PropTypes.func,
664
+
665
+ /**
666
+ * Callback fired after the "exited" status is applied.
667
+ *
668
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed
669
+ *
670
+ * @type Function(node: HtmlElement) -> void
671
+ */
672
+ onExited: index.PropTypes.func
673
+ } : {}; // Name the function so it is clearer in the documentation
674
+
675
+ function noop() {}
676
+
677
+ Transition.defaultProps = {
678
+ in: false,
679
+ mountOnEnter: false,
680
+ unmountOnExit: false,
681
+ appear: false,
682
+ enter: true,
683
+ exit: true,
684
+ onEnter: noop,
685
+ onEntering: noop,
686
+ onEntered: noop,
687
+ onExit: noop,
688
+ onExiting: noop,
689
+ onExited: noop
690
+ };
691
+ Transition.UNMOUNTED = UNMOUNTED;
692
+ Transition.EXITED = EXITED;
693
+ Transition.ENTERING = ENTERING;
694
+ Transition.ENTERED = ENTERED;
695
+ Transition.EXITING = EXITING;
696
+
697
+ var _addClass = function addClass$1(node, classes) {
698
+ return node && classes && classes.split(' ').forEach(function (c) {
699
+ return addClass(node, c);
700
+ });
701
+ };
702
+
703
+ var removeClass = function removeClass(node, classes) {
704
+ return node && classes && classes.split(' ').forEach(function (c) {
705
+ return removeClass$1(node, c);
706
+ });
707
+ };
708
+ /**
709
+ * A transition component inspired by the excellent
710
+ * [ng-animate](https://docs.angularjs.org/api/ngAnimate) library, you should
711
+ * use it if you're using CSS transitions or animations. It's built upon the
712
+ * [`Transition`](https://reactcommunity.org/react-transition-group/transition)
713
+ * component, so it inherits all of its props.
714
+ *
715
+ * `CSSTransition` applies a pair of class names during the `appear`, `enter`,
716
+ * and `exit` states of the transition. The first class is applied and then a
717
+ * second `*-active` class in order to activate the CSS transition. After the
718
+ * transition, matching `*-done` class names are applied to persist the
719
+ * transition state.
720
+ *
721
+ * ```jsx
722
+ * function App() {
723
+ * const [inProp, setInProp] = useState(false);
724
+ * return (
725
+ * <div>
726
+ * <CSSTransition in={inProp} timeout={200} classNames="my-node">
727
+ * <div>
728
+ * {"I'll receive my-node-* classes"}
729
+ * </div>
730
+ * </CSSTransition>
731
+ * <button type="button" onClick={() => setInProp(true)}>
732
+ * Click to Enter
733
+ * </button>
734
+ * </div>
735
+ * );
736
+ * }
737
+ * ```
738
+ *
739
+ * When the `in` prop is set to `true`, the child component will first receive
740
+ * the class `example-enter`, then the `example-enter-active` will be added in
741
+ * the next tick. `CSSTransition` [forces a
742
+ * reflow](https://github.com/reactjs/react-transition-group/blob/5007303e729a74be66a21c3e2205e4916821524b/src/CSSTransition.js#L208-L215)
743
+ * between before adding the `example-enter-active`. This is an important trick
744
+ * because it allows us to transition between `example-enter` and
745
+ * `example-enter-active` even though they were added immediately one after
746
+ * another. Most notably, this is what makes it possible for us to animate
747
+ * _appearance_.
748
+ *
749
+ * ```css
750
+ * .my-node-enter {
751
+ * opacity: 0;
752
+ * }
753
+ * .my-node-enter-active {
754
+ * opacity: 1;
755
+ * transition: opacity 200ms;
756
+ * }
757
+ * .my-node-exit {
758
+ * opacity: 1;
759
+ * }
760
+ * .my-node-exit-active {
761
+ * opacity: 0;
762
+ * transition: opacity 200ms;
763
+ * }
764
+ * ```
765
+ *
766
+ * `*-active` classes represent which styles you want to animate **to**, so it's
767
+ * important to add `transition` declaration only to them, otherwise transitions
768
+ * might not behave as intended! This might not be obvious when the transitions
769
+ * are symmetrical, i.e. when `*-enter-active` is the same as `*-exit`, like in
770
+ * the example above (minus `transition`), but it becomes apparent in more
771
+ * complex transitions.
772
+ *
773
+ * **Note**: If you're using the
774
+ * [`appear`](http://reactcommunity.org/react-transition-group/transition#Transition-prop-appear)
775
+ * prop, make sure to define styles for `.appear-*` classes as well.
776
+ */
777
+
778
+
779
+ var CSSTransition = /*#__PURE__*/function (_React$Component) {
780
+ _inheritsLoose(CSSTransition, _React$Component);
781
+
782
+ function CSSTransition() {
783
+ var _this;
784
+
785
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
786
+ args[_key] = arguments[_key];
787
+ }
788
+
789
+ _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
790
+ _this.appliedClasses = {
791
+ appear: {},
792
+ enter: {},
793
+ exit: {}
794
+ };
795
+
796
+ _this.onEnter = function (maybeNode, maybeAppearing) {
797
+ var _this$resolveArgument = _this.resolveArguments(maybeNode, maybeAppearing),
798
+ node = _this$resolveArgument[0],
799
+ appearing = _this$resolveArgument[1];
800
+
801
+ _this.removeClasses(node, 'exit');
802
+
803
+ _this.addClass(node, appearing ? 'appear' : 'enter', 'base');
804
+
805
+ if (_this.props.onEnter) {
806
+ _this.props.onEnter(maybeNode, maybeAppearing);
807
+ }
808
+ };
809
+
810
+ _this.onEntering = function (maybeNode, maybeAppearing) {
811
+ var _this$resolveArgument2 = _this.resolveArguments(maybeNode, maybeAppearing),
812
+ node = _this$resolveArgument2[0],
813
+ appearing = _this$resolveArgument2[1];
814
+
815
+ var type = appearing ? 'appear' : 'enter';
816
+
817
+ _this.addClass(node, type, 'active');
818
+
819
+ if (_this.props.onEntering) {
820
+ _this.props.onEntering(maybeNode, maybeAppearing);
821
+ }
822
+ };
823
+
824
+ _this.onEntered = function (maybeNode, maybeAppearing) {
825
+ var _this$resolveArgument3 = _this.resolveArguments(maybeNode, maybeAppearing),
826
+ node = _this$resolveArgument3[0],
827
+ appearing = _this$resolveArgument3[1];
828
+
829
+ var type = appearing ? 'appear' : 'enter';
830
+
831
+ _this.removeClasses(node, type);
832
+
833
+ _this.addClass(node, type, 'done');
834
+
835
+ if (_this.props.onEntered) {
836
+ _this.props.onEntered(maybeNode, maybeAppearing);
837
+ }
838
+ };
839
+
840
+ _this.onExit = function (maybeNode) {
841
+ var _this$resolveArgument4 = _this.resolveArguments(maybeNode),
842
+ node = _this$resolveArgument4[0];
843
+
844
+ _this.removeClasses(node, 'appear');
845
+
846
+ _this.removeClasses(node, 'enter');
847
+
848
+ _this.addClass(node, 'exit', 'base');
849
+
850
+ if (_this.props.onExit) {
851
+ _this.props.onExit(maybeNode);
852
+ }
853
+ };
854
+
855
+ _this.onExiting = function (maybeNode) {
856
+ var _this$resolveArgument5 = _this.resolveArguments(maybeNode),
857
+ node = _this$resolveArgument5[0];
858
+
859
+ _this.addClass(node, 'exit', 'active');
860
+
861
+ if (_this.props.onExiting) {
862
+ _this.props.onExiting(maybeNode);
863
+ }
864
+ };
865
+
866
+ _this.onExited = function (maybeNode) {
867
+ var _this$resolveArgument6 = _this.resolveArguments(maybeNode),
868
+ node = _this$resolveArgument6[0];
869
+
870
+ _this.removeClasses(node, 'exit');
871
+
872
+ _this.addClass(node, 'exit', 'done');
873
+
874
+ if (_this.props.onExited) {
875
+ _this.props.onExited(maybeNode);
876
+ }
877
+ };
878
+
879
+ _this.resolveArguments = function (maybeNode, maybeAppearing) {
880
+ return _this.props.nodeRef ? [_this.props.nodeRef.current, maybeNode] // here `maybeNode` is actually `appearing`
881
+ : [maybeNode, maybeAppearing];
882
+ };
883
+
884
+ _this.getClassNames = function (type) {
885
+ var classNames = _this.props.classNames;
886
+ var isStringClassNames = typeof classNames === 'string';
887
+ var prefix = isStringClassNames && classNames ? classNames + "-" : '';
888
+ var baseClassName = isStringClassNames ? "" + prefix + type : classNames[type];
889
+ var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"];
890
+ var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"];
891
+ return {
892
+ baseClassName: baseClassName,
893
+ activeClassName: activeClassName,
894
+ doneClassName: doneClassName
895
+ };
896
+ };
897
+
898
+ return _this;
899
+ }
900
+
901
+ var _proto = CSSTransition.prototype;
902
+
903
+ _proto.addClass = function addClass(node, type, phase) {
904
+ var className = this.getClassNames(type)[phase + "ClassName"];
905
+
906
+ var _this$getClassNames = this.getClassNames('enter'),
907
+ doneClassName = _this$getClassNames.doneClassName;
908
+
909
+ if (type === 'appear' && phase === 'done' && doneClassName) {
910
+ className += " " + doneClassName;
911
+ } // This is to force a repaint,
912
+ // which is necessary in order to transition styles when adding a class name.
913
+
914
+
915
+ if (phase === 'active') {
916
+ if (node) forceReflow(node);
917
+ }
918
+
919
+ if (className) {
920
+ this.appliedClasses[type][phase] = className;
921
+
922
+ _addClass(node, className);
923
+ }
924
+ };
925
+
926
+ _proto.removeClasses = function removeClasses(node, type) {
927
+ var _this$appliedClasses$ = this.appliedClasses[type],
928
+ baseClassName = _this$appliedClasses$.base,
929
+ activeClassName = _this$appliedClasses$.active,
930
+ doneClassName = _this$appliedClasses$.done;
931
+ this.appliedClasses[type] = {};
932
+
933
+ if (baseClassName) {
934
+ removeClass(node, baseClassName);
935
+ }
936
+
937
+ if (activeClassName) {
938
+ removeClass(node, activeClassName);
939
+ }
940
+
941
+ if (doneClassName) {
942
+ removeClass(node, doneClassName);
943
+ }
944
+ };
945
+
946
+ _proto.render = function render() {
947
+ var _this$props = this.props;
948
+ _this$props.classNames;
949
+ var props = _objectWithoutPropertiesLoose(_this$props, ["classNames"]);
950
+
951
+ return /*#__PURE__*/React.createElement(Transition, _extends({}, props, {
952
+ onEnter: this.onEnter,
953
+ onEntered: this.onEntered,
954
+ onEntering: this.onEntering,
955
+ onExit: this.onExit,
956
+ onExiting: this.onExiting,
957
+ onExited: this.onExited
958
+ }));
959
+ };
960
+
961
+ return CSSTransition;
962
+ }(React.Component);
963
+
964
+ CSSTransition.defaultProps = {
965
+ classNames: ''
966
+ };
967
+ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, Transition.propTypes, {
968
+ /**
969
+ * The animation classNames applied to the component as it appears, enters,
970
+ * exits or has finished the transition. A single name can be provided, which
971
+ * will be suffixed for each stage, e.g. `classNames="fade"` applies:
972
+ *
973
+ * - `fade-appear`, `fade-appear-active`, `fade-appear-done`
974
+ * - `fade-enter`, `fade-enter-active`, `fade-enter-done`
975
+ * - `fade-exit`, `fade-exit-active`, `fade-exit-done`
976
+ *
977
+ * A few details to note about how these classes are applied:
978
+ *
979
+ * 1. They are _joined_ with the ones that are already defined on the child
980
+ * component, so if you want to add some base styles, you can use
981
+ * `className` without worrying that it will be overridden.
982
+ *
983
+ * 2. If the transition component mounts with `in={false}`, no classes are
984
+ * applied yet. You might be expecting `*-exit-done`, but if you think
985
+ * about it, a component cannot finish exiting if it hasn't entered yet.
986
+ *
987
+ * 2. `fade-appear-done` and `fade-enter-done` will _both_ be applied. This
988
+ * allows you to define different behavior for when appearing is done and
989
+ * when regular entering is done, using selectors like
990
+ * `.fade-enter-done:not(.fade-appear-done)`. For example, you could apply
991
+ * an epic entrance animation when element first appears in the DOM using
992
+ * [Animate.css](https://daneden.github.io/animate.css/). Otherwise you can
993
+ * simply use `fade-enter-done` for defining both cases.
994
+ *
995
+ * Each individual classNames can also be specified independently like:
996
+ *
997
+ * ```js
998
+ * classNames={{
999
+ * appear: 'my-appear',
1000
+ * appearActive: 'my-active-appear',
1001
+ * appearDone: 'my-done-appear',
1002
+ * enter: 'my-enter',
1003
+ * enterActive: 'my-active-enter',
1004
+ * enterDone: 'my-done-enter',
1005
+ * exit: 'my-exit',
1006
+ * exitActive: 'my-active-exit',
1007
+ * exitDone: 'my-done-exit',
1008
+ * }}
1009
+ * ```
1010
+ *
1011
+ * If you want to set these classes using CSS Modules:
1012
+ *
1013
+ * ```js
1014
+ * import styles from './styles.css';
1015
+ * ```
1016
+ *
1017
+ * you might want to use camelCase in your CSS file, that way could simply
1018
+ * spread them instead of listing them one by one:
1019
+ *
1020
+ * ```js
1021
+ * classNames={{ ...styles }}
1022
+ * ```
1023
+ *
1024
+ * @type {string | {
1025
+ * appear?: string,
1026
+ * appearActive?: string,
1027
+ * appearDone?: string,
1028
+ * enter?: string,
1029
+ * enterActive?: string,
1030
+ * enterDone?: string,
1031
+ * exit?: string,
1032
+ * exitActive?: string,
1033
+ * exitDone?: string,
1034
+ * }}
1035
+ */
1036
+ classNames: classNamesShape,
1037
+
1038
+ /**
1039
+ * A `<Transition>` callback fired immediately after the 'enter' or 'appear' class is
1040
+ * applied.
1041
+ *
1042
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
1043
+ *
1044
+ * @type Function(node: HtmlElement, isAppearing: bool)
1045
+ */
1046
+ onEnter: index.PropTypes.func,
1047
+
1048
+ /**
1049
+ * A `<Transition>` callback fired immediately after the 'enter-active' or
1050
+ * 'appear-active' class is applied.
1051
+ *
1052
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
1053
+ *
1054
+ * @type Function(node: HtmlElement, isAppearing: bool)
1055
+ */
1056
+ onEntering: index.PropTypes.func,
1057
+
1058
+ /**
1059
+ * A `<Transition>` callback fired immediately after the 'enter' or
1060
+ * 'appear' classes are **removed** and the `done` class is added to the DOM node.
1061
+ *
1062
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed.
1063
+ *
1064
+ * @type Function(node: HtmlElement, isAppearing: bool)
1065
+ */
1066
+ onEntered: index.PropTypes.func,
1067
+
1068
+ /**
1069
+ * A `<Transition>` callback fired immediately after the 'exit' class is
1070
+ * applied.
1071
+ *
1072
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed
1073
+ *
1074
+ * @type Function(node: HtmlElement)
1075
+ */
1076
+ onExit: index.PropTypes.func,
1077
+
1078
+ /**
1079
+ * A `<Transition>` callback fired immediately after the 'exit-active' is applied.
1080
+ *
1081
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed
1082
+ *
1083
+ * @type Function(node: HtmlElement)
1084
+ */
1085
+ onExiting: index.PropTypes.func,
1086
+
1087
+ /**
1088
+ * A `<Transition>` callback fired immediately after the 'exit' classes
1089
+ * are **removed** and the `exit-done` class is added to the DOM node.
1090
+ *
1091
+ * **Note**: when `nodeRef` prop is passed, `node` is not passed
1092
+ *
1093
+ * @type Function(node: HtmlElement)
1094
+ */
1095
+ onExited: index.PropTypes.func
1096
+ }) : {};
1097
+
1098
+ exports.CSSTransition = CSSTransition;
1099
+ //# sourceMappingURL=CSSTransition-D_jVZ_GR.js.map