@mutt/widget-datetime
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -1,1 +0,1 @@ | ||
import MuttVue from"@mutt/widgets-vue";import moment from"moment";import Mutt from"@mutt/forms";class MomentDateTimeValidator extends Mutt.validators.Validator{constructor({min:min=null,max:max=null,messages:messages=null,required:required=!0}={}){super(messages),null!==min&&(this.min=min),null!==max&&(this.max=max),this.messages=messages,this.required=required}validate(value){return value?("string"==typeof value&&(value=moment.utc(value)),!!moment.isMoment(value)&&(Object.prototype.hasOwnProperty.call(value,"isValid")&&!value.isValid()?(this.error="Please enter a valid date.",!1):this.min&&value<this.min?(this.messages&&this.messages.min?this.error=this.messages.min:this.error="Date is before earliest allowed.",!1):!(this.max&&value>this.max)||(this.messages&&this.messages.max?this.error=this.messages.max:this.error="Date is after maximum allowed.",!1))):!this.required||(this.error="This field is required.",!1)}}class MomentDateValidator extends MomentDateTimeValidator{constructor({min:min=null,max:max=null,messages:messages=null,required:required=null}={}){super({min:min,max:max,messages:messages,required:required}),null!==min&&(this.min=this.min.startOf("day")),null!==max&&(this.max=this.max.endOf("day")),this.messages=messages}}var script={name:"mutt-datetime",mixins:[MuttVue.mixin],data:()=>({updateOnFirstSet:!0,errors:null,value:null,initialised:!1,date:null,day:null,month:null,year:null,hour:"00",minute:"00",second:"00",hideDay:!1,min:null,max:null,required:null,dateFormat:"day-month-year",isTimeField:!1,activeFieldIndex:0,jump:!0,dateFieldSeparator:null,buildValueTimeout:null}),computed:{formattedDate(){let format=this.isTimeField?"h:mm:ss, MMMM Do YYYY":"MMMM Do YYYY";return moment.utc(this.field.value).format(format)},inputFields(){let inputFields=this.dateFormat.split("-").filter(date=>!(this.hideDay&&"day"===date)).map(date=>this.inputTypes[date]);if(this.isTimeField){let timeFields=["hour","minute","second"].map(date=>this.inputTypes[date]);inputFields=[...inputFields,...timeFields]}return inputFields},inputFieldOrder(){return this.inputFields.map(fieldObject=>fieldObject.model)},inputTypes(){return{day:{model:"day",attrs:{type:"text",inputmode:"numeric",pattern:"^(0?[1-9]|[12]\\d|3[01])$",placeholder:this.$t("DD")}},month:{model:"month",attrs:{type:"text",inputmode:"numeric",pattern:"^(0?[1-9]|1[012])$",placeholder:this.$t("MM")}},year:{model:"year",attrs:{type:"text",inputmode:"numeric",min:this.getMinYears,max:this.getMaxYears,placeholder:this.$t("YYYY")}},hour:{model:"hour",attrs:{type:"text",inputmode:"numeric",pattern:"^[01]?\\d|2[0-3]$",placeholder:this.$t("hh")}},minute:{model:"minute",attrs:{type:"text",inputmode:"numeric",pattern:"^[0-5]?\\d$",placeholder:this.$t("mm")}},second:{model:"second",attrs:{type:"text",inputmode:"numeric",pattern:"^[0-5]?\\d$",placeholder:this.$t("ss")}}}},getMinYears(){return this.min?this.min.year():moment.utc().add(moment.duration("P-120Y")).year()},getMaxYears(){return this.max?this.max.year():moment.utc().add(moment.duration("P120Y")).year()}},watch:{day(){this.preBuildValue("day")},month(){this.preBuildValue("month")},year(){this.preBuildValue("year")},hour(){this.preBuildValue("hour")},minute(){this.preBuildValue("minute")},second(){this.preBuildValue("second")},activeFieldIndex(newValue){if(newValue>this.inputFields.length-1||newValue<0)this.activeFieldIndex=this.inputFields.length-1;else{const activeField=this.inputFields[newValue];this.$refs[activeField.model][0].focus()}},"field.value":function(newValue){1==this.updateOnFirstSet&&(this.updateOnFirstSet=!1,this.setInitialValue(newValue,null))}},mounted(){this.field.options.min&&(this.field.options.min.startsWith("P")?this.min=moment.utc().add(moment.duration(this.field.options.min)):this.min=moment.utc(this.field.options.min)),this.field.options.showTime&&(this.isTimeField=!0),this.field.options.max&&(this.field.options.max.startsWith("P")?this.max=moment.utc().add(moment.duration(this.field.options.max)):this.max=moment.utc(this.field.options.max)),this.field.options.dateFormat&&(this.dateFormat=this.field.options.dateFormat),this.field.options.dateFieldSeparator&&(this.dateFieldSeparator=this.field.options.dateFieldSeparator);let messages=this.field.options.messages||null;this.field.options.hideDay&&(this.hideDay=!0),this.field.validators.push(new MomentDateValidator({min:this.min,max:this.max,messages:messages,required:this.required})),this.setInitialValue(this.field.value,null),this.initialised=!0,this.field.value&&this.field.validate()&&this.$emit("callback",{key:this.field.name,value:this.field.value,action:"populated",validated:!0,bubble:!0})},created(){this.$t||(this.$t=(str=>str)),!1===this.field.options.required?this.required=!1:this.required=!0,this.$i18n&&this.$i18n.locale&&moment.locale(this.$i18n.locale)},methods:{zeroPad:value=>(value&&1===value.toString().length&&(value=`0${value}`),value),getFieldClass:()=>"mutt-field mutt-field-choice mutt-field-dateinput",getFieldWrapperClass(){return this.hasErrors?`mutt-field-wrapper ${this.getErrorWrapperClass()}`:"mutt-field-wrapper"},preBuildValue(field){if(this.initialised){const filteredInputOrder=this.inputFieldOrder.filter(field=>!/hour|minute|second/.test(field)),delay=filteredInputOrder.indexOf(field)<filteredInputOrder.length-1?1e3:0;this.buildValue(delay)}},buildValue(delay=0){clearTimeout(this.buildValueTimeout),this.buildValueTimeout=setTimeout(()=>{this.hideDay&&(this.day="01");let yearValidLength=!1;this.year&&this.year.toString().length>3&&(yearValidLength=!0);const reset=()=>{this.field.refreshValidationState(!1),this.field.value=null};if(yearValidLength&&this.day&&this.month&&(this.hour||0===this.hour)&&(this.minute||0===this.minute)&&(this.second||0===this.second)){const date=`${this.year}-${this.zeroPad(this.month)}-${this.zeroPad(this.day)}`,time=`${this.zeroPad(this.hour)}:${this.zeroPad(this.minute)}:${this.zeroPad(this.second)}`;let value;if((value=this.isTimeField?moment.utc(`${date}T${time}Z`):moment.utc(`${date}`)).isValid()){this.field.value=value;const validated=this.field.validate();this.$emit("datetimeValidated",{key:this.field.name,value:this.field.value,action:"populated",validated:validated,bubble:!0})}else reset()}else reset()},delay)},restrictDates(dateElement,dateVal){switch(dateElement){case"second":case"minute":dateVal>59&&(this[dateElement]="59");break;case"hour":dateVal>23&&(this.hour="23");break;case"day":dateVal>31?this.day="31":"00"===dateVal&&(this.day="01");break;case"month":dateVal>12?this.month="12":"00"===dateVal&&(this.month="01")}},jumper(){switch(this.inputFields[this.activeFieldIndex].model){case"day":this.updateActiveField("day",2);break;case"month":this.updateActiveField("month",2);break;case"year":this.updateActiveField("year",4);break;case"hour":this.updateActiveField("hour",2);break;case"minute":this.updateActiveField("minute",2);break;case"second":this.updateActiveField("second",2)}},checkJump(type,index){this.activeFieldIndex=index,this[type]&&(this.jump=!1)},updateActiveField(field,minLength){this[field]&&(this.restrictDates(field,this[field]),this[field].length>minLength-1&&this.jump&&(this.activeFieldIndex+=1))},focus(){this.$nextTick(()=>{this.$refs[this.inputFields[this.activeFieldIndex].model][0].focus()})},resetInputs(){this.year=null,this.month=null,this.day=null,this.jump=!0,this.hour="00",this.minute="00",this.second="00"},isNotZero:value=>"0"!==value,refresh(){this.initialised=!1;const value=moment.isMoment(this.field.value)?this.field.value:moment.utc(this.field.value);value.isValid()?(this.second=value.second(),this.minute=value.minute(),this.hour=value.hour(),this.day=value.date(),this.month=value.month()+1,this.year=value.year()):this.resetInputs(),this.initialised=!0},setInitialValue(newValue,oldValue){let initialValue=oldValue;newValue?initialValue=moment.utc(newValue):this.field.options.default&&(initialValue=moment.utc(this.field.options.default)),initialValue&&(this.day=initialValue.date(),this.month=initialValue.month()+1,this.year=initialValue.year())},shouldShowSeparator(fieldIndex){if(this.dateFieldSeparator&&this.inputFields[fieldIndex]&&this.inputFields[fieldIndex+1]){const thisField=this.inputFields[fieldIndex],nextField=this.inputFields[fieldIndex+1];if(["day","month","year"].indexOf(thisField.model)>-1&&["day","month","year"].indexOf(nextField.model)>-1)return!0}return!1}}};function normalizeComponent(template,style,script,scopeId,isFunctionalTemplate,moduleIdentifier,shadowMode,createInjector,createInjectorSSR,createInjectorShadow){"boolean"!=typeof shadowMode&&(createInjectorSSR=createInjector,createInjector=shadowMode,shadowMode=!1);var hook,options="function"==typeof script?script.options:script;if(template&&template.render&&(options.render=template.render,options.staticRenderFns=template.staticRenderFns,options._compiled=!0,isFunctionalTemplate&&(options.functional=!0)),scopeId&&(options._scopeId=scopeId),moduleIdentifier?(hook=function hook(context){(context=context||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(context=__VUE_SSR_CONTEXT__),style&&style.call(this,createInjectorSSR(context)),context&&context._registeredComponents&&context._registeredComponents.add(moduleIdentifier)},options._ssrRegister=hook):style&&(hook=shadowMode?function(){style.call(this,createInjectorShadow(this.$root.$options.shadowRoot))}:function(context){style.call(this,createInjector(context))}),hook)if(options.functional){var originalRender=options.render;options.render=function renderWithStyleInjection(h,context){return hook.call(context),originalRender(h,context)}}else{var existing=options.beforeCreate;options.beforeCreate=existing?[].concat(existing,hook):[hook]}return script}var normalizeComponent_1=normalizeComponent;const __vue_script__=script;var __vue_render__=function(){var _vm=this,_h=_vm.$createElement,_c=_vm._self._c||_h;return _vm.field?_c("div",{class:_vm.getFieldWrapperClass()},[_c("label-widget",{attrs:{field:_vm.field,"field-id":_vm.getFieldId()}}),_vm._v(" "),_vm.isReadOnly?_c("readonly-widget",{attrs:{value:_vm.formattedDate}}):_vm._e(),_vm._v(" "),_vm.isReadOnly?_vm._e():_c("span",{staticClass:"mutt-field-wrapper-dateofbirth"},[_vm._l(_vm.inputFields,function(inputField,inputFieldIndex){return["checkbox"===inputField.attrs.type?_c("input",_vm._b({directives:[{name:"model",rawName:"v-model",value:_vm.$data[inputField.model],expression:"$data[inputField.model]"}],key:inputField.model,ref:inputField.model,refInFor:!0,class:"mutt-field mutt-dateinput mutt-dateinput--"+inputField.model,attrs:{required:_vm.required,type:"checkbox"},domProps:{checked:Array.isArray(_vm.$data[inputField.model])?_vm._i(_vm.$data[inputField.model],null)>-1:_vm.$data[inputField.model]},on:{keyup:function($event){return _vm.jumper($event,inputField.model)},keypress:function($event){return!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")?null:($event.preventDefault(),_vm.submitCallback($event))},click:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},focus:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},change:function($event){var $$a=_vm.$data[inputField.model],$$el=$event.target,$$c=!!$$el.checked;if(Array.isArray($$a)){var $$i=_vm._i($$a,null);$$el.checked?$$i<0&&_vm.$set(_vm.$data,inputField.model,$$a.concat([null])):$$i>-1&&_vm.$set(_vm.$data,inputField.model,$$a.slice(0,$$i).concat($$a.slice($$i+1)))}else _vm.$set(_vm.$data,inputField.model,$$c)}}},"input",inputField.attrs,!1)):"radio"===inputField.attrs.type?_c("input",_vm._b({directives:[{name:"model",rawName:"v-model",value:_vm.$data[inputField.model],expression:"$data[inputField.model]"}],key:inputField.model,ref:inputField.model,refInFor:!0,class:"mutt-field mutt-dateinput mutt-dateinput--"+inputField.model,attrs:{required:_vm.required,type:"radio"},domProps:{checked:_vm._q(_vm.$data[inputField.model],null)},on:{keyup:function($event){return _vm.jumper($event,inputField.model)},keypress:function($event){return!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")?null:($event.preventDefault(),_vm.submitCallback($event))},click:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},focus:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},change:function($event){return _vm.$set(_vm.$data,inputField.model,null)}}},"input",inputField.attrs,!1)):_c("input",_vm._b({directives:[{name:"model",rawName:"v-model",value:_vm.$data[inputField.model],expression:"$data[inputField.model]"}],key:inputField.model,ref:inputField.model,refInFor:!0,class:"mutt-field mutt-dateinput mutt-dateinput--"+inputField.model,attrs:{required:_vm.required,type:inputField.attrs.type},domProps:{value:_vm.$data[inputField.model]},on:{keyup:function($event){return _vm.jumper($event,inputField.model)},keypress:function($event){return!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")?null:($event.preventDefault(),_vm.submitCallback($event))},click:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},focus:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},input:function($event){$event.target.composing||_vm.$set(_vm.$data,inputField.model,$event.target.value)}}},"input",inputField.attrs,!1)),_vm._v(" "),_vm.shouldShowSeparator(inputFieldIndex)?_c("span",{key:"separator-"+inputField.model,staticClass:"mutt-dateinput-separator",domProps:{innerHTML:_vm._s(_vm.dateFieldSeparator)}}):_vm._e()]})],2),_vm._v(" "),_c("help-widget",{attrs:{field:_vm.field}}),_vm._v(" "),_vm.isReadOnly?_vm._e():_c("error-widget",{attrs:{field:_vm.field,errors:_vm.errors,"error-class":_vm.getErrorClass()}})],1):_vm._e()},__vue_staticRenderFns__=[];__vue_render__._withStripped=!0;const __vue_inject_styles__=void 0,__vue_scope_id__=void 0,__vue_module_identifier__=void 0,__vue_is_functional_template__=!1;var Datetime=normalizeComponent_1({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},void 0,__vue_script__,void 0,!1,void 0,void 0,void 0);export default Datetime; | ||
import MuttVue from"@mutt/widgets-vue";import moment from"moment";import Mutt from"@mutt/forms";class MomentDateTimeValidator extends Mutt.validators.Validator{constructor({min:min=null,max:max=null,messages:messages=null,required:required=!0}={}){super(messages),null!==min&&(this.min=min),null!==max&&(this.max=max),this.messages=messages,this.required=required}validate(value){return value?("string"==typeof value&&(value=moment.utc(value)),!!moment.isMoment(value)&&(Object.prototype.hasOwnProperty.call(value,"isValid")&&!value.isValid()?(this.error="Please enter a valid date.",!1):this.min&&value<this.min?(this.messages&&this.messages.min?this.error=this.messages.min:this.error="Date is before earliest allowed.",!1):!(this.max&&value>this.max)||(this.messages&&this.messages.max?this.error=this.messages.max:this.error="Date is after maximum allowed.",!1))):!this.required||(this.error="This field is required.",!1)}}class MomentDateValidator extends MomentDateTimeValidator{constructor({min:min=null,max:max=null,messages:messages=null,required:required=null}={}){super({min:min,max:max,messages:messages,required:required}),null!==min&&(this.min=this.min.startOf("day")),null!==max&&(this.max=this.max.endOf("day")),this.messages=messages}}var script={name:"mutt-datetime",mixins:[MuttVue.mixin],data:()=>({updateOnFirstSet:!0,errors:null,value:null,initialised:!1,date:null,day:null,month:null,year:null,hour:"00",minute:"00",second:"00",hideDay:!1,min:null,max:null,required:null,dateFormat:"day-month-year",isTimeField:!1,activeFieldIndex:0,jump:!0,dateFieldSeparator:null,buildValueTimeout:null}),computed:{formattedDate(){let format=this.isTimeField?"h:mm:ss, MMMM Do YYYY":"MMMM Do YYYY";return moment.utc(this.field.value).format(format)},inputFields(){let inputFields=this.dateFormat.split("-").filter(date=>!(this.hideDay&&"day"===date)).map(date=>this.inputTypes[date]);if(this.isTimeField){let timeFields=["hour","minute","second"].map(date=>this.inputTypes[date]);inputFields=[...inputFields,...timeFields]}return inputFields},inputFieldOrder(){return this.inputFields.map(fieldObject=>fieldObject.model)},inputTypes(){return{day:{model:"day",attrs:{type:"text",inputmode:"numeric",pattern:"^(0?[1-9]|[12]\\d|3[01])$",placeholder:this.$t("DD")}},month:{model:"month",attrs:{type:"text",inputmode:"numeric",pattern:"^(0?[1-9]|1[012])$",placeholder:this.$t("MM")}},year:{model:"year",attrs:{type:"text",inputmode:"numeric",min:this.getMinYears,max:this.getMaxYears,placeholder:this.$t("YYYY")}},hour:{model:"hour",attrs:{type:"text",inputmode:"numeric",pattern:"^[01]?\\d|2[0-3]$",placeholder:this.$t("hh")}},minute:{model:"minute",attrs:{type:"text",inputmode:"numeric",pattern:"^[0-5]?\\d$",placeholder:this.$t("mm")}},second:{model:"second",attrs:{type:"text",inputmode:"numeric",pattern:"^[0-5]?\\d$",placeholder:this.$t("ss")}}}},getMinYears(){return this.min?this.min.year():moment.utc().add(moment.duration("P-120Y")).year()},getMaxYears(){return this.max?this.max.year():moment.utc().add(moment.duration("P120Y")).year()}},watch:{day(){this.preBuildValue("day")},month(){this.preBuildValue("month")},year(){this.preBuildValue("year")},hour(){this.preBuildValue("hour")},minute(){this.preBuildValue("minute")},second(){this.preBuildValue("second")},activeFieldIndex(newValue){if(newValue>this.inputFields.length-1||newValue<0)this.activeFieldIndex=this.inputFields.length-1;else{const activeField=this.inputFields[newValue];this.$refs[activeField.model][0].focus()}},"field.value":function(newValue){1==this.updateOnFirstSet&&(this.updateOnFirstSet=!1,this.setInitialValue(newValue,null))}},mounted(){this.field.options.min&&(this.field.options.min.startsWith("P")?this.min=moment.utc().add(moment.duration(this.field.options.min)):this.min=moment.utc(this.field.options.min)),this.field.options.showTime&&(this.isTimeField=!0),this.field.options.max&&(this.field.options.max.startsWith("P")?this.max=moment.utc().add(moment.duration(this.field.options.max)):this.max=moment.utc(this.field.options.max)),this.field.options.dateFormat&&(this.dateFormat=this.field.options.dateFormat),this.field.options.dateFieldSeparator&&(this.dateFieldSeparator=this.field.options.dateFieldSeparator);let messages=this.field.options.messages||null;this.field.options.hideDay&&(this.hideDay=!0),this.field.validators.push(new MomentDateValidator({min:this.min,max:this.max,messages:messages,required:this.required})),this.setInitialValue(this.field.value,null),this.initialised=!0,this.field.value&&this.field.validate()&&this.$emit("callback",{key:this.field.name,value:this.field.value,action:"populated",validated:!0,bubble:!0})},created(){this.$t||(this.$t=(str=>str)),!1===this.field.options.required?this.required=!1:this.required=!0,this.$i18n&&this.$i18n.locale&&moment.locale(this.$i18n.locale)},methods:{zeroPad:value=>(value&&1===value.toString().length&&(value=`0${value}`),value),getFieldClass:()=>"mutt-field mutt-field-choice mutt-field-dateinput",getFieldWrapperClass(){return this.hasErrors?`mutt-field-wrapper ${this.getErrorWrapperClass()}`:"mutt-field-wrapper"},preBuildValue(field){if(this.initialised){const filteredInputOrder=this.inputFieldOrder.filter(field=>!/hour|minute|second/.test(field)),delay=filteredInputOrder.indexOf(field)<filteredInputOrder.length-1?1e3:0;this.buildValue(delay)}},buildValue(delay=0){clearTimeout(this.buildValueTimeout),this.buildValueTimeout=setTimeout(()=>{this.hideDay&&(this.day="01");let yearValidLength=!1;this.year&&this.year.toString().length>3&&(yearValidLength=!0);const reset=()=>{this.field.refreshValidationState(!1),this.field.value=null};if(yearValidLength&&this.day&&this.month&&(this.hour||0===this.hour)&&(this.minute||0===this.minute)&&(this.second||0===this.second)){const date=`${this.year}-${this.zeroPad(this.month)}-${this.zeroPad(this.day)}`,time=`${this.zeroPad(this.hour)}:${this.zeroPad(this.minute)}:${this.zeroPad(this.second)}`;let value;if((value=this.isTimeField?moment.utc(`${date}T${time}Z`):moment.utc(`${date}`)).isValid()){this.field.value=value;const validated=this.field.validate();this.$emit("datetimeValidated",{key:this.field.name,value:this.field.value,action:"populated",validated:validated,bubble:!0})}else reset()}else reset()},delay)},restrictDates(dateElement,dateVal){switch(dateElement){case"second":case"minute":dateVal>59&&(this[dateElement]="59");break;case"hour":dateVal>23&&(this.hour="23");break;case"day":dateVal>31?this.day="31":"00"===dateVal&&(this.day="01");break;case"month":dateVal>12?this.month="12":"00"===dateVal&&(this.month="01")}},jumper(){switch(this.inputFields[this.activeFieldIndex].model){case"day":this.updateActiveField("day",2);break;case"month":this.updateActiveField("month",2);break;case"year":this.updateActiveField("year",4);break;case"hour":this.updateActiveField("hour",2);break;case"minute":this.updateActiveField("minute",2);break;case"second":this.updateActiveField("second",2)}},checkJump(type,index){this.activeFieldIndex=index,this[type]&&(this.jump=!1)},updateActiveField(field,minLength){this[field]&&(this.restrictDates(field,this[field]),this[field].length>minLength-1&&this.jump&&(this.activeFieldIndex+=1))},focus(){this.$nextTick(()=>{this.$refs[this.inputFields[this.activeFieldIndex].model][0].focus()})},resetInputs(){this.year=null,this.month=null,this.day=null,this.jump=!0,this.hour="00",this.minute="00",this.second="00"},isNotZero:value=>"0"!==value,refresh(){this.initialised=!1;const value=moment.isMoment(this.field.value)?this.field.value:moment.utc(this.field.value);value.isValid()?(this.second=this.zeroPad(value.second()),this.minute=this.zeroPad(value.minute()),this.hour=this.zeroPad(value.hour()),this.day=this.zeroPad(value.date()),this.month=this.zeroPad(value.month()+1),this.year=value.year()):this.resetInputs(),this.initialised=!0},setInitialValue(newValue,oldValue){let initialValue=oldValue;newValue?initialValue=moment.utc(newValue):this.field.options.default&&(initialValue=moment.utc(this.field.options.default)),initialValue&&(this.day=this.zeroPad(initialValue.date()),this.month=this.zeroPad(initialValue.month()+1),this.year=initialValue.year())},shouldShowSeparator(fieldIndex){if(this.dateFieldSeparator&&this.inputFields[fieldIndex]&&this.inputFields[fieldIndex+1]){const thisField=this.inputFields[fieldIndex],nextField=this.inputFields[fieldIndex+1];if(["day","month","year"].indexOf(thisField.model)>-1&&["day","month","year"].indexOf(nextField.model)>-1)return!0}return!1}}};function normalizeComponent(template,style,script,scopeId,isFunctionalTemplate,moduleIdentifier,shadowMode,createInjector,createInjectorSSR,createInjectorShadow){"boolean"!=typeof shadowMode&&(createInjectorSSR=createInjector,createInjector=shadowMode,shadowMode=!1);var hook,options="function"==typeof script?script.options:script;if(template&&template.render&&(options.render=template.render,options.staticRenderFns=template.staticRenderFns,options._compiled=!0,isFunctionalTemplate&&(options.functional=!0)),scopeId&&(options._scopeId=scopeId),moduleIdentifier?(hook=function hook(context){(context=context||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(context=__VUE_SSR_CONTEXT__),style&&style.call(this,createInjectorSSR(context)),context&&context._registeredComponents&&context._registeredComponents.add(moduleIdentifier)},options._ssrRegister=hook):style&&(hook=shadowMode?function(){style.call(this,createInjectorShadow(this.$root.$options.shadowRoot))}:function(context){style.call(this,createInjector(context))}),hook)if(options.functional){var originalRender=options.render;options.render=function renderWithStyleInjection(h,context){return hook.call(context),originalRender(h,context)}}else{var existing=options.beforeCreate;options.beforeCreate=existing?[].concat(existing,hook):[hook]}return script}var normalizeComponent_1=normalizeComponent;const __vue_script__=script;var __vue_render__=function(){var _vm=this,_h=_vm.$createElement,_c=_vm._self._c||_h;return _vm.field?_c("div",{class:_vm.getFieldWrapperClass()},[_c("label-widget",{attrs:{field:_vm.field,"field-id":_vm.getFieldId()}}),_vm._v(" "),_vm.isReadOnly?_c("readonly-widget",{attrs:{value:_vm.formattedDate}}):_vm._e(),_vm._v(" "),_vm.isReadOnly?_vm._e():_c("span",{staticClass:"mutt-field-wrapper-dateofbirth"},[_vm._l(_vm.inputFields,function(inputField,inputFieldIndex){return["checkbox"===inputField.attrs.type?_c("input",_vm._b({directives:[{name:"model",rawName:"v-model",value:_vm.$data[inputField.model],expression:"$data[inputField.model]"}],key:inputField.model,ref:inputField.model,refInFor:!0,class:"mutt-field mutt-dateinput mutt-dateinput--"+inputField.model,attrs:{required:_vm.required,type:"checkbox"},domProps:{checked:Array.isArray(_vm.$data[inputField.model])?_vm._i(_vm.$data[inputField.model],null)>-1:_vm.$data[inputField.model]},on:{keyup:function($event){return _vm.jumper($event,inputField.model)},keypress:function($event){return!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")?null:($event.preventDefault(),_vm.submitCallback($event))},click:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},focus:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},change:function($event){var $$a=_vm.$data[inputField.model],$$el=$event.target,$$c=!!$$el.checked;if(Array.isArray($$a)){var $$i=_vm._i($$a,null);$$el.checked?$$i<0&&_vm.$set(_vm.$data,inputField.model,$$a.concat([null])):$$i>-1&&_vm.$set(_vm.$data,inputField.model,$$a.slice(0,$$i).concat($$a.slice($$i+1)))}else _vm.$set(_vm.$data,inputField.model,$$c)}}},"input",inputField.attrs,!1)):"radio"===inputField.attrs.type?_c("input",_vm._b({directives:[{name:"model",rawName:"v-model",value:_vm.$data[inputField.model],expression:"$data[inputField.model]"}],key:inputField.model,ref:inputField.model,refInFor:!0,class:"mutt-field mutt-dateinput mutt-dateinput--"+inputField.model,attrs:{required:_vm.required,type:"radio"},domProps:{checked:_vm._q(_vm.$data[inputField.model],null)},on:{keyup:function($event){return _vm.jumper($event,inputField.model)},keypress:function($event){return!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")?null:($event.preventDefault(),_vm.submitCallback($event))},click:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},focus:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},change:function($event){return _vm.$set(_vm.$data,inputField.model,null)}}},"input",inputField.attrs,!1)):_c("input",_vm._b({directives:[{name:"model",rawName:"v-model",value:_vm.$data[inputField.model],expression:"$data[inputField.model]"}],key:inputField.model,ref:inputField.model,refInFor:!0,class:"mutt-field mutt-dateinput mutt-dateinput--"+inputField.model,attrs:{required:_vm.required,type:inputField.attrs.type},domProps:{value:_vm.$data[inputField.model]},on:{keyup:function($event){return _vm.jumper($event,inputField.model)},keypress:function($event){return!$event.type.indexOf("key")&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")?null:($event.preventDefault(),_vm.submitCallback($event))},click:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},focus:function($event){return _vm.checkJump(inputField.model,inputFieldIndex)},input:function($event){$event.target.composing||_vm.$set(_vm.$data,inputField.model,$event.target.value)}}},"input",inputField.attrs,!1)),_vm._v(" "),_vm.shouldShowSeparator(inputFieldIndex)?_c("span",{key:"separator-"+inputField.model,staticClass:"mutt-dateinput-separator",domProps:{innerHTML:_vm._s(_vm.dateFieldSeparator)}}):_vm._e()]})],2),_vm._v(" "),_c("help-widget",{attrs:{field:_vm.field}}),_vm._v(" "),_vm.isReadOnly?_vm._e():_c("error-widget",{attrs:{field:_vm.field,errors:_vm.errors,"error-class":_vm.getErrorClass()}})],1):_vm._e()},__vue_staticRenderFns__=[];__vue_render__._withStripped=!0;const __vue_inject_styles__=void 0,__vue_scope_id__=void 0,__vue_module_identifier__=void 0,__vue_is_functional_template__=!1;var Datetime=normalizeComponent_1({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},void 0,__vue_script__,void 0,!1,void 0,void 0,void 0);export default Datetime; |
{ | ||
"name": "@mutt/widget-datetime", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Mutt Forms Widget - Date and Time Input", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18628
56