@kdcloudjs/kingdee-base-components 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/kd/buttonMenu.js +1 -1
- package/dist/cjs/kd/calendar.js +1 -1
- package/dist/cjs/kd/calendarDay.js +1 -1
- package/dist/cjs/kd/calendarMonth.js +1 -1
- package/dist/cjs/kd/calendarYear.js +1 -1
- package/dist/cjs/kd/icon.js +1 -1
- package/dist/cjs/kd/radio.js +1 -1
- package/dist/cjs/kd/radioGroup.js +1 -1
- package/dist/cjs/kd/select.js +1 -1
- package/dist/esm/kd/buttonMenu.js +1 -1
- package/dist/esm/kd/calendar.js +1 -1
- package/dist/esm/kd/calendarDay.js +1 -1
- package/dist/esm/kd/calendarMonth.js +1 -1
- package/dist/esm/kd/calendarYear.js +1 -1
- package/dist/esm/kd/icon.js +1 -1
- package/dist/esm/kd/radio.js +1 -1
- package/dist/esm/kd/radioGroup.js +1 -1
- package/dist/esm/kd/select.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as s,registerComponent as r}from"@kdcloudjs/kwc";import{s as n}from"../calendar.kdds-DkhZH3qI.js";import i from"./icon.js";import l from"./calendarTime.js";import o from"./shadowBaseClassPrivate.js";import{c as d}from"../classSet-DY6Qvt6E.js";import{i as c}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import"../i18n-B98kiI7M.js";import{TIME_SEPARATOR as h,STANDARD_DATE_FORMAT as u}from"./iso8601Utils.js";import{v as m,c as g}from"../utilsPrivate-ekbvijnB.js";import{i as p,D,j as k,z as y,r as f,s as C}from"../intlFormat-DNT_1eg4.js";import{a as v,g as b}from"../intlDisplayNames-CI-izIck.js";import"../client-Ddi3i8XR.js";import"../colorValid-qIPgkqGp.js";import"../empty_html-CjXB8rB4.js";import"./i18nCldrOptions.js";import"./i18nService.js";import"./configProvider.js";import"../labelUtils-DAuN2uUV.js";import"../label-CY8Q8HAO.js";import"./features.js";var M=[n,function(e,t,a){return(t?":host [role='year-title']":(e?"["+e+"-host]":"")+" [role='year-title']")+(e?"["+e+"]":"")+" {margin-right: 8px;}"}];const _=e`<div class="kdds-align-middle kdds-middle-text${0}"${2}><span data-value="year" role="year-title"${3}>${"t2"}</span><span data-value="month"${3}>${"t4"}</span></div>`,Y=e`<th${"a0:id"} scope="col"${3}><span${"a1:title"}${3}>${"t2"}</span></th>`,S=e`<td role="gridcell"${"a0:aria-selected"}${"a0:aria-current"}${"c0"}${"a0:tabindex"}${"a0:data-value"}${"a0:aria-label"}${2}><span class="kdds-day${0}" tabindex="-1" role="button"${2}>${"t2"}</span></td>`,N={classMap:{"kdds-grid":!0},key:0},x={classMap:{"kdds-datepicker__container":!0},attrs:{part:"calendar"},key:1},I={classMap:{"kdds-datepicker__filter":!0,"kdds-grid":!0},key:2},$={classMap:{"kdds-datepicker__filter_month":!0,"kdds-grid":!0,"kdds-grid_align-spread":!0,"kdds-grow":!0},key:3},w={classMap:{"kdds-align-middle":!0},key:4},P={classMap:{"kdds-align-middle":!0},key:11},V={classMap:{"kdds-datepicker__month":!0},attrs:{role:"grid"},key:16},j={key:17},T={key:21},F={classMap:{"time-container":!0},key:26};function A(e,t,a,s){const{ncls:r,b:n,c:o,h:d,d:c,sp:h,st:u,gid:m,k:g,i:p,ti:D,fr:k}=e,{_m0:y,_m1:f,_m2:C,_m3:v,_m4:b,_m5:M,_m6:A,_m7:E}=s;return[d("div",N,[d("div",x,[d("div",I,[d("div",$,[d("div",w,[d("span",{className:r(t.computePrevYearIconClass),key:5,on:y||(s._m0={click:n(t.goToPreviousYear)})},[o("kd-icon",i,{props:{iconName:t.previousYearIconName},key:6})]),d("span",{className:r(t.computePrevMonthIconClass),key:7,on:f||(s._m1={click:n(t.goToPreviousMonth)})},[o("kd-icon",i,{props:{iconName:t.previousMonthIconName},key:8})])]),u(_,10,[h(0,{on:v||(s._m3={click:n(t.handleModeChangeClick)})},null),h(2,null,c(t.computedYearTitle)),h(4,null,c(t.computedMonthTitle))]),d("div",P,[d("span",{className:r(t.computeNextMonthIconClass),key:12,on:b||(s._m4={click:n(t.goToNextMonth)})},[o("kd-icon",i,{props:{iconName:t.nextMonthIconName},key:13})]),d("span",{className:r(t.computeNextYearIconClass),key:14,on:M||(s._m5={click:n(t.goToNextYear)})},[o("kd-icon",i,{props:{iconName:t.nextYearIconName},key:15})])])])]),d("table",V,[d("thead",j,[d("tr",{attrs:{id:m("weekdays-element")},key:18},p(t.computedWeekdayLabels,function(e){return u(Y,g(20,e.fullName),[h(0,{attrs:{id:m(e.fullName)}},null),h(1,{attrs:{title:e.fullName}},null),h(2,null,c(e.shortName))])}))]),d("tbody",T,p(t.computedMonth,function(e,a){return d("tr",{key:g(22,e.id)},p(e.days,function(e){return u(S,g(24,e.dateValue),[h(0,{className:r(e.className),attrs:{"aria-selected":e.isSelected,"aria-current":e.ariaCurrent,tabindex:D(e.tabIndex),"data-value":e.dateValue,"aria-label":e.dateValue}},null),h(1,{on:A||(s._m6={click:n(t.handleDateClick)})},null),h(2,null,c(e.dayInMonth))])}))}))])]),t.isDateTime?k(25,[d("div",F,[o("kd-calendar-time",l,{props:{value:t.timeValue},key:27,on:E||(s._m7={timechange:n(t.handleTimeSelect)})})])],0):null])]}var E=t(A);function W(e){e.preventDefault(),e.stopPropagation()}A.stylesheets=[],A.stylesheetToken="kwc-3usa09gfeck",A.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarDay-undefined_calendarDay",M&&A.stylesheets.push.apply(A.stylesheets,M),a(A);const B={};class O extends o{constructor(...e){super(...e),this.calendarYear=null,this.calendarMonth=null,this.type=void 0,this._timeValue="00:00:00",this._dateValue=void 0}get value(){return this._dateValue}set value(e){e&&(e=e.split(" ").join(h));const t="string"==typeof e?e.split(h)[0]:e;if(t!==this._dateValue){if(this._dateValue=t,!this._connected)return;const e=this.parseDate(t);e?this.selectDate(e):(this._dateValue=null,this.renderToday())}}get timeValue(){return this._timeValue}set timeValue(e){e&&(this._timeValue=e)}get isDateTime(){return"datetime"===this.type}connectedCallback(){super.connectedCallback(),this._connected=!0,this.todayDate=p();const e=this.getSelectedDate()||this.getTodaysDate();this.renderCalendar(e)}disconnectedCallback(){this._connected=!1}get computedYearTitle(){return`${this.padYear(this.calendarYear)}年`}get computedMonthTitle(){const e=this.getCalendarDate().getMonth();return v()[e].fullName}get computedSelectedDate(){return this._dateValue+h+this._timeValue}get computedWeekdayLabels(){const e=b(),t=this.getFirstDayOfWeek(),a=[];for(let s=t;s<e.length;s++)a.push(e[s]);for(let s=0;s<t;s++)a.push(e[s]);return a}get hostDirection(){let e;return c&&(e=window.getComputedStyle(this.template.host)),e?e.direction.toLowerCase():"ltr"}get previousMonthIconName(){return"ltr"===this.hostDirection?"kdfont-shangyiyue":"kdfont-xiayiyue"}get previousYearIconName(){return"ltr"===this.hostDirection?"kdfont-qianfanshuangjiantou":"kdfont-houfanshuangjiantou"}get nextMonthIconName(){return"ltr"===this.hostDirection?"kdfont-xiayiyue":"kdfont-shangyiyue"}get nextYearIconName(){return"ltr"===this.hostDirection?"kdfont-houfanshuangjiantou ":"kdfont-qianfanshuangjiantou"}get canPrevYear(){return this.calendarYear-1>=1}get canPrevMonth(){return!(1===this.calendarYear&&this.calendarMonth-1<0)}get canNextYear(){return this.calendarYear+1<=9999}get canNextMonth(){return!(9999===this.calendarYear&&this.calendarMonth+1>11)}get computePrevYearIconClass(){return this.canPrevYear?"":"disabled"}get computePrevMonthIconClass(){return this.canPrevMonth?"":"disabled"}get computeNextMonthIconClass(){return this.canNextMonth?"":"disabled"}get computeNextYearIconClass(){return this.canNextYear?"":"disabled"}get computedMonth(){if(!this._connected)return[];const e=this.getSelectedDate(),t=this.getCalendarDate(),a=this.getCalendarCacheKey(t,e);if(a in B)return B[a];const s={_dateValue:e,renderDate:t,todayDate:this.getTodaysDate(),minDate:this.parseDate(this.min),maxDate:this.parseDate(this.max)},r=[],n=this.getCalendarStartDate(t);for(let e=0;e<6;e++){const t={id:e,days:[]};for(let e=0;e<7;e++){const e=this.getDateCellAttributes(n,s);t.days.push(e),n.setDate(n.getDate()+1)}r.push(t)}return B[a]=r,r}padYear(e){return String(e).padStart(4,"0")}padMonth(e){return String(e+1).padStart(2,"0")}getDateCellAttributes(e,t){const a=!this.dateInCalendar(e,t.renderDate)||!this.isBetween(e,t.minDate,t.maxDate),s=this.isSame(e,t._dateValue),r=this.isSame(e,t.todayDate),n=!!r&&"date",i=!!this.isSame(e,t.focusableDate)&&"0",l=d().add({"kdds-is-today":r,"kdds-is-selected":s,"kdds-day_adjacent-month":a}).toString()||void 0;return{dayInMonth:D(String(e.getDate())),dateValue:this.formatDate(e),isSelected:s?"true":"false",className:l,tabIndex:i,ariaCurrent:n}}dispatchSelectEvent(){this.dispatchEvent(new CustomEvent("privatedayselect",{composed:!0,bubbles:!0,cancelable:!0,detail:{value:this.computedSelectedDate}}))}dateInCalendar(e,t){const a=t||this.getCalendarDate();return e.getMonth()===a.getMonth()&&e.getFullYear()===a.getFullYear()}getInitialFocusDate(e,t,a){if(t&&this.dateInCalendar(t,a))return t;if(this.dateInCalendar(e,a))return e;const s=`${this.padYear(a.getFullYear())}-${this.padMonth(a.getMonth())}-01`;return new Date(s)}getTodaysDate(){return this.todayDate?this.parseDate(this.todayDate):new Date}getSelectedDate(){return this.parseDate(this._dateValue)}getCalendarDate(){if(this.calendarYear){const e=`${this.padYear(this.calendarYear)}-${this.padMonth(this.calendarMonth)}-01`;return new Date(e)}return this.getTodaysDate()}getCalendarStartDate(e){const t=`${this.padYear(e.getFullYear())}-${this.padMonth(e.getMonth())}-01`,a=new Date(t);return this.getStartOfWeek(a)}getStartOfWeek(e){const t=this.getFirstDayOfWeek();let a=e.getDay();for(;a!==t;)e.setDate(e.getDate()-1),a=e.getDay();return e}getFirstDayOfWeek(){return 1}selectDate(e){if(this.dateInCalendar(e)){const t=this.getElementByDate(this.formatDate(e));this.selectDateInCalendar(t)}else this.renderCalendar(e)}selectDateInCalendar(e){this._dateValue=e.getAttribute("data-value"),this.removeCurrentlySelectedDateAttributes(),this.addSelectedDateAttributes(e)}selectDateInCalendarAndDispatchSelect(e){this.selectDateInCalendar(e),this.dispatchSelectEvent()}getElementByDate(e){return this.template.querySelector(`td[data-value='${e}']`)}getFocusableDateCell(){return this.template.querySelector("td[tabIndex='0']")}unfocusDateCell(e){e&&e.removeAttribute("tabIndex")}focusDateCell(e){e&&(e.setAttribute("tabIndex",0),e.focus())}focusElementByDate(e){requestAnimationFrame(()=>{const t=this.getElementByDate(this.formatDate(e));t&&(this.unfocusDateCell(this.getFocusableDateCell()),this.focusDateCell(t))})}renderCalendar(e){this.calendarMonth=e.getMonth(),this.calendarYear=e.getFullYear()}renderToday(){const e=this.getTodaysDate();if(this.dateInCalendar(e)){this.removeCurrentlySelectedDateAttributes(),this.unfocusDateCell(this.getFocusableDateCell());this.getElementByDate(this.todayDate).setAttribute("tabIndex",0)}else this.renderCalendar(e)}removeCurrentlySelectedDateAttributes(){const e=this.template.querySelector("td[class*='kdds-is-selected']");e&&(e.classList.remove("kdds-is-selected"),e.setAttribute("aria-selected","false")),this.unfocusDateCell(this.getFocusableDateCell())}addSelectedDateAttributes(e){this.focusDateCell(e),e.classList.add("kdds-is-selected"),e.setAttribute("aria-selected","true")}handleCalendarKeyDown(e){const t=e.target.getAttribute("data-value");!function(e,t,a){const s=e.target;switch(m(e.key)){case"ArrowUp":W(e),t.setDate(t.getDate()-7),a.focusDate(t);break;case"ArrowDown":W(e),t.setDate(t.getDate()+7),a.focusDate(t);break;case"ArrowRight":W(e),g()?t.setDate(t.getDate()-1):t.setDate(t.getDate()+1),a.focusDate(t);break;case"ArrowLeft":W(e),g()?t.setDate(t.getDate()+1):t.setDate(t.getDate()-1),a.focusDate(t);break;case"Enter":case" ":W(e),a.selectDate(s);break;case"PageUp":W(e),e.altKey?t.setFullYear(t.getFullYear()-1):t.setMonth(t.getMonth()-1),a.focusDate(t);break;case"PageDown":W(e),e.altKey?t.setFullYear(t.getFullYear()+1):t.setMonth(t.getMonth()+1),a.focusDate(t);break;case"Home":{W(e);const s=a.getStartOfWeek(t);a.focusDate(s);break}case"End":{W(e);const s=a.getStartOfWeek(t);s.setDate(s.getDate()+6),a.focusDate(s);break}}}(e,this.parseDate(t),this.keyboardInterface)}handleDateClick(e){e.stopPropagation();const t=e.target.parentElement;this.selectDateInCalendarAndDispatchSelect(t)}handleTodayClick(e){e.stopPropagation(),this._dateValue=this.todayDate,this.selectDate(this.getTodaysDate()),this.dispatchSelectEvent()}handleModeChangeClick(e){if(e.stopPropagation(),"SPAN"===e.target.tagName){const t=e.target.getAttribute("data-value");this.dispatchEvent(new CustomEvent("modechange",{detail:{value:t}}))}}handleYearChange(e){e.stopPropagation();const t=e.target.value;this.calendarYear!==t&&(this.calendarYear=t)}handleTimeSelect(e){const{value:t}=e.detail;this._dateValue||(this._dateValue=this.todayDate),this._timeValue=t,this.dispatchSelectEvent()}goToNextMonth(e){if(e.stopPropagation(),!this.canNextMonth)return;const t=this.getCalendarDate();t.setMonth(t.getMonth()+1),this.renderCalendar(t)}goToNextYear(e){if(e.stopPropagation(),!this.canNextYear)return;const t=this.getCalendarDate(),a=t.getFullYear()+1;t.setFullYear(a),this.renderCalendar(t)}goToPreviousMonth(e){if(e.stopPropagation(),!this.canPrevMonth)return;const t=this.getCalendarDate();t.setMonth(t.getMonth()-1),this.renderCalendar(t)}goToPreviousYear(e){if(e.stopPropagation(),!this.canPrevYear)return;const t=this.getCalendarDate(),a=t.getFullYear()-1;t.setFullYear(a),this.renderCalendar(t)}formatDate(e){return k(e)}parseDate(e){return y(e,u,!0)}isSame(e,t){return!(!e||!t)&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())}isBetween(e,t,a){let s=!0,r=!0;return a&&(s=f(e,a,"day")||this.isSame(e,a)),t&&(r=C(e,t,"day")||this.isSame(e,t)),s&&r}getCalendarCacheKey(e,t){let a=`${e.getFullYear()}-${e.getMonth()}`;return a+=this.min?`min${this.min}`:"",a+=this.max?`max${this.max}`:"",t&&this.dateInCalendar(t,e)&&(a+=`_${t.getDate()}`),a}}s(O,{publicProps:{type:{config:0},value:{config:3},timeValue:{config:3}},track:{calendarYear:1,calendarMonth:1,_timeValue:1,_dateValue:1}});const q=r(O,{tmpl:E,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarDay-",apiVersion:63});export{q as default};
|
|
1
|
+
import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as s,registerComponent as r}from"@kdcloudjs/kwc";import{s as n}from"../calendar.kdds-DkhZH3qI.js";import i from"./icon.js";import l from"./calendarTime.js";import o from"./shadowBaseClassPrivate.js";import{c as d}from"../classSet-DY6Qvt6E.js";import{i as c}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import"../i18n-B98kiI7M.js";import{TIME_SEPARATOR as h,STANDARD_DATE_FORMAT as u}from"./iso8601Utils.js";import{v as g,c as m}from"../utilsPrivate-ekbvijnB.js";import{i as p,D,j as k,z as y,r as f,s as C}from"../intlFormat-DNT_1eg4.js";import{a as v,g as b}from"../intlDisplayNames-CI-izIck.js";import"../client-Ddi3i8XR.js";import"../colorValid-qIPgkqGp.js";import"../empty_html-CjXB8rB4.js";import"./i18nCldrOptions.js";import"./i18nService.js";import"./configProvider.js";import"../labelUtils-DAuN2uUV.js";import"../label-CY8Q8HAO.js";import"./features.js";var M=[n,function(e,t,a){return(t?":host [role='year-title']":(e?"["+e+"-host]":"")+" [role='year-title']")+(e?"["+e+"]":"")+" {margin-right: 8px;}"}];const _=e`<div class="kdds-align-middle kdds-middle-text${0}"${2}><span data-value="year" role="year-title"${3}>${"t2"}</span><span data-value="month"${3}>${"t4"}</span></div>`,Y=e`<th${"a0:id"} scope="col"${3}><span${"a1:title"}${3}>${"t2"}</span></th>`,S=e`<td role="gridcell"${"a0:aria-selected"}${"a0:aria-current"}${"c0"}${"a0:tabindex"}${"a0:data-value"}${"a0:aria-label"}${2}><span class="kdds-day${0}" tabindex="-1" role="button"${2}>${"t2"}</span></td>`,N={classMap:{"kdds-grid":!0},key:0},x={classMap:{"kdds-datepicker__container":!0},attrs:{part:"calendar"},key:1},I={classMap:{"kdds-datepicker__filter":!0,"kdds-grid":!0},key:2},$={classMap:{"kdds-datepicker__filter_month":!0,"kdds-grid":!0,"kdds-grid_align-spread":!0,"kdds-grow":!0},key:3},w={classMap:{"kdds-align-middle":!0},key:4},P={classMap:{"kdds-align-middle":!0},key:11},V={classMap:{"kdds-datepicker__month":!0},attrs:{role:"grid"},key:16},j={key:17},T={key:21},F={classMap:{"time-container":!0},key:26};function A(e,t,a,s){const{ncls:r,b:n,c:o,h:d,d:c,sp:h,st:u,gid:g,k:m,i:p,ti:D,fr:k}=e,{_m0:y,_m1:f,_m2:C,_m3:v,_m4:b,_m5:M,_m6:A,_m7:E}=s;return[d("div",N,[d("div",x,[d("div",I,[d("div",$,[d("div",w,[d("span",{className:r(t.computePrevYearIconClass),key:5,on:y||(s._m0={click:n(t.goToPreviousYear)})},[o("kd-icon",i,{props:{iconName:t.previousYearIconName},key:6})]),d("span",{className:r(t.computePrevMonthIconClass),key:7,on:f||(s._m1={click:n(t.goToPreviousMonth)})},[o("kd-icon",i,{props:{iconName:t.previousMonthIconName},key:8})])]),u(_,10,[h(0,{on:v||(s._m3={click:n(t.handleModeChangeClick)})},null),h(2,null,c(t.computedYearTitle)),h(4,null,c(t.computedMonthTitle))]),d("div",P,[d("span",{className:r(t.computeNextMonthIconClass),key:12,on:b||(s._m4={click:n(t.goToNextMonth)})},[o("kd-icon",i,{props:{iconName:t.nextMonthIconName},key:13})]),d("span",{className:r(t.computeNextYearIconClass),key:14,on:M||(s._m5={click:n(t.goToNextYear)})},[o("kd-icon",i,{props:{iconName:t.nextYearIconName},key:15})])])])]),d("table",V,[d("thead",j,[d("tr",{attrs:{id:g("weekdays-element")},key:18},p(t.computedWeekdayLabels,function(e){return u(Y,m(20,e.fullName),[h(0,{attrs:{id:g(e.fullName)}},null),h(1,{attrs:{title:e.fullName}},null),h(2,null,c(e.shortName))])}))]),d("tbody",T,p(t.computedMonth,function(e,a){return d("tr",{key:m(22,e.id)},p(e.days,function(e){return u(S,m(24,e.dateValue),[h(0,{className:r(e.className),attrs:{"aria-selected":e.isSelected,"aria-current":e.ariaCurrent,tabindex:D(e.tabIndex),"data-value":e.dateValue,"aria-label":e.dateValue}},null),h(1,{on:A||(s._m6={click:n(t.handleDateClick)})},null),h(2,null,c(e.dayInMonth))])}))}))])]),t.isDateTime?k(25,[d("div",F,[o("kd-calendar-time",l,{props:{value:t.timeValue},key:27,on:E||(s._m7={timechange:n(t.handleTimeSelect)})})])],0):null])]}var E=t(A);function W(e){e.preventDefault(),e.stopPropagation()}A.stylesheets=[],A.stylesheetToken="kwc-3usa09gfeck",A.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarDay-undefined_calendarDay",M&&A.stylesheets.push.apply(A.stylesheets,M),a(A);const B={};class O extends o{constructor(...e){super(...e),this.calendarYear=null,this.calendarMonth=null,this.type=void 0,this._timeValue="00:00:00",this._dateValue=void 0,this._calendarDate=null}get calendarDate(){return this._calendarDate}set calendarDate(e){this._calendarDate=e,e&&this.renderCalendar(e)}get value(){return this._dateValue}set value(e){e&&(e=e.split(" ").join(h));const t="string"==typeof e?e.split(h)[0]:e;if(t!==this._dateValue){if(this._dateValue=t,!this._connected)return;const e=this.parseDate(t);e?this.selectDate(e):(this._dateValue=null,this.renderToday())}}get timeValue(){return this._timeValue}set timeValue(e){e&&(this._timeValue=e)}get isDateTime(){return"datetime"===this.type}connectedCallback(){super.connectedCallback(),this._connected=!0,this.todayDate=p();const e=this._calendarDate||this.getSelectedDate()||this.getTodaysDate();this.renderCalendar(e)}disconnectedCallback(){this._connected=!1}get computedYearTitle(){return`${this.padYear(this.calendarYear)}年`}get computedMonthTitle(){const e=this.getCalendarDate().getMonth();return v()[e].fullName}get computedSelectedDate(){return this._dateValue+h+this._timeValue}get computedWeekdayLabels(){const e=b(),t=this.getFirstDayOfWeek(),a=[];for(let s=t;s<e.length;s++)a.push(e[s]);for(let s=0;s<t;s++)a.push(e[s]);return a}get hostDirection(){let e;return c&&(e=window.getComputedStyle(this.template.host)),e?e.direction.toLowerCase():"ltr"}get previousMonthIconName(){return"ltr"===this.hostDirection?"kdfont-shangyiyue":"kdfont-xiayiyue"}get previousYearIconName(){return"ltr"===this.hostDirection?"kdfont-qianfanshuangjiantou":"kdfont-houfanshuangjiantou"}get nextMonthIconName(){return"ltr"===this.hostDirection?"kdfont-xiayiyue":"kdfont-shangyiyue"}get nextYearIconName(){return"ltr"===this.hostDirection?"kdfont-houfanshuangjiantou ":"kdfont-qianfanshuangjiantou"}get canPrevYear(){return this.calendarYear-1>=1}get canPrevMonth(){return!(1===this.calendarYear&&this.calendarMonth-1<0)}get canNextYear(){return this.calendarYear+1<=9999}get canNextMonth(){return!(9999===this.calendarYear&&this.calendarMonth+1>11)}get computePrevYearIconClass(){return this.canPrevYear?"":"disabled"}get computePrevMonthIconClass(){return this.canPrevMonth?"":"disabled"}get computeNextMonthIconClass(){return this.canNextMonth?"":"disabled"}get computeNextYearIconClass(){return this.canNextYear?"":"disabled"}get computedMonth(){if(!this._connected)return[];const e=this.getSelectedDate(),t=this.getCalendarDate(),a=this.getCalendarCacheKey(t,e);if(a in B)return B[a];const s={_dateValue:e,renderDate:t,todayDate:this.getTodaysDate(),minDate:this.parseDate(this.min),maxDate:this.parseDate(this.max)},r=[],n=this.getCalendarStartDate(t);for(let e=0;e<6;e++){const t={id:e,days:[]};for(let e=0;e<7;e++){const e=this.getDateCellAttributes(n,s);t.days.push(e),n.setDate(n.getDate()+1)}r.push(t)}return B[a]=r,r}padYear(e){return String(e).padStart(4,"0")}padMonth(e){return String(e+1).padStart(2,"0")}getDateCellAttributes(e,t){const a=!this.dateInCalendar(e,t.renderDate)||!this.isBetween(e,t.minDate,t.maxDate),s=this.isSame(e,t._dateValue),r=this.isSame(e,t.todayDate),n=!!r&&"date",i=!!this.isSame(e,t.focusableDate)&&"0",l=d().add({"kdds-is-today":r,"kdds-is-selected":s,"kdds-day_adjacent-month":a}).toString()||void 0;return{dayInMonth:D(String(e.getDate())),dateValue:this.formatDate(e),isSelected:s?"true":"false",className:l,tabIndex:i,ariaCurrent:n}}dispatchSelectEvent(){this.dispatchEvent(new CustomEvent("privatedayselect",{composed:!0,bubbles:!0,cancelable:!0,detail:{value:this.computedSelectedDate}}))}dateInCalendar(e,t){const a=t||this.getCalendarDate();return e.getMonth()===a.getMonth()&&e.getFullYear()===a.getFullYear()}getInitialFocusDate(e,t,a){if(t&&this.dateInCalendar(t,a))return t;if(this.dateInCalendar(e,a))return e;const s=`${this.padYear(a.getFullYear())}-${this.padMonth(a.getMonth())}-01`;return new Date(s)}getTodaysDate(){return this.todayDate?this.parseDate(this.todayDate):new Date}getSelectedDate(){return this.parseDate(this._dateValue)}getCalendarDate(){if(this.calendarYear){const e=`${this.padYear(this.calendarYear)}-${this.padMonth(this.calendarMonth)}-01`;return new Date(e)}return this.getTodaysDate()}getCalendarStartDate(e){const t=`${this.padYear(e.getFullYear())}-${this.padMonth(e.getMonth())}-01`,a=new Date(t);return this.getStartOfWeek(a)}getStartOfWeek(e){const t=this.getFirstDayOfWeek();let a=e.getDay();for(;a!==t;)e.setDate(e.getDate()-1),a=e.getDay();return e}getFirstDayOfWeek(){return 1}selectDate(e){if(this.dateInCalendar(e)){const t=this.getElementByDate(this.formatDate(e));this.selectDateInCalendar(t)}else this.renderCalendar(e)}selectDateInCalendar(e){this._dateValue=e.getAttribute("data-value"),this.removeCurrentlySelectedDateAttributes(),this.addSelectedDateAttributes(e)}selectDateInCalendarAndDispatchSelect(e){this.selectDateInCalendar(e),this.dispatchSelectEvent()}getElementByDate(e){return this.template.querySelector(`td[data-value='${e}']`)}getFocusableDateCell(){return this.template.querySelector("td[tabIndex='0']")}unfocusDateCell(e){e&&e.removeAttribute("tabIndex")}focusDateCell(e){e&&(e.setAttribute("tabIndex",0),e.focus())}focusElementByDate(e){requestAnimationFrame(()=>{const t=this.getElementByDate(this.formatDate(e));t&&(this.unfocusDateCell(this.getFocusableDateCell()),this.focusDateCell(t))})}renderCalendar(e){this.calendarMonth=e.getMonth(),this.calendarYear=e.getFullYear()}renderToday(){const e=this.getTodaysDate();if(this.dateInCalendar(e)){this.removeCurrentlySelectedDateAttributes(),this.unfocusDateCell(this.getFocusableDateCell());this.getElementByDate(this.todayDate).setAttribute("tabIndex",0)}else this.renderCalendar(e)}removeCurrentlySelectedDateAttributes(){const e=this.template.querySelector("td[class*='kdds-is-selected']");e&&(e.classList.remove("kdds-is-selected"),e.setAttribute("aria-selected","false")),this.unfocusDateCell(this.getFocusableDateCell())}addSelectedDateAttributes(e){this.focusDateCell(e),e.classList.add("kdds-is-selected"),e.setAttribute("aria-selected","true")}handleCalendarKeyDown(e){const t=e.target.getAttribute("data-value");!function(e,t,a){const s=e.target;switch(g(e.key)){case"ArrowUp":W(e),t.setDate(t.getDate()-7),a.focusDate(t);break;case"ArrowDown":W(e),t.setDate(t.getDate()+7),a.focusDate(t);break;case"ArrowRight":W(e),m()?t.setDate(t.getDate()-1):t.setDate(t.getDate()+1),a.focusDate(t);break;case"ArrowLeft":W(e),m()?t.setDate(t.getDate()+1):t.setDate(t.getDate()-1),a.focusDate(t);break;case"Enter":case" ":W(e),a.selectDate(s);break;case"PageUp":W(e),e.altKey?t.setFullYear(t.getFullYear()-1):t.setMonth(t.getMonth()-1),a.focusDate(t);break;case"PageDown":W(e),e.altKey?t.setFullYear(t.getFullYear()+1):t.setMonth(t.getMonth()+1),a.focusDate(t);break;case"Home":{W(e);const s=a.getStartOfWeek(t);a.focusDate(s);break}case"End":{W(e);const s=a.getStartOfWeek(t);s.setDate(s.getDate()+6),a.focusDate(s);break}}}(e,this.parseDate(t),this.keyboardInterface)}handleDateClick(e){e.stopPropagation();const t=e.target.parentElement;this.selectDateInCalendarAndDispatchSelect(t)}handleTodayClick(e){e.stopPropagation(),this._dateValue=this.todayDate,this.selectDate(this.getTodaysDate()),this.dispatchSelectEvent()}handleModeChangeClick(e){if(e.stopPropagation(),"SPAN"===e.target.tagName){const t=e.target.getAttribute("data-value");this.dispatchEvent(new CustomEvent("modechange",{detail:{value:t}}))}}handleYearChange(e){e.stopPropagation();const t=e.target.value;this.calendarYear!==t&&(this.calendarYear=t)}handleTimeSelect(e){const{value:t}=e.detail;this._dateValue||(this._dateValue=this.todayDate),this._timeValue=t,this.dispatchSelectEvent()}goToNextMonth(e){if(e.stopPropagation(),!this.canNextMonth)return;const t=this.getCalendarDate();t.setMonth(t.getMonth()+1),this.renderCalendar(t)}goToNextYear(e){if(e.stopPropagation(),!this.canNextYear)return;const t=this.getCalendarDate(),a=t.getFullYear()+1;t.setFullYear(a),this.renderCalendar(t)}goToPreviousMonth(e){if(e.stopPropagation(),!this.canPrevMonth)return;const t=this.getCalendarDate();t.setMonth(t.getMonth()-1),this.renderCalendar(t)}goToPreviousYear(e){if(e.stopPropagation(),!this.canPrevYear)return;const t=this.getCalendarDate(),a=t.getFullYear()-1;t.setFullYear(a),this.renderCalendar(t)}formatDate(e){return k(e)}parseDate(e){return y(e,u,!0)}isSame(e,t){return!(!e||!t)&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())}isBetween(e,t,a){let s=!0,r=!0;return a&&(s=f(e,a,"day")||this.isSame(e,a)),t&&(r=C(e,t,"day")||this.isSame(e,t)),s&&r}getCalendarCacheKey(e,t){let a=`${e.getFullYear()}-${e.getMonth()}`;return a+=this.min?`min${this.min}`:"",a+=this.max?`max${this.max}`:"",t&&this.dateInCalendar(t,e)&&(a+=`_${t.getDate()}`),a}}s(O,{publicProps:{type:{config:0},calendarDate:{config:3},value:{config:3},timeValue:{config:3}},track:{calendarYear:1,calendarMonth:1,_timeValue:1,_dateValue:1,_calendarDate:1}});const q=r(O,{tmpl:E,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarDay-",apiVersion:63});export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as
|
|
1
|
+
import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as r,registerComponent as s}from"@kdcloudjs/kwc";import{s as n}from"../calendarMonth-D9AFuDlp.js";import i from"./icon.js";import o from"./shadowBaseClassPrivate.js";import{z as l,i as d}from"../intlFormat-DNT_1eg4.js";import"../i18n-B98kiI7M.js";import{i as c}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import{STANDARD_DATE_FORMAT as h}from"./iso8601Utils.js";import{a as u}from"../intlDisplayNames-CI-izIck.js";import"../calendar.kdds-DkhZH3qI.js";import"../utilsPrivate-ekbvijnB.js";import"../client-Ddi3i8XR.js";import"../colorValid-qIPgkqGp.js";import"./i18nCldrOptions.js";import"./i18nService.js";import"./configProvider.js";import"../empty_html-CjXB8rB4.js";import"../classSet-DY6Qvt6E.js";import"../labelUtils-DAuN2uUV.js";import"../label-CY8Q8HAO.js";import"./features.js";const m=e`<div class="kdds-align-middle kdds-middle-text${0}"${2}><span data-value="year" role="year-title"${3}>${"t2"}</span></div>`,p=e`<button${"a0:aria-selected"}${"a0:aria-current"} class="kdds-button kdds-month-button${0}"${"a0:data-month"}${2}>${"t1"}</button>`,g={classMap:{"kdds-datepicker__filter":!0,"kdds-grid":!0},key:0},k={classMap:{"kdds-datepicker__filter_month":!0,"kdds-grid":!0,"kdds-grid_align-spread":!0,"kdds-grow":!0},key:1},D={classMap:{"kdds-align-middle":!0},key:2},Y={classMap:{"kdds-align-middle":!0},key:7},v={classMap:{"kdds-datepicker__month-list":!0},key:10};function f(e,t,a,r){const{ncls:s,b:n,c:o,h:l,d:d,sp:c,st:h,k:u,i:f}=e,{_m0:_,_m1:y,_m2:C,_m3:j,_m4:b,_m5:M}=r;return[l("div",g,[l("div",k,[l("div",D,[l("span",{className:s(t.computePrevYearIconClass),key:3,on:_||(r._m0={click:n(t.goToPreviousYear)})},[o("kd-icon",i,{props:{iconName:t.previousYearIconName},key:4})])]),h(m,6,[c(0,{on:C||(r._m2={click:n(t.handleModeChangeClick)})},null),c(2,null,d(t.computedYearTitle))]),l("div",Y,[l("span",{className:s(t.computeNextYearIconClass),key:8,on:j||(r._m3={click:n(t.goToNextYear)})},[o("kd-icon",i,{props:{iconName:t.nextYearIconName},key:9})])])])]),l("div",v,f(t.months,function(e){return h(p,u(12,e.numeric),[c(0,{on:M||(r._m5={click:n(t.handleMonthClick)}),attrs:{"aria-selected":e.isSelected,"aria-current":e.isCurrent,"data-month":e.numeric}},null),c(1,null,d(e.fullName))])}))]}var _=t(f);f.stylesheets=[],f.stylesheetToken="kwc-6s2fno4cj8c",f.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarMonth-undefined_calendarMonth",n&&f.stylesheets.push.apply(f.stylesheets,n),a(f);class y extends o{constructor(...e){super(...e),this._selectedDate=null,this.calendarYear=null,this.calendarMonth=null,this._calendarDate=null}get calendarDate(){return this._calendarDate}set calendarDate(e){this._calendarDate=e,e&&this.renderCalendar(e)}get value(){return this._selectedDate}set value(e){const t=this.parseDate(e,h,!0);t&&(this._selectedDate=e,this.renderCalendar(t))}renderCalendar(e){this.calendarMonth=e.getMonth(),this.calendarYear=e.getFullYear()}get computedYearTitle(){return`${this.padStartZero(this.calendarYear)}年`}get months(){return u().map((e,t)=>({...e,isCurrent:this.getTodaysDate().getMonth()===e.numeric&&this.calendarYear===this.getTodaysDate().getFullYear(),isSelected:!!this.getSelectedDate()&&(this.getSelectedDate().getMonth()===t&&this.calendarYear===this.getSelectedDate().getFullYear())}))}get hostDirection(){let e;return c&&(e=window.getComputedStyle(this.template.host)),e?e.direction.toLowerCase():"ltr"}get previousYearIconName(){return"ltr"===this.hostDirection?"kdfont-qianfanshuangjiantou":"kdfont-houfanshuangjiantou"}get nextYearIconName(){return"ltr"===this.hostDirection?"kdfont-houfanshuangjiantou ":"kdfont-qianfanshuangjiantou"}get canPrevYear(){return this.calendarYear-1>=1}get canNextYear(){return this.calendarYear+1<=9999}get computePrevYearIconClass(){return this.canPrevYear?"":"disabled"}get computeNextYearIconClass(){return this.canNextYear?"":"disabled"}getCalendarDate(){if(this.calendarYear){const e=`${this.padStartZero(this.calendarYear)}-${this.padStartZero(this.calendarMonth+1,2)}-01`;return new Date(e)}return this.getTodaysDate()}getTodaysDate(){return this.todayDate?this.parseDate(this.todayDate):new Date}getSelectedDate(){return this.parseDate(this.value)}parseDate(e){return l(e,h,!0)}handleModeChangeClick(e){if(e.stopPropagation(),"SPAN"===e.target.tagName){const t=e.target.getAttribute("data-value");this.dispatchEvent(new CustomEvent("modechange",{detail:{value:t}}))}}handleMonthClick(e){const t=e.target.getAttribute("data-month");this.dispatchEvent(new CustomEvent("privatemonthselect",{detail:{month:t,year:this.calendarYear}}))}padStartZero(e,t=4){return e.toString().padStart(t,"0")}goToNextYear(e){if(e.stopPropagation(),!this.canNextYear)return;const t=this.getCalendarDate();t.setFullYear(t.getFullYear()+1),this.renderCalendar(t)}goToPreviousYear(e){if(e.stopPropagation(),!this.canPrevYear)return;const t=this.getCalendarDate();t.setFullYear(t.getFullYear()-1),this.renderCalendar(t)}connectedCallback(){super.connectedCallback(),this._connected=!0,this.todayDate=d();const e=this._calendarDate||this.getSelectedDate()||this.getTodaysDate();this.renderCalendar(e)}disconnectedCallback(){this._connected=!1}}r(y,{publicProps:{calendarDate:{config:3},value:{config:3}},track:{calendarYear:1,calendarMonth:1,_calendarDate:1},fields:["_selectedDate"]});const C=s(y,{tmpl:_,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarMonth-",apiVersion:63});export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as r,registerComponent as s}from"@kdcloudjs/kwc";import{s as i}from"../calendarMonth-D9AFuDlp.js";import n from"./icon.js";import o from"./shadowBaseClassPrivate.js";import{z as l,i as d}from"../intlFormat-DNT_1eg4.js";import"../i18n-B98kiI7M.js";import{i as c}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import{STANDARD_DATE_FORMAT as p}from"./iso8601Utils.js";import"../calendar.kdds-DkhZH3qI.js";import"../utilsPrivate-ekbvijnB.js";import"../client-Ddi3i8XR.js";import"../colorValid-qIPgkqGp.js";import"../empty_html-CjXB8rB4.js";import"./i18nCldrOptions.js";import"./i18nService.js";import"./configProvider.js";import"../classSet-DY6Qvt6E.js";import"../labelUtils-DAuN2uUV.js";import"../label-CY8Q8HAO.js";import"./features.js";var
|
|
1
|
+
import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as r,registerComponent as s}from"@kdcloudjs/kwc";import{s as i}from"../calendarMonth-D9AFuDlp.js";import n from"./icon.js";import o from"./shadowBaseClassPrivate.js";import{z as l,i as d}from"../intlFormat-DNT_1eg4.js";import"../i18n-B98kiI7M.js";import{i as c}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import{STANDARD_DATE_FORMAT as p}from"./iso8601Utils.js";import"../calendar.kdds-DkhZH3qI.js";import"../utilsPrivate-ekbvijnB.js";import"../client-Ddi3i8XR.js";import"../colorValid-qIPgkqGp.js";import"../empty_html-CjXB8rB4.js";import"./i18nCldrOptions.js";import"./i18nService.js";import"./configProvider.js";import"../classSet-DY6Qvt6E.js";import"../labelUtils-DAuN2uUV.js";import"../label-CY8Q8HAO.js";import"./features.js";var u=[i,function(e,t,a){var r=e?"["+e+"]":"",s=e?"["+e+"-host]":"";return(t?":host [role='year-title']"+r+",\r:host [role='year-title']:hover":s+" [role='year-title']"+r+","+s+" [role='year-title']:hover")+r+" {color: var(--kdds-c-datepicker-switch-color);pointer-events: none;}"}];const m=e`<div class="kdds-align-middle kdds-middle-text${0}"${2}><span role="year-title"${3}>${"t2"}</span></div>`,h=e`<button class="kdds-button kdds-month-button${0}"${"a0:data-year"}${"a0:aria-selected"}${"a0:aria-current"}${2}>${"t1"}</button>`,k={classMap:{"kdds-datepicker__filter":!0,"kdds-grid":!0},key:0},g={classMap:{"kdds-datepicker__filter_month":!0,"kdds-grid":!0,"kdds-grid_align-spread":!0,"kdds-grow":!0},key:1},Y={classMap:{"kdds-align-middle":!0},key:2},v={classMap:{"kdds-align-middle":!0},key:7},y={classMap:{"kdds-datepicker__month-list":!0},key:10};function f(e,t,a,r){const{ncls:s,b:i,c:o,h:l,d:d,sp:c,st:p,k:u,i:f}=e,{_m0:j,_m1:b,_m2:_,_m3:D}=r;return[l("div",k,[l("div",g,[l("div",Y,[l("span",{className:s(t.computePrevYearIconClass),key:3,on:j||(r._m0={click:i(t.goToPreviousYearRange)})},[o("kd-icon",n,{props:{iconName:t.previousYearIconName},key:4})])]),p(m,6,[c(2,null,d(t.computedYearTitle))]),l("div",v,[l("span",{className:s(t.computeNextYearIconClass),key:8,on:b||(r._m1={click:i(t.goToNextYearRange)})},[o("kd-icon",n,{props:{iconName:t.nextYearIconName},key:9})])])])]),l("div",y,f(t.years,function(e){return p(h,u(12,e.fullName),[c(0,{on:D||(r._m3={click:i(t.handleYearClick)}),attrs:{"data-year":e.fullName,"aria-selected":e.isSelected,"aria-current":e.isCurrent}},null),c(1,null,d(e.fullName))])}))]}var j=t(f);f.stylesheets=[],f.stylesheetToken="kwc-5g8qgb1ol8e",f.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarYear-undefined_calendarYear",u&&f.stylesheets.push.apply(f.stylesheets,u),a(f);class b extends o{constructor(...e){super(...e),this.value=void 0,this.calendarYear=void 0}renderCalendar(e){let t=e.getFullYear();t>1&&(t=Math.max(1,t-14)),t<9999&&(t=Math.min(9999,t+14)),this.calendarYear=t}get computedYearTitle(){const e=this.calendarYear-14,t=this.calendarYear;return`${this.padYear(e)} - ${this.padYear(t)}`}get years(){const e=this.calendarYear-14,t=[];for(let a=0;a<15;a++){const r=e+a;t.push({fullName:this.padYear(r),isCurrent:this.getTodaysDate().getFullYear()===e+a,isSelected:this.value&&e+a===this.getSelectedDate()?.getFullYear(),isDisabled:!1})}return t}get hostDirection(){let e;return c&&(e=window.getComputedStyle(this.template.host)),e?e.direction.toLowerCase():"ltr"}get previousYearIconName(){return"ltr"===this.hostDirection?"kdfont-qianfanshuangjiantou":"kdfont-houfanshuangjiantou"}get nextYearIconName(){return"ltr"===this.hostDirection?"kdfont-houfanshuangjiantou ":"kdfont-qianfanshuangjiantou"}get canPrevYear(){return this.calendarYear>15}get canNextYear(){return this.calendarYear<9999}get computePrevYearIconClass(){return this.canPrevYear?"":"disabled"}get computeNextYearIconClass(){return this.canNextYear?"":"disabled"}getTodaysDate(){return this.todayDate?this.parseDate(this.todayDate):new Date}getSelectedDate(){return this.parseDate(this.value)}parseDate(e){return l(e,p,!0)}handleYearClick(e){const t=e.target.getAttribute("data-year");this.dispatchEvent(new CustomEvent("privateyearselect",{detail:{value:t}}))}padYear(e){return e.toString().padStart(4,"0")}goToPreviousYearRange(){this.canPrevYear&&(this.calendarYear=Math.max(15,this.calendarYear-15))}goToNextYearRange(){this.canNextYear&&(this.calendarYear=Math.min(9999,this.calendarYear+15))}connectedCallback(){super.connectedCallback(),this._connected=!0,this.todayDate=d();const e=this.getSelectedDate()||this.getTodaysDate();this.renderCalendar(e)}disconnectedCallback(){this._connected=!1}}r(b,{publicProps:{value:{config:0}},track:{calendarYear:1}});const _=s(b,{tmpl:j,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarYear-",apiVersion:63});export{_ as default};
|