VimUnDo@7TY.=W׬T<W<\T_T 5_?T/?module.exports = (children, targetWidth, componentWidth, margin5_(TRImodule.exports = (children, targetWidth, componentWidth, margin, maxWidth5_IRIvITWSmodule.exports = (children, targetWidth, maxWidth, componentWidth, margin, maxWidth5_IRIvITXImodule.exports = (children, targetWidth, maxWidth, componentWidth, margin5_RIvITMmodule.exports = (children, targetWidth, maxWidth, componentWidth, margin) ->5_RIvIT5_  VT9 _calcComponentWidth = (adjustComponentsPerRow = 0) =>7 # Calculate the # of components per row to place.< componentCount = React.Children.count(@props.children)M componentsPerRow = Math.round(@state.componentWidth/@props.targetWidth)B componentsPerRow = componentsPerRow - adjustComponentsPerRow7 # There has to be at least one component per row.6 componentsPerRow = Math.max(componentsPerRow, 1)* if componentsPerRow > componentCount) componentsPerRow = componentCountC # Calculate the per-component width with space for in-between # components subtracted9 rawWidth = @state.componentWidth / componentsPerRowa marginRightOffset = ((@props.margin * componentsPerRow) - @props.margin) / componentsPerRow: componentWidth = rawWidth - marginRightOffset - 0.25 # Don't get too big.W maxWidth = if @props.maxWidth? then @props.maxWidth else @props.targetWidth * 1.59 componentWidth = Math.min(componentWidth, maxWidth)B return [componentWidth, componentsPerRow, marginRightOffset]Q [componentWidth, componentsPerRow, marginRightOffset] = _calcComponentWidth()Z # If the total margin used in a row is greater than one component, drop the components # per row.< if componentWidth < marginRightOffset * componentsPerRowR adjustment = Math.round((marginRightOffset*componentsPerRow)/componentWidth)] [componentWidth, componentsPerRow, marginRightOffset] = _calcComponentWidth(adjustment)- return [componentWidth, componentsPerRow]5_ **v*TU maxWidth = if @props.maxWidth? then @props.maxWidth else @props.targetWidth * 1.5_ marginRightOffset = ((@props.margin * componentsPerRow) - @props.margin) / componentsPerRow7 rawWidth = @state.componentWidth / componentsPerRowK componentsPerRow = Math.round(@state.componentWidth/@props.targetWidth): componentCount = React.Children.count(@props.children)5_ **v*T ! 5_ 5**v*T/"7 _calcComponentWidth = (adjustComponentsPerRow = 0) =>5_ D**v*T6"X # If the total margin used in a row is greater than one component, drop the components5_  **v*T8# # drop the componentsper row.# # per row.5_ **v*Tn#"5_**v*Tv$ # #5_**v*T$ if isArray(props.children)5_/**v*T$/ componentCount = if isArray(props.children)5_P**v*T$Q componentCount = if isArray(props.children) then props.children.length else 05_P**v*TQ componentCount = if isArray(props.children) then props.children.length else 15_P**v*T % # $5_ * *v*T % console.log props.children5_$ * *v*T- % %5_  $ vT/ &% console.log props.children.length5_ $ vT6R #componentCount = if isArray(props.children) then props.children.length else 15_ $ vTK' # &5_ $ vTP 'Q componentCount = if isArray(props.children) then props.children.length else 15_9 $ vTT (  '5_  $ vT_ 9 componentCount = React.Children.count(props.children)5_  $ vTa *  )5_  VT % console.log props.children.length console.log props.children console.log componentCount: #componentCount = React.Children.count(props.children)5_   VTReact = require 'react'5_!   VT %5_ "!  VT5 # Calculate the # of components per row to place.5_!#"   VT % %5_"$#  VT' &5_#%$  VT ' # Count # of children5_$&%   VT   componentCount = 05_%'&  VT  '  &5_&('   VTD (X throw new Error("At least one children must be passed to react-component-gallery")5_')( IVTE  )J "At least one children must be passed to react-component-gallery")5_(*)   VTg ! # No children, throw error. throw new Error(I "At least one children must be passed to react-component-gallery" )5_)+*  VTh '  &5_*,+  VTm (  '5_+-,   VT{  ( return 5_,.-$* VT{#%(: if componentWidth < marginRightOffset * componentsPerRow5_-/.$; VT|#%(; if componentWidth < marginRightOffset * (componentsPerRow5_.0/%/ VT$&(P adjustment = Math.round((marginRightOffset*componentsPerRow)/componentWidth)5_/10%@ VT$&(Q adjustment = Math.round((marginRightOffset*(componentsPerRow)/componentWidth)5_021::HvHT(] marginRightOffset = ((props.margin * componentsPerRow) - props.margin) / componentsPerRow5_132):HvHT(N marginRightOffset = ((props.margin * componentsPerRow)) / componentsPerRow5_253::HvHT(O marginRightOffset = ((props.margin * (componentsPerRow)) / componentsPerRow5_3645 v T6 rawWidth = state.componentWidth / componentsPerRow5_586 v T8 componentWidth = rawWidth - marginRightOffset - 0.255_6978vTT marginRightOffset = ((props.margin * (componentsPerRow - 1))) / componentsPerRow5_8:9vTF componentWidth = totalWidthPerComponent - marginRightOffset - 0.255_9;:vT@ return [componentWidth, componentsPerRow, marginRightOffset]5_:<; vT!O [componentWidth, componentsPerRow, marginRightOffset] = _calcComponentWidth()5_;=<$vT#%@ if componentWidth < marginRightOffset * (componentsPerRow - 1)5_<>=%vT$&V adjustment = Math.round((marginRightOffset*(componentsPerRow - 1))/componentWidth)5_=?>&vT%'[ [componentWidth, componentsPerRow, marginRightOffset] = _calcComponentWidth(adjustment)5_>@?%-vT$&(U adjustment = Math.round((totalRightMargin*(componentsPerRow - 1))/componentWidth)5_?A@%/vT$&(V adjustment = Math.round((totalRightMargin *(componentsPerRow - 1))/componentWidth)5_@BA%GvT$&(W adjustment = Math.round((totalRightMargin * (componentsPerRow - 1))/componentWidth)5_ADB%IvT$&(X adjustment = Math.round((totalRightMargin * (componentsPerRow - 1)) /componentWidth)5_BECD''AvT?(A # Calculate the per-component width with space for in-between # components subtracted5_DFE''AvATC'B # Calculate the per-component width # components subtracted5_EGF''AvATD'' # Calculate the per-component width5_FHGvT]S totalRightMargin = ((props.margin * (componentsPerRow - 1))) / componentsPerRow5_GIHvT^E componentWidth = totalWidthPerComponent - totalRightMargin - 0.255_HJIvT^? return [componentWidth, componentsPerRow, totalRightMargin]5_IKJvT_ N [componentWidth, componentsPerRow, totalRightMargin] = _calcComponentWidth()5_JLK#vT`"$? if componentWidth < totalRightMargin * (componentsPerRow - 1)5_KML$vT`#%Y adjustment = Math.round((totalRightMargin * (componentsPerRow - 1)) / componentWidth)5_LNM%vT`$&Z [componentWidth, componentsPerRow, totalRightMargin] = _calcComponentWidth(adjustment)5_MONvTG componentWidth = totalWidthPerComponent - averageRightMargin - 0.255_NPOvT7 componentWidth = Math.min(componentWidth, maxWidth)5_OQPvTA return [componentWidth, componentsPerRow, averageRightMargin]5_PRQvT P [componentWidth, componentsPerRow, averageRightMargin] = _calcComponentWidth()5_QSR#vT"$A if componentWidth < averageRightMargin * (componentsPerRow - 1)5_RTS$vT#%[ adjustment = Math.round((averageRightMargin * (componentsPerRow - 1)) / componentWidth)5_SUT%vT$&\ [componentWidth, componentsPerRow, averageRightMargin] = _calcComponentWidth(adjustment)5_TVU'vT &(+ return [componentWidth, componentsPerRow]5_UWV" vT!#' # drop the components per row.5_VXW#vT"$'F if childComponentWidth < averageRightMargin * (componentsPerRow - 1)5_WYX#GvT"$'G if childComponentWidth < (averageRightMargin * (componentsPerRow - 1)5_XZY")vT6"$( # "$'5_Y[Z%"vT? %') %'(5_Z\['vTO'))'()5_[]\(vTO')*# console.log _calcComponentWidth()5_\^]($vTR')*% console.log _calcComponentWidth()5_]`^%vT$&*` adjustment = Math.round((averageRightMargin * (componentsPerRow - 1)) / childComponentWidth)5_^a_`%^vT$&*_ adjustment = Math.ceil((averageRightMargin * (componentsPerRow - 1)) / childComponentWidth)5_`ba&vT<%& console.log adjustment5_acb'vT=&'/ console.log _calcComponentWidth(adjustment)5_bdc#vT="## console.log _calcComponentWidth()5_ced&VT'x#7 _calcComponentWidth = (adjustComponentsPerRow = 0) -> # Count # of children. if props.childrenS componentCount = if isArray(props.children) then props.children.length else 1 else # No children, return. return [0,0]5 # Calculate the # of components per row to place.I componentsPerRow = Math.round(state.componentWidth/props.targetWidth)@ componentsPerRow = componentsPerRow - adjustComponentsPerRow5 # There has to be at least one component per row.4 componentsPerRow = Math.max(componentsPerRow, 1)( if componentsPerRow > componentCount' componentsPerRow = componentCount( # Calculate the per-component width.D totalWidthPerComponent = state.componentWidth / componentsPerRowU averageRightMargin = ((props.margin * (componentsPerRow - 1))) / componentsPerRowL childComponentWidth = totalWidthPerComponent - averageRightMargin - 0.25 # Don't get too big.R maxWidth = if props.maxWidth? then props.maxWidth else props.targetWidth * 1.5A childComponentWidth = Math.min(childComponentWidth, maxWidth)F return [childComponentWidth, componentsPerRow, averageRightMargin]U [childComponentWidth, componentsPerRow, averageRightMargin] = _calcComponentWidth()D # If the total margin used in a row is greater than one component,* # drop the number of components per row.H if childComponentWidth < (averageRightMargin * (componentsPerRow - 1))c adjustment = Math.ceil((averageRightMargin * (componentsPerRow - 1)) / childComponentWidth / 2)a [childComponentWidth, componentsPerRow, averageRightMargin] = _calcComponentWidth(adjustment)5_dfeVT'y 5_egfVT'A idealComponentsPerRow = (state.componentWidth/props.margin) + 15_fhgBVT'B idealComponentsPerRow = ((state.componentWidth/props.margin) + 15_gih)VT'  5_hji >  VT( R childComponentWidth = ((state.componentWidth + props.margin) / componentsPerRow)5_ikj   VT(  / componentsPerRow)5_jlk   VT( > childComponentWidth = ((state.componentWidth + props.margin)"/ componentsPerRow) - props.margin & / componentsPerRow) - props.margin5_kml @  VT( a childComponentWidth = ((state.componentWidth + props.margin) / componentsPerRow) - props.margin5_lnm   VT( " componentsPerRow) - props.margin5_mon   VT( % componentsPerRow) - props.margin5_npo  VT(g  5_oqpVT( # Calculations illustrated 5_prqVT( # Formula illustrated 5_qsrgVT(5_rtsVT( #5_sutVT( # 5_tvuVT( 5_uwvVT(5 # Formula = componentWidth = numComponentsPerRow * 5_vxw1VT(1 # Formula = totalWidth = numComponentsPerRow * 5_wyxT 5_xzyT 5_y{z Td # Formula = totalWidth = numComponentsPerRow * componentWidth + (numComponentsPerRow - 1) * margin5_z|{ Tc # Formula totalWidth = numComponentsPerRow * componentWidth + (numComponentsPerRow - 1) * margin5_{}|Te # Formula is totalWidth = numComponentsPerRow * componentWidth + (numComponentsPerRow - 1) * margin5_|~}fTf # Formula is (totalWidth = numComponentsPerRow * componentWidth + (numComponentsPerRow - 1) * margin5_}~gTg # Formula is (totalWidth = numComponentsPerRow * componentWidth + (numComponentsPerRow - 1) * margin)5_~DTh # Formula is (totalWidth = numComponentsPerRow * componentWidth + (numComponentsPerRow - 1) * margin))5_ -Tr  #  5_  VT쩗 E idealComponentsPerRow = ((state.componentWidth/props.margin) + 1) /* ((props.targetWidth/props.margin) + 1)5_T3 console.log childComponentWidth, componentsPerRow5_T console.log props, state5_^`_%^vT$&*c adjustment = Math.ceil((averageRightMargin * (componentsPerRow - 1)) / childComponentWidth / 2)5_BDC''Bv'T<(k # Calculate the per-component width totalWidthPerComponent = state.componentWidth / componentsPerRow5_687vT(C = ((props.margin * (componentsPerRow - 1))) / componentsPerRow5_354:HvHT(8 totalWidth = state.componentWidth / componentsPerRow5