@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.
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 +1 @@
1
- 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";function a(e){o=e}function l(){return o}function t(a,l={}){let t=(e[o]||e["en-US"])[a]||a;for(const[e,o]of Object.entries(l))t=t.replace(`{${e}}`,o);return t}function c(o,a){e[o]||(e[o]={}),Object.assign(e[o],a)}export{c as addMessages,l as getLocale,a as setLocale,t};
1
+ 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 a="en-US";function t(e){a=e}function o(){return a}function l(t,o={}){let l=(e[a]||e["en-US"])[t]||t;for(const[e,a]of Object.entries(o))l=l.replace(`{${e}}`,a);return l}function c(a,t){e[a]||(e[a]={}),Object.assign(e[a],t)}export{c as addMessages,o as getLocale,t as setLocale,l as t};
@@ -1,4 +1,4 @@
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,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 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 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(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(l).join("")):c(i)?s.push(e(i.value)):"function"!=typeof i&&s.push(e(i??""))}return s.join("")}function u(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 f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.m?this.container.insertBefore(n,this.m):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 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.p=null}mount(){"function"==typeof this.handler&&(this.p=t=>this.handler(t),this.element.addEventListener(this.eventName,this.p))}destroy(){this.p&&(this.element.removeEventListener(this.eventName,this.p),this.p=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function m(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(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(l).join("")):"function"==typeof i||c(i)?s.push(r(o)):s.push(e(i??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=u,y(u,n.values,i,o);for(const t of o.parts)t.mount();return s.appendChild(u),o}function y(t,n,s,o){const i=[...t.childNodes];for(const e of i)3===e.nodeType?p(e,n,s,o,t):1===e.nodeType&&v(e,n,s,o)}function p(t,n,s,o,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),h=e.indexOf(l);if(-1===h)continue;if("text"!==u(s,l).type)continue;const d=e.substring(0,h),a=e.substring(h+l.length);d&&i.insertBefore(document.createTextNode(d),t);const m=new f(i,n[c]);o.parts.push(m);let y=t;return a&&(y=document.createTextNode(a),i.insertBefore(y,t)),i.removeChild(t),m.m=y!==t?y:null,void(a&&p(y,n,s,o,i))}}function v(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 l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[i]);o.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 h(t,e.name,n[i]);o.parts.push(r)}}y(t,n,s,o)}exports.Modal=function(t={},s=null){const{title:o="",width:i="",closableOnMask:e=!0,escClose:c=!0}=t;let r=!1;function l(){if(r)return;r=!0,y&&y.classList.add("is-visible"),document.body.style.overflow="hidden";const t=y?.querySelector(".ds-modal");t&&t.focus()}function u(){r&&(r=!1,y&&y.classList.remove("is-visible"),document.body.style.overflow="")}const f=t=>{c&&"Escape"===t.key&&r&&u()};document.addEventListener("keydown",f);const h=n`
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,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 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 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(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(l).join("")):c(i)?s.push(e(i.value)):"function"!=typeof i&&s.push(e(i??""))}return s.join("")}function u(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 f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.m?this.container.insertBefore(n,this.m):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 d{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.p=null}mount(){"function"==typeof this.handler&&(this.p=t=>this.handler(t),this.element.addEventListener(this.eventName,this.p))}destroy(){this.p&&(this.element.removeEventListener(this.eventName,this.p),this.p=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function m(n,s){const o=new h,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(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(l).join("")):"function"==typeof i||c(i)?s.push(r(o)):s.push(e(i??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=u,y(u,n.values,i,o);for(const t of o.parts)t.mount();return s.appendChild(u),o}function y(t,n,s,o){const i=[...t.childNodes];for(const e of i)3===e.nodeType?p(e,n,s,o,t):1===e.nodeType&&b(e,n,s,o)}function p(t,n,s,o,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),d=e.indexOf(l);if(-1===d)continue;if("text"!==u(s,l).type)continue;const a=e.substring(0,d),h=e.substring(d+l.length);a&&i.insertBefore(document.createTextNode(a),t);const m=new f(i,n[c]);o.parts.push(m);let y=t;return h&&(y=document.createTextNode(h),i.insertBefore(y,t)),i.removeChild(t),m.m=y!==t?y:null,void(h&&p(y,n,s,o,i))}}function b(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 l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[i]);o.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 d(t,e.name,n[i]);o.parts.push(r)}}y(t,n,s,o)}exports.Modal=function(t={},s=null){const{title:o="",width:i="",closableOnMask:e=!0,escClose:c=!0}=t;let r=!1;function l(){if(r)return;r=!0,y&&y.classList.add("is-visible"),document.body.style.overflow="hidden";const t=y?.querySelector(".ds-modal");t&&t.focus()}function u(){r&&(r=!1,y&&y.classList.remove("is-visible"),document.body.style.overflow="")}const f=t=>{if(r)if(c&&"Escape"===t.key)u();else if("Tab"===t.key&&y){const n=y.querySelector(".ds-modal");if(!n)return;const s=Array.from(n.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])'));if(0===s.length)return void t.preventDefault();const o=s[0],i=s[s.length-1];t.shiftKey?document.activeElement===o&&(t.preventDefault(),i.focus()):document.activeElement===i&&(t.preventDefault(),o.focus())}};document.addEventListener("keydown",f);const d=n`
2
2
  <div class="ds-modal-mask" onclick="${t=>{e&&t.target===t.currentTarget&&u()}}">
3
3
  <div class="ds-modal" style="${i?`max-width: ${i}`:""}" role="dialog" aria-modal="true" aria-labelledby="modal-title" tabindex="-1">
4
4
  <div class="ds-modal__header">
@@ -12,4 +12,4 @@
12
12
  <div class="ds-modal__body">${s}</div>
13
13
  </div>
14
14
  </div>
15
- `,d=document.createDocumentFragment(),a=m(h,d),y=d.querySelector?d.querySelector(".ds-modal-mask"):d.firstChild;return{get element(){return d},open:l,close:u,toggle:function(){r?u():l()},destroy(){document.removeEventListener("keydown",f),document.body.style.overflow="",a.destroy()}}};
15
+ `,a=document.createDocumentFragment(),h=m(d,a),y=a.querySelector?a.querySelector(".ds-modal-mask"):a.firstChild;return{get element(){return a},open:l,close:u,toggle:function(){r?u():l()},destroy(){document.removeEventListener("keydown",f),document.body.style.overflow="",h.destroy()}}};
@@ -1,4 +1,4 @@
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,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 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 l=t=>`຿${t}຿`;function r(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(r(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(r).join("")):c(i)?s.push(e(i.value)):"function"!=typeof i&&s.push(e(i??""))}return s.join("")}function u(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 f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.m?this.container.insertBefore(n,this.m):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=r(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.p=null}mount(){"function"==typeof this.handler&&(this.p=t=>this.handler(t),this.element.addEventListener(this.eventName,this.p))}destroy(){this.p&&(this.element.removeEventListener(this.eventName,this.p),this.p=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function m(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(r(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(r).join("")):"function"==typeof i||c(i)?s.push(l(o)):s.push(e(i??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=u,y(u,n.values,i,o);for(const t of o.parts)t.mount();return s.appendChild(u),o}function y(t,n,s,o){const i=[...t.childNodes];for(const e of i)3===e.nodeType?p(e,n,s,o,t):1===e.nodeType&&v(e,n,s,o)}function p(t,n,s,o,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const r=l(c),h=e.indexOf(r);if(-1===h)continue;if("text"!==u(s,r).type)continue;const d=e.substring(0,h),a=e.substring(h+r.length);d&&i.insertBefore(document.createTextNode(d),t);const m=new f(i,n[c]);o.parts.push(m);let y=t;return a&&(y=document.createTextNode(a),i.insertBefore(y,t)),i.removeChild(t),m.m=y!==t?y:null,void(a&&p(y,n,s,o,i))}}function v(t,n,s,o){const i=[...t.attributes];for(const e of i)for(let i=0;i<n.length;i++){const c=l(i);if(!e.value.includes(c))continue;const r=u(s,c);if("event"===r.type&&r.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[i]);o.parts.push(s)}else if("attr"===r.type&&r.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const l=new h(t,e.name,n[i]);o.parts.push(l)}}y(t,n,s,o)}function g(t={},s=null){const{title:o="",width:i="",closableOnMask:e=!0,escClose:c=!0}=t;let l=!1;function r(){if(l)return;l=!0,y&&y.classList.add("is-visible"),document.body.style.overflow="hidden";const t=y?.querySelector(".ds-modal");t&&t.focus()}function u(){l&&(l=!1,y&&y.classList.remove("is-visible"),document.body.style.overflow="")}const f=t=>{c&&"Escape"===t.key&&l&&u()};document.addEventListener("keydown",f);const h=n`
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,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 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 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(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(l).join("")):c(i)?s.push(e(i.value)):"function"!=typeof i&&s.push(e(i??""))}return s.join("")}function u(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 f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.m?this.container.insertBefore(n,this.m):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 d{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.p=null}mount(){"function"==typeof this.handler&&(this.p=t=>this.handler(t),this.element.addEventListener(this.eventName,this.p))}destroy(){this.p&&(this.element.removeEventListener(this.eventName,this.p),this.p=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function m(n,s){const o=new h,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(l(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(l).join("")):"function"==typeof i||c(i)?s.push(r(o)):s.push(e(i??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=u,y(u,n.values,i,o);for(const t of o.parts)t.mount();return s.appendChild(u),o}function y(t,n,s,o){const i=[...t.childNodes];for(const e of i)3===e.nodeType?p(e,n,s,o,t):1===e.nodeType&&b(e,n,s,o)}function p(t,n,s,o,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),d=e.indexOf(l);if(-1===d)continue;if("text"!==u(s,l).type)continue;const a=e.substring(0,d),h=e.substring(d+l.length);a&&i.insertBefore(document.createTextNode(a),t);const m=new f(i,n[c]);o.parts.push(m);let y=t;return h&&(y=document.createTextNode(h),i.insertBefore(y,t)),i.removeChild(t),m.m=y!==t?y:null,void(h&&p(y,n,s,o,i))}}function b(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 l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[i]);o.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 d(t,e.name,n[i]);o.parts.push(r)}}y(t,n,s,o)}function v(t={},s=null){const{title:o="",width:i="",closableOnMask:e=!0,escClose:c=!0}=t;let r=!1;function l(){if(r)return;r=!0,y&&y.classList.add("is-visible"),document.body.style.overflow="hidden";const t=y?.querySelector(".ds-modal");t&&t.focus()}function u(){r&&(r=!1,y&&y.classList.remove("is-visible"),document.body.style.overflow="")}const f=t=>{if(r)if(c&&"Escape"===t.key)u();else if("Tab"===t.key&&y){const n=y.querySelector(".ds-modal");if(!n)return;const s=Array.from(n.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])'));if(0===s.length)return void t.preventDefault();const o=s[0],i=s[s.length-1];t.shiftKey?document.activeElement===o&&(t.preventDefault(),i.focus()):document.activeElement===i&&(t.preventDefault(),o.focus())}};document.addEventListener("keydown",f);const d=n`
2
2
  <div class="ds-modal-mask" onclick="${t=>{e&&t.target===t.currentTarget&&u()}}">
3
3
  <div class="ds-modal" style="${i?`max-width: ${i}`:""}" role="dialog" aria-modal="true" aria-labelledby="modal-title" tabindex="-1">
4
4
  <div class="ds-modal__header">
@@ -12,4 +12,4 @@ class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return
12
12
  <div class="ds-modal__body">${s}</div>
13
13
  </div>
14
14
  </div>
15
- `,d=document.createDocumentFragment(),a=m(h,d),y=d.querySelector?d.querySelector(".ds-modal-mask"):d.firstChild;return{get element(){return d},open:r,close:u,toggle:function(){l?u():r()},destroy(){document.removeEventListener("keydown",f),document.body.style.overflow="",a.destroy()}}}export{g as Modal};
15
+ `,a=document.createDocumentFragment(),h=m(d,a),y=a.querySelector?a.querySelector(".ds-modal-mask"):a.firstChild;return{get element(){return a},open:l,close:u,toggle:function(){r?u():l()},destroy(){document.removeEventListener("keydown",f),document.body.style.overflow="",h.destroy()}}}export{v as Modal};
@@ -1,7 +1,8 @@
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.h.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function u(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 r(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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):u(e)?s.push(o(e.value)):"function"!=typeof e&&s.push(o(e??""))}return s.join("")}function f(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 h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.l=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,u(this.rawValue)){const t=this.rawValue;this.l=s(()=>{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.l?.(),this.node?.remove()}}class l{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.l=null}mount(){if(u(this.rawValue)){const t=this.rawValue;this.l=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.l?.()}}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 p{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function b(n,s){const i=new p,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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):"function"==typeof e||u(e)?s.push(c(i)):s.push(o(e??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);i.fragment=f,d(f,n.values,e,i);for(const t of i.parts)t.mount();return s.appendChild(f),i}function d(t,n,s,i){const e=[...t.childNodes];for(const o of e)3===o.nodeType?m(o,n,s,i,t):1===o.nodeType&&y(o,n,s,i)}function m(t,n,s,i,e){const o=t.textContent||"";for(let u=0;u<n.length;u++){const r=c(u),l=o.indexOf(r);if(-1===l)continue;if("text"!==f(s,r).type)continue;const a=o.substring(0,l),p=o.substring(l+r.length);a&&e.insertBefore(document.createTextNode(a),t);const b=new h(e,n[u]);i.parts.push(b);let d=t;return p&&(d=document.createTextNode(p),e.insertBefore(d,t)),e.removeChild(t),b.p=d!==t?d:null,void(p&&m(d,n,s,i,e))}}function y(t,n,s,i){const e=[...t.attributes];for(const o of e)for(let e=0;e<n.length;e++){const u=c(e);if(!o.value.includes(u))continue;const r=f(s,u);if("event"===r.type&&r.attrName===o.name){t.removeAttribute(o.name);const s=new a(t,o.name,n[e]);i.parts.push(s)}else if("attr"===r.type&&r.attrName===o.name){const s=o.value.replace(u,"");s?t.setAttribute(o.name,s):t.removeAttribute(o.name);const c=new l(t,o.name,n[e]);i.parts.push(c)}}d(t,n,s,i)}exports.NumberInput=function(t={}){const{min:s=-1/0,max:i=1/0,step:e=1,value:o=0,disabled:u=!1,onChange:c=null}=t;let r=h(o);function f(t){r=h(Number(t)||0),g&&(g.value=r),d(),c&&c(r)}function h(t){return Math.max(s,Math.min(i,t))}function l(t){const n=Number(t.target.value);isNaN(n)||(r=h(n),t.target.value=r,d(),c&&c(r))}function a(){f(r+e)}function p(){f(r-e)}function d(){v&&(v.disabled=u||r<=s),w&&(w.disabled=u||r>=i)}const m=n`
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 u(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 r(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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):u(e)?s.push(o(e.value)):"function"!=typeof e&&s.push(o(e??""))}return s.join("")}function f(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 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,u(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=r(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(u(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 b{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,s){const i=new b,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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):"function"==typeof e||u(e)?s.push(c(i)):s.push(o(e??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);i.fragment=f,d(f,n.values,e,i);for(const t of i.parts)t.mount();return s.appendChild(f),i}function d(t,n,s,i){const e=[...t.childNodes];for(const o of e)3===o.nodeType?m(o,n,s,i,t):1===o.nodeType&&y(o,n,s,i)}function m(t,n,s,i,e){const o=t.textContent||"";for(let u=0;u<n.length;u++){const r=c(u),h=o.indexOf(r);if(-1===h)continue;if("text"!==f(s,r).type)continue;const a=o.substring(0,h),b=o.substring(h+r.length);a&&e.insertBefore(document.createTextNode(a),t);const p=new l(e,n[u]);i.parts.push(p);let d=t;return b&&(d=document.createTextNode(b),e.insertBefore(d,t)),e.removeChild(t),p.p=d!==t?d:null,void(b&&m(d,n,s,i,e))}}function y(t,n,s,i){const e=[...t.attributes];for(const o of e)for(let e=0;e<n.length;e++){const u=c(e);if(!o.value.includes(u))continue;const r=f(s,u);if("event"===r.type&&r.attrName===o.name){t.removeAttribute(o.name);const s=new a(t,o.name,n[e]);i.parts.push(s)}else if("attr"===r.type&&r.attrName===o.name){const s=o.value.replace(u,"");s?t.setAttribute(o.name,s):t.removeAttribute(o.name);const c=new h(t,o.name,n[e]);i.parts.push(c)}}d(t,n,s,i)}exports.NumberInput=function(t={}){const{label:s="",id:i="",min:e=-1/0,max:o=1/0,step:u=1,value:c=0,disabled:r=!1,onChange:f=null}=t,l=i||(s?`ds-numinput-${Math.random().toString(36).slice(2,8)}`:""),h=!!s;let a=d(c);function b(t){a=d(Number(t)||0),x&&(x.value=a),g(),f&&f(a)}function d(t){return Math.max(e,Math.min(o,t))}function m(t){const n=Number(t.target.value);isNaN(n)||(a=d(n),t.target.value=a,g(),f&&f(a))}function y(){b(a+u)}function _(){b(a-u)}function g(){N&&(N.disabled=r||a<=e),S&&(S.disabled=r||a>=o)}const v=n`
2
+ ${h?n`<label class="ds-form-label" for="${l}">${s}</label>`:""}
2
3
  <div class="ds-number-input">
3
- <button class="ds-number-input__btn ds-number-input__btn--decrease" type="button">−</button>
4
- <input class="ds-number-input__input" type="number" />
5
- <button class="ds-number-input__btn ds-number-input__btn--increase" type="button">+</button>
4
+ <button class="ds-number-input__btn ds-number-input__btn--decrease" type="button" aria-label="Decrease">−</button>
5
+ <input class="ds-number-input__input" type="number" id="${l}" ${s?"":'aria-label="Number input"'} />
6
+ <button class="ds-number-input__btn ds-number-input__btn--increase" type="button" aria-label="Increase">+</button>
6
7
  </div>
7
- `,y=document.createDocumentFragment(),_=b(m,y),g=y.querySelector(".ds-number-input__input"),v=y.querySelector(".ds-number-input__btn--decrease"),w=y.querySelector(".ds-number-input__btn--increase");return g&&(g.value=r,g.min=s,g.max=i,g.step=e,g.disabled=u,g.addEventListener("change",l)),v&&(v.disabled=u||r<=s,v.addEventListener("click",p)),w&&(w.disabled=u||r>=i,w.addEventListener("click",a)),{get element(){return y},getValue:function(){return r},setValue:f,destroy:function(){g&&g.removeEventListener("change",l),v&&v.removeEventListener("click",p),w&&w.removeEventListener("click",a),_.destroy()}}};
8
+ `,$=document.createDocumentFragment(),w=p(v,$),x=$.querySelector(".ds-number-input__input"),N=$.querySelector(".ds-number-input__btn--decrease"),S=$.querySelector(".ds-number-input__btn--increase");return x&&(x.value=a,x.min=e,x.max=o,x.step=u,x.disabled=r,x.addEventListener("change",m)),N&&(N.disabled=r||a<=e,N.addEventListener("click",_)),S&&(S.disabled=r||a>=o,S.addEventListener("click",y)),{get element(){return $},getValue:function(){return a},setValue:b,destroy:function(){x&&x.removeEventListener("change",m),N&&N.removeEventListener("click",_),S&&S.removeEventListener("click",y),w.destroy()}}};
@@ -1,7 +1,8 @@
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.h.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function u(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 r(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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):u(e)?s.push(o(e.value)):"function"!=typeof e&&s.push(o(e??""))}return s.join("")}function f(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 h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.l=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,u(this.rawValue)){const t=this.rawValue;this.l=s(()=>{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.l?.(),this.node?.remove()}}class l{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.l=null}mount(){if(u(this.rawValue)){const t=this.rawValue;this.l=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.l?.()}}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 p{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function b(n,s){const i=new p,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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):"function"==typeof e||u(e)?s.push(c(i)):s.push(o(e??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);i.fragment=f,d(f,n.values,e,i);for(const t of i.parts)t.mount();return s.appendChild(f),i}function d(t,n,s,i){const e=[...t.childNodes];for(const o of e)3===o.nodeType?m(o,n,s,i,t):1===o.nodeType&&y(o,n,s,i)}function m(t,n,s,i,e){const o=t.textContent||"";for(let u=0;u<n.length;u++){const r=c(u),l=o.indexOf(r);if(-1===l)continue;if("text"!==f(s,r).type)continue;const a=o.substring(0,l),p=o.substring(l+r.length);a&&e.insertBefore(document.createTextNode(a),t);const b=new h(e,n[u]);i.parts.push(b);let d=t;return p&&(d=document.createTextNode(p),e.insertBefore(d,t)),e.removeChild(t),b.p=d!==t?d:null,void(p&&m(d,n,s,i,e))}}function y(t,n,s,i){const e=[...t.attributes];for(const o of e)for(let e=0;e<n.length;e++){const u=c(e);if(!o.value.includes(u))continue;const r=f(s,u);if("event"===r.type&&r.attrName===o.name){t.removeAttribute(o.name);const s=new a(t,o.name,n[e]);i.parts.push(s)}else if("attr"===r.type&&r.attrName===o.name){const s=o.value.replace(u,"");s?t.setAttribute(o.name,s):t.removeAttribute(o.name);const c=new l(t,o.name,n[e]);i.parts.push(c)}}d(t,n,s,i)}function _(t={}){const{min:s=-1/0,max:i=1/0,step:e=1,value:o=0,disabled:u=!1,onChange:c=null}=t;let r=h(o);function f(t){r=h(Number(t)||0),g&&(g.value=r),d(),c&&c(r)}function h(t){return Math.max(s,Math.min(i,t))}function l(t){const n=Number(t.target.value);isNaN(n)||(r=h(n),t.target.value=r,d(),c&&c(r))}function a(){f(r+e)}function p(){f(r-e)}function d(){v&&(v.disabled=u||r<=s),w&&(w.disabled=u||r>=i)}const m=n`
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 u(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 r(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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):u(e)?s.push(o(e.value)):"function"!=typeof e&&s.push(o(e??""))}return s.join("")}function f(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 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,u(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=r(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(u(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 b{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,s){const i=new b,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(r(e)):Array.isArray(e)&&e.length>0&&e[0]instanceof t?s.push(e.map(r).join("")):"function"==typeof e||u(e)?s.push(c(i)):s.push(o(e??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(e);i.fragment=f,d(f,n.values,e,i);for(const t of i.parts)t.mount();return s.appendChild(f),i}function d(t,n,s,i){const e=[...t.childNodes];for(const o of e)3===o.nodeType?m(o,n,s,i,t):1===o.nodeType&&y(o,n,s,i)}function m(t,n,s,i,e){const o=t.textContent||"";for(let u=0;u<n.length;u++){const r=c(u),h=o.indexOf(r);if(-1===h)continue;if("text"!==f(s,r).type)continue;const a=o.substring(0,h),b=o.substring(h+r.length);a&&e.insertBefore(document.createTextNode(a),t);const p=new l(e,n[u]);i.parts.push(p);let d=t;return b&&(d=document.createTextNode(b),e.insertBefore(d,t)),e.removeChild(t),p.p=d!==t?d:null,void(b&&m(d,n,s,i,e))}}function y(t,n,s,i){const e=[...t.attributes];for(const o of e)for(let e=0;e<n.length;e++){const u=c(e);if(!o.value.includes(u))continue;const r=f(s,u);if("event"===r.type&&r.attrName===o.name){t.removeAttribute(o.name);const s=new a(t,o.name,n[e]);i.parts.push(s)}else if("attr"===r.type&&r.attrName===o.name){const s=o.value.replace(u,"");s?t.setAttribute(o.name,s):t.removeAttribute(o.name);const c=new h(t,o.name,n[e]);i.parts.push(c)}}d(t,n,s,i)}function _(t={}){const{label:s="",id:i="",min:e=-1/0,max:o=1/0,step:u=1,value:c=0,disabled:r=!1,onChange:f=null}=t,l=i||(s?`ds-numinput-${Math.random().toString(36).slice(2,8)}`:""),h=!!s;let a=d(c);function b(t){a=d(Number(t)||0),x&&(x.value=a),g(),f&&f(a)}function d(t){return Math.max(e,Math.min(o,t))}function m(t){const n=Number(t.target.value);isNaN(n)||(a=d(n),t.target.value=a,g(),f&&f(a))}function y(){b(a+u)}function _(){b(a-u)}function g(){N&&(N.disabled=r||a<=e),S&&(S.disabled=r||a>=o)}const v=n`
2
+ ${h?n`<label class="ds-form-label" for="${l}">${s}</label>`:""}
2
3
  <div class="ds-number-input">
3
- <button class="ds-number-input__btn ds-number-input__btn--decrease" type="button">−</button>
4
- <input class="ds-number-input__input" type="number" />
5
- <button class="ds-number-input__btn ds-number-input__btn--increase" type="button">+</button>
4
+ <button class="ds-number-input__btn ds-number-input__btn--decrease" type="button" aria-label="Decrease">−</button>
5
+ <input class="ds-number-input__input" type="number" id="${l}" ${s?"":'aria-label="Number input"'} />
6
+ <button class="ds-number-input__btn ds-number-input__btn--increase" type="button" aria-label="Increase">+</button>
6
7
  </div>
7
- `,y=document.createDocumentFragment(),_=b(m,y),g=y.querySelector(".ds-number-input__input"),v=y.querySelector(".ds-number-input__btn--decrease"),w=y.querySelector(".ds-number-input__btn--increase");return g&&(g.value=r,g.min=s,g.max=i,g.step=e,g.disabled=u,g.addEventListener("change",l)),v&&(v.disabled=u||r<=s,v.addEventListener("click",p)),w&&(w.disabled=u||r>=i,w.addEventListener("click",a)),{get element(){return y},getValue:function(){return r},setValue:f,destroy:function(){g&&g.removeEventListener("change",l),v&&v.removeEventListener("click",p),w&&w.removeEventListener("click",a),_.destroy()}}}export{_ as NumberInput};
8
+ `,$=document.createDocumentFragment(),w=p(v,$),x=$.querySelector(".ds-number-input__input"),N=$.querySelector(".ds-number-input__btn--decrease"),S=$.querySelector(".ds-number-input__btn--increase");return x&&(x.value=a,x.min=e,x.max=o,x.step=u,x.disabled=r,x.addEventListener("change",m)),N&&(N.disabled=r||a<=e,N.addEventListener("click",_)),S&&(S.disabled=r||a>=o,S.addEventListener("click",y)),{get element(){return $},getValue:function(){return a},setValue:b,destroy:function(){x&&x.removeEventListener("change",m),N&&N.removeEventListener("click",_),S&&S.removeEventListener("click",y),w.destroy()}}}export{_ as NumberInput};
@@ -1,15 +1,16 @@
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,i:new Set,o:null,u:!1};return e.o=()=>{e.u||s(e)},s(e),()=>function(t){if(t.u)return;t.u=!0,c(t)}(e)}function s(t){c(t);try{t.t()}finally{}}function c(t){for(const e of t.i)e.l.delete(t);t.i.clear()}function i(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function o(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 u=t=>`຿${t}຿`;function r(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):o(c)?n.push(i(c.value)):"function"!=typeof c&&n.push(i(c??""))}return n.join("")}function l(t,e){const n=t.indexOf(e);if(-1===n)return{type:"text"};const s=t.substring(0,n).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,n).includes(">"))return{type:"text"};const c=t.substring(s+1,n).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!c)return{type:"text"};const i=c[1];return i.startsWith("on")&&i.length>2?{type:"event",attrName:i}:{type:"attr",attrName:i}}class f{constructor(t,e){this.container=t,this.rawValue=e,this.node=null,this.h=null}mount(){const e=document.createTextNode("");if(this._?this.container.insertBefore(e,this._):this.container.appendChild(e),this.node=e,o(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=r(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class a{constructor(t,e,n){this.element=t,this.attrName=e,this.rawValue=n,this.h=null}mount(){if(o(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 h{constructor(t,e,n){this.element=t,this.eventName=e.slice(2).toLowerCase(),this.handler=n,this.p=null}mount(){"function"==typeof this.handler&&(this.p=t=>this.handler(t),this.element.addEventListener(this.eventName,this.p))}destroy(){this.p&&(this.element.removeEventListener(this.eventName,this.p),this.p=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function _(e,n){const s=new d,c=function(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):"function"==typeof c||o(c)?n.push(u(s)):n.push(i(c??""))}return n.join("")}(e),l=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(c);s.fragment=l,p(l,e.values,c,s);for(const t of s.parts)t.mount();return n.appendChild(l),s}function p(t,e,n,s){const c=[...t.childNodes];for(const i of c)3===i.nodeType?v(i,e,n,s,t):1===i.nodeType&&m(i,e,n,s)}function v(t,e,n,s,c){const i=t.textContent||"";for(let o=0;o<e.length;o++){const r=u(o),a=i.indexOf(r);if(-1===a)continue;if("text"!==l(n,r).type)continue;const h=i.substring(0,a),d=i.substring(a+r.length);h&&c.insertBefore(document.createTextNode(h),t);const _=new f(c,e[o]);s.parts.push(_);let p=t;return d&&(p=document.createTextNode(d),c.insertBefore(p,t)),c.removeChild(t),_._=p!==t?p:null,void(d&&v(p,e,n,s,c))}}function m(t,e,n,s){const c=[...t.attributes];for(const i of c)for(let c=0;c<e.length;c++){const o=u(c);if(!i.value.includes(o))continue;const r=l(n,o);if("event"===r.type&&r.attrName===i.name){t.removeAttribute(i.name);const n=new h(t,i.name,e[c]);s.parts.push(n)}else if("attr"===r.type&&r.attrName===i.name){const n=i.value.replace(o,"");n?t.setAttribute(i.name,n):t.removeAttribute(i.name);const u=new a(t,i.name,e[c]);s.parts.push(u)}}p(t,e,n,s)}exports.Select=function(t={}){const{items:n=[],placeholder:s="Select...",searchable:c=!1,clearable:i=!1,multiple:o=!1,value:u="",values:r=null,onChange:l=null}=t;let f=!1,a=-1,h="",d=new Set;function p(){if(!h)return n;const t=h.toLowerCase();return n.filter(e=>e.text.toLowerCase().includes(t))}function v(){if(0===d.size)return"";if(o)return"";const t=n.find(t=>d.has(t.value));return t?t.text:""}function m(){f||(f=!0,h="",a=-1,B.classList.add("is-open"),z&&(z.value="",z.focus()),k())}function y(){f&&(f=!1,h="",a=-1,B.classList.remove("is-open"),$())}function g(){f?y():m()}function w(t){o?d.has(t.value)?d.delete(t.value):d.add(t.value):(d.clear(),d.add(t.value)),l&&l({value:t.value,text:t.text,values:[...d]}),b(),k(),o||y()}function b(){if(!D)return;const t=v();t?(D.textContent=t,D.classList.remove("ds-select__value--placeholder")):o&&d.size>0?(D.textContent=`${d.size} selected`,D.classList.remove("ds-select__value--placeholder")):(D.textContent=s,D.classList.add("ds-select__value--placeholder"))}function k(){if(!U)return;const t=p();U.querySelectorAll(".ds-select__item").forEach(t=>t.remove()),t.forEach((t,e)=>{const n=document.createElement("button");n.className="ds-select__item",d.has(t.value)&&n.classList.add("is-active"),e===a&&n.classList.add("is-focused"),n.setAttribute("data-value",t.value),n.textContent=t.text,n.addEventListener("click",e=>{e.stopPropagation(),w(t)}),U.appendChild(n)})}function $(){if(!U)return;U.querySelectorAll(".ds-select__item").forEach(t=>t.classList.remove("is-focused"))}function S(t){const e=p();if(0===e.length)return;if($(),a=(t%e.length+e.length)%e.length,!U)return;const n=U.querySelectorAll(".ds-select__item");n[a]&&n[a].classList.add("is-focused")}o&&r?d=new Set(r):!o&&u&&d.add(u);const x=t=>{t.stopPropagation(),g()},A=t=>{f&&B&&!B.contains(t.target)&&y()};document.addEventListener("click",A);const j=t=>{if(f)switch(t.key){case"ArrowDown":t.preventDefault(),S(a+1);break;case"ArrowUp":t.preventDefault(),S(a-1);break;case"Enter":t.preventDefault();{const t=p();a>=0&&a<t.length&&w(t[a])}break;case"Escape":t.preventDefault(),y()}};document.addEventListener("keydown",j);const O=t=>{h=t.target.value,a=-1,k()},C=t=>{t.stopPropagation(),d.clear(),b(),k(),l&&l({value:"",text:"",values:[]})},E=v(),N=e`
2
- <div class="ds-select">
3
- <div class="ds-select__trigger">
4
- <span class="ds-select__value${E?"":" ds-select__value--placeholder"}">${E||s}</span>
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||s(e)},s(e),()=>function(t){if(t.l)return;t.l=!0,c(t)}(e)}function s(t){c(t);try{t.t()}finally{}}function c(t){for(const e of t.o)e.u.delete(t);t.o.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function i(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 l=t=>`຿${t}຿`;function r(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):i(c)?n.push(o(c.value)):"function"!=typeof c&&n.push(o(c??""))}return n.join("")}function u(t,e){const n=t.indexOf(e);if(-1===n)return{type:"text"};const s=t.substring(0,n).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,n).includes(">"))return{type:"text"};const c=t.substring(s+1,n).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!c)return{type:"text"};const o=c[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class a{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,i(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=r(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,e,n){this.element=t,this.attrName=e,this.rawValue=n,this.h=null}mount(){if(i(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 d{constructor(t,e,n){this.element=t,this.eventName=e.slice(2).toLowerCase(),this.handler=n,this._=null}mount(){"function"==typeof this.handler&&(this._=t=>this.handler(t),this.element.addEventListener(this.eventName,this._))}destroy(){this._&&(this.element.removeEventListener(this.eventName,this._),this._=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 s=new h,c=function(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):"function"==typeof c||i(c)?n.push(l(s)):n.push(o(c??""))}return n.join("")}(e),u=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(c);s.fragment=u,_(u,e.values,c,s);for(const t of s.parts)t.mount();return n.appendChild(u),s}function _(t,e,n,s){const c=[...t.childNodes];for(const o of c)3===o.nodeType?m(o,e,n,s,t):1===o.nodeType&&g(o,e,n,s)}function m(t,e,n,s,c){const o=t.textContent||"";for(let i=0;i<e.length;i++){const r=l(i),f=o.indexOf(r);if(-1===f)continue;if("text"!==u(n,r).type)continue;const d=o.substring(0,f),h=o.substring(f+r.length);d&&c.insertBefore(document.createTextNode(d),t);const p=new a(c,e[i]);s.parts.push(p);let _=t;return h&&(_=document.createTextNode(h),c.insertBefore(_,t)),c.removeChild(t),p.p=_!==t?_:null,void(h&&m(_,e,n,s,c))}}function g(t,e,n,s){const c=[...t.attributes];for(const o of c)for(let c=0;c<e.length;c++){const i=l(c);if(!o.value.includes(i))continue;const r=u(n,i);if("event"===r.type&&r.attrName===o.name){t.removeAttribute(o.name);const n=new d(t,o.name,e[c]);s.parts.push(n)}else if("attr"===r.type&&r.attrName===o.name){const n=o.value.replace(i,"");n?t.setAttribute(o.name,n):t.removeAttribute(o.name);const l=new f(t,o.name,e[c]);s.parts.push(l)}}_(t,e,n,s)}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":"暂无数据"}};exports.Select=function(t={}){const{label:n="",items:s=[],placeholder:c=null,searchable:o=!1,clearable:i=!1,multiple:l=!1,value:r="",values:u=null,onChange:a=null}=t,f=c||function(t,e={}){let n=(v["en-US"]||v["en-US"])[t]||t;for(const[t,s]of Object.entries(e))n=n.replace(`{${t}}`,s);return n}("select.placeholder"),d=n?`ds-select-${Math.random().toString(36).slice(2,8)}`:"",h=!!n;let _=!1,m=-1,g="",y=new Set;function b(){if(!g)return s;const t=g.toLowerCase();return s.filter(e=>e.text.toLowerCase().includes(t))}function k(){if(0===y.size)return"";if(l)return"";const t=s.find(t=>y.has(t.value));return t?t.text:""}function w(){_||(_=!0,g="",m=-1,V.classList.add("is-open"),H&&(H.value="",H.focus()),N())}function S(){_&&(_=!1,g="",m=-1,V.classList.remove("is-open"),O())}function $(){_?S():w()}function x(t){l?y.has(t.value)?y.delete(t.value):y.add(t.value):(y.clear(),y.add(t.value)),a&&a({value:t.value,text:t.text,values:[...y]}),A(),N(),l||S()}function A(){if(!q)return;const t=k();t?(q.textContent=t,q.classList.remove("ds-select__value--placeholder")):l&&y.size>0?(q.textContent=`${y.size} selected`,q.classList.remove("ds-select__value--placeholder")):(q.textContent=f,q.classList.add("ds-select__value--placeholder"))}function N(){if(!z)return;const t=b();z.querySelectorAll(".ds-select__item").forEach(t=>t.remove()),t.forEach((t,e)=>{const n=document.createElement("button");n.className="ds-select__item",y.has(t.value)&&n.classList.add("is-active"),e===m&&n.classList.add("is-focused"),n.setAttribute("data-value",t.value),n.textContent=t.text,n.addEventListener("click",e=>{e.stopPropagation(),x(t)}),z.appendChild(n)})}function O(){if(!z)return;z.querySelectorAll(".ds-select__item").forEach(t=>t.classList.remove("is-focused"))}function j(t){const e=b();if(0===e.length)return;if(O(),m=(t%e.length+e.length)%e.length,!z)return;const n=z.querySelectorAll(".ds-select__item");n[m]&&n[m].classList.add("is-focused")}l&&u?y=new Set(u):!l&&r&&y.add(r);const C=t=>{t.stopPropagation(),$()},M=t=>{_&&V&&!V.contains(t.target)&&S()};document.addEventListener("click",M);const D=t=>{if(_)switch(t.key){case"ArrowDown":t.preventDefault(),j(m+1);break;case"ArrowUp":t.preventDefault(),j(m-1);break;case"Home":t.preventDefault(),j(0);break;case"End":t.preventDefault(),j(b().length-1);break;case"Enter":t.preventDefault();{const t=b();m>=0&&m<t.length&&x(t[m])}break;case"Escape":case"Tab":t.preventDefault(),S()}};document.addEventListener("keydown",D);const E=t=>{g=t.target.value,m=-1,N()},J=t=>{t.stopPropagation(),y.clear(),A(),N(),a&&a({value:"",text:"",values:[]})},T=k(),B=e`
2
+ ${h?e`<label class="ds-form-label" for="${d}">${n}</label>`:""}
3
+ <div class="ds-select" ${n?"":'aria-label="Select"'}>
4
+ <div class="ds-select__trigger" id="${d}">
5
+ <span class="ds-select__value${T?"":" ds-select__value--placeholder"}">${T||f}</span>
5
6
  ${i?e`<button class="ds-select__clear">&times;</button>`:""}
6
7
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
7
8
  <polyline points="6 9 12 15 18 9"/>
8
9
  </svg>
9
10
  </div>
10
11
  <div class="ds-select__menu">
11
- ${c?e`<div class="ds-select__search"><input class="ds-select__search-input" placeholder="Search..." /></div>`:""}
12
- ${n.map(t=>e`<button class="ds-select__item${d.has(t.value)?" is-active":""}" data-value="${t.value}">${t.text}</button>`)}
12
+ ${o?e`<div class="ds-select__search"><input class="ds-select__search-input" placeholder="Search..." /></div>`:""}
13
+ ${s.map(t=>e`<button class="ds-select__item${y.has(t.value)?" is-active":""}" data-value="${t.value}">${t.text}</button>`)}
13
14
  </div>
14
15
  </div>
15
- `,V=document.createDocumentFragment(),q=_(N,V),B=V.querySelector(".ds-select"),D=V.querySelector(".ds-select__value"),U=V.querySelector(".ds-select__menu"),z=V.querySelector(".ds-select__search-input"),F=V.querySelector(".ds-select__trigger");F&&F.addEventListener("click",x),z&&z.addEventListener("input",O);const G=V.querySelector(".ds-select__clear");return G&&G.addEventListener("click",C),function(){if(!U)return;U.querySelectorAll(".ds-select__item").forEach((t,e)=>{t.addEventListener("click",t=>{t.stopPropagation(),w(n[e])})})}(),{get element(){return V},open:m,close:y,toggle:g,getValue:function(){return o?[...d]:[...d][0]||""},setValue:function(t){d.clear(),o&&Array.isArray(t)?t.forEach(t=>d.add(t)):t&&d.add(t),b(),k()},destroy(){document.removeEventListener("click",A),document.removeEventListener("keydown",j),q.destroy()}}};
16
+ `,F=document.createDocumentFragment(),U=p(B,F),V=F.querySelector(".ds-select"),q=F.querySelector(".ds-select__value"),z=F.querySelector(".ds-select__menu"),H=F.querySelector(".ds-select__search-input"),K=F.querySelector(".ds-select__trigger");K&&K.addEventListener("click",C),H&&H.addEventListener("input",E);const P=F.querySelector(".ds-select__clear");return P&&P.addEventListener("click",J),function(){if(!z)return;z.querySelectorAll(".ds-select__item").forEach((t,e)=>{t.addEventListener("click",t=>{t.stopPropagation(),x(s[e])})})}(),{get element(){return F},open:w,close:S,toggle:$,getValue:function(){return l?[...y]:[...y][0]||""},setValue:function(t){y.clear(),l&&Array.isArray(t)?t.forEach(t=>y.add(t)):t&&y.add(t),A(),N()},destroy(){document.removeEventListener("click",M),document.removeEventListener("keydown",D),U.destroy()}}};
@@ -1,15 +1,16 @@
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,i:new Set,o:null,u:!1};return e.o=()=>{e.u||s(e)},s(e),()=>function(t){if(t.u)return;t.u=!0,c(t)}(e)}function s(t){c(t);try{t.t()}finally{}}function c(t){for(const e of t.i)e.l.delete(t);t.i.clear()}function i(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function o(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 u=t=>`຿${t}຿`;function r(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):o(c)?n.push(i(c.value)):"function"!=typeof c&&n.push(i(c??""))}return n.join("")}function l(t,e){const n=t.indexOf(e);if(-1===n)return{type:"text"};const s=t.substring(0,n).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,n).includes(">"))return{type:"text"};const c=t.substring(s+1,n).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!c)return{type:"text"};const i=c[1];return i.startsWith("on")&&i.length>2?{type:"event",attrName:i}:{type:"attr",attrName:i}}class f{constructor(t,e){this.container=t,this.rawValue=e,this.node=null,this.h=null}mount(){const e=document.createTextNode("");if(this._?this.container.insertBefore(e,this._):this.container.appendChild(e),this.node=e,o(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=r(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class a{constructor(t,e,n){this.element=t,this.attrName=e,this.rawValue=n,this.h=null}mount(){if(o(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 h{constructor(t,e,n){this.element=t,this.eventName=e.slice(2).toLowerCase(),this.handler=n,this.p=null}mount(){"function"==typeof this.handler&&(this.p=t=>this.handler(t),this.element.addEventListener(this.eventName,this.p))}destroy(){this.p&&(this.element.removeEventListener(this.eventName,this.p),this.p=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function _(e,n){const s=new d,c=function(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):"function"==typeof c||o(c)?n.push(u(s)):n.push(i(c??""))}return n.join("")}(e),l=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(c);s.fragment=l,p(l,e.values,c,s);for(const t of s.parts)t.mount();return n.appendChild(l),s}function p(t,e,n,s){const c=[...t.childNodes];for(const i of c)3===i.nodeType?v(i,e,n,s,t):1===i.nodeType&&m(i,e,n,s)}function v(t,e,n,s,c){const i=t.textContent||"";for(let o=0;o<e.length;o++){const r=u(o),a=i.indexOf(r);if(-1===a)continue;if("text"!==l(n,r).type)continue;const h=i.substring(0,a),d=i.substring(a+r.length);h&&c.insertBefore(document.createTextNode(h),t);const _=new f(c,e[o]);s.parts.push(_);let p=t;return d&&(p=document.createTextNode(d),c.insertBefore(p,t)),c.removeChild(t),_._=p!==t?p:null,void(d&&v(p,e,n,s,c))}}function m(t,e,n,s){const c=[...t.attributes];for(const i of c)for(let c=0;c<e.length;c++){const o=u(c);if(!i.value.includes(o))continue;const r=l(n,o);if("event"===r.type&&r.attrName===i.name){t.removeAttribute(i.name);const n=new h(t,i.name,e[c]);s.parts.push(n)}else if("attr"===r.type&&r.attrName===i.name){const n=i.value.replace(o,"");n?t.setAttribute(i.name,n):t.removeAttribute(i.name);const u=new a(t,i.name,e[c]);s.parts.push(u)}}p(t,e,n,s)}function y(t={}){const{items:n=[],placeholder:s="Select...",searchable:c=!1,clearable:i=!1,multiple:o=!1,value:u="",values:r=null,onChange:l=null}=t;let f=!1,a=-1,h="",d=new Set;function p(){if(!h)return n;const t=h.toLowerCase();return n.filter(e=>e.text.toLowerCase().includes(t))}function v(){if(0===d.size)return"";if(o)return"";const t=n.find(t=>d.has(t.value));return t?t.text:""}function m(){f||(f=!0,h="",a=-1,B.classList.add("is-open"),z&&(z.value="",z.focus()),k())}function y(){f&&(f=!1,h="",a=-1,B.classList.remove("is-open"),$())}function g(){f?y():m()}function w(t){o?d.has(t.value)?d.delete(t.value):d.add(t.value):(d.clear(),d.add(t.value)),l&&l({value:t.value,text:t.text,values:[...d]}),b(),k(),o||y()}function b(){if(!D)return;const t=v();t?(D.textContent=t,D.classList.remove("ds-select__value--placeholder")):o&&d.size>0?(D.textContent=`${d.size} selected`,D.classList.remove("ds-select__value--placeholder")):(D.textContent=s,D.classList.add("ds-select__value--placeholder"))}function k(){if(!U)return;const t=p();U.querySelectorAll(".ds-select__item").forEach(t=>t.remove()),t.forEach((t,e)=>{const n=document.createElement("button");n.className="ds-select__item",d.has(t.value)&&n.classList.add("is-active"),e===a&&n.classList.add("is-focused"),n.setAttribute("data-value",t.value),n.textContent=t.text,n.addEventListener("click",e=>{e.stopPropagation(),w(t)}),U.appendChild(n)})}function $(){if(!U)return;U.querySelectorAll(".ds-select__item").forEach(t=>t.classList.remove("is-focused"))}function S(t){const e=p();if(0===e.length)return;if($(),a=(t%e.length+e.length)%e.length,!U)return;const n=U.querySelectorAll(".ds-select__item");n[a]&&n[a].classList.add("is-focused")}o&&r?d=new Set(r):!o&&u&&d.add(u);const x=t=>{t.stopPropagation(),g()},A=t=>{f&&B&&!B.contains(t.target)&&y()};document.addEventListener("click",A);const j=t=>{if(f)switch(t.key){case"ArrowDown":t.preventDefault(),S(a+1);break;case"ArrowUp":t.preventDefault(),S(a-1);break;case"Enter":t.preventDefault();{const t=p();a>=0&&a<t.length&&w(t[a])}break;case"Escape":t.preventDefault(),y()}};document.addEventListener("keydown",j);const O=t=>{h=t.target.value,a=-1,k()},C=t=>{t.stopPropagation(),d.clear(),b(),k(),l&&l({value:"",text:"",values:[]})},E=v(),N=e`
2
- <div class="ds-select">
3
- <div class="ds-select__trigger">
4
- <span class="ds-select__value${E?"":" ds-select__value--placeholder"}">${E||s}</span>
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||s(e)},s(e),()=>function(t){if(t.l)return;t.l=!0,c(t)}(e)}function s(t){c(t);try{t.t()}finally{}}function c(t){for(const e of t.o)e.u.delete(t);t.o.clear()}function o(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function i(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 l=t=>`຿${t}຿`;function r(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):i(c)?n.push(o(c.value)):"function"!=typeof c&&n.push(o(c??""))}return n.join("")}function a(t,e){const n=t.indexOf(e);if(-1===n)return{type:"text"};const s=t.substring(0,n).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,n).includes(">"))return{type:"text"};const c=t.substring(s+1,n).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!c)return{type:"text"};const o=c[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}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,i(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=r(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,e,n){this.element=t,this.attrName=e,this.rawValue=n,this.h=null}mount(){if(i(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 d{constructor(t,e,n){this.element=t,this.eventName=e.slice(2).toLowerCase(),this.handler=n,this._=null}mount(){"function"==typeof this.handler&&(this._=t=>this.handler(t),this.element.addEventListener(this.eventName,this._))}destroy(){this._&&(this.element.removeEventListener(this.eventName,this._),this._=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 s=new h,c=function(e){const n=[];for(let s=0;s<e.strings.length;s++)if(n.push(e.strings[s]),s<e.values.length){const c=e.values[s];c instanceof t?n.push(r(c)):Array.isArray(c)&&c.length>0&&c[0]instanceof t?n.push(c.map(r).join("")):"function"==typeof c||i(c)?n.push(l(s)):n.push(o(c??""))}return n.join("")}(e),a=function(t){const e=document.createElement("template");return e.innerHTML=t,e.content}(c);s.fragment=a,_(a,e.values,c,s);for(const t of s.parts)t.mount();return n.appendChild(a),s}function _(t,e,n,s){const c=[...t.childNodes];for(const o of c)3===o.nodeType?m(o,e,n,s,t):1===o.nodeType&&g(o,e,n,s)}function m(t,e,n,s,c){const o=t.textContent||"";for(let i=0;i<e.length;i++){const r=l(i),f=o.indexOf(r);if(-1===f)continue;if("text"!==a(n,r).type)continue;const d=o.substring(0,f),h=o.substring(f+r.length);d&&c.insertBefore(document.createTextNode(d),t);const p=new u(c,e[i]);s.parts.push(p);let _=t;return h&&(_=document.createTextNode(h),c.insertBefore(_,t)),c.removeChild(t),p.p=_!==t?_:null,void(h&&m(_,e,n,s,c))}}function g(t,e,n,s){const c=[...t.attributes];for(const o of c)for(let c=0;c<e.length;c++){const i=l(c);if(!o.value.includes(i))continue;const r=a(n,i);if("event"===r.type&&r.attrName===o.name){t.removeAttribute(o.name);const n=new d(t,o.name,e[c]);s.parts.push(n)}else if("attr"===r.type&&r.attrName===o.name){const n=o.value.replace(i,"");n?t.setAttribute(o.name,n):t.removeAttribute(o.name);const l=new f(t,o.name,e[c]);s.parts.push(l)}}_(t,e,n,s)}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 y(t={}){const{label:n="",items:s=[],placeholder:c=null,searchable:o=!1,clearable:i=!1,multiple:l=!1,value:r="",values:a=null,onChange:u=null}=t,f=c||function(t,e={}){let n=(v["en-US"]||v["en-US"])[t]||t;for(const[t,s]of Object.entries(e))n=n.replace(`{${t}}`,s);return n}("select.placeholder"),d=n?`ds-select-${Math.random().toString(36).slice(2,8)}`:"",h=!!n;let _=!1,m=-1,g="",y=new Set;function b(){if(!g)return s;const t=g.toLowerCase();return s.filter(e=>e.text.toLowerCase().includes(t))}function k(){if(0===y.size)return"";if(l)return"";const t=s.find(t=>y.has(t.value));return t?t.text:""}function w(){_||(_=!0,g="",m=-1,V.classList.add("is-open"),H&&(H.value="",H.focus()),N())}function S(){_&&(_=!1,g="",m=-1,V.classList.remove("is-open"),O())}function $(){_?S():w()}function x(t){l?y.has(t.value)?y.delete(t.value):y.add(t.value):(y.clear(),y.add(t.value)),u&&u({value:t.value,text:t.text,values:[...y]}),A(),N(),l||S()}function A(){if(!q)return;const t=k();t?(q.textContent=t,q.classList.remove("ds-select__value--placeholder")):l&&y.size>0?(q.textContent=`${y.size} selected`,q.classList.remove("ds-select__value--placeholder")):(q.textContent=f,q.classList.add("ds-select__value--placeholder"))}function N(){if(!z)return;const t=b();z.querySelectorAll(".ds-select__item").forEach(t=>t.remove()),t.forEach((t,e)=>{const n=document.createElement("button");n.className="ds-select__item",y.has(t.value)&&n.classList.add("is-active"),e===m&&n.classList.add("is-focused"),n.setAttribute("data-value",t.value),n.textContent=t.text,n.addEventListener("click",e=>{e.stopPropagation(),x(t)}),z.appendChild(n)})}function O(){if(!z)return;z.querySelectorAll(".ds-select__item").forEach(t=>t.classList.remove("is-focused"))}function j(t){const e=b();if(0===e.length)return;if(O(),m=(t%e.length+e.length)%e.length,!z)return;const n=z.querySelectorAll(".ds-select__item");n[m]&&n[m].classList.add("is-focused")}l&&a?y=new Set(a):!l&&r&&y.add(r);const C=t=>{t.stopPropagation(),$()},M=t=>{_&&V&&!V.contains(t.target)&&S()};document.addEventListener("click",M);const D=t=>{if(_)switch(t.key){case"ArrowDown":t.preventDefault(),j(m+1);break;case"ArrowUp":t.preventDefault(),j(m-1);break;case"Home":t.preventDefault(),j(0);break;case"End":t.preventDefault(),j(b().length-1);break;case"Enter":t.preventDefault();{const t=b();m>=0&&m<t.length&&x(t[m])}break;case"Escape":case"Tab":t.preventDefault(),S()}};document.addEventListener("keydown",D);const E=t=>{g=t.target.value,m=-1,N()},J=t=>{t.stopPropagation(),y.clear(),A(),N(),u&&u({value:"",text:"",values:[]})},T=k(),B=e`
2
+ ${h?e`<label class="ds-form-label" for="${d}">${n}</label>`:""}
3
+ <div class="ds-select" ${n?"":'aria-label="Select"'}>
4
+ <div class="ds-select__trigger" id="${d}">
5
+ <span class="ds-select__value${T?"":" ds-select__value--placeholder"}">${T||f}</span>
5
6
  ${i?e`<button class="ds-select__clear">&times;</button>`:""}
6
7
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
7
8
  <polyline points="6 9 12 15 18 9"/>
8
9
  </svg>
9
10
  </div>
10
11
  <div class="ds-select__menu">
11
- ${c?e`<div class="ds-select__search"><input class="ds-select__search-input" placeholder="Search..." /></div>`:""}
12
- ${n.map(t=>e`<button class="ds-select__item${d.has(t.value)?" is-active":""}" data-value="${t.value}">${t.text}</button>`)}
12
+ ${o?e`<div class="ds-select__search"><input class="ds-select__search-input" placeholder="Search..." /></div>`:""}
13
+ ${s.map(t=>e`<button class="ds-select__item${y.has(t.value)?" is-active":""}" data-value="${t.value}">${t.text}</button>`)}
13
14
  </div>
14
15
  </div>
15
- `,V=document.createDocumentFragment(),q=_(N,V),B=V.querySelector(".ds-select"),D=V.querySelector(".ds-select__value"),U=V.querySelector(".ds-select__menu"),z=V.querySelector(".ds-select__search-input"),F=V.querySelector(".ds-select__trigger");F&&F.addEventListener("click",x),z&&z.addEventListener("input",O);const G=V.querySelector(".ds-select__clear");return G&&G.addEventListener("click",C),function(){if(!U)return;U.querySelectorAll(".ds-select__item").forEach((t,e)=>{t.addEventListener("click",t=>{t.stopPropagation(),w(n[e])})})}(),{get element(){return V},open:m,close:y,toggle:g,getValue:function(){return o?[...d]:[...d][0]||""},setValue:function(t){d.clear(),o&&Array.isArray(t)?t.forEach(t=>d.add(t)):t&&d.add(t),b(),k()},destroy(){document.removeEventListener("click",A),document.removeEventListener("keydown",j),q.destroy()}}}export{y as Select};
16
+ `,F=document.createDocumentFragment(),U=p(B,F),V=F.querySelector(".ds-select"),q=F.querySelector(".ds-select__value"),z=F.querySelector(".ds-select__menu"),H=F.querySelector(".ds-select__search-input"),K=F.querySelector(".ds-select__trigger");K&&K.addEventListener("click",C),H&&H.addEventListener("input",E);const P=F.querySelector(".ds-select__clear");return P&&P.addEventListener("click",J),function(){if(!z)return;z.querySelectorAll(".ds-select__item").forEach((t,e)=>{t.addEventListener("click",t=>{t.stopPropagation(),x(s[e])})})}(),{get element(){return F},open:w,close:S,toggle:$,getValue:function(){return l?[...y]:[...y][0]||""},setValue:function(t){y.clear(),l&&Array.isArray(t)?t.forEach(t=>y.add(t)):t&&y.add(t),A(),N()},destroy(){document.removeEventListener("click",M),document.removeEventListener("keydown",D),U.destroy()}}}export{y as Select};
@@ -1 +1 @@
1
- "use strict";exports.Table=function(t={}){if(!t||"object"!=typeof t)throw new TypeError("Table options must be an object.");const n=document.createElement("div"),e=[],o=t.columns||[],c=t.rowKey||"id",a=t.selection||null,l=t.expandable||null,u=t.editable||!1,r=t.resizable||!1,i=t.draggable||!1,s=t.tree||null,d=t.virtualScroll||null,p=t.mergeCells||null,f=t.multiSort||!1;let b=Array.isArray(t.data)?[...t.data]:[],m=!1,k=[],g=1,y=t.pageSize||10,h="",v=new Set,S=new Set,x=new Set,w=null,$={},T=[],A=[],D=null;function M(t,n){const e=n||s?.childrenKey||"children";t.forEach(t=>{const n=t[c];t[e]?.length&&(x.add(n),M(t[e],e))})}function E(t,n,e){const o=e||s?.childrenKey||"children",a=[];for(const e of t){const t=e[c];a.push({...e,t:n,o:!!e[o]?.length}),e[o]?.length&&x.has(t)&&a.push(...E(e[o],n+1,o))}return a}function L(){let n=[...b];if(h){const t=h.toLowerCase();n=s?j(n,t):n.filter(n=>o.some(e=>{const o=n[e.key];return e.filterFn?e.filterFn(o,h):null!=o&&String(o).toLowerCase().includes(t)}))}k.length>0&&(n=z(n));const e=s?E(n,0):n,c=e.length;let a=e;if(!1!==t.showPagination&&y>0){const t=(g-1)*y;a=e.slice(t,t+y)}return{pageData:a,total:c}}function j(t,n,e){const a=e||s?.childrenKey||"children";return t.reduce((t,e)=>{const l=e[a]?j(e[a],n,a):[];return(o.some(t=>{const o=e[t.key];return null!=o&&String(o).toLowerCase().includes(n)})||l.length>0)&&(t.push({...e,[a]:l}),l.length>0&&x.add(e[c])),t},[])}function z(t){const n=[...t].sort((t,n)=>{for(const e of k){const c=o.find(t=>t.key===e.key);let a=t[e.key],l=n[e.key],u=0;if(u=c?.sorter?c.sorter(a,l,e.order):null==a?1:null==l?-1:"number"==typeof a&&"number"==typeof l?"asc"===e.order?a-l:l-a:"asc"===e.order?String(a).localeCompare(String(l)):String(l).localeCompare(String(a)),0!==u)return u}return 0});if(s){const t=s.childrenKey||"children";return n.map(n=>n[t]?.length?{...n,[t]:z(n[t])}:n)}return n}function F(){const{pageData:e,total:s}=L();n.innerHTML="",(t.showFilter||t.showToolbar)&&n.appendChild(function(){const n=document.createElement("div");n.className="kupola-table-toolbar";const e=document.createElement("div");if("checkbox"===a&&v.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`Selected ${v.size} items`,e.appendChild(t)}const o=document.createElement("div");if(o.className="kupola-table-toolbar-right",t.showFilter){const n=document.createElement("input");n.type="text",n.className="kupola-table-filter-input",n.placeholder="Filter...",n.value=h,n.addEventListener("input",()=>{clearTimeout(D),D=setTimeout(()=>{h=n.value,g=1,F(),t.onFilter&&t.onFilter(h)},300)}),o.appendChild(n)}return n.appendChild(e),n.appendChild(o),n}());const d=document.createElement("div");d.className="kupola-table-container";const x=document.createElement("table");x.className=function(){const n=["kupola-table"];t.striped&&n.push("kupola-table-striped");!1!==t.hoverable&&n.push("kupola-table-hover");t.bordered&&n.push("kupola-table-bordered");t.compact&&n.push("kupola-table-compact");return n.join(" ")}(),x.appendChild(function(){const n=document.createElement("thead"),e=document.createElement("tr");a&&function(t){const n=document.createElement("th");if(n.className="kupola-table-col-selection","checkbox"===a){const t=document.createElement("input");t.type="checkbox";const{pageData:e}=L(),o=e.map(t=>t[c]);t.checked=o.length>0&&o.every(t=>v.has(t)),t.addEventListener("change",()=>t.checked?_():V()),n.appendChild(t)}t.appendChild(n)}(e);if(l){const t=document.createElement("th");t.className="kupola-table-col-expand",e.appendChild(t)}return o.forEach(n=>{const c=document.createElement("th");if(c.textContent=n.title||n.key,n.width&&(c.style.width="number"==typeof n.width?n.width+"px":n.width),n.minWidth&&(c.style.minWidth="number"==typeof n.minWidth?n.minWidth+"px":n.minWidth),n.align&&(c.style.textAlign=n.align),n.fixed&&c.setAttribute("data-fixed",n.fixed),n.sortable){c.classList.add("kupola-table-sortable");const e=k.find(t=>t.key===n.key);e&&c.classList.add(`kupola-table-sort-${e.order}`),c.addEventListener("click",()=>function(n){const e=k.find(t=>t.key===n);e?"asc"===e.order?e.order="desc":k=f?k.filter(t=>t.key!==n):[]:f?k.push({key:n,order:"asc"}):k=[{key:n,order:"asc"}];g=1,F(),t.onSort&&t.onSort(k)}(n.key));const o=document.createElement("span");o.className="kupola-table-sort-icon",o.textContent=e?f?` ${k.indexOf(e)+1}${"asc"===e.order?"▲":"▼"}`:"asc"===e.order?" ▲":" ▼":" ⇅",c.appendChild(o)}if(r&&n.key!==o[o.length-1]?.key){const t=document.createElement("span");t.className="kupola-table-resize-handle",t.setAttribute("data-col-key",n.key),c.appendChild(t)}e.appendChild(c)}),n.appendChild(e),n}()),x.appendChild(function(n){const e=document.createElement("tbody");if(m){const n=document.createElement("tr"),o=document.createElement("td");o.colSpan=K(),o.className="kupola-table-loading",o.textContent=t.loadingText||"Loading...",n.appendChild(o),e.appendChild(n)}else if(0===n.length){const n=document.createElement("tr"),o=document.createElement("td");o.colSpan=K(),o.className="kupola-table-empty",o.textContent=t.emptyText||"No data",n.appendChild(o),e.appendChild(n)}else{const r=p?p(n):[],s=new Map;r.forEach(t=>s.set(`${t.row}-${t.col}`,t));const d=new Set;n.forEach((n,r)=>{const p=n[c]??r,f=v.has(p),m=S.has(p),k=document.createElement("tr");if(k.setAttribute("data-row-key",p),f&&k.classList.add("kupola-table-row-selected"),i&&(k.draggable=!0,k.classList.add("kupola-table-draggable")),t.onRowClick&&k.addEventListener("click",()=>t.onRowClick(n,p)),a&&function(t,n,e){const o=document.createElement("td");o.className="kupola-table-col-selection";const c=document.createElement("input");c.type="radio"===a?"radio":"checkbox",c.checked=e,c.addEventListener("change",()=>{c.checked?C(n):N(n)}),o.appendChild(c),t.appendChild(o)}(k,p,f),l&&function(t,n,e){const o=document.createElement("td");o.className="kupola-table-col-expand";const c=document.createElement("button");c.type="button",c.className="kupola-table-expand-btn",c.textContent=e?"▼":"▶",c.addEventListener("click",()=>q(n)),o.appendChild(c),t.appendChild(o)}(k,p,m),o.forEach((e,o)=>{if(d.has(`${r}-${o}`))return;const a=document.createElement("td");e.align&&(a.style.textAlign=e.align),e.fixed&&a.setAttribute("data-fixed",e.fixed);const l=s.get(`${r}-${o}`);if(l){l.rowSpan>1&&(a.rowSpan=l.rowSpan),l.colSpan>1&&(a.colSpan=l.colSpan);for(let t=0;t<(l.rowSpan||1);t++)for(let n=0;n<(l.colSpan||1);n++)0===t&&0===n||d.add(`${r+t}-${o+n}`)}const i=n[e.key];if(w&&w.rowKey===p&&w.colKey===e.key)a.appendChild(function(n,e,o,a){const l=document.createElement("div");l.className="kupola-table-edit-cell";const u=document.createElement("input");u.type="text",u.className="kupola-table-edit-input",u.value=$[o.key]??e[o.key]??"",u.addEventListener("input",()=>{$[o.key]=u.value});const r=document.createElement("div");r.className="kupola-table-edit-actions";const i=document.createElement("button");i.type="button",i.className="kupola-table-edit-save",i.textContent="✓",i.addEventListener("click",()=>function(n,e){const o=b.find(t=>t[c]===n);o&&void 0!==$[e]&&(o[e]=$[e]);w=null,$={},t.onEditSave&&t.onEditSave(o,e);F()}(a,o.key));const s=document.createElement("button");return s.type="button",s.className="kupola-table-edit-cancel",s.textContent="✗",s.addEventListener("click",H),r.appendChild(i),r.appendChild(s),l.appendChild(u),l.appendChild(r),l}(0,n,e,p));else if(e.editable&&u)a.classList.add("kupola-table-editable-cell"),a.addEventListener("dblclick",()=>function(t,n,e){w={rowKey:t,colKey:n},$={[n]:null!=e?String(e):""},F()}(p,e.key,i)),function(t,n,e,o){if(n.render){const c=n.render(e,o);"string"==typeof c?t.innerHTML=c:c instanceof HTMLElement&&t.appendChild(c)}else t.textContent=null!=e?String(e):""}(a,e,i,n);else if(e.render){const t=e.render(i,n);"string"==typeof t?a.innerHTML=t:t instanceof HTMLElement&&a.appendChild(t)}else a.textContent=null!=i?String(i):"";k.appendChild(a)}),e.appendChild(k),l&&m){const t=document.createElement("tr");t.className="kupola-table-expand-row";const o=document.createElement("td");o.colSpan=K();const c=l(n);"string"==typeof c?o.innerHTML=c:c instanceof HTMLElement&&o.appendChild(c),t.appendChild(o),e.appendChild(t)}})}return e}(e)),d.appendChild(x),n.appendChild(d),!1!==t.showPagination&&s>y&&n.appendChild(function(n){const e=Math.ceil(n/y)||1,o=document.createElement("div");o.className="kupola-table-pagination";const c=document.createElement("span");c.className="kupola-table-page-info";const a=(g-1)*y+1,l=Math.min(g*y,n);c.textContent=`${a}-${l} / ${n}`;const u=document.createElement("div");u.className="kupola-table-pages";const r=document.createElement("button");r.type="button",r.className="kupola-table-page-btn",r.textContent="‹",r.disabled=g<=1,r.addEventListener("click",()=>{g>1&&(g--,F(),t.onPageChange&&t.onPageChange(g))}),u.appendChild(r);(function(t,n){if(n<=7)return Array.from({length:n},(t,n)=>n+1);const e=[];if(t<=4){for(let t=1;t<=5;t++)e.push(t);e.push("...",n)}else if(t>=n-3){e.push(1,"...");for(let t=n-4;t<=n;t++)e.push(t)}else{e.push(1,"...");for(let n=t-1;n<=t+1;n++)e.push(n);e.push("...",n)}return e})(g,e).forEach(n=>{if("..."===n){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",u.appendChild(t)}else{const e=document.createElement("button");e.type="button",e.className="kupola-table-page-btn"+(n===g?" active":""),e.textContent=n,e.addEventListener("click",()=>{g=n,F(),t.onPageChange&&t.onPageChange(g)}),u.appendChild(e)}});const i=document.createElement("button");if(i.type="button",i.className="kupola-table-page-btn",i.textContent="›",i.disabled=g>=e,i.addEventListener("click",()=>{g<e&&(g++,F(),t.onPageChange&&t.onPageChange(g))}),u.appendChild(i),t.pageSizeOptions?.length>1){const n=document.createElement("select");n.className="kupola-table-page-size",t.pageSizeOptions.forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=`${t} / page`,t===y&&(e.selected=!0),n.appendChild(e)}),n.addEventListener("change",()=>{y=Number(n.value),g=1,F()}),o.appendChild(c),o.appendChild(u),o.appendChild(n)}else o.appendChild(c),o.appendChild(u);return o}(s)),r&&n.querySelectorAll(".kupola-table-resize-handle").forEach(n=>{let e,c,a;const l=l=>{const u=n.parentElement;e=l.pageX,c=u.offsetWidth;const r=n.getAttribute("data-col-key");a=o.find(t=>t.key===r);const i=t=>{const n=t.pageX-e,o=Math.max(50,c+n);u.style.width=o+"px"},s=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s),a&&t.onColumnResize&&t.onColumnResize(a.key,u.offsetWidth)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)};n.addEventListener("mousedown",l),A.push(()=>n.removeEventListener("mousedown",l))}),i&&function(){const e=n.querySelectorAll("tbody tr[data-row-key]");e.forEach(n=>{const o=t=>{n.classList.add("kupola-table-dragging"),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",n.getAttribute("data-row-key"))},a=t=>{t.preventDefault(),n.classList.add("kupola-table-drag-over")},l=()=>n.classList.remove("kupola-table-drag-over"),u=e=>{e.preventDefault(),n.classList.remove("kupola-table-drag-over");const o=e.dataTransfer.getData("text/plain"),a=n.getAttribute("data-row-key");o!==a&&function(n,e){const o=b.findIndex(t=>String(t[c])===String(n)),a=b.findIndex(t=>String(t[c])===String(e));if(-1===o||-1===a)return;const[l]=b.splice(o,1);b.splice(a,0,l),F(),t.onRowDragEnd&&t.onRowDragEnd(n,e)}(o,a)},r=()=>{n.classList.remove("kupola-table-dragging"),e.forEach(t=>t.classList.remove("kupola-table-drag-over"))};n.addEventListener("dragstart",o),n.addEventListener("dragover",a),n.addEventListener("dragleave",l),n.addEventListener("drop",u),n.addEventListener("dragend",r),A.push(()=>{n.removeEventListener("dragstart",o),n.removeEventListener("dragover",a),n.removeEventListener("dragleave",l),n.removeEventListener("drop",u),n.removeEventListener("dragend",r)})})}()}function H(){w=null,$={},t.onEditCancel&&t.onEditCancel(),F()}function K(){return o.length+(a?1:0)+(l?1:0)}function P(){return[...v]}function R(){return b.filter(t=>v.has(t[c]))}function C(n){"radio"===a?(v.clear(),v.add(n)):v.add(n),F(),t.onSelect&&t.onSelect(P(),R())}function N(n){v.delete(n),F(),t.onSelect&&t.onSelect(P(),R())}function _(){const{pageData:n}=L();n.forEach(t=>v.add(t[c])),F(),t.onSelect&&t.onSelect(P(),R())}function V(){v.clear(),F(),t.onSelect&&t.onSelect(P(),R())}function q(n){S.has(n)?S.delete(n):S.add(n),F(),t.onExpand&&t.onExpand(n,S.has(n))}return s?.defaultExpandAll&&M(b),n.classList.add("kupola-table-wrapper"),d&&n.classList.add("kupola-table-virtual-wrapper"),F(),{element:n,destroy:function(){e.forEach(({el:t,event:n,handler:e})=>t.removeEventListener(n,e)),e.length=0,T.forEach(t=>t()),T.length=0,A.forEach(t=>t()),A.length=0,clearTimeout(D),n.remove()},setData:function(t){t&&"object"==typeof t&&"value"in t?(b=Array.isArray(t.value)?[...t.value]:[],t.subscribe&&T.push(t.subscribe(t=>{b=Array.isArray(t)?[...t]:[],F()}))):b=Array.isArray(t)?[...t]:[],s&&s.defaultExpandAll&&(x.clear(),M(b)),F()},setLoading:function(t){t&&"object"==typeof t&&"value"in t?(m=!!t.value,t.subscribe&&T.push(t.subscribe(t=>{m=!!t,F()}))):m=!!t,F()},getData:function(){return[...b]},getProcessedData:()=>L().pageData,getSelectedRows:R,getSelectedKeys:P,selectRow:C,deselectRow:N,selectAll:_,deselectAll:V,toggleExpand:q,expandAll:function(){const{pageData:t}=L();t.forEach(t=>S.add(t[c])),F()},collapseAll:function(){S.clear(),F()},setSort:function(t,n){if(f){const e=k.find(n=>n.key===t);e?e.order=n||"asc":k.push({key:t,order:n||"asc"})}else k=[{key:t,order:n||"asc"}];g=1,F()},clearSort:function(){k=[],F()},setPage:function(n){g=Math.max(1,n),F(),t.onPageChange&&t.onPageChange(g)},setPageSize:function(t){y=t,g=1,F()},setFilterText:function(t){h=t,g=1,F()},getFilterText:function(){return h},exportCSV:function(){const t=o.map(t=>t.title||t.key).join(","),{pageData:n}=L();return[t,...n.map(t=>o.map(n=>{const e=t[n.key],o=null!=e?String(e):"";return o.includes(",")?`"${o}"`:o}).join(","))].join("\n")},refresh:function(){F()}}};
1
+ "use strict";const t={"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":"暂无数据"}};exports.Table=function(e={}){if(!e||"object"!=typeof e)throw new TypeError("Table options must be an object.");const n=document.createElement("div"),o=[],c=e.columns||[],a=e.rowKey||"id",l=e.selection||null,u=e.expandable||null,r=e.editable||!1,i=e.resizable||!1,s=e.draggable||!1,d=e.tree||null,p=e.virtualScroll||null,f=e.mergeCells||null,b=e.multiSort||!1;let m=Array.isArray(e.data)?[...e.data]:[],g=!1,k=[],h=1,y=e.pageSize||10,S="",v=new Set,w=new Set,x=new Set,$=null,T={},A=[],D=[],M=null;function j(t,e){const n=e||d?.childrenKey||"children";t.forEach(t=>{const e=t[a];t[n]?.length&&(x.add(e),j(t[n],n))})}function z(t,e,n){const o=n||d?.childrenKey||"children",c=[];for(const n of t){const t=n[a];c.push({...n,t:e,o:!!n[o]?.length}),n[o]?.length&&x.has(t)&&c.push(...z(n[o],e+1,o))}return c}function C(){let t=[...m];if(S){const e=S.toLowerCase();t=d?E(t,e):t.filter(t=>c.some(n=>{const o=t[n.key];return n.filterFn?n.filterFn(o,S):null!=o&&String(o).toLowerCase().includes(e)}))}k.length>0&&(t=F(t));const n=d?z(t,0):t,o=n.length;let a=n;if(!1!==e.showPagination&&y>0){const t=(h-1)*y;a=n.slice(t,t+y)}return{pageData:a,total:o}}function E(t,e,n){const o=n||d?.childrenKey||"children";return t.reduce((t,n)=>{const l=n[o]?E(n[o],e,o):[];return(c.some(t=>{const o=n[t.key];return null!=o&&String(o).toLowerCase().includes(e)})||l.length>0)&&(t.push({...n,[o]:l}),l.length>0&&x.add(n[a])),t},[])}function F(t){const e=[...t].sort((t,e)=>{for(const n of k){const o=c.find(t=>t.key===n.key);let a=t[n.key],l=e[n.key],u=0;if(u=o?.sorter?o.sorter(a,l,n.order):null==a?1:null==l?-1:"number"==typeof a&&"number"==typeof l?"asc"===n.order?a-l:l-a:"asc"===n.order?String(a).localeCompare(String(l)):String(l).localeCompare(String(a)),0!==u)return u}return 0});if(d){const t=d.childrenKey||"children";return e.map(e=>e[t]?.length?{...e,[t]:F(e[t])}:e)}return e}function L(){const{pageData:o,total:d}=C();n.innerHTML="",(e.showFilter||e.showToolbar)&&n.appendChild(function(){const t=document.createElement("div");t.className="kupola-table-toolbar";const n=document.createElement("div");if("checkbox"===l&&v.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`Selected ${v.size} items`,n.appendChild(t)}const o=document.createElement("div");if(o.className="kupola-table-toolbar-right",e.showFilter){const t=document.createElement("input");t.type="text",t.className="kupola-table-filter-input",t.placeholder="Filter...",t.value=S,t.addEventListener("input",()=>{clearTimeout(M),M=setTimeout(()=>{S=t.value,h=1,L(),e.onFilter&&e.onFilter(S)},300)}),o.appendChild(t)}return t.appendChild(n),t.appendChild(o),t}());const p=document.createElement("div");p.className="kupola-table-container";const x=document.createElement("table");x.className=function(){const t=["kupola-table"];e.striped&&t.push("kupola-table-striped");!1!==e.hoverable&&t.push("kupola-table-hover");e.bordered&&t.push("kupola-table-bordered");e.compact&&t.push("kupola-table-compact");return t.join(" ")}(),x.appendChild(function(){const t=document.createElement("thead"),n=document.createElement("tr");l&&function(t){const e=document.createElement("th");if(e.className="kupola-table-col-selection","checkbox"===l){const t=document.createElement("input");t.type="checkbox";const{pageData:n}=C(),o=n.map(t=>t[a]);t.checked=o.length>0&&o.every(t=>v.has(t)),t.addEventListener("change",()=>t.checked?R():_()),e.appendChild(t)}t.appendChild(e)}(n);if(u){const t=document.createElement("th");t.className="kupola-table-col-expand",n.appendChild(t)}return c.forEach(t=>{const o=document.createElement("th");if(o.textContent=t.title||t.key,t.width&&(o.style.width="number"==typeof t.width?t.width+"px":t.width),t.minWidth&&(o.style.minWidth="number"==typeof t.minWidth?t.minWidth+"px":t.minWidth),t.align&&(o.style.textAlign=t.align),t.fixed&&o.setAttribute("data-fixed",t.fixed),t.sortable){o.classList.add("kupola-table-sortable");const n=k.find(e=>e.key===t.key);n&&o.classList.add(`kupola-table-sort-${n.order}`),o.addEventListener("click",()=>function(t){const n=k.find(e=>e.key===t);n?"asc"===n.order?n.order="desc":k=b?k.filter(e=>e.key!==t):[]:b?k.push({key:t,order:"asc"}):k=[{key:t,order:"asc"}];h=1,L(),e.onSort&&e.onSort(k)}(t.key));const c=document.createElement("span");c.className="kupola-table-sort-icon",c.textContent=n?b?` ${k.indexOf(n)+1}${"asc"===n.order?"▲":"▼"}`:"asc"===n.order?" ▲":" ▼":" ⇅",o.appendChild(c)}if(i&&t.key!==c[c.length-1]?.key){const e=document.createElement("span");e.className="kupola-table-resize-handle",e.setAttribute("data-col-key",t.key),o.appendChild(e)}n.appendChild(o)}),t.appendChild(n),t}()),x.appendChild(function(n){const o=document.createElement("tbody");if(g){const t=document.createElement("tr"),n=document.createElement("td");n.colSpan=K(),n.className="kupola-table-loading",n.textContent=e.loadingText||"Loading...",t.appendChild(n),o.appendChild(t)}else if(0===n.length){const n=document.createElement("tr"),c=document.createElement("td");c.colSpan=K(),c.className="kupola-table-empty",c.textContent=e.emptyText||function(e,n={}){let o=(t["en-US"]||t["en-US"])[e]||e;for(const[t,e]of Object.entries(n))o=o.replace(`{${t}}`,e);return o}("table.empty"),n.appendChild(c),o.appendChild(n)}else{const t=f?f(n):[],i=new Map;t.forEach(t=>i.set(`${t.row}-${t.col}`,t));const d=new Set;n.forEach((t,n)=>{const p=t[a]??n,f=v.has(p),b=w.has(p),g=document.createElement("tr");if(g.setAttribute("data-row-key",p),f&&g.classList.add("kupola-table-row-selected"),s&&(g.draggable=!0,g.classList.add("kupola-table-draggable")),e.onRowClick&&g.addEventListener("click",()=>e.onRowClick(t,p)),l&&function(t,e,n){const o=document.createElement("td");o.className="kupola-table-col-selection";const c=document.createElement("input");c.type="radio"===l?"radio":"checkbox",c.checked=n,c.addEventListener("change",()=>{c.checked?J(e):O(e)}),o.appendChild(c),t.appendChild(o)}(g,p,f),u&&function(t,e,n){const o=document.createElement("td");o.className="kupola-table-col-expand";const c=document.createElement("button");c.type="button",c.className="kupola-table-expand-btn",c.textContent=n?"▼":"▶",c.addEventListener("click",()=>B(e)),o.appendChild(c),t.appendChild(o)}(g,p,b),c.forEach((o,c)=>{if(d.has(`${n}-${c}`))return;const l=document.createElement("td");o.align&&(l.style.textAlign=o.align),o.fixed&&l.setAttribute("data-fixed",o.fixed);const u=i.get(`${n}-${c}`);if(u){u.rowSpan>1&&(l.rowSpan=u.rowSpan),u.colSpan>1&&(l.colSpan=u.colSpan);for(let t=0;t<(u.rowSpan||1);t++)for(let e=0;e<(u.colSpan||1);e++)0===t&&0===e||d.add(`${n+t}-${c+e}`)}const s=t[o.key];if($&&$.rowKey===p&&$.colKey===o.key)l.appendChild(function(t,n,o,c){const l=document.createElement("div");l.className="kupola-table-edit-cell";const u=document.createElement("input");u.type="text",u.className="kupola-table-edit-input",u.value=T[o.key]??n[o.key]??"",u.addEventListener("input",()=>{T[o.key]=u.value});const r=document.createElement("div");r.className="kupola-table-edit-actions";const i=document.createElement("button");i.type="button",i.className="kupola-table-edit-save",i.textContent="✓",i.addEventListener("click",()=>function(t,n){const o=m.find(e=>e[a]===t);o&&void 0!==T[n]&&(o[n]=T[n]);$=null,T={},e.onEditSave&&e.onEditSave(o,n);L()}(c,o.key));const s=document.createElement("button");return s.type="button",s.className="kupola-table-edit-cancel",s.textContent="✗",s.addEventListener("click",N),r.appendChild(i),r.appendChild(s),l.appendChild(u),l.appendChild(r),l}(0,t,o,p));else if(o.editable&&r)l.classList.add("kupola-table-editable-cell"),l.addEventListener("dblclick",()=>function(t,e,n){$={rowKey:t,colKey:e},T={[e]:null!=n?String(n):""},L()}(p,o.key,s)),function(t,e,n,o){if(e.render){const c=e.render(n,o);"string"==typeof c?t.innerHTML=c:c instanceof HTMLElement&&t.appendChild(c)}else t.textContent=null!=n?String(n):""}(l,o,s,t);else if(o.render){const e=o.render(s,t);"string"==typeof e?l.innerHTML=e:e instanceof HTMLElement&&l.appendChild(e)}else l.textContent=null!=s?String(s):"";g.appendChild(l)}),o.appendChild(g),u&&b){const e=document.createElement("tr");e.className="kupola-table-expand-row";const n=document.createElement("td");n.colSpan=K();const c=u(t);"string"==typeof c?n.innerHTML=c:c instanceof HTMLElement&&n.appendChild(c),e.appendChild(n),o.appendChild(e)}})}return o}(o)),p.appendChild(x),n.appendChild(p),!1!==e.showPagination&&d>y&&n.appendChild(function(t){const n=Math.ceil(t/y)||1,o=document.createElement("div");o.className="kupola-table-pagination";const c=document.createElement("span");c.className="kupola-table-page-info";const a=(h-1)*y+1,l=Math.min(h*y,t);c.textContent=`${a}-${l} / ${t}`;const u=document.createElement("div");u.className="kupola-table-pages";const r=document.createElement("button");r.type="button",r.className="kupola-table-page-btn",r.textContent="‹",r.disabled=h<=1,r.addEventListener("click",()=>{h>1&&(h--,L(),e.onPageChange&&e.onPageChange(h))}),u.appendChild(r);(function(t,e){if(e<=7)return Array.from({length:e},(t,e)=>e+1);const n=[];if(t<=4){for(let t=1;t<=5;t++)n.push(t);n.push("...",e)}else if(t>=e-3){n.push(1,"...");for(let t=e-4;t<=e;t++)n.push(t)}else{n.push(1,"...");for(let e=t-1;e<=t+1;e++)n.push(e);n.push("...",e)}return n})(h,n).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",u.appendChild(t)}else{const n=document.createElement("button");n.type="button",n.className="kupola-table-page-btn"+(t===h?" active":""),n.textContent=t,n.addEventListener("click",()=>{h=t,L(),e.onPageChange&&e.onPageChange(h)}),u.appendChild(n)}});const i=document.createElement("button");if(i.type="button",i.className="kupola-table-page-btn",i.textContent="›",i.disabled=h>=n,i.addEventListener("click",()=>{h<n&&(h++,L(),e.onPageChange&&e.onPageChange(h))}),u.appendChild(i),e.pageSizeOptions?.length>1){const t=document.createElement("select");t.className="kupola-table-page-size",e.pageSizeOptions.forEach(e=>{const n=document.createElement("option");n.value=e,n.textContent=`${e} / page`,e===y&&(n.selected=!0),t.appendChild(n)}),t.addEventListener("change",()=>{y=Number(t.value),h=1,L()}),o.appendChild(c),o.appendChild(u),o.appendChild(t)}else o.appendChild(c),o.appendChild(u);return o}(d)),i&&n.querySelectorAll(".kupola-table-resize-handle").forEach(t=>{let n,o,a;const l=l=>{const u=t.parentElement;n=l.pageX,o=u.offsetWidth;const r=t.getAttribute("data-col-key");a=c.find(t=>t.key===r);const i=t=>{const e=t.pageX-n,c=Math.max(50,o+e);u.style.width=c+"px"},s=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s),a&&e.onColumnResize&&e.onColumnResize(a.key,u.offsetWidth)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)};t.addEventListener("mousedown",l),D.push(()=>t.removeEventListener("mousedown",l))}),s&&function(){const t=n.querySelectorAll("tbody tr[data-row-key]");t.forEach(n=>{const o=t=>{n.classList.add("kupola-table-dragging"),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",n.getAttribute("data-row-key"))},c=t=>{t.preventDefault(),n.classList.add("kupola-table-drag-over")},l=()=>n.classList.remove("kupola-table-drag-over"),u=t=>{t.preventDefault(),n.classList.remove("kupola-table-drag-over");const o=t.dataTransfer.getData("text/plain"),c=n.getAttribute("data-row-key");o!==c&&function(t,n){const o=m.findIndex(e=>String(e[a])===String(t)),c=m.findIndex(t=>String(t[a])===String(n));if(-1===o||-1===c)return;const[l]=m.splice(o,1);m.splice(c,0,l),L(),e.onRowDragEnd&&e.onRowDragEnd(t,n)}(o,c)},r=()=>{n.classList.remove("kupola-table-dragging"),t.forEach(t=>t.classList.remove("kupola-table-drag-over"))};n.addEventListener("dragstart",o),n.addEventListener("dragover",c),n.addEventListener("dragleave",l),n.addEventListener("drop",u),n.addEventListener("dragend",r),D.push(()=>{n.removeEventListener("dragstart",o),n.removeEventListener("dragover",c),n.removeEventListener("dragleave",l),n.removeEventListener("drop",u),n.removeEventListener("dragend",r)})})}()}function N(){$=null,T={},e.onEditCancel&&e.onEditCancel(),L()}function K(){return c.length+(l?1:0)+(u?1:0)}function P(){return[...v]}function H(){return m.filter(t=>v.has(t[a]))}function J(t){"radio"===l?(v.clear(),v.add(t)):v.add(t),L(),e.onSelect&&e.onSelect(P(),H())}function O(t){v.delete(t),L(),e.onSelect&&e.onSelect(P(),H())}function R(){const{pageData:t}=C();t.forEach(t=>v.add(t[a])),L(),e.onSelect&&e.onSelect(P(),H())}function _(){v.clear(),L(),e.onSelect&&e.onSelect(P(),H())}function B(t){w.has(t)?w.delete(t):w.add(t),L(),e.onExpand&&e.onExpand(t,w.has(t))}return d?.defaultExpandAll&&j(m),n.classList.add("kupola-table-wrapper"),p&&n.classList.add("kupola-table-virtual-wrapper"),L(),{element:n,destroy:function(){o.forEach(({el:t,event:e,handler:n})=>t.removeEventListener(e,n)),o.length=0,A.forEach(t=>t()),A.length=0,D.forEach(t=>t()),D.length=0,clearTimeout(M),n.remove()},setData:function(t){t&&"object"==typeof t&&"value"in t?(m=Array.isArray(t.value)?[...t.value]:[],t.subscribe&&A.push(t.subscribe(t=>{m=Array.isArray(t)?[...t]:[],L()}))):m=Array.isArray(t)?[...t]:[],d&&d.defaultExpandAll&&(x.clear(),j(m)),L()},setLoading:function(t){t&&"object"==typeof t&&"value"in t?(g=!!t.value,t.subscribe&&A.push(t.subscribe(t=>{g=!!t,L()}))):g=!!t,L()},getData:function(){return[...m]},getProcessedData:()=>C().pageData,getSelectedRows:H,getSelectedKeys:P,selectRow:J,deselectRow:O,selectAll:R,deselectAll:_,toggleExpand:B,expandAll:function(){const{pageData:t}=C();t.forEach(t=>w.add(t[a])),L()},collapseAll:function(){w.clear(),L()},setSort:function(t,e){if(b){const n=k.find(e=>e.key===t);n?n.order=e||"asc":k.push({key:t,order:e||"asc"})}else k=[{key:t,order:e||"asc"}];h=1,L()},clearSort:function(){k=[],L()},setPage:function(t){h=Math.max(1,t),L(),e.onPageChange&&e.onPageChange(h)},setPageSize:function(t){y=t,h=1,L()},setFilterText:function(t){S=t,h=1,L()},getFilterText:function(){return S},exportCSV:function(){const t=c.map(t=>t.title||t.key).join(","),{pageData:e}=C();return[t,...e.map(t=>c.map(e=>{const n=t[e.key],o=null!=n?String(n):"";return o.includes(",")?`"${o}"`:o}).join(","))].join("\n")},refresh:function(){L()}}};
@@ -1 +1 @@
1
- function t(t={}){if(!t||"object"!=typeof t)throw new TypeError("Table options must be an object.");const n=document.createElement("div"),e=[],o=t.columns||[],c=t.rowKey||"id",a=t.selection||null,l=t.expandable||null,u=t.editable||!1,r=t.resizable||!1,i=t.draggable||!1,s=t.tree||null,d=t.virtualScroll||null,p=t.mergeCells||null,f=t.multiSort||!1;let b=Array.isArray(t.data)?[...t.data]:[],m=!1,k=[],g=1,y=t.pageSize||10,h="",v=new Set,S=new Set,x=new Set,w=null,$={},T=[],A=[],D=null;function M(t,n){const e=n||s?.childrenKey||"children";t.forEach(t=>{const n=t[c];t[e]?.length&&(x.add(n),M(t[e],e))})}function E(t,n,e){const o=e||s?.childrenKey||"children",a=[];for(const e of t){const t=e[c];a.push({...e,t:n,o:!!e[o]?.length}),e[o]?.length&&x.has(t)&&a.push(...E(e[o],n+1,o))}return a}function L(){let n=[...b];if(h){const t=h.toLowerCase();n=s?j(n,t):n.filter(n=>o.some(e=>{const o=n[e.key];return e.filterFn?e.filterFn(o,h):null!=o&&String(o).toLowerCase().includes(t)}))}k.length>0&&(n=z(n));const e=s?E(n,0):n,c=e.length;let a=e;if(!1!==t.showPagination&&y>0){const t=(g-1)*y;a=e.slice(t,t+y)}return{pageData:a,total:c}}function j(t,n,e){const a=e||s?.childrenKey||"children";return t.reduce((t,e)=>{const l=e[a]?j(e[a],n,a):[];return(o.some(t=>{const o=e[t.key];return null!=o&&String(o).toLowerCase().includes(n)})||l.length>0)&&(t.push({...e,[a]:l}),l.length>0&&x.add(e[c])),t},[])}function z(t){const n=[...t].sort((t,n)=>{for(const e of k){const c=o.find(t=>t.key===e.key);let a=t[e.key],l=n[e.key],u=0;if(u=c?.sorter?c.sorter(a,l,e.order):null==a?1:null==l?-1:"number"==typeof a&&"number"==typeof l?"asc"===e.order?a-l:l-a:"asc"===e.order?String(a).localeCompare(String(l)):String(l).localeCompare(String(a)),0!==u)return u}return 0});if(s){const t=s.childrenKey||"children";return n.map(n=>n[t]?.length?{...n,[t]:z(n[t])}:n)}return n}function F(){const{pageData:e,total:s}=L();n.innerHTML="",(t.showFilter||t.showToolbar)&&n.appendChild(function(){const n=document.createElement("div");n.className="kupola-table-toolbar";const e=document.createElement("div");if("checkbox"===a&&v.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`Selected ${v.size} items`,e.appendChild(t)}const o=document.createElement("div");if(o.className="kupola-table-toolbar-right",t.showFilter){const n=document.createElement("input");n.type="text",n.className="kupola-table-filter-input",n.placeholder="Filter...",n.value=h,n.addEventListener("input",()=>{clearTimeout(D),D=setTimeout(()=>{h=n.value,g=1,F(),t.onFilter&&t.onFilter(h)},300)}),o.appendChild(n)}return n.appendChild(e),n.appendChild(o),n}());const d=document.createElement("div");d.className="kupola-table-container";const x=document.createElement("table");x.className=function(){const n=["kupola-table"];t.striped&&n.push("kupola-table-striped");!1!==t.hoverable&&n.push("kupola-table-hover");t.bordered&&n.push("kupola-table-bordered");t.compact&&n.push("kupola-table-compact");return n.join(" ")}(),x.appendChild(function(){const n=document.createElement("thead"),e=document.createElement("tr");a&&function(t){const n=document.createElement("th");if(n.className="kupola-table-col-selection","checkbox"===a){const t=document.createElement("input");t.type="checkbox";const{pageData:e}=L(),o=e.map(t=>t[c]);t.checked=o.length>0&&o.every(t=>v.has(t)),t.addEventListener("change",()=>t.checked?_():V()),n.appendChild(t)}t.appendChild(n)}(e);if(l){const t=document.createElement("th");t.className="kupola-table-col-expand",e.appendChild(t)}return o.forEach(n=>{const c=document.createElement("th");if(c.textContent=n.title||n.key,n.width&&(c.style.width="number"==typeof n.width?n.width+"px":n.width),n.minWidth&&(c.style.minWidth="number"==typeof n.minWidth?n.minWidth+"px":n.minWidth),n.align&&(c.style.textAlign=n.align),n.fixed&&c.setAttribute("data-fixed",n.fixed),n.sortable){c.classList.add("kupola-table-sortable");const e=k.find(t=>t.key===n.key);e&&c.classList.add(`kupola-table-sort-${e.order}`),c.addEventListener("click",()=>function(n){const e=k.find(t=>t.key===n);e?"asc"===e.order?e.order="desc":k=f?k.filter(t=>t.key!==n):[]:f?k.push({key:n,order:"asc"}):k=[{key:n,order:"asc"}];g=1,F(),t.onSort&&t.onSort(k)}(n.key));const o=document.createElement("span");o.className="kupola-table-sort-icon",o.textContent=e?f?` ${k.indexOf(e)+1}${"asc"===e.order?"▲":"▼"}`:"asc"===e.order?" ▲":" ▼":" ⇅",c.appendChild(o)}if(r&&n.key!==o[o.length-1]?.key){const t=document.createElement("span");t.className="kupola-table-resize-handle",t.setAttribute("data-col-key",n.key),c.appendChild(t)}e.appendChild(c)}),n.appendChild(e),n}()),x.appendChild(function(n){const e=document.createElement("tbody");if(m){const n=document.createElement("tr"),o=document.createElement("td");o.colSpan=K(),o.className="kupola-table-loading",o.textContent=t.loadingText||"Loading...",n.appendChild(o),e.appendChild(n)}else if(0===n.length){const n=document.createElement("tr"),o=document.createElement("td");o.colSpan=K(),o.className="kupola-table-empty",o.textContent=t.emptyText||"No data",n.appendChild(o),e.appendChild(n)}else{const r=p?p(n):[],s=new Map;r.forEach(t=>s.set(`${t.row}-${t.col}`,t));const d=new Set;n.forEach((n,r)=>{const p=n[c]??r,f=v.has(p),m=S.has(p),k=document.createElement("tr");if(k.setAttribute("data-row-key",p),f&&k.classList.add("kupola-table-row-selected"),i&&(k.draggable=!0,k.classList.add("kupola-table-draggable")),t.onRowClick&&k.addEventListener("click",()=>t.onRowClick(n,p)),a&&function(t,n,e){const o=document.createElement("td");o.className="kupola-table-col-selection";const c=document.createElement("input");c.type="radio"===a?"radio":"checkbox",c.checked=e,c.addEventListener("change",()=>{c.checked?C(n):N(n)}),o.appendChild(c),t.appendChild(o)}(k,p,f),l&&function(t,n,e){const o=document.createElement("td");o.className="kupola-table-col-expand";const c=document.createElement("button");c.type="button",c.className="kupola-table-expand-btn",c.textContent=e?"▼":"▶",c.addEventListener("click",()=>q(n)),o.appendChild(c),t.appendChild(o)}(k,p,m),o.forEach((e,o)=>{if(d.has(`${r}-${o}`))return;const a=document.createElement("td");e.align&&(a.style.textAlign=e.align),e.fixed&&a.setAttribute("data-fixed",e.fixed);const l=s.get(`${r}-${o}`);if(l){l.rowSpan>1&&(a.rowSpan=l.rowSpan),l.colSpan>1&&(a.colSpan=l.colSpan);for(let t=0;t<(l.rowSpan||1);t++)for(let n=0;n<(l.colSpan||1);n++)0===t&&0===n||d.add(`${r+t}-${o+n}`)}const i=n[e.key];if(w&&w.rowKey===p&&w.colKey===e.key)a.appendChild(function(n,e,o,a){const l=document.createElement("div");l.className="kupola-table-edit-cell";const u=document.createElement("input");u.type="text",u.className="kupola-table-edit-input",u.value=$[o.key]??e[o.key]??"",u.addEventListener("input",()=>{$[o.key]=u.value});const r=document.createElement("div");r.className="kupola-table-edit-actions";const i=document.createElement("button");i.type="button",i.className="kupola-table-edit-save",i.textContent="✓",i.addEventListener("click",()=>function(n,e){const o=b.find(t=>t[c]===n);o&&void 0!==$[e]&&(o[e]=$[e]);w=null,$={},t.onEditSave&&t.onEditSave(o,e);F()}(a,o.key));const s=document.createElement("button");return s.type="button",s.className="kupola-table-edit-cancel",s.textContent="✗",s.addEventListener("click",H),r.appendChild(i),r.appendChild(s),l.appendChild(u),l.appendChild(r),l}(0,n,e,p));else if(e.editable&&u)a.classList.add("kupola-table-editable-cell"),a.addEventListener("dblclick",()=>function(t,n,e){w={rowKey:t,colKey:n},$={[n]:null!=e?String(e):""},F()}(p,e.key,i)),function(t,n,e,o){if(n.render){const c=n.render(e,o);"string"==typeof c?t.innerHTML=c:c instanceof HTMLElement&&t.appendChild(c)}else t.textContent=null!=e?String(e):""}(a,e,i,n);else if(e.render){const t=e.render(i,n);"string"==typeof t?a.innerHTML=t:t instanceof HTMLElement&&a.appendChild(t)}else a.textContent=null!=i?String(i):"";k.appendChild(a)}),e.appendChild(k),l&&m){const t=document.createElement("tr");t.className="kupola-table-expand-row";const o=document.createElement("td");o.colSpan=K();const c=l(n);"string"==typeof c?o.innerHTML=c:c instanceof HTMLElement&&o.appendChild(c),t.appendChild(o),e.appendChild(t)}})}return e}(e)),d.appendChild(x),n.appendChild(d),!1!==t.showPagination&&s>y&&n.appendChild(function(n){const e=Math.ceil(n/y)||1,o=document.createElement("div");o.className="kupola-table-pagination";const c=document.createElement("span");c.className="kupola-table-page-info";const a=(g-1)*y+1,l=Math.min(g*y,n);c.textContent=`${a}-${l} / ${n}`;const u=document.createElement("div");u.className="kupola-table-pages";const r=document.createElement("button");r.type="button",r.className="kupola-table-page-btn",r.textContent="‹",r.disabled=g<=1,r.addEventListener("click",()=>{g>1&&(g--,F(),t.onPageChange&&t.onPageChange(g))}),u.appendChild(r);(function(t,n){if(n<=7)return Array.from({length:n},(t,n)=>n+1);const e=[];if(t<=4){for(let t=1;t<=5;t++)e.push(t);e.push("...",n)}else if(t>=n-3){e.push(1,"...");for(let t=n-4;t<=n;t++)e.push(t)}else{e.push(1,"...");for(let n=t-1;n<=t+1;n++)e.push(n);e.push("...",n)}return e})(g,e).forEach(n=>{if("..."===n){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",u.appendChild(t)}else{const e=document.createElement("button");e.type="button",e.className="kupola-table-page-btn"+(n===g?" active":""),e.textContent=n,e.addEventListener("click",()=>{g=n,F(),t.onPageChange&&t.onPageChange(g)}),u.appendChild(e)}});const i=document.createElement("button");if(i.type="button",i.className="kupola-table-page-btn",i.textContent="›",i.disabled=g>=e,i.addEventListener("click",()=>{g<e&&(g++,F(),t.onPageChange&&t.onPageChange(g))}),u.appendChild(i),t.pageSizeOptions?.length>1){const n=document.createElement("select");n.className="kupola-table-page-size",t.pageSizeOptions.forEach(t=>{const e=document.createElement("option");e.value=t,e.textContent=`${t} / page`,t===y&&(e.selected=!0),n.appendChild(e)}),n.addEventListener("change",()=>{y=Number(n.value),g=1,F()}),o.appendChild(c),o.appendChild(u),o.appendChild(n)}else o.appendChild(c),o.appendChild(u);return o}(s)),r&&n.querySelectorAll(".kupola-table-resize-handle").forEach(n=>{let e,c,a;const l=l=>{const u=n.parentElement;e=l.pageX,c=u.offsetWidth;const r=n.getAttribute("data-col-key");a=o.find(t=>t.key===r);const i=t=>{const n=t.pageX-e,o=Math.max(50,c+n);u.style.width=o+"px"},s=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s),a&&t.onColumnResize&&t.onColumnResize(a.key,u.offsetWidth)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)};n.addEventListener("mousedown",l),A.push(()=>n.removeEventListener("mousedown",l))}),i&&function(){const e=n.querySelectorAll("tbody tr[data-row-key]");e.forEach(n=>{const o=t=>{n.classList.add("kupola-table-dragging"),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",n.getAttribute("data-row-key"))},a=t=>{t.preventDefault(),n.classList.add("kupola-table-drag-over")},l=()=>n.classList.remove("kupola-table-drag-over"),u=e=>{e.preventDefault(),n.classList.remove("kupola-table-drag-over");const o=e.dataTransfer.getData("text/plain"),a=n.getAttribute("data-row-key");o!==a&&function(n,e){const o=b.findIndex(t=>String(t[c])===String(n)),a=b.findIndex(t=>String(t[c])===String(e));if(-1===o||-1===a)return;const[l]=b.splice(o,1);b.splice(a,0,l),F(),t.onRowDragEnd&&t.onRowDragEnd(n,e)}(o,a)},r=()=>{n.classList.remove("kupola-table-dragging"),e.forEach(t=>t.classList.remove("kupola-table-drag-over"))};n.addEventListener("dragstart",o),n.addEventListener("dragover",a),n.addEventListener("dragleave",l),n.addEventListener("drop",u),n.addEventListener("dragend",r),A.push(()=>{n.removeEventListener("dragstart",o),n.removeEventListener("dragover",a),n.removeEventListener("dragleave",l),n.removeEventListener("drop",u),n.removeEventListener("dragend",r)})})}()}function H(){w=null,$={},t.onEditCancel&&t.onEditCancel(),F()}function K(){return o.length+(a?1:0)+(l?1:0)}function P(){return[...v]}function R(){return b.filter(t=>v.has(t[c]))}function C(n){"radio"===a?(v.clear(),v.add(n)):v.add(n),F(),t.onSelect&&t.onSelect(P(),R())}function N(n){v.delete(n),F(),t.onSelect&&t.onSelect(P(),R())}function _(){const{pageData:n}=L();n.forEach(t=>v.add(t[c])),F(),t.onSelect&&t.onSelect(P(),R())}function V(){v.clear(),F(),t.onSelect&&t.onSelect(P(),R())}function q(n){S.has(n)?S.delete(n):S.add(n),F(),t.onExpand&&t.onExpand(n,S.has(n))}return s?.defaultExpandAll&&M(b),n.classList.add("kupola-table-wrapper"),d&&n.classList.add("kupola-table-virtual-wrapper"),F(),{element:n,destroy:function(){e.forEach(({el:t,event:n,handler:e})=>t.removeEventListener(n,e)),e.length=0,T.forEach(t=>t()),T.length=0,A.forEach(t=>t()),A.length=0,clearTimeout(D),n.remove()},setData:function(t){t&&"object"==typeof t&&"value"in t?(b=Array.isArray(t.value)?[...t.value]:[],t.subscribe&&T.push(t.subscribe(t=>{b=Array.isArray(t)?[...t]:[],F()}))):b=Array.isArray(t)?[...t]:[],s&&s.defaultExpandAll&&(x.clear(),M(b)),F()},setLoading:function(t){t&&"object"==typeof t&&"value"in t?(m=!!t.value,t.subscribe&&T.push(t.subscribe(t=>{m=!!t,F()}))):m=!!t,F()},getData:function(){return[...b]},getProcessedData:()=>L().pageData,getSelectedRows:R,getSelectedKeys:P,selectRow:C,deselectRow:N,selectAll:_,deselectAll:V,toggleExpand:q,expandAll:function(){const{pageData:t}=L();t.forEach(t=>S.add(t[c])),F()},collapseAll:function(){S.clear(),F()},setSort:function(t,n){if(f){const e=k.find(n=>n.key===t);e?e.order=n||"asc":k.push({key:t,order:n||"asc"})}else k=[{key:t,order:n||"asc"}];g=1,F()},clearSort:function(){k=[],F()},setPage:function(n){g=Math.max(1,n),F(),t.onPageChange&&t.onPageChange(g)},setPageSize:function(t){y=t,g=1,F()},setFilterText:function(t){h=t,g=1,F()},getFilterText:function(){return h},exportCSV:function(){const t=o.map(t=>t.title||t.key).join(","),{pageData:n}=L();return[t,...n.map(t=>o.map(n=>{const e=t[n.key],o=null!=e?String(e):"";return o.includes(",")?`"${o}"`:o}).join(","))].join("\n")},refresh:function(){F()}}}export{t as Table};
1
+ const t={"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 e(e={}){if(!e||"object"!=typeof e)throw new TypeError("Table options must be an object.");const n=document.createElement("div"),o=[],c=e.columns||[],a=e.rowKey||"id",l=e.selection||null,u=e.expandable||null,r=e.editable||!1,i=e.resizable||!1,s=e.draggable||!1,d=e.tree||null,p=e.virtualScroll||null,f=e.mergeCells||null,b=e.multiSort||!1;let m=Array.isArray(e.data)?[...e.data]:[],g=!1,k=[],h=1,y=e.pageSize||10,S="",v=new Set,w=new Set,x=new Set,$=null,T={},A=[],D=[],M=null;function j(t,e){const n=e||d?.childrenKey||"children";t.forEach(t=>{const e=t[a];t[n]?.length&&(x.add(e),j(t[n],n))})}function z(t,e,n){const o=n||d?.childrenKey||"children",c=[];for(const n of t){const t=n[a];c.push({...n,t:e,o:!!n[o]?.length}),n[o]?.length&&x.has(t)&&c.push(...z(n[o],e+1,o))}return c}function C(){let t=[...m];if(S){const e=S.toLowerCase();t=d?E(t,e):t.filter(t=>c.some(n=>{const o=t[n.key];return n.filterFn?n.filterFn(o,S):null!=o&&String(o).toLowerCase().includes(e)}))}k.length>0&&(t=F(t));const n=d?z(t,0):t,o=n.length;let a=n;if(!1!==e.showPagination&&y>0){const t=(h-1)*y;a=n.slice(t,t+y)}return{pageData:a,total:o}}function E(t,e,n){const o=n||d?.childrenKey||"children";return t.reduce((t,n)=>{const l=n[o]?E(n[o],e,o):[];return(c.some(t=>{const o=n[t.key];return null!=o&&String(o).toLowerCase().includes(e)})||l.length>0)&&(t.push({...n,[o]:l}),l.length>0&&x.add(n[a])),t},[])}function F(t){const e=[...t].sort((t,e)=>{for(const n of k){const o=c.find(t=>t.key===n.key);let a=t[n.key],l=e[n.key],u=0;if(u=o?.sorter?o.sorter(a,l,n.order):null==a?1:null==l?-1:"number"==typeof a&&"number"==typeof l?"asc"===n.order?a-l:l-a:"asc"===n.order?String(a).localeCompare(String(l)):String(l).localeCompare(String(a)),0!==u)return u}return 0});if(d){const t=d.childrenKey||"children";return e.map(e=>e[t]?.length?{...e,[t]:F(e[t])}:e)}return e}function L(){const{pageData:o,total:d}=C();n.innerHTML="",(e.showFilter||e.showToolbar)&&n.appendChild(function(){const t=document.createElement("div");t.className="kupola-table-toolbar";const n=document.createElement("div");if("checkbox"===l&&v.size>0){const t=document.createElement("span");t.className="kupola-table-selection-info",t.textContent=`Selected ${v.size} items`,n.appendChild(t)}const o=document.createElement("div");if(o.className="kupola-table-toolbar-right",e.showFilter){const t=document.createElement("input");t.type="text",t.className="kupola-table-filter-input",t.placeholder="Filter...",t.value=S,t.addEventListener("input",()=>{clearTimeout(M),M=setTimeout(()=>{S=t.value,h=1,L(),e.onFilter&&e.onFilter(S)},300)}),o.appendChild(t)}return t.appendChild(n),t.appendChild(o),t}());const p=document.createElement("div");p.className="kupola-table-container";const x=document.createElement("table");x.className=function(){const t=["kupola-table"];e.striped&&t.push("kupola-table-striped");!1!==e.hoverable&&t.push("kupola-table-hover");e.bordered&&t.push("kupola-table-bordered");e.compact&&t.push("kupola-table-compact");return t.join(" ")}(),x.appendChild(function(){const t=document.createElement("thead"),n=document.createElement("tr");l&&function(t){const e=document.createElement("th");if(e.className="kupola-table-col-selection","checkbox"===l){const t=document.createElement("input");t.type="checkbox";const{pageData:n}=C(),o=n.map(t=>t[a]);t.checked=o.length>0&&o.every(t=>v.has(t)),t.addEventListener("change",()=>t.checked?R():_()),e.appendChild(t)}t.appendChild(e)}(n);if(u){const t=document.createElement("th");t.className="kupola-table-col-expand",n.appendChild(t)}return c.forEach(t=>{const o=document.createElement("th");if(o.textContent=t.title||t.key,t.width&&(o.style.width="number"==typeof t.width?t.width+"px":t.width),t.minWidth&&(o.style.minWidth="number"==typeof t.minWidth?t.minWidth+"px":t.minWidth),t.align&&(o.style.textAlign=t.align),t.fixed&&o.setAttribute("data-fixed",t.fixed),t.sortable){o.classList.add("kupola-table-sortable");const n=k.find(e=>e.key===t.key);n&&o.classList.add(`kupola-table-sort-${n.order}`),o.addEventListener("click",()=>function(t){const n=k.find(e=>e.key===t);n?"asc"===n.order?n.order="desc":k=b?k.filter(e=>e.key!==t):[]:b?k.push({key:t,order:"asc"}):k=[{key:t,order:"asc"}];h=1,L(),e.onSort&&e.onSort(k)}(t.key));const c=document.createElement("span");c.className="kupola-table-sort-icon",c.textContent=n?b?` ${k.indexOf(n)+1}${"asc"===n.order?"▲":"▼"}`:"asc"===n.order?" ▲":" ▼":" ⇅",o.appendChild(c)}if(i&&t.key!==c[c.length-1]?.key){const e=document.createElement("span");e.className="kupola-table-resize-handle",e.setAttribute("data-col-key",t.key),o.appendChild(e)}n.appendChild(o)}),t.appendChild(n),t}()),x.appendChild(function(n){const o=document.createElement("tbody");if(g){const t=document.createElement("tr"),n=document.createElement("td");n.colSpan=K(),n.className="kupola-table-loading",n.textContent=e.loadingText||"Loading...",t.appendChild(n),o.appendChild(t)}else if(0===n.length){const n=document.createElement("tr"),c=document.createElement("td");c.colSpan=K(),c.className="kupola-table-empty",c.textContent=e.emptyText||function(e,n={}){let o=(t["en-US"]||t["en-US"])[e]||e;for(const[t,e]of Object.entries(n))o=o.replace(`{${t}}`,e);return o}("table.empty"),n.appendChild(c),o.appendChild(n)}else{const t=f?f(n):[],i=new Map;t.forEach(t=>i.set(`${t.row}-${t.col}`,t));const d=new Set;n.forEach((t,n)=>{const p=t[a]??n,f=v.has(p),b=w.has(p),g=document.createElement("tr");if(g.setAttribute("data-row-key",p),f&&g.classList.add("kupola-table-row-selected"),s&&(g.draggable=!0,g.classList.add("kupola-table-draggable")),e.onRowClick&&g.addEventListener("click",()=>e.onRowClick(t,p)),l&&function(t,e,n){const o=document.createElement("td");o.className="kupola-table-col-selection";const c=document.createElement("input");c.type="radio"===l?"radio":"checkbox",c.checked=n,c.addEventListener("change",()=>{c.checked?J(e):O(e)}),o.appendChild(c),t.appendChild(o)}(g,p,f),u&&function(t,e,n){const o=document.createElement("td");o.className="kupola-table-col-expand";const c=document.createElement("button");c.type="button",c.className="kupola-table-expand-btn",c.textContent=n?"▼":"▶",c.addEventListener("click",()=>B(e)),o.appendChild(c),t.appendChild(o)}(g,p,b),c.forEach((o,c)=>{if(d.has(`${n}-${c}`))return;const l=document.createElement("td");o.align&&(l.style.textAlign=o.align),o.fixed&&l.setAttribute("data-fixed",o.fixed);const u=i.get(`${n}-${c}`);if(u){u.rowSpan>1&&(l.rowSpan=u.rowSpan),u.colSpan>1&&(l.colSpan=u.colSpan);for(let t=0;t<(u.rowSpan||1);t++)for(let e=0;e<(u.colSpan||1);e++)0===t&&0===e||d.add(`${n+t}-${c+e}`)}const s=t[o.key];if($&&$.rowKey===p&&$.colKey===o.key)l.appendChild(function(t,n,o,c){const l=document.createElement("div");l.className="kupola-table-edit-cell";const u=document.createElement("input");u.type="text",u.className="kupola-table-edit-input",u.value=T[o.key]??n[o.key]??"",u.addEventListener("input",()=>{T[o.key]=u.value});const r=document.createElement("div");r.className="kupola-table-edit-actions";const i=document.createElement("button");i.type="button",i.className="kupola-table-edit-save",i.textContent="✓",i.addEventListener("click",()=>function(t,n){const o=m.find(e=>e[a]===t);o&&void 0!==T[n]&&(o[n]=T[n]);$=null,T={},e.onEditSave&&e.onEditSave(o,n);L()}(c,o.key));const s=document.createElement("button");return s.type="button",s.className="kupola-table-edit-cancel",s.textContent="✗",s.addEventListener("click",N),r.appendChild(i),r.appendChild(s),l.appendChild(u),l.appendChild(r),l}(0,t,o,p));else if(o.editable&&r)l.classList.add("kupola-table-editable-cell"),l.addEventListener("dblclick",()=>function(t,e,n){$={rowKey:t,colKey:e},T={[e]:null!=n?String(n):""},L()}(p,o.key,s)),function(t,e,n,o){if(e.render){const c=e.render(n,o);"string"==typeof c?t.innerHTML=c:c instanceof HTMLElement&&t.appendChild(c)}else t.textContent=null!=n?String(n):""}(l,o,s,t);else if(o.render){const e=o.render(s,t);"string"==typeof e?l.innerHTML=e:e instanceof HTMLElement&&l.appendChild(e)}else l.textContent=null!=s?String(s):"";g.appendChild(l)}),o.appendChild(g),u&&b){const e=document.createElement("tr");e.className="kupola-table-expand-row";const n=document.createElement("td");n.colSpan=K();const c=u(t);"string"==typeof c?n.innerHTML=c:c instanceof HTMLElement&&n.appendChild(c),e.appendChild(n),o.appendChild(e)}})}return o}(o)),p.appendChild(x),n.appendChild(p),!1!==e.showPagination&&d>y&&n.appendChild(function(t){const n=Math.ceil(t/y)||1,o=document.createElement("div");o.className="kupola-table-pagination";const c=document.createElement("span");c.className="kupola-table-page-info";const a=(h-1)*y+1,l=Math.min(h*y,t);c.textContent=`${a}-${l} / ${t}`;const u=document.createElement("div");u.className="kupola-table-pages";const r=document.createElement("button");r.type="button",r.className="kupola-table-page-btn",r.textContent="‹",r.disabled=h<=1,r.addEventListener("click",()=>{h>1&&(h--,L(),e.onPageChange&&e.onPageChange(h))}),u.appendChild(r);(function(t,e){if(e<=7)return Array.from({length:e},(t,e)=>e+1);const n=[];if(t<=4){for(let t=1;t<=5;t++)n.push(t);n.push("...",e)}else if(t>=e-3){n.push(1,"...");for(let t=e-4;t<=e;t++)n.push(t)}else{n.push(1,"...");for(let e=t-1;e<=t+1;e++)n.push(e);n.push("...",e)}return n})(h,n).forEach(t=>{if("..."===t){const t=document.createElement("span");t.className="kupola-table-page-ellipsis",t.textContent="...",u.appendChild(t)}else{const n=document.createElement("button");n.type="button",n.className="kupola-table-page-btn"+(t===h?" active":""),n.textContent=t,n.addEventListener("click",()=>{h=t,L(),e.onPageChange&&e.onPageChange(h)}),u.appendChild(n)}});const i=document.createElement("button");if(i.type="button",i.className="kupola-table-page-btn",i.textContent="›",i.disabled=h>=n,i.addEventListener("click",()=>{h<n&&(h++,L(),e.onPageChange&&e.onPageChange(h))}),u.appendChild(i),e.pageSizeOptions?.length>1){const t=document.createElement("select");t.className="kupola-table-page-size",e.pageSizeOptions.forEach(e=>{const n=document.createElement("option");n.value=e,n.textContent=`${e} / page`,e===y&&(n.selected=!0),t.appendChild(n)}),t.addEventListener("change",()=>{y=Number(t.value),h=1,L()}),o.appendChild(c),o.appendChild(u),o.appendChild(t)}else o.appendChild(c),o.appendChild(u);return o}(d)),i&&n.querySelectorAll(".kupola-table-resize-handle").forEach(t=>{let n,o,a;const l=l=>{const u=t.parentElement;n=l.pageX,o=u.offsetWidth;const r=t.getAttribute("data-col-key");a=c.find(t=>t.key===r);const i=t=>{const e=t.pageX-n,c=Math.max(50,o+e);u.style.width=c+"px"},s=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s),a&&e.onColumnResize&&e.onColumnResize(a.key,u.offsetWidth)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)};t.addEventListener("mousedown",l),D.push(()=>t.removeEventListener("mousedown",l))}),s&&function(){const t=n.querySelectorAll("tbody tr[data-row-key]");t.forEach(n=>{const o=t=>{n.classList.add("kupola-table-dragging"),t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",n.getAttribute("data-row-key"))},c=t=>{t.preventDefault(),n.classList.add("kupola-table-drag-over")},l=()=>n.classList.remove("kupola-table-drag-over"),u=t=>{t.preventDefault(),n.classList.remove("kupola-table-drag-over");const o=t.dataTransfer.getData("text/plain"),c=n.getAttribute("data-row-key");o!==c&&function(t,n){const o=m.findIndex(e=>String(e[a])===String(t)),c=m.findIndex(t=>String(t[a])===String(n));if(-1===o||-1===c)return;const[l]=m.splice(o,1);m.splice(c,0,l),L(),e.onRowDragEnd&&e.onRowDragEnd(t,n)}(o,c)},r=()=>{n.classList.remove("kupola-table-dragging"),t.forEach(t=>t.classList.remove("kupola-table-drag-over"))};n.addEventListener("dragstart",o),n.addEventListener("dragover",c),n.addEventListener("dragleave",l),n.addEventListener("drop",u),n.addEventListener("dragend",r),D.push(()=>{n.removeEventListener("dragstart",o),n.removeEventListener("dragover",c),n.removeEventListener("dragleave",l),n.removeEventListener("drop",u),n.removeEventListener("dragend",r)})})}()}function N(){$=null,T={},e.onEditCancel&&e.onEditCancel(),L()}function K(){return c.length+(l?1:0)+(u?1:0)}function P(){return[...v]}function H(){return m.filter(t=>v.has(t[a]))}function J(t){"radio"===l?(v.clear(),v.add(t)):v.add(t),L(),e.onSelect&&e.onSelect(P(),H())}function O(t){v.delete(t),L(),e.onSelect&&e.onSelect(P(),H())}function R(){const{pageData:t}=C();t.forEach(t=>v.add(t[a])),L(),e.onSelect&&e.onSelect(P(),H())}function _(){v.clear(),L(),e.onSelect&&e.onSelect(P(),H())}function B(t){w.has(t)?w.delete(t):w.add(t),L(),e.onExpand&&e.onExpand(t,w.has(t))}return d?.defaultExpandAll&&j(m),n.classList.add("kupola-table-wrapper"),p&&n.classList.add("kupola-table-virtual-wrapper"),L(),{element:n,destroy:function(){o.forEach(({el:t,event:e,handler:n})=>t.removeEventListener(e,n)),o.length=0,A.forEach(t=>t()),A.length=0,D.forEach(t=>t()),D.length=0,clearTimeout(M),n.remove()},setData:function(t){t&&"object"==typeof t&&"value"in t?(m=Array.isArray(t.value)?[...t.value]:[],t.subscribe&&A.push(t.subscribe(t=>{m=Array.isArray(t)?[...t]:[],L()}))):m=Array.isArray(t)?[...t]:[],d&&d.defaultExpandAll&&(x.clear(),j(m)),L()},setLoading:function(t){t&&"object"==typeof t&&"value"in t?(g=!!t.value,t.subscribe&&A.push(t.subscribe(t=>{g=!!t,L()}))):g=!!t,L()},getData:function(){return[...m]},getProcessedData:()=>C().pageData,getSelectedRows:H,getSelectedKeys:P,selectRow:J,deselectRow:O,selectAll:R,deselectAll:_,toggleExpand:B,expandAll:function(){const{pageData:t}=C();t.forEach(t=>w.add(t[a])),L()},collapseAll:function(){w.clear(),L()},setSort:function(t,e){if(b){const n=k.find(e=>e.key===t);n?n.order=e||"asc":k.push({key:t,order:e||"asc"})}else k=[{key:t,order:e||"asc"}];h=1,L()},clearSort:function(){k=[],L()},setPage:function(t){h=Math.max(1,t),L(),e.onPageChange&&e.onPageChange(h)},setPageSize:function(t){y=t,h=1,L()},setFilterText:function(t){S=t,h=1,L()},getFilterText:function(){return S},exportCSV:function(){const t=c.map(t=>t.title||t.key).join(","),{pageData:e}=C();return[t,...e.map(t=>c.map(e=>{const n=t[e.key],o=null!=n?String(n):"";return o.includes(",")?`"${o}"`:o}).join(","))].join("\n")},refresh:function(){L()}}}export{e as Table};