ngx-bootstrap-datepicker.js 203 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630
  1. import { Injectable, EventEmitter, Component, Renderer2, ElementRef, Directive, ViewContainerRef, Input, Output, forwardRef, Host, ChangeDetectorRef, ChangeDetectionStrategy, NgModule, ViewChild } from '@angular/core';
  2. import { __values, __spread, __extends } from 'tslib';
  3. import { filter, map, take } from 'rxjs/operators';
  4. import { getMonth, getFullYear, isFirstDayOfWeek, getDay, shiftDate, isBefore, endOf, isAfter, startOf, isSame, getFirstDayOfMonth, formatDate, getLocale, isSameMonth, isSameDay, isDisabledDay, isSameYear, setFullDate, isDateValid, isArray, isDate, parseDate, utcAsLocal } from 'ngx-bootstrap/chronos';
  5. import { BehaviorSubject } from 'rxjs';
  6. import { MiniState, MiniStore } from 'ngx-bootstrap/mini-ngrx';
  7. import { PositioningService } from 'ngx-bootstrap/positioning';
  8. import { trigger, state, style, transition, animate } from '@angular/animations';
  9. import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
  10. import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule } from '@angular/forms';
  11. import { CommonModule } from '@angular/common';
  12. import { isBs3 } from 'ngx-bootstrap/utils';
  13. /**
  14. * @fileoverview added by tsickle
  15. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  16. */
  17. /**
  18. * For date range picker there are `BsDaterangepickerConfig` which inherits all properties,
  19. * except `displayMonths`, for range picker it default to `2`
  20. */
  21. var BsDatepickerConfig = /** @class */ (function () {
  22. function BsDatepickerConfig() {
  23. /**
  24. * sets use adaptive position
  25. */
  26. this.adaptivePosition = false;
  27. /**
  28. * sets use UTC date time format
  29. */
  30. this.useUtc = false;
  31. /**
  32. * turn on/off animation
  33. */
  34. this.isAnimated = false;
  35. /**
  36. * CSS class which will be applied to datepicker container,
  37. * usually used to set color theme
  38. */
  39. this.containerClass = 'theme-green';
  40. // DatepickerRenderOptions
  41. this.displayMonths = 1;
  42. /**
  43. * Allows to hide week numbers in datepicker
  44. */
  45. this.showWeekNumbers = true;
  46. this.dateInputFormat = 'L';
  47. // range picker
  48. this.rangeSeparator = ' - ';
  49. /**
  50. * Date format for date range input field
  51. */
  52. this.rangeInputFormat = 'L';
  53. // DatepickerFormatOptions
  54. this.monthTitle = 'MMMM';
  55. this.yearTitle = 'YYYY';
  56. this.dayLabel = 'D';
  57. this.monthLabel = 'MMMM';
  58. this.yearLabel = 'YYYY';
  59. this.weekNumbers = 'w';
  60. }
  61. BsDatepickerConfig.decorators = [
  62. { type: Injectable }
  63. ];
  64. return BsDatepickerConfig;
  65. }());
  66. /**
  67. * @fileoverview added by tsickle
  68. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  69. */
  70. /**
  71. * @abstract
  72. */
  73. var /**
  74. * @abstract
  75. */
  76. BsDatepickerAbstractComponent = /** @class */ (function () {
  77. function BsDatepickerAbstractComponent() {
  78. this._customRangesFish = [];
  79. }
  80. Object.defineProperty(BsDatepickerAbstractComponent.prototype, "minDate", {
  81. set: /**
  82. * @param {?} value
  83. * @return {?}
  84. */
  85. function (value) {
  86. this._effects.setMinDate(value);
  87. },
  88. enumerable: true,
  89. configurable: true
  90. });
  91. Object.defineProperty(BsDatepickerAbstractComponent.prototype, "maxDate", {
  92. set: /**
  93. * @param {?} value
  94. * @return {?}
  95. */
  96. function (value) {
  97. this._effects.setMaxDate(value);
  98. },
  99. enumerable: true,
  100. configurable: true
  101. });
  102. Object.defineProperty(BsDatepickerAbstractComponent.prototype, "daysDisabled", {
  103. set: /**
  104. * @param {?} value
  105. * @return {?}
  106. */
  107. function (value) {
  108. this._effects.setDaysDisabled(value);
  109. },
  110. enumerable: true,
  111. configurable: true
  112. });
  113. Object.defineProperty(BsDatepickerAbstractComponent.prototype, "datesDisabled", {
  114. set: /**
  115. * @param {?} value
  116. * @return {?}
  117. */
  118. function (value) {
  119. this._effects.setDatesDisabled(value);
  120. },
  121. enumerable: true,
  122. configurable: true
  123. });
  124. Object.defineProperty(BsDatepickerAbstractComponent.prototype, "isDisabled", {
  125. set: /**
  126. * @param {?} value
  127. * @return {?}
  128. */
  129. function (value) {
  130. this._effects.setDisabled(value);
  131. },
  132. enumerable: true,
  133. configurable: true
  134. });
  135. Object.defineProperty(BsDatepickerAbstractComponent.prototype, "dateCustomClasses", {
  136. set: /**
  137. * @param {?} value
  138. * @return {?}
  139. */
  140. function (value) {
  141. this._effects.setDateCustomClasses(value);
  142. },
  143. enumerable: true,
  144. configurable: true
  145. });
  146. /**
  147. * @param {?} event
  148. * @return {?}
  149. */
  150. BsDatepickerAbstractComponent.prototype.setViewMode = /**
  151. * @param {?} event
  152. * @return {?}
  153. */
  154. function (event) { };
  155. /**
  156. * @param {?} event
  157. * @return {?}
  158. */
  159. BsDatepickerAbstractComponent.prototype.navigateTo = /**
  160. * @param {?} event
  161. * @return {?}
  162. */
  163. function (event) { };
  164. /**
  165. * @param {?} event
  166. * @return {?}
  167. */
  168. BsDatepickerAbstractComponent.prototype.dayHoverHandler = /**
  169. * @param {?} event
  170. * @return {?}
  171. */
  172. function (event) { };
  173. /**
  174. * @param {?} event
  175. * @return {?}
  176. */
  177. BsDatepickerAbstractComponent.prototype.weekHoverHandler = /**
  178. * @param {?} event
  179. * @return {?}
  180. */
  181. function (event) { };
  182. /**
  183. * @param {?} event
  184. * @return {?}
  185. */
  186. BsDatepickerAbstractComponent.prototype.monthHoverHandler = /**
  187. * @param {?} event
  188. * @return {?}
  189. */
  190. function (event) { };
  191. /**
  192. * @param {?} event
  193. * @return {?}
  194. */
  195. BsDatepickerAbstractComponent.prototype.yearHoverHandler = /**
  196. * @param {?} event
  197. * @return {?}
  198. */
  199. function (event) { };
  200. /**
  201. * @param {?} day
  202. * @return {?}
  203. */
  204. BsDatepickerAbstractComponent.prototype.daySelectHandler = /**
  205. * @param {?} day
  206. * @return {?}
  207. */
  208. function (day) { };
  209. /**
  210. * @param {?} event
  211. * @return {?}
  212. */
  213. BsDatepickerAbstractComponent.prototype.monthSelectHandler = /**
  214. * @param {?} event
  215. * @return {?}
  216. */
  217. function (event) { };
  218. /**
  219. * @param {?} event
  220. * @return {?}
  221. */
  222. BsDatepickerAbstractComponent.prototype.yearSelectHandler = /**
  223. * @param {?} event
  224. * @return {?}
  225. */
  226. function (event) { };
  227. /* tslint:disable-next-line: no-any */
  228. /* tslint:disable-next-line: no-any */
  229. /**
  230. * @param {?} event
  231. * @return {?}
  232. */
  233. BsDatepickerAbstractComponent.prototype._stopPropagation = /* tslint:disable-next-line: no-any */
  234. /**
  235. * @param {?} event
  236. * @return {?}
  237. */
  238. function (event) {
  239. event.stopPropagation();
  240. };
  241. return BsDatepickerAbstractComponent;
  242. }());
  243. /**
  244. * @fileoverview added by tsickle
  245. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  246. */
  247. var BsDatepickerActions = /** @class */ (function () {
  248. function BsDatepickerActions() {
  249. }
  250. /**
  251. * @return {?}
  252. */
  253. BsDatepickerActions.prototype.calculate = /**
  254. * @return {?}
  255. */
  256. function () {
  257. return { type: BsDatepickerActions.CALCULATE };
  258. };
  259. /**
  260. * @return {?}
  261. */
  262. BsDatepickerActions.prototype.format = /**
  263. * @return {?}
  264. */
  265. function () {
  266. return { type: BsDatepickerActions.FORMAT };
  267. };
  268. /**
  269. * @return {?}
  270. */
  271. BsDatepickerActions.prototype.flag = /**
  272. * @return {?}
  273. */
  274. function () {
  275. return { type: BsDatepickerActions.FLAG };
  276. };
  277. /**
  278. * @param {?} date
  279. * @return {?}
  280. */
  281. BsDatepickerActions.prototype.select = /**
  282. * @param {?} date
  283. * @return {?}
  284. */
  285. function (date) {
  286. return {
  287. type: BsDatepickerActions.SELECT,
  288. payload: date
  289. };
  290. };
  291. /**
  292. * @param {?} event
  293. * @return {?}
  294. */
  295. BsDatepickerActions.prototype.changeViewMode = /**
  296. * @param {?} event
  297. * @return {?}
  298. */
  299. function (event) {
  300. return {
  301. type: BsDatepickerActions.CHANGE_VIEWMODE,
  302. payload: event
  303. };
  304. };
  305. /**
  306. * @param {?} event
  307. * @return {?}
  308. */
  309. BsDatepickerActions.prototype.navigateTo = /**
  310. * @param {?} event
  311. * @return {?}
  312. */
  313. function (event) {
  314. return {
  315. type: BsDatepickerActions.NAVIGATE_TO,
  316. payload: event
  317. };
  318. };
  319. /**
  320. * @param {?} step
  321. * @return {?}
  322. */
  323. BsDatepickerActions.prototype.navigateStep = /**
  324. * @param {?} step
  325. * @return {?}
  326. */
  327. function (step) {
  328. return {
  329. type: BsDatepickerActions.NAVIGATE_OFFSET,
  330. payload: step
  331. };
  332. };
  333. /**
  334. * @param {?} options
  335. * @return {?}
  336. */
  337. BsDatepickerActions.prototype.setOptions = /**
  338. * @param {?} options
  339. * @return {?}
  340. */
  341. function (options) {
  342. return {
  343. type: BsDatepickerActions.SET_OPTIONS,
  344. payload: options
  345. };
  346. };
  347. // date range picker
  348. // date range picker
  349. /**
  350. * @param {?} value
  351. * @return {?}
  352. */
  353. BsDatepickerActions.prototype.selectRange =
  354. // date range picker
  355. /**
  356. * @param {?} value
  357. * @return {?}
  358. */
  359. function (value) {
  360. return {
  361. type: BsDatepickerActions.SELECT_RANGE,
  362. payload: value
  363. };
  364. };
  365. /**
  366. * @param {?} event
  367. * @return {?}
  368. */
  369. BsDatepickerActions.prototype.hoverDay = /**
  370. * @param {?} event
  371. * @return {?}
  372. */
  373. function (event) {
  374. return {
  375. type: BsDatepickerActions.HOVER,
  376. payload: event.isHovered ? event.cell.date : null
  377. };
  378. };
  379. /**
  380. * @param {?} date
  381. * @return {?}
  382. */
  383. BsDatepickerActions.prototype.minDate = /**
  384. * @param {?} date
  385. * @return {?}
  386. */
  387. function (date) {
  388. return {
  389. type: BsDatepickerActions.SET_MIN_DATE,
  390. payload: date
  391. };
  392. };
  393. /**
  394. * @param {?} date
  395. * @return {?}
  396. */
  397. BsDatepickerActions.prototype.maxDate = /**
  398. * @param {?} date
  399. * @return {?}
  400. */
  401. function (date) {
  402. return {
  403. type: BsDatepickerActions.SET_MAX_DATE,
  404. payload: date
  405. };
  406. };
  407. /**
  408. * @param {?} days
  409. * @return {?}
  410. */
  411. BsDatepickerActions.prototype.daysDisabled = /**
  412. * @param {?} days
  413. * @return {?}
  414. */
  415. function (days) {
  416. return {
  417. type: BsDatepickerActions.SET_DAYSDISABLED,
  418. payload: days
  419. };
  420. };
  421. /**
  422. * @param {?} dates
  423. * @return {?}
  424. */
  425. BsDatepickerActions.prototype.datesDisabled = /**
  426. * @param {?} dates
  427. * @return {?}
  428. */
  429. function (dates) {
  430. return {
  431. type: BsDatepickerActions.SET_DATESDISABLED,
  432. payload: dates
  433. };
  434. };
  435. /**
  436. * @param {?} value
  437. * @return {?}
  438. */
  439. BsDatepickerActions.prototype.isDisabled = /**
  440. * @param {?} value
  441. * @return {?}
  442. */
  443. function (value) {
  444. return {
  445. type: BsDatepickerActions.SET_IS_DISABLED,
  446. payload: value
  447. };
  448. };
  449. /**
  450. * @param {?} value
  451. * @return {?}
  452. */
  453. BsDatepickerActions.prototype.setDateCustomClasses = /**
  454. * @param {?} value
  455. * @return {?}
  456. */
  457. function (value) {
  458. return {
  459. type: BsDatepickerActions.SET_DATE_CUSTOM_CLASSES,
  460. payload: value
  461. };
  462. };
  463. /**
  464. * @param {?} locale
  465. * @return {?}
  466. */
  467. BsDatepickerActions.prototype.setLocale = /**
  468. * @param {?} locale
  469. * @return {?}
  470. */
  471. function (locale) {
  472. return {
  473. type: BsDatepickerActions.SET_LOCALE,
  474. payload: locale
  475. };
  476. };
  477. BsDatepickerActions.CALCULATE = '[datepicker] calculate dates matrix';
  478. BsDatepickerActions.FORMAT = '[datepicker] format datepicker values';
  479. BsDatepickerActions.FLAG = '[datepicker] set flags';
  480. BsDatepickerActions.SELECT = '[datepicker] select date';
  481. BsDatepickerActions.NAVIGATE_OFFSET = '[datepicker] shift view date';
  482. BsDatepickerActions.NAVIGATE_TO = '[datepicker] change view date';
  483. BsDatepickerActions.SET_OPTIONS = '[datepicker] update render options';
  484. BsDatepickerActions.HOVER = '[datepicker] hover date';
  485. BsDatepickerActions.CHANGE_VIEWMODE = '[datepicker] switch view mode';
  486. BsDatepickerActions.SET_MIN_DATE = '[datepicker] set min date';
  487. BsDatepickerActions.SET_MAX_DATE = '[datepicker] set max date';
  488. BsDatepickerActions.SET_DAYSDISABLED = '[datepicker] set days disabled';
  489. BsDatepickerActions.SET_DATESDISABLED = '[datepicker] set dates disabled';
  490. BsDatepickerActions.SET_IS_DISABLED = '[datepicker] set is disabled';
  491. BsDatepickerActions.SET_DATE_CUSTOM_CLASSES = '[datepicker] set date custom classes';
  492. BsDatepickerActions.SET_LOCALE = '[datepicker] set datepicker locale';
  493. BsDatepickerActions.SELECT_RANGE = '[daterangepicker] select dates range';
  494. BsDatepickerActions.decorators = [
  495. { type: Injectable }
  496. ];
  497. return BsDatepickerActions;
  498. }());
  499. /**
  500. * @fileoverview added by tsickle
  501. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  502. */
  503. var BsLocaleService = /** @class */ (function () {
  504. function BsLocaleService() {
  505. this._defaultLocale = 'en';
  506. this._locale = new BehaviorSubject(this._defaultLocale);
  507. this._localeChange = this._locale.asObservable();
  508. }
  509. Object.defineProperty(BsLocaleService.prototype, "locale", {
  510. get: /**
  511. * @return {?}
  512. */
  513. function () {
  514. return this._locale;
  515. },
  516. enumerable: true,
  517. configurable: true
  518. });
  519. Object.defineProperty(BsLocaleService.prototype, "localeChange", {
  520. get: /**
  521. * @return {?}
  522. */
  523. function () {
  524. return this._localeChange;
  525. },
  526. enumerable: true,
  527. configurable: true
  528. });
  529. Object.defineProperty(BsLocaleService.prototype, "currentLocale", {
  530. get: /**
  531. * @return {?}
  532. */
  533. function () {
  534. return this._locale.getValue();
  535. },
  536. enumerable: true,
  537. configurable: true
  538. });
  539. /**
  540. * @param {?} locale
  541. * @return {?}
  542. */
  543. BsLocaleService.prototype.use = /**
  544. * @param {?} locale
  545. * @return {?}
  546. */
  547. function (locale) {
  548. if (locale === this.currentLocale) {
  549. return;
  550. }
  551. this._locale.next(locale);
  552. };
  553. BsLocaleService.decorators = [
  554. { type: Injectable }
  555. ];
  556. return BsLocaleService;
  557. }());
  558. /**
  559. * @fileoverview added by tsickle
  560. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  561. */
  562. var BsDatepickerEffects = /** @class */ (function () {
  563. function BsDatepickerEffects(_actions, _localeService) {
  564. this._actions = _actions;
  565. this._localeService = _localeService;
  566. this._subs = [];
  567. }
  568. /**
  569. * @param {?} _bsDatepickerStore
  570. * @return {?}
  571. */
  572. BsDatepickerEffects.prototype.init = /**
  573. * @param {?} _bsDatepickerStore
  574. * @return {?}
  575. */
  576. function (_bsDatepickerStore) {
  577. this._store = _bsDatepickerStore;
  578. return this;
  579. };
  580. /** setters */
  581. /**
  582. * setters
  583. * @param {?} value
  584. * @return {?}
  585. */
  586. BsDatepickerEffects.prototype.setValue = /**
  587. * setters
  588. * @param {?} value
  589. * @return {?}
  590. */
  591. function (value) {
  592. this._store.dispatch(this._actions.select(value));
  593. };
  594. /**
  595. * @param {?} value
  596. * @return {?}
  597. */
  598. BsDatepickerEffects.prototype.setRangeValue = /**
  599. * @param {?} value
  600. * @return {?}
  601. */
  602. function (value) {
  603. this._store.dispatch(this._actions.selectRange(value));
  604. };
  605. /**
  606. * @param {?} value
  607. * @return {?}
  608. */
  609. BsDatepickerEffects.prototype.setMinDate = /**
  610. * @param {?} value
  611. * @return {?}
  612. */
  613. function (value) {
  614. this._store.dispatch(this._actions.minDate(value));
  615. return this;
  616. };
  617. /**
  618. * @param {?} value
  619. * @return {?}
  620. */
  621. BsDatepickerEffects.prototype.setMaxDate = /**
  622. * @param {?} value
  623. * @return {?}
  624. */
  625. function (value) {
  626. this._store.dispatch(this._actions.maxDate(value));
  627. return this;
  628. };
  629. /**
  630. * @template THIS
  631. * @this {THIS}
  632. * @param {?} value
  633. * @return {THIS}
  634. */
  635. BsDatepickerEffects.prototype.setDaysDisabled = /**
  636. * @template THIS
  637. * @this {THIS}
  638. * @param {?} value
  639. * @return {THIS}
  640. */
  641. function (value) {
  642. (/** @type {?} */ (this))._store.dispatch((/** @type {?} */ (this))._actions.daysDisabled(value));
  643. return (/** @type {?} */ (this));
  644. };
  645. /**
  646. * @template THIS
  647. * @this {THIS}
  648. * @param {?} value
  649. * @return {THIS}
  650. */
  651. BsDatepickerEffects.prototype.setDatesDisabled = /**
  652. * @template THIS
  653. * @this {THIS}
  654. * @param {?} value
  655. * @return {THIS}
  656. */
  657. function (value) {
  658. (/** @type {?} */ (this))._store.dispatch((/** @type {?} */ (this))._actions.datesDisabled(value));
  659. return (/** @type {?} */ (this));
  660. };
  661. /**
  662. * @param {?} value
  663. * @return {?}
  664. */
  665. BsDatepickerEffects.prototype.setDisabled = /**
  666. * @param {?} value
  667. * @return {?}
  668. */
  669. function (value) {
  670. this._store.dispatch(this._actions.isDisabled(value));
  671. return this;
  672. };
  673. /**
  674. * @param {?} value
  675. * @return {?}
  676. */
  677. BsDatepickerEffects.prototype.setDateCustomClasses = /**
  678. * @param {?} value
  679. * @return {?}
  680. */
  681. function (value) {
  682. this._store.dispatch(this._actions.setDateCustomClasses(value));
  683. return this;
  684. };
  685. /* Set rendering options */
  686. /* Set rendering options */
  687. /**
  688. * @param {?} _config
  689. * @return {?}
  690. */
  691. BsDatepickerEffects.prototype.setOptions = /* Set rendering options */
  692. /**
  693. * @param {?} _config
  694. * @return {?}
  695. */
  696. function (_config) {
  697. /** @type {?} */
  698. var _options = Object.assign({ locale: this._localeService.currentLocale }, _config);
  699. this._store.dispatch(this._actions.setOptions(_options));
  700. return this;
  701. };
  702. /** view to mode bindings */
  703. /**
  704. * view to mode bindings
  705. * @param {?} container
  706. * @return {?}
  707. */
  708. BsDatepickerEffects.prototype.setBindings = /**
  709. * view to mode bindings
  710. * @param {?} container
  711. * @return {?}
  712. */
  713. function (container) {
  714. container.daysCalendar = this._store
  715. .select((/**
  716. * @param {?} state
  717. * @return {?}
  718. */
  719. function (state) { return state.flaggedMonths; }))
  720. .pipe(filter((/**
  721. * @param {?} months
  722. * @return {?}
  723. */
  724. function (months) { return !!months; })));
  725. // month calendar
  726. container.monthsCalendar = this._store
  727. .select((/**
  728. * @param {?} state
  729. * @return {?}
  730. */
  731. function (state) { return state.flaggedMonthsCalendar; }))
  732. .pipe(filter((/**
  733. * @param {?} months
  734. * @return {?}
  735. */
  736. function (months) { return !!months; })));
  737. // year calendar
  738. container.yearsCalendar = this._store
  739. .select((/**
  740. * @param {?} state
  741. * @return {?}
  742. */
  743. function (state) { return state.yearsCalendarFlagged; }))
  744. .pipe(filter((/**
  745. * @param {?} years
  746. * @return {?}
  747. */
  748. function (years) { return !!years; })));
  749. container.viewMode = this._store.select((/**
  750. * @param {?} state
  751. * @return {?}
  752. */
  753. function (state) { return state.view.mode; }));
  754. container.options = this._store
  755. .select((/**
  756. * @param {?} state
  757. * @return {?}
  758. */
  759. function (state) { return state.showWeekNumbers; }))
  760. .pipe(map((/**
  761. * @param {?} showWeekNumbers
  762. * @return {?}
  763. */
  764. function (showWeekNumbers) { return ({ showWeekNumbers: showWeekNumbers }); })));
  765. return this;
  766. };
  767. /** event handlers */
  768. /**
  769. * event handlers
  770. * @param {?} container
  771. * @return {?}
  772. */
  773. BsDatepickerEffects.prototype.setEventHandlers = /**
  774. * event handlers
  775. * @param {?} container
  776. * @return {?}
  777. */
  778. function (container) {
  779. var _this = this;
  780. container.setViewMode = (/**
  781. * @param {?} event
  782. * @return {?}
  783. */
  784. function (event) {
  785. _this._store.dispatch(_this._actions.changeViewMode(event));
  786. });
  787. container.navigateTo = (/**
  788. * @param {?} event
  789. * @return {?}
  790. */
  791. function (event) {
  792. _this._store.dispatch(_this._actions.navigateStep(event.step));
  793. });
  794. container.dayHoverHandler = (/**
  795. * @param {?} event
  796. * @return {?}
  797. */
  798. function (event) {
  799. /** @type {?} */
  800. var _cell = (/** @type {?} */ (event.cell));
  801. if (_cell.isOtherMonth || _cell.isDisabled) {
  802. return;
  803. }
  804. _this._store.dispatch(_this._actions.hoverDay(event));
  805. _cell.isHovered = event.isHovered;
  806. });
  807. container.monthHoverHandler = (/**
  808. * @param {?} event
  809. * @return {?}
  810. */
  811. function (event) {
  812. event.cell.isHovered = event.isHovered;
  813. });
  814. container.yearHoverHandler = (/**
  815. * @param {?} event
  816. * @return {?}
  817. */
  818. function (event) {
  819. event.cell.isHovered = event.isHovered;
  820. });
  821. container.monthSelectHandler = (/**
  822. * @param {?} event
  823. * @return {?}
  824. */
  825. function (event) {
  826. if (event.isDisabled) {
  827. return;
  828. }
  829. _this._store.dispatch(_this._actions.navigateTo({
  830. unit: {
  831. month: getMonth(event.date),
  832. year: getFullYear(event.date)
  833. },
  834. viewMode: 'day'
  835. }));
  836. });
  837. container.yearSelectHandler = (/**
  838. * @param {?} event
  839. * @return {?}
  840. */
  841. function (event) {
  842. if (event.isDisabled) {
  843. return;
  844. }
  845. _this._store.dispatch(_this._actions.navigateTo({
  846. unit: {
  847. year: getFullYear(event.date)
  848. },
  849. viewMode: 'month'
  850. }));
  851. });
  852. return this;
  853. };
  854. /**
  855. * @return {?}
  856. */
  857. BsDatepickerEffects.prototype.registerDatepickerSideEffects = /**
  858. * @return {?}
  859. */
  860. function () {
  861. var _this = this;
  862. this._subs.push(this._store.select((/**
  863. * @param {?} state
  864. * @return {?}
  865. */
  866. function (state) { return state.view; })).subscribe((/**
  867. * @param {?} view
  868. * @return {?}
  869. */
  870. function (view) {
  871. _this._store.dispatch(_this._actions.calculate());
  872. })));
  873. // format calendar values on month model change
  874. this._subs.push(this._store
  875. .select((/**
  876. * @param {?} state
  877. * @return {?}
  878. */
  879. function (state) { return state.monthsModel; }))
  880. .pipe(filter((/**
  881. * @param {?} monthModel
  882. * @return {?}
  883. */
  884. function (monthModel) { return !!monthModel; })))
  885. .subscribe((/**
  886. * @param {?} month
  887. * @return {?}
  888. */
  889. function (month) { return _this._store.dispatch(_this._actions.format()); })));
  890. // flag day values
  891. this._subs.push(this._store
  892. .select((/**
  893. * @param {?} state
  894. * @return {?}
  895. */
  896. function (state) { return state.formattedMonths; }))
  897. .pipe(filter((/**
  898. * @param {?} month
  899. * @return {?}
  900. */
  901. function (month) { return !!month; })))
  902. .subscribe((/**
  903. * @param {?} month
  904. * @return {?}
  905. */
  906. function (month) { return _this._store.dispatch(_this._actions.flag()); })));
  907. // flag day values
  908. this._subs.push(this._store
  909. .select((/**
  910. * @param {?} state
  911. * @return {?}
  912. */
  913. function (state) { return state.selectedDate; }))
  914. .pipe(filter((/**
  915. * @param {?} selectedDate
  916. * @return {?}
  917. */
  918. function (selectedDate) { return !!selectedDate; })))
  919. .subscribe((/**
  920. * @param {?} selectedDate
  921. * @return {?}
  922. */
  923. function (selectedDate) { return _this._store.dispatch(_this._actions.flag()); })));
  924. // flag for date range picker
  925. this._subs.push(this._store
  926. .select((/**
  927. * @param {?} state
  928. * @return {?}
  929. */
  930. function (state) { return state.selectedRange; }))
  931. .pipe(filter((/**
  932. * @param {?} selectedRange
  933. * @return {?}
  934. */
  935. function (selectedRange) { return !!selectedRange; })))
  936. .subscribe((/**
  937. * @param {?} selectedRange
  938. * @return {?}
  939. */
  940. function (selectedRange) { return _this._store.dispatch(_this._actions.flag()); })));
  941. // monthsCalendar
  942. this._subs.push(this._store
  943. .select((/**
  944. * @param {?} state
  945. * @return {?}
  946. */
  947. function (state) { return state.monthsCalendar; }))
  948. .subscribe((/**
  949. * @return {?}
  950. */
  951. function () { return _this._store.dispatch(_this._actions.flag()); })));
  952. // years calendar
  953. this._subs.push(this._store
  954. .select((/**
  955. * @param {?} state
  956. * @return {?}
  957. */
  958. function (state) { return state.yearsCalendarModel; }))
  959. .pipe(filter((/**
  960. * @param {?} state
  961. * @return {?}
  962. */
  963. function (state) { return !!state; })))
  964. .subscribe((/**
  965. * @return {?}
  966. */
  967. function () { return _this._store.dispatch(_this._actions.flag()); })));
  968. // on hover
  969. this._subs.push(this._store
  970. .select((/**
  971. * @param {?} state
  972. * @return {?}
  973. */
  974. function (state) { return state.hoveredDate; }))
  975. .pipe(filter((/**
  976. * @param {?} hoveredDate
  977. * @return {?}
  978. */
  979. function (hoveredDate) { return !!hoveredDate; })))
  980. .subscribe((/**
  981. * @param {?} hoveredDate
  982. * @return {?}
  983. */
  984. function (hoveredDate) { return _this._store.dispatch(_this._actions.flag()); })));
  985. // date custom classes
  986. this._subs.push(this._store
  987. .select((/**
  988. * @param {?} state
  989. * @return {?}
  990. */
  991. function (state) { return state.dateCustomClasses; }))
  992. .pipe(filter((/**
  993. * @param {?} dateCustomClasses
  994. * @return {?}
  995. */
  996. function (dateCustomClasses) { return !!dateCustomClasses; })))
  997. .subscribe((/**
  998. * @param {?} dateCustomClasses
  999. * @return {?}
  1000. */
  1001. function (dateCustomClasses) { return _this._store.dispatch(_this._actions.flag()); })));
  1002. // on locale change
  1003. this._subs.push(this._localeService.localeChange
  1004. .subscribe((/**
  1005. * @param {?} locale
  1006. * @return {?}
  1007. */
  1008. function (locale) { return _this._store.dispatch(_this._actions.setLocale(locale)); })));
  1009. return this;
  1010. };
  1011. /**
  1012. * @return {?}
  1013. */
  1014. BsDatepickerEffects.prototype.destroy = /**
  1015. * @return {?}
  1016. */
  1017. function () {
  1018. var e_1, _a;
  1019. try {
  1020. for (var _b = __values(this._subs), _c = _b.next(); !_c.done; _c = _b.next()) {
  1021. var sub = _c.value;
  1022. sub.unsubscribe();
  1023. }
  1024. }
  1025. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  1026. finally {
  1027. try {
  1028. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  1029. }
  1030. finally { if (e_1) throw e_1.error; }
  1031. }
  1032. };
  1033. BsDatepickerEffects.decorators = [
  1034. { type: Injectable }
  1035. ];
  1036. /** @nocollapse */
  1037. BsDatepickerEffects.ctorParameters = function () { return [
  1038. { type: BsDatepickerActions },
  1039. { type: BsLocaleService }
  1040. ]; };
  1041. return BsDatepickerEffects;
  1042. }());
  1043. /**
  1044. * @fileoverview added by tsickle
  1045. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1046. */
  1047. /** @type {?} */
  1048. var defaultMonthOptions = {
  1049. width: 7,
  1050. height: 6
  1051. };
  1052. /**
  1053. * @fileoverview added by tsickle
  1054. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1055. */
  1056. /** @type {?} */
  1057. var _initialView = { date: new Date(), mode: 'day' };
  1058. /** @type {?} */
  1059. var initialDatepickerState = Object.assign(new BsDatepickerConfig(), {
  1060. locale: 'en',
  1061. view: _initialView,
  1062. selectedRange: [],
  1063. monthViewOptions: defaultMonthOptions
  1064. });
  1065. /**
  1066. * @fileoverview added by tsickle
  1067. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1068. */
  1069. /**
  1070. * @param {?} date
  1071. * @param {?} options
  1072. * @return {?}
  1073. */
  1074. function getStartingDayOfCalendar(date, options) {
  1075. if (isFirstDayOfWeek(date, options.firstDayOfWeek)) {
  1076. return date;
  1077. }
  1078. /** @type {?} */
  1079. var weekDay = getDay(date);
  1080. /** @type {?} */
  1081. var offset = calculateDateOffset(weekDay, options.firstDayOfWeek);
  1082. return shiftDate(date, { day: -offset });
  1083. }
  1084. /**
  1085. * @param {?} weekday
  1086. * @param {?} startingDayOffset
  1087. * @return {?}
  1088. */
  1089. function calculateDateOffset(weekday, startingDayOffset) {
  1090. if (startingDayOffset === 0) {
  1091. return weekday;
  1092. }
  1093. /** @type {?} */
  1094. var offset = weekday - startingDayOffset % 7;
  1095. return offset < 0 ? offset + 7 : offset;
  1096. }
  1097. /**
  1098. * @param {?} date
  1099. * @param {?} min
  1100. * @param {?} max
  1101. * @return {?}
  1102. */
  1103. function isMonthDisabled(date, min, max) {
  1104. /** @type {?} */
  1105. var minBound = min && isBefore(endOf(date, 'month'), min, 'day');
  1106. /** @type {?} */
  1107. var maxBound = max && isAfter(startOf(date, 'month'), max, 'day');
  1108. return minBound || maxBound;
  1109. }
  1110. /**
  1111. * @param {?} date
  1112. * @param {?} min
  1113. * @param {?} max
  1114. * @return {?}
  1115. */
  1116. function isYearDisabled(date, min, max) {
  1117. /** @type {?} */
  1118. var minBound = min && isBefore(endOf(date, 'year'), min, 'day');
  1119. /** @type {?} */
  1120. var maxBound = max && isAfter(startOf(date, 'year'), max, 'day');
  1121. return minBound || maxBound;
  1122. }
  1123. /**
  1124. * @param {?} date
  1125. * @param {?} datesDisabled
  1126. * @return {?}
  1127. */
  1128. function isDisabledDate(date, datesDisabled) {
  1129. if (datesDisabled === undefined || !datesDisabled || !datesDisabled.length) {
  1130. return false;
  1131. }
  1132. return datesDisabled.some((/**
  1133. * @param {?} dateDisabled
  1134. * @return {?}
  1135. */
  1136. function (dateDisabled) { return isSame(date, dateDisabled, 'date'); }));
  1137. }
  1138. /**
  1139. * @param {?} state
  1140. * @param {?=} calendarIndex
  1141. * @return {?}
  1142. */
  1143. function getYearsCalendarInitialDate(state, calendarIndex) {
  1144. if (calendarIndex === void 0) { calendarIndex = 0; }
  1145. /** @type {?} */
  1146. var model = state && state.yearsCalendarModel && state.yearsCalendarModel[calendarIndex];
  1147. return model && model.years && model.years[0] && model.years[0][0] && model.years[0][0].date;
  1148. }
  1149. /**
  1150. * @fileoverview added by tsickle
  1151. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1152. */
  1153. /**
  1154. * @template T
  1155. * @param {?} options
  1156. * @param {?} fn
  1157. * @return {?}
  1158. */
  1159. function createMatrix(options, fn) {
  1160. /** @type {?} */
  1161. var prevValue = options.initialDate;
  1162. /** @type {?} */
  1163. var matrix = new Array(options.height);
  1164. for (var i = 0; i < options.height; i++) {
  1165. matrix[i] = new Array(options.width);
  1166. for (var j = 0; j < options.width; j++) {
  1167. matrix[i][j] = fn(prevValue);
  1168. prevValue = shiftDate(prevValue, options.shift);
  1169. }
  1170. }
  1171. return matrix;
  1172. }
  1173. /**
  1174. * @fileoverview added by tsickle
  1175. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1176. */
  1177. /**
  1178. * @param {?} startingDate
  1179. * @param {?} options
  1180. * @return {?}
  1181. */
  1182. function calcDaysCalendar(startingDate, options) {
  1183. /** @type {?} */
  1184. var firstDay = getFirstDayOfMonth(startingDate);
  1185. /** @type {?} */
  1186. var initialDate = getStartingDayOfCalendar(firstDay, options);
  1187. /** @type {?} */
  1188. var matrixOptions = {
  1189. width: options.width,
  1190. height: options.height,
  1191. initialDate: initialDate,
  1192. shift: { day: 1 }
  1193. };
  1194. /** @type {?} */
  1195. var daysMatrix = createMatrix(matrixOptions, (/**
  1196. * @param {?} date
  1197. * @return {?}
  1198. */
  1199. function (date) { return date; }));
  1200. return {
  1201. daysMatrix: daysMatrix,
  1202. month: firstDay
  1203. };
  1204. }
  1205. /**
  1206. * @fileoverview added by tsickle
  1207. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1208. */
  1209. /**
  1210. * @param {?} daysCalendar
  1211. * @param {?} formatOptions
  1212. * @param {?} monthIndex
  1213. * @return {?}
  1214. */
  1215. function formatDaysCalendar(daysCalendar, formatOptions, monthIndex) {
  1216. return {
  1217. month: daysCalendar.month,
  1218. monthTitle: formatDate(daysCalendar.month, formatOptions.monthTitle, formatOptions.locale),
  1219. yearTitle: formatDate(daysCalendar.month, formatOptions.yearTitle, formatOptions.locale),
  1220. weekNumbers: getWeekNumbers(daysCalendar.daysMatrix, formatOptions.weekNumbers, formatOptions.locale),
  1221. weekdays: getShiftedWeekdays(formatOptions.locale),
  1222. weeks: daysCalendar.daysMatrix.map((/**
  1223. * @param {?} week
  1224. * @param {?} weekIndex
  1225. * @return {?}
  1226. */
  1227. function (week, weekIndex) { return ({
  1228. days: week.map((/**
  1229. * @param {?} date
  1230. * @param {?} dayIndex
  1231. * @return {?}
  1232. */
  1233. function (date, dayIndex) { return ({
  1234. date: date,
  1235. label: formatDate(date, formatOptions.dayLabel, formatOptions.locale),
  1236. monthIndex: monthIndex,
  1237. weekIndex: weekIndex,
  1238. dayIndex: dayIndex
  1239. }); }))
  1240. }); }))
  1241. };
  1242. }
  1243. /**
  1244. * @param {?} daysMatrix
  1245. * @param {?} format
  1246. * @param {?} locale
  1247. * @return {?}
  1248. */
  1249. function getWeekNumbers(daysMatrix, format, locale) {
  1250. return daysMatrix.map((/**
  1251. * @param {?} days
  1252. * @return {?}
  1253. */
  1254. function (days) { return (days[0] ? formatDate(days[0], format, locale) : ''); }));
  1255. }
  1256. /**
  1257. * @param {?} locale
  1258. * @return {?}
  1259. */
  1260. function getShiftedWeekdays(locale) {
  1261. /** @type {?} */
  1262. var _locale = getLocale(locale);
  1263. /** @type {?} */
  1264. var weekdays = (/** @type {?} */ (_locale.weekdaysShort()));
  1265. /** @type {?} */
  1266. var firstDayOfWeek = _locale.firstDayOfWeek();
  1267. return __spread(weekdays.slice(firstDayOfWeek), weekdays.slice(0, firstDayOfWeek));
  1268. }
  1269. /**
  1270. * @fileoverview added by tsickle
  1271. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1272. */
  1273. /**
  1274. * @param {?} formattedMonth
  1275. * @param {?} options
  1276. * @return {?}
  1277. */
  1278. function flagDaysCalendar(formattedMonth, options) {
  1279. formattedMonth.weeks.forEach((/**
  1280. * @param {?} week
  1281. * @return {?}
  1282. */
  1283. function (week) {
  1284. /* tslint:disable-next-line: cyclomatic-complexity */
  1285. week.days.forEach((/**
  1286. * @param {?} day
  1287. * @param {?} dayIndex
  1288. * @return {?}
  1289. */
  1290. function (day, dayIndex) {
  1291. // datepicker
  1292. /** @type {?} */
  1293. var isOtherMonth = !isSameMonth(day.date, formattedMonth.month);
  1294. /** @type {?} */
  1295. var isHovered = !isOtherMonth && isSameDay(day.date, options.hoveredDate);
  1296. // date range picker
  1297. /** @type {?} */
  1298. var isSelectionStart = !isOtherMonth &&
  1299. options.selectedRange &&
  1300. isSameDay(day.date, options.selectedRange[0]);
  1301. /** @type {?} */
  1302. var isSelectionEnd = !isOtherMonth &&
  1303. options.selectedRange &&
  1304. isSameDay(day.date, options.selectedRange[1]);
  1305. /** @type {?} */
  1306. var isSelected = (!isOtherMonth && isSameDay(day.date, options.selectedDate)) ||
  1307. isSelectionStart ||
  1308. isSelectionEnd;
  1309. /** @type {?} */
  1310. var isInRange = !isOtherMonth &&
  1311. options.selectedRange &&
  1312. isDateInRange(day.date, options.selectedRange, options.hoveredDate);
  1313. /** @type {?} */
  1314. var isDisabled = options.isDisabled ||
  1315. isBefore(day.date, options.minDate, 'day') ||
  1316. isAfter(day.date, options.maxDate, 'day') ||
  1317. isDisabledDay(day.date, options.daysDisabled) ||
  1318. isDisabledDate(day.date, options.datesDisabled);
  1319. /** @type {?} */
  1320. var currentDate = new Date();
  1321. /** @type {?} */
  1322. var isToday = !isOtherMonth && isSameDay(day.date, currentDate);
  1323. /** @type {?} */
  1324. var customClasses = options.dateCustomClasses && options.dateCustomClasses
  1325. .map((/**
  1326. * @param {?} dcc
  1327. * @return {?}
  1328. */
  1329. function (dcc) { return isSameDay(day.date, dcc.date) ? dcc.classes : []; }))
  1330. .reduce((/**
  1331. * @param {?} previousValue
  1332. * @param {?} currentValue
  1333. * @return {?}
  1334. */
  1335. function (previousValue, currentValue) { return previousValue.concat(currentValue); }), [])
  1336. .join(' ')
  1337. || '';
  1338. // decide update or not
  1339. /** @type {?} */
  1340. var newDay = Object.assign({}, day, {
  1341. isOtherMonth: isOtherMonth,
  1342. isHovered: isHovered,
  1343. isSelected: isSelected,
  1344. isSelectionStart: isSelectionStart,
  1345. isSelectionEnd: isSelectionEnd,
  1346. isInRange: isInRange,
  1347. isDisabled: isDisabled,
  1348. isToday: isToday,
  1349. customClasses: customClasses
  1350. });
  1351. if (day.isOtherMonth !== newDay.isOtherMonth ||
  1352. day.isHovered !== newDay.isHovered ||
  1353. day.isSelected !== newDay.isSelected ||
  1354. day.isSelectionStart !== newDay.isSelectionStart ||
  1355. day.isSelectionEnd !== newDay.isSelectionEnd ||
  1356. day.isDisabled !== newDay.isDisabled ||
  1357. day.isInRange !== newDay.isInRange ||
  1358. day.customClasses !== newDay.customClasses) {
  1359. week.days[dayIndex] = newDay;
  1360. }
  1361. }));
  1362. }));
  1363. // todo: add check for linked calendars
  1364. formattedMonth.hideLeftArrow =
  1365. options.isDisabled ||
  1366. (options.monthIndex > 0 && options.monthIndex !== options.displayMonths);
  1367. formattedMonth.hideRightArrow =
  1368. options.isDisabled ||
  1369. (options.monthIndex < options.displayMonths &&
  1370. options.monthIndex + 1 !== options.displayMonths);
  1371. formattedMonth.disableLeftArrow = isMonthDisabled(shiftDate(formattedMonth.month, { month: -1 }), options.minDate, options.maxDate);
  1372. formattedMonth.disableRightArrow = isMonthDisabled(shiftDate(formattedMonth.month, { month: 1 }), options.minDate, options.maxDate);
  1373. return formattedMonth;
  1374. }
  1375. /**
  1376. * @param {?} date
  1377. * @param {?} selectedRange
  1378. * @param {?} hoveredDate
  1379. * @return {?}
  1380. */
  1381. function isDateInRange(date, selectedRange, hoveredDate) {
  1382. if (!date || !selectedRange[0]) {
  1383. return false;
  1384. }
  1385. if (selectedRange[1]) {
  1386. return date > selectedRange[0] && date <= selectedRange[1];
  1387. }
  1388. if (hoveredDate) {
  1389. return date > selectedRange[0] && date <= hoveredDate;
  1390. }
  1391. return false;
  1392. }
  1393. /**
  1394. * @fileoverview added by tsickle
  1395. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1396. */
  1397. /**
  1398. * @param {?} mode
  1399. * @param {?=} minMode
  1400. * @return {?}
  1401. */
  1402. function canSwitchMode(mode, minMode) {
  1403. return minMode ? mode >= minMode : true;
  1404. }
  1405. /**
  1406. * @fileoverview added by tsickle
  1407. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1408. */
  1409. /** @type {?} */
  1410. var height = 4;
  1411. /** @type {?} */
  1412. var width = 3;
  1413. /** @type {?} */
  1414. var shift = { month: 1 };
  1415. /**
  1416. * @param {?} viewDate
  1417. * @param {?} formatOptions
  1418. * @return {?}
  1419. */
  1420. function formatMonthsCalendar(viewDate, formatOptions) {
  1421. /** @type {?} */
  1422. var initialDate = startOf(viewDate, 'year');
  1423. /** @type {?} */
  1424. var matrixOptions = { width: width, height: height, initialDate: initialDate, shift: shift };
  1425. /** @type {?} */
  1426. var monthMatrix = createMatrix(matrixOptions, (/**
  1427. * @param {?} date
  1428. * @return {?}
  1429. */
  1430. function (date) { return ({
  1431. date: date,
  1432. label: formatDate(date, formatOptions.monthLabel, formatOptions.locale)
  1433. }); }));
  1434. return {
  1435. months: monthMatrix,
  1436. monthTitle: '',
  1437. yearTitle: formatDate(viewDate, formatOptions.yearTitle, formatOptions.locale)
  1438. };
  1439. }
  1440. /**
  1441. * @fileoverview added by tsickle
  1442. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1443. */
  1444. /**
  1445. * @param {?} monthCalendar
  1446. * @param {?} options
  1447. * @return {?}
  1448. */
  1449. function flagMonthsCalendar(monthCalendar, options) {
  1450. monthCalendar.months.forEach((/**
  1451. * @param {?} months
  1452. * @param {?} rowIndex
  1453. * @return {?}
  1454. */
  1455. function (months, rowIndex) {
  1456. months.forEach((/**
  1457. * @param {?} month
  1458. * @param {?} monthIndex
  1459. * @return {?}
  1460. */
  1461. function (month, monthIndex) {
  1462. /** @type {?} */
  1463. var isHovered = isSameMonth(month.date, options.hoveredMonth);
  1464. /** @type {?} */
  1465. var isDisabled = options.isDisabled ||
  1466. isMonthDisabled(month.date, options.minDate, options.maxDate);
  1467. /** @type {?} */
  1468. var isSelected = isSameMonth(month.date, options.selectedDate);
  1469. /** @type {?} */
  1470. var newMonth = Object.assign(/*{},*/ month, {
  1471. isHovered: isHovered,
  1472. isDisabled: isDisabled,
  1473. isSelected: isSelected
  1474. });
  1475. if (month.isHovered !== newMonth.isHovered ||
  1476. month.isDisabled !== newMonth.isDisabled ||
  1477. month.isSelected !== newMonth.isSelected) {
  1478. monthCalendar.months[rowIndex][monthIndex] = newMonth;
  1479. }
  1480. }));
  1481. }));
  1482. // todo: add check for linked calendars
  1483. monthCalendar.hideLeftArrow =
  1484. options.monthIndex > 0 && options.monthIndex !== options.displayMonths;
  1485. monthCalendar.hideRightArrow =
  1486. options.monthIndex < options.displayMonths &&
  1487. options.monthIndex + 1 !== options.displayMonths;
  1488. monthCalendar.disableLeftArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: -1 }), options.minDate, options.maxDate);
  1489. monthCalendar.disableRightArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: 1 }), options.minDate, options.maxDate);
  1490. return monthCalendar;
  1491. }
  1492. /**
  1493. * @fileoverview added by tsickle
  1494. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1495. */
  1496. /** @type {?} */
  1497. var height$1 = 4;
  1498. /** @type {?} */
  1499. var width$1 = 4;
  1500. /** @type {?} */
  1501. var yearsPerCalendar = height$1 * width$1;
  1502. /** @type {?} */
  1503. var initialYearShift = (Math.floor(yearsPerCalendar / 2) - 1) * -1;
  1504. /** @type {?} */
  1505. var shift$1 = { year: 1 };
  1506. /**
  1507. * @param {?} viewDate
  1508. * @param {?} formatOptions
  1509. * @param {?=} previousInitialDate
  1510. * @return {?}
  1511. */
  1512. function formatYearsCalendar(viewDate, formatOptions, previousInitialDate) {
  1513. /** @type {?} */
  1514. var initialDate = calculateInitialDate(viewDate, previousInitialDate);
  1515. /** @type {?} */
  1516. var matrixOptions = { width: width$1, height: height$1, initialDate: initialDate, shift: shift$1 };
  1517. /** @type {?} */
  1518. var yearsMatrix = createMatrix(matrixOptions, (/**
  1519. * @param {?} date
  1520. * @return {?}
  1521. */
  1522. function (date) { return ({
  1523. date: date,
  1524. label: formatDate(date, formatOptions.yearLabel, formatOptions.locale)
  1525. }); }));
  1526. /** @type {?} */
  1527. var yearTitle = formatYearRangeTitle(yearsMatrix, formatOptions);
  1528. return {
  1529. years: yearsMatrix,
  1530. monthTitle: '',
  1531. yearTitle: yearTitle
  1532. };
  1533. }
  1534. /**
  1535. * @param {?} viewDate
  1536. * @param {?=} previousInitialDate
  1537. * @return {?}
  1538. */
  1539. function calculateInitialDate(viewDate, previousInitialDate) {
  1540. if (previousInitialDate
  1541. && viewDate.getFullYear() >= previousInitialDate.getFullYear()
  1542. && viewDate.getFullYear() < previousInitialDate.getFullYear() + yearsPerCalendar) {
  1543. return previousInitialDate;
  1544. }
  1545. return shiftDate(viewDate, { year: initialYearShift });
  1546. }
  1547. /**
  1548. * @param {?} yearsMatrix
  1549. * @param {?} formatOptions
  1550. * @return {?}
  1551. */
  1552. function formatYearRangeTitle(yearsMatrix, formatOptions) {
  1553. /** @type {?} */
  1554. var from = formatDate(yearsMatrix[0][0].date, formatOptions.yearTitle, formatOptions.locale);
  1555. /** @type {?} */
  1556. var to = formatDate(yearsMatrix[height$1 - 1][width$1 - 1].date, formatOptions.yearTitle, formatOptions.locale);
  1557. return from + " - " + to;
  1558. }
  1559. /**
  1560. * @fileoverview added by tsickle
  1561. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1562. */
  1563. /**
  1564. * @param {?} yearsCalendar
  1565. * @param {?} options
  1566. * @return {?}
  1567. */
  1568. function flagYearsCalendar(yearsCalendar, options) {
  1569. yearsCalendar.years.forEach((/**
  1570. * @param {?} years
  1571. * @param {?} rowIndex
  1572. * @return {?}
  1573. */
  1574. function (years, rowIndex) {
  1575. years.forEach((/**
  1576. * @param {?} year
  1577. * @param {?} yearIndex
  1578. * @return {?}
  1579. */
  1580. function (year, yearIndex) {
  1581. /** @type {?} */
  1582. var isHovered = isSameYear(year.date, options.hoveredYear);
  1583. /** @type {?} */
  1584. var isDisabled = options.isDisabled ||
  1585. isYearDisabled(year.date, options.minDate, options.maxDate);
  1586. /** @type {?} */
  1587. var isSelected = isSameYear(year.date, options.selectedDate);
  1588. /** @type {?} */
  1589. var newMonth = Object.assign(/*{},*/ year, { isHovered: isHovered, isDisabled: isDisabled, isSelected: isSelected });
  1590. if (year.isHovered !== newMonth.isHovered ||
  1591. year.isDisabled !== newMonth.isDisabled ||
  1592. year.isSelected !== newMonth.isSelected) {
  1593. yearsCalendar.years[rowIndex][yearIndex] = newMonth;
  1594. }
  1595. }));
  1596. }));
  1597. // todo: add check for linked calendars
  1598. yearsCalendar.hideLeftArrow =
  1599. options.yearIndex > 0 && options.yearIndex !== options.displayMonths;
  1600. yearsCalendar.hideRightArrow =
  1601. options.yearIndex < options.displayMonths &&
  1602. options.yearIndex + 1 !== options.displayMonths;
  1603. yearsCalendar.disableLeftArrow = isYearDisabled(shiftDate(yearsCalendar.years[0][0].date, { year: -1 }), options.minDate, options.maxDate);
  1604. /** @type {?} */
  1605. var i = yearsCalendar.years.length - 1;
  1606. /** @type {?} */
  1607. var j = yearsCalendar.years[i].length - 1;
  1608. yearsCalendar.disableRightArrow = isYearDisabled(shiftDate(yearsCalendar.years[i][j].date, { year: 1 }), options.minDate, options.maxDate);
  1609. return yearsCalendar;
  1610. }
  1611. /**
  1612. * @fileoverview added by tsickle
  1613. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1614. */
  1615. /* tslint:disable-next-line: cyclomatic-complexity */
  1616. /**
  1617. * @param {?=} state
  1618. * @param {?=} action
  1619. * @return {?}
  1620. */
  1621. function bsDatepickerReducer(state, action) {
  1622. if (state === void 0) { state = initialDatepickerState; }
  1623. switch (action.type) {
  1624. case BsDatepickerActions.CALCULATE: {
  1625. return calculateReducer(state);
  1626. }
  1627. case BsDatepickerActions.FORMAT: {
  1628. return formatReducer(state);
  1629. }
  1630. case BsDatepickerActions.FLAG: {
  1631. return flagReducer(state);
  1632. }
  1633. case BsDatepickerActions.NAVIGATE_OFFSET: {
  1634. return navigateOffsetReducer(state, action);
  1635. }
  1636. case BsDatepickerActions.NAVIGATE_TO: {
  1637. /** @type {?} */
  1638. var payload = action.payload;
  1639. /** @type {?} */
  1640. var date = setFullDate(state.view.date, payload.unit);
  1641. /** @type {?} */
  1642. var newState = void 0;
  1643. /** @type {?} */
  1644. var mode = void 0;
  1645. if (canSwitchMode(payload.viewMode, state.minMode)) {
  1646. mode = payload.viewMode;
  1647. newState = { view: { date: date, mode: mode } };
  1648. }
  1649. else {
  1650. mode = state.view.mode;
  1651. newState = { selectedDate: date, view: { date: date, mode: mode } };
  1652. }
  1653. return Object.assign({}, state, newState);
  1654. }
  1655. case BsDatepickerActions.CHANGE_VIEWMODE: {
  1656. if (!canSwitchMode(action.payload, state.minMode)) {
  1657. return state;
  1658. }
  1659. /** @type {?} */
  1660. var date = state.view.date;
  1661. /** @type {?} */
  1662. var mode = action.payload;
  1663. /** @type {?} */
  1664. var newState = { view: { date: date, mode: mode } };
  1665. return Object.assign({}, state, newState);
  1666. }
  1667. case BsDatepickerActions.HOVER: {
  1668. return Object.assign({}, state, { hoveredDate: action.payload });
  1669. }
  1670. case BsDatepickerActions.SELECT: {
  1671. /** @type {?} */
  1672. var newState = {
  1673. selectedDate: action.payload,
  1674. view: state.view
  1675. };
  1676. /** @type {?} */
  1677. var mode = state.view.mode;
  1678. /** @type {?} */
  1679. var _date = action.payload || state.view.date;
  1680. /** @type {?} */
  1681. var date = getViewDate(_date, state.minDate, state.maxDate);
  1682. newState.view = { mode: mode, date: date };
  1683. return Object.assign({}, state, newState);
  1684. }
  1685. case BsDatepickerActions.SET_OPTIONS: {
  1686. /** @type {?} */
  1687. var newState = action.payload;
  1688. // preserve view mode
  1689. /** @type {?} */
  1690. var mode = newState.minMode ? newState.minMode : state.view.mode;
  1691. /** @type {?} */
  1692. var _viewDate = isDateValid(newState.value) && newState.value
  1693. || isArray(newState.value) && isDateValid(newState.value[0]) && newState.value[0]
  1694. || state.view.date;
  1695. /** @type {?} */
  1696. var date = getViewDate(_viewDate, newState.minDate, newState.maxDate);
  1697. newState.view = { mode: mode, date: date };
  1698. // update selected value
  1699. if (newState.value) {
  1700. // if new value is array we work with date range
  1701. if (isArray(newState.value)) {
  1702. newState.selectedRange = newState.value;
  1703. }
  1704. // if new value is a date -> datepicker
  1705. if (newState.value instanceof Date) {
  1706. newState.selectedDate = newState.value;
  1707. }
  1708. // provided value is not supported :)
  1709. // need to report it somehow
  1710. }
  1711. return Object.assign({}, state, newState);
  1712. }
  1713. // date range picker
  1714. case BsDatepickerActions.SELECT_RANGE: {
  1715. /** @type {?} */
  1716. var newState = {
  1717. selectedRange: action.payload,
  1718. view: state.view
  1719. };
  1720. /** @type {?} */
  1721. var mode = state.view.mode;
  1722. /** @type {?} */
  1723. var _date = action.payload && action.payload[0] || state.view.date;
  1724. /** @type {?} */
  1725. var date = getViewDate(_date, state.minDate, state.maxDate);
  1726. newState.view = { mode: mode, date: date };
  1727. return Object.assign({}, state, newState);
  1728. }
  1729. case BsDatepickerActions.SET_MIN_DATE: {
  1730. return Object.assign({}, state, {
  1731. minDate: action.payload
  1732. });
  1733. }
  1734. case BsDatepickerActions.SET_MAX_DATE: {
  1735. return Object.assign({}, state, {
  1736. maxDate: action.payload
  1737. });
  1738. }
  1739. case BsDatepickerActions.SET_IS_DISABLED: {
  1740. return Object.assign({}, state, {
  1741. isDisabled: action.payload
  1742. });
  1743. }
  1744. case BsDatepickerActions.SET_DATE_CUSTOM_CLASSES: {
  1745. return Object.assign({}, state, {
  1746. dateCustomClasses: action.payload
  1747. });
  1748. }
  1749. default:
  1750. return state;
  1751. }
  1752. }
  1753. /**
  1754. * @param {?} state
  1755. * @return {?}
  1756. */
  1757. function calculateReducer(state) {
  1758. // how many calendars
  1759. /** @type {?} */
  1760. var displayMonths = state.displayMonths;
  1761. // use selected date on initial rendering if set
  1762. /** @type {?} */
  1763. var viewDate = state.view.date;
  1764. if (state.view.mode === 'day') {
  1765. state.monthViewOptions.firstDayOfWeek = getLocale(state.locale).firstDayOfWeek();
  1766. /** @type {?} */
  1767. var monthsModel = new Array(displayMonths);
  1768. for (var monthIndex = 0; monthIndex < displayMonths; monthIndex++) {
  1769. // todo: for unlinked calendars it will be harder
  1770. monthsModel[monthIndex] = calcDaysCalendar(viewDate, state.monthViewOptions);
  1771. viewDate = shiftDate(viewDate, { month: 1 });
  1772. }
  1773. return Object.assign({}, state, { monthsModel: monthsModel });
  1774. }
  1775. if (state.view.mode === 'month') {
  1776. /** @type {?} */
  1777. var monthsCalendar = new Array(displayMonths);
  1778. for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
  1779. // todo: for unlinked calendars it will be harder
  1780. monthsCalendar[calendarIndex] = formatMonthsCalendar(viewDate, getFormatOptions(state));
  1781. viewDate = shiftDate(viewDate, { year: 1 });
  1782. }
  1783. return Object.assign({}, state, { monthsCalendar: monthsCalendar });
  1784. }
  1785. if (state.view.mode === 'year') {
  1786. /** @type {?} */
  1787. var yearsCalendarModel = new Array(displayMonths);
  1788. for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
  1789. // todo: for unlinked calendars it will be harder
  1790. yearsCalendarModel[calendarIndex] = formatYearsCalendar(viewDate, getFormatOptions(state), state.minMode === 'year' ? getYearsCalendarInitialDate(state, calendarIndex) : undefined);
  1791. viewDate = shiftDate(viewDate, { year: yearsPerCalendar });
  1792. }
  1793. return Object.assign({}, state, { yearsCalendarModel: yearsCalendarModel });
  1794. }
  1795. return state;
  1796. }
  1797. /**
  1798. * @param {?} state
  1799. * @param {?} action
  1800. * @return {?}
  1801. */
  1802. function formatReducer(state, action) {
  1803. if (state.view.mode === 'day') {
  1804. /** @type {?} */
  1805. var formattedMonths = state.monthsModel.map((/**
  1806. * @param {?} month
  1807. * @param {?} monthIndex
  1808. * @return {?}
  1809. */
  1810. function (month, monthIndex) {
  1811. return formatDaysCalendar(month, getFormatOptions(state), monthIndex);
  1812. }));
  1813. return Object.assign({}, state, { formattedMonths: formattedMonths });
  1814. }
  1815. // how many calendars
  1816. /** @type {?} */
  1817. var displayMonths = state.displayMonths;
  1818. // check initial rendering
  1819. // use selected date on initial rendering if set
  1820. /** @type {?} */
  1821. var viewDate = state.view.date;
  1822. if (state.view.mode === 'month') {
  1823. /** @type {?} */
  1824. var monthsCalendar = new Array(displayMonths);
  1825. for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
  1826. // todo: for unlinked calendars it will be harder
  1827. monthsCalendar[calendarIndex] = formatMonthsCalendar(viewDate, getFormatOptions(state));
  1828. viewDate = shiftDate(viewDate, { year: 1 });
  1829. }
  1830. return Object.assign({}, state, { monthsCalendar: monthsCalendar });
  1831. }
  1832. if (state.view.mode === 'year') {
  1833. /** @type {?} */
  1834. var yearsCalendarModel = new Array(displayMonths);
  1835. for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
  1836. // todo: for unlinked calendars it will be harder
  1837. yearsCalendarModel[calendarIndex] = formatYearsCalendar(viewDate, getFormatOptions(state));
  1838. viewDate = shiftDate(viewDate, { year: 16 });
  1839. }
  1840. return Object.assign({}, state, { yearsCalendarModel: yearsCalendarModel });
  1841. }
  1842. return state;
  1843. }
  1844. /**
  1845. * @param {?} state
  1846. * @param {?} action
  1847. * @return {?}
  1848. */
  1849. function flagReducer(state, action) {
  1850. if (state.view.mode === 'day') {
  1851. /** @type {?} */
  1852. var flaggedMonths = state.formattedMonths.map((/**
  1853. * @param {?} formattedMonth
  1854. * @param {?} monthIndex
  1855. * @return {?}
  1856. */
  1857. function (formattedMonth, monthIndex) {
  1858. return flagDaysCalendar(formattedMonth, {
  1859. isDisabled: state.isDisabled,
  1860. minDate: state.minDate,
  1861. maxDate: state.maxDate,
  1862. daysDisabled: state.daysDisabled,
  1863. datesDisabled: state.datesDisabled,
  1864. hoveredDate: state.hoveredDate,
  1865. selectedDate: state.selectedDate,
  1866. selectedRange: state.selectedRange,
  1867. displayMonths: state.displayMonths,
  1868. dateCustomClasses: state.dateCustomClasses,
  1869. monthIndex: monthIndex
  1870. });
  1871. }));
  1872. return Object.assign({}, state, { flaggedMonths: flaggedMonths });
  1873. }
  1874. if (state.view.mode === 'month') {
  1875. /** @type {?} */
  1876. var flaggedMonthsCalendar = state.monthsCalendar.map((/**
  1877. * @param {?} formattedMonth
  1878. * @param {?} monthIndex
  1879. * @return {?}
  1880. */
  1881. function (formattedMonth, monthIndex) {
  1882. return flagMonthsCalendar(formattedMonth, {
  1883. isDisabled: state.isDisabled,
  1884. minDate: state.minDate,
  1885. maxDate: state.maxDate,
  1886. hoveredMonth: state.hoveredMonth,
  1887. selectedDate: state.selectedDate,
  1888. displayMonths: state.displayMonths,
  1889. monthIndex: monthIndex
  1890. });
  1891. }));
  1892. return Object.assign({}, state, { flaggedMonthsCalendar: flaggedMonthsCalendar });
  1893. }
  1894. if (state.view.mode === 'year') {
  1895. /** @type {?} */
  1896. var yearsCalendarFlagged = state.yearsCalendarModel.map((/**
  1897. * @param {?} formattedMonth
  1898. * @param {?} yearIndex
  1899. * @return {?}
  1900. */
  1901. function (formattedMonth, yearIndex) {
  1902. return flagYearsCalendar(formattedMonth, {
  1903. isDisabled: state.isDisabled,
  1904. minDate: state.minDate,
  1905. maxDate: state.maxDate,
  1906. hoveredYear: state.hoveredYear,
  1907. selectedDate: state.selectedDate,
  1908. displayMonths: state.displayMonths,
  1909. yearIndex: yearIndex
  1910. });
  1911. }));
  1912. return Object.assign({}, state, { yearsCalendarFlagged: yearsCalendarFlagged });
  1913. }
  1914. return state;
  1915. }
  1916. /**
  1917. * @param {?} state
  1918. * @param {?} action
  1919. * @return {?}
  1920. */
  1921. function navigateOffsetReducer(state, action) {
  1922. /** @type {?} */
  1923. var newState = {
  1924. view: {
  1925. mode: state.view.mode,
  1926. date: shiftViewDate(state, action)
  1927. }
  1928. };
  1929. return Object.assign({}, state, newState);
  1930. }
  1931. /**
  1932. * @param {?} state
  1933. * @param {?} action
  1934. * @return {?}
  1935. */
  1936. function shiftViewDate(state, action) {
  1937. if (state.view.mode === 'year' && state.minMode === 'year') {
  1938. /** @type {?} */
  1939. var initialDate = getYearsCalendarInitialDate(state, 0);
  1940. /** @type {?} */
  1941. var middleDate = shiftDate(initialDate, { year: -initialYearShift });
  1942. return shiftDate(middleDate, action.payload);
  1943. }
  1944. return shiftDate(startOf(state.view.date, 'month'), action.payload);
  1945. }
  1946. /**
  1947. * @param {?} state
  1948. * @return {?}
  1949. */
  1950. function getFormatOptions(state) {
  1951. return {
  1952. locale: state.locale,
  1953. monthTitle: state.monthTitle,
  1954. yearTitle: state.yearTitle,
  1955. dayLabel: state.dayLabel,
  1956. monthLabel: state.monthLabel,
  1957. yearLabel: state.yearLabel,
  1958. weekNumbers: state.weekNumbers
  1959. };
  1960. }
  1961. /**
  1962. * if view date is provided (bsValue|ngModel) it should be shown
  1963. * if view date is not provider:
  1964. * if minDate>currentDate (default view value), show minDate
  1965. * if maxDate<currentDate(default view value) show maxDate
  1966. * @param {?} viewDate
  1967. * @param {?} minDate
  1968. * @param {?} maxDate
  1969. * @return {?}
  1970. */
  1971. function getViewDate(viewDate, minDate, maxDate) {
  1972. /** @type {?} */
  1973. var _date = Array.isArray(viewDate) ? viewDate[0] : viewDate;
  1974. if (minDate && isAfter(minDate, _date, 'day')) {
  1975. return minDate;
  1976. }
  1977. if (maxDate && isBefore(maxDate, _date, 'day')) {
  1978. return maxDate;
  1979. }
  1980. return _date;
  1981. }
  1982. /**
  1983. * @fileoverview added by tsickle
  1984. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1985. */
  1986. var BsDatepickerStore = /** @class */ (function (_super) {
  1987. __extends(BsDatepickerStore, _super);
  1988. function BsDatepickerStore() {
  1989. var _this = this;
  1990. /** @type {?} */
  1991. var _dispatcher = new BehaviorSubject({
  1992. type: '[datepicker] dispatcher init'
  1993. });
  1994. /** @type {?} */
  1995. var state = new MiniState(initialDatepickerState, _dispatcher, bsDatepickerReducer);
  1996. _this = _super.call(this, _dispatcher, bsDatepickerReducer, state) || this;
  1997. return _this;
  1998. }
  1999. BsDatepickerStore.decorators = [
  2000. { type: Injectable }
  2001. ];
  2002. /** @nocollapse */
  2003. BsDatepickerStore.ctorParameters = function () { return []; };
  2004. return BsDatepickerStore;
  2005. }(MiniStore));
  2006. /**
  2007. * @fileoverview added by tsickle
  2008. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2009. */
  2010. /** @type {?} */
  2011. var DATEPICKER_ANIMATION_TIMING = '220ms cubic-bezier(0, 0, 0.2, 1)';
  2012. /** @type {?} */
  2013. var datepickerAnimation = trigger('datepickerAnimation', [
  2014. state('animated-down', style({ height: '*', overflow: 'hidden' })),
  2015. transition('* => animated-down', [
  2016. style({ height: 0, overflow: 'hidden' }),
  2017. animate(DATEPICKER_ANIMATION_TIMING)
  2018. ]),
  2019. state('animated-up', style({ height: '*', overflow: 'hidden' })),
  2020. transition('* => animated-up', [
  2021. style({ height: '*', overflow: 'hidden' }),
  2022. animate(DATEPICKER_ANIMATION_TIMING)
  2023. ]),
  2024. transition('* => unanimated', animate('0s'))
  2025. ]);
  2026. /**
  2027. * @fileoverview added by tsickle
  2028. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2029. */
  2030. var BsDatepickerContainerComponent = /** @class */ (function (_super) {
  2031. __extends(BsDatepickerContainerComponent, _super);
  2032. function BsDatepickerContainerComponent(_renderer, _config, _store, _element, _actions, _effects, _positionService) {
  2033. var _this = _super.call(this) || this;
  2034. _this._config = _config;
  2035. _this._store = _store;
  2036. _this._element = _element;
  2037. _this._actions = _actions;
  2038. _this._positionService = _positionService;
  2039. _this.valueChange = new EventEmitter();
  2040. _this.animationState = 'void';
  2041. _this._subs = [];
  2042. _this._effects = _effects;
  2043. _renderer.setStyle(_element.nativeElement, 'display', 'block');
  2044. _renderer.setStyle(_element.nativeElement, 'position', 'absolute');
  2045. return _this;
  2046. }
  2047. Object.defineProperty(BsDatepickerContainerComponent.prototype, "value", {
  2048. set: /**
  2049. * @param {?} value
  2050. * @return {?}
  2051. */
  2052. function (value) {
  2053. this._effects.setValue(value);
  2054. },
  2055. enumerable: true,
  2056. configurable: true
  2057. });
  2058. /**
  2059. * @return {?}
  2060. */
  2061. BsDatepickerContainerComponent.prototype.ngOnInit = /**
  2062. * @return {?}
  2063. */
  2064. function () {
  2065. var _this = this;
  2066. this._positionService.setOptions({
  2067. modifiers: { flip: { enabled: this._config.adaptivePosition } },
  2068. allowedPositions: ['top', 'bottom']
  2069. });
  2070. this._positionService.event$
  2071. .pipe(take(1))
  2072. .subscribe((/**
  2073. * @return {?}
  2074. */
  2075. function () {
  2076. _this._positionService.disable();
  2077. if (_this._config.isAnimated) {
  2078. _this.animationState = _this.isTopPosition ? 'animated-up' : 'animated-down';
  2079. return;
  2080. }
  2081. _this.animationState = 'unanimated';
  2082. }));
  2083. this.isOtherMonthsActive = this._config.selectFromOtherMonth;
  2084. this.containerClass = this._config.containerClass;
  2085. this._effects
  2086. .init(this._store)
  2087. // intial state options
  2088. .setOptions(this._config)
  2089. // data binding view --> model
  2090. .setBindings(this)
  2091. // set event handlers
  2092. .setEventHandlers(this)
  2093. .registerDatepickerSideEffects();
  2094. // todo: move it somewhere else
  2095. // on selected date change
  2096. this._subs.push(this._store
  2097. /* tslint:disable-next-line: no-any */
  2098. .select((/**
  2099. * @param {?} state
  2100. * @return {?}
  2101. */
  2102. function (state) { return state.selectedDate; }))
  2103. /* tslint:disable-next-line: no-any */
  2104. .subscribe((/**
  2105. * @param {?} date
  2106. * @return {?}
  2107. */
  2108. function (date) { return _this.valueChange.emit(date); })));
  2109. };
  2110. Object.defineProperty(BsDatepickerContainerComponent.prototype, "isTopPosition", {
  2111. get: /**
  2112. * @return {?}
  2113. */
  2114. function () {
  2115. return this._element.nativeElement.classList.contains('top');
  2116. },
  2117. enumerable: true,
  2118. configurable: true
  2119. });
  2120. /**
  2121. * @return {?}
  2122. */
  2123. BsDatepickerContainerComponent.prototype.positionServiceEnable = /**
  2124. * @return {?}
  2125. */
  2126. function () {
  2127. this._positionService.enable();
  2128. };
  2129. /**
  2130. * @param {?} day
  2131. * @return {?}
  2132. */
  2133. BsDatepickerContainerComponent.prototype.daySelectHandler = /**
  2134. * @param {?} day
  2135. * @return {?}
  2136. */
  2137. function (day) {
  2138. /** @type {?} */
  2139. var isDisabled = this.isOtherMonthsActive ? day.isDisabled : (day.isOtherMonth || day.isDisabled);
  2140. if (isDisabled) {
  2141. return;
  2142. }
  2143. this._store.dispatch(this._actions.select(day.date));
  2144. };
  2145. /**
  2146. * @return {?}
  2147. */
  2148. BsDatepickerContainerComponent.prototype.ngOnDestroy = /**
  2149. * @return {?}
  2150. */
  2151. function () {
  2152. var e_1, _a;
  2153. try {
  2154. for (var _b = __values(this._subs), _c = _b.next(); !_c.done; _c = _b.next()) {
  2155. var sub = _c.value;
  2156. sub.unsubscribe();
  2157. }
  2158. }
  2159. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2160. finally {
  2161. try {
  2162. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  2163. }
  2164. finally { if (e_1) throw e_1.error; }
  2165. }
  2166. this._effects.destroy();
  2167. };
  2168. BsDatepickerContainerComponent.decorators = [
  2169. { type: Component, args: [{
  2170. selector: 'bs-datepicker-container',
  2171. providers: [BsDatepickerStore, BsDatepickerEffects],
  2172. template: "<!-- days calendar view mode -->\n<div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\">\n <div class=\"bs-datepicker-container\"\n [@datepickerAnimation]=\"animationState\"\n (@datepickerAnimation.done)=\"positionServiceEnable()\">\n <!--calendars-->\n <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\">\n <!--days calendar-->\n <div *ngSwitchCase=\"'day'\" class=\"bs-media-container\">\n <bs-days-calendar-view\n *ngFor=\"let calendar of daysCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n [options]=\"options | async\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"dayHoverHandler($event)\"\n (onHoverWeek)=\"weekHoverHandler($event)\"\n (onSelect)=\"daySelectHandler($event)\">\n </bs-days-calendar-view>\n </div>\n\n <!--months calendar-->\n <div *ngSwitchCase=\"'month'\" class=\"bs-media-container\">\n <bs-month-calendar-view\n *ngFor=\"let calendar of monthsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"monthHoverHandler($event)\"\n (onSelect)=\"monthSelectHandler($event)\">\n </bs-month-calendar-view>\n </div>\n\n <!--years calendar-->\n <div *ngSwitchCase=\"'year'\" class=\"bs-media-container\">\n <bs-years-calendar-view\n *ngFor=\"let calendar of yearsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"yearHoverHandler($event)\"\n (onSelect)=\"yearSelectHandler($event)\">\n </bs-years-calendar-view>\n </div>\n </div>\n\n <!--applycancel buttons-->\n <div class=\"bs-datepicker-buttons\" *ngIf=\"false\">\n <button class=\"btn btn-success\" type=\"button\">Apply</button>\n <button class=\"btn btn-default\" type=\"button\">Cancel</button>\n </div>\n </div>\n\n <!--custom dates or date ranges picker-->\n <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\">\n <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view>\n </div>\n</div>\n",
  2173. host: {
  2174. class: 'bottom',
  2175. '(click)': '_stopPropagation($event)',
  2176. role: 'dialog',
  2177. 'aria-label': 'calendar'
  2178. },
  2179. animations: [datepickerAnimation]
  2180. }] }
  2181. ];
  2182. /** @nocollapse */
  2183. BsDatepickerContainerComponent.ctorParameters = function () { return [
  2184. { type: Renderer2 },
  2185. { type: BsDatepickerConfig },
  2186. { type: BsDatepickerStore },
  2187. { type: ElementRef },
  2188. { type: BsDatepickerActions },
  2189. { type: BsDatepickerEffects },
  2190. { type: PositioningService }
  2191. ]; };
  2192. return BsDatepickerContainerComponent;
  2193. }(BsDatepickerAbstractComponent));
  2194. /**
  2195. * @fileoverview added by tsickle
  2196. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2197. */
  2198. var BsDatepickerDirective = /** @class */ (function () {
  2199. function BsDatepickerDirective(_config, _elementRef, _renderer, _viewContainerRef, cis) {
  2200. this._config = _config;
  2201. /**
  2202. * Placement of a datepicker. Accepts: "top", "bottom", "left", "right"
  2203. */
  2204. this.placement = 'bottom';
  2205. /**
  2206. * Specifies events that should trigger. Supports a space separated list of
  2207. * event names.
  2208. */
  2209. this.triggers = 'click';
  2210. /**
  2211. * Close datepicker on outside click
  2212. */
  2213. this.outsideClick = true;
  2214. /**
  2215. * A selector specifying the element the datepicker should be appended to.
  2216. */
  2217. this.container = 'body';
  2218. this.outsideEsc = true;
  2219. /**
  2220. * Emits when datepicker value has been changed
  2221. */
  2222. this.bsValueChange = new EventEmitter();
  2223. this._subs = [];
  2224. // todo: assign only subset of fields
  2225. Object.assign(this, this._config);
  2226. this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
  2227. this.onShown = this._datepicker.onShown;
  2228. this.onHidden = this._datepicker.onHidden;
  2229. }
  2230. Object.defineProperty(BsDatepickerDirective.prototype, "isOpen", {
  2231. /**
  2232. * Returns whether or not the datepicker is currently being shown
  2233. */
  2234. get: /**
  2235. * Returns whether or not the datepicker is currently being shown
  2236. * @return {?}
  2237. */
  2238. function () {
  2239. return this._datepicker.isShown;
  2240. },
  2241. set: /**
  2242. * @param {?} value
  2243. * @return {?}
  2244. */
  2245. function (value) {
  2246. if (value) {
  2247. this.show();
  2248. }
  2249. else {
  2250. this.hide();
  2251. }
  2252. },
  2253. enumerable: true,
  2254. configurable: true
  2255. });
  2256. Object.defineProperty(BsDatepickerDirective.prototype, "bsValue", {
  2257. /**
  2258. * Initial value of datepicker
  2259. */
  2260. set: /**
  2261. * Initial value of datepicker
  2262. * @param {?} value
  2263. * @return {?}
  2264. */
  2265. function (value) {
  2266. if (this._bsValue === value) {
  2267. return;
  2268. }
  2269. this._bsValue = value;
  2270. this.bsValueChange.emit(value);
  2271. },
  2272. enumerable: true,
  2273. configurable: true
  2274. });
  2275. /**
  2276. * @return {?}
  2277. */
  2278. BsDatepickerDirective.prototype.ngOnInit = /**
  2279. * @return {?}
  2280. */
  2281. function () {
  2282. var _this = this;
  2283. this._datepicker.listen({
  2284. outsideClick: this.outsideClick,
  2285. outsideEsc: this.outsideEsc,
  2286. triggers: this.triggers,
  2287. show: (/**
  2288. * @return {?}
  2289. */
  2290. function () { return _this.show(); })
  2291. });
  2292. this.setConfig();
  2293. };
  2294. /**
  2295. * @param {?} changes
  2296. * @return {?}
  2297. */
  2298. BsDatepickerDirective.prototype.ngOnChanges = /**
  2299. * @param {?} changes
  2300. * @return {?}
  2301. */
  2302. function (changes) {
  2303. if (!this._datepickerRef || !this._datepickerRef.instance) {
  2304. return;
  2305. }
  2306. if (changes.minDate) {
  2307. this._datepickerRef.instance.minDate = this.minDate;
  2308. }
  2309. if (changes.maxDate) {
  2310. this._datepickerRef.instance.maxDate = this.maxDate;
  2311. }
  2312. if (changes.daysDisabled) {
  2313. this._datepickerRef.instance.daysDisabled = this.daysDisabled;
  2314. }
  2315. if (changes.datesDisabled) {
  2316. this._datepickerRef.instance.datesDisabled = this.datesDisabled;
  2317. }
  2318. if (changes.isDisabled) {
  2319. this._datepickerRef.instance.isDisabled = this.isDisabled;
  2320. }
  2321. if (changes.dateCustomClasses) {
  2322. this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
  2323. }
  2324. };
  2325. /**
  2326. * Opens an element’s datepicker. This is considered a “manual” triggering of
  2327. * the datepicker.
  2328. */
  2329. /**
  2330. * Opens an element’s datepicker. This is considered a “manual” triggering of
  2331. * the datepicker.
  2332. * @return {?}
  2333. */
  2334. BsDatepickerDirective.prototype.show = /**
  2335. * Opens an element’s datepicker. This is considered a “manual” triggering of
  2336. * the datepicker.
  2337. * @return {?}
  2338. */
  2339. function () {
  2340. var _this = this;
  2341. if (this._datepicker.isShown) {
  2342. return;
  2343. }
  2344. this.setConfig();
  2345. this._datepickerRef = this._datepicker
  2346. .provide({ provide: BsDatepickerConfig, useValue: this._config })
  2347. .attach(BsDatepickerContainerComponent)
  2348. .to(this.container)
  2349. .position({ attachment: this.placement })
  2350. .show({ placement: this.placement });
  2351. // if date changes from external source (model -> view)
  2352. this._subs.push(this.bsValueChange.subscribe((/**
  2353. * @param {?} value
  2354. * @return {?}
  2355. */
  2356. function (value) {
  2357. _this._datepickerRef.instance.value = value;
  2358. })));
  2359. // if date changes from picker (view -> model)
  2360. this._subs.push(this._datepickerRef.instance.valueChange.subscribe((/**
  2361. * @param {?} value
  2362. * @return {?}
  2363. */
  2364. function (value) {
  2365. _this.bsValue = value;
  2366. _this.hide();
  2367. })));
  2368. };
  2369. /**
  2370. * Closes an element’s datepicker. This is considered a “manual” triggering of
  2371. * the datepicker.
  2372. */
  2373. /**
  2374. * Closes an element’s datepicker. This is considered a “manual” triggering of
  2375. * the datepicker.
  2376. * @return {?}
  2377. */
  2378. BsDatepickerDirective.prototype.hide = /**
  2379. * Closes an element’s datepicker. This is considered a “manual” triggering of
  2380. * the datepicker.
  2381. * @return {?}
  2382. */
  2383. function () {
  2384. var e_1, _a;
  2385. if (this.isOpen) {
  2386. this._datepicker.hide();
  2387. }
  2388. try {
  2389. for (var _b = __values(this._subs), _c = _b.next(); !_c.done; _c = _b.next()) {
  2390. var sub = _c.value;
  2391. sub.unsubscribe();
  2392. }
  2393. }
  2394. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2395. finally {
  2396. try {
  2397. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  2398. }
  2399. finally { if (e_1) throw e_1.error; }
  2400. }
  2401. };
  2402. /**
  2403. * Toggles an element’s datepicker. This is considered a “manual” triggering
  2404. * of the datepicker.
  2405. */
  2406. /**
  2407. * Toggles an element’s datepicker. This is considered a “manual” triggering
  2408. * of the datepicker.
  2409. * @return {?}
  2410. */
  2411. BsDatepickerDirective.prototype.toggle = /**
  2412. * Toggles an element’s datepicker. This is considered a “manual” triggering
  2413. * of the datepicker.
  2414. * @return {?}
  2415. */
  2416. function () {
  2417. if (this.isOpen) {
  2418. return this.hide();
  2419. }
  2420. this.show();
  2421. };
  2422. /**
  2423. * Set config for datepicker
  2424. */
  2425. /**
  2426. * Set config for datepicker
  2427. * @return {?}
  2428. */
  2429. BsDatepickerDirective.prototype.setConfig = /**
  2430. * Set config for datepicker
  2431. * @return {?}
  2432. */
  2433. function () {
  2434. this._config = Object.assign({}, this._config, this.bsConfig, {
  2435. value: this._bsValue,
  2436. isDisabled: this.isDisabled,
  2437. minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
  2438. maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
  2439. daysDisabled: this.daysDisabled || this.bsConfig && this.bsConfig.daysDisabled,
  2440. dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
  2441. datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled,
  2442. minMode: this.minMode || this.bsConfig && this.bsConfig.minMode
  2443. });
  2444. };
  2445. /**
  2446. * @return {?}
  2447. */
  2448. BsDatepickerDirective.prototype.ngOnDestroy = /**
  2449. * @return {?}
  2450. */
  2451. function () {
  2452. this._datepicker.dispose();
  2453. };
  2454. BsDatepickerDirective.decorators = [
  2455. { type: Directive, args: [{
  2456. selector: '[bsDatepicker]',
  2457. exportAs: 'bsDatepicker'
  2458. },] }
  2459. ];
  2460. /** @nocollapse */
  2461. BsDatepickerDirective.ctorParameters = function () { return [
  2462. { type: BsDatepickerConfig },
  2463. { type: ElementRef },
  2464. { type: Renderer2 },
  2465. { type: ViewContainerRef },
  2466. { type: ComponentLoaderFactory }
  2467. ]; };
  2468. BsDatepickerDirective.propDecorators = {
  2469. placement: [{ type: Input }],
  2470. triggers: [{ type: Input }],
  2471. outsideClick: [{ type: Input }],
  2472. container: [{ type: Input }],
  2473. outsideEsc: [{ type: Input }],
  2474. isOpen: [{ type: Input }],
  2475. onShown: [{ type: Output }],
  2476. onHidden: [{ type: Output }],
  2477. bsValue: [{ type: Input }],
  2478. bsConfig: [{ type: Input }],
  2479. isDisabled: [{ type: Input }],
  2480. minDate: [{ type: Input }],
  2481. maxDate: [{ type: Input }],
  2482. minMode: [{ type: Input }],
  2483. daysDisabled: [{ type: Input }],
  2484. datesDisabled: [{ type: Input }],
  2485. dateCustomClasses: [{ type: Input }],
  2486. bsValueChange: [{ type: Output }]
  2487. };
  2488. return BsDatepickerDirective;
  2489. }());
  2490. /**
  2491. * @fileoverview added by tsickle
  2492. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2493. */
  2494. var BsDatepickerInlineConfig = /** @class */ (function (_super) {
  2495. __extends(BsDatepickerInlineConfig, _super);
  2496. function BsDatepickerInlineConfig() {
  2497. return _super !== null && _super.apply(this, arguments) || this;
  2498. }
  2499. BsDatepickerInlineConfig.decorators = [
  2500. { type: Injectable }
  2501. ];
  2502. return BsDatepickerInlineConfig;
  2503. }(BsDatepickerConfig));
  2504. /**
  2505. * @fileoverview added by tsickle
  2506. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2507. */
  2508. var BsDatepickerInlineContainerComponent = /** @class */ (function (_super) {
  2509. __extends(BsDatepickerInlineContainerComponent, _super);
  2510. function BsDatepickerInlineContainerComponent(_renderer, _config, _store, _element, _actions, _effects, _positioningService) {
  2511. var _this = _super.call(this, _renderer, _config, _store, _element, _actions, _effects, _positioningService) || this;
  2512. _renderer.setStyle(_element.nativeElement, 'display', 'inline-block');
  2513. _renderer.setStyle(_element.nativeElement, 'position', 'static');
  2514. return _this;
  2515. }
  2516. BsDatepickerInlineContainerComponent.decorators = [
  2517. { type: Component, args: [{
  2518. selector: 'bs-datepicker-inline-container',
  2519. providers: [BsDatepickerStore, BsDatepickerEffects],
  2520. template: "<!-- days calendar view mode -->\n<div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\">\n <div class=\"bs-datepicker-container\"\n [@datepickerAnimation]=\"animationState\"\n (@datepickerAnimation.done)=\"positionServiceEnable()\">\n <!--calendars-->\n <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\">\n <!--days calendar-->\n <div *ngSwitchCase=\"'day'\" class=\"bs-media-container\">\n <bs-days-calendar-view\n *ngFor=\"let calendar of daysCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n [options]=\"options | async\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"dayHoverHandler($event)\"\n (onHoverWeek)=\"weekHoverHandler($event)\"\n (onSelect)=\"daySelectHandler($event)\">\n </bs-days-calendar-view>\n </div>\n\n <!--months calendar-->\n <div *ngSwitchCase=\"'month'\" class=\"bs-media-container\">\n <bs-month-calendar-view\n *ngFor=\"let calendar of monthsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"monthHoverHandler($event)\"\n (onSelect)=\"monthSelectHandler($event)\">\n </bs-month-calendar-view>\n </div>\n\n <!--years calendar-->\n <div *ngSwitchCase=\"'year'\" class=\"bs-media-container\">\n <bs-years-calendar-view\n *ngFor=\"let calendar of yearsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"yearHoverHandler($event)\"\n (onSelect)=\"yearSelectHandler($event)\">\n </bs-years-calendar-view>\n </div>\n </div>\n\n <!--applycancel buttons-->\n <div class=\"bs-datepicker-buttons\" *ngIf=\"false\">\n <button class=\"btn btn-success\" type=\"button\">Apply</button>\n <button class=\"btn btn-default\" type=\"button\">Cancel</button>\n </div>\n </div>\n\n <!--custom dates or date ranges picker-->\n <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\">\n <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view>\n </div>\n</div>\n",
  2521. host: {
  2522. '(click)': '_stopPropagation($event)'
  2523. },
  2524. animations: [datepickerAnimation]
  2525. }] }
  2526. ];
  2527. /** @nocollapse */
  2528. BsDatepickerInlineContainerComponent.ctorParameters = function () { return [
  2529. { type: Renderer2 },
  2530. { type: BsDatepickerConfig },
  2531. { type: BsDatepickerStore },
  2532. { type: ElementRef },
  2533. { type: BsDatepickerActions },
  2534. { type: BsDatepickerEffects },
  2535. { type: PositioningService }
  2536. ]; };
  2537. return BsDatepickerInlineContainerComponent;
  2538. }(BsDatepickerContainerComponent));
  2539. /**
  2540. * @fileoverview added by tsickle
  2541. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2542. */
  2543. var BsDatepickerInlineDirective = /** @class */ (function () {
  2544. function BsDatepickerInlineDirective(_config, _elementRef, _renderer, _viewContainerRef, cis) {
  2545. this._config = _config;
  2546. this._elementRef = _elementRef;
  2547. /**
  2548. * Emits when datepicker value has been changed
  2549. */
  2550. this.bsValueChange = new EventEmitter();
  2551. this._subs = [];
  2552. // todo: assign only subset of fields
  2553. Object.assign(this, this._config);
  2554. this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
  2555. }
  2556. Object.defineProperty(BsDatepickerInlineDirective.prototype, "bsValue", {
  2557. /**
  2558. * Initial value of datepicker
  2559. */
  2560. set: /**
  2561. * Initial value of datepicker
  2562. * @param {?} value
  2563. * @return {?}
  2564. */
  2565. function (value) {
  2566. if (this._bsValue === value) {
  2567. return;
  2568. }
  2569. this._bsValue = value;
  2570. this.bsValueChange.emit(value);
  2571. },
  2572. enumerable: true,
  2573. configurable: true
  2574. });
  2575. /**
  2576. * @return {?}
  2577. */
  2578. BsDatepickerInlineDirective.prototype.ngOnInit = /**
  2579. * @return {?}
  2580. */
  2581. function () {
  2582. var _this = this;
  2583. this.setConfig();
  2584. this._datepickerRef = this._datepicker
  2585. .provide({ provide: BsDatepickerConfig, useValue: this._config })
  2586. .attach(BsDatepickerInlineContainerComponent)
  2587. .to(this._elementRef)
  2588. .show();
  2589. // if date changes from external source (model -> view)
  2590. this._subs.push(this.bsValueChange.subscribe((/**
  2591. * @param {?} value
  2592. * @return {?}
  2593. */
  2594. function (value) {
  2595. _this._datepickerRef.instance.value = value;
  2596. })));
  2597. // if date changes from picker (view -> model)
  2598. this._subs.push(this._datepickerRef.instance.valueChange.subscribe((/**
  2599. * @param {?} value
  2600. * @return {?}
  2601. */
  2602. function (value) {
  2603. _this.bsValue = value;
  2604. })));
  2605. };
  2606. /**
  2607. * @param {?} changes
  2608. * @return {?}
  2609. */
  2610. BsDatepickerInlineDirective.prototype.ngOnChanges = /**
  2611. * @param {?} changes
  2612. * @return {?}
  2613. */
  2614. function (changes) {
  2615. if (!this._datepickerRef || !this._datepickerRef.instance) {
  2616. return;
  2617. }
  2618. if (changes.minDate) {
  2619. this._datepickerRef.instance.minDate = this.minDate;
  2620. this._datepickerRef.instance.value = this._bsValue;
  2621. }
  2622. if (changes.maxDate) {
  2623. this._datepickerRef.instance.maxDate = this.maxDate;
  2624. this._datepickerRef.instance.value = this._bsValue;
  2625. }
  2626. if (changes.datesDisabled) {
  2627. this._datepickerRef.instance.datesDisabled = this.datesDisabled;
  2628. this._datepickerRef.instance.value = this._bsValue;
  2629. }
  2630. if (changes.isDisabled) {
  2631. this._datepickerRef.instance.isDisabled = this.isDisabled;
  2632. }
  2633. if (changes.dateCustomClasses) {
  2634. this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
  2635. }
  2636. };
  2637. /**
  2638. * Set config for datepicker
  2639. */
  2640. /**
  2641. * Set config for datepicker
  2642. * @return {?}
  2643. */
  2644. BsDatepickerInlineDirective.prototype.setConfig = /**
  2645. * Set config for datepicker
  2646. * @return {?}
  2647. */
  2648. function () {
  2649. this._config = Object.assign({}, this._config, this.bsConfig, {
  2650. value: this._bsValue,
  2651. isDisabled: this.isDisabled,
  2652. minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
  2653. maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
  2654. dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
  2655. datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled
  2656. });
  2657. };
  2658. /**
  2659. * @return {?}
  2660. */
  2661. BsDatepickerInlineDirective.prototype.ngOnDestroy = /**
  2662. * @return {?}
  2663. */
  2664. function () {
  2665. this._datepicker.dispose();
  2666. };
  2667. BsDatepickerInlineDirective.decorators = [
  2668. { type: Directive, args: [{
  2669. selector: 'bs-datepicker-inline',
  2670. exportAs: 'bsDatepickerInline'
  2671. },] }
  2672. ];
  2673. /** @nocollapse */
  2674. BsDatepickerInlineDirective.ctorParameters = function () { return [
  2675. { type: BsDatepickerInlineConfig },
  2676. { type: ElementRef },
  2677. { type: Renderer2 },
  2678. { type: ViewContainerRef },
  2679. { type: ComponentLoaderFactory }
  2680. ]; };
  2681. BsDatepickerInlineDirective.propDecorators = {
  2682. bsValue: [{ type: Input }],
  2683. bsConfig: [{ type: Input }],
  2684. isDisabled: [{ type: Input }],
  2685. minDate: [{ type: Input }],
  2686. maxDate: [{ type: Input }],
  2687. dateCustomClasses: [{ type: Input }],
  2688. datesDisabled: [{ type: Input }],
  2689. bsValueChange: [{ type: Output }]
  2690. };
  2691. return BsDatepickerInlineDirective;
  2692. }());
  2693. /**
  2694. * @fileoverview added by tsickle
  2695. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2696. */
  2697. var BsDaterangepickerInlineConfig = /** @class */ (function (_super) {
  2698. __extends(BsDaterangepickerInlineConfig, _super);
  2699. function BsDaterangepickerInlineConfig() {
  2700. var _this = _super !== null && _super.apply(this, arguments) || this;
  2701. // DatepickerRenderOptions
  2702. _this.displayMonths = 2;
  2703. /**
  2704. * turn on/off animation
  2705. */
  2706. _this.isAnimated = false;
  2707. return _this;
  2708. }
  2709. BsDaterangepickerInlineConfig.decorators = [
  2710. { type: Injectable }
  2711. ];
  2712. return BsDaterangepickerInlineConfig;
  2713. }(BsDatepickerConfig));
  2714. /**
  2715. * @fileoverview added by tsickle
  2716. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2717. */
  2718. var BsDaterangepickerContainerComponent = /** @class */ (function (_super) {
  2719. __extends(BsDaterangepickerContainerComponent, _super);
  2720. function BsDaterangepickerContainerComponent(_renderer, _config, _store, _element, _actions, _effects, _positionService) {
  2721. var _this = _super.call(this) || this;
  2722. _this._config = _config;
  2723. _this._store = _store;
  2724. _this._element = _element;
  2725. _this._actions = _actions;
  2726. _this._positionService = _positionService;
  2727. _this.valueChange = new EventEmitter();
  2728. _this.animationState = 'void';
  2729. _this._rangeStack = [];
  2730. _this._subs = [];
  2731. _this._effects = _effects;
  2732. _renderer.setStyle(_element.nativeElement, 'display', 'block');
  2733. _renderer.setStyle(_element.nativeElement, 'position', 'absolute');
  2734. return _this;
  2735. }
  2736. Object.defineProperty(BsDaterangepickerContainerComponent.prototype, "value", {
  2737. set: /**
  2738. * @param {?} value
  2739. * @return {?}
  2740. */
  2741. function (value) {
  2742. this._effects.setRangeValue(value);
  2743. },
  2744. enumerable: true,
  2745. configurable: true
  2746. });
  2747. /**
  2748. * @return {?}
  2749. */
  2750. BsDaterangepickerContainerComponent.prototype.ngOnInit = /**
  2751. * @return {?}
  2752. */
  2753. function () {
  2754. var _this = this;
  2755. this._positionService.setOptions({
  2756. modifiers: { flip: { enabled: this._config.adaptivePosition } },
  2757. allowedPositions: ['top', 'bottom']
  2758. });
  2759. this._positionService.event$
  2760. .pipe(take(1))
  2761. .subscribe((/**
  2762. * @return {?}
  2763. */
  2764. function () {
  2765. _this._positionService.disable();
  2766. if (_this._config.isAnimated) {
  2767. _this.animationState = _this.isTopPosition ? 'animated-up' : 'animated-down';
  2768. return;
  2769. }
  2770. _this.animationState = 'unanimated';
  2771. }));
  2772. this.containerClass = this._config.containerClass;
  2773. this.isOtherMonthsActive = this._config.selectFromOtherMonth;
  2774. this._effects
  2775. .init(this._store)
  2776. // intial state options
  2777. // todo: fix this, split configs
  2778. .setOptions(this._config)
  2779. // data binding view --> model
  2780. .setBindings(this)
  2781. // set event handlers
  2782. .setEventHandlers(this)
  2783. .registerDatepickerSideEffects();
  2784. // todo: move it somewhere else
  2785. // on selected date change
  2786. this._subs.push(this._store
  2787. .select((/**
  2788. * @param {?} state
  2789. * @return {?}
  2790. */
  2791. function (state) { return state.selectedRange; }))
  2792. .subscribe((/**
  2793. * @param {?} date
  2794. * @return {?}
  2795. */
  2796. function (date) { return _this.valueChange.emit(date); })));
  2797. };
  2798. Object.defineProperty(BsDaterangepickerContainerComponent.prototype, "isTopPosition", {
  2799. get: /**
  2800. * @return {?}
  2801. */
  2802. function () {
  2803. return this._element.nativeElement.classList.contains('top');
  2804. },
  2805. enumerable: true,
  2806. configurable: true
  2807. });
  2808. /**
  2809. * @return {?}
  2810. */
  2811. BsDaterangepickerContainerComponent.prototype.positionServiceEnable = /**
  2812. * @return {?}
  2813. */
  2814. function () {
  2815. this._positionService.enable();
  2816. };
  2817. /**
  2818. * @param {?} day
  2819. * @return {?}
  2820. */
  2821. BsDaterangepickerContainerComponent.prototype.daySelectHandler = /**
  2822. * @param {?} day
  2823. * @return {?}
  2824. */
  2825. function (day) {
  2826. /** @type {?} */
  2827. var isDisabled = this.isOtherMonthsActive ? day.isDisabled : (day.isOtherMonth || day.isDisabled);
  2828. if (isDisabled) {
  2829. return;
  2830. }
  2831. // if only one date is already selected
  2832. // and user clicks on previous date
  2833. // start selection from new date
  2834. // but if new date is after initial one
  2835. // than finish selection
  2836. if (this._rangeStack.length === 1) {
  2837. this._rangeStack =
  2838. day.date >= this._rangeStack[0]
  2839. ? [this._rangeStack[0], day.date]
  2840. : [day.date];
  2841. }
  2842. if (this._rangeStack.length === 0) {
  2843. this._rangeStack = [day.date];
  2844. }
  2845. this._store.dispatch(this._actions.selectRange(this._rangeStack));
  2846. if (this._rangeStack.length === 2) {
  2847. this._rangeStack = [];
  2848. }
  2849. };
  2850. /**
  2851. * @return {?}
  2852. */
  2853. BsDaterangepickerContainerComponent.prototype.ngOnDestroy = /**
  2854. * @return {?}
  2855. */
  2856. function () {
  2857. var e_1, _a;
  2858. try {
  2859. for (var _b = __values(this._subs), _c = _b.next(); !_c.done; _c = _b.next()) {
  2860. var sub = _c.value;
  2861. sub.unsubscribe();
  2862. }
  2863. }
  2864. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2865. finally {
  2866. try {
  2867. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  2868. }
  2869. finally { if (e_1) throw e_1.error; }
  2870. }
  2871. this._effects.destroy();
  2872. };
  2873. BsDaterangepickerContainerComponent.decorators = [
  2874. { type: Component, args: [{
  2875. selector: 'bs-daterangepicker-container',
  2876. providers: [BsDatepickerStore, BsDatepickerEffects],
  2877. template: "<!-- days calendar view mode -->\n<div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\">\n <div class=\"bs-datepicker-container\"\n [@datepickerAnimation]=\"animationState\"\n (@datepickerAnimation.done)=\"positionServiceEnable()\">\n <!--calendars-->\n <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\">\n <!--days calendar-->\n <div *ngSwitchCase=\"'day'\" class=\"bs-media-container\">\n <bs-days-calendar-view\n *ngFor=\"let calendar of daysCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n [options]=\"options | async\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"dayHoverHandler($event)\"\n (onHoverWeek)=\"weekHoverHandler($event)\"\n (onSelect)=\"daySelectHandler($event)\">\n </bs-days-calendar-view>\n </div>\n\n <!--months calendar-->\n <div *ngSwitchCase=\"'month'\" class=\"bs-media-container\">\n <bs-month-calendar-view\n *ngFor=\"let calendar of monthsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"monthHoverHandler($event)\"\n (onSelect)=\"monthSelectHandler($event)\">\n </bs-month-calendar-view>\n </div>\n\n <!--years calendar-->\n <div *ngSwitchCase=\"'year'\" class=\"bs-media-container\">\n <bs-years-calendar-view\n *ngFor=\"let calendar of yearsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"yearHoverHandler($event)\"\n (onSelect)=\"yearSelectHandler($event)\">\n </bs-years-calendar-view>\n </div>\n </div>\n\n <!--applycancel buttons-->\n <div class=\"bs-datepicker-buttons\" *ngIf=\"false\">\n <button class=\"btn btn-success\" type=\"button\">Apply</button>\n <button class=\"btn btn-default\" type=\"button\">Cancel</button>\n </div>\n </div>\n\n <!--custom dates or date ranges picker-->\n <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\">\n <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view>\n </div>\n</div>\n",
  2878. host: {
  2879. class: 'bottom',
  2880. '(click)': '_stopPropagation($event)',
  2881. role: 'dialog',
  2882. 'aria-label': 'calendar'
  2883. },
  2884. animations: [datepickerAnimation]
  2885. }] }
  2886. ];
  2887. /** @nocollapse */
  2888. BsDaterangepickerContainerComponent.ctorParameters = function () { return [
  2889. { type: Renderer2 },
  2890. { type: BsDatepickerConfig },
  2891. { type: BsDatepickerStore },
  2892. { type: ElementRef },
  2893. { type: BsDatepickerActions },
  2894. { type: BsDatepickerEffects },
  2895. { type: PositioningService }
  2896. ]; };
  2897. return BsDaterangepickerContainerComponent;
  2898. }(BsDatepickerAbstractComponent));
  2899. /**
  2900. * @fileoverview added by tsickle
  2901. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2902. */
  2903. var BsDaterangepickerInlineContainerComponent = /** @class */ (function (_super) {
  2904. __extends(BsDaterangepickerInlineContainerComponent, _super);
  2905. function BsDaterangepickerInlineContainerComponent(_renderer, _config, _store, _element, _actions, _effects, _positioningService) {
  2906. var _this = _super.call(this, _renderer, _config, _store, _element, _actions, _effects, _positioningService) || this;
  2907. _renderer.setStyle(_element.nativeElement, 'display', 'inline-block');
  2908. _renderer.setStyle(_element.nativeElement, 'position', 'static');
  2909. return _this;
  2910. }
  2911. BsDaterangepickerInlineContainerComponent.decorators = [
  2912. { type: Component, args: [{
  2913. selector: 'bs-daterangepicker-inline-container',
  2914. providers: [BsDatepickerStore, BsDatepickerEffects],
  2915. template: "<!-- days calendar view mode -->\n<div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\">\n <div class=\"bs-datepicker-container\"\n [@datepickerAnimation]=\"animationState\"\n (@datepickerAnimation.done)=\"positionServiceEnable()\">\n <!--calendars-->\n <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\">\n <!--days calendar-->\n <div *ngSwitchCase=\"'day'\" class=\"bs-media-container\">\n <bs-days-calendar-view\n *ngFor=\"let calendar of daysCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n [options]=\"options | async\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"dayHoverHandler($event)\"\n (onHoverWeek)=\"weekHoverHandler($event)\"\n (onSelect)=\"daySelectHandler($event)\">\n </bs-days-calendar-view>\n </div>\n\n <!--months calendar-->\n <div *ngSwitchCase=\"'month'\" class=\"bs-media-container\">\n <bs-month-calendar-view\n *ngFor=\"let calendar of monthsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"monthHoverHandler($event)\"\n (onSelect)=\"monthSelectHandler($event)\">\n </bs-month-calendar-view>\n </div>\n\n <!--years calendar-->\n <div *ngSwitchCase=\"'year'\" class=\"bs-media-container\">\n <bs-years-calendar-view\n *ngFor=\"let calendar of yearsCalendar | async\"\n [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"setViewMode($event)\"\n (onHover)=\"yearHoverHandler($event)\"\n (onSelect)=\"yearSelectHandler($event)\">\n </bs-years-calendar-view>\n </div>\n </div>\n\n <!--applycancel buttons-->\n <div class=\"bs-datepicker-buttons\" *ngIf=\"false\">\n <button class=\"btn btn-success\" type=\"button\">Apply</button>\n <button class=\"btn btn-default\" type=\"button\">Cancel</button>\n </div>\n </div>\n\n <!--custom dates or date ranges picker-->\n <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\">\n <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view>\n </div>\n</div>\n",
  2916. host: {
  2917. '(click)': '_stopPropagation($event)'
  2918. },
  2919. animations: [datepickerAnimation]
  2920. }] }
  2921. ];
  2922. /** @nocollapse */
  2923. BsDaterangepickerInlineContainerComponent.ctorParameters = function () { return [
  2924. { type: Renderer2 },
  2925. { type: BsDatepickerConfig },
  2926. { type: BsDatepickerStore },
  2927. { type: ElementRef },
  2928. { type: BsDatepickerActions },
  2929. { type: BsDatepickerEffects },
  2930. { type: PositioningService }
  2931. ]; };
  2932. return BsDaterangepickerInlineContainerComponent;
  2933. }(BsDaterangepickerContainerComponent));
  2934. /**
  2935. * @fileoverview added by tsickle
  2936. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2937. */
  2938. var BsDaterangepickerInlineDirective = /** @class */ (function () {
  2939. function BsDaterangepickerInlineDirective(_config, _elementRef, _renderer, _viewContainerRef, cis) {
  2940. this._config = _config;
  2941. this._elementRef = _elementRef;
  2942. /**
  2943. * Emits when daterangepicker value has been changed
  2944. */
  2945. this.bsValueChange = new EventEmitter();
  2946. this._subs = [];
  2947. // todo: assign only subset of fields
  2948. Object.assign(this, this._config);
  2949. this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
  2950. }
  2951. Object.defineProperty(BsDaterangepickerInlineDirective.prototype, "bsValue", {
  2952. /**
  2953. * Initial value of datepicker
  2954. */
  2955. set: /**
  2956. * Initial value of datepicker
  2957. * @param {?} value
  2958. * @return {?}
  2959. */
  2960. function (value) {
  2961. if (this._bsValue === value) {
  2962. return;
  2963. }
  2964. this._bsValue = value;
  2965. this.bsValueChange.emit(value);
  2966. },
  2967. enumerable: true,
  2968. configurable: true
  2969. });
  2970. /**
  2971. * @return {?}
  2972. */
  2973. BsDaterangepickerInlineDirective.prototype.ngOnInit = /**
  2974. * @return {?}
  2975. */
  2976. function () {
  2977. var _this = this;
  2978. this.setConfig();
  2979. this._datepickerRef = this._datepicker
  2980. .provide({ provide: BsDatepickerConfig, useValue: this._config })
  2981. .attach(BsDaterangepickerInlineContainerComponent)
  2982. .to(this._elementRef)
  2983. .show();
  2984. // if date changes from external source (model -> view)
  2985. this._subs.push(this.bsValueChange.subscribe((/**
  2986. * @param {?} value
  2987. * @return {?}
  2988. */
  2989. function (value) {
  2990. _this._datepickerRef.instance.value = value;
  2991. })));
  2992. // if date changes from picker (view -> model)
  2993. this._subs.push(this._datepickerRef.instance.valueChange
  2994. .pipe(filter((/**
  2995. * @param {?} range
  2996. * @return {?}
  2997. */
  2998. function (range) { return range && range[0] && !!range[1]; })))
  2999. .subscribe((/**
  3000. * @param {?} value
  3001. * @return {?}
  3002. */
  3003. function (value) {
  3004. _this.bsValue = value;
  3005. })));
  3006. };
  3007. /**
  3008. * @param {?} changes
  3009. * @return {?}
  3010. */
  3011. BsDaterangepickerInlineDirective.prototype.ngOnChanges = /**
  3012. * @param {?} changes
  3013. * @return {?}
  3014. */
  3015. function (changes) {
  3016. if (!this._datepickerRef || !this._datepickerRef.instance) {
  3017. return;
  3018. }
  3019. if (changes.minDate) {
  3020. this._datepickerRef.instance.minDate = this.minDate;
  3021. }
  3022. if (changes.maxDate) {
  3023. this._datepickerRef.instance.maxDate = this.maxDate;
  3024. }
  3025. if (changes.datesDisabled) {
  3026. this._datepickerRef.instance.datesDisabled = this.datesDisabled;
  3027. }
  3028. if (changes.isDisabled) {
  3029. this._datepickerRef.instance.isDisabled = this.isDisabled;
  3030. }
  3031. if (changes.dateCustomClasses) {
  3032. this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
  3033. }
  3034. };
  3035. /**
  3036. * Set config for datepicker
  3037. */
  3038. /**
  3039. * Set config for datepicker
  3040. * @return {?}
  3041. */
  3042. BsDaterangepickerInlineDirective.prototype.setConfig = /**
  3043. * Set config for datepicker
  3044. * @return {?}
  3045. */
  3046. function () {
  3047. this._config = Object.assign({}, this._config, this.bsConfig, {
  3048. value: this._bsValue,
  3049. isDisabled: this.isDisabled,
  3050. minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
  3051. maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
  3052. dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
  3053. datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled
  3054. });
  3055. };
  3056. /**
  3057. * @return {?}
  3058. */
  3059. BsDaterangepickerInlineDirective.prototype.ngOnDestroy = /**
  3060. * @return {?}
  3061. */
  3062. function () {
  3063. this._datepicker.dispose();
  3064. };
  3065. BsDaterangepickerInlineDirective.decorators = [
  3066. { type: Directive, args: [{
  3067. selector: 'bs-daterangepicker-inline',
  3068. exportAs: 'bsDaterangepickerInline'
  3069. },] }
  3070. ];
  3071. /** @nocollapse */
  3072. BsDaterangepickerInlineDirective.ctorParameters = function () { return [
  3073. { type: BsDaterangepickerInlineConfig },
  3074. { type: ElementRef },
  3075. { type: Renderer2 },
  3076. { type: ViewContainerRef },
  3077. { type: ComponentLoaderFactory }
  3078. ]; };
  3079. BsDaterangepickerInlineDirective.propDecorators = {
  3080. bsValue: [{ type: Input }],
  3081. bsConfig: [{ type: Input }],
  3082. isDisabled: [{ type: Input }],
  3083. minDate: [{ type: Input }],
  3084. maxDate: [{ type: Input }],
  3085. dateCustomClasses: [{ type: Input }],
  3086. datesDisabled: [{ type: Input }],
  3087. bsValueChange: [{ type: Output }]
  3088. };
  3089. return BsDaterangepickerInlineDirective;
  3090. }());
  3091. /**
  3092. * @fileoverview added by tsickle
  3093. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3094. */
  3095. /** @type {?} */
  3096. var BS_DATEPICKER_VALUE_ACCESSOR = {
  3097. provide: NG_VALUE_ACCESSOR,
  3098. /* tslint:disable-next-line: no-use-before-declare */
  3099. useExisting: forwardRef((/**
  3100. * @return {?}
  3101. */
  3102. function () { return BsDatepickerInputDirective; })),
  3103. multi: true
  3104. };
  3105. /** @type {?} */
  3106. var BS_DATEPICKER_VALIDATOR = {
  3107. provide: NG_VALIDATORS,
  3108. /* tslint:disable-next-line: no-use-before-declare */
  3109. useExisting: forwardRef((/**
  3110. * @return {?}
  3111. */
  3112. function () { return BsDatepickerInputDirective; })),
  3113. multi: true
  3114. };
  3115. var BsDatepickerInputDirective = /** @class */ (function () {
  3116. function BsDatepickerInputDirective(_picker, _localeService, _renderer, _elRef, changeDetection) {
  3117. var _this = this;
  3118. this._picker = _picker;
  3119. this._localeService = _localeService;
  3120. this._renderer = _renderer;
  3121. this._elRef = _elRef;
  3122. this.changeDetection = changeDetection;
  3123. this._onChange = Function.prototype;
  3124. this._onTouched = Function.prototype;
  3125. /* tslint:disable-next-line: no-unused-variable */
  3126. this._validatorChange = Function.prototype;
  3127. // update input value on datepicker value update
  3128. this._picker.bsValueChange.subscribe((/**
  3129. * @param {?} value
  3130. * @return {?}
  3131. */
  3132. function (value) {
  3133. _this._setInputValue(value);
  3134. if (_this._value !== value) {
  3135. _this._value = value;
  3136. _this._onChange(value);
  3137. _this._onTouched();
  3138. }
  3139. _this.changeDetection.markForCheck();
  3140. }));
  3141. // update input value on locale change
  3142. this._localeService.localeChange.subscribe((/**
  3143. * @return {?}
  3144. */
  3145. function () {
  3146. _this._setInputValue(_this._value);
  3147. }));
  3148. }
  3149. /**
  3150. * @param {?} value
  3151. * @return {?}
  3152. */
  3153. BsDatepickerInputDirective.prototype._setInputValue = /**
  3154. * @param {?} value
  3155. * @return {?}
  3156. */
  3157. function (value) {
  3158. /** @type {?} */
  3159. var initialDate = !value ? ''
  3160. : formatDate(value, this._picker._config.dateInputFormat, this._localeService.currentLocale);
  3161. this._renderer.setProperty(this._elRef.nativeElement, 'value', initialDate);
  3162. };
  3163. /**
  3164. * @param {?} event
  3165. * @return {?}
  3166. */
  3167. BsDatepickerInputDirective.prototype.onChange = /**
  3168. * @param {?} event
  3169. * @return {?}
  3170. */
  3171. function (event) {
  3172. /* tslint:disable-next-line: no-any*/
  3173. this.writeValue(((/** @type {?} */ (event.target))).value);
  3174. this._onChange(this._value);
  3175. this._onTouched();
  3176. };
  3177. /**
  3178. * @param {?} c
  3179. * @return {?}
  3180. */
  3181. BsDatepickerInputDirective.prototype.validate = /**
  3182. * @param {?} c
  3183. * @return {?}
  3184. */
  3185. function (c) {
  3186. /** @type {?} */
  3187. var _value = c.value;
  3188. /* tslint:disable-next-line: prefer-switch */
  3189. if (_value === null || _value === undefined || _value === '') {
  3190. return null;
  3191. }
  3192. if (isDate(_value)) {
  3193. /** @type {?} */
  3194. var _isDateValid = isDateValid(_value);
  3195. if (!_isDateValid) {
  3196. return { bsDate: { invalid: _value } };
  3197. }
  3198. if (this._picker && this._picker.minDate && isBefore(_value, this._picker.minDate, 'date')) {
  3199. return { bsDate: { minDate: this._picker.minDate } };
  3200. }
  3201. if (this._picker && this._picker.maxDate && isAfter(_value, this._picker.maxDate, 'date')) {
  3202. return { bsDate: { maxDate: this._picker.maxDate } };
  3203. }
  3204. }
  3205. };
  3206. /**
  3207. * @param {?} fn
  3208. * @return {?}
  3209. */
  3210. BsDatepickerInputDirective.prototype.registerOnValidatorChange = /**
  3211. * @param {?} fn
  3212. * @return {?}
  3213. */
  3214. function (fn) {
  3215. this._validatorChange = fn;
  3216. };
  3217. /**
  3218. * @param {?} value
  3219. * @return {?}
  3220. */
  3221. BsDatepickerInputDirective.prototype.writeValue = /**
  3222. * @param {?} value
  3223. * @return {?}
  3224. */
  3225. function (value) {
  3226. if (!value) {
  3227. this._value = null;
  3228. }
  3229. else {
  3230. /** @type {?} */
  3231. var _localeKey = this._localeService.currentLocale;
  3232. /** @type {?} */
  3233. var _locale = getLocale(_localeKey);
  3234. if (!_locale) {
  3235. throw new Error("Locale \"" + _localeKey + "\" is not defined, please add it with \"defineLocale(...)\"");
  3236. }
  3237. this._value = parseDate(value, this._picker._config.dateInputFormat, this._localeService.currentLocale);
  3238. if (this._picker._config.useUtc) {
  3239. this._value = utcAsLocal(this._value);
  3240. }
  3241. }
  3242. this._picker.bsValue = this._value;
  3243. };
  3244. /**
  3245. * @param {?} isDisabled
  3246. * @return {?}
  3247. */
  3248. BsDatepickerInputDirective.prototype.setDisabledState = /**
  3249. * @param {?} isDisabled
  3250. * @return {?}
  3251. */
  3252. function (isDisabled) {
  3253. this._picker.isDisabled = isDisabled;
  3254. if (isDisabled) {
  3255. this._renderer.setAttribute(this._elRef.nativeElement, 'disabled', 'disabled');
  3256. return;
  3257. }
  3258. this._renderer.removeAttribute(this._elRef.nativeElement, 'disabled');
  3259. };
  3260. /**
  3261. * @param {?} fn
  3262. * @return {?}
  3263. */
  3264. BsDatepickerInputDirective.prototype.registerOnChange = /**
  3265. * @param {?} fn
  3266. * @return {?}
  3267. */
  3268. function (fn) {
  3269. this._onChange = fn;
  3270. };
  3271. /**
  3272. * @param {?} fn
  3273. * @return {?}
  3274. */
  3275. BsDatepickerInputDirective.prototype.registerOnTouched = /**
  3276. * @param {?} fn
  3277. * @return {?}
  3278. */
  3279. function (fn) {
  3280. this._onTouched = fn;
  3281. };
  3282. /**
  3283. * @return {?}
  3284. */
  3285. BsDatepickerInputDirective.prototype.onBlur = /**
  3286. * @return {?}
  3287. */
  3288. function () {
  3289. this._onTouched();
  3290. };
  3291. /**
  3292. * @return {?}
  3293. */
  3294. BsDatepickerInputDirective.prototype.hide = /**
  3295. * @return {?}
  3296. */
  3297. function () {
  3298. this._picker.hide();
  3299. this._renderer.selectRootElement(this._elRef.nativeElement).blur();
  3300. };
  3301. BsDatepickerInputDirective.decorators = [
  3302. { type: Directive, args: [{
  3303. selector: "input[bsDatepicker]",
  3304. host: {
  3305. '(change)': 'onChange($event)',
  3306. '(keyup.esc)': 'hide()',
  3307. '(blur)': 'onBlur()'
  3308. },
  3309. providers: [BS_DATEPICKER_VALUE_ACCESSOR, BS_DATEPICKER_VALIDATOR]
  3310. },] }
  3311. ];
  3312. /** @nocollapse */
  3313. BsDatepickerInputDirective.ctorParameters = function () { return [
  3314. { type: BsDatepickerDirective, decorators: [{ type: Host }] },
  3315. { type: BsLocaleService },
  3316. { type: Renderer2 },
  3317. { type: ElementRef },
  3318. { type: ChangeDetectorRef }
  3319. ]; };
  3320. return BsDatepickerInputDirective;
  3321. }());
  3322. /**
  3323. * @fileoverview added by tsickle
  3324. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3325. */
  3326. var BsDaterangepickerConfig = /** @class */ (function (_super) {
  3327. __extends(BsDaterangepickerConfig, _super);
  3328. function BsDaterangepickerConfig() {
  3329. var _this = _super !== null && _super.apply(this, arguments) || this;
  3330. // DatepickerRenderOptions
  3331. _this.displayMonths = 2;
  3332. return _this;
  3333. }
  3334. BsDaterangepickerConfig.decorators = [
  3335. { type: Injectable }
  3336. ];
  3337. return BsDaterangepickerConfig;
  3338. }(BsDatepickerConfig));
  3339. /**
  3340. * @fileoverview added by tsickle
  3341. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3342. */
  3343. var BsDaterangepickerDirective = /** @class */ (function () {
  3344. function BsDaterangepickerDirective(_config, _elementRef, _renderer, _viewContainerRef, cis) {
  3345. this._config = _config;
  3346. /**
  3347. * Placement of a daterangepicker. Accepts: "top", "bottom", "left", "right"
  3348. */
  3349. this.placement = 'bottom';
  3350. /**
  3351. * Specifies events that should trigger. Supports a space separated list of
  3352. * event names.
  3353. */
  3354. this.triggers = 'click';
  3355. /**
  3356. * Close daterangepicker on outside click
  3357. */
  3358. this.outsideClick = true;
  3359. /**
  3360. * A selector specifying the element the daterangepicker should be appended to.
  3361. */
  3362. this.container = 'body';
  3363. this.outsideEsc = true;
  3364. /**
  3365. * Emits when daterangepicker value has been changed
  3366. */
  3367. this.bsValueChange = new EventEmitter();
  3368. this._subs = [];
  3369. this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
  3370. Object.assign(this, _config);
  3371. this.onShown = this._datepicker.onShown;
  3372. this.onHidden = this._datepicker.onHidden;
  3373. }
  3374. Object.defineProperty(BsDaterangepickerDirective.prototype, "isOpen", {
  3375. /**
  3376. * Returns whether or not the daterangepicker is currently being shown
  3377. */
  3378. get: /**
  3379. * Returns whether or not the daterangepicker is currently being shown
  3380. * @return {?}
  3381. */
  3382. function () {
  3383. return this._datepicker.isShown;
  3384. },
  3385. set: /**
  3386. * @param {?} value
  3387. * @return {?}
  3388. */
  3389. function (value) {
  3390. if (value) {
  3391. this.show();
  3392. }
  3393. else {
  3394. this.hide();
  3395. }
  3396. },
  3397. enumerable: true,
  3398. configurable: true
  3399. });
  3400. Object.defineProperty(BsDaterangepickerDirective.prototype, "bsValue", {
  3401. /**
  3402. * Initial value of daterangepicker
  3403. */
  3404. set: /**
  3405. * Initial value of daterangepicker
  3406. * @param {?} value
  3407. * @return {?}
  3408. */
  3409. function (value) {
  3410. if (this._bsValue === value) {
  3411. return;
  3412. }
  3413. this._bsValue = value;
  3414. this.bsValueChange.emit(value);
  3415. },
  3416. enumerable: true,
  3417. configurable: true
  3418. });
  3419. /**
  3420. * @return {?}
  3421. */
  3422. BsDaterangepickerDirective.prototype.ngOnInit = /**
  3423. * @return {?}
  3424. */
  3425. function () {
  3426. var _this = this;
  3427. this._datepicker.listen({
  3428. outsideClick: this.outsideClick,
  3429. outsideEsc: this.outsideEsc,
  3430. triggers: this.triggers,
  3431. show: (/**
  3432. * @return {?}
  3433. */
  3434. function () { return _this.show(); })
  3435. });
  3436. this.setConfig();
  3437. };
  3438. /**
  3439. * @param {?} changes
  3440. * @return {?}
  3441. */
  3442. BsDaterangepickerDirective.prototype.ngOnChanges = /**
  3443. * @param {?} changes
  3444. * @return {?}
  3445. */
  3446. function (changes) {
  3447. if (!this._datepickerRef || !this._datepickerRef.instance) {
  3448. return;
  3449. }
  3450. if (changes.minDate) {
  3451. this._datepickerRef.instance.minDate = this.minDate;
  3452. }
  3453. if (changes.maxDate) {
  3454. this._datepickerRef.instance.maxDate = this.maxDate;
  3455. }
  3456. if (changes.datesDisabled) {
  3457. this._datepickerRef.instance.datesDisabled = this.datesDisabled;
  3458. }
  3459. if (changes.isDisabled) {
  3460. this._datepickerRef.instance.isDisabled = this.isDisabled;
  3461. }
  3462. if (changes.dateCustomClasses) {
  3463. this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
  3464. }
  3465. };
  3466. /**
  3467. * Opens an element’s datepicker. This is considered a “manual” triggering of
  3468. * the datepicker.
  3469. */
  3470. /**
  3471. * Opens an element’s datepicker. This is considered a “manual” triggering of
  3472. * the datepicker.
  3473. * @return {?}
  3474. */
  3475. BsDaterangepickerDirective.prototype.show = /**
  3476. * Opens an element’s datepicker. This is considered a “manual” triggering of
  3477. * the datepicker.
  3478. * @return {?}
  3479. */
  3480. function () {
  3481. var _this = this;
  3482. if (this._datepicker.isShown) {
  3483. return;
  3484. }
  3485. this.setConfig();
  3486. this._datepickerRef = this._datepicker
  3487. .provide({ provide: BsDatepickerConfig, useValue: this._config })
  3488. .attach(BsDaterangepickerContainerComponent)
  3489. .to(this.container)
  3490. .position({ attachment: this.placement })
  3491. .show({ placement: this.placement });
  3492. // if date changes from external source (model -> view)
  3493. this._subs.push(this.bsValueChange.subscribe((/**
  3494. * @param {?} value
  3495. * @return {?}
  3496. */
  3497. function (value) {
  3498. _this._datepickerRef.instance.value = value;
  3499. })));
  3500. // if date changes from picker (view -> model)
  3501. this._subs.push(this._datepickerRef.instance.valueChange
  3502. .pipe(filter((/**
  3503. * @param {?} range
  3504. * @return {?}
  3505. */
  3506. function (range) { return range && range[0] && !!range[1]; })))
  3507. .subscribe((/**
  3508. * @param {?} value
  3509. * @return {?}
  3510. */
  3511. function (value) {
  3512. _this.bsValue = value;
  3513. _this.hide();
  3514. })));
  3515. };
  3516. /**
  3517. * Set config for daterangepicker
  3518. */
  3519. /**
  3520. * Set config for daterangepicker
  3521. * @return {?}
  3522. */
  3523. BsDaterangepickerDirective.prototype.setConfig = /**
  3524. * Set config for daterangepicker
  3525. * @return {?}
  3526. */
  3527. function () {
  3528. this._config = Object.assign({}, this._config, this.bsConfig, {
  3529. value: this._bsValue,
  3530. isDisabled: this.isDisabled,
  3531. minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
  3532. maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
  3533. dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
  3534. datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled
  3535. });
  3536. };
  3537. /**
  3538. * Closes an element’s datepicker. This is considered a “manual” triggering of
  3539. * the datepicker.
  3540. */
  3541. /**
  3542. * Closes an element’s datepicker. This is considered a “manual” triggering of
  3543. * the datepicker.
  3544. * @return {?}
  3545. */
  3546. BsDaterangepickerDirective.prototype.hide = /**
  3547. * Closes an element’s datepicker. This is considered a “manual” triggering of
  3548. * the datepicker.
  3549. * @return {?}
  3550. */
  3551. function () {
  3552. var e_1, _a;
  3553. if (this.isOpen) {
  3554. this._datepicker.hide();
  3555. }
  3556. try {
  3557. for (var _b = __values(this._subs), _c = _b.next(); !_c.done; _c = _b.next()) {
  3558. var sub = _c.value;
  3559. sub.unsubscribe();
  3560. }
  3561. }
  3562. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  3563. finally {
  3564. try {
  3565. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  3566. }
  3567. finally { if (e_1) throw e_1.error; }
  3568. }
  3569. };
  3570. /**
  3571. * Toggles an element’s datepicker. This is considered a “manual” triggering
  3572. * of the datepicker.
  3573. */
  3574. /**
  3575. * Toggles an element’s datepicker. This is considered a “manual” triggering
  3576. * of the datepicker.
  3577. * @return {?}
  3578. */
  3579. BsDaterangepickerDirective.prototype.toggle = /**
  3580. * Toggles an element’s datepicker. This is considered a “manual” triggering
  3581. * of the datepicker.
  3582. * @return {?}
  3583. */
  3584. function () {
  3585. if (this.isOpen) {
  3586. return this.hide();
  3587. }
  3588. this.show();
  3589. };
  3590. /**
  3591. * @return {?}
  3592. */
  3593. BsDaterangepickerDirective.prototype.ngOnDestroy = /**
  3594. * @return {?}
  3595. */
  3596. function () {
  3597. this._datepicker.dispose();
  3598. };
  3599. BsDaterangepickerDirective.decorators = [
  3600. { type: Directive, args: [{
  3601. selector: '[bsDaterangepicker]',
  3602. exportAs: 'bsDaterangepicker'
  3603. },] }
  3604. ];
  3605. /** @nocollapse */
  3606. BsDaterangepickerDirective.ctorParameters = function () { return [
  3607. { type: BsDaterangepickerConfig },
  3608. { type: ElementRef },
  3609. { type: Renderer2 },
  3610. { type: ViewContainerRef },
  3611. { type: ComponentLoaderFactory }
  3612. ]; };
  3613. BsDaterangepickerDirective.propDecorators = {
  3614. placement: [{ type: Input }],
  3615. triggers: [{ type: Input }],
  3616. outsideClick: [{ type: Input }],
  3617. container: [{ type: Input }],
  3618. outsideEsc: [{ type: Input }],
  3619. isOpen: [{ type: Input }],
  3620. onShown: [{ type: Output }],
  3621. onHidden: [{ type: Output }],
  3622. bsValue: [{ type: Input }],
  3623. bsConfig: [{ type: Input }],
  3624. isDisabled: [{ type: Input }],
  3625. minDate: [{ type: Input }],
  3626. maxDate: [{ type: Input }],
  3627. dateCustomClasses: [{ type: Input }],
  3628. datesDisabled: [{ type: Input }],
  3629. bsValueChange: [{ type: Output }]
  3630. };
  3631. return BsDaterangepickerDirective;
  3632. }());
  3633. /**
  3634. * @fileoverview added by tsickle
  3635. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3636. */
  3637. /** @type {?} */
  3638. var BS_DATERANGEPICKER_VALUE_ACCESSOR = {
  3639. provide: NG_VALUE_ACCESSOR,
  3640. /* tslint:disable-next-line: no-use-before-declare */
  3641. useExisting: forwardRef((/**
  3642. * @return {?}
  3643. */
  3644. function () { return BsDaterangepickerInputDirective; })),
  3645. multi: true
  3646. };
  3647. /** @type {?} */
  3648. var BS_DATERANGEPICKER_VALIDATOR = {
  3649. provide: NG_VALIDATORS,
  3650. /* tslint:disable-next-line: no-use-before-declare */
  3651. useExisting: forwardRef((/**
  3652. * @return {?}
  3653. */
  3654. function () { return BsDaterangepickerInputDirective; })),
  3655. multi: true
  3656. };
  3657. var BsDaterangepickerInputDirective = /** @class */ (function () {
  3658. function BsDaterangepickerInputDirective(_picker, _localeService, _renderer, _elRef, changeDetection) {
  3659. var _this = this;
  3660. this._picker = _picker;
  3661. this._localeService = _localeService;
  3662. this._renderer = _renderer;
  3663. this._elRef = _elRef;
  3664. this.changeDetection = changeDetection;
  3665. this._onChange = Function.prototype;
  3666. this._onTouched = Function.prototype;
  3667. /* tslint:disable-next-line: no-unused-variable */
  3668. this._validatorChange = Function.prototype;
  3669. // update input value on datepicker value update
  3670. this._picker.bsValueChange.subscribe((/**
  3671. * @param {?} value
  3672. * @return {?}
  3673. */
  3674. function (value) {
  3675. _this._setInputValue(value);
  3676. if (_this._value !== value) {
  3677. _this._value = value;
  3678. _this._onChange(value);
  3679. _this._onTouched();
  3680. }
  3681. _this.changeDetection.markForCheck();
  3682. }));
  3683. // update input value on locale change
  3684. this._localeService.localeChange.subscribe((/**
  3685. * @return {?}
  3686. */
  3687. function () {
  3688. _this._setInputValue(_this._value);
  3689. }));
  3690. }
  3691. /**
  3692. * @param {?} date
  3693. * @return {?}
  3694. */
  3695. BsDaterangepickerInputDirective.prototype._setInputValue = /**
  3696. * @param {?} date
  3697. * @return {?}
  3698. */
  3699. function (date) {
  3700. /** @type {?} */
  3701. var range = '';
  3702. if (date) {
  3703. /** @type {?} */
  3704. var start = !date[0] ? ''
  3705. : formatDate(date[0], this._picker._config.rangeInputFormat, this._localeService.currentLocale);
  3706. /** @type {?} */
  3707. var end = !date[1] ? ''
  3708. : formatDate(date[1], this._picker._config.rangeInputFormat, this._localeService.currentLocale);
  3709. range = (start && end) ? start + this._picker._config.rangeSeparator + end : '';
  3710. }
  3711. this._renderer.setProperty(this._elRef.nativeElement, 'value', range);
  3712. };
  3713. /**
  3714. * @param {?} event
  3715. * @return {?}
  3716. */
  3717. BsDaterangepickerInputDirective.prototype.onChange = /**
  3718. * @param {?} event
  3719. * @return {?}
  3720. */
  3721. function (event) {
  3722. /* tslint:disable-next-line: no-any*/
  3723. this.writeValue(((/** @type {?} */ (event.target))).value);
  3724. this._onChange(this._value);
  3725. this._onTouched();
  3726. };
  3727. /**
  3728. * @param {?} c
  3729. * @return {?}
  3730. */
  3731. BsDaterangepickerInputDirective.prototype.validate = /**
  3732. * @param {?} c
  3733. * @return {?}
  3734. */
  3735. function (c) {
  3736. /** @type {?} */
  3737. var _value = c.value;
  3738. if (_value === null || _value === undefined || !isArray(_value)) {
  3739. return null;
  3740. }
  3741. /** @type {?} */
  3742. var _isFirstDateValid = isDateValid(_value[0]);
  3743. /** @type {?} */
  3744. var _isSecondDateValid = isDateValid(_value[1]);
  3745. if (!_isFirstDateValid) {
  3746. return { bsDate: { invalid: _value[0] } };
  3747. }
  3748. if (!_isSecondDateValid) {
  3749. return { bsDate: { invalid: _value[1] } };
  3750. }
  3751. if (this._picker && this._picker.minDate && isBefore(_value[0], this._picker.minDate, 'date')) {
  3752. return { bsDate: { minDate: this._picker.minDate } };
  3753. }
  3754. if (this._picker && this._picker.maxDate && isAfter(_value[1], this._picker.maxDate, 'date')) {
  3755. return { bsDate: { maxDate: this._picker.maxDate } };
  3756. }
  3757. };
  3758. /**
  3759. * @param {?} fn
  3760. * @return {?}
  3761. */
  3762. BsDaterangepickerInputDirective.prototype.registerOnValidatorChange = /**
  3763. * @param {?} fn
  3764. * @return {?}
  3765. */
  3766. function (fn) {
  3767. this._validatorChange = fn;
  3768. };
  3769. /**
  3770. * @param {?} value
  3771. * @return {?}
  3772. */
  3773. BsDaterangepickerInputDirective.prototype.writeValue = /**
  3774. * @param {?} value
  3775. * @return {?}
  3776. */
  3777. function (value) {
  3778. var _this = this;
  3779. if (!value) {
  3780. this._value = null;
  3781. }
  3782. else {
  3783. /** @type {?} */
  3784. var _localeKey = this._localeService.currentLocale;
  3785. /** @type {?} */
  3786. var _locale = getLocale(_localeKey);
  3787. if (!_locale) {
  3788. throw new Error("Locale \"" + _localeKey + "\" is not defined, please add it with \"defineLocale(...)\"");
  3789. }
  3790. /** @type {?} */
  3791. var _input = [];
  3792. if (typeof value === 'string') {
  3793. _input = value.split(this._picker._config.rangeSeparator);
  3794. }
  3795. if (Array.isArray(value)) {
  3796. _input = value;
  3797. }
  3798. this._value = ((/** @type {?} */ (_input)))
  3799. .map((/**
  3800. * @param {?} _val
  3801. * @return {?}
  3802. */
  3803. function (_val) {
  3804. if (_this._picker._config.useUtc) {
  3805. return utcAsLocal(parseDate(_val, _this._picker._config.dateInputFormat, _this._localeService.currentLocale));
  3806. }
  3807. return parseDate(_val, _this._picker._config.dateInputFormat, _this._localeService.currentLocale);
  3808. }))
  3809. .map((/**
  3810. * @param {?} date
  3811. * @return {?}
  3812. */
  3813. function (date) { return (isNaN(date.valueOf()) ? null : date); }));
  3814. }
  3815. this._picker.bsValue = this._value;
  3816. };
  3817. /**
  3818. * @param {?} isDisabled
  3819. * @return {?}
  3820. */
  3821. BsDaterangepickerInputDirective.prototype.setDisabledState = /**
  3822. * @param {?} isDisabled
  3823. * @return {?}
  3824. */
  3825. function (isDisabled) {
  3826. this._picker.isDisabled = isDisabled;
  3827. if (isDisabled) {
  3828. this._renderer.setAttribute(this._elRef.nativeElement, 'disabled', 'disabled');
  3829. return;
  3830. }
  3831. this._renderer.removeAttribute(this._elRef.nativeElement, 'disabled');
  3832. };
  3833. /* tslint:disable-next-line: no-any*/
  3834. /* tslint:disable-next-line: no-any*/
  3835. /**
  3836. * @param {?} fn
  3837. * @return {?}
  3838. */
  3839. BsDaterangepickerInputDirective.prototype.registerOnChange = /* tslint:disable-next-line: no-any*/
  3840. /**
  3841. * @param {?} fn
  3842. * @return {?}
  3843. */
  3844. function (fn) {
  3845. this._onChange = fn;
  3846. };
  3847. /* tslint:disable-next-line: no-any*/
  3848. /* tslint:disable-next-line: no-any*/
  3849. /**
  3850. * @param {?} fn
  3851. * @return {?}
  3852. */
  3853. BsDaterangepickerInputDirective.prototype.registerOnTouched = /* tslint:disable-next-line: no-any*/
  3854. /**
  3855. * @param {?} fn
  3856. * @return {?}
  3857. */
  3858. function (fn) {
  3859. this._onTouched = fn;
  3860. };
  3861. /**
  3862. * @return {?}
  3863. */
  3864. BsDaterangepickerInputDirective.prototype.onBlur = /**
  3865. * @return {?}
  3866. */
  3867. function () {
  3868. this._onTouched();
  3869. };
  3870. /**
  3871. * @return {?}
  3872. */
  3873. BsDaterangepickerInputDirective.prototype.hide = /**
  3874. * @return {?}
  3875. */
  3876. function () {
  3877. this._picker.hide();
  3878. this._renderer.selectRootElement(this._elRef.nativeElement).blur();
  3879. };
  3880. BsDaterangepickerInputDirective.decorators = [
  3881. { type: Directive, args: [{
  3882. selector: "input[bsDaterangepicker]",
  3883. host: {
  3884. '(change)': 'onChange($event)',
  3885. '(keyup.esc)': 'hide()',
  3886. '(blur)': 'onBlur()'
  3887. },
  3888. providers: [BS_DATERANGEPICKER_VALUE_ACCESSOR, BS_DATERANGEPICKER_VALIDATOR]
  3889. },] }
  3890. ];
  3891. /** @nocollapse */
  3892. BsDaterangepickerInputDirective.ctorParameters = function () { return [
  3893. { type: BsDaterangepickerDirective, decorators: [{ type: Host }] },
  3894. { type: BsLocaleService },
  3895. { type: Renderer2 },
  3896. { type: ElementRef },
  3897. { type: ChangeDetectorRef }
  3898. ]; };
  3899. return BsDaterangepickerInputDirective;
  3900. }());
  3901. /**
  3902. * @fileoverview added by tsickle
  3903. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3904. */
  3905. var BsCalendarLayoutComponent = /** @class */ (function () {
  3906. function BsCalendarLayoutComponent() {
  3907. }
  3908. BsCalendarLayoutComponent.decorators = [
  3909. { type: Component, args: [{
  3910. selector: 'bs-calendar-layout',
  3911. template: "\n <!-- current date, will be added in nearest releases -->\n <bs-current-date title=\"hey there\" *ngIf=\"false\"></bs-current-date>\n\n <!--navigation-->\n <div class=\"bs-datepicker-head\">\n <ng-content select=\"bs-datepicker-navigation-view\"></ng-content>\n </div>\n\n <div class=\"bs-datepicker-body\">\n <ng-content></ng-content>\n </div>\n\n <!--timepicker-->\n <bs-timepicker *ngIf=\"false\"></bs-timepicker>\n "
  3912. }] }
  3913. ];
  3914. return BsCalendarLayoutComponent;
  3915. }());
  3916. /**
  3917. * @fileoverview added by tsickle
  3918. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3919. */
  3920. var BsCurrentDateViewComponent = /** @class */ (function () {
  3921. function BsCurrentDateViewComponent() {
  3922. }
  3923. BsCurrentDateViewComponent.decorators = [
  3924. { type: Component, args: [{
  3925. selector: 'bs-current-date',
  3926. template: "<div class=\"current-timedate\"><span>{{ title }}</span></div>"
  3927. }] }
  3928. ];
  3929. BsCurrentDateViewComponent.propDecorators = {
  3930. title: [{ type: Input }]
  3931. };
  3932. return BsCurrentDateViewComponent;
  3933. }());
  3934. /**
  3935. * @fileoverview added by tsickle
  3936. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3937. */
  3938. var BsCustomDatesViewComponent = /** @class */ (function () {
  3939. function BsCustomDatesViewComponent() {
  3940. }
  3941. BsCustomDatesViewComponent.decorators = [
  3942. { type: Component, args: [{
  3943. selector: 'bs-custom-date-view',
  3944. template: "\n <div class=\"bs-datepicker-predefined-btns\">\n <button *ngFor=\"let range of ranges\" type=\"button\">{{ range.label }}</button>\n <button *ngIf=\"isCustomRangeShown\" type=\"button\">Custom Range</button>\n </div>\n ",
  3945. changeDetection: ChangeDetectionStrategy.OnPush
  3946. }] }
  3947. ];
  3948. BsCustomDatesViewComponent.propDecorators = {
  3949. isCustomRangeShown: [{ type: Input }],
  3950. ranges: [{ type: Input }]
  3951. };
  3952. return BsCustomDatesViewComponent;
  3953. }());
  3954. /**
  3955. * @fileoverview added by tsickle
  3956. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3957. */
  3958. var BsDatepickerDayDecoratorComponent = /** @class */ (function () {
  3959. function BsDatepickerDayDecoratorComponent(_config, _elRef, _renderer) {
  3960. this._config = _config;
  3961. this._elRef = _elRef;
  3962. this._renderer = _renderer;
  3963. }
  3964. /**
  3965. * @return {?}
  3966. */
  3967. BsDatepickerDayDecoratorComponent.prototype.ngOnInit = /**
  3968. * @return {?}
  3969. */
  3970. function () {
  3971. var _this = this;
  3972. if (this.day.isToday && this._config && this._config.customTodayClass) {
  3973. this._renderer.addClass(this._elRef.nativeElement, this._config.customTodayClass);
  3974. }
  3975. if (typeof this.day.customClasses === 'string') {
  3976. this.day.customClasses.split(' ')
  3977. .filter((/**
  3978. * @param {?} className
  3979. * @return {?}
  3980. */
  3981. function (className) { return className; }))
  3982. .forEach((/**
  3983. * @param {?} className
  3984. * @return {?}
  3985. */
  3986. function (className) {
  3987. _this._renderer.addClass(_this._elRef.nativeElement, className);
  3988. }));
  3989. }
  3990. };
  3991. BsDatepickerDayDecoratorComponent.decorators = [
  3992. { type: Component, args: [{
  3993. selector: '[bsDatepickerDayDecorator]',
  3994. changeDetection: ChangeDetectionStrategy.OnPush,
  3995. host: {
  3996. '[class.disabled]': 'day.isDisabled',
  3997. '[class.is-highlighted]': 'day.isHovered',
  3998. '[class.is-other-month]': 'day.isOtherMonth',
  3999. '[class.is-active-other-month]': 'day.isOtherMonthHovered',
  4000. '[class.in-range]': 'day.isInRange',
  4001. '[class.select-start]': 'day.isSelectionStart',
  4002. '[class.select-end]': 'day.isSelectionEnd',
  4003. '[class.selected]': 'day.isSelected'
  4004. },
  4005. template: "{{ day.label }}"
  4006. }] }
  4007. ];
  4008. /** @nocollapse */
  4009. BsDatepickerDayDecoratorComponent.ctorParameters = function () { return [
  4010. { type: BsDatepickerConfig },
  4011. { type: ElementRef },
  4012. { type: Renderer2 }
  4013. ]; };
  4014. BsDatepickerDayDecoratorComponent.propDecorators = {
  4015. day: [{ type: Input }]
  4016. };
  4017. return BsDatepickerDayDecoratorComponent;
  4018. }());
  4019. /**
  4020. * @fileoverview added by tsickle
  4021. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4022. */
  4023. /** @enum {number} */
  4024. var BsNavigationDirection = {
  4025. UP: 0,
  4026. DOWN: 1,
  4027. };
  4028. BsNavigationDirection[BsNavigationDirection.UP] = 'UP';
  4029. BsNavigationDirection[BsNavigationDirection.DOWN] = 'DOWN';
  4030. /**
  4031. * @fileoverview added by tsickle
  4032. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4033. */
  4034. var BsDatepickerNavigationViewComponent = /** @class */ (function () {
  4035. function BsDatepickerNavigationViewComponent() {
  4036. this.onNavigate = new EventEmitter();
  4037. this.onViewMode = new EventEmitter();
  4038. }
  4039. /**
  4040. * @param {?} down
  4041. * @return {?}
  4042. */
  4043. BsDatepickerNavigationViewComponent.prototype.navTo = /**
  4044. * @param {?} down
  4045. * @return {?}
  4046. */
  4047. function (down) {
  4048. this.onNavigate.emit(down ? BsNavigationDirection.DOWN : BsNavigationDirection.UP);
  4049. };
  4050. /**
  4051. * @param {?} viewMode
  4052. * @return {?}
  4053. */
  4054. BsDatepickerNavigationViewComponent.prototype.view = /**
  4055. * @param {?} viewMode
  4056. * @return {?}
  4057. */
  4058. function (viewMode) {
  4059. this.onViewMode.emit(viewMode);
  4060. };
  4061. BsDatepickerNavigationViewComponent.decorators = [
  4062. { type: Component, args: [{
  4063. selector: 'bs-datepicker-navigation-view',
  4064. changeDetection: ChangeDetectionStrategy.OnPush,
  4065. template: "\n <button class=\"previous\"\n [disabled]=\"calendar.disableLeftArrow\"\n [style.visibility]=\"calendar.hideLeftArrow ? 'hidden' : 'visible'\"\n type=\"button\"\n (click)=\"navTo(true)\">\n <span>&lsaquo;</span>\n </button>\n\n &#8203; <!-- zero-width space needed for correct alignement\n with preserveWhitespaces: false in Angular -->\n\n <button class=\"current\"\n *ngIf=\"calendar.monthTitle\"\n type=\"button\"\n (click)=\"view('month')\">\n <span>{{ calendar.monthTitle }}</span>\n </button>\n\n &#8203; <!-- zero-width space needed for correct alignement\n with preserveWhitespaces: false in Angular -->\n\n <button class=\"current\" (click)=\"view('year')\" type=\"button\">\n <span>{{ calendar.yearTitle }}</span>\n </button>\n\n &#8203; <!-- zero-width space needed for correct alignement\n with preserveWhitespaces: false in Angular -->\n\n <button class=\"next\"\n [disabled]=\"calendar.disableRightArrow\"\n [style.visibility]=\"calendar.hideRightArrow ? 'hidden' : 'visible'\"\n type=\"button\"\n (click)=\"navTo(false)\"><span>&rsaquo;</span>\n </button>\n "
  4066. }] }
  4067. ];
  4068. BsDatepickerNavigationViewComponent.propDecorators = {
  4069. calendar: [{ type: Input }],
  4070. onNavigate: [{ type: Output }],
  4071. onViewMode: [{ type: Output }]
  4072. };
  4073. return BsDatepickerNavigationViewComponent;
  4074. }());
  4075. /**
  4076. * @fileoverview added by tsickle
  4077. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4078. */
  4079. var BsDaysCalendarViewComponent = /** @class */ (function () {
  4080. function BsDaysCalendarViewComponent(_config) {
  4081. this._config = _config;
  4082. this.onNavigate = new EventEmitter();
  4083. this.onViewMode = new EventEmitter();
  4084. this.onSelect = new EventEmitter();
  4085. this.onHover = new EventEmitter();
  4086. this.onHoverWeek = new EventEmitter();
  4087. }
  4088. /**
  4089. * @param {?} event
  4090. * @return {?}
  4091. */
  4092. BsDaysCalendarViewComponent.prototype.navigateTo = /**
  4093. * @param {?} event
  4094. * @return {?}
  4095. */
  4096. function (event) {
  4097. /** @type {?} */
  4098. var step = BsNavigationDirection.DOWN === event ? -1 : 1;
  4099. this.onNavigate.emit({ step: { month: step } });
  4100. };
  4101. /**
  4102. * @param {?} event
  4103. * @return {?}
  4104. */
  4105. BsDaysCalendarViewComponent.prototype.changeViewMode = /**
  4106. * @param {?} event
  4107. * @return {?}
  4108. */
  4109. function (event) {
  4110. this.onViewMode.emit(event);
  4111. };
  4112. /**
  4113. * @param {?} event
  4114. * @return {?}
  4115. */
  4116. BsDaysCalendarViewComponent.prototype.selectDay = /**
  4117. * @param {?} event
  4118. * @return {?}
  4119. */
  4120. function (event) {
  4121. this.onSelect.emit(event);
  4122. };
  4123. /**
  4124. * @param {?} week
  4125. * @return {?}
  4126. */
  4127. BsDaysCalendarViewComponent.prototype.selectWeek = /**
  4128. * @param {?} week
  4129. * @return {?}
  4130. */
  4131. function (week) {
  4132. var _this = this;
  4133. if (!this._config.selectWeek) {
  4134. return;
  4135. }
  4136. if (week.days
  4137. && week.days[0]
  4138. && !week.days[0].isDisabled
  4139. && this._config.selectFromOtherMonth) {
  4140. this.onSelect.emit(week.days[0]);
  4141. return;
  4142. }
  4143. if (week.days.length === 0) {
  4144. return;
  4145. }
  4146. /** @type {?} */
  4147. var selectedDay = week.days.find((/**
  4148. * @param {?} day
  4149. * @return {?}
  4150. */
  4151. function (day) {
  4152. return _this._config.selectFromOtherMonth
  4153. ? !day.isDisabled
  4154. : !day.isOtherMonth && !day.isDisabled;
  4155. }));
  4156. this.onSelect.emit(selectedDay);
  4157. };
  4158. /**
  4159. * @param {?} cell
  4160. * @param {?} isHovered
  4161. * @return {?}
  4162. */
  4163. BsDaysCalendarViewComponent.prototype.weekHoverHandler = /**
  4164. * @param {?} cell
  4165. * @param {?} isHovered
  4166. * @return {?}
  4167. */
  4168. function (cell, isHovered) {
  4169. var _this = this;
  4170. if (!this._config.selectWeek) {
  4171. return;
  4172. }
  4173. /** @type {?} */
  4174. var hasActiveDays = cell.days.find((/**
  4175. * @param {?} day
  4176. * @return {?}
  4177. */
  4178. function (day) {
  4179. return _this._config.selectFromOtherMonth
  4180. ? !day.isDisabled
  4181. : !day.isOtherMonth && !day.isDisabled;
  4182. }));
  4183. if (hasActiveDays) {
  4184. cell.isHovered = isHovered;
  4185. this.isWeekHovered = isHovered;
  4186. this.onHoverWeek.emit(cell);
  4187. }
  4188. };
  4189. /**
  4190. * @param {?} cell
  4191. * @param {?} isHovered
  4192. * @return {?}
  4193. */
  4194. BsDaysCalendarViewComponent.prototype.hoverDay = /**
  4195. * @param {?} cell
  4196. * @param {?} isHovered
  4197. * @return {?}
  4198. */
  4199. function (cell, isHovered) {
  4200. if (this._config.selectFromOtherMonth && cell.isOtherMonth) {
  4201. cell.isOtherMonthHovered = isHovered;
  4202. }
  4203. this.onHover.emit({ cell: cell, isHovered: isHovered });
  4204. };
  4205. BsDaysCalendarViewComponent.decorators = [
  4206. { type: Component, args: [{
  4207. selector: 'bs-days-calendar-view',
  4208. // changeDetection: ChangeDetectionStrategy.OnPush,
  4209. template: "\n <bs-calendar-layout>\n <bs-datepicker-navigation-view\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"changeViewMode($event)\"\n ></bs-datepicker-navigation-view>\n\n <!--days matrix-->\n <table role=\"grid\" class=\"days weeks\">\n <thead>\n <tr>\n <!--if show weeks-->\n <th *ngIf=\"options.showWeekNumbers\"></th>\n <th *ngFor=\"let weekday of calendar.weekdays; let i = index\"\n aria-label=\"weekday\">{{ calendar.weekdays[i] }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let week of calendar.weeks; let i = index\">\n <td class=\"week\" [class.active-week]=\"isWeekHovered\" *ngIf=\"options.showWeekNumbers\">\n <span\n (click)=\"selectWeek(week)\"\n (mouseenter)=\"weekHoverHandler(week, true)\"\n (mouseleave)=\"weekHoverHandler(week, false)\">{{ calendar.weekNumbers[i] }}</span>\n </td>\n <td *ngFor=\"let day of week.days\" role=\"gridcell\">\n <span bsDatepickerDayDecorator\n [day]=\"day\"\n (click)=\"selectDay(day)\"\n (mouseenter)=\"hoverDay(day, true)\"\n (mouseleave)=\"hoverDay(day, false)\">{{ day.label }}</span>\n </td>\n </tr>\n </tbody>\n </table>\n\n </bs-calendar-layout>\n "
  4210. }] }
  4211. ];
  4212. /** @nocollapse */
  4213. BsDaysCalendarViewComponent.ctorParameters = function () { return [
  4214. { type: BsDatepickerConfig }
  4215. ]; };
  4216. BsDaysCalendarViewComponent.propDecorators = {
  4217. calendar: [{ type: Input }],
  4218. options: [{ type: Input }],
  4219. onNavigate: [{ type: Output }],
  4220. onViewMode: [{ type: Output }],
  4221. onSelect: [{ type: Output }],
  4222. onHover: [{ type: Output }],
  4223. onHoverWeek: [{ type: Output }]
  4224. };
  4225. return BsDaysCalendarViewComponent;
  4226. }());
  4227. /**
  4228. * @fileoverview added by tsickle
  4229. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4230. */
  4231. var BsMonthCalendarViewComponent = /** @class */ (function () {
  4232. function BsMonthCalendarViewComponent() {
  4233. this.onNavigate = new EventEmitter();
  4234. this.onViewMode = new EventEmitter();
  4235. this.onSelect = new EventEmitter();
  4236. this.onHover = new EventEmitter();
  4237. }
  4238. /**
  4239. * @param {?} event
  4240. * @return {?}
  4241. */
  4242. BsMonthCalendarViewComponent.prototype.navigateTo = /**
  4243. * @param {?} event
  4244. * @return {?}
  4245. */
  4246. function (event) {
  4247. /** @type {?} */
  4248. var step = BsNavigationDirection.DOWN === event ? -1 : 1;
  4249. this.onNavigate.emit({ step: { year: step } });
  4250. };
  4251. /**
  4252. * @param {?} month
  4253. * @return {?}
  4254. */
  4255. BsMonthCalendarViewComponent.prototype.viewMonth = /**
  4256. * @param {?} month
  4257. * @return {?}
  4258. */
  4259. function (month) {
  4260. this.onSelect.emit(month);
  4261. };
  4262. /**
  4263. * @param {?} cell
  4264. * @param {?} isHovered
  4265. * @return {?}
  4266. */
  4267. BsMonthCalendarViewComponent.prototype.hoverMonth = /**
  4268. * @param {?} cell
  4269. * @param {?} isHovered
  4270. * @return {?}
  4271. */
  4272. function (cell, isHovered) {
  4273. this.onHover.emit({ cell: cell, isHovered: isHovered });
  4274. };
  4275. /**
  4276. * @param {?} event
  4277. * @return {?}
  4278. */
  4279. BsMonthCalendarViewComponent.prototype.changeViewMode = /**
  4280. * @param {?} event
  4281. * @return {?}
  4282. */
  4283. function (event) {
  4284. this.onViewMode.emit(event);
  4285. };
  4286. BsMonthCalendarViewComponent.decorators = [
  4287. { type: Component, args: [{
  4288. selector: 'bs-month-calendar-view',
  4289. template: "\n <bs-calendar-layout>\n <bs-datepicker-navigation-view\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"changeViewMode($event)\"\n ></bs-datepicker-navigation-view>\n\n <table role=\"grid\" class=\"months\">\n <tbody>\n <tr *ngFor=\"let row of calendar.months\">\n <td *ngFor=\"let month of row\" role=\"gridcell\"\n (click)=\"viewMonth(month)\"\n (mouseenter)=\"hoverMonth(month, true)\"\n (mouseleave)=\"hoverMonth(month, false)\"\n [class.disabled]=\"month.isDisabled\"\n [class.is-highlighted]=\"month.isHovered\">\n <span [class.selected]=\"month.isSelected\">{{ month.label }}</span>\n </td>\n </tr>\n </tbody>\n </table>\n </bs-calendar-layout>\n "
  4290. }] }
  4291. ];
  4292. BsMonthCalendarViewComponent.propDecorators = {
  4293. calendar: [{ type: Input }],
  4294. onNavigate: [{ type: Output }],
  4295. onViewMode: [{ type: Output }],
  4296. onSelect: [{ type: Output }],
  4297. onHover: [{ type: Output }]
  4298. };
  4299. return BsMonthCalendarViewComponent;
  4300. }());
  4301. /**
  4302. * @fileoverview added by tsickle
  4303. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4304. */
  4305. var BsTimepickerViewComponent = /** @class */ (function () {
  4306. function BsTimepickerViewComponent() {
  4307. this.ampm = 'ok';
  4308. this.hours = 0;
  4309. this.minutes = 0;
  4310. }
  4311. BsTimepickerViewComponent.decorators = [
  4312. { type: Component, args: [{
  4313. selector: 'bs-timepicker',
  4314. template: "\n <div class=\"bs-timepicker-container\">\n <div class=\"bs-timepicker-controls\">\n <button class=\"bs-decrease\" type=\"button\">-</button>\n <input type=\"text\" [value]=\"hours\" placeholder=\"00\">\n <button class=\"bs-increase\" type=\"button\">+</button>\n </div>\n <div class=\"bs-timepicker-controls\">\n <button class=\"bs-decrease\" type=\"button\">-</button>\n <input type=\"text\" [value]=\"minutes\" placeholder=\"00\">\n <button class=\"bs-increase\" type=\"button\">+</button>\n </div>\n <button class=\"switch-time-format\" type=\"button\">{{ ampm }}\n <img\n src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAABi8KSDAAABSElEQVQYV3XQPUvDUBQG4HNuagtVqc6KgouCv6GIuIntYBLB9hcIQpLStCAIV7DYmpTcRWcXqZio3Vwc/UCc/QEqfgyKGbr0I7nS1EiHeqYzPO/h5SD0jaxUZjmSLCB+OFb+UFINFwASAEAdpu9gaGXVyAHHFQBkHpKHc6a9dzECvADyY9sqlAMsK9W0jzxDXqeytr3mhQckxSji27TJJ5/rPmIpwJJq3HrtduriYOurv1a4i1p5HnhkG9OFymi0ReoO05cGwb+ayv4dysVygjeFmsP05f8wpZQ8fsdvfmuY9zjWSNqUtgYFVnOVReILYoBFzdQI5/GGFzNHhGbeZnopDGU29sZbscgldmC99w35VOATTycIMMcBXIfpSVGzZhA6C8hh00conln6VQ9TGgV32OEAKQC4DrBq7CJwd0ggR7Vq/rPrfgB+C3sGypY5DAAAAABJRU5ErkJggg==\"\n alt=\"\">\n </button>\n </div>\n "
  4315. }] }
  4316. ];
  4317. return BsTimepickerViewComponent;
  4318. }());
  4319. /**
  4320. * @fileoverview added by tsickle
  4321. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4322. */
  4323. var BsYearsCalendarViewComponent = /** @class */ (function () {
  4324. function BsYearsCalendarViewComponent() {
  4325. this.onNavigate = new EventEmitter();
  4326. this.onViewMode = new EventEmitter();
  4327. this.onSelect = new EventEmitter();
  4328. this.onHover = new EventEmitter();
  4329. }
  4330. /**
  4331. * @param {?} event
  4332. * @return {?}
  4333. */
  4334. BsYearsCalendarViewComponent.prototype.navigateTo = /**
  4335. * @param {?} event
  4336. * @return {?}
  4337. */
  4338. function (event) {
  4339. /** @type {?} */
  4340. var step = BsNavigationDirection.DOWN === event ? -1 : 1;
  4341. this.onNavigate.emit({ step: { year: step * yearsPerCalendar } });
  4342. };
  4343. /**
  4344. * @param {?} year
  4345. * @return {?}
  4346. */
  4347. BsYearsCalendarViewComponent.prototype.viewYear = /**
  4348. * @param {?} year
  4349. * @return {?}
  4350. */
  4351. function (year) {
  4352. this.onSelect.emit(year);
  4353. };
  4354. /**
  4355. * @param {?} cell
  4356. * @param {?} isHovered
  4357. * @return {?}
  4358. */
  4359. BsYearsCalendarViewComponent.prototype.hoverYear = /**
  4360. * @param {?} cell
  4361. * @param {?} isHovered
  4362. * @return {?}
  4363. */
  4364. function (cell, isHovered) {
  4365. this.onHover.emit({ cell: cell, isHovered: isHovered });
  4366. };
  4367. /**
  4368. * @param {?} event
  4369. * @return {?}
  4370. */
  4371. BsYearsCalendarViewComponent.prototype.changeViewMode = /**
  4372. * @param {?} event
  4373. * @return {?}
  4374. */
  4375. function (event) {
  4376. this.onViewMode.emit(event);
  4377. };
  4378. BsYearsCalendarViewComponent.decorators = [
  4379. { type: Component, args: [{
  4380. selector: 'bs-years-calendar-view',
  4381. template: "\n <bs-calendar-layout>\n <bs-datepicker-navigation-view\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"changeViewMode($event)\"\n ></bs-datepicker-navigation-view>\n\n <table role=\"grid\" class=\"years\">\n <tbody>\n <tr *ngFor=\"let row of calendar.years\">\n <td *ngFor=\"let year of row\" role=\"gridcell\"\n (click)=\"viewYear(year)\"\n (mouseenter)=\"hoverYear(year, true)\"\n (mouseleave)=\"hoverYear(year, false)\"\n [class.disabled]=\"year.isDisabled\"\n [class.is-highlighted]=\"year.isHovered\">\n <span [class.selected]=\"year.isSelected\">{{ year.label }}</span>\n </td>\n </tr>\n </tbody>\n </table>\n </bs-calendar-layout>\n "
  4382. }] }
  4383. ];
  4384. BsYearsCalendarViewComponent.propDecorators = {
  4385. calendar: [{ type: Input }],
  4386. onNavigate: [{ type: Output }],
  4387. onViewMode: [{ type: Output }],
  4388. onSelect: [{ type: Output }],
  4389. onHover: [{ type: Output }]
  4390. };
  4391. return BsYearsCalendarViewComponent;
  4392. }());
  4393. /**
  4394. * @fileoverview added by tsickle
  4395. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4396. */
  4397. /** @type {?} */
  4398. var _exports = [
  4399. BsDatepickerContainerComponent,
  4400. BsDatepickerDirective,
  4401. BsDatepickerInlineContainerComponent,
  4402. BsDatepickerInlineDirective,
  4403. BsDatepickerInputDirective,
  4404. BsDaterangepickerContainerComponent,
  4405. BsDaterangepickerDirective,
  4406. BsDaterangepickerInlineContainerComponent,
  4407. BsDaterangepickerInlineDirective,
  4408. BsDaterangepickerInputDirective
  4409. ];
  4410. var BsDatepickerModule = /** @class */ (function () {
  4411. function BsDatepickerModule() {
  4412. }
  4413. /**
  4414. * @return {?}
  4415. */
  4416. BsDatepickerModule.forRoot = /**
  4417. * @return {?}
  4418. */
  4419. function () {
  4420. return {
  4421. ngModule: BsDatepickerModule,
  4422. providers: [
  4423. ComponentLoaderFactory,
  4424. PositioningService,
  4425. BsDatepickerStore,
  4426. BsDatepickerActions,
  4427. BsDatepickerConfig,
  4428. BsDaterangepickerConfig,
  4429. BsDatepickerInlineConfig,
  4430. BsDaterangepickerInlineConfig,
  4431. BsDatepickerEffects,
  4432. BsLocaleService
  4433. ]
  4434. };
  4435. };
  4436. BsDatepickerModule.decorators = [
  4437. { type: NgModule, args: [{
  4438. imports: [CommonModule],
  4439. declarations: __spread([
  4440. BsCalendarLayoutComponent,
  4441. BsCurrentDateViewComponent,
  4442. BsCustomDatesViewComponent,
  4443. BsDatepickerDayDecoratorComponent,
  4444. BsDatepickerNavigationViewComponent,
  4445. BsDaysCalendarViewComponent,
  4446. BsMonthCalendarViewComponent,
  4447. BsTimepickerViewComponent,
  4448. BsYearsCalendarViewComponent
  4449. ], _exports),
  4450. entryComponents: [
  4451. BsDatepickerContainerComponent,
  4452. BsDaterangepickerContainerComponent,
  4453. BsDatepickerInlineContainerComponent,
  4454. BsDaterangepickerInlineContainerComponent
  4455. ],
  4456. exports: _exports
  4457. },] }
  4458. ];
  4459. return BsDatepickerModule;
  4460. }());
  4461. /**
  4462. * @fileoverview added by tsickle
  4463. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4464. */
  4465. var DateFormatter = /** @class */ (function () {
  4466. function DateFormatter() {
  4467. }
  4468. /**
  4469. * @param {?} date
  4470. * @param {?} format
  4471. * @param {?} locale
  4472. * @return {?}
  4473. */
  4474. DateFormatter.prototype.format = /**
  4475. * @param {?} date
  4476. * @param {?} format
  4477. * @param {?} locale
  4478. * @return {?}
  4479. */
  4480. function (date, format, locale) {
  4481. return formatDate(date, format, locale);
  4482. };
  4483. return DateFormatter;
  4484. }());
  4485. /**
  4486. * @fileoverview added by tsickle
  4487. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4488. */
  4489. var DatePickerInnerComponent = /** @class */ (function () {
  4490. function DatePickerInnerComponent() {
  4491. this.selectionDone = new EventEmitter(undefined);
  4492. this.update = new EventEmitter(false);
  4493. this.activeDateChange = new EventEmitter(undefined);
  4494. /* tslint:disable-next-line: no-any*/
  4495. this.stepDay = {};
  4496. /* tslint:disable-next-line: no-any*/
  4497. this.stepMonth = {};
  4498. /* tslint:disable-next-line: no-any*/
  4499. this.stepYear = {};
  4500. this.modes = ['day', 'month', 'year'];
  4501. this.dateFormatter = new DateFormatter();
  4502. }
  4503. Object.defineProperty(DatePickerInnerComponent.prototype, "activeDate", {
  4504. get: /**
  4505. * @return {?}
  4506. */
  4507. function () {
  4508. return this._activeDate;
  4509. },
  4510. set: /**
  4511. * @param {?} value
  4512. * @return {?}
  4513. */
  4514. function (value) {
  4515. this._activeDate = value;
  4516. },
  4517. enumerable: true,
  4518. configurable: true
  4519. });
  4520. // todo: add formatter value to Date object
  4521. // todo: add formatter value to Date object
  4522. /**
  4523. * @return {?}
  4524. */
  4525. DatePickerInnerComponent.prototype.ngOnInit =
  4526. // todo: add formatter value to Date object
  4527. /**
  4528. * @return {?}
  4529. */
  4530. function () {
  4531. // todo: use date for unique value
  4532. this.uniqueId = "datepicker--" + Math.floor(Math.random() * 10000);
  4533. if (this.initDate) {
  4534. this.activeDate = this.initDate;
  4535. this.selectedDate = new Date(this.activeDate.valueOf());
  4536. this.update.emit(this.activeDate);
  4537. }
  4538. else if (this.activeDate === undefined) {
  4539. this.activeDate = new Date();
  4540. }
  4541. };
  4542. // this.refreshView should be called here to reflect the changes on the fly
  4543. // tslint:disable-next-line:no-unused-variable
  4544. // this.refreshView should be called here to reflect the changes on the fly
  4545. // tslint:disable-next-line:no-unused-variable
  4546. /**
  4547. * @param {?} changes
  4548. * @return {?}
  4549. */
  4550. DatePickerInnerComponent.prototype.ngOnChanges =
  4551. // this.refreshView should be called here to reflect the changes on the fly
  4552. // tslint:disable-next-line:no-unused-variable
  4553. /**
  4554. * @param {?} changes
  4555. * @return {?}
  4556. */
  4557. function (changes) {
  4558. this.refreshView();
  4559. this.checkIfActiveDateGotUpdated(changes.activeDate);
  4560. };
  4561. // Check if activeDate has been update and then emit the activeDateChange with the new date
  4562. /* tslint:disable-next-line: no-any */
  4563. // Check if activeDate has been update and then emit the activeDateChange with the new date
  4564. /* tslint:disable-next-line: no-any */
  4565. /**
  4566. * @param {?} activeDate
  4567. * @return {?}
  4568. */
  4569. DatePickerInnerComponent.prototype.checkIfActiveDateGotUpdated =
  4570. // Check if activeDate has been update and then emit the activeDateChange with the new date
  4571. /* tslint:disable-next-line: no-any */
  4572. /**
  4573. * @param {?} activeDate
  4574. * @return {?}
  4575. */
  4576. function (activeDate) {
  4577. if (activeDate && !activeDate.firstChange) {
  4578. /** @type {?} */
  4579. var previousValue = activeDate.previousValue;
  4580. if (previousValue &&
  4581. previousValue instanceof Date &&
  4582. previousValue.getTime() !== activeDate.currentValue.getTime()) {
  4583. this.activeDateChange.emit(this.activeDate);
  4584. }
  4585. }
  4586. };
  4587. /**
  4588. * @param {?} handler
  4589. * @param {?} type
  4590. * @return {?}
  4591. */
  4592. DatePickerInnerComponent.prototype.setCompareHandler = /**
  4593. * @param {?} handler
  4594. * @param {?} type
  4595. * @return {?}
  4596. */
  4597. function (handler, type) {
  4598. if (type === 'day') {
  4599. this.compareHandlerDay = handler;
  4600. }
  4601. if (type === 'month') {
  4602. this.compareHandlerMonth = handler;
  4603. }
  4604. if (type === 'year') {
  4605. this.compareHandlerYear = handler;
  4606. }
  4607. };
  4608. /**
  4609. * @param {?} date1
  4610. * @param {?} date2
  4611. * @return {?}
  4612. */
  4613. DatePickerInnerComponent.prototype.compare = /**
  4614. * @param {?} date1
  4615. * @param {?} date2
  4616. * @return {?}
  4617. */
  4618. function (date1, date2) {
  4619. if (date1 === undefined || date2 === undefined) {
  4620. return undefined;
  4621. }
  4622. if (this.datepickerMode === 'day' && this.compareHandlerDay) {
  4623. return this.compareHandlerDay(date1, date2);
  4624. }
  4625. if (this.datepickerMode === 'month' && this.compareHandlerMonth) {
  4626. return this.compareHandlerMonth(date1, date2);
  4627. }
  4628. if (this.datepickerMode === 'year' && this.compareHandlerYear) {
  4629. return this.compareHandlerYear(date1, date2);
  4630. }
  4631. return void 0;
  4632. };
  4633. /**
  4634. * @param {?} handler
  4635. * @param {?} type
  4636. * @return {?}
  4637. */
  4638. DatePickerInnerComponent.prototype.setRefreshViewHandler = /**
  4639. * @param {?} handler
  4640. * @param {?} type
  4641. * @return {?}
  4642. */
  4643. function (handler, type) {
  4644. if (type === 'day') {
  4645. this.refreshViewHandlerDay = handler;
  4646. }
  4647. if (type === 'month') {
  4648. this.refreshViewHandlerMonth = handler;
  4649. }
  4650. if (type === 'year') {
  4651. this.refreshViewHandlerYear = handler;
  4652. }
  4653. };
  4654. /**
  4655. * @return {?}
  4656. */
  4657. DatePickerInnerComponent.prototype.refreshView = /**
  4658. * @return {?}
  4659. */
  4660. function () {
  4661. if (this.datepickerMode === 'day' && this.refreshViewHandlerDay) {
  4662. this.refreshViewHandlerDay();
  4663. }
  4664. if (this.datepickerMode === 'month' && this.refreshViewHandlerMonth) {
  4665. this.refreshViewHandlerMonth();
  4666. }
  4667. if (this.datepickerMode === 'year' && this.refreshViewHandlerYear) {
  4668. this.refreshViewHandlerYear();
  4669. }
  4670. };
  4671. /**
  4672. * @param {?} date
  4673. * @param {?} format
  4674. * @return {?}
  4675. */
  4676. DatePickerInnerComponent.prototype.dateFilter = /**
  4677. * @param {?} date
  4678. * @param {?} format
  4679. * @return {?}
  4680. */
  4681. function (date, format) {
  4682. return this.dateFormatter.format(date, format, this.locale);
  4683. };
  4684. /* tslint:disable-next-line: no-any*/
  4685. /* tslint:disable-next-line: no-any*/
  4686. /**
  4687. * @param {?} dateObject
  4688. * @return {?}
  4689. */
  4690. DatePickerInnerComponent.prototype.isActive = /* tslint:disable-next-line: no-any*/
  4691. /**
  4692. * @param {?} dateObject
  4693. * @return {?}
  4694. */
  4695. function (dateObject) {
  4696. if (this.compare(dateObject.date, this.activeDate) === 0) {
  4697. this.activeDateId = dateObject.uid;
  4698. return true;
  4699. }
  4700. return false;
  4701. };
  4702. /* tslint:disable-next-line: no-any*/
  4703. /* tslint:disable-next-line: no-any*/
  4704. /**
  4705. * @param {?} date
  4706. * @param {?} format
  4707. * @return {?}
  4708. */
  4709. DatePickerInnerComponent.prototype.createDateObject = /* tslint:disable-next-line: no-any*/
  4710. /**
  4711. * @param {?} date
  4712. * @param {?} format
  4713. * @return {?}
  4714. */
  4715. function (date, format) {
  4716. /* tslint:disable-next-line: no-any*/
  4717. /** @type {?} */
  4718. var dateObject = {};
  4719. dateObject.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
  4720. dateObject.date = this.fixTimeZone(dateObject.date);
  4721. dateObject.label = this.dateFilter(date, format);
  4722. dateObject.selected = this.compare(date, this.selectedDate) === 0;
  4723. dateObject.disabled = this.isDisabled(date);
  4724. dateObject.current = this.compare(date, new Date()) === 0;
  4725. dateObject.customClass = this.getCustomClassForDate(dateObject.date);
  4726. return dateObject;
  4727. };
  4728. /* tslint:disable-next-line: no-any*/
  4729. /* tslint:disable-next-line: no-any*/
  4730. /**
  4731. * @param {?} arr
  4732. * @param {?} size
  4733. * @return {?}
  4734. */
  4735. DatePickerInnerComponent.prototype.split = /* tslint:disable-next-line: no-any*/
  4736. /**
  4737. * @param {?} arr
  4738. * @param {?} size
  4739. * @return {?}
  4740. */
  4741. function (arr, size) {
  4742. /* tslint:disable-next-line: no-any*/
  4743. /** @type {?} */
  4744. var arrays = [];
  4745. while (arr.length > 0) {
  4746. arrays.push(arr.splice(0, size));
  4747. }
  4748. return arrays;
  4749. };
  4750. // Fix a hard-reproducible bug with timezones
  4751. // The bug depends on OS, browser, current timezone and current date
  4752. // i.e.
  4753. // var date = new Date(2014, 0, 1);
  4754. // console.log(date.getFullYear(), date.getMonth(), date.getDate(),
  4755. // date.getHours()); can result in "2013 11 31 23" because of the bug.
  4756. // Fix a hard-reproducible bug with timezones
  4757. // The bug depends on OS, browser, current timezone and current date
  4758. // i.e.
  4759. // var date = new Date(2014, 0, 1);
  4760. // console.log(date.getFullYear(), date.getMonth(), date.getDate(),
  4761. // date.getHours()); can result in "2013 11 31 23" because of the bug.
  4762. /**
  4763. * @param {?} date
  4764. * @return {?}
  4765. */
  4766. DatePickerInnerComponent.prototype.fixTimeZone =
  4767. // Fix a hard-reproducible bug with timezones
  4768. // The bug depends on OS, browser, current timezone and current date
  4769. // i.e.
  4770. // var date = new Date(2014, 0, 1);
  4771. // console.log(date.getFullYear(), date.getMonth(), date.getDate(),
  4772. // date.getHours()); can result in "2013 11 31 23" because of the bug.
  4773. /**
  4774. * @param {?} date
  4775. * @return {?}
  4776. */
  4777. function (date) {
  4778. /** @type {?} */
  4779. var hours = date.getHours();
  4780. return new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours === 23 ? hours + 2 : 0);
  4781. };
  4782. /**
  4783. * @param {?} date
  4784. * @param {?=} isManual
  4785. * @return {?}
  4786. */
  4787. DatePickerInnerComponent.prototype.select = /**
  4788. * @param {?} date
  4789. * @param {?=} isManual
  4790. * @return {?}
  4791. */
  4792. function (date, isManual) {
  4793. if (isManual === void 0) { isManual = true; }
  4794. if (this.datepickerMode === this.minMode) {
  4795. if (!this.activeDate) {
  4796. this.activeDate = new Date(0, 0, 0, 0, 0, 0, 0);
  4797. }
  4798. this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
  4799. this.activeDate = this.fixTimeZone(this.activeDate);
  4800. if (isManual) {
  4801. this.selectionDone.emit(this.activeDate);
  4802. }
  4803. }
  4804. else {
  4805. this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
  4806. this.activeDate = this.fixTimeZone(this.activeDate);
  4807. if (isManual) {
  4808. this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1];
  4809. }
  4810. }
  4811. this.selectedDate = new Date(this.activeDate.valueOf());
  4812. this.update.emit(this.activeDate);
  4813. this.refreshView();
  4814. };
  4815. /**
  4816. * @param {?} direction
  4817. * @return {?}
  4818. */
  4819. DatePickerInnerComponent.prototype.move = /**
  4820. * @param {?} direction
  4821. * @return {?}
  4822. */
  4823. function (direction) {
  4824. /* tslint:disable-next-line: no-any*/
  4825. /** @type {?} */
  4826. var expectedStep;
  4827. if (this.datepickerMode === 'day') {
  4828. expectedStep = this.stepDay;
  4829. }
  4830. if (this.datepickerMode === 'month') {
  4831. expectedStep = this.stepMonth;
  4832. }
  4833. if (this.datepickerMode === 'year') {
  4834. expectedStep = this.stepYear;
  4835. }
  4836. if (expectedStep) {
  4837. /** @type {?} */
  4838. var year = this.activeDate.getFullYear() + direction * (expectedStep.years || 0);
  4839. /** @type {?} */
  4840. var month = this.activeDate.getMonth() + direction * (expectedStep.months || 0);
  4841. this.activeDate = new Date(year, month, 1);
  4842. this.refreshView();
  4843. this.activeDateChange.emit(this.activeDate);
  4844. }
  4845. };
  4846. /**
  4847. * @param {?} _direction
  4848. * @return {?}
  4849. */
  4850. DatePickerInnerComponent.prototype.toggleMode = /**
  4851. * @param {?} _direction
  4852. * @return {?}
  4853. */
  4854. function (_direction) {
  4855. /** @type {?} */
  4856. var direction = _direction || 1;
  4857. if ((this.datepickerMode === this.maxMode && direction === 1) ||
  4858. (this.datepickerMode === this.minMode && direction === -1)) {
  4859. return;
  4860. }
  4861. this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) + direction];
  4862. this.refreshView();
  4863. };
  4864. /**
  4865. * @protected
  4866. * @param {?} date
  4867. * @return {?}
  4868. */
  4869. DatePickerInnerComponent.prototype.getCustomClassForDate = /**
  4870. * @protected
  4871. * @param {?} date
  4872. * @return {?}
  4873. */
  4874. function (date) {
  4875. var _this = this;
  4876. if (!this.customClass) {
  4877. return '';
  4878. }
  4879. // todo: build a hash of custom classes, it will work faster
  4880. /** @type {?} */
  4881. var customClassObject = this.customClass.find((/**
  4882. * @param {?} customClass
  4883. * @return {?}
  4884. */
  4885. function (customClass) {
  4886. return (customClass.date.valueOf() === date.valueOf() &&
  4887. customClass.mode === _this.datepickerMode);
  4888. }), this);
  4889. return customClassObject === undefined ? '' : customClassObject.clazz;
  4890. };
  4891. /**
  4892. * @protected
  4893. * @param {?} date1Disabled
  4894. * @param {?} date2
  4895. * @return {?}
  4896. */
  4897. DatePickerInnerComponent.prototype.compareDateDisabled = /**
  4898. * @protected
  4899. * @param {?} date1Disabled
  4900. * @param {?} date2
  4901. * @return {?}
  4902. */
  4903. function (date1Disabled, date2) {
  4904. if (date1Disabled === undefined || date2 === undefined) {
  4905. return undefined;
  4906. }
  4907. if (date1Disabled.mode === 'day' && this.compareHandlerDay) {
  4908. return this.compareHandlerDay(date1Disabled.date, date2);
  4909. }
  4910. if (date1Disabled.mode === 'month' && this.compareHandlerMonth) {
  4911. return this.compareHandlerMonth(date1Disabled.date, date2);
  4912. }
  4913. if (date1Disabled.mode === 'year' && this.compareHandlerYear) {
  4914. return this.compareHandlerYear(date1Disabled.date, date2);
  4915. }
  4916. return undefined;
  4917. };
  4918. /**
  4919. * @protected
  4920. * @param {?} date
  4921. * @return {?}
  4922. */
  4923. DatePickerInnerComponent.prototype.isDisabled = /**
  4924. * @protected
  4925. * @param {?} date
  4926. * @return {?}
  4927. */
  4928. function (date) {
  4929. var _this = this;
  4930. /** @type {?} */
  4931. var isDateDisabled = false;
  4932. if (this.dateDisabled) {
  4933. this.dateDisabled.forEach((/**
  4934. * @param {?} disabledDate
  4935. * @return {?}
  4936. */
  4937. function (disabledDate) {
  4938. if (_this.compareDateDisabled(disabledDate, date) === 0) {
  4939. isDateDisabled = true;
  4940. }
  4941. }));
  4942. }
  4943. if (this.dayDisabled) {
  4944. isDateDisabled =
  4945. isDateDisabled ||
  4946. this.dayDisabled.indexOf(date.getDay()) > -1;
  4947. }
  4948. return (isDateDisabled ||
  4949. (this.minDate && this.compare(date, this.minDate) < 0) ||
  4950. (this.maxDate && this.compare(date, this.maxDate) > 0));
  4951. };
  4952. DatePickerInnerComponent.decorators = [
  4953. { type: Component, args: [{
  4954. selector: 'datepicker-inner',
  4955. template: "\n <!--&lt;!&ndash;ng-keydown=\"keydown($event)\"&ndash;&gt;-->\n <div *ngIf=\"datepickerMode\" class=\"well well-sm bg-faded p-a card\" role=\"application\" >\n <ng-content></ng-content>\n </div>\n "
  4956. }] }
  4957. ];
  4958. DatePickerInnerComponent.propDecorators = {
  4959. locale: [{ type: Input }],
  4960. datepickerMode: [{ type: Input }],
  4961. startingDay: [{ type: Input }],
  4962. yearRange: [{ type: Input }],
  4963. minDate: [{ type: Input }],
  4964. maxDate: [{ type: Input }],
  4965. minMode: [{ type: Input }],
  4966. maxMode: [{ type: Input }],
  4967. showWeeks: [{ type: Input }],
  4968. formatDay: [{ type: Input }],
  4969. formatMonth: [{ type: Input }],
  4970. formatYear: [{ type: Input }],
  4971. formatDayHeader: [{ type: Input }],
  4972. formatDayTitle: [{ type: Input }],
  4973. formatMonthTitle: [{ type: Input }],
  4974. onlyCurrentMonth: [{ type: Input }],
  4975. shortcutPropagation: [{ type: Input }],
  4976. customClass: [{ type: Input }],
  4977. monthColLimit: [{ type: Input }],
  4978. yearColLimit: [{ type: Input }],
  4979. dateDisabled: [{ type: Input }],
  4980. dayDisabled: [{ type: Input }],
  4981. initDate: [{ type: Input }],
  4982. selectionDone: [{ type: Output }],
  4983. update: [{ type: Output }],
  4984. activeDateChange: [{ type: Output }],
  4985. activeDate: [{ type: Input }]
  4986. };
  4987. return DatePickerInnerComponent;
  4988. }());
  4989. /**
  4990. * @fileoverview added by tsickle
  4991. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4992. */
  4993. var DatepickerConfig = /** @class */ (function () {
  4994. function DatepickerConfig() {
  4995. this.locale = 'en';
  4996. this.datepickerMode = 'day';
  4997. this.startingDay = 0;
  4998. this.yearRange = 20;
  4999. this.minMode = 'day';
  5000. this.maxMode = 'year';
  5001. this.showWeeks = true;
  5002. this.formatDay = 'DD';
  5003. this.formatMonth = 'MMMM';
  5004. this.formatYear = 'YYYY';
  5005. this.formatDayHeader = 'dd';
  5006. this.formatDayTitle = 'MMMM YYYY';
  5007. this.formatMonthTitle = 'YYYY';
  5008. this.onlyCurrentMonth = false;
  5009. this.monthColLimit = 3;
  5010. this.yearColLimit = 5;
  5011. this.shortcutPropagation = false;
  5012. }
  5013. DatepickerConfig.decorators = [
  5014. { type: Injectable }
  5015. ];
  5016. return DatepickerConfig;
  5017. }());
  5018. /**
  5019. * @fileoverview added by tsickle
  5020. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5021. */
  5022. /** @type {?} */
  5023. var DATEPICKER_CONTROL_VALUE_ACCESSOR = {
  5024. provide: NG_VALUE_ACCESSOR,
  5025. /* tslint:disable-next-line: no-use-before-declare */
  5026. useExisting: forwardRef((/**
  5027. * @return {?}
  5028. */
  5029. function () { return DatePickerComponent; })),
  5030. multi: true
  5031. };
  5032. /* tslint:disable:component-selector-name component-selector-type */
  5033. var DatePickerComponent = /** @class */ (function () {
  5034. function DatePickerComponent(config) {
  5035. /**
  5036. * sets datepicker mode, supports: `day`, `month`, `year`
  5037. */
  5038. this.datepickerMode = 'day';
  5039. /**
  5040. * if false week numbers will be hidden
  5041. */
  5042. this.showWeeks = true;
  5043. this.selectionDone = new EventEmitter(undefined);
  5044. /**
  5045. * callback to invoke when the activeDate is changed.
  5046. */
  5047. this.activeDateChange = new EventEmitter(undefined);
  5048. /* tslint:disable-next-line: no-any*/
  5049. this.onChange = Function.prototype;
  5050. /* tslint:disable-next-line: no-any*/
  5051. this.onTouched = Function.prototype;
  5052. this._now = new Date();
  5053. this.config = config;
  5054. this.configureOptions();
  5055. }
  5056. Object.defineProperty(DatePickerComponent.prototype, "activeDate", {
  5057. /** currently active date */
  5058. get: /**
  5059. * currently active date
  5060. * @return {?}
  5061. */
  5062. function () {
  5063. return this._activeDate || this._now;
  5064. },
  5065. set: /**
  5066. * @param {?} value
  5067. * @return {?}
  5068. */
  5069. function (value) {
  5070. this._activeDate = value;
  5071. },
  5072. enumerable: true,
  5073. configurable: true
  5074. });
  5075. /**
  5076. * @return {?}
  5077. */
  5078. DatePickerComponent.prototype.configureOptions = /**
  5079. * @return {?}
  5080. */
  5081. function () {
  5082. Object.assign(this, this.config);
  5083. };
  5084. /**
  5085. * @param {?} event
  5086. * @return {?}
  5087. */
  5088. DatePickerComponent.prototype.onUpdate = /**
  5089. * @param {?} event
  5090. * @return {?}
  5091. */
  5092. function (event) {
  5093. this.activeDate = event;
  5094. this.onChange(event);
  5095. };
  5096. /**
  5097. * @param {?} event
  5098. * @return {?}
  5099. */
  5100. DatePickerComponent.prototype.onSelectionDone = /**
  5101. * @param {?} event
  5102. * @return {?}
  5103. */
  5104. function (event) {
  5105. this.selectionDone.emit(event);
  5106. };
  5107. /**
  5108. * @param {?} event
  5109. * @return {?}
  5110. */
  5111. DatePickerComponent.prototype.onActiveDateChange = /**
  5112. * @param {?} event
  5113. * @return {?}
  5114. */
  5115. function (event) {
  5116. this.activeDateChange.emit(event);
  5117. };
  5118. // todo: support null value
  5119. /* tslint:disable-next-line: no-any*/
  5120. // todo: support null value
  5121. /* tslint:disable-next-line: no-any*/
  5122. /**
  5123. * @param {?} value
  5124. * @return {?}
  5125. */
  5126. DatePickerComponent.prototype.writeValue =
  5127. // todo: support null value
  5128. /* tslint:disable-next-line: no-any*/
  5129. /**
  5130. * @param {?} value
  5131. * @return {?}
  5132. */
  5133. function (value) {
  5134. if (this._datePicker.compare(value, this._activeDate) === 0) {
  5135. return;
  5136. }
  5137. if (value && value instanceof Date) {
  5138. this.activeDate = value;
  5139. this._datePicker.select(value, false);
  5140. return;
  5141. }
  5142. this.activeDate = value ? new Date(value) : void 0;
  5143. };
  5144. /**
  5145. * @param {?} fn
  5146. * @return {?}
  5147. */
  5148. DatePickerComponent.prototype.registerOnChange = /**
  5149. * @param {?} fn
  5150. * @return {?}
  5151. */
  5152. function (fn) {
  5153. this.onChange = fn;
  5154. };
  5155. /**
  5156. * @param {?} fn
  5157. * @return {?}
  5158. */
  5159. DatePickerComponent.prototype.registerOnTouched = /**
  5160. * @param {?} fn
  5161. * @return {?}
  5162. */
  5163. function (fn) {
  5164. this.onTouched = fn;
  5165. };
  5166. DatePickerComponent.decorators = [
  5167. { type: Component, args: [{
  5168. selector: 'datepicker',
  5169. template: "\n <datepicker-inner [activeDate]=\"activeDate\"\n (update)=\"onUpdate($event)\"\n [locale]=\"config.locale\"\n [datepickerMode]=\"datepickerMode\"\n [initDate]=\"initDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [minMode]=\"minMode\"\n [maxMode]=\"maxMode\"\n [showWeeks]=\"showWeeks\"\n [formatDay]=\"formatDay\"\n [formatMonth]=\"formatMonth\"\n [formatYear]=\"formatYear\"\n [formatDayHeader]=\"formatDayHeader\"\n [formatDayTitle]=\"formatDayTitle\"\n [formatMonthTitle]=\"formatMonthTitle\"\n [startingDay]=\"startingDay\"\n [yearRange]=\"yearRange\"\n [customClass]=\"customClass\"\n [dateDisabled]=\"dateDisabled\"\n [dayDisabled]=\"dayDisabled\"\n [onlyCurrentMonth]=\"onlyCurrentMonth\"\n [shortcutPropagation]=\"shortcutPropagation\"\n [monthColLimit]=\"monthColLimit\"\n [yearColLimit]=\"yearColLimit\"\n (selectionDone)=\"onSelectionDone($event)\"\n (activeDateChange)=\"onActiveDateChange($event)\">\n <daypicker tabindex=\"0\"></daypicker>\n <monthpicker tabindex=\"0\"></monthpicker>\n <yearpicker tabindex=\"0\"></yearpicker>\n </datepicker-inner>\n ",
  5170. providers: [DATEPICKER_CONTROL_VALUE_ACCESSOR]
  5171. }] }
  5172. ];
  5173. /** @nocollapse */
  5174. DatePickerComponent.ctorParameters = function () { return [
  5175. { type: DatepickerConfig }
  5176. ]; };
  5177. DatePickerComponent.propDecorators = {
  5178. datepickerMode: [{ type: Input }],
  5179. initDate: [{ type: Input }],
  5180. minDate: [{ type: Input }],
  5181. maxDate: [{ type: Input }],
  5182. minMode: [{ type: Input }],
  5183. maxMode: [{ type: Input }],
  5184. showWeeks: [{ type: Input }],
  5185. formatDay: [{ type: Input }],
  5186. formatMonth: [{ type: Input }],
  5187. formatYear: [{ type: Input }],
  5188. formatDayHeader: [{ type: Input }],
  5189. formatDayTitle: [{ type: Input }],
  5190. formatMonthTitle: [{ type: Input }],
  5191. startingDay: [{ type: Input }],
  5192. yearRange: [{ type: Input }],
  5193. onlyCurrentMonth: [{ type: Input }],
  5194. shortcutPropagation: [{ type: Input }],
  5195. monthColLimit: [{ type: Input }],
  5196. yearColLimit: [{ type: Input }],
  5197. customClass: [{ type: Input }],
  5198. dateDisabled: [{ type: Input }],
  5199. dayDisabled: [{ type: Input }],
  5200. activeDate: [{ type: Input }],
  5201. selectionDone: [{ type: Output }],
  5202. activeDateChange: [{ type: Output }],
  5203. _datePicker: [{ type: ViewChild, args: [DatePickerInnerComponent, { static: true },] }]
  5204. };
  5205. return DatePickerComponent;
  5206. }());
  5207. /**
  5208. * @fileoverview added by tsickle
  5209. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5210. */
  5211. var DayPickerComponent = /** @class */ (function () {
  5212. function DayPickerComponent(datePicker) {
  5213. this.labels = [];
  5214. this.rows = [];
  5215. this.weekNumbers = [];
  5216. this.datePicker = datePicker;
  5217. }
  5218. Object.defineProperty(DayPickerComponent.prototype, "isBs4", {
  5219. get: /**
  5220. * @return {?}
  5221. */
  5222. function () {
  5223. return !isBs3();
  5224. },
  5225. enumerable: true,
  5226. configurable: true
  5227. });
  5228. /*protected getDaysInMonth(year:number, month:number) {
  5229. return ((month === 1) && (year % 4 === 0) &&
  5230. ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
  5231. }*/
  5232. /*protected getDaysInMonth(year:number, month:number) {
  5233. return ((month === 1) && (year % 4 === 0) &&
  5234. ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
  5235. }*/
  5236. /**
  5237. * @return {?}
  5238. */
  5239. DayPickerComponent.prototype.ngOnInit = /*protected getDaysInMonth(year:number, month:number) {
  5240. return ((month === 1) && (year % 4 === 0) &&
  5241. ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
  5242. }*/
  5243. /**
  5244. * @return {?}
  5245. */
  5246. function () {
  5247. /** @type {?} */
  5248. var self = this;
  5249. this.datePicker.stepDay = { months: 1 };
  5250. this.datePicker.setRefreshViewHandler((/**
  5251. * @return {?}
  5252. */
  5253. function () {
  5254. /** @type {?} */
  5255. var year = this.activeDate.getFullYear();
  5256. /** @type {?} */
  5257. var month = this.activeDate.getMonth();
  5258. /** @type {?} */
  5259. var firstDayOfMonth = new Date(year, month, 1);
  5260. /** @type {?} */
  5261. var difference = this.startingDay - firstDayOfMonth.getDay();
  5262. /** @type {?} */
  5263. var numDisplayedFromPreviousMonth = difference > 0 ? 7 - difference : -difference;
  5264. /** @type {?} */
  5265. var firstDate = new Date(firstDayOfMonth.getTime());
  5266. if (numDisplayedFromPreviousMonth > 0) {
  5267. firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
  5268. }
  5269. // 42 is the number of days on a six-week calendar
  5270. /** @type {?} */
  5271. var _days = self.getDates(firstDate, 42);
  5272. /** @type {?} */
  5273. var days = [];
  5274. for (var i = 0; i < 42; i++) {
  5275. /** @type {?} */
  5276. var _dateObject = this.createDateObject(_days[i], this.formatDay);
  5277. _dateObject.secondary = _days[i].getMonth() !== month;
  5278. _dateObject.uid = this.uniqueId + '-' + i;
  5279. days[i] = _dateObject;
  5280. }
  5281. self.labels = [];
  5282. for (var j = 0; j < 7; j++) {
  5283. self.labels[j] = {};
  5284. self.labels[j].abbr = this.dateFilter(days[j].date, this.formatDayHeader);
  5285. self.labels[j].full = this.dateFilter(days[j].date, 'EEEE');
  5286. }
  5287. self.title = this.dateFilter(this.activeDate, this.formatDayTitle);
  5288. self.rows = this.split(days, 7);
  5289. if (this.showWeeks) {
  5290. self.weekNumbers = [];
  5291. /** @type {?} */
  5292. var thursdayIndex = (4 + 7 - this.startingDay) % 7;
  5293. /** @type {?} */
  5294. var numWeeks = self.rows.length;
  5295. for (var curWeek = 0; curWeek < numWeeks; curWeek++) {
  5296. self.weekNumbers.push(self.getISO8601WeekNumber(self.rows[curWeek][thursdayIndex].date));
  5297. }
  5298. }
  5299. }), 'day');
  5300. this.datePicker.setCompareHandler((/**
  5301. * @param {?} date1
  5302. * @param {?} date2
  5303. * @return {?}
  5304. */
  5305. function (date1, date2) {
  5306. /** @type {?} */
  5307. var d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
  5308. /** @type {?} */
  5309. var d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
  5310. return d1.getTime() - d2.getTime();
  5311. }), 'day');
  5312. this.datePicker.refreshView();
  5313. };
  5314. /**
  5315. * @protected
  5316. * @param {?} startDate
  5317. * @param {?} n
  5318. * @return {?}
  5319. */
  5320. DayPickerComponent.prototype.getDates = /**
  5321. * @protected
  5322. * @param {?} startDate
  5323. * @param {?} n
  5324. * @return {?}
  5325. */
  5326. function (startDate, n) {
  5327. /** @type {?} */
  5328. var dates = new Array(n);
  5329. /** @type {?} */
  5330. var current = new Date(startDate.getTime());
  5331. /** @type {?} */
  5332. var i = 0;
  5333. /** @type {?} */
  5334. var date;
  5335. while (i < n) {
  5336. date = new Date(current.getTime());
  5337. date = this.datePicker.fixTimeZone(date);
  5338. dates[i++] = date;
  5339. current = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
  5340. }
  5341. return dates;
  5342. };
  5343. /**
  5344. * @protected
  5345. * @param {?} date
  5346. * @return {?}
  5347. */
  5348. DayPickerComponent.prototype.getISO8601WeekNumber = /**
  5349. * @protected
  5350. * @param {?} date
  5351. * @return {?}
  5352. */
  5353. function (date) {
  5354. /** @type {?} */
  5355. var checkDate = new Date(date.getTime());
  5356. // Thursday
  5357. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  5358. /** @type {?} */
  5359. var time = checkDate.getTime();
  5360. // Compare with Jan 1
  5361. checkDate.setMonth(0);
  5362. checkDate.setDate(1);
  5363. return (Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 1);
  5364. };
  5365. DayPickerComponent.decorators = [
  5366. { type: Component, args: [{
  5367. selector: 'daypicker',
  5368. template: "\n<table *ngIf=\"datePicker.datepickerMode === 'day'\" role=\"grid\" [attr.aria-labelledby]=\"datePicker.uniqueId + '-title'\" aria-activedescendant=\"activeDateId\">\n <thead>\n <tr>\n <th>\n <button *ngIf=\"!isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\"\n tabindex=\"-1\">\u2039</button>\n <button *ngIf=\"isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\"\n tabindex=\"-1\">&lt;</button>\n </th>\n <th [attr.colspan]=\"5 + (datePicker.showWeeks ? 1 : 0)\">\n <button [id]=\"datePicker.uniqueId + '-title'\"\n type=\"button\" class=\"btn btn-default btn-secondary btn-sm\"\n (click)=\"datePicker.toggleMode(0)\"\n [disabled]=\"datePicker.datepickerMode === datePicker.maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === datePicker.maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{ title }}</strong>\n </button>\n </th>\n <th>\n <button *ngIf=\"!isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\"\n tabindex=\"-1\">\u203A</button>\n <button *ngIf=\"isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\"\n tabindex=\"-1\">&gt;\n </button>\n </th>\n </tr>\n <tr>\n <th *ngIf=\"datePicker.showWeeks\"></th>\n <th *ngFor=\"let labelz of labels\" class=\"text-center\">\n <small aria-label=\"labelz.full\"><b>{{ labelz.abbr }}</b></small>\n </th>\n </tr>\n </thead>\n <tbody>\n <ng-template ngFor [ngForOf]=\"rows\" let-rowz=\"$implicit\" let-index=\"index\">\n <tr *ngIf=\"!(datePicker.onlyCurrentMonth && rowz[0].secondary && rowz[6].secondary)\">\n <td *ngIf=\"datePicker.showWeeks\" class=\"h6\" class=\"text-center\">\n <em>{{ weekNumbers[index] }}</em>\n </td>\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" [id]=\"dtz.uid\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-sm {{dtz.customClass}}\"\n *ngIf=\"!(datePicker.onlyCurrentMonth && dtz.secondary)\"\n [ngClass]=\"{'btn-secondary': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected, disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz), 'btn-default': !isBs4}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-muted': dtz.secondary || dtz.current, 'text-info': !isBs4 && dtz.current}\">{{ dtz.label }}</span>\n </button>\n </td>\n </tr>\n </ng-template>\n </tbody>\n</table>\n ",
  5369. styles: ["\n :host .btn-secondary {\n color: #292b2c;\n background-color: #fff;\n border-color: #ccc;\n }\n :host .btn-info .text-muted {\n color: #292b2c !important;\n }\n "]
  5370. }] }
  5371. ];
  5372. /** @nocollapse */
  5373. DayPickerComponent.ctorParameters = function () { return [
  5374. { type: DatePickerInnerComponent }
  5375. ]; };
  5376. return DayPickerComponent;
  5377. }());
  5378. /**
  5379. * @fileoverview added by tsickle
  5380. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5381. */
  5382. var MonthPickerComponent = /** @class */ (function () {
  5383. function MonthPickerComponent(datePicker) {
  5384. this.rows = [];
  5385. this.datePicker = datePicker;
  5386. }
  5387. Object.defineProperty(MonthPickerComponent.prototype, "isBs4", {
  5388. get: /**
  5389. * @return {?}
  5390. */
  5391. function () {
  5392. return !isBs3();
  5393. },
  5394. enumerable: true,
  5395. configurable: true
  5396. });
  5397. /**
  5398. * @return {?}
  5399. */
  5400. MonthPickerComponent.prototype.ngOnInit = /**
  5401. * @return {?}
  5402. */
  5403. function () {
  5404. /** @type {?} */
  5405. var self = this;
  5406. this.datePicker.stepMonth = { years: 1 };
  5407. this.datePicker.setRefreshViewHandler((/**
  5408. * @return {?}
  5409. */
  5410. function () {
  5411. /** @type {?} */
  5412. var months = new Array(12);
  5413. /** @type {?} */
  5414. var year = this.activeDate.getFullYear();
  5415. /** @type {?} */
  5416. var date;
  5417. for (var i = 0; i < 12; i++) {
  5418. date = new Date(year, i, 1);
  5419. date = this.fixTimeZone(date);
  5420. months[i] = this.createDateObject(date, this.formatMonth);
  5421. months[i].uid = this.uniqueId + '-' + i;
  5422. }
  5423. self.title = this.dateFilter(this.activeDate, this.formatMonthTitle);
  5424. self.rows = this.split(months, self.datePicker.monthColLimit);
  5425. }), 'month');
  5426. this.datePicker.setCompareHandler((/**
  5427. * @param {?} date1
  5428. * @param {?} date2
  5429. * @return {?}
  5430. */
  5431. function (date1, date2) {
  5432. /** @type {?} */
  5433. var d1 = new Date(date1.getFullYear(), date1.getMonth());
  5434. /** @type {?} */
  5435. var d2 = new Date(date2.getFullYear(), date2.getMonth());
  5436. return d1.getTime() - d2.getTime();
  5437. }), 'month');
  5438. this.datePicker.refreshView();
  5439. };
  5440. MonthPickerComponent.decorators = [
  5441. { type: Component, args: [{
  5442. selector: 'monthpicker',
  5443. template: "\n<table *ngIf=\"datePicker.datepickerMode==='month'\" role=\"grid\">\n <thead>\n <tr>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\" tabindex=\"-1\">\u2039</button></th>\n <th [attr.colspan]=\"((datePicker.monthColLimit - 2) <= 0) ? 1 : datePicker.monthColLimit - 2\">\n <button [id]=\"datePicker.uniqueId + '-title'\"\n type=\"button\" class=\"btn btn-default btn-sm\"\n (click)=\"datePicker.toggleMode(0)\"\n [disabled]=\"datePicker.datepickerMode === maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{ title }}</strong> \n </button>\n </th>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\" tabindex=\"-1\">\u203A</button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let rowz of rows\">\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" [attr.id]=\"dtz.uid\" [ngClass]=\"dtz.customClass\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\"\n [ngClass]=\"{'btn-link': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected || (isBs4 && !dtz.selected && datePicker.isActive(dtz)), disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz)}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}\">{{ dtz.label }}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n ",
  5444. styles: ["\n :host .btn-info .text-success {\n color: #fff !important;\n }\n "]
  5445. }] }
  5446. ];
  5447. /** @nocollapse */
  5448. MonthPickerComponent.ctorParameters = function () { return [
  5449. { type: DatePickerInnerComponent }
  5450. ]; };
  5451. return MonthPickerComponent;
  5452. }());
  5453. /**
  5454. * @fileoverview added by tsickle
  5455. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5456. */
  5457. var YearPickerComponent = /** @class */ (function () {
  5458. function YearPickerComponent(datePicker) {
  5459. this.rows = [];
  5460. this.datePicker = datePicker;
  5461. }
  5462. Object.defineProperty(YearPickerComponent.prototype, "isBs4", {
  5463. get: /**
  5464. * @return {?}
  5465. */
  5466. function () {
  5467. return !isBs3();
  5468. },
  5469. enumerable: true,
  5470. configurable: true
  5471. });
  5472. /**
  5473. * @return {?}
  5474. */
  5475. YearPickerComponent.prototype.ngOnInit = /**
  5476. * @return {?}
  5477. */
  5478. function () {
  5479. /** @type {?} */
  5480. var self = this;
  5481. this.datePicker.stepYear = { years: this.datePicker.yearRange };
  5482. this.datePicker.setRefreshViewHandler((/**
  5483. * @return {?}
  5484. */
  5485. function () {
  5486. /** @type {?} */
  5487. var years = new Array(this.yearRange);
  5488. /** @type {?} */
  5489. var date;
  5490. /** @type {?} */
  5491. var start = self.getStartingYear(this.activeDate.getFullYear());
  5492. for (var i = 0; i < this.yearRange; i++) {
  5493. date = new Date(start + i, 0, 1);
  5494. date = this.fixTimeZone(date);
  5495. years[i] = this.createDateObject(date, this.formatYear);
  5496. years[i].uid = this.uniqueId + '-' + i;
  5497. }
  5498. self.title = [years[0].label, years[this.yearRange - 1].label].join(' - ');
  5499. self.rows = this.split(years, self.datePicker.yearColLimit);
  5500. }), 'year');
  5501. this.datePicker.setCompareHandler((/**
  5502. * @param {?} date1
  5503. * @param {?} date2
  5504. * @return {?}
  5505. */
  5506. function (date1, date2) {
  5507. return date1.getFullYear() - date2.getFullYear();
  5508. }), 'year');
  5509. this.datePicker.refreshView();
  5510. };
  5511. /**
  5512. * @protected
  5513. * @param {?} year
  5514. * @return {?}
  5515. */
  5516. YearPickerComponent.prototype.getStartingYear = /**
  5517. * @protected
  5518. * @param {?} year
  5519. * @return {?}
  5520. */
  5521. function (year) {
  5522. // todo: parseInt
  5523. return ((year - 1) / this.datePicker.yearRange * this.datePicker.yearRange + 1);
  5524. };
  5525. YearPickerComponent.decorators = [
  5526. { type: Component, args: [{
  5527. selector: 'yearpicker',
  5528. template: "\n<table *ngIf=\"datePicker.datepickerMode==='year'\" role=\"grid\">\n <thead>\n <tr>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\" tabindex=\"-1\">\u2039</button>\n </th>\n <th [attr.colspan]=\"((datePicker.yearColLimit - 2) <= 0) ? 1 : datePicker.yearColLimit - 2\">\n <button [id]=\"datePicker.uniqueId + '-title'\" role=\"heading\"\n type=\"button\" class=\"btn btn-default btn-sm\"\n (click)=\"datePicker.toggleMode(0)\"\n [disabled]=\"datePicker.datepickerMode === datePicker.maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === datePicker.maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{ title }}</strong>\n </button>\n </th>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\" tabindex=\"-1\">\u203A</button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let rowz of rows\">\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" [attr.id]=\"dtz.uid\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\"\n [ngClass]=\"{'btn-link': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected || (isBs4 && !dtz.selected && datePicker.isActive(dtz)), disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz)}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}\">{{ dtz.label }}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n ",
  5529. styles: ["\n :host .btn-info .text-success {\n color: #fff !important;\n }\n "]
  5530. }] }
  5531. ];
  5532. /** @nocollapse */
  5533. YearPickerComponent.ctorParameters = function () { return [
  5534. { type: DatePickerInnerComponent }
  5535. ]; };
  5536. return YearPickerComponent;
  5537. }());
  5538. /**
  5539. * @fileoverview added by tsickle
  5540. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5541. */
  5542. var DatepickerModule = /** @class */ (function () {
  5543. function DatepickerModule() {
  5544. }
  5545. /**
  5546. * @return {?}
  5547. */
  5548. DatepickerModule.forRoot = /**
  5549. * @return {?}
  5550. */
  5551. function () {
  5552. return { ngModule: DatepickerModule, providers: [DatepickerConfig] };
  5553. };
  5554. DatepickerModule.decorators = [
  5555. { type: NgModule, args: [{
  5556. imports: [CommonModule, FormsModule],
  5557. declarations: [
  5558. DatePickerComponent,
  5559. DatePickerInnerComponent,
  5560. DayPickerComponent,
  5561. MonthPickerComponent,
  5562. YearPickerComponent
  5563. ],
  5564. exports: [
  5565. DatePickerComponent,
  5566. DatePickerInnerComponent,
  5567. DayPickerComponent,
  5568. MonthPickerComponent,
  5569. YearPickerComponent
  5570. ],
  5571. entryComponents: [DatePickerComponent]
  5572. },] }
  5573. ];
  5574. return DatepickerModule;
  5575. }());
  5576. export { BsDatepickerConfig, BsDatepickerContainerComponent, BsDatepickerDirective, BsDatepickerInlineConfig, BsDatepickerInlineContainerComponent, BsDatepickerInlineDirective, BsDatepickerInputDirective, BsDatepickerModule, BsDaterangepickerConfig, BsDaterangepickerContainerComponent, BsDaterangepickerDirective, BsDaterangepickerInlineConfig, BsDaterangepickerInlineContainerComponent, BsDaterangepickerInlineDirective, BsDaterangepickerInputDirective, BsLocaleService, DateFormatter, DatePickerComponent, DatePickerInnerComponent, DatepickerConfig, DatepickerModule, DayPickerComponent, MonthPickerComponent, YearPickerComponent, DATEPICKER_CONTROL_VALUE_ACCESSOR as ɵa, BsDatepickerAbstractComponent as ɵb, BsDatepickerStore as ɵc, BsDatepickerEffects as ɵd, BsDatepickerActions as ɵe, datepickerAnimation as ɵf, BsCalendarLayoutComponent as ɵg, BsCurrentDateViewComponent as ɵh, BsCustomDatesViewComponent as ɵi, BsDatepickerDayDecoratorComponent as ɵj, BsDatepickerNavigationViewComponent as ɵk, BsDaysCalendarViewComponent as ɵl, BsMonthCalendarViewComponent as ɵm, BsTimepickerViewComponent as ɵn, BsYearsCalendarViewComponent as ɵo };
  5577. //# sourceMappingURL=ngx-bootstrap-datepicker.js.map