@wordpress/block-library
Version:
Block library for the WordPress editor.
8 lines (7 loc) • 2.96 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/cover/edit/embed-video-url-input.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport {\n\t__experimentalConfirmDialog as ConfirmDialog,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tNotice,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isValidVideoEmbedUrl } from '../embed-video-utils';\n\nexport default function EmbedVideoUrlInput( {\n\tonSubmit,\n\tonClose,\n\tinitialUrl = '',\n} ) {\n\tconst [ url, setUrl ] = useState( initialUrl );\n\tconst [ error, setError ] = useState( '' );\n\n\tconst handleConfirm = () => {\n\t\tif ( ! url ) {\n\t\t\tsetError( __( 'Please enter a URL.' ) );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isValidVideoEmbedUrl( url ) ) {\n\t\t\tsetError(\n\t\t\t\t__(\n\t\t\t\t\t'This URL is not supported. Please enter a valid video link from a supported provider.'\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tonSubmit( url );\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen\n\t\t\tonConfirm={ handleConfirm }\n\t\t\tonCancel={ onClose }\n\t\t\tconfirmButtonText={ __( 'Add video' ) }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t{ error && (\n\t\t\t\t\t<Notice status=\"error\" isDismissible={ false }>\n\t\t\t\t\t\t{ error }\n\t\t\t\t\t</Notice>\n\t\t\t\t) }\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Video URL' ) }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetUrl( value );\n\t\t\t\t\t\tsetError( '' );\n\t\t\t\t\t} }\n\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t'Enter YouTube, Vimeo, or other video URL'\n\t\t\t\t\t) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Add a background video to the cover block that will autoplay in a loop.'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</VStack>\n\t\t</ConfirmDialog>\n\t);\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyB;AACzB,wBAKO;AACP,kBAAmB;AAKnB,+BAAqC;AAqClC;AAnCY,SAAR,mBAAqC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA,aAAa;AACd,GAAI;AACH,QAAM,CAAE,KAAK,MAAO,QAAI,yBAAU,UAAW;AAC7C,QAAM,CAAE,OAAO,QAAS,QAAI,yBAAU,EAAG;AAEzC,QAAM,gBAAgB,MAAM;AAC3B,QAAK,CAAE,KAAM;AACZ,mBAAU,gBAAI,qBAAsB,CAAE;AACtC;AAAA,IACD;AAEA,QAAK,KAAE,+CAAsB,GAAI,GAAI;AACpC;AAAA,YACC;AAAA,UACC;AAAA,QACD;AAAA,MACD;AACA;AAAA,IACD;AAEA,aAAU,GAAI;AACd,YAAQ;AAAA,EACT;AAEA,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,QAAM;AAAA,MACN,WAAY;AAAA,MACZ,UAAW;AAAA,MACX,uBAAoB,gBAAI,WAAY;AAAA,MACpC,MAAK;AAAA,MAEL,uDAAC,kBAAAC,sBAAA,EAAO,SAAU,GACf;AAAA,iBACD,4CAAC,4BAAO,QAAO,SAAQ,eAAgB,OACpC,iBACH;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,WAAQ,gBAAI,WAAY;AAAA,YACxB,OAAQ;AAAA,YACR,UAAW,CAAE,UAAW;AACvB,qBAAQ,KAAM;AACd,uBAAU,EAAG;AAAA,YACd;AAAA,YACA,iBAAc;AAAA,cACb;AAAA,YACD;AAAA,YACA,UAAO;AAAA,cACN;AAAA,YACD;AAAA;AAAA,QACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
"names": ["ConfirmDialog", "VStack"]
}