@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.63 kB
Source Map (JSON)
{"version":3,"file":"utils.cjs","names":[],"sources":["../../src/focal-point-picker/utils.ts"],"sourcesContent":["export const INITIAL_BOUNDS = {\n\twidth: 200,\n\theight: 170,\n};\n\nconst VIDEO_EXTENSIONS = [\n\t'avi',\n\t'mpg',\n\t'mpeg',\n\t'mov',\n\t'mp4',\n\t'm4v',\n\t'ogg',\n\t'ogv',\n\t'webm',\n\t'wmv',\n];\n\n/**\n * Gets the extension of a file name.\n *\n * @param filename The file name.\n * @return The extension of the file name.\n */\nexport function getExtension( filename = '' ): string {\n\tconst parts = filename.split( '.' );\n\treturn parts[ parts.length - 1 ];\n}\n\n/**\n * Checks if a file is a video.\n *\n * @param filename The file name.\n * @return Whether the file is a video.\n */\nexport function isVideoType( filename: string = '' ): boolean {\n\tif ( ! filename ) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfilename.startsWith( 'data:video/' ) ||\n\t\tVIDEO_EXTENSIONS.includes( getExtension( filename ) )\n\t);\n}\n\n/**\n * Transforms a fraction value to a percentage value.\n *\n * @param fraction The fraction value.\n * @return A percentage value.\n */\nexport function fractionToPercentage( fraction: number ): number {\n\treturn Math.round( fraction * 100 );\n}\n"],"mappings":";;;;;;AAAA,MAAa,iBAAiB;CAC7B,OAAO;CACP,QAAQ;AACT;AAEA,MAAM,mBAAmB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;;;AAQA,SAAgB,aAAc,WAAW,IAAa;CACrD,MAAM,QAAQ,SAAS,MAAO,GAAI;CAClC,OAAO,MAAO,MAAM,SAAS;AAC9B;;;;;;;AAQA,SAAgB,YAAa,WAAmB,IAAc;CAC7D,IAAK,CAAE,UACN,OAAO;CAER,OACC,SAAS,WAAY,aAAc,KACnC,iBAAiB,SAAU,aAAc,QAAS,CAAE;AAEtD;;;;;;;AAQA,SAAgB,qBAAsB,UAA2B;CAChE,OAAO,KAAK,MAAO,WAAW,GAAI;AACnC"}