UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 14.8 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.calendar.min.js`),require(`kendo.popup.min.js`),require(`kendo.dateinput.min.js`),require(`kendo.html.button.min.js`),require(`kendo.label.min.js`),require(`kendo.actionsheet.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.calendar.min`,`kendo.popup.min`,`kendo.dateinput.min`,`kendo.html.button.min`,`kendo.label.min`,`kendo.actionsheet.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Datepicker={}),e.kendo._globals.Calendar,e.kendo._globals.Popup,e.kendo._globals.Dateinput,e.kendo._globals.HtmlButton,e.kendo._globals.Label,e.kendo._globals.Actionsheet))})(this,function(e,t,n,r,i,a,o){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let s={id:`datepicker`,name:`DatePicker`,category:`web`,description:`The DatePicker widget allows the user to select a date from a calendar or by direct input.`,depends:[`calendar`,`popup`,`html.button`,`label`,`actionsheet`]};(function(e,t){var n=window.kendo,r=n.ui,i=n.html,a=n.mediaQuery,o=r.Widget,s=n.parseDate,c=n.keys,l=n.support,u=n.template,d=n._activeElement,f=`<div />`,p=`<span />`,m=`.kendoDatePicker`,h=`click`+m,g=l.mouseAndTouchPresent?n.applyEventMap(`up`,m.slice(1)):h,_=`open`,v=`close`,y=`change`,b=`disabled`,x=`readonly`,S=`k-focus`,C=`k-selected`,w=`k-disabled`,T=`k-hover`,E=`mouseenter`+m+` mouseleave`+m,D=`mousedown`+m,O=`navigate`,k=`id`,A=`min`,j=`max`,M=`month`,N=`aria-disabled`,P=`aria-readonly`,F=`aria-expanded`,I=`aria-hidden`,L=`aria-activedescendant`,R=n.calendar,z=R.isInRange,B=R.restrictValue,V=R.isEqualDatePart,H=e.extend,U=Date;function W(t){var n=t.parseFormats,r=t.format;R.normalize(t),n=Array.isArray(n)?n:[n],n.length||n.push(`yyyy-MM-dd`),e.inArray(r,n)===-1&&n.splice(0,0,t.format),t.parseFormats=n}function G(e){e.preventDefault()}var K=function(t){var i=this,o,s=document.body,c=e(f).attr(I,`true`).addClass(`k-calendar-container`);i.options=t||={},o=t.id;let l=t._buttons;i.bigScreenMQL=a(`large`),i.smallScreenMQL=a(`small`),t.adaptiveMode==`auto`&&i.smallScreenMQL.onChange(function(){i.popup&&n.isFunction(i.popup.fullscreen)&&i.popup.fullscreen(i.smallScreenMQL.mediaQueryList.matches)}),t.omitPopup?c=t.dateDiv:(c.appendTo(s),t.adaptiveMode==`auto`&&!i.bigScreenMQL.mediaQueryList.matches?i.popup=new r.ActionSheet(c,{adaptive:!0,title:t.adaptiveTitle||`Set dates`,subtitle:t.adaptiveSubtitle,closeButton:{icon:`check`,themeColor:`primary`},actionButtons:l,focusOnActivate:!1,fullscreen:i.smallScreenMQL.mediaQueryList.matches,open:t.open,close:t.close,popup:H(t.popup,t,{name:`Popup`,isRtl:n.support.isRtl(t.anchor)})}):i.popup=new r.Popup(c,H(t.popup,t,{name:`Popup`,isRtl:n.support.isRtl(t.anchor)}))),o&&(o+=`_dateview`,c.attr(k,o),i._dateViewID=o),i.div=c,i.value(t.value)};K.prototype={_calendar:function(){var t=this,i=t.calendar,a=t.options,o;if(!i){var s=a.adaptiveMode!=`auto`||this.bigScreenMQL.mediaQueryList.matches?this.options.size:`large`;o=e(f).attr(k,n.guid()).appendTo(a.omitPopup?a.dateDiv:t.popup._content||t.popup.element).on(D,G).on(h,`td:has(.k-link)`,t._click.bind(t)),t.calendar=i=new r.Calendar(o,{componentType:a.componentType,size:s,messages:a.messages}),t._setOptions(a),o.addClass(n.getValidCssClass(`k-calendar-`,`size`,s)),i.navigate(t._value||t._current,a.start),t.value(t._value)}},_setOptions:function(e){this.calendar.setOptions({focusOnNav:!1,componentType:e.componentType,change:e.change,culture:e.culture,dates:e.dates,depth:e.depth,footer:e.footer,format:e.format,max:e.max,min:e.min,month:e.month,weekNumber:e.weekNumber,start:e.start,messages:e.messages,disableDates:e.disableDates})},setOptions:function(e){var t=this,n=t.options,r=e.disableDates;r&&(e.disableDates=R.disabled(r)),t.options=H(n,e,{change:n.change,close:n.close,open:n.open}),t.calendar&&t._setOptions(t.options)},destroy:function(){var e=this;this.popup&&this.popup.destroy(),e.bigScreenMQL&&=(e.bigScreenMQL.destroy(),null),e.smallScreenMQL&&=(e.smallScreenMQL.destroy(),null)},open:function(){var e=this,t;e._calendar(),t=e.popup._hovered,e.popup._hovered=!0,e.popup.open(),setTimeout(function(){e.popup._hovered=t},1)},close:function(){this.popup&&this.popup.close()},min:function(e){this._option(A,e)},max:function(e){this._option(j,e)},toggle:function(){var e=this;e[e.popup.visible()?v:_]()},move:function(e){var t=this,n=e.keyCode,r=t.calendar,i=e.ctrlKey&&n==c.DOWN||n==c.ENTER,a=!1;if(e.altKey)n==c.DOWN?(t.open(),e.preventDefault(),a=!0):n==c.UP&&(t.close(),e.preventDefault(),a=!0);else if(t.popup&&t.popup.visible()){if(n==c.ESC||i&&r._cell.hasClass(C))return t.close(),e.preventDefault(),!0;n!=c.SPACEBAR&&(t._current=r._move(e)),a=!0}return a},current:function(e){this._current=e,this.calendar&&this.calendar._focus(e)},value:function(e){var t=this,n=t.calendar,r=t.options,i=r.disableDates;i&&i(e)&&(e=null),t._value=e,t._current=new U(+B(e,r.min,r.max)),n&&n.value(e)},_click:function(e){e.currentTarget.className.indexOf(C)!==-1&&(this.calendar.trigger(`change`),this.close())},_option:function(e,t){var n=this,r=n.calendar;n.options[e]=t,r&&r[e](t)}},K.normalize=W,n.DateView=K;var q=o.extend({init:function(r,i){var c=this,l,u;o.fn.init.call(c,r,i),r=c.element,i=c.options,i.disableDates=n.calendar.disabled(i.disableDates),i.min=s(r.attr(`min`))||s(i.min),i.max=s(r.attr(`max`))||s(i.max),c.options.readonly=i.readonly===t?!!c.element.attr(`readonly`):i.readonly,c.options.enable=i.enable===t?!(r.is(`[disabled]`)||e(r).parents(`fieldset`).is(`:disabled`)):i.enable,c.options.inputMode=i.inputMode||c.element.attr(`inputmode`)||`text`,c.element.attr(`inputmode`,c.options.inputMode),W(i),c._initialOptions=H({},i),c._wrapper(),c._createDateView(),c._createDateViewProxy=c._createDateView.bind(c),c.bigScreenMQL=a(`large`),c.options.adaptiveMode==`auto`&&c.bigScreenMQL.onChange(()=>{c._createDateViewProxy(),c.dateView.value(c._value)}),c._icon();try{r[0].setAttribute(`type`,`text`)}catch{r[0].type=`text`}r.addClass(`k-input-inner`).attr({role:`combobox`,"aria-expanded":!1,"aria-haspopup":`grid`,"aria-controls":c.dateView._dateViewID,autocomplete:`off`}),c._reset(),c._template(),u=!c.options.enable,u?c.enable(!1):c.readonly(r.is(`[readonly]`)),l=s(i.value||c.element.val(),i.parseFormats,i.culture),c._createDateInput(i),c._old=c._update(l||c.element.val()),c._oldText=r.val(),c._applyCssClasses(),i.label&&c._label(),c.element.removeAttr(`style`),n.notify(c)},events:[_,v,y],options:{name:`DatePicker`,autoAdjust:!0,value:null,footer:``,format:``,culture:``,parseFormats:[],min:new Date(1900,0,1),max:new Date(2099,11,31),start:M,depth:M,animation:{},month:{},dates:[],disableDates:null,ARIATemplate:({valueType:e,text:t})=>`Current focused ${e} is ${t}`,dateInput:!1,weekNumber:!1,messages:{weekColumnHeader:``},componentType:`classic`,adaptiveMode:`none`,size:t,fillMode:t,rounded:t,label:null,autoFill:!1,autoCorrectParts:!0,adaptiveTitle:null,adaptiveSubtitle:null},_createDateView:function(){var e=this,t=e.options,n=e.element,r;e.dateView&&=(e.dateView.popup&&e.dateView.popup.wrapper&&e.dateView.popup.wrapper.remove(),e.dateView.destroy(),null),e.dateView=new K(H({},t,{id:n.attr(k),anchor:e.wrapper,change:function(){e._change(this.value()),e.close()},close:function(t){e.trigger(v)?t.preventDefault():(n.attr(F,!1),r.attr(I,!0),setTimeout(function(){n.removeAttr(`aria-activedescendant`)}))},open:function(t){var i=e.options,a;e.trigger(_)?t.preventDefault():(e.element.val()!==e._oldText&&(a=s(n.val(),i.parseFormats,i.culture),e.dateView[a?`current`:`value`](a)),n.attr(F,!0),r.attr(I,!1),e._updateARIA(a))}})),r=e.dateView.div},setOptions:function(e){let r=this,i=e.value||r.options.value||r._value;o.fn.setOptions.call(r,e),r._value=i,e=r.options,e.min=s(e.min),e.max=s(e.max),W(e),r._dateIcon.off(m),r._dateIcon.remove(),r.dateView.setOptions(e),r._icon(),r._editable({readonly:e.readonly===t?r.options.readonly:e.readonly,disable:!(e.enable===t?r.options.enable:e.enable)}),r._createDateInput(e),!r._dateInput&&i&&r.element.val(n.toString(i,e.format,e.culture)),i&&(r._updateARIA(i),r.value(new Date(i)),r.dateView&&r.dateView.value(new Date(i)),r._dateInput&&r._dateInput.value(new Date(i))),e.label&&r._inputLabel?r.label.setOptions(e.label):e.label===!1?(r.label._unwrapFloating(),r._inputLabel.remove(),delete r._inputLabel):e.label&&r._label()},_editable:function(e){var t=this,n=t._dateIcon.off(m),r=t.element.off(m),i=t.wrapper.off(m),a=e.readonly,o=e.disable;!a&&!o?(i.removeClass(w).on(E,t._toggleHover),r&&r.length&&(r[0].removeAttribute(b),r[0].removeAttribute(x)),r.attr(N,!1).attr(P,!1).on(`keydown`+m,t._keydown.bind(t)).on(`focusout`+m,t._blur.bind(t)).on(`focus`+m,function(){t.wrapper.addClass(S)}),n.on(g,t._click.bind(t)).on(D,G)):(i.addClass(o?w:``).removeClass(o?``:w),r.attr(b,o).attr(x,a).attr(N,o).attr(P,a))},readonly:function(e){this._editable({readonly:e===t?!0:e,disable:!1}),this._dateInput&&this._dateInput._editable({readonly:e===t?!0:e,disable:!1}),this.label&&this.label.floatingLabel&&this.label.floatingLabel.readonly(e===t?!0:e)},enable:function(e){this._editable({readonly:!1,disable:!(e=e===t?!0:e)}),this._dateInput&&this._dateInput._editable({readonly:!1,disable:!(e=e===t?!0:e)}),this.label&&this.label.floatingLabel&&this.label.floatingLabel.enable(e=e===t?!0:e)},_label:function(){var t=this,r=t.options,i=e.isPlainObject(r.label)?r.label:{content:r.label};t._dateInput&&(i.floatCheck=()=>!t.value()&&(!t._dateInput._hasDateInput()||t.element.val()===``)&&document.activeElement!==t.element[0]?(t.element.val(``),!0):!1),t.label=new n.ui.Label(null,e.extend({},i,{widget:t})),t._inputLabel=t.label.element},destroy:function(){var e=this;e.label&&e.label.destroy(),o.fn.destroy.call(e),e.dateView.calendar&&e._navigateCalendarHandler&&(e.dateView.calendar.unbind(O,e._navigateCalendarHandler),e._navigateCalendarHandler=null),e.dateView.destroy(),e.element.off(m),e._dateIcon.off(m),e._form&&e._form.off(`reset`,e._resetHandler),e.bigScreenMQL&&e.bigScreenMQL.destroy(),e._createDateViewProxy=null},open:function(){this.dateView.open(),this._navigateCalendar()},close:function(){this.dateView.close()},min:function(e){return this._option(A,e)},max:function(e){return this._option(j,e)},value:function(e){var n=this;if(e===t)return n._value;n._old=n._update(e),n._old===null&&(n._dateInput?n._dateInput.value(n._old):n.element.val(``)),n._oldText=n.element.val(),n.label&&n.label.floatingLabel&&n.label.floatingLabel.refresh()},_toggleHover:function(t){e(t.currentTarget).toggleClass(T,t.type===`mouseenter`)},_isReset:function(e){var t=this;return t.options.dateInput&&t.options.autoFill&&t._dateInput._emptyMask==e},_blur:function(){var e=this,t=e.element.val();e.close(),t!==e._oldText&&(e.options.autoFill&&!e._isReset(t)&&(e._dateInput.dateInputInstance.autoFill(),t=e.element.val()),e._change(t),t||e.dateView.current(n.calendar.getToday())),e.wrapper.removeClass(S)},_click:function(e){var t=this;t.dateView.toggle(),t._navigateCalendar(),t._focusElement(e.type)},_focusElement:function(e){var t=this.element;(!l.touch||l.mouseAndTouchPresent&&!(e||``).match(/touch/i))&&t[0]!==d()&&t.trigger(`focus`)},_change:function(e){var t=this,r=t.element.val(),i;e=t._update(e),i=!n.calendar.isEqualDate(t._old,e);var a=i&&!t._typing,o=r!==t.element.val();(a||o)&&t.element.trigger(y),i&&(t._old=e,t._oldText=t.element.val(),t.trigger(y)),t._typing=!1},_keydown:function(e){var t=this,n=t.dateView,r=t.element.val(),i=!1;!n.popup.visible()&&e.keyCode==c.ENTER&&r!==t._oldText?t._change(r):(i=n.move(e),t._updateARIA(n._current),i?t._dateInput&&e.stopImmediatePropagation&&e.stopImmediatePropagation():t._typing=!0)},_icon:function(){var t=this,n=t.element,r=t.options,a=n.next(`button.k-input-button`);a[0]||(a=e(i.renderButton(`<button aria-label="select" tabindex="-1" class="k-input-button k-button k-icon-button"></button>`,{icon:`calendar`,size:r.size,fillMode:r.fillMode,shape:`none`})).insertAfter(n)),t._dateIcon=a.attr({role:`button`})},_setCalendarAttribute:function(){var e=this;setTimeout(function(){e.element.attr(L,e.dateView.calendar._table.attr(L))})},_navigateCalendar:function(){var e=this;e._navigateCalendarHandler||=e._setCalendarAttribute.bind(e),e.dateView.calendar&&e.dateView.calendar.unbind(O,e._navigateCalendarHandler).bind(O,e._navigateCalendarHandler)},_option:function(e,n){var r=this,i=r.options;if(n===t)return i[e];n=s(n,i.parseFormats,i.culture),n&&(i[e]=new U(+n),r.dateView[e](n),r._dateInput&&r._dateInput[e](n))},_update:function(e){var t=this,r=t.options,i=r.min,a=r.max,o=t._value,c=s(e,r.parseFormats,r.culture),l=c===null&&o===null||c instanceof Date&&o instanceof Date,u;return r.disableDates(c)&&(c=null,!t._old&&!t.element.val()&&(e=null)),+c==+o&&l?(u=n.toString(c,r.format,r.culture),u!==e&&!(t._dateInput&&!c)&&t.element.val(c===null?e:u),c):(c!==null&&V(c,i)?c=B(c,i,a):z(c,i,a)||(c=null),t._value=c,t.dateView.value(c),t._dateInput&&c?t._dateInput.value(c||e):t.element.val(n.toString(c||e,r.format,r.culture)),t._updateARIA(c),c)},_wrapper:function(){var e=this,t=e.element,n=t.parents(`.k-datepicker`);n[0]||(n=t.wrap(p).parent()),n[0].style.cssText=t[0].style.cssText,t.css({height:t[0].style.height}),e.wrapper=n.addClass(`k-datepicker k-input`).addClass(t[0].className).removeClass(`input-validation-error`)},_reset:function(){var t=this,r=t.element,i=r.attr(`form`),a=t.options,o=a.disableDates,s=a.parseFormats.length?a.parseFormats:null,c=t._initialOptions.value,l=i?e(`#`+i):r.closest(`form`),u=r[0].defaultValue;c&&o&&o(c)&&(c=null),(!u||!n.parseDate(u,s,a.culture))&&c&&r.attr(`value`,n.toString(c,a.format,a.culture)),l[0]&&(t._resetHandler=function(){t.value(c||r[0].defaultValue),t.max(t._initialOptions.max),t.min(t._initialOptions.min)},t._form=l.on(`reset`,t._resetHandler))},_template:function(){this._ariaTemplate=u(this.options.ARIATemplate).bind(this)},_createDateInput:function(e){this._dateInput&&=(this._dateInput.destroy(),null),e.dateInput&&(this._dateInput=new r.DateInput(this.element,{autoAdjust:e.autoAdjust,culture:e.culture,format:e.format,size:e.size,fillMode:e.fillMode,rounded:e.rounded,min:e.min,max:e.max,messages:e.messages.dateInput,autoFill:e.autoFill,autoCorrectParts:e.autoCorrectParts,toggleDayPeriod:!0,inputMode:e.inputMode}))},_updateARIA:function(e){var t=this,n=t.dateView.calendar;t.element&&t.element.length&&t.element[0].removeAttribute(L),n&&t.element.attr(L,n._updateAria(t._ariaTemplate,e))}});n.cssProperties.registerPrefix(`DatePicker`,`k-input-`),n.cssProperties.registerValues(`DatePicker`,[{prop:`rounded`,values:n.cssProperties.roundedValues.concat([[`full`,`full`]])}]),r.plugin(q)})(window.kendo.jQuery);var c=kendo;e.__meta__=s,e.default=c}); //# sourceMappingURL=kendo.datepicker.min.js.map