11"use strict" ;
22
3- function _typeof ( obj ) { "@babel/helpers - typeof" ; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol . iterator ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && "function" == typeof Symbol && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } , _typeof ( obj ) ; }
43Object . defineProperty ( exports , "__esModule" , {
54 value : true
65} ) ;
@@ -19,79 +18,67 @@ var _ArrowDropDown = _interopRequireDefault(require("@material-ui/icons/ArrowDro
1918var _Theme = _interopRequireDefault ( require ( "../Theme/Theme" ) ) ;
2019var _typeUtil = require ( "../../util/typeUtil" ) ;
2120function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
22- function _getRequireWildcardCache ( nodeInterop ) { if ( typeof WeakMap !== "function" ) return null ; var cacheBabelInterop = new WeakMap ( ) ; var cacheNodeInterop = new WeakMap ( ) ; return ( _getRequireWildcardCache = function _getRequireWildcardCache ( nodeInterop ) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop ; } ) ( nodeInterop ) ; }
23- function _interopRequireWildcard ( obj , nodeInterop ) { if ( ! nodeInterop && obj && obj . __esModule ) { return obj ; } if ( obj === null || _typeof ( obj ) !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( nodeInterop ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( key !== "default" && Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
21+ function _getRequireWildcardCache ( e ) { if ( "function" != typeof WeakMap ) return null ; var r = new WeakMap ( ) , t = new WeakMap ( ) ; return ( _getRequireWildcardCache = function ( e ) { return e ? t : r ; } ) ( e ) ; }
22+ function _interopRequireWildcard ( e , r ) { if ( ! r && e && e . __esModule ) return e ; if ( null === e || "object" != typeof e && "function" != typeof e ) return { default : e } ; var t = _getRequireWildcardCache ( r ) ; if ( t && t . has ( e ) ) return t . get ( e ) ; var n = { __proto__ : null } , a = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var u in e ) if ( "default" !== u && Object . prototype . hasOwnProperty . call ( e , u ) ) { var i = a ? Object . getOwnPropertyDescriptor ( e , u ) : null ; i && ( i . get || i . set ) ? Object . defineProperty ( n , u , i ) : n [ u ] = e [ u ] ; } return n . default = e , t && t . set ( e , n ) , n ; }
2423function _extends ( ) { _extends = Object . assign ? Object . assign . bind ( ) : 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 ) ; }
25- function _slicedToArray ( arr , i ) { return _arrayWithHoles ( arr ) || _iterableToArrayLimit ( arr , i ) || _unsupportedIterableToArray ( arr , i ) || _nonIterableRest ( ) ; }
26- function _nonIterableRest ( ) { throw new TypeError ( "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ; }
27- function _unsupportedIterableToArray ( o , minLen ) { if ( ! o ) return ; if ( typeof o === "string" ) return _arrayLikeToArray ( o , minLen ) ; var n = Object . prototype . toString . call ( o ) . slice ( 8 , - 1 ) ; if ( n === "Object" && o . constructor ) n = o . constructor . name ; if ( n === "Map" || n === "Set" ) return Array . from ( o ) ; if ( n === "Arguments" || / ^ (?: U i | I ) n t (?: 8 | 1 6 | 3 2 ) (?: C l a m p e d ) ? A r r a y $ / . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ; }
28- function _arrayLikeToArray ( arr , len ) { if ( len == null || len > arr . length ) len = arr . length ; for ( var i = 0 , arr2 = new Array ( len ) ; i < len ; i ++ ) arr2 [ i ] = arr [ i ] ; return arr2 ; }
29- function _iterableToArrayLimit ( arr , i ) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr [ Symbol . iterator ] || arr [ "@@iterator" ] ; if ( null != _i ) { var _s , _e , _x , _r , _arr = [ ] , _n = ! 0 , _d = ! 1 ; try { if ( _x = ( _i = _i . call ( arr ) ) . next , 0 === i ) { if ( Object ( _i ) !== _i ) return ; _n = ! 1 ; } else for ( ; ! ( _n = ( _s = _x . call ( _i ) ) . done ) && ( _arr . push ( _s . value ) , _arr . length !== i ) ; _n = ! 0 ) ; } catch ( err ) { _d = ! 0 , _e = err ; } finally { try { if ( ! _n && null != _i . return && ( _r = _i . return ( ) , Object ( _r ) !== _r ) ) return ; } finally { if ( _d ) throw _e ; } } return _arr ; } }
30- function _arrayWithHoles ( arr ) { if ( Array . isArray ( arr ) ) return arr ; }
31- var SplitButton = function SplitButton ( props ) {
32- var name = props . name ,
33- options = props . options ,
34- selectedOption = props . selectedOption ,
35- selectedOptionDisplayCallback = props . selectedOptionDisplayCallback ,
36- onClick = props . onClick ,
37- onChange = props . onChange ,
38- buttonGroupProps = props . buttonGroupProps ,
39- buttonMenuProps = props . buttonMenuProps ,
40- buttonProps = props . buttonProps ;
41- var _useState = ( 0 , _react . useState ) ( false ) ,
42- _useState2 = _slicedToArray ( _useState , 2 ) ,
43- open = _useState2 [ 0 ] ,
44- setOpen = _useState2 [ 1 ] ;
45- var _useState3 = ( 0 , _react . useState ) ( selectedOption ) ,
46- _useState4 = _slicedToArray ( _useState3 , 2 ) ,
47- stateSelectedOption = _useState4 [ 0 ] ,
48- setStateSelectedOption = _useState4 [ 1 ] ;
49- var anchorRef = ( 0 , _react . useRef ) ( null ) ;
50- var appliedButtonGroupProps = {
24+ const SplitButton = props => {
25+ const {
26+ name,
27+ options,
28+ selectedOption,
29+ selectedOptionDisplayCallback,
30+ onClick,
31+ onChange,
32+ buttonGroupProps,
33+ buttonMenuProps,
34+ buttonProps
35+ } = props ;
36+ const [ open , setOpen ] = ( 0 , _react . useState ) ( false ) ;
37+ const [ stateSelectedOption , setStateSelectedOption ] = ( 0 , _react . useState ) ( selectedOption ) ;
38+ const anchorRef = ( 0 , _react . useRef ) ( null ) ;
39+ let appliedButtonGroupProps = {
5140 variant : 'outlined' ,
5241 color : 'primary'
5342 } ;
5443 if ( ( 0 , _typeUtil . exists ) ( buttonGroupProps ) ) {
5544 appliedButtonGroupProps = buttonGroupProps ;
5645 }
57- var appliedButtonProps = {
46+ let appliedButtonProps = {
5847 color : 'primary' ,
5948 size : 'small'
6049 } ;
6150 if ( ( 0 , _typeUtil . exists ) ( buttonProps ) ) {
6251 appliedButtonProps = buttonProps ;
6352 }
64- var appliedButtonMenuProps = {
53+ let appliedButtonMenuProps = {
6554 color : 'primary' ,
6655 size : 'small'
6756 } ;
6857 if ( ( 0 , _typeUtil . exists ) ( buttonMenuProps ) ) {
6958 appliedButtonMenuProps = buttonMenuProps ;
7059 }
71- ( 0 , _react . useEffect ) ( function ( ) {
60+ ( 0 , _react . useEffect ) ( ( ) => {
7261 if ( selectedOption === stateSelectedOption ) return ;
7362 setStateSelectedOption ( selectedOption ) ;
7463 } , [ selectedOption , stateSelectedOption ] ) ;
75- var handleClick = function handleClick ( ) {
64+ const handleClick = ( ) => {
7665 onClick ( stateSelectedOption ) ;
7766 } ;
78- var handleMenuItemClick = function handleMenuItemClick ( event , index ) {
67+ const handleMenuItemClick = ( event , index ) => {
7968 setStateSelectedOption ( options [ index ] ) ;
8069 onChange ( options [ index ] ) ;
8170 setOpen ( false ) ;
8271 } ;
83- var handleToggle = function handleToggle ( ) {
84- setOpen ( function ( prevOpen ) {
85- return ! prevOpen ;
86- } ) ;
72+ const handleToggle = ( ) => {
73+ setOpen ( prevOpen => ! prevOpen ) ;
8774 } ;
88- var handleClose = function handleClose ( event ) {
75+ const handleClose = event => {
8976 if ( anchorRef . current && anchorRef . current . contains ( event . target ) ) {
9077 return ;
9178 }
9279 setOpen ( false ) ;
9380 } ;
94- var renderSelectedOption = function renderSelectedOption ( ) {
81+ const renderSelectedOption = ( ) => {
9582 if ( ( 0 , _typeUtil . exists ) ( selectedOptionDisplayCallback ) ) {
9683 // eslint-disable-next-line max-len
9784 return selectedOptionDisplayCallback ( stateSelectedOption ) ;
@@ -123,9 +110,11 @@ var SplitButton = function SplitButton(props) {
123110 anchorEl : anchorRef . current ,
124111 open : open ,
125112 role : undefined
126- } , function ( _ref ) {
127- var TransitionProps = _ref . TransitionProps ,
128- placement = _ref . placement ;
113+ } , _ref => {
114+ let {
115+ TransitionProps,
116+ placement
117+ } = _ref ;
129118 return /*#__PURE__*/ _react . default . createElement ( _Grow . default , _extends ( { } , TransitionProps , {
130119 style : {
131120 transformOrigin : placement === 'bottom' ? 'center top' : 'center bottom'
@@ -134,17 +123,12 @@ var SplitButton = function SplitButton(props) {
134123 onClickAway : handleClose
135124 } , /*#__PURE__*/ _react . default . createElement ( _MenuList . default , {
136125 id : "" . concat ( name , "-split-button-menu" )
137- } , options . map ( function ( option , index ) {
138- return /*#__PURE__*/ _react . default . createElement ( _MenuItem . default , {
139- key : option ,
140- selected : option === stateSelectedOption ,
141- onClick : function onClick ( event ) {
142- return handleMenuItemClick ( event , index ) ;
143- }
144- } , option ) ;
145- } ) ) ) ) ) ;
126+ } , options . map ( ( option , index ) => /*#__PURE__*/ _react . default . createElement ( _MenuItem . default , {
127+ key : option ,
128+ selected : option === stateSelectedOption ,
129+ onClick : event => handleMenuItemClick ( event , index )
130+ } , option ) ) ) ) ) ) ;
146131 } ) ) ) ;
147132} ;
148- var WrappedSplitButton = _Theme . default . getWrappedComponent ( SplitButton ) ;
149- var _default = WrappedSplitButton ;
150- exports . default = _default ;
133+ const WrappedSplitButton = _Theme . default . getWrappedComponent ( SplitButton ) ;
134+ var _default = exports . default = WrappedSplitButton ;
0 commit comments