index.modern.js 142 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499
  1. import React__default, { createElement, useRef, useState, useEffect, useCallback, forwardRef, Fragment as Fragment$1 } from 'react';
  2. import { InputBase, Grid, Box, Typography, TextField, NativeSelect, Button } from '@material-ui/core';
  3. import { withStyles, makeStyles } from '@material-ui/core/styles';
  4. import Popper from '@material-ui/core/Popper';
  5. import ListSubheader from '@material-ui/core/ListSubheader';
  6. import Paper from '@material-ui/core/Paper';
  7. import IconButton from '@material-ui/core/IconButton';
  8. import Chip from '@material-ui/core/Chip';
  9. import { createSvgIcon, unstable_useId, useControlled, useEventCallback, setRef } from '@material-ui/core/utils';
  10. import Table$1 from '@material-ui/core/Table';
  11. import TableBody$1 from '@material-ui/core/TableBody';
  12. import TableCell$1 from '@material-ui/core/TableCell';
  13. import TableContainer$1 from '@material-ui/core/TableContainer';
  14. import TableHead$1 from '@material-ui/core/TableHead';
  15. import TablePagination from '@material-ui/core/TablePagination';
  16. import TableRow$1 from '@material-ui/core/TableRow';
  17. import TableSortLabel from '@material-ui/core/TableSortLabel';
  18. function List({
  19. groupName,
  20. members = []
  21. }) {
  22. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("h1", null, "1.0.3"), /*#__PURE__*/React__default.createElement("h5", null, "Group: ", /*#__PURE__*/React__default.createElement("em", null, groupName)), /*#__PURE__*/React__default.createElement("ul", null, /*#__PURE__*/React__default.createElement("p", null, "Members"), members.map(member => /*#__PURE__*/React__default.createElement("li", {
  23. key: member
  24. }, member))));
  25. }
  26. function createCommonjsModule(fn, module) {
  27. return module = { exports: {} }, fn(module, module.exports), module.exports;
  28. }
  29. /** @license React v16.13.1
  30. * react-is.production.min.js
  31. *
  32. * Copyright (c) Facebook, Inc. and its affiliates.
  33. *
  34. * This source code is licensed under the MIT license found in the
  35. * LICENSE file in the root directory of this source tree.
  36. */
  37. var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
  38. Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
  39. function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element=c;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
  40. var Profiler=g;var StrictMode=f;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e};var isLazy=function(a){return z(a)===t};
  41. var isMemo=function(a){return z(a)===r};var isPortal=function(a){return z(a)===d};var isProfiler=function(a){return z(a)===g};var isStrictMode=function(a){return z(a)===f};var isSuspense=function(a){return z(a)===p};
  42. var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
  43. var reactIs_production_min = {
  44. AsyncMode: AsyncMode,
  45. ConcurrentMode: ConcurrentMode,
  46. ContextConsumer: ContextConsumer,
  47. ContextProvider: ContextProvider,
  48. Element: Element,
  49. ForwardRef: ForwardRef,
  50. Fragment: Fragment,
  51. Lazy: Lazy,
  52. Memo: Memo,
  53. Portal: Portal,
  54. Profiler: Profiler,
  55. StrictMode: StrictMode,
  56. Suspense: Suspense,
  57. isAsyncMode: isAsyncMode,
  58. isConcurrentMode: isConcurrentMode,
  59. isContextConsumer: isContextConsumer,
  60. isContextProvider: isContextProvider,
  61. isElement: isElement,
  62. isForwardRef: isForwardRef,
  63. isFragment: isFragment,
  64. isLazy: isLazy,
  65. isMemo: isMemo,
  66. isPortal: isPortal,
  67. isProfiler: isProfiler,
  68. isStrictMode: isStrictMode,
  69. isSuspense: isSuspense,
  70. isValidElementType: isValidElementType,
  71. typeOf: typeOf
  72. };
  73. var reactIs_development = createCommonjsModule(function (module, exports) {
  74. if (process.env.NODE_ENV !== "production") {
  75. (function() {
  76. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  77. // nor polyfill, then a plain number is used for performance.
  78. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  79. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  80. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  81. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  82. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  83. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  84. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  85. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  86. // (unstable) APIs that have been removed. Can we remove the symbols?
  87. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  88. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  89. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  90. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  91. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  92. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  93. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  94. var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
  95. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  96. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  97. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  98. function isValidElementType(type) {
  99. return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  100. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
  101. }
  102. function typeOf(object) {
  103. if (typeof object === 'object' && object !== null) {
  104. var $$typeof = object.$$typeof;
  105. switch ($$typeof) {
  106. case REACT_ELEMENT_TYPE:
  107. var type = object.type;
  108. switch (type) {
  109. case REACT_ASYNC_MODE_TYPE:
  110. case REACT_CONCURRENT_MODE_TYPE:
  111. case REACT_FRAGMENT_TYPE:
  112. case REACT_PROFILER_TYPE:
  113. case REACT_STRICT_MODE_TYPE:
  114. case REACT_SUSPENSE_TYPE:
  115. return type;
  116. default:
  117. var $$typeofType = type && type.$$typeof;
  118. switch ($$typeofType) {
  119. case REACT_CONTEXT_TYPE:
  120. case REACT_FORWARD_REF_TYPE:
  121. case REACT_LAZY_TYPE:
  122. case REACT_MEMO_TYPE:
  123. case REACT_PROVIDER_TYPE:
  124. return $$typeofType;
  125. default:
  126. return $$typeof;
  127. }
  128. }
  129. case REACT_PORTAL_TYPE:
  130. return $$typeof;
  131. }
  132. }
  133. return undefined;
  134. } // AsyncMode is deprecated along with isAsyncMode
  135. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  136. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  137. var ContextConsumer = REACT_CONTEXT_TYPE;
  138. var ContextProvider = REACT_PROVIDER_TYPE;
  139. var Element = REACT_ELEMENT_TYPE;
  140. var ForwardRef = REACT_FORWARD_REF_TYPE;
  141. var Fragment = REACT_FRAGMENT_TYPE;
  142. var Lazy = REACT_LAZY_TYPE;
  143. var Memo = REACT_MEMO_TYPE;
  144. var Portal = REACT_PORTAL_TYPE;
  145. var Profiler = REACT_PROFILER_TYPE;
  146. var StrictMode = REACT_STRICT_MODE_TYPE;
  147. var Suspense = REACT_SUSPENSE_TYPE;
  148. var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
  149. function isAsyncMode(object) {
  150. {
  151. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  152. hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
  153. console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
  154. }
  155. }
  156. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  157. }
  158. function isConcurrentMode(object) {
  159. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  160. }
  161. function isContextConsumer(object) {
  162. return typeOf(object) === REACT_CONTEXT_TYPE;
  163. }
  164. function isContextProvider(object) {
  165. return typeOf(object) === REACT_PROVIDER_TYPE;
  166. }
  167. function isElement(object) {
  168. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  169. }
  170. function isForwardRef(object) {
  171. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  172. }
  173. function isFragment(object) {
  174. return typeOf(object) === REACT_FRAGMENT_TYPE;
  175. }
  176. function isLazy(object) {
  177. return typeOf(object) === REACT_LAZY_TYPE;
  178. }
  179. function isMemo(object) {
  180. return typeOf(object) === REACT_MEMO_TYPE;
  181. }
  182. function isPortal(object) {
  183. return typeOf(object) === REACT_PORTAL_TYPE;
  184. }
  185. function isProfiler(object) {
  186. return typeOf(object) === REACT_PROFILER_TYPE;
  187. }
  188. function isStrictMode(object) {
  189. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  190. }
  191. function isSuspense(object) {
  192. return typeOf(object) === REACT_SUSPENSE_TYPE;
  193. }
  194. exports.AsyncMode = AsyncMode;
  195. exports.ConcurrentMode = ConcurrentMode;
  196. exports.ContextConsumer = ContextConsumer;
  197. exports.ContextProvider = ContextProvider;
  198. exports.Element = Element;
  199. exports.ForwardRef = ForwardRef;
  200. exports.Fragment = Fragment;
  201. exports.Lazy = Lazy;
  202. exports.Memo = Memo;
  203. exports.Portal = Portal;
  204. exports.Profiler = Profiler;
  205. exports.StrictMode = StrictMode;
  206. exports.Suspense = Suspense;
  207. exports.isAsyncMode = isAsyncMode;
  208. exports.isConcurrentMode = isConcurrentMode;
  209. exports.isContextConsumer = isContextConsumer;
  210. exports.isContextProvider = isContextProvider;
  211. exports.isElement = isElement;
  212. exports.isForwardRef = isForwardRef;
  213. exports.isFragment = isFragment;
  214. exports.isLazy = isLazy;
  215. exports.isMemo = isMemo;
  216. exports.isPortal = isPortal;
  217. exports.isProfiler = isProfiler;
  218. exports.isStrictMode = isStrictMode;
  219. exports.isSuspense = isSuspense;
  220. exports.isValidElementType = isValidElementType;
  221. exports.typeOf = typeOf;
  222. })();
  223. }
  224. });
  225. var reactIs = createCommonjsModule(function (module) {
  226. if (process.env.NODE_ENV === 'production') {
  227. module.exports = reactIs_production_min;
  228. } else {
  229. module.exports = reactIs_development;
  230. }
  231. });
  232. /*
  233. object-assign
  234. (c) Sindre Sorhus
  235. @license MIT
  236. */
  237. /* eslint-disable no-unused-vars */
  238. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  239. var hasOwnProperty = Object.prototype.hasOwnProperty;
  240. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  241. function toObject(val) {
  242. if (val === null || val === undefined) {
  243. throw new TypeError('Object.assign cannot be called with null or undefined');
  244. }
  245. return Object(val);
  246. }
  247. function shouldUseNative() {
  248. try {
  249. if (!Object.assign) {
  250. return false;
  251. }
  252. // Detect buggy property enumeration order in older V8 versions.
  253. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  254. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  255. test1[5] = 'de';
  256. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  257. return false;
  258. }
  259. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  260. var test2 = {};
  261. for (var i = 0; i < 10; i++) {
  262. test2['_' + String.fromCharCode(i)] = i;
  263. }
  264. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  265. return test2[n];
  266. });
  267. if (order2.join('') !== '0123456789') {
  268. return false;
  269. }
  270. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  271. var test3 = {};
  272. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  273. test3[letter] = letter;
  274. });
  275. if (Object.keys(Object.assign({}, test3)).join('') !==
  276. 'abcdefghijklmnopqrst') {
  277. return false;
  278. }
  279. return true;
  280. } catch (err) {
  281. // We don't expect any of the above to throw, but better to be safe.
  282. return false;
  283. }
  284. }
  285. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  286. var from;
  287. var to = toObject(target);
  288. var symbols;
  289. for (var s = 1; s < arguments.length; s++) {
  290. from = Object(arguments[s]);
  291. for (var key in from) {
  292. if (hasOwnProperty.call(from, key)) {
  293. to[key] = from[key];
  294. }
  295. }
  296. if (getOwnPropertySymbols) {
  297. symbols = getOwnPropertySymbols(from);
  298. for (var i = 0; i < symbols.length; i++) {
  299. if (propIsEnumerable.call(from, symbols[i])) {
  300. to[symbols[i]] = from[symbols[i]];
  301. }
  302. }
  303. }
  304. }
  305. return to;
  306. };
  307. /**
  308. * Copyright (c) 2013-present, Facebook, Inc.
  309. *
  310. * This source code is licensed under the MIT license found in the
  311. * LICENSE file in the root directory of this source tree.
  312. */
  313. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  314. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  315. var printWarning = function() {};
  316. if (process.env.NODE_ENV !== 'production') {
  317. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  318. var loggedTypeFailures = {};
  319. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  320. printWarning = function(text) {
  321. var message = 'Warning: ' + text;
  322. if (typeof console !== 'undefined') {
  323. console.error(message);
  324. }
  325. try {
  326. // --- Welcome to debugging React ---
  327. // This error was thrown as a convenience so that you can use this stack
  328. // to find the callsite that caused this warning to fire.
  329. throw new Error(message);
  330. } catch (x) {}
  331. };
  332. }
  333. /**
  334. * Assert that the values match with the type specs.
  335. * Error messages are memorized and will only be shown once.
  336. *
  337. * @param {object} typeSpecs Map of name to a ReactPropType
  338. * @param {object} values Runtime values that need to be type-checked
  339. * @param {string} location e.g. "prop", "context", "child context"
  340. * @param {string} componentName Name of the component for error messages.
  341. * @param {?Function} getStack Returns the component stack.
  342. * @private
  343. */
  344. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  345. if (process.env.NODE_ENV !== 'production') {
  346. for (var typeSpecName in typeSpecs) {
  347. if (has(typeSpecs, typeSpecName)) {
  348. var error;
  349. // Prop type validation may throw. In case they do, we don't want to
  350. // fail the render phase where it didn't fail before. So we log it.
  351. // After these have been cleaned up, we'll let them throw.
  352. try {
  353. // This is intentionally an invariant that gets caught. It's the same
  354. // behavior as without this statement except with a better message.
  355. if (typeof typeSpecs[typeSpecName] !== 'function') {
  356. var err = Error(
  357. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  358. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  359. );
  360. err.name = 'Invariant Violation';
  361. throw err;
  362. }
  363. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  364. } catch (ex) {
  365. error = ex;
  366. }
  367. if (error && !(error instanceof Error)) {
  368. printWarning(
  369. (componentName || 'React class') + ': type specification of ' +
  370. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  371. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  372. 'You may have forgotten to pass an argument to the type checker ' +
  373. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  374. 'shape all require an argument).'
  375. );
  376. }
  377. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  378. // Only monitor this failure once because there tends to be a lot of the
  379. // same error.
  380. loggedTypeFailures[error.message] = true;
  381. var stack = getStack ? getStack() : '';
  382. printWarning(
  383. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  384. );
  385. }
  386. }
  387. }
  388. }
  389. }
  390. /**
  391. * Resets warning cache when testing.
  392. *
  393. * @private
  394. */
  395. checkPropTypes.resetWarningCache = function() {
  396. if (process.env.NODE_ENV !== 'production') {
  397. loggedTypeFailures = {};
  398. }
  399. };
  400. var checkPropTypes_1 = checkPropTypes;
  401. var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  402. var printWarning$1 = function() {};
  403. if (process.env.NODE_ENV !== 'production') {
  404. printWarning$1 = function(text) {
  405. var message = 'Warning: ' + text;
  406. if (typeof console !== 'undefined') {
  407. console.error(message);
  408. }
  409. try {
  410. // --- Welcome to debugging React ---
  411. // This error was thrown as a convenience so that you can use this stack
  412. // to find the callsite that caused this warning to fire.
  413. throw new Error(message);
  414. } catch (x) {}
  415. };
  416. }
  417. function emptyFunctionThatReturnsNull() {
  418. return null;
  419. }
  420. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  421. /* global Symbol */
  422. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  423. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  424. /**
  425. * Returns the iterator method function contained on the iterable object.
  426. *
  427. * Be sure to invoke the function with the iterable as context:
  428. *
  429. * var iteratorFn = getIteratorFn(myIterable);
  430. * if (iteratorFn) {
  431. * var iterator = iteratorFn.call(myIterable);
  432. * ...
  433. * }
  434. *
  435. * @param {?object} maybeIterable
  436. * @return {?function}
  437. */
  438. function getIteratorFn(maybeIterable) {
  439. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  440. if (typeof iteratorFn === 'function') {
  441. return iteratorFn;
  442. }
  443. }
  444. /**
  445. * Collection of methods that allow declaration and validation of props that are
  446. * supplied to React components. Example usage:
  447. *
  448. * var Props = require('ReactPropTypes');
  449. * var MyArticle = React.createClass({
  450. * propTypes: {
  451. * // An optional string prop named "description".
  452. * description: Props.string,
  453. *
  454. * // A required enum prop named "category".
  455. * category: Props.oneOf(['News','Photos']).isRequired,
  456. *
  457. * // A prop named "dialog" that requires an instance of Dialog.
  458. * dialog: Props.instanceOf(Dialog).isRequired
  459. * },
  460. * render: function() { ... }
  461. * });
  462. *
  463. * A more formal specification of how these methods are used:
  464. *
  465. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  466. * decl := ReactPropTypes.{type}(.isRequired)?
  467. *
  468. * Each and every declaration produces a function with the same signature. This
  469. * allows the creation of custom validation functions. For example:
  470. *
  471. * var MyLink = React.createClass({
  472. * propTypes: {
  473. * // An optional string or URI prop named "href".
  474. * href: function(props, propName, componentName) {
  475. * var propValue = props[propName];
  476. * if (propValue != null && typeof propValue !== 'string' &&
  477. * !(propValue instanceof URI)) {
  478. * return new Error(
  479. * 'Expected a string or an URI for ' + propName + ' in ' +
  480. * componentName
  481. * );
  482. * }
  483. * }
  484. * },
  485. * render: function() {...}
  486. * });
  487. *
  488. * @internal
  489. */
  490. var ANONYMOUS = '<<anonymous>>';
  491. // Important!
  492. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  493. var ReactPropTypes = {
  494. array: createPrimitiveTypeChecker('array'),
  495. bool: createPrimitiveTypeChecker('boolean'),
  496. func: createPrimitiveTypeChecker('function'),
  497. number: createPrimitiveTypeChecker('number'),
  498. object: createPrimitiveTypeChecker('object'),
  499. string: createPrimitiveTypeChecker('string'),
  500. symbol: createPrimitiveTypeChecker('symbol'),
  501. any: createAnyTypeChecker(),
  502. arrayOf: createArrayOfTypeChecker,
  503. element: createElementTypeChecker(),
  504. elementType: createElementTypeTypeChecker(),
  505. instanceOf: createInstanceTypeChecker,
  506. node: createNodeChecker(),
  507. objectOf: createObjectOfTypeChecker,
  508. oneOf: createEnumTypeChecker,
  509. oneOfType: createUnionTypeChecker,
  510. shape: createShapeTypeChecker,
  511. exact: createStrictShapeTypeChecker,
  512. };
  513. /**
  514. * inlined Object.is polyfill to avoid requiring consumers ship their own
  515. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  516. */
  517. /*eslint-disable no-self-compare*/
  518. function is(x, y) {
  519. // SameValue algorithm
  520. if (x === y) {
  521. // Steps 1-5, 7-10
  522. // Steps 6.b-6.e: +0 != -0
  523. return x !== 0 || 1 / x === 1 / y;
  524. } else {
  525. // Step 6.a: NaN == NaN
  526. return x !== x && y !== y;
  527. }
  528. }
  529. /*eslint-enable no-self-compare*/
  530. /**
  531. * We use an Error-like object for backward compatibility as people may call
  532. * PropTypes directly and inspect their output. However, we don't use real
  533. * Errors anymore. We don't inspect their stack anyway, and creating them
  534. * is prohibitively expensive if they are created too often, such as what
  535. * happens in oneOfType() for any type before the one that matched.
  536. */
  537. function PropTypeError(message) {
  538. this.message = message;
  539. this.stack = '';
  540. }
  541. // Make `instanceof Error` still work for returned errors.
  542. PropTypeError.prototype = Error.prototype;
  543. function createChainableTypeChecker(validate) {
  544. if (process.env.NODE_ENV !== 'production') {
  545. var manualPropTypeCallCache = {};
  546. var manualPropTypeWarningCount = 0;
  547. }
  548. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  549. componentName = componentName || ANONYMOUS;
  550. propFullName = propFullName || propName;
  551. if (secret !== ReactPropTypesSecret_1) {
  552. if (throwOnDirectAccess) {
  553. // New behavior only for users of `prop-types` package
  554. var err = new Error(
  555. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  556. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  557. 'Read more at http://fb.me/use-check-prop-types'
  558. );
  559. err.name = 'Invariant Violation';
  560. throw err;
  561. } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
  562. // Old behavior for people using React.PropTypes
  563. var cacheKey = componentName + ':' + propName;
  564. if (
  565. !manualPropTypeCallCache[cacheKey] &&
  566. // Avoid spamming the console because they are often not actionable except for lib authors
  567. manualPropTypeWarningCount < 3
  568. ) {
  569. printWarning$1(
  570. 'You are manually calling a React.PropTypes validation ' +
  571. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  572. 'and will throw in the standalone `prop-types` package. ' +
  573. 'You may be seeing this warning due to a third-party PropTypes ' +
  574. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  575. );
  576. manualPropTypeCallCache[cacheKey] = true;
  577. manualPropTypeWarningCount++;
  578. }
  579. }
  580. }
  581. if (props[propName] == null) {
  582. if (isRequired) {
  583. if (props[propName] === null) {
  584. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  585. }
  586. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  587. }
  588. return null;
  589. } else {
  590. return validate(props, propName, componentName, location, propFullName);
  591. }
  592. }
  593. var chainedCheckType = checkType.bind(null, false);
  594. chainedCheckType.isRequired = checkType.bind(null, true);
  595. return chainedCheckType;
  596. }
  597. function createPrimitiveTypeChecker(expectedType) {
  598. function validate(props, propName, componentName, location, propFullName, secret) {
  599. var propValue = props[propName];
  600. var propType = getPropType(propValue);
  601. if (propType !== expectedType) {
  602. // `propValue` being instance of, say, date/regexp, pass the 'object'
  603. // check, but we can offer a more precise error message here rather than
  604. // 'of type `object`'.
  605. var preciseType = getPreciseType(propValue);
  606. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  607. }
  608. return null;
  609. }
  610. return createChainableTypeChecker(validate);
  611. }
  612. function createAnyTypeChecker() {
  613. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  614. }
  615. function createArrayOfTypeChecker(typeChecker) {
  616. function validate(props, propName, componentName, location, propFullName) {
  617. if (typeof typeChecker !== 'function') {
  618. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  619. }
  620. var propValue = props[propName];
  621. if (!Array.isArray(propValue)) {
  622. var propType = getPropType(propValue);
  623. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  624. }
  625. for (var i = 0; i < propValue.length; i++) {
  626. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  627. if (error instanceof Error) {
  628. return error;
  629. }
  630. }
  631. return null;
  632. }
  633. return createChainableTypeChecker(validate);
  634. }
  635. function createElementTypeChecker() {
  636. function validate(props, propName, componentName, location, propFullName) {
  637. var propValue = props[propName];
  638. if (!isValidElement(propValue)) {
  639. var propType = getPropType(propValue);
  640. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  641. }
  642. return null;
  643. }
  644. return createChainableTypeChecker(validate);
  645. }
  646. function createElementTypeTypeChecker() {
  647. function validate(props, propName, componentName, location, propFullName) {
  648. var propValue = props[propName];
  649. if (!reactIs.isValidElementType(propValue)) {
  650. var propType = getPropType(propValue);
  651. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  652. }
  653. return null;
  654. }
  655. return createChainableTypeChecker(validate);
  656. }
  657. function createInstanceTypeChecker(expectedClass) {
  658. function validate(props, propName, componentName, location, propFullName) {
  659. if (!(props[propName] instanceof expectedClass)) {
  660. var expectedClassName = expectedClass.name || ANONYMOUS;
  661. var actualClassName = getClassName(props[propName]);
  662. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  663. }
  664. return null;
  665. }
  666. return createChainableTypeChecker(validate);
  667. }
  668. function createEnumTypeChecker(expectedValues) {
  669. if (!Array.isArray(expectedValues)) {
  670. if (process.env.NODE_ENV !== 'production') {
  671. if (arguments.length > 1) {
  672. printWarning$1(
  673. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  674. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  675. );
  676. } else {
  677. printWarning$1('Invalid argument supplied to oneOf, expected an array.');
  678. }
  679. }
  680. return emptyFunctionThatReturnsNull;
  681. }
  682. function validate(props, propName, componentName, location, propFullName) {
  683. var propValue = props[propName];
  684. for (var i = 0; i < expectedValues.length; i++) {
  685. if (is(propValue, expectedValues[i])) {
  686. return null;
  687. }
  688. }
  689. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  690. var type = getPreciseType(value);
  691. if (type === 'symbol') {
  692. return String(value);
  693. }
  694. return value;
  695. });
  696. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  697. }
  698. return createChainableTypeChecker(validate);
  699. }
  700. function createObjectOfTypeChecker(typeChecker) {
  701. function validate(props, propName, componentName, location, propFullName) {
  702. if (typeof typeChecker !== 'function') {
  703. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  704. }
  705. var propValue = props[propName];
  706. var propType = getPropType(propValue);
  707. if (propType !== 'object') {
  708. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  709. }
  710. for (var key in propValue) {
  711. if (has$1(propValue, key)) {
  712. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  713. if (error instanceof Error) {
  714. return error;
  715. }
  716. }
  717. }
  718. return null;
  719. }
  720. return createChainableTypeChecker(validate);
  721. }
  722. function createUnionTypeChecker(arrayOfTypeCheckers) {
  723. if (!Array.isArray(arrayOfTypeCheckers)) {
  724. process.env.NODE_ENV !== 'production' ? printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  725. return emptyFunctionThatReturnsNull;
  726. }
  727. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  728. var checker = arrayOfTypeCheckers[i];
  729. if (typeof checker !== 'function') {
  730. printWarning$1(
  731. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  732. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  733. );
  734. return emptyFunctionThatReturnsNull;
  735. }
  736. }
  737. function validate(props, propName, componentName, location, propFullName) {
  738. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  739. var checker = arrayOfTypeCheckers[i];
  740. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  741. return null;
  742. }
  743. }
  744. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  745. }
  746. return createChainableTypeChecker(validate);
  747. }
  748. function createNodeChecker() {
  749. function validate(props, propName, componentName, location, propFullName) {
  750. if (!isNode(props[propName])) {
  751. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  752. }
  753. return null;
  754. }
  755. return createChainableTypeChecker(validate);
  756. }
  757. function createShapeTypeChecker(shapeTypes) {
  758. function validate(props, propName, componentName, location, propFullName) {
  759. var propValue = props[propName];
  760. var propType = getPropType(propValue);
  761. if (propType !== 'object') {
  762. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  763. }
  764. for (var key in shapeTypes) {
  765. var checker = shapeTypes[key];
  766. if (!checker) {
  767. continue;
  768. }
  769. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  770. if (error) {
  771. return error;
  772. }
  773. }
  774. return null;
  775. }
  776. return createChainableTypeChecker(validate);
  777. }
  778. function createStrictShapeTypeChecker(shapeTypes) {
  779. function validate(props, propName, componentName, location, propFullName) {
  780. var propValue = props[propName];
  781. var propType = getPropType(propValue);
  782. if (propType !== 'object') {
  783. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  784. }
  785. // We need to check all keys in case some are required but missing from
  786. // props.
  787. var allKeys = objectAssign({}, props[propName], shapeTypes);
  788. for (var key in allKeys) {
  789. var checker = shapeTypes[key];
  790. if (!checker) {
  791. return new PropTypeError(
  792. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  793. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  794. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  795. );
  796. }
  797. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  798. if (error) {
  799. return error;
  800. }
  801. }
  802. return null;
  803. }
  804. return createChainableTypeChecker(validate);
  805. }
  806. function isNode(propValue) {
  807. switch (typeof propValue) {
  808. case 'number':
  809. case 'string':
  810. case 'undefined':
  811. return true;
  812. case 'boolean':
  813. return !propValue;
  814. case 'object':
  815. if (Array.isArray(propValue)) {
  816. return propValue.every(isNode);
  817. }
  818. if (propValue === null || isValidElement(propValue)) {
  819. return true;
  820. }
  821. var iteratorFn = getIteratorFn(propValue);
  822. if (iteratorFn) {
  823. var iterator = iteratorFn.call(propValue);
  824. var step;
  825. if (iteratorFn !== propValue.entries) {
  826. while (!(step = iterator.next()).done) {
  827. if (!isNode(step.value)) {
  828. return false;
  829. }
  830. }
  831. } else {
  832. // Iterator will provide entry [k,v] tuples rather than values.
  833. while (!(step = iterator.next()).done) {
  834. var entry = step.value;
  835. if (entry) {
  836. if (!isNode(entry[1])) {
  837. return false;
  838. }
  839. }
  840. }
  841. }
  842. } else {
  843. return false;
  844. }
  845. return true;
  846. default:
  847. return false;
  848. }
  849. }
  850. function isSymbol(propType, propValue) {
  851. // Native Symbol.
  852. if (propType === 'symbol') {
  853. return true;
  854. }
  855. // falsy value can't be a Symbol
  856. if (!propValue) {
  857. return false;
  858. }
  859. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  860. if (propValue['@@toStringTag'] === 'Symbol') {
  861. return true;
  862. }
  863. // Fallback for non-spec compliant Symbols which are polyfilled.
  864. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  865. return true;
  866. }
  867. return false;
  868. }
  869. // Equivalent of `typeof` but with special handling for array and regexp.
  870. function getPropType(propValue) {
  871. var propType = typeof propValue;
  872. if (Array.isArray(propValue)) {
  873. return 'array';
  874. }
  875. if (propValue instanceof RegExp) {
  876. // Old webkits (at least until Android 4.0) return 'function' rather than
  877. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  878. // passes PropTypes.object.
  879. return 'object';
  880. }
  881. if (isSymbol(propType, propValue)) {
  882. return 'symbol';
  883. }
  884. return propType;
  885. }
  886. // This handles more types than `getPropType`. Only used for error messages.
  887. // See `createPrimitiveTypeChecker`.
  888. function getPreciseType(propValue) {
  889. if (typeof propValue === 'undefined' || propValue === null) {
  890. return '' + propValue;
  891. }
  892. var propType = getPropType(propValue);
  893. if (propType === 'object') {
  894. if (propValue instanceof Date) {
  895. return 'date';
  896. } else if (propValue instanceof RegExp) {
  897. return 'regexp';
  898. }
  899. }
  900. return propType;
  901. }
  902. // Returns a string that is postfixed to a warning about an invalid type.
  903. // For example, "undefined" or "of type array"
  904. function getPostfixForTypeWarning(value) {
  905. var type = getPreciseType(value);
  906. switch (type) {
  907. case 'array':
  908. case 'object':
  909. return 'an ' + type;
  910. case 'boolean':
  911. case 'date':
  912. case 'regexp':
  913. return 'a ' + type;
  914. default:
  915. return type;
  916. }
  917. }
  918. // Returns class name of the object, if any.
  919. function getClassName(propValue) {
  920. if (!propValue.constructor || !propValue.constructor.name) {
  921. return ANONYMOUS;
  922. }
  923. return propValue.constructor.name;
  924. }
  925. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  926. ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  927. ReactPropTypes.PropTypes = ReactPropTypes;
  928. return ReactPropTypes;
  929. };
  930. function emptyFunction() {}
  931. function emptyFunctionWithReset() {}
  932. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  933. var factoryWithThrowingShims = function() {
  934. function shim(props, propName, componentName, location, propFullName, secret) {
  935. if (secret === ReactPropTypesSecret_1) {
  936. // It is still safe when called from React.
  937. return;
  938. }
  939. var err = new Error(
  940. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  941. 'Use PropTypes.checkPropTypes() to call them. ' +
  942. 'Read more at http://fb.me/use-check-prop-types'
  943. );
  944. err.name = 'Invariant Violation';
  945. throw err;
  946. } shim.isRequired = shim;
  947. function getShim() {
  948. return shim;
  949. } // Important!
  950. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  951. var ReactPropTypes = {
  952. array: shim,
  953. bool: shim,
  954. func: shim,
  955. number: shim,
  956. object: shim,
  957. string: shim,
  958. symbol: shim,
  959. any: shim,
  960. arrayOf: getShim,
  961. element: shim,
  962. elementType: shim,
  963. instanceOf: getShim,
  964. node: shim,
  965. objectOf: getShim,
  966. oneOf: getShim,
  967. oneOfType: getShim,
  968. shape: getShim,
  969. exact: getShim,
  970. checkPropTypes: emptyFunctionWithReset,
  971. resetWarningCache: emptyFunction
  972. };
  973. ReactPropTypes.PropTypes = ReactPropTypes;
  974. return ReactPropTypes;
  975. };
  976. var propTypes = createCommonjsModule(function (module) {
  977. /**
  978. * Copyright (c) 2013-present, Facebook, Inc.
  979. *
  980. * This source code is licensed under the MIT license found in the
  981. * LICENSE file in the root directory of this source tree.
  982. */
  983. if (process.env.NODE_ENV !== 'production') {
  984. var ReactIs = reactIs;
  985. // By explicitly using `prop-types` you are opting into new development behavior.
  986. // http://fb.me/prop-types-in-prod
  987. var throwOnDirectAccess = true;
  988. module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  989. } else {
  990. // By explicitly using `prop-types` you are opting into new production behavior.
  991. // http://fb.me/prop-types-in-prod
  992. module.exports = factoryWithThrowingShims();
  993. }
  994. });
  995. function _objectWithoutPropertiesLoose(source, excluded) {
  996. if (source == null) return {};
  997. var target = {};
  998. var sourceKeys = Object.keys(source);
  999. var key, i;
  1000. for (i = 0; i < sourceKeys.length; i++) {
  1001. key = sourceKeys[i];
  1002. if (excluded.indexOf(key) >= 0) continue;
  1003. target[key] = source[key];
  1004. }
  1005. return target;
  1006. }
  1007. function _objectWithoutProperties(source, excluded) {
  1008. if (source == null) return {};
  1009. var target = _objectWithoutPropertiesLoose(source, excluded);
  1010. var key, i;
  1011. if (Object.getOwnPropertySymbols) {
  1012. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  1013. for (i = 0; i < sourceSymbolKeys.length; i++) {
  1014. key = sourceSymbolKeys[i];
  1015. if (excluded.indexOf(key) >= 0) continue;
  1016. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  1017. target[key] = source[key];
  1018. }
  1019. }
  1020. return target;
  1021. }
  1022. function _defineProperty(obj, key, value) {
  1023. if (key in obj) {
  1024. Object.defineProperty(obj, key, {
  1025. value: value,
  1026. enumerable: true,
  1027. configurable: true,
  1028. writable: true
  1029. });
  1030. } else {
  1031. obj[key] = value;
  1032. }
  1033. return obj;
  1034. }
  1035. function _extends() {
  1036. _extends = Object.assign || function (target) {
  1037. for (var i = 1; i < arguments.length; i++) {
  1038. var source = arguments[i];
  1039. for (var key in source) {
  1040. if (Object.prototype.hasOwnProperty.call(source, key)) {
  1041. target[key] = source[key];
  1042. }
  1043. }
  1044. }
  1045. return target;
  1046. };
  1047. return _extends.apply(this, arguments);
  1048. }
  1049. function toVal(mix) {
  1050. var k, y, str='';
  1051. if (typeof mix === 'string' || typeof mix === 'number') {
  1052. str += mix;
  1053. } else if (typeof mix === 'object') {
  1054. if (Array.isArray(mix)) {
  1055. for (k=0; k < mix.length; k++) {
  1056. if (mix[k]) {
  1057. if (y = toVal(mix[k])) {
  1058. str && (str += ' ');
  1059. str += y;
  1060. }
  1061. }
  1062. }
  1063. } else {
  1064. for (k in mix) {
  1065. if (mix[k]) {
  1066. str && (str += ' ');
  1067. str += k;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. return str;
  1073. }
  1074. function clsx () {
  1075. var i=0, tmp, x, str='';
  1076. while (i < arguments.length) {
  1077. if (tmp = arguments[i++]) {
  1078. if (x = toVal(tmp)) {
  1079. str && (str += ' ');
  1080. str += x;
  1081. }
  1082. }
  1083. }
  1084. return str;
  1085. }
  1086. /**
  1087. * @ignore - internal component.
  1088. */
  1089. var CloseIcon = createSvgIcon( /*#__PURE__*/createElement("path", {
  1090. d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
  1091. }), 'Close');
  1092. /**
  1093. * @ignore - internal component.
  1094. */
  1095. var ArrowDropDownIcon = createSvgIcon( /*#__PURE__*/createElement("path", {
  1096. d: "M7 10l5 5 5-5z"
  1097. }), 'ArrowDropDown');
  1098. function _arrayWithHoles(arr) {
  1099. if (Array.isArray(arr)) return arr;
  1100. }
  1101. function _iterableToArrayLimit(arr, i) {
  1102. if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
  1103. var _arr = [];
  1104. var _n = true;
  1105. var _d = false;
  1106. var _e = undefined;
  1107. try {
  1108. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  1109. _arr.push(_s.value);
  1110. if (i && _arr.length === i) break;
  1111. }
  1112. } catch (err) {
  1113. _d = true;
  1114. _e = err;
  1115. } finally {
  1116. try {
  1117. if (!_n && _i["return"] != null) _i["return"]();
  1118. } finally {
  1119. if (_d) throw _e;
  1120. }
  1121. }
  1122. return _arr;
  1123. }
  1124. function _arrayLikeToArray(arr, len) {
  1125. if (len == null || len > arr.length) len = arr.length;
  1126. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1127. arr2[i] = arr[i];
  1128. }
  1129. return arr2;
  1130. }
  1131. function _unsupportedIterableToArray(o, minLen) {
  1132. if (!o) return;
  1133. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  1134. var n = Object.prototype.toString.call(o).slice(8, -1);
  1135. if (n === "Object" && o.constructor) n = o.constructor.name;
  1136. if (n === "Map" || n === "Set") return Array.from(o);
  1137. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  1138. }
  1139. function _nonIterableRest() {
  1140. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1141. }
  1142. function _slicedToArray(arr, i) {
  1143. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  1144. }
  1145. function _typeof(obj) {
  1146. "@babel/helpers - typeof";
  1147. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  1148. _typeof = function _typeof(obj) {
  1149. return typeof obj;
  1150. };
  1151. } else {
  1152. _typeof = function _typeof(obj) {
  1153. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1154. };
  1155. }
  1156. return _typeof(obj);
  1157. }
  1158. // Give up on IE 11 support for this feature
  1159. function stripDiacritics(string) {
  1160. return typeof string.normalize !== 'undefined' ? string.normalize('NFD').replace(/[\u0300-\u036f]/g, '') : string;
  1161. }
  1162. function createFilterOptions() {
  1163. var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1164. var _config$ignoreAccents = config.ignoreAccents,
  1165. ignoreAccents = _config$ignoreAccents === void 0 ? true : _config$ignoreAccents,
  1166. _config$ignoreCase = config.ignoreCase,
  1167. ignoreCase = _config$ignoreCase === void 0 ? true : _config$ignoreCase,
  1168. limit = config.limit,
  1169. _config$matchFrom = config.matchFrom,
  1170. matchFrom = _config$matchFrom === void 0 ? 'any' : _config$matchFrom,
  1171. stringify = config.stringify,
  1172. _config$trim = config.trim,
  1173. trim = _config$trim === void 0 ? false : _config$trim;
  1174. return function (options, _ref) {
  1175. var inputValue = _ref.inputValue,
  1176. getOptionLabel = _ref.getOptionLabel;
  1177. var input = trim ? inputValue.trim() : inputValue;
  1178. if (ignoreCase) {
  1179. input = input.toLowerCase();
  1180. }
  1181. if (ignoreAccents) {
  1182. input = stripDiacritics(input);
  1183. }
  1184. var filteredOptions = options.filter(function (option) {
  1185. var candidate = (stringify || getOptionLabel)(option);
  1186. if (ignoreCase) {
  1187. candidate = candidate.toLowerCase();
  1188. }
  1189. if (ignoreAccents) {
  1190. candidate = stripDiacritics(candidate);
  1191. }
  1192. return matchFrom === 'start' ? candidate.indexOf(input) === 0 : candidate.indexOf(input) > -1;
  1193. });
  1194. return typeof limit === 'number' ? filteredOptions.slice(0, limit) : filteredOptions;
  1195. };
  1196. } // To replace with .findIndex() once we stop IE 11 support.
  1197. function findIndex(array, comp) {
  1198. for (var i = 0; i < array.length; i += 1) {
  1199. if (comp(array[i])) {
  1200. return i;
  1201. }
  1202. }
  1203. return -1;
  1204. }
  1205. var defaultFilterOptions = createFilterOptions(); // Number of options to jump in list box when pageup and pagedown keys are used.
  1206. var pageSize = 5;
  1207. function useAutocomplete(props) {
  1208. var _props$autoComplete = props.autoComplete,
  1209. autoComplete = _props$autoComplete === void 0 ? false : _props$autoComplete,
  1210. _props$autoHighlight = props.autoHighlight,
  1211. autoHighlight = _props$autoHighlight === void 0 ? false : _props$autoHighlight,
  1212. _props$autoSelect = props.autoSelect,
  1213. autoSelect = _props$autoSelect === void 0 ? false : _props$autoSelect,
  1214. _props$blurOnSelect = props.blurOnSelect,
  1215. blurOnSelect = _props$blurOnSelect === void 0 ? false : _props$blurOnSelect,
  1216. _props$clearOnBlur = props.clearOnBlur,
  1217. clearOnBlur = _props$clearOnBlur === void 0 ? !props.freeSolo : _props$clearOnBlur,
  1218. _props$clearOnEscape = props.clearOnEscape,
  1219. clearOnEscape = _props$clearOnEscape === void 0 ? false : _props$clearOnEscape,
  1220. _props$componentName = props.componentName,
  1221. componentName = _props$componentName === void 0 ? 'useAutocomplete' : _props$componentName,
  1222. _props$debug = props.debug,
  1223. debug = _props$debug === void 0 ? false : _props$debug,
  1224. _props$defaultValue = props.defaultValue,
  1225. defaultValue = _props$defaultValue === void 0 ? props.multiple ? [] : null : _props$defaultValue,
  1226. _props$disableClearab = props.disableClearable,
  1227. disableClearable = _props$disableClearab === void 0 ? false : _props$disableClearab,
  1228. _props$disableCloseOn = props.disableCloseOnSelect,
  1229. disableCloseOnSelect = _props$disableCloseOn === void 0 ? false : _props$disableCloseOn,
  1230. _props$disabledItemsF = props.disabledItemsFocusable,
  1231. disabledItemsFocusable = _props$disabledItemsF === void 0 ? false : _props$disabledItemsF,
  1232. _props$disableListWra = props.disableListWrap,
  1233. disableListWrap = _props$disableListWra === void 0 ? false : _props$disableListWra,
  1234. _props$filterOptions = props.filterOptions,
  1235. filterOptions = _props$filterOptions === void 0 ? defaultFilterOptions : _props$filterOptions,
  1236. _props$filterSelected = props.filterSelectedOptions,
  1237. filterSelectedOptions = _props$filterSelected === void 0 ? false : _props$filterSelected,
  1238. _props$freeSolo = props.freeSolo,
  1239. freeSolo = _props$freeSolo === void 0 ? false : _props$freeSolo,
  1240. getOptionDisabled = props.getOptionDisabled,
  1241. _props$getOptionLabel = props.getOptionLabel,
  1242. getOptionLabelProp = _props$getOptionLabel === void 0 ? function (option) {
  1243. return option;
  1244. } : _props$getOptionLabel,
  1245. _props$getOptionSelec = props.getOptionSelected,
  1246. getOptionSelected = _props$getOptionSelec === void 0 ? function (option, value) {
  1247. return option === value;
  1248. } : _props$getOptionSelec,
  1249. groupBy = props.groupBy,
  1250. _props$handleHomeEndK = props.handleHomeEndKeys,
  1251. handleHomeEndKeys = _props$handleHomeEndK === void 0 ? !props.freeSolo : _props$handleHomeEndK,
  1252. idProp = props.id,
  1253. _props$includeInputIn = props.includeInputInList,
  1254. includeInputInList = _props$includeInputIn === void 0 ? false : _props$includeInputIn,
  1255. inputValueProp = props.inputValue,
  1256. _props$multiple = props.multiple,
  1257. multiple = _props$multiple === void 0 ? false : _props$multiple,
  1258. onChange = props.onChange,
  1259. onClose = props.onClose,
  1260. onHighlightChange = props.onHighlightChange,
  1261. onInputChange = props.onInputChange,
  1262. onOpen = props.onOpen,
  1263. openProp = props.open,
  1264. _props$openOnFocus = props.openOnFocus,
  1265. openOnFocus = _props$openOnFocus === void 0 ? false : _props$openOnFocus,
  1266. options = props.options,
  1267. _props$selectOnFocus = props.selectOnFocus,
  1268. selectOnFocus = _props$selectOnFocus === void 0 ? !props.freeSolo : _props$selectOnFocus,
  1269. valueProp = props.value;
  1270. var id = unstable_useId(idProp);
  1271. var getOptionLabel = getOptionLabelProp;
  1272. if (process.env.NODE_ENV !== 'production') {
  1273. getOptionLabel = function getOptionLabel(option) {
  1274. var optionLabel = getOptionLabelProp(option);
  1275. if (typeof optionLabel !== 'string') {
  1276. var erroneousReturn = optionLabel === undefined ? 'undefined' : "".concat(_typeof(optionLabel), " (").concat(optionLabel, ")");
  1277. console.error("Material-UI: The `getOptionLabel` method of ".concat(componentName, " returned ").concat(erroneousReturn, " instead of a string for ").concat(JSON.stringify(option), "."));
  1278. }
  1279. return optionLabel;
  1280. };
  1281. }
  1282. var ignoreFocus = useRef(false);
  1283. var firstFocus = useRef(true);
  1284. var inputRef = useRef(null);
  1285. var listboxRef = useRef(null);
  1286. var _React$useState = useState(null),
  1287. anchorEl = _React$useState[0],
  1288. setAnchorEl = _React$useState[1];
  1289. var _React$useState2 = useState(-1),
  1290. focusedTag = _React$useState2[0],
  1291. setFocusedTag = _React$useState2[1];
  1292. var defaultHighlighted = autoHighlight ? 0 : -1;
  1293. var highlightedIndexRef = useRef(defaultHighlighted);
  1294. var _useControlled = useControlled({
  1295. controlled: valueProp,
  1296. default: defaultValue,
  1297. name: componentName
  1298. }),
  1299. _useControlled2 = _slicedToArray(_useControlled, 2),
  1300. value = _useControlled2[0],
  1301. setValue = _useControlled2[1];
  1302. var _useControlled3 = useControlled({
  1303. controlled: inputValueProp,
  1304. default: '',
  1305. name: componentName,
  1306. state: 'inputValue'
  1307. }),
  1308. _useControlled4 = _slicedToArray(_useControlled3, 2),
  1309. inputValue = _useControlled4[0],
  1310. setInputValue = _useControlled4[1];
  1311. var _React$useState3 = useState(false),
  1312. focused = _React$useState3[0],
  1313. setFocused = _React$useState3[1];
  1314. var resetInputValue = useEventCallback(function (event, newValue) {
  1315. var newInputValue;
  1316. if (multiple) {
  1317. newInputValue = '';
  1318. } else if (newValue == null) {
  1319. newInputValue = '';
  1320. } else {
  1321. var optionLabel = getOptionLabel(newValue);
  1322. newInputValue = typeof optionLabel === 'string' ? optionLabel : '';
  1323. }
  1324. if (inputValue === newInputValue) {
  1325. return;
  1326. }
  1327. setInputValue(newInputValue);
  1328. if (onInputChange) {
  1329. onInputChange(event, newInputValue, 'reset');
  1330. }
  1331. });
  1332. useEffect(function () {
  1333. resetInputValue(null, value);
  1334. }, [value, resetInputValue]);
  1335. var _useControlled5 = useControlled({
  1336. controlled: openProp,
  1337. default: false,
  1338. name: componentName,
  1339. state: 'open'
  1340. }),
  1341. _useControlled6 = _slicedToArray(_useControlled5, 2),
  1342. open = _useControlled6[0],
  1343. setOpenState = _useControlled6[1];
  1344. var inputValueIsSelectedValue = !multiple && value != null && inputValue === getOptionLabel(value);
  1345. var popupOpen = open;
  1346. var filteredOptions = popupOpen ? filterOptions(options.filter(function (option) {
  1347. if (filterSelectedOptions && (multiple ? value : [value]).some(function (value2) {
  1348. return value2 !== null && getOptionSelected(option, value2);
  1349. })) {
  1350. return false;
  1351. }
  1352. return true;
  1353. }), // we use the empty string to manipulate `filterOptions` to not filter any options
  1354. // i.e. the filter predicate always returns true
  1355. {
  1356. inputValue: inputValueIsSelectedValue ? '' : inputValue,
  1357. getOptionLabel: getOptionLabel
  1358. }) : [];
  1359. if (process.env.NODE_ENV !== 'production') {
  1360. if (value !== null && !freeSolo && options.length > 0) {
  1361. var missingValue = (multiple ? value : [value]).filter(function (value2) {
  1362. return !options.some(function (option) {
  1363. return getOptionSelected(option, value2);
  1364. });
  1365. });
  1366. if (missingValue.length > 0) {
  1367. console.warn(["Material-UI: The value provided to ".concat(componentName, " is invalid."), "None of the options match with `".concat(missingValue.length > 1 ? JSON.stringify(missingValue) : JSON.stringify(missingValue[0]), "`."), 'You can use the `getOptionSelected` prop to customize the equality test.'].join('\n'));
  1368. }
  1369. }
  1370. }
  1371. var focusTag = useEventCallback(function (tagToFocus) {
  1372. if (tagToFocus === -1) {
  1373. inputRef.current.focus();
  1374. } else {
  1375. anchorEl.querySelector("[data-tag-index=\"".concat(tagToFocus, "\"]")).focus();
  1376. }
  1377. }); // Ensure the focusedTag is never inconsistent
  1378. useEffect(function () {
  1379. if (multiple && focusedTag > value.length - 1) {
  1380. setFocusedTag(-1);
  1381. focusTag(-1);
  1382. }
  1383. }, [value, multiple, focusedTag, focusTag]);
  1384. function validOptionIndex(index, direction) {
  1385. if (!listboxRef.current || index === -1) {
  1386. return -1;
  1387. }
  1388. var nextFocus = index;
  1389. while (true) {
  1390. // Out of range
  1391. if (direction === 'next' && nextFocus === filteredOptions.length || direction === 'previous' && nextFocus === -1) {
  1392. return -1;
  1393. }
  1394. var option = listboxRef.current.querySelector("[data-option-index=\"".concat(nextFocus, "\"]")); // Same logic as MenuList.js
  1395. var nextFocusDisabled = disabledItemsFocusable ? false : option && (option.disabled || option.getAttribute('aria-disabled') === 'true');
  1396. if (option && !option.hasAttribute('tabindex') || nextFocusDisabled) {
  1397. // Move to the next element.
  1398. nextFocus += direction === 'next' ? 1 : -1;
  1399. } else {
  1400. return nextFocus;
  1401. }
  1402. }
  1403. }
  1404. var setHighlightedIndex = useEventCallback(function (_ref2) {
  1405. var event = _ref2.event,
  1406. index = _ref2.index,
  1407. _ref2$reason = _ref2.reason,
  1408. reason = _ref2$reason === void 0 ? 'auto' : _ref2$reason;
  1409. highlightedIndexRef.current = index; // does the index exist?
  1410. if (index === -1) {
  1411. inputRef.current.removeAttribute('aria-activedescendant');
  1412. } else {
  1413. inputRef.current.setAttribute('aria-activedescendant', "".concat(id, "-option-").concat(index));
  1414. }
  1415. if (onHighlightChange) {
  1416. onHighlightChange(event, index === -1 ? null : filteredOptions[index], reason);
  1417. }
  1418. if (!listboxRef.current) {
  1419. return;
  1420. }
  1421. var prev = listboxRef.current.querySelector('[data-focus]');
  1422. if (prev) {
  1423. prev.removeAttribute('data-focus');
  1424. }
  1425. var listboxNode = listboxRef.current.parentElement.querySelector('[role="listbox"]'); // "No results"
  1426. if (!listboxNode) {
  1427. return;
  1428. }
  1429. if (index === -1) {
  1430. listboxNode.scrollTop = 0;
  1431. return;
  1432. }
  1433. var option = listboxRef.current.querySelector("[data-option-index=\"".concat(index, "\"]"));
  1434. if (!option) {
  1435. return;
  1436. }
  1437. option.setAttribute('data-focus', 'true'); // Scroll active descendant into view.
  1438. // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
  1439. //
  1440. // Consider this API instead once it has a better browser support:
  1441. // .scrollIntoView({ scrollMode: 'if-needed', block: 'nearest' });
  1442. if (listboxNode.scrollHeight > listboxNode.clientHeight && reason !== 'mouse') {
  1443. var element = option;
  1444. var scrollBottom = listboxNode.clientHeight + listboxNode.scrollTop;
  1445. var elementBottom = element.offsetTop + element.offsetHeight;
  1446. if (elementBottom > scrollBottom) {
  1447. listboxNode.scrollTop = elementBottom - listboxNode.clientHeight;
  1448. } else if (element.offsetTop - element.offsetHeight * (groupBy ? 1.3 : 0) < listboxNode.scrollTop) {
  1449. listboxNode.scrollTop = element.offsetTop - element.offsetHeight * (groupBy ? 1.3 : 0);
  1450. }
  1451. }
  1452. });
  1453. var changeHighlightedIndex = useEventCallback(function (_ref3) {
  1454. var event = _ref3.event,
  1455. diff = _ref3.diff,
  1456. _ref3$direction = _ref3.direction,
  1457. direction = _ref3$direction === void 0 ? 'next' : _ref3$direction,
  1458. _ref3$reason = _ref3.reason,
  1459. reason = _ref3$reason === void 0 ? 'auto' : _ref3$reason;
  1460. if (!popupOpen) {
  1461. return;
  1462. }
  1463. var getNextIndex = function getNextIndex() {
  1464. var maxIndex = filteredOptions.length - 1;
  1465. if (diff === 'reset') {
  1466. return defaultHighlighted;
  1467. }
  1468. if (diff === 'start') {
  1469. return 0;
  1470. }
  1471. if (diff === 'end') {
  1472. return maxIndex;
  1473. }
  1474. var newIndex = highlightedIndexRef.current + diff;
  1475. if (newIndex < 0) {
  1476. if (newIndex === -1 && includeInputInList) {
  1477. return -1;
  1478. }
  1479. if (disableListWrap && highlightedIndexRef.current !== -1 || Math.abs(diff) > 1) {
  1480. return 0;
  1481. }
  1482. return maxIndex;
  1483. }
  1484. if (newIndex > maxIndex) {
  1485. if (newIndex === maxIndex + 1 && includeInputInList) {
  1486. return -1;
  1487. }
  1488. if (disableListWrap || Math.abs(diff) > 1) {
  1489. return maxIndex;
  1490. }
  1491. return 0;
  1492. }
  1493. return newIndex;
  1494. };
  1495. var nextIndex = validOptionIndex(getNextIndex(), direction);
  1496. setHighlightedIndex({
  1497. index: nextIndex,
  1498. reason: reason,
  1499. event: event
  1500. }); // Sync the content of the input with the highlighted option.
  1501. if (autoComplete && diff !== 'reset') {
  1502. if (nextIndex === -1) {
  1503. inputRef.current.value = inputValue;
  1504. } else {
  1505. var option = getOptionLabel(filteredOptions[nextIndex]);
  1506. inputRef.current.value = option; // The portion of the selected suggestion that has not been typed by the user,
  1507. // a completion string, appears inline after the input cursor in the textbox.
  1508. var index = option.toLowerCase().indexOf(inputValue.toLowerCase());
  1509. if (index === 0 && inputValue.length > 0) {
  1510. inputRef.current.setSelectionRange(inputValue.length, option.length);
  1511. }
  1512. }
  1513. }
  1514. });
  1515. var syncHighlightedIndex = useCallback(function () {
  1516. if (!popupOpen) {
  1517. return;
  1518. }
  1519. var valueItem = multiple ? value[0] : value; // The popup is empty, reset
  1520. if (filteredOptions.length === 0 || valueItem == null) {
  1521. changeHighlightedIndex({
  1522. diff: 'reset'
  1523. });
  1524. return;
  1525. }
  1526. if (!listboxRef.current) {
  1527. return;
  1528. } // Synchronize the value with the highlighted index
  1529. if (!filterSelectedOptions && valueItem != null) {
  1530. var currentOption = filteredOptions[highlightedIndexRef.current]; // Keep the current highlighted index if possible
  1531. if (multiple && currentOption && findIndex(value, function (val) {
  1532. return getOptionSelected(currentOption, val);
  1533. }) !== -1) {
  1534. return;
  1535. }
  1536. var itemIndex = findIndex(filteredOptions, function (optionItem) {
  1537. return getOptionSelected(optionItem, valueItem);
  1538. });
  1539. if (itemIndex === -1) {
  1540. changeHighlightedIndex({
  1541. diff: 'reset'
  1542. });
  1543. } else {
  1544. setHighlightedIndex({
  1545. index: itemIndex
  1546. });
  1547. }
  1548. return;
  1549. } // Prevent the highlighted index to leak outside the boundaries.
  1550. if (highlightedIndexRef.current >= filteredOptions.length - 1) {
  1551. setHighlightedIndex({
  1552. index: filteredOptions.length - 1
  1553. });
  1554. return;
  1555. } // Restore the focus to the previous index.
  1556. setHighlightedIndex({
  1557. index: highlightedIndexRef.current
  1558. }); // Ignore filteredOptions (and options, getOptionSelected, getOptionLabel) not to break the scroll position
  1559. // eslint-disable-next-line react-hooks/exhaustive-deps
  1560. }, [// Only sync the highlighted index when the option switch between empty and not
  1561. // eslint-disable-next-line react-hooks/exhaustive-deps
  1562. filteredOptions.length === 0, // Don't sync the highlighted index with the value when multiple
  1563. // eslint-disable-next-line react-hooks/exhaustive-deps
  1564. multiple ? false : value, filterSelectedOptions, changeHighlightedIndex, setHighlightedIndex, popupOpen, inputValue, multiple]);
  1565. var handleListboxRef = useEventCallback(function (node) {
  1566. setRef(listboxRef, node);
  1567. if (!node) {
  1568. return;
  1569. }
  1570. syncHighlightedIndex();
  1571. });
  1572. useEffect(function () {
  1573. syncHighlightedIndex();
  1574. }, [syncHighlightedIndex]);
  1575. var handleOpen = function handleOpen(event) {
  1576. if (open) {
  1577. return;
  1578. }
  1579. setOpenState(true);
  1580. if (onOpen) {
  1581. onOpen(event);
  1582. }
  1583. };
  1584. var handleClose = function handleClose(event, reason) {
  1585. if (!open) {
  1586. return;
  1587. }
  1588. setOpenState(false);
  1589. if (onClose) {
  1590. onClose(event, reason);
  1591. }
  1592. };
  1593. var handleValue = function handleValue(event, newValue, reason, details) {
  1594. if (value === newValue) {
  1595. return;
  1596. }
  1597. if (onChange) {
  1598. onChange(event, newValue, reason, details);
  1599. }
  1600. setValue(newValue);
  1601. };
  1602. var isTouch = useRef(false);
  1603. var selectNewValue = function selectNewValue(event, option) {
  1604. var reasonProp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'select-option';
  1605. var origin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'options';
  1606. var reason = reasonProp;
  1607. var newValue = option;
  1608. if (multiple) {
  1609. newValue = Array.isArray(value) ? value.slice() : [];
  1610. if (process.env.NODE_ENV !== 'production') {
  1611. var matches = newValue.filter(function (val) {
  1612. return getOptionSelected(option, val);
  1613. });
  1614. if (matches.length > 1) {
  1615. console.error(["Material-UI: The `getOptionSelected` method of ".concat(componentName, " do not handle the arguments correctly."), "The component expects a single value to match a given option but found ".concat(matches.length, " matches.")].join('\n'));
  1616. }
  1617. }
  1618. var itemIndex = findIndex(newValue, function (valueItem) {
  1619. return getOptionSelected(option, valueItem);
  1620. });
  1621. if (itemIndex === -1) {
  1622. newValue.push(option);
  1623. } else if (origin !== 'freeSolo') {
  1624. newValue.splice(itemIndex, 1);
  1625. reason = 'remove-option';
  1626. }
  1627. }
  1628. resetInputValue(event, newValue);
  1629. handleValue(event, newValue, reason, {
  1630. option: option
  1631. });
  1632. if (!disableCloseOnSelect) {
  1633. handleClose(event, reason);
  1634. }
  1635. if (blurOnSelect === true || blurOnSelect === 'touch' && isTouch.current || blurOnSelect === 'mouse' && !isTouch.current) {
  1636. inputRef.current.blur();
  1637. }
  1638. };
  1639. function validTagIndex(index, direction) {
  1640. if (index === -1) {
  1641. return -1;
  1642. }
  1643. var nextFocus = index;
  1644. while (true) {
  1645. // Out of range
  1646. if (direction === 'next' && nextFocus === value.length || direction === 'previous' && nextFocus === -1) {
  1647. return -1;
  1648. }
  1649. var option = anchorEl.querySelector("[data-tag-index=\"".concat(nextFocus, "\"]")); // Same logic as MenuList.js
  1650. if (option && (!option.hasAttribute('tabindex') || option.disabled || option.getAttribute('aria-disabled') === 'true')) {
  1651. nextFocus += direction === 'next' ? 1 : -1;
  1652. } else {
  1653. return nextFocus;
  1654. }
  1655. }
  1656. }
  1657. var handleFocusTag = function handleFocusTag(event, direction) {
  1658. if (!multiple) {
  1659. return;
  1660. }
  1661. handleClose(event, 'toggleInput');
  1662. var nextTag = focusedTag;
  1663. if (focusedTag === -1) {
  1664. if (inputValue === '' && direction === 'previous') {
  1665. nextTag = value.length - 1;
  1666. }
  1667. } else {
  1668. nextTag += direction === 'next' ? 1 : -1;
  1669. if (nextTag < 0) {
  1670. nextTag = 0;
  1671. }
  1672. if (nextTag === value.length) {
  1673. nextTag = -1;
  1674. }
  1675. }
  1676. nextTag = validTagIndex(nextTag, direction);
  1677. setFocusedTag(nextTag);
  1678. focusTag(nextTag);
  1679. };
  1680. var handleClear = function handleClear(event) {
  1681. ignoreFocus.current = true;
  1682. setInputValue('');
  1683. if (onInputChange) {
  1684. onInputChange(event, '', 'clear');
  1685. }
  1686. handleValue(event, multiple ? [] : null, 'clear');
  1687. };
  1688. var handleKeyDown = function handleKeyDown(other) {
  1689. return function (event) {
  1690. if (focusedTag !== -1 && ['ArrowLeft', 'ArrowRight'].indexOf(event.key) === -1) {
  1691. setFocusedTag(-1);
  1692. focusTag(-1);
  1693. }
  1694. switch (event.key) {
  1695. case 'Home':
  1696. if (popupOpen && handleHomeEndKeys) {
  1697. // Prevent scroll of the page
  1698. event.preventDefault();
  1699. changeHighlightedIndex({
  1700. diff: 'start',
  1701. direction: 'next',
  1702. reason: 'keyboard',
  1703. event: event
  1704. });
  1705. }
  1706. break;
  1707. case 'End':
  1708. if (popupOpen && handleHomeEndKeys) {
  1709. // Prevent scroll of the page
  1710. event.preventDefault();
  1711. changeHighlightedIndex({
  1712. diff: 'end',
  1713. direction: 'previous',
  1714. reason: 'keyboard',
  1715. event: event
  1716. });
  1717. }
  1718. break;
  1719. case 'PageUp':
  1720. // Prevent scroll of the page
  1721. event.preventDefault();
  1722. changeHighlightedIndex({
  1723. diff: -pageSize,
  1724. direction: 'previous',
  1725. reason: 'keyboard',
  1726. event: event
  1727. });
  1728. handleOpen(event);
  1729. break;
  1730. case 'PageDown':
  1731. // Prevent scroll of the page
  1732. event.preventDefault();
  1733. changeHighlightedIndex({
  1734. diff: pageSize,
  1735. direction: 'next',
  1736. reason: 'keyboard',
  1737. event: event
  1738. });
  1739. handleOpen(event);
  1740. break;
  1741. case 'ArrowDown':
  1742. // Prevent cursor move
  1743. event.preventDefault();
  1744. changeHighlightedIndex({
  1745. diff: 1,
  1746. direction: 'next',
  1747. reason: 'keyboard',
  1748. event: event
  1749. });
  1750. handleOpen(event);
  1751. break;
  1752. case 'ArrowUp':
  1753. // Prevent cursor move
  1754. event.preventDefault();
  1755. changeHighlightedIndex({
  1756. diff: -1,
  1757. direction: 'previous',
  1758. reason: 'keyboard',
  1759. event: event
  1760. });
  1761. handleOpen(event);
  1762. break;
  1763. case 'ArrowLeft':
  1764. handleFocusTag(event, 'previous');
  1765. break;
  1766. case 'ArrowRight':
  1767. handleFocusTag(event, 'next');
  1768. break;
  1769. case 'Enter':
  1770. // Wait until IME is settled.
  1771. if (event.which === 229) {
  1772. break;
  1773. }
  1774. if (highlightedIndexRef.current !== -1 && popupOpen) {
  1775. var option = filteredOptions[highlightedIndexRef.current];
  1776. var disabled = getOptionDisabled ? getOptionDisabled(option) : false; // We don't want to validate the form.
  1777. event.preventDefault();
  1778. if (disabled) {
  1779. return;
  1780. }
  1781. selectNewValue(event, option, 'select-option'); // Move the selection to the end.
  1782. if (autoComplete) {
  1783. inputRef.current.setSelectionRange(inputRef.current.value.length, inputRef.current.value.length);
  1784. }
  1785. } else if (freeSolo && inputValue !== '' && inputValueIsSelectedValue === false) {
  1786. if (multiple) {
  1787. // Allow people to add new values before they submit the form.
  1788. event.preventDefault();
  1789. }
  1790. selectNewValue(event, inputValue, 'create-option', 'freeSolo');
  1791. }
  1792. break;
  1793. case 'Escape':
  1794. if (popupOpen) {
  1795. // Avoid Opera to exit fullscreen mode.
  1796. event.preventDefault(); // Avoid the Modal to handle the event.
  1797. event.stopPropagation();
  1798. handleClose(event, 'escape');
  1799. } else if (clearOnEscape && (inputValue !== '' || multiple && value.length > 0)) {
  1800. // Avoid Opera to exit fullscreen mode.
  1801. event.preventDefault(); // Avoid the Modal to handle the event.
  1802. event.stopPropagation();
  1803. handleClear(event);
  1804. }
  1805. break;
  1806. case 'Backspace':
  1807. if (multiple && inputValue === '' && value.length > 0) {
  1808. var index = focusedTag === -1 ? value.length - 1 : focusedTag;
  1809. var newValue = value.slice();
  1810. newValue.splice(index, 1);
  1811. handleValue(event, newValue, 'remove-option', {
  1812. option: value[index]
  1813. });
  1814. }
  1815. break;
  1816. }
  1817. if (other.onKeyDown) {
  1818. other.onKeyDown(event);
  1819. }
  1820. };
  1821. };
  1822. var handleFocus = function handleFocus(event) {
  1823. setFocused(true);
  1824. if (openOnFocus && !ignoreFocus.current) {
  1825. handleOpen(event);
  1826. }
  1827. };
  1828. var handleBlur = function handleBlur(event) {
  1829. // Ignore the event when using the scrollbar with IE 11
  1830. if (listboxRef.current !== null && document.activeElement === listboxRef.current.parentElement) {
  1831. inputRef.current.focus();
  1832. return;
  1833. }
  1834. setFocused(false);
  1835. firstFocus.current = true;
  1836. ignoreFocus.current = false;
  1837. if (debug && inputValue !== '') {
  1838. return;
  1839. }
  1840. if (autoSelect && highlightedIndexRef.current !== -1 && popupOpen) {
  1841. selectNewValue(event, filteredOptions[highlightedIndexRef.current], 'blur');
  1842. } else if (autoSelect && freeSolo && inputValue !== '') {
  1843. selectNewValue(event, inputValue, 'blur', 'freeSolo');
  1844. } else if (clearOnBlur) {
  1845. resetInputValue(event, value);
  1846. }
  1847. handleClose(event, 'blur');
  1848. };
  1849. var handleInputChange = function handleInputChange(event) {
  1850. var newValue = event.target.value;
  1851. if (inputValue !== newValue) {
  1852. setInputValue(newValue);
  1853. if (onInputChange) {
  1854. onInputChange(event, newValue, 'input');
  1855. }
  1856. }
  1857. if (newValue === '') {
  1858. if (!disableClearable && !multiple) {
  1859. handleValue(event, null, 'clear');
  1860. }
  1861. } else {
  1862. handleOpen(event);
  1863. }
  1864. };
  1865. var handleOptionMouseOver = function handleOptionMouseOver(event) {
  1866. setHighlightedIndex({
  1867. event: event,
  1868. index: Number(event.currentTarget.getAttribute('data-option-index')),
  1869. reason: 'mouse'
  1870. });
  1871. };
  1872. var handleOptionTouchStart = function handleOptionTouchStart() {
  1873. isTouch.current = true;
  1874. };
  1875. var handleOptionClick = function handleOptionClick(event) {
  1876. var index = Number(event.currentTarget.getAttribute('data-option-index'));
  1877. selectNewValue(event, filteredOptions[index], 'select-option');
  1878. isTouch.current = false;
  1879. };
  1880. var handleTagDelete = function handleTagDelete(index) {
  1881. return function (event) {
  1882. var newValue = value.slice();
  1883. newValue.splice(index, 1);
  1884. handleValue(event, newValue, 'remove-option', {
  1885. option: value[index]
  1886. });
  1887. };
  1888. };
  1889. var handlePopupIndicator = function handlePopupIndicator(event) {
  1890. if (open) {
  1891. handleClose(event, 'toggleInput');
  1892. } else {
  1893. handleOpen(event);
  1894. }
  1895. }; // Prevent input blur when interacting with the combobox
  1896. var handleMouseDown = function handleMouseDown(event) {
  1897. if (event.target.getAttribute('id') !== id) {
  1898. event.preventDefault();
  1899. }
  1900. }; // Focus the input when interacting with the combobox
  1901. var handleClick = function handleClick() {
  1902. inputRef.current.focus();
  1903. if (selectOnFocus && firstFocus.current && inputRef.current.selectionEnd - inputRef.current.selectionStart === 0) {
  1904. inputRef.current.select();
  1905. }
  1906. firstFocus.current = false;
  1907. };
  1908. var handleInputMouseDown = function handleInputMouseDown(event) {
  1909. if (inputValue === '' || !open) {
  1910. handlePopupIndicator(event);
  1911. }
  1912. };
  1913. var dirty = freeSolo && inputValue.length > 0;
  1914. dirty = dirty || (multiple ? value.length > 0 : value !== null);
  1915. var groupedOptions = filteredOptions;
  1916. if (groupBy) {
  1917. // used to keep track of key and indexes in the result array
  1918. var indexBy = new Map();
  1919. var warn = false;
  1920. groupedOptions = filteredOptions.reduce(function (acc, option, index) {
  1921. var group = groupBy(option);
  1922. if (acc.length > 0 && acc[acc.length - 1].group === group) {
  1923. acc[acc.length - 1].options.push(option);
  1924. } else {
  1925. if (process.env.NODE_ENV !== 'production') {
  1926. if (indexBy.get(group) && !warn) {
  1927. console.warn("Material-UI: The options provided combined with the `groupBy` method of ".concat(componentName, " returns duplicated headers."), 'You can solve the issue by sorting the options with the output of `groupBy`.');
  1928. warn = true;
  1929. }
  1930. indexBy.set(group, true);
  1931. }
  1932. acc.push({
  1933. key: index,
  1934. index: index,
  1935. group: group,
  1936. options: [option]
  1937. });
  1938. }
  1939. return acc;
  1940. }, []);
  1941. }
  1942. return {
  1943. getRootProps: function getRootProps() {
  1944. var other = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1945. return _extends({
  1946. 'aria-owns': popupOpen ? "".concat(id, "-popup") : null,
  1947. role: 'combobox',
  1948. 'aria-expanded': popupOpen
  1949. }, other, {
  1950. onKeyDown: handleKeyDown(other),
  1951. onMouseDown: handleMouseDown,
  1952. onClick: handleClick
  1953. });
  1954. },
  1955. getInputLabelProps: function getInputLabelProps() {
  1956. return {
  1957. id: "".concat(id, "-label"),
  1958. htmlFor: id
  1959. };
  1960. },
  1961. getInputProps: function getInputProps() {
  1962. return {
  1963. id: id,
  1964. value: inputValue,
  1965. onBlur: handleBlur,
  1966. onFocus: handleFocus,
  1967. onChange: handleInputChange,
  1968. onMouseDown: handleInputMouseDown,
  1969. // if open then this is handled imperativeley so don't let react override
  1970. // only have an opinion about this when closed
  1971. 'aria-activedescendant': popupOpen ? '' : null,
  1972. 'aria-autocomplete': autoComplete ? 'both' : 'list',
  1973. 'aria-controls': popupOpen ? "".concat(id, "-popup") : null,
  1974. // Disable browser's suggestion that might overlap with the popup.
  1975. // Handle autocomplete but not autofill.
  1976. autoComplete: 'off',
  1977. ref: inputRef,
  1978. autoCapitalize: 'none',
  1979. spellCheck: 'false'
  1980. };
  1981. },
  1982. getClearProps: function getClearProps() {
  1983. return {
  1984. tabIndex: -1,
  1985. onClick: handleClear
  1986. };
  1987. },
  1988. getPopupIndicatorProps: function getPopupIndicatorProps() {
  1989. return {
  1990. tabIndex: -1,
  1991. onClick: handlePopupIndicator
  1992. };
  1993. },
  1994. getTagProps: function getTagProps(_ref4) {
  1995. var index = _ref4.index;
  1996. return {
  1997. key: index,
  1998. 'data-tag-index': index,
  1999. tabIndex: -1,
  2000. onDelete: handleTagDelete(index)
  2001. };
  2002. },
  2003. getListboxProps: function getListboxProps() {
  2004. return {
  2005. role: 'listbox',
  2006. id: "".concat(id, "-popup"),
  2007. 'aria-labelledby': "".concat(id, "-label"),
  2008. ref: handleListboxRef,
  2009. onMouseDown: function onMouseDown(event) {
  2010. // Prevent blur
  2011. event.preventDefault();
  2012. }
  2013. };
  2014. },
  2015. getOptionProps: function getOptionProps(_ref5) {
  2016. var index = _ref5.index,
  2017. option = _ref5.option;
  2018. var selected = (multiple ? value : [value]).some(function (value2) {
  2019. return value2 != null && getOptionSelected(option, value2);
  2020. });
  2021. var disabled = getOptionDisabled ? getOptionDisabled(option) : false;
  2022. return {
  2023. key: index,
  2024. tabIndex: -1,
  2025. role: 'option',
  2026. id: "".concat(id, "-option-").concat(index),
  2027. onMouseOver: handleOptionMouseOver,
  2028. onClick: handleOptionClick,
  2029. onTouchStart: handleOptionTouchStart,
  2030. 'data-option-index': index,
  2031. 'aria-disabled': disabled,
  2032. 'aria-selected': selected
  2033. };
  2034. },
  2035. id: id,
  2036. inputValue: inputValue,
  2037. value: value,
  2038. dirty: dirty,
  2039. popupOpen: popupOpen,
  2040. focused: focused || focusedTag !== -1,
  2041. anchorEl: anchorEl,
  2042. setAnchorEl: setAnchorEl,
  2043. focusedTag: focusedTag,
  2044. groupedOptions: groupedOptions
  2045. };
  2046. }
  2047. var styles = function styles(theme) {
  2048. var _option;
  2049. return {
  2050. /* Styles applied to the root element. */
  2051. root: {
  2052. '&$focused $clearIndicatorDirty': {
  2053. visibility: 'visible'
  2054. },
  2055. /* Avoid double tap issue on iOS */
  2056. '@media (pointer: fine)': {
  2057. '&:hover $clearIndicatorDirty': {
  2058. visibility: 'visible'
  2059. }
  2060. }
  2061. },
  2062. /* Styles applied to the root element if `fullWidth={true}`. */
  2063. fullWidth: {
  2064. width: '100%'
  2065. },
  2066. /* Pseudo-class applied to the root element if focused. */
  2067. focused: {},
  2068. /* Styles applied to the tag elements, e.g. the chips. */
  2069. tag: {
  2070. margin: 3,
  2071. maxWidth: 'calc(100% - 6px)'
  2072. },
  2073. /* Styles applied to the tag elements, e.g. the chips if `size="small"`. */
  2074. tagSizeSmall: {
  2075. margin: 2,
  2076. maxWidth: 'calc(100% - 4px)'
  2077. },
  2078. /* Styles applied when the popup icon is rendered. */
  2079. hasPopupIcon: {},
  2080. /* Styles applied when the clear icon is rendered. */
  2081. hasClearIcon: {},
  2082. /* Styles applied to the Input element. */
  2083. inputRoot: {
  2084. flexWrap: 'wrap',
  2085. '$hasPopupIcon &, $hasClearIcon &': {
  2086. paddingRight: 26 + 4
  2087. },
  2088. '$hasPopupIcon$hasClearIcon &': {
  2089. paddingRight: 52 + 4
  2090. },
  2091. '& $input': {
  2092. width: 0,
  2093. minWidth: 30
  2094. },
  2095. '&[class*="MuiInput-root"]': {
  2096. paddingBottom: 1,
  2097. '& $input': {
  2098. padding: 4
  2099. },
  2100. '& $input:first-child': {
  2101. padding: '6px 0'
  2102. }
  2103. },
  2104. '&[class*="MuiInput-root"][class*="MuiInput-marginDense"]': {
  2105. '& $input': {
  2106. padding: '4px 4px 5px'
  2107. },
  2108. '& $input:first-child': {
  2109. padding: '3px 0 6px'
  2110. }
  2111. },
  2112. '&[class*="MuiOutlinedInput-root"]': {
  2113. padding: 9,
  2114. '$hasPopupIcon &, $hasClearIcon &': {
  2115. paddingRight: 26 + 4 + 9
  2116. },
  2117. '$hasPopupIcon$hasClearIcon &': {
  2118. paddingRight: 52 + 4 + 9
  2119. },
  2120. '& $input': {
  2121. padding: '9.5px 4px'
  2122. },
  2123. '& $input:first-child': {
  2124. paddingLeft: 6
  2125. },
  2126. '& $endAdornment': {
  2127. right: 9
  2128. }
  2129. },
  2130. '&[class*="MuiOutlinedInput-root"][class*="MuiOutlinedInput-marginDense"]': {
  2131. padding: 6,
  2132. '& $input': {
  2133. padding: '4.5px 4px'
  2134. }
  2135. },
  2136. '&[class*="MuiFilledInput-root"]': {
  2137. paddingTop: 19,
  2138. paddingLeft: 8,
  2139. '$hasPopupIcon &, $hasClearIcon &': {
  2140. paddingRight: 26 + 4 + 9
  2141. },
  2142. '$hasPopupIcon$hasClearIcon &': {
  2143. paddingRight: 52 + 4 + 9
  2144. },
  2145. '& $input': {
  2146. padding: '9px 4px'
  2147. },
  2148. '& $endAdornment': {
  2149. right: 9
  2150. }
  2151. },
  2152. '&[class*="MuiFilledInput-root"][class*="MuiFilledInput-marginDense"]': {
  2153. paddingBottom: 1,
  2154. '& $input': {
  2155. padding: '4.5px 4px'
  2156. }
  2157. }
  2158. },
  2159. /* Styles applied to the input element. */
  2160. input: {
  2161. flexGrow: 1,
  2162. textOverflow: 'ellipsis',
  2163. opacity: 0
  2164. },
  2165. /* Styles applied to the input element if tag focused. */
  2166. inputFocused: {
  2167. opacity: 1
  2168. },
  2169. /* Styles applied to the endAdornment element. */
  2170. endAdornment: {
  2171. // We use a position absolute to support wrapping tags.
  2172. position: 'absolute',
  2173. right: 0,
  2174. top: 'calc(50% - 14px)' // Center vertically
  2175. },
  2176. /* Styles applied to the clear indicator. */
  2177. clearIndicator: {
  2178. marginRight: -2,
  2179. padding: 4,
  2180. visibility: 'hidden'
  2181. },
  2182. /* Styles applied to the clear indicator if the input is dirty. */
  2183. clearIndicatorDirty: {},
  2184. /* Styles applied to the popup indicator. */
  2185. popupIndicator: {
  2186. padding: 2,
  2187. marginRight: -2
  2188. },
  2189. /* Styles applied to the popup indicator if the popup is open. */
  2190. popupIndicatorOpen: {
  2191. transform: 'rotate(180deg)'
  2192. },
  2193. /* Styles applied to the popper element. */
  2194. popper: {
  2195. zIndex: theme.zIndex.modal
  2196. },
  2197. /* Styles applied to the popper element if `disablePortal={true}`. */
  2198. popperDisablePortal: {
  2199. position: 'absolute'
  2200. },
  2201. /* Styles applied to the `Paper` component. */
  2202. paper: _extends({}, theme.typography.body1, {
  2203. overflow: 'hidden',
  2204. margin: '4px 0'
  2205. }),
  2206. /* Styles applied to the `listbox` component. */
  2207. listbox: {
  2208. listStyle: 'none',
  2209. margin: 0,
  2210. padding: '8px 0',
  2211. maxHeight: '40vh',
  2212. overflow: 'auto'
  2213. },
  2214. /* Styles applied to the loading wrapper. */
  2215. loading: {
  2216. color: theme.palette.text.secondary,
  2217. padding: '14px 16px'
  2218. },
  2219. /* Styles applied to the no option wrapper. */
  2220. noOptions: {
  2221. color: theme.palette.text.secondary,
  2222. padding: '14px 16px'
  2223. },
  2224. /* Styles applied to the option elements. */
  2225. option: (_option = {
  2226. minHeight: 48,
  2227. display: 'flex',
  2228. justifyContent: 'flex-start',
  2229. alignItems: 'center',
  2230. cursor: 'pointer',
  2231. paddingTop: 6,
  2232. boxSizing: 'border-box',
  2233. outline: '0',
  2234. WebkitTapHighlightColor: 'transparent',
  2235. paddingBottom: 6,
  2236. paddingLeft: 16,
  2237. paddingRight: 16
  2238. }, _defineProperty(_option, theme.breakpoints.up('sm'), {
  2239. minHeight: 'auto'
  2240. }), _defineProperty(_option, '&[aria-selected="true"]', {
  2241. backgroundColor: theme.palette.action.selected
  2242. }), _defineProperty(_option, '&[data-focus="true"]', {
  2243. backgroundColor: theme.palette.action.hover
  2244. }), _defineProperty(_option, '&:active', {
  2245. backgroundColor: theme.palette.action.selected
  2246. }), _defineProperty(_option, '&[aria-disabled="true"]', {
  2247. opacity: theme.palette.action.disabledOpacity,
  2248. pointerEvents: 'none'
  2249. }), _option),
  2250. /* Styles applied to the group's label elements. */
  2251. groupLabel: {
  2252. backgroundColor: theme.palette.background.paper,
  2253. top: -8
  2254. },
  2255. /* Styles applied to the group's ul elements. */
  2256. groupUl: {
  2257. padding: 0,
  2258. '& $option': {
  2259. paddingLeft: 24
  2260. }
  2261. }
  2262. };
  2263. };
  2264. function DisablePortal(props) {
  2265. // eslint-disable-next-line react/prop-types
  2266. var other = _objectWithoutProperties(props, ["anchorEl", "open"]);
  2267. return /*#__PURE__*/createElement("div", other);
  2268. }
  2269. var _ref = /*#__PURE__*/createElement(CloseIcon, {
  2270. fontSize: "small"
  2271. });
  2272. var _ref2 = /*#__PURE__*/createElement(ArrowDropDownIcon, null);
  2273. var Autocomplete = /*#__PURE__*/forwardRef(function Autocomplete(props, ref) {
  2274. /* eslint-disable no-unused-vars */
  2275. var ChipProps = props.ChipProps,
  2276. classes = props.classes,
  2277. className = props.className,
  2278. _props$clearText = props.clearText,
  2279. clearText = _props$clearText === void 0 ? 'Clear' : _props$clearText,
  2280. _props$closeIcon = props.closeIcon,
  2281. closeIcon = _props$closeIcon === void 0 ? _ref : _props$closeIcon,
  2282. _props$closeText = props.closeText,
  2283. closeText = _props$closeText === void 0 ? 'Close' : _props$closeText,
  2284. _props$disableClearab = props.disableClearable,
  2285. disableClearable = _props$disableClearab === void 0 ? false : _props$disableClearab,
  2286. _props$disabled = props.disabled,
  2287. disabled = _props$disabled === void 0 ? false : _props$disabled,
  2288. _props$disablePortal = props.disablePortal,
  2289. disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal,
  2290. _props$forcePopupIcon = props.forcePopupIcon,
  2291. forcePopupIcon = _props$forcePopupIcon === void 0 ? 'auto' : _props$forcePopupIcon,
  2292. _props$freeSolo = props.freeSolo,
  2293. freeSolo = _props$freeSolo === void 0 ? false : _props$freeSolo,
  2294. _props$fullWidth = props.fullWidth,
  2295. fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
  2296. _props$getLimitTagsTe = props.getLimitTagsText,
  2297. getLimitTagsText = _props$getLimitTagsTe === void 0 ? function (more) {
  2298. return "+".concat(more);
  2299. } : _props$getLimitTagsTe,
  2300. _props$getOptionLabel = props.getOptionLabel,
  2301. getOptionLabel = _props$getOptionLabel === void 0 ? function (x) {
  2302. return x;
  2303. } : _props$getOptionLabel,
  2304. groupBy = props.groupBy,
  2305. _props$limitTags = props.limitTags,
  2306. limitTags = _props$limitTags === void 0 ? -1 : _props$limitTags,
  2307. _props$ListboxCompone = props.ListboxComponent,
  2308. ListboxComponent = _props$ListboxCompone === void 0 ? 'ul' : _props$ListboxCompone,
  2309. ListboxProps = props.ListboxProps,
  2310. _props$loading = props.loading,
  2311. loading = _props$loading === void 0 ? false : _props$loading,
  2312. _props$loadingText = props.loadingText,
  2313. loadingText = _props$loadingText === void 0 ? 'Loading…' : _props$loadingText,
  2314. _props$multiple = props.multiple,
  2315. multiple = _props$multiple === void 0 ? false : _props$multiple,
  2316. _props$noOptionsText = props.noOptionsText,
  2317. noOptionsText = _props$noOptionsText === void 0 ? 'No options' : _props$noOptionsText,
  2318. _props$openText = props.openText,
  2319. openText = _props$openText === void 0 ? 'Open' : _props$openText,
  2320. _props$PaperComponent = props.PaperComponent,
  2321. PaperComponent = _props$PaperComponent === void 0 ? Paper : _props$PaperComponent,
  2322. _props$PopperComponen = props.PopperComponent,
  2323. PopperComponentProp = _props$PopperComponen === void 0 ? Popper : _props$PopperComponen,
  2324. _props$popupIcon = props.popupIcon,
  2325. popupIcon = _props$popupIcon === void 0 ? _ref2 : _props$popupIcon,
  2326. renderGroupProp = props.renderGroup,
  2327. renderInput = props.renderInput,
  2328. renderOptionProp = props.renderOption,
  2329. renderTags = props.renderTags,
  2330. _props$size = props.size,
  2331. size = _props$size === void 0 ? 'medium' : _props$size,
  2332. other = _objectWithoutProperties(props, ["autoComplete", "autoHighlight", "autoSelect", "blurOnSelect", "ChipProps", "classes", "className", "clearOnBlur", "clearOnEscape", "clearText", "closeIcon", "closeText", "debug", "defaultValue", "disableClearable", "disableCloseOnSelect", "disabled", "disabledItemsFocusable", "disableListWrap", "disablePortal", "filterOptions", "filterSelectedOptions", "forcePopupIcon", "freeSolo", "fullWidth", "getLimitTagsText", "getOptionDisabled", "getOptionLabel", "getOptionSelected", "groupBy", "handleHomeEndKeys", "id", "includeInputInList", "inputValue", "limitTags", "ListboxComponent", "ListboxProps", "loading", "loadingText", "multiple", "noOptionsText", "onChange", "onClose", "onHighlightChange", "onInputChange", "onOpen", "open", "openOnFocus", "openText", "options", "PaperComponent", "PopperComponent", "popupIcon", "renderGroup", "renderInput", "renderOption", "renderTags", "selectOnFocus", "size", "value"]);
  2333. /* eslint-enable no-unused-vars */
  2334. var PopperComponent = disablePortal ? DisablePortal : PopperComponentProp;
  2335. var _useAutocomplete = useAutocomplete(_extends({}, props, {
  2336. componentName: 'Autocomplete'
  2337. })),
  2338. getRootProps = _useAutocomplete.getRootProps,
  2339. getInputProps = _useAutocomplete.getInputProps,
  2340. getInputLabelProps = _useAutocomplete.getInputLabelProps,
  2341. getPopupIndicatorProps = _useAutocomplete.getPopupIndicatorProps,
  2342. getClearProps = _useAutocomplete.getClearProps,
  2343. getTagProps = _useAutocomplete.getTagProps,
  2344. getListboxProps = _useAutocomplete.getListboxProps,
  2345. getOptionProps = _useAutocomplete.getOptionProps,
  2346. value = _useAutocomplete.value,
  2347. dirty = _useAutocomplete.dirty,
  2348. id = _useAutocomplete.id,
  2349. popupOpen = _useAutocomplete.popupOpen,
  2350. focused = _useAutocomplete.focused,
  2351. focusedTag = _useAutocomplete.focusedTag,
  2352. anchorEl = _useAutocomplete.anchorEl,
  2353. setAnchorEl = _useAutocomplete.setAnchorEl,
  2354. inputValue = _useAutocomplete.inputValue,
  2355. groupedOptions = _useAutocomplete.groupedOptions;
  2356. var startAdornment;
  2357. if (multiple && value.length > 0) {
  2358. var getCustomizedTagProps = function getCustomizedTagProps(params) {
  2359. return _extends({
  2360. className: clsx(classes.tag, size === 'small' && classes.tagSizeSmall),
  2361. disabled: disabled
  2362. }, getTagProps(params));
  2363. };
  2364. if (renderTags) {
  2365. startAdornment = renderTags(value, getCustomizedTagProps);
  2366. } else {
  2367. startAdornment = value.map(function (option, index) {
  2368. return /*#__PURE__*/createElement(Chip, _extends({
  2369. label: getOptionLabel(option),
  2370. size: size
  2371. }, getCustomizedTagProps({
  2372. index: index
  2373. }), ChipProps));
  2374. });
  2375. }
  2376. }
  2377. if (limitTags > -1 && Array.isArray(startAdornment)) {
  2378. var more = startAdornment.length - limitTags;
  2379. if (!focused && more > 0) {
  2380. startAdornment = startAdornment.splice(0, limitTags);
  2381. startAdornment.push( /*#__PURE__*/createElement("span", {
  2382. className: classes.tag,
  2383. key: startAdornment.length
  2384. }, getLimitTagsText(more)));
  2385. }
  2386. }
  2387. var defaultRenderGroup = function defaultRenderGroup(params) {
  2388. return /*#__PURE__*/createElement("li", {
  2389. key: params.key
  2390. }, /*#__PURE__*/createElement(ListSubheader, {
  2391. className: classes.groupLabel,
  2392. component: "div"
  2393. }, params.group), /*#__PURE__*/createElement("ul", {
  2394. className: classes.groupUl
  2395. }, params.children));
  2396. };
  2397. var renderGroup = renderGroupProp || defaultRenderGroup;
  2398. var renderOption = renderOptionProp || getOptionLabel;
  2399. var renderListOption = function renderListOption(option, index) {
  2400. var optionProps = getOptionProps({
  2401. option: option,
  2402. index: index
  2403. });
  2404. return /*#__PURE__*/createElement("li", _extends({}, optionProps, {
  2405. className: classes.option
  2406. }), renderOption(option, {
  2407. selected: optionProps['aria-selected'],
  2408. inputValue: inputValue
  2409. }));
  2410. };
  2411. var hasClearIcon = !disableClearable && !disabled;
  2412. var hasPopupIcon = (!freeSolo || forcePopupIcon === true) && forcePopupIcon !== false;
  2413. return /*#__PURE__*/createElement(Fragment$1, null, /*#__PURE__*/createElement("div", _extends({
  2414. ref: ref,
  2415. className: clsx(classes.root, className, focused && classes.focused, fullWidth && classes.fullWidth, hasClearIcon && classes.hasClearIcon, hasPopupIcon && classes.hasPopupIcon)
  2416. }, getRootProps(other)), renderInput({
  2417. id: id,
  2418. disabled: disabled,
  2419. fullWidth: true,
  2420. size: size === 'small' ? 'small' : undefined,
  2421. InputLabelProps: getInputLabelProps(),
  2422. InputProps: {
  2423. ref: setAnchorEl,
  2424. className: classes.inputRoot,
  2425. startAdornment: startAdornment,
  2426. endAdornment: /*#__PURE__*/createElement("div", {
  2427. className: classes.endAdornment
  2428. }, hasClearIcon ? /*#__PURE__*/createElement(IconButton, _extends({}, getClearProps(), {
  2429. "aria-label": clearText,
  2430. title: clearText,
  2431. className: clsx(classes.clearIndicator, dirty && classes.clearIndicatorDirty)
  2432. }), closeIcon) : null, hasPopupIcon ? /*#__PURE__*/createElement(IconButton, _extends({}, getPopupIndicatorProps(), {
  2433. disabled: disabled,
  2434. "aria-label": popupOpen ? closeText : openText,
  2435. title: popupOpen ? closeText : openText,
  2436. className: clsx(classes.popupIndicator, popupOpen && classes.popupIndicatorOpen)
  2437. }), popupIcon) : null)
  2438. },
  2439. inputProps: _extends({
  2440. className: clsx(classes.input, focusedTag === -1 && classes.inputFocused),
  2441. disabled: disabled
  2442. }, getInputProps())
  2443. })), popupOpen && anchorEl ? /*#__PURE__*/createElement(PopperComponent, {
  2444. className: clsx(classes.popper, disablePortal && classes.popperDisablePortal),
  2445. style: {
  2446. width: anchorEl ? anchorEl.clientWidth : null
  2447. },
  2448. role: "presentation",
  2449. anchorEl: anchorEl,
  2450. open: true
  2451. }, /*#__PURE__*/createElement(PaperComponent, {
  2452. className: classes.paper
  2453. }, loading && groupedOptions.length === 0 ? /*#__PURE__*/createElement("div", {
  2454. className: classes.loading
  2455. }, loadingText) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/createElement("div", {
  2456. className: classes.noOptions
  2457. }, noOptionsText) : null, groupedOptions.length > 0 ? /*#__PURE__*/createElement(ListboxComponent, _extends({
  2458. className: classes.listbox
  2459. }, getListboxProps(), ListboxProps), groupedOptions.map(function (option, index) {
  2460. if (groupBy) {
  2461. return renderGroup({
  2462. key: option.key,
  2463. group: option.group,
  2464. children: option.options.map(function (option2, index2) {
  2465. return renderListOption(option2, option.index + index2);
  2466. })
  2467. });
  2468. }
  2469. return renderListOption(option, index);
  2470. })) : null)) : null);
  2471. });
  2472. process.env.NODE_ENV !== "production" ? Autocomplete.propTypes = {
  2473. // ----------------------------- Warning --------------------------------
  2474. // | These PropTypes are generated from the TypeScript type definitions |
  2475. // | To update them edit the d.ts file and run "yarn proptypes" |
  2476. // ----------------------------------------------------------------------
  2477. /**
  2478. * If `true`, the portion of the selected suggestion that has not been typed by the user,
  2479. * known as the completion string, appears inline after the input cursor in the textbox.
  2480. * The inline completion string is visually highlighted and has a selected state.
  2481. */
  2482. autoComplete: propTypes.bool,
  2483. /**
  2484. * If `true`, the first option is automatically highlighted.
  2485. */
  2486. autoHighlight: propTypes.bool,
  2487. /**
  2488. * If `true`, the selected option becomes the value of the input
  2489. * when the Autocomplete loses focus unless the user chooses
  2490. * a different option or changes the character string in the input.
  2491. */
  2492. autoSelect: propTypes.bool,
  2493. /**
  2494. * Control if the input should be blurred when an option is selected:
  2495. *
  2496. * - `false` the input is not blurred.
  2497. * - `true` the input is always blurred.
  2498. * - `touch` the input is blurred after a touch event.
  2499. * - `mouse` the input is blurred after a mouse event.
  2500. */
  2501. blurOnSelect: propTypes.oneOfType([propTypes.oneOf(['mouse', 'touch']), propTypes.bool]),
  2502. /**
  2503. * Props applied to the [`Chip`](/api/chip/) element.
  2504. */
  2505. ChipProps: propTypes.object,
  2506. /**
  2507. * Override or extend the styles applied to the component.
  2508. * See [CSS API](#css) below for more details.
  2509. */
  2510. classes: propTypes.object,
  2511. /**
  2512. * @ignore
  2513. */
  2514. className: propTypes.string,
  2515. /**
  2516. * If `true`, the input's text will be cleared on blur if no value is selected.
  2517. *
  2518. * Set to `true` if you want to help the user enter a new value.
  2519. * Set to `false` if you want to help the user resume his search.
  2520. */
  2521. clearOnBlur: propTypes.bool,
  2522. /**
  2523. * If `true`, clear all values when the user presses escape and the popup is closed.
  2524. */
  2525. clearOnEscape: propTypes.bool,
  2526. /**
  2527. * Override the default text for the *clear* icon button.
  2528. *
  2529. * For localization purposes, you can use the provided [translations](/guides/localization/).
  2530. */
  2531. clearText: propTypes.string,
  2532. /**
  2533. * The icon to display in place of the default close icon.
  2534. */
  2535. closeIcon: propTypes.node,
  2536. /**
  2537. * Override the default text for the *close popup* icon button.
  2538. *
  2539. * For localization purposes, you can use the provided [translations](/guides/localization/).
  2540. */
  2541. closeText: propTypes.string,
  2542. /**
  2543. * If `true`, the popup will ignore the blur event if the input is filled.
  2544. * You can inspect the popup markup with your browser tools.
  2545. * Consider this option when you need to customize the component.
  2546. */
  2547. debug: propTypes.bool,
  2548. /**
  2549. * The default input value. Use when the component is not controlled.
  2550. */
  2551. defaultValue: propTypes.any,
  2552. /**
  2553. * If `true`, the input can't be cleared.
  2554. */
  2555. disableClearable: propTypes
  2556. /* @typescript-to-proptypes-ignore */
  2557. .bool,
  2558. /**
  2559. * If `true`, the popup won't close when a value is selected.
  2560. */
  2561. disableCloseOnSelect: propTypes.bool,
  2562. /**
  2563. * If `true`, the input will be disabled.
  2564. */
  2565. disabled: propTypes.bool,
  2566. /**
  2567. * If `true`, will allow focus on disabled items.
  2568. */
  2569. disabledItemsFocusable: propTypes.bool,
  2570. /**
  2571. * If `true`, the list box in the popup will not wrap focus.
  2572. */
  2573. disableListWrap: propTypes.bool,
  2574. /**
  2575. * Disable the portal behavior.
  2576. * The children stay within it's parent DOM hierarchy.
  2577. */
  2578. disablePortal: propTypes.bool,
  2579. /**
  2580. * A filter function that determines the options that are eligible.
  2581. *
  2582. * @param {T[]} options The options to render.
  2583. * @param {object} state The state of the component.
  2584. * @returns {T[]}
  2585. */
  2586. filterOptions: propTypes.func,
  2587. /**
  2588. * If `true`, hide the selected options from the list box.
  2589. */
  2590. filterSelectedOptions: propTypes.bool,
  2591. /**
  2592. * Force the visibility display of the popup icon.
  2593. */
  2594. forcePopupIcon: propTypes.oneOfType([propTypes.oneOf(['auto']), propTypes.bool]),
  2595. /**
  2596. * If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
  2597. */
  2598. freeSolo: propTypes
  2599. /* @typescript-to-proptypes-ignore */
  2600. .bool,
  2601. /**
  2602. * If `true`, the input will take up the full width of its container.
  2603. */
  2604. fullWidth: propTypes.bool,
  2605. /**
  2606. * The label to display when the tags are truncated (`limitTags`).
  2607. *
  2608. * @param {number} more The number of truncated tags.
  2609. * @returns {ReactNode}
  2610. */
  2611. getLimitTagsText: propTypes.func,
  2612. /**
  2613. * Used to determine the disabled state for a given option.
  2614. *
  2615. * @param {T} option The option to test.
  2616. * @returns {boolean}
  2617. */
  2618. getOptionDisabled: propTypes.func,
  2619. /**
  2620. * Used to determine the string value for a given option.
  2621. * It's used to fill the input (and the list box options if `renderOption` is not provided).
  2622. *
  2623. * @param {T} option
  2624. * @returns {string}
  2625. */
  2626. getOptionLabel: propTypes.func,
  2627. /**
  2628. * Used to determine if an option is selected, considering the current value.
  2629. * Uses strict equality by default.
  2630. *
  2631. * @param {T} option The option to test.
  2632. * @param {T} value The value to test against.
  2633. * @returns {boolean}
  2634. */
  2635. getOptionSelected: propTypes.func,
  2636. /**
  2637. * If provided, the options will be grouped under the returned string.
  2638. * The groupBy value is also used as the text for group headings when `renderGroup` is not provided.
  2639. *
  2640. * @param {T} options The options to group.
  2641. * @returns {string}
  2642. */
  2643. groupBy: propTypes.func,
  2644. /**
  2645. * If `true`, the component handles the "Home" and "End" keys when the popup is open.
  2646. * It should move focus to the first option and last option, respectively.
  2647. */
  2648. handleHomeEndKeys: propTypes.bool,
  2649. /**
  2650. * This prop is used to help implement the accessibility logic.
  2651. * If you don't provide this prop. It falls back to a randomly generated id.
  2652. */
  2653. id: propTypes.string,
  2654. /**
  2655. * If `true`, the highlight can move to the input.
  2656. */
  2657. includeInputInList: propTypes.bool,
  2658. /**
  2659. * The input value.
  2660. */
  2661. inputValue: propTypes.string,
  2662. /**
  2663. * The maximum number of tags that will be visible when not focused.
  2664. * Set `-1` to disable the limit.
  2665. */
  2666. limitTags: propTypes.number,
  2667. /**
  2668. * The component used to render the listbox.
  2669. */
  2670. ListboxComponent: propTypes.elementType,
  2671. /**
  2672. * Props applied to the Listbox element.
  2673. */
  2674. ListboxProps: propTypes.object,
  2675. /**
  2676. * If `true`, the component is in a loading state.
  2677. */
  2678. loading: propTypes.bool,
  2679. /**
  2680. * Text to display when in a loading state.
  2681. *
  2682. * For localization purposes, you can use the provided [translations](/guides/localization/).
  2683. */
  2684. loadingText: propTypes.node,
  2685. /**
  2686. * If `true`, `value` must be an array and the menu will support multiple selections.
  2687. */
  2688. multiple: propTypes
  2689. /* @typescript-to-proptypes-ignore */
  2690. .bool,
  2691. /**
  2692. * Text to display when there are no options.
  2693. *
  2694. * For localization purposes, you can use the provided [translations](/guides/localization/).
  2695. */
  2696. noOptionsText: propTypes.node,
  2697. /**
  2698. * Callback fired when the value changes.
  2699. *
  2700. * @param {object} event The event source of the callback.
  2701. * @param {T|T[]} value The new value of the component.
  2702. * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear".
  2703. */
  2704. onChange: propTypes.func,
  2705. /**
  2706. * Callback fired when the popup requests to be closed.
  2707. * Use in controlled mode (see open).
  2708. *
  2709. * @param {object} event The event source of the callback.
  2710. * @param {string} reason Can be: `"toggleInput"`, `"escape"`, `"select-option"`, `"blur"`.
  2711. */
  2712. onClose: propTypes.func,
  2713. /**
  2714. * Callback fired when the highlight option changes.
  2715. *
  2716. * @param {object} event The event source of the callback.
  2717. * @param {T} option The highlighted option.
  2718. * @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`.
  2719. */
  2720. onHighlightChange: propTypes.func,
  2721. /**
  2722. * Callback fired when the input value changes.
  2723. *
  2724. * @param {object} event The event source of the callback.
  2725. * @param {string} value The new value of the text input.
  2726. * @param {string} reason Can be: `"input"` (user input), `"reset"` (programmatic change), `"clear"`.
  2727. */
  2728. onInputChange: propTypes.func,
  2729. /**
  2730. * Callback fired when the popup requests to be opened.
  2731. * Use in controlled mode (see open).
  2732. *
  2733. * @param {object} event The event source of the callback.
  2734. */
  2735. onOpen: propTypes.func,
  2736. /**
  2737. * Control the popup` open state.
  2738. */
  2739. open: propTypes.bool,
  2740. /**
  2741. * If `true`, the popup will open on input focus.
  2742. */
  2743. openOnFocus: propTypes.bool,
  2744. /**
  2745. * Override the default text for the *open popup* icon button.
  2746. *
  2747. * For localization purposes, you can use the provided [translations](/guides/localization/).
  2748. */
  2749. openText: propTypes.string,
  2750. /**
  2751. * Array of options.
  2752. */
  2753. options: propTypes.array.isRequired,
  2754. /**
  2755. * The component used to render the body of the popup.
  2756. */
  2757. PaperComponent: propTypes.elementType,
  2758. /**
  2759. * The component used to position the popup.
  2760. */
  2761. PopperComponent: propTypes.elementType,
  2762. /**
  2763. * The icon to display in place of the default popup icon.
  2764. */
  2765. popupIcon: propTypes.node,
  2766. /**
  2767. * Render the group.
  2768. *
  2769. * @param {any} option The group to render.
  2770. * @returns {ReactNode}
  2771. */
  2772. renderGroup: propTypes.func,
  2773. /**
  2774. * Render the input.
  2775. *
  2776. * @param {object} params
  2777. * @returns {ReactNode}
  2778. */
  2779. renderInput: propTypes.func.isRequired,
  2780. /**
  2781. * Render the option, use `getOptionLabel` by default.
  2782. *
  2783. * @param {T} option The option to render.
  2784. * @param {object} state The state of the component.
  2785. * @returns {ReactNode}
  2786. */
  2787. renderOption: propTypes.func,
  2788. /**
  2789. * Render the selected value.
  2790. *
  2791. * @param {T[]} value The `value` provided to the component.
  2792. * @param {function} getTagProps A tag props getter.
  2793. * @returns {ReactNode}
  2794. */
  2795. renderTags: propTypes.func,
  2796. /**
  2797. * If `true`, the input's text will be selected on focus.
  2798. * It helps the user clear the selected value.
  2799. */
  2800. selectOnFocus: propTypes.bool,
  2801. /**
  2802. * The size of the autocomplete.
  2803. */
  2804. size: propTypes.oneOf(['medium', 'small']),
  2805. /**
  2806. * The value of the autocomplete.
  2807. *
  2808. * The value must have reference equality with the option in order to be selected.
  2809. * You can customize the equality behavior with the `getOptionSelected` prop.
  2810. */
  2811. value: propTypes.any
  2812. } : void 0;
  2813. var Autocomplete$1 = withStyles(styles, {
  2814. name: 'MuiAutocomplete'
  2815. })(Autocomplete);
  2816. const filter = createFilterOptions();
  2817. const BootstrapInput = withStyles(theme => ({
  2818. root: {
  2819. 'label + &': {
  2820. marginTop: theme.spacing(3)
  2821. }
  2822. },
  2823. input: {
  2824. borderRadius: 4,
  2825. position: 'relative',
  2826. backgroundColor: 'transparent',
  2827. border: '1px solid #ced4da',
  2828. fontSize: 16,
  2829. padding: '10px 26px 10px 12px',
  2830. transition: theme.transitions.create(['border-color', 'box-shadow']),
  2831. fontFamily: ['-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
  2832. '&:focus': {
  2833. borderRadius: 4,
  2834. borderColor: '#80bdff',
  2835. boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)'
  2836. }
  2837. }
  2838. }))(InputBase);
  2839. const useStyles = makeStyles(theme => ({
  2840. root: {
  2841. width: '100%'
  2842. },
  2843. paper: {
  2844. width: '100%',
  2845. marginBottom: theme.spacing(2)
  2846. },
  2847. table: {
  2848. minWidth: 750
  2849. },
  2850. visuallyHidden: {
  2851. border: 0,
  2852. clip: 'rect(0 0 0 0)',
  2853. height: 1,
  2854. margin: -1,
  2855. overflow: 'hidden',
  2856. padding: 0,
  2857. position: 'absolute',
  2858. top: 20,
  2859. width: 1
  2860. },
  2861. underline: {
  2862. "&&&:before": {
  2863. borderBottom: "none"
  2864. },
  2865. "&&:after": {
  2866. borderBottom: "none"
  2867. }
  2868. }
  2869. }));
  2870. function FieldList(props) {
  2871. const classes = useStyles();
  2872. const {
  2873. fields = [],
  2874. updateData = {},
  2875. isNew = false,
  2876. currentTabName,
  2877. onCancel,
  2878. onCanCreateNew,
  2879. actions = []
  2880. } = props;
  2881. const [data, setDataField] = React__default.useState(updateData != undefined ? updateData : {});
  2882. const handleTextString = (e, fieldName) => {
  2883. setDataField({ ...data,
  2884. [fieldName]: e.target.value
  2885. });
  2886. };
  2887. const handleTextNumber = (e, fieldName) => {
  2888. setDataField({ ...data,
  2889. [fieldName]: e.target.value
  2890. });
  2891. };
  2892. const handleTextMultiline = (e, fieldName) => {
  2893. setDataField({ ...data,
  2894. [fieldName]: e.target.value
  2895. });
  2896. };
  2897. const handleDate = (e, fieldName) => {
  2898. setDataField({ ...data,
  2899. [fieldName]: e.target.value
  2900. });
  2901. };
  2902. const handleDropDownChange = (e, fieldName) => {
  2903. var selectedIndex = e.target.options.selectedIndex;
  2904. var selectedValue = e.target.options[selectedIndex].getAttribute('name');
  2905. var fn = fieldName.split('_');
  2906. var fieldId = fn[0] + '_' + 'id';
  2907. setDataField({ ...data,
  2908. [fieldName]: selectedValue,
  2909. [fieldId]: e.target.value
  2910. });
  2911. };
  2912. const handleCanCreateNew = data => {
  2913. onCanCreateNew(data);
  2914. };
  2915. const onChangeValue = (fieldName, value) => {
  2916. var fn = fieldName.split('_');
  2917. var fieldId = fn[0] + '_' + 'id';
  2918. var d = value['name'] != undefined ? value['name'] : value['product_desc'];
  2919. if (isNew) {
  2920. setDataField({ ...data,
  2921. [fieldName]: d,
  2922. [fieldId]: value['id']
  2923. });
  2924. } else {
  2925. setDataField({ ...data,
  2926. [fieldName]: d,
  2927. [fieldId]: value['id']
  2928. });
  2929. }
  2930. };
  2931. return /*#__PURE__*/React__default.createElement("div", {
  2932. className: classes.root
  2933. }, /*#__PURE__*/React__default.createElement(Grid, {
  2934. container: true
  2935. }, /*#__PURE__*/React__default.createElement(Grid, {
  2936. item: true,
  2937. xs: 12
  2938. }, fields.map((f, i) => {
  2939. if (f.type == 'text_string') {
  2940. return /*#__PURE__*/React__default.createElement(Grid, {
  2941. key: f.fieldName,
  2942. container: true,
  2943. style: {
  2944. display: 'flex',
  2945. alignItems: 'center',
  2946. marginBottom: '10px'
  2947. }
  2948. }, /*#__PURE__*/React__default.createElement(Grid, {
  2949. item: true,
  2950. xs: 12,
  2951. sm: 5
  2952. }, /*#__PURE__*/React__default.createElement(Box, {
  2953. style: {
  2954. width: '150px'
  2955. }
  2956. }, /*#__PURE__*/React__default.createElement(Typography, {
  2957. style: {
  2958. paddingRight: '30px',
  2959. color: 'grey'
  2960. }
  2961. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  2962. item: true,
  2963. xs: 12,
  2964. sm: 7
  2965. }, /*#__PURE__*/React__default.createElement(TextField, {
  2966. id: f.fieldName,
  2967. variant: "outlined",
  2968. autoComplete: "off",
  2969. size: "small",
  2970. style: {
  2971. width: '100%'
  2972. },
  2973. InputProps: {
  2974. readOnly: f.readOnly ? f.readOnly : false
  2975. },
  2976. value: data != undefined ? data[f.fieldName] : '',
  2977. onChange: e => handleTextString(e, f.fieldName)
  2978. })));
  2979. } else if (f.type == 'text_number') {
  2980. return /*#__PURE__*/React__default.createElement(Grid, {
  2981. key: f.fieldName,
  2982. container: true,
  2983. style: {
  2984. display: 'flex',
  2985. alignItems: 'center',
  2986. marginBottom: '10px'
  2987. }
  2988. }, /*#__PURE__*/React__default.createElement(Grid, {
  2989. item: true,
  2990. xs: 12,
  2991. sm: 5
  2992. }, /*#__PURE__*/React__default.createElement(Box, {
  2993. style: {
  2994. width: '150px'
  2995. }
  2996. }, /*#__PURE__*/React__default.createElement(Typography, {
  2997. style: {
  2998. paddingRight: '30px',
  2999. color: 'grey'
  3000. }
  3001. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3002. item: true,
  3003. xs: 12,
  3004. sm: 7
  3005. }, /*#__PURE__*/React__default.createElement(TextField, {
  3006. id: f.fieldName,
  3007. variant: "outlined",
  3008. autoComplete: "off",
  3009. size: "small",
  3010. style: {
  3011. width: '100%'
  3012. },
  3013. type: "number",
  3014. value: data != undefined ? data[f.fieldName] : '',
  3015. onChange: e => handleTextNumber(e, f.fieldName)
  3016. })));
  3017. } else if (f.type == 'text_multiline') {
  3018. return /*#__PURE__*/React__default.createElement(Grid, {
  3019. key: f.fieldName,
  3020. container: true,
  3021. style: {
  3022. display: 'flex',
  3023. alignItems: 'center',
  3024. marginBottom: '10px'
  3025. }
  3026. }, /*#__PURE__*/React__default.createElement(Grid, {
  3027. item: true,
  3028. xs: 12,
  3029. sm: 5
  3030. }, /*#__PURE__*/React__default.createElement(Box, {
  3031. style: {
  3032. width: '150px'
  3033. }
  3034. }, /*#__PURE__*/React__default.createElement(Typography, {
  3035. style: {
  3036. paddingRight: '30px',
  3037. color: 'grey'
  3038. }
  3039. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3040. item: true,
  3041. xs: 12,
  3042. sm: 7
  3043. }, /*#__PURE__*/React__default.createElement(TextField, {
  3044. id: f.fieldName,
  3045. multiline: true,
  3046. autoComplete: "off",
  3047. rows: 3,
  3048. size: "small",
  3049. style: {
  3050. width: '100%'
  3051. },
  3052. value: data != undefined ? data[f.fieldName] : '',
  3053. variant: "outlined",
  3054. onChange: e => handleTextMultiline(e, f.fieldName)
  3055. })));
  3056. } else if (f.type == 'date') {
  3057. return /*#__PURE__*/React__default.createElement(Grid, {
  3058. key: f.fieldName,
  3059. container: true,
  3060. style: {
  3061. display: 'flex',
  3062. alignItems: 'center',
  3063. marginBottom: '10px'
  3064. }
  3065. }, /*#__PURE__*/React__default.createElement(Grid, {
  3066. item: true,
  3067. xs: 12,
  3068. sm: 5
  3069. }, /*#__PURE__*/React__default.createElement(Box, {
  3070. style: {
  3071. width: '150px'
  3072. }
  3073. }, /*#__PURE__*/React__default.createElement(Typography, {
  3074. style: {
  3075. paddingRight: '30px',
  3076. color: 'grey'
  3077. }
  3078. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3079. item: true,
  3080. xs: 12,
  3081. sm: 7
  3082. }, /*#__PURE__*/React__default.createElement(TextField, {
  3083. id: f.fieldName,
  3084. variant: "outlined",
  3085. autoComplete: "off",
  3086. size: "small",
  3087. value: data != undefined ? data[f.fieldName] : '',
  3088. type: "date",
  3089. style: {
  3090. width: '100%'
  3091. },
  3092. onChange: e => handleDate(e, f.fieldName)
  3093. })));
  3094. } else if (f.type == 'dropdown') {
  3095. if (f.options != undefined) {
  3096. if (f.fieldName == 'priority') {
  3097. return /*#__PURE__*/React__default.createElement(Grid, {
  3098. key: f.fieldName,
  3099. container: true,
  3100. style: {
  3101. display: 'flex',
  3102. alignItems: 'center',
  3103. marginBottom: '10px'
  3104. }
  3105. }, /*#__PURE__*/React__default.createElement(Grid, {
  3106. item: true,
  3107. xs: 12,
  3108. sm: 5
  3109. }, /*#__PURE__*/React__default.createElement(Box, {
  3110. style: {
  3111. width: '150px'
  3112. }
  3113. }, /*#__PURE__*/React__default.createElement(Typography, {
  3114. style: {
  3115. paddingRight: '30px',
  3116. color: 'grey'
  3117. }
  3118. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3119. item: true,
  3120. xs: 12,
  3121. sm: 7
  3122. }, /*#__PURE__*/React__default.createElement(NativeSelect, {
  3123. id: "demo-customized-select-native",
  3124. value: data != undefined ? data[f.fieldName] : '',
  3125. onChange: e => handleDropDownChange(e, f.fieldName),
  3126. id: f.fieldName,
  3127. input: /*#__PURE__*/React__default.createElement(BootstrapInput, null),
  3128. style: {
  3129. width: '100%'
  3130. }
  3131. }, /*#__PURE__*/React__default.createElement("option", {
  3132. "aria-label": "None",
  3133. value: ""
  3134. }, "Select"), f.options.map((d, i) => {
  3135. return /*#__PURE__*/React__default.createElement("option", {
  3136. name: d.name,
  3137. value: d.id
  3138. }, d.name);
  3139. }))));
  3140. } else {
  3141. var fn = f.fieldName.split('_');
  3142. var fieldId = fn[0] + '_' + 'id';
  3143. if (isNew) {
  3144. return /*#__PURE__*/React__default.createElement(Grid, {
  3145. key: f.fieldName,
  3146. container: true,
  3147. style: {
  3148. display: 'flex',
  3149. alignItems: 'center',
  3150. marginBottom: '10px'
  3151. }
  3152. }, /*#__PURE__*/React__default.createElement(Grid, {
  3153. item: true,
  3154. xs: 12,
  3155. sm: 5
  3156. }, /*#__PURE__*/React__default.createElement(Box, {
  3157. style: {
  3158. width: '150px'
  3159. }
  3160. }, /*#__PURE__*/React__default.createElement(Typography, {
  3161. style: {
  3162. paddingRight: '30px',
  3163. color: 'grey'
  3164. }
  3165. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3166. item: true,
  3167. xs: 12,
  3168. sm: 7
  3169. }, /*#__PURE__*/React__default.createElement(Autocomplete$1, {
  3170. id: "combo-box-demo",
  3171. options: f.options,
  3172. getOptionLabel: option => {
  3173. if (typeof option === 'string') {
  3174. return option;
  3175. }
  3176. return option[f.fieldName] != undefined ? option[f.fieldName] : option.name != undefined ? option.name : option.product_desc != undefined ? option.product_desc : '';
  3177. },
  3178. style: {
  3179. width: '100%'
  3180. },
  3181. size: "small",
  3182. value: data != undefined ? data[f.fieldName] ? data[f.fieldName] : " " : " ",
  3183. filterOptions: (options, params) => {
  3184. console.log("Autocomplete", f.canCreate);
  3185. if (f.canCreate) {
  3186. var newFilter = ['+ Add New'];
  3187. var filtered = filter(options, params);
  3188. return [...newFilter, ...filtered];
  3189. } else {
  3190. var filtered = filter(options, params);
  3191. return filtered;
  3192. }
  3193. },
  3194. onChange: (event, newValue) => {
  3195. if (typeof newValue === 'string') {
  3196. console.log('f.fieldName', f.fieldName, " f.canCreate", f.canCreate);
  3197. var d = {
  3198. "canCreate": f.canCreate,
  3199. "fields": f.fields,
  3200. "name": f.name,
  3201. "fieldName": f.fieldName
  3202. };
  3203. handleCanCreateNew(d);
  3204. } else {
  3205. if (newValue != null && newValue.inputValue != '' && newValue.product_desc != "") {
  3206. onChangeValue(f.fieldName, newValue);
  3207. }
  3208. }
  3209. },
  3210. renderInput: params => /*#__PURE__*/React__default.createElement(TextField, Object.assign({}, params, {
  3211. variant: "outlined"
  3212. }))
  3213. })));
  3214. } else {
  3215. return /*#__PURE__*/React__default.createElement(Grid, {
  3216. key: f.fieldName,
  3217. container: true,
  3218. style: {
  3219. display: 'flex',
  3220. alignItems: 'center',
  3221. marginBottom: '10px'
  3222. }
  3223. }, /*#__PURE__*/React__default.createElement(Grid, {
  3224. item: true,
  3225. xs: 12,
  3226. sm: 5
  3227. }, /*#__PURE__*/React__default.createElement(Box, {
  3228. style: {
  3229. width: '150px'
  3230. }
  3231. }, /*#__PURE__*/React__default.createElement(Typography, {
  3232. style: {
  3233. paddingRight: '30px',
  3234. color: 'grey'
  3235. }
  3236. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3237. item: true,
  3238. xs: 12,
  3239. sm: 7
  3240. }, /*#__PURE__*/React__default.createElement(NativeSelect, {
  3241. id: "demo-customized-select-native",
  3242. value: data != undefined ? data[fieldId] : '',
  3243. onChange: e => handleDropDownChange(e, f.fieldName),
  3244. id: f.fieldName,
  3245. input: /*#__PURE__*/React__default.createElement(BootstrapInput, null),
  3246. style: {
  3247. width: '100%'
  3248. }
  3249. }, /*#__PURE__*/React__default.createElement("option", {
  3250. "aria-label": "None",
  3251. value: ""
  3252. }, "Select"), f.options.map((d, i) => {
  3253. var name = d[f.fieldName] != undefined ? d[f.fieldName] : d.name;
  3254. return /*#__PURE__*/React__default.createElement("option", {
  3255. name: name,
  3256. value: d.id
  3257. }, name);
  3258. }))));
  3259. }
  3260. }
  3261. }
  3262. } else if (f.type == 'photo_list') {
  3263. console.log('photo_list:', data);
  3264. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Grid, {
  3265. key: f.fieldName,
  3266. container: true,
  3267. style: {
  3268. display: 'flex',
  3269. alignItems: 'center',
  3270. marginBottom: '10px'
  3271. }
  3272. }, /*#__PURE__*/React__default.createElement(Grid, {
  3273. item: true,
  3274. xs: 12,
  3275. sm: 5
  3276. }, /*#__PURE__*/React__default.createElement(Box, {
  3277. style: {
  3278. width: '150px'
  3279. }
  3280. }, /*#__PURE__*/React__default.createElement(Typography, {
  3281. style: {
  3282. paddingRight: '30px',
  3283. color: 'grey'
  3284. }
  3285. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3286. item: true,
  3287. xs: 12,
  3288. sm: 7
  3289. }, /*#__PURE__*/React__default.createElement("div", {
  3290. style: {
  3291. display: 'flex',
  3292. alignItems: 'center',
  3293. marginBottom: '10px'
  3294. }
  3295. }, /*#__PURE__*/React__default.createElement("form", null, /*#__PURE__*/React__default.createElement("div", {
  3296. className: "form-group"
  3297. }, /*#__PURE__*/React__default.createElement("input", {
  3298. type: "file",
  3299. name: "imgCollection",
  3300. onChange: e => onFileChange(e, f.fieldName),
  3301. multiple: true
  3302. })))))), data[f.fieldName] != undefined && data[f.fieldName].length != 0 ? /*#__PURE__*/React__default.createElement(Grid, {
  3303. key: f.fieldName,
  3304. container: true,
  3305. style: {
  3306. display: 'flex',
  3307. alignItems: 'center',
  3308. marginBottom: '10px'
  3309. }
  3310. }, /*#__PURE__*/React__default.createElement(Grid, {
  3311. item: true,
  3312. xs: 12
  3313. }, /*#__PURE__*/React__default.createElement("div", {
  3314. style: {
  3315. display: 'block',
  3316. alignItems: 'center',
  3317. marginBottom: '10px'
  3318. }
  3319. }, /*#__PURE__*/React__default.createElement(GridList, {
  3320. className: classes.gridList
  3321. }, data[f.fieldName] == undefined ? /*#__PURE__*/React__default.createElement("span", null) : data[f.fieldName].map(tile => /*#__PURE__*/React__default.createElement(GridListTile, {
  3322. key: tile,
  3323. style: {
  3324. width: '100px',
  3325. height: '100px'
  3326. }
  3327. }, /*#__PURE__*/React__default.createElement("img", {
  3328. src: tile,
  3329. alt: tile,
  3330. onClick: e => {
  3331. setSelectedPhoto(tile);
  3332. setOpen(true);
  3333. }
  3334. })))))), /*#__PURE__*/React__default.createElement(Dialog, {
  3335. maxWidth: "lg",
  3336. "aria-labelledby": "customized-dialog-title",
  3337. open: open
  3338. }, /*#__PURE__*/React__default.createElement(DialogTitle, {
  3339. id: "customized-dialog-title",
  3340. onClose: e => setOpen(false)
  3341. }, "Photos"), /*#__PURE__*/React__default.createElement(DialogContent, {
  3342. dividers: true
  3343. }, /*#__PURE__*/React__default.createElement(Grid, {
  3344. item: true,
  3345. xs: 12
  3346. }, /*#__PURE__*/React__default.createElement(Grid, null, /*#__PURE__*/React__default.createElement("img", {
  3347. src: selectedPhoto,
  3348. className: "show-img",
  3349. alt: "logo"
  3350. })), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement(Grid, {
  3351. container: true,
  3352. spacing: 3
  3353. }, data[f.fieldName].length > 0 ? data[f.fieldName].map(value => /*#__PURE__*/React__default.createElement(Grid, {
  3354. key: value,
  3355. item: true
  3356. }, /*#__PURE__*/React__default.createElement(Box, {
  3357. className: "square"
  3358. }, " ", /*#__PURE__*/React__default.createElement("img", {
  3359. src: value,
  3360. className: "thumnail-img",
  3361. alt: "logo",
  3362. onClick: e => setSelectedPhoto(value)
  3363. })))) : /*#__PURE__*/React__default.createElement("span", null)))))) : /*#__PURE__*/React__default.createElement(Grid, null));
  3364. } else if (f.type == 'list') {
  3365. console.log('list', data[f.fieldName]);
  3366. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Grid, {
  3367. key: f.fieldName,
  3368. container: true,
  3369. style: {
  3370. display: 'flex',
  3371. alignItems: 'center',
  3372. marginBottom: '10px'
  3373. }
  3374. }, /*#__PURE__*/React__default.createElement(Grid, {
  3375. item: true,
  3376. xs: 12,
  3377. sm: 5
  3378. }, /*#__PURE__*/React__default.createElement(Box, {
  3379. style: {
  3380. width: '150px'
  3381. }
  3382. }, /*#__PURE__*/React__default.createElement(Typography, {
  3383. style: {
  3384. paddingRight: '30px',
  3385. color: 'grey'
  3386. }
  3387. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3388. item: true,
  3389. xs: 12,
  3390. sm: 7
  3391. }, /*#__PURE__*/React__default.createElement("div", {
  3392. style: {
  3393. display: 'block',
  3394. alignItems: 'center',
  3395. marginBottom: '10px'
  3396. }
  3397. }, /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3398. onClick: handleSelectItemDialog
  3399. }, /*#__PURE__*/React__default.createElement(AddIcon, null)))))), /*#__PURE__*/React__default.createElement(Grid, {
  3400. key: f.fieldName,
  3401. container: true,
  3402. style: {
  3403. display: 'block',
  3404. alignItems: 'center',
  3405. marginBottom: '10px'
  3406. }
  3407. }, /*#__PURE__*/React__default.createElement("div", {
  3408. style: {
  3409. display: 'block',
  3410. alignItems: 'center',
  3411. marginBottom: '10px'
  3412. }
  3413. }, /*#__PURE__*/React__default.createElement(TableContainer, null, /*#__PURE__*/React__default.createElement(Table, {
  3414. className: classes.table,
  3415. size: "small",
  3416. "aria-label": "a dense table"
  3417. }, /*#__PURE__*/React__default.createElement(TableHead, null, /*#__PURE__*/React__default.createElement(TableRow, null, partHeaders.map((h, i) => {
  3418. return /*#__PURE__*/React__default.createElement(TableCell, {
  3419. key: h.id,
  3420. align: "left"
  3421. }, h.label);
  3422. }))), /*#__PURE__*/React__default.createElement(TableBody, null, data[f.fieldName].length > 0 ? data[f.fieldName].map(row => /*#__PURE__*/React__default.createElement(TableRow, {
  3423. key: row.name
  3424. }, partHeaders.map((h, i) => {
  3425. return /*#__PURE__*/React__default.createElement(TableCell, {
  3426. key: h.id,
  3427. align: h.numeric ? 'right' : 'left'
  3428. }, row[h.id]);
  3429. }))) : /*#__PURE__*/React__default.createElement("span", null)))))));
  3430. } else if (f.type == 'time') {
  3431. return /*#__PURE__*/React__default.createElement(Grid, {
  3432. key: f.fieldName,
  3433. container: true,
  3434. style: {
  3435. display: 'flex',
  3436. alignItems: 'center',
  3437. marginBottom: '10px'
  3438. }
  3439. }, /*#__PURE__*/React__default.createElement(Grid, {
  3440. item: true,
  3441. xs: 12,
  3442. sm: 5
  3443. }, /*#__PURE__*/React__default.createElement(Box, {
  3444. style: {
  3445. width: '150px'
  3446. }
  3447. }, /*#__PURE__*/React__default.createElement(Typography, {
  3448. style: {
  3449. paddingRight: '30px',
  3450. color: 'grey'
  3451. }
  3452. }, f.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3453. item: true,
  3454. xs: 12,
  3455. sm: 7
  3456. }, " ", /*#__PURE__*/React__default.createElement(TextField, {
  3457. id: "time",
  3458. variant: "outlined",
  3459. size: "small",
  3460. type: "time",
  3461. className: classes.textField,
  3462. InputLabelProps: {
  3463. shrink: true
  3464. },
  3465. inputProps: {
  3466. step: 300
  3467. },
  3468. onChange: e => handleTime(e, f.fieldName)
  3469. })));
  3470. }
  3471. })), actions.length > 0 ? currentTabName === 'account' ? /*#__PURE__*/React__default.createElement(Grid, {
  3472. item: true,
  3473. xs: 12
  3474. }, data != undefined ? actions.map(a => {
  3475. if (a.status === data.status) {
  3476. return /*#__PURE__*/React__default.createElement(MButton, {
  3477. action: a,
  3478. onCallback: a.callback(data)
  3479. });
  3480. }
  3481. }) : /*#__PURE__*/React__default.createElement(Grid, null)) : /*#__PURE__*/React__default.createElement(Grid, {
  3482. item: true,
  3483. xs: 12
  3484. }, actions.map(a => {
  3485. if (a.status === data.status && currentTabName !== 'account') {
  3486. return /*#__PURE__*/React__default.createElement(MButton, {
  3487. action: a,
  3488. onCallback: a.callback(data)
  3489. });
  3490. }
  3491. })) : /*#__PURE__*/React__default.createElement(Grid, null)));
  3492. }
  3493. FieldList.propTypes = {
  3494. history: propTypes.object,
  3495. fields: propTypes.array.isRequired,
  3496. updateData: propTypes.object,
  3497. isNew: propTypes.bool,
  3498. currentTabName: propTypes.string,
  3499. onCancel: propTypes.func,
  3500. actions: propTypes.array,
  3501. onCanCreateNew: propTypes.func
  3502. };
  3503. function descendingComparator(a, b, orderBy) {
  3504. if (b[orderBy] < a[orderBy]) {
  3505. return -1;
  3506. }
  3507. if (b[orderBy] > a[orderBy]) {
  3508. return 1;
  3509. }
  3510. return 0;
  3511. }
  3512. function getComparator(order, orderBy) {
  3513. return order === 'desc' ? (a, b) => descendingComparator(a, b, orderBy) : (a, b) => -descendingComparator(a, b, orderBy);
  3514. }
  3515. function stableSort(array, comparator) {
  3516. const stabilizedThis = array.map((el, index) => [el, index]);
  3517. stabilizedThis.sort((a, b) => {
  3518. const order = comparator(a[0], b[0]);
  3519. if (order !== 0) return order;
  3520. return a[1] - b[1];
  3521. });
  3522. return stabilizedThis.map(el => el[0]);
  3523. }
  3524. function EnhancedTableHead(props) {
  3525. const {
  3526. classes,
  3527. order,
  3528. orderBy,
  3529. onRequestSort,
  3530. onRefreshData,
  3531. headCells
  3532. } = props;
  3533. const createSortHandler = property => event => {
  3534. onRequestSort(event, property);
  3535. onRefreshData();
  3536. };
  3537. return /*#__PURE__*/React__default.createElement(TableHead$1, null, /*#__PURE__*/React__default.createElement(TableRow$1, null, headCells.map(headCell => /*#__PURE__*/React__default.createElement(TableCell$1, {
  3538. key: headCell.id,
  3539. align: headCell.numeric ? 'right' : 'left',
  3540. padding: headCell.disablePadding ? 'none' : 'default',
  3541. sortDirection: orderBy === headCell.id ? order : false
  3542. }, headCell.id != 'id' ? /*#__PURE__*/React__default.createElement(TableSortLabel, {
  3543. active: orderBy === headCell.id,
  3544. direction: orderBy === headCell.id ? order : 'asc',
  3545. onClick: createSortHandler(headCell.id)
  3546. }, headCell.label, orderBy === headCell.id ? /*#__PURE__*/React__default.createElement("span", {
  3547. className: classes.visuallyHidden
  3548. }, order === 'desc' ? 'sorted descending' : 'sorted ascending') : null) : /*#__PURE__*/React__default.createElement(TableSortLabel, {
  3549. hideSortIcon: true
  3550. }, headCell.label)))));
  3551. }
  3552. EnhancedTableHead.propTypes = {
  3553. classes: propTypes.object.isRequired,
  3554. numSelected: propTypes.number.isRequired,
  3555. onRequestSort: propTypes.func.isRequired,
  3556. onRefreshData: propTypes.func.isRequired,
  3557. onSelectAllClick: propTypes.func.isRequired,
  3558. order: propTypes.oneOf(['asc', 'desc']).isRequired,
  3559. orderBy: propTypes.string.isRequired,
  3560. rowCount: propTypes.number.isRequired
  3561. };
  3562. const useStyles$1 = makeStyles(theme => ({
  3563. root: {
  3564. width: '100%'
  3565. },
  3566. paper: {
  3567. width: '100%',
  3568. marginBottom: theme.spacing(2)
  3569. },
  3570. table: {
  3571. minWidth: 750
  3572. },
  3573. visuallyHidden: {
  3574. border: 0,
  3575. clip: 'rect(0 0 0 0)',
  3576. height: 1,
  3577. margin: -1,
  3578. overflow: 'hidden',
  3579. padding: 0,
  3580. position: 'absolute',
  3581. top: 20,
  3582. width: 1
  3583. },
  3584. underline: {
  3585. "&&&:before": {
  3586. borderBottom: "none"
  3587. },
  3588. "&&:after": {
  3589. borderBottom: "none"
  3590. }
  3591. }
  3592. }));
  3593. function TableTemplate(props) {
  3594. const classes = useStyles$1();
  3595. const {
  3596. data = [],
  3597. headers = [],
  3598. onUpdateData,
  3599. onReloadData,
  3600. onChangePage,
  3601. onChangeRowsPerPage,
  3602. rowsPerPage = 10,
  3603. page = 0,
  3604. order = 'asc',
  3605. orderBy
  3606. } = props;
  3607. const [selected, setSelected] = React__default.useState([]);
  3608. const [dense, setDense] = React__default.useState(false);
  3609. const [rowDataPerPage, setRowsPerPage] = React__default.useState(rowsPerPage != undefined ? rowsPerPage : 10);
  3610. const [paginatePage, setPage] = React__default.useState(page != undefined ? page : 0);
  3611. const [paginateOrder, setOrder] = React__default.useState(order != undefined ? order : 'asc');
  3612. const [paginateOrderBy, setOrderBy] = React__default.useState(orderBy != undefined ? orderBy : 'name');
  3613. var offset = paginatePage * rowDataPerPage;
  3614. const handleRequestSort = (event, property) => {
  3615. const isAsc = orderBy === property && order === 'asc';
  3616. setOrder(isAsc ? 'desc' : 'asc');
  3617. setOrderBy(property);
  3618. };
  3619. const handleSelectAllClick = event => {
  3620. if (event.target.checked) {
  3621. const newSelecteds = data.map(n => n.name);
  3622. setSelected(newSelecteds);
  3623. return;
  3624. }
  3625. setSelected([]);
  3626. };
  3627. const handleClick = (event, rowdata) => {
  3628. onUpdateData(true, rowdata);
  3629. };
  3630. const handleChangePage = (event, newPage) => {
  3631. onChangePage(newPage);
  3632. };
  3633. const handleReloadData = () => {
  3634. onReloadData();
  3635. };
  3636. const handleChangeRowsPerPage = event => {
  3637. setRowsPerPage(parseInt(event.target.value, 10));
  3638. onChangeRowsPerPage(parseInt(event.target.value));
  3639. onReloadData();
  3640. };
  3641. const isSelected = name => selected.indexOf(name) !== -1;
  3642. const emptyRows = rowsPerPage - Math.min(rowsPerPage, data.length - page * rowsPerPage);
  3643. return /*#__PURE__*/React__default.createElement("div", {
  3644. className: classes.root
  3645. }, /*#__PURE__*/React__default.createElement(Grid, {
  3646. container: true
  3647. }, /*#__PURE__*/React__default.createElement(Grid, {
  3648. item: true,
  3649. style: {
  3650. marginRight: '10%'
  3651. }
  3652. }, /*#__PURE__*/React__default.createElement(TableContainer$1, null, /*#__PURE__*/React__default.createElement(Table$1, {
  3653. className: classes.table,
  3654. "aria-labelledby": "tableTitle",
  3655. size: dense ? 'small' : 'medium',
  3656. "aria-label": "enhanced table"
  3657. }, /*#__PURE__*/React__default.createElement(EnhancedTableHead, {
  3658. classes: classes,
  3659. numSelected: selected.length,
  3660. headCells: headers,
  3661. order: order,
  3662. orderBy: orderBy,
  3663. onSelectAllClick: handleSelectAllClick,
  3664. onRequestSort: handleRequestSort,
  3665. onRefreshData: handleReloadData,
  3666. rowCount: data.length
  3667. }), /*#__PURE__*/React__default.createElement(TableBody$1, null, data.length != 0 ? stableSort(data, getComparator(order, orderBy)).slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((row, index) => {
  3668. const isItemSelected = isSelected(row.name);
  3669. return /*#__PURE__*/React__default.createElement(TableRow$1, {
  3670. hover: true,
  3671. onClick: event => handleClick(event, row),
  3672. role: "checkbox",
  3673. "aria-checked": isItemSelected,
  3674. tabIndex: -1,
  3675. key: index,
  3676. selected: isItemSelected
  3677. }, headers.map((h, i) => {
  3678. if (h.id == 'id') {
  3679. return /*#__PURE__*/React__default.createElement(TableCell$1, {
  3680. key: h.id,
  3681. align: "right"
  3682. }, ++offset);
  3683. } else {
  3684. return /*#__PURE__*/React__default.createElement(TableCell$1, {
  3685. key: h.id,
  3686. align: "right"
  3687. }, row[h.id]);
  3688. }
  3689. }));
  3690. }) : /*#__PURE__*/React__default.createElement("div", null), emptyRows > 0 && /*#__PURE__*/React__default.createElement(TableRow$1, {
  3691. style: {
  3692. height: (dense ? 33 : 53) * emptyRows
  3693. }
  3694. }, /*#__PURE__*/React__default.createElement(TableCell$1, {
  3695. colSpan: 6
  3696. }))))), /*#__PURE__*/React__default.createElement(TablePagination, {
  3697. rowsPerPageOptions: [5, 10, 20, 30],
  3698. labelDisplayedRows: function ({
  3699. from,
  3700. to,
  3701. count
  3702. }) {},
  3703. component: "div",
  3704. count: data.length,
  3705. rowsPerPage: rowsPerPage,
  3706. rowsPerPage: rowsPerPage,
  3707. page: page,
  3708. onChangePage: handleChangePage,
  3709. onChangeRowsPerPage: handleChangeRowsPerPage
  3710. }))));
  3711. }
  3712. TableTemplate.propTypes = {
  3713. history: propTypes.object,
  3714. headers: propTypes.array.isRequired,
  3715. data: propTypes.array.isRequired,
  3716. onUpdateData: propTypes.func,
  3717. onReloadData: propTypes.func,
  3718. onChangePage: propTypes.func,
  3719. onChangeRowsPerPage: propTypes.func,
  3720. query: propTypes.object,
  3721. page: propTypes.any,
  3722. rowsPerPage: propTypes.any,
  3723. order: propTypes.any,
  3724. orderBy: propTypes.any
  3725. };
  3726. const useStyles$2 = makeStyles(theme => ({
  3727. root: {
  3728. width: '100%'
  3729. },
  3730. paper: {
  3731. width: '100%',
  3732. marginBottom: theme.spacing(2)
  3733. },
  3734. table: {
  3735. minWidth: 750
  3736. },
  3737. visuallyHidden: {
  3738. border: 0,
  3739. clip: 'rect(0 0 0 0)',
  3740. height: 1,
  3741. margin: -1,
  3742. overflow: 'hidden',
  3743. padding: 0,
  3744. position: 'absolute',
  3745. top: 20,
  3746. width: 1
  3747. },
  3748. underline: {
  3749. "&&&:before": {
  3750. borderBottom: "none"
  3751. },
  3752. "&&:after": {
  3753. borderBottom: "none"
  3754. }
  3755. },
  3756. button: {
  3757. color: 'white',
  3758. color: theme.palette.primary.main,
  3759. width: 150,
  3760. height: 55
  3761. },
  3762. closeButton: {
  3763. position: 'absolute',
  3764. right: theme.spacing(1),
  3765. top: theme.spacing(1),
  3766. color: theme.palette.grey[500]
  3767. },
  3768. headText: {
  3769. fontSize: 14,
  3770. float: "left",
  3771. color: theme.palette.primary.main,
  3772. fontWeight: "bold"
  3773. },
  3774. paper: {
  3775. padding: theme.spacing(2),
  3776. textAlign: 'center',
  3777. color: theme.palette.text.secondary
  3778. }
  3779. }));
  3780. function getDataString(data, fieldName) {
  3781. return data[fieldName];
  3782. }
  3783. function InfoPage(props) {
  3784. const classes = useStyles$2();
  3785. const {
  3786. infoData,
  3787. displayFields,
  3788. isNew = false,
  3789. isEditable,
  3790. currentTabName,
  3791. actions
  3792. } = props;
  3793. const [editable, setEditable] = React__default.useState(isEditable != undefined ? isEditable : true);
  3794. const [data, setData] = React__default.useState({});
  3795. const handleEdit = () => {
  3796. setEditable(false);
  3797. };
  3798. const handleUpdateData = data => {
  3799. console.log('handle update date:', data);
  3800. setData(data);
  3801. };
  3802. return /*#__PURE__*/React__default.createElement("div", {
  3803. className: classes.root
  3804. }, isNew ? /*#__PURE__*/React__default.createElement(Grid, {
  3805. container: true,
  3806. style: {
  3807. marginTop: '30px'
  3808. }
  3809. }, /*#__PURE__*/React__default.createElement(Grid, {
  3810. item: true,
  3811. xs: 12,
  3812. sm: 7
  3813. }, /*#__PURE__*/React__default.createElement(FieldList, {
  3814. updateData: infoData,
  3815. fields: displayFields,
  3816. isNew: isNew,
  3817. onDataCallback: d => handleUpdateData(d)
  3818. }))) : /*#__PURE__*/React__default.createElement(Grid, {
  3819. container: true,
  3820. style: {
  3821. marginTop: '30px'
  3822. }
  3823. }, /*#__PURE__*/React__default.createElement(Grid, {
  3824. item: true,
  3825. xs: 12,
  3826. sm: 7
  3827. }, !editable ? /*#__PURE__*/React__default.createElement(FieldList, {
  3828. fields: displayFields,
  3829. isNew: isNew,
  3830. updateData: infoData,
  3831. onDataCallback: d => handleUpdateData(d)
  3832. }) : displayFields.map((d, i) => {
  3833. return /*#__PURE__*/React__default.createElement(Grid, {
  3834. container: true
  3835. }, /*#__PURE__*/React__default.createElement(Grid, {
  3836. item: true,
  3837. xs: 12,
  3838. style: {
  3839. display: 'flex',
  3840. alignItems: 'center',
  3841. marginBottom: '10px'
  3842. }
  3843. }, /*#__PURE__*/React__default.createElement(Grid, {
  3844. item: true,
  3845. xs: 12,
  3846. sm: 5
  3847. }, /*#__PURE__*/React__default.createElement(Box, {
  3848. style: {
  3849. width: '250px'
  3850. }
  3851. }, /*#__PURE__*/React__default.createElement(Typography, {
  3852. style: {
  3853. paddingRight: '30px',
  3854. color: 'grey'
  3855. }
  3856. }, d.label))), /*#__PURE__*/React__default.createElement(Grid, {
  3857. item: true,
  3858. xs: 12,
  3859. sm: 7
  3860. }, d.type == 'photo' ? /*#__PURE__*/React__default.createElement("img", {
  3861. src: infoData['photo_url'],
  3862. style: {
  3863. width: '120px',
  3864. height: '120px',
  3865. border: '1px solid grey'
  3866. }
  3867. }) : /*#__PURE__*/React__default.createElement(Typography, {
  3868. style: {
  3869. paddingRight: '30px'
  3870. }
  3871. }, infoData != undefined ? getDataString(infoData, d.fieldName) : ''))));
  3872. })), /*#__PURE__*/React__default.createElement(Grid, {
  3873. item: true,
  3874. xs: 12,
  3875. sm: 7
  3876. }, /*#__PURE__*/React__default.createElement(Grid, {
  3877. container: true,
  3878. direction: "row",
  3879. alignItems: "flex-end"
  3880. }, actions.map((a, i) => {
  3881. if (currentTabName == 'account') {
  3882. if (infoData.status == 'invited') {
  3883. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3884. style: {
  3885. color: 'white',
  3886. backgroundColor: 'grey',
  3887. float: 'right',
  3888. marginLeft: '10px'
  3889. },
  3890. onClick: () => a.callback(data)
  3891. }, a.label));
  3892. }
  3893. if (infoData.status == 'joined') {
  3894. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3895. style: {
  3896. color: 'white',
  3897. backgroundColor: 'grey',
  3898. float: 'right',
  3899. marginLeft: '10px'
  3900. },
  3901. onClick: () => a.callback(data)
  3902. }, a.label));
  3903. }
  3904. if (infoData.status == 'disabled') {
  3905. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3906. style: {
  3907. color: 'white',
  3908. backgroundColor: 'grey',
  3909. float: 'right',
  3910. marginLeft: '10px'
  3911. },
  3912. onClick: () => a.callback(data)
  3913. }, a.label));
  3914. }
  3915. if (infoData.status == 'requested') {
  3916. if (editable) {
  3917. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3918. style: {
  3919. marginLeft: '10px'
  3920. },
  3921. onClick: handleEdit
  3922. }, a.icon, a.label));
  3923. } else {
  3924. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3925. style: {
  3926. color: 'white',
  3927. backgroundColor: 'grey',
  3928. float: 'right',
  3929. marginLeft: '10px'
  3930. },
  3931. onClick: () => a.callback(data)
  3932. }, a.label));
  3933. }
  3934. }
  3935. } else {
  3936. if (editable) {
  3937. if (a.action_type == 'edit') {
  3938. console.log('type: ', a.action_type, 'editable: ', editable);
  3939. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3940. style: {
  3941. marginLeft: '10px'
  3942. },
  3943. onClick: handleEdit
  3944. }, a.icon, a.label));
  3945. }
  3946. if (a.action_type == 'delete') {
  3947. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3948. style: {
  3949. float: 'right',
  3950. marginLeft: '10px'
  3951. },
  3952. onClick: () => a.callback(data)
  3953. }, a.icon, a.label));
  3954. }
  3955. } else {
  3956. if (a.action_type == 'save') {
  3957. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3958. style: {
  3959. marginLeft: '10px'
  3960. },
  3961. onClick: () => a.callback(data)
  3962. }, a.icon, a.label));
  3963. }
  3964. if (a.action_type == 'cancel') {
  3965. return /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  3966. style: {
  3967. float: 'right',
  3968. marginLeft: '10px'
  3969. },
  3970. onClick: () => a.callback(data)
  3971. }, a.icon, a.label));
  3972. }
  3973. }
  3974. }
  3975. })))));
  3976. }
  3977. InfoPage.propTypes = {
  3978. history: propTypes.object,
  3979. infoData: propTypes.object,
  3980. displayFields: propTypes.array,
  3981. isNew: propTypes.bool,
  3982. isEditable: propTypes.bool,
  3983. actions: propTypes.any
  3984. };
  3985. function CheckboxList() {
  3986. return /*#__PURE__*/React.createElement("div", null, "checkbox list");
  3987. }
  3988. function RadioList() {
  3989. return /*#__PURE__*/React.createElement("div", null, "radio list");
  3990. }
  3991. const useStyles$3 = makeStyles(theme => ({
  3992. root: {
  3993. width: '100%'
  3994. }
  3995. }));
  3996. function MButton(props) {
  3997. const classes = useStyles$3();
  3998. const {
  3999. action,
  4000. onCallback
  4001. } = props;
  4002. return /*#__PURE__*/React__default.createElement("div", {
  4003. className: classes.root
  4004. }, /*#__PURE__*/React__default.createElement(Box, null, /*#__PURE__*/React__default.createElement(Button, {
  4005. variant: "contained",
  4006. style: {
  4007. float: 'right',
  4008. margin: "5px"
  4009. },
  4010. onClick: e => {
  4011. }
  4012. }, action.icon, action.label)));
  4013. }
  4014. MButton.propTypes = {
  4015. history: propTypes.object,
  4016. action: propTypes.object,
  4017. onCallback: propTypes.func
  4018. };
  4019. export { CheckboxList, FieldList, InfoPage, List, MButton, RadioList, TableTemplate };
  4020. //# sourceMappingURL=index.modern.js.map