| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140 |
- import { Injectable, EventEmitter, Component, Renderer2, ElementRef, Directive, ViewContainerRef, Input, Output, forwardRef, Host, ChangeDetectorRef, ChangeDetectionStrategy, NgModule, ViewChild } from '@angular/core';
- import { filter, map, take } from 'rxjs/operators';
- 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';
- import { BehaviorSubject } from 'rxjs';
- import { MiniStore, MiniState } from 'ngx-bootstrap/mini-ngrx';
- import { PositioningService } from 'ngx-bootstrap/positioning';
- import { trigger, state, style, transition, animate } from '@angular/animations';
- import { ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
- import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule } from '@angular/forms';
- import { CommonModule } from '@angular/common';
- import { isBs3 } from 'ngx-bootstrap/utils';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * For date range picker there are `BsDaterangepickerConfig` which inherits all properties,
- * except `displayMonths`, for range picker it default to `2`
- */
- class BsDatepickerConfig {
- constructor() {
- /**
- * sets use adaptive position
- */
- this.adaptivePosition = false;
- /**
- * sets use UTC date time format
- */
- this.useUtc = false;
- /**
- * turn on/off animation
- */
- this.isAnimated = false;
- /**
- * CSS class which will be applied to datepicker container,
- * usually used to set color theme
- */
- this.containerClass = 'theme-green';
- // DatepickerRenderOptions
- this.displayMonths = 1;
- /**
- * Allows to hide week numbers in datepicker
- */
- this.showWeekNumbers = true;
- this.dateInputFormat = 'L';
- // range picker
- this.rangeSeparator = ' - ';
- /**
- * Date format for date range input field
- */
- this.rangeInputFormat = 'L';
- // DatepickerFormatOptions
- this.monthTitle = 'MMMM';
- this.yearTitle = 'YYYY';
- this.dayLabel = 'D';
- this.monthLabel = 'MMMM';
- this.yearLabel = 'YYYY';
- this.weekNumbers = 'w';
- }
- }
- BsDatepickerConfig.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @abstract
- */
- class BsDatepickerAbstractComponent {
- constructor() {
- this._customRangesFish = [];
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set minDate(value) {
- this._effects.setMinDate(value);
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set maxDate(value) {
- this._effects.setMaxDate(value);
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set daysDisabled(value) {
- this._effects.setDaysDisabled(value);
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set datesDisabled(value) {
- this._effects.setDatesDisabled(value);
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set isDisabled(value) {
- this._effects.setDisabled(value);
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set dateCustomClasses(value) {
- this._effects.setDateCustomClasses(value);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- setViewMode(event) { }
- /**
- * @param {?} event
- * @return {?}
- */
- navigateTo(event) { }
- /**
- * @param {?} event
- * @return {?}
- */
- dayHoverHandler(event) { }
- /**
- * @param {?} event
- * @return {?}
- */
- weekHoverHandler(event) { }
- /**
- * @param {?} event
- * @return {?}
- */
- monthHoverHandler(event) { }
- /**
- * @param {?} event
- * @return {?}
- */
- yearHoverHandler(event) { }
- /**
- * @param {?} day
- * @return {?}
- */
- daySelectHandler(day) { }
- /**
- * @param {?} event
- * @return {?}
- */
- monthSelectHandler(event) { }
- /**
- * @param {?} event
- * @return {?}
- */
- yearSelectHandler(event) { }
- /* tslint:disable-next-line: no-any */
- /**
- * @param {?} event
- * @return {?}
- */
- _stopPropagation(event) {
- event.stopPropagation();
- }
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerActions {
- /**
- * @return {?}
- */
- calculate() {
- return { type: BsDatepickerActions.CALCULATE };
- }
- /**
- * @return {?}
- */
- format() {
- return { type: BsDatepickerActions.FORMAT };
- }
- /**
- * @return {?}
- */
- flag() {
- return { type: BsDatepickerActions.FLAG };
- }
- /**
- * @param {?} date
- * @return {?}
- */
- select(date) {
- return {
- type: BsDatepickerActions.SELECT,
- payload: date
- };
- }
- /**
- * @param {?} event
- * @return {?}
- */
- changeViewMode(event) {
- return {
- type: BsDatepickerActions.CHANGE_VIEWMODE,
- payload: event
- };
- }
- /**
- * @param {?} event
- * @return {?}
- */
- navigateTo(event) {
- return {
- type: BsDatepickerActions.NAVIGATE_TO,
- payload: event
- };
- }
- /**
- * @param {?} step
- * @return {?}
- */
- navigateStep(step) {
- return {
- type: BsDatepickerActions.NAVIGATE_OFFSET,
- payload: step
- };
- }
- /**
- * @param {?} options
- * @return {?}
- */
- setOptions(options) {
- return {
- type: BsDatepickerActions.SET_OPTIONS,
- payload: options
- };
- }
- // date range picker
- /**
- * @param {?} value
- * @return {?}
- */
- selectRange(value) {
- return {
- type: BsDatepickerActions.SELECT_RANGE,
- payload: value
- };
- }
- /**
- * @param {?} event
- * @return {?}
- */
- hoverDay(event) {
- return {
- type: BsDatepickerActions.HOVER,
- payload: event.isHovered ? event.cell.date : null
- };
- }
- /**
- * @param {?} date
- * @return {?}
- */
- minDate(date) {
- return {
- type: BsDatepickerActions.SET_MIN_DATE,
- payload: date
- };
- }
- /**
- * @param {?} date
- * @return {?}
- */
- maxDate(date) {
- return {
- type: BsDatepickerActions.SET_MAX_DATE,
- payload: date
- };
- }
- /**
- * @param {?} days
- * @return {?}
- */
- daysDisabled(days) {
- return {
- type: BsDatepickerActions.SET_DAYSDISABLED,
- payload: days
- };
- }
- /**
- * @param {?} dates
- * @return {?}
- */
- datesDisabled(dates) {
- return {
- type: BsDatepickerActions.SET_DATESDISABLED,
- payload: dates
- };
- }
- /**
- * @param {?} value
- * @return {?}
- */
- isDisabled(value) {
- return {
- type: BsDatepickerActions.SET_IS_DISABLED,
- payload: value
- };
- }
- /**
- * @param {?} value
- * @return {?}
- */
- setDateCustomClasses(value) {
- return {
- type: BsDatepickerActions.SET_DATE_CUSTOM_CLASSES,
- payload: value
- };
- }
- /**
- * @param {?} locale
- * @return {?}
- */
- setLocale(locale) {
- return {
- type: BsDatepickerActions.SET_LOCALE,
- payload: locale
- };
- }
- }
- BsDatepickerActions.CALCULATE = '[datepicker] calculate dates matrix';
- BsDatepickerActions.FORMAT = '[datepicker] format datepicker values';
- BsDatepickerActions.FLAG = '[datepicker] set flags';
- BsDatepickerActions.SELECT = '[datepicker] select date';
- BsDatepickerActions.NAVIGATE_OFFSET = '[datepicker] shift view date';
- BsDatepickerActions.NAVIGATE_TO = '[datepicker] change view date';
- BsDatepickerActions.SET_OPTIONS = '[datepicker] update render options';
- BsDatepickerActions.HOVER = '[datepicker] hover date';
- BsDatepickerActions.CHANGE_VIEWMODE = '[datepicker] switch view mode';
- BsDatepickerActions.SET_MIN_DATE = '[datepicker] set min date';
- BsDatepickerActions.SET_MAX_DATE = '[datepicker] set max date';
- BsDatepickerActions.SET_DAYSDISABLED = '[datepicker] set days disabled';
- BsDatepickerActions.SET_DATESDISABLED = '[datepicker] set dates disabled';
- BsDatepickerActions.SET_IS_DISABLED = '[datepicker] set is disabled';
- BsDatepickerActions.SET_DATE_CUSTOM_CLASSES = '[datepicker] set date custom classes';
- BsDatepickerActions.SET_LOCALE = '[datepicker] set datepicker locale';
- BsDatepickerActions.SELECT_RANGE = '[daterangepicker] select dates range';
- BsDatepickerActions.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsLocaleService {
- constructor() {
- this._defaultLocale = 'en';
- this._locale = new BehaviorSubject(this._defaultLocale);
- this._localeChange = this._locale.asObservable();
- }
- /**
- * @return {?}
- */
- get locale() {
- return this._locale;
- }
- /**
- * @return {?}
- */
- get localeChange() {
- return this._localeChange;
- }
- /**
- * @return {?}
- */
- get currentLocale() {
- return this._locale.getValue();
- }
- /**
- * @param {?} locale
- * @return {?}
- */
- use(locale) {
- if (locale === this.currentLocale) {
- return;
- }
- this._locale.next(locale);
- }
- }
- BsLocaleService.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerEffects {
- /**
- * @param {?} _actions
- * @param {?} _localeService
- */
- constructor(_actions, _localeService) {
- this._actions = _actions;
- this._localeService = _localeService;
- this._subs = [];
- }
- /**
- * @param {?} _bsDatepickerStore
- * @return {?}
- */
- init(_bsDatepickerStore) {
- this._store = _bsDatepickerStore;
- return this;
- }
- /**
- * setters
- * @param {?} value
- * @return {?}
- */
- setValue(value) {
- this._store.dispatch(this._actions.select(value));
- }
- /**
- * @param {?} value
- * @return {?}
- */
- setRangeValue(value) {
- this._store.dispatch(this._actions.selectRange(value));
- }
- /**
- * @param {?} value
- * @return {?}
- */
- setMinDate(value) {
- this._store.dispatch(this._actions.minDate(value));
- return this;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- setMaxDate(value) {
- this._store.dispatch(this._actions.maxDate(value));
- return this;
- }
- /**
- * @template THIS
- * @this {THIS}
- * @param {?} value
- * @return {THIS}
- */
- setDaysDisabled(value) {
- (/** @type {?} */ (this))._store.dispatch((/** @type {?} */ (this))._actions.daysDisabled(value));
- return (/** @type {?} */ (this));
- }
- /**
- * @template THIS
- * @this {THIS}
- * @param {?} value
- * @return {THIS}
- */
- setDatesDisabled(value) {
- (/** @type {?} */ (this))._store.dispatch((/** @type {?} */ (this))._actions.datesDisabled(value));
- return (/** @type {?} */ (this));
- }
- /**
- * @param {?} value
- * @return {?}
- */
- setDisabled(value) {
- this._store.dispatch(this._actions.isDisabled(value));
- return this;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- setDateCustomClasses(value) {
- this._store.dispatch(this._actions.setDateCustomClasses(value));
- return this;
- }
- /* Set rendering options */
- /**
- * @param {?} _config
- * @return {?}
- */
- setOptions(_config) {
- /** @type {?} */
- const _options = Object.assign({ locale: this._localeService.currentLocale }, _config);
- this._store.dispatch(this._actions.setOptions(_options));
- return this;
- }
- /**
- * view to mode bindings
- * @param {?} container
- * @return {?}
- */
- setBindings(container) {
- container.daysCalendar = this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.flaggedMonths))
- .pipe(filter((/**
- * @param {?} months
- * @return {?}
- */
- months => !!months)));
- // month calendar
- container.monthsCalendar = this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.flaggedMonthsCalendar))
- .pipe(filter((/**
- * @param {?} months
- * @return {?}
- */
- months => !!months)));
- // year calendar
- container.yearsCalendar = this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.yearsCalendarFlagged))
- .pipe(filter((/**
- * @param {?} years
- * @return {?}
- */
- years => !!years)));
- container.viewMode = this._store.select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.view.mode));
- container.options = this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.showWeekNumbers))
- .pipe(map((/**
- * @param {?} showWeekNumbers
- * @return {?}
- */
- showWeekNumbers => ({ showWeekNumbers }))));
- return this;
- }
- /**
- * event handlers
- * @param {?} container
- * @return {?}
- */
- setEventHandlers(container) {
- container.setViewMode = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- this._store.dispatch(this._actions.changeViewMode(event));
- });
- container.navigateTo = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- this._store.dispatch(this._actions.navigateStep(event.step));
- });
- container.dayHoverHandler = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- /** @type {?} */
- const _cell = (/** @type {?} */ (event.cell));
- if (_cell.isOtherMonth || _cell.isDisabled) {
- return;
- }
- this._store.dispatch(this._actions.hoverDay(event));
- _cell.isHovered = event.isHovered;
- });
- container.monthHoverHandler = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- event.cell.isHovered = event.isHovered;
- });
- container.yearHoverHandler = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- event.cell.isHovered = event.isHovered;
- });
- container.monthSelectHandler = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- if (event.isDisabled) {
- return;
- }
- this._store.dispatch(this._actions.navigateTo({
- unit: {
- month: getMonth(event.date),
- year: getFullYear(event.date)
- },
- viewMode: 'day'
- }));
- });
- container.yearSelectHandler = (/**
- * @param {?} event
- * @return {?}
- */
- (event) => {
- if (event.isDisabled) {
- return;
- }
- this._store.dispatch(this._actions.navigateTo({
- unit: {
- year: getFullYear(event.date)
- },
- viewMode: 'month'
- }));
- });
- return this;
- }
- /**
- * @return {?}
- */
- registerDatepickerSideEffects() {
- this._subs.push(this._store.select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.view)).subscribe((/**
- * @param {?} view
- * @return {?}
- */
- view => {
- this._store.dispatch(this._actions.calculate());
- })));
- // format calendar values on month model change
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.monthsModel))
- .pipe(filter((/**
- * @param {?} monthModel
- * @return {?}
- */
- monthModel => !!monthModel)))
- .subscribe((/**
- * @param {?} month
- * @return {?}
- */
- month => this._store.dispatch(this._actions.format()))));
- // flag day values
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.formattedMonths))
- .pipe(filter((/**
- * @param {?} month
- * @return {?}
- */
- month => !!month)))
- .subscribe((/**
- * @param {?} month
- * @return {?}
- */
- month => this._store.dispatch(this._actions.flag()))));
- // flag day values
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.selectedDate))
- .pipe(filter((/**
- * @param {?} selectedDate
- * @return {?}
- */
- selectedDate => !!selectedDate)))
- .subscribe((/**
- * @param {?} selectedDate
- * @return {?}
- */
- selectedDate => this._store.dispatch(this._actions.flag()))));
- // flag for date range picker
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.selectedRange))
- .pipe(filter((/**
- * @param {?} selectedRange
- * @return {?}
- */
- selectedRange => !!selectedRange)))
- .subscribe((/**
- * @param {?} selectedRange
- * @return {?}
- */
- selectedRange => this._store.dispatch(this._actions.flag()))));
- // monthsCalendar
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.monthsCalendar))
- .subscribe((/**
- * @return {?}
- */
- () => this._store.dispatch(this._actions.flag()))));
- // years calendar
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.yearsCalendarModel))
- .pipe(filter((/**
- * @param {?} state
- * @return {?}
- */
- state => !!state)))
- .subscribe((/**
- * @return {?}
- */
- () => this._store.dispatch(this._actions.flag()))));
- // on hover
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.hoveredDate))
- .pipe(filter((/**
- * @param {?} hoveredDate
- * @return {?}
- */
- hoveredDate => !!hoveredDate)))
- .subscribe((/**
- * @param {?} hoveredDate
- * @return {?}
- */
- hoveredDate => this._store.dispatch(this._actions.flag()))));
- // date custom classes
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.dateCustomClasses))
- .pipe(filter((/**
- * @param {?} dateCustomClasses
- * @return {?}
- */
- dateCustomClasses => !!dateCustomClasses)))
- .subscribe((/**
- * @param {?} dateCustomClasses
- * @return {?}
- */
- dateCustomClasses => this._store.dispatch(this._actions.flag()))));
- // on locale change
- this._subs.push(this._localeService.localeChange
- .subscribe((/**
- * @param {?} locale
- * @return {?}
- */
- locale => this._store.dispatch(this._actions.setLocale(locale)))));
- return this;
- }
- /**
- * @return {?}
- */
- destroy() {
- for (const sub of this._subs) {
- sub.unsubscribe();
- }
- }
- }
- BsDatepickerEffects.decorators = [
- { type: Injectable }
- ];
- /** @nocollapse */
- BsDatepickerEffects.ctorParameters = () => [
- { type: BsDatepickerActions },
- { type: BsLocaleService }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const defaultMonthOptions = {
- width: 7,
- height: 6
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const _initialView = { date: new Date(), mode: 'day' };
- /** @type {?} */
- const initialDatepickerState = Object.assign(new BsDatepickerConfig(), {
- locale: 'en',
- view: _initialView,
- selectedRange: [],
- monthViewOptions: defaultMonthOptions
- });
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} date
- * @param {?} options
- * @return {?}
- */
- function getStartingDayOfCalendar(date, options) {
- if (isFirstDayOfWeek(date, options.firstDayOfWeek)) {
- return date;
- }
- /** @type {?} */
- const weekDay = getDay(date);
- /** @type {?} */
- const offset = calculateDateOffset(weekDay, options.firstDayOfWeek);
- return shiftDate(date, { day: -offset });
- }
- /**
- * @param {?} weekday
- * @param {?} startingDayOffset
- * @return {?}
- */
- function calculateDateOffset(weekday, startingDayOffset) {
- if (startingDayOffset === 0) {
- return weekday;
- }
- /** @type {?} */
- const offset = weekday - startingDayOffset % 7;
- return offset < 0 ? offset + 7 : offset;
- }
- /**
- * @param {?} date
- * @param {?} min
- * @param {?} max
- * @return {?}
- */
- function isMonthDisabled(date, min, max) {
- /** @type {?} */
- const minBound = min && isBefore(endOf(date, 'month'), min, 'day');
- /** @type {?} */
- const maxBound = max && isAfter(startOf(date, 'month'), max, 'day');
- return minBound || maxBound;
- }
- /**
- * @param {?} date
- * @param {?} min
- * @param {?} max
- * @return {?}
- */
- function isYearDisabled(date, min, max) {
- /** @type {?} */
- const minBound = min && isBefore(endOf(date, 'year'), min, 'day');
- /** @type {?} */
- const maxBound = max && isAfter(startOf(date, 'year'), max, 'day');
- return minBound || maxBound;
- }
- /**
- * @param {?} date
- * @param {?} datesDisabled
- * @return {?}
- */
- function isDisabledDate(date, datesDisabled) {
- if (datesDisabled === undefined || !datesDisabled || !datesDisabled.length) {
- return false;
- }
- return datesDisabled.some((/**
- * @param {?} dateDisabled
- * @return {?}
- */
- (dateDisabled) => isSame(date, dateDisabled, 'date')));
- }
- /**
- * @param {?} state
- * @param {?=} calendarIndex
- * @return {?}
- */
- function getYearsCalendarInitialDate(state, calendarIndex = 0) {
- /** @type {?} */
- const model = state && state.yearsCalendarModel && state.yearsCalendarModel[calendarIndex];
- return model && model.years && model.years[0] && model.years[0][0] && model.years[0][0].date;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @template T
- * @param {?} options
- * @param {?} fn
- * @return {?}
- */
- function createMatrix(options, fn) {
- /** @type {?} */
- let prevValue = options.initialDate;
- /** @type {?} */
- const matrix = new Array(options.height);
- for (let i = 0; i < options.height; i++) {
- matrix[i] = new Array(options.width);
- for (let j = 0; j < options.width; j++) {
- matrix[i][j] = fn(prevValue);
- prevValue = shiftDate(prevValue, options.shift);
- }
- }
- return matrix;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} startingDate
- * @param {?} options
- * @return {?}
- */
- function calcDaysCalendar(startingDate, options) {
- /** @type {?} */
- const firstDay = getFirstDayOfMonth(startingDate);
- /** @type {?} */
- const initialDate = getStartingDayOfCalendar(firstDay, options);
- /** @type {?} */
- const matrixOptions = {
- width: options.width,
- height: options.height,
- initialDate,
- shift: { day: 1 }
- };
- /** @type {?} */
- const daysMatrix = createMatrix(matrixOptions, (/**
- * @param {?} date
- * @return {?}
- */
- date => date));
- return {
- daysMatrix,
- month: firstDay
- };
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} daysCalendar
- * @param {?} formatOptions
- * @param {?} monthIndex
- * @return {?}
- */
- function formatDaysCalendar(daysCalendar, formatOptions, monthIndex) {
- return {
- month: daysCalendar.month,
- monthTitle: formatDate(daysCalendar.month, formatOptions.monthTitle, formatOptions.locale),
- yearTitle: formatDate(daysCalendar.month, formatOptions.yearTitle, formatOptions.locale),
- weekNumbers: getWeekNumbers(daysCalendar.daysMatrix, formatOptions.weekNumbers, formatOptions.locale),
- weekdays: getShiftedWeekdays(formatOptions.locale),
- weeks: daysCalendar.daysMatrix.map((/**
- * @param {?} week
- * @param {?} weekIndex
- * @return {?}
- */
- (week, weekIndex) => ({
- days: week.map((/**
- * @param {?} date
- * @param {?} dayIndex
- * @return {?}
- */
- (date, dayIndex) => ({
- date,
- label: formatDate(date, formatOptions.dayLabel, formatOptions.locale),
- monthIndex,
- weekIndex,
- dayIndex
- })))
- })))
- };
- }
- /**
- * @param {?} daysMatrix
- * @param {?} format
- * @param {?} locale
- * @return {?}
- */
- function getWeekNumbers(daysMatrix, format, locale) {
- return daysMatrix.map((/**
- * @param {?} days
- * @return {?}
- */
- (days) => (days[0] ? formatDate(days[0], format, locale) : '')));
- }
- /**
- * @param {?} locale
- * @return {?}
- */
- function getShiftedWeekdays(locale) {
- /** @type {?} */
- const _locale = getLocale(locale);
- /** @type {?} */
- const weekdays = (/** @type {?} */ (_locale.weekdaysShort()));
- /** @type {?} */
- const firstDayOfWeek = _locale.firstDayOfWeek();
- return [...weekdays.slice(firstDayOfWeek), ...weekdays.slice(0, firstDayOfWeek)];
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} formattedMonth
- * @param {?} options
- * @return {?}
- */
- function flagDaysCalendar(formattedMonth, options) {
- formattedMonth.weeks.forEach((/**
- * @param {?} week
- * @return {?}
- */
- (week) => {
- /* tslint:disable-next-line: cyclomatic-complexity */
- week.days.forEach((/**
- * @param {?} day
- * @param {?} dayIndex
- * @return {?}
- */
- (day, dayIndex) => {
- // datepicker
- /** @type {?} */
- const isOtherMonth = !isSameMonth(day.date, formattedMonth.month);
- /** @type {?} */
- const isHovered = !isOtherMonth && isSameDay(day.date, options.hoveredDate);
- // date range picker
- /** @type {?} */
- const isSelectionStart = !isOtherMonth &&
- options.selectedRange &&
- isSameDay(day.date, options.selectedRange[0]);
- /** @type {?} */
- const isSelectionEnd = !isOtherMonth &&
- options.selectedRange &&
- isSameDay(day.date, options.selectedRange[1]);
- /** @type {?} */
- const isSelected = (!isOtherMonth && isSameDay(day.date, options.selectedDate)) ||
- isSelectionStart ||
- isSelectionEnd;
- /** @type {?} */
- const isInRange = !isOtherMonth &&
- options.selectedRange &&
- isDateInRange(day.date, options.selectedRange, options.hoveredDate);
- /** @type {?} */
- const isDisabled = options.isDisabled ||
- isBefore(day.date, options.minDate, 'day') ||
- isAfter(day.date, options.maxDate, 'day') ||
- isDisabledDay(day.date, options.daysDisabled) ||
- isDisabledDate(day.date, options.datesDisabled);
- /** @type {?} */
- const currentDate = new Date();
- /** @type {?} */
- const isToday = !isOtherMonth && isSameDay(day.date, currentDate);
- /** @type {?} */
- const customClasses = options.dateCustomClasses && options.dateCustomClasses
- .map((/**
- * @param {?} dcc
- * @return {?}
- */
- dcc => isSameDay(day.date, dcc.date) ? dcc.classes : []))
- .reduce((/**
- * @param {?} previousValue
- * @param {?} currentValue
- * @return {?}
- */
- (previousValue, currentValue) => previousValue.concat(currentValue)), [])
- .join(' ')
- || '';
- // decide update or not
- /** @type {?} */
- const newDay = Object.assign({}, day, {
- isOtherMonth,
- isHovered,
- isSelected,
- isSelectionStart,
- isSelectionEnd,
- isInRange,
- isDisabled,
- isToday,
- customClasses
- });
- if (day.isOtherMonth !== newDay.isOtherMonth ||
- day.isHovered !== newDay.isHovered ||
- day.isSelected !== newDay.isSelected ||
- day.isSelectionStart !== newDay.isSelectionStart ||
- day.isSelectionEnd !== newDay.isSelectionEnd ||
- day.isDisabled !== newDay.isDisabled ||
- day.isInRange !== newDay.isInRange ||
- day.customClasses !== newDay.customClasses) {
- week.days[dayIndex] = newDay;
- }
- }));
- }));
- // todo: add check for linked calendars
- formattedMonth.hideLeftArrow =
- options.isDisabled ||
- (options.monthIndex > 0 && options.monthIndex !== options.displayMonths);
- formattedMonth.hideRightArrow =
- options.isDisabled ||
- (options.monthIndex < options.displayMonths &&
- options.monthIndex + 1 !== options.displayMonths);
- formattedMonth.disableLeftArrow = isMonthDisabled(shiftDate(formattedMonth.month, { month: -1 }), options.minDate, options.maxDate);
- formattedMonth.disableRightArrow = isMonthDisabled(shiftDate(formattedMonth.month, { month: 1 }), options.minDate, options.maxDate);
- return formattedMonth;
- }
- /**
- * @param {?} date
- * @param {?} selectedRange
- * @param {?} hoveredDate
- * @return {?}
- */
- function isDateInRange(date, selectedRange, hoveredDate) {
- if (!date || !selectedRange[0]) {
- return false;
- }
- if (selectedRange[1]) {
- return date > selectedRange[0] && date <= selectedRange[1];
- }
- if (hoveredDate) {
- return date > selectedRange[0] && date <= hoveredDate;
- }
- return false;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} mode
- * @param {?=} minMode
- * @return {?}
- */
- function canSwitchMode(mode, minMode) {
- return minMode ? mode >= minMode : true;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const height = 4;
- /** @type {?} */
- const width = 3;
- /** @type {?} */
- const shift = { month: 1 };
- /**
- * @param {?} viewDate
- * @param {?} formatOptions
- * @return {?}
- */
- function formatMonthsCalendar(viewDate, formatOptions) {
- /** @type {?} */
- const initialDate = startOf(viewDate, 'year');
- /** @type {?} */
- const matrixOptions = { width, height, initialDate, shift };
- /** @type {?} */
- const monthMatrix = createMatrix(matrixOptions, (/**
- * @param {?} date
- * @return {?}
- */
- date => ({
- date,
- label: formatDate(date, formatOptions.monthLabel, formatOptions.locale)
- })));
- return {
- months: monthMatrix,
- monthTitle: '',
- yearTitle: formatDate(viewDate, formatOptions.yearTitle, formatOptions.locale)
- };
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} monthCalendar
- * @param {?} options
- * @return {?}
- */
- function flagMonthsCalendar(monthCalendar, options) {
- monthCalendar.months.forEach((/**
- * @param {?} months
- * @param {?} rowIndex
- * @return {?}
- */
- (months, rowIndex) => {
- months.forEach((/**
- * @param {?} month
- * @param {?} monthIndex
- * @return {?}
- */
- (month, monthIndex) => {
- /** @type {?} */
- const isHovered = isSameMonth(month.date, options.hoveredMonth);
- /** @type {?} */
- const isDisabled = options.isDisabled ||
- isMonthDisabled(month.date, options.minDate, options.maxDate);
- /** @type {?} */
- const isSelected = isSameMonth(month.date, options.selectedDate);
- /** @type {?} */
- const newMonth = Object.assign(/*{},*/ month, {
- isHovered,
- isDisabled,
- isSelected
- });
- if (month.isHovered !== newMonth.isHovered ||
- month.isDisabled !== newMonth.isDisabled ||
- month.isSelected !== newMonth.isSelected) {
- monthCalendar.months[rowIndex][monthIndex] = newMonth;
- }
- }));
- }));
- // todo: add check for linked calendars
- monthCalendar.hideLeftArrow =
- options.monthIndex > 0 && options.monthIndex !== options.displayMonths;
- monthCalendar.hideRightArrow =
- options.monthIndex < options.displayMonths &&
- options.monthIndex + 1 !== options.displayMonths;
- monthCalendar.disableLeftArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: -1 }), options.minDate, options.maxDate);
- monthCalendar.disableRightArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: 1 }), options.minDate, options.maxDate);
- return monthCalendar;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const height$1 = 4;
- /** @type {?} */
- const width$1 = 4;
- /** @type {?} */
- const yearsPerCalendar = height$1 * width$1;
- /** @type {?} */
- const initialYearShift = (Math.floor(yearsPerCalendar / 2) - 1) * -1;
- /** @type {?} */
- const shift$1 = { year: 1 };
- /**
- * @param {?} viewDate
- * @param {?} formatOptions
- * @param {?=} previousInitialDate
- * @return {?}
- */
- function formatYearsCalendar(viewDate, formatOptions, previousInitialDate) {
- /** @type {?} */
- const initialDate = calculateInitialDate(viewDate, previousInitialDate);
- /** @type {?} */
- const matrixOptions = { width: width$1, height: height$1, initialDate, shift: shift$1 };
- /** @type {?} */
- const yearsMatrix = createMatrix(matrixOptions, (/**
- * @param {?} date
- * @return {?}
- */
- date => ({
- date,
- label: formatDate(date, formatOptions.yearLabel, formatOptions.locale)
- })));
- /** @type {?} */
- const yearTitle = formatYearRangeTitle(yearsMatrix, formatOptions);
- return {
- years: yearsMatrix,
- monthTitle: '',
- yearTitle
- };
- }
- /**
- * @param {?} viewDate
- * @param {?=} previousInitialDate
- * @return {?}
- */
- function calculateInitialDate(viewDate, previousInitialDate) {
- if (previousInitialDate
- && viewDate.getFullYear() >= previousInitialDate.getFullYear()
- && viewDate.getFullYear() < previousInitialDate.getFullYear() + yearsPerCalendar) {
- return previousInitialDate;
- }
- return shiftDate(viewDate, { year: initialYearShift });
- }
- /**
- * @param {?} yearsMatrix
- * @param {?} formatOptions
- * @return {?}
- */
- function formatYearRangeTitle(yearsMatrix, formatOptions) {
- /** @type {?} */
- const from = formatDate(yearsMatrix[0][0].date, formatOptions.yearTitle, formatOptions.locale);
- /** @type {?} */
- const to = formatDate(yearsMatrix[height$1 - 1][width$1 - 1].date, formatOptions.yearTitle, formatOptions.locale);
- return `${from} - ${to}`;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * @param {?} yearsCalendar
- * @param {?} options
- * @return {?}
- */
- function flagYearsCalendar(yearsCalendar, options) {
- yearsCalendar.years.forEach((/**
- * @param {?} years
- * @param {?} rowIndex
- * @return {?}
- */
- (years, rowIndex) => {
- years.forEach((/**
- * @param {?} year
- * @param {?} yearIndex
- * @return {?}
- */
- (year, yearIndex) => {
- /** @type {?} */
- const isHovered = isSameYear(year.date, options.hoveredYear);
- /** @type {?} */
- const isDisabled = options.isDisabled ||
- isYearDisabled(year.date, options.minDate, options.maxDate);
- /** @type {?} */
- const isSelected = isSameYear(year.date, options.selectedDate);
- /** @type {?} */
- const newMonth = Object.assign(/*{},*/ year, { isHovered, isDisabled, isSelected });
- if (year.isHovered !== newMonth.isHovered ||
- year.isDisabled !== newMonth.isDisabled ||
- year.isSelected !== newMonth.isSelected) {
- yearsCalendar.years[rowIndex][yearIndex] = newMonth;
- }
- }));
- }));
- // todo: add check for linked calendars
- yearsCalendar.hideLeftArrow =
- options.yearIndex > 0 && options.yearIndex !== options.displayMonths;
- yearsCalendar.hideRightArrow =
- options.yearIndex < options.displayMonths &&
- options.yearIndex + 1 !== options.displayMonths;
- yearsCalendar.disableLeftArrow = isYearDisabled(shiftDate(yearsCalendar.years[0][0].date, { year: -1 }), options.minDate, options.maxDate);
- /** @type {?} */
- const i = yearsCalendar.years.length - 1;
- /** @type {?} */
- const j = yearsCalendar.years[i].length - 1;
- yearsCalendar.disableRightArrow = isYearDisabled(shiftDate(yearsCalendar.years[i][j].date, { year: 1 }), options.minDate, options.maxDate);
- return yearsCalendar;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /* tslint:disable-next-line: cyclomatic-complexity */
- /**
- * @param {?=} state
- * @param {?=} action
- * @return {?}
- */
- function bsDatepickerReducer(state = initialDatepickerState, action) {
- switch (action.type) {
- case BsDatepickerActions.CALCULATE: {
- return calculateReducer(state);
- }
- case BsDatepickerActions.FORMAT: {
- return formatReducer(state);
- }
- case BsDatepickerActions.FLAG: {
- return flagReducer(state);
- }
- case BsDatepickerActions.NAVIGATE_OFFSET: {
- return navigateOffsetReducer(state, action);
- }
- case BsDatepickerActions.NAVIGATE_TO: {
- /** @type {?} */
- const payload = action.payload;
- /** @type {?} */
- const date = setFullDate(state.view.date, payload.unit);
- /** @type {?} */
- let newState;
- /** @type {?} */
- let mode;
- if (canSwitchMode(payload.viewMode, state.minMode)) {
- mode = payload.viewMode;
- newState = { view: { date, mode } };
- }
- else {
- mode = state.view.mode;
- newState = { selectedDate: date, view: { date, mode } };
- }
- return Object.assign({}, state, newState);
- }
- case BsDatepickerActions.CHANGE_VIEWMODE: {
- if (!canSwitchMode(action.payload, state.minMode)) {
- return state;
- }
- /** @type {?} */
- const date = state.view.date;
- /** @type {?} */
- const mode = action.payload;
- /** @type {?} */
- const newState = { view: { date, mode } };
- return Object.assign({}, state, newState);
- }
- case BsDatepickerActions.HOVER: {
- return Object.assign({}, state, { hoveredDate: action.payload });
- }
- case BsDatepickerActions.SELECT: {
- /** @type {?} */
- const newState = {
- selectedDate: action.payload,
- view: state.view
- };
- /** @type {?} */
- const mode = state.view.mode;
- /** @type {?} */
- const _date = action.payload || state.view.date;
- /** @type {?} */
- const date = getViewDate(_date, state.minDate, state.maxDate);
- newState.view = { mode, date };
- return Object.assign({}, state, newState);
- }
- case BsDatepickerActions.SET_OPTIONS: {
- /** @type {?} */
- const newState = action.payload;
- // preserve view mode
- /** @type {?} */
- const mode = newState.minMode ? newState.minMode : state.view.mode;
- /** @type {?} */
- const _viewDate = isDateValid(newState.value) && newState.value
- || isArray(newState.value) && isDateValid(newState.value[0]) && newState.value[0]
- || state.view.date;
- /** @type {?} */
- const date = getViewDate(_viewDate, newState.minDate, newState.maxDate);
- newState.view = { mode, date };
- // update selected value
- if (newState.value) {
- // if new value is array we work with date range
- if (isArray(newState.value)) {
- newState.selectedRange = newState.value;
- }
- // if new value is a date -> datepicker
- if (newState.value instanceof Date) {
- newState.selectedDate = newState.value;
- }
- // provided value is not supported :)
- // need to report it somehow
- }
- return Object.assign({}, state, newState);
- }
- // date range picker
- case BsDatepickerActions.SELECT_RANGE: {
- /** @type {?} */
- const newState = {
- selectedRange: action.payload,
- view: state.view
- };
- /** @type {?} */
- const mode = state.view.mode;
- /** @type {?} */
- const _date = action.payload && action.payload[0] || state.view.date;
- /** @type {?} */
- const date = getViewDate(_date, state.minDate, state.maxDate);
- newState.view = { mode, date };
- return Object.assign({}, state, newState);
- }
- case BsDatepickerActions.SET_MIN_DATE: {
- return Object.assign({}, state, {
- minDate: action.payload
- });
- }
- case BsDatepickerActions.SET_MAX_DATE: {
- return Object.assign({}, state, {
- maxDate: action.payload
- });
- }
- case BsDatepickerActions.SET_IS_DISABLED: {
- return Object.assign({}, state, {
- isDisabled: action.payload
- });
- }
- case BsDatepickerActions.SET_DATE_CUSTOM_CLASSES: {
- return Object.assign({}, state, {
- dateCustomClasses: action.payload
- });
- }
- default:
- return state;
- }
- }
- /**
- * @param {?} state
- * @return {?}
- */
- function calculateReducer(state) {
- // how many calendars
- /** @type {?} */
- const displayMonths = state.displayMonths;
- // use selected date on initial rendering if set
- /** @type {?} */
- let viewDate = state.view.date;
- if (state.view.mode === 'day') {
- state.monthViewOptions.firstDayOfWeek = getLocale(state.locale).firstDayOfWeek();
- /** @type {?} */
- const monthsModel = new Array(displayMonths);
- for (let monthIndex = 0; monthIndex < displayMonths; monthIndex++) {
- // todo: for unlinked calendars it will be harder
- monthsModel[monthIndex] = calcDaysCalendar(viewDate, state.monthViewOptions);
- viewDate = shiftDate(viewDate, { month: 1 });
- }
- return Object.assign({}, state, { monthsModel });
- }
- if (state.view.mode === 'month') {
- /** @type {?} */
- const monthsCalendar = new Array(displayMonths);
- for (let calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
- // todo: for unlinked calendars it will be harder
- monthsCalendar[calendarIndex] = formatMonthsCalendar(viewDate, getFormatOptions(state));
- viewDate = shiftDate(viewDate, { year: 1 });
- }
- return Object.assign({}, state, { monthsCalendar });
- }
- if (state.view.mode === 'year') {
- /** @type {?} */
- const yearsCalendarModel = new Array(displayMonths);
- for (let calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
- // todo: for unlinked calendars it will be harder
- yearsCalendarModel[calendarIndex] = formatYearsCalendar(viewDate, getFormatOptions(state), state.minMode === 'year' ? getYearsCalendarInitialDate(state, calendarIndex) : undefined);
- viewDate = shiftDate(viewDate, { year: yearsPerCalendar });
- }
- return Object.assign({}, state, { yearsCalendarModel });
- }
- return state;
- }
- /**
- * @param {?} state
- * @param {?} action
- * @return {?}
- */
- function formatReducer(state, action) {
- if (state.view.mode === 'day') {
- /** @type {?} */
- const formattedMonths = state.monthsModel.map((/**
- * @param {?} month
- * @param {?} monthIndex
- * @return {?}
- */
- (month, monthIndex) => formatDaysCalendar(month, getFormatOptions(state), monthIndex)));
- return Object.assign({}, state, { formattedMonths });
- }
- // how many calendars
- /** @type {?} */
- const displayMonths = state.displayMonths;
- // check initial rendering
- // use selected date on initial rendering if set
- /** @type {?} */
- let viewDate = state.view.date;
- if (state.view.mode === 'month') {
- /** @type {?} */
- const monthsCalendar = new Array(displayMonths);
- for (let calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
- // todo: for unlinked calendars it will be harder
- monthsCalendar[calendarIndex] = formatMonthsCalendar(viewDate, getFormatOptions(state));
- viewDate = shiftDate(viewDate, { year: 1 });
- }
- return Object.assign({}, state, { monthsCalendar });
- }
- if (state.view.mode === 'year') {
- /** @type {?} */
- const yearsCalendarModel = new Array(displayMonths);
- for (let calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
- // todo: for unlinked calendars it will be harder
- yearsCalendarModel[calendarIndex] = formatYearsCalendar(viewDate, getFormatOptions(state));
- viewDate = shiftDate(viewDate, { year: 16 });
- }
- return Object.assign({}, state, { yearsCalendarModel });
- }
- return state;
- }
- /**
- * @param {?} state
- * @param {?} action
- * @return {?}
- */
- function flagReducer(state, action) {
- if (state.view.mode === 'day') {
- /** @type {?} */
- const flaggedMonths = state.formattedMonths.map((/**
- * @param {?} formattedMonth
- * @param {?} monthIndex
- * @return {?}
- */
- (formattedMonth, monthIndex) => flagDaysCalendar(formattedMonth, {
- isDisabled: state.isDisabled,
- minDate: state.minDate,
- maxDate: state.maxDate,
- daysDisabled: state.daysDisabled,
- datesDisabled: state.datesDisabled,
- hoveredDate: state.hoveredDate,
- selectedDate: state.selectedDate,
- selectedRange: state.selectedRange,
- displayMonths: state.displayMonths,
- dateCustomClasses: state.dateCustomClasses,
- monthIndex
- })));
- return Object.assign({}, state, { flaggedMonths });
- }
- if (state.view.mode === 'month') {
- /** @type {?} */
- const flaggedMonthsCalendar = state.monthsCalendar.map((/**
- * @param {?} formattedMonth
- * @param {?} monthIndex
- * @return {?}
- */
- (formattedMonth, monthIndex) => flagMonthsCalendar(formattedMonth, {
- isDisabled: state.isDisabled,
- minDate: state.minDate,
- maxDate: state.maxDate,
- hoveredMonth: state.hoveredMonth,
- selectedDate: state.selectedDate,
- displayMonths: state.displayMonths,
- monthIndex
- })));
- return Object.assign({}, state, { flaggedMonthsCalendar });
- }
- if (state.view.mode === 'year') {
- /** @type {?} */
- const yearsCalendarFlagged = state.yearsCalendarModel.map((/**
- * @param {?} formattedMonth
- * @param {?} yearIndex
- * @return {?}
- */
- (formattedMonth, yearIndex) => flagYearsCalendar(formattedMonth, {
- isDisabled: state.isDisabled,
- minDate: state.minDate,
- maxDate: state.maxDate,
- hoveredYear: state.hoveredYear,
- selectedDate: state.selectedDate,
- displayMonths: state.displayMonths,
- yearIndex
- })));
- return Object.assign({}, state, { yearsCalendarFlagged });
- }
- return state;
- }
- /**
- * @param {?} state
- * @param {?} action
- * @return {?}
- */
- function navigateOffsetReducer(state, action) {
- /** @type {?} */
- const newState = {
- view: {
- mode: state.view.mode,
- date: shiftViewDate(state, action)
- }
- };
- return Object.assign({}, state, newState);
- }
- /**
- * @param {?} state
- * @param {?} action
- * @return {?}
- */
- function shiftViewDate(state, action) {
- if (state.view.mode === 'year' && state.minMode === 'year') {
- /** @type {?} */
- const initialDate = getYearsCalendarInitialDate(state, 0);
- /** @type {?} */
- const middleDate = shiftDate(initialDate, { year: -initialYearShift });
- return shiftDate(middleDate, action.payload);
- }
- return shiftDate(startOf(state.view.date, 'month'), action.payload);
- }
- /**
- * @param {?} state
- * @return {?}
- */
- function getFormatOptions(state) {
- return {
- locale: state.locale,
- monthTitle: state.monthTitle,
- yearTitle: state.yearTitle,
- dayLabel: state.dayLabel,
- monthLabel: state.monthLabel,
- yearLabel: state.yearLabel,
- weekNumbers: state.weekNumbers
- };
- }
- /**
- * if view date is provided (bsValue|ngModel) it should be shown
- * if view date is not provider:
- * if minDate>currentDate (default view value), show minDate
- * if maxDate<currentDate(default view value) show maxDate
- * @param {?} viewDate
- * @param {?} minDate
- * @param {?} maxDate
- * @return {?}
- */
- function getViewDate(viewDate, minDate, maxDate) {
- /** @type {?} */
- const _date = Array.isArray(viewDate) ? viewDate[0] : viewDate;
- if (minDate && isAfter(minDate, _date, 'day')) {
- return minDate;
- }
- if (maxDate && isBefore(maxDate, _date, 'day')) {
- return maxDate;
- }
- return _date;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerStore extends MiniStore {
- constructor() {
- /** @type {?} */
- const _dispatcher = new BehaviorSubject({
- type: '[datepicker] dispatcher init'
- });
- /** @type {?} */
- const state = new MiniState(initialDatepickerState, _dispatcher, bsDatepickerReducer);
- super(_dispatcher, bsDatepickerReducer, state);
- }
- }
- BsDatepickerStore.decorators = [
- { type: Injectable }
- ];
- /** @nocollapse */
- BsDatepickerStore.ctorParameters = () => [];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const DATEPICKER_ANIMATION_TIMING = '220ms cubic-bezier(0, 0, 0.2, 1)';
- /** @type {?} */
- const datepickerAnimation = trigger('datepickerAnimation', [
- state('animated-down', style({ height: '*', overflow: 'hidden' })),
- transition('* => animated-down', [
- style({ height: 0, overflow: 'hidden' }),
- animate(DATEPICKER_ANIMATION_TIMING)
- ]),
- state('animated-up', style({ height: '*', overflow: 'hidden' })),
- transition('* => animated-up', [
- style({ height: '*', overflow: 'hidden' }),
- animate(DATEPICKER_ANIMATION_TIMING)
- ]),
- transition('* => unanimated', animate('0s'))
- ]);
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerContainerComponent extends BsDatepickerAbstractComponent {
- /**
- * @param {?} _renderer
- * @param {?} _config
- * @param {?} _store
- * @param {?} _element
- * @param {?} _actions
- * @param {?} _effects
- * @param {?} _positionService
- */
- constructor(_renderer, _config, _store, _element, _actions, _effects, _positionService) {
- super();
- this._config = _config;
- this._store = _store;
- this._element = _element;
- this._actions = _actions;
- this._positionService = _positionService;
- this.valueChange = new EventEmitter();
- this.animationState = 'void';
- this._subs = [];
- this._effects = _effects;
- _renderer.setStyle(_element.nativeElement, 'display', 'block');
- _renderer.setStyle(_element.nativeElement, 'position', 'absolute');
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set value(value) {
- this._effects.setValue(value);
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- this._positionService.setOptions({
- modifiers: { flip: { enabled: this._config.adaptivePosition } },
- allowedPositions: ['top', 'bottom']
- });
- this._positionService.event$
- .pipe(take(1))
- .subscribe((/**
- * @return {?}
- */
- () => {
- this._positionService.disable();
- if (this._config.isAnimated) {
- this.animationState = this.isTopPosition ? 'animated-up' : 'animated-down';
- return;
- }
- this.animationState = 'unanimated';
- }));
- this.isOtherMonthsActive = this._config.selectFromOtherMonth;
- this.containerClass = this._config.containerClass;
- this._effects
- .init(this._store)
- // intial state options
- .setOptions(this._config)
- // data binding view --> model
- .setBindings(this)
- // set event handlers
- .setEventHandlers(this)
- .registerDatepickerSideEffects();
- // todo: move it somewhere else
- // on selected date change
- this._subs.push(this._store
- /* tslint:disable-next-line: no-any */
- .select((/**
- * @param {?} state
- * @return {?}
- */
- (state) => state.selectedDate))
- /* tslint:disable-next-line: no-any */
- .subscribe((/**
- * @param {?} date
- * @return {?}
- */
- (date) => this.valueChange.emit(date))));
- }
- /**
- * @return {?}
- */
- get isTopPosition() {
- return this._element.nativeElement.classList.contains('top');
- }
- /**
- * @return {?}
- */
- positionServiceEnable() {
- this._positionService.enable();
- }
- /**
- * @param {?} day
- * @return {?}
- */
- daySelectHandler(day) {
- /** @type {?} */
- const isDisabled = this.isOtherMonthsActive ? day.isDisabled : (day.isOtherMonth || day.isDisabled);
- if (isDisabled) {
- return;
- }
- this._store.dispatch(this._actions.select(day.date));
- }
- /**
- * @return {?}
- */
- ngOnDestroy() {
- for (const sub of this._subs) {
- sub.unsubscribe();
- }
- this._effects.destroy();
- }
- }
- BsDatepickerContainerComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-datepicker-container',
- providers: [BsDatepickerStore, BsDatepickerEffects],
- 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",
- host: {
- class: 'bottom',
- '(click)': '_stopPropagation($event)',
- role: 'dialog',
- 'aria-label': 'calendar'
- },
- animations: [datepickerAnimation]
- }] }
- ];
- /** @nocollapse */
- BsDatepickerContainerComponent.ctorParameters = () => [
- { type: Renderer2 },
- { type: BsDatepickerConfig },
- { type: BsDatepickerStore },
- { type: ElementRef },
- { type: BsDatepickerActions },
- { type: BsDatepickerEffects },
- { type: PositioningService }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerDirective {
- /**
- * @param {?} _config
- * @param {?} _elementRef
- * @param {?} _renderer
- * @param {?} _viewContainerRef
- * @param {?} cis
- */
- constructor(_config, _elementRef, _renderer, _viewContainerRef, cis) {
- this._config = _config;
- /**
- * Placement of a datepicker. Accepts: "top", "bottom", "left", "right"
- */
- this.placement = 'bottom';
- /**
- * Specifies events that should trigger. Supports a space separated list of
- * event names.
- */
- this.triggers = 'click';
- /**
- * Close datepicker on outside click
- */
- this.outsideClick = true;
- /**
- * A selector specifying the element the datepicker should be appended to.
- */
- this.container = 'body';
- this.outsideEsc = true;
- /**
- * Emits when datepicker value has been changed
- */
- this.bsValueChange = new EventEmitter();
- this._subs = [];
- // todo: assign only subset of fields
- Object.assign(this, this._config);
- this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
- this.onShown = this._datepicker.onShown;
- this.onHidden = this._datepicker.onHidden;
- }
- /**
- * Returns whether or not the datepicker is currently being shown
- * @return {?}
- */
- get isOpen() {
- return this._datepicker.isShown;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set isOpen(value) {
- if (value) {
- this.show();
- }
- else {
- this.hide();
- }
- }
- /**
- * Initial value of datepicker
- * @param {?} value
- * @return {?}
- */
- set bsValue(value) {
- if (this._bsValue === value) {
- return;
- }
- this._bsValue = value;
- this.bsValueChange.emit(value);
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- this._datepicker.listen({
- outsideClick: this.outsideClick,
- outsideEsc: this.outsideEsc,
- triggers: this.triggers,
- show: (/**
- * @return {?}
- */
- () => this.show())
- });
- this.setConfig();
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- ngOnChanges(changes) {
- if (!this._datepickerRef || !this._datepickerRef.instance) {
- return;
- }
- if (changes.minDate) {
- this._datepickerRef.instance.minDate = this.minDate;
- }
- if (changes.maxDate) {
- this._datepickerRef.instance.maxDate = this.maxDate;
- }
- if (changes.daysDisabled) {
- this._datepickerRef.instance.daysDisabled = this.daysDisabled;
- }
- if (changes.datesDisabled) {
- this._datepickerRef.instance.datesDisabled = this.datesDisabled;
- }
- if (changes.isDisabled) {
- this._datepickerRef.instance.isDisabled = this.isDisabled;
- }
- if (changes.dateCustomClasses) {
- this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
- }
- }
- /**
- * Opens an element’s datepicker. This is considered a “manual” triggering of
- * the datepicker.
- * @return {?}
- */
- show() {
- if (this._datepicker.isShown) {
- return;
- }
- this.setConfig();
- this._datepickerRef = this._datepicker
- .provide({ provide: BsDatepickerConfig, useValue: this._config })
- .attach(BsDatepickerContainerComponent)
- .to(this.container)
- .position({ attachment: this.placement })
- .show({ placement: this.placement });
- // if date changes from external source (model -> view)
- this._subs.push(this.bsValueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this._datepickerRef.instance.value = value;
- })));
- // if date changes from picker (view -> model)
- this._subs.push(this._datepickerRef.instance.valueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this.bsValue = value;
- this.hide();
- })));
- }
- /**
- * Closes an element’s datepicker. This is considered a “manual” triggering of
- * the datepicker.
- * @return {?}
- */
- hide() {
- if (this.isOpen) {
- this._datepicker.hide();
- }
- for (const sub of this._subs) {
- sub.unsubscribe();
- }
- }
- /**
- * Toggles an element’s datepicker. This is considered a “manual” triggering
- * of the datepicker.
- * @return {?}
- */
- toggle() {
- if (this.isOpen) {
- return this.hide();
- }
- this.show();
- }
- /**
- * Set config for datepicker
- * @return {?}
- */
- setConfig() {
- this._config = Object.assign({}, this._config, this.bsConfig, {
- value: this._bsValue,
- isDisabled: this.isDisabled,
- minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
- maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
- daysDisabled: this.daysDisabled || this.bsConfig && this.bsConfig.daysDisabled,
- dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
- datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled,
- minMode: this.minMode || this.bsConfig && this.bsConfig.minMode
- });
- }
- /**
- * @return {?}
- */
- ngOnDestroy() {
- this._datepicker.dispose();
- }
- }
- BsDatepickerDirective.decorators = [
- { type: Directive, args: [{
- selector: '[bsDatepicker]',
- exportAs: 'bsDatepicker'
- },] }
- ];
- /** @nocollapse */
- BsDatepickerDirective.ctorParameters = () => [
- { type: BsDatepickerConfig },
- { type: ElementRef },
- { type: Renderer2 },
- { type: ViewContainerRef },
- { type: ComponentLoaderFactory }
- ];
- BsDatepickerDirective.propDecorators = {
- placement: [{ type: Input }],
- triggers: [{ type: Input }],
- outsideClick: [{ type: Input }],
- container: [{ type: Input }],
- outsideEsc: [{ type: Input }],
- isOpen: [{ type: Input }],
- onShown: [{ type: Output }],
- onHidden: [{ type: Output }],
- bsValue: [{ type: Input }],
- bsConfig: [{ type: Input }],
- isDisabled: [{ type: Input }],
- minDate: [{ type: Input }],
- maxDate: [{ type: Input }],
- minMode: [{ type: Input }],
- daysDisabled: [{ type: Input }],
- datesDisabled: [{ type: Input }],
- dateCustomClasses: [{ type: Input }],
- bsValueChange: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerInlineConfig extends BsDatepickerConfig {
- }
- BsDatepickerInlineConfig.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerInlineContainerComponent extends BsDatepickerContainerComponent {
- /**
- * @param {?} _renderer
- * @param {?} _config
- * @param {?} _store
- * @param {?} _element
- * @param {?} _actions
- * @param {?} _effects
- * @param {?} _positioningService
- */
- constructor(_renderer, _config, _store, _element, _actions, _effects, _positioningService) {
- super(_renderer, _config, _store, _element, _actions, _effects, _positioningService);
- _renderer.setStyle(_element.nativeElement, 'display', 'inline-block');
- _renderer.setStyle(_element.nativeElement, 'position', 'static');
- }
- }
- BsDatepickerInlineContainerComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-datepicker-inline-container',
- providers: [BsDatepickerStore, BsDatepickerEffects],
- 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",
- host: {
- '(click)': '_stopPropagation($event)'
- },
- animations: [datepickerAnimation]
- }] }
- ];
- /** @nocollapse */
- BsDatepickerInlineContainerComponent.ctorParameters = () => [
- { type: Renderer2 },
- { type: BsDatepickerConfig },
- { type: BsDatepickerStore },
- { type: ElementRef },
- { type: BsDatepickerActions },
- { type: BsDatepickerEffects },
- { type: PositioningService }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerInlineDirective {
- /**
- * @param {?} _config
- * @param {?} _elementRef
- * @param {?} _renderer
- * @param {?} _viewContainerRef
- * @param {?} cis
- */
- constructor(_config, _elementRef, _renderer, _viewContainerRef, cis) {
- this._config = _config;
- this._elementRef = _elementRef;
- /**
- * Emits when datepicker value has been changed
- */
- this.bsValueChange = new EventEmitter();
- this._subs = [];
- // todo: assign only subset of fields
- Object.assign(this, this._config);
- this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
- }
- /**
- * Initial value of datepicker
- * @param {?} value
- * @return {?}
- */
- set bsValue(value) {
- if (this._bsValue === value) {
- return;
- }
- this._bsValue = value;
- this.bsValueChange.emit(value);
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- this.setConfig();
- this._datepickerRef = this._datepicker
- .provide({ provide: BsDatepickerConfig, useValue: this._config })
- .attach(BsDatepickerInlineContainerComponent)
- .to(this._elementRef)
- .show();
- // if date changes from external source (model -> view)
- this._subs.push(this.bsValueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this._datepickerRef.instance.value = value;
- })));
- // if date changes from picker (view -> model)
- this._subs.push(this._datepickerRef.instance.valueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this.bsValue = value;
- })));
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- ngOnChanges(changes) {
- if (!this._datepickerRef || !this._datepickerRef.instance) {
- return;
- }
- if (changes.minDate) {
- this._datepickerRef.instance.minDate = this.minDate;
- this._datepickerRef.instance.value = this._bsValue;
- }
- if (changes.maxDate) {
- this._datepickerRef.instance.maxDate = this.maxDate;
- this._datepickerRef.instance.value = this._bsValue;
- }
- if (changes.datesDisabled) {
- this._datepickerRef.instance.datesDisabled = this.datesDisabled;
- this._datepickerRef.instance.value = this._bsValue;
- }
- if (changes.isDisabled) {
- this._datepickerRef.instance.isDisabled = this.isDisabled;
- }
- if (changes.dateCustomClasses) {
- this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
- }
- }
- /**
- * Set config for datepicker
- * @return {?}
- */
- setConfig() {
- this._config = Object.assign({}, this._config, this.bsConfig, {
- value: this._bsValue,
- isDisabled: this.isDisabled,
- minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
- maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
- dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
- datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled
- });
- }
- /**
- * @return {?}
- */
- ngOnDestroy() {
- this._datepicker.dispose();
- }
- }
- BsDatepickerInlineDirective.decorators = [
- { type: Directive, args: [{
- selector: 'bs-datepicker-inline',
- exportAs: 'bsDatepickerInline'
- },] }
- ];
- /** @nocollapse */
- BsDatepickerInlineDirective.ctorParameters = () => [
- { type: BsDatepickerInlineConfig },
- { type: ElementRef },
- { type: Renderer2 },
- { type: ViewContainerRef },
- { type: ComponentLoaderFactory }
- ];
- BsDatepickerInlineDirective.propDecorators = {
- bsValue: [{ type: Input }],
- bsConfig: [{ type: Input }],
- isDisabled: [{ type: Input }],
- minDate: [{ type: Input }],
- maxDate: [{ type: Input }],
- dateCustomClasses: [{ type: Input }],
- datesDisabled: [{ type: Input }],
- bsValueChange: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaterangepickerInlineConfig extends BsDatepickerConfig {
- constructor() {
- super(...arguments);
- // DatepickerRenderOptions
- this.displayMonths = 2;
- /**
- * turn on/off animation
- */
- this.isAnimated = false;
- }
- }
- BsDaterangepickerInlineConfig.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaterangepickerContainerComponent extends BsDatepickerAbstractComponent {
- /**
- * @param {?} _renderer
- * @param {?} _config
- * @param {?} _store
- * @param {?} _element
- * @param {?} _actions
- * @param {?} _effects
- * @param {?} _positionService
- */
- constructor(_renderer, _config, _store, _element, _actions, _effects, _positionService) {
- super();
- this._config = _config;
- this._store = _store;
- this._element = _element;
- this._actions = _actions;
- this._positionService = _positionService;
- this.valueChange = new EventEmitter();
- this.animationState = 'void';
- this._rangeStack = [];
- this._subs = [];
- this._effects = _effects;
- _renderer.setStyle(_element.nativeElement, 'display', 'block');
- _renderer.setStyle(_element.nativeElement, 'position', 'absolute');
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set value(value) {
- this._effects.setRangeValue(value);
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- this._positionService.setOptions({
- modifiers: { flip: { enabled: this._config.adaptivePosition } },
- allowedPositions: ['top', 'bottom']
- });
- this._positionService.event$
- .pipe(take(1))
- .subscribe((/**
- * @return {?}
- */
- () => {
- this._positionService.disable();
- if (this._config.isAnimated) {
- this.animationState = this.isTopPosition ? 'animated-up' : 'animated-down';
- return;
- }
- this.animationState = 'unanimated';
- }));
- this.containerClass = this._config.containerClass;
- this.isOtherMonthsActive = this._config.selectFromOtherMonth;
- this._effects
- .init(this._store)
- // intial state options
- // todo: fix this, split configs
- .setOptions(this._config)
- // data binding view --> model
- .setBindings(this)
- // set event handlers
- .setEventHandlers(this)
- .registerDatepickerSideEffects();
- // todo: move it somewhere else
- // on selected date change
- this._subs.push(this._store
- .select((/**
- * @param {?} state
- * @return {?}
- */
- state => state.selectedRange))
- .subscribe((/**
- * @param {?} date
- * @return {?}
- */
- date => this.valueChange.emit(date))));
- }
- /**
- * @return {?}
- */
- get isTopPosition() {
- return this._element.nativeElement.classList.contains('top');
- }
- /**
- * @return {?}
- */
- positionServiceEnable() {
- this._positionService.enable();
- }
- /**
- * @param {?} day
- * @return {?}
- */
- daySelectHandler(day) {
- /** @type {?} */
- const isDisabled = this.isOtherMonthsActive ? day.isDisabled : (day.isOtherMonth || day.isDisabled);
- if (isDisabled) {
- return;
- }
- // if only one date is already selected
- // and user clicks on previous date
- // start selection from new date
- // but if new date is after initial one
- // than finish selection
- if (this._rangeStack.length === 1) {
- this._rangeStack =
- day.date >= this._rangeStack[0]
- ? [this._rangeStack[0], day.date]
- : [day.date];
- }
- if (this._rangeStack.length === 0) {
- this._rangeStack = [day.date];
- }
- this._store.dispatch(this._actions.selectRange(this._rangeStack));
- if (this._rangeStack.length === 2) {
- this._rangeStack = [];
- }
- }
- /**
- * @return {?}
- */
- ngOnDestroy() {
- for (const sub of this._subs) {
- sub.unsubscribe();
- }
- this._effects.destroy();
- }
- }
- BsDaterangepickerContainerComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-daterangepicker-container',
- providers: [BsDatepickerStore, BsDatepickerEffects],
- 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",
- host: {
- class: 'bottom',
- '(click)': '_stopPropagation($event)',
- role: 'dialog',
- 'aria-label': 'calendar'
- },
- animations: [datepickerAnimation]
- }] }
- ];
- /** @nocollapse */
- BsDaterangepickerContainerComponent.ctorParameters = () => [
- { type: Renderer2 },
- { type: BsDatepickerConfig },
- { type: BsDatepickerStore },
- { type: ElementRef },
- { type: BsDatepickerActions },
- { type: BsDatepickerEffects },
- { type: PositioningService }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaterangepickerInlineContainerComponent extends BsDaterangepickerContainerComponent {
- /**
- * @param {?} _renderer
- * @param {?} _config
- * @param {?} _store
- * @param {?} _element
- * @param {?} _actions
- * @param {?} _effects
- * @param {?} _positioningService
- */
- constructor(_renderer, _config, _store, _element, _actions, _effects, _positioningService) {
- super(_renderer, _config, _store, _element, _actions, _effects, _positioningService);
- _renderer.setStyle(_element.nativeElement, 'display', 'inline-block');
- _renderer.setStyle(_element.nativeElement, 'position', 'static');
- }
- }
- BsDaterangepickerInlineContainerComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-daterangepicker-inline-container',
- providers: [BsDatepickerStore, BsDatepickerEffects],
- 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",
- host: {
- '(click)': '_stopPropagation($event)'
- },
- animations: [datepickerAnimation]
- }] }
- ];
- /** @nocollapse */
- BsDaterangepickerInlineContainerComponent.ctorParameters = () => [
- { type: Renderer2 },
- { type: BsDatepickerConfig },
- { type: BsDatepickerStore },
- { type: ElementRef },
- { type: BsDatepickerActions },
- { type: BsDatepickerEffects },
- { type: PositioningService }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaterangepickerInlineDirective {
- /**
- * @param {?} _config
- * @param {?} _elementRef
- * @param {?} _renderer
- * @param {?} _viewContainerRef
- * @param {?} cis
- */
- constructor(_config, _elementRef, _renderer, _viewContainerRef, cis) {
- this._config = _config;
- this._elementRef = _elementRef;
- /**
- * Emits when daterangepicker value has been changed
- */
- this.bsValueChange = new EventEmitter();
- this._subs = [];
- // todo: assign only subset of fields
- Object.assign(this, this._config);
- this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
- }
- /**
- * Initial value of datepicker
- * @param {?} value
- * @return {?}
- */
- set bsValue(value) {
- if (this._bsValue === value) {
- return;
- }
- this._bsValue = value;
- this.bsValueChange.emit(value);
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- this.setConfig();
- this._datepickerRef = this._datepicker
- .provide({ provide: BsDatepickerConfig, useValue: this._config })
- .attach(BsDaterangepickerInlineContainerComponent)
- .to(this._elementRef)
- .show();
- // if date changes from external source (model -> view)
- this._subs.push(this.bsValueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this._datepickerRef.instance.value = value;
- })));
- // if date changes from picker (view -> model)
- this._subs.push(this._datepickerRef.instance.valueChange
- .pipe(filter((/**
- * @param {?} range
- * @return {?}
- */
- (range) => range && range[0] && !!range[1])))
- .subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this.bsValue = value;
- })));
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- ngOnChanges(changes) {
- if (!this._datepickerRef || !this._datepickerRef.instance) {
- return;
- }
- if (changes.minDate) {
- this._datepickerRef.instance.minDate = this.minDate;
- }
- if (changes.maxDate) {
- this._datepickerRef.instance.maxDate = this.maxDate;
- }
- if (changes.datesDisabled) {
- this._datepickerRef.instance.datesDisabled = this.datesDisabled;
- }
- if (changes.isDisabled) {
- this._datepickerRef.instance.isDisabled = this.isDisabled;
- }
- if (changes.dateCustomClasses) {
- this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
- }
- }
- /**
- * Set config for datepicker
- * @return {?}
- */
- setConfig() {
- this._config = Object.assign({}, this._config, this.bsConfig, {
- value: this._bsValue,
- isDisabled: this.isDisabled,
- minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
- maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
- dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
- datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled
- });
- }
- /**
- * @return {?}
- */
- ngOnDestroy() {
- this._datepicker.dispose();
- }
- }
- BsDaterangepickerInlineDirective.decorators = [
- { type: Directive, args: [{
- selector: 'bs-daterangepicker-inline',
- exportAs: 'bsDaterangepickerInline'
- },] }
- ];
- /** @nocollapse */
- BsDaterangepickerInlineDirective.ctorParameters = () => [
- { type: BsDaterangepickerInlineConfig },
- { type: ElementRef },
- { type: Renderer2 },
- { type: ViewContainerRef },
- { type: ComponentLoaderFactory }
- ];
- BsDaterangepickerInlineDirective.propDecorators = {
- bsValue: [{ type: Input }],
- bsConfig: [{ type: Input }],
- isDisabled: [{ type: Input }],
- minDate: [{ type: Input }],
- maxDate: [{ type: Input }],
- dateCustomClasses: [{ type: Input }],
- datesDisabled: [{ type: Input }],
- bsValueChange: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const BS_DATEPICKER_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- () => BsDatepickerInputDirective)),
- multi: true
- };
- /** @type {?} */
- const BS_DATEPICKER_VALIDATOR = {
- provide: NG_VALIDATORS,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- () => BsDatepickerInputDirective)),
- multi: true
- };
- class BsDatepickerInputDirective {
- /**
- * @param {?} _picker
- * @param {?} _localeService
- * @param {?} _renderer
- * @param {?} _elRef
- * @param {?} changeDetection
- */
- constructor(_picker, _localeService, _renderer, _elRef, changeDetection) {
- this._picker = _picker;
- this._localeService = _localeService;
- this._renderer = _renderer;
- this._elRef = _elRef;
- this.changeDetection = changeDetection;
- this._onChange = Function.prototype;
- this._onTouched = Function.prototype;
- /* tslint:disable-next-line: no-unused-variable */
- this._validatorChange = Function.prototype;
- // update input value on datepicker value update
- this._picker.bsValueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this._setInputValue(value);
- if (this._value !== value) {
- this._value = value;
- this._onChange(value);
- this._onTouched();
- }
- this.changeDetection.markForCheck();
- }));
- // update input value on locale change
- this._localeService.localeChange.subscribe((/**
- * @return {?}
- */
- () => {
- this._setInputValue(this._value);
- }));
- }
- /**
- * @param {?} value
- * @return {?}
- */
- _setInputValue(value) {
- /** @type {?} */
- const initialDate = !value ? ''
- : formatDate(value, this._picker._config.dateInputFormat, this._localeService.currentLocale);
- this._renderer.setProperty(this._elRef.nativeElement, 'value', initialDate);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- onChange(event) {
- /* tslint:disable-next-line: no-any*/
- this.writeValue(((/** @type {?} */ (event.target))).value);
- this._onChange(this._value);
- this._onTouched();
- }
- /**
- * @param {?} c
- * @return {?}
- */
- validate(c) {
- /** @type {?} */
- const _value = c.value;
- /* tslint:disable-next-line: prefer-switch */
- if (_value === null || _value === undefined || _value === '') {
- return null;
- }
- if (isDate(_value)) {
- /** @type {?} */
- const _isDateValid = isDateValid(_value);
- if (!_isDateValid) {
- return { bsDate: { invalid: _value } };
- }
- if (this._picker && this._picker.minDate && isBefore(_value, this._picker.minDate, 'date')) {
- return { bsDate: { minDate: this._picker.minDate } };
- }
- if (this._picker && this._picker.maxDate && isAfter(_value, this._picker.maxDate, 'date')) {
- return { bsDate: { maxDate: this._picker.maxDate } };
- }
- }
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnValidatorChange(fn) {
- this._validatorChange = fn;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- writeValue(value) {
- if (!value) {
- this._value = null;
- }
- else {
- /** @type {?} */
- const _localeKey = this._localeService.currentLocale;
- /** @type {?} */
- const _locale = getLocale(_localeKey);
- if (!_locale) {
- throw new Error(`Locale "${_localeKey}" is not defined, please add it with "defineLocale(...)"`);
- }
- this._value = parseDate(value, this._picker._config.dateInputFormat, this._localeService.currentLocale);
- if (this._picker._config.useUtc) {
- this._value = utcAsLocal(this._value);
- }
- }
- this._picker.bsValue = this._value;
- }
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- setDisabledState(isDisabled) {
- this._picker.isDisabled = isDisabled;
- if (isDisabled) {
- this._renderer.setAttribute(this._elRef.nativeElement, 'disabled', 'disabled');
- return;
- }
- this._renderer.removeAttribute(this._elRef.nativeElement, 'disabled');
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnChange(fn) {
- this._onChange = fn;
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnTouched(fn) {
- this._onTouched = fn;
- }
- /**
- * @return {?}
- */
- onBlur() {
- this._onTouched();
- }
- /**
- * @return {?}
- */
- hide() {
- this._picker.hide();
- this._renderer.selectRootElement(this._elRef.nativeElement).blur();
- }
- }
- BsDatepickerInputDirective.decorators = [
- { type: Directive, args: [{
- selector: `input[bsDatepicker]`,
- host: {
- '(change)': 'onChange($event)',
- '(keyup.esc)': 'hide()',
- '(blur)': 'onBlur()'
- },
- providers: [BS_DATEPICKER_VALUE_ACCESSOR, BS_DATEPICKER_VALIDATOR]
- },] }
- ];
- /** @nocollapse */
- BsDatepickerInputDirective.ctorParameters = () => [
- { type: BsDatepickerDirective, decorators: [{ type: Host }] },
- { type: BsLocaleService },
- { type: Renderer2 },
- { type: ElementRef },
- { type: ChangeDetectorRef }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaterangepickerConfig extends BsDatepickerConfig {
- constructor() {
- super(...arguments);
- // DatepickerRenderOptions
- this.displayMonths = 2;
- }
- }
- BsDaterangepickerConfig.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaterangepickerDirective {
- /**
- * @param {?} _config
- * @param {?} _elementRef
- * @param {?} _renderer
- * @param {?} _viewContainerRef
- * @param {?} cis
- */
- constructor(_config, _elementRef, _renderer, _viewContainerRef, cis) {
- this._config = _config;
- /**
- * Placement of a daterangepicker. Accepts: "top", "bottom", "left", "right"
- */
- this.placement = 'bottom';
- /**
- * Specifies events that should trigger. Supports a space separated list of
- * event names.
- */
- this.triggers = 'click';
- /**
- * Close daterangepicker on outside click
- */
- this.outsideClick = true;
- /**
- * A selector specifying the element the daterangepicker should be appended to.
- */
- this.container = 'body';
- this.outsideEsc = true;
- /**
- * Emits when daterangepicker value has been changed
- */
- this.bsValueChange = new EventEmitter();
- this._subs = [];
- this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
- Object.assign(this, _config);
- this.onShown = this._datepicker.onShown;
- this.onHidden = this._datepicker.onHidden;
- }
- /**
- * Returns whether or not the daterangepicker is currently being shown
- * @return {?}
- */
- get isOpen() {
- return this._datepicker.isShown;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set isOpen(value) {
- if (value) {
- this.show();
- }
- else {
- this.hide();
- }
- }
- /**
- * Initial value of daterangepicker
- * @param {?} value
- * @return {?}
- */
- set bsValue(value) {
- if (this._bsValue === value) {
- return;
- }
- this._bsValue = value;
- this.bsValueChange.emit(value);
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- this._datepicker.listen({
- outsideClick: this.outsideClick,
- outsideEsc: this.outsideEsc,
- triggers: this.triggers,
- show: (/**
- * @return {?}
- */
- () => this.show())
- });
- this.setConfig();
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- ngOnChanges(changes) {
- if (!this._datepickerRef || !this._datepickerRef.instance) {
- return;
- }
- if (changes.minDate) {
- this._datepickerRef.instance.minDate = this.minDate;
- }
- if (changes.maxDate) {
- this._datepickerRef.instance.maxDate = this.maxDate;
- }
- if (changes.datesDisabled) {
- this._datepickerRef.instance.datesDisabled = this.datesDisabled;
- }
- if (changes.isDisabled) {
- this._datepickerRef.instance.isDisabled = this.isDisabled;
- }
- if (changes.dateCustomClasses) {
- this._datepickerRef.instance.dateCustomClasses = this.dateCustomClasses;
- }
- }
- /**
- * Opens an element’s datepicker. This is considered a “manual” triggering of
- * the datepicker.
- * @return {?}
- */
- show() {
- if (this._datepicker.isShown) {
- return;
- }
- this.setConfig();
- this._datepickerRef = this._datepicker
- .provide({ provide: BsDatepickerConfig, useValue: this._config })
- .attach(BsDaterangepickerContainerComponent)
- .to(this.container)
- .position({ attachment: this.placement })
- .show({ placement: this.placement });
- // if date changes from external source (model -> view)
- this._subs.push(this.bsValueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this._datepickerRef.instance.value = value;
- })));
- // if date changes from picker (view -> model)
- this._subs.push(this._datepickerRef.instance.valueChange
- .pipe(filter((/**
- * @param {?} range
- * @return {?}
- */
- (range) => range && range[0] && !!range[1])))
- .subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this.bsValue = value;
- this.hide();
- })));
- }
- /**
- * Set config for daterangepicker
- * @return {?}
- */
- setConfig() {
- this._config = Object.assign({}, this._config, this.bsConfig, {
- value: this._bsValue,
- isDisabled: this.isDisabled,
- minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
- maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate,
- dateCustomClasses: this.dateCustomClasses || this.bsConfig && this.bsConfig.dateCustomClasses,
- datesDisabled: this.datesDisabled || this.bsConfig && this.bsConfig.datesDisabled
- });
- }
- /**
- * Closes an element’s datepicker. This is considered a “manual” triggering of
- * the datepicker.
- * @return {?}
- */
- hide() {
- if (this.isOpen) {
- this._datepicker.hide();
- }
- for (const sub of this._subs) {
- sub.unsubscribe();
- }
- }
- /**
- * Toggles an element’s datepicker. This is considered a “manual” triggering
- * of the datepicker.
- * @return {?}
- */
- toggle() {
- if (this.isOpen) {
- return this.hide();
- }
- this.show();
- }
- /**
- * @return {?}
- */
- ngOnDestroy() {
- this._datepicker.dispose();
- }
- }
- BsDaterangepickerDirective.decorators = [
- { type: Directive, args: [{
- selector: '[bsDaterangepicker]',
- exportAs: 'bsDaterangepicker'
- },] }
- ];
- /** @nocollapse */
- BsDaterangepickerDirective.ctorParameters = () => [
- { type: BsDaterangepickerConfig },
- { type: ElementRef },
- { type: Renderer2 },
- { type: ViewContainerRef },
- { type: ComponentLoaderFactory }
- ];
- BsDaterangepickerDirective.propDecorators = {
- placement: [{ type: Input }],
- triggers: [{ type: Input }],
- outsideClick: [{ type: Input }],
- container: [{ type: Input }],
- outsideEsc: [{ type: Input }],
- isOpen: [{ type: Input }],
- onShown: [{ type: Output }],
- onHidden: [{ type: Output }],
- bsValue: [{ type: Input }],
- bsConfig: [{ type: Input }],
- isDisabled: [{ type: Input }],
- minDate: [{ type: Input }],
- maxDate: [{ type: Input }],
- dateCustomClasses: [{ type: Input }],
- datesDisabled: [{ type: Input }],
- bsValueChange: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const BS_DATERANGEPICKER_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- () => BsDaterangepickerInputDirective)),
- multi: true
- };
- /** @type {?} */
- const BS_DATERANGEPICKER_VALIDATOR = {
- provide: NG_VALIDATORS,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- () => BsDaterangepickerInputDirective)),
- multi: true
- };
- class BsDaterangepickerInputDirective {
- /**
- * @param {?} _picker
- * @param {?} _localeService
- * @param {?} _renderer
- * @param {?} _elRef
- * @param {?} changeDetection
- */
- constructor(_picker, _localeService, _renderer, _elRef, changeDetection) {
- this._picker = _picker;
- this._localeService = _localeService;
- this._renderer = _renderer;
- this._elRef = _elRef;
- this.changeDetection = changeDetection;
- this._onChange = Function.prototype;
- this._onTouched = Function.prototype;
- /* tslint:disable-next-line: no-unused-variable */
- this._validatorChange = Function.prototype;
- // update input value on datepicker value update
- this._picker.bsValueChange.subscribe((/**
- * @param {?} value
- * @return {?}
- */
- (value) => {
- this._setInputValue(value);
- if (this._value !== value) {
- this._value = value;
- this._onChange(value);
- this._onTouched();
- }
- this.changeDetection.markForCheck();
- }));
- // update input value on locale change
- this._localeService.localeChange.subscribe((/**
- * @return {?}
- */
- () => {
- this._setInputValue(this._value);
- }));
- }
- /**
- * @param {?} date
- * @return {?}
- */
- _setInputValue(date) {
- /** @type {?} */
- let range = '';
- if (date) {
- /** @type {?} */
- const start = !date[0] ? ''
- : formatDate(date[0], this._picker._config.rangeInputFormat, this._localeService.currentLocale);
- /** @type {?} */
- const end = !date[1] ? ''
- : formatDate(date[1], this._picker._config.rangeInputFormat, this._localeService.currentLocale);
- range = (start && end) ? start + this._picker._config.rangeSeparator + end : '';
- }
- this._renderer.setProperty(this._elRef.nativeElement, 'value', range);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- onChange(event) {
- /* tslint:disable-next-line: no-any*/
- this.writeValue(((/** @type {?} */ (event.target))).value);
- this._onChange(this._value);
- this._onTouched();
- }
- /**
- * @param {?} c
- * @return {?}
- */
- validate(c) {
- /** @type {?} */
- const _value = c.value;
- if (_value === null || _value === undefined || !isArray(_value)) {
- return null;
- }
- /** @type {?} */
- const _isFirstDateValid = isDateValid(_value[0]);
- /** @type {?} */
- const _isSecondDateValid = isDateValid(_value[1]);
- if (!_isFirstDateValid) {
- return { bsDate: { invalid: _value[0] } };
- }
- if (!_isSecondDateValid) {
- return { bsDate: { invalid: _value[1] } };
- }
- if (this._picker && this._picker.minDate && isBefore(_value[0], this._picker.minDate, 'date')) {
- return { bsDate: { minDate: this._picker.minDate } };
- }
- if (this._picker && this._picker.maxDate && isAfter(_value[1], this._picker.maxDate, 'date')) {
- return { bsDate: { maxDate: this._picker.maxDate } };
- }
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnValidatorChange(fn) {
- this._validatorChange = fn;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- writeValue(value) {
- if (!value) {
- this._value = null;
- }
- else {
- /** @type {?} */
- const _localeKey = this._localeService.currentLocale;
- /** @type {?} */
- const _locale = getLocale(_localeKey);
- if (!_locale) {
- throw new Error(`Locale "${_localeKey}" is not defined, please add it with "defineLocale(...)"`);
- }
- /** @type {?} */
- let _input = [];
- if (typeof value === 'string') {
- _input = value.split(this._picker._config.rangeSeparator);
- }
- if (Array.isArray(value)) {
- _input = value;
- }
- this._value = ((/** @type {?} */ (_input)))
- .map((/**
- * @param {?} _val
- * @return {?}
- */
- (_val) => {
- if (this._picker._config.useUtc) {
- return utcAsLocal(parseDate(_val, this._picker._config.dateInputFormat, this._localeService.currentLocale));
- }
- return parseDate(_val, this._picker._config.dateInputFormat, this._localeService.currentLocale);
- }))
- .map((/**
- * @param {?} date
- * @return {?}
- */
- (date) => (isNaN(date.valueOf()) ? null : date)));
- }
- this._picker.bsValue = this._value;
- }
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- setDisabledState(isDisabled) {
- this._picker.isDisabled = isDisabled;
- if (isDisabled) {
- this._renderer.setAttribute(this._elRef.nativeElement, 'disabled', 'disabled');
- return;
- }
- this._renderer.removeAttribute(this._elRef.nativeElement, 'disabled');
- }
- /* tslint:disable-next-line: no-any*/
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnChange(fn) {
- this._onChange = fn;
- }
- /* tslint:disable-next-line: no-any*/
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnTouched(fn) {
- this._onTouched = fn;
- }
- /**
- * @return {?}
- */
- onBlur() {
- this._onTouched();
- }
- /**
- * @return {?}
- */
- hide() {
- this._picker.hide();
- this._renderer.selectRootElement(this._elRef.nativeElement).blur();
- }
- }
- BsDaterangepickerInputDirective.decorators = [
- { type: Directive, args: [{
- selector: `input[bsDaterangepicker]`,
- host: {
- '(change)': 'onChange($event)',
- '(keyup.esc)': 'hide()',
- '(blur)': 'onBlur()'
- },
- providers: [BS_DATERANGEPICKER_VALUE_ACCESSOR, BS_DATERANGEPICKER_VALIDATOR]
- },] }
- ];
- /** @nocollapse */
- BsDaterangepickerInputDirective.ctorParameters = () => [
- { type: BsDaterangepickerDirective, decorators: [{ type: Host }] },
- { type: BsLocaleService },
- { type: Renderer2 },
- { type: ElementRef },
- { type: ChangeDetectorRef }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsCalendarLayoutComponent {
- }
- BsCalendarLayoutComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-calendar-layout',
- template: `
- <!-- current date, will be added in nearest releases -->
- <bs-current-date title="hey there" *ngIf="false"></bs-current-date>
- <!--navigation-->
- <div class="bs-datepicker-head">
- <ng-content select="bs-datepicker-navigation-view"></ng-content>
- </div>
- <div class="bs-datepicker-body">
- <ng-content></ng-content>
- </div>
- <!--timepicker-->
- <bs-timepicker *ngIf="false"></bs-timepicker>
- `
- }] }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsCurrentDateViewComponent {
- }
- BsCurrentDateViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-current-date',
- template: `<div class="current-timedate"><span>{{ title }}</span></div>`
- }] }
- ];
- BsCurrentDateViewComponent.propDecorators = {
- title: [{ type: Input }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsCustomDatesViewComponent {
- }
- BsCustomDatesViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-custom-date-view',
- template: `
- <div class="bs-datepicker-predefined-btns">
- <button *ngFor="let range of ranges" type="button">{{ range.label }}</button>
- <button *ngIf="isCustomRangeShown" type="button">Custom Range</button>
- </div>
- `,
- changeDetection: ChangeDetectionStrategy.OnPush
- }] }
- ];
- BsCustomDatesViewComponent.propDecorators = {
- isCustomRangeShown: [{ type: Input }],
- ranges: [{ type: Input }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerDayDecoratorComponent {
- /**
- * @param {?} _config
- * @param {?} _elRef
- * @param {?} _renderer
- */
- constructor(_config, _elRef, _renderer) {
- this._config = _config;
- this._elRef = _elRef;
- this._renderer = _renderer;
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- if (this.day.isToday && this._config && this._config.customTodayClass) {
- this._renderer.addClass(this._elRef.nativeElement, this._config.customTodayClass);
- }
- if (typeof this.day.customClasses === 'string') {
- this.day.customClasses.split(' ')
- .filter((/**
- * @param {?} className
- * @return {?}
- */
- (className) => className))
- .forEach((/**
- * @param {?} className
- * @return {?}
- */
- (className) => {
- this._renderer.addClass(this._elRef.nativeElement, className);
- }));
- }
- }
- }
- BsDatepickerDayDecoratorComponent.decorators = [
- { type: Component, args: [{
- selector: '[bsDatepickerDayDecorator]',
- changeDetection: ChangeDetectionStrategy.OnPush,
- host: {
- '[class.disabled]': 'day.isDisabled',
- '[class.is-highlighted]': 'day.isHovered',
- '[class.is-other-month]': 'day.isOtherMonth',
- '[class.is-active-other-month]': 'day.isOtherMonthHovered',
- '[class.in-range]': 'day.isInRange',
- '[class.select-start]': 'day.isSelectionStart',
- '[class.select-end]': 'day.isSelectionEnd',
- '[class.selected]': 'day.isSelected'
- },
- template: `{{ day.label }}`
- }] }
- ];
- /** @nocollapse */
- BsDatepickerDayDecoratorComponent.ctorParameters = () => [
- { type: BsDatepickerConfig },
- { type: ElementRef },
- { type: Renderer2 }
- ];
- BsDatepickerDayDecoratorComponent.propDecorators = {
- day: [{ type: Input }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @enum {number} */
- const BsNavigationDirection = {
- UP: 0,
- DOWN: 1,
- };
- BsNavigationDirection[BsNavigationDirection.UP] = 'UP';
- BsNavigationDirection[BsNavigationDirection.DOWN] = 'DOWN';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDatepickerNavigationViewComponent {
- constructor() {
- this.onNavigate = new EventEmitter();
- this.onViewMode = new EventEmitter();
- }
- /**
- * @param {?} down
- * @return {?}
- */
- navTo(down) {
- this.onNavigate.emit(down ? BsNavigationDirection.DOWN : BsNavigationDirection.UP);
- }
- /**
- * @param {?} viewMode
- * @return {?}
- */
- view(viewMode) {
- this.onViewMode.emit(viewMode);
- }
- }
- BsDatepickerNavigationViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-datepicker-navigation-view',
- changeDetection: ChangeDetectionStrategy.OnPush,
- template: `
- <button class="previous"
- [disabled]="calendar.disableLeftArrow"
- [style.visibility]="calendar.hideLeftArrow ? 'hidden' : 'visible'"
- type="button"
- (click)="navTo(true)">
- <span>‹</span>
- </button>
- ​ <!-- zero-width space needed for correct alignement
- with preserveWhitespaces: false in Angular -->
- <button class="current"
- *ngIf="calendar.monthTitle"
- type="button"
- (click)="view('month')">
- <span>{{ calendar.monthTitle }}</span>
- </button>
- ​ <!-- zero-width space needed for correct alignement
- with preserveWhitespaces: false in Angular -->
- <button class="current" (click)="view('year')" type="button">
- <span>{{ calendar.yearTitle }}</span>
- </button>
- ​ <!-- zero-width space needed for correct alignement
- with preserveWhitespaces: false in Angular -->
- <button class="next"
- [disabled]="calendar.disableRightArrow"
- [style.visibility]="calendar.hideRightArrow ? 'hidden' : 'visible'"
- type="button"
- (click)="navTo(false)"><span>›</span>
- </button>
- `
- }] }
- ];
- BsDatepickerNavigationViewComponent.propDecorators = {
- calendar: [{ type: Input }],
- onNavigate: [{ type: Output }],
- onViewMode: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsDaysCalendarViewComponent {
- /**
- * @param {?} _config
- */
- constructor(_config) {
- this._config = _config;
- this.onNavigate = new EventEmitter();
- this.onViewMode = new EventEmitter();
- this.onSelect = new EventEmitter();
- this.onHover = new EventEmitter();
- this.onHoverWeek = new EventEmitter();
- }
- /**
- * @param {?} event
- * @return {?}
- */
- navigateTo(event) {
- /** @type {?} */
- const step = BsNavigationDirection.DOWN === event ? -1 : 1;
- this.onNavigate.emit({ step: { month: step } });
- }
- /**
- * @param {?} event
- * @return {?}
- */
- changeViewMode(event) {
- this.onViewMode.emit(event);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- selectDay(event) {
- this.onSelect.emit(event);
- }
- /**
- * @param {?} week
- * @return {?}
- */
- selectWeek(week) {
- if (!this._config.selectWeek) {
- return;
- }
- if (week.days
- && week.days[0]
- && !week.days[0].isDisabled
- && this._config.selectFromOtherMonth) {
- this.onSelect.emit(week.days[0]);
- return;
- }
- if (week.days.length === 0) {
- return;
- }
- /** @type {?} */
- const selectedDay = week.days.find((/**
- * @param {?} day
- * @return {?}
- */
- (day) => {
- return this._config.selectFromOtherMonth
- ? !day.isDisabled
- : !day.isOtherMonth && !day.isDisabled;
- }));
- this.onSelect.emit(selectedDay);
- }
- /**
- * @param {?} cell
- * @param {?} isHovered
- * @return {?}
- */
- weekHoverHandler(cell, isHovered) {
- if (!this._config.selectWeek) {
- return;
- }
- /** @type {?} */
- const hasActiveDays = cell.days.find((/**
- * @param {?} day
- * @return {?}
- */
- (day) => {
- return this._config.selectFromOtherMonth
- ? !day.isDisabled
- : !day.isOtherMonth && !day.isDisabled;
- }));
- if (hasActiveDays) {
- cell.isHovered = isHovered;
- this.isWeekHovered = isHovered;
- this.onHoverWeek.emit(cell);
- }
- }
- /**
- * @param {?} cell
- * @param {?} isHovered
- * @return {?}
- */
- hoverDay(cell, isHovered) {
- if (this._config.selectFromOtherMonth && cell.isOtherMonth) {
- cell.isOtherMonthHovered = isHovered;
- }
- this.onHover.emit({ cell, isHovered });
- }
- }
- BsDaysCalendarViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-days-calendar-view',
- // changeDetection: ChangeDetectionStrategy.OnPush,
- template: `
- <bs-calendar-layout>
- <bs-datepicker-navigation-view
- [calendar]="calendar"
- (onNavigate)="navigateTo($event)"
- (onViewMode)="changeViewMode($event)"
- ></bs-datepicker-navigation-view>
- <!--days matrix-->
- <table role="grid" class="days weeks">
- <thead>
- <tr>
- <!--if show weeks-->
- <th *ngIf="options.showWeekNumbers"></th>
- <th *ngFor="let weekday of calendar.weekdays; let i = index"
- aria-label="weekday">{{ calendar.weekdays[i] }}
- </th>
- </tr>
- </thead>
- <tbody>
- <tr *ngFor="let week of calendar.weeks; let i = index">
- <td class="week" [class.active-week]="isWeekHovered" *ngIf="options.showWeekNumbers">
- <span
- (click)="selectWeek(week)"
- (mouseenter)="weekHoverHandler(week, true)"
- (mouseleave)="weekHoverHandler(week, false)">{{ calendar.weekNumbers[i] }}</span>
- </td>
- <td *ngFor="let day of week.days" role="gridcell">
- <span bsDatepickerDayDecorator
- [day]="day"
- (click)="selectDay(day)"
- (mouseenter)="hoverDay(day, true)"
- (mouseleave)="hoverDay(day, false)">{{ day.label }}</span>
- </td>
- </tr>
- </tbody>
- </table>
- </bs-calendar-layout>
- `
- }] }
- ];
- /** @nocollapse */
- BsDaysCalendarViewComponent.ctorParameters = () => [
- { type: BsDatepickerConfig }
- ];
- BsDaysCalendarViewComponent.propDecorators = {
- calendar: [{ type: Input }],
- options: [{ type: Input }],
- onNavigate: [{ type: Output }],
- onViewMode: [{ type: Output }],
- onSelect: [{ type: Output }],
- onHover: [{ type: Output }],
- onHoverWeek: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsMonthCalendarViewComponent {
- constructor() {
- this.onNavigate = new EventEmitter();
- this.onViewMode = new EventEmitter();
- this.onSelect = new EventEmitter();
- this.onHover = new EventEmitter();
- }
- /**
- * @param {?} event
- * @return {?}
- */
- navigateTo(event) {
- /** @type {?} */
- const step = BsNavigationDirection.DOWN === event ? -1 : 1;
- this.onNavigate.emit({ step: { year: step } });
- }
- /**
- * @param {?} month
- * @return {?}
- */
- viewMonth(month) {
- this.onSelect.emit(month);
- }
- /**
- * @param {?} cell
- * @param {?} isHovered
- * @return {?}
- */
- hoverMonth(cell, isHovered) {
- this.onHover.emit({ cell, isHovered });
- }
- /**
- * @param {?} event
- * @return {?}
- */
- changeViewMode(event) {
- this.onViewMode.emit(event);
- }
- }
- BsMonthCalendarViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-month-calendar-view',
- template: `
- <bs-calendar-layout>
- <bs-datepicker-navigation-view
- [calendar]="calendar"
- (onNavigate)="navigateTo($event)"
- (onViewMode)="changeViewMode($event)"
- ></bs-datepicker-navigation-view>
- <table role="grid" class="months">
- <tbody>
- <tr *ngFor="let row of calendar.months">
- <td *ngFor="let month of row" role="gridcell"
- (click)="viewMonth(month)"
- (mouseenter)="hoverMonth(month, true)"
- (mouseleave)="hoverMonth(month, false)"
- [class.disabled]="month.isDisabled"
- [class.is-highlighted]="month.isHovered">
- <span [class.selected]="month.isSelected">{{ month.label }}</span>
- </td>
- </tr>
- </tbody>
- </table>
- </bs-calendar-layout>
- `
- }] }
- ];
- BsMonthCalendarViewComponent.propDecorators = {
- calendar: [{ type: Input }],
- onNavigate: [{ type: Output }],
- onViewMode: [{ type: Output }],
- onSelect: [{ type: Output }],
- onHover: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsTimepickerViewComponent {
- constructor() {
- this.ampm = 'ok';
- this.hours = 0;
- this.minutes = 0;
- }
- }
- BsTimepickerViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-timepicker',
- template: `
- <div class="bs-timepicker-container">
- <div class="bs-timepicker-controls">
- <button class="bs-decrease" type="button">-</button>
- <input type="text" [value]="hours" placeholder="00">
- <button class="bs-increase" type="button">+</button>
- </div>
- <div class="bs-timepicker-controls">
- <button class="bs-decrease" type="button">-</button>
- <input type="text" [value]="minutes" placeholder="00">
- <button class="bs-increase" type="button">+</button>
- </div>
- <button class="switch-time-format" type="button">{{ ampm }}
- <img
- src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAABi8KSDAAABSElEQVQYV3XQPUvDUBQG4HNuagtVqc6KgouCv6GIuIntYBLB9hcIQpLStCAIV7DYmpTcRWcXqZio3Vwc/UCc/QEqfgyKGbr0I7nS1EiHeqYzPO/h5SD0jaxUZjmSLCB+OFb+UFINFwASAEAdpu9gaGXVyAHHFQBkHpKHc6a9dzECvADyY9sqlAMsK9W0jzxDXqeytr3mhQckxSji27TJJ5/rPmIpwJJq3HrtduriYOurv1a4i1p5HnhkG9OFymi0ReoO05cGwb+ayv4dysVygjeFmsP05f8wpZQ8fsdvfmuY9zjWSNqUtgYFVnOVReILYoBFzdQI5/GGFzNHhGbeZnopDGU29sZbscgldmC99w35VOATTycIMMcBXIfpSVGzZhA6C8hh00conln6VQ9TGgV32OEAKQC4DrBq7CJwd0ggR7Vq/rPrfgB+C3sGypY5DAAAAABJRU5ErkJggg=="
- alt="">
- </button>
- </div>
- `
- }] }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class BsYearsCalendarViewComponent {
- constructor() {
- this.onNavigate = new EventEmitter();
- this.onViewMode = new EventEmitter();
- this.onSelect = new EventEmitter();
- this.onHover = new EventEmitter();
- }
- /**
- * @param {?} event
- * @return {?}
- */
- navigateTo(event) {
- /** @type {?} */
- const step = BsNavigationDirection.DOWN === event ? -1 : 1;
- this.onNavigate.emit({ step: { year: step * yearsPerCalendar } });
- }
- /**
- * @param {?} year
- * @return {?}
- */
- viewYear(year) {
- this.onSelect.emit(year);
- }
- /**
- * @param {?} cell
- * @param {?} isHovered
- * @return {?}
- */
- hoverYear(cell, isHovered) {
- this.onHover.emit({ cell, isHovered });
- }
- /**
- * @param {?} event
- * @return {?}
- */
- changeViewMode(event) {
- this.onViewMode.emit(event);
- }
- }
- BsYearsCalendarViewComponent.decorators = [
- { type: Component, args: [{
- selector: 'bs-years-calendar-view',
- template: `
- <bs-calendar-layout>
- <bs-datepicker-navigation-view
- [calendar]="calendar"
- (onNavigate)="navigateTo($event)"
- (onViewMode)="changeViewMode($event)"
- ></bs-datepicker-navigation-view>
- <table role="grid" class="years">
- <tbody>
- <tr *ngFor="let row of calendar.years">
- <td *ngFor="let year of row" role="gridcell"
- (click)="viewYear(year)"
- (mouseenter)="hoverYear(year, true)"
- (mouseleave)="hoverYear(year, false)"
- [class.disabled]="year.isDisabled"
- [class.is-highlighted]="year.isHovered">
- <span [class.selected]="year.isSelected">{{ year.label }}</span>
- </td>
- </tr>
- </tbody>
- </table>
- </bs-calendar-layout>
- `
- }] }
- ];
- BsYearsCalendarViewComponent.propDecorators = {
- calendar: [{ type: Input }],
- onNavigate: [{ type: Output }],
- onViewMode: [{ type: Output }],
- onSelect: [{ type: Output }],
- onHover: [{ type: Output }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const _exports = [
- BsDatepickerContainerComponent,
- BsDatepickerDirective,
- BsDatepickerInlineContainerComponent,
- BsDatepickerInlineDirective,
- BsDatepickerInputDirective,
- BsDaterangepickerContainerComponent,
- BsDaterangepickerDirective,
- BsDaterangepickerInlineContainerComponent,
- BsDaterangepickerInlineDirective,
- BsDaterangepickerInputDirective
- ];
- class BsDatepickerModule {
- /**
- * @return {?}
- */
- static forRoot() {
- return {
- ngModule: BsDatepickerModule,
- providers: [
- ComponentLoaderFactory,
- PositioningService,
- BsDatepickerStore,
- BsDatepickerActions,
- BsDatepickerConfig,
- BsDaterangepickerConfig,
- BsDatepickerInlineConfig,
- BsDaterangepickerInlineConfig,
- BsDatepickerEffects,
- BsLocaleService
- ]
- };
- }
- }
- BsDatepickerModule.decorators = [
- { type: NgModule, args: [{
- imports: [CommonModule],
- declarations: [
- BsCalendarLayoutComponent,
- BsCurrentDateViewComponent,
- BsCustomDatesViewComponent,
- BsDatepickerDayDecoratorComponent,
- BsDatepickerNavigationViewComponent,
- BsDaysCalendarViewComponent,
- BsMonthCalendarViewComponent,
- BsTimepickerViewComponent,
- BsYearsCalendarViewComponent,
- ..._exports
- ],
- entryComponents: [
- BsDatepickerContainerComponent,
- BsDaterangepickerContainerComponent,
- BsDatepickerInlineContainerComponent,
- BsDaterangepickerInlineContainerComponent
- ],
- exports: _exports
- },] }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class DateFormatter {
- /**
- * @param {?} date
- * @param {?} format
- * @param {?} locale
- * @return {?}
- */
- format(date, format, locale) {
- return formatDate(date, format, locale);
- }
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class DatePickerInnerComponent {
- constructor() {
- this.selectionDone = new EventEmitter(undefined);
- this.update = new EventEmitter(false);
- this.activeDateChange = new EventEmitter(undefined);
- /* tslint:disable-next-line: no-any*/
- this.stepDay = {};
- /* tslint:disable-next-line: no-any*/
- this.stepMonth = {};
- /* tslint:disable-next-line: no-any*/
- this.stepYear = {};
- this.modes = ['day', 'month', 'year'];
- this.dateFormatter = new DateFormatter();
- }
- /**
- * @return {?}
- */
- get activeDate() {
- return this._activeDate;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set activeDate(value) {
- this._activeDate = value;
- }
- // todo: add formatter value to Date object
- /**
- * @return {?}
- */
- ngOnInit() {
- // todo: use date for unique value
- this.uniqueId = `datepicker--${Math.floor(Math.random() * 10000)}`;
- if (this.initDate) {
- this.activeDate = this.initDate;
- this.selectedDate = new Date(this.activeDate.valueOf());
- this.update.emit(this.activeDate);
- }
- else if (this.activeDate === undefined) {
- this.activeDate = new Date();
- }
- }
- // this.refreshView should be called here to reflect the changes on the fly
- // tslint:disable-next-line:no-unused-variable
- /**
- * @param {?} changes
- * @return {?}
- */
- ngOnChanges(changes) {
- this.refreshView();
- this.checkIfActiveDateGotUpdated(changes.activeDate);
- }
- // Check if activeDate has been update and then emit the activeDateChange with the new date
- /* tslint:disable-next-line: no-any */
- /**
- * @param {?} activeDate
- * @return {?}
- */
- checkIfActiveDateGotUpdated(activeDate) {
- if (activeDate && !activeDate.firstChange) {
- /** @type {?} */
- const previousValue = activeDate.previousValue;
- if (previousValue &&
- previousValue instanceof Date &&
- previousValue.getTime() !== activeDate.currentValue.getTime()) {
- this.activeDateChange.emit(this.activeDate);
- }
- }
- }
- /**
- * @param {?} handler
- * @param {?} type
- * @return {?}
- */
- setCompareHandler(handler, type) {
- if (type === 'day') {
- this.compareHandlerDay = handler;
- }
- if (type === 'month') {
- this.compareHandlerMonth = handler;
- }
- if (type === 'year') {
- this.compareHandlerYear = handler;
- }
- }
- /**
- * @param {?} date1
- * @param {?} date2
- * @return {?}
- */
- compare(date1, date2) {
- if (date1 === undefined || date2 === undefined) {
- return undefined;
- }
- if (this.datepickerMode === 'day' && this.compareHandlerDay) {
- return this.compareHandlerDay(date1, date2);
- }
- if (this.datepickerMode === 'month' && this.compareHandlerMonth) {
- return this.compareHandlerMonth(date1, date2);
- }
- if (this.datepickerMode === 'year' && this.compareHandlerYear) {
- return this.compareHandlerYear(date1, date2);
- }
- return void 0;
- }
- /**
- * @param {?} handler
- * @param {?} type
- * @return {?}
- */
- setRefreshViewHandler(handler, type) {
- if (type === 'day') {
- this.refreshViewHandlerDay = handler;
- }
- if (type === 'month') {
- this.refreshViewHandlerMonth = handler;
- }
- if (type === 'year') {
- this.refreshViewHandlerYear = handler;
- }
- }
- /**
- * @return {?}
- */
- refreshView() {
- if (this.datepickerMode === 'day' && this.refreshViewHandlerDay) {
- this.refreshViewHandlerDay();
- }
- if (this.datepickerMode === 'month' && this.refreshViewHandlerMonth) {
- this.refreshViewHandlerMonth();
- }
- if (this.datepickerMode === 'year' && this.refreshViewHandlerYear) {
- this.refreshViewHandlerYear();
- }
- }
- /**
- * @param {?} date
- * @param {?} format
- * @return {?}
- */
- dateFilter(date, format) {
- return this.dateFormatter.format(date, format, this.locale);
- }
- /* tslint:disable-next-line: no-any*/
- /**
- * @param {?} dateObject
- * @return {?}
- */
- isActive(dateObject) {
- if (this.compare(dateObject.date, this.activeDate) === 0) {
- this.activeDateId = dateObject.uid;
- return true;
- }
- return false;
- }
- /* tslint:disable-next-line: no-any*/
- /**
- * @param {?} date
- * @param {?} format
- * @return {?}
- */
- createDateObject(date, format) {
- /* tslint:disable-next-line: no-any*/
- /** @type {?} */
- const dateObject = {};
- dateObject.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
- dateObject.date = this.fixTimeZone(dateObject.date);
- dateObject.label = this.dateFilter(date, format);
- dateObject.selected = this.compare(date, this.selectedDate) === 0;
- dateObject.disabled = this.isDisabled(date);
- dateObject.current = this.compare(date, new Date()) === 0;
- dateObject.customClass = this.getCustomClassForDate(dateObject.date);
- return dateObject;
- }
- /* tslint:disable-next-line: no-any*/
- /**
- * @param {?} arr
- * @param {?} size
- * @return {?}
- */
- split(arr, size) {
- /* tslint:disable-next-line: no-any*/
- /** @type {?} */
- const arrays = [];
- while (arr.length > 0) {
- arrays.push(arr.splice(0, size));
- }
- return arrays;
- }
- // Fix a hard-reproducible bug with timezones
- // The bug depends on OS, browser, current timezone and current date
- // i.e.
- // var date = new Date(2014, 0, 1);
- // console.log(date.getFullYear(), date.getMonth(), date.getDate(),
- // date.getHours()); can result in "2013 11 31 23" because of the bug.
- /**
- * @param {?} date
- * @return {?}
- */
- fixTimeZone(date) {
- /** @type {?} */
- const hours = date.getHours();
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours === 23 ? hours + 2 : 0);
- }
- /**
- * @param {?} date
- * @param {?=} isManual
- * @return {?}
- */
- select(date, isManual = true) {
- if (this.datepickerMode === this.minMode) {
- if (!this.activeDate) {
- this.activeDate = new Date(0, 0, 0, 0, 0, 0, 0);
- }
- this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
- this.activeDate = this.fixTimeZone(this.activeDate);
- if (isManual) {
- this.selectionDone.emit(this.activeDate);
- }
- }
- else {
- this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
- this.activeDate = this.fixTimeZone(this.activeDate);
- if (isManual) {
- this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1];
- }
- }
- this.selectedDate = new Date(this.activeDate.valueOf());
- this.update.emit(this.activeDate);
- this.refreshView();
- }
- /**
- * @param {?} direction
- * @return {?}
- */
- move(direction) {
- /* tslint:disable-next-line: no-any*/
- /** @type {?} */
- let expectedStep;
- if (this.datepickerMode === 'day') {
- expectedStep = this.stepDay;
- }
- if (this.datepickerMode === 'month') {
- expectedStep = this.stepMonth;
- }
- if (this.datepickerMode === 'year') {
- expectedStep = this.stepYear;
- }
- if (expectedStep) {
- /** @type {?} */
- const year = this.activeDate.getFullYear() + direction * (expectedStep.years || 0);
- /** @type {?} */
- const month = this.activeDate.getMonth() + direction * (expectedStep.months || 0);
- this.activeDate = new Date(year, month, 1);
- this.refreshView();
- this.activeDateChange.emit(this.activeDate);
- }
- }
- /**
- * @param {?} _direction
- * @return {?}
- */
- toggleMode(_direction) {
- /** @type {?} */
- const direction = _direction || 1;
- if ((this.datepickerMode === this.maxMode && direction === 1) ||
- (this.datepickerMode === this.minMode && direction === -1)) {
- return;
- }
- this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) + direction];
- this.refreshView();
- }
- /**
- * @protected
- * @param {?} date
- * @return {?}
- */
- getCustomClassForDate(date) {
- if (!this.customClass) {
- return '';
- }
- // todo: build a hash of custom classes, it will work faster
- /** @type {?} */
- const customClassObject = this.customClass.find((/**
- * @param {?} customClass
- * @return {?}
- */
- (customClass) => {
- return (customClass.date.valueOf() === date.valueOf() &&
- customClass.mode === this.datepickerMode);
- }), this);
- return customClassObject === undefined ? '' : customClassObject.clazz;
- }
- /**
- * @protected
- * @param {?} date1Disabled
- * @param {?} date2
- * @return {?}
- */
- compareDateDisabled(date1Disabled, date2) {
- if (date1Disabled === undefined || date2 === undefined) {
- return undefined;
- }
- if (date1Disabled.mode === 'day' && this.compareHandlerDay) {
- return this.compareHandlerDay(date1Disabled.date, date2);
- }
- if (date1Disabled.mode === 'month' && this.compareHandlerMonth) {
- return this.compareHandlerMonth(date1Disabled.date, date2);
- }
- if (date1Disabled.mode === 'year' && this.compareHandlerYear) {
- return this.compareHandlerYear(date1Disabled.date, date2);
- }
- return undefined;
- }
- /**
- * @protected
- * @param {?} date
- * @return {?}
- */
- isDisabled(date) {
- /** @type {?} */
- let isDateDisabled = false;
- if (this.dateDisabled) {
- this.dateDisabled.forEach((/**
- * @param {?} disabledDate
- * @return {?}
- */
- (disabledDate) => {
- if (this.compareDateDisabled(disabledDate, date) === 0) {
- isDateDisabled = true;
- }
- }));
- }
- if (this.dayDisabled) {
- isDateDisabled =
- isDateDisabled ||
- this.dayDisabled.indexOf(date.getDay()) > -1;
- }
- return (isDateDisabled ||
- (this.minDate && this.compare(date, this.minDate) < 0) ||
- (this.maxDate && this.compare(date, this.maxDate) > 0));
- }
- }
- DatePickerInnerComponent.decorators = [
- { type: Component, args: [{
- selector: 'datepicker-inner',
- template: `
- <!--<!–ng-keydown="keydown($event)"–>-->
- <div *ngIf="datepickerMode" class="well well-sm bg-faded p-a card" role="application" >
- <ng-content></ng-content>
- </div>
- `
- }] }
- ];
- DatePickerInnerComponent.propDecorators = {
- locale: [{ type: Input }],
- datepickerMode: [{ type: Input }],
- startingDay: [{ type: Input }],
- yearRange: [{ type: Input }],
- minDate: [{ type: Input }],
- maxDate: [{ type: Input }],
- minMode: [{ type: Input }],
- maxMode: [{ type: Input }],
- showWeeks: [{ type: Input }],
- formatDay: [{ type: Input }],
- formatMonth: [{ type: Input }],
- formatYear: [{ type: Input }],
- formatDayHeader: [{ type: Input }],
- formatDayTitle: [{ type: Input }],
- formatMonthTitle: [{ type: Input }],
- onlyCurrentMonth: [{ type: Input }],
- shortcutPropagation: [{ type: Input }],
- customClass: [{ type: Input }],
- monthColLimit: [{ type: Input }],
- yearColLimit: [{ type: Input }],
- dateDisabled: [{ type: Input }],
- dayDisabled: [{ type: Input }],
- initDate: [{ type: Input }],
- selectionDone: [{ type: Output }],
- update: [{ type: Output }],
- activeDateChange: [{ type: Output }],
- activeDate: [{ type: Input }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class DatepickerConfig {
- constructor() {
- this.locale = 'en';
- this.datepickerMode = 'day';
- this.startingDay = 0;
- this.yearRange = 20;
- this.minMode = 'day';
- this.maxMode = 'year';
- this.showWeeks = true;
- this.formatDay = 'DD';
- this.formatMonth = 'MMMM';
- this.formatYear = 'YYYY';
- this.formatDayHeader = 'dd';
- this.formatDayTitle = 'MMMM YYYY';
- this.formatMonthTitle = 'YYYY';
- this.onlyCurrentMonth = false;
- this.monthColLimit = 3;
- this.yearColLimit = 5;
- this.shortcutPropagation = false;
- }
- }
- DatepickerConfig.decorators = [
- { type: Injectable }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- const DATEPICKER_CONTROL_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- () => DatePickerComponent)),
- multi: true
- };
- /* tslint:disable:component-selector-name component-selector-type */
- /* tslint:enable:component-selector-name component-selector-type */
- class DatePickerComponent {
- /**
- * @param {?} config
- */
- constructor(config) {
- /**
- * sets datepicker mode, supports: `day`, `month`, `year`
- */
- this.datepickerMode = 'day';
- /**
- * if false week numbers will be hidden
- */
- this.showWeeks = true;
- this.selectionDone = new EventEmitter(undefined);
- /**
- * callback to invoke when the activeDate is changed.
- */
- this.activeDateChange = new EventEmitter(undefined);
- /* tslint:disable-next-line: no-any*/
- this.onChange = Function.prototype;
- /* tslint:disable-next-line: no-any*/
- this.onTouched = Function.prototype;
- this._now = new Date();
- this.config = config;
- this.configureOptions();
- }
- /**
- * currently active date
- * @return {?}
- */
- get activeDate() {
- return this._activeDate || this._now;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- set activeDate(value) {
- this._activeDate = value;
- }
- /**
- * @return {?}
- */
- configureOptions() {
- Object.assign(this, this.config);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- onUpdate(event) {
- this.activeDate = event;
- this.onChange(event);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- onSelectionDone(event) {
- this.selectionDone.emit(event);
- }
- /**
- * @param {?} event
- * @return {?}
- */
- onActiveDateChange(event) {
- this.activeDateChange.emit(event);
- }
- // todo: support null value
- /* tslint:disable-next-line: no-any*/
- /**
- * @param {?} value
- * @return {?}
- */
- writeValue(value) {
- if (this._datePicker.compare(value, this._activeDate) === 0) {
- return;
- }
- if (value && value instanceof Date) {
- this.activeDate = value;
- this._datePicker.select(value, false);
- return;
- }
- this.activeDate = value ? new Date(value) : void 0;
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnChange(fn) {
- this.onChange = fn;
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- registerOnTouched(fn) {
- this.onTouched = fn;
- }
- }
- DatePickerComponent.decorators = [
- { type: Component, args: [{
- selector: 'datepicker',
- template: `
- <datepicker-inner [activeDate]="activeDate"
- (update)="onUpdate($event)"
- [locale]="config.locale"
- [datepickerMode]="datepickerMode"
- [initDate]="initDate"
- [minDate]="minDate"
- [maxDate]="maxDate"
- [minMode]="minMode"
- [maxMode]="maxMode"
- [showWeeks]="showWeeks"
- [formatDay]="formatDay"
- [formatMonth]="formatMonth"
- [formatYear]="formatYear"
- [formatDayHeader]="formatDayHeader"
- [formatDayTitle]="formatDayTitle"
- [formatMonthTitle]="formatMonthTitle"
- [startingDay]="startingDay"
- [yearRange]="yearRange"
- [customClass]="customClass"
- [dateDisabled]="dateDisabled"
- [dayDisabled]="dayDisabled"
- [onlyCurrentMonth]="onlyCurrentMonth"
- [shortcutPropagation]="shortcutPropagation"
- [monthColLimit]="monthColLimit"
- [yearColLimit]="yearColLimit"
- (selectionDone)="onSelectionDone($event)"
- (activeDateChange)="onActiveDateChange($event)">
- <daypicker tabindex="0"></daypicker>
- <monthpicker tabindex="0"></monthpicker>
- <yearpicker tabindex="0"></yearpicker>
- </datepicker-inner>
- `,
- providers: [DATEPICKER_CONTROL_VALUE_ACCESSOR]
- }] }
- ];
- /** @nocollapse */
- DatePickerComponent.ctorParameters = () => [
- { type: DatepickerConfig }
- ];
- DatePickerComponent.propDecorators = {
- datepickerMode: [{ type: Input }],
- initDate: [{ type: Input }],
- minDate: [{ type: Input }],
- maxDate: [{ type: Input }],
- minMode: [{ type: Input }],
- maxMode: [{ type: Input }],
- showWeeks: [{ type: Input }],
- formatDay: [{ type: Input }],
- formatMonth: [{ type: Input }],
- formatYear: [{ type: Input }],
- formatDayHeader: [{ type: Input }],
- formatDayTitle: [{ type: Input }],
- formatMonthTitle: [{ type: Input }],
- startingDay: [{ type: Input }],
- yearRange: [{ type: Input }],
- onlyCurrentMonth: [{ type: Input }],
- shortcutPropagation: [{ type: Input }],
- monthColLimit: [{ type: Input }],
- yearColLimit: [{ type: Input }],
- customClass: [{ type: Input }],
- dateDisabled: [{ type: Input }],
- dayDisabled: [{ type: Input }],
- activeDate: [{ type: Input }],
- selectionDone: [{ type: Output }],
- activeDateChange: [{ type: Output }],
- _datePicker: [{ type: ViewChild, args: [DatePickerInnerComponent, { static: true },] }]
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class DayPickerComponent {
- /**
- * @param {?} datePicker
- */
- constructor(datePicker) {
- this.labels = [];
- this.rows = [];
- this.weekNumbers = [];
- this.datePicker = datePicker;
- }
- /**
- * @return {?}
- */
- get isBs4() {
- return !isBs3();
- }
- /*protected getDaysInMonth(year:number, month:number) {
- return ((month === 1) && (year % 4 === 0) &&
- ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
- }*/
- /**
- * @return {?}
- */
- ngOnInit() {
- /** @type {?} */
- const self = this;
- this.datePicker.stepDay = { months: 1 };
- this.datePicker.setRefreshViewHandler((/**
- * @return {?}
- */
- function () {
- /** @type {?} */
- const year = this.activeDate.getFullYear();
- /** @type {?} */
- const month = this.activeDate.getMonth();
- /** @type {?} */
- const firstDayOfMonth = new Date(year, month, 1);
- /** @type {?} */
- const difference = this.startingDay - firstDayOfMonth.getDay();
- /** @type {?} */
- const numDisplayedFromPreviousMonth = difference > 0 ? 7 - difference : -difference;
- /** @type {?} */
- const firstDate = new Date(firstDayOfMonth.getTime());
- if (numDisplayedFromPreviousMonth > 0) {
- firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
- }
- // 42 is the number of days on a six-week calendar
- /** @type {?} */
- const _days = self.getDates(firstDate, 42);
- /** @type {?} */
- const days = [];
- for (let i = 0; i < 42; i++) {
- /** @type {?} */
- const _dateObject = this.createDateObject(_days[i], this.formatDay);
- _dateObject.secondary = _days[i].getMonth() !== month;
- _dateObject.uid = this.uniqueId + '-' + i;
- days[i] = _dateObject;
- }
- self.labels = [];
- for (let j = 0; j < 7; j++) {
- self.labels[j] = {};
- self.labels[j].abbr = this.dateFilter(days[j].date, this.formatDayHeader);
- self.labels[j].full = this.dateFilter(days[j].date, 'EEEE');
- }
- self.title = this.dateFilter(this.activeDate, this.formatDayTitle);
- self.rows = this.split(days, 7);
- if (this.showWeeks) {
- self.weekNumbers = [];
- /** @type {?} */
- const thursdayIndex = (4 + 7 - this.startingDay) % 7;
- /** @type {?} */
- const numWeeks = self.rows.length;
- for (let curWeek = 0; curWeek < numWeeks; curWeek++) {
- self.weekNumbers.push(self.getISO8601WeekNumber(self.rows[curWeek][thursdayIndex].date));
- }
- }
- }), 'day');
- this.datePicker.setCompareHandler((/**
- * @param {?} date1
- * @param {?} date2
- * @return {?}
- */
- function (date1, date2) {
- /** @type {?} */
- const d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
- /** @type {?} */
- const d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
- return d1.getTime() - d2.getTime();
- }), 'day');
- this.datePicker.refreshView();
- }
- /**
- * @protected
- * @param {?} startDate
- * @param {?} n
- * @return {?}
- */
- getDates(startDate, n) {
- /** @type {?} */
- const dates = new Array(n);
- /** @type {?} */
- let current = new Date(startDate.getTime());
- /** @type {?} */
- let i = 0;
- /** @type {?} */
- let date;
- while (i < n) {
- date = new Date(current.getTime());
- date = this.datePicker.fixTimeZone(date);
- dates[i++] = date;
- current = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
- }
- return dates;
- }
- /**
- * @protected
- * @param {?} date
- * @return {?}
- */
- getISO8601WeekNumber(date) {
- /** @type {?} */
- const checkDate = new Date(date.getTime());
- // Thursday
- checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
- /** @type {?} */
- const time = checkDate.getTime();
- // Compare with Jan 1
- checkDate.setMonth(0);
- checkDate.setDate(1);
- return (Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 1);
- }
- }
- DayPickerComponent.decorators = [
- { type: Component, args: [{
- selector: 'daypicker',
- template: `
- <table *ngIf="datePicker.datepickerMode === 'day'" role="grid" [attr.aria-labelledby]="datePicker.uniqueId + '-title'" aria-activedescendant="activeDateId">
- <thead>
- <tr>
- <th>
- <button *ngIf="!isBs4"
- type="button"
- class="btn btn-default btn-secondary btn-sm pull-left float-left"
- (click)="datePicker.move(-1)"
- tabindex="-1">‹</button>
- <button *ngIf="isBs4"
- type="button"
- class="btn btn-default btn-secondary btn-sm pull-left float-left"
- (click)="datePicker.move(-1)"
- tabindex="-1"><</button>
- </th>
- <th [attr.colspan]="5 + (datePicker.showWeeks ? 1 : 0)">
- <button [id]="datePicker.uniqueId + '-title'"
- type="button" class="btn btn-default btn-secondary btn-sm"
- (click)="datePicker.toggleMode(0)"
- [disabled]="datePicker.datepickerMode === datePicker.maxMode"
- [ngClass]="{disabled: datePicker.datepickerMode === datePicker.maxMode}" tabindex="-1" style="width:100%;">
- <strong>{{ title }}</strong>
- </button>
- </th>
- <th>
- <button *ngIf="!isBs4"
- type="button"
- class="btn btn-default btn-secondary btn-sm pull-right float-right"
- (click)="datePicker.move(1)"
- tabindex="-1">›</button>
- <button *ngIf="isBs4"
- type="button"
- class="btn btn-default btn-secondary btn-sm pull-right float-right"
- (click)="datePicker.move(1)"
- tabindex="-1">>
- </button>
- </th>
- </tr>
- <tr>
- <th *ngIf="datePicker.showWeeks"></th>
- <th *ngFor="let labelz of labels" class="text-center">
- <small aria-label="labelz.full"><b>{{ labelz.abbr }}</b></small>
- </th>
- </tr>
- </thead>
- <tbody>
- <ng-template ngFor [ngForOf]="rows" let-rowz="$implicit" let-index="index">
- <tr *ngIf="!(datePicker.onlyCurrentMonth && rowz[0].secondary && rowz[6].secondary)">
- <td *ngIf="datePicker.showWeeks" class="h6" class="text-center">
- <em>{{ weekNumbers[index] }}</em>
- </td>
- <td *ngFor="let dtz of rowz" class="text-center" role="gridcell" [id]="dtz.uid">
- <button type="button" style="min-width:100%;" class="btn btn-sm {{dtz.customClass}}"
- *ngIf="!(datePicker.onlyCurrentMonth && dtz.secondary)"
- [ngClass]="{'btn-secondary': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected, disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz), 'btn-default': !isBs4}"
- [disabled]="dtz.disabled"
- (click)="datePicker.select(dtz.date)" tabindex="-1">
- <span [ngClass]="{'text-muted': dtz.secondary || dtz.current, 'text-info': !isBs4 && dtz.current}">{{ dtz.label }}</span>
- </button>
- </td>
- </tr>
- </ng-template>
- </tbody>
- </table>
- `,
- styles: [`
- :host .btn-secondary {
- color: #292b2c;
- background-color: #fff;
- border-color: #ccc;
- }
- :host .btn-info .text-muted {
- color: #292b2c !important;
- }
- `]
- }] }
- ];
- /** @nocollapse */
- DayPickerComponent.ctorParameters = () => [
- { type: DatePickerInnerComponent }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class MonthPickerComponent {
- /**
- * @param {?} datePicker
- */
- constructor(datePicker) {
- this.rows = [];
- this.datePicker = datePicker;
- }
- /**
- * @return {?}
- */
- get isBs4() {
- return !isBs3();
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- /** @type {?} */
- const self = this;
- this.datePicker.stepMonth = { years: 1 };
- this.datePicker.setRefreshViewHandler((/**
- * @return {?}
- */
- function () {
- /** @type {?} */
- const months = new Array(12);
- /** @type {?} */
- const year = this.activeDate.getFullYear();
- /** @type {?} */
- let date;
- for (let i = 0; i < 12; i++) {
- date = new Date(year, i, 1);
- date = this.fixTimeZone(date);
- months[i] = this.createDateObject(date, this.formatMonth);
- months[i].uid = this.uniqueId + '-' + i;
- }
- self.title = this.dateFilter(this.activeDate, this.formatMonthTitle);
- self.rows = this.split(months, self.datePicker.monthColLimit);
- }), 'month');
- this.datePicker.setCompareHandler((/**
- * @param {?} date1
- * @param {?} date2
- * @return {?}
- */
- function (date1, date2) {
- /** @type {?} */
- const d1 = new Date(date1.getFullYear(), date1.getMonth());
- /** @type {?} */
- const d2 = new Date(date2.getFullYear(), date2.getMonth());
- return d1.getTime() - d2.getTime();
- }), 'month');
- this.datePicker.refreshView();
- }
- }
- MonthPickerComponent.decorators = [
- { type: Component, args: [{
- selector: 'monthpicker',
- template: `
- <table *ngIf="datePicker.datepickerMode==='month'" role="grid">
- <thead>
- <tr>
- <th>
- <button type="button" class="btn btn-default btn-sm pull-left float-left"
- (click)="datePicker.move(-1)" tabindex="-1">‹</button></th>
- <th [attr.colspan]="((datePicker.monthColLimit - 2) <= 0) ? 1 : datePicker.monthColLimit - 2">
- <button [id]="datePicker.uniqueId + '-title'"
- type="button" class="btn btn-default btn-sm"
- (click)="datePicker.toggleMode(0)"
- [disabled]="datePicker.datepickerMode === maxMode"
- [ngClass]="{disabled: datePicker.datepickerMode === maxMode}" tabindex="-1" style="width:100%;">
- <strong>{{ title }}</strong>
- </button>
- </th>
- <th>
- <button type="button" class="btn btn-default btn-sm pull-right float-right"
- (click)="datePicker.move(1)" tabindex="-1">›</button>
- </th>
- </tr>
- </thead>
- <tbody>
- <tr *ngFor="let rowz of rows">
- <td *ngFor="let dtz of rowz" class="text-center" role="gridcell" [attr.id]="dtz.uid" [ngClass]="dtz.customClass">
- <button type="button" style="min-width:100%;" class="btn btn-default"
- [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)}"
- [disabled]="dtz.disabled"
- (click)="datePicker.select(dtz.date)" tabindex="-1">
- <span [ngClass]="{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}">{{ dtz.label }}</span>
- </button>
- </td>
- </tr>
- </tbody>
- </table>
- `,
- styles: [`
- :host .btn-info .text-success {
- color: #fff !important;
- }
- `]
- }] }
- ];
- /** @nocollapse */
- MonthPickerComponent.ctorParameters = () => [
- { type: DatePickerInnerComponent }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class YearPickerComponent {
- /**
- * @param {?} datePicker
- */
- constructor(datePicker) {
- this.rows = [];
- this.datePicker = datePicker;
- }
- /**
- * @return {?}
- */
- get isBs4() {
- return !isBs3();
- }
- /**
- * @return {?}
- */
- ngOnInit() {
- /** @type {?} */
- const self = this;
- this.datePicker.stepYear = { years: this.datePicker.yearRange };
- this.datePicker.setRefreshViewHandler((/**
- * @return {?}
- */
- function () {
- /** @type {?} */
- const years = new Array(this.yearRange);
- /** @type {?} */
- let date;
- /** @type {?} */
- const start = self.getStartingYear(this.activeDate.getFullYear());
- for (let i = 0; i < this.yearRange; i++) {
- date = new Date(start + i, 0, 1);
- date = this.fixTimeZone(date);
- years[i] = this.createDateObject(date, this.formatYear);
- years[i].uid = this.uniqueId + '-' + i;
- }
- self.title = [years[0].label, years[this.yearRange - 1].label].join(' - ');
- self.rows = this.split(years, self.datePicker.yearColLimit);
- }), 'year');
- this.datePicker.setCompareHandler((/**
- * @param {?} date1
- * @param {?} date2
- * @return {?}
- */
- function (date1, date2) {
- return date1.getFullYear() - date2.getFullYear();
- }), 'year');
- this.datePicker.refreshView();
- }
- /**
- * @protected
- * @param {?} year
- * @return {?}
- */
- getStartingYear(year) {
- // todo: parseInt
- return ((year - 1) / this.datePicker.yearRange * this.datePicker.yearRange + 1);
- }
- }
- YearPickerComponent.decorators = [
- { type: Component, args: [{
- selector: 'yearpicker',
- template: `
- <table *ngIf="datePicker.datepickerMode==='year'" role="grid">
- <thead>
- <tr>
- <th>
- <button type="button" class="btn btn-default btn-sm pull-left float-left"
- (click)="datePicker.move(-1)" tabindex="-1">‹</button>
- </th>
- <th [attr.colspan]="((datePicker.yearColLimit - 2) <= 0) ? 1 : datePicker.yearColLimit - 2">
- <button [id]="datePicker.uniqueId + '-title'" role="heading"
- type="button" class="btn btn-default btn-sm"
- (click)="datePicker.toggleMode(0)"
- [disabled]="datePicker.datepickerMode === datePicker.maxMode"
- [ngClass]="{disabled: datePicker.datepickerMode === datePicker.maxMode}" tabindex="-1" style="width:100%;">
- <strong>{{ title }}</strong>
- </button>
- </th>
- <th>
- <button type="button" class="btn btn-default btn-sm pull-right float-right"
- (click)="datePicker.move(1)" tabindex="-1">›</button>
- </th>
- </tr>
- </thead>
- <tbody>
- <tr *ngFor="let rowz of rows">
- <td *ngFor="let dtz of rowz" class="text-center" role="gridcell" [attr.id]="dtz.uid">
- <button type="button" style="min-width:100%;" class="btn btn-default"
- [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)}"
- [disabled]="dtz.disabled"
- (click)="datePicker.select(dtz.date)" tabindex="-1">
- <span [ngClass]="{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}">{{ dtz.label }}</span>
- </button>
- </td>
- </tr>
- </tbody>
- </table>
- `,
- styles: [`
- :host .btn-info .text-success {
- color: #fff !important;
- }
- `]
- }] }
- ];
- /** @nocollapse */
- YearPickerComponent.ctorParameters = () => [
- { type: DatePickerInnerComponent }
- ];
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- class DatepickerModule {
- /**
- * @return {?}
- */
- static forRoot() {
- return { ngModule: DatepickerModule, providers: [DatepickerConfig] };
- }
- }
- DatepickerModule.decorators = [
- { type: NgModule, args: [{
- imports: [CommonModule, FormsModule],
- declarations: [
- DatePickerComponent,
- DatePickerInnerComponent,
- DayPickerComponent,
- MonthPickerComponent,
- YearPickerComponent
- ],
- exports: [
- DatePickerComponent,
- DatePickerInnerComponent,
- DayPickerComponent,
- MonthPickerComponent,
- YearPickerComponent
- ],
- entryComponents: [DatePickerComponent]
- },] }
- ];
- 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 };
- //# sourceMappingURL=ngx-bootstrap-datepicker.js.map
|