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) 8.55 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("kendo.core.js"),require("kendo.label.js"),require("kendo.icons.js"),require("kendo.dateinputs-common.cmn.chunk.js")):"function"==typeof define&&define.amd?define(["exports","kendo.core.min","kendo.label","kendo.icons","kendo.dateinputs-common.cmn.chunk"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Dateinput={}),e.kendo._globals.Core,e.kendo._globals.Label,e.kendo._globals.Icons,e.kendo._globals.DateinputsCommonCmnChunk)}(this,(function(e,t,n,a,o){!function(e,t){var n=window.kendo,a=n.ui,i=a.Widget,s=".kendoDateInput",l={}.toString,r=e.isPlainObject,u="k-focus",d="k-disabled",c="k-invalid",p="disabled",m="readonly",f="change",h=n.Class.extend({init:function(e){const t=e.culture?n.getCulture(e.culture):n.culture();this.messages=e.messages,this.cldr={},this.cldr[t.name]={name:t.name,calendar:t.calendar||{},numbers:t.numberFormat}},parseDate:function(e,t,a){return n.parseDate(e,t,a,!0)},formatDate:function(e,t,a){return n.toString(e,t,a)},splitDateFormat:function(e){return n.date.splitDateFormat(e)},dateFormatNames:function(e,t){return n.date.dateFormatNames(t)},dateFieldName:function(e){return this.messages[e.type]||{}}});function v(){const e=n.culture();let t=[];return t.push(e.calendars.standard["/"]),t.push(e.calendars.standard[":"]),t}function b(e,t){if(!e)return t;return n.getCulture(e).calendars.standard.patterns[t]||t}var g=i.extend({init:function(t,a){var l=this;i.fn.init.call(l,t,a),t=l.element,(a=l.options).format=n._extractFormat(a.format||n.getCulture(a.culture).calendars.standard.patterns.d),a.min=n.parseDate(t.attr("min"))||n.parseDate(a.min),a.max=n.parseDate(t.attr("max"))||n.parseDate(a.max),a.inputMode=a.inputMode||t.attr("inputmode")||"text";var r=t.parent().attr("class")||"",d=r.indexOf("picker")>=0&&r.indexOf("rangepicker")<0,c=l.options.value||t.val();d?l.wrapper=l.element.parent():(l.wrapper=t.wrap("<span class='k-dateinput k-input'></span>").parent(),l.wrapper.addClass(t[0].className).removeClass("input-validation-error")),l.wrapper[0].style.cssText=t[0].style.cssText,t.css({height:t[0].style.height}),l._validationIcon=e(n.ui.icon({icon:"exclamation-circle",iconClass:"k-input-validation-icon k-hidden"})).insertAfter(t),l._form(),l.dateInputInstance=new o.D(t[0],{format:b(a.culture,a.format),autoCorrectParts:a.autoCorrectParts,autoSwitchKeys:a.autoSwitchKeys.length?a.autoSwitchKeys:v(),enableMouseWheel:a.enableMouseWheel,twoDigitYearMax:a.twoDigitYearMax,steps:a.steps,formatPlaceholder:a.messages,events:{inputEnd:function(e){e.error&&l._blinkInvalidState()},keydown:function(e){e.event.keyCode?e.event.keyCode!=n.keys.UP&&e.event.keyCode!=n.keys.DOWN||setTimeout((function(){l.element.trigger(f)})):e.preventDefault()},blur:function(e){l._change(),e.preventDefault()}},intlService:new h({culture:a.culture,messages:l.options.messages}),autoSwitchParts:a.autoSwitchParts,autoFill:a.autoFill,toggleDayPeriod:a.toggleDayPeriod}),l._emptyMask=this.element.val(),a.value&&l.value(a.value),l.element.addClass("k-input-inner").attr("autocomplete","off").attr("inputmode",a.inputMode).on("focus"+s,(function(){l.wrapper.addClass(u)})).on("focusout"+s,(function(){l.wrapper.removeClass(u)}));try{t[0].setAttribute("type","text")}catch(e){t[0].type="text"}t.is("[disabled]")||e(l.element).parents("fieldset").is(":disabled")?l.enable(!1):l.readonly(t.is("[readonly]")),l.value(c),d||l._applyCssClasses(),a.label&&l._label(),l.element.removeAttr("style"),n.notify(l)},options:{name:"DateInput",autoAdjust:!0,autoCorrectParts:!0,autoSwitchKeys:[],autoSwitchParts:!1,enableMouseWheel:!0,culture:"",value:"",format:"",min:new Date(1900,0,1),max:new Date(2099,11,31),messages:{year:"year",month:"month",day:"day",weekday:"day of the week",hour:"hours",minute:"minutes",second:"seconds",milliseconds:"milliseconds",dayperiod:"AM/PM"},size:"medium",steps:{year:1,month:1,day:1,hour:1,minute:1,second:1,millisecond:1},fillMode:"solid",rounded:"medium",label:null,autoFill:!1,toggleDayPeriod:!0},events:[f],min:function(e){if(e===t)return this.options.min;this.options.min=e},max:function(e){if(e===t)return this.options.max;this.options.max=e},setOptions:function(e){var t=this;i.fn.setOptions.call(t,e),t.dateInputInstance.destroy(),t.dateInputInstance=null,t.dateInputInstance=new o.D(this.element[0],{format:b(t.options.culture,t.options.format),autoSwitchKeys:t.options.autoSwitchKeys.length?t.options.autoSwitchKeys:v(),autoCorrectParts:t.options.autoCorrectParts,enableMouseWheel:t.options.enableMouseWheel,steps:t.options.steps,twoDigitYearMax:t.options.twoDigitYearMax,formatPlaceholder:t.options.messages,events:{inputEnd:function(e){e.error&&t._blinkInvalidState()},keydown:function(e){e.event.keyCode!=n.keys.UP&&e.event.keyCode!=n.keys.DOWN||setTimeout((function(){t.element.trigger(f)}))},blur:function(e){t._change(),e.preventDefault()}},intlService:new h({culture:t.options.culture,messages:t.options.messages}),autoSwitchParts:t.options.autoSwitchParts,autoFill:t.options.autoFill,toggleDayPeriod:t.options.toggleDayPeriod})},destroy:function(){var e=this;e.element.off(s),e.dateInputInstance.destroy(),e._formElement&&e._formElement.off("reset",e._resetHandler),e.label&&e.label.destroy(),e._validationIcon&&e._validationIcon.remove(),i.fn.destroy.call(e)},value:function(e){if(e===t)return this.dateInputInstance.value;null===e&&(e=""),"[object Date]"!==l.call(e)&&(e=n.parseDate(e,this.options.format,this.options.culture)),e&&!e.getTime()&&(e=null),this.dateInputInstance.writeValue(e),this._oldValue=e,this.label&&this.label.floatingLabel&&this.label.floatingLabel.refresh()},_hasDateInput:function(){return this._emptyMask!==this.element.val()},readonly:function(e){this._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.label&&this.label.floatingLabel&&this.label.floatingLabel.enable(e=e===t||e)},_label:function(){var t=this,a=t.options,o=r(a.label)?a.label:{content:a.label};t.label=new n.ui.Label(null,e.extend({},o,{widget:t,floatCheck:()=>!(t.value()||t._hasDateInput()&&""!==t.element.val()||document.activeElement===t.element[0])&&(this.element.val(""),!0)})),t._inputLabel=t.label.element},_bindInput:function(){var e=this;e.element.on("focus"+s,(function(){e.wrapper.addClass(u)})).on("focusout"+s,(function(){e.wrapper.removeClass(u)})),this.dateInputInstance&&this.dateInputInstance.bindEvents()},_unbindInput:function(){this.element.off("focus"+s).off("focusout"+s),this.dateInputInstance&&this.dateInputInstance.unbindEvents()},_editable:function(e){var t=this,n=t.element,a=e.disable,o=e.readonly,i=t.wrapper;t._unbindInput(),o||a?(a&&(i.addClass(d),n.attr(p,a),n&&n.length&&n[0].removeAttribute(m)),o&&n.attr(m,o)):(i.removeClass(d),n&&n.length&&(n[0].removeAttribute(p),n[0].removeAttribute(m)),t._bindInput())},_change:function(){let e=this,t=e._oldValue,n=e.value(),a=e.options.autoAdjust;a&&n&&e.min()&&n<e.min()&&(e.value(e.min()),n=e.value()),a&&n&&e.max()&&n>e.max()&&(e.value(e.max()),n=e.value()),(t&&n&&n.getTime()!==t.getTime()||t&&!n||!t&&n)&&(e._oldValue=n,e.trigger(f,{blur:!0}),e.element.trigger(f))},_blinkInvalidState:function(){var e=this;e._addInvalidState(),clearTimeout(e._invalidStateTimeout),e._invalidStateTimeout=setTimeout(e._removeInvalidState.bind(e),100)},_addInvalidState:function(){this.wrapper.addClass(c),this._validationIcon.removeClass("k-hidden")},_removeInvalidState:function(){var e=this;e.wrapper.removeClass(c),e._validationIcon.addClass("k-hidden"),e._invalidStateTimeout=null},_form:function(){var t=this,n=t.element,a=n.attr("form"),o=a?e("#"+a):n.closest("form"),i=n[0].value;!i&&t.options.value&&(i=t.options.value),o[0]&&(t._resetHandler=function(){setTimeout((function(){t.value(i)}))},t._formElement=o.on("reset",t._resetHandler))},_paste:function(e){e.preventDefault()}});n.cssProperties.registerPrefix("DateInput","k-input-"),n.cssProperties.registerValues("DateInput",[{prop:"rounded",values:n.cssProperties.roundedValues.concat([["full","full"]])}]),a.plugin(g)}(window.kendo.jQuery);var i=kendo;e.__meta__={id:"dateinput",name:"DateInput",category:"web",description:"The DateInput widget allows to edit date by typing.",depends:["core","label","dateinputs-common.cmn.chunk"]},e.default=i,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=kendo.dateinput.min.js.map