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