12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345 |
- /******/ (function() { // webpackBootstrap
- /******/ var __webpack_modules__ = ({
- /***/ 8294:
- /***/ (function(module) {
- /*!
- * clipboard.js v2.0.11
- * https://clipboardjs.com/
- *
- * Licensed MIT © Zeno Rocha
- */
- (function webpackUniversalModuleDefinition(root, factory) {
- if(true)
- module.exports = factory();
- else {}
- })(this, function() {
- return /******/ (function() { // webpackBootstrap
- /******/ var __webpack_modules__ = ({
- /***/ 686:
- /***/ (function(__unused_webpack_module, __webpack_exports__, __nested_webpack_require_623__) {
- "use strict";
- // EXPORTS
- __nested_webpack_require_623__.d(__webpack_exports__, {
- "default": function() { return /* binding */ clipboard; }
- });
- // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
- var tiny_emitter = __nested_webpack_require_623__(279);
- var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_623__.n(tiny_emitter);
- // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
- var listen = __nested_webpack_require_623__(370);
- var listen_default = /*#__PURE__*/__nested_webpack_require_623__.n(listen);
- // EXTERNAL MODULE: ./node_modules/select/src/select.js
- var src_select = __nested_webpack_require_623__(817);
- var select_default = /*#__PURE__*/__nested_webpack_require_623__.n(src_select);
- ;// CONCATENATED MODULE: ./src/common/command.js
- /**
- * Executes a given operation type.
- * @param {String} type
- * @return {Boolean}
- */
- function command(type) {
- try {
- return document.execCommand(type);
- } catch (err) {
- return false;
- }
- }
- ;// CONCATENATED MODULE: ./src/actions/cut.js
- /**
- * Cut action wrapper.
- * @param {String|HTMLElement} target
- * @return {String}
- */
- var ClipboardActionCut = function ClipboardActionCut(target) {
- var selectedText = select_default()(target);
- command('cut');
- return selectedText;
- };
- /* harmony default export */ var actions_cut = (ClipboardActionCut);
- ;// CONCATENATED MODULE: ./src/common/create-fake-element.js
- /**
- * Creates a fake textarea element with a value.
- * @param {String} value
- * @return {HTMLElement}
- */
- function createFakeElement(value) {
- var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
- var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS
- fakeElement.style.fontSize = '12pt'; // Reset box model
- fakeElement.style.border = '0';
- fakeElement.style.padding = '0';
- fakeElement.style.margin = '0'; // Move element out of screen horizontally
- fakeElement.style.position = 'absolute';
- fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
- var yPosition = window.pageYOffset || document.documentElement.scrollTop;
- fakeElement.style.top = "".concat(yPosition, "px");
- fakeElement.setAttribute('readonly', '');
- fakeElement.value = value;
- return fakeElement;
- }
- ;// CONCATENATED MODULE: ./src/actions/copy.js
- /**
- * Create fake copy action wrapper using a fake element.
- * @param {String} target
- * @param {Object} options
- * @return {String}
- */
- var fakeCopyAction = function fakeCopyAction(value, options) {
- var fakeElement = createFakeElement(value);
- options.container.appendChild(fakeElement);
- var selectedText = select_default()(fakeElement);
- command('copy');
- fakeElement.remove();
- return selectedText;
- };
- /**
- * Copy action wrapper.
- * @param {String|HTMLElement} target
- * @param {Object} options
- * @return {String}
- */
- var ClipboardActionCopy = function ClipboardActionCopy(target) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- container: document.body
- };
- var selectedText = '';
- if (typeof target === 'string') {
- selectedText = fakeCopyAction(target, options);
- } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {
- // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
- selectedText = fakeCopyAction(target.value, options);
- } else {
- selectedText = select_default()(target);
- command('copy');
- }
- return selectedText;
- };
- /* harmony default export */ var actions_copy = (ClipboardActionCopy);
- ;// CONCATENATED MODULE: ./src/actions/default.js
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
- /**
- * Inner function which performs selection from either `text` or `target`
- * properties and then executes copy or cut operations.
- * @param {Object} options
- */
- var ClipboardActionDefault = function ClipboardActionDefault() {
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- // Defines base properties passed from constructor.
- var _options$action = options.action,
- action = _options$action === void 0 ? 'copy' : _options$action,
- container = options.container,
- target = options.target,
- text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.
- if (action !== 'copy' && action !== 'cut') {
- throw new Error('Invalid "action" value, use either "copy" or "cut"');
- } // Sets the `target` property using an element that will be have its content copied.
- if (target !== undefined) {
- if (target && _typeof(target) === 'object' && target.nodeType === 1) {
- if (action === 'copy' && target.hasAttribute('disabled')) {
- throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
- }
- if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
- throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
- }
- } else {
- throw new Error('Invalid "target" value, use a valid Element');
- }
- } // Define selection strategy based on `text` property.
- if (text) {
- return actions_copy(text, {
- container: container
- });
- } // Defines which selection strategy based on `target` property.
- if (target) {
- return action === 'cut' ? actions_cut(target) : actions_copy(target, {
- container: container
- });
- }
- };
- /* harmony default export */ var actions_default = (ClipboardActionDefault);
- ;// CONCATENATED MODULE: ./src/clipboard.js
- function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
- function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- /**
- * Helper function to retrieve attribute value.
- * @param {String} suffix
- * @param {Element} element
- */
- function getAttributeValue(suffix, element) {
- var attribute = "data-clipboard-".concat(suffix);
- if (!element.hasAttribute(attribute)) {
- return;
- }
- return element.getAttribute(attribute);
- }
- /**
- * Base class which takes one or more elements, adds event listeners to them,
- * and instantiates a new `ClipboardAction` on each click.
- */
- var Clipboard = /*#__PURE__*/function (_Emitter) {
- _inherits(Clipboard, _Emitter);
- var _super = _createSuper(Clipboard);
- /**
- * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
- * @param {Object} options
- */
- function Clipboard(trigger, options) {
- var _this;
- _classCallCheck(this, Clipboard);
- _this = _super.call(this);
- _this.resolveOptions(options);
- _this.listenClick(trigger);
- return _this;
- }
- /**
- * Defines if attributes would be resolved using internal setter functions
- * or custom functions that were passed in the constructor.
- * @param {Object} options
- */
- _createClass(Clipboard, [{
- key: "resolveOptions",
- value: function resolveOptions() {
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
- this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
- this.text = typeof options.text === 'function' ? options.text : this.defaultText;
- this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
- }
- /**
- * Adds a click event listener to the passed trigger.
- * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
- */
- }, {
- key: "listenClick",
- value: function listenClick(trigger) {
- var _this2 = this;
- this.listener = listen_default()(trigger, 'click', function (e) {
- return _this2.onClick(e);
- });
- }
- /**
- * Defines a new `ClipboardAction` on each click event.
- * @param {Event} e
- */
- }, {
- key: "onClick",
- value: function onClick(e) {
- var trigger = e.delegateTarget || e.currentTarget;
- var action = this.action(trigger) || 'copy';
- var text = actions_default({
- action: action,
- container: this.container,
- target: this.target(trigger),
- text: this.text(trigger)
- }); // Fires an event based on the copy operation result.
- this.emit(text ? 'success' : 'error', {
- action: action,
- text: text,
- trigger: trigger,
- clearSelection: function clearSelection() {
- if (trigger) {
- trigger.focus();
- }
- window.getSelection().removeAllRanges();
- }
- });
- }
- /**
- * Default `action` lookup function.
- * @param {Element} trigger
- */
- }, {
- key: "defaultAction",
- value: function defaultAction(trigger) {
- return getAttributeValue('action', trigger);
- }
- /**
- * Default `target` lookup function.
- * @param {Element} trigger
- */
- }, {
- key: "defaultTarget",
- value: function defaultTarget(trigger) {
- var selector = getAttributeValue('target', trigger);
- if (selector) {
- return document.querySelector(selector);
- }
- }
- /**
- * Allow fire programmatically a copy action
- * @param {String|HTMLElement} target
- * @param {Object} options
- * @returns Text copied.
- */
- }, {
- key: "defaultText",
- /**
- * Default `text` lookup function.
- * @param {Element} trigger
- */
- value: function defaultText(trigger) {
- return getAttributeValue('text', trigger);
- }
- /**
- * Destroy lifecycle.
- */
- }, {
- key: "destroy",
- value: function destroy() {
- this.listener.destroy();
- }
- }], [{
- key: "copy",
- value: function copy(target) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- container: document.body
- };
- return actions_copy(target, options);
- }
- /**
- * Allow fire programmatically a cut action
- * @param {String|HTMLElement} target
- * @returns Text cutted.
- */
- }, {
- key: "cut",
- value: function cut(target) {
- return actions_cut(target);
- }
- /**
- * Returns the support of the given action, or all actions if no action is
- * given.
- * @param {String} [action]
- */
- }, {
- key: "isSupported",
- value: function isSupported() {
- var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
- var actions = typeof action === 'string' ? [action] : action;
- var support = !!document.queryCommandSupported;
- actions.forEach(function (action) {
- support = support && !!document.queryCommandSupported(action);
- });
- return support;
- }
- }]);
- return Clipboard;
- }((tiny_emitter_default()));
- /* harmony default export */ var clipboard = (Clipboard);
- /***/ }),
- /***/ 828:
- /***/ (function(module) {
- var DOCUMENT_NODE_TYPE = 9;
- /**
- * A polyfill for Element.matches()
- */
- if (typeof Element !== 'undefined' && !Element.prototype.matches) {
- var proto = Element.prototype;
- proto.matches = proto.matchesSelector ||
- proto.mozMatchesSelector ||
- proto.msMatchesSelector ||
- proto.oMatchesSelector ||
- proto.webkitMatchesSelector;
- }
- /**
- * Finds the closest parent that matches a selector.
- *
- * @param {Element} element
- * @param {String} selector
- * @return {Function}
- */
- function closest (element, selector) {
- while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
- if (typeof element.matches === 'function' &&
- element.matches(selector)) {
- return element;
- }
- element = element.parentNode;
- }
- }
- module.exports = closest;
- /***/ }),
- /***/ 438:
- /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_15749__) {
- var closest = __nested_webpack_require_15749__(828);
- /**
- * Delegates event to a selector.
- *
- * @param {Element} element
- * @param {String} selector
- * @param {String} type
- * @param {Function} callback
- * @param {Boolean} useCapture
- * @return {Object}
- */
- function _delegate(element, selector, type, callback, useCapture) {
- var listenerFn = listener.apply(this, arguments);
- element.addEventListener(type, listenerFn, useCapture);
- return {
- destroy: function() {
- element.removeEventListener(type, listenerFn, useCapture);
- }
- }
- }
- /**
- * Delegates event to a selector.
- *
- * @param {Element|String|Array} [elements]
- * @param {String} selector
- * @param {String} type
- * @param {Function} callback
- * @param {Boolean} useCapture
- * @return {Object}
- */
- function delegate(elements, selector, type, callback, useCapture) {
- // Handle the regular Element usage
- if (typeof elements.addEventListener === 'function') {
- return _delegate.apply(null, arguments);
- }
- // Handle Element-less usage, it defaults to global delegation
- if (typeof type === 'function') {
- // Use `document` as the first parameter, then apply arguments
- // This is a short way to .unshift `arguments` without running into deoptimizations
- return _delegate.bind(null, document).apply(null, arguments);
- }
- // Handle Selector-based usage
- if (typeof elements === 'string') {
- elements = document.querySelectorAll(elements);
- }
- // Handle Array-like based usage
- return Array.prototype.map.call(elements, function (element) {
- return _delegate(element, selector, type, callback, useCapture);
- });
- }
- /**
- * Finds closest match and invokes callback.
- *
- * @param {Element} element
- * @param {String} selector
- * @param {String} type
- * @param {Function} callback
- * @return {Function}
- */
- function listener(element, selector, type, callback) {
- return function(e) {
- e.delegateTarget = closest(e.target, selector);
- if (e.delegateTarget) {
- callback.call(element, e);
- }
- }
- }
- module.exports = delegate;
- /***/ }),
- /***/ 879:
- /***/ (function(__unused_webpack_module, exports) {
- /**
- * Check if argument is a HTML element.
- *
- * @param {Object} value
- * @return {Boolean}
- */
- exports.node = function(value) {
- return value !== undefined
- && value instanceof HTMLElement
- && value.nodeType === 1;
- };
- /**
- * Check if argument is a list of HTML elements.
- *
- * @param {Object} value
- * @return {Boolean}
- */
- exports.nodeList = function(value) {
- var type = Object.prototype.toString.call(value);
- return value !== undefined
- && (type === '[object NodeList]' || type === '[object HTMLCollection]')
- && ('length' in value)
- && (value.length === 0 || exports.node(value[0]));
- };
- /**
- * Check if argument is a string.
- *
- * @param {Object} value
- * @return {Boolean}
- */
- exports.string = function(value) {
- return typeof value === 'string'
- || value instanceof String;
- };
- /**
- * Check if argument is a function.
- *
- * @param {Object} value
- * @return {Boolean}
- */
- exports.fn = function(value) {
- var type = Object.prototype.toString.call(value);
- return type === '[object Function]';
- };
- /***/ }),
- /***/ 370:
- /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_19113__) {
- var is = __nested_webpack_require_19113__(879);
- var delegate = __nested_webpack_require_19113__(438);
- /**
- * Validates all params and calls the right
- * listener function based on its target type.
- *
- * @param {String|HTMLElement|HTMLCollection|NodeList} target
- * @param {String} type
- * @param {Function} callback
- * @return {Object}
- */
- function listen(target, type, callback) {
- if (!target && !type && !callback) {
- throw new Error('Missing required arguments');
- }
- if (!is.string(type)) {
- throw new TypeError('Second argument must be a String');
- }
- if (!is.fn(callback)) {
- throw new TypeError('Third argument must be a Function');
- }
- if (is.node(target)) {
- return listenNode(target, type, callback);
- }
- else if (is.nodeList(target)) {
- return listenNodeList(target, type, callback);
- }
- else if (is.string(target)) {
- return listenSelector(target, type, callback);
- }
- else {
- throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
- }
- }
- /**
- * Adds an event listener to a HTML element
- * and returns a remove listener function.
- *
- * @param {HTMLElement} node
- * @param {String} type
- * @param {Function} callback
- * @return {Object}
- */
- function listenNode(node, type, callback) {
- node.addEventListener(type, callback);
- return {
- destroy: function() {
- node.removeEventListener(type, callback);
- }
- }
- }
- /**
- * Add an event listener to a list of HTML elements
- * and returns a remove listener function.
- *
- * @param {NodeList|HTMLCollection} nodeList
- * @param {String} type
- * @param {Function} callback
- * @return {Object}
- */
- function listenNodeList(nodeList, type, callback) {
- Array.prototype.forEach.call(nodeList, function(node) {
- node.addEventListener(type, callback);
- });
- return {
- destroy: function() {
- Array.prototype.forEach.call(nodeList, function(node) {
- node.removeEventListener(type, callback);
- });
- }
- }
- }
- /**
- * Add an event listener to a selector
- * and returns a remove listener function.
- *
- * @param {String} selector
- * @param {String} type
- * @param {Function} callback
- * @return {Object}
- */
- function listenSelector(selector, type, callback) {
- return delegate(document.body, selector, type, callback);
- }
- module.exports = listen;
- /***/ }),
- /***/ 817:
- /***/ (function(module) {
- function select(element) {
- var selectedText;
- if (element.nodeName === 'SELECT') {
- element.focus();
- selectedText = element.value;
- }
- else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
- var isReadOnly = element.hasAttribute('readonly');
- if (!isReadOnly) {
- element.setAttribute('readonly', '');
- }
- element.select();
- element.setSelectionRange(0, element.value.length);
- if (!isReadOnly) {
- element.removeAttribute('readonly');
- }
- selectedText = element.value;
- }
- else {
- if (element.hasAttribute('contenteditable')) {
- element.focus();
- }
- var selection = window.getSelection();
- var range = document.createRange();
- range.selectNodeContents(element);
- selection.removeAllRanges();
- selection.addRange(range);
- selectedText = selection.toString();
- }
- return selectedText;
- }
- module.exports = select;
- /***/ }),
- /***/ 279:
- /***/ (function(module) {
- function E () {
- // Keep this empty so it's easier to inherit from
- // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
- }
- E.prototype = {
- on: function (name, callback, ctx) {
- var e = this.e || (this.e = {});
- (e[name] || (e[name] = [])).push({
- fn: callback,
- ctx: ctx
- });
- return this;
- },
- once: function (name, callback, ctx) {
- var self = this;
- function listener () {
- self.off(name, listener);
- callback.apply(ctx, arguments);
- };
- listener._ = callback
- return this.on(name, listener, ctx);
- },
- emit: function (name) {
- var data = [].slice.call(arguments, 1);
- var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
- var i = 0;
- var len = evtArr.length;
- for (i; i < len; i++) {
- evtArr[i].fn.apply(evtArr[i].ctx, data);
- }
- return this;
- },
- off: function (name, callback) {
- var e = this.e || (this.e = {});
- var evts = e[name];
- var liveEvents = [];
- if (evts && callback) {
- for (var i = 0, len = evts.length; i < len; i++) {
- if (evts[i].fn !== callback && evts[i].fn._ !== callback)
- liveEvents.push(evts[i]);
- }
- }
- // Remove event from queue to prevent memory leak
- // Suggested by https://github.com/lazd
- // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
- (liveEvents.length)
- ? e[name] = liveEvents
- : delete e[name];
- return this;
- }
- };
- module.exports = E;
- module.exports.TinyEmitter = E;
- /***/ })
- /******/ });
- /************************************************************************/
- /******/ // The module cache
- /******/ var __webpack_module_cache__ = {};
- /******/
- /******/ // The require function
- /******/ function __nested_webpack_require_24495__(moduleId) {
- /******/ // Check if module is in cache
- /******/ if(__webpack_module_cache__[moduleId]) {
- /******/ return __webpack_module_cache__[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = __webpack_module_cache__[moduleId] = {
- /******/ // no module.id needed
- /******/ // no module.loaded needed
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_24495__);
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /************************************************************************/
- /******/ /* webpack/runtime/compat get default export */
- /******/ !function() {
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __nested_webpack_require_24495__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function() { return module['default']; } :
- /******/ function() { return module; };
- /******/ __nested_webpack_require_24495__.d(getter, { a: getter });
- /******/ return getter;
- /******/ };
- /******/ }();
- /******/
- /******/ /* webpack/runtime/define property getters */
- /******/ !function() {
- /******/ // define getter functions for harmony exports
- /******/ __nested_webpack_require_24495__.d = function(exports, definition) {
- /******/ for(var key in definition) {
- /******/ if(__nested_webpack_require_24495__.o(definition, key) && !__nested_webpack_require_24495__.o(exports, key)) {
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
- /******/ }
- /******/ }
- /******/ };
- /******/ }();
- /******/
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
- /******/ !function() {
- /******/ __nested_webpack_require_24495__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
- /******/ }();
- /******/
- /************************************************************************/
- /******/ // module exports must be returned from runtime so entry inlining is disabled
- /******/ // startup
- /******/ // Load entry module and return exports
- /******/ return __nested_webpack_require_24495__(686);
- /******/ })()
- .default;
- });
- /***/ }),
- /***/ 7973:
- /***/ (function(module, exports, __webpack_require__) {
- var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */
- /**
- * Copyright 2012-2017 Craig Campbell
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Mousetrap is a simple keyboard shortcut library for Javascript with
- * no external dependencies
- *
- * @version 1.6.5
- * @url craig.is/killing/mice
- */
- (function(window, document, undefined) {
- // Check if mousetrap is used inside browser, if not, return
- if (!window) {
- return;
- }
- /**
- * mapping of special keycodes to their corresponding keys
- *
- * everything in this dictionary cannot use keypress events
- * so it has to be here to map to the correct keycodes for
- * keyup/keydown events
- *
- * @type {Object}
- */
- var _MAP = {
- 8: 'backspace',
- 9: 'tab',
- 13: 'enter',
- 16: 'shift',
- 17: 'ctrl',
- 18: 'alt',
- 20: 'capslock',
- 27: 'esc',
- 32: 'space',
- 33: 'pageup',
- 34: 'pagedown',
- 35: 'end',
- 36: 'home',
- 37: 'left',
- 38: 'up',
- 39: 'right',
- 40: 'down',
- 45: 'ins',
- 46: 'del',
- 91: 'meta',
- 93: 'meta',
- 224: 'meta'
- };
- /**
- * mapping for special characters so they can support
- *
- * this dictionary is only used incase you want to bind a
- * keyup or keydown event to one of these keys
- *
- * @type {Object}
- */
- var _KEYCODE_MAP = {
- 106: '*',
- 107: '+',
- 109: '-',
- 110: '.',
- 111 : '/',
- 186: ';',
- 187: '=',
- 188: ',',
- 189: '-',
- 190: '.',
- 191: '/',
- 192: '`',
- 219: '[',
- 220: '\\',
- 221: ']',
- 222: '\''
- };
- /**
- * this is a mapping of keys that require shift on a US keypad
- * back to the non shift equivelents
- *
- * this is so you can use keyup events with these keys
- *
- * note that this will only work reliably on US keyboards
- *
- * @type {Object}
- */
- var _SHIFT_MAP = {
- '~': '`',
- '!': '1',
- '@': '2',
- '#': '3',
- '$': '4',
- '%': '5',
- '^': '6',
- '&': '7',
- '*': '8',
- '(': '9',
- ')': '0',
- '_': '-',
- '+': '=',
- ':': ';',
- '\"': '\'',
- '<': ',',
- '>': '.',
- '?': '/',
- '|': '\\'
- };
- /**
- * this is a list of special strings you can use to map
- * to modifier keys when you specify your keyboard shortcuts
- *
- * @type {Object}
- */
- var _SPECIAL_ALIASES = {
- 'option': 'alt',
- 'command': 'meta',
- 'return': 'enter',
- 'escape': 'esc',
- 'plus': '+',
- 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
- };
- /**
- * variable to store the flipped version of _MAP from above
- * needed to check if we should use keypress or not when no action
- * is specified
- *
- * @type {Object|undefined}
- */
- var _REVERSE_MAP;
- /**
- * loop through the f keys, f1 to f19 and add them to the map
- * programatically
- */
- for (var i = 1; i < 20; ++i) {
- _MAP[111 + i] = 'f' + i;
- }
- /**
- * loop through to map numbers on the numeric keypad
- */
- for (i = 0; i <= 9; ++i) {
- // This needs to use a string cause otherwise since 0 is falsey
- // mousetrap will never fire for numpad 0 pressed as part of a keydown
- // event.
- //
- // @see https://github.com/ccampbell/mousetrap/pull/258
- _MAP[i + 96] = i.toString();
- }
- /**
- * cross browser add event method
- *
- * @param {Element|HTMLDocument} object
- * @param {string} type
- * @param {Function} callback
- * @returns void
- */
- function _addEvent(object, type, callback) {
- if (object.addEventListener) {
- object.addEventListener(type, callback, false);
- return;
- }
- object.attachEvent('on' + type, callback);
- }
- /**
- * takes the event and returns the key character
- *
- * @param {Event} e
- * @return {string}
- */
- function _characterFromEvent(e) {
- // for keypress events we should return the character as is
- if (e.type == 'keypress') {
- var character = String.fromCharCode(e.which);
- // if the shift key is not pressed then it is safe to assume
- // that we want the character to be lowercase. this means if
- // you accidentally have caps lock on then your key bindings
- // will continue to work
- //
- // the only side effect that might not be desired is if you
- // bind something like 'A' cause you want to trigger an
- // event when capital A is pressed caps lock will no longer
- // trigger the event. shift+a will though.
- if (!e.shiftKey) {
- character = character.toLowerCase();
- }
- return character;
- }
- // for non keypress events the special maps are needed
- if (_MAP[e.which]) {
- return _MAP[e.which];
- }
- if (_KEYCODE_MAP[e.which]) {
- return _KEYCODE_MAP[e.which];
- }
- // if it is not in the special map
- // with keydown and keyup events the character seems to always
- // come in as an uppercase character whether you are pressing shift
- // or not. we should make sure it is always lowercase for comparisons
- return String.fromCharCode(e.which).toLowerCase();
- }
- /**
- * checks if two arrays are equal
- *
- * @param {Array} modifiers1
- * @param {Array} modifiers2
- * @returns {boolean}
- */
- function _modifiersMatch(modifiers1, modifiers2) {
- return modifiers1.sort().join(',') === modifiers2.sort().join(',');
- }
- /**
- * takes a key event and figures out what the modifiers are
- *
- * @param {Event} e
- * @returns {Array}
- */
- function _eventModifiers(e) {
- var modifiers = [];
- if (e.shiftKey) {
- modifiers.push('shift');
- }
- if (e.altKey) {
- modifiers.push('alt');
- }
- if (e.ctrlKey) {
- modifiers.push('ctrl');
- }
- if (e.metaKey) {
- modifiers.push('meta');
- }
- return modifiers;
- }
- /**
- * prevents default for this event
- *
- * @param {Event} e
- * @returns void
- */
- function _preventDefault(e) {
- if (e.preventDefault) {
- e.preventDefault();
- return;
- }
- e.returnValue = false;
- }
- /**
- * stops propogation for this event
- *
- * @param {Event} e
- * @returns void
- */
- function _stopPropagation(e) {
- if (e.stopPropagation) {
- e.stopPropagation();
- return;
- }
- e.cancelBubble = true;
- }
- /**
- * determines if the keycode specified is a modifier key or not
- *
- * @param {string} key
- * @returns {boolean}
- */
- function _isModifier(key) {
- return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
- }
- /**
- * reverses the map lookup so that we can look for specific keys
- * to see what can and can't use keypress
- *
- * @return {Object}
- */
- function _getReverseMap() {
- if (!_REVERSE_MAP) {
- _REVERSE_MAP = {};
- for (var key in _MAP) {
- // pull out the numeric keypad from here cause keypress should
- // be able to detect the keys from the character
- if (key > 95 && key < 112) {
- continue;
- }
- if (_MAP.hasOwnProperty(key)) {
- _REVERSE_MAP[_MAP[key]] = key;
- }
- }
- }
- return _REVERSE_MAP;
- }
- /**
- * picks the best action based on the key combination
- *
- * @param {string} key - character for key
- * @param {Array} modifiers
- * @param {string=} action passed in
- */
- function _pickBestAction(key, modifiers, action) {
- // if no action was picked in we should try to pick the one
- // that we think would work best for this key
- if (!action) {
- action = _getReverseMap()[key] ? 'keydown' : 'keypress';
- }
- // modifier keys don't work as expected with keypress,
- // switch to keydown
- if (action == 'keypress' && modifiers.length) {
- action = 'keydown';
- }
- return action;
- }
- /**
- * Converts from a string key combination to an array
- *
- * @param {string} combination like "command+shift+l"
- * @return {Array}
- */
- function _keysFromString(combination) {
- if (combination === '+') {
- return ['+'];
- }
- combination = combination.replace(/\+{2}/g, '+plus');
- return combination.split('+');
- }
- /**
- * Gets info for a specific key combination
- *
- * @param {string} combination key combination ("command+s" or "a" or "*")
- * @param {string=} action
- * @returns {Object}
- */
- function _getKeyInfo(combination, action) {
- var keys;
- var key;
- var i;
- var modifiers = [];
- // take the keys from this pattern and figure out what the actual
- // pattern is all about
- keys = _keysFromString(combination);
- for (i = 0; i < keys.length; ++i) {
- key = keys[i];
- // normalize key names
- if (_SPECIAL_ALIASES[key]) {
- key = _SPECIAL_ALIASES[key];
- }
- // if this is not a keypress event then we should
- // be smart about using shift keys
- // this will only work for US keyboards however
- if (action && action != 'keypress' && _SHIFT_MAP[key]) {
- key = _SHIFT_MAP[key];
- modifiers.push('shift');
- }
- // if this key is a modifier then add it to the list of modifiers
- if (_isModifier(key)) {
- modifiers.push(key);
- }
- }
- // depending on what the key combination is
- // we will try to pick the best event for it
- action = _pickBestAction(key, modifiers, action);
- return {
- key: key,
- modifiers: modifiers,
- action: action
- };
- }
- function _belongsTo(element, ancestor) {
- if (element === null || element === document) {
- return false;
- }
- if (element === ancestor) {
- return true;
- }
- return _belongsTo(element.parentNode, ancestor);
- }
- function Mousetrap(targetElement) {
- var self = this;
- targetElement = targetElement || document;
- if (!(self instanceof Mousetrap)) {
- return new Mousetrap(targetElement);
- }
- /**
- * element to attach key events to
- *
- * @type {Element}
- */
- self.target = targetElement;
- /**
- * a list of all the callbacks setup via Mousetrap.bind()
- *
- * @type {Object}
- */
- self._callbacks = {};
- /**
- * direct map of string combinations to callbacks used for trigger()
- *
- * @type {Object}
- */
- self._directMap = {};
- /**
- * keeps track of what level each sequence is at since multiple
- * sequences can start out with the same sequence
- *
- * @type {Object}
- */
- var _sequenceLevels = {};
- /**
- * variable to store the setTimeout call
- *
- * @type {null|number}
- */
- var _resetTimer;
- /**
- * temporary state where we will ignore the next keyup
- *
- * @type {boolean|string}
- */
- var _ignoreNextKeyup = false;
- /**
- * temporary state where we will ignore the next keypress
- *
- * @type {boolean}
- */
- var _ignoreNextKeypress = false;
- /**
- * are we currently inside of a sequence?
- * type of action ("keyup" or "keydown" or "keypress") or false
- *
- * @type {boolean|string}
- */
- var _nextExpectedAction = false;
- /**
- * resets all sequence counters except for the ones passed in
- *
- * @param {Object} doNotReset
- * @returns void
- */
- function _resetSequences(doNotReset) {
- doNotReset = doNotReset || {};
- var activeSequences = false,
- key;
- for (key in _sequenceLevels) {
- if (doNotReset[key]) {
- activeSequences = true;
- continue;
- }
- _sequenceLevels[key] = 0;
- }
- if (!activeSequences) {
- _nextExpectedAction = false;
- }
- }
- /**
- * finds all callbacks that match based on the keycode, modifiers,
- * and action
- *
- * @param {string} character
- * @param {Array} modifiers
- * @param {Event|Object} e
- * @param {string=} sequenceName - name of the sequence we are looking for
- * @param {string=} combination
- * @param {number=} level
- * @returns {Array}
- */
- function _getMatches(character, modifiers, e, sequenceName, combination, level) {
- var i;
- var callback;
- var matches = [];
- var action = e.type;
- // if there are no events related to this keycode
- if (!self._callbacks[character]) {
- return [];
- }
- // if a modifier key is coming up on its own we should allow it
- if (action == 'keyup' && _isModifier(character)) {
- modifiers = [character];
- }
- // loop through all callbacks for the key that was pressed
- // and see if any of them match
- for (i = 0; i < self._callbacks[character].length; ++i) {
- callback = self._callbacks[character][i];
- // if a sequence name is not specified, but this is a sequence at
- // the wrong level then move onto the next match
- if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
- continue;
- }
- // if the action we are looking for doesn't match the action we got
- // then we should keep going
- if (action != callback.action) {
- continue;
- }
- // if this is a keypress event and the meta key and control key
- // are not pressed that means that we need to only look at the
- // character, otherwise check the modifiers as well
- //
- // chrome will not fire a keypress if meta or control is down
- // safari will fire a keypress if meta or meta+shift is down
- // firefox will fire a keypress if meta or control is down
- if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
- // when you bind a combination or sequence a second time it
- // should overwrite the first one. if a sequenceName or
- // combination is specified in this call it does just that
- //
- // @todo make deleting its own method?
- var deleteCombo = !sequenceName && callback.combo == combination;
- var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
- if (deleteCombo || deleteSequence) {
- self._callbacks[character].splice(i, 1);
- }
- matches.push(callback);
- }
- }
- return matches;
- }
- /**
- * actually calls the callback function
- *
- * if your callback function returns false this will use the jquery
- * convention - prevent default and stop propogation on the event
- *
- * @param {Function} callback
- * @param {Event} e
- * @returns void
- */
- function _fireCallback(callback, e, combo, sequence) {
- // if this event should not happen stop here
- if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
- return;
- }
- if (callback(e, combo) === false) {
- _preventDefault(e);
- _stopPropagation(e);
- }
- }
- /**
- * handles a character key event
- *
- * @param {string} character
- * @param {Array} modifiers
- * @param {Event} e
- * @returns void
- */
- self._handleKey = function(character, modifiers, e) {
- var callbacks = _getMatches(character, modifiers, e);
- var i;
- var doNotReset = {};
- var maxLevel = 0;
- var processedSequenceCallback = false;
- // Calculate the maxLevel for sequences so we can only execute the longest callback sequence
- for (i = 0; i < callbacks.length; ++i) {
- if (callbacks[i].seq) {
- maxLevel = Math.max(maxLevel, callbacks[i].level);
- }
- }
- // loop through matching callbacks for this key event
- for (i = 0; i < callbacks.length; ++i) {
- // fire for all sequence callbacks
- // this is because if for example you have multiple sequences
- // bound such as "g i" and "g t" they both need to fire the
- // callback for matching g cause otherwise you can only ever
- // match the first one
- if (callbacks[i].seq) {
- // only fire callbacks for the maxLevel to prevent
- // subsequences from also firing
- //
- // for example 'a option b' should not cause 'option b' to fire
- // even though 'option b' is part of the other sequence
- //
- // any sequences that do not match here will be discarded
- // below by the _resetSequences call
- if (callbacks[i].level != maxLevel) {
- continue;
- }
- processedSequenceCallback = true;
- // keep a list of which sequences were matches for later
- doNotReset[callbacks[i].seq] = 1;
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
- continue;
- }
- // if there were no sequence matches but we are still here
- // that means this is a regular match so we should fire that
- if (!processedSequenceCallback) {
- _fireCallback(callbacks[i].callback, e, callbacks[i].combo);
- }
- }
- // if the key you pressed matches the type of sequence without
- // being a modifier (ie "keyup" or "keypress") then we should
- // reset all sequences that were not matched by this event
- //
- // this is so, for example, if you have the sequence "h a t" and you
- // type "h e a r t" it does not match. in this case the "e" will
- // cause the sequence to reset
- //
- // modifier keys are ignored because you can have a sequence
- // that contains modifiers such as "enter ctrl+space" and in most
- // cases the modifier key will be pressed before the next key
- //
- // also if you have a sequence such as "ctrl+b a" then pressing the
- // "b" key will trigger a "keypress" and a "keydown"
- //
- // the "keydown" is expected when there is a modifier, but the
- // "keypress" ends up matching the _nextExpectedAction since it occurs
- // after and that causes the sequence to reset
- //
- // we ignore keypresses in a sequence that directly follow a keydown
- // for the same character
- var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
- if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
- _resetSequences(doNotReset);
- }
- _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
- };
- /**
- * handles a keydown event
- *
- * @param {Event} e
- * @returns void
- */
- function _handleKeyEvent(e) {
- // normalize e.which for key events
- // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
- if (typeof e.which !== 'number') {
- e.which = e.keyCode;
- }
- var character = _characterFromEvent(e);
- // no character found then stop
- if (!character) {
- return;
- }
- // need to use === for the character check because the character can be 0
- if (e.type == 'keyup' && _ignoreNextKeyup === character) {
- _ignoreNextKeyup = false;
- return;
- }
- self.handleKey(character, _eventModifiers(e), e);
- }
- /**
- * called to set a 1 second timeout on the specified sequence
- *
- * this is so after each key press in the sequence you have 1 second
- * to press the next key before you have to start over
- *
- * @returns void
- */
- function _resetSequenceTimer() {
- clearTimeout(_resetTimer);
- _resetTimer = setTimeout(_resetSequences, 1000);
- }
- /**
- * binds a key sequence to an event
- *
- * @param {string} combo - combo specified in bind call
- * @param {Array} keys
- * @param {Function} callback
- * @param {string=} action
- * @returns void
- */
- function _bindSequence(combo, keys, callback, action) {
- // start off by adding a sequence level record for this combination
- // and setting the level to 0
- _sequenceLevels[combo] = 0;
- /**
- * callback to increase the sequence level for this sequence and reset
- * all other sequences that were active
- *
- * @param {string} nextAction
- * @returns {Function}
- */
- function _increaseSequence(nextAction) {
- return function() {
- _nextExpectedAction = nextAction;
- ++_sequenceLevels[combo];
- _resetSequenceTimer();
- };
- }
- /**
- * wraps the specified callback inside of another function in order
- * to reset all sequence counters as soon as this sequence is done
- *
- * @param {Event} e
- * @returns void
- */
- function _callbackAndReset(e) {
- _fireCallback(callback, e, combo);
- // we should ignore the next key up if the action is key down
- // or keypress. this is so if you finish a sequence and
- // release the key the final key will not trigger a keyup
- if (action !== 'keyup') {
- _ignoreNextKeyup = _characterFromEvent(e);
- }
- // weird race condition if a sequence ends with the key
- // another sequence begins with
- setTimeout(_resetSequences, 10);
- }
- // loop through keys one at a time and bind the appropriate callback
- // function. for any key leading up to the final one it should
- // increase the sequence. after the final, it should reset all sequences
- //
- // if an action is specified in the original bind call then that will
- // be used throughout. otherwise we will pass the action that the
- // next key in the sequence should match. this allows a sequence
- // to mix and match keypress and keydown events depending on which
- // ones are better suited to the key provided
- for (var i = 0; i < keys.length; ++i) {
- var isFinal = i + 1 === keys.length;
- var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
- _bindSingle(keys[i], wrappedCallback, action, combo, i);
- }
- }
- /**
- * binds a single keyboard combination
- *
- * @param {string} combination
- * @param {Function} callback
- * @param {string=} action
- * @param {string=} sequenceName - name of sequence if part of sequence
- * @param {number=} level - what part of the sequence the command is
- * @returns void
- */
- function _bindSingle(combination, callback, action, sequenceName, level) {
- // store a direct mapped reference for use with Mousetrap.trigger
- self._directMap[combination + ':' + action] = callback;
- // make sure multiple spaces in a row become a single space
- combination = combination.replace(/\s+/g, ' ');
- var sequence = combination.split(' ');
- var info;
- // if this pattern is a sequence of keys then run through this method
- // to reprocess each pattern one key at a time
- if (sequence.length > 1) {
- _bindSequence(combination, sequence, callback, action);
- return;
- }
- info = _getKeyInfo(combination, action);
- // make sure to initialize array if this is the first time
- // a callback is added for this key
- self._callbacks[info.key] = self._callbacks[info.key] || [];
- // remove an existing match if there is one
- _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
- // add this call back to the array
- // if it is a sequence put it at the beginning
- // if not put it at the end
- //
- // this is important because the way these are processed expects
- // the sequence ones to come first
- self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({
- callback: callback,
- modifiers: info.modifiers,
- action: info.action,
- seq: sequenceName,
- level: level,
- combo: combination
- });
- }
- /**
- * binds multiple combinations to the same callback
- *
- * @param {Array} combinations
- * @param {Function} callback
- * @param {string|undefined} action
- * @returns void
- */
- self._bindMultiple = function(combinations, callback, action) {
- for (var i = 0; i < combinations.length; ++i) {
- _bindSingle(combinations[i], callback, action);
- }
- };
- // start!
- _addEvent(targetElement, 'keypress', _handleKeyEvent);
- _addEvent(targetElement, 'keydown', _handleKeyEvent);
- _addEvent(targetElement, 'keyup', _handleKeyEvent);
- }
- /**
- * binds an event to mousetrap
- *
- * can be a single key, a combination of keys separated with +,
- * an array of keys, or a sequence of keys separated by spaces
- *
- * be sure to list the modifier keys first to make sure that the
- * correct key ends up getting bound (the last key in the pattern)
- *
- * @param {string|Array} keys
- * @param {Function} callback
- * @param {string=} action - 'keypress', 'keydown', or 'keyup'
- * @returns void
- */
- Mousetrap.prototype.bind = function(keys, callback, action) {
- var self = this;
- keys = keys instanceof Array ? keys : [keys];
- self._bindMultiple.call(self, keys, callback, action);
- return self;
- };
- /**
- * unbinds an event to mousetrap
- *
- * the unbinding sets the callback function of the specified key combo
- * to an empty function and deletes the corresponding key in the
- * _directMap dict.
- *
- * TODO: actually remove this from the _callbacks dictionary instead
- * of binding an empty function
- *
- * the keycombo+action has to be exactly the same as
- * it was defined in the bind method
- *
- * @param {string|Array} keys
- * @param {string} action
- * @returns void
- */
- Mousetrap.prototype.unbind = function(keys, action) {
- var self = this;
- return self.bind.call(self, keys, function() {}, action);
- };
- /**
- * triggers an event that has already been bound
- *
- * @param {string} keys
- * @param {string=} action
- * @returns void
- */
- Mousetrap.prototype.trigger = function(keys, action) {
- var self = this;
- if (self._directMap[keys + ':' + action]) {
- self._directMap[keys + ':' + action]({}, keys);
- }
- return self;
- };
- /**
- * resets the library back to its initial state. this is useful
- * if you want to clear out the current keyboard shortcuts and bind
- * new ones - for example if you switch to another page
- *
- * @returns void
- */
- Mousetrap.prototype.reset = function() {
- var self = this;
- self._callbacks = {};
- self._directMap = {};
- return self;
- };
- /**
- * should we stop this event before firing off callbacks
- *
- * @param {Event} e
- * @param {Element} element
- * @return {boolean}
- */
- Mousetrap.prototype.stopCallback = function(e, element) {
- var self = this;
- // if the element has the class "mousetrap" then no need to stop
- if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
- return false;
- }
- if (_belongsTo(element, self.target)) {
- return false;
- }
- // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host,
- // not the initial event target in the shadow tree. Note that not all events cross the
- // shadow boundary.
- // For shadow trees with `mode: 'open'`, the initial event target is the first element in
- // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event
- // target cannot be obtained.
- if ('composedPath' in e && typeof e.composedPath === 'function') {
- // For open shadow trees, update `element` so that the following check works.
- var initialEventTarget = e.composedPath()[0];
- if (initialEventTarget !== e.target) {
- element = initialEventTarget;
- }
- }
- // stop for input, select, and textarea
- return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
- };
- /**
- * exposes _handleKey publicly so it can be overwritten by extensions
- */
- Mousetrap.prototype.handleKey = function() {
- var self = this;
- return self._handleKey.apply(self, arguments);
- };
- /**
- * allow custom key mappings
- */
- Mousetrap.addKeycodes = function(object) {
- for (var key in object) {
- if (object.hasOwnProperty(key)) {
- _MAP[key] = object[key];
- }
- }
- _REVERSE_MAP = null;
- };
- /**
- * Init the global mousetrap functions
- *
- * This method is needed to allow the global mousetrap functions to work
- * now that mousetrap is a constructor function.
- */
- Mousetrap.init = function() {
- var documentMousetrap = Mousetrap(document);
- for (var method in documentMousetrap) {
- if (method.charAt(0) !== '_') {
- Mousetrap[method] = (function(method) {
- return function() {
- return documentMousetrap[method].apply(documentMousetrap, arguments);
- };
- } (method));
- }
- }
- };
- Mousetrap.init();
- // expose mousetrap to the global object
- window.Mousetrap = Mousetrap;
- // expose as a common js module
- if ( true && module.exports) {
- module.exports = Mousetrap;
- }
- // expose mousetrap as an AMD module
- if (true) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
- return Mousetrap;
- }).call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- }
- }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null);
- /***/ }),
- /***/ 5538:
- /***/ (function() {
- /**
- * adds a bindGlobal method to Mousetrap that allows you to
- * bind specific keyboard shortcuts that will still work
- * inside a text input field
- *
- * usage:
- * Mousetrap.bindGlobal('ctrl+s', _saveChanges);
- */
- /* global Mousetrap:true */
- (function(Mousetrap) {
- if (! Mousetrap) {
- return;
- }
- var _globalCallbacks = {};
- var _originalStopCallback = Mousetrap.prototype.stopCallback;
- Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) {
- var self = this;
- if (self.paused) {
- return true;
- }
- if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
- return false;
- }
- return _originalStopCallback.call(self, e, element, combo);
- };
- Mousetrap.prototype.bindGlobal = function(keys, callback, action) {
- var self = this;
- self.bind(keys, callback, action);
- if (keys instanceof Array) {
- for (var i = 0; i < keys.length; i++) {
- _globalCallbacks[keys[i]] = true;
- }
- return;
- }
- _globalCallbacks[keys] = true;
- };
- Mousetrap.init();
- }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined);
- /***/ })
- /******/ });
- /************************************************************************/
- /******/ // The module cache
- /******/ var __webpack_module_cache__ = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
- /******/ if (cachedModule !== undefined) {
- /******/ return cachedModule.exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = __webpack_module_cache__[moduleId] = {
- /******/ // no module.id needed
- /******/ // no module.loaded needed
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /************************************************************************/
- /******/ /* webpack/runtime/compat get default export */
- /******/ !function() {
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function() { return module['default']; } :
- /******/ function() { return module; };
- /******/ __webpack_require__.d(getter, { a: getter });
- /******/ return getter;
- /******/ };
- /******/ }();
- /******/
- /******/ /* webpack/runtime/define property getters */
- /******/ !function() {
- /******/ // define getter functions for harmony exports
- /******/ __webpack_require__.d = function(exports, definition) {
- /******/ for(var key in definition) {
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
- /******/ }
- /******/ }
- /******/ };
- /******/ }();
- /******/
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
- /******/ !function() {
- /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
- /******/ }();
- /******/
- /******/ /* webpack/runtime/make namespace object */
- /******/ !function() {
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/ }();
- /******/
- /************************************************************************/
- var __webpack_exports__ = {};
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
- !function() {
- "use strict";
- // ESM COMPAT FLAG
- __webpack_require__.r(__webpack_exports__);
- // EXPORTS
- __webpack_require__.d(__webpack_exports__, {
- "__experimentalUseDialog": function() { return /* reexport */ use_dialog; },
- "__experimentalUseDragging": function() { return /* reexport */ useDragging; },
- "__experimentalUseDropZone": function() { return /* reexport */ useDropZone; },
- "__experimentalUseFixedWindowList": function() { return /* reexport */ useFixedWindowList; },
- "__experimentalUseFocusOutside": function() { return /* reexport */ useFocusOutside; },
- "compose": function() { return /* reexport */ compose; },
- "createHigherOrderComponent": function() { return /* reexport */ createHigherOrderComponent; },
- "ifCondition": function() { return /* reexport */ if_condition; },
- "pure": function() { return /* reexport */ higher_order_pure; },
- "useAsyncList": function() { return /* reexport */ use_async_list; },
- "useConstrainedTabbing": function() { return /* reexport */ use_constrained_tabbing; },
- "useCopyOnClick": function() { return /* reexport */ useCopyOnClick; },
- "useCopyToClipboard": function() { return /* reexport */ useCopyToClipboard; },
- "useDebounce": function() { return /* reexport */ useDebounce; },
- "useDisabled": function() { return /* reexport */ useDisabled; },
- "useFocusOnMount": function() { return /* reexport */ useFocusOnMount; },
- "useFocusReturn": function() { return /* reexport */ use_focus_return; },
- "useFocusableIframe": function() { return /* reexport */ useFocusableIframe; },
- "useInstanceId": function() { return /* reexport */ useInstanceId; },
- "useIsomorphicLayoutEffect": function() { return /* reexport */ use_isomorphic_layout_effect; },
- "useKeyboardShortcut": function() { return /* reexport */ use_keyboard_shortcut; },
- "useMediaQuery": function() { return /* reexport */ useMediaQuery; },
- "useMergeRefs": function() { return /* reexport */ useMergeRefs; },
- "usePrevious": function() { return /* reexport */ usePrevious; },
- "useReducedMotion": function() { return /* reexport */ use_reduced_motion; },
- "useRefEffect": function() { return /* reexport */ useRefEffect; },
- "useResizeObserver": function() { return /* reexport */ useResizeAware; },
- "useThrottle": function() { return /* reexport */ useThrottle; },
- "useViewportMatch": function() { return /* reexport */ use_viewport_match; },
- "useWarnOnChange": function() { return /* reexport */ use_warn_on_change; },
- "withGlobalEvents": function() { return /* reexport */ withGlobalEvents; },
- "withInstanceId": function() { return /* reexport */ with_instance_id; },
- "withSafeTimeout": function() { return /* reexport */ with_safe_timeout; },
- "withState": function() { return /* reexport */ withState; }
- });
- ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation.
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
- ***************************************************************************** */
- /* global Reflect, Promise */
- var extendStatics = function(d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- function __extends(d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
- var __assign = function() {
- __assign = Object.assign || function __assign(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- return t;
- }
- return __assign.apply(this, arguments);
- }
- function __rest(s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
- }
- function __decorate(decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- }
- function __param(paramIndex, decorator) {
- return function (target, key) { decorator(target, key, paramIndex); }
- }
- function __metadata(metadataKey, metadataValue) {
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
- }
- function __awaiter(thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- }
- function __generator(thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- }
- var __createBinding = Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- function __exportStar(m, o) {
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
- }
- function __values(o) {
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- }
- function __read(o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- }
- /** @deprecated */
- function __spread() {
- for (var ar = [], i = 0; i < arguments.length; i++)
- ar = ar.concat(__read(arguments[i]));
- return ar;
- }
- /** @deprecated */
- function __spreadArrays() {
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
- r[k] = a[j];
- return r;
- }
- function __spreadArray(to, from, pack) {
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
- if (ar || !(i in from)) {
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
- ar[i] = from[i];
- }
- }
- return to.concat(ar || Array.prototype.slice.call(from));
- }
- function __await(v) {
- return this instanceof __await ? (this.v = v, this) : new __await(v);
- }
- function __asyncGenerator(thisArg, _arguments, generator) {
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
- function fulfill(value) { resume("next", value); }
- function reject(value) { resume("throw", value); }
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
- }
- function __asyncDelegator(o) {
- var i, p;
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
- }
- function __asyncValues(o) {
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
- var m = o[Symbol.asyncIterator], i;
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
- }
- function __makeTemplateObject(cooked, raw) {
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
- return cooked;
- };
- var __setModuleDefault = Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- };
- function __importStar(mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- }
- function __importDefault(mod) {
- return (mod && mod.__esModule) ? mod : { default: mod };
- }
- function __classPrivateFieldGet(receiver, state, kind, f) {
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
- }
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
- if (kind === "m") throw new TypeError("Private method is not writable");
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
- }
- ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
- /**
- * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
- */
- var SUPPORTED_LOCALE = {
- tr: {
- regexp: /\u0130|\u0049|\u0049\u0307/g,
- map: {
- İ: "\u0069",
- I: "\u0131",
- İ: "\u0069",
- },
- },
- az: {
- regexp: /\u0130/g,
- map: {
- İ: "\u0069",
- I: "\u0131",
- İ: "\u0069",
- },
- },
- lt: {
- regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
- map: {
- I: "\u0069\u0307",
- J: "\u006A\u0307",
- Į: "\u012F\u0307",
- Ì: "\u0069\u0307\u0300",
- Í: "\u0069\u0307\u0301",
- Ĩ: "\u0069\u0307\u0303",
- },
- },
- };
- /**
- * Localized lower case.
- */
- function localeLowerCase(str, locale) {
- var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
- if (lang)
- return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
- return lowerCase(str);
- }
- /**
- * Lower case as a function.
- */
- function lowerCase(str) {
- return str.toLowerCase();
- }
- ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
- // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
- var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
- // Remove all non-word characters.
- var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
- /**
- * Normalize the string into something other libraries can manipulate easier.
- */
- function noCase(input, options) {
- if (options === void 0) { options = {}; }
- var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
- var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
- var start = 0;
- var end = result.length;
- // Trim the delimiter from around the output string.
- while (result.charAt(start) === "\0")
- start++;
- while (result.charAt(end - 1) === "\0")
- end--;
- // Transform each token independently.
- return result.slice(start, end).split("\0").map(transform).join(delimiter);
- }
- /**
- * Replace `re` in the input string with the replacement value.
- */
- function replace(input, re, value) {
- if (re instanceof RegExp)
- return input.replace(re, value);
- return re.reduce(function (input, re) { return input.replace(re, value); }, input);
- }
- ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
- function pascalCaseTransform(input, index) {
- var firstChar = input.charAt(0);
- var lowerChars = input.substr(1).toLowerCase();
- if (index > 0 && firstChar >= "0" && firstChar <= "9") {
- return "_" + firstChar + lowerChars;
- }
- return "" + firstChar.toUpperCase() + lowerChars;
- }
- function pascalCaseTransformMerge(input) {
- return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
- }
- function pascalCase(input, options) {
- if (options === void 0) { options = {}; }
- return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js
- /**
- * External dependencies
- */
- /**
- * Given a function mapping a component to an enhanced component and modifier
- * name, returns the enhanced component augmented with a generated displayName.
- *
- * @param mapComponent Function mapping component to enhanced component.
- * @param modifierName Seed name from which to generated display name.
- *
- * @return Component class with generated display name assigned.
- */
- function createHigherOrderComponent(mapComponent, modifierName) {
- return Inner => {
- const Outer = mapComponent(Inner);
- Outer.displayName = hocName(modifierName, Inner);
- return Outer;
- };
- }
- /**
- * Returns a displayName for a higher-order component, given a wrapper name.
- *
- * @example
- * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)';
- * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)';
- *
- * @param name Name assigned to higher-order component's wrapper component.
- * @param Inner Wrapped component inside higher-order component.
- * @return Wrapped name of higher-order component.
- */
- const hocName = (name, Inner) => {
- const inner = Inner.displayName || Inner.name || 'Component';
- const outer = pascalCase(name !== null && name !== void 0 ? name : '');
- return `${outer}(${inner})`;
- };
- ;// CONCATENATED MODULE: external "lodash"
- var external_lodash_namespaceObject = window["lodash"];
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/compose.js
- /**
- * External dependencies
- */
- /**
- * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function
- * composition, where each successive invocation is supplied the return value of the previous.
- *
- * This is just a re-export of `lodash`'s `flowRight` function.
- *
- * @see https://docs-lodash.com/v4/flow-right/
- */
- /* harmony default export */ var compose = (external_lodash_namespaceObject.flowRight);
- ;// CONCATENATED MODULE: external ["wp","element"]
- var external_wp_element_namespaceObject = window["wp"]["element"];
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js
- /**
- * External dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * Higher-order component creator, creating a new component which renders if
- * the given condition is satisfied or with the given optional prop name.
- *
- * @example
- * ```ts
- * type Props = { foo: string };
- * const Component = ( props: Props ) => <div>{ props.foo }</div>;
- * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );
- * <ConditionalComponent foo="" />; // => null
- * <ConditionalComponent foo="bar" />; // => <div>bar</div>;
- * ```
- *
- * @param predicate Function to test condition.
- *
- * @return Higher-order component.
- */
- function ifCondition(predicate) {
- return createHigherOrderComponent(WrappedComponent => props => {
- if (!predicate(props)) {
- return null;
- }
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, props);
- }, 'ifCondition');
- }
- /* harmony default export */ var if_condition = (ifCondition);
- ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
- var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
- var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * Given a component returns the enhanced component augmented with a component
- * only re-rendering when its props/state change
- */
- const pure = createHigherOrderComponent(function (WrappedComponent) {
- if (WrappedComponent.prototype instanceof external_wp_element_namespaceObject.Component) {
- return class extends WrappedComponent {
- shouldComponentUpdate(nextProps, nextState) {
- return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state);
- }
- };
- }
- return class extends external_wp_element_namespaceObject.Component {
- shouldComponentUpdate(nextProps) {
- return !external_wp_isShallowEqual_default()(nextProps, this.props);
- }
- render() {
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, this.props);
- }
- };
- }, 'pure');
- /* harmony default export */ var higher_order_pure = (pure);
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
- function _extends() {
- _extends = Object.assign ? Object.assign.bind() : function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- return target;
- };
- return _extends.apply(this, arguments);
- }
- ;// CONCATENATED MODULE: external ["wp","deprecated"]
- var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
- var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js
- /**
- * External dependencies
- */
- /**
- * Class responsible for orchestrating event handling on the global window,
- * binding a single event to be shared across all handling instances, and
- * removing the handler when no instances are listening for the event.
- */
- class Listener {
- constructor() {
- /** @type {any} */
- this.listeners = {};
- this.handleEvent = this.handleEvent.bind(this);
- }
- add(
- /** @type {any} */
- eventType,
- /** @type {any} */
- instance) {
- if (!this.listeners[eventType]) {
- // Adding first listener for this type, so bind event.
- window.addEventListener(eventType, this.handleEvent);
- this.listeners[eventType] = [];
- }
- this.listeners[eventType].push(instance);
- }
- remove(
- /** @type {any} */
- eventType,
- /** @type {any} */
- instance) {
- this.listeners[eventType] = (0,external_lodash_namespaceObject.without)(this.listeners[eventType], instance);
- if (!this.listeners[eventType].length) {
- // Removing last listener for this type, so unbind event.
- window.removeEventListener(eventType, this.handleEvent);
- delete this.listeners[eventType];
- }
- }
- handleEvent(
- /** @type {any} */
- event) {
- var _this$listeners$event;
- (_this$listeners$event = this.listeners[event.type]) === null || _this$listeners$event === void 0 ? void 0 : _this$listeners$event.forEach((
- /** @type {any} */
- instance) => {
- instance.handleEvent(event);
- });
- }
- }
- /* harmony default export */ var listener = (Listener);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * Listener instance responsible for managing document event handling.
- */
- const with_global_events_listener = new listener();
- /* eslint-disable jsdoc/no-undefined-types */
- /**
- * Higher-order component creator which, given an object of DOM event types and
- * values corresponding to a callback function name on the component, will
- * create or update a window event handler to invoke the callback when an event
- * occurs. On behalf of the consuming developer, the higher-order component
- * manages unbinding when the component unmounts, and binding at most a single
- * event handler for the entire application.
- *
- * @deprecated
- *
- * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM
- * event type, the value a
- * name of the function on
- * the original component's
- * instance which handles
- * the event.
- *
- * @return {any} Higher-order component.
- */
- function withGlobalEvents(eventTypesToHandlers) {
- external_wp_deprecated_default()('wp.compose.withGlobalEvents', {
- since: '5.7',
- alternative: 'useEffect'
- }); // @ts-ignore We don't need to fix the type-related issues because this is deprecated.
- return createHigherOrderComponent(WrappedComponent => {
- class Wrapper extends external_wp_element_namespaceObject.Component {
- constructor(
- /** @type {any} */
- props) {
- super(props);
- this.handleEvent = this.handleEvent.bind(this);
- this.handleRef = this.handleRef.bind(this);
- }
- componentDidMount() {
- Object.keys(eventTypesToHandlers).forEach(eventType => {
- with_global_events_listener.add(eventType, this);
- });
- }
- componentWillUnmount() {
- Object.keys(eventTypesToHandlers).forEach(eventType => {
- with_global_events_listener.remove(eventType, this);
- });
- }
- handleEvent(
- /** @type {any} */
- event) {
- const handler = eventTypesToHandlers[
- /** @type {keyof GlobalEventHandlersEventMap} */
- event.type
- /* eslint-enable jsdoc/no-undefined-types */
- ];
- if (typeof this.wrappedRef[handler] === 'function') {
- this.wrappedRef[handler](event);
- }
- }
- handleRef(
- /** @type {any} */
- el) {
- this.wrappedRef = el; // Any component using `withGlobalEvents` that is not setting a `ref`
- // will cause `this.props.forwardedRef` to be `null`, so we need this
- // check.
- if (this.props.forwardedRef) {
- this.props.forwardedRef(el);
- }
- }
- render() {
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, this.props.ownProps, {
- ref: this.handleRef
- }));
- }
- }
- return (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
- return (0,external_wp_element_namespaceObject.createElement)(Wrapper, {
- ownProps: props,
- forwardedRef: ref
- });
- });
- }, 'withGlobalEvents');
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js
- // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
- // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
- /* eslint-disable jsdoc/check-types */
- /**
- * WordPress dependencies
- */
- /**
- * @type {WeakMap<object, number>}
- */
- const instanceMap = new WeakMap();
- /**
- * Creates a new id for a given object.
- *
- * @param {object} object Object reference to create an id for.
- * @return {number} The instance id (index).
- */
- function createId(object) {
- const instances = instanceMap.get(object) || 0;
- instanceMap.set(object, instances + 1);
- return instances;
- }
- /**
- * Provides a unique instance ID.
- *
- * @param {object} object Object reference to create an id for.
- * @param {string} [prefix] Prefix for the unique id.
- * @param {string | number} [preferredId=''] Default ID to use.
- * @return {string | number} The unique instance id.
- */
- function useInstanceId(object, prefix) {
- let preferredId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
- return (0,external_wp_element_namespaceObject.useMemo)(() => {
- if (preferredId) return preferredId;
- const id = createId(object);
- return prefix ? `${prefix}-${id}` : id;
- }, [object]);
- }
- /* eslint-enable jsdoc/check-types */
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js
- /**
- * Internal dependencies
- */
- /**
- * A Higher Order Component used to be provide a unique instance ID by
- * component.
- */
- const withInstanceId = createHigherOrderComponent(WrappedComponent => {
- return props => {
- const instanceId = useInstanceId(WrappedComponent); // @ts-ignore
- return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, _extends({}, props, {
- instanceId: instanceId
- }));
- };
- }, 'instanceId');
- /* harmony default export */ var with_instance_id = (withInstanceId);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`
- * types here because those functions include functionality that is not handled
- * by this component, like the ability to pass extra arguments.
- *
- * In the case of this component, we only handle the simplest case where
- * `setTimeout` only accepts a function (not a string) and an optional delay.
- */
- /**
- * A higher-order component used to provide and manage delayed function calls
- * that ought to be bound to a component's lifecycle.
- */
- const withSafeTimeout = createHigherOrderComponent(OriginalComponent => {
- return class WrappedComponent extends external_wp_element_namespaceObject.Component {
- constructor(props) {
- super(props);
- this.timeouts = [];
- this.setTimeout = this.setTimeout.bind(this);
- this.clearTimeout = this.clearTimeout.bind(this);
- }
- componentWillUnmount() {
- this.timeouts.forEach(clearTimeout);
- }
- setTimeout(fn, delay) {
- const id = setTimeout(() => {
- fn();
- this.clearTimeout(id);
- }, delay);
- this.timeouts.push(id);
- return id;
- }
- clearTimeout(id) {
- clearTimeout(id);
- this.timeouts = (0,external_lodash_namespaceObject.without)(this.timeouts, id);
- }
- render() {
- return (// @ts-ignore
- (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, this.props, {
- setTimeout: this.setTimeout,
- clearTimeout: this.clearTimeout
- }))
- );
- }
- };
- }, 'withSafeTimeout');
- /* harmony default export */ var with_safe_timeout = (withSafeTimeout);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * A Higher Order Component used to provide and manage internal component state
- * via props.
- *
- * @deprecated Use `useState` instead.
- *
- * @param {any} initialState Optional initial state of the component.
- *
- * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props.
- */
- function withState() {
- let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- external_wp_deprecated_default()('wp.compose.withState', {
- since: '5.8',
- alternative: 'wp.element.useState'
- });
- return createHigherOrderComponent(OriginalComponent => {
- return class WrappedComponent extends external_wp_element_namespaceObject.Component {
- constructor(
- /** @type {any} */
- props) {
- super(props);
- this.setState = this.setState.bind(this);
- this.state = initialState;
- }
- render() {
- return (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, this.props, this.state, {
- setState: this.setState
- }));
- }
- };
- }, 'withState');
- }
- ;// CONCATENATED MODULE: external ["wp","keycodes"]
- var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
- ;// CONCATENATED MODULE: external ["wp","dom"]
- var external_wp_dom_namespaceObject = window["wp"]["dom"];
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Effect-like ref callback. Just like with `useEffect`, this allows you to
- * return a cleanup function to be run if the ref changes or one of the
- * dependencies changes. The ref is provided as an argument to the callback
- * functions. The main difference between this and `useEffect` is that
- * the `useEffect` callback is not called when the ref changes, but this is.
- * Pass the returned ref callback as the component's ref and merge multiple refs
- * with `useMergeRefs`.
- *
- * It's worth noting that if the dependencies array is empty, there's not
- * strictly a need to clean up event handlers for example, because the node is
- * to be removed. It *is* necessary if you add dependencies because the ref
- * callback will be called multiple times for the same node.
- *
- * @param callback Callback with ref as argument.
- * @param dependencies Dependencies of the callback.
- *
- * @return Ref callback.
- */
- function useRefEffect(callback, dependencies) {
- const cleanup = (0,external_wp_element_namespaceObject.useRef)();
- return (0,external_wp_element_namespaceObject.useCallback)(node => {
- if (node) {
- cleanup.current = callback(node);
- } else if (cleanup.current) {
- cleanup.current();
- }
- }, dependencies);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * In Dialogs/modals, the tabbing must be constrained to the content of
- * the wrapper element. This hook adds the behavior to the returned ref.
- *
- * @return {import('react').RefCallback<Element>} Element Ref.
- *
- * @example
- * ```js
- * import { useConstrainedTabbing } from '@wordpress/compose';
- *
- * const ConstrainedTabbingExample = () => {
- * const constrainedTabbingRef = useConstrainedTabbing()
- * return (
- * <div ref={ constrainedTabbingRef }>
- * <Button />
- * <Button />
- * </div>
- * );
- * }
- * ```
- */
- function useConstrainedTabbing() {
- return useRefEffect((
- /** @type {HTMLElement} */
- node) => {
- /** @type {number|undefined} */
- let timeoutId;
- function onKeyDown(
- /** @type {KeyboardEvent} */
- event) {
- const {
- keyCode,
- shiftKey,
- target
- } = event;
- if (keyCode !== external_wp_keycodes_namespaceObject.TAB) {
- return;
- }
- const action = shiftKey ? 'findPrevious' : 'findNext';
- const nextElement = external_wp_dom_namespaceObject.focus.tabbable[action](
- /** @type {HTMLElement} */
- target) || null; // If the element that is about to receive focus is outside the
- // area, move focus to a div and insert it at the start or end of
- // the area, depending on the direction. Without preventing default
- // behaviour, the browser will then move focus to the next element.
- if (node.contains(nextElement)) {
- return;
- }
- const domAction = shiftKey ? 'append' : 'prepend';
- const {
- ownerDocument
- } = node;
- const trap = ownerDocument.createElement('div');
- trap.tabIndex = -1;
- node[domAction](trap);
- trap.focus(); // Remove after the browser moves focus to the next element.
- timeoutId = setTimeout(() => node.removeChild(trap));
- }
- node.addEventListener('keydown', onKeyDown);
- return () => {
- node.removeEventListener('keydown', onKeyDown);
- clearTimeout(timeoutId);
- };
- }, []);
- }
- /* harmony default export */ var use_constrained_tabbing = (useConstrainedTabbing);
- // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js
- var dist_clipboard = __webpack_require__(8294);
- var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /* eslint-disable jsdoc/no-undefined-types */
- /**
- * Copies the text to the clipboard when the element is clicked.
- *
- * @deprecated
- *
- * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.
- * @param {string|Function} text The text to copy.
- * @param {number} [timeout] Optional timeout to reset the returned
- * state. 4 seconds by default.
- *
- * @return {boolean} Whether or not the text has been copied. Resets after the
- * timeout.
- */
- function useCopyOnClick(ref, text) {
- let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4000;
- /* eslint-enable jsdoc/no-undefined-types */
- external_wp_deprecated_default()('wp.compose.useCopyOnClick', {
- since: '5.8',
- alternative: 'wp.compose.useCopyToClipboard'
- });
- /** @type {import('react').MutableRefObject<Clipboard | undefined>} */
- const clipboard = (0,external_wp_element_namespaceObject.useRef)();
- const [hasCopied, setHasCopied] = (0,external_wp_element_namespaceObject.useState)(false);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- /** @type {number | undefined} */
- let timeoutId;
- if (!ref.current) {
- return;
- } // Clipboard listens to click events.
- clipboard.current = new (clipboard_default())(ref.current, {
- text: () => typeof text === 'function' ? text() : text
- });
- clipboard.current.on('success', _ref => {
- let {
- clearSelection,
- trigger
- } = _ref;
- // Clearing selection will move focus back to the triggering button,
- // ensuring that it is not reset to the body, and further that it is
- // kept within the rendered node.
- clearSelection(); // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
- if (trigger) {
- /** @type {HTMLElement} */
- trigger.focus();
- }
- if (timeout) {
- setHasCopied(true);
- clearTimeout(timeoutId);
- timeoutId = setTimeout(() => setHasCopied(false), timeout);
- }
- });
- return () => {
- if (clipboard.current) {
- clipboard.current.destroy();
- }
- clearTimeout(timeoutId);
- };
- }, [text, timeout, setHasCopied]);
- return hasCopied;
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * @template T
- * @param {T} value
- * @return {import('react').RefObject<T>} The updated ref
- */
- function useUpdatedRef(value) {
- const ref = (0,external_wp_element_namespaceObject.useRef)(value);
- ref.current = value;
- return ref;
- }
- /**
- * Copies the given text to the clipboard when the element is clicked.
- *
- * @template {HTMLElement} TElementType
- * @param {string | (() => string)} text The text to copy. Use a function if not
- * already available and expensive to compute.
- * @param {Function} onSuccess Called when to text is copied.
- *
- * @return {import('react').Ref<TElementType>} A ref to assign to the target element.
- */
- function useCopyToClipboard(text, onSuccess) {
- // Store the dependencies as refs and continuously update them so they're
- // fresh when the callback is called.
- const textRef = useUpdatedRef(text);
- const onSuccessRef = useUpdatedRef(onSuccess);
- return useRefEffect(node => {
- // Clipboard listens to click events.
- const clipboard = new (clipboard_default())(node, {
- text() {
- return typeof textRef.current === 'function' ? textRef.current() : textRef.current || '';
- }
- });
- clipboard.on('success', _ref => {
- let {
- clearSelection
- } = _ref;
- // Clearing selection will move focus back to the triggering
- // button, ensuring that it is not reset to the body, and
- // further that it is kept within the rendered node.
- clearSelection(); // Handle ClipboardJS focus bug, see
- // https://github.com/zenorocha/clipboard.js/issues/680
- node.focus();
- if (onSuccessRef.current) {
- onSuccessRef.current();
- }
- });
- return () => {
- clipboard.destroy();
- };
- }, []);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Hook used to focus the first tabbable element on mount.
- *
- * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode.
- * @return {import('react').RefCallback<HTMLElement>} Ref callback.
- *
- * @example
- * ```js
- * import { useFocusOnMount } from '@wordpress/compose';
- *
- * const WithFocusOnMount = () => {
- * const ref = useFocusOnMount()
- * return (
- * <div ref={ ref }>
- * <Button />
- * <Button />
- * </div>
- * );
- * }
- * ```
- */
- function useFocusOnMount() {
- let focusOnMount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'firstElement';
- const focusOnMountRef = (0,external_wp_element_namespaceObject.useRef)(focusOnMount);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- focusOnMountRef.current = focusOnMount;
- }, [focusOnMount]);
- return (0,external_wp_element_namespaceObject.useCallback)(node => {
- var _node$ownerDocument$a, _node$ownerDocument;
- if (!node || focusOnMountRef.current === false) {
- return;
- }
- if (node.contains((_node$ownerDocument$a = (_node$ownerDocument = node.ownerDocument) === null || _node$ownerDocument === void 0 ? void 0 : _node$ownerDocument.activeElement) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null)) {
- return;
- }
- let target = node;
- if (focusOnMountRef.current === 'firstElement') {
- const firstTabbable = external_wp_dom_namespaceObject.focus.tabbable.find(node)[0];
- if (firstTabbable) {
- target =
- /** @type {HTMLElement} */
- firstTabbable;
- }
- }
- target.focus({
- // When focusing newly mounted dialogs,
- // the position of the popover is often not right on the first render
- // This prevents the layout shifts when focusing the dialogs.
- preventScroll: true
- });
- }, []);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js
- /**
- * WordPress dependencies
- */
- /**
- * When opening modals/sidebars/dialogs, the focus
- * must move to the opened area and return to the
- * previously focused element when closed.
- * The current hook implements the returning behavior.
- *
- * @param {() => void} [onFocusReturn] Overrides the default return behavior.
- * @return {import('react').RefCallback<HTMLElement>} Element Ref.
- *
- * @example
- * ```js
- * import { useFocusReturn } from '@wordpress/compose';
- *
- * const WithFocusReturn = () => {
- * const ref = useFocusReturn()
- * return (
- * <div ref={ ref }>
- * <Button />
- * <Button />
- * </div>
- * );
- * }
- * ```
- */
- function useFocusReturn(onFocusReturn) {
- /** @type {import('react').MutableRefObject<null | HTMLElement>} */
- const ref = (0,external_wp_element_namespaceObject.useRef)(null);
- /** @type {import('react').MutableRefObject<null | Element>} */
- const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null);
- const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- onFocusReturnRef.current = onFocusReturn;
- }, [onFocusReturn]);
- return (0,external_wp_element_namespaceObject.useCallback)(node => {
- if (node) {
- // Set ref to be used when unmounting.
- ref.current = node; // Only set when the node mounts.
- if (focusedBeforeMount.current) {
- return;
- }
- focusedBeforeMount.current = node.ownerDocument.activeElement;
- } else if (focusedBeforeMount.current) {
- var _ref$current, _ref$current2, _ref$current3;
- const isFocused = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.ownerDocument.activeElement);
- if ((_ref$current3 = ref.current) !== null && _ref$current3 !== void 0 && _ref$current3.isConnected && !isFocused) {
- return;
- } // Defer to the component's own explicit focus return behavior, if
- // specified. This allows for support that the `onFocusReturn`
- // decides to allow the default behavior to occur under some
- // conditions.
- if (onFocusReturnRef.current) {
- onFocusReturnRef.current();
- } else {
- var _focusedBeforeMount$c;
- /** @type {null | HTMLElement} */
- (_focusedBeforeMount$c = focusedBeforeMount.current) === null || _focusedBeforeMount$c === void 0 ? void 0 : _focusedBeforeMount$c.focus();
- }
- }
- }, []);
- }
- /* harmony default export */ var use_focus_return = (useFocusReturn);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Input types which are classified as button types, for use in considering
- * whether element is a (focus-normalized) button.
- *
- * @type {string[]}
- */
- const INPUT_BUTTON_TYPES = ['button', 'submit'];
- /**
- * @typedef {HTMLButtonElement | HTMLLinkElement | HTMLInputElement} FocusNormalizedButton
- */
- // Disable reason: Rule doesn't support predicate return types.
- /* eslint-disable jsdoc/valid-types */
- /**
- * Returns true if the given element is a button element subject to focus
- * normalization, or false otherwise.
- *
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
- *
- * @param {EventTarget} eventTarget The target from a mouse or touch event.
- *
- * @return {eventTarget is FocusNormalizedButton} Whether element is a button.
- */
- function isFocusNormalizedButton(eventTarget) {
- if (!(eventTarget instanceof window.HTMLElement)) {
- return false;
- }
- switch (eventTarget.nodeName) {
- case 'A':
- case 'BUTTON':
- return true;
- case 'INPUT':
- return (0,external_lodash_namespaceObject.includes)(INPUT_BUTTON_TYPES,
- /** @type {HTMLInputElement} */
- eventTarget.type);
- }
- return false;
- }
- /* eslint-enable jsdoc/valid-types */
- /**
- * @typedef {import('react').SyntheticEvent} SyntheticEvent
- */
- /**
- * @callback EventCallback
- * @param {SyntheticEvent} event input related event.
- */
- /**
- * @typedef FocusOutsideReactElement
- * @property {EventCallback} handleFocusOutside callback for a focus outside event.
- */
- /**
- * @typedef {import('react').MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef
- */
- /**
- * @typedef {Object} FocusOutsideReturnValue
- * @property {EventCallback} onFocus An event handler for focus events.
- * @property {EventCallback} onBlur An event handler for blur events.
- * @property {EventCallback} onMouseDown An event handler for mouse down events.
- * @property {EventCallback} onMouseUp An event handler for mouse up events.
- * @property {EventCallback} onTouchStart An event handler for touch start events.
- * @property {EventCallback} onTouchEnd An event handler for touch end events.
- */
- /**
- * A react hook that can be used to check whether focus has moved outside the
- * element the event handlers are bound to.
- *
- * @param {EventCallback} onFocusOutside A callback triggered when focus moves outside
- * the element the event handlers are bound to.
- *
- * @return {FocusOutsideReturnValue} An object containing event handlers. Bind the event handlers
- * to a wrapping element element to capture when focus moves
- * outside that element.
- */
- function useFocusOutside(onFocusOutside) {
- const currentOnFocusOutside = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- currentOnFocusOutside.current = onFocusOutside;
- }, [onFocusOutside]);
- const preventBlurCheck = (0,external_wp_element_namespaceObject.useRef)(false);
- /**
- * @type {import('react').MutableRefObject<number | undefined>}
- */
- const blurCheckTimeoutId = (0,external_wp_element_namespaceObject.useRef)();
- /**
- * Cancel a blur check timeout.
- */
- const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => {
- clearTimeout(blurCheckTimeoutId.current);
- }, []); // Cancel blur checks on unmount.
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- return () => cancelBlurCheck();
- }, []); // Cancel a blur check if the callback or ref is no longer provided.
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- if (!onFocusOutside) {
- cancelBlurCheck();
- }
- }, [onFocusOutside, cancelBlurCheck]);
- /**
- * Handles a mousedown or mouseup event to respectively assign and
- * unassign a flag for preventing blur check on button elements. Some
- * browsers, namely Firefox and Safari, do not emit a focus event on
- * button elements when clicked, while others do. The logic here
- * intends to normalize this as treating click on buttons as focus.
- *
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
- *
- * @param {SyntheticEvent} event Event for mousedown or mouseup.
- */
- const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => {
- const {
- type,
- target
- } = event;
- const isInteractionEnd = (0,external_lodash_namespaceObject.includes)(['mouseup', 'touchend'], type);
- if (isInteractionEnd) {
- preventBlurCheck.current = false;
- } else if (isFocusNormalizedButton(target)) {
- preventBlurCheck.current = true;
- }
- }, []);
- /**
- * A callback triggered when a blur event occurs on the element the handler
- * is bound to.
- *
- * Calls the `onFocusOutside` callback in an immediate timeout if focus has
- * move outside the bound element and is still within the document.
- *
- * @param {SyntheticEvent} event Blur event.
- */
- const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => {
- // React does not allow using an event reference asynchronously
- // due to recycling behavior, except when explicitly persisted.
- event.persist(); // Skip blur check if clicking button. See `normalizeButtonFocus`.
- if (preventBlurCheck.current) {
- return;
- }
- blurCheckTimeoutId.current = setTimeout(() => {
- // If document is not focused then focus should remain
- // inside the wrapped component and therefore we cancel
- // this blur event thereby leaving focus in place.
- // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus.
- if (!document.hasFocus()) {
- event.preventDefault();
- return;
- }
- if ('function' === typeof currentOnFocusOutside.current) {
- currentOnFocusOutside.current(event);
- }
- }, 0);
- }, []);
- return {
- onFocus: cancelBlurCheck,
- onMouseDown: normalizeButtonFocus,
- onMouseUp: normalizeButtonFocus,
- onTouchStart: normalizeButtonFocus,
- onTouchEnd: normalizeButtonFocus,
- onBlur: queueBlurCheck
- };
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js
- /**
- * WordPress dependencies
- */
- /* eslint-disable jsdoc/valid-types */
- /**
- * @template T
- * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef
- */
- /* eslint-enable jsdoc/valid-types */
- /**
- * @template T
- * @param {import('react').Ref<T>} ref
- * @param {T} value
- */
- function assignRef(ref, value) {
- if (typeof ref === 'function') {
- ref(value);
- } else if (ref && ref.hasOwnProperty('current')) {
- /* eslint-disable jsdoc/no-undefined-types */
- /** @type {import('react').MutableRefObject<T>} */
- ref.current = value;
- /* eslint-enable jsdoc/no-undefined-types */
- }
- }
- /**
- * Merges refs into one ref callback.
- *
- * It also ensures that the merged ref callbacks are only called when they
- * change (as a result of a `useCallback` dependency update) OR when the ref
- * value changes, just as React does when passing a single ref callback to the
- * component.
- *
- * As expected, if you pass a new function on every render, the ref callback
- * will be called after every render.
- *
- * If you don't wish a ref callback to be called after every render, wrap it
- * with `useCallback( callback, dependencies )`. When a dependency changes, the
- * old ref callback will be called with `null` and the new ref callback will be
- * called with the same value.
- *
- * To make ref callbacks easier to use, you can also pass the result of
- * `useRefEffect`, which makes cleanup easier by allowing you to return a
- * cleanup function instead of handling `null`.
- *
- * It's also possible to _disable_ a ref (and its behaviour) by simply not
- * passing the ref.
- *
- * ```jsx
- * const ref = useRefEffect( ( node ) => {
- * node.addEventListener( ... );
- * return () => {
- * node.removeEventListener( ... );
- * };
- * }, [ ...dependencies ] );
- * const otherRef = useRef();
- * const mergedRefs useMergeRefs( [
- * enabled && ref,
- * otherRef,
- * ] );
- * return <div ref={ mergedRefs } />;
- * ```
- *
- * @template {import('react').Ref<any>} TRef
- * @param {Array<TRef>} refs The refs to be merged.
- *
- * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.
- */
- function useMergeRefs(refs) {
- const element = (0,external_wp_element_namespaceObject.useRef)();
- const didElementChange = (0,external_wp_element_namespaceObject.useRef)(false);
- /* eslint-disable jsdoc/no-undefined-types */
- /** @type {import('react').MutableRefObject<TRef[]>} */
- /* eslint-enable jsdoc/no-undefined-types */
- const previousRefs = (0,external_wp_element_namespaceObject.useRef)([]);
- const currentRefs = (0,external_wp_element_namespaceObject.useRef)(refs); // Update on render before the ref callback is called, so the ref callback
- // always has access to the current refs.
- currentRefs.current = refs; // If any of the refs change, call the previous ref with `null` and the new
- // ref with the node, except when the element changes in the same cycle, in
- // which case the ref callbacks will already have been called.
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
- if (didElementChange.current === false) {
- refs.forEach((ref, index) => {
- const previousRef = previousRefs.current[index];
- if (ref !== previousRef) {
- assignRef(previousRef, null);
- assignRef(ref, element.current);
- }
- });
- }
- previousRefs.current = refs;
- }, refs); // No dependencies, must be reset after every render so ref callbacks are
- // correctly called after a ref change.
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
- didElementChange.current = false;
- }); // There should be no dependencies so that `callback` is only called when
- // the node changes.
- return (0,external_wp_element_namespaceObject.useCallback)(value => {
- // Update the element so it can be used when calling ref callbacks on a
- // dependency change.
- assignRef(element, value);
- didElementChange.current = true; // When an element changes, the current ref callback should be called
- // with the new element and the previous one with `null`.
- const refsToAssign = value ? currentRefs.current : previousRefs.current; // Update the latest refs.
- for (const ref of refsToAssign) {
- assignRef(ref, value);
- }
- }, []);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:
- * - constrained tabbing.
- * - focus on mount.
- * - return focus on unmount.
- * - focus outside.
- *
- * @param options Dialog Options.
- */
- function useDialog(options) {
- const currentOptions = (0,external_wp_element_namespaceObject.useRef)();
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- currentOptions.current = options;
- }, Object.values(options));
- const constrainedTabbingRef = use_constrained_tabbing();
- const focusOnMountRef = useFocusOnMount(options.focusOnMount);
- const focusReturnRef = use_focus_return();
- const focusOutsideProps = useFocusOutside(event => {
- var _currentOptions$curre, _currentOptions$curre2;
- // This unstable prop is here only to manage backward compatibility
- // for the Popover component otherwise, the onClose should be enough.
- if ((_currentOptions$curre = currentOptions.current) !== null && _currentOptions$curre !== void 0 && _currentOptions$curre.__unstableOnClose) {
- currentOptions.current.__unstableOnClose('focus-outside', event);
- } else if ((_currentOptions$curre2 = currentOptions.current) !== null && _currentOptions$curre2 !== void 0 && _currentOptions$curre2.onClose) {
- currentOptions.current.onClose();
- }
- });
- const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => {
- if (!node) {
- return;
- }
- node.addEventListener('keydown', event => {
- var _currentOptions$curre3;
- // Close on escape.
- if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && (_currentOptions$curre3 = currentOptions.current) !== null && _currentOptions$curre3 !== void 0 && _currentOptions$curre3.onClose) {
- event.preventDefault();
- currentOptions.current.onClose();
- }
- });
- }, []);
- return [useMergeRefs([options.focusOnMount !== false ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { ...focusOutsideProps,
- tabIndex: -1
- }];
- }
- /* harmony default export */ var use_dialog = (useDialog);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * Names of control nodes which qualify for disabled behavior.
- *
- * See WHATWG HTML Standard: 4.10.18.5: "Enabling and disabling form controls: the disabled attribute".
- *
- * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
- *
- * @type {string[]}
- */
- const DISABLED_ELIGIBLE_NODE_NAMES = ['BUTTON', 'FIELDSET', 'INPUT', 'OPTGROUP', 'OPTION', 'SELECT', 'TEXTAREA'];
- /**
- * In some circumstances, such as block previews, all focusable DOM elements
- * (input fields, links, buttons, etc.) need to be disabled. This hook adds the
- * behavior to disable nested DOM elements to the returned ref.
- *
- * @param {Object} config Configuration object.
- * @param {boolean=} config.isDisabled Whether the element should be disabled.
- * @return {import('react').RefCallback<HTMLElement>} Element Ref.
- *
- * @example
- * ```js
- * import { useDisabled } from '@wordpress/compose';
- * const DisabledExample = () => {
- * const disabledRef = useDisabled();
- * return (
- * <div ref={ disabledRef }>
- * <a href="#">This link will have tabindex set to -1</a>
- * <input placeholder="This input will have the disabled attribute added to it." type="text" />
- * </div>
- * );
- * };
- * ```
- */
- function useDisabled() {
- let {
- isDisabled: isDisabledProp = false
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- return useRefEffect(node => {
- if (isDisabledProp) {
- return;
- }
- /** A variable keeping track of the previous updates in order to restore them. */
- /** @type {Function[]} */
- const updates = [];
- const disable = () => {
- if (node.style.getPropertyValue('user-select') !== 'none') {
- const previousValue = node.style.getPropertyValue('user-select');
- node.style.setProperty('user-select', 'none');
- node.style.setProperty('-webkit-user-select', 'none');
- updates.push(() => {
- if (!node.isConnected) {
- return;
- }
- node.style.setProperty('user-select', previousValue);
- node.style.setProperty('-webkit-user-select', previousValue);
- });
- }
- external_wp_dom_namespaceObject.focus.focusable.find(node).forEach(focusable => {
- var _node$ownerDocument$d;
- if ((0,external_lodash_namespaceObject.includes)(DISABLED_ELIGIBLE_NODE_NAMES, focusable.nodeName) && // @ts-ignore
- !focusable.disabled) {
- focusable.setAttribute('disabled', '');
- updates.push(() => {
- if (!focusable.isConnected) {
- return;
- } // @ts-ignore
- focusable.disabled = false;
- });
- }
- if (focusable.nodeName === 'A' && focusable.getAttribute('tabindex') !== '-1') {
- const previousValue = focusable.getAttribute('tabindex');
- focusable.setAttribute('tabindex', '-1');
- updates.push(() => {
- if (!focusable.isConnected) {
- return;
- }
- if (!previousValue) {
- focusable.removeAttribute('tabindex');
- } else {
- focusable.setAttribute('tabindex', previousValue);
- }
- });
- }
- const tabIndex = focusable.getAttribute('tabindex');
- if (tabIndex !== null && tabIndex !== '-1') {
- focusable.removeAttribute('tabindex');
- updates.push(() => {
- if (!focusable.isConnected) {
- return;
- }
- focusable.setAttribute('tabindex', tabIndex);
- });
- }
- if (focusable.hasAttribute('contenteditable') && focusable.getAttribute('contenteditable') !== 'false') {
- focusable.setAttribute('contenteditable', 'false');
- updates.push(() => {
- if (!focusable.isConnected) {
- return;
- }
- focusable.setAttribute('contenteditable', 'true');
- });
- }
- if ((_node$ownerDocument$d = node.ownerDocument.defaultView) !== null && _node$ownerDocument$d !== void 0 && _node$ownerDocument$d.HTMLElement && focusable instanceof node.ownerDocument.defaultView.HTMLElement) {
- const previousValue = focusable.style.getPropertyValue('pointer-events');
- focusable.style.setProperty('pointer-events', 'none');
- updates.push(() => {
- if (!focusable.isConnected) {
- return;
- }
- focusable.style.setProperty('pointer-events', previousValue);
- });
- }
- });
- }; // Debounce re-disable since disabling process itself will incur
- // additional mutations which should be ignored.
- const debouncedDisable = (0,external_lodash_namespaceObject.debounce)(disable, undefined, {
- leading: true
- });
- disable();
- /** @type {MutationObserver | undefined} */
- const observer = new window.MutationObserver(debouncedDisable);
- observer.observe(node, {
- childList: true,
- attributes: true,
- subtree: true
- });
- return () => {
- if (observer) {
- observer.disconnect();
- }
- debouncedDisable.cancel();
- updates.forEach(update => update());
- };
- }, [isDisabledProp]);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Preferred over direct usage of `useLayoutEffect` when supporting
- * server rendered components (SSR) because currently React
- * throws a warning when using useLayoutEffect in that environment.
- */
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_namespaceObject.useLayoutEffect : external_wp_element_namespaceObject.useEffect;
- /* harmony default export */ var use_isomorphic_layout_effect = (useIsomorphicLayoutEffect);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- // Event handlers that are triggered from `document` listeners accept a MouseEvent,
- // while those triggered from React listeners accept a React.MouseEvent.
- /**
- * @param {Object} props
- * @param {(e: import('react').MouseEvent) => void} props.onDragStart
- * @param {(e: MouseEvent) => void} props.onDragMove
- * @param {(e?: MouseEvent) => void} props.onDragEnd
- */
- function useDragging(_ref) {
- let {
- onDragStart,
- onDragMove,
- onDragEnd
- } = _ref;
- const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false);
- const eventsRef = (0,external_wp_element_namespaceObject.useRef)({
- onDragStart,
- onDragMove,
- onDragEnd
- });
- use_isomorphic_layout_effect(() => {
- eventsRef.current.onDragStart = onDragStart;
- eventsRef.current.onDragMove = onDragMove;
- eventsRef.current.onDragEnd = onDragEnd;
- }, [onDragStart, onDragMove, onDragEnd]);
- /** @type {(e: MouseEvent) => void} */
- const onMouseMove = (0,external_wp_element_namespaceObject.useCallback)(event => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), []);
- /** @type {(e?: MouseEvent) => void} */
- const endDrag = (0,external_wp_element_namespaceObject.useCallback)(event => {
- if (eventsRef.current.onDragEnd) {
- eventsRef.current.onDragEnd(event);
- }
- document.removeEventListener('mousemove', onMouseMove);
- document.removeEventListener('mouseup', endDrag);
- setIsDragging(false);
- }, []);
- /** @type {(e: import('react').MouseEvent) => void} */
- const startDrag = (0,external_wp_element_namespaceObject.useCallback)(event => {
- if (eventsRef.current.onDragStart) {
- eventsRef.current.onDragStart(event);
- }
- document.addEventListener('mousemove', onMouseMove);
- document.addEventListener('mouseup', endDrag);
- setIsDragging(true);
- }, []); // Remove the global events when unmounting if needed.
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- return () => {
- if (isDragging) {
- document.removeEventListener('mousemove', onMouseMove);
- document.removeEventListener('mouseup', endDrag);
- }
- };
- }, [isDragging]);
- return {
- startDrag,
- endDrag,
- isDragging
- };
- }
- // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js
- var mousetrap_mousetrap = __webpack_require__(7973);
- var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap);
- // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
- var mousetrap_global_bind = __webpack_require__(5538);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * A block selection object.
- *
- * @typedef {Object} WPKeyboardShortcutConfig
- *
- * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.
- * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.
- * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.
- * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event.
- */
- /* eslint-disable jsdoc/valid-types */
- /**
- * Attach a keyboard shortcut handler.
- *
- * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.
- *
- * @param {string[]|string} shortcuts Keyboard Shortcuts.
- * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.
- * @param {WPKeyboardShortcutConfig} options Shortcut options.
- */
- function useKeyboardShortcut(
- /* eslint-enable jsdoc/valid-types */
- shortcuts, callback) {
- let {
- bindGlobal = false,
- eventName = 'keydown',
- isDisabled = false,
- // This is important for performance considerations.
- target
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- const currentCallback = (0,external_wp_element_namespaceObject.useRef)(callback);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- currentCallback.current = callback;
- }, [callback]);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- if (isDisabled) {
- return;
- }
- const mousetrap = new (mousetrap_default())(target && target.current ? target.current : // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
- // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's
- // necessary to maintain the existing behavior.
- /** @type {Element} */
- /** @type {unknown} */
- document);
- (0,external_lodash_namespaceObject.castArray)(shortcuts).forEach(shortcut => {
- const keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string.
- // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that
- // the modifiers are Shift and Cmd because they're not a single character.
- const modifiers = new Set(keys.filter(value => value.length > 1));
- const hasAlt = modifiers.has('alt');
- const hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead.
- if ((0,external_wp_keycodes_namespaceObject.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
- throw new Error(`Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`);
- }
- const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; // @ts-ignore `bindGlobal` is an undocumented property
- mousetrap[bindFn](shortcut, function () {
- return (
- /* eslint-enable jsdoc/valid-types */
- currentCallback.current(...arguments)
- );
- }, eventName);
- });
- return () => {
- mousetrap.reset();
- };
- }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
- }
- /* harmony default export */ var use_keyboard_shortcut = (useKeyboardShortcut);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Runs a media query and returns its value when it changes.
- *
- * @param {string} [query] Media Query.
- * @return {boolean} return value of the media query.
- */
- function useMediaQuery(query) {
- const [match, setMatch] = (0,external_wp_element_namespaceObject.useState)(() => !!(query && typeof window !== 'undefined' && window.matchMedia(query).matches));
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- if (!query) {
- return;
- }
- const updateMatch = () => setMatch(window.matchMedia(query).matches);
- updateMatch();
- const list = window.matchMedia(query);
- list.addListener(updateMatch);
- return () => {
- list.removeListener(updateMatch);
- };
- }, [query]);
- return !!query && match;
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Use something's value from the previous render.
- * Based on https://usehooks.com/usePrevious/.
- *
- * @param value The value to track.
- *
- * @return The value from the previous render.
- */
- function usePrevious(value) {
- const ref = (0,external_wp_element_namespaceObject.useRef)(); // Store current value in ref.
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- ref.current = value;
- }, [value]); // Re-run when value changes.
- // Return previous value (happens before update in useEffect above).
- return ref.current;
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js
- /**
- * Internal dependencies
- */
- /**
- * Hook returning whether the user has a preference for reduced motion.
- *
- * @return {boolean} Reduced motion preference value.
- */
- const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)');
- /* harmony default export */ var use_reduced_motion = (useReducedMotion);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /**
- * @typedef {"huge" | "wide" | "large" | "medium" | "small" | "mobile"} WPBreakpoint
- */
- /**
- * Hash of breakpoint names with pixel width at which it becomes effective.
- *
- * @see _breakpoints.scss
- *
- * @type {Record<WPBreakpoint, number>}
- */
- const BREAKPOINTS = {
- huge: 1440,
- wide: 1280,
- large: 960,
- medium: 782,
- small: 600,
- mobile: 480
- };
- /**
- * @typedef {">=" | "<"} WPViewportOperator
- */
- /**
- * Object mapping media query operators to the condition to be used.
- *
- * @type {Record<WPViewportOperator, string>}
- */
- const CONDITIONS = {
- '>=': 'min-width',
- '<': 'max-width'
- };
- /**
- * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.
- *
- * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}
- */
- const OPERATOR_EVALUATORS = {
- '>=': (breakpointValue, width) => width >= breakpointValue,
- '<': (breakpointValue, width) => width < breakpointValue
- };
- const ViewportMatchWidthContext = (0,external_wp_element_namespaceObject.createContext)(
- /** @type {null | number} */
- null);
- /**
- * Returns true if the viewport matches the given query, or false otherwise.
- *
- * @param {WPBreakpoint} breakpoint Breakpoint size name.
- * @param {WPViewportOperator} [operator=">="] Viewport operator.
- *
- * @example
- *
- * ```js
- * useViewportMatch( 'huge', '<' );
- * useViewportMatch( 'medium' );
- * ```
- *
- * @return {boolean} Whether viewport matches query.
- */
- const useViewportMatch = function (breakpoint) {
- let operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '>=';
- const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext);
- const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
- const mediaQueryResult = useMediaQuery(mediaQuery || undefined);
- if (simulatedWidth) {
- return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth);
- }
- return mediaQueryResult;
- };
- useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
- /* harmony default export */ var use_viewport_match = (useViewportMatch);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- // This of course could've been more streamlined with internal state instead of
- // refs, but then host hooks / components could not opt out of renders.
- // This could've been exported to its own module, but the current build doesn't
- // seem to work with module imports and I had no more time to spend on this...
- function useResolvedElement(subscriber, refOrElement) {
- const callbackRefElement = (0,external_wp_element_namespaceObject.useRef)(null);
- const lastReportRef = (0,external_wp_element_namespaceObject.useRef)(null);
- const cleanupRef = (0,external_wp_element_namespaceObject.useRef)();
- const callSubscriber = (0,external_wp_element_namespaceObject.useCallback)(() => {
- let element = null;
- if (callbackRefElement.current) {
- element = callbackRefElement.current;
- } else if (refOrElement) {
- if (refOrElement instanceof HTMLElement) {
- element = refOrElement;
- } else {
- element = refOrElement.current;
- }
- }
- if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.reporter === callSubscriber) {
- return;
- }
- if (cleanupRef.current) {
- cleanupRef.current(); // Making sure the cleanup is not called accidentally multiple times.
- cleanupRef.current = null;
- }
- lastReportRef.current = {
- reporter: callSubscriber,
- element
- }; // Only calling the subscriber, if there's an actual element to report.
- if (element) {
- cleanupRef.current = subscriber(element);
- }
- }, [refOrElement, subscriber]); // On each render, we check whether a ref changed, or if we got a new raw
- // element.
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- // With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a
- // render accompanying that change as well.
- // To guarantee we always have the right element, one must use the ref callback provided instead, but we support
- // RefObjects to make the hook API more convenient in certain cases.
- callSubscriber();
- }, [callSubscriber]);
- return (0,external_wp_element_namespaceObject.useCallback)(element => {
- callbackRefElement.current = element;
- callSubscriber();
- }, [callSubscriber]);
- }
- // We're only using the first element of the size sequences, until future versions of the spec solidify on how
- // exactly it'll be used for fragments in multi-column scenarios:
- // From the spec:
- // > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,
- // > which occur in multi-column scenarios. However the current definitions of content rect and border box do not
- // > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single
- // > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.
- // > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.
- // (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)
- //
- // Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,
- // regardless of the "box" option.
- // The spec states the following on this:
- // > This does not have any impact on which box dimensions are returned to the defined callback when the event
- // > is fired, it solely defines which box the author wishes to observe layout changes on.
- // (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
- // I'm not exactly clear on what this means, especially when you consider a later section stating the following:
- // > This section is non-normative. An author may desire to observe more than one CSS box.
- // > In this case, author will need to use multiple ResizeObservers.
- // (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
- // Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.
- // For this reason I decided to only return the requested size,
- // even though it seems we have access to results for all box types.
- // This also means that we get to keep the current api, being able to return a simple { width, height } pair,
- // regardless of box option.
- const extractSize = (entry, boxProp, sizeType) => {
- if (!entry[boxProp]) {
- if (boxProp === 'contentBoxSize') {
- // The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.
- // See the 6th step in the description for the RO algorithm:
- // https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h
- // > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box".
- // In real browser implementations of course these objects differ, but the width/height values should be equivalent.
- return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height'];
- }
- return undefined;
- } // A couple bytes smaller than calling Array.isArray() and just as effective here.
- return entry[boxProp][0] ? entry[boxProp][0][sizeType] : // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
- // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
- // @ts-ignore
- entry[boxProp][sizeType];
- };
- function useResizeObserver() {
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- // Saving the callback as a ref. With this, I don't need to put onResize in the
- // effect dep array, and just passing in an anonymous function without memoising
- // will not reinstantiate the hook's ResizeObserver.
- const onResize = opts.onResize;
- const onResizeRef = (0,external_wp_element_namespaceObject.useRef)(undefined);
- onResizeRef.current = onResize;
- const round = opts.round || Math.round; // Using a single instance throughout the hook's lifetime
- const resizeObserverRef = (0,external_wp_element_namespaceObject.useRef)();
- const [size, setSize] = (0,external_wp_element_namespaceObject.useState)({
- width: undefined,
- height: undefined
- }); // In certain edge cases the RO might want to report a size change just after
- // the component unmounted.
- const didUnmount = (0,external_wp_element_namespaceObject.useRef)(false);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- return () => {
- didUnmount.current = true;
- };
- }, []); // Using a ref to track the previous width / height to avoid unnecessary renders.
- const previous = (0,external_wp_element_namespaceObject.useRef)({
- width: undefined,
- height: undefined
- }); // This block is kinda like a useEffect, only it's called whenever a new
- // element could be resolved based on the ref option. It also has a cleanup
- // function.
- const refCallback = useResolvedElement((0,external_wp_element_namespaceObject.useCallback)(element => {
- // We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.
- // This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.
- if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
- resizeObserverRef.current = {
- box: opts.box,
- round,
- instance: new ResizeObserver(entries => {
- const entry = entries[0];
- let boxProp = 'borderBoxSize';
- if (opts.box === 'border-box') {
- boxProp = 'borderBoxSize';
- } else {
- boxProp = opts.box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize';
- }
- const reportedWidth = extractSize(entry, boxProp, 'inlineSize');
- const reportedHeight = extractSize(entry, boxProp, 'blockSize');
- const newWidth = reportedWidth ? round(reportedWidth) : undefined;
- const newHeight = reportedHeight ? round(reportedHeight) : undefined;
- if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
- const newSize = {
- width: newWidth,
- height: newHeight
- };
- previous.current.width = newWidth;
- previous.current.height = newHeight;
- if (onResizeRef.current) {
- onResizeRef.current(newSize);
- } else if (!didUnmount.current) {
- setSize(newSize);
- }
- }
- })
- };
- }
- resizeObserverRef.current.instance.observe(element, {
- box: opts.box
- });
- return () => {
- if (resizeObserverRef.current) {
- resizeObserverRef.current.instance.unobserve(element);
- }
- };
- }, [opts.box, round]), opts.ref);
- return (0,external_wp_element_namespaceObject.useMemo)(() => ({
- ref: refCallback,
- width: size.width,
- height: size.height
- }), [refCallback, size ? size.width : null, size ? size.height : null]);
- }
- /**
- * Hook which allows to listen the resize event of any target element when it changes sizes.
- * _Note: `useResizeObserver` will report `null` until after first render.
- *
- * @example
- *
- * ```js
- * const App = () => {
- * const [ resizeListener, sizes ] = useResizeObserver();
- *
- * return (
- * <div>
- * { resizeListener }
- * Your content here
- * </div>
- * );
- * };
- * ```
- */
- function useResizeAware() {
- const {
- ref,
- width,
- height
- } = useResizeObserver();
- const sizes = (0,external_wp_element_namespaceObject.useMemo)(() => {
- return {
- width: width !== null && width !== void 0 ? width : null,
- height: height !== null && height !== void 0 ? height : null
- };
- }, [width, height]);
- const resizeListener = (0,external_wp_element_namespaceObject.createElement)("div", {
- style: {
- position: 'absolute',
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- pointerEvents: 'none',
- opacity: 0,
- overflow: 'hidden',
- zIndex: -1
- },
- "aria-hidden": "true",
- ref: ref
- });
- return [resizeListener, sizes];
- }
- ;// CONCATENATED MODULE: external ["wp","priorityQueue"]
- var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"];
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Returns the first items from list that are present on state.
- *
- * @param list New array.
- * @param state Current state.
- * @return First items present iin state.
- */
- function getFirstItemsPresentInState(list, state) {
- const firstItems = [];
- for (let i = 0; i < list.length; i++) {
- const item = list[i];
- if (!state.includes(item)) {
- break;
- }
- firstItems.push(item);
- }
- return firstItems;
- }
- /**
- * React hook returns an array which items get asynchronously appended from a source array.
- * This behavior is useful if we want to render a list of items asynchronously for performance reasons.
- *
- * @param list Source array.
- * @param config Configuration object.
- *
- * @return Async array.
- */
- function useAsyncList(list) {
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- step: 1
- };
- const {
- step = 1
- } = config;
- const [current, setCurrent] = (0,external_wp_element_namespaceObject.useState)([]);
- (0,external_wp_element_namespaceObject.useEffect)(() => {
- // On reset, we keep the first items that were previously rendered.
- let firstItems = getFirstItemsPresentInState(list, current);
- if (firstItems.length < step) {
- firstItems = firstItems.concat(list.slice(firstItems.length, step));
- }
- setCurrent(firstItems);
- let nextIndex = firstItems.length;
- const asyncQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)();
- const append = () => {
- if (list.length <= nextIndex) {
- return;
- }
- setCurrent(state => [...state, ...list.slice(nextIndex, nextIndex + step)]);
- nextIndex += step;
- asyncQueue.add({}, append);
- };
- asyncQueue.add({}, append);
- return () => asyncQueue.reset();
- }, [list]);
- return current;
- }
- /* harmony default export */ var use_async_list = (useAsyncList);
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js
- /**
- * Internal dependencies
- */
- // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
- // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
- /* eslint-disable jsdoc/check-types */
- /**
- * Hook that performs a shallow comparison between the preview value of an object
- * and the new one, if there's a difference, it prints it to the console.
- * this is useful in performance related work, to check why a component re-renders.
- *
- * @example
- *
- * ```jsx
- * function MyComponent(props) {
- * useWarnOnChange(props);
- *
- * return "Something";
- * }
- * ```
- *
- * @param {object} object Object which changes to compare.
- * @param {string} prefix Just a prefix to show when console logging.
- */
- function useWarnOnChange(object) {
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Change detection';
- const previousValues = usePrevious(object);
- Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(_ref => {
- let [key, value] = _ref;
- if (value !== object[
- /** @type {keyof typeof object} */
- key]) {
- // eslint-disable-next-line no-console
- console.warn(`${prefix}: ${key} key changed:`, value, object[
- /** @type {keyof typeof object} */
- key]
- /* eslint-enable jsdoc/check-types */
- );
- }
- });
- }
- /* harmony default export */ var use_warn_on_change = (useWarnOnChange);
- ;// CONCATENATED MODULE: external "React"
- var external_React_namespaceObject = window["React"];
- ;// CONCATENATED MODULE: ./node_modules/use-memo-one/dist/use-memo-one.esm.js
- function areInputsEqual(newInputs, lastInputs) {
- if (newInputs.length !== lastInputs.length) {
- return false;
- }
- for (var i = 0; i < newInputs.length; i++) {
- if (newInputs[i] !== lastInputs[i]) {
- return false;
- }
- }
- return true;
- }
- function useMemoOne(getResult, inputs) {
- var initial = (0,external_React_namespaceObject.useState)(function () {
- return {
- inputs: inputs,
- result: getResult()
- };
- })[0];
- var isFirstRun = (0,external_React_namespaceObject.useRef)(true);
- var committed = (0,external_React_namespaceObject.useRef)(initial);
- var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
- var cache = useCache ? committed.current : {
- inputs: inputs,
- result: getResult()
- };
- (0,external_React_namespaceObject.useEffect)(function () {
- isFirstRun.current = false;
- committed.current = cache;
- }, [cache]);
- return cache.result;
- }
- function useCallbackOne(callback, inputs) {
- return useMemoOne(function () {
- return callback;
- }, inputs);
- }
- var useMemo = (/* unused pure expression or super */ null && (useMemoOne));
- var useCallback = (/* unused pure expression or super */ null && (useCallbackOne));
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /* eslint-disable jsdoc/valid-types */
- /**
- * Debounces a function with Lodash's `debounce`. A new debounced function will
- * be returned and any scheduled calls cancelled if any of the arguments change,
- * including the function to debounce, so please wrap functions created on
- * render in components in `useCallback`.
- *
- * @see https://docs-lodash.com/v4/debounce/
- *
- * @template {(...args: any[]) => void} TFunc
- *
- * @param {TFunc} fn The function to debounce.
- * @param {number} [wait] The number of milliseconds to delay.
- * @param {import('lodash').DebounceSettings} [options] The options object.
- * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.
- */
- function useDebounce(fn, wait, options) {
- /* eslint-enable jsdoc/valid-types */
- const debounced = useMemoOne(() => (0,external_lodash_namespaceObject.debounce)(fn, wait, options), [fn, wait, options]);
- (0,external_wp_element_namespaceObject.useEffect)(() => () => debounced.cancel(), [debounced]);
- return debounced;
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- /**
- * Throttles a function with Lodash's `throttle`. A new throttled function will
- * be returned and any scheduled calls cancelled if any of the arguments change,
- * including the function to throttle, so please wrap functions created on
- * render in components in `useCallback`.
- *
- * @see https://docs-lodash.com/v4/throttle/
- *
- * @template {(...args: any[]) => void} TFunc
- *
- * @param {TFunc} fn The function to throttle.
- * @param {number} [wait] The number of milliseconds to throttle invocations to.
- * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.
- * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.
- */
- function useThrottle(fn, wait, options) {
- const throttled = useMemoOne(() => (0,external_lodash_namespaceObject.throttle)(fn, wait, options), [fn, wait, options]);
- (0,external_wp_element_namespaceObject.useEffect)(() => () => throttled.cancel(), [throttled]);
- return throttled;
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js
- /**
- * WordPress dependencies
- */
- /**
- * Internal dependencies
- */
- /* eslint-disable jsdoc/valid-types */
- /**
- * @template T
- * @param {T} value
- * @return {import('react').MutableRefObject<T|null>} A ref with the value.
- */
- function useFreshRef(value) {
- /* eslint-enable jsdoc/valid-types */
- /* eslint-disable jsdoc/no-undefined-types */
- /** @type {import('react').MutableRefObject<T>} */
- /* eslint-enable jsdoc/no-undefined-types */
- // Disable reason: We're doing something pretty JavaScript-y here where the
- // ref will always have a current value that is not null or undefined but it
- // needs to start as undefined. We don't want to change the return type so
- // it's easier to just ts-ignore this specific line that's complaining about
- // undefined not being part of T.
- // @ts-ignore
- const ref = (0,external_wp_element_namespaceObject.useRef)();
- ref.current = value;
- return ref;
- }
- /**
- * A hook to facilitate drag and drop handling.
- *
- * @param {Object} props Named parameters.
- * @param {boolean} [props.isDisabled] Whether or not to disable the drop zone.
- * @param {(e: DragEvent) => void} [props.onDragStart] Called when dragging has started.
- * @param {(e: DragEvent) => void} [props.onDragEnter] Called when the zone is entered.
- * @param {(e: DragEvent) => void} [props.onDragOver] Called when the zone is moved within.
- * @param {(e: DragEvent) => void} [props.onDragLeave] Called when the zone is left.
- * @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended.
- * @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone.
- *
- * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element.
- */
- function useDropZone(_ref) {
- let {
- isDisabled,
- onDrop: _onDrop,
- onDragStart: _onDragStart,
- onDragEnter: _onDragEnter,
- onDragLeave: _onDragLeave,
- onDragEnd: _onDragEnd,
- onDragOver: _onDragOver
- } = _ref;
- const onDropRef = useFreshRef(_onDrop);
- const onDragStartRef = useFreshRef(_onDragStart);
- const onDragEnterRef = useFreshRef(_onDragEnter);
- const onDragLeaveRef = useFreshRef(_onDragLeave);
- const onDragEndRef = useFreshRef(_onDragEnd);
- const onDragOverRef = useFreshRef(_onDragOver);
- return useRefEffect(element => {
- if (isDisabled) {
- return;
- }
- let isDragging = false;
- const {
- ownerDocument
- } = element;
- /**
- * Checks if an element is in the drop zone.
- *
- * @param {EventTarget|null} targetToCheck
- *
- * @return {boolean} True if in drop zone, false if not.
- */
- function isElementInZone(targetToCheck) {
- const {
- defaultView
- } = ownerDocument;
- if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) {
- return false;
- }
- /** @type {HTMLElement|null} */
- let elementToCheck = targetToCheck;
- do {
- if (elementToCheck.dataset.isDropZone) {
- return elementToCheck === element;
- }
- } while (elementToCheck = elementToCheck.parentElement);
- return false;
- }
- function maybeDragStart(
- /** @type {DragEvent} */
- event) {
- if (isDragging) {
- return;
- }
- isDragging = true;
- ownerDocument.removeEventListener('dragenter', maybeDragStart); // Note that `dragend` doesn't fire consistently for file and
- // HTML drag events where the drag origin is outside the browser
- // window. In Firefox it may also not fire if the originating
- // node is removed.
- ownerDocument.addEventListener('dragend', maybeDragEnd);
- ownerDocument.addEventListener('mousemove', maybeDragEnd);
- if (onDragStartRef.current) {
- onDragStartRef.current(event);
- }
- }
- function onDragEnter(
- /** @type {DragEvent} */
- event) {
- event.preventDefault(); // The `dragenter` event will also fire when entering child
- // elements, but we only want to call `onDragEnter` when
- // entering the drop zone, which means the `relatedTarget`
- // (element that has been left) should be outside the drop zone.
- if (element.contains(
- /** @type {Node} */
- event.relatedTarget)) {
- return;
- }
- if (onDragEnterRef.current) {
- onDragEnterRef.current(event);
- }
- }
- function onDragOver(
- /** @type {DragEvent} */
- event) {
- // Only call onDragOver for the innermost hovered drop zones.
- if (!event.defaultPrevented && onDragOverRef.current) {
- onDragOverRef.current(event);
- } // Prevent the browser default while also signalling to parent
- // drop zones that `onDragOver` is already handled.
- event.preventDefault();
- }
- function onDragLeave(
- /** @type {DragEvent} */
- event) {
- // The `dragleave` event will also fire when leaving child
- // elements, but we only want to call `onDragLeave` when
- // leaving the drop zone, which means the `relatedTarget`
- // (element that has been entered) should be outside the drop
- // zone.
- if (isElementInZone(event.relatedTarget)) {
- return;
- }
- if (onDragLeaveRef.current) {
- onDragLeaveRef.current(event);
- }
- }
- function onDrop(
- /** @type {DragEvent} */
- event) {
- // Don't handle drop if an inner drop zone already handled it.
- if (event.defaultPrevented) {
- return;
- } // Prevent the browser default while also signalling to parent
- // drop zones that `onDrop` is already handled.
- event.preventDefault(); // This seemingly useless line has been shown to resolve a
- // Safari issue where files dragged directly from the dock are
- // not recognized.
- // eslint-disable-next-line no-unused-expressions
- event.dataTransfer && event.dataTransfer.files.length;
- if (onDropRef.current) {
- onDropRef.current(event);
- }
- maybeDragEnd(event);
- }
- function maybeDragEnd(
- /** @type {MouseEvent} */
- event) {
- if (!isDragging) {
- return;
- }
- isDragging = false;
- ownerDocument.addEventListener('dragenter', maybeDragStart);
- ownerDocument.removeEventListener('dragend', maybeDragEnd);
- ownerDocument.removeEventListener('mousemove', maybeDragEnd);
- if (onDragEndRef.current) {
- onDragEndRef.current(event);
- }
- }
- element.dataset.isDropZone = 'true';
- element.addEventListener('drop', onDrop);
- element.addEventListener('dragenter', onDragEnter);
- element.addEventListener('dragover', onDragOver);
- element.addEventListener('dragleave', onDragLeave); // The `dragstart` event doesn't fire if the drag started outside
- // the document.
- ownerDocument.addEventListener('dragenter', maybeDragStart);
- return () => {
- onDropRef.current = null;
- onDragStartRef.current = null;
- onDragEnterRef.current = null;
- onDragLeaveRef.current = null;
- onDragEndRef.current = null;
- onDragOverRef.current = null;
- delete element.dataset.isDropZone;
- element.removeEventListener('drop', onDrop);
- element.removeEventListener('dragenter', onDragEnter);
- element.removeEventListener('dragover', onDragOver);
- element.removeEventListener('dragleave', onDragLeave);
- ownerDocument.removeEventListener('dragend', maybeDragEnd);
- ownerDocument.removeEventListener('mousemove', maybeDragEnd);
- ownerDocument.addEventListener('dragenter', maybeDragStart);
- };
- }, [isDisabled]);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js
- /**
- * Internal dependencies
- */
- /**
- * Dispatches a bubbling focus event when the iframe receives focus. Use
- * `onFocus` as usual on the iframe or a parent element.
- *
- * @return {Object} Ref to pass to the iframe.
- */
- function useFocusableIframe() {
- return useRefEffect(element => {
- const {
- ownerDocument
- } = element;
- if (!ownerDocument) return;
- const {
- defaultView
- } = ownerDocument;
- if (!defaultView) return;
- /**
- * Checks whether the iframe is the activeElement, inferring that it has
- * then received focus, and dispatches a focus event.
- */
- function checkFocus() {
- if (ownerDocument && ownerDocument.activeElement === element) {
- /** @type {HTMLElement} */
- element.focus();
- }
- }
- defaultView.addEventListener('blur', checkFocus);
- return () => {
- defaultView.removeEventListener('blur', checkFocus);
- };
- }, []);
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js
- /**
- * External dependencies
- */
- /**
- * WordPress dependencies
- */
- const DEFAULT_INIT_WINDOW_SIZE = 30;
- /**
- * @typedef {Object} WPFixedWindowList
- *
- * @property {number} visibleItems Items visible in the current viewport
- * @property {number} start Start index of the window
- * @property {number} end End index of the window
- * @property {(index:number)=>boolean} itemInView Returns true if item is in the window
- */
- /**
- * @typedef {Object} WPFixedWindowListOptions
- *
- * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window.
- * @property {boolean} [useWindowing] When false avoids calculating the window size
- * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size.
- */
- /**
- *
- * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.
- * @param { number } itemHeight Fixed item height in pixels
- * @param { number } totalItems Total items in list
- * @param { WPFixedWindowListOptions } [options] Options object
- * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter
- */
- function useFixedWindowList(elementRef, itemHeight, totalItems, options) {
- var _options$initWindowSi, _options$useWindowing;
- const initWindowSize = (_options$initWindowSi = options === null || options === void 0 ? void 0 : options.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE;
- const useWindowing = (_options$useWindowing = options === null || options === void 0 ? void 0 : options.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true;
- const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({
- visibleItems: initWindowSize,
- start: 0,
- end: initWindowSize,
- itemInView: (
- /** @type {number} */
- index) => {
- return index >= 0 && index <= initWindowSize;
- }
- });
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
- var _scrollContainer$owne, _scrollContainer$owne2, _scrollContainer$owne3, _scrollContainer$owne4;
- if (!useWindowing) {
- return;
- }
- const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current);
- const measureWindow = (
- /** @type {boolean | undefined} */
- initRender) => {
- var _options$windowOversc;
- if (!scrollContainer) {
- return;
- }
- const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); // Aim to keep opening list view fast, afterward we can optimize for scrolling.
- const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options === null || options === void 0 ? void 0 : options.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems;
- const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight);
- const start = Math.max(0, firstViewableIndex - windowOverscan);
- const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan);
- setFixedListWindow(lastWindow => {
- const nextWindow = {
- visibleItems,
- start,
- end,
- itemInView: (
- /** @type {number} */
- index) => {
- return start <= index && index <= end;
- }
- };
- if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) {
- return nextWindow;
- }
- return lastWindow;
- });
- };
- measureWindow(true);
- const debounceMeasureList = (0,external_lodash_namespaceObject.debounce)(() => {
- measureWindow();
- }, 16);
- scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', debounceMeasureList);
- scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne = scrollContainer.ownerDocument) === null || _scrollContainer$owne === void 0 ? void 0 : (_scrollContainer$owne2 = _scrollContainer$owne.defaultView) === null || _scrollContainer$owne2 === void 0 ? void 0 : _scrollContainer$owne2.addEventListener('resize', debounceMeasureList);
- scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne3 = scrollContainer.ownerDocument) === null || _scrollContainer$owne3 === void 0 ? void 0 : (_scrollContainer$owne4 = _scrollContainer$owne3.defaultView) === null || _scrollContainer$owne4 === void 0 ? void 0 : _scrollContainer$owne4.addEventListener('resize', debounceMeasureList);
- return () => {
- var _scrollContainer$owne5, _scrollContainer$owne6;
- scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', debounceMeasureList);
- scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne5 = scrollContainer.ownerDocument) === null || _scrollContainer$owne5 === void 0 ? void 0 : (_scrollContainer$owne6 = _scrollContainer$owne5.defaultView) === null || _scrollContainer$owne6 === void 0 ? void 0 : _scrollContainer$owne6.removeEventListener('resize', debounceMeasureList);
- };
- }, [itemHeight, elementRef, totalItems]);
- (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
- var _scrollContainer$owne7, _scrollContainer$owne8;
- if (!useWindowing) {
- return;
- }
- const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current);
- const handleKeyDown = (
- /** @type {KeyboardEvent} */
- event) => {
- switch (event.keyCode) {
- case external_wp_keycodes_namespaceObject.HOME:
- {
- return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
- top: 0
- });
- }
- case external_wp_keycodes_namespaceObject.END:
- {
- return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
- top: totalItems * itemHeight
- });
- }
- case external_wp_keycodes_namespaceObject.PAGEUP:
- {
- return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
- top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight
- });
- }
- case external_wp_keycodes_namespaceObject.PAGEDOWN:
- {
- return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
- top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight
- });
- }
- }
- };
- scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne7 = scrollContainer.ownerDocument) === null || _scrollContainer$owne7 === void 0 ? void 0 : (_scrollContainer$owne8 = _scrollContainer$owne7.defaultView) === null || _scrollContainer$owne8 === void 0 ? void 0 : _scrollContainer$owne8.addEventListener('keydown', handleKeyDown);
- return () => {
- var _scrollContainer$owne9, _scrollContainer$owne10;
- scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne9 = scrollContainer.ownerDocument) === null || _scrollContainer$owne9 === void 0 ? void 0 : (_scrollContainer$owne10 = _scrollContainer$owne9.defaultView) === null || _scrollContainer$owne10 === void 0 ? void 0 : _scrollContainer$owne10.removeEventListener('keydown', handleKeyDown);
- };
- }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems]);
- return [fixedListWindow, setFixedListWindow];
- }
- ;// CONCATENATED MODULE: ./node_modules/@wordpress/compose/build-module/index.js
- // The `createHigherOrderComponent` helper and helper types.
- // Compose helper (aliased flowRight from Lodash)
- // Higher-order components.
- // Hooks.
- }();
- (window.wp = window.wp || {}).compose = __webpack_exports__;
- /******/ })()
- ;
|