1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879 |
- import * as i0 from '@angular/core';
- import { Injectable, inject, ElementRef, NgZone, EventEmitter, Injector, Renderer2, afterNextRender, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, Optional, SkipSelf, InjectionToken, ChangeDetectorRef, ViewChild, ANIMATION_MODULE_TYPE, ViewContainerRef, booleanAttribute, Directive, forwardRef, signal, HostAttributeToken, ContentChild, TemplateRef, NgModule } from '@angular/core';
- import { Subject, Subscription, merge, of } from 'rxjs';
- import { D as DateAdapter, a as MAT_DATE_FORMATS } from './date-formats-K6TQue-Y.mjs';
- import { _IdGenerator, CdkMonitorFocus, CdkTrapFocus, A11yModule } from '@angular/cdk/a11y';
- import { Directionality } from '@angular/cdk/bidi';
- import { coerceStringArray } from '@angular/cdk/coercion';
- import { ESCAPE, hasModifierKey, SPACE, ENTER, PAGE_DOWN, PAGE_UP, END, HOME, DOWN_ARROW, UP_ARROW, RIGHT_ARROW, LEFT_ARROW, BACKSPACE } from '@angular/cdk/keycodes';
- import { Overlay, FlexibleConnectedPositionStrategy, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
- import { Platform, _bindEventWithOptions, _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
- import { ComponentPortal, CdkPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal';
- import { NgClass, DOCUMENT } from '@angular/common';
- import { startWith, take, filter } from 'rxjs/operators';
- import { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from '@angular/cdk/private';
- import { _ as _StructuralStylesLoader } from './structural-styles-BQUT6wsL.mjs';
- import { MatButton, MatButtonModule } from './button.mjs';
- import { M as MatIconButton } from './icon-button-D1J0zeqv.mjs';
- import { NG_VALUE_ACCESSOR, NG_VALIDATORS, Validators, ControlContainer, NgForm, FormGroupDirective, NgControl } from '@angular/forms';
- import { M as MAT_INPUT_VALUE_ACCESSOR } from './input-value-accessor-D1GvPuqO.mjs';
- import { h as MAT_FORM_FIELD, k as MatFormFieldControl } from './form-field-DqPi4knt.mjs';
- import { E as ErrorStateMatcher } from './error-options-Dm2JJUbF.mjs';
- import { _ as _ErrorStateTracker } from './error-state-Dtb1IHM-.mjs';
- import { CdkScrollableModule } from '@angular/cdk/scrolling';
- import { M as MatCommonModule } from './common-module-WayjW0Pb.mjs';
- import './index-SYVYjXwK.mjs';
- import './ripple-BT3tzh6F.mjs';
- import './ripple-loader-Ce3DAhPW.mjs';
- import '@angular/cdk/observers/private';
- /** @docs-private */
- function createMissingDateImplError(provider) {
- return Error(`MatDatepicker: No provider found for ${provider}. You must add one of the following ` +
- `to your app config: provideNativeDateAdapter, provideDateFnsAdapter, ` +
- `provideLuxonDateAdapter, provideMomentDateAdapter, or provide a custom implementation.`);
- }
- /** Datepicker data that requires internationalization. */
- class MatDatepickerIntl {
- /**
- * Stream that emits whenever the labels here are changed. Use this to notify
- * components if the labels have changed after initialization.
- */
- changes = new Subject();
- /** A label for the calendar popup (used by screen readers). */
- calendarLabel = 'Calendar';
- /** A label for the button used to open the calendar popup (used by screen readers). */
- openCalendarLabel = 'Open calendar';
- /** Label for the button used to close the calendar popup. */
- closeCalendarLabel = 'Close calendar';
- /** A label for the previous month button (used by screen readers). */
- prevMonthLabel = 'Previous month';
- /** A label for the next month button (used by screen readers). */
- nextMonthLabel = 'Next month';
- /** A label for the previous year button (used by screen readers). */
- prevYearLabel = 'Previous year';
- /** A label for the next year button (used by screen readers). */
- nextYearLabel = 'Next year';
- /** A label for the previous multi-year button (used by screen readers). */
- prevMultiYearLabel = 'Previous 24 years';
- /** A label for the next multi-year button (used by screen readers). */
- nextMultiYearLabel = 'Next 24 years';
- /** A label for the 'switch to month view' button (used by screen readers). */
- switchToMonthViewLabel = 'Choose date';
- /** A label for the 'switch to year view' button (used by screen readers). */
- switchToMultiYearViewLabel = 'Choose month and year';
- /**
- * A label for the first date of a range of dates (used by screen readers).
- * @deprecated Provide your own internationalization string.
- * @breaking-change 17.0.0
- */
- startDateLabel = 'Start date';
- /**
- * A label for the last date of a range of dates (used by screen readers).
- * @deprecated Provide your own internationalization string.
- * @breaking-change 17.0.0
- */
- endDateLabel = 'End date';
- /**
- * A label for the Comparison date of a range of dates (used by screen readers).
- */
- comparisonDateLabel = 'Comparison range';
- /** Formats a range of years (used for visuals). */
- formatYearRange(start, end) {
- return `${start} \u2013 ${end}`;
- }
- /** Formats a label for a range of years (used by screen readers). */
- formatYearRangeLabel(start, end) {
- return `${start} to ${end}`;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerIntl, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerIntl, providedIn: 'root' });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerIntl, decorators: [{
- type: Injectable,
- args: [{ providedIn: 'root' }]
- }] });
- let uniqueIdCounter$1 = 0;
- /**
- * An internal class that represents the data corresponding to a single calendar cell.
- * @docs-private
- */
- class MatCalendarCell {
- value;
- displayValue;
- ariaLabel;
- enabled;
- cssClasses;
- compareValue;
- rawValue;
- id = uniqueIdCounter$1++;
- constructor(value, displayValue, ariaLabel, enabled, cssClasses = {}, compareValue = value, rawValue) {
- this.value = value;
- this.displayValue = displayValue;
- this.ariaLabel = ariaLabel;
- this.enabled = enabled;
- this.cssClasses = cssClasses;
- this.compareValue = compareValue;
- this.rawValue = rawValue;
- }
- }
- /** Event options that can be used to bind an active, capturing event. */
- const activeCapturingEventOptions = {
- passive: false,
- capture: true,
- };
- /** Event options that can be used to bind a passive, capturing event. */
- const passiveCapturingEventOptions = {
- passive: true,
- capture: true,
- };
- /** Event options that can be used to bind a passive, non-capturing event. */
- const passiveEventOptions = { passive: true };
- /**
- * An internal component used to display calendar data in a table.
- * @docs-private
- */
- class MatCalendarBody {
- _elementRef = inject(ElementRef);
- _ngZone = inject(NgZone);
- _platform = inject(Platform);
- _intl = inject(MatDatepickerIntl);
- _eventCleanups;
- /**
- * Used to skip the next focus event when rendering the preview range.
- * We need a flag like this, because some browsers fire focus events asynchronously.
- */
- _skipNextFocus;
- /**
- * Used to focus the active cell after change detection has run.
- */
- _focusActiveCellAfterViewChecked = false;
- /** The label for the table. (e.g. "Jan 2017"). */
- label;
- /** The cells to display in the table. */
- rows;
- /** The value in the table that corresponds to today. */
- todayValue;
- /** Start value of the selected date range. */
- startValue;
- /** End value of the selected date range. */
- endValue;
- /** The minimum number of free cells needed to fit the label in the first row. */
- labelMinRequiredCells;
- /** The number of columns in the table. */
- numCols = 7;
- /** The cell number of the active cell in the table. */
- activeCell = 0;
- ngAfterViewChecked() {
- if (this._focusActiveCellAfterViewChecked) {
- this._focusActiveCell();
- this._focusActiveCellAfterViewChecked = false;
- }
- }
- /** Whether a range is being selected. */
- isRange = false;
- /**
- * The aspect ratio (width / height) to use for the cells in the table. This aspect ratio will be
- * maintained even as the table resizes.
- */
- cellAspectRatio = 1;
- /** Start of the comparison range. */
- comparisonStart;
- /** End of the comparison range. */
- comparisonEnd;
- /** Start of the preview range. */
- previewStart = null;
- /** End of the preview range. */
- previewEnd = null;
- /** ARIA Accessible name of the `<input matStartDate/>` */
- startDateAccessibleName;
- /** ARIA Accessible name of the `<input matEndDate/>` */
- endDateAccessibleName;
- /** Emits when a new value is selected. */
- selectedValueChange = new EventEmitter();
- /** Emits when the preview has changed as a result of a user action. */
- previewChange = new EventEmitter();
- activeDateChange = new EventEmitter();
- /** Emits the date at the possible start of a drag event. */
- dragStarted = new EventEmitter();
- /** Emits the date at the conclusion of a drag, or null if mouse was not released on a date. */
- dragEnded = new EventEmitter();
- /** The number of blank cells to put at the beginning for the first row. */
- _firstRowOffset;
- /** Padding for the individual date cells. */
- _cellPadding;
- /** Width of an individual cell. */
- _cellWidth;
- /** ID for the start date label. */
- _startDateLabelId;
- /** ID for the end date label. */
- _endDateLabelId;
- /** ID for the comparison start date label. */
- _comparisonStartDateLabelId;
- /** ID for the comparison end date label. */
- _comparisonEndDateLabelId;
- _didDragSinceMouseDown = false;
- _injector = inject(Injector);
- comparisonDateAccessibleName = this._intl.comparisonDateLabel;
- /**
- * Tracking function for rows based on their identity. Ideally we would use some sort of
- * key on the row, but that would require a breaking change for the `rows` input. We don't
- * use the built-in identity tracking, because it logs warnings.
- */
- _trackRow = (row) => row;
- constructor() {
- const renderer = inject(Renderer2);
- const idGenerator = inject(_IdGenerator);
- this._startDateLabelId = idGenerator.getId('mat-calendar-body-start-');
- this._endDateLabelId = idGenerator.getId('mat-calendar-body-end-');
- this._comparisonStartDateLabelId = idGenerator.getId('mat-calendar-body-comparison-start-');
- this._comparisonEndDateLabelId = idGenerator.getId('mat-calendar-body-comparison-end-');
- inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
- this._ngZone.runOutsideAngular(() => {
- const element = this._elementRef.nativeElement;
- const cleanups = [
- // `touchmove` is active since we need to call `preventDefault`.
- _bindEventWithOptions(renderer, element, 'touchmove', this._touchmoveHandler, activeCapturingEventOptions),
- _bindEventWithOptions(renderer, element, 'mouseenter', this._enterHandler, passiveCapturingEventOptions),
- _bindEventWithOptions(renderer, element, 'focus', this._enterHandler, passiveCapturingEventOptions),
- _bindEventWithOptions(renderer, element, 'mouseleave', this._leaveHandler, passiveCapturingEventOptions),
- _bindEventWithOptions(renderer, element, 'blur', this._leaveHandler, passiveCapturingEventOptions),
- _bindEventWithOptions(renderer, element, 'mousedown', this._mousedownHandler, passiveEventOptions),
- _bindEventWithOptions(renderer, element, 'touchstart', this._mousedownHandler, passiveEventOptions),
- ];
- if (this._platform.isBrowser) {
- cleanups.push(renderer.listen('window', 'mouseup', this._mouseupHandler), renderer.listen('window', 'touchend', this._touchendHandler));
- }
- this._eventCleanups = cleanups;
- });
- }
- /** Called when a cell is clicked. */
- _cellClicked(cell, event) {
- // Ignore "clicks" that are actually canceled drags (eg the user dragged
- // off and then went back to this cell to undo).
- if (this._didDragSinceMouseDown) {
- return;
- }
- if (cell.enabled) {
- this.selectedValueChange.emit({ value: cell.value, event });
- }
- }
- _emitActiveDateChange(cell, event) {
- if (cell.enabled) {
- this.activeDateChange.emit({ value: cell.value, event });
- }
- }
- /** Returns whether a cell should be marked as selected. */
- _isSelected(value) {
- return this.startValue === value || this.endValue === value;
- }
- ngOnChanges(changes) {
- const columnChanges = changes['numCols'];
- const { rows, numCols } = this;
- if (changes['rows'] || columnChanges) {
- this._firstRowOffset = rows && rows.length && rows[0].length ? numCols - rows[0].length : 0;
- }
- if (changes['cellAspectRatio'] || columnChanges || !this._cellPadding) {
- this._cellPadding = `${(50 * this.cellAspectRatio) / numCols}%`;
- }
- if (columnChanges || !this._cellWidth) {
- this._cellWidth = `${100 / numCols}%`;
- }
- }
- ngOnDestroy() {
- this._eventCleanups.forEach(cleanup => cleanup());
- }
- /** Returns whether a cell is active. */
- _isActiveCell(rowIndex, colIndex) {
- let cellNumber = rowIndex * this.numCols + colIndex;
- // Account for the fact that the first row may not have as many cells.
- if (rowIndex) {
- cellNumber -= this._firstRowOffset;
- }
- return cellNumber == this.activeCell;
- }
- /**
- * Focuses the active cell after the microtask queue is empty.
- *
- * Adding a 0ms setTimeout seems to fix Voiceover losing focus when pressing PageUp/PageDown
- * (issue #24330).
- *
- * Determined a 0ms by gradually increasing duration from 0 and testing two use cases with screen
- * reader enabled:
- *
- * 1. Pressing PageUp/PageDown repeatedly with pausing between each key press.
- * 2. Pressing and holding the PageDown key with repeated keys enabled.
- *
- * Test 1 worked roughly 95-99% of the time with 0ms and got a little bit better as the duration
- * increased. Test 2 got slightly better until the duration was long enough to interfere with
- * repeated keys. If the repeated key speed was faster than the timeout duration, then pressing
- * and holding pagedown caused the entire page to scroll.
- *
- * Since repeated key speed can verify across machines, determined that any duration could
- * potentially interfere with repeated keys. 0ms would be best because it almost entirely
- * eliminates the focus being lost in Voiceover (#24330) without causing unintended side effects.
- * Adding delay also complicates writing tests.
- */
- _focusActiveCell(movePreview = true) {
- afterNextRender(() => {
- setTimeout(() => {
- const activeCell = this._elementRef.nativeElement.querySelector('.mat-calendar-body-active');
- if (activeCell) {
- if (!movePreview) {
- this._skipNextFocus = true;
- }
- activeCell.focus();
- }
- });
- }, { injector: this._injector });
- }
- /** Focuses the active cell after change detection has run and the microtask queue is empty. */
- _scheduleFocusActiveCellAfterViewChecked() {
- this._focusActiveCellAfterViewChecked = true;
- }
- /** Gets whether a value is the start of the main range. */
- _isRangeStart(value) {
- return isStart(value, this.startValue, this.endValue);
- }
- /** Gets whether a value is the end of the main range. */
- _isRangeEnd(value) {
- return isEnd(value, this.startValue, this.endValue);
- }
- /** Gets whether a value is within the currently-selected range. */
- _isInRange(value) {
- return isInRange(value, this.startValue, this.endValue, this.isRange);
- }
- /** Gets whether a value is the start of the comparison range. */
- _isComparisonStart(value) {
- return isStart(value, this.comparisonStart, this.comparisonEnd);
- }
- /** Whether the cell is a start bridge cell between the main and comparison ranges. */
- _isComparisonBridgeStart(value, rowIndex, colIndex) {
- if (!this._isComparisonStart(value) || this._isRangeStart(value) || !this._isInRange(value)) {
- return false;
- }
- let previousCell = this.rows[rowIndex][colIndex - 1];
- if (!previousCell) {
- const previousRow = this.rows[rowIndex - 1];
- previousCell = previousRow && previousRow[previousRow.length - 1];
- }
- return previousCell && !this._isRangeEnd(previousCell.compareValue);
- }
- /** Whether the cell is an end bridge cell between the main and comparison ranges. */
- _isComparisonBridgeEnd(value, rowIndex, colIndex) {
- if (!this._isComparisonEnd(value) || this._isRangeEnd(value) || !this._isInRange(value)) {
- return false;
- }
- let nextCell = this.rows[rowIndex][colIndex + 1];
- if (!nextCell) {
- const nextRow = this.rows[rowIndex + 1];
- nextCell = nextRow && nextRow[0];
- }
- return nextCell && !this._isRangeStart(nextCell.compareValue);
- }
- /** Gets whether a value is the end of the comparison range. */
- _isComparisonEnd(value) {
- return isEnd(value, this.comparisonStart, this.comparisonEnd);
- }
- /** Gets whether a value is within the current comparison range. */
- _isInComparisonRange(value) {
- return isInRange(value, this.comparisonStart, this.comparisonEnd, this.isRange);
- }
- /**
- * Gets whether a value is the same as the start and end of the comparison range.
- * For context, the functions that we use to determine whether something is the start/end of
- * a range don't allow for the start and end to be on the same day, because we'd have to use
- * much more specific CSS selectors to style them correctly in all scenarios. This is fine for
- * the regular range, because when it happens, the selected styles take over and still show where
- * the range would've been, however we don't have these selected styles for a comparison range.
- * This function is used to apply a class that serves the same purpose as the one for selected
- * dates, but it only applies in the context of a comparison range.
- */
- _isComparisonIdentical(value) {
- // Note that we don't need to null check the start/end
- // here, because the `value` will always be defined.
- return this.comparisonStart === this.comparisonEnd && value === this.comparisonStart;
- }
- /** Gets whether a value is the start of the preview range. */
- _isPreviewStart(value) {
- return isStart(value, this.previewStart, this.previewEnd);
- }
- /** Gets whether a value is the end of the preview range. */
- _isPreviewEnd(value) {
- return isEnd(value, this.previewStart, this.previewEnd);
- }
- /** Gets whether a value is inside the preview range. */
- _isInPreview(value) {
- return isInRange(value, this.previewStart, this.previewEnd, this.isRange);
- }
- /** Gets ids of aria descriptions for the start and end of a date range. */
- _getDescribedby(value) {
- if (!this.isRange) {
- return null;
- }
- if (this.startValue === value && this.endValue === value) {
- return `${this._startDateLabelId} ${this._endDateLabelId}`;
- }
- else if (this.startValue === value) {
- return this._startDateLabelId;
- }
- else if (this.endValue === value) {
- return this._endDateLabelId;
- }
- if (this.comparisonStart !== null && this.comparisonEnd !== null) {
- if (value === this.comparisonStart && value === this.comparisonEnd) {
- return `${this._comparisonStartDateLabelId} ${this._comparisonEndDateLabelId}`;
- }
- else if (value === this.comparisonStart) {
- return this._comparisonStartDateLabelId;
- }
- else if (value === this.comparisonEnd) {
- return this._comparisonEndDateLabelId;
- }
- }
- return null;
- }
- /**
- * Event handler for when the user enters an element
- * inside the calendar body (e.g. by hovering in or focus).
- */
- _enterHandler = (event) => {
- if (this._skipNextFocus && event.type === 'focus') {
- this._skipNextFocus = false;
- return;
- }
- // We only need to hit the zone when we're selecting a range.
- if (event.target && this.isRange) {
- const cell = this._getCellFromElement(event.target);
- if (cell) {
- this._ngZone.run(() => this.previewChange.emit({ value: cell.enabled ? cell : null, event }));
- }
- }
- };
- _touchmoveHandler = (event) => {
- if (!this.isRange)
- return;
- const target = getActualTouchTarget(event);
- const cell = target ? this._getCellFromElement(target) : null;
- if (target !== event.target) {
- this._didDragSinceMouseDown = true;
- }
- // If the initial target of the touch is a date cell, prevent default so
- // that the move is not handled as a scroll.
- if (getCellElement(event.target)) {
- event.preventDefault();
- }
- this._ngZone.run(() => this.previewChange.emit({ value: cell?.enabled ? cell : null, event }));
- };
- /**
- * Event handler for when the user's pointer leaves an element
- * inside the calendar body (e.g. by hovering out or blurring).
- */
- _leaveHandler = (event) => {
- // We only need to hit the zone when we're selecting a range.
- if (this.previewEnd !== null && this.isRange) {
- if (event.type !== 'blur') {
- this._didDragSinceMouseDown = true;
- }
- // Only reset the preview end value when leaving cells. This looks better, because
- // we have a gap between the cells and the rows and we don't want to remove the
- // range just for it to show up again when the user moves a few pixels to the side.
- if (event.target &&
- this._getCellFromElement(event.target) &&
- !(event.relatedTarget &&
- this._getCellFromElement(event.relatedTarget))) {
- this._ngZone.run(() => this.previewChange.emit({ value: null, event }));
- }
- }
- };
- /**
- * Triggered on mousedown or touchstart on a date cell.
- * Respsonsible for starting a drag sequence.
- */
- _mousedownHandler = (event) => {
- if (!this.isRange)
- return;
- this._didDragSinceMouseDown = false;
- // Begin a drag if a cell within the current range was targeted.
- const cell = event.target && this._getCellFromElement(event.target);
- if (!cell || !this._isInRange(cell.compareValue)) {
- return;
- }
- this._ngZone.run(() => {
- this.dragStarted.emit({
- value: cell.rawValue,
- event,
- });
- });
- };
- /** Triggered on mouseup anywhere. Respsonsible for ending a drag sequence. */
- _mouseupHandler = (event) => {
- if (!this.isRange)
- return;
- const cellElement = getCellElement(event.target);
- if (!cellElement) {
- // Mouseup happened outside of datepicker. Cancel drag.
- this._ngZone.run(() => {
- this.dragEnded.emit({ value: null, event });
- });
- return;
- }
- if (cellElement.closest('.mat-calendar-body') !== this._elementRef.nativeElement) {
- // Mouseup happened inside a different month instance.
- // Allow it to handle the event.
- return;
- }
- this._ngZone.run(() => {
- const cell = this._getCellFromElement(cellElement);
- this.dragEnded.emit({ value: cell?.rawValue ?? null, event });
- });
- };
- /** Triggered on touchend anywhere. Respsonsible for ending a drag sequence. */
- _touchendHandler = (event) => {
- const target = getActualTouchTarget(event);
- if (target) {
- this._mouseupHandler({ target });
- }
- };
- /** Finds the MatCalendarCell that corresponds to a DOM node. */
- _getCellFromElement(element) {
- const cell = getCellElement(element);
- if (cell) {
- const row = cell.getAttribute('data-mat-row');
- const col = cell.getAttribute('data-mat-col');
- if (row && col) {
- return this.rows[parseInt(row)][parseInt(col)];
- }
- }
- return null;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCalendarBody, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: MatCalendarBody, isStandalone: true, selector: "[mat-calendar-body]", inputs: { label: "label", rows: "rows", todayValue: "todayValue", startValue: "startValue", endValue: "endValue", labelMinRequiredCells: "labelMinRequiredCells", numCols: "numCols", activeCell: "activeCell", isRange: "isRange", cellAspectRatio: "cellAspectRatio", comparisonStart: "comparisonStart", comparisonEnd: "comparisonEnd", previewStart: "previewStart", previewEnd: "previewEnd", startDateAccessibleName: "startDateAccessibleName", endDateAccessibleName: "endDateAccessibleName" }, outputs: { selectedValueChange: "selectedValueChange", previewChange: "previewChange", activeDateChange: "activeDateChange", dragStarted: "dragStarted", dragEnded: "dragEnded" }, host: { classAttribute: "mat-calendar-body" }, exportAs: ["matCalendarBody"], usesOnChanges: true, ngImport: i0, template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n@if (_firstRowOffset < labelMinRequiredCells) {\n <tr aria-hidden=\"true\">\n <td class=\"mat-calendar-body-label\"\n [attr.colspan]=\"numCols\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{label}}\n </td>\n </tr>\n}\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n@for (row of rows; track _trackRow(row); let rowIndex = $index) {\n <tr role=\"row\">\n <!--\n This cell is purely decorative, but we can't put `aria-hidden` or `role=\"presentation\"` on it,\n because it throws off the week days for the rest of the row on NVDA. The aspect ratio of the\n table cells is maintained by setting the top and bottom padding as a percentage of the width\n (a variant of the trick described here: https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n @if (rowIndex === 0 && _firstRowOffset) {\n <td\n class=\"mat-calendar-body-label\"\n [attr.colspan]=\"_firstRowOffset\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{_firstRowOffset >= labelMinRequiredCells ? label : ''}}\n </td>\n }\n <!--\n Each gridcell in the calendar contains a button, which signals to assistive technology that the\n cell is interactable, as well as the selection state via `aria-pressed`. See #23476 for\n background.\n -->\n @for (item of row; track item.id; let colIndex = $index) {\n <td\n role=\"gridcell\"\n class=\"mat-calendar-body-cell-container\"\n [style.width]=\"_cellWidth\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\"\n [attr.data-mat-row]=\"rowIndex\"\n [attr.data-mat-col]=\"colIndex\"\n >\n <button\n type=\"button\"\n class=\"mat-calendar-body-cell\"\n [ngClass]=\"item.cssClasses\"\n [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [class.mat-calendar-body-disabled]=\"!item.enabled\"\n [class.mat-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\n [class.mat-calendar-body-range-start]=\"_isRangeStart(item.compareValue)\"\n [class.mat-calendar-body-range-end]=\"_isRangeEnd(item.compareValue)\"\n [class.mat-calendar-body-in-range]=\"_isInRange(item.compareValue)\"\n [class.mat-calendar-body-comparison-bridge-start]=\"_isComparisonBridgeStart(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-bridge-end]=\"_isComparisonBridgeEnd(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-start]=\"_isComparisonStart(item.compareValue)\"\n [class.mat-calendar-body-comparison-end]=\"_isComparisonEnd(item.compareValue)\"\n [class.mat-calendar-body-in-comparison-range]=\"_isInComparisonRange(item.compareValue)\"\n [class.mat-calendar-body-preview-start]=\"_isPreviewStart(item.compareValue)\"\n [class.mat-calendar-body-preview-end]=\"_isPreviewEnd(item.compareValue)\"\n [class.mat-calendar-body-in-preview]=\"_isInPreview(item.compareValue)\"\n [attr.aria-label]=\"item.ariaLabel\"\n [attr.aria-disabled]=\"!item.enabled || null\"\n [attr.aria-pressed]=\"_isSelected(item.compareValue)\"\n [attr.aria-current]=\"todayValue === item.compareValue ? 'date' : null\"\n [attr.aria-describedby]=\"_getDescribedby(item.compareValue)\"\n (click)=\"_cellClicked(item, $event)\"\n (focus)=\"_emitActiveDateChange(item, $event)\">\n <span class=\"mat-calendar-body-cell-content mat-focus-indicator\"\n [class.mat-calendar-body-selected]=\"_isSelected(item.compareValue)\"\n [class.mat-calendar-body-comparison-identical]=\"_isComparisonIdentical(item.compareValue)\"\n [class.mat-calendar-body-today]=\"todayValue === item.compareValue\">\n {{item.displayValue}}\n </span>\n <span class=\"mat-calendar-body-cell-preview\" aria-hidden=\"true\"></span>\n </button>\n </td>\n }\n </tr>\n}\n\n<span [id]=\"_startDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{startDateAccessibleName}}\n</span>\n<span [id]=\"_endDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{endDateAccessibleName}}\n</span>\n<span [id]=\"_comparisonStartDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{comparisonDateAccessibleName}} {{startDateAccessibleName}}\n</span>\n<span [id]=\"_comparisonEndDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{comparisonDateAccessibleName}} {{endDateAccessibleName}}\n</span>\n", styles: [".mat-calendar-body{min-width:224px}.mat-calendar-body-today:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){border-color:var(--mat-datepicker-calendar-date-today-outline-color, var(--mat-sys-primary))}.mat-calendar-body-label{height:0;line-height:0;text-align:start;padding-left:4.7142857143%;padding-right:4.7142857143%;font-size:var(--mat-datepicker-calendar-body-label-text-size, var(--mat-sys-title-small-size));font-weight:var(--mat-datepicker-calendar-body-label-text-weight, var(--mat-sys-title-small-weight));color:var(--mat-datepicker-calendar-body-label-text-color, var(--mat-sys-on-surface))}.mat-calendar-body-hidden-label{display:none}.mat-calendar-body-cell-container{position:relative;height:0;line-height:0}.mat-calendar-body-cell{position:absolute;top:0;left:0;width:100%;height:100%;background:none;text-align:center;outline:none;font-family:inherit;margin:0;font-family:var(--mat-datepicker-calendar-text-font, var(--mat-sys-body-medium-font));font-size:var(--mat-datepicker-calendar-text-size, var(--mat-sys-body-medium-size));-webkit-user-select:none;user-select:none;cursor:pointer;outline:none;border:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-calendar-body-cell::-moz-focus-inner{border:0}.mat-calendar-body-cell::before,.mat-calendar-body-cell::after,.mat-calendar-body-cell-preview{content:\"\";position:absolute;top:5%;left:0;z-index:0;box-sizing:border-box;display:block;height:90%;width:100%}.mat-calendar-body-range-start:not(.mat-calendar-body-in-comparison-range)::before,.mat-calendar-body-range-start::after,.mat-calendar-body-comparison-start:not(.mat-calendar-body-comparison-bridge-start)::before,.mat-calendar-body-comparison-start::after,.mat-calendar-body-preview-start .mat-calendar-body-cell-preview{left:5%;width:95%;border-top-left-radius:999px;border-bottom-left-radius:999px}[dir=rtl] .mat-calendar-body-range-start:not(.mat-calendar-body-in-comparison-range)::before,[dir=rtl] .mat-calendar-body-range-start::after,[dir=rtl] .mat-calendar-body-comparison-start:not(.mat-calendar-body-comparison-bridge-start)::before,[dir=rtl] .mat-calendar-body-comparison-start::after,[dir=rtl] .mat-calendar-body-preview-start .mat-calendar-body-cell-preview{left:0;border-radius:0;border-top-right-radius:999px;border-bottom-right-radius:999px}.mat-calendar-body-range-end:not(.mat-calendar-body-in-comparison-range)::before,.mat-calendar-body-range-end::after,.mat-calendar-body-comparison-end:not(.mat-calendar-body-comparison-bridge-end)::before,.mat-calendar-body-comparison-end::after,.mat-calendar-body-preview-end .mat-calendar-body-cell-preview{width:95%;border-top-right-radius:999px;border-bottom-right-radius:999px}[dir=rtl] .mat-calendar-body-range-end:not(.mat-calendar-body-in-comparison-range)::before,[dir=rtl] .mat-calendar-body-range-end::after,[dir=rtl] .mat-calendar-body-comparison-end:not(.mat-calendar-body-comparison-bridge-end)::before,[dir=rtl] .mat-calendar-body-comparison-end::after,[dir=rtl] .mat-calendar-body-preview-end .mat-calendar-body-cell-preview{left:5%;border-radius:0;border-top-left-radius:999px;border-bottom-left-radius:999px}[dir=rtl] .mat-calendar-body-comparison-bridge-start.mat-calendar-body-range-end::after,[dir=rtl] .mat-calendar-body-comparison-bridge-end.mat-calendar-body-range-start::after{width:95%;border-top-right-radius:999px;border-bottom-right-radius:999px}.mat-calendar-body-comparison-start.mat-calendar-body-range-end::after,[dir=rtl] .mat-calendar-body-comparison-start.mat-calendar-body-range-end::after,.mat-calendar-body-comparison-end.mat-calendar-body-range-start::after,[dir=rtl] .mat-calendar-body-comparison-end.mat-calendar-body-range-start::after{width:90%}.mat-calendar-body-in-preview{color:var(--mat-datepicker-calendar-date-preview-state-outline-color, var(--mat-sys-primary))}.mat-calendar-body-in-preview .mat-calendar-body-cell-preview{border-top:dashed 1px;border-bottom:dashed 1px}.mat-calendar-body-preview-start .mat-calendar-body-cell-preview{border-left:dashed 1px}[dir=rtl] .mat-calendar-body-preview-start .mat-calendar-body-cell-preview{border-left:0;border-right:dashed 1px}.mat-calendar-body-preview-end .mat-calendar-body-cell-preview{border-right:dashed 1px}[dir=rtl] .mat-calendar-body-preview-end .mat-calendar-body-cell-preview{border-right:0;border-left:dashed 1px}.mat-calendar-body-disabled{cursor:default}.mat-calendar-body-disabled>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){color:var(--mat-datepicker-calendar-date-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-calendar-body-disabled>.mat-calendar-body-today:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){border-color:var(--mat-datepicker-calendar-date-today-disabled-state-outline-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}@media(forced-colors: active){.mat-calendar-body-disabled{opacity:.5}}.mat-calendar-body-cell-content{top:5%;left:5%;z-index:1;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;line-height:1;border-width:1px;border-style:solid;border-radius:999px;color:var(--mat-datepicker-calendar-date-text-color, var(--mat-sys-on-surface));border-color:var(--mat-datepicker-calendar-date-outline-color, transparent)}.mat-calendar-body-cell-content.mat-focus-indicator{position:absolute}@media(forced-colors: active){.mat-calendar-body-cell-content{border:none}}.cdk-keyboard-focused .mat-calendar-body-active>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical),.cdk-program-focused .mat-calendar-body-active>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background-color:var(--mat-datepicker-calendar-date-focus-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) calc(var(--mat-sys-focus-state-layer-opacity) * 100%), transparent))}@media(hover: hover){.mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background-color:var(--mat-datepicker-calendar-date-hover-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) calc(var(--mat-sys-hover-state-layer-opacity) * 100%), transparent))}}.mat-calendar-body-selected{background-color:var(--mat-datepicker-calendar-date-selected-state-background-color, var(--mat-sys-primary));color:var(--mat-datepicker-calendar-date-selected-state-text-color, var(--mat-sys-on-primary))}.mat-calendar-body-disabled>.mat-calendar-body-selected{background-color:var(--mat-datepicker-calendar-date-selected-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-calendar-body-selected.mat-calendar-body-today{box-shadow:inset 0 0 0 1px var(--mat-datepicker-calendar-date-today-selected-state-outline-color, var(--mat-sys-primary))}.mat-calendar-body-in-range::before{background:var(--mat-datepicker-calendar-date-in-range-state-background-color, var(--mat-sys-primary-container))}.mat-calendar-body-comparison-identical,.mat-calendar-body-in-comparison-range::before{background:var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container))}.mat-calendar-body-comparison-identical,.mat-calendar-body-in-comparison-range::before{background:var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container))}.mat-calendar-body-comparison-bridge-start::before,[dir=rtl] .mat-calendar-body-comparison-bridge-end::before{background:linear-gradient(to right, var(--mat-datepicker-calendar-date-in-range-state-background-color, var(--mat-sys-primary-container)) 50%, var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container)) 50%)}.mat-calendar-body-comparison-bridge-end::before,[dir=rtl] .mat-calendar-body-comparison-bridge-start::before{background:linear-gradient(to left, var(--mat-datepicker-calendar-date-in-range-state-background-color, var(--mat-sys-primary-container)) 50%, var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container)) 50%)}.mat-calendar-body-in-range>.mat-calendar-body-comparison-identical,.mat-calendar-body-in-comparison-range.mat-calendar-body-in-range::after{background:var(--mat-datepicker-calendar-date-in-overlap-range-state-background-color, var(--mat-sys-secondary-container))}.mat-calendar-body-comparison-identical.mat-calendar-body-selected,.mat-calendar-body-in-comparison-range>.mat-calendar-body-selected{background:var(--mat-datepicker-calendar-date-in-overlap-range-selected-state-background-color, var(--mat-sys-secondary))}@media(forced-colors: active){.mat-datepicker-popup:not(:empty),.mat-calendar-body-cell:not(.mat-calendar-body-in-range) .mat-calendar-body-selected{outline:solid 1px}.mat-calendar-body-today{outline:dotted 1px}.mat-calendar-body-cell::before,.mat-calendar-body-cell::after,.mat-calendar-body-selected{background:none}.mat-calendar-body-in-range::before,.mat-calendar-body-comparison-bridge-start::before,.mat-calendar-body-comparison-bridge-end::before{border-top:solid 1px;border-bottom:solid 1px}.mat-calendar-body-range-start::before{border-left:solid 1px}[dir=rtl] .mat-calendar-body-range-start::before{border-left:0;border-right:solid 1px}.mat-calendar-body-range-end::before{border-right:solid 1px}[dir=rtl] .mat-calendar-body-range-end::before{border-right:0;border-left:solid 1px}.mat-calendar-body-in-comparison-range::before{border-top:dashed 1px;border-bottom:dashed 1px}.mat-calendar-body-comparison-start::before{border-left:dashed 1px}[dir=rtl] .mat-calendar-body-comparison-start::before{border-left:0;border-right:dashed 1px}.mat-calendar-body-comparison-end::before{border-right:dashed 1px}[dir=rtl] .mat-calendar-body-comparison-end::before{border-right:0;border-left:dashed 1px}}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCalendarBody, decorators: [{
- type: Component,
- args: [{ selector: '[mat-calendar-body]', host: {
- 'class': 'mat-calendar-body',
- }, exportAs: 'matCalendarBody', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgClass], template: "<!--\n If there's not enough space in the first row, create a separate label row. We mark this row as\n aria-hidden because we don't want it to be read out as one of the weeks in the month.\n-->\n@if (_firstRowOffset < labelMinRequiredCells) {\n <tr aria-hidden=\"true\">\n <td class=\"mat-calendar-body-label\"\n [attr.colspan]=\"numCols\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{label}}\n </td>\n </tr>\n}\n\n<!-- Create the first row separately so we can include a special spacer cell. -->\n@for (row of rows; track _trackRow(row); let rowIndex = $index) {\n <tr role=\"row\">\n <!--\n This cell is purely decorative, but we can't put `aria-hidden` or `role=\"presentation\"` on it,\n because it throws off the week days for the rest of the row on NVDA. The aspect ratio of the\n table cells is maintained by setting the top and bottom padding as a percentage of the width\n (a variant of the trick described here: https://www.w3schools.com/howto/howto_css_aspect_ratio.asp).\n -->\n @if (rowIndex === 0 && _firstRowOffset) {\n <td\n class=\"mat-calendar-body-label\"\n [attr.colspan]=\"_firstRowOffset\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\">\n {{_firstRowOffset >= labelMinRequiredCells ? label : ''}}\n </td>\n }\n <!--\n Each gridcell in the calendar contains a button, which signals to assistive technology that the\n cell is interactable, as well as the selection state via `aria-pressed`. See #23476 for\n background.\n -->\n @for (item of row; track item.id; let colIndex = $index) {\n <td\n role=\"gridcell\"\n class=\"mat-calendar-body-cell-container\"\n [style.width]=\"_cellWidth\"\n [style.paddingTop]=\"_cellPadding\"\n [style.paddingBottom]=\"_cellPadding\"\n [attr.data-mat-row]=\"rowIndex\"\n [attr.data-mat-col]=\"colIndex\"\n >\n <button\n type=\"button\"\n class=\"mat-calendar-body-cell\"\n [ngClass]=\"item.cssClasses\"\n [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\n [class.mat-calendar-body-disabled]=\"!item.enabled\"\n [class.mat-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\n [class.mat-calendar-body-range-start]=\"_isRangeStart(item.compareValue)\"\n [class.mat-calendar-body-range-end]=\"_isRangeEnd(item.compareValue)\"\n [class.mat-calendar-body-in-range]=\"_isInRange(item.compareValue)\"\n [class.mat-calendar-body-comparison-bridge-start]=\"_isComparisonBridgeStart(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-bridge-end]=\"_isComparisonBridgeEnd(item.compareValue, rowIndex, colIndex)\"\n [class.mat-calendar-body-comparison-start]=\"_isComparisonStart(item.compareValue)\"\n [class.mat-calendar-body-comparison-end]=\"_isComparisonEnd(item.compareValue)\"\n [class.mat-calendar-body-in-comparison-range]=\"_isInComparisonRange(item.compareValue)\"\n [class.mat-calendar-body-preview-start]=\"_isPreviewStart(item.compareValue)\"\n [class.mat-calendar-body-preview-end]=\"_isPreviewEnd(item.compareValue)\"\n [class.mat-calendar-body-in-preview]=\"_isInPreview(item.compareValue)\"\n [attr.aria-label]=\"item.ariaLabel\"\n [attr.aria-disabled]=\"!item.enabled || null\"\n [attr.aria-pressed]=\"_isSelected(item.compareValue)\"\n [attr.aria-current]=\"todayValue === item.compareValue ? 'date' : null\"\n [attr.aria-describedby]=\"_getDescribedby(item.compareValue)\"\n (click)=\"_cellClicked(item, $event)\"\n (focus)=\"_emitActiveDateChange(item, $event)\">\n <span class=\"mat-calendar-body-cell-content mat-focus-indicator\"\n [class.mat-calendar-body-selected]=\"_isSelected(item.compareValue)\"\n [class.mat-calendar-body-comparison-identical]=\"_isComparisonIdentical(item.compareValue)\"\n [class.mat-calendar-body-today]=\"todayValue === item.compareValue\">\n {{item.displayValue}}\n </span>\n <span class=\"mat-calendar-body-cell-preview\" aria-hidden=\"true\"></span>\n </button>\n </td>\n }\n </tr>\n}\n\n<span [id]=\"_startDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{startDateAccessibleName}}\n</span>\n<span [id]=\"_endDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{endDateAccessibleName}}\n</span>\n<span [id]=\"_comparisonStartDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{comparisonDateAccessibleName}} {{startDateAccessibleName}}\n</span>\n<span [id]=\"_comparisonEndDateLabelId\" class=\"mat-calendar-body-hidden-label\">\n {{comparisonDateAccessibleName}} {{endDateAccessibleName}}\n</span>\n", styles: [".mat-calendar-body{min-width:224px}.mat-calendar-body-today:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){border-color:var(--mat-datepicker-calendar-date-today-outline-color, var(--mat-sys-primary))}.mat-calendar-body-label{height:0;line-height:0;text-align:start;padding-left:4.7142857143%;padding-right:4.7142857143%;font-size:var(--mat-datepicker-calendar-body-label-text-size, var(--mat-sys-title-small-size));font-weight:var(--mat-datepicker-calendar-body-label-text-weight, var(--mat-sys-title-small-weight));color:var(--mat-datepicker-calendar-body-label-text-color, var(--mat-sys-on-surface))}.mat-calendar-body-hidden-label{display:none}.mat-calendar-body-cell-container{position:relative;height:0;line-height:0}.mat-calendar-body-cell{position:absolute;top:0;left:0;width:100%;height:100%;background:none;text-align:center;outline:none;font-family:inherit;margin:0;font-family:var(--mat-datepicker-calendar-text-font, var(--mat-sys-body-medium-font));font-size:var(--mat-datepicker-calendar-text-size, var(--mat-sys-body-medium-size));-webkit-user-select:none;user-select:none;cursor:pointer;outline:none;border:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-calendar-body-cell::-moz-focus-inner{border:0}.mat-calendar-body-cell::before,.mat-calendar-body-cell::after,.mat-calendar-body-cell-preview{content:\"\";position:absolute;top:5%;left:0;z-index:0;box-sizing:border-box;display:block;height:90%;width:100%}.mat-calendar-body-range-start:not(.mat-calendar-body-in-comparison-range)::before,.mat-calendar-body-range-start::after,.mat-calendar-body-comparison-start:not(.mat-calendar-body-comparison-bridge-start)::before,.mat-calendar-body-comparison-start::after,.mat-calendar-body-preview-start .mat-calendar-body-cell-preview{left:5%;width:95%;border-top-left-radius:999px;border-bottom-left-radius:999px}[dir=rtl] .mat-calendar-body-range-start:not(.mat-calendar-body-in-comparison-range)::before,[dir=rtl] .mat-calendar-body-range-start::after,[dir=rtl] .mat-calendar-body-comparison-start:not(.mat-calendar-body-comparison-bridge-start)::before,[dir=rtl] .mat-calendar-body-comparison-start::after,[dir=rtl] .mat-calendar-body-preview-start .mat-calendar-body-cell-preview{left:0;border-radius:0;border-top-right-radius:999px;border-bottom-right-radius:999px}.mat-calendar-body-range-end:not(.mat-calendar-body-in-comparison-range)::before,.mat-calendar-body-range-end::after,.mat-calendar-body-comparison-end:not(.mat-calendar-body-comparison-bridge-end)::before,.mat-calendar-body-comparison-end::after,.mat-calendar-body-preview-end .mat-calendar-body-cell-preview{width:95%;border-top-right-radius:999px;border-bottom-right-radius:999px}[dir=rtl] .mat-calendar-body-range-end:not(.mat-calendar-body-in-comparison-range)::before,[dir=rtl] .mat-calendar-body-range-end::after,[dir=rtl] .mat-calendar-body-comparison-end:not(.mat-calendar-body-comparison-bridge-end)::before,[dir=rtl] .mat-calendar-body-comparison-end::after,[dir=rtl] .mat-calendar-body-preview-end .mat-calendar-body-cell-preview{left:5%;border-radius:0;border-top-left-radius:999px;border-bottom-left-radius:999px}[dir=rtl] .mat-calendar-body-comparison-bridge-start.mat-calendar-body-range-end::after,[dir=rtl] .mat-calendar-body-comparison-bridge-end.mat-calendar-body-range-start::after{width:95%;border-top-right-radius:999px;border-bottom-right-radius:999px}.mat-calendar-body-comparison-start.mat-calendar-body-range-end::after,[dir=rtl] .mat-calendar-body-comparison-start.mat-calendar-body-range-end::after,.mat-calendar-body-comparison-end.mat-calendar-body-range-start::after,[dir=rtl] .mat-calendar-body-comparison-end.mat-calendar-body-range-start::after{width:90%}.mat-calendar-body-in-preview{color:var(--mat-datepicker-calendar-date-preview-state-outline-color, var(--mat-sys-primary))}.mat-calendar-body-in-preview .mat-calendar-body-cell-preview{border-top:dashed 1px;border-bottom:dashed 1px}.mat-calendar-body-preview-start .mat-calendar-body-cell-preview{border-left:dashed 1px}[dir=rtl] .mat-calendar-body-preview-start .mat-calendar-body-cell-preview{border-left:0;border-right:dashed 1px}.mat-calendar-body-preview-end .mat-calendar-body-cell-preview{border-right:dashed 1px}[dir=rtl] .mat-calendar-body-preview-end .mat-calendar-body-cell-preview{border-right:0;border-left:dashed 1px}.mat-calendar-body-disabled{cursor:default}.mat-calendar-body-disabled>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){color:var(--mat-datepicker-calendar-date-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-calendar-body-disabled>.mat-calendar-body-today:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){border-color:var(--mat-datepicker-calendar-date-today-disabled-state-outline-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}@media(forced-colors: active){.mat-calendar-body-disabled{opacity:.5}}.mat-calendar-body-cell-content{top:5%;left:5%;z-index:1;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;line-height:1;border-width:1px;border-style:solid;border-radius:999px;color:var(--mat-datepicker-calendar-date-text-color, var(--mat-sys-on-surface));border-color:var(--mat-datepicker-calendar-date-outline-color, transparent)}.mat-calendar-body-cell-content.mat-focus-indicator{position:absolute}@media(forced-colors: active){.mat-calendar-body-cell-content{border:none}}.cdk-keyboard-focused .mat-calendar-body-active>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical),.cdk-program-focused .mat-calendar-body-active>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background-color:var(--mat-datepicker-calendar-date-focus-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) calc(var(--mat-sys-focus-state-layer-opacity) * 100%), transparent))}@media(hover: hover){.mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical){background-color:var(--mat-datepicker-calendar-date-hover-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) calc(var(--mat-sys-hover-state-layer-opacity) * 100%), transparent))}}.mat-calendar-body-selected{background-color:var(--mat-datepicker-calendar-date-selected-state-background-color, var(--mat-sys-primary));color:var(--mat-datepicker-calendar-date-selected-state-text-color, var(--mat-sys-on-primary))}.mat-calendar-body-disabled>.mat-calendar-body-selected{background-color:var(--mat-datepicker-calendar-date-selected-disabled-state-background-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-calendar-body-selected.mat-calendar-body-today{box-shadow:inset 0 0 0 1px var(--mat-datepicker-calendar-date-today-selected-state-outline-color, var(--mat-sys-primary))}.mat-calendar-body-in-range::before{background:var(--mat-datepicker-calendar-date-in-range-state-background-color, var(--mat-sys-primary-container))}.mat-calendar-body-comparison-identical,.mat-calendar-body-in-comparison-range::before{background:var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container))}.mat-calendar-body-comparison-identical,.mat-calendar-body-in-comparison-range::before{background:var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container))}.mat-calendar-body-comparison-bridge-start::before,[dir=rtl] .mat-calendar-body-comparison-bridge-end::before{background:linear-gradient(to right, var(--mat-datepicker-calendar-date-in-range-state-background-color, var(--mat-sys-primary-container)) 50%, var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container)) 50%)}.mat-calendar-body-comparison-bridge-end::before,[dir=rtl] .mat-calendar-body-comparison-bridge-start::before{background:linear-gradient(to left, var(--mat-datepicker-calendar-date-in-range-state-background-color, var(--mat-sys-primary-container)) 50%, var(--mat-datepicker-calendar-date-in-comparison-range-state-background-color, var(--mat-sys-tertiary-container)) 50%)}.mat-calendar-body-in-range>.mat-calendar-body-comparison-identical,.mat-calendar-body-in-comparison-range.mat-calendar-body-in-range::after{background:var(--mat-datepicker-calendar-date-in-overlap-range-state-background-color, var(--mat-sys-secondary-container))}.mat-calendar-body-comparison-identical.mat-calendar-body-selected,.mat-calendar-body-in-comparison-range>.mat-calendar-body-selected{background:var(--mat-datepicker-calendar-date-in-overlap-range-selected-state-background-color, var(--mat-sys-secondary))}@media(forced-colors: active){.mat-datepicker-popup:not(:empty),.mat-calendar-body-cell:not(.mat-calendar-body-in-range) .mat-calendar-body-selected{outline:solid 1px}.mat-calendar-body-today{outline:dotted 1px}.mat-calendar-body-cell::before,.mat-calendar-body-cell::after,.mat-calendar-body-selected{background:none}.mat-calendar-body-in-range::before,.mat-calendar-body-comparison-bridge-start::before,.mat-calendar-body-comparison-bridge-end::before{border-top:solid 1px;border-bottom:solid 1px}.mat-calendar-body-range-start::before{border-left:solid 1px}[dir=rtl] .mat-calendar-body-range-start::before{border-left:0;border-right:solid 1px}.mat-calendar-body-range-end::before{border-right:solid 1px}[dir=rtl] .mat-calendar-body-range-end::before{border-right:0;border-left:solid 1px}.mat-calendar-body-in-comparison-range::before{border-top:dashed 1px;border-bottom:dashed 1px}.mat-calendar-body-comparison-start::before{border-left:dashed 1px}[dir=rtl] .mat-calendar-body-comparison-start::before{border-left:0;border-right:dashed 1px}.mat-calendar-body-comparison-end::before{border-right:dashed 1px}[dir=rtl] .mat-calendar-body-comparison-end::before{border-right:0;border-left:dashed 1px}}\n"] }]
- }], ctorParameters: () => [], propDecorators: { label: [{
- type: Input
- }], rows: [{
- type: Input
- }], todayValue: [{
- type: Input
- }], startValue: [{
- type: Input
- }], endValue: [{
- type: Input
- }], labelMinRequiredCells: [{
- type: Input
- }], numCols: [{
- type: Input
- }], activeCell: [{
- type: Input
- }], isRange: [{
- type: Input
- }], cellAspectRatio: [{
- type: Input
- }], comparisonStart: [{
- type: Input
- }], comparisonEnd: [{
- type: Input
- }], previewStart: [{
- type: Input
- }], previewEnd: [{
- type: Input
- }], startDateAccessibleName: [{
- type: Input
- }], endDateAccessibleName: [{
- type: Input
- }], selectedValueChange: [{
- type: Output
- }], previewChange: [{
- type: Output
- }], activeDateChange: [{
- type: Output
- }], dragStarted: [{
- type: Output
- }], dragEnded: [{
- type: Output
- }] } });
- /** Checks whether a node is a table cell element. */
- function isTableCell(node) {
- return node?.nodeName === 'TD';
- }
- /**
- * Gets the date table cell element that is or contains the specified element.
- * Or returns null if element is not part of a date cell.
- */
- function getCellElement(element) {
- let cell;
- if (isTableCell(element)) {
- cell = element;
- }
- else if (isTableCell(element.parentNode)) {
- cell = element.parentNode;
- }
- else if (isTableCell(element.parentNode?.parentNode)) {
- cell = element.parentNode.parentNode;
- }
- return cell?.getAttribute('data-mat-row') != null ? cell : null;
- }
- /** Checks whether a value is the start of a range. */
- function isStart(value, start, end) {
- return end !== null && start !== end && value < end && value === start;
- }
- /** Checks whether a value is the end of a range. */
- function isEnd(value, start, end) {
- return start !== null && start !== end && value >= start && value === end;
- }
- /** Checks whether a value is inside of a range. */
- function isInRange(value, start, end, rangeEnabled) {
- return (rangeEnabled &&
- start !== null &&
- end !== null &&
- start !== end &&
- value >= start &&
- value <= end);
- }
- /**
- * Extracts the element that actually corresponds to a touch event's location
- * (rather than the element that initiated the sequence of touch events).
- */
- function getActualTouchTarget(event) {
- const touchLocation = event.changedTouches[0];
- return document.elementFromPoint(touchLocation.clientX, touchLocation.clientY);
- }
- /** A class representing a range of dates. */
- class DateRange {
- start;
- end;
- /**
- * Ensures that objects with a `start` and `end` property can't be assigned to a variable that
- * expects a `DateRange`
- */
- // tslint:disable-next-line:no-unused-variable
- _disableStructuralEquivalency;
- constructor(
- /** The start date of the range. */
- start,
- /** The end date of the range. */
- end) {
- this.start = start;
- this.end = end;
- }
- }
- /**
- * A selection model containing a date selection.
- * @docs-private
- */
- class MatDateSelectionModel {
- selection;
- _adapter;
- _selectionChanged = new Subject();
- /** Emits when the selection has changed. */
- selectionChanged = this._selectionChanged;
- constructor(
- /** The current selection. */
- selection, _adapter) {
- this.selection = selection;
- this._adapter = _adapter;
- this.selection = selection;
- }
- /**
- * Updates the current selection in the model.
- * @param value New selection that should be assigned.
- * @param source Object that triggered the selection change.
- */
- updateSelection(value, source) {
- const oldValue = this.selection;
- this.selection = value;
- this._selectionChanged.next({ selection: value, source, oldValue });
- }
- ngOnDestroy() {
- this._selectionChanged.complete();
- }
- _isValidDateInstance(date) {
- return this._adapter.isDateInstance(date) && this._adapter.isValid(date);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateSelectionModel, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateSelectionModel });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateSelectionModel, decorators: [{
- type: Injectable
- }], ctorParameters: () => [{ type: undefined }, { type: DateAdapter }] });
- /**
- * A selection model that contains a single date.
- * @docs-private
- */
- class MatSingleDateSelectionModel extends MatDateSelectionModel {
- constructor(adapter) {
- super(null, adapter);
- }
- /**
- * Adds a date to the current selection. In the case of a single date selection, the added date
- * simply overwrites the previous selection
- */
- add(date) {
- super.updateSelection(date, this);
- }
- /** Checks whether the current selection is valid. */
- isValid() {
- return this.selection != null && this._isValidDateInstance(this.selection);
- }
- /**
- * Checks whether the current selection is complete. In the case of a single date selection, this
- * is true if the current selection is not null.
- */
- isComplete() {
- return this.selection != null;
- }
- /** Clones the selection model. */
- clone() {
- const clone = new MatSingleDateSelectionModel(this._adapter);
- clone.updateSelection(this.selection, this);
- return clone;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSingleDateSelectionModel, deps: [{ token: DateAdapter }], target: i0.ɵɵFactoryTarget.Injectable });
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSingleDateSelectionModel });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatSingleDateSelectionModel, decorators: [{
- type: Injectable
- }], ctorParameters: () => [{ type: DateAdapter }] });
- /**
- * A selection model that contains a date range.
- * @docs-private
- */
- class MatRangeDateSelectionModel extends MatDateSelectionModel {
- constructor(adapter) {
- super(new DateRange(null, null), adapter);
- }
- /**
- * Adds a date to the current selection. In the case of a date range selection, the added date
- * fills in the next `null` value in the range. If both the start and the end already have a date,
- * the selection is reset so that the given date is the new `start` and the `end` is null.
- */
- add(date) {
- let { start, end } = this.selection;
- if (start == null) {
- start = date;
- }
- else if (end == null) {
- end = date;
- }
- else {
- start = date;
- end = null;
- }
- super.updateSelection(new DateRange(start, end), this);
- }
- /** Checks whether the current selection is valid. */
- isValid() {
- const { start, end } = this.selection;
- // Empty ranges are valid.
- if (start == null && end == null) {
- return true;
- }
- // Complete ranges are only valid if both dates are valid and the start is before the end.
- if (start != null && end != null) {
- return (this._isValidDateInstance(start) &&
- this._isValidDateInstance(end) &&
- this._adapter.compareDate(start, end) <= 0);
- }
- // Partial ranges are valid if the start/end is valid.
- return ((start == null || this._isValidDateInstance(start)) &&
- (end == null || this._isValidDateInstance(end)));
- }
- /**
- * Checks whether the current selection is complete. In the case of a date range selection, this
- * is true if the current selection has a non-null `start` and `end`.
- */
- isComplete() {
- return this.selection.start != null && this.selection.end != null;
- }
- /** Clones the selection model. */
- clone() {
- const clone = new MatRangeDateSelectionModel(this._adapter);
- clone.updateSelection(this.selection, this);
- return clone;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRangeDateSelectionModel, deps: [{ token: DateAdapter }], target: i0.ɵɵFactoryTarget.Injectable });
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRangeDateSelectionModel });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatRangeDateSelectionModel, decorators: [{
- type: Injectable
- }], ctorParameters: () => [{ type: DateAdapter }] });
- /**
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- function MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY(parent, adapter) {
- return parent || new MatSingleDateSelectionModel(adapter);
- }
- /**
- * Used to provide a single selection model to a component.
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- const MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER = {
- provide: MatDateSelectionModel,
- deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
- useFactory: MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY,
- };
- /**
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- function MAT_RANGE_DATE_SELECTION_MODEL_FACTORY(parent, adapter) {
- return parent || new MatRangeDateSelectionModel(adapter);
- }
- /**
- * Used to provide a range selection model to a component.
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- const MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER = {
- provide: MatDateSelectionModel,
- deps: [[new Optional(), new SkipSelf(), MatDateSelectionModel], DateAdapter],
- useFactory: MAT_RANGE_DATE_SELECTION_MODEL_FACTORY,
- };
- /** Injection token used to customize the date range selection behavior. */
- const MAT_DATE_RANGE_SELECTION_STRATEGY = new InjectionToken('MAT_DATE_RANGE_SELECTION_STRATEGY');
- /** Provides the default date range selection behavior. */
- class DefaultMatCalendarRangeStrategy {
- _dateAdapter;
- constructor(_dateAdapter) {
- this._dateAdapter = _dateAdapter;
- }
- selectionFinished(date, currentRange) {
- let { start, end } = currentRange;
- if (start == null) {
- start = date;
- }
- else if (end == null && date && this._dateAdapter.compareDate(date, start) >= 0) {
- end = date;
- }
- else {
- start = date;
- end = null;
- }
- return new DateRange(start, end);
- }
- createPreview(activeDate, currentRange) {
- let start = null;
- let end = null;
- if (currentRange.start && !currentRange.end && activeDate) {
- start = currentRange.start;
- end = activeDate;
- }
- return new DateRange(start, end);
- }
- createDrag(dragOrigin, originalRange, newDate) {
- let start = originalRange.start;
- let end = originalRange.end;
- if (!start || !end) {
- // Can't drag from an incomplete range.
- return null;
- }
- const adapter = this._dateAdapter;
- const isRange = adapter.compareDate(start, end) !== 0;
- const diffYears = adapter.getYear(newDate) - adapter.getYear(dragOrigin);
- const diffMonths = adapter.getMonth(newDate) - adapter.getMonth(dragOrigin);
- const diffDays = adapter.getDate(newDate) - adapter.getDate(dragOrigin);
- if (isRange && adapter.sameDate(dragOrigin, originalRange.start)) {
- start = newDate;
- if (adapter.compareDate(newDate, end) > 0) {
- end = adapter.addCalendarYears(end, diffYears);
- end = adapter.addCalendarMonths(end, diffMonths);
- end = adapter.addCalendarDays(end, diffDays);
- }
- }
- else if (isRange && adapter.sameDate(dragOrigin, originalRange.end)) {
- end = newDate;
- if (adapter.compareDate(newDate, start) < 0) {
- start = adapter.addCalendarYears(start, diffYears);
- start = adapter.addCalendarMonths(start, diffMonths);
- start = adapter.addCalendarDays(start, diffDays);
- }
- }
- else {
- start = adapter.addCalendarYears(start, diffYears);
- start = adapter.addCalendarMonths(start, diffMonths);
- start = adapter.addCalendarDays(start, diffDays);
- end = adapter.addCalendarYears(end, diffYears);
- end = adapter.addCalendarMonths(end, diffMonths);
- end = adapter.addCalendarDays(end, diffDays);
- }
- return new DateRange(start, end);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DefaultMatCalendarRangeStrategy, deps: [{ token: DateAdapter }], target: i0.ɵɵFactoryTarget.Injectable });
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DefaultMatCalendarRangeStrategy });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: DefaultMatCalendarRangeStrategy, decorators: [{
- type: Injectable
- }], ctorParameters: () => [{ type: DateAdapter }] });
- /**
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- function MAT_CALENDAR_RANGE_STRATEGY_PROVIDER_FACTORY(parent, adapter) {
- return parent || new DefaultMatCalendarRangeStrategy(adapter);
- }
- /**
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- const MAT_CALENDAR_RANGE_STRATEGY_PROVIDER = {
- provide: MAT_DATE_RANGE_SELECTION_STRATEGY,
- deps: [[new Optional(), new SkipSelf(), MAT_DATE_RANGE_SELECTION_STRATEGY], DateAdapter],
- useFactory: MAT_CALENDAR_RANGE_STRATEGY_PROVIDER_FACTORY,
- };
- const DAYS_PER_WEEK = 7;
- let uniqueIdCounter = 0;
- /**
- * An internal component used to display a single month in the datepicker.
- * @docs-private
- */
- class MatMonthView {
- _changeDetectorRef = inject(ChangeDetectorRef);
- _dateFormats = inject(MAT_DATE_FORMATS, { optional: true });
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dir = inject(Directionality, { optional: true });
- _rangeStrategy = inject(MAT_DATE_RANGE_SELECTION_STRATEGY, { optional: true });
- _rerenderSubscription = Subscription.EMPTY;
- /** Flag used to filter out space/enter keyup events that originated outside of the view. */
- _selectionKeyPressed;
- /**
- * The date to display in this month view (everything other than the month and year is ignored).
- */
- get activeDate() {
- return this._activeDate;
- }
- set activeDate(value) {
- const oldActiveDate = this._activeDate;
- const validDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)) ||
- this._dateAdapter.today();
- this._activeDate = this._dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
- if (!this._hasSameMonthAndYear(oldActiveDate, this._activeDate)) {
- this._init();
- }
- }
- _activeDate;
- /** The currently selected date. */
- get selected() {
- return this._selected;
- }
- set selected(value) {
- if (value instanceof DateRange) {
- this._selected = value;
- }
- else {
- this._selected = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- this._setRanges(this._selected);
- }
- _selected;
- /** The minimum selectable date. */
- get minDate() {
- return this._minDate;
- }
- set minDate(value) {
- this._minDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _minDate;
- /** The maximum selectable date. */
- get maxDate() {
- return this._maxDate;
- }
- set maxDate(value) {
- this._maxDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _maxDate;
- /** Function used to filter which dates are selectable. */
- dateFilter;
- /** Function that can be used to add custom CSS classes to dates. */
- dateClass;
- /** Start of the comparison range. */
- comparisonStart;
- /** End of the comparison range. */
- comparisonEnd;
- /** ARIA Accessible name of the `<input matStartDate/>` */
- startDateAccessibleName;
- /** ARIA Accessible name of the `<input matEndDate/>` */
- endDateAccessibleName;
- /** Origin of active drag, or null when dragging is not active. */
- activeDrag = null;
- /** Emits when a new date is selected. */
- selectedChange = new EventEmitter();
- /** Emits when any date is selected. */
- _userSelection = new EventEmitter();
- /** Emits when the user initiates a date range drag via mouse or touch. */
- dragStarted = new EventEmitter();
- /**
- * Emits when the user completes or cancels a date range drag.
- * Emits null when the drag was canceled or the newly selected date range if completed.
- */
- dragEnded = new EventEmitter();
- /** Emits when any date is activated. */
- activeDateChange = new EventEmitter();
- /** The body of calendar table */
- _matCalendarBody;
- /** The label for this month (e.g. "January 2017"). */
- _monthLabel;
- /** Grid of calendar cells representing the dates of the month. */
- _weeks;
- /** The number of blank cells in the first row before the 1st of the month. */
- _firstWeekOffset;
- /** Start value of the currently-shown date range. */
- _rangeStart;
- /** End value of the currently-shown date range. */
- _rangeEnd;
- /** Start value of the currently-shown comparison date range. */
- _comparisonRangeStart;
- /** End value of the currently-shown comparison date range. */
- _comparisonRangeEnd;
- /** Start of the preview range. */
- _previewStart;
- /** End of the preview range. */
- _previewEnd;
- /** Whether the user is currently selecting a range of dates. */
- _isRange;
- /** The date of the month that today falls on. Null if today is in another month. */
- _todayDate;
- /** The names of the weekdays. */
- _weekdays;
- constructor() {
- inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
- if (!this._dateAdapter) {
- throw createMissingDateImplError('DateAdapter');
- }
- if (!this._dateFormats) {
- throw createMissingDateImplError('MAT_DATE_FORMATS');
- }
- }
- this._activeDate = this._dateAdapter.today();
- }
- ngAfterContentInit() {
- this._rerenderSubscription = this._dateAdapter.localeChanges
- .pipe(startWith(null))
- .subscribe(() => this._init());
- }
- ngOnChanges(changes) {
- const comparisonChange = changes['comparisonStart'] || changes['comparisonEnd'];
- if (comparisonChange && !comparisonChange.firstChange) {
- this._setRanges(this.selected);
- }
- if (changes['activeDrag'] && !this.activeDrag) {
- this._clearPreview();
- }
- }
- ngOnDestroy() {
- this._rerenderSubscription.unsubscribe();
- }
- /** Handles when a new date is selected. */
- _dateSelected(event) {
- const date = event.value;
- const selectedDate = this._getDateFromDayOfMonth(date);
- let rangeStartDate;
- let rangeEndDate;
- if (this._selected instanceof DateRange) {
- rangeStartDate = this._getDateInCurrentMonth(this._selected.start);
- rangeEndDate = this._getDateInCurrentMonth(this._selected.end);
- }
- else {
- rangeStartDate = rangeEndDate = this._getDateInCurrentMonth(this._selected);
- }
- if (rangeStartDate !== date || rangeEndDate !== date) {
- this.selectedChange.emit(selectedDate);
- }
- this._userSelection.emit({ value: selectedDate, event: event.event });
- this._clearPreview();
- this._changeDetectorRef.markForCheck();
- }
- /**
- * Takes the index of a calendar body cell wrapped in an event as argument. For the date that
- * corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
- * that date.
- *
- * This function is used to match each component's model of the active date with the calendar
- * body cell that was focused. It updates its value of `activeDate` synchronously and updates the
- * parent's value asynchronously via the `activeDateChange` event. The child component receives an
- * updated value asynchronously via the `activeCell` Input.
- */
- _updateActiveDate(event) {
- const month = event.value;
- const oldActiveDate = this._activeDate;
- this.activeDate = this._getDateFromDayOfMonth(month);
- if (this._dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
- this.activeDateChange.emit(this._activeDate);
- }
- }
- /** Handles keydown events on the calendar body when calendar is in month view. */
- _handleCalendarBodyKeydown(event) {
- // TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
- // disabled ones from being selected. This may not be ideal, we should look into whether
- // navigation should skip over disabled dates, and if so, how to implement that efficiently.
- const oldActiveDate = this._activeDate;
- const isRtl = this._isRtl();
- switch (event.keyCode) {
- case LEFT_ARROW:
- this.activeDate = this._dateAdapter.addCalendarDays(this._activeDate, isRtl ? 1 : -1);
- break;
- case RIGHT_ARROW:
- this.activeDate = this._dateAdapter.addCalendarDays(this._activeDate, isRtl ? -1 : 1);
- break;
- case UP_ARROW:
- this.activeDate = this._dateAdapter.addCalendarDays(this._activeDate, -7);
- break;
- case DOWN_ARROW:
- this.activeDate = this._dateAdapter.addCalendarDays(this._activeDate, 7);
- break;
- case HOME:
- this.activeDate = this._dateAdapter.addCalendarDays(this._activeDate, 1 - this._dateAdapter.getDate(this._activeDate));
- break;
- case END:
- this.activeDate = this._dateAdapter.addCalendarDays(this._activeDate, this._dateAdapter.getNumDaysInMonth(this._activeDate) -
- this._dateAdapter.getDate(this._activeDate));
- break;
- case PAGE_UP:
- this.activeDate = event.altKey
- ? this._dateAdapter.addCalendarYears(this._activeDate, -1)
- : this._dateAdapter.addCalendarMonths(this._activeDate, -1);
- break;
- case PAGE_DOWN:
- this.activeDate = event.altKey
- ? this._dateAdapter.addCalendarYears(this._activeDate, 1)
- : this._dateAdapter.addCalendarMonths(this._activeDate, 1);
- break;
- case ENTER:
- case SPACE:
- this._selectionKeyPressed = true;
- if (this._canSelect(this._activeDate)) {
- // Prevent unexpected default actions such as form submission.
- // Note that we only prevent the default action here while the selection happens in
- // `keyup` below. We can't do the selection here, because it can cause the calendar to
- // reopen if focus is restored immediately. We also can't call `preventDefault` on `keyup`
- // because it's too late (see #23305).
- event.preventDefault();
- }
- return;
- case ESCAPE:
- // Abort the current range selection if the user presses escape mid-selection.
- if (this._previewEnd != null && !hasModifierKey(event)) {
- this._clearPreview();
- // If a drag is in progress, cancel the drag without changing the
- // current selection.
- if (this.activeDrag) {
- this.dragEnded.emit({ value: null, event });
- }
- else {
- this.selectedChange.emit(null);
- this._userSelection.emit({ value: null, event });
- }
- event.preventDefault();
- event.stopPropagation(); // Prevents the overlay from closing.
- }
- return;
- default:
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
- return;
- }
- if (this._dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
- this.activeDateChange.emit(this.activeDate);
- this._focusActiveCellAfterViewChecked();
- }
- // Prevent unexpected default actions such as form submission.
- event.preventDefault();
- }
- /** Handles keyup events on the calendar body when calendar is in month view. */
- _handleCalendarBodyKeyup(event) {
- if (event.keyCode === SPACE || event.keyCode === ENTER) {
- if (this._selectionKeyPressed && this._canSelect(this._activeDate)) {
- this._dateSelected({ value: this._dateAdapter.getDate(this._activeDate), event });
- }
- this._selectionKeyPressed = false;
- }
- }
- /** Initializes this month view. */
- _init() {
- this._setRanges(this.selected);
- this._todayDate = this._getCellCompareValue(this._dateAdapter.today());
- this._monthLabel = this._dateFormats.display.monthLabel
- ? this._dateAdapter.format(this.activeDate, this._dateFormats.display.monthLabel)
- : this._dateAdapter
- .getMonthNames('short')[this._dateAdapter.getMonth(this.activeDate)].toLocaleUpperCase();
- let firstOfMonth = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), this._dateAdapter.getMonth(this.activeDate), 1);
- this._firstWeekOffset =
- (DAYS_PER_WEEK +
- this._dateAdapter.getDayOfWeek(firstOfMonth) -
- this._dateAdapter.getFirstDayOfWeek()) %
- DAYS_PER_WEEK;
- this._initWeekdays();
- this._createWeekCells();
- this._changeDetectorRef.markForCheck();
- }
- /** Focuses the active cell after the microtask queue is empty. */
- _focusActiveCell(movePreview) {
- this._matCalendarBody._focusActiveCell(movePreview);
- }
- /** Focuses the active cell after change detection has run and the microtask queue is empty. */
- _focusActiveCellAfterViewChecked() {
- this._matCalendarBody._scheduleFocusActiveCellAfterViewChecked();
- }
- /** Called when the user has activated a new cell and the preview needs to be updated. */
- _previewChanged({ event, value: cell }) {
- if (this._rangeStrategy) {
- // We can assume that this will be a range, because preview
- // events aren't fired for single date selections.
- const value = cell ? cell.rawValue : null;
- const previewRange = this._rangeStrategy.createPreview(value, this.selected, event);
- this._previewStart = this._getCellCompareValue(previewRange.start);
- this._previewEnd = this._getCellCompareValue(previewRange.end);
- if (this.activeDrag && value) {
- const dragRange = this._rangeStrategy.createDrag?.(this.activeDrag.value, this.selected, value, event);
- if (dragRange) {
- this._previewStart = this._getCellCompareValue(dragRange.start);
- this._previewEnd = this._getCellCompareValue(dragRange.end);
- }
- }
- // Note that here we need to use `detectChanges`, rather than `markForCheck`, because
- // the way `_focusActiveCell` is set up at the moment makes it fire at the wrong time
- // when navigating one month back using the keyboard which will cause this handler
- // to throw a "changed after checked" error when updating the preview state.
- this._changeDetectorRef.detectChanges();
- }
- }
- /**
- * Called when the user has ended a drag. If the drag/drop was successful,
- * computes and emits the new range selection.
- */
- _dragEnded(event) {
- if (!this.activeDrag)
- return;
- if (event.value) {
- // Propagate drag effect
- const dragDropResult = this._rangeStrategy?.createDrag?.(this.activeDrag.value, this.selected, event.value, event.event);
- this.dragEnded.emit({ value: dragDropResult ?? null, event: event.event });
- }
- else {
- this.dragEnded.emit({ value: null, event: event.event });
- }
- }
- /**
- * Takes a day of the month and returns a new date in the same month and year as the currently
- * active date. The returned date will have the same day of the month as the argument date.
- */
- _getDateFromDayOfMonth(dayOfMonth) {
- return this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), this._dateAdapter.getMonth(this.activeDate), dayOfMonth);
- }
- /** Initializes the weekdays. */
- _initWeekdays() {
- const firstDayOfWeek = this._dateAdapter.getFirstDayOfWeek();
- const narrowWeekdays = this._dateAdapter.getDayOfWeekNames('narrow');
- const longWeekdays = this._dateAdapter.getDayOfWeekNames('long');
- // Rotate the labels for days of the week based on the configured first day of the week.
- let weekdays = longWeekdays.map((long, i) => {
- return { long, narrow: narrowWeekdays[i], id: uniqueIdCounter++ };
- });
- this._weekdays = weekdays.slice(firstDayOfWeek).concat(weekdays.slice(0, firstDayOfWeek));
- }
- /** Creates MatCalendarCells for the dates in this month. */
- _createWeekCells() {
- const daysInMonth = this._dateAdapter.getNumDaysInMonth(this.activeDate);
- const dateNames = this._dateAdapter.getDateNames();
- this._weeks = [[]];
- for (let i = 0, cell = this._firstWeekOffset; i < daysInMonth; i++, cell++) {
- if (cell == DAYS_PER_WEEK) {
- this._weeks.push([]);
- cell = 0;
- }
- const date = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), this._dateAdapter.getMonth(this.activeDate), i + 1);
- const enabled = this._shouldEnableDate(date);
- const ariaLabel = this._dateAdapter.format(date, this._dateFormats.display.dateA11yLabel);
- const cellClasses = this.dateClass ? this.dateClass(date, 'month') : undefined;
- this._weeks[this._weeks.length - 1].push(new MatCalendarCell(i + 1, dateNames[i], ariaLabel, enabled, cellClasses, this._getCellCompareValue(date), date));
- }
- }
- /** Date filter for the month */
- _shouldEnableDate(date) {
- return (!!date &&
- (!this.minDate || this._dateAdapter.compareDate(date, this.minDate) >= 0) &&
- (!this.maxDate || this._dateAdapter.compareDate(date, this.maxDate) <= 0) &&
- (!this.dateFilter || this.dateFilter(date)));
- }
- /**
- * Gets the date in this month that the given Date falls on.
- * Returns null if the given Date is in another month.
- */
- _getDateInCurrentMonth(date) {
- return date && this._hasSameMonthAndYear(date, this.activeDate)
- ? this._dateAdapter.getDate(date)
- : null;
- }
- /** Checks whether the 2 dates are non-null and fall within the same month of the same year. */
- _hasSameMonthAndYear(d1, d2) {
- return !!(d1 &&
- d2 &&
- this._dateAdapter.getMonth(d1) == this._dateAdapter.getMonth(d2) &&
- this._dateAdapter.getYear(d1) == this._dateAdapter.getYear(d2));
- }
- /** Gets the value that will be used to one cell to another. */
- _getCellCompareValue(date) {
- if (date) {
- // We use the time since the Unix epoch to compare dates in this view, rather than the
- // cell values, because we need to support ranges that span across multiple months/years.
- const year = this._dateAdapter.getYear(date);
- const month = this._dateAdapter.getMonth(date);
- const day = this._dateAdapter.getDate(date);
- return new Date(year, month, day).getTime();
- }
- return null;
- }
- /** Determines whether the user has the RTL layout direction. */
- _isRtl() {
- return this._dir && this._dir.value === 'rtl';
- }
- /** Sets the current range based on a model value. */
- _setRanges(selectedValue) {
- if (selectedValue instanceof DateRange) {
- this._rangeStart = this._getCellCompareValue(selectedValue.start);
- this._rangeEnd = this._getCellCompareValue(selectedValue.end);
- this._isRange = true;
- }
- else {
- this._rangeStart = this._rangeEnd = this._getCellCompareValue(selectedValue);
- this._isRange = false;
- }
- this._comparisonRangeStart = this._getCellCompareValue(this.comparisonStart);
- this._comparisonRangeEnd = this._getCellCompareValue(this.comparisonEnd);
- }
- /** Gets whether a date can be selected in the month view. */
- _canSelect(date) {
- return !this.dateFilter || this.dateFilter(date);
- }
- /** Clears out preview state. */
- _clearPreview() {
- this._previewStart = this._previewEnd = null;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatMonthView, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: MatMonthView, isStandalone: true, selector: "mat-month-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass", comparisonStart: "comparisonStart", comparisonEnd: "comparisonEnd", startDateAccessibleName: "startDateAccessibleName", endDateAccessibleName: "endDateAccessibleName", activeDrag: "activeDrag" }, outputs: { selectedChange: "selectedChange", _userSelection: "_userSelection", dragStarted: "dragStarted", dragEnded: "dragEnded", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "_matCalendarBody", first: true, predicate: MatCalendarBody, descendants: true }], exportAs: ["matMonthView"], usesOnChanges: true, ngImport: i0, template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead class=\"mat-calendar-table-header\">\n <tr>\n @for (day of _weekdays; track day.id) {\n <th scope=\"col\">\n <span class=\"cdk-visually-hidden\">{{day.long}}</span>\n <span aria-hidden=\"true\">{{day.narrow}}</span>\n </th>\n }\n </tr>\n <tr aria-hidden=\"true\"><th class=\"mat-calendar-table-header-divider\" colspan=\"7\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_monthLabel\"\n [rows]=\"_weeks\"\n [todayValue]=\"_todayDate!\"\n [startValue]=\"_rangeStart!\"\n [endValue]=\"_rangeEnd!\"\n [comparisonStart]=\"_comparisonRangeStart\"\n [comparisonEnd]=\"_comparisonRangeEnd\"\n [previewStart]=\"_previewStart\"\n [previewEnd]=\"_previewEnd\"\n [isRange]=\"_isRange\"\n [labelMinRequiredCells]=\"3\"\n [activeCell]=\"_dateAdapter.getDate(activeDate) - 1\"\n [startDateAccessibleName]=\"startDateAccessibleName\"\n [endDateAccessibleName]=\"endDateAccessibleName\"\n (selectedValueChange)=\"_dateSelected($event)\"\n (activeDateChange)=\"_updateActiveDate($event)\"\n (previewChange)=\"_previewChanged($event)\"\n (dragStarted)=\"dragStarted.emit($event)\"\n (dragEnded)=\"_dragEnded($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n", dependencies: [{ kind: "component", type: MatCalendarBody, selector: "[mat-calendar-body]", inputs: ["label", "rows", "todayValue", "startValue", "endValue", "labelMinRequiredCells", "numCols", "activeCell", "isRange", "cellAspectRatio", "comparisonStart", "comparisonEnd", "previewStart", "previewEnd", "startDateAccessibleName", "endDateAccessibleName"], outputs: ["selectedValueChange", "previewChange", "activeDateChange", "dragStarted", "dragEnded"], exportAs: ["matCalendarBody"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatMonthView, decorators: [{
- type: Component,
- args: [{ selector: 'mat-month-view', exportAs: 'matMonthView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatCalendarBody], template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead class=\"mat-calendar-table-header\">\n <tr>\n @for (day of _weekdays; track day.id) {\n <th scope=\"col\">\n <span class=\"cdk-visually-hidden\">{{day.long}}</span>\n <span aria-hidden=\"true\">{{day.narrow}}</span>\n </th>\n }\n </tr>\n <tr aria-hidden=\"true\"><th class=\"mat-calendar-table-header-divider\" colspan=\"7\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_monthLabel\"\n [rows]=\"_weeks\"\n [todayValue]=\"_todayDate!\"\n [startValue]=\"_rangeStart!\"\n [endValue]=\"_rangeEnd!\"\n [comparisonStart]=\"_comparisonRangeStart\"\n [comparisonEnd]=\"_comparisonRangeEnd\"\n [previewStart]=\"_previewStart\"\n [previewEnd]=\"_previewEnd\"\n [isRange]=\"_isRange\"\n [labelMinRequiredCells]=\"3\"\n [activeCell]=\"_dateAdapter.getDate(activeDate) - 1\"\n [startDateAccessibleName]=\"startDateAccessibleName\"\n [endDateAccessibleName]=\"endDateAccessibleName\"\n (selectedValueChange)=\"_dateSelected($event)\"\n (activeDateChange)=\"_updateActiveDate($event)\"\n (previewChange)=\"_previewChanged($event)\"\n (dragStarted)=\"dragStarted.emit($event)\"\n (dragEnded)=\"_dragEnded($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n" }]
- }], ctorParameters: () => [], propDecorators: { activeDate: [{
- type: Input
- }], selected: [{
- type: Input
- }], minDate: [{
- type: Input
- }], maxDate: [{
- type: Input
- }], dateFilter: [{
- type: Input
- }], dateClass: [{
- type: Input
- }], comparisonStart: [{
- type: Input
- }], comparisonEnd: [{
- type: Input
- }], startDateAccessibleName: [{
- type: Input
- }], endDateAccessibleName: [{
- type: Input
- }], activeDrag: [{
- type: Input
- }], selectedChange: [{
- type: Output
- }], _userSelection: [{
- type: Output
- }], dragStarted: [{
- type: Output
- }], dragEnded: [{
- type: Output
- }], activeDateChange: [{
- type: Output
- }], _matCalendarBody: [{
- type: ViewChild,
- args: [MatCalendarBody]
- }] } });
- const yearsPerPage = 24;
- const yearsPerRow = 4;
- /**
- * An internal component used to display a year selector in the datepicker.
- * @docs-private
- */
- class MatMultiYearView {
- _changeDetectorRef = inject(ChangeDetectorRef);
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dir = inject(Directionality, { optional: true });
- _rerenderSubscription = Subscription.EMPTY;
- /** Flag used to filter out space/enter keyup events that originated outside of the view. */
- _selectionKeyPressed;
- /** The date to display in this multi-year view (everything other than the year is ignored). */
- get activeDate() {
- return this._activeDate;
- }
- set activeDate(value) {
- let oldActiveDate = this._activeDate;
- const validDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)) ||
- this._dateAdapter.today();
- this._activeDate = this._dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
- if (!isSameMultiYearView(this._dateAdapter, oldActiveDate, this._activeDate, this.minDate, this.maxDate)) {
- this._init();
- }
- }
- _activeDate;
- /** The currently selected date. */
- get selected() {
- return this._selected;
- }
- set selected(value) {
- if (value instanceof DateRange) {
- this._selected = value;
- }
- else {
- this._selected = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- this._setSelectedYear(value);
- }
- _selected;
- /** The minimum selectable date. */
- get minDate() {
- return this._minDate;
- }
- set minDate(value) {
- this._minDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _minDate;
- /** The maximum selectable date. */
- get maxDate() {
- return this._maxDate;
- }
- set maxDate(value) {
- this._maxDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _maxDate;
- /** A function used to filter which dates are selectable. */
- dateFilter;
- /** Function that can be used to add custom CSS classes to date cells. */
- dateClass;
- /** Emits when a new year is selected. */
- selectedChange = new EventEmitter();
- /** Emits the selected year. This doesn't imply a change on the selected date */
- yearSelected = new EventEmitter();
- /** Emits when any date is activated. */
- activeDateChange = new EventEmitter();
- /** The body of calendar table */
- _matCalendarBody;
- /** Grid of calendar cells representing the currently displayed years. */
- _years;
- /** The year that today falls on. */
- _todayYear;
- /** The year of the selected date. Null if the selected date is null. */
- _selectedYear;
- constructor() {
- if (!this._dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw createMissingDateImplError('DateAdapter');
- }
- this._activeDate = this._dateAdapter.today();
- }
- ngAfterContentInit() {
- this._rerenderSubscription = this._dateAdapter.localeChanges
- .pipe(startWith(null))
- .subscribe(() => this._init());
- }
- ngOnDestroy() {
- this._rerenderSubscription.unsubscribe();
- }
- /** Initializes this multi-year view. */
- _init() {
- this._todayYear = this._dateAdapter.getYear(this._dateAdapter.today());
- // We want a range years such that we maximize the number of
- // enabled dates visible at once. This prevents issues where the minimum year
- // is the last item of a page OR the maximum year is the first item of a page.
- // The offset from the active year to the "slot" for the starting year is the
- // *actual* first rendered year in the multi-year view.
- const activeYear = this._dateAdapter.getYear(this._activeDate);
- const minYearOfPage = activeYear - getActiveOffset(this._dateAdapter, this.activeDate, this.minDate, this.maxDate);
- this._years = [];
- for (let i = 0, row = []; i < yearsPerPage; i++) {
- row.push(minYearOfPage + i);
- if (row.length == yearsPerRow) {
- this._years.push(row.map(year => this._createCellForYear(year)));
- row = [];
- }
- }
- this._changeDetectorRef.markForCheck();
- }
- /** Handles when a new year is selected. */
- _yearSelected(event) {
- const year = event.value;
- const selectedYear = this._dateAdapter.createDate(year, 0, 1);
- const selectedDate = this._getDateFromYear(year);
- this.yearSelected.emit(selectedYear);
- this.selectedChange.emit(selectedDate);
- }
- /**
- * Takes the index of a calendar body cell wrapped in an event as argument. For the date that
- * corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
- * that date.
- *
- * This function is used to match each component's model of the active date with the calendar
- * body cell that was focused. It updates its value of `activeDate` synchronously and updates the
- * parent's value asynchronously via the `activeDateChange` event. The child component receives an
- * updated value asynchronously via the `activeCell` Input.
- */
- _updateActiveDate(event) {
- const year = event.value;
- const oldActiveDate = this._activeDate;
- this.activeDate = this._getDateFromYear(year);
- if (this._dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
- this.activeDateChange.emit(this.activeDate);
- }
- }
- /** Handles keydown events on the calendar body when calendar is in multi-year view. */
- _handleCalendarBodyKeydown(event) {
- const oldActiveDate = this._activeDate;
- const isRtl = this._isRtl();
- switch (event.keyCode) {
- case LEFT_ARROW:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, isRtl ? 1 : -1);
- break;
- case RIGHT_ARROW:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, isRtl ? -1 : 1);
- break;
- case UP_ARROW:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, -yearsPerRow);
- break;
- case DOWN_ARROW:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, yearsPerRow);
- break;
- case HOME:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, -getActiveOffset(this._dateAdapter, this.activeDate, this.minDate, this.maxDate));
- break;
- case END:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, yearsPerPage -
- getActiveOffset(this._dateAdapter, this.activeDate, this.minDate, this.maxDate) -
- 1);
- break;
- case PAGE_UP:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, event.altKey ? -yearsPerPage * 10 : -yearsPerPage);
- break;
- case PAGE_DOWN:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, event.altKey ? yearsPerPage * 10 : yearsPerPage);
- break;
- case ENTER:
- case SPACE:
- // Note that we only prevent the default action here while the selection happens in
- // `keyup` below. We can't do the selection here, because it can cause the calendar to
- // reopen if focus is restored immediately. We also can't call `preventDefault` on `keyup`
- // because it's too late (see #23305).
- this._selectionKeyPressed = true;
- break;
- default:
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
- return;
- }
- if (this._dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
- this.activeDateChange.emit(this.activeDate);
- }
- this._focusActiveCellAfterViewChecked();
- // Prevent unexpected default actions such as form submission.
- event.preventDefault();
- }
- /** Handles keyup events on the calendar body when calendar is in multi-year view. */
- _handleCalendarBodyKeyup(event) {
- if (event.keyCode === SPACE || event.keyCode === ENTER) {
- if (this._selectionKeyPressed) {
- this._yearSelected({ value: this._dateAdapter.getYear(this._activeDate), event });
- }
- this._selectionKeyPressed = false;
- }
- }
- _getActiveCell() {
- return getActiveOffset(this._dateAdapter, this.activeDate, this.minDate, this.maxDate);
- }
- /** Focuses the active cell after the microtask queue is empty. */
- _focusActiveCell() {
- this._matCalendarBody._focusActiveCell();
- }
- /** Focuses the active cell after change detection has run and the microtask queue is empty. */
- _focusActiveCellAfterViewChecked() {
- this._matCalendarBody._scheduleFocusActiveCellAfterViewChecked();
- }
- /**
- * Takes a year and returns a new date on the same day and month as the currently active date
- * The returned date will have the same year as the argument date.
- */
- _getDateFromYear(year) {
- const activeMonth = this._dateAdapter.getMonth(this.activeDate);
- const daysInMonth = this._dateAdapter.getNumDaysInMonth(this._dateAdapter.createDate(year, activeMonth, 1));
- const normalizedDate = this._dateAdapter.createDate(year, activeMonth, Math.min(this._dateAdapter.getDate(this.activeDate), daysInMonth));
- return normalizedDate;
- }
- /** Creates an MatCalendarCell for the given year. */
- _createCellForYear(year) {
- const date = this._dateAdapter.createDate(year, 0, 1);
- const yearName = this._dateAdapter.getYearName(date);
- const cellClasses = this.dateClass ? this.dateClass(date, 'multi-year') : undefined;
- return new MatCalendarCell(year, yearName, yearName, this._shouldEnableYear(year), cellClasses);
- }
- /** Whether the given year is enabled. */
- _shouldEnableYear(year) {
- // disable if the year is greater than maxDate lower than minDate
- if (year === undefined ||
- year === null ||
- (this.maxDate && year > this._dateAdapter.getYear(this.maxDate)) ||
- (this.minDate && year < this._dateAdapter.getYear(this.minDate))) {
- return false;
- }
- // enable if it reaches here and there's no filter defined
- if (!this.dateFilter) {
- return true;
- }
- const firstOfYear = this._dateAdapter.createDate(year, 0, 1);
- // If any date in the year is enabled count the year as enabled.
- for (let date = firstOfYear; this._dateAdapter.getYear(date) == year; date = this._dateAdapter.addCalendarDays(date, 1)) {
- if (this.dateFilter(date)) {
- return true;
- }
- }
- return false;
- }
- /** Determines whether the user has the RTL layout direction. */
- _isRtl() {
- return this._dir && this._dir.value === 'rtl';
- }
- /** Sets the currently-highlighted year based on a model value. */
- _setSelectedYear(value) {
- this._selectedYear = null;
- if (value instanceof DateRange) {
- const displayValue = value.start || value.end;
- if (displayValue) {
- this._selectedYear = this._dateAdapter.getYear(displayValue);
- }
- }
- else if (value) {
- this._selectedYear = this._dateAdapter.getYear(value);
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatMultiYearView, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatMultiYearView, isStandalone: true, selector: "mat-multi-year-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass" }, outputs: { selectedChange: "selectedChange", yearSelected: "yearSelected", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "_matCalendarBody", first: true, predicate: MatCalendarBody, descendants: true }], exportAs: ["matMultiYearView"], ngImport: i0, template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [rows]=\"_years\"\n [todayValue]=\"_todayYear\"\n [startValue]=\"_selectedYear!\"\n [endValue]=\"_selectedYear!\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_getActiveCell()\"\n (selectedValueChange)=\"_yearSelected($event)\"\n (activeDateChange)=\"_updateActiveDate($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n", dependencies: [{ kind: "component", type: MatCalendarBody, selector: "[mat-calendar-body]", inputs: ["label", "rows", "todayValue", "startValue", "endValue", "labelMinRequiredCells", "numCols", "activeCell", "isRange", "cellAspectRatio", "comparisonStart", "comparisonEnd", "previewStart", "previewEnd", "startDateAccessibleName", "endDateAccessibleName"], outputs: ["selectedValueChange", "previewChange", "activeDateChange", "dragStarted", "dragEnded"], exportAs: ["matCalendarBody"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatMultiYearView, decorators: [{
- type: Component,
- args: [{ selector: 'mat-multi-year-view', exportAs: 'matMultiYearView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatCalendarBody], template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [rows]=\"_years\"\n [todayValue]=\"_todayYear\"\n [startValue]=\"_selectedYear!\"\n [endValue]=\"_selectedYear!\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_getActiveCell()\"\n (selectedValueChange)=\"_yearSelected($event)\"\n (activeDateChange)=\"_updateActiveDate($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n" }]
- }], ctorParameters: () => [], propDecorators: { activeDate: [{
- type: Input
- }], selected: [{
- type: Input
- }], minDate: [{
- type: Input
- }], maxDate: [{
- type: Input
- }], dateFilter: [{
- type: Input
- }], dateClass: [{
- type: Input
- }], selectedChange: [{
- type: Output
- }], yearSelected: [{
- type: Output
- }], activeDateChange: [{
- type: Output
- }], _matCalendarBody: [{
- type: ViewChild,
- args: [MatCalendarBody]
- }] } });
- function isSameMultiYearView(dateAdapter, date1, date2, minDate, maxDate) {
- const year1 = dateAdapter.getYear(date1);
- const year2 = dateAdapter.getYear(date2);
- const startingYear = getStartingYear(dateAdapter, minDate, maxDate);
- return (Math.floor((year1 - startingYear) / yearsPerPage) ===
- Math.floor((year2 - startingYear) / yearsPerPage));
- }
- /**
- * When the multi-year view is first opened, the active year will be in view.
- * So we compute how many years are between the active year and the *slot* where our
- * "startingYear" will render when paged into view.
- */
- function getActiveOffset(dateAdapter, activeDate, minDate, maxDate) {
- const activeYear = dateAdapter.getYear(activeDate);
- return euclideanModulo(activeYear - getStartingYear(dateAdapter, minDate, maxDate), yearsPerPage);
- }
- /**
- * We pick a "starting" year such that either the maximum year would be at the end
- * or the minimum year would be at the beginning of a page.
- */
- function getStartingYear(dateAdapter, minDate, maxDate) {
- let startingYear = 0;
- if (maxDate) {
- const maxYear = dateAdapter.getYear(maxDate);
- startingYear = maxYear - yearsPerPage + 1;
- }
- else if (minDate) {
- startingYear = dateAdapter.getYear(minDate);
- }
- return startingYear;
- }
- /** Gets remainder that is non-negative, even if first number is negative */
- function euclideanModulo(a, b) {
- return ((a % b) + b) % b;
- }
- /**
- * An internal component used to display a single year in the datepicker.
- * @docs-private
- */
- class MatYearView {
- _changeDetectorRef = inject(ChangeDetectorRef);
- _dateFormats = inject(MAT_DATE_FORMATS, { optional: true });
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dir = inject(Directionality, { optional: true });
- _rerenderSubscription = Subscription.EMPTY;
- /** Flag used to filter out space/enter keyup events that originated outside of the view. */
- _selectionKeyPressed;
- /** The date to display in this year view (everything other than the year is ignored). */
- get activeDate() {
- return this._activeDate;
- }
- set activeDate(value) {
- let oldActiveDate = this._activeDate;
- const validDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value)) ||
- this._dateAdapter.today();
- this._activeDate = this._dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
- if (this._dateAdapter.getYear(oldActiveDate) !== this._dateAdapter.getYear(this._activeDate)) {
- this._init();
- }
- }
- _activeDate;
- /** The currently selected date. */
- get selected() {
- return this._selected;
- }
- set selected(value) {
- if (value instanceof DateRange) {
- this._selected = value;
- }
- else {
- this._selected = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- this._setSelectedMonth(value);
- }
- _selected;
- /** The minimum selectable date. */
- get minDate() {
- return this._minDate;
- }
- set minDate(value) {
- this._minDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _minDate;
- /** The maximum selectable date. */
- get maxDate() {
- return this._maxDate;
- }
- set maxDate(value) {
- this._maxDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _maxDate;
- /** A function used to filter which dates are selectable. */
- dateFilter;
- /** Function that can be used to add custom CSS classes to date cells. */
- dateClass;
- /** Emits when a new month is selected. */
- selectedChange = new EventEmitter();
- /** Emits the selected month. This doesn't imply a change on the selected date */
- monthSelected = new EventEmitter();
- /** Emits when any date is activated. */
- activeDateChange = new EventEmitter();
- /** The body of calendar table */
- _matCalendarBody;
- /** Grid of calendar cells representing the months of the year. */
- _months;
- /** The label for this year (e.g. "2017"). */
- _yearLabel;
- /** The month in this year that today falls on. Null if today is in a different year. */
- _todayMonth;
- /**
- * The month in this year that the selected Date falls on.
- * Null if the selected Date is in a different year.
- */
- _selectedMonth;
- constructor() {
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
- if (!this._dateAdapter) {
- throw createMissingDateImplError('DateAdapter');
- }
- if (!this._dateFormats) {
- throw createMissingDateImplError('MAT_DATE_FORMATS');
- }
- }
- this._activeDate = this._dateAdapter.today();
- }
- ngAfterContentInit() {
- this._rerenderSubscription = this._dateAdapter.localeChanges
- .pipe(startWith(null))
- .subscribe(() => this._init());
- }
- ngOnDestroy() {
- this._rerenderSubscription.unsubscribe();
- }
- /** Handles when a new month is selected. */
- _monthSelected(event) {
- const month = event.value;
- const selectedMonth = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, 1);
- this.monthSelected.emit(selectedMonth);
- const selectedDate = this._getDateFromMonth(month);
- this.selectedChange.emit(selectedDate);
- }
- /**
- * Takes the index of a calendar body cell wrapped in an event as argument. For the date that
- * corresponds to the given cell, set `activeDate` to that date and fire `activeDateChange` with
- * that date.
- *
- * This function is used to match each component's model of the active date with the calendar
- * body cell that was focused. It updates its value of `activeDate` synchronously and updates the
- * parent's value asynchronously via the `activeDateChange` event. The child component receives an
- * updated value asynchronously via the `activeCell` Input.
- */
- _updateActiveDate(event) {
- const month = event.value;
- const oldActiveDate = this._activeDate;
- this.activeDate = this._getDateFromMonth(month);
- if (this._dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
- this.activeDateChange.emit(this.activeDate);
- }
- }
- /** Handles keydown events on the calendar body when calendar is in year view. */
- _handleCalendarBodyKeydown(event) {
- // TODO(mmalerba): We currently allow keyboard navigation to disabled dates, but just prevent
- // disabled ones from being selected. This may not be ideal, we should look into whether
- // navigation should skip over disabled dates, and if so, how to implement that efficiently.
- const oldActiveDate = this._activeDate;
- const isRtl = this._isRtl();
- switch (event.keyCode) {
- case LEFT_ARROW:
- this.activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, isRtl ? 1 : -1);
- break;
- case RIGHT_ARROW:
- this.activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, isRtl ? -1 : 1);
- break;
- case UP_ARROW:
- this.activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, -4);
- break;
- case DOWN_ARROW:
- this.activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, 4);
- break;
- case HOME:
- this.activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, -this._dateAdapter.getMonth(this._activeDate));
- break;
- case END:
- this.activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, 11 - this._dateAdapter.getMonth(this._activeDate));
- break;
- case PAGE_UP:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, event.altKey ? -10 : -1);
- break;
- case PAGE_DOWN:
- this.activeDate = this._dateAdapter.addCalendarYears(this._activeDate, event.altKey ? 10 : 1);
- break;
- case ENTER:
- case SPACE:
- // Note that we only prevent the default action here while the selection happens in
- // `keyup` below. We can't do the selection here, because it can cause the calendar to
- // reopen if focus is restored immediately. We also can't call `preventDefault` on `keyup`
- // because it's too late (see #23305).
- this._selectionKeyPressed = true;
- break;
- default:
- // Don't prevent default or focus active cell on keys that we don't explicitly handle.
- return;
- }
- if (this._dateAdapter.compareDate(oldActiveDate, this.activeDate)) {
- this.activeDateChange.emit(this.activeDate);
- this._focusActiveCellAfterViewChecked();
- }
- // Prevent unexpected default actions such as form submission.
- event.preventDefault();
- }
- /** Handles keyup events on the calendar body when calendar is in year view. */
- _handleCalendarBodyKeyup(event) {
- if (event.keyCode === SPACE || event.keyCode === ENTER) {
- if (this._selectionKeyPressed) {
- this._monthSelected({ value: this._dateAdapter.getMonth(this._activeDate), event });
- }
- this._selectionKeyPressed = false;
- }
- }
- /** Initializes this year view. */
- _init() {
- this._setSelectedMonth(this.selected);
- this._todayMonth = this._getMonthInCurrentYear(this._dateAdapter.today());
- this._yearLabel = this._dateAdapter.getYearName(this.activeDate);
- let monthNames = this._dateAdapter.getMonthNames('short');
- // First row of months only contains 5 elements so we can fit the year label on the same row.
- this._months = [
- [0, 1, 2, 3],
- [4, 5, 6, 7],
- [8, 9, 10, 11],
- ].map(row => row.map(month => this._createCellForMonth(month, monthNames[month])));
- this._changeDetectorRef.markForCheck();
- }
- /** Focuses the active cell after the microtask queue is empty. */
- _focusActiveCell() {
- this._matCalendarBody._focusActiveCell();
- }
- /** Schedules the matCalendarBody to focus the active cell after change detection has run */
- _focusActiveCellAfterViewChecked() {
- this._matCalendarBody._scheduleFocusActiveCellAfterViewChecked();
- }
- /**
- * Gets the month in this year that the given Date falls on.
- * Returns null if the given Date is in another year.
- */
- _getMonthInCurrentYear(date) {
- return date && this._dateAdapter.getYear(date) == this._dateAdapter.getYear(this.activeDate)
- ? this._dateAdapter.getMonth(date)
- : null;
- }
- /**
- * Takes a month and returns a new date in the same day and year as the currently active date.
- * The returned date will have the same month as the argument date.
- */
- _getDateFromMonth(month) {
- const normalizedDate = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, 1);
- const daysInMonth = this._dateAdapter.getNumDaysInMonth(normalizedDate);
- return this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, Math.min(this._dateAdapter.getDate(this.activeDate), daysInMonth));
- }
- /** Creates an MatCalendarCell for the given month. */
- _createCellForMonth(month, monthName) {
- const date = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, 1);
- const ariaLabel = this._dateAdapter.format(date, this._dateFormats.display.monthYearA11yLabel);
- const cellClasses = this.dateClass ? this.dateClass(date, 'year') : undefined;
- return new MatCalendarCell(month, monthName.toLocaleUpperCase(), ariaLabel, this._shouldEnableMonth(month), cellClasses);
- }
- /** Whether the given month is enabled. */
- _shouldEnableMonth(month) {
- const activeYear = this._dateAdapter.getYear(this.activeDate);
- if (month === undefined ||
- month === null ||
- this._isYearAndMonthAfterMaxDate(activeYear, month) ||
- this._isYearAndMonthBeforeMinDate(activeYear, month)) {
- return false;
- }
- if (!this.dateFilter) {
- return true;
- }
- const firstOfMonth = this._dateAdapter.createDate(activeYear, month, 1);
- // If any date in the month is enabled count the month as enabled.
- for (let date = firstOfMonth; this._dateAdapter.getMonth(date) == month; date = this._dateAdapter.addCalendarDays(date, 1)) {
- if (this.dateFilter(date)) {
- return true;
- }
- }
- return false;
- }
- /**
- * Tests whether the combination month/year is after this.maxDate, considering
- * just the month and year of this.maxDate
- */
- _isYearAndMonthAfterMaxDate(year, month) {
- if (this.maxDate) {
- const maxYear = this._dateAdapter.getYear(this.maxDate);
- const maxMonth = this._dateAdapter.getMonth(this.maxDate);
- return year > maxYear || (year === maxYear && month > maxMonth);
- }
- return false;
- }
- /**
- * Tests whether the combination month/year is before this.minDate, considering
- * just the month and year of this.minDate
- */
- _isYearAndMonthBeforeMinDate(year, month) {
- if (this.minDate) {
- const minYear = this._dateAdapter.getYear(this.minDate);
- const minMonth = this._dateAdapter.getMonth(this.minDate);
- return year < minYear || (year === minYear && month < minMonth);
- }
- return false;
- }
- /** Determines whether the user has the RTL layout direction. */
- _isRtl() {
- return this._dir && this._dir.value === 'rtl';
- }
- /** Sets the currently-selected month based on a model value. */
- _setSelectedMonth(value) {
- if (value instanceof DateRange) {
- this._selectedMonth =
- this._getMonthInCurrentYear(value.start) || this._getMonthInCurrentYear(value.end);
- }
- else {
- this._selectedMonth = this._getMonthInCurrentYear(value);
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatYearView, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatYearView, isStandalone: true, selector: "mat-year-view", inputs: { activeDate: "activeDate", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass" }, outputs: { selectedChange: "selectedChange", monthSelected: "monthSelected", activeDateChange: "activeDateChange" }, viewQueries: [{ propertyName: "_matCalendarBody", first: true, predicate: MatCalendarBody, descendants: true }], exportAs: ["matYearView"], ngImport: i0, template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_yearLabel\"\n [rows]=\"_months\"\n [todayValue]=\"_todayMonth!\"\n [startValue]=\"_selectedMonth!\"\n [endValue]=\"_selectedMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_dateAdapter.getMonth(activeDate)\"\n (selectedValueChange)=\"_monthSelected($event)\"\n (activeDateChange)=\"_updateActiveDate($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n", dependencies: [{ kind: "component", type: MatCalendarBody, selector: "[mat-calendar-body]", inputs: ["label", "rows", "todayValue", "startValue", "endValue", "labelMinRequiredCells", "numCols", "activeCell", "isRange", "cellAspectRatio", "comparisonStart", "comparisonEnd", "previewStart", "previewEnd", "startDateAccessibleName", "endDateAccessibleName"], outputs: ["selectedValueChange", "previewChange", "activeDateChange", "dragStarted", "dragEnded"], exportAs: ["matCalendarBody"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatYearView, decorators: [{
- type: Component,
- args: [{ selector: 'mat-year-view', exportAs: 'matYearView', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatCalendarBody], template: "<table class=\"mat-calendar-table\" role=\"grid\">\n <thead aria-hidden=\"true\" class=\"mat-calendar-table-header\">\n <tr><th class=\"mat-calendar-table-header-divider\" colspan=\"4\"></th></tr>\n </thead>\n <tbody mat-calendar-body\n [label]=\"_yearLabel\"\n [rows]=\"_months\"\n [todayValue]=\"_todayMonth!\"\n [startValue]=\"_selectedMonth!\"\n [endValue]=\"_selectedMonth!\"\n [labelMinRequiredCells]=\"2\"\n [numCols]=\"4\"\n [cellAspectRatio]=\"4 / 7\"\n [activeCell]=\"_dateAdapter.getMonth(activeDate)\"\n (selectedValueChange)=\"_monthSelected($event)\"\n (activeDateChange)=\"_updateActiveDate($event)\"\n (keyup)=\"_handleCalendarBodyKeyup($event)\"\n (keydown)=\"_handleCalendarBodyKeydown($event)\">\n </tbody>\n</table>\n" }]
- }], ctorParameters: () => [], propDecorators: { activeDate: [{
- type: Input
- }], selected: [{
- type: Input
- }], minDate: [{
- type: Input
- }], maxDate: [{
- type: Input
- }], dateFilter: [{
- type: Input
- }], dateClass: [{
- type: Input
- }], selectedChange: [{
- type: Output
- }], monthSelected: [{
- type: Output
- }], activeDateChange: [{
- type: Output
- }], _matCalendarBody: [{
- type: ViewChild,
- args: [MatCalendarBody]
- }] } });
- /** Default header for MatCalendar */
- class MatCalendarHeader {
- _intl = inject(MatDatepickerIntl);
- calendar = inject(MatCalendar);
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dateFormats = inject(MAT_DATE_FORMATS, { optional: true });
- constructor() {
- inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
- const changeDetectorRef = inject(ChangeDetectorRef);
- this.calendar.stateChanges.subscribe(() => changeDetectorRef.markForCheck());
- }
- /** The display text for the current calendar view. */
- get periodButtonText() {
- if (this.calendar.currentView == 'month') {
- return this._dateAdapter
- .format(this.calendar.activeDate, this._dateFormats.display.monthYearLabel)
- .toLocaleUpperCase();
- }
- if (this.calendar.currentView == 'year') {
- return this._dateAdapter.getYearName(this.calendar.activeDate);
- }
- return this._intl.formatYearRange(...this._formatMinAndMaxYearLabels());
- }
- /** The aria description for the current calendar view. */
- get periodButtonDescription() {
- if (this.calendar.currentView == 'month') {
- return this._dateAdapter
- .format(this.calendar.activeDate, this._dateFormats.display.monthYearLabel)
- .toLocaleUpperCase();
- }
- if (this.calendar.currentView == 'year') {
- return this._dateAdapter.getYearName(this.calendar.activeDate);
- }
- // Format a label for the window of years displayed in the multi-year calendar view. Use
- // `formatYearRangeLabel` because it is TTS friendly.
- return this._intl.formatYearRangeLabel(...this._formatMinAndMaxYearLabels());
- }
- /** The `aria-label` for changing the calendar view. */
- get periodButtonLabel() {
- return this.calendar.currentView == 'month'
- ? this._intl.switchToMultiYearViewLabel
- : this._intl.switchToMonthViewLabel;
- }
- /** The label for the previous button. */
- get prevButtonLabel() {
- return {
- 'month': this._intl.prevMonthLabel,
- 'year': this._intl.prevYearLabel,
- 'multi-year': this._intl.prevMultiYearLabel,
- }[this.calendar.currentView];
- }
- /** The label for the next button. */
- get nextButtonLabel() {
- return {
- 'month': this._intl.nextMonthLabel,
- 'year': this._intl.nextYearLabel,
- 'multi-year': this._intl.nextMultiYearLabel,
- }[this.calendar.currentView];
- }
- /** Handles user clicks on the period label. */
- currentPeriodClicked() {
- this.calendar.currentView = this.calendar.currentView == 'month' ? 'multi-year' : 'month';
- }
- /** Handles user clicks on the previous button. */
- previousClicked() {
- this.calendar.activeDate =
- this.calendar.currentView == 'month'
- ? this._dateAdapter.addCalendarMonths(this.calendar.activeDate, -1)
- : this._dateAdapter.addCalendarYears(this.calendar.activeDate, this.calendar.currentView == 'year' ? -1 : -yearsPerPage);
- }
- /** Handles user clicks on the next button. */
- nextClicked() {
- this.calendar.activeDate =
- this.calendar.currentView == 'month'
- ? this._dateAdapter.addCalendarMonths(this.calendar.activeDate, 1)
- : this._dateAdapter.addCalendarYears(this.calendar.activeDate, this.calendar.currentView == 'year' ? 1 : yearsPerPage);
- }
- /** Whether the previous period button is enabled. */
- previousEnabled() {
- if (!this.calendar.minDate) {
- return true;
- }
- return (!this.calendar.minDate || !this._isSameView(this.calendar.activeDate, this.calendar.minDate));
- }
- /** Whether the next period button is enabled. */
- nextEnabled() {
- return (!this.calendar.maxDate || !this._isSameView(this.calendar.activeDate, this.calendar.maxDate));
- }
- /** Whether the two dates represent the same view in the current view mode (month or year). */
- _isSameView(date1, date2) {
- if (this.calendar.currentView == 'month') {
- return (this._dateAdapter.getYear(date1) == this._dateAdapter.getYear(date2) &&
- this._dateAdapter.getMonth(date1) == this._dateAdapter.getMonth(date2));
- }
- if (this.calendar.currentView == 'year') {
- return this._dateAdapter.getYear(date1) == this._dateAdapter.getYear(date2);
- }
- // Otherwise we are in 'multi-year' view.
- return isSameMultiYearView(this._dateAdapter, date1, date2, this.calendar.minDate, this.calendar.maxDate);
- }
- /**
- * Format two individual labels for the minimum year and maximum year available in the multi-year
- * calendar view. Returns an array of two strings where the first string is the formatted label
- * for the minimum year, and the second string is the formatted label for the maximum year.
- */
- _formatMinAndMaxYearLabels() {
- // The offset from the active year to the "slot" for the starting year is the
- // *actual* first rendered year in the multi-year view, and the last year is
- // just yearsPerPage - 1 away.
- const activeYear = this._dateAdapter.getYear(this.calendar.activeDate);
- const minYearOfPage = activeYear -
- getActiveOffset(this._dateAdapter, this.calendar.activeDate, this.calendar.minDate, this.calendar.maxDate);
- const maxYearOfPage = minYearOfPage + yearsPerPage - 1;
- const minYearLabel = this._dateAdapter.getYearName(this._dateAdapter.createDate(minYearOfPage, 0, 1));
- const maxYearLabel = this._dateAdapter.getYearName(this._dateAdapter.createDate(maxYearOfPage, 0, 1));
- return [minYearLabel, maxYearLabel];
- }
- _periodButtonLabelId = inject(_IdGenerator).getId('mat-calendar-period-label-');
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCalendarHeader, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatCalendarHeader, isStandalone: true, selector: "mat-calendar-header", exportAs: ["matCalendarHeader"], ngImport: i0, template: "<div class=\"mat-calendar-header\">\n <div class=\"mat-calendar-controls\">\n <!-- [Firefox Issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1880533]\n Relocated label next to related button and made visually hidden via cdk-visually-hidden\n to enable label to appear in a11y tree for SR when using Firefox -->\n <span [id]=\"_periodButtonLabelId\" class=\"cdk-visually-hidden\" aria-live=\"polite\">{{periodButtonDescription}}</span>\n <button mat-button type=\"button\" class=\"mat-calendar-period-button\"\n (click)=\"currentPeriodClicked()\" [attr.aria-label]=\"periodButtonLabel\"\n [attr.aria-describedby]=\"_periodButtonLabelId\">\n <span aria-hidden=\"true\">{{periodButtonText}}</span>\n <svg class=\"mat-calendar-arrow\" [class.mat-calendar-invert]=\"calendar.currentView !== 'month'\"\n viewBox=\"0 0 10 5\" focusable=\"false\" aria-hidden=\"true\">\n <polygon points=\"0,0 5,5 10,0\"/>\n </svg>\n </button>\n\n <div class=\"mat-calendar-spacer\"></div>\n\n <ng-content></ng-content>\n\n <button mat-icon-button type=\"button\" class=\"mat-calendar-previous-button\"\n [disabled]=\"!previousEnabled()\" (click)=\"previousClicked()\"\n [attr.aria-label]=\"prevButtonLabel\">\n <svg viewBox=\"0 0 24 24\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z\"/>\n </svg>\n </button>\n\n <button mat-icon-button type=\"button\" class=\"mat-calendar-next-button\"\n [disabled]=\"!nextEnabled()\" (click)=\"nextClicked()\"\n [attr.aria-label]=\"nextButtonLabel\">\n <svg viewBox=\"0 0 24 24\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\"/>\n </svg>\n </button>\n </div>\n</div>\n", dependencies: [{ kind: "component", type: MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCalendarHeader, decorators: [{
- type: Component,
- args: [{ selector: 'mat-calendar-header', exportAs: 'matCalendarHeader', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatButton, MatIconButton], template: "<div class=\"mat-calendar-header\">\n <div class=\"mat-calendar-controls\">\n <!-- [Firefox Issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1880533]\n Relocated label next to related button and made visually hidden via cdk-visually-hidden\n to enable label to appear in a11y tree for SR when using Firefox -->\n <span [id]=\"_periodButtonLabelId\" class=\"cdk-visually-hidden\" aria-live=\"polite\">{{periodButtonDescription}}</span>\n <button mat-button type=\"button\" class=\"mat-calendar-period-button\"\n (click)=\"currentPeriodClicked()\" [attr.aria-label]=\"periodButtonLabel\"\n [attr.aria-describedby]=\"_periodButtonLabelId\">\n <span aria-hidden=\"true\">{{periodButtonText}}</span>\n <svg class=\"mat-calendar-arrow\" [class.mat-calendar-invert]=\"calendar.currentView !== 'month'\"\n viewBox=\"0 0 10 5\" focusable=\"false\" aria-hidden=\"true\">\n <polygon points=\"0,0 5,5 10,0\"/>\n </svg>\n </button>\n\n <div class=\"mat-calendar-spacer\"></div>\n\n <ng-content></ng-content>\n\n <button mat-icon-button type=\"button\" class=\"mat-calendar-previous-button\"\n [disabled]=\"!previousEnabled()\" (click)=\"previousClicked()\"\n [attr.aria-label]=\"prevButtonLabel\">\n <svg viewBox=\"0 0 24 24\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z\"/>\n </svg>\n </button>\n\n <button mat-icon-button type=\"button\" class=\"mat-calendar-next-button\"\n [disabled]=\"!nextEnabled()\" (click)=\"nextClicked()\"\n [attr.aria-label]=\"nextButtonLabel\">\n <svg viewBox=\"0 0 24 24\" focusable=\"false\" aria-hidden=\"true\">\n <path d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\"/>\n </svg>\n </button>\n </div>\n</div>\n" }]
- }], ctorParameters: () => [] });
- /** A calendar that is used as part of the datepicker. */
- class MatCalendar {
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dateFormats = inject(MAT_DATE_FORMATS, { optional: true });
- _changeDetectorRef = inject(ChangeDetectorRef);
- _elementRef = inject(ElementRef);
- /** An input indicating the type of the header component, if set. */
- headerComponent;
- /** A portal containing the header component type for this calendar. */
- _calendarHeaderPortal;
- _intlChanges;
- /**
- * Used for scheduling that focus should be moved to the active cell on the next tick.
- * We need to schedule it, rather than do it immediately, because we have to wait
- * for Angular to re-evaluate the view children.
- */
- _moveFocusOnNextTick = false;
- /** A date representing the period (month or year) to start the calendar in. */
- get startAt() {
- return this._startAt;
- }
- set startAt(value) {
- this._startAt = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _startAt;
- /** Whether the calendar should be started in month or year view. */
- startView = 'month';
- /** The currently selected date. */
- get selected() {
- return this._selected;
- }
- set selected(value) {
- if (value instanceof DateRange) {
- this._selected = value;
- }
- else {
- this._selected = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- }
- _selected;
- /** The minimum selectable date. */
- get minDate() {
- return this._minDate;
- }
- set minDate(value) {
- this._minDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _minDate;
- /** The maximum selectable date. */
- get maxDate() {
- return this._maxDate;
- }
- set maxDate(value) {
- this._maxDate = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _maxDate;
- /** Function used to filter which dates are selectable. */
- dateFilter;
- /** Function that can be used to add custom CSS classes to dates. */
- dateClass;
- /** Start of the comparison range. */
- comparisonStart;
- /** End of the comparison range. */
- comparisonEnd;
- /** ARIA Accessible name of the `<input matStartDate/>` */
- startDateAccessibleName;
- /** ARIA Accessible name of the `<input matEndDate/>` */
- endDateAccessibleName;
- /** Emits when the currently selected date changes. */
- selectedChange = new EventEmitter();
- /**
- * Emits the year chosen in multiyear view.
- * This doesn't imply a change on the selected date.
- */
- yearSelected = new EventEmitter();
- /**
- * Emits the month chosen in year view.
- * This doesn't imply a change on the selected date.
- */
- monthSelected = new EventEmitter();
- /**
- * Emits when the current view changes.
- */
- viewChanged = new EventEmitter(true);
- /** Emits when any date is selected. */
- _userSelection = new EventEmitter();
- /** Emits a new date range value when the user completes a drag drop operation. */
- _userDragDrop = new EventEmitter();
- /** Reference to the current month view component. */
- monthView;
- /** Reference to the current year view component. */
- yearView;
- /** Reference to the current multi-year view component. */
- multiYearView;
- /**
- * The current active date. This determines which time period is shown and which date is
- * highlighted when using keyboard navigation.
- */
- get activeDate() {
- return this._clampedActiveDate;
- }
- set activeDate(value) {
- this._clampedActiveDate = this._dateAdapter.clampDate(value, this.minDate, this.maxDate);
- this.stateChanges.next();
- this._changeDetectorRef.markForCheck();
- }
- _clampedActiveDate;
- /** Whether the calendar is in month view. */
- get currentView() {
- return this._currentView;
- }
- set currentView(value) {
- const viewChangedResult = this._currentView !== value ? value : null;
- this._currentView = value;
- this._moveFocusOnNextTick = true;
- this._changeDetectorRef.markForCheck();
- if (viewChangedResult) {
- this.viewChanged.emit(viewChangedResult);
- }
- }
- _currentView;
- /** Origin of active drag, or null when dragging is not active. */
- _activeDrag = null;
- /**
- * Emits whenever there is a state change that the header may need to respond to.
- */
- stateChanges = new Subject();
- constructor() {
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
- if (!this._dateAdapter) {
- throw createMissingDateImplError('DateAdapter');
- }
- if (!this._dateFormats) {
- throw createMissingDateImplError('MAT_DATE_FORMATS');
- }
- }
- this._intlChanges = inject(MatDatepickerIntl).changes.subscribe(() => {
- this._changeDetectorRef.markForCheck();
- this.stateChanges.next();
- });
- }
- ngAfterContentInit() {
- this._calendarHeaderPortal = new ComponentPortal(this.headerComponent || MatCalendarHeader);
- this.activeDate = this.startAt || this._dateAdapter.today();
- // Assign to the private property since we don't want to move focus on init.
- this._currentView = this.startView;
- }
- ngAfterViewChecked() {
- if (this._moveFocusOnNextTick) {
- this._moveFocusOnNextTick = false;
- this.focusActiveCell();
- }
- }
- ngOnDestroy() {
- this._intlChanges.unsubscribe();
- this.stateChanges.complete();
- }
- ngOnChanges(changes) {
- // Ignore date changes that are at a different time on the same day. This fixes issues where
- // the calendar re-renders when there is no meaningful change to [minDate] or [maxDate]
- // (#24435).
- const minDateChange = changes['minDate'] &&
- !this._dateAdapter.sameDate(changes['minDate'].previousValue, changes['minDate'].currentValue)
- ? changes['minDate']
- : undefined;
- const maxDateChange = changes['maxDate'] &&
- !this._dateAdapter.sameDate(changes['maxDate'].previousValue, changes['maxDate'].currentValue)
- ? changes['maxDate']
- : undefined;
- const changeRequiringRerender = minDateChange || maxDateChange || changes['dateFilter'];
- if (changeRequiringRerender && !changeRequiringRerender.firstChange) {
- const view = this._getCurrentViewComponent();
- if (view) {
- // Schedule focus to be moved to the active date since re-rendering can blur the active
- // cell (see #29265), however don't do so if focus is outside of the calendar, because it
- // can steal away the user's attention (see #30635).
- if (this._elementRef.nativeElement.contains(_getFocusedElementPierceShadowDom())) {
- this._moveFocusOnNextTick = true;
- }
- // We need to `detectChanges` manually here, because the `minDate`, `maxDate` etc. are
- // passed down to the view via data bindings which won't be up-to-date when we call `_init`.
- this._changeDetectorRef.detectChanges();
- view._init();
- }
- }
- this.stateChanges.next();
- }
- /** Focuses the active date. */
- focusActiveCell() {
- this._getCurrentViewComponent()._focusActiveCell(false);
- }
- /** Updates today's date after an update of the active date */
- updateTodaysDate() {
- this._getCurrentViewComponent()._init();
- }
- /** Handles date selection in the month view. */
- _dateSelected(event) {
- const date = event.value;
- if (this.selected instanceof DateRange ||
- (date && !this._dateAdapter.sameDate(date, this.selected))) {
- this.selectedChange.emit(date);
- }
- this._userSelection.emit(event);
- }
- /** Handles year selection in the multiyear view. */
- _yearSelectedInMultiYearView(normalizedYear) {
- this.yearSelected.emit(normalizedYear);
- }
- /** Handles month selection in the year view. */
- _monthSelectedInYearView(normalizedMonth) {
- this.monthSelected.emit(normalizedMonth);
- }
- /** Handles year/month selection in the multi-year/year views. */
- _goToDateInView(date, view) {
- this.activeDate = date;
- this.currentView = view;
- }
- /** Called when the user starts dragging to change a date range. */
- _dragStarted(event) {
- this._activeDrag = event;
- }
- /**
- * Called when a drag completes. It may end in cancelation or in the selection
- * of a new range.
- */
- _dragEnded(event) {
- if (!this._activeDrag)
- return;
- if (event.value) {
- this._userDragDrop.emit(event);
- }
- this._activeDrag = null;
- }
- /** Returns the component instance that corresponds to the current calendar view. */
- _getCurrentViewComponent() {
- // The return type is explicitly written as a union to ensure that the Closure compiler does
- // not optimize calls to _init(). Without the explicit return type, TypeScript narrows it to
- // only the first component type. See https://github.com/angular/components/issues/22996.
- return this.monthView || this.yearView || this.multiYearView;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCalendar, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: MatCalendar, isStandalone: true, selector: "mat-calendar", inputs: { headerComponent: "headerComponent", startAt: "startAt", startView: "startView", selected: "selected", minDate: "minDate", maxDate: "maxDate", dateFilter: "dateFilter", dateClass: "dateClass", comparisonStart: "comparisonStart", comparisonEnd: "comparisonEnd", startDateAccessibleName: "startDateAccessibleName", endDateAccessibleName: "endDateAccessibleName" }, outputs: { selectedChange: "selectedChange", yearSelected: "yearSelected", monthSelected: "monthSelected", viewChanged: "viewChanged", _userSelection: "_userSelection", _userDragDrop: "_userDragDrop" }, host: { classAttribute: "mat-calendar" }, providers: [MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER], viewQueries: [{ propertyName: "monthView", first: true, predicate: MatMonthView, descendants: true }, { propertyName: "yearView", first: true, predicate: MatYearView, descendants: true }, { propertyName: "multiYearView", first: true, predicate: MatMultiYearView, descendants: true }], exportAs: ["matCalendar"], usesOnChanges: true, ngImport: i0, template: "<ng-template [cdkPortalOutlet]=\"_calendarHeaderPortal\"></ng-template>\n\n<div class=\"mat-calendar-content\" cdkMonitorSubtreeFocus tabindex=\"-1\">\n @switch (currentView) {\n @case ('month') {\n <mat-month-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n [comparisonStart]=\"comparisonStart\"\n [comparisonEnd]=\"comparisonEnd\"\n [startDateAccessibleName]=\"startDateAccessibleName\"\n [endDateAccessibleName]=\"endDateAccessibleName\"\n (_userSelection)=\"_dateSelected($event)\"\n (dragStarted)=\"_dragStarted($event)\"\n (dragEnded)=\"_dragEnded($event)\"\n [activeDrag]=\"_activeDrag\"></mat-month-view>\n }\n\n @case ('year') {\n <mat-year-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n (monthSelected)=\"_monthSelectedInYearView($event)\"\n (selectedChange)=\"_goToDateInView($event, 'month')\"></mat-year-view>\n }\n\n @case ('multi-year') {\n <mat-multi-year-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n (yearSelected)=\"_yearSelectedInMultiYearView($event)\"\n (selectedChange)=\"_goToDateInView($event, 'year')\"></mat-multi-year-view>\n }\n }\n</div>\n", styles: [".mat-calendar{display:block;line-height:normal;font-family:var(--mat-datepicker-calendar-text-font, var(--mat-sys-body-medium-font));font-size:var(--mat-datepicker-calendar-text-size, var(--mat-sys-body-medium-size))}.mat-calendar-header{padding:8px 8px 0 8px}.mat-calendar-content{padding:0 8px 8px 8px;outline:none}.mat-calendar-controls{display:flex;align-items:center;margin:5% calc(4.7142857143% - 16px)}.mat-calendar-spacer{flex:1 1 auto}.mat-calendar-period-button{min-width:0;margin:0 8px;font-size:var(--mat-datepicker-calendar-period-button-text-size, var(--mat-sys-title-small-size));font-weight:var(--mat-datepicker-calendar-period-button-text-weight, var(--mat-sys-title-small-weight));--mdc-text-button-label-text-color:var(--mat-datepicker-calendar-period-button-text-color, var(--mat-sys-on-surface-variant))}.mat-calendar-arrow{display:inline-block;width:10px;height:5px;margin:0 0 0 5px;vertical-align:middle;fill:var(--mat-datepicker-calendar-period-button-icon-color, var(--mat-sys-on-surface-variant))}.mat-calendar-arrow.mat-calendar-invert{transform:rotate(180deg)}[dir=rtl] .mat-calendar-arrow{margin:0 5px 0 0}@media(forced-colors: active){.mat-calendar-arrow{fill:CanvasText}}.mat-datepicker-content .mat-calendar-previous-button:not(.mat-mdc-button-disabled),.mat-datepicker-content .mat-calendar-next-button:not(.mat-mdc-button-disabled){color:var(--mat-datepicker-calendar-navigation-button-icon-color, var(--mat-sys-on-surface-variant))}[dir=rtl] .mat-calendar-previous-button,[dir=rtl] .mat-calendar-next-button{transform:rotate(180deg)}.mat-calendar-table{border-spacing:0;border-collapse:collapse;width:100%}.mat-calendar-table-header th{text-align:center;padding:0 0 8px 0;color:var(--mat-datepicker-calendar-header-text-color, var(--mat-sys-on-surface-variant));font-size:var(--mat-datepicker-calendar-header-text-size, var(--mat-sys-title-small-size));font-weight:var(--mat-datepicker-calendar-header-text-weight, var(--mat-sys-title-small-weight))}.mat-calendar-table-header-divider{position:relative;height:1px}.mat-calendar-table-header-divider::after{content:\"\";position:absolute;top:0;left:-8px;right:-8px;height:1px;background:var(--mat-datepicker-calendar-header-divider-color, transparent)}.mat-calendar-body-cell-content::before{margin:calc(calc(var(--mat-focus-indicator-border-width, 3px) + 3px)*-1)}.mat-calendar-body-cell:focus .mat-focus-indicator::before{content:\"\"}\n"], dependencies: [{ kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "directive", type: CdkMonitorFocus, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: ["cdkFocusChange"], exportAs: ["cdkMonitorFocus"] }, { kind: "component", type: MatMonthView, selector: "mat-month-view", inputs: ["activeDate", "selected", "minDate", "maxDate", "dateFilter", "dateClass", "comparisonStart", "comparisonEnd", "startDateAccessibleName", "endDateAccessibleName", "activeDrag"], outputs: ["selectedChange", "_userSelection", "dragStarted", "dragEnded", "activeDateChange"], exportAs: ["matMonthView"] }, { kind: "component", type: MatYearView, selector: "mat-year-view", inputs: ["activeDate", "selected", "minDate", "maxDate", "dateFilter", "dateClass"], outputs: ["selectedChange", "monthSelected", "activeDateChange"], exportAs: ["matYearView"] }, { kind: "component", type: MatMultiYearView, selector: "mat-multi-year-view", inputs: ["activeDate", "selected", "minDate", "maxDate", "dateFilter", "dateClass"], outputs: ["selectedChange", "yearSelected", "activeDateChange"], exportAs: ["matMultiYearView"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatCalendar, decorators: [{
- type: Component,
- args: [{ selector: 'mat-calendar', host: {
- 'class': 'mat-calendar',
- }, exportAs: 'matCalendar', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER], imports: [CdkPortalOutlet, CdkMonitorFocus, MatMonthView, MatYearView, MatMultiYearView], template: "<ng-template [cdkPortalOutlet]=\"_calendarHeaderPortal\"></ng-template>\n\n<div class=\"mat-calendar-content\" cdkMonitorSubtreeFocus tabindex=\"-1\">\n @switch (currentView) {\n @case ('month') {\n <mat-month-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n [comparisonStart]=\"comparisonStart\"\n [comparisonEnd]=\"comparisonEnd\"\n [startDateAccessibleName]=\"startDateAccessibleName\"\n [endDateAccessibleName]=\"endDateAccessibleName\"\n (_userSelection)=\"_dateSelected($event)\"\n (dragStarted)=\"_dragStarted($event)\"\n (dragEnded)=\"_dragEnded($event)\"\n [activeDrag]=\"_activeDrag\"></mat-month-view>\n }\n\n @case ('year') {\n <mat-year-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n (monthSelected)=\"_monthSelectedInYearView($event)\"\n (selectedChange)=\"_goToDateInView($event, 'month')\"></mat-year-view>\n }\n\n @case ('multi-year') {\n <mat-multi-year-view\n [(activeDate)]=\"activeDate\"\n [selected]=\"selected\"\n [dateFilter]=\"dateFilter\"\n [maxDate]=\"maxDate\"\n [minDate]=\"minDate\"\n [dateClass]=\"dateClass\"\n (yearSelected)=\"_yearSelectedInMultiYearView($event)\"\n (selectedChange)=\"_goToDateInView($event, 'year')\"></mat-multi-year-view>\n }\n }\n</div>\n", styles: [".mat-calendar{display:block;line-height:normal;font-family:var(--mat-datepicker-calendar-text-font, var(--mat-sys-body-medium-font));font-size:var(--mat-datepicker-calendar-text-size, var(--mat-sys-body-medium-size))}.mat-calendar-header{padding:8px 8px 0 8px}.mat-calendar-content{padding:0 8px 8px 8px;outline:none}.mat-calendar-controls{display:flex;align-items:center;margin:5% calc(4.7142857143% - 16px)}.mat-calendar-spacer{flex:1 1 auto}.mat-calendar-period-button{min-width:0;margin:0 8px;font-size:var(--mat-datepicker-calendar-period-button-text-size, var(--mat-sys-title-small-size));font-weight:var(--mat-datepicker-calendar-period-button-text-weight, var(--mat-sys-title-small-weight));--mdc-text-button-label-text-color:var(--mat-datepicker-calendar-period-button-text-color, var(--mat-sys-on-surface-variant))}.mat-calendar-arrow{display:inline-block;width:10px;height:5px;margin:0 0 0 5px;vertical-align:middle;fill:var(--mat-datepicker-calendar-period-button-icon-color, var(--mat-sys-on-surface-variant))}.mat-calendar-arrow.mat-calendar-invert{transform:rotate(180deg)}[dir=rtl] .mat-calendar-arrow{margin:0 5px 0 0}@media(forced-colors: active){.mat-calendar-arrow{fill:CanvasText}}.mat-datepicker-content .mat-calendar-previous-button:not(.mat-mdc-button-disabled),.mat-datepicker-content .mat-calendar-next-button:not(.mat-mdc-button-disabled){color:var(--mat-datepicker-calendar-navigation-button-icon-color, var(--mat-sys-on-surface-variant))}[dir=rtl] .mat-calendar-previous-button,[dir=rtl] .mat-calendar-next-button{transform:rotate(180deg)}.mat-calendar-table{border-spacing:0;border-collapse:collapse;width:100%}.mat-calendar-table-header th{text-align:center;padding:0 0 8px 0;color:var(--mat-datepicker-calendar-header-text-color, var(--mat-sys-on-surface-variant));font-size:var(--mat-datepicker-calendar-header-text-size, var(--mat-sys-title-small-size));font-weight:var(--mat-datepicker-calendar-header-text-weight, var(--mat-sys-title-small-weight))}.mat-calendar-table-header-divider{position:relative;height:1px}.mat-calendar-table-header-divider::after{content:\"\";position:absolute;top:0;left:-8px;right:-8px;height:1px;background:var(--mat-datepicker-calendar-header-divider-color, transparent)}.mat-calendar-body-cell-content::before{margin:calc(calc(var(--mat-focus-indicator-border-width, 3px) + 3px)*-1)}.mat-calendar-body-cell:focus .mat-focus-indicator::before{content:\"\"}\n"] }]
- }], ctorParameters: () => [], propDecorators: { headerComponent: [{
- type: Input
- }], startAt: [{
- type: Input
- }], startView: [{
- type: Input
- }], selected: [{
- type: Input
- }], minDate: [{
- type: Input
- }], maxDate: [{
- type: Input
- }], dateFilter: [{
- type: Input
- }], dateClass: [{
- type: Input
- }], comparisonStart: [{
- type: Input
- }], comparisonEnd: [{
- type: Input
- }], startDateAccessibleName: [{
- type: Input
- }], endDateAccessibleName: [{
- type: Input
- }], selectedChange: [{
- type: Output
- }], yearSelected: [{
- type: Output
- }], monthSelected: [{
- type: Output
- }], viewChanged: [{
- type: Output
- }], _userSelection: [{
- type: Output
- }], _userDragDrop: [{
- type: Output
- }], monthView: [{
- type: ViewChild,
- args: [MatMonthView]
- }], yearView: [{
- type: ViewChild,
- args: [MatYearView]
- }], multiYearView: [{
- type: ViewChild,
- args: [MatMultiYearView]
- }] } });
- /** Injection token that determines the scroll handling while the calendar is open. */
- const MAT_DATEPICKER_SCROLL_STRATEGY = new InjectionToken('mat-datepicker-scroll-strategy', {
- providedIn: 'root',
- factory: () => {
- const overlay = inject(Overlay);
- return () => overlay.scrollStrategies.reposition();
- },
- });
- /**
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- function MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY(overlay) {
- return () => overlay.scrollStrategies.reposition();
- }
- /**
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- const MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER = {
- provide: MAT_DATEPICKER_SCROLL_STRATEGY,
- deps: [Overlay],
- useFactory: MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY,
- };
- /**
- * Component used as the content for the datepicker overlay. We use this instead of using
- * MatCalendar directly as the content so we can control the initial focus. This also gives us a
- * place to put additional features of the overlay that are not part of the calendar itself in the
- * future. (e.g. confirmation buttons).
- * @docs-private
- */
- class MatDatepickerContent {
- _elementRef = inject(ElementRef);
- _animationsDisabled = inject(ANIMATION_MODULE_TYPE, { optional: true }) === 'NoopAnimations';
- _changeDetectorRef = inject(ChangeDetectorRef);
- _globalModel = inject(MatDateSelectionModel);
- _dateAdapter = inject(DateAdapter);
- _ngZone = inject(NgZone);
- _rangeSelectionStrategy = inject(MAT_DATE_RANGE_SELECTION_STRATEGY, { optional: true });
- _stateChanges;
- _model;
- _eventCleanups;
- _animationFallback;
- /** Reference to the internal calendar component. */
- _calendar;
- /**
- * Theme color of the internal calendar. This API is supported in M2 themes
- * only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/datepicker/styling.
- *
- * For information on applying color variants in M3, see
- * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants
- */
- color;
- /** Reference to the datepicker that created the overlay. */
- datepicker;
- /** Start of the comparison range. */
- comparisonStart;
- /** End of the comparison range. */
- comparisonEnd;
- /** ARIA Accessible name of the `<input matStartDate/>` */
- startDateAccessibleName;
- /** ARIA Accessible name of the `<input matEndDate/>` */
- endDateAccessibleName;
- /** Whether the datepicker is above or below the input. */
- _isAbove;
- /** Emits when an animation has finished. */
- _animationDone = new Subject();
- /** Whether there is an in-progress animation. */
- _isAnimating = false;
- /** Text for the close button. */
- _closeButtonText;
- /** Whether the close button currently has focus. */
- _closeButtonFocused;
- /** Portal with projected action buttons. */
- _actionsPortal = null;
- /** Id of the label for the `role="dialog"` element. */
- _dialogLabelId;
- constructor() {
- inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
- this._closeButtonText = inject(MatDatepickerIntl).closeCalendarLabel;
- if (!this._animationsDisabled) {
- const element = this._elementRef.nativeElement;
- const renderer = inject(Renderer2);
- this._eventCleanups = this._ngZone.runOutsideAngular(() => [
- renderer.listen(element, 'animationstart', this._handleAnimationEvent),
- renderer.listen(element, 'animationend', this._handleAnimationEvent),
- renderer.listen(element, 'animationcancel', this._handleAnimationEvent),
- ]);
- }
- }
- ngAfterViewInit() {
- this._stateChanges = this.datepicker.stateChanges.subscribe(() => {
- this._changeDetectorRef.markForCheck();
- });
- this._calendar.focusActiveCell();
- }
- ngOnDestroy() {
- clearTimeout(this._animationFallback);
- this._eventCleanups?.forEach(cleanup => cleanup());
- this._stateChanges?.unsubscribe();
- this._animationDone.complete();
- }
- _handleUserSelection(event) {
- const selection = this._model.selection;
- const value = event.value;
- const isRange = selection instanceof DateRange;
- // If we're selecting a range and we have a selection strategy, always pass the value through
- // there. Otherwise don't assign null values to the model, unless we're selecting a range.
- // A null value when picking a range means that the user cancelled the selection (e.g. by
- // pressing escape), whereas when selecting a single value it means that the value didn't
- // change. This isn't very intuitive, but it's here for backwards-compatibility.
- if (isRange && this._rangeSelectionStrategy) {
- const newSelection = this._rangeSelectionStrategy.selectionFinished(value, selection, event.event);
- this._model.updateSelection(newSelection, this);
- }
- else if (value &&
- (isRange || !this._dateAdapter.sameDate(value, selection))) {
- this._model.add(value);
- }
- // Delegate closing the overlay to the actions.
- if ((!this._model || this._model.isComplete()) && !this._actionsPortal) {
- this.datepicker.close();
- }
- }
- _handleUserDragDrop(event) {
- this._model.updateSelection(event.value, this);
- }
- _startExitAnimation() {
- this._elementRef.nativeElement.classList.add('mat-datepicker-content-exit');
- if (this._animationsDisabled) {
- this._animationDone.next();
- }
- else {
- // Some internal apps disable animations in tests using `* {animation: none !important}`.
- // If that happens, the animation events won't fire and we'll never clean up the overlay.
- // Add a fallback that will fire if the animation doesn't run in a certain amount of time.
- clearTimeout(this._animationFallback);
- this._animationFallback = setTimeout(() => {
- if (!this._isAnimating) {
- this._animationDone.next();
- }
- }, 200);
- }
- }
- _handleAnimationEvent = (event) => {
- const element = this._elementRef.nativeElement;
- if (event.target !== element || !event.animationName.startsWith('_mat-datepicker-content')) {
- return;
- }
- clearTimeout(this._animationFallback);
- this._isAnimating = event.type === 'animationstart';
- element.classList.toggle('mat-datepicker-content-animating', this._isAnimating);
- if (!this._isAnimating) {
- this._animationDone.next();
- }
- };
- _getSelected() {
- return this._model.selection;
- }
- /** Applies the current pending selection to the global model. */
- _applyPendingSelection() {
- if (this._model !== this._globalModel) {
- this._globalModel.updateSelection(this._model.selection, this);
- }
- }
- /**
- * Assigns a new portal containing the datepicker actions.
- * @param portal Portal with the actions to be assigned.
- * @param forceRerender Whether a re-render of the portal should be triggered. This isn't
- * necessary if the portal is assigned during initialization, but it may be required if it's
- * added at a later point.
- */
- _assignActions(portal, forceRerender) {
- // If we have actions, clone the model so that we have the ability to cancel the selection,
- // otherwise update the global model directly. Note that we want to assign this as soon as
- // possible, but `_actionsPortal` isn't available in the constructor so we do it in `ngOnInit`.
- this._model = portal ? this._globalModel.clone() : this._globalModel;
- this._actionsPortal = portal;
- if (forceRerender) {
- this._changeDetectorRef.detectChanges();
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerContent, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepickerContent, isStandalone: true, selector: "mat-datepicker-content", inputs: { color: "color" }, host: { properties: { "class": "color ? \"mat-\" + color : \"\"", "class.mat-datepicker-content-touch": "datepicker.touchUi", "class.mat-datepicker-content-animations-enabled": "!_animationsDisabled" }, classAttribute: "mat-datepicker-content" }, viewQueries: [{ propertyName: "_calendar", first: true, predicate: MatCalendar, descendants: true }], exportAs: ["matDatepickerContent"], ngImport: i0, template: "<div\n cdkTrapFocus\n role=\"dialog\"\n [attr.aria-modal]=\"true\"\n [attr.aria-labelledby]=\"_dialogLabelId ?? undefined\"\n class=\"mat-datepicker-content-container\"\n [class.mat-datepicker-content-container-with-custom-header]=\"datepicker.calendarHeaderComponent\"\n [class.mat-datepicker-content-container-with-actions]=\"_actionsPortal\">\n <mat-calendar\n [id]=\"datepicker.id\"\n [class]=\"datepicker.panelClass\"\n [startAt]=\"datepicker.startAt\"\n [startView]=\"datepicker.startView\"\n [minDate]=\"datepicker._getMinDate()\"\n [maxDate]=\"datepicker._getMaxDate()\"\n [dateFilter]=\"datepicker._getDateFilter()\"\n [headerComponent]=\"datepicker.calendarHeaderComponent\"\n [selected]=\"_getSelected()\"\n [dateClass]=\"datepicker.dateClass\"\n [comparisonStart]=\"comparisonStart\"\n [comparisonEnd]=\"comparisonEnd\"\n [startDateAccessibleName]=\"startDateAccessibleName\"\n [endDateAccessibleName]=\"endDateAccessibleName\"\n (yearSelected)=\"datepicker._selectYear($event)\"\n (monthSelected)=\"datepicker._selectMonth($event)\"\n (viewChanged)=\"datepicker._viewChanged($event)\"\n (_userSelection)=\"_handleUserSelection($event)\"\n (_userDragDrop)=\"_handleUserDragDrop($event)\"></mat-calendar>\n\n <ng-template [cdkPortalOutlet]=\"_actionsPortal\"></ng-template>\n\n <!-- Invisible close button for screen reader users. -->\n <button\n type=\"button\"\n mat-raised-button\n [color]=\"color || 'primary'\"\n class=\"mat-datepicker-close-button\"\n [class.cdk-visually-hidden]=\"!_closeButtonFocused\"\n (focus)=\"_closeButtonFocused = true\"\n (blur)=\"_closeButtonFocused = false\"\n (click)=\"datepicker.close()\">{{ _closeButtonText }}</button>\n</div>\n", styles: ["@keyframes _mat-datepicker-content-dropdown-enter{from{opacity:0;transform:scaleY(0.8)}to{opacity:1;transform:none}}@keyframes _mat-datepicker-content-dialog-enter{from{opacity:0;transform:scale(0.8)}to{opacity:1;transform:none}}@keyframes _mat-datepicker-content-exit{from{opacity:1}to{opacity:0}}.mat-datepicker-content{display:block;border-radius:4px;background-color:var(--mat-datepicker-calendar-container-background-color, var(--mat-sys-surface-container-high));color:var(--mat-datepicker-calendar-container-text-color, var(--mat-sys-on-surface));box-shadow:var(--mat-datepicker-calendar-container-elevation-shadow, 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12));border-radius:var(--mat-datepicker-calendar-container-shape, var(--mat-sys-corner-large))}.mat-datepicker-content.mat-datepicker-content-animations-enabled{animation:_mat-datepicker-content-dropdown-enter 120ms cubic-bezier(0, 0, 0.2, 1)}.mat-datepicker-content .mat-calendar{width:296px;height:354px}.mat-datepicker-content .mat-datepicker-content-container-with-custom-header .mat-calendar{height:auto}.mat-datepicker-content .mat-datepicker-close-button{position:absolute;top:100%;left:0;margin-top:8px}.mat-datepicker-content-animating .mat-datepicker-content .mat-datepicker-close-button{display:none}.mat-datepicker-content-container{display:flex;flex-direction:column;justify-content:space-between}.mat-datepicker-content-touch{display:block;max-height:80vh;box-shadow:var(--mat-datepicker-calendar-container-touch-elevation-shadow, 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12));border-radius:var(--mat-datepicker-calendar-container-touch-shape, var(--mat-sys-corner-extra-large));position:relative;overflow:visible}.mat-datepicker-content-touch.mat-datepicker-content-animations-enabled{animation:_mat-datepicker-content-dialog-enter 150ms cubic-bezier(0, 0, 0.2, 1)}.mat-datepicker-content-touch .mat-datepicker-content-container{min-height:312px;max-height:788px;min-width:250px;max-width:750px}.mat-datepicker-content-touch .mat-calendar{width:100%;height:auto}.mat-datepicker-content-exit.mat-datepicker-content-animations-enabled{animation:_mat-datepicker-content-exit 100ms linear}@media all and (orientation: landscape){.mat-datepicker-content-touch .mat-datepicker-content-container{width:64vh;height:80vh}}@media all and (orientation: portrait){.mat-datepicker-content-touch .mat-datepicker-content-container{width:80vw;height:100vw}.mat-datepicker-content-touch .mat-datepicker-content-container-with-actions{height:115vw}}\n"], dependencies: [{ kind: "directive", type: CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "component", type: MatCalendar, selector: "mat-calendar", inputs: ["headerComponent", "startAt", "startView", "selected", "minDate", "maxDate", "dateFilter", "dateClass", "comparisonStart", "comparisonEnd", "startDateAccessibleName", "endDateAccessibleName"], outputs: ["selectedChange", "yearSelected", "monthSelected", "viewChanged", "_userSelection", "_userDragDrop"], exportAs: ["matCalendar"] }, { kind: "directive", type: CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "component", type: MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerContent, decorators: [{
- type: Component,
- args: [{ selector: 'mat-datepicker-content', host: {
- 'class': 'mat-datepicker-content',
- '[class]': 'color ? "mat-" + color : ""',
- '[class.mat-datepicker-content-touch]': 'datepicker.touchUi',
- '[class.mat-datepicker-content-animations-enabled]': '!_animationsDisabled',
- }, exportAs: 'matDatepickerContent', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [CdkTrapFocus, MatCalendar, CdkPortalOutlet, MatButton], template: "<div\n cdkTrapFocus\n role=\"dialog\"\n [attr.aria-modal]=\"true\"\n [attr.aria-labelledby]=\"_dialogLabelId ?? undefined\"\n class=\"mat-datepicker-content-container\"\n [class.mat-datepicker-content-container-with-custom-header]=\"datepicker.calendarHeaderComponent\"\n [class.mat-datepicker-content-container-with-actions]=\"_actionsPortal\">\n <mat-calendar\n [id]=\"datepicker.id\"\n [class]=\"datepicker.panelClass\"\n [startAt]=\"datepicker.startAt\"\n [startView]=\"datepicker.startView\"\n [minDate]=\"datepicker._getMinDate()\"\n [maxDate]=\"datepicker._getMaxDate()\"\n [dateFilter]=\"datepicker._getDateFilter()\"\n [headerComponent]=\"datepicker.calendarHeaderComponent\"\n [selected]=\"_getSelected()\"\n [dateClass]=\"datepicker.dateClass\"\n [comparisonStart]=\"comparisonStart\"\n [comparisonEnd]=\"comparisonEnd\"\n [startDateAccessibleName]=\"startDateAccessibleName\"\n [endDateAccessibleName]=\"endDateAccessibleName\"\n (yearSelected)=\"datepicker._selectYear($event)\"\n (monthSelected)=\"datepicker._selectMonth($event)\"\n (viewChanged)=\"datepicker._viewChanged($event)\"\n (_userSelection)=\"_handleUserSelection($event)\"\n (_userDragDrop)=\"_handleUserDragDrop($event)\"></mat-calendar>\n\n <ng-template [cdkPortalOutlet]=\"_actionsPortal\"></ng-template>\n\n <!-- Invisible close button for screen reader users. -->\n <button\n type=\"button\"\n mat-raised-button\n [color]=\"color || 'primary'\"\n class=\"mat-datepicker-close-button\"\n [class.cdk-visually-hidden]=\"!_closeButtonFocused\"\n (focus)=\"_closeButtonFocused = true\"\n (blur)=\"_closeButtonFocused = false\"\n (click)=\"datepicker.close()\">{{ _closeButtonText }}</button>\n</div>\n", styles: ["@keyframes _mat-datepicker-content-dropdown-enter{from{opacity:0;transform:scaleY(0.8)}to{opacity:1;transform:none}}@keyframes _mat-datepicker-content-dialog-enter{from{opacity:0;transform:scale(0.8)}to{opacity:1;transform:none}}@keyframes _mat-datepicker-content-exit{from{opacity:1}to{opacity:0}}.mat-datepicker-content{display:block;border-radius:4px;background-color:var(--mat-datepicker-calendar-container-background-color, var(--mat-sys-surface-container-high));color:var(--mat-datepicker-calendar-container-text-color, var(--mat-sys-on-surface));box-shadow:var(--mat-datepicker-calendar-container-elevation-shadow, 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12));border-radius:var(--mat-datepicker-calendar-container-shape, var(--mat-sys-corner-large))}.mat-datepicker-content.mat-datepicker-content-animations-enabled{animation:_mat-datepicker-content-dropdown-enter 120ms cubic-bezier(0, 0, 0.2, 1)}.mat-datepicker-content .mat-calendar{width:296px;height:354px}.mat-datepicker-content .mat-datepicker-content-container-with-custom-header .mat-calendar{height:auto}.mat-datepicker-content .mat-datepicker-close-button{position:absolute;top:100%;left:0;margin-top:8px}.mat-datepicker-content-animating .mat-datepicker-content .mat-datepicker-close-button{display:none}.mat-datepicker-content-container{display:flex;flex-direction:column;justify-content:space-between}.mat-datepicker-content-touch{display:block;max-height:80vh;box-shadow:var(--mat-datepicker-calendar-container-touch-elevation-shadow, 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12));border-radius:var(--mat-datepicker-calendar-container-touch-shape, var(--mat-sys-corner-extra-large));position:relative;overflow:visible}.mat-datepicker-content-touch.mat-datepicker-content-animations-enabled{animation:_mat-datepicker-content-dialog-enter 150ms cubic-bezier(0, 0, 0.2, 1)}.mat-datepicker-content-touch .mat-datepicker-content-container{min-height:312px;max-height:788px;min-width:250px;max-width:750px}.mat-datepicker-content-touch .mat-calendar{width:100%;height:auto}.mat-datepicker-content-exit.mat-datepicker-content-animations-enabled{animation:_mat-datepicker-content-exit 100ms linear}@media all and (orientation: landscape){.mat-datepicker-content-touch .mat-datepicker-content-container{width:64vh;height:80vh}}@media all and (orientation: portrait){.mat-datepicker-content-touch .mat-datepicker-content-container{width:80vw;height:100vw}.mat-datepicker-content-touch .mat-datepicker-content-container-with-actions{height:115vw}}\n"] }]
- }], ctorParameters: () => [], propDecorators: { _calendar: [{
- type: ViewChild,
- args: [MatCalendar]
- }], color: [{
- type: Input
- }] } });
- /** Base class for a datepicker. */
- class MatDatepickerBase {
- _overlay = inject(Overlay);
- _viewContainerRef = inject(ViewContainerRef);
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dir = inject(Directionality, { optional: true });
- _model = inject(MatDateSelectionModel);
- _scrollStrategy = inject(MAT_DATEPICKER_SCROLL_STRATEGY);
- _inputStateChanges = Subscription.EMPTY;
- _document = inject(DOCUMENT);
- /** An input indicating the type of the custom header component for the calendar, if set. */
- calendarHeaderComponent;
- /** The date to open the calendar to initially. */
- get startAt() {
- // If an explicit startAt is set we start there, otherwise we start at whatever the currently
- // selected value is.
- return this._startAt || (this.datepickerInput ? this.datepickerInput.getStartValue() : null);
- }
- set startAt(value) {
- this._startAt = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- }
- _startAt;
- /** The view that the calendar should start in. */
- startView = 'month';
- /**
- * Theme color of the datepicker's calendar. This API is supported in M2 themes only, it
- * has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/datepicker/styling.
- *
- * For information on applying color variants in M3, see
- * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants
- */
- get color() {
- return (this._color || (this.datepickerInput ? this.datepickerInput.getThemePalette() : undefined));
- }
- set color(value) {
- this._color = value;
- }
- _color;
- /**
- * Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather
- * than a dropdown and elements have more padding to allow for bigger touch targets.
- */
- touchUi = false;
- /** Whether the datepicker pop-up should be disabled. */
- get disabled() {
- return this._disabled === undefined && this.datepickerInput
- ? this.datepickerInput.disabled
- : !!this._disabled;
- }
- set disabled(value) {
- if (value !== this._disabled) {
- this._disabled = value;
- this.stateChanges.next(undefined);
- }
- }
- _disabled;
- /** Preferred position of the datepicker in the X axis. */
- xPosition = 'start';
- /** Preferred position of the datepicker in the Y axis. */
- yPosition = 'below';
- /**
- * Whether to restore focus to the previously-focused element when the calendar is closed.
- * Note that automatic focus restoration is an accessibility feature and it is recommended that
- * you provide your own equivalent, if you decide to turn it off.
- */
- restoreFocus = true;
- /**
- * Emits selected year in multiyear view.
- * This doesn't imply a change on the selected date.
- */
- yearSelected = new EventEmitter();
- /**
- * Emits selected month in year view.
- * This doesn't imply a change on the selected date.
- */
- monthSelected = new EventEmitter();
- /**
- * Emits when the current view changes.
- */
- viewChanged = new EventEmitter(true);
- /** Function that can be used to add custom CSS classes to dates. */
- dateClass;
- /** Emits when the datepicker has been opened. */
- openedStream = new EventEmitter();
- /** Emits when the datepicker has been closed. */
- closedStream = new EventEmitter();
- /** Classes to be passed to the date picker panel. */
- get panelClass() {
- return this._panelClass;
- }
- set panelClass(value) {
- this._panelClass = coerceStringArray(value);
- }
- _panelClass;
- /** Whether the calendar is open. */
- get opened() {
- return this._opened;
- }
- set opened(value) {
- if (value) {
- this.open();
- }
- else {
- this.close();
- }
- }
- _opened = false;
- /** The id for the datepicker calendar. */
- id = inject(_IdGenerator).getId('mat-datepicker-');
- /** The minimum selectable date. */
- _getMinDate() {
- return this.datepickerInput && this.datepickerInput.min;
- }
- /** The maximum selectable date. */
- _getMaxDate() {
- return this.datepickerInput && this.datepickerInput.max;
- }
- _getDateFilter() {
- return this.datepickerInput && this.datepickerInput.dateFilter;
- }
- /** A reference to the overlay into which we've rendered the calendar. */
- _overlayRef;
- /** Reference to the component instance rendered in the overlay. */
- _componentRef;
- /** The element that was focused before the datepicker was opened. */
- _focusedElementBeforeOpen = null;
- /** Unique class that will be added to the backdrop so that the test harnesses can look it up. */
- _backdropHarnessClass = `${this.id}-backdrop`;
- /** Currently-registered actions portal. */
- _actionsPortal;
- /** The input element this datepicker is associated with. */
- datepickerInput;
- /** Emits when the datepicker's state changes. */
- stateChanges = new Subject();
- _injector = inject(Injector);
- _changeDetectorRef = inject(ChangeDetectorRef);
- constructor() {
- if (!this._dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw createMissingDateImplError('DateAdapter');
- }
- this._model.selectionChanged.subscribe(() => {
- this._changeDetectorRef.markForCheck();
- });
- }
- ngOnChanges(changes) {
- const positionChange = changes['xPosition'] || changes['yPosition'];
- if (positionChange && !positionChange.firstChange && this._overlayRef) {
- const positionStrategy = this._overlayRef.getConfig().positionStrategy;
- if (positionStrategy instanceof FlexibleConnectedPositionStrategy) {
- this._setConnectedPositions(positionStrategy);
- if (this.opened) {
- this._overlayRef.updatePosition();
- }
- }
- }
- this.stateChanges.next(undefined);
- }
- ngOnDestroy() {
- this._destroyOverlay();
- this.close();
- this._inputStateChanges.unsubscribe();
- this.stateChanges.complete();
- }
- /** Selects the given date */
- select(date) {
- this._model.add(date);
- }
- /** Emits the selected year in multiyear view */
- _selectYear(normalizedYear) {
- this.yearSelected.emit(normalizedYear);
- }
- /** Emits selected month in year view */
- _selectMonth(normalizedMonth) {
- this.monthSelected.emit(normalizedMonth);
- }
- /** Emits changed view */
- _viewChanged(view) {
- this.viewChanged.emit(view);
- }
- /**
- * Register an input with this datepicker.
- * @param input The datepicker input to register with this datepicker.
- * @returns Selection model that the input should hook itself up to.
- */
- registerInput(input) {
- if (this.datepickerInput && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw Error('A MatDatepicker can only be associated with a single input.');
- }
- this._inputStateChanges.unsubscribe();
- this.datepickerInput = input;
- this._inputStateChanges = input.stateChanges.subscribe(() => this.stateChanges.next(undefined));
- return this._model;
- }
- /**
- * Registers a portal containing action buttons with the datepicker.
- * @param portal Portal to be registered.
- */
- registerActions(portal) {
- if (this._actionsPortal && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw Error('A MatDatepicker can only be associated with a single actions row.');
- }
- this._actionsPortal = portal;
- this._componentRef?.instance._assignActions(portal, true);
- }
- /**
- * Removes a portal containing action buttons from the datepicker.
- * @param portal Portal to be removed.
- */
- removeActions(portal) {
- if (portal === this._actionsPortal) {
- this._actionsPortal = null;
- this._componentRef?.instance._assignActions(null, true);
- }
- }
- /** Open the calendar. */
- open() {
- // Skip reopening if there's an in-progress animation to avoid overlapping
- // sequences which can cause "changed after checked" errors. See #25837.
- if (this._opened || this.disabled || this._componentRef?.instance._isAnimating) {
- return;
- }
- if (!this.datepickerInput && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw Error('Attempted to open an MatDatepicker with no associated input.');
- }
- this._focusedElementBeforeOpen = _getFocusedElementPierceShadowDom();
- this._openOverlay();
- this._opened = true;
- this.openedStream.emit();
- }
- /** Close the calendar. */
- close() {
- // Skip reopening if there's an in-progress animation to avoid overlapping
- // sequences which can cause "changed after checked" errors. See #25837.
- if (!this._opened || this._componentRef?.instance._isAnimating) {
- return;
- }
- const canRestoreFocus = this.restoreFocus &&
- this._focusedElementBeforeOpen &&
- typeof this._focusedElementBeforeOpen.focus === 'function';
- const completeClose = () => {
- // The `_opened` could've been reset already if
- // we got two events in quick succession.
- if (this._opened) {
- this._opened = false;
- this.closedStream.emit();
- }
- };
- if (this._componentRef) {
- const { instance, location } = this._componentRef;
- instance._animationDone.pipe(take(1)).subscribe(() => {
- const activeElement = this._document.activeElement;
- // Since we restore focus after the exit animation, we have to check that
- // the user didn't move focus themselves inside the `close` handler.
- if (canRestoreFocus &&
- (!activeElement ||
- activeElement === this._document.activeElement ||
- location.nativeElement.contains(activeElement))) {
- this._focusedElementBeforeOpen.focus();
- }
- this._focusedElementBeforeOpen = null;
- this._destroyOverlay();
- });
- instance._startExitAnimation();
- }
- if (canRestoreFocus) {
- // Because IE moves focus asynchronously, we can't count on it being restored before we've
- // marked the datepicker as closed. If the event fires out of sequence and the element that
- // we're refocusing opens the datepicker on focus, the user could be stuck with not being
- // able to close the calendar at all. We work around it by making the logic, that marks
- // the datepicker as closed, async as well.
- setTimeout(completeClose);
- }
- else {
- completeClose();
- }
- }
- /** Applies the current pending selection on the overlay to the model. */
- _applyPendingSelection() {
- this._componentRef?.instance?._applyPendingSelection();
- }
- /** Forwards relevant values from the datepicker to the datepicker content inside the overlay. */
- _forwardContentValues(instance) {
- instance.datepicker = this;
- instance.color = this.color;
- instance._dialogLabelId = this.datepickerInput.getOverlayLabelId();
- instance._assignActions(this._actionsPortal, false);
- }
- /** Opens the overlay with the calendar. */
- _openOverlay() {
- this._destroyOverlay();
- const isDialog = this.touchUi;
- const portal = new ComponentPortal(MatDatepickerContent, this._viewContainerRef);
- const overlayRef = (this._overlayRef = this._overlay.create(new OverlayConfig({
- positionStrategy: isDialog ? this._getDialogStrategy() : this._getDropdownStrategy(),
- hasBackdrop: true,
- backdropClass: [
- isDialog ? 'cdk-overlay-dark-backdrop' : 'mat-overlay-transparent-backdrop',
- this._backdropHarnessClass,
- ],
- direction: this._dir || 'ltr',
- scrollStrategy: isDialog ? this._overlay.scrollStrategies.block() : this._scrollStrategy(),
- panelClass: `mat-datepicker-${isDialog ? 'dialog' : 'popup'}`,
- })));
- this._getCloseStream(overlayRef).subscribe(event => {
- if (event) {
- event.preventDefault();
- }
- this.close();
- });
- // The `preventDefault` call happens inside the calendar as well, however focus moves into
- // it inside a timeout which can give browsers a chance to fire off a keyboard event in-between
- // that can scroll the page (see #24969). Always block default actions of arrow keys for the
- // entire overlay so the page doesn't get scrolled by accident.
- overlayRef.keydownEvents().subscribe(event => {
- const keyCode = event.keyCode;
- if (keyCode === UP_ARROW ||
- keyCode === DOWN_ARROW ||
- keyCode === LEFT_ARROW ||
- keyCode === RIGHT_ARROW ||
- keyCode === PAGE_UP ||
- keyCode === PAGE_DOWN) {
- event.preventDefault();
- }
- });
- this._componentRef = overlayRef.attach(portal);
- this._forwardContentValues(this._componentRef.instance);
- // Update the position once the calendar has rendered. Only relevant in dropdown mode.
- if (!isDialog) {
- afterNextRender(() => {
- overlayRef.updatePosition();
- }, { injector: this._injector });
- }
- }
- /** Destroys the current overlay. */
- _destroyOverlay() {
- if (this._overlayRef) {
- this._overlayRef.dispose();
- this._overlayRef = this._componentRef = null;
- }
- }
- /** Gets a position strategy that will open the calendar as a dropdown. */
- _getDialogStrategy() {
- return this._overlay.position().global().centerHorizontally().centerVertically();
- }
- /** Gets a position strategy that will open the calendar as a dropdown. */
- _getDropdownStrategy() {
- const strategy = this._overlay
- .position()
- .flexibleConnectedTo(this.datepickerInput.getConnectedOverlayOrigin())
- .withTransformOriginOn('.mat-datepicker-content')
- .withFlexibleDimensions(false)
- .withViewportMargin(8)
- .withLockedPosition();
- return this._setConnectedPositions(strategy);
- }
- /** Sets the positions of the datepicker in dropdown mode based on the current configuration. */
- _setConnectedPositions(strategy) {
- const primaryX = this.xPosition === 'end' ? 'end' : 'start';
- const secondaryX = primaryX === 'start' ? 'end' : 'start';
- const primaryY = this.yPosition === 'above' ? 'bottom' : 'top';
- const secondaryY = primaryY === 'top' ? 'bottom' : 'top';
- return strategy.withPositions([
- {
- originX: primaryX,
- originY: secondaryY,
- overlayX: primaryX,
- overlayY: primaryY,
- },
- {
- originX: primaryX,
- originY: primaryY,
- overlayX: primaryX,
- overlayY: secondaryY,
- },
- {
- originX: secondaryX,
- originY: secondaryY,
- overlayX: secondaryX,
- overlayY: primaryY,
- },
- {
- originX: secondaryX,
- originY: primaryY,
- overlayX: secondaryX,
- overlayY: secondaryY,
- },
- ]);
- }
- /** Gets an observable that will emit when the overlay is supposed to be closed. */
- _getCloseStream(overlayRef) {
- const ctrlShiftMetaModifiers = ['ctrlKey', 'shiftKey', 'metaKey'];
- return merge(overlayRef.backdropClick(), overlayRef.detachments(), overlayRef.keydownEvents().pipe(filter(event => {
- // Closing on alt + up is only valid when there's an input associated with the datepicker.
- return ((event.keyCode === ESCAPE && !hasModifierKey(event)) ||
- (this.datepickerInput &&
- hasModifierKey(event, 'altKey') &&
- event.keyCode === UP_ARROW &&
- ctrlShiftMetaModifiers.every((modifier) => !hasModifierKey(event, modifier))));
- })));
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.6", type: MatDatepickerBase, isStandalone: true, inputs: { calendarHeaderComponent: "calendarHeaderComponent", startAt: "startAt", startView: "startView", color: "color", touchUi: ["touchUi", "touchUi", booleanAttribute], disabled: ["disabled", "disabled", booleanAttribute], xPosition: "xPosition", yPosition: "yPosition", restoreFocus: ["restoreFocus", "restoreFocus", booleanAttribute], dateClass: "dateClass", panelClass: "panelClass", opened: ["opened", "opened", booleanAttribute] }, outputs: { yearSelected: "yearSelected", monthSelected: "monthSelected", viewChanged: "viewChanged", openedStream: "opened", closedStream: "closed" }, usesOnChanges: true, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerBase, decorators: [{
- type: Directive
- }], ctorParameters: () => [], propDecorators: { calendarHeaderComponent: [{
- type: Input
- }], startAt: [{
- type: Input
- }], startView: [{
- type: Input
- }], color: [{
- type: Input
- }], touchUi: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], disabled: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], xPosition: [{
- type: Input
- }], yPosition: [{
- type: Input
- }], restoreFocus: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], yearSelected: [{
- type: Output
- }], monthSelected: [{
- type: Output
- }], viewChanged: [{
- type: Output
- }], dateClass: [{
- type: Input
- }], openedStream: [{
- type: Output,
- args: ['opened']
- }], closedStream: [{
- type: Output,
- args: ['closed']
- }], panelClass: [{
- type: Input
- }], opened: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }] } });
- // TODO(mmalerba): We use a component instead of a directive here so the user can use implicit
- // template reference variables (e.g. #d vs #d="matDatepicker"). We can change this to a directive
- // if angular adds support for `exportAs: '$implicit'` on directives.
- /** Component responsible for managing the datepicker popup/dialog. */
- class MatDatepicker extends MatDatepickerBase {
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepicker, deps: null, target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepicker, isStandalone: true, selector: "mat-datepicker", providers: [
- MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER,
- { provide: MatDatepickerBase, useExisting: MatDatepicker },
- ], exportAs: ["matDatepicker"], usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepicker, decorators: [{
- type: Component,
- args: [{
- selector: 'mat-datepicker',
- template: '',
- exportAs: 'matDatepicker',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- providers: [
- MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER,
- { provide: MatDatepickerBase, useExisting: MatDatepicker },
- ],
- }]
- }] });
- /**
- * An event used for datepicker input and change events. We don't always have access to a native
- * input or change event because the event may have been triggered by the user clicking on the
- * calendar popup. For consistency, we always use MatDatepickerInputEvent instead.
- */
- class MatDatepickerInputEvent {
- target;
- targetElement;
- /** The new value for the target datepicker input. */
- value;
- constructor(
- /** Reference to the datepicker input component that emitted the event. */
- target,
- /** Reference to the native input element associated with the datepicker input. */
- targetElement) {
- this.target = target;
- this.targetElement = targetElement;
- this.value = this.target.value;
- }
- }
- /** Base class for datepicker inputs. */
- class MatDatepickerInputBase {
- _elementRef = inject(ElementRef);
- _dateAdapter = inject(DateAdapter, { optional: true });
- _dateFormats = inject(MAT_DATE_FORMATS, { optional: true });
- /** Whether the component has been initialized. */
- _isInitialized;
- /** The value of the input. */
- get value() {
- return this._model ? this._getValueFromModel(this._model.selection) : this._pendingValue;
- }
- set value(value) {
- this._assignValueProgrammatically(value);
- }
- _model;
- /** Whether the datepicker-input is disabled. */
- get disabled() {
- return !!this._disabled || this._parentDisabled();
- }
- set disabled(value) {
- const newValue = value;
- const element = this._elementRef.nativeElement;
- if (this._disabled !== newValue) {
- this._disabled = newValue;
- this.stateChanges.next(undefined);
- }
- // We need to null check the `blur` method, because it's undefined during SSR.
- // In Ivy static bindings are invoked earlier, before the element is attached to the DOM.
- // This can cause an error to be thrown in some browsers (IE/Edge) which assert that the
- // element has been inserted.
- if (newValue && this._isInitialized && element.blur) {
- // Normally, native input elements automatically blur if they turn disabled. This behavior
- // is problematic, because it would mean that it triggers another change detection cycle,
- // which then causes a changed after checked error if the input element was focused before.
- element.blur();
- }
- }
- _disabled;
- /** Emits when a `change` event is fired on this `<input>`. */
- dateChange = new EventEmitter();
- /** Emits when an `input` event is fired on this `<input>`. */
- dateInput = new EventEmitter();
- /** Emits when the internal state has changed */
- stateChanges = new Subject();
- _onTouched = () => { };
- _validatorOnChange = () => { };
- _cvaOnChange = () => { };
- _valueChangesSubscription = Subscription.EMPTY;
- _localeSubscription = Subscription.EMPTY;
- /**
- * Since the value is kept on the model which is assigned in an Input,
- * we might get a value before we have a model. This property keeps track
- * of the value until we have somewhere to assign it.
- */
- _pendingValue;
- /** The form control validator for whether the input parses. */
- _parseValidator = () => {
- return this._lastValueValid
- ? null
- : { 'matDatepickerParse': { 'text': this._elementRef.nativeElement.value } };
- };
- /** The form control validator for the date filter. */
- _filterValidator = (control) => {
- const controlValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
- return !controlValue || this._matchesFilter(controlValue)
- ? null
- : { 'matDatepickerFilter': true };
- };
- /** The form control validator for the min date. */
- _minValidator = (control) => {
- const controlValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
- const min = this._getMinDate();
- return !min || !controlValue || this._dateAdapter.compareDate(min, controlValue) <= 0
- ? null
- : { 'matDatepickerMin': { 'min': min, 'actual': controlValue } };
- };
- /** The form control validator for the max date. */
- _maxValidator = (control) => {
- const controlValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
- const max = this._getMaxDate();
- return !max || !controlValue || this._dateAdapter.compareDate(max, controlValue) >= 0
- ? null
- : { 'matDatepickerMax': { 'max': max, 'actual': controlValue } };
- };
- /** Gets the base validator functions. */
- _getValidators() {
- return [this._parseValidator, this._minValidator, this._maxValidator, this._filterValidator];
- }
- /** Registers a date selection model with the input. */
- _registerModel(model) {
- this._model = model;
- this._valueChangesSubscription.unsubscribe();
- if (this._pendingValue) {
- this._assignValue(this._pendingValue);
- }
- this._valueChangesSubscription = this._model.selectionChanged.subscribe(event => {
- if (this._shouldHandleChangeEvent(event)) {
- const value = this._getValueFromModel(event.selection);
- this._lastValueValid = this._isValidValue(value);
- this._cvaOnChange(value);
- this._onTouched();
- this._formatValue(value);
- this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
- this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
- }
- });
- }
- /** Whether the last value set on the input was valid. */
- _lastValueValid = false;
- constructor() {
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
- if (!this._dateAdapter) {
- throw createMissingDateImplError('DateAdapter');
- }
- if (!this._dateFormats) {
- throw createMissingDateImplError('MAT_DATE_FORMATS');
- }
- }
- // Update the displayed date when the locale changes.
- this._localeSubscription = this._dateAdapter.localeChanges.subscribe(() => {
- this._assignValueProgrammatically(this.value);
- });
- }
- ngAfterViewInit() {
- this._isInitialized = true;
- }
- ngOnChanges(changes) {
- if (dateInputsHaveChanged(changes, this._dateAdapter)) {
- this.stateChanges.next(undefined);
- }
- }
- ngOnDestroy() {
- this._valueChangesSubscription.unsubscribe();
- this._localeSubscription.unsubscribe();
- this.stateChanges.complete();
- }
- /** @docs-private */
- registerOnValidatorChange(fn) {
- this._validatorOnChange = fn;
- }
- /** @docs-private */
- validate(c) {
- return this._validator ? this._validator(c) : null;
- }
- // Implemented as part of ControlValueAccessor.
- writeValue(value) {
- this._assignValueProgrammatically(value);
- }
- // Implemented as part of ControlValueAccessor.
- registerOnChange(fn) {
- this._cvaOnChange = fn;
- }
- // Implemented as part of ControlValueAccessor.
- registerOnTouched(fn) {
- this._onTouched = fn;
- }
- // Implemented as part of ControlValueAccessor.
- setDisabledState(isDisabled) {
- this.disabled = isDisabled;
- }
- _onKeydown(event) {
- const ctrlShiftMetaModifiers = ['ctrlKey', 'shiftKey', 'metaKey'];
- const isAltDownArrow = hasModifierKey(event, 'altKey') &&
- event.keyCode === DOWN_ARROW &&
- ctrlShiftMetaModifiers.every((modifier) => !hasModifierKey(event, modifier));
- if (isAltDownArrow && !this._elementRef.nativeElement.readOnly) {
- this._openPopup();
- event.preventDefault();
- }
- }
- _onInput(value) {
- const lastValueWasValid = this._lastValueValid;
- let date = this._dateAdapter.parse(value, this._dateFormats.parse.dateInput);
- this._lastValueValid = this._isValidValue(date);
- date = this._dateAdapter.getValidDateOrNull(date);
- const hasChanged = !this._dateAdapter.sameDate(date, this.value);
- // We need to fire the CVA change event for all
- // nulls, otherwise the validators won't run.
- if (!date || hasChanged) {
- this._cvaOnChange(date);
- }
- else {
- // Call the CVA change handler for invalid values
- // since this is what marks the control as dirty.
- if (value && !this.value) {
- this._cvaOnChange(date);
- }
- if (lastValueWasValid !== this._lastValueValid) {
- this._validatorOnChange();
- }
- }
- if (hasChanged) {
- this._assignValue(date);
- this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
- }
- }
- _onChange() {
- this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
- }
- /** Handles blur events on the input. */
- _onBlur() {
- // Reformat the input only if we have a valid value.
- if (this.value) {
- this._formatValue(this.value);
- }
- this._onTouched();
- }
- /** Formats a value and sets it on the input element. */
- _formatValue(value) {
- this._elementRef.nativeElement.value =
- value != null ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : '';
- }
- /** Assigns a value to the model. */
- _assignValue(value) {
- // We may get some incoming values before the model was
- // assigned. Save the value so that we can assign it later.
- if (this._model) {
- this._assignValueToModel(value);
- this._pendingValue = null;
- }
- else {
- this._pendingValue = value;
- }
- }
- /** Whether a value is considered valid. */
- _isValidValue(value) {
- return !value || this._dateAdapter.isValid(value);
- }
- /**
- * Checks whether a parent control is disabled. This is in place so that it can be overridden
- * by inputs extending this one which can be placed inside of a group that can be disabled.
- */
- _parentDisabled() {
- return false;
- }
- /** Programmatically assigns a value to the input. */
- _assignValueProgrammatically(value) {
- value = this._dateAdapter.deserialize(value);
- this._lastValueValid = this._isValidValue(value);
- value = this._dateAdapter.getValidDateOrNull(value);
- this._assignValue(value);
- this._formatValue(value);
- }
- /** Gets whether a value matches the current date filter. */
- _matchesFilter(value) {
- const filter = this._getDateFilter();
- return !filter || filter(value);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerInputBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "19.2.6", type: MatDatepickerInputBase, isStandalone: true, inputs: { value: "value", disabled: ["disabled", "disabled", booleanAttribute] }, outputs: { dateChange: "dateChange", dateInput: "dateInput" }, usesOnChanges: true, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerInputBase, decorators: [{
- type: Directive
- }], ctorParameters: () => [], propDecorators: { value: [{
- type: Input
- }], disabled: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], dateChange: [{
- type: Output
- }], dateInput: [{
- type: Output
- }] } });
- /**
- * Checks whether the `SimpleChanges` object from an `ngOnChanges`
- * callback has any changes, accounting for date objects.
- */
- function dateInputsHaveChanged(changes, adapter) {
- const keys = Object.keys(changes);
- for (let key of keys) {
- const { previousValue, currentValue } = changes[key];
- if (adapter.isDateInstance(previousValue) && adapter.isDateInstance(currentValue)) {
- if (!adapter.sameDate(previousValue, currentValue)) {
- return true;
- }
- }
- else {
- return true;
- }
- }
- return false;
- }
- /** @docs-private */
- const MAT_DATEPICKER_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(() => MatDatepickerInput),
- multi: true,
- };
- /** @docs-private */
- const MAT_DATEPICKER_VALIDATORS = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(() => MatDatepickerInput),
- multi: true,
- };
- /** Directive used to connect an input to a MatDatepicker. */
- class MatDatepickerInput extends MatDatepickerInputBase {
- _formField = inject(MAT_FORM_FIELD, { optional: true });
- _closedSubscription = Subscription.EMPTY;
- _openedSubscription = Subscription.EMPTY;
- /** The datepicker that this input is associated with. */
- set matDatepicker(datepicker) {
- if (datepicker) {
- this._datepicker = datepicker;
- this._ariaOwns.set(datepicker.opened ? datepicker.id : null);
- this._closedSubscription = datepicker.closedStream.subscribe(() => {
- this._onTouched();
- this._ariaOwns.set(null);
- });
- this._openedSubscription = datepicker.openedStream.subscribe(() => {
- this._ariaOwns.set(datepicker.id);
- });
- this._registerModel(datepicker.registerInput(this));
- }
- }
- _datepicker;
- /** The id of the panel owned by this input. */
- _ariaOwns = signal(null);
- /** The minimum valid date. */
- get min() {
- return this._min;
- }
- set min(value) {
- const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- if (!this._dateAdapter.sameDate(validValue, this._min)) {
- this._min = validValue;
- this._validatorOnChange();
- }
- }
- _min;
- /** The maximum valid date. */
- get max() {
- return this._max;
- }
- set max(value) {
- const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- if (!this._dateAdapter.sameDate(validValue, this._max)) {
- this._max = validValue;
- this._validatorOnChange();
- }
- }
- _max;
- /** Function that can be used to filter out dates within the datepicker. */
- get dateFilter() {
- return this._dateFilter;
- }
- set dateFilter(value) {
- const wasMatchingValue = this._matchesFilter(this.value);
- this._dateFilter = value;
- if (this._matchesFilter(this.value) !== wasMatchingValue) {
- this._validatorOnChange();
- }
- }
- _dateFilter;
- /** The combined form control validator for this input. */
- _validator;
- constructor() {
- super();
- this._validator = Validators.compose(super._getValidators());
- }
- /**
- * Gets the element that the datepicker popup should be connected to.
- * @return The element to connect the popup to.
- */
- getConnectedOverlayOrigin() {
- return this._formField ? this._formField.getConnectedOverlayOrigin() : this._elementRef;
- }
- /** Gets the ID of an element that should be used a description for the calendar overlay. */
- getOverlayLabelId() {
- if (this._formField) {
- return this._formField.getLabelId();
- }
- return this._elementRef.nativeElement.getAttribute('aria-labelledby');
- }
- /** Returns the palette used by the input's form field, if any. */
- getThemePalette() {
- return this._formField ? this._formField.color : undefined;
- }
- /** Gets the value at which the calendar should start. */
- getStartValue() {
- return this.value;
- }
- ngOnDestroy() {
- super.ngOnDestroy();
- this._closedSubscription.unsubscribe();
- this._openedSubscription.unsubscribe();
- }
- /** Opens the associated datepicker. */
- _openPopup() {
- if (this._datepicker) {
- this._datepicker.open();
- }
- }
- _getValueFromModel(modelValue) {
- return modelValue;
- }
- _assignValueToModel(value) {
- if (this._model) {
- this._model.updateSelection(value, this);
- }
- }
- /** Gets the input's minimum date. */
- _getMinDate() {
- return this._min;
- }
- /** Gets the input's maximum date. */
- _getMaxDate() {
- return this._max;
- }
- /** Gets the input's date filtering function. */
- _getDateFilter() {
- return this._dateFilter;
- }
- _shouldHandleChangeEvent(event) {
- return event.source !== this;
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepickerInput, isStandalone: true, selector: "input[matDatepicker]", inputs: { matDatepicker: "matDatepicker", min: "min", max: "max", dateFilter: ["matDatepickerFilter", "dateFilter"] }, host: { listeners: { "input": "_onInput($event.target.value)", "change": "_onChange()", "blur": "_onBlur()", "keydown": "_onKeydown($event)" }, properties: { "attr.aria-haspopup": "_datepicker ? \"dialog\" : null", "attr.aria-owns": "_ariaOwns()", "attr.min": "min ? _dateAdapter.toIso8601(min) : null", "attr.max": "max ? _dateAdapter.toIso8601(max) : null", "attr.data-mat-calendar": "_datepicker ? _datepicker.id : null", "disabled": "disabled" }, classAttribute: "mat-datepicker-input" }, providers: [
- MAT_DATEPICKER_VALUE_ACCESSOR,
- MAT_DATEPICKER_VALIDATORS,
- { provide: MAT_INPUT_VALUE_ACCESSOR, useExisting: MatDatepickerInput },
- ], exportAs: ["matDatepickerInput"], usesInheritance: true, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerInput, decorators: [{
- type: Directive,
- args: [{
- selector: 'input[matDatepicker]',
- providers: [
- MAT_DATEPICKER_VALUE_ACCESSOR,
- MAT_DATEPICKER_VALIDATORS,
- { provide: MAT_INPUT_VALUE_ACCESSOR, useExisting: MatDatepickerInput },
- ],
- host: {
- 'class': 'mat-datepicker-input',
- '[attr.aria-haspopup]': '_datepicker ? "dialog" : null',
- '[attr.aria-owns]': '_ariaOwns()',
- '[attr.min]': 'min ? _dateAdapter.toIso8601(min) : null',
- '[attr.max]': 'max ? _dateAdapter.toIso8601(max) : null',
- // Used by the test harness to tie this input to its calendar. We can't depend on
- // `aria-owns` for this, because it's only defined while the calendar is open.
- '[attr.data-mat-calendar]': '_datepicker ? _datepicker.id : null',
- '[disabled]': 'disabled',
- '(input)': '_onInput($event.target.value)',
- '(change)': '_onChange()',
- '(blur)': '_onBlur()',
- '(keydown)': '_onKeydown($event)',
- },
- exportAs: 'matDatepickerInput',
- }]
- }], ctorParameters: () => [], propDecorators: { matDatepicker: [{
- type: Input
- }], min: [{
- type: Input
- }], max: [{
- type: Input
- }], dateFilter: [{
- type: Input,
- args: ['matDatepickerFilter']
- }] } });
- /** Can be used to override the icon of a `matDatepickerToggle`. */
- class MatDatepickerToggleIcon {
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerToggleIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepickerToggleIcon, isStandalone: true, selector: "[matDatepickerToggleIcon]", ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerToggleIcon, decorators: [{
- type: Directive,
- args: [{
- selector: '[matDatepickerToggleIcon]',
- }]
- }] });
- class MatDatepickerToggle {
- _intl = inject(MatDatepickerIntl);
- _changeDetectorRef = inject(ChangeDetectorRef);
- _stateChanges = Subscription.EMPTY;
- /** Datepicker instance that the button will toggle. */
- datepicker;
- /** Tabindex for the toggle. */
- tabIndex;
- /** Screen-reader label for the button. */
- ariaLabel;
- /** Whether the toggle button is disabled. */
- get disabled() {
- if (this._disabled === undefined && this.datepicker) {
- return this.datepicker.disabled;
- }
- return !!this._disabled;
- }
- set disabled(value) {
- this._disabled = value;
- }
- _disabled;
- /** Whether ripples on the toggle should be disabled. */
- disableRipple;
- /** Custom icon set by the consumer. */
- _customIcon;
- /** Underlying button element. */
- _button;
- constructor() {
- const defaultTabIndex = inject(new HostAttributeToken('tabindex'), { optional: true });
- const parsedTabIndex = Number(defaultTabIndex);
- this.tabIndex = parsedTabIndex || parsedTabIndex === 0 ? parsedTabIndex : null;
- }
- ngOnChanges(changes) {
- if (changes['datepicker']) {
- this._watchStateChanges();
- }
- }
- ngOnDestroy() {
- this._stateChanges.unsubscribe();
- }
- ngAfterContentInit() {
- this._watchStateChanges();
- }
- _open(event) {
- if (this.datepicker && !this.disabled) {
- this.datepicker.open();
- event.stopPropagation();
- }
- }
- _watchStateChanges() {
- const datepickerStateChanged = this.datepicker ? this.datepicker.stateChanges : of();
- const inputStateChanged = this.datepicker && this.datepicker.datepickerInput
- ? this.datepicker.datepickerInput.stateChanges
- : of();
- const datepickerToggled = this.datepicker
- ? merge(this.datepicker.openedStream, this.datepicker.closedStream)
- : of();
- this._stateChanges.unsubscribe();
- this._stateChanges = merge(this._intl.changes, datepickerStateChanged, inputStateChanged, datepickerToggled).subscribe(() => this._changeDetectorRef.markForCheck());
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.6", type: MatDatepickerToggle, isStandalone: true, selector: "mat-datepicker-toggle", inputs: { datepicker: ["for", "datepicker"], tabIndex: "tabIndex", ariaLabel: ["aria-label", "ariaLabel"], disabled: ["disabled", "disabled", booleanAttribute], disableRipple: "disableRipple" }, host: { listeners: { "click": "_open($event)" }, properties: { "attr.tabindex": "null", "class.mat-datepicker-toggle-active": "datepicker && datepicker.opened", "class.mat-accent": "datepicker && datepicker.color === \"accent\"", "class.mat-warn": "datepicker && datepicker.color === \"warn\"", "attr.data-mat-calendar": "datepicker ? datepicker.id : null" }, classAttribute: "mat-datepicker-toggle" }, queries: [{ propertyName: "_customIcon", first: true, predicate: MatDatepickerToggleIcon, descendants: true }], viewQueries: [{ propertyName: "_button", first: true, predicate: ["button"], descendants: true }], exportAs: ["matDatepickerToggle"], usesOnChanges: true, ngImport: i0, template: "<button\n #button\n mat-icon-button\n type=\"button\"\n [attr.aria-haspopup]=\"datepicker ? 'dialog' : null\"\n [attr.aria-label]=\"ariaLabel || _intl.openCalendarLabel\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\n [attr.aria-expanded]=\"datepicker ? datepicker.opened : null\"\n [disabled]=\"disabled\"\n [disableRipple]=\"disableRipple\">\n\n @if (!_customIcon) {\n <svg\n class=\"mat-datepicker-toggle-default-icon\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n fill=\"currentColor\"\n focusable=\"false\"\n aria-hidden=\"true\">\n <path d=\"M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z\"/>\n </svg>\n }\n\n <ng-content select=\"[matDatepickerToggleIcon]\"></ng-content>\n</button>\n", styles: [".mat-datepicker-toggle{pointer-events:auto;color:var(--mat-datepicker-toggle-icon-color, var(--mat-sys-on-surface-variant))}.mat-datepicker-toggle-active{color:var(--mat-datepicker-toggle-active-state-icon-color, var(--mat-sys-on-surface-variant))}@media(forced-colors: active){.mat-datepicker-toggle-default-icon{color:CanvasText}}\n"], dependencies: [{ kind: "component", type: MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerToggle, decorators: [{
- type: Component,
- args: [{ selector: 'mat-datepicker-toggle', host: {
- 'class': 'mat-datepicker-toggle',
- '[attr.tabindex]': 'null',
- '[class.mat-datepicker-toggle-active]': 'datepicker && datepicker.opened',
- '[class.mat-accent]': 'datepicker && datepicker.color === "accent"',
- '[class.mat-warn]': 'datepicker && datepicker.color === "warn"',
- // Used by the test harness to tie this toggle to its datepicker.
- '[attr.data-mat-calendar]': 'datepicker ? datepicker.id : null',
- // Bind the `click` on the host, rather than the inner `button`, so that we can call
- // `stopPropagation` on it without affecting the user's `click` handlers. We need to stop
- // it so that the input doesn't get focused automatically by the form field (See #21836).
- '(click)': '_open($event)',
- }, exportAs: 'matDatepickerToggle', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [MatIconButton], template: "<button\n #button\n mat-icon-button\n type=\"button\"\n [attr.aria-haspopup]=\"datepicker ? 'dialog' : null\"\n [attr.aria-label]=\"ariaLabel || _intl.openCalendarLabel\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\n [attr.aria-expanded]=\"datepicker ? datepicker.opened : null\"\n [disabled]=\"disabled\"\n [disableRipple]=\"disableRipple\">\n\n @if (!_customIcon) {\n <svg\n class=\"mat-datepicker-toggle-default-icon\"\n viewBox=\"0 0 24 24\"\n width=\"24px\"\n height=\"24px\"\n fill=\"currentColor\"\n focusable=\"false\"\n aria-hidden=\"true\">\n <path d=\"M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z\"/>\n </svg>\n }\n\n <ng-content select=\"[matDatepickerToggleIcon]\"></ng-content>\n</button>\n", styles: [".mat-datepicker-toggle{pointer-events:auto;color:var(--mat-datepicker-toggle-icon-color, var(--mat-sys-on-surface-variant))}.mat-datepicker-toggle-active{color:var(--mat-datepicker-toggle-active-state-icon-color, var(--mat-sys-on-surface-variant))}@media(forced-colors: active){.mat-datepicker-toggle-default-icon{color:CanvasText}}\n"] }]
- }], ctorParameters: () => [], propDecorators: { datepicker: [{
- type: Input,
- args: ['for']
- }], tabIndex: [{
- type: Input
- }], ariaLabel: [{
- type: Input,
- args: ['aria-label']
- }], disabled: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], disableRipple: [{
- type: Input
- }], _customIcon: [{
- type: ContentChild,
- args: [MatDatepickerToggleIcon]
- }], _button: [{
- type: ViewChild,
- args: ['button']
- }] } });
- class MatDateRangeInput {
- _changeDetectorRef = inject(ChangeDetectorRef);
- _elementRef = inject(ElementRef);
- _dateAdapter = inject(DateAdapter, { optional: true });
- _formField = inject(MAT_FORM_FIELD, { optional: true });
- _closedSubscription = Subscription.EMPTY;
- _openedSubscription = Subscription.EMPTY;
- _startInput;
- _endInput;
- /** Current value of the range input. */
- get value() {
- return this._model ? this._model.selection : null;
- }
- /** Unique ID for the group. */
- id = inject(_IdGenerator).getId('mat-date-range-input-');
- /** Whether the control is focused. */
- focused = false;
- /** Whether the control's label should float. */
- get shouldLabelFloat() {
- return this.focused || !this.empty;
- }
- /** Name of the form control. */
- controlType = 'mat-date-range-input';
- /**
- * Implemented as a part of `MatFormFieldControl`.
- * Set the placeholder attribute on `matStartDate` and `matEndDate`.
- * @docs-private
- */
- get placeholder() {
- const start = this._startInput?._getPlaceholder() || '';
- const end = this._endInput?._getPlaceholder() || '';
- return start || end ? `${start} ${this.separator} ${end}` : '';
- }
- /** The range picker that this input is associated with. */
- get rangePicker() {
- return this._rangePicker;
- }
- set rangePicker(rangePicker) {
- if (rangePicker) {
- this._model = rangePicker.registerInput(this);
- this._rangePicker = rangePicker;
- this._closedSubscription.unsubscribe();
- this._openedSubscription.unsubscribe();
- this._ariaOwns.set(this.rangePicker.opened ? rangePicker.id : null);
- this._closedSubscription = rangePicker.closedStream.subscribe(() => {
- this._startInput?._onTouched();
- this._endInput?._onTouched();
- this._ariaOwns.set(null);
- });
- this._openedSubscription = rangePicker.openedStream.subscribe(() => {
- this._ariaOwns.set(rangePicker.id);
- });
- this._registerModel(this._model);
- }
- }
- _rangePicker;
- /** The id of the panel owned by this input. */
- _ariaOwns = signal(null);
- /** Whether the input is required. */
- get required() {
- return (this._required ??
- (this._isTargetRequired(this) ||
- this._isTargetRequired(this._startInput) ||
- this._isTargetRequired(this._endInput)) ??
- false);
- }
- set required(value) {
- this._required = value;
- }
- _required;
- /** Function that can be used to filter out dates within the date range picker. */
- get dateFilter() {
- return this._dateFilter;
- }
- set dateFilter(value) {
- const start = this._startInput;
- const end = this._endInput;
- const wasMatchingStart = start && start._matchesFilter(start.value);
- const wasMatchingEnd = end && end._matchesFilter(start.value);
- this._dateFilter = value;
- if (start && start._matchesFilter(start.value) !== wasMatchingStart) {
- start._validatorOnChange();
- }
- if (end && end._matchesFilter(end.value) !== wasMatchingEnd) {
- end._validatorOnChange();
- }
- }
- _dateFilter;
- /** The minimum valid date. */
- get min() {
- return this._min;
- }
- set min(value) {
- const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- if (!this._dateAdapter.sameDate(validValue, this._min)) {
- this._min = validValue;
- this._revalidate();
- }
- }
- _min;
- /** The maximum valid date. */
- get max() {
- return this._max;
- }
- set max(value) {
- const validValue = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(value));
- if (!this._dateAdapter.sameDate(validValue, this._max)) {
- this._max = validValue;
- this._revalidate();
- }
- }
- _max;
- /** Whether the input is disabled. */
- get disabled() {
- return this._startInput && this._endInput
- ? this._startInput.disabled && this._endInput.disabled
- : this._groupDisabled;
- }
- set disabled(value) {
- if (value !== this._groupDisabled) {
- this._groupDisabled = value;
- this.stateChanges.next(undefined);
- }
- }
- _groupDisabled = false;
- /** Whether the input is in an error state. */
- get errorState() {
- if (this._startInput && this._endInput) {
- return this._startInput.errorState || this._endInput.errorState;
- }
- return false;
- }
- /** Whether the datepicker input is empty. */
- get empty() {
- const startEmpty = this._startInput ? this._startInput.isEmpty() : false;
- const endEmpty = this._endInput ? this._endInput.isEmpty() : false;
- return startEmpty && endEmpty;
- }
- /** Value for the `aria-describedby` attribute of the inputs. */
- _ariaDescribedBy = null;
- /** Date selection model currently registered with the input. */
- _model;
- /** Separator text to be shown between the inputs. */
- separator = '–';
- /** Start of the comparison range that should be shown in the calendar. */
- comparisonStart = null;
- /** End of the comparison range that should be shown in the calendar. */
- comparisonEnd = null;
- /**
- * Implemented as a part of `MatFormFieldControl`.
- * TODO(crisbeto): change type to `AbstractControlDirective` after #18206 lands.
- * @docs-private
- */
- ngControl;
- /** Emits when the input's state has changed. */
- stateChanges = new Subject();
- /**
- * Disable the automatic labeling to avoid issues like #27241.
- * @docs-private
- */
- disableAutomaticLabeling = true;
- constructor() {
- if (!this._dateAdapter && (typeof ngDevMode === 'undefined' || ngDevMode)) {
- throw createMissingDateImplError('DateAdapter');
- }
- // The datepicker module can be used both with MDC and non-MDC form fields. We have
- // to conditionally add the MDC input class so that the range picker looks correctly.
- if (this._formField?._elementRef.nativeElement.classList.contains('mat-mdc-form-field')) {
- this._elementRef.nativeElement.classList.add('mat-mdc-input-element', 'mat-mdc-form-field-input-control', 'mdc-text-field__input');
- }
- // TODO(crisbeto): remove `as any` after #18206 lands.
- this.ngControl = inject(ControlContainer, { optional: true, self: true });
- }
- /**
- * Implemented as a part of `MatFormFieldControl`.
- * @docs-private
- */
- setDescribedByIds(ids) {
- this._ariaDescribedBy = ids.length ? ids.join(' ') : null;
- }
- /**
- * Implemented as a part of `MatFormFieldControl`.
- * @docs-private
- */
- onContainerClick() {
- if (!this.focused && !this.disabled) {
- if (!this._model || !this._model.selection.start) {
- this._startInput.focus();
- }
- else {
- this._endInput.focus();
- }
- }
- }
- ngAfterContentInit() {
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
- if (!this._startInput) {
- throw Error('mat-date-range-input must contain a matStartDate input');
- }
- if (!this._endInput) {
- throw Error('mat-date-range-input must contain a matEndDate input');
- }
- }
- if (this._model) {
- this._registerModel(this._model);
- }
- // We don't need to unsubscribe from this, because we
- // know that the input streams will be completed on destroy.
- merge(this._startInput.stateChanges, this._endInput.stateChanges).subscribe(() => {
- this.stateChanges.next(undefined);
- });
- }
- ngOnChanges(changes) {
- if (dateInputsHaveChanged(changes, this._dateAdapter)) {
- this.stateChanges.next(undefined);
- }
- }
- ngOnDestroy() {
- this._closedSubscription.unsubscribe();
- this._openedSubscription.unsubscribe();
- this.stateChanges.complete();
- }
- /** Gets the date at which the calendar should start. */
- getStartValue() {
- return this.value ? this.value.start : null;
- }
- /** Gets the input's theme palette. */
- getThemePalette() {
- return this._formField ? this._formField.color : undefined;
- }
- /** Gets the element to which the calendar overlay should be attached. */
- getConnectedOverlayOrigin() {
- return this._formField ? this._formField.getConnectedOverlayOrigin() : this._elementRef;
- }
- /** Gets the ID of an element that should be used a description for the calendar overlay. */
- getOverlayLabelId() {
- return this._formField ? this._formField.getLabelId() : null;
- }
- /** Gets the value that is used to mirror the state input. */
- _getInputMirrorValue(part) {
- const input = part === 'start' ? this._startInput : this._endInput;
- return input ? input.getMirrorValue() : '';
- }
- /** Whether the input placeholders should be hidden. */
- _shouldHidePlaceholders() {
- return this._startInput ? !this._startInput.isEmpty() : false;
- }
- /** Handles the value in one of the child inputs changing. */
- _handleChildValueChange() {
- this.stateChanges.next(undefined);
- this._changeDetectorRef.markForCheck();
- }
- /** Opens the date range picker associated with the input. */
- _openDatepicker() {
- if (this._rangePicker) {
- this._rangePicker.open();
- }
- }
- /** Whether the separate text should be hidden. */
- _shouldHideSeparator() {
- return ((!this._formField ||
- (this._formField.getLabelId() && !this._formField._shouldLabelFloat())) &&
- this.empty);
- }
- /** Gets the value for the `aria-labelledby` attribute of the inputs. */
- _getAriaLabelledby() {
- const formField = this._formField;
- return formField && formField._hasFloatingLabel() ? formField._labelId : null;
- }
- _getStartDateAccessibleName() {
- return this._startInput._getAccessibleName();
- }
- _getEndDateAccessibleName() {
- return this._endInput._getAccessibleName();
- }
- /** Updates the focused state of the range input. */
- _updateFocus(origin) {
- this.focused = origin !== null;
- this.stateChanges.next();
- }
- /** Re-runs the validators on the start/end inputs. */
- _revalidate() {
- if (this._startInput) {
- this._startInput._validatorOnChange();
- }
- if (this._endInput) {
- this._endInput._validatorOnChange();
- }
- }
- /** Registers the current date selection model with the start/end inputs. */
- _registerModel(model) {
- if (this._startInput) {
- this._startInput._registerModel(model);
- }
- if (this._endInput) {
- this._endInput._registerModel(model);
- }
- }
- /** Checks whether a specific range input directive is required. */
- _isTargetRequired(target) {
- return target?.ngControl?.control?.hasValidator(Validators.required);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateRangeInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.6", type: MatDateRangeInput, isStandalone: true, selector: "mat-date-range-input", inputs: { rangePicker: "rangePicker", required: ["required", "required", booleanAttribute], dateFilter: "dateFilter", min: "min", max: "max", disabled: ["disabled", "disabled", booleanAttribute], separator: "separator", comparisonStart: "comparisonStart", comparisonEnd: "comparisonEnd" }, host: { attributes: { "role": "group" }, properties: { "class.mat-date-range-input-hide-placeholders": "_shouldHidePlaceholders()", "class.mat-date-range-input-required": "required", "attr.id": "id", "attr.aria-labelledby": "_getAriaLabelledby()", "attr.aria-describedby": "_ariaDescribedBy", "attr.data-mat-calendar": "rangePicker ? rangePicker.id : null" }, classAttribute: "mat-date-range-input" }, providers: [{ provide: MatFormFieldControl, useExisting: MatDateRangeInput }], exportAs: ["matDateRangeInput"], usesOnChanges: true, ngImport: i0, template: "<div\n class=\"mat-date-range-input-container\"\n cdkMonitorSubtreeFocus\n (cdkFocusChange)=\"_updateFocus($event)\">\n <div class=\"mat-date-range-input-wrapper\">\n <ng-content select=\"input[matStartDate]\"></ng-content>\n <span\n class=\"mat-date-range-input-mirror\"\n aria-hidden=\"true\">{{_getInputMirrorValue('start')}}</span>\n </div>\n\n <span\n class=\"mat-date-range-input-separator\"\n [class.mat-date-range-input-separator-hidden]=\"_shouldHideSeparator()\">{{separator}}</span>\n\n <div class=\"mat-date-range-input-wrapper mat-date-range-input-end-wrapper\">\n <ng-content select=\"input[matEndDate]\"></ng-content>\n <span\n class=\"mat-date-range-input-mirror\"\n aria-hidden=\"true\">{{_getInputMirrorValue('end')}}</span>\n </div>\n</div>\n\n", styles: [".mat-date-range-input{display:block;width:100%}.mat-date-range-input-container{display:flex;align-items:center}.mat-date-range-input-separator{transition:opacity 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1);margin:0 4px;color:var(--mat-datepicker-range-input-separator-color, var(--mat-sys-on-surface))}.mat-form-field-disabled .mat-date-range-input-separator{color:var(--mat-datepicker-range-input-disabled-state-separator-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}._mat-animation-noopable .mat-date-range-input-separator{transition:none}.mat-date-range-input-separator-hidden{-webkit-user-select:none;user-select:none;opacity:0;transition:none}.mat-date-range-input-wrapper{position:relative;overflow:hidden;max-width:calc(50% - 4px)}.mat-date-range-input-end-wrapper{flex-grow:1}.mat-date-range-input-inner{position:absolute;top:0;left:0;font:inherit;background:rgba(0,0,0,0);color:currentColor;border:none;outline:none;padding:0;margin:0;vertical-align:bottom;text-align:inherit;-webkit-appearance:none;width:100%;height:100%}.mat-date-range-input-inner:-moz-ui-invalid{box-shadow:none}.mat-date-range-input-inner::placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner::-moz-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner::-webkit-input-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner:-ms-input-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner[disabled]{color:var(--mat-datepicker-range-input-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-form-field-hide-placeholder .mat-date-range-input-inner::placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner::placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::placeholder{opacity:0}}.mat-form-field-hide-placeholder .mat-date-range-input-inner::-moz-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-moz-placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner::-moz-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-moz-placeholder{opacity:0}}.mat-form-field-hide-placeholder .mat-date-range-input-inner::-webkit-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-webkit-input-placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner::-webkit-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-webkit-input-placeholder{opacity:0}}.mat-form-field-hide-placeholder .mat-date-range-input-inner:-ms-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner:-ms-input-placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner:-ms-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner:-ms-input-placeholder{opacity:0}}._mat-animation-noopable .mat-date-range-input-inner::placeholder{transition:none}._mat-animation-noopable .mat-date-range-input-inner::-moz-placeholder{transition:none}._mat-animation-noopable .mat-date-range-input-inner::-webkit-input-placeholder{transition:none}._mat-animation-noopable .mat-date-range-input-inner:-ms-input-placeholder{transition:none}.mat-date-range-input-mirror{-webkit-user-select:none;user-select:none;visibility:hidden;white-space:nowrap;display:inline-block;min-width:2px}.mat-mdc-form-field-type-mat-date-range-input .mat-mdc-form-field-infix{width:200px}\n"], dependencies: [{ kind: "directive", type: CdkMonitorFocus, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: ["cdkFocusChange"], exportAs: ["cdkMonitorFocus"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateRangeInput, decorators: [{
- type: Component,
- args: [{ selector: 'mat-date-range-input', exportAs: 'matDateRangeInput', host: {
- 'class': 'mat-date-range-input',
- '[class.mat-date-range-input-hide-placeholders]': '_shouldHidePlaceholders()',
- '[class.mat-date-range-input-required]': 'required',
- '[attr.id]': 'id',
- 'role': 'group',
- '[attr.aria-labelledby]': '_getAriaLabelledby()',
- '[attr.aria-describedby]': '_ariaDescribedBy',
- // Used by the test harness to tie this input to its calendar. We can't depend on
- // `aria-owns` for this, because it's only defined while the calendar is open.
- '[attr.data-mat-calendar]': 'rangePicker ? rangePicker.id : null',
- }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: MatFormFieldControl, useExisting: MatDateRangeInput }], imports: [CdkMonitorFocus], template: "<div\n class=\"mat-date-range-input-container\"\n cdkMonitorSubtreeFocus\n (cdkFocusChange)=\"_updateFocus($event)\">\n <div class=\"mat-date-range-input-wrapper\">\n <ng-content select=\"input[matStartDate]\"></ng-content>\n <span\n class=\"mat-date-range-input-mirror\"\n aria-hidden=\"true\">{{_getInputMirrorValue('start')}}</span>\n </div>\n\n <span\n class=\"mat-date-range-input-separator\"\n [class.mat-date-range-input-separator-hidden]=\"_shouldHideSeparator()\">{{separator}}</span>\n\n <div class=\"mat-date-range-input-wrapper mat-date-range-input-end-wrapper\">\n <ng-content select=\"input[matEndDate]\"></ng-content>\n <span\n class=\"mat-date-range-input-mirror\"\n aria-hidden=\"true\">{{_getInputMirrorValue('end')}}</span>\n </div>\n</div>\n\n", styles: [".mat-date-range-input{display:block;width:100%}.mat-date-range-input-container{display:flex;align-items:center}.mat-date-range-input-separator{transition:opacity 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1);margin:0 4px;color:var(--mat-datepicker-range-input-separator-color, var(--mat-sys-on-surface))}.mat-form-field-disabled .mat-date-range-input-separator{color:var(--mat-datepicker-range-input-disabled-state-separator-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}._mat-animation-noopable .mat-date-range-input-separator{transition:none}.mat-date-range-input-separator-hidden{-webkit-user-select:none;user-select:none;opacity:0;transition:none}.mat-date-range-input-wrapper{position:relative;overflow:hidden;max-width:calc(50% - 4px)}.mat-date-range-input-end-wrapper{flex-grow:1}.mat-date-range-input-inner{position:absolute;top:0;left:0;font:inherit;background:rgba(0,0,0,0);color:currentColor;border:none;outline:none;padding:0;margin:0;vertical-align:bottom;text-align:inherit;-webkit-appearance:none;width:100%;height:100%}.mat-date-range-input-inner:-moz-ui-invalid{box-shadow:none}.mat-date-range-input-inner::placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner::-moz-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner::-webkit-input-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner:-ms-input-placeholder{transition:color 400ms 133.3333333333ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-date-range-input-inner[disabled]{color:var(--mat-datepicker-range-input-disabled-state-text-color, color-mix(in srgb, var(--mat-sys-on-surface) 38%, transparent))}.mat-form-field-hide-placeholder .mat-date-range-input-inner::placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner::placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::placeholder{opacity:0}}.mat-form-field-hide-placeholder .mat-date-range-input-inner::-moz-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-moz-placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner::-moz-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-moz-placeholder{opacity:0}}.mat-form-field-hide-placeholder .mat-date-range-input-inner::-webkit-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-webkit-input-placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner::-webkit-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner::-webkit-input-placeholder{opacity:0}}.mat-form-field-hide-placeholder .mat-date-range-input-inner:-ms-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner:-ms-input-placeholder{-webkit-user-select:none;user-select:none;color:rgba(0,0,0,0) !important;-webkit-text-fill-color:rgba(0,0,0,0);transition:none}@media(forced-colors: active){.mat-form-field-hide-placeholder .mat-date-range-input-inner:-ms-input-placeholder,.mat-date-range-input-hide-placeholders .mat-date-range-input-inner:-ms-input-placeholder{opacity:0}}._mat-animation-noopable .mat-date-range-input-inner::placeholder{transition:none}._mat-animation-noopable .mat-date-range-input-inner::-moz-placeholder{transition:none}._mat-animation-noopable .mat-date-range-input-inner::-webkit-input-placeholder{transition:none}._mat-animation-noopable .mat-date-range-input-inner:-ms-input-placeholder{transition:none}.mat-date-range-input-mirror{-webkit-user-select:none;user-select:none;visibility:hidden;white-space:nowrap;display:inline-block;min-width:2px}.mat-mdc-form-field-type-mat-date-range-input .mat-mdc-form-field-infix{width:200px}\n"] }]
- }], ctorParameters: () => [], propDecorators: { rangePicker: [{
- type: Input
- }], required: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], dateFilter: [{
- type: Input
- }], min: [{
- type: Input
- }], max: [{
- type: Input
- }], disabled: [{
- type: Input,
- args: [{ transform: booleanAttribute }]
- }], separator: [{
- type: Input
- }], comparisonStart: [{
- type: Input
- }], comparisonEnd: [{
- type: Input
- }] } });
- // This file contains the `_computeAriaAccessibleName` function, which computes what the *expected*
- // ARIA accessible name would be for a given element. Implements a subset of ARIA specification
- // [Accessible Name and Description Computation 1.2](https://www.w3.org/TR/accname-1.2/).
- //
- // Specification accname-1.2 can be summarized by returning the result of the first method
- // available.
- //
- // 1. `aria-labelledby` attribute
- // ```
- // <!-- example using aria-labelledby-->
- // <label id='label-id'>Start Date</label>
- // <input aria-labelledby='label-id'/>
- // ```
- // 2. `aria-label` attribute (e.g. `<input aria-label="Departure"/>`)
- // 3. Label with `for`/`id`
- // ```
- // <!-- example using for/id -->
- // <label for="current-node">Label</label>
- // <input id="current-node"/>
- // ```
- // 4. `placeholder` attribute (e.g. `<input placeholder="06/03/1990"/>`)
- // 5. `title` attribute (e.g. `<input title="Check-In"/>`)
- // 6. text content
- // ```
- // <!-- example using text content -->
- // <label for="current-node"><span>Departure</span> Date</label>
- // <input id="current-node"/>
- // ```
- /**
- * Computes the *expected* ARIA accessible name for argument element based on [accname-1.2
- * specification](https://www.w3.org/TR/accname-1.2/). Implements a subset of accname-1.2,
- * and should only be used for the Datepicker's specific use case.
- *
- * Intended use:
- * This is not a general use implementation. Only implements the parts of accname-1.2 that are
- * required for the Datepicker's specific use case. This function is not intended for any other
- * use.
- *
- * Limitations:
- * - Only covers the needs of `matStartDate` and `matEndDate`. Does not support other use cases.
- * - See NOTES's in implementation for specific details on what parts of the accname-1.2
- * specification are not implemented.
- *
- * @param element {HTMLInputElement} native <input/> element of `matStartDate` or
- * `matEndDate` component. Corresponds to the 'Root Element' from accname-1.2
- *
- * @return expected ARIA accessible name of argument <input/>
- */
- function _computeAriaAccessibleName(element) {
- return _computeAriaAccessibleNameInternal(element, true);
- }
- /**
- * Determine if argument node is an Element based on `nodeType` property. This function is safe to
- * use with server-side rendering.
- */
- function ssrSafeIsElement(node) {
- return node.nodeType === Node.ELEMENT_NODE;
- }
- /**
- * Determine if argument node is an HTMLInputElement based on `nodeName` property. This funciton is
- * safe to use with server-side rendering.
- */
- function ssrSafeIsHTMLInputElement(node) {
- return node.nodeName === 'INPUT';
- }
- /**
- * Determine if argument node is an HTMLTextAreaElement based on `nodeName` property. This
- * funciton is safe to use with server-side rendering.
- */
- function ssrSafeIsHTMLTextAreaElement(node) {
- return node.nodeName === 'TEXTAREA';
- }
- /**
- * Calculate the expected ARIA accessible name for given DOM Node. Given DOM Node may be either the
- * "Root node" passed to `_computeAriaAccessibleName` or "Current node" as result of recursion.
- *
- * @return the accessible name of argument DOM Node
- *
- * @param currentNode node to determine accessible name of
- * @param isDirectlyReferenced true if `currentNode` is the root node to calculate ARIA accessible
- * name of. False if it is a result of recursion.
- */
- function _computeAriaAccessibleNameInternal(currentNode, isDirectlyReferenced) {
- // NOTE: this differs from accname-1.2 specification.
- // - Does not implement Step 1. of accname-1.2: '''If `currentNode`'s role prohibits naming,
- // return the empty string ("")'''.
- // - Does not implement Step 2.A. of accname-1.2: '''if current node is hidden and not directly
- // referenced by aria-labelledby... return the empty string.'''
- // acc-name-1.2 Step 2.B.: aria-labelledby
- if (ssrSafeIsElement(currentNode) && isDirectlyReferenced) {
- const labelledbyIds = currentNode.getAttribute?.('aria-labelledby')?.split(/\s+/g) || [];
- const validIdRefs = labelledbyIds.reduce((validIds, id) => {
- const elem = document.getElementById(id);
- if (elem) {
- validIds.push(elem);
- }
- return validIds;
- }, []);
- if (validIdRefs.length) {
- return validIdRefs
- .map(idRef => {
- return _computeAriaAccessibleNameInternal(idRef, false);
- })
- .join(' ');
- }
- }
- // acc-name-1.2 Step 2.C.: aria-label
- if (ssrSafeIsElement(currentNode)) {
- const ariaLabel = currentNode.getAttribute('aria-label')?.trim();
- if (ariaLabel) {
- return ariaLabel;
- }
- }
- // acc-name-1.2 Step 2.D. attribute or element that defines a text alternative
- //
- // NOTE: this differs from accname-1.2 specification.
- // Only implements Step 2.D. for `<label>`,`<input/>`, and `<textarea/>` element. Does not
- // implement other elements that have an attribute or element that defines a text alternative.
- if (ssrSafeIsHTMLInputElement(currentNode) || ssrSafeIsHTMLTextAreaElement(currentNode)) {
- // use label with a `for` attribute referencing the current node
- if (currentNode.labels?.length) {
- return Array.from(currentNode.labels)
- .map(x => _computeAriaAccessibleNameInternal(x, false))
- .join(' ');
- }
- // use placeholder if available
- const placeholder = currentNode.getAttribute('placeholder')?.trim();
- if (placeholder) {
- return placeholder;
- }
- // use title if available
- const title = currentNode.getAttribute('title')?.trim();
- if (title) {
- return title;
- }
- }
- // NOTE: this differs from accname-1.2 specification.
- // - does not implement acc-name-1.2 Step 2.E.: '''if the current node is a control embedded
- // within the label... then include the embedded control as part of the text alternative in
- // the following manner...'''. Step 2E applies to embedded controls such as textbox, listbox,
- // range, etc.
- // - does not implement acc-name-1.2 step 2.F.: check that '''role allows name from content''',
- // which applies to `currentNode` and its children.
- // - does not implement acc-name-1.2 Step 2.F.ii.: '''Check for CSS generated textual content'''
- // (e.g. :before and :after).
- // - does not implement acc-name-1.2 Step 2.I.: '''if the current node has a Tooltip attribute,
- // return its value'''
- // Return text content with whitespace collapsed into a single space character. Accomplish
- // acc-name-1.2 steps 2F, 2G, and 2H.
- return (currentNode.textContent || '').replace(/\s+/g, ' ').trim();
- }
- /**
- * Base class for the individual inputs that can be projected inside a `mat-date-range-input`.
- */
- class MatDateRangeInputPartBase extends MatDatepickerInputBase {
- _rangeInput = inject(MatDateRangeInput);
- _elementRef = inject(ElementRef);
- _defaultErrorStateMatcher = inject(ErrorStateMatcher);
- _injector = inject(Injector);
- _parentForm = inject(NgForm, { optional: true });
- _parentFormGroup = inject(FormGroupDirective, { optional: true });
- /**
- * Form control bound to this input part.
- * @docs-private
- */
- ngControl;
- _dir = inject(Directionality, { optional: true });
- _errorStateTracker;
- /** Object used to control when error messages are shown. */
- get errorStateMatcher() {
- return this._errorStateTracker.matcher;
- }
- set errorStateMatcher(value) {
- this._errorStateTracker.matcher = value;
- }
- /** Whether the input is in an error state. */
- get errorState() {
- return this._errorStateTracker.errorState;
- }
- set errorState(value) {
- this._errorStateTracker.errorState = value;
- }
- constructor() {
- super();
- this._errorStateTracker = new _ErrorStateTracker(this._defaultErrorStateMatcher, null, this._parentFormGroup, this._parentForm, this.stateChanges);
- }
- ngOnInit() {
- // We need the date input to provide itself as a `ControlValueAccessor` and a `Validator`, while
- // injecting its `NgControl` so that the error state is handled correctly. This introduces a
- // circular dependency, because both `ControlValueAccessor` and `Validator` depend on the input
- // itself. Usually we can work around it for the CVA, but there's no API to do it for the
- // validator. We work around it here by injecting the `NgControl` in `ngOnInit`, after
- // everything has been resolved.
- const ngControl = this._injector.get(NgControl, null, { optional: true, self: true });
- if (ngControl) {
- this.ngControl = ngControl;
- this._errorStateTracker.ngControl = ngControl;
- }
- }
- ngAfterContentInit() {
- this._register();
- }
- ngDoCheck() {
- if (this.ngControl) {
- // We need to re-evaluate this on every change detection cycle, because there are some
- // error triggers that we can't subscribe to (e.g. parent form submissions). This means
- // that whatever logic is in here has to be super lean or we risk destroying the performance.
- this.updateErrorState();
- }
- }
- /** Gets whether the input is empty. */
- isEmpty() {
- return this._elementRef.nativeElement.value.length === 0;
- }
- /** Gets the placeholder of the input. */
- _getPlaceholder() {
- return this._elementRef.nativeElement.placeholder;
- }
- /** Focuses the input. */
- focus() {
- this._elementRef.nativeElement.focus();
- }
- /** Gets the value that should be used when mirroring the input's size. */
- getMirrorValue() {
- const element = this._elementRef.nativeElement;
- const value = element.value;
- return value.length > 0 ? value : element.placeholder;
- }
- /** Refreshes the error state of the input. */
- updateErrorState() {
- this._errorStateTracker.updateErrorState();
- }
- /** Handles `input` events on the input element. */
- _onInput(value) {
- super._onInput(value);
- this._rangeInput._handleChildValueChange();
- }
- /** Opens the datepicker associated with the input. */
- _openPopup() {
- this._rangeInput._openDatepicker();
- }
- /** Gets the minimum date from the range input. */
- _getMinDate() {
- return this._rangeInput.min;
- }
- /** Gets the maximum date from the range input. */
- _getMaxDate() {
- return this._rangeInput.max;
- }
- /** Gets the date filter function from the range input. */
- _getDateFilter() {
- return this._rangeInput.dateFilter;
- }
- _parentDisabled() {
- return this._rangeInput._groupDisabled;
- }
- _shouldHandleChangeEvent({ source }) {
- return source !== this._rangeInput._startInput && source !== this._rangeInput._endInput;
- }
- _assignValueProgrammatically(value) {
- super._assignValueProgrammatically(value);
- const opposite = (this === this._rangeInput._startInput
- ? this._rangeInput._endInput
- : this._rangeInput._startInput);
- opposite?._validatorOnChange();
- }
- _formatValue(value) {
- super._formatValue(value);
- // Any time the input value is reformatted we need to tell the parent.
- this._rangeInput._handleChildValueChange();
- }
- /** return the ARIA accessible name of the input element */
- _getAccessibleName() {
- return _computeAriaAccessibleName(this._elementRef.nativeElement);
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateRangeInputPartBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatDateRangeInputPartBase, isStandalone: true, inputs: { errorStateMatcher: "errorStateMatcher" }, usesInheritance: true, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateRangeInputPartBase, decorators: [{
- type: Directive
- }], ctorParameters: () => [], propDecorators: { errorStateMatcher: [{
- type: Input
- }] } });
- /** Input for entering the start date in a `mat-date-range-input`. */
- class MatStartDate extends MatDateRangeInputPartBase {
- /** Validator that checks that the start date isn't after the end date. */
- _startValidator = (control) => {
- const start = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
- const end = this._model ? this._model.selection.end : null;
- return !start || !end || this._dateAdapter.compareDate(start, end) <= 0
- ? null
- : { 'matStartDateInvalid': { 'end': end, 'actual': start } };
- };
- _validator = Validators.compose([...super._getValidators(), this._startValidator]);
- _register() {
- this._rangeInput._startInput = this;
- }
- _getValueFromModel(modelValue) {
- return modelValue.start;
- }
- _shouldHandleChangeEvent(change) {
- if (!super._shouldHandleChangeEvent(change)) {
- return false;
- }
- else {
- return !change.oldValue?.start
- ? !!change.selection.start
- : !change.selection.start ||
- !!this._dateAdapter.compareDate(change.oldValue.start, change.selection.start);
- }
- }
- _assignValueToModel(value) {
- if (this._model) {
- const range = new DateRange(value, this._model.selection.end);
- this._model.updateSelection(range, this);
- this._rangeInput._handleChildValueChange();
- }
- }
- _onKeydown(event) {
- const endInput = this._rangeInput._endInput;
- const element = this._elementRef.nativeElement;
- const isLtr = this._dir?.value !== 'rtl';
- // If the user hits RIGHT (LTR) when at the end of the input (and no
- // selection), move the cursor to the start of the end input.
- if (((event.keyCode === RIGHT_ARROW && isLtr) || (event.keyCode === LEFT_ARROW && !isLtr)) &&
- element.selectionStart === element.value.length &&
- element.selectionEnd === element.value.length) {
- event.preventDefault();
- endInput._elementRef.nativeElement.setSelectionRange(0, 0);
- endInput.focus();
- }
- else {
- super._onKeydown(event);
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatStartDate, deps: null, target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatStartDate, isStandalone: true, selector: "input[matStartDate]", outputs: { dateChange: "dateChange", dateInput: "dateInput" }, host: { attributes: { "type": "text" }, listeners: { "input": "_onInput($event.target.value)", "change": "_onChange()", "keydown": "_onKeydown($event)", "blur": "_onBlur()" }, properties: { "disabled": "disabled", "attr.aria-haspopup": "_rangeInput.rangePicker ? \"dialog\" : null", "attr.aria-owns": "_rangeInput._ariaOwns\n ? _rangeInput._ariaOwns()\n : (_rangeInput.rangePicker?.opened && _rangeInput.rangePicker.id) || null", "attr.min": "_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()) : null", "attr.max": "_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()) : null" }, classAttribute: "mat-start-date mat-date-range-input-inner" }, providers: [
- { provide: NG_VALUE_ACCESSOR, useExisting: MatStartDate, multi: true },
- { provide: NG_VALIDATORS, useExisting: MatStartDate, multi: true },
- ], usesInheritance: true, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatStartDate, decorators: [{
- type: Directive,
- args: [{
- selector: 'input[matStartDate]',
- host: {
- 'class': 'mat-start-date mat-date-range-input-inner',
- '[disabled]': 'disabled',
- '(input)': '_onInput($event.target.value)',
- '(change)': '_onChange()',
- '(keydown)': '_onKeydown($event)',
- '[attr.aria-haspopup]': '_rangeInput.rangePicker ? "dialog" : null',
- '[attr.aria-owns]': `_rangeInput._ariaOwns
- ? _rangeInput._ariaOwns()
- : (_rangeInput.rangePicker?.opened && _rangeInput.rangePicker.id) || null`,
- '[attr.min]': '_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()) : null',
- '[attr.max]': '_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()) : null',
- '(blur)': '_onBlur()',
- 'type': 'text',
- },
- providers: [
- { provide: NG_VALUE_ACCESSOR, useExisting: MatStartDate, multi: true },
- { provide: NG_VALIDATORS, useExisting: MatStartDate, multi: true },
- ],
- // These need to be specified explicitly, because some tooling doesn't
- // seem to pick them up from the base class. See #20932.
- outputs: ['dateChange', 'dateInput'],
- }]
- }] });
- /** Input for entering the end date in a `mat-date-range-input`. */
- class MatEndDate extends MatDateRangeInputPartBase {
- /** Validator that checks that the end date isn't before the start date. */
- _endValidator = (control) => {
- const end = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(control.value));
- const start = this._model ? this._model.selection.start : null;
- return !end || !start || this._dateAdapter.compareDate(end, start) >= 0
- ? null
- : { 'matEndDateInvalid': { 'start': start, 'actual': end } };
- };
- _register() {
- this._rangeInput._endInput = this;
- }
- _validator = Validators.compose([...super._getValidators(), this._endValidator]);
- _getValueFromModel(modelValue) {
- return modelValue.end;
- }
- _shouldHandleChangeEvent(change) {
- if (!super._shouldHandleChangeEvent(change)) {
- return false;
- }
- else {
- return !change.oldValue?.end
- ? !!change.selection.end
- : !change.selection.end ||
- !!this._dateAdapter.compareDate(change.oldValue.end, change.selection.end);
- }
- }
- _assignValueToModel(value) {
- if (this._model) {
- const range = new DateRange(this._model.selection.start, value);
- this._model.updateSelection(range, this);
- }
- }
- _moveCaretToEndOfStartInput() {
- const startInput = this._rangeInput._startInput._elementRef.nativeElement;
- const value = startInput.value;
- if (value.length > 0) {
- startInput.setSelectionRange(value.length, value.length);
- }
- startInput.focus();
- }
- _onKeydown(event) {
- const element = this._elementRef.nativeElement;
- const isLtr = this._dir?.value !== 'rtl';
- // If the user is pressing backspace on an empty end input, move focus back to the start.
- if (event.keyCode === BACKSPACE && !element.value) {
- this._moveCaretToEndOfStartInput();
- }
- // If the user hits LEFT (LTR) when at the start of the input (and no
- // selection), move the cursor to the end of the start input.
- else if (((event.keyCode === LEFT_ARROW && isLtr) || (event.keyCode === RIGHT_ARROW && !isLtr)) &&
- element.selectionStart === 0 &&
- element.selectionEnd === 0) {
- event.preventDefault();
- this._moveCaretToEndOfStartInput();
- }
- else {
- super._onKeydown(event);
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatEndDate, deps: null, target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatEndDate, isStandalone: true, selector: "input[matEndDate]", outputs: { dateChange: "dateChange", dateInput: "dateInput" }, host: { attributes: { "type": "text" }, listeners: { "input": "_onInput($event.target.value)", "change": "_onChange()", "keydown": "_onKeydown($event)", "blur": "_onBlur()" }, properties: { "disabled": "disabled", "attr.aria-haspopup": "_rangeInput.rangePicker ? \"dialog\" : null", "attr.aria-owns": "_rangeInput._ariaOwns\n ? _rangeInput._ariaOwns()\n : (_rangeInput.rangePicker?.opened && _rangeInput.rangePicker.id) || null", "attr.min": "_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()) : null", "attr.max": "_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()) : null" }, classAttribute: "mat-end-date mat-date-range-input-inner" }, providers: [
- { provide: NG_VALUE_ACCESSOR, useExisting: MatEndDate, multi: true },
- { provide: NG_VALIDATORS, useExisting: MatEndDate, multi: true },
- ], usesInheritance: true, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatEndDate, decorators: [{
- type: Directive,
- args: [{
- selector: 'input[matEndDate]',
- host: {
- 'class': 'mat-end-date mat-date-range-input-inner',
- '[disabled]': 'disabled',
- '(input)': '_onInput($event.target.value)',
- '(change)': '_onChange()',
- '(keydown)': '_onKeydown($event)',
- '[attr.aria-haspopup]': '_rangeInput.rangePicker ? "dialog" : null',
- '[attr.aria-owns]': `_rangeInput._ariaOwns
- ? _rangeInput._ariaOwns()
- : (_rangeInput.rangePicker?.opened && _rangeInput.rangePicker.id) || null`,
- '[attr.min]': '_getMinDate() ? _dateAdapter.toIso8601(_getMinDate()) : null',
- '[attr.max]': '_getMaxDate() ? _dateAdapter.toIso8601(_getMaxDate()) : null',
- '(blur)': '_onBlur()',
- 'type': 'text',
- },
- providers: [
- { provide: NG_VALUE_ACCESSOR, useExisting: MatEndDate, multi: true },
- { provide: NG_VALIDATORS, useExisting: MatEndDate, multi: true },
- ],
- // These need to be specified explicitly, because some tooling doesn't
- // seem to pick them up from the base class. See #20932.
- outputs: ['dateChange', 'dateInput'],
- }]
- }] });
- // TODO(mmalerba): We use a component instead of a directive here so the user can use implicit
- // template reference variables (e.g. #d vs #d="matDateRangePicker"). We can change this to a
- // directive if angular adds support for `exportAs: '$implicit'` on directives.
- /** Component responsible for managing the date range picker popup/dialog. */
- class MatDateRangePicker extends MatDatepickerBase {
- _forwardContentValues(instance) {
- super._forwardContentValues(instance);
- const input = this.datepickerInput;
- if (input) {
- instance.comparisonStart = input.comparisonStart;
- instance.comparisonEnd = input.comparisonEnd;
- instance.startDateAccessibleName = input._getStartDateAccessibleName();
- instance.endDateAccessibleName = input._getEndDateAccessibleName();
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateRangePicker, deps: null, target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatDateRangePicker, isStandalone: true, selector: "mat-date-range-picker", providers: [
- MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER,
- MAT_CALENDAR_RANGE_STRATEGY_PROVIDER,
- { provide: MatDatepickerBase, useExisting: MatDateRangePicker },
- ], exportAs: ["matDateRangePicker"], usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDateRangePicker, decorators: [{
- type: Component,
- args: [{
- selector: 'mat-date-range-picker',
- template: '',
- exportAs: 'matDateRangePicker',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- providers: [
- MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER,
- MAT_CALENDAR_RANGE_STRATEGY_PROVIDER,
- { provide: MatDatepickerBase, useExisting: MatDateRangePicker },
- ],
- }]
- }] });
- /** Button that will close the datepicker and assign the current selection to the data model. */
- class MatDatepickerApply {
- _datepicker = inject(MatDatepickerBase);
- constructor() { }
- _applySelection() {
- this._datepicker._applyPendingSelection();
- this._datepicker.close();
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerApply, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepickerApply, isStandalone: true, selector: "[matDatepickerApply], [matDateRangePickerApply]", host: { listeners: { "click": "_applySelection()" } }, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerApply, decorators: [{
- type: Directive,
- args: [{
- selector: '[matDatepickerApply], [matDateRangePickerApply]',
- host: { '(click)': '_applySelection()' },
- }]
- }], ctorParameters: () => [] });
- /** Button that will close the datepicker and discard the current selection. */
- class MatDatepickerCancel {
- _datepicker = inject(MatDatepickerBase);
- constructor() { }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerCancel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepickerCancel, isStandalone: true, selector: "[matDatepickerCancel], [matDateRangePickerCancel]", host: { listeners: { "click": "_datepicker.close()" } }, ngImport: i0 });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerCancel, decorators: [{
- type: Directive,
- args: [{
- selector: '[matDatepickerCancel], [matDateRangePickerCancel]',
- host: { '(click)': '_datepicker.close()' },
- }]
- }], ctorParameters: () => [] });
- /**
- * Container that can be used to project a row of action buttons
- * to the bottom of a datepicker or date range picker.
- */
- class MatDatepickerActions {
- _datepicker = inject(MatDatepickerBase);
- _viewContainerRef = inject(ViewContainerRef);
- _template;
- _portal;
- constructor() { }
- ngAfterViewInit() {
- this._portal = new TemplatePortal(this._template, this._viewContainerRef);
- this._datepicker.registerActions(this._portal);
- }
- ngOnDestroy() {
- this._datepicker.removeActions(this._portal);
- // Needs to be null checked since we initialize it in `ngAfterViewInit`.
- if (this._portal && this._portal.isAttached) {
- this._portal?.detach();
- }
- }
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerActions, deps: [], target: i0.ɵɵFactoryTarget.Component });
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.6", type: MatDatepickerActions, isStandalone: true, selector: "mat-datepicker-actions, mat-date-range-picker-actions", viewQueries: [{ propertyName: "_template", first: true, predicate: TemplateRef, descendants: true }], ngImport: i0, template: `
- <ng-template>
- <div class="mat-datepicker-actions">
- <ng-content></ng-content>
- </div>
- </ng-template>
- `, isInline: true, styles: [".mat-datepicker-actions{display:flex;justify-content:flex-end;align-items:center;padding:0 8px 8px 8px}.mat-datepicker-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:8px}[dir=rtl] .mat-datepicker-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:0;margin-right:8px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerActions, decorators: [{
- type: Component,
- args: [{ selector: 'mat-datepicker-actions, mat-date-range-picker-actions', template: `
- <ng-template>
- <div class="mat-datepicker-actions">
- <ng-content></ng-content>
- </div>
- </ng-template>
- `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [".mat-datepicker-actions{display:flex;justify-content:flex-end;align-items:center;padding:0 8px 8px 8px}.mat-datepicker-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:8px}[dir=rtl] .mat-datepicker-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:0;margin-right:8px}\n"] }]
- }], ctorParameters: () => [], propDecorators: { _template: [{
- type: ViewChild,
- args: [TemplateRef]
- }] } });
- class MatDatepickerModule {
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerModule, imports: [MatButtonModule,
- OverlayModule,
- A11yModule,
- PortalModule,
- MatCommonModule,
- MatCalendar,
- MatCalendarBody,
- MatDatepicker,
- MatDatepickerContent,
- MatDatepickerInput,
- MatDatepickerToggle,
- MatDatepickerToggleIcon,
- MatMonthView,
- MatYearView,
- MatMultiYearView,
- MatCalendarHeader,
- MatDateRangeInput,
- MatStartDate,
- MatEndDate,
- MatDateRangePicker,
- MatDatepickerActions,
- MatDatepickerCancel,
- MatDatepickerApply], exports: [CdkScrollableModule,
- MatCalendar,
- MatCalendarBody,
- MatDatepicker,
- MatDatepickerContent,
- MatDatepickerInput,
- MatDatepickerToggle,
- MatDatepickerToggleIcon,
- MatMonthView,
- MatYearView,
- MatMultiYearView,
- MatCalendarHeader,
- MatDateRangeInput,
- MatStartDate,
- MatEndDate,
- MatDateRangePicker,
- MatDatepickerActions,
- MatDatepickerCancel,
- MatDatepickerApply] });
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerModule, providers: [MatDatepickerIntl, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER], imports: [MatButtonModule,
- OverlayModule,
- A11yModule,
- PortalModule,
- MatCommonModule,
- MatDatepickerContent,
- MatDatepickerToggle,
- MatCalendarHeader, CdkScrollableModule] });
- }
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatDatepickerModule, decorators: [{
- type: NgModule,
- args: [{
- imports: [
- MatButtonModule,
- OverlayModule,
- A11yModule,
- PortalModule,
- MatCommonModule,
- MatCalendar,
- MatCalendarBody,
- MatDatepicker,
- MatDatepickerContent,
- MatDatepickerInput,
- MatDatepickerToggle,
- MatDatepickerToggleIcon,
- MatMonthView,
- MatYearView,
- MatMultiYearView,
- MatCalendarHeader,
- MatDateRangeInput,
- MatStartDate,
- MatEndDate,
- MatDateRangePicker,
- MatDatepickerActions,
- MatDatepickerCancel,
- MatDatepickerApply,
- ],
- exports: [
- CdkScrollableModule,
- MatCalendar,
- MatCalendarBody,
- MatDatepicker,
- MatDatepickerContent,
- MatDatepickerInput,
- MatDatepickerToggle,
- MatDatepickerToggleIcon,
- MatMonthView,
- MatYearView,
- MatMultiYearView,
- MatCalendarHeader,
- MatDateRangeInput,
- MatStartDate,
- MatEndDate,
- MatDateRangePicker,
- MatDatepickerActions,
- MatDatepickerCancel,
- MatDatepickerApply,
- ],
- providers: [MatDatepickerIntl, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER],
- }]
- }] });
- /**
- * Animations used by the Material datepicker.
- * @docs-private
- * @deprecated No longer used, will be removed.
- * @breaking-change 21.0.0
- */
- const matDatepickerAnimations = {
- // Represents:
- // trigger('transformPanel', [
- // transition(
- // 'void => enter-dropdown',
- // animate(
- // '120ms cubic-bezier(0, 0, 0.2, 1)',
- // keyframes([
- // style({opacity: 0, transform: 'scale(1, 0.8)'}),
- // style({opacity: 1, transform: 'scale(1, 1)'}),
- // ]),
- // ),
- // ),
- // transition(
- // 'void => enter-dialog',
- // animate(
- // '150ms cubic-bezier(0, 0, 0.2, 1)',
- // keyframes([
- // style({opacity: 0, transform: 'scale(0.7)'}),
- // style({transform: 'none', opacity: 1}),
- // ]),
- // ),
- // ),
- // transition('* => void', animate('100ms linear', style({opacity: 0}))),
- // ])
- /** Transforms the height of the datepicker's calendar. */
- transformPanel: {
- type: 7,
- name: 'transformPanel',
- definitions: [
- {
- type: 1,
- expr: 'void => enter-dropdown',
- animation: {
- type: 4,
- styles: {
- type: 5,
- steps: [
- { type: 6, styles: { opacity: 0, transform: 'scale(1, 0.8)' }, offset: null },
- { type: 6, styles: { opacity: 1, transform: 'scale(1, 1)' }, offset: null },
- ],
- },
- timings: '120ms cubic-bezier(0, 0, 0.2, 1)',
- },
- options: null,
- },
- {
- type: 1,
- expr: 'void => enter-dialog',
- animation: {
- type: 4,
- styles: {
- type: 5,
- steps: [
- { type: 6, styles: { opacity: 0, transform: 'scale(0.7)' }, offset: null },
- { type: 6, styles: { transform: 'none', opacity: 1 }, offset: null },
- ],
- },
- timings: '150ms cubic-bezier(0, 0, 0.2, 1)',
- },
- options: null,
- },
- {
- type: 1,
- expr: '* => void',
- animation: {
- type: 4,
- styles: { type: 6, styles: { opacity: 0 }, offset: null },
- timings: '100ms linear',
- },
- options: null,
- },
- ],
- options: {},
- },
- // Represents:
- // trigger('fadeInCalendar', [
- // state('void', style({opacity: 0})),
- // state('enter', style({opacity: 1})),
- // // TODO(crisbeto): this animation should be removed since it isn't quite on spec, but we
- // // need to keep it until #12440 gets in, otherwise the exit animation will look glitchy.
- // transition('void => *', animate('120ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)')),
- // ])
- /** Fades in the content of the calendar. */
- fadeInCalendar: {
- type: 7,
- name: 'fadeInCalendar',
- definitions: [
- { type: 0, name: 'void', styles: { type: 6, styles: { opacity: 0 }, offset: null } },
- { type: 0, name: 'enter', styles: { type: 6, styles: { opacity: 1 }, offset: null } },
- {
- type: 1,
- expr: 'void => *',
- animation: {
- type: 4,
- styles: null,
- timings: '120ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)',
- },
- options: null,
- },
- ],
- options: {},
- },
- };
- export { DateRange, DefaultMatCalendarRangeStrategy, MAT_DATEPICKER_SCROLL_STRATEGY, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER, MAT_DATEPICKER_VALIDATORS, MAT_DATEPICKER_VALUE_ACCESSOR, MAT_DATE_RANGE_SELECTION_STRATEGY, MAT_RANGE_DATE_SELECTION_MODEL_FACTORY, MAT_RANGE_DATE_SELECTION_MODEL_PROVIDER, MAT_SINGLE_DATE_SELECTION_MODEL_FACTORY, MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER, MatCalendar, MatCalendarBody, MatCalendarCell, MatCalendarHeader, MatDateRangeInput, MatDateRangePicker, MatDateSelectionModel, MatDatepicker, MatDatepickerActions, MatDatepickerApply, MatDatepickerCancel, MatDatepickerContent, MatDatepickerInput, MatDatepickerInputEvent, MatDatepickerIntl, MatDatepickerModule, MatDatepickerToggle, MatDatepickerToggleIcon, MatEndDate, MatMonthView, MatMultiYearView, MatRangeDateSelectionModel, MatSingleDateSelectionModel, MatStartDate, MatYearView, matDatepickerAnimations, yearsPerPage, yearsPerRow };
- //# sourceMappingURL=datepicker.mjs.map
|