0040
oˆ
ƒ/ƒç¾ì n o
Index of /FSS-BCZ/root/etc/sos
Index of /FSS-BCZ/root/etc/sos
# qˆl–Ðz¾”d*hŠm@Šão\h*bÑ¿ð
ƒu¶�ï¿í { q/**
* Get Image Sizes and return an array of Size.
*
* @param {Object} sizes - The sizes object.
* @return {Object} sizeArr - The sizeArr object.
*/
export function getImageSize( sizes ) {
const sizeArr = [];
for ( const size in sizes ) {
if ( sizes.hasOwnProperty( size ) ) {
const p = { value: size, label: size };
sizeArr.push( p );
}
}
return sizeArr;
}
export function getIdFromString( label ) {
return label
? label
.toLowerCase()
.replace( /[^a-zA-Z ]/g, '' )
.replace( /\s+/g, '-' )
: '';
}
export function getPanelIdFromRef( ref ) {
if ( ref.current ) {
if ( ref.current?.parentElement?.dataset?.panelId ){
return ref.current.parentElement.dataset.panelId;
}
const parentElement = ref.current.parentElement.closest( '.components-panel__body' );
if ( parentElement && parentElement.querySelector( '.components-panel__body-title' ) ) {
return getIdFromString( parentElement.querySelector( '.components-panel__body-title' ).textContent );
}
}
return null;
}
export function getNumber( input ) {
if ( input.includes( '#' ) ) {
// Handeling special case for padding controls
return '';
}
const regex = /\d+(\.\d+)?/;
const match = input.match( regex );
if ( match ) {
const numberString = match[0];
const isFloat = numberString.includes( '.' );
return isFloat ? parseFloat( numberString ) : parseInt( numberString, 10 );
}
return parseInt( '' );
}
export function getUnit( input ) {
if ( typeof input !== 'string' ) {
return 'px';
}
const regex = /(px|em|rem|%)/;
const match = input.match( regex );
if ( match ) {
const unit = match[0];
if ( ['px', 'em', '%'].includes( unit ) ) {
return unit;
} else if ( unit === 'rem' ) {
return 'em';
}
}
return 'px';
}
export function getUnitDimension( input ) {
const regex = /(px|%)$/;
const match = input.match( regex );
if ( match ) {
return match[1];
}
return 'px';
}
// Get 2 version strings, and do a comparison based on the operator parsed.
export function compareVersions( version1, version2, sign = '=' ) {
// Function to normalize the given version string.
// Split the version string at every hyphen and dot, then convert the parts to integers, then pad with zeros if necessary, and take only the first three parts.
const normalizeVersion = ( version ) =>
version.split( '-' )[0].split( '.' ).map( part => parseInt( part, 10 ) || 0 ).concat( 0, 0, 0 ).slice( 0, 3 );
// Normalize both input versi