24,'Shrink'=>24,'Order'=>100] as $property=>$max){$key='flex'.$property.$device;$value=Document::number($raw[$key]??-1,-1,$max);$out[$key]=$property==='Order'?(int)$value:$value;} $key='flexBasis'.$device;$value=$raw[$key]??''; $out[$key]=is_string($value)&&preg_match('/^(?:auto|0|(?:\d{1,4}(?:\.\d{1,2})?)(?:px|%))?$/D',$value)?$value:''; $key='flexSelf'.$device;$out[$key]=Document::choice($raw[$key]??'',['inherit','auto','start','center','end','stretch','baseline'],'inherit'); } return $out; } public static function css(array $node,?array $parent,array $settings): string { $css='';$id='#dbs-'.$node['id'];$p=$node['props']; if($node['type']==='section'&&($p['layout']??'')==='flex'&&($p['gridMode']??'legacy')==='legacy'){ foreach(['Tablet','Mobile'] as $i=>$device){ $rules=[]; foreach(['direction'=>'flex-direction','justify'=>'justify-content','alignItems'=>'align-items','wrap'=>'flex-wrap'] as $key=>$property){ $value=$p[$key.$device]??'inherit'; if($value!=='inherit'){$rules[]=$property.':'.strtr($value,['start'=>'flex-start','end'=>'flex-end','yes'=>'wrap','no'=>'nowrap']).'!important';} } if(($p['flexGap'.$device]??-1)>=0){$rules[]='gap:'.(float)$p['flexGap'.$device].'px!important';} if($rules){$css.='@media(max-width:'.(int)$settings[$i===0?'tabletBreakpoint':'mobileBreakpoint'].'px){'.$id.'>.dbs-grid{'.implode(';',$rules).'}}';} } } if($parent&&$parent['type']==='section'&&($parent['props']['layout']??'')==='flex'&&($parent['props']['gridMode']??'legacy')==='legacy'){ foreach(['Desktop','Tablet','Mobile'] as $i=>$device){ $rules=[];$s=$node['style']; foreach(['Grow'=>'flex-grow','Shrink'=>'flex-shrink','Order'=>'order'] as $key=>$property){if(($s['flex'.$key.$device]??-1)>=0){$rules[]=$property.':'.(float)$s['flex'.$key.$device];}} if(($s['flexBasis'.$device]??'')!==''){$rules[]='flex-basis:'.$s['flexBasis'.$device];} if(($s['flexSelf'.$device]??'inherit')!=='inherit'){$rules[]='align-self:'.strtr($s['flexSelf'.$device],['start'=>'flex-start','end'=>'flex-end']);} if($rules){$rule=$id.'{'.implode(';',$rules).'}';$css.=$i?'@media(max-width:'.(int)$settings[$i===1?'tabletBreakpoint':'mobileBreakpoint'].'px){'.$rule.'}':$rule;} } } return Assets::inline_style($css,'flex-'.substr(hash('sha256',$css),0,16)); } }