@nextcloud/vue
Version:
Nextcloud vue components
2 lines (1 loc) • 4.23 kB
JavaScript
var v=require("../assets/index12.css");const o=require("../chunks/l10n-46d0c1c0.cjs"),u=require("./NcTimezonePicker.cjs"),p=require("./NcPopover.cjs"),c=require("../chunks/l10n-dacb6440.cjs"),m=require("vue-material-design-icons/CalendarBlank.vue"),d=require("vue-material-design-icons/Web.vue"),r=require("@nextcloud/l10n"),h=require("vue2-datepicker"),f=require("../chunks/_plugin-vue2_normalizer-764a4c12.cjs"),y=require("../chunks/ScopeComponent-f6122f5a.cjs");const l={date:"YYYY-MM-DD",datetime:"YYYY-MM-DD H:mm:ss",year:"YYYY",month:"YYYY-MM",time:"H:mm:ss",week:"w"},k={name:"NcDatetimePicker",components:{CalendarBlank:m,DatePicker:h,NcPopover:p,NcTimezonePicker:u,Web:d},mixins:[c.l10n],inheritAttrs:!1,props:{clearable:{type:Boolean,default:!1},minuteStep:{type:Number,default:10},type:{type:String,default:"date"},format:{type:String,default:null},formatter:{type:Object,default:null},lang:{type:Object,default:null},value:{default:()=>new Date},timezoneId:{type:String,default:"UTC"},showTimezoneSelect:{type:Boolean,default:!1},highlightTimezone:{type:Boolean,default:!1},appendToBody:{type:Boolean,default:!1},showWeekNumber:{type:Boolean,default:!1},placeholder:{type:String,default:null}},emits:["update:value","update:timezone-id"],data(){return{showTimezonePopover:!1,tzVal:this.timezoneId}},computed:{defaultLang(){return{formatLocale:{months:r.getMonthNames(),monthsShort:r.getMonthNamesShort(),weekdays:r.getDayNames(),weekdaysShort:r.getDayNamesShort(),weekdaysMin:r.getDayNamesMin(),firstDayOfWeek:r.getFirstDay()},monthFormat:"MMM"}},defaultPlaceholder(){return this.type==="time"?o.t("Pick a time"):this.type==="month"?o.t("Pick a month"):this.type==="year"?o.t("Pick a year"):this.type==="week"?o.t("Pick a week"):this.type==="date"?o.t("Pick a date"):o.t("Pick a date and a time")},formatTypeMap(){var e;return(e=l[this.type])!=null?e:l.date}},methods:{handleSelectYear(e){const t=this.$refs.datepicker.currentValue;if(t)try{const a=new Date(new Date(t).setFullYear(e));this.$refs.datepicker.selectDate(a)}catch{console.error("Invalid value",t,e)}},handleSelectMonth(e){const t=this.$refs.datepicker.currentValue;if(t)try{const a=new Date(new Date(t).setMonth(e));this.$refs.datepicker.selectDate(a)}catch{console.error("Invalid value",t,e)}},toggleTimezonePopover(){this.showTimezoneSelect&&(this.showTimezonePopover=!this.showTimezonePopover)}}};var w=function(){var e=this,t=e._self._c;return t("DatePicker",e._g(e._b({ref:"datepicker",attrs:{"append-to-body":e.appendToBody,clearable:e.clearable,format:e.format?e.format:e.formatTypeMap,formatter:e.formatter,lang:e.lang?e.lang:e.defaultLang,"minute-step":e.minuteStep,placeholder:e.placeholder?e.placeholder:e.defaultPlaceholder,"popup-class":{"show-week-number":e.showWeekNumber},"show-week-number":e.showWeekNumber,type:e.type,value:e.value},on:{"select-year":e.handleSelectYear,"select-month":e.handleSelectMonth,"update:value":function(a){return e.$emit("update:value",e.value)}},scopedSlots:e._u([{key:"icon-calendar",fn:function(){return[e.showTimezoneSelect?t("NcPopover",{attrs:{shown:e.showTimezonePopover,"popover-base-class":"timezone-select__popper"},on:{"update:shown":function(a){e.showTimezonePopover=a}},scopedSlots:e._u([{key:"trigger",fn:function(){return[t("button",{staticClass:"datetime-picker-inline-icon",class:{"datetime-picker-inline-icon--highlighted":e.highlightTimezone},on:{mousedown:function(a){return a.stopPropagation(),a.preventDefault(),(()=>{}).apply(null,arguments)}}},[t("Web",{attrs:{size:20}})],1)]},proxy:!0}],null,!1,3375037618)},[t("div",{staticClass:"timezone-popover-wrapper__label"},[t("strong",[e._v(" "+e._s(e.t("Please select a time zone:"))+" ")])]),t("NcTimezonePicker",{staticClass:"timezone-popover-wrapper__timezone-select",on:{input:function(a){return e.$emit("update:timezone-id",arguments[0])}},model:{value:e.tzVal,callback:function(a){e.tzVal=a},expression:"tzVal"}})],1):t("CalendarBlank",{attrs:{size:20}})]},proxy:!0},e._l(e.$scopedSlots,function(a,n){return{key:n,fn:function(s){return[e._t(n,null,null,s)]}}})],null,!0)},"DatePicker",e.$attrs,!1),e.$listeners))},g=[],z=f.normalizeComponent(k,w,g,!1,null,"a0af66c9",null,null);const i=z.exports;y.ScopeComponent(i),module.exports=i;