@kupola/kupola 2.0.0-beta.2 → 2.0.0-beta.3

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.
Files changed (35) hide show
  1. package/dist/kupola-core-datepicker.cjs.js +9 -9
  2. package/dist/kupola-core-datepicker.esm.js +9 -9
  3. package/dist/kupola-core-dialog.cjs.js +8 -8
  4. package/dist/kupola-core-dialog.esm.js +8 -8
  5. package/dist/kupola-core-drawer.cjs.js +5 -5
  6. package/dist/kupola-core-drawer.esm.js +5 -5
  7. package/dist/kupola-core-dropdown.cjs.js +4 -4
  8. package/dist/kupola-core-dropdown.esm.js +4 -4
  9. package/dist/kupola-core-i18n.cjs.js +1 -1
  10. package/dist/kupola-core-i18n.esm.js +1 -1
  11. package/dist/kupola-core-modal.cjs.js +2 -2
  12. package/dist/kupola-core-modal.esm.js +2 -2
  13. package/dist/kupola-core-numberinput.cjs.js +6 -5
  14. package/dist/kupola-core-numberinput.esm.js +6 -5
  15. package/dist/kupola-core-select.cjs.js +8 -7
  16. package/dist/kupola-core-select.esm.js +8 -7
  17. package/dist/kupola-core-table.cjs.js +1 -1
  18. package/dist/kupola-core-table.esm.js +1 -1
  19. package/dist/kupola-core-timepicker.cjs.js +3 -3
  20. package/dist/kupola-core-timepicker.esm.js +3 -3
  21. package/dist/kupola-core.cjs.js +1 -1
  22. package/dist/kupola-core.esm.js +1 -1
  23. package/package.json +1 -1
  24. package/packages/core/src/components/datepicker.js +11 -6
  25. package/packages/core/src/components/dialog.js +14 -7
  26. package/packages/core/src/components/drawer.js +5 -3
  27. package/packages/core/src/components/dropdown.js +15 -3
  28. package/packages/core/src/components/modal.js +20 -1
  29. package/packages/core/src/components/numberinput.js +12 -3
  30. package/packages/core/src/components/select.js +22 -5
  31. package/packages/core/src/components/table.js +3 -1
  32. package/packages/core/src/components/timepicker.js +2 -1
  33. package/packages/core/src/errors.js +80 -0
  34. package/packages/core/src/i18n.js +5 -0
  35. package/packages/core/src/index.js +3 -0
@@ -1,8 +1,8 @@
1
- "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return new t(n,e)}function e(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function s(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const e=Object.getPrototypeOf(t);if(e){const t=Object.getOwnPropertyDescriptor(e,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):c(i)?e.push(o(i.value)):"function"!=typeof i&&e.push(o(i??""))}return e.join("")}function l(t,n){const e=t.indexOf(n);if(-1===e)return{type:"text"};const s=t.substring(0,e).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,e).includes(">"))return{type:"text"};const i=t.substring(s+1,e).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const o=i[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class a{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,n,e){this.element=t,this.attrName=n,this.rawValue=e,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class f{constructor(t,n,e){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=e,this.k=null}mount(){"function"==typeof this.handler&&(this.k=t=>this.handler(t),this.element.addEventListener(this.eventName,this.k))}destroy(){this.k&&(this.element.removeEventListener(this.eventName,this.k),this.k=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,e){const s=new h,i=function(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):"function"==typeof i||c(i)?e.push(r(s)):e.push(o(i??""))}return e.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);s.fragment=l,y(l,n.values,i,s);for(const t of s.parts)t.mount();return e.appendChild(l),s}function y(t,n,e,s){const i=[...t.childNodes];for(const o of i)3===o.nodeType?k(o,n,e,s,t):1===o.nodeType&&_(o,n,e,s)}function k(t,n,e,s,i){const o=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),d=o.indexOf(u);if(-1===d)continue;if("text"!==l(e,u).type)continue;const f=o.substring(0,d),h=o.substring(d+u.length);f&&i.insertBefore(document.createTextNode(f),t);const p=new a(i,n[c]);s.parts.push(p);let y=t;return h&&(y=document.createTextNode(h),i.insertBefore(y,t)),i.removeChild(t),p.p=y!==t?y:null,void(h&&k(y,n,e,s,i))}}function _(t,n,e,s){const i=[...t.attributes];for(const o of i)for(let i=0;i<n.length;i++){const c=r(i);if(!o.value.includes(c))continue;const u=l(e,c);if("event"===u.type&&u.attrName===o.name){t.removeAttribute(o.name);const e=new f(t,o.name,n[i]);s.parts.push(e)}else if("attr"===u.type&&u.attrName===o.name){const e=o.value.replace(c,"");e?t.setAttribute(o.name,e):t.removeAttribute(o.name);const r=new d(t,o.name,n[i]);s.parts.push(r)}}y(t,n,e,s)}const w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.Datepicker=function(t={}){const{placeholder:e="Select date",format:s="YYYY-MM-DD",value:i="",weekStart:o=1,minDate:c=null,maxDate:r=null,onChange:u=null}=t;let l=!1,a=(new Date).getFullYear(),d=(new Date).getMonth(),f=null,h=null;i&&(f=_(i),f&&(a=f.getFullYear(),d=f.getMonth()));const y=c?_(c):null,k=r?_(r):null;function _(t){if(!t)return null;let n=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);return n?new Date(+n[1],+n[2]-1,+n[3]):(n=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),n?new Date(+n[3],+n[1]-1,+n[2]):(n=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/),n?new Date(+n[3],+n[2]-1,+n[1]):null))}function v(t){if(!t)return"";const n=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");switch(s){case"MM/DD/YYYY":return`${e}/${i}/${n}`;case"DD/MM/YYYY":return`${i}.${e}.${n}`;default:return`${n}-${e}-${i}`}}function g(t){return!!(y&&t<y)||!!(k&&t>k)}function $(t,n){return new Date(t,n+1,0).getDate()}function m(){if(l)return;l=!0;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="block")}function x(){if(!l)return;l=!1;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="none")}function D(){l?x():m()}function b(){const t=C?C.querySelector(".ds-datepicker__input"):null;t&&(t.value=f?v(f):"")}function S(){const t=C?C.querySelector(".ds-datepicker__calendar"):null;if(!t)return;const n=t.querySelector(".ds-datepicker__title");n&&(n.textContent=`${w[d]} ${a}`);const e=t.querySelector(".ds-datepicker__days");if(!e)return;e.innerHTML="";(function(){const t=$(a,d);let n=new Date(a,d,1).getDay();1===o&&(n=0===n?6:n-1);const e=[],s=0===d?11:d-1,i=0===d?a-1:a,c=$(i,s);for(let t=n-1;t>=0;t--)e.push({date:new Date(i,s,c-t),outside:!0});for(let n=1;n<=t;n++)e.push({date:new Date(a,d,n),outside:!1});const r=7-e.length%7;if(r<7){const t=11===d?0:d+1,n=11===d?a+1:a;for(let s=1;s<=r;s++)e.push({date:new Date(n,t,s),outside:!0})}return e})().forEach(({date:t,outside:n})=>{const s=document.createElement("button");s.textContent=t.getDate(),n&&s.classList.add("is-outside"),function(t){const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}(t)&&s.classList.add("is-today"),function(t){return!!f&&t.getFullYear()===f.getFullYear()&&t.getMonth()===f.getMonth()&&t.getDate()===f.getDate()}(t)&&s.classList.add("is-selected"),g(t)&&(s.disabled=!0,s.style.opacity="0.3",s.style.cursor="not-allowed"),s.addEventListener("click",n=>{n.stopPropagation(),function(t){g(t)||(f=t,a=t.getFullYear(),d=t.getMonth(),b(),S(),x(),u&&u(v(t),t))}(t)}),e.appendChild(s)})}const Y=t=>{l&&C&&!C.contains(t.target)&&x()};document.addEventListener("click",Y);const M=t=>{"Escape"===t.key&&l&&x()};document.addEventListener("keydown",M);const j=n`
1
+ "use strict";class t{constructor(t,e){this.strings=t,this.values=e}}function e(e,...n){return new t(e,n)}function n(t){const e={t:t,o:new Set,i:null,l:!1};return e.i=()=>{e.l||o(e)},o(e),()=>function(t){if(t.l)return;t.l=!0,i(t)}(e)}function o(t){i(t);try{t.t()}finally{}}function i(t){for(const e of t.o)e.u.delete(t);t.o.clear()}function s(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const e=Object.getOwnPropertyDescriptor(t,"value");if(e&&"function"==typeof e.get)return!0;const n=Object.getPrototypeOf(t);if(n){const t=Object.getOwnPropertyDescriptor(n,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function l(e){const n=[];for(let o=0;o<e.strings.length;o++)if(n.push(e.strings[o]),o<e.values.length){const i=e.values[o];i instanceof t?n.push(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?n.push(i.map(l).join("")):c(i)?n.push(s(i.value)):"function"!=typeof i&&n.push(s(i??""))}return n.join("")}function a(t,e){const n=t.indexOf(e);if(-1===n)return{type:"text"};const o=t.substring(0,n).lastIndexOf("<");if(-1===o)return{type:"text"};if(t.substring(o,n).includes(">"))return{type:"text"};const i=t.substring(o+1,n).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const s=i[1];return s.startsWith("on")&&s.length>2?{type:"event",attrName:s}:{type:"attr",attrName:s}}class u{constructor(t,e){this.container=t,this.rawValue=e,this.node=null,this.h=null}mount(){const e=document.createTextNode("");if(this.p?this.container.insertBefore(e,this.p):this.container.appendChild(e),this.node=e,c(this.rawValue)){const t=this.rawValue;this.h=n(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,e,n){this.element=t,this.attrName=e,this.rawValue=n,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=n(()=>{const e=t.value;null==e||!1===e?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(e))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class f{constructor(t,e,n){this.element=t,this.eventName=e.slice(2).toLowerCase(),this.handler=n,this.k=null}mount(){"function"==typeof this.handler&&(this.k=t=>this.handler(t),this.element.addEventListener(this.eventName,this.k))}destroy(){this.k&&(this.element.removeEventListener(this.eventName,this.k),this.k=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(e,n){const o=new h,i=function(e){const n=[];for(let o=0;o<e.strings.length;o++)if(n.push(e.strings[o]),o<e.values.length){const i=e.values[o];i instanceof t?n.push(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?n.push(i.map(l).join("")):"function"==typeof i||c(i)?n.push(r(o)):n.push(s(i??""))}return n.join("")}(e),a=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(i);o.fragment=a,k(a,e.values,i,o);for(const t of o.parts)t.mount();return n.appendChild(a),o}function k(t,e,n,o){const i=[...t.childNodes];for(const s of i)3===s.nodeType?y(s,e,n,o,t):1===s.nodeType&&g(s,e,n,o)}function y(t,e,n,o,i){const s=t.textContent||"";for(let c=0;c<e.length;c++){const l=r(c),d=s.indexOf(l);if(-1===d)continue;if("text"!==a(n,l).type)continue;const f=s.substring(0,d),h=s.substring(d+l.length);f&&i.insertBefore(document.createTextNode(f),t);const p=new u(i,e[c]);o.parts.push(p);let k=t;return h&&(k=document.createTextNode(h),i.insertBefore(k,t)),i.removeChild(t),p.p=k!==t?k:null,void(h&&y(k,e,n,o,i))}}function g(t,e,n,o){const i=[...t.attributes];for(const s of i)for(let i=0;i<e.length;i++){const c=r(i);if(!s.value.includes(c))continue;const l=a(n,c);if("event"===l.type&&l.attrName===s.name){t.removeAttribute(s.name);const n=new f(t,s.name,e[i]);o.parts.push(n)}else if("attr"===l.type&&l.attrName===s.name){const n=s.value.replace(c,"");n?t.setAttribute(s.name,n):t.removeAttribute(s.name);const r=new d(t,s.name,e[i]);o.parts.push(r)}}k(t,e,n,o)}const w={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};function m(t,e={}){let n=(w["en-US"]||w["en-US"])[t]||t;for(const[t,o]of Object.entries(e))n=n.replace(`{${t}}`,o);return n}exports.Datepicker=function(t={}){const{placeholder:n=null,format:o="YYYY-MM-DD",value:i="",weekStart:s=1,minDate:c=null,maxDate:r=null,onChange:l=null}=t,a=n||m("datepicker.placeholder"),u=m("datepicker.months").split(","),d=m("datepicker.weekdays").split(",");let f=!1,h=(new Date).getFullYear(),k=(new Date).getMonth(),y=null,g=null;i&&(y=v(i),y&&(h=y.getFullYear(),k=y.getMonth()));const w=c?v(c):null,_=r?v(r):null;function v(t){if(!t)return null;let e=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);return e?new Date(+e[1],+e[2]-1,+e[3]):(e=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),e?new Date(+e[3],+e[1]-1,+e[2]):(e=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/),e?new Date(+e[3],+e[2]-1,+e[1]):null))}function $(t){if(!t)return"";const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");switch(o){case"MM/DD/YYYY":return`${n}/${i}/${e}`;case"DD/MM/YYYY":return`${i}.${n}.${e}`;default:return`${e}-${n}-${i}`}}function x(t){return!!(w&&t<w)||!!(_&&t>_)}function D(t,e){return new Date(t,e+1,0).getDate()}function b(){if(f)return;f=!0;const t=B?B.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="block")}function S(){if(!f)return;f=!1;const t=B?B.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="none")}function Y(){f?S():b()}function M(){const t=B?B.querySelector(".ds-datepicker__input"):null;t&&(t.value=y?$(y):"")}function C(){const t=B?B.querySelector(".ds-datepicker__calendar"):null;if(!t)return;const e=t.querySelector(".ds-datepicker__title");e&&(e.textContent=`${u[k]} ${h}`);const n=t.querySelector(".ds-datepicker__days");if(!n)return;n.innerHTML="";(function(){const t=D(h,k);let e=new Date(h,k,1).getDay();1===s&&(e=0===e?6:e-1);const n=[],o=0===k?11:k-1,i=0===k?h-1:h,c=D(i,o);for(let t=e-1;t>=0;t--)n.push({date:new Date(i,o,c-t),outside:!0});for(let e=1;e<=t;e++)n.push({date:new Date(h,k,e),outside:!1});const r=7-n.length%7;if(r<7){const t=11===k?0:k+1,e=11===k?h+1:h;for(let o=1;o<=r;o++)n.push({date:new Date(e,t,o),outside:!0})}return n})().forEach(({date:t,outside:e})=>{const o=document.createElement("button");o.textContent=t.getDate(),e&&o.classList.add("is-outside"),function(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}(t)&&o.classList.add("is-today"),function(t){return!!y&&t.getFullYear()===y.getFullYear()&&t.getMonth()===y.getMonth()&&t.getDate()===y.getDate()}(t)&&o.classList.add("is-selected"),x(t)&&(o.disabled=!0,o.style.opacity="0.3",o.style.cursor="not-allowed"),o.addEventListener("click",e=>{e.stopPropagation(),function(t){x(t)||(y=t,h=t.getFullYear(),k=t.getMonth(),M(),C(),S(),l&&l($(t),t))}(t)}),n.appendChild(o)})}const N=t=>{f&&B&&!B.contains(t.target)&&S()};document.addEventListener("click",N);const O=t=>{"Escape"===t.key&&f&&S()};document.addEventListener("keydown",O);const j=e`
2
2
  <div class="ds-datepicker">
3
- <div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),D()}}">
4
- <input class="ds-datepicker__input" type="text" readonly placeholder="${e}" value="${f?v(f):""}" />
5
- <button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),D()}}">
3
+ <div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),Y()}}">
4
+ <input class="ds-datepicker__input" type="text" readonly placeholder="${a}" value="${y?$(y):""}" />
5
+ <button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),Y()}}">
6
6
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
7
7
  <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
8
8
  <line x1="16" y1="2" x2="16" y2="6"/>
@@ -13,16 +13,16 @@
13
13
  </div>
14
14
  <div class="ds-datepicker__calendar" style="display:none">
15
15
  <div class="ds-datepicker__header">
16
- <button class="ds-datepicker__nav" onclick="${function(){0===d?(d=11,a--):d--,S()}}" aria-label="Previous month">
16
+ <button class="ds-datepicker__nav" onclick="${function(){0===k?(k=11,h--):k--,C()}}" aria-label="Previous month">
17
17
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
18
18
  </button>
19
- <span class="ds-datepicker__title">${`${w[d]} ${a}`}</span>
20
- <button class="ds-datepicker__nav" onclick="${function(){11===d?(d=0,a++):d++,S()}}" aria-label="Next month">
19
+ <span class="ds-datepicker__title">${`${u[k]} ${h}`}</span>
20
+ <button class="ds-datepicker__nav" onclick="${function(){11===k?(k=0,h++):k++,C()}}" aria-label="Next month">
21
21
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
22
22
  </button>
23
23
  </div>
24
- <div class="ds-datepicker__weekdays">${(1===o?["Mo","Tu","We","Th","Fr","Sa","Su"]:["Su","Mo","Tu","We","Th","Fr","Sa"]).map(t=>n`<span>${t}</span>`)}</div>
24
+ <div class="ds-datepicker__weekdays">${(1===s?d:[d[6],...d.slice(0,6)]).map(t=>e`<span>${t}</span>`)}</div>
25
25
  <div class="ds-datepicker__days"></div>
26
26
  </div>
27
27
  </div>
28
- `,A=document.createDocumentFragment();h=p(j,A);const C=A.querySelector(".ds-datepicker");return S(),{get element(){return A},open:m,close:x,toggle:D,getValue:function(){return f?v(f):""},setValue:function(t){f=_(t),f&&(a=f.getFullYear(),d=f.getMonth()),b(),S()},destroy(){document.removeEventListener("click",Y),document.removeEventListener("keydown",M),h&&h.destroy()}}};
28
+ `,A=document.createDocumentFragment();g=p(j,A);const B=A.querySelector(".ds-datepicker");return C(),{get element(){return A},open:b,close:S,toggle:Y,getValue:function(){return y?$(y):""},setValue:function(t){y=v(t),y&&(h=y.getFullYear(),k=y.getMonth()),M(),C()},destroy(){document.removeEventListener("click",N),document.removeEventListener("keydown",O),g&&g.destroy()}}};
@@ -1,8 +1,8 @@
1
- class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return new t(n,e)}function e(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function s(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const e=Object.getPrototypeOf(t);if(e){const t=Object.getOwnPropertyDescriptor(e,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):c(i)?e.push(o(i.value)):"function"!=typeof i&&e.push(o(i??""))}return e.join("")}function l(t,n){const e=t.indexOf(n);if(-1===e)return{type:"text"};const s=t.substring(0,e).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,e).includes(">"))return{type:"text"};const i=t.substring(s+1,e).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const o=i[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class a{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,n,e){this.element=t,this.attrName=n,this.rawValue=e,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class f{constructor(t,n,e){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=e,this.k=null}mount(){"function"==typeof this.handler&&(this.k=t=>this.handler(t),this.element.addEventListener(this.eventName,this.k))}destroy(){this.k&&(this.element.removeEventListener(this.eventName,this.k),this.k=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,e){const s=new h,i=function(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):"function"==typeof i||c(i)?e.push(r(s)):e.push(o(i??""))}return e.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);s.fragment=l,y(l,n.values,i,s);for(const t of s.parts)t.mount();return e.appendChild(l),s}function y(t,n,e,s){const i=[...t.childNodes];for(const o of i)3===o.nodeType?k(o,n,e,s,t):1===o.nodeType&&_(o,n,e,s)}function k(t,n,e,s,i){const o=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),d=o.indexOf(u);if(-1===d)continue;if("text"!==l(e,u).type)continue;const f=o.substring(0,d),h=o.substring(d+u.length);f&&i.insertBefore(document.createTextNode(f),t);const p=new a(i,n[c]);s.parts.push(p);let y=t;return h&&(y=document.createTextNode(h),i.insertBefore(y,t)),i.removeChild(t),p.p=y!==t?y:null,void(h&&k(y,n,e,s,i))}}function _(t,n,e,s){const i=[...t.attributes];for(const o of i)for(let i=0;i<n.length;i++){const c=r(i);if(!o.value.includes(c))continue;const u=l(e,c);if("event"===u.type&&u.attrName===o.name){t.removeAttribute(o.name);const e=new f(t,o.name,n[i]);s.parts.push(e)}else if("attr"===u.type&&u.attrName===o.name){const e=o.value.replace(c,"");e?t.setAttribute(o.name,e):t.removeAttribute(o.name);const r=new d(t,o.name,n[i]);s.parts.push(r)}}y(t,n,e,s)}const w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function v(t={}){const{placeholder:e="Select date",format:s="YYYY-MM-DD",value:i="",weekStart:o=1,minDate:c=null,maxDate:r=null,onChange:u=null}=t;let l=!1,a=(new Date).getFullYear(),d=(new Date).getMonth(),f=null,h=null;i&&(f=_(i),f&&(a=f.getFullYear(),d=f.getMonth()));const y=c?_(c):null,k=r?_(r):null;function _(t){if(!t)return null;let n=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);return n?new Date(+n[1],+n[2]-1,+n[3]):(n=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),n?new Date(+n[3],+n[1]-1,+n[2]):(n=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/),n?new Date(+n[3],+n[2]-1,+n[1]):null))}function v(t){if(!t)return"";const n=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");switch(s){case"MM/DD/YYYY":return`${e}/${i}/${n}`;case"DD/MM/YYYY":return`${i}.${e}.${n}`;default:return`${n}-${e}-${i}`}}function g(t){return!!(y&&t<y)||!!(k&&t>k)}function $(t,n){return new Date(t,n+1,0).getDate()}function m(){if(l)return;l=!0;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="block")}function x(){if(!l)return;l=!1;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="none")}function D(){l?x():m()}function b(){const t=C?C.querySelector(".ds-datepicker__input"):null;t&&(t.value=f?v(f):"")}function S(){const t=C?C.querySelector(".ds-datepicker__calendar"):null;if(!t)return;const n=t.querySelector(".ds-datepicker__title");n&&(n.textContent=`${w[d]} ${a}`);const e=t.querySelector(".ds-datepicker__days");if(!e)return;e.innerHTML="";(function(){const t=$(a,d);let n=new Date(a,d,1).getDay();1===o&&(n=0===n?6:n-1);const e=[],s=0===d?11:d-1,i=0===d?a-1:a,c=$(i,s);for(let t=n-1;t>=0;t--)e.push({date:new Date(i,s,c-t),outside:!0});for(let n=1;n<=t;n++)e.push({date:new Date(a,d,n),outside:!1});const r=7-e.length%7;if(r<7){const t=11===d?0:d+1,n=11===d?a+1:a;for(let s=1;s<=r;s++)e.push({date:new Date(n,t,s),outside:!0})}return e})().forEach(({date:t,outside:n})=>{const s=document.createElement("button");s.textContent=t.getDate(),n&&s.classList.add("is-outside"),function(t){const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}(t)&&s.classList.add("is-today"),function(t){return!!f&&t.getFullYear()===f.getFullYear()&&t.getMonth()===f.getMonth()&&t.getDate()===f.getDate()}(t)&&s.classList.add("is-selected"),g(t)&&(s.disabled=!0,s.style.opacity="0.3",s.style.cursor="not-allowed"),s.addEventListener("click",n=>{n.stopPropagation(),function(t){g(t)||(f=t,a=t.getFullYear(),d=t.getMonth(),b(),S(),x(),u&&u(v(t),t))}(t)}),e.appendChild(s)})}const Y=t=>{l&&C&&!C.contains(t.target)&&x()};document.addEventListener("click",Y);const M=t=>{"Escape"===t.key&&l&&x()};document.addEventListener("keydown",M);const j=n`
1
+ class t{constructor(t,e){this.strings=t,this.values=e}}function e(e,...n){return new t(e,n)}function n(t){const e={t:t,o:new Set,i:null,l:!1};return e.i=()=>{e.l||o(e)},o(e),()=>function(t){if(t.l)return;t.l=!0,i(t)}(e)}function o(t){i(t);try{t.t()}finally{}}function i(t){for(const e of t.o)e.u.delete(t);t.o.clear()}function s(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const e=Object.getOwnPropertyDescriptor(t,"value");if(e&&"function"==typeof e.get)return!0;const n=Object.getPrototypeOf(t);if(n){const t=Object.getOwnPropertyDescriptor(n,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function l(e){const n=[];for(let o=0;o<e.strings.length;o++)if(n.push(e.strings[o]),o<e.values.length){const i=e.values[o];i instanceof t?n.push(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?n.push(i.map(l).join("")):c(i)?n.push(s(i.value)):"function"!=typeof i&&n.push(s(i??""))}return n.join("")}function a(t,e){const n=t.indexOf(e);if(-1===n)return{type:"text"};const o=t.substring(0,n).lastIndexOf("<");if(-1===o)return{type:"text"};if(t.substring(o,n).includes(">"))return{type:"text"};const i=t.substring(o+1,n).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const s=i[1];return s.startsWith("on")&&s.length>2?{type:"event",attrName:s}:{type:"attr",attrName:s}}class u{constructor(t,e){this.container=t,this.rawValue=e,this.node=null,this.h=null}mount(){const e=document.createTextNode("");if(this.p?this.container.insertBefore(e,this.p):this.container.appendChild(e),this.node=e,c(this.rawValue)){const t=this.rawValue;this.h=n(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,e,n){this.element=t,this.attrName=e,this.rawValue=n,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=n(()=>{const e=t.value;null==e||!1===e?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(e))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class f{constructor(t,e,n){this.element=t,this.eventName=e.slice(2).toLowerCase(),this.handler=n,this.k=null}mount(){"function"==typeof this.handler&&(this.k=t=>this.handler(t),this.element.addEventListener(this.eventName,this.k))}destroy(){this.k&&(this.element.removeEventListener(this.eventName,this.k),this.k=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(e,n){const o=new h,i=function(e){const n=[];for(let o=0;o<e.strings.length;o++)if(n.push(e.strings[o]),o<e.values.length){const i=e.values[o];i instanceof t?n.push(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?n.push(i.map(l).join("")):"function"==typeof i||c(i)?n.push(r(o)):n.push(s(i??""))}return n.join("")}(e),a=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(i);o.fragment=a,k(a,e.values,i,o);for(const t of o.parts)t.mount();return n.appendChild(a),o}function k(t,e,n,o){const i=[...t.childNodes];for(const s of i)3===s.nodeType?y(s,e,n,o,t):1===s.nodeType&&g(s,e,n,o)}function y(t,e,n,o,i){const s=t.textContent||"";for(let c=0;c<e.length;c++){const l=r(c),d=s.indexOf(l);if(-1===d)continue;if("text"!==a(n,l).type)continue;const f=s.substring(0,d),h=s.substring(d+l.length);f&&i.insertBefore(document.createTextNode(f),t);const p=new u(i,e[c]);o.parts.push(p);let k=t;return h&&(k=document.createTextNode(h),i.insertBefore(k,t)),i.removeChild(t),p.p=k!==t?k:null,void(h&&y(k,e,n,o,i))}}function g(t,e,n,o){const i=[...t.attributes];for(const s of i)for(let i=0;i<e.length;i++){const c=r(i);if(!s.value.includes(c))continue;const l=a(n,c);if("event"===l.type&&l.attrName===s.name){t.removeAttribute(s.name);const n=new f(t,s.name,e[i]);o.parts.push(n)}else if("attr"===l.type&&l.attrName===s.name){const n=s.value.replace(c,"");n?t.setAttribute(s.name,n):t.removeAttribute(s.name);const r=new d(t,s.name,e[i]);o.parts.push(r)}}k(t,e,n,o)}const w={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};function m(t,e={}){let n=(w["en-US"]||w["en-US"])[t]||t;for(const[t,o]of Object.entries(e))n=n.replace(`{${t}}`,o);return n}function _(t={}){const{placeholder:n=null,format:o="YYYY-MM-DD",value:i="",weekStart:s=1,minDate:c=null,maxDate:r=null,onChange:l=null}=t,a=n||m("datepicker.placeholder"),u=m("datepicker.months").split(","),d=m("datepicker.weekdays").split(",");let f=!1,h=(new Date).getFullYear(),k=(new Date).getMonth(),y=null,g=null;i&&(y=v(i),y&&(h=y.getFullYear(),k=y.getMonth()));const w=c?v(c):null,_=r?v(r):null;function v(t){if(!t)return null;let e=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);return e?new Date(+e[1],+e[2]-1,+e[3]):(e=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),e?new Date(+e[3],+e[1]-1,+e[2]):(e=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/),e?new Date(+e[3],+e[2]-1,+e[1]):null))}function $(t){if(!t)return"";const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");switch(o){case"MM/DD/YYYY":return`${n}/${i}/${e}`;case"DD/MM/YYYY":return`${i}.${n}.${e}`;default:return`${e}-${n}-${i}`}}function x(t){return!!(w&&t<w)||!!(_&&t>_)}function D(t,e){return new Date(t,e+1,0).getDate()}function b(){if(f)return;f=!0;const t=B?B.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="block")}function S(){if(!f)return;f=!1;const t=B?B.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="none")}function Y(){f?S():b()}function M(){const t=B?B.querySelector(".ds-datepicker__input"):null;t&&(t.value=y?$(y):"")}function C(){const t=B?B.querySelector(".ds-datepicker__calendar"):null;if(!t)return;const e=t.querySelector(".ds-datepicker__title");e&&(e.textContent=`${u[k]} ${h}`);const n=t.querySelector(".ds-datepicker__days");if(!n)return;n.innerHTML="";(function(){const t=D(h,k);let e=new Date(h,k,1).getDay();1===s&&(e=0===e?6:e-1);const n=[],o=0===k?11:k-1,i=0===k?h-1:h,c=D(i,o);for(let t=e-1;t>=0;t--)n.push({date:new Date(i,o,c-t),outside:!0});for(let e=1;e<=t;e++)n.push({date:new Date(h,k,e),outside:!1});const r=7-n.length%7;if(r<7){const t=11===k?0:k+1,e=11===k?h+1:h;for(let o=1;o<=r;o++)n.push({date:new Date(e,t,o),outside:!0})}return n})().forEach(({date:t,outside:e})=>{const o=document.createElement("button");o.textContent=t.getDate(),e&&o.classList.add("is-outside"),function(t){const e=new Date;return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}(t)&&o.classList.add("is-today"),function(t){return!!y&&t.getFullYear()===y.getFullYear()&&t.getMonth()===y.getMonth()&&t.getDate()===y.getDate()}(t)&&o.classList.add("is-selected"),x(t)&&(o.disabled=!0,o.style.opacity="0.3",o.style.cursor="not-allowed"),o.addEventListener("click",e=>{e.stopPropagation(),function(t){x(t)||(y=t,h=t.getFullYear(),k=t.getMonth(),M(),C(),S(),l&&l($(t),t))}(t)}),n.appendChild(o)})}const N=t=>{f&&B&&!B.contains(t.target)&&S()};document.addEventListener("click",N);const O=t=>{"Escape"===t.key&&f&&S()};document.addEventListener("keydown",O);const j=e`
2
2
  <div class="ds-datepicker">
3
- <div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),D()}}">
4
- <input class="ds-datepicker__input" type="text" readonly placeholder="${e}" value="${f?v(f):""}" />
5
- <button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),D()}}">
3
+ <div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),Y()}}">
4
+ <input class="ds-datepicker__input" type="text" readonly placeholder="${a}" value="${y?$(y):""}" />
5
+ <button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),Y()}}">
6
6
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
7
7
  <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
8
8
  <line x1="16" y1="2" x2="16" y2="6"/>
@@ -13,16 +13,16 @@ class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return
13
13
  </div>
14
14
  <div class="ds-datepicker__calendar" style="display:none">
15
15
  <div class="ds-datepicker__header">
16
- <button class="ds-datepicker__nav" onclick="${function(){0===d?(d=11,a--):d--,S()}}" aria-label="Previous month">
16
+ <button class="ds-datepicker__nav" onclick="${function(){0===k?(k=11,h--):k--,C()}}" aria-label="Previous month">
17
17
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
18
18
  </button>
19
- <span class="ds-datepicker__title">${`${w[d]} ${a}`}</span>
20
- <button class="ds-datepicker__nav" onclick="${function(){11===d?(d=0,a++):d++,S()}}" aria-label="Next month">
19
+ <span class="ds-datepicker__title">${`${u[k]} ${h}`}</span>
20
+ <button class="ds-datepicker__nav" onclick="${function(){11===k?(k=0,h++):k++,C()}}" aria-label="Next month">
21
21
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
22
22
  </button>
23
23
  </div>
24
- <div class="ds-datepicker__weekdays">${(1===o?["Mo","Tu","We","Th","Fr","Sa","Su"]:["Su","Mo","Tu","We","Th","Fr","Sa"]).map(t=>n`<span>${t}</span>`)}</div>
24
+ <div class="ds-datepicker__weekdays">${(1===s?d:[d[6],...d.slice(0,6)]).map(t=>e`<span>${t}</span>`)}</div>
25
25
  <div class="ds-datepicker__days"></div>
26
26
  </div>
27
27
  </div>
28
- `,A=document.createDocumentFragment();h=p(j,A);const C=A.querySelector(".ds-datepicker");return S(),{get element(){return A},open:m,close:x,toggle:D,getValue:function(){return f?v(f):""},setValue:function(t){f=_(t),f&&(a=f.getFullYear(),d=f.getMonth()),b(),S()},destroy(){document.removeEventListener("click",Y),document.removeEventListener("keydown",M),h&&h.destroy()}}}export{v as Datepicker};
28
+ `,A=document.createDocumentFragment();g=p(j,A);const B=A.querySelector(".ds-datepicker");return C(),{get element(){return A},open:b,close:S,toggle:Y,getValue:function(){return y?$(y):""},setValue:function(t){y=v(t),y&&(h=y.getFullYear(),k=y.getMonth()),M(),C()},destroy(){document.removeEventListener("click",N),document.removeEventListener("keydown",O),g&&g.destroy()}}}export{_ as Datepicker};
@@ -1,13 +1,13 @@
1
- "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||i(n)},i(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function l(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function u(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new d,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=u,v(u,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(u),i}function v(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function g(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(s,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);i.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[o]);i.parts.push(s)}else if("attr"===l.type&&l.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);i.parts.push(r)}}v(t,n,s,i)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:s="",content:i="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{p(),t(!0)},u=()=>{p(),t(!1)},h=t=>{t.target===t.currentTarget&&u()},f=t=>{"Escape"===t.key&&u(),"Enter"===t.key&&l()},a=n`
1
+ "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return new t(n,e)}function e(t){const n={t:t,o:new Set,i:null,l:!1};return n.i=()=>{n.l||o(n)},o(n),()=>function(t){if(t.l)return;t.l=!0,i(t)}(n)}function o(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.o)n.u.delete(t);t.o.clear()}function s(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const e=Object.getPrototypeOf(t);if(e){const t=Object.getOwnPropertyDescriptor(e,"value");if(t&&"function"==typeof t.get)return!0}return!1}const l=t=>`຿${t}຿`;function r(n){const e=[];for(let o=0;o<n.strings.length;o++)if(e.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?e.push(r(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(r).join("")):c(i)?e.push(s(i.value)):"function"!=typeof i&&e.push(s(i??""))}return e.join("")}function a(t,n){const e=t.indexOf(n);if(-1===e)return{type:"text"};const o=t.substring(0,e).lastIndexOf("<");if(-1===o)return{type:"text"};if(t.substring(o,e).includes(">"))return{type:"text"};const i=t.substring(o+1,e).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const s=i[1];return s.startsWith("on")&&s.length>2?{type:"event",attrName:s}:{type:"attr",attrName:s}}class d{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=r(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class u{constructor(t,n,e){this.element=t,this.attrName=n,this.rawValue=e,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class h{constructor(t,n,e){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=e,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class f{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,e){const o=new f,i=function(n){const e=[];for(let o=0;o<n.strings.length;o++)if(e.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?e.push(r(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(r).join("")):"function"==typeof i||c(i)?e.push(l(o)):e.push(s(i??""))}return e.join("")}(n),a=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=a,g(a,n.values,i,o);for(const t of o.parts)t.mount();return e.appendChild(a),o}function g(t,n,e,o){const i=[...t.childNodes];for(const s of i)3===s.nodeType?y(s,n,e,o,t):1===s.nodeType&&m(s,n,e,o)}function y(t,n,e,o,i){const s=t.textContent||"";for(let c=0;c<n.length;c++){const r=l(c),u=s.indexOf(r);if(-1===u)continue;if("text"!==a(e,r).type)continue;const h=s.substring(0,u),f=s.substring(u+r.length);h&&i.insertBefore(document.createTextNode(h),t);const p=new d(i,n[c]);o.parts.push(p);let g=t;return f&&(g=document.createTextNode(f),i.insertBefore(g,t)),i.removeChild(t),p.p=g!==t?g:null,void(f&&y(g,n,e,o,i))}}function m(t,n,e,o){const i=[...t.attributes];for(const s of i)for(let i=0;i<n.length;i++){const c=l(i);if(!s.value.includes(c))continue;const r=a(e,c);if("event"===r.type&&r.attrName===s.name){t.removeAttribute(s.name);const e=new h(t,s.name,n[i]);o.parts.push(e)}else if("attr"===r.type&&r.attrName===s.name){const e=s.value.replace(c,"");e?t.setAttribute(s.name,e):t.removeAttribute(s.name);const l=new u(t,s.name,n[i]);o.parts.push(l)}}g(t,n,e,o)}const v={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};function x(t,n={}){let e=(v["en-US"]||v["en-US"])[t]||t;for(const[t,o]of Object.entries(n))e=e.replace(`{${t}}`,o);return e}const w={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function k(t={}){const{title:e="",content:o="",type:i="normal",confirmText:s=null,cancelText:c=null,showCancel:l=!0}=t,r=s||x("dialog.ok"),a=c||x("dialog.cancel");return new Promise(t=>{const s=()=>{k(),t(!0)},c=()=>{k(),t(!1)},d=t=>{t.target===t.currentTarget&&c()},u=t=>{"Escape"===t.key&&c(),"Enter"===t.key&&s()},h=n`
2
2
  <div class="ds-modal-mask">
3
- <div class="ds-dialog">
4
- <div class="ds-dialog__icon ds-dialog__icon--${o}">${x[o]||x.normal}</div>
5
- <div class="ds-dialog__title">${s}</div>
6
- <div class="ds-dialog__content">${i}</div>
3
+ <div class="ds-dialog" role="alertdialog" aria-modal="true" aria-labelledby="dialog-title" aria-describedby="dialog-content" tabindex="-1">
4
+ <div class="ds-dialog__icon ds-dialog__icon--${i}">${w[i]||w.normal}</div>
5
+ <div class="ds-dialog__title" id="dialog-title">${e}</div>
6
+ <div class="ds-dialog__content" id="dialog-content">${o}</div>
7
7
  <div class="ds-dialog__actions">
8
- ${r?n`<button class="ds-btn ds-btn--ghost" data-action="cancel">${c}</button>`:""}
9
- <button class="ds-btn ds-btn--primary" data-action="confirm">${e}</button>
8
+ ${l?n`<button class="ds-btn ds-btn--ghost" data-action="cancel" type="button">${a}</button>`:""}
9
+ <button class="ds-btn ds-btn--primary" data-action="confirm" type="button">${r}</button>
10
10
  </div>
11
11
  </div>
12
12
  </div>
13
- `,d=document.createDocumentFragment(),v=y(a,d);document.body.appendChild(d);const g=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;g&&g.classList.add("is-visible"),document.body.style.overflow="hidden";const m=g.querySelector('[data-action="confirm"]'),w=g.querySelector('[data-action="cancel"]');function p(){document.removeEventListener("keydown",f),document.body.style.overflow="",g&&g.classList.remove("is-visible"),setTimeout(()=>{v.destroy(),g&&g.parentNode&&g.parentNode.removeChild(g)},50)}m&&m.addEventListener("click",l),w&&w.addEventListener("click",u),g&&g.addEventListener("click",h),document.addEventListener("keydown",f)})}const p={confirm:w,alert:function(t={}){return w({...t,showCancel:!1}).then(()=>{})}};exports.Dialog=p;
13
+ `,f=document.createDocumentFragment(),g=p(h,f);document.body.appendChild(f);const y=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;y&&y.classList.add("is-visible"),document.body.style.overflow="hidden";const m=y?.querySelector(".ds-dialog");m&&m.focus();const v=y.querySelector('[data-action="confirm"]'),x=y.querySelector('[data-action="cancel"]');function k(){document.removeEventListener("keydown",u),document.body.style.overflow="",y&&y.classList.remove("is-visible"),setTimeout(()=>{g.destroy(),y&&y.parentNode&&y.parentNode.removeChild(y)},50)}v&&v.addEventListener("click",s),x&&x.addEventListener("click",c),y&&y.addEventListener("click",d),document.addEventListener("keydown",u)})}const b={confirm:k,alert:function(t={}){return k({...t,showCancel:!1}).then(()=>{})}};exports.Dialog=b;
@@ -1,13 +1,13 @@
1
- class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...i){return new t(n,i)}function i(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||s(n)},s(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function s(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const i=Object.getPrototypeOf(t);if(i){const t=Object.getOwnPropertyDescriptor(i,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function l(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):c(o)?i.push(e(o.value)):"function"!=typeof o&&i.push(e(o??""))}return i.join("")}function u(t,n){const i=t.indexOf(n);if(-1===i)return{type:"text"};const s=t.substring(0,i).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,i).includes(">"))return{type:"text"};const o=t.substring(s+1,i).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,i){this.element=t,this.attrName=n,this.rawValue=i,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,i){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=i,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,i){const s=new d,o=function(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):"function"==typeof o||c(o)?i.push(r(s)):i.push(e(o??""))}return i.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);s.fragment=u,v(u,n.values,o,s);for(const t of s.parts)t.mount();return i.appendChild(u),s}function v(t,n,i,s){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,i,s,t):1===e.nodeType&&m(e,n,i,s)}function g(t,n,i,s,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(i,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);s.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,i,s,o))}}function m(t,n,i,s){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(i,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const i=new a(t,e.name,n[o]);s.parts.push(i)}else if("attr"===l.type&&l.attrName===e.name){const i=e.value.replace(c,"");i?t.setAttribute(e.name,i):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);s.parts.push(r)}}v(t,n,i,s)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:i="",content:s="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{p(),t(!0)},u=()=>{p(),t(!1)},h=t=>{t.target===t.currentTarget&&u()},f=t=>{"Escape"===t.key&&u(),"Enter"===t.key&&l()},a=n`
1
+ class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return new t(n,e)}function e(t){const n={t:t,o:new Set,i:null,l:!1};return n.i=()=>{n.l||o(n)},o(n),()=>function(t){if(t.l)return;t.l=!0,i(t)}(n)}function o(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.o)n.u.delete(t);t.o.clear()}function s(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const e=Object.getPrototypeOf(t);if(e){const t=Object.getOwnPropertyDescriptor(e,"value");if(t&&"function"==typeof t.get)return!0}return!1}const l=t=>`຿${t}຿`;function r(n){const e=[];for(let o=0;o<n.strings.length;o++)if(e.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?e.push(r(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(r).join("")):c(i)?e.push(s(i.value)):"function"!=typeof i&&e.push(s(i??""))}return e.join("")}function a(t,n){const e=t.indexOf(n);if(-1===e)return{type:"text"};const o=t.substring(0,e).lastIndexOf("<");if(-1===o)return{type:"text"};if(t.substring(o,e).includes(">"))return{type:"text"};const i=t.substring(o+1,e).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const s=i[1];return s.startsWith("on")&&s.length>2?{type:"event",attrName:s}:{type:"attr",attrName:s}}class d{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=r(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class u{constructor(t,n,e){this.element=t,this.attrName=n,this.rawValue=e,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class h{constructor(t,n,e){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=e,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class f{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,e){const o=new f,i=function(n){const e=[];for(let o=0;o<n.strings.length;o++)if(e.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?e.push(r(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(r).join("")):"function"==typeof i||c(i)?e.push(l(o)):e.push(s(i??""))}return e.join("")}(n),a=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=a,g(a,n.values,i,o);for(const t of o.parts)t.mount();return e.appendChild(a),o}function g(t,n,e,o){const i=[...t.childNodes];for(const s of i)3===s.nodeType?y(s,n,e,o,t):1===s.nodeType&&m(s,n,e,o)}function y(t,n,e,o,i){const s=t.textContent||"";for(let c=0;c<n.length;c++){const r=l(c),u=s.indexOf(r);if(-1===u)continue;if("text"!==a(e,r).type)continue;const h=s.substring(0,u),f=s.substring(u+r.length);h&&i.insertBefore(document.createTextNode(h),t);const p=new d(i,n[c]);o.parts.push(p);let g=t;return f&&(g=document.createTextNode(f),i.insertBefore(g,t)),i.removeChild(t),p.p=g!==t?g:null,void(f&&y(g,n,e,o,i))}}function m(t,n,e,o){const i=[...t.attributes];for(const s of i)for(let i=0;i<n.length;i++){const c=l(i);if(!s.value.includes(c))continue;const r=a(e,c);if("event"===r.type&&r.attrName===s.name){t.removeAttribute(s.name);const e=new h(t,s.name,n[i]);o.parts.push(e)}else if("attr"===r.type&&r.attrName===s.name){const e=s.value.replace(c,"");e?t.setAttribute(s.name,e):t.removeAttribute(s.name);const l=new u(t,s.name,n[i]);o.parts.push(l)}}g(t,n,e,o)}const v={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};function x(t,n={}){let e=(v["en-US"]||v["en-US"])[t]||t;for(const[t,o]of Object.entries(n))e=e.replace(`{${t}}`,o);return e}const w={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function k(t={}){const{title:e="",content:o="",type:i="normal",confirmText:s=null,cancelText:c=null,showCancel:l=!0}=t,r=s||x("dialog.ok"),a=c||x("dialog.cancel");return new Promise(t=>{const s=()=>{k(),t(!0)},c=()=>{k(),t(!1)},d=t=>{t.target===t.currentTarget&&c()},u=t=>{"Escape"===t.key&&c(),"Enter"===t.key&&s()},h=n`
2
2
  <div class="ds-modal-mask">
3
- <div class="ds-dialog">
4
- <div class="ds-dialog__icon ds-dialog__icon--${o}">${x[o]||x.normal}</div>
5
- <div class="ds-dialog__title">${i}</div>
6
- <div class="ds-dialog__content">${s}</div>
3
+ <div class="ds-dialog" role="alertdialog" aria-modal="true" aria-labelledby="dialog-title" aria-describedby="dialog-content" tabindex="-1">
4
+ <div class="ds-dialog__icon ds-dialog__icon--${i}">${w[i]||w.normal}</div>
5
+ <div class="ds-dialog__title" id="dialog-title">${e}</div>
6
+ <div class="ds-dialog__content" id="dialog-content">${o}</div>
7
7
  <div class="ds-dialog__actions">
8
- ${r?n`<button class="ds-btn ds-btn--ghost" data-action="cancel">${c}</button>`:""}
9
- <button class="ds-btn ds-btn--primary" data-action="confirm">${e}</button>
8
+ ${l?n`<button class="ds-btn ds-btn--ghost" data-action="cancel" type="button">${a}</button>`:""}
9
+ <button class="ds-btn ds-btn--primary" data-action="confirm" type="button">${r}</button>
10
10
  </div>
11
11
  </div>
12
12
  </div>
13
- `,d=document.createDocumentFragment(),v=y(a,d);document.body.appendChild(d);const g=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;g&&g.classList.add("is-visible"),document.body.style.overflow="hidden";const m=g.querySelector('[data-action="confirm"]'),w=g.querySelector('[data-action="cancel"]');function p(){document.removeEventListener("keydown",f),document.body.style.overflow="",g&&g.classList.remove("is-visible"),setTimeout(()=>{v.destroy(),g&&g.parentNode&&g.parentNode.removeChild(g)},50)}m&&m.addEventListener("click",l),w&&w.addEventListener("click",u),g&&g.addEventListener("click",h),document.addEventListener("keydown",f)})}const p={confirm:w,alert:function(t={}){return w({...t,showCancel:!1}).then(()=>{})}};export{p as Dialog};
13
+ `,f=document.createDocumentFragment(),g=p(h,f);document.body.appendChild(f);const y=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;y&&y.classList.add("is-visible"),document.body.style.overflow="hidden";const m=y?.querySelector(".ds-dialog");m&&m.focus();const v=y.querySelector('[data-action="confirm"]'),x=y.querySelector('[data-action="cancel"]');function k(){document.removeEventListener("keydown",u),document.body.style.overflow="",y&&y.classList.remove("is-visible"),setTimeout(()=>{g.destroy(),y&&y.parentNode&&y.parentNode.removeChild(y)},50)}v&&v.addEventListener("click",s),x&&x.addEventListener("click",c),y&&y.addEventListener("click",d),document.addEventListener("keydown",u)})}const b={confirm:k,alert:function(t={}){return k({...t,showCancel:!1}).then(()=>{})}};export{b as Dialog};
@@ -1,9 +1,9 @@
1
- "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function l(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new a,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=l,w(l,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(l),i}function w(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?p(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function p(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==l(s,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&o.insertBefore(document.createTextNode(d),t);const y=new f(o,n[c]);i.parts.push(y);let w=t;return a&&(w=document.createTextNode(a),o.insertBefore(w,t)),o.removeChild(t),y.p=w!==t?w:null,void(a&&p(w,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const u=l(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[o]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new h(t,e.name,n[o]);i.parts.push(r)}}w(t,n,s,i)}exports.Drawer=function(t={},s=null){const{title:i="",placement:o="left",width:e="",closableOnMask:c=!0,escClose:r=!0}=t;let u=!1;function l(){u||(u=!0,p&&p.classList.add("is-visible"),m&&m.classList.add("is-visible"),document.body.style.overflow="hidden")}function f(){u&&(u=!1,p&&p.classList.remove("is-visible"),m&&m.classList.remove("is-visible"),document.body.style.overflow="")}const h=t=>{r&&"Escape"===t.key&&u&&f()};document.addEventListener("keydown",h);const d=n`
2
- <div class="ds-drawer-mask" onclick="${t=>{c&&t.target===t.currentTarget&&f()}}">
3
- <div class="${"right"===o?"ds-drawer ds-drawer--right":"ds-drawer"}" style="${e?`width: ${e}`:""}">
1
+ "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,e(t)}(n)}function i(t){e(t);try{t.t()}finally{}}function e(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function r(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const c=t=>`຿${t}຿`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const e=n.values[i];e instanceof t?s.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(u).join("")):r(e)?s.push(o(e.value)):"function"!=typeof e&&s.push(o(e??""))}return s.join("")}function l(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const e=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!e)return{type:"text"};const o=e[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,r(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(r(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new a,e=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const e=n.values[i];e instanceof t?s.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(u).join("")):"function"==typeof e||r(e)?s.push(c(i)):s.push(o(e??""))}return s.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);i.fragment=l,w(l,n.values,e,i);for(const t of i.parts)t.mount();return s.appendChild(l),i}function w(t,n,s,i){const e=[...t.childNodes];for(const o of e)3===o.nodeType?p(o,n,s,i,t):1===o.nodeType&&m(o,n,s,i)}function p(t,n,s,i,e){const o=t.textContent||"";for(let r=0;r<n.length;r++){const u=c(r),h=o.indexOf(u);if(-1===h)continue;if("text"!==l(s,u).type)continue;const d=o.substring(0,h),a=o.substring(h+u.length);d&&e.insertBefore(document.createTextNode(d),t);const y=new f(e,n[r]);i.parts.push(y);let w=t;return a&&(w=document.createTextNode(a),e.insertBefore(w,t)),e.removeChild(t),y.p=w!==t?w:null,void(a&&p(w,n,s,i,e))}}function m(t,n,s,i){const e=[...t.attributes];for(const o of e)for(let e=0;e<n.length;e++){const r=c(e);if(!o.value.includes(r))continue;const u=l(s,r);if("event"===u.type&&u.attrName===o.name){t.removeAttribute(o.name);const s=new d(t,o.name,n[e]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===o.name){const s=o.value.replace(r,"");s?t.setAttribute(o.name,s):t.removeAttribute(o.name);const c=new h(t,o.name,n[e]);i.parts.push(c)}}w(t,n,s,i)}exports.Drawer=function(t={},s=null){const{title:i="",placement:e="left",width:o="",closableOnMask:r=!0,escClose:c=!0}=t;let u=!1;function l(){u||(u=!0,p&&p.classList.add("is-visible"),m&&m.classList.add("is-visible"),document.body.style.overflow="hidden",m&&m.focus())}function f(){u&&(u=!1,p&&p.classList.remove("is-visible"),m&&m.classList.remove("is-visible"),document.body.style.overflow="")}const h=t=>{c&&"Escape"===t.key&&u&&f()};document.addEventListener("keydown",h);const d=n`
2
+ <div class="ds-drawer-mask" onclick="${t=>{r&&t.target===t.currentTarget&&f()}}">
3
+ <div class="${"right"===e?"ds-drawer ds-drawer--right":"ds-drawer"}" style="${o?`width: ${o}`:""}" role="dialog" aria-modal="true" aria-labelledby="drawer-title" tabindex="-1">
4
4
  <div class="ds-drawer__header">
5
- <span class="ds-drawer__title">${i}</span>
6
- <button class="ds-drawer__close" onclick="${f}" aria-label="Close">
5
+ <span class="ds-drawer__title" id="drawer-title">${i}</span>
6
+ <button class="ds-drawer__close" onclick="${f}" aria-label="Close" type="button">
7
7
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8
8
  <path d="M18 6L6 18M6 6l12 12"/>
9
9
  </svg>
@@ -1,9 +1,9 @@
1
- class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function l(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new a,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=l,w(l,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(l),i}function w(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?p(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function p(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==l(s,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&o.insertBefore(document.createTextNode(d),t);const y=new f(o,n[c]);i.parts.push(y);let w=t;return a&&(w=document.createTextNode(a),o.insertBefore(w,t)),o.removeChild(t),y.p=w!==t?w:null,void(a&&p(w,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const u=l(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[o]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new h(t,e.name,n[o]);i.parts.push(r)}}w(t,n,s,i)}function v(t={},s=null){const{title:i="",placement:o="left",width:e="",closableOnMask:c=!0,escClose:r=!0}=t;let u=!1;function l(){u||(u=!0,p&&p.classList.add("is-visible"),m&&m.classList.add("is-visible"),document.body.style.overflow="hidden")}function f(){u&&(u=!1,p&&p.classList.remove("is-visible"),m&&m.classList.remove("is-visible"),document.body.style.overflow="")}const h=t=>{r&&"Escape"===t.key&&u&&f()};document.addEventListener("keydown",h);const d=n`
2
- <div class="ds-drawer-mask" onclick="${t=>{c&&t.target===t.currentTarget&&f()}}">
3
- <div class="${"right"===o?"ds-drawer ds-drawer--right":"ds-drawer"}" style="${e?`width: ${e}`:""}">
1
+ class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,e(t)}(n)}function i(t){e(t);try{t.t()}finally{}}function e(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function r(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const c=t=>`຿${t}຿`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const e=n.values[i];e instanceof t?s.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(u).join("")):r(e)?s.push(o(e.value)):"function"!=typeof e&&s.push(o(e??""))}return s.join("")}function l(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const e=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!e)return{type:"text"};const o=e[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,r(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(r(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new a,e=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const e=n.values[i];e instanceof t?s.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(u).join("")):"function"==typeof e||r(e)?s.push(c(i)):s.push(o(e??""))}return s.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);i.fragment=l,w(l,n.values,e,i);for(const t of i.parts)t.mount();return s.appendChild(l),i}function w(t,n,s,i){const e=[...t.childNodes];for(const o of e)3===o.nodeType?p(o,n,s,i,t):1===o.nodeType&&m(o,n,s,i)}function p(t,n,s,i,e){const o=t.textContent||"";for(let r=0;r<n.length;r++){const u=c(r),h=o.indexOf(u);if(-1===h)continue;if("text"!==l(s,u).type)continue;const d=o.substring(0,h),a=o.substring(h+u.length);d&&e.insertBefore(document.createTextNode(d),t);const y=new f(e,n[r]);i.parts.push(y);let w=t;return a&&(w=document.createTextNode(a),e.insertBefore(w,t)),e.removeChild(t),y.p=w!==t?w:null,void(a&&p(w,n,s,i,e))}}function m(t,n,s,i){const e=[...t.attributes];for(const o of e)for(let e=0;e<n.length;e++){const r=c(e);if(!o.value.includes(r))continue;const u=l(s,r);if("event"===u.type&&u.attrName===o.name){t.removeAttribute(o.name);const s=new d(t,o.name,n[e]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===o.name){const s=o.value.replace(r,"");s?t.setAttribute(o.name,s):t.removeAttribute(o.name);const c=new h(t,o.name,n[e]);i.parts.push(c)}}w(t,n,s,i)}function v(t={},s=null){const{title:i="",placement:e="left",width:o="",closableOnMask:r=!0,escClose:c=!0}=t;let u=!1;function l(){u||(u=!0,p&&p.classList.add("is-visible"),m&&m.classList.add("is-visible"),document.body.style.overflow="hidden",m&&m.focus())}function f(){u&&(u=!1,p&&p.classList.remove("is-visible"),m&&m.classList.remove("is-visible"),document.body.style.overflow="")}const h=t=>{c&&"Escape"===t.key&&u&&f()};document.addEventListener("keydown",h);const d=n`
2
+ <div class="ds-drawer-mask" onclick="${t=>{r&&t.target===t.currentTarget&&f()}}">
3
+ <div class="${"right"===e?"ds-drawer ds-drawer--right":"ds-drawer"}" style="${o?`width: ${o}`:""}" role="dialog" aria-modal="true" aria-labelledby="drawer-title" tabindex="-1">
4
4
  <div class="ds-drawer__header">
5
- <span class="ds-drawer__title">${i}</span>
6
- <button class="ds-drawer__close" onclick="${f}" aria-label="Close">
5
+ <span class="ds-drawer__title" id="drawer-title">${i}</span>
6
+ <button class="ds-drawer__close" onclick="${f}" aria-label="Close" type="button">
7
7
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8
8
  <path d="M18 6L6 18M6 6l12 12"/>
9
9
  </svg>
@@ -1,11 +1,11 @@
1
- "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||o(n)},o(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function o(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.o)n.l.delete(t);t.o.clear()}function e(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const s=[];for(let o=0;o<n.strings.length;o++)if(s.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?s.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(u).join("")):c(i)?s.push(e(i.value)):"function"!=typeof i&&s.push(e(i??""))}return s.join("")}function f(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const o=t.substring(0,s).lastIndexOf("<");if(-1===o)return{type:"text"};if(t.substring(o,s).includes(">"))return{type:"text"};const i=t.substring(o+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const e=i[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class l{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,s){const o=new a,i=function(n){const s=[];for(let o=0;o<n.strings.length;o++)if(s.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?s.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(u).join("")):"function"==typeof i||c(i)?s.push(r(o)):s.push(e(i??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=f,m(f,n.values,i,o);for(const t of o.parts)t.mount();return s.appendChild(f),o}function m(t,n,s,o){const i=[...t.childNodes];for(const e of i)3===e.nodeType?w(e,n,s,o,t):1===e.nodeType&&y(e,n,s,o)}function w(t,n,s,o,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==f(s,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&i.insertBefore(document.createTextNode(d),t);const p=new l(i,n[c]);o.parts.push(p);let m=t;return a&&(m=document.createTextNode(a),i.insertBefore(m,t)),i.removeChild(t),p.p=m!==t?m:null,void(a&&w(m,n,s,o,i))}}function y(t,n,s,o){const i=[...t.attributes];for(const e of i)for(let i=0;i<n.length;i++){const c=r(i);if(!e.value.includes(c))continue;const u=f(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[i]);o.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new h(t,e.name,n[i]);o.parts.push(r)}}m(t,n,s,o)}exports.Dropdown=function(t={}){const{items:s=[],trigger:o="click",closeOnClick:i=!0,onSelect:e=null,placeholder:c="Select..."}=t;let r=!1,u=-1;function f(){r||(r=!0,b&&b.classList.add("is-open"))}function l(){r&&(r=!1,u=-1,b&&b.classList.remove("is-open"),d())}function h(){r?l():f()}function d(){if(!b)return;b.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused"))}function a(t){if(!b)return;const n=b.querySelectorAll(".ds-dropdown__item");0!==n.length&&(d(),u=(t%n.length+n.length)%n.length,n[u].classList.add("is-focused"))}function m(t){if(t<0||t>=s.length)return;const n=s[t];e&&e({value:n.value,text:n.text,item:n}),i&&l()}const w=t=>{r&&k&&!k.contains(t.target)&&l()};document.addEventListener("click",w);const y=t=>{if(r)switch(t.key){case"ArrowDown":t.preventDefault(),a(u+1);break;case"ArrowUp":t.preventDefault(),a(u-1);break;case"Enter":t.preventDefault(),u>=0&&m(u);break;case"Escape":t.preventDefault(),l()}};document.addEventListener("keydown",y);const g=n`
1
+ "use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...o){return new t(n,o)}function o(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,e(t)}(n)}function s(t){e(t);try{t.t()}finally{}}function e(t){for(const n of t.o)n.l.delete(t);t.o.clear()}function i(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const e=n.values[s];e instanceof t?o.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?o.push(e.map(u).join("")):c(e)?o.push(i(e.value)):"function"!=typeof e&&o.push(i(e??""))}return o.join("")}function f(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const s=t.substring(0,o).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,o).includes(">"))return{type:"text"};const e=t.substring(s+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!e)return{type:"text"};const i=e[1];return i.startsWith("on")&&i.length>2?{type:"event",attrName:i}:{type:"attr",attrName:i}}class l{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class h{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,o){const s=new a,e=function(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const e=n.values[s];e instanceof t?o.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?o.push(e.map(u).join("")):"function"==typeof e||c(e)?o.push(r(s)):o.push(i(e??""))}return o.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);s.fragment=f,m(f,n.values,e,s);for(const t of s.parts)t.mount();return o.appendChild(f),s}function m(t,n,o,s){const e=[...t.childNodes];for(const i of e)3===i.nodeType?w(i,n,o,s,t):1===i.nodeType&&y(i,n,o,s)}function w(t,n,o,s,e){const i=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),d=i.indexOf(u);if(-1===d)continue;if("text"!==f(o,u).type)continue;const h=i.substring(0,d),a=i.substring(d+u.length);h&&e.insertBefore(document.createTextNode(h),t);const p=new l(e,n[c]);s.parts.push(p);let m=t;return a&&(m=document.createTextNode(a),e.insertBefore(m,t)),e.removeChild(t),p.p=m!==t?m:null,void(a&&w(m,n,o,s,e))}}function y(t,n,o,s){const e=[...t.attributes];for(const i of e)for(let e=0;e<n.length;e++){const c=r(e);if(!i.value.includes(c))continue;const u=f(o,c);if("event"===u.type&&u.attrName===i.name){t.removeAttribute(i.name);const o=new h(t,i.name,n[e]);s.parts.push(o)}else if("attr"===u.type&&u.attrName===i.name){const o=i.value.replace(c,"");o?t.setAttribute(i.name,o):t.removeAttribute(i.name);const r=new d(t,i.name,n[e]);s.parts.push(r)}}m(t,n,o,s)}exports.Dropdown=function(t={}){const{items:o=[],trigger:s="click",closeOnClick:e=!0,onSelect:i=null,placeholder:c="Select..."}=t;let r=!1,u=-1;function f(){r||(r=!0,v&&v.classList.add("is-open"),x&&x.setAttribute("aria-expanded","true"))}function l(){r&&(r=!1,u=-1,v&&v.classList.remove("is-open"),x&&x.setAttribute("aria-expanded","false"),h())}function d(){r?l():f()}function h(){if(!v)return;v.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused"))}function a(t){if(!v)return;const n=v.querySelectorAll(".ds-dropdown__item");0!==n.length&&(h(),u=(t%n.length+n.length)%n.length,n[u].classList.add("is-focused"))}function m(t){if(t<0||t>=o.length)return;const n=o[t];i&&i({value:n.value,text:n.text,item:n}),e&&l()}const w=t=>{r&&k&&!k.contains(t.target)&&l()};document.addEventListener("click",w);const y=t=>{if(r)switch(t.key){case"ArrowDown":t.preventDefault(),a(u+1);break;case"ArrowUp":t.preventDefault(),a(u-1);break;case"Home":t.preventDefault(),a(0);break;case"End":t.preventDefault(),a(o.length-1);break;case"Enter":t.preventDefault(),u>=0&&m(u);break;case"Escape":case"Tab":t.preventDefault(),l()}};document.addEventListener("keydown",y);const g=n`
2
2
  <div class="ds-dropdown">
3
- <button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===o&&h()}}">
3
+ <button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===s&&d()}}" aria-haspopup="listbox" aria-expanded="false">
4
4
  <span>${c}</span>
5
5
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6
6
  <polyline points="6 9 12 15 18 9"/>
7
7
  </svg>
8
8
  </button>
9
- <div class="ds-dropdown__menu">${s.map(t=>n`<button class="ds-dropdown__item" data-value="${t.value}">${t.text}</button>`)}</div>
9
+ <div class="ds-dropdown__menu" role="listbox">${o.map(t=>n`<button class="ds-dropdown__item" data-value="${t.value}" role="option">${t.text}</button>`)}</div>
10
10
  </div>
11
- `,_=document.createDocumentFragment(),v=p(g,_),k=_.querySelector(".ds-dropdown"),b=_.querySelector(".ds-dropdown__menu");if(b){b.querySelectorAll(".ds-dropdown__item").forEach((t,n)=>{var s;t.addEventListener("click",(s=n,t=>{t.stopPropagation(),m(s)}))})}return{get element(){return _},open:f,close:l,toggle:h,destroy(){document.removeEventListener("click",w),document.removeEventListener("keydown",y),v.destroy()}}};
11
+ `,_=document.createDocumentFragment(),b=p(g,_),k=_.querySelector(".ds-dropdown"),v=_.querySelector(".ds-dropdown__menu"),x=_.querySelector(".ds-dropdown__trigger");if(v){v.querySelectorAll(".ds-dropdown__item").forEach((t,n)=>{var o;t.addEventListener("click",(o=n,t=>{t.stopPropagation(),m(o)}))})}return{get element(){return _},open:f,close:l,toggle:d,destroy(){document.removeEventListener("click",w),document.removeEventListener("keydown",y),b.destroy()}}};
@@ -1,11 +1,11 @@
1
- class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...o){return new t(n,o)}function o(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function s(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.o)n.l.delete(t);t.o.clear()}function e(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?o.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?o.push(i.map(u).join("")):c(i)?o.push(e(i.value)):"function"!=typeof i&&o.push(e(i??""))}return o.join("")}function f(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const s=t.substring(0,o).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,o).includes(">"))return{type:"text"};const i=t.substring(s+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const e=i[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class l{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,o){const s=new a,i=function(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?o.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?o.push(i.map(u).join("")):"function"==typeof i||c(i)?o.push(r(s)):o.push(e(i??""))}return o.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);s.fragment=f,m(f,n.values,i,s);for(const t of s.parts)t.mount();return o.appendChild(f),s}function m(t,n,o,s){const i=[...t.childNodes];for(const e of i)3===e.nodeType?w(e,n,o,s,t):1===e.nodeType&&y(e,n,o,s)}function w(t,n,o,s,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==f(o,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&i.insertBefore(document.createTextNode(d),t);const p=new l(i,n[c]);s.parts.push(p);let m=t;return a&&(m=document.createTextNode(a),i.insertBefore(m,t)),i.removeChild(t),p.p=m!==t?m:null,void(a&&w(m,n,o,s,i))}}function y(t,n,o,s){const i=[...t.attributes];for(const e of i)for(let i=0;i<n.length;i++){const c=r(i);if(!e.value.includes(c))continue;const u=f(o,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const o=new d(t,e.name,n[i]);s.parts.push(o)}else if("attr"===u.type&&u.attrName===e.name){const o=e.value.replace(c,"");o?t.setAttribute(e.name,o):t.removeAttribute(e.name);const r=new h(t,e.name,n[i]);s.parts.push(r)}}m(t,n,o,s)}function g(t={}){const{items:o=[],trigger:s="click",closeOnClick:i=!0,onSelect:e=null,placeholder:c="Select..."}=t;let r=!1,u=-1;function f(){r||(r=!0,b&&b.classList.add("is-open"))}function l(){r&&(r=!1,u=-1,b&&b.classList.remove("is-open"),d())}function h(){r?l():f()}function d(){if(!b)return;b.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused"))}function a(t){if(!b)return;const n=b.querySelectorAll(".ds-dropdown__item");0!==n.length&&(d(),u=(t%n.length+n.length)%n.length,n[u].classList.add("is-focused"))}function m(t){if(t<0||t>=o.length)return;const n=o[t];e&&e({value:n.value,text:n.text,item:n}),i&&l()}const w=t=>{r&&k&&!k.contains(t.target)&&l()};document.addEventListener("click",w);const y=t=>{if(r)switch(t.key){case"ArrowDown":t.preventDefault(),a(u+1);break;case"ArrowUp":t.preventDefault(),a(u-1);break;case"Enter":t.preventDefault(),u>=0&&m(u);break;case"Escape":t.preventDefault(),l()}};document.addEventListener("keydown",y);const g=n`
1
+ class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...o){return new t(n,o)}function o(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,e(t)}(n)}function s(t){e(t);try{t.t()}finally{}}function e(t){for(const n of t.o)n.l.delete(t);t.o.clear()}function i(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`຿${t}຿`;function u(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const e=n.values[s];e instanceof t?o.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?o.push(e.map(u).join("")):c(e)?o.push(i(e.value)):"function"!=typeof e&&o.push(i(e??""))}return o.join("")}function f(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const s=t.substring(0,o).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,o).includes(">"))return{type:"text"};const e=t.substring(s+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!e)return{type:"text"};const i=e[1];return i.startsWith("on")&&i.length>2?{type:"event",attrName:i}:{type:"attr",attrName:i}}class l{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class h{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,o){const s=new a,e=function(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const e=n.values[s];e instanceof t?o.push(u(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?o.push(e.map(u).join("")):"function"==typeof e||c(e)?o.push(r(s)):o.push(i(e??""))}return o.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);s.fragment=f,m(f,n.values,e,s);for(const t of s.parts)t.mount();return o.appendChild(f),s}function m(t,n,o,s){const e=[...t.childNodes];for(const i of e)3===i.nodeType?w(i,n,o,s,t):1===i.nodeType&&y(i,n,o,s)}function w(t,n,o,s,e){const i=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),d=i.indexOf(u);if(-1===d)continue;if("text"!==f(o,u).type)continue;const h=i.substring(0,d),a=i.substring(d+u.length);h&&e.insertBefore(document.createTextNode(h),t);const p=new l(e,n[c]);s.parts.push(p);let m=t;return a&&(m=document.createTextNode(a),e.insertBefore(m,t)),e.removeChild(t),p.p=m!==t?m:null,void(a&&w(m,n,o,s,e))}}function y(t,n,o,s){const e=[...t.attributes];for(const i of e)for(let e=0;e<n.length;e++){const c=r(e);if(!i.value.includes(c))continue;const u=f(o,c);if("event"===u.type&&u.attrName===i.name){t.removeAttribute(i.name);const o=new h(t,i.name,n[e]);s.parts.push(o)}else if("attr"===u.type&&u.attrName===i.name){const o=i.value.replace(c,"");o?t.setAttribute(i.name,o):t.removeAttribute(i.name);const r=new d(t,i.name,n[e]);s.parts.push(r)}}m(t,n,o,s)}function g(t={}){const{items:o=[],trigger:s="click",closeOnClick:e=!0,onSelect:i=null,placeholder:c="Select..."}=t;let r=!1,u=-1;function f(){r||(r=!0,v&&v.classList.add("is-open"),x&&x.setAttribute("aria-expanded","true"))}function l(){r&&(r=!1,u=-1,v&&v.classList.remove("is-open"),x&&x.setAttribute("aria-expanded","false"),h())}function d(){r?l():f()}function h(){if(!v)return;v.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused"))}function a(t){if(!v)return;const n=v.querySelectorAll(".ds-dropdown__item");0!==n.length&&(h(),u=(t%n.length+n.length)%n.length,n[u].classList.add("is-focused"))}function m(t){if(t<0||t>=o.length)return;const n=o[t];i&&i({value:n.value,text:n.text,item:n}),e&&l()}const w=t=>{r&&k&&!k.contains(t.target)&&l()};document.addEventListener("click",w);const y=t=>{if(r)switch(t.key){case"ArrowDown":t.preventDefault(),a(u+1);break;case"ArrowUp":t.preventDefault(),a(u-1);break;case"Home":t.preventDefault(),a(0);break;case"End":t.preventDefault(),a(o.length-1);break;case"Enter":t.preventDefault(),u>=0&&m(u);break;case"Escape":case"Tab":t.preventDefault(),l()}};document.addEventListener("keydown",y);const g=n`
2
2
  <div class="ds-dropdown">
3
- <button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===s&&h()}}">
3
+ <button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===s&&d()}}" aria-haspopup="listbox" aria-expanded="false">
4
4
  <span>${c}</span>
5
5
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
6
6
  <polyline points="6 9 12 15 18 9"/>
7
7
  </svg>
8
8
  </button>
9
- <div class="ds-dropdown__menu">${o.map(t=>n`<button class="ds-dropdown__item" data-value="${t.value}">${t.text}</button>`)}</div>
9
+ <div class="ds-dropdown__menu" role="listbox">${o.map(t=>n`<button class="ds-dropdown__item" data-value="${t.value}" role="option">${t.text}</button>`)}</div>
10
10
  </div>
11
- `,_=document.createDocumentFragment(),v=p(g,_),k=_.querySelector(".ds-dropdown"),b=_.querySelector(".ds-dropdown__menu");if(b){b.querySelectorAll(".ds-dropdown__item").forEach((t,n)=>{var o;t.addEventListener("click",(o=n,t=>{t.stopPropagation(),m(o)}))})}return{get element(){return _},open:f,close:l,toggle:h,destroy(){document.removeEventListener("click",w),document.removeEventListener("keydown",y),v.destroy()}}}export{g as Dropdown};
11
+ `,_=document.createDocumentFragment(),b=p(g,_),k=_.querySelector(".ds-dropdown"),v=_.querySelector(".ds-dropdown__menu"),x=_.querySelector(".ds-dropdown__trigger");if(v){v.querySelectorAll(".ds-dropdown__item").forEach((t,n)=>{var o;t.addEventListener("click",(o=n,t=>{t.stopPropagation(),m(o)}))})}return{get element(){return _},open:f,close:l,toggle:d,destroy(){document.removeEventListener("click",w),document.removeEventListener("keydown",y),b.destroy()}}}export{g as Dropdown};
@@ -1 +1 @@
1
- "use strict";const e={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let o="en-US";exports.addMessages=function(o,t){e[o]||(e[o]={}),Object.assign(e[o],t)},exports.getLocale=function(){return o},exports.setLocale=function(e){o=e},exports.t=function(t,a={}){let l=(e[o]||e["en-US"])[t]||t;for(const[e,o]of Object.entries(a))l=l.replace(`{${e}}`,o);return l};
1
+ "use strict";const e={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data","datepicker.months":"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec","datepicker.weekdays":"Mo,Tu,We,Th,Fr,Sa,Su","timepicker.placeholder":"Select time"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","datepicker.months":"1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月","datepicker.weekdays":"一,二,三,四,五,六,日","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let t="en-US";exports.addMessages=function(t,a){e[t]||(e[t]={}),Object.assign(e[t],a)},exports.getLocale=function(){return t},exports.setLocale=function(e){t=e},exports.t=function(a,o={}){let l=(e[t]||e["en-US"])[a]||a;for(const[e,t]of Object.entries(o))l=l.replace(`{${e}}`,t);return l};