UNPKG

@progress/kendo-ui

Version:

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

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