UNPKG

@gsretail.com/gui-core

Version:

A skeleton to create your own React component library using Rollup, TypeScript, Sass and Storybook

2 lines (1 loc) 1.86 kB
import e from"../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";import t from"../../@babel/runtime/helpers/esm/extends.js";import n from"../../@babel/runtime/helpers/esm/assertThisInitialized.js";import r from"../../@babel/runtime/helpers/esm/inheritsLoose.js";import o from"../../prop-types/index.js";import i from"react";import s from"./TransitionGroupContext.js";import{getInitialChildMapping as a,getNextChildMapping as l,getChildMapping as p}from"./utils/ChildMapping.js";var c=Object.values||function(e){return Object.keys(e).map((function(t){return e[t]}))},d=function(o){function d(e,t){var r,i=(r=o.call(this,e,t)||this).handleExited.bind(n(r));return r.state={contextValue:{isMounting:!0},handleExited:i,firstRender:!0},r}r(d,o);var u=d.prototype;return u.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},u.componentWillUnmount=function(){this.mounted=!1},d.getDerivedStateFromProps=function(e,t){var n=t.children,r=t.handleExited;return{children:t.firstRender?a(e,r):l(e,n,r),firstRender:!1}},u.handleExited=function(e,n){var r=p(this.props.children);e.key in r||(e.props.onExited&&e.props.onExited(n),this.mounted&&this.setState((function(n){var r=t({},n.children);return delete r[e.key],{children:r}})))},u.render=function(){var t=this.props,n=t.component,r=t.childFactory,o=e(t,["component","childFactory"]),a=this.state.contextValue,l=c(this.state.children).map(r);return delete o.appear,delete o.enter,delete o.exit,null===n?i.createElement(s.Provider,{value:a},l):i.createElement(s.Provider,{value:a},i.createElement(n,o,l))},d}(i.Component);d.propTypes="production"!==process.env.NODE_ENV?{component:o.any,children:o.node,appear:o.bool,enter:o.bool,exit:o.bool,childFactory:o.func}:{},d.defaultProps={component:"div",childFactory:function(e){return e}};var u=d;export{u as default};