@kupola/kupola 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kupola-core-datepicker.cjs.js +9 -9
- package/dist/kupola-core-datepicker.esm.js +9 -9
- package/dist/kupola-core-dialog.cjs.js +8 -8
- package/dist/kupola-core-dialog.esm.js +8 -8
- package/dist/kupola-core-drawer.cjs.js +5 -5
- package/dist/kupola-core-drawer.esm.js +5 -5
- package/dist/kupola-core-dropdown.cjs.js +4 -4
- package/dist/kupola-core-dropdown.esm.js +4 -4
- package/dist/kupola-core-i18n.cjs.js +1 -1
- package/dist/kupola-core-i18n.esm.js +1 -1
- package/dist/kupola-core-modal.cjs.js +2 -2
- package/dist/kupola-core-modal.esm.js +2 -2
- package/dist/kupola-core-numberinput.cjs.js +6 -5
- package/dist/kupola-core-numberinput.esm.js +6 -5
- package/dist/kupola-core-select.cjs.js +8 -7
- package/dist/kupola-core-select.esm.js +8 -7
- package/dist/kupola-core-table.cjs.js +1 -1
- package/dist/kupola-core-table.esm.js +1 -1
- package/dist/kupola-core-timepicker.cjs.js +3 -3
- package/dist/kupola-core-timepicker.esm.js +3 -3
- package/dist/kupola-core.cjs.js +1 -1
- package/dist/kupola-core.esm.js +1 -1
- package/package.json +1 -1
- package/packages/core/src/components/datepicker.js +11 -6
- package/packages/core/src/components/dialog.js +14 -7
- package/packages/core/src/components/drawer.js +5 -3
- package/packages/core/src/components/dropdown.js +15 -3
- package/packages/core/src/components/modal.js +20 -1
- package/packages/core/src/components/numberinput.js +12 -3
- package/packages/core/src/components/select.js +22 -5
- package/packages/core/src/components/table.js +3 -1
- package/packages/core/src/components/timepicker.js +2 -1
- package/packages/core/src/errors.js +80 -0
- package/packages/core/src/i18n.js +5 -0
- package/packages/core/src/index.js +3 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";class t{constructor(t,
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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(),
|
|
4
|
-
<input class="ds-datepicker__input" type="text" readonly placeholder="${
|
|
5
|
-
<button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),
|
|
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===
|
|
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">${`${
|
|
20
|
-
<button class="ds-datepicker__nav" onclick="${function(){11===
|
|
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===
|
|
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();
|
|
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,
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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(),
|
|
4
|
-
<input class="ds-datepicker__input" type="text" readonly placeholder="${
|
|
5
|
-
<button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),
|
|
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===
|
|
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">${`${
|
|
20
|
-
<button class="ds-datepicker__nav" onclick="${function(){11===
|
|
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===
|
|
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();
|
|
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,...
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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--${
|
|
5
|
-
<div class="ds-dialog__title">${
|
|
6
|
-
<div class="ds-dialog__content">${
|
|
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
|
-
${
|
|
9
|
-
<button class="ds-btn ds-btn--primary" data-action="confirm">${
|
|
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
|
-
`,
|
|
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,...
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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--${
|
|
5
|
-
<div class="ds-dialog__title">${
|
|
6
|
-
<div class="ds-dialog__content">${
|
|
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
|
-
${
|
|
9
|
-
<button class="ds-btn ds-btn--primary" data-action="confirm">${
|
|
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
|
-
`,
|
|
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,
|
|
2
|
-
<div class="ds-drawer-mask" onclick="${t=>{
|
|
3
|
-
<div class="${"right"===
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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,
|
|
2
|
-
<div class="ds-drawer-mask" onclick="${t=>{
|
|
3
|
-
<div class="${"right"===
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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,...
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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"===
|
|
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">${
|
|
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(),
|
|
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,
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}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&&
|
|
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(),
|
|
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
|
|
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};
|