@kupola/kupola 2.0.0-beta.10 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/css/index.css +0 -1
- package/dist/css/tokens.css +0 -9
- package/dist/kupola-core-datepicker.cjs.js +28 -0
- package/dist/kupola-core-datepicker.esm.js +9 -9
- package/dist/kupola-core-dialog.cjs.js +13 -0
- package/dist/kupola-core-dialog.esm.js +8 -8
- package/dist/kupola-core-drawer.cjs.js +15 -0
- package/dist/kupola-core-drawer.esm.js +5 -5
- package/dist/kupola-core-dropdown.cjs.js +11 -0
- package/dist/kupola-core-dropdown.esm.js +4 -4
- package/dist/kupola-core-i18n.cjs.js +1 -0
- package/dist/kupola-core-i18n.esm.js +1 -1
- package/dist/{kupola-core-modal.cjs → kupola-core-modal.cjs.js} +2 -2
- package/dist/kupola-core-modal.esm.js +2 -2
- package/dist/{kupola-core-numberinput.cjs → kupola-core-numberinput.cjs.js} +5 -6
- package/dist/kupola-core-numberinput.esm.js +5 -6
- package/dist/kupola-core-select.cjs.js +15 -0
- package/dist/kupola-core-select.esm.js +7 -8
- package/dist/kupola-core-table.cjs.js +1 -0
- package/dist/kupola-core-table.esm.js +1 -1
- package/dist/kupola-core-timepicker.cjs.js +22 -0
- package/dist/kupola-core-timepicker.esm.js +3 -3
- package/dist/kupola-core.cjs.js +1 -0
- package/dist/kupola-core.esm.js +1 -1
- package/package.json +54 -63
- package/packages/core/package.json +52 -52
- package/packages/core/src/components/datepicker.js +6 -11
- package/packages/core/src/components/dialog.js +7 -14
- package/packages/core/src/components/drawer.js +3 -5
- package/packages/core/src/components/dropdown.js +3 -15
- package/packages/core/src/components/modal.js +1 -20
- package/packages/core/src/components/numberinput.js +3 -12
- package/packages/core/src/components/select.js +5 -22
- package/packages/core/src/components/table.js +1 -3
- package/packages/core/src/components/timepicker.js +1 -2
- package/packages/core/src/effect.js +1 -6
- package/packages/core/src/i18n.js +0 -5
- package/packages/core/src/index.js +0 -12
- package/packages/core/src/signal.js +0 -3
- package/packages/css/index.css +0 -1
- package/packages/css/tokens.css +0 -9
- package/dist/css/components.min.css +0 -1
- package/dist/css/index.min.css +0 -1
- package/dist/css/responsive.css +0 -153
- package/dist/css/responsive.min.css +0 -1
- package/dist/css/tokens.min.css +0 -1
- package/dist/kupola-core-datepicker.cjs +0 -28
- package/dist/kupola-core-dialog.cjs +0 -13
- package/dist/kupola-core-drawer.cjs +0 -15
- package/dist/kupola-core-dropdown.cjs +0 -11
- package/dist/kupola-core-i18n.cjs +0 -1
- package/dist/kupola-core-select.cjs +0 -16
- package/dist/kupola-core-table.cjs +0 -1
- package/dist/kupola-core-timepicker.cjs +0 -22
- package/dist/kupola-core.cjs +0 -1
- package/packages/core/src/devtools.js +0 -303
- package/packages/core/src/errors.js +0 -80
- package/packages/core/src/lazy.js +0 -128
- package/packages/core/src/theme.js +0 -173
- package/packages/css/responsive.css +0 -153
- /package/dist/{kupola-core-alert.cjs → kupola-core-alert.cjs.js} +0 -0
- /package/dist/{kupola-core-avatar.cjs → kupola-core-avatar.cjs.js} +0 -0
- /package/dist/{kupola-core-badge.cjs → kupola-core-badge.cjs.js} +0 -0
- /package/dist/{kupola-core-breadcrumb.cjs → kupola-core-breadcrumb.cjs.js} +0 -0
- /package/dist/{kupola-core-calendar.cjs → kupola-core-calendar.cjs.js} +0 -0
- /package/dist/{kupola-core-carousel.cjs → kupola-core-carousel.cjs.js} +0 -0
- /package/dist/{kupola-core-checkbox.cjs → kupola-core-checkbox.cjs.js} +0 -0
- /package/dist/{kupola-core-collapse.cjs → kupola-core-collapse.cjs.js} +0 -0
- /package/dist/{kupola-core-colorpicker.cjs → kupola-core-colorpicker.cjs.js} +0 -0
- /package/dist/{kupola-core-countdown.cjs → kupola-core-countdown.cjs.js} +0 -0
- /package/dist/{kupola-core-directives.cjs → kupola-core-directives.cjs.js} +0 -0
- /package/dist/{kupola-core-divider.cjs → kupola-core-divider.cjs.js} +0 -0
- /package/dist/{kupola-core-dynamictags.cjs → kupola-core-dynamictags.cjs.js} +0 -0
- /package/dist/{kupola-core-empty.cjs → kupola-core-empty.cjs.js} +0 -0
- /package/dist/{kupola-core-fileupload.cjs → kupola-core-fileupload.cjs.js} +0 -0
- /package/dist/{kupola-core-form.cjs → kupola-core-form.cjs.js} +0 -0
- /package/dist/{kupola-core-heatmap.cjs → kupola-core-heatmap.cjs.js} +0 -0
- /package/dist/{kupola-core-icons.cjs → kupola-core-icons.cjs.js} +0 -0
- /package/dist/{kupola-core-imagepreview.cjs → kupola-core-imagepreview.cjs.js} +0 -0
- /package/dist/{kupola-core-input.cjs → kupola-core-input.cjs.js} +0 -0
- /package/dist/{kupola-core-kbd.cjs → kupola-core-kbd.cjs.js} +0 -0
- /package/dist/{kupola-core-menu.cjs → kupola-core-menu.cjs.js} +0 -0
- /package/dist/{kupola-core-message.cjs → kupola-core-message.cjs.js} +0 -0
- /package/dist/{kupola-core-notification.cjs → kupola-core-notification.cjs.js} +0 -0
- /package/dist/{kupola-core-pagination.cjs → kupola-core-pagination.cjs.js} +0 -0
- /package/dist/{kupola-core-progress.cjs → kupola-core-progress.cjs.js} +0 -0
- /package/dist/{kupola-core-radio.cjs → kupola-core-radio.cjs.js} +0 -0
- /package/dist/{kupola-core-server.cjs → kupola-core-server.cjs.js} +0 -0
- /package/dist/{kupola-core-skeleton.cjs → kupola-core-skeleton.cjs.js} +0 -0
- /package/dist/{kupola-core-slider.cjs → kupola-core-slider.cjs.js} +0 -0
- /package/dist/{kupola-core-spin.cjs → kupola-core-spin.cjs.js} +0 -0
- /package/dist/{kupola-core-statcard.cjs → kupola-core-statcard.cjs.js} +0 -0
- /package/dist/{kupola-core-switch.cjs → kupola-core-switch.cjs.js} +0 -0
- /package/dist/{kupola-core-tabs.cjs → kupola-core-tabs.cjs.js} +0 -0
- /package/dist/{kupola-core-tag.cjs → kupola-core-tag.cjs.js} +0 -0
- /package/dist/{kupola-core-textarea.cjs → kupola-core-textarea.cjs.js} +0 -0
- /package/dist/{kupola-core-timeline.cjs → kupola-core-timeline.cjs.js} +0 -0
- /package/dist/{kupola-core-tooltip.cjs → kupola-core-tooltip.cjs.js} +0 -0
- /package/dist/{kupola-core-tree.cjs → kupola-core-tree.cjs.js} +0 -0
- /package/dist/{kupola-core-validation.cjs → kupola-core-validation.cjs.js} +0 -0
- /package/dist/{kupola-core-virtuallist.cjs → kupola-core-virtuallist.cjs.js} +0 -0
package/README.md
CHANGED
package/dist/css/index.css
CHANGED
package/dist/css/tokens.css
CHANGED
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
:root {
|
|
11
|
-
|
|
12
|
-
/* ── Anti-FOUC: hide elements until JS removes [k-cloak] ── */
|
|
13
|
-
[k-cloak] { display: none !important; }
|
|
14
11
|
/* ── Primitives: Radius ─────────────────────────────────── */
|
|
15
12
|
--radius-2: 2px;
|
|
16
13
|
--radius-4: 4px;
|
|
@@ -78,12 +75,6 @@
|
|
|
78
75
|
--transition-fast: 0.12s ease;
|
|
79
76
|
--transition-normal: 0.2s ease;
|
|
80
77
|
--transition-slow: 0.3s ease;
|
|
81
|
-
|
|
82
|
-
/* ── Breakpoints ────────────────────────────────────────── */
|
|
83
|
-
--breakpoint-sm: 576px;
|
|
84
|
-
--breakpoint-md: 768px;
|
|
85
|
-
--breakpoint-lg: 1024px;
|
|
86
|
-
--breakpoint-xl: 1280px;
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
/* ═══════════════════════════════════════════════════════════
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return new t(n,e)}function e(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function s(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const e=Object.getPrototypeOf(t);if(e){const t=Object.getOwnPropertyDescriptor(e,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):c(i)?e.push(o(i.value)):"function"!=typeof i&&e.push(o(i??""))}return e.join("")}function l(t,n){const e=t.indexOf(n);if(-1===e)return{type:"text"};const s=t.substring(0,e).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,e).includes(">"))return{type:"text"};const i=t.substring(s+1,e).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const o=i[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class a{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,n,e){this.element=t,this.attrName=n,this.rawValue=e,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class f{constructor(t,n,e){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=e,this.k=null}mount(){"function"==typeof this.handler&&(this.k=t=>this.handler(t),this.element.addEventListener(this.eventName,this.k))}destroy(){this.k&&(this.element.removeEventListener(this.eventName,this.k),this.k=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,e){const s=new h,i=function(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):"function"==typeof i||c(i)?e.push(r(s)):e.push(o(i??""))}return e.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);s.fragment=l,y(l,n.values,i,s);for(const t of s.parts)t.mount();return e.appendChild(l),s}function y(t,n,e,s){const i=[...t.childNodes];for(const o of i)3===o.nodeType?k(o,n,e,s,t):1===o.nodeType&&_(o,n,e,s)}function k(t,n,e,s,i){const o=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),d=o.indexOf(u);if(-1===d)continue;if("text"!==l(e,u).type)continue;const f=o.substring(0,d),h=o.substring(d+u.length);f&&i.insertBefore(document.createTextNode(f),t);const p=new a(i,n[c]);s.parts.push(p);let y=t;return h&&(y=document.createTextNode(h),i.insertBefore(y,t)),i.removeChild(t),p.p=y!==t?y:null,void(h&&k(y,n,e,s,i))}}function _(t,n,e,s){const i=[...t.attributes];for(const o of i)for(let i=0;i<n.length;i++){const c=r(i);if(!o.value.includes(c))continue;const u=l(e,c);if("event"===u.type&&u.attrName===o.name){t.removeAttribute(o.name);const e=new f(t,o.name,n[i]);s.parts.push(e)}else if("attr"===u.type&&u.attrName===o.name){const e=o.value.replace(c,"");e?t.setAttribute(o.name,e):t.removeAttribute(o.name);const r=new d(t,o.name,n[i]);s.parts.push(r)}}y(t,n,e,s)}const w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.Datepicker=function(t={}){const{placeholder:e="Select date",format:s="YYYY-MM-DD",value:i="",weekStart:o=1,minDate:c=null,maxDate:r=null,onChange:u=null}=t;let l=!1,a=(new Date).getFullYear(),d=(new Date).getMonth(),f=null,h=null;i&&(f=_(i),f&&(a=f.getFullYear(),d=f.getMonth()));const y=c?_(c):null,k=r?_(r):null;function _(t){if(!t)return null;let n=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);return n?new Date(+n[1],+n[2]-1,+n[3]):(n=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),n?new Date(+n[3],+n[1]-1,+n[2]):(n=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/),n?new Date(+n[3],+n[2]-1,+n[1]):null))}function v(t){if(!t)return"";const n=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");switch(s){case"MM/DD/YYYY":return`${e}/${i}/${n}`;case"DD/MM/YYYY":return`${i}.${e}.${n}`;default:return`${n}-${e}-${i}`}}function g(t){return!!(y&&t<y)||!!(k&&t>k)}function $(t,n){return new Date(t,n+1,0).getDate()}function m(){if(l)return;l=!0;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="block")}function x(){if(!l)return;l=!1;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="none")}function D(){l?x():m()}function b(){const t=C?C.querySelector(".ds-datepicker__input"):null;t&&(t.value=f?v(f):"")}function S(){const t=C?C.querySelector(".ds-datepicker__calendar"):null;if(!t)return;const n=t.querySelector(".ds-datepicker__title");n&&(n.textContent=`${w[d]} ${a}`);const e=t.querySelector(".ds-datepicker__days");if(!e)return;e.innerHTML="";(function(){const t=$(a,d);let n=new Date(a,d,1).getDay();1===o&&(n=0===n?6:n-1);const e=[],s=0===d?11:d-1,i=0===d?a-1:a,c=$(i,s);for(let t=n-1;t>=0;t--)e.push({date:new Date(i,s,c-t),outside:!0});for(let n=1;n<=t;n++)e.push({date:new Date(a,d,n),outside:!1});const r=7-e.length%7;if(r<7){const t=11===d?0:d+1,n=11===d?a+1:a;for(let s=1;s<=r;s++)e.push({date:new Date(n,t,s),outside:!0})}return e})().forEach(({date:t,outside:n})=>{const s=document.createElement("button");s.textContent=t.getDate(),n&&s.classList.add("is-outside"),function(t){const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}(t)&&s.classList.add("is-today"),function(t){return!!f&&t.getFullYear()===f.getFullYear()&&t.getMonth()===f.getMonth()&&t.getDate()===f.getDate()}(t)&&s.classList.add("is-selected"),g(t)&&(s.disabled=!0,s.style.opacity="0.3",s.style.cursor="not-allowed"),s.addEventListener("click",n=>{n.stopPropagation(),function(t){g(t)||(f=t,a=t.getFullYear(),d=t.getMonth(),b(),S(),x(),u&&u(v(t),t))}(t)}),e.appendChild(s)})}const Y=t=>{l&&C&&!C.contains(t.target)&&x()};document.addEventListener("click",Y);const M=t=>{"Escape"===t.key&&l&&x()};document.addEventListener("keydown",M);const j=n`
|
|
2
|
+
<div class="ds-datepicker">
|
|
3
|
+
<div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),D()}}">
|
|
4
|
+
<input class="ds-datepicker__input" type="text" readonly placeholder="${e}" value="${f?v(f):""}" />
|
|
5
|
+
<button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),D()}}">
|
|
6
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
7
|
+
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
|
|
8
|
+
<line x1="16" y1="2" x2="16" y2="6"/>
|
|
9
|
+
<line x1="8" y1="2" x2="8" y2="6"/>
|
|
10
|
+
<line x1="3" y1="10" x2="21" y2="10"/>
|
|
11
|
+
</svg>
|
|
12
|
+
</button>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="ds-datepicker__calendar" style="display:none">
|
|
15
|
+
<div class="ds-datepicker__header">
|
|
16
|
+
<button class="ds-datepicker__nav" onclick="${function(){0===d?(d=11,a--):d--,S()}}" aria-label="Previous month">
|
|
17
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
|
|
18
|
+
</button>
|
|
19
|
+
<span class="ds-datepicker__title">${`${w[d]} ${a}`}</span>
|
|
20
|
+
<button class="ds-datepicker__nav" onclick="${function(){11===d?(d=0,a++):d++,S()}}" aria-label="Next month">
|
|
21
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
|
|
22
|
+
</button>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="ds-datepicker__weekdays">${(1===o?["Mo","Tu","We","Th","Fr","Sa","Su"]:["Su","Mo","Tu","We","Th","Fr","Sa"]).map(t=>n`<span>${t}</span>`)}</div>
|
|
25
|
+
<div class="ds-datepicker__days"></div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
`,A=document.createDocumentFragment();h=p(j,A);const C=A.querySelector(".ds-datepicker");return S(),{get element(){return A},open:m,close:x,toggle:D,getValue:function(){return f?v(f):""},setValue:function(t){f=_(t),f&&(a=f.getFullYear(),d=f.getMonth()),b(),S()},destroy(){document.removeEventListener("click",Y),document.removeEventListener("keydown",M),h&&h.destroy()}}};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
class t{constructor(t,
|
|
1
|
+
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...e){return new t(n,e)}function e(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function s(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function o(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const e=Object.getPrototypeOf(t);if(e){const t=Object.getOwnPropertyDescriptor(e,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):c(i)?e.push(o(i.value)):"function"!=typeof i&&e.push(o(i??""))}return e.join("")}function l(t,n){const e=t.indexOf(n);if(-1===e)return{type:"text"};const s=t.substring(0,e).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,e).includes(">"))return{type:"text"};const i=t.substring(s+1,e).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const o=i[1];return o.startsWith("on")&&o.length>2?{type:"event",attrName:o}:{type:"attr",attrName:o}}class a{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class d{constructor(t,n,e){this.element=t,this.attrName=n,this.rawValue=e,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=e(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class f{constructor(t,n,e){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=e,this.k=null}mount(){"function"==typeof this.handler&&(this.k=t=>this.handler(t),this.element.addEventListener(this.eventName,this.k))}destroy(){this.k&&(this.element.removeEventListener(this.eventName,this.k),this.k=null)}}class h{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,e){const s=new h,i=function(n){const e=[];for(let s=0;s<n.strings.length;s++)if(e.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?e.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?e.push(i.map(u).join("")):"function"==typeof i||c(i)?e.push(r(s)):e.push(o(i??""))}return e.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);s.fragment=l,y(l,n.values,i,s);for(const t of s.parts)t.mount();return e.appendChild(l),s}function y(t,n,e,s){const i=[...t.childNodes];for(const o of i)3===o.nodeType?k(o,n,e,s,t):1===o.nodeType&&_(o,n,e,s)}function k(t,n,e,s,i){const o=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),d=o.indexOf(u);if(-1===d)continue;if("text"!==l(e,u).type)continue;const f=o.substring(0,d),h=o.substring(d+u.length);f&&i.insertBefore(document.createTextNode(f),t);const p=new a(i,n[c]);s.parts.push(p);let y=t;return h&&(y=document.createTextNode(h),i.insertBefore(y,t)),i.removeChild(t),p.p=y!==t?y:null,void(h&&k(y,n,e,s,i))}}function _(t,n,e,s){const i=[...t.attributes];for(const o of i)for(let i=0;i<n.length;i++){const c=r(i);if(!o.value.includes(c))continue;const u=l(e,c);if("event"===u.type&&u.attrName===o.name){t.removeAttribute(o.name);const e=new f(t,o.name,n[i]);s.parts.push(e)}else if("attr"===u.type&&u.attrName===o.name){const e=o.value.replace(c,"");e?t.setAttribute(o.name,e):t.removeAttribute(o.name);const r=new d(t,o.name,n[i]);s.parts.push(r)}}y(t,n,e,s)}const w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function v(t={}){const{placeholder:e="Select date",format:s="YYYY-MM-DD",value:i="",weekStart:o=1,minDate:c=null,maxDate:r=null,onChange:u=null}=t;let l=!1,a=(new Date).getFullYear(),d=(new Date).getMonth(),f=null,h=null;i&&(f=_(i),f&&(a=f.getFullYear(),d=f.getMonth()));const y=c?_(c):null,k=r?_(r):null;function _(t){if(!t)return null;let n=t.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);return n?new Date(+n[1],+n[2]-1,+n[3]):(n=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/),n?new Date(+n[3],+n[1]-1,+n[2]):(n=t.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/),n?new Date(+n[3],+n[2]-1,+n[1]):null))}function v(t){if(!t)return"";const n=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");switch(s){case"MM/DD/YYYY":return`${e}/${i}/${n}`;case"DD/MM/YYYY":return`${i}.${e}.${n}`;default:return`${n}-${e}-${i}`}}function g(t){return!!(y&&t<y)||!!(k&&t>k)}function $(t,n){return new Date(t,n+1,0).getDate()}function m(){if(l)return;l=!0;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="block")}function x(){if(!l)return;l=!1;const t=C?C.querySelector(".ds-datepicker__calendar"):null;t&&(t.style.display="none")}function D(){l?x():m()}function b(){const t=C?C.querySelector(".ds-datepicker__input"):null;t&&(t.value=f?v(f):"")}function S(){const t=C?C.querySelector(".ds-datepicker__calendar"):null;if(!t)return;const n=t.querySelector(".ds-datepicker__title");n&&(n.textContent=`${w[d]} ${a}`);const e=t.querySelector(".ds-datepicker__days");if(!e)return;e.innerHTML="";(function(){const t=$(a,d);let n=new Date(a,d,1).getDay();1===o&&(n=0===n?6:n-1);const e=[],s=0===d?11:d-1,i=0===d?a-1:a,c=$(i,s);for(let t=n-1;t>=0;t--)e.push({date:new Date(i,s,c-t),outside:!0});for(let n=1;n<=t;n++)e.push({date:new Date(a,d,n),outside:!1});const r=7-e.length%7;if(r<7){const t=11===d?0:d+1,n=11===d?a+1:a;for(let s=1;s<=r;s++)e.push({date:new Date(n,t,s),outside:!0})}return e})().forEach(({date:t,outside:n})=>{const s=document.createElement("button");s.textContent=t.getDate(),n&&s.classList.add("is-outside"),function(t){const n=new Date;return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}(t)&&s.classList.add("is-today"),function(t){return!!f&&t.getFullYear()===f.getFullYear()&&t.getMonth()===f.getMonth()&&t.getDate()===f.getDate()}(t)&&s.classList.add("is-selected"),g(t)&&(s.disabled=!0,s.style.opacity="0.3",s.style.cursor="not-allowed"),s.addEventListener("click",n=>{n.stopPropagation(),function(t){g(t)||(f=t,a=t.getFullYear(),d=t.getMonth(),b(),S(),x(),u&&u(v(t),t))}(t)}),e.appendChild(s)})}const Y=t=>{l&&C&&!C.contains(t.target)&&x()};document.addEventListener("click",Y);const M=t=>{"Escape"===t.key&&l&&x()};document.addEventListener("keydown",M);const j=n`
|
|
2
2
|
<div class="ds-datepicker">
|
|
3
|
-
<div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),
|
|
4
|
-
<input class="ds-datepicker__input" type="text" readonly placeholder="${
|
|
5
|
-
<button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),
|
|
3
|
+
<div class="ds-datepicker__input-wrap" onclick="${t=>{t.stopPropagation(),D()}}">
|
|
4
|
+
<input class="ds-datepicker__input" type="text" readonly placeholder="${e}" value="${f?v(f):""}" />
|
|
5
|
+
<button class="ds-datepicker__icon" onclick="${t=>{t.stopPropagation(),D()}}">
|
|
6
6
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
7
7
|
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
|
|
8
8
|
<line x1="16" y1="2" x2="16" y2="6"/>
|
|
@@ -13,16 +13,16 @@ class t{constructor(t,e){this.strings=t,this.values=e}}function e(e,...n){return
|
|
|
13
13
|
</div>
|
|
14
14
|
<div class="ds-datepicker__calendar" style="display:none">
|
|
15
15
|
<div class="ds-datepicker__header">
|
|
16
|
-
<button class="ds-datepicker__nav" onclick="${function(){0===
|
|
16
|
+
<button class="ds-datepicker__nav" onclick="${function(){0===d?(d=11,a--):d--,S()}}" aria-label="Previous month">
|
|
17
17
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg>
|
|
18
18
|
</button>
|
|
19
|
-
<span class="ds-datepicker__title">${`${
|
|
20
|
-
<button class="ds-datepicker__nav" onclick="${function(){11===
|
|
19
|
+
<span class="ds-datepicker__title">${`${w[d]} ${a}`}</span>
|
|
20
|
+
<button class="ds-datepicker__nav" onclick="${function(){11===d?(d=0,a++):d++,S()}}" aria-label="Next month">
|
|
21
21
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
|
|
22
22
|
</button>
|
|
23
23
|
</div>
|
|
24
|
-
<div class="ds-datepicker__weekdays">${(1===
|
|
24
|
+
<div class="ds-datepicker__weekdays">${(1===o?["Mo","Tu","We","Th","Fr","Sa","Su"]:["Su","Mo","Tu","We","Th","Fr","Sa"]).map(t=>n`<span>${t}</span>`)}</div>
|
|
25
25
|
<div class="ds-datepicker__days"></div>
|
|
26
26
|
</div>
|
|
27
27
|
</div>
|
|
28
|
-
`,A=document.createDocumentFragment();
|
|
28
|
+
`,A=document.createDocumentFragment();h=p(j,A);const C=A.querySelector(".ds-datepicker");return S(),{get element(){return A},open:m,close:x,toggle:D,getValue:function(){return f?v(f):""},setValue:function(t){f=_(t),f&&(a=f.getFullYear(),d=f.getMonth()),b(),S()},destroy(){document.removeEventListener("click",Y),document.removeEventListener("keydown",M),h&&h.destroy()}}}export{v as Datepicker};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||i(n)},i(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function l(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function u(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new d,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=u,v(u,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(u),i}function v(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function g(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(s,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);i.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[o]);i.parts.push(s)}else if("attr"===l.type&&l.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);i.parts.push(r)}}v(t,n,s,i)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:s="",content:i="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{p(),t(!0)},u=()=>{p(),t(!1)},h=t=>{t.target===t.currentTarget&&u()},f=t=>{"Escape"===t.key&&u(),"Enter"===t.key&&l()},a=n`
|
|
2
|
+
<div class="ds-modal-mask">
|
|
3
|
+
<div class="ds-dialog">
|
|
4
|
+
<div class="ds-dialog__icon ds-dialog__icon--${o}">${x[o]||x.normal}</div>
|
|
5
|
+
<div class="ds-dialog__title">${s}</div>
|
|
6
|
+
<div class="ds-dialog__content">${i}</div>
|
|
7
|
+
<div class="ds-dialog__actions">
|
|
8
|
+
${r?n`<button class="ds-btn ds-btn--ghost" data-action="cancel">${c}</button>`:""}
|
|
9
|
+
<button class="ds-btn ds-btn--primary" data-action="confirm">${e}</button>
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
`,d=document.createDocumentFragment(),v=y(a,d);document.body.appendChild(d);const g=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;g&&g.classList.add("is-visible"),document.body.style.overflow="hidden";const m=g.querySelector('[data-action="confirm"]'),w=g.querySelector('[data-action="cancel"]');function p(){document.removeEventListener("keydown",f),document.body.style.overflow="",g&&g.classList.remove("is-visible"),setTimeout(()=>{v.destroy(),g&&g.parentNode&&g.parentNode.removeChild(g)},50)}m&&m.addEventListener("click",l),w&&w.addEventListener("click",u),g&&g.addEventListener("click",h),document.addEventListener("keydown",f)})}const p={confirm:w,alert:function(t={}){return w({...t,showCancel:!1}).then(()=>{})}};exports.Dialog=p;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...
|
|
1
|
+
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...i){return new t(n,i)}function i(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||s(n)},s(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function s(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const i=Object.getPrototypeOf(t);if(i){const t=Object.getOwnPropertyDescriptor(i,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function l(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):c(o)?i.push(e(o.value)):"function"!=typeof o&&i.push(e(o??""))}return i.join("")}function u(t,n){const i=t.indexOf(n);if(-1===i)return{type:"text"};const s=t.substring(0,i).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,i).includes(">"))return{type:"text"};const o=t.substring(s+1,i).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,i){this.element=t,this.attrName=n,this.rawValue=i,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,i){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=i,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,i){const s=new d,o=function(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):"function"==typeof o||c(o)?i.push(r(s)):i.push(e(o??""))}return i.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);s.fragment=u,v(u,n.values,o,s);for(const t of s.parts)t.mount();return i.appendChild(u),s}function v(t,n,i,s){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,i,s,t):1===e.nodeType&&m(e,n,i,s)}function g(t,n,i,s,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(i,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);s.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,i,s,o))}}function m(t,n,i,s){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(i,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const i=new a(t,e.name,n[o]);s.parts.push(i)}else if("attr"===l.type&&l.attrName===e.name){const i=e.value.replace(c,"");i?t.setAttribute(e.name,i):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);s.parts.push(r)}}v(t,n,i,s)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:i="",content:s="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{p(),t(!0)},u=()=>{p(),t(!1)},h=t=>{t.target===t.currentTarget&&u()},f=t=>{"Escape"===t.key&&u(),"Enter"===t.key&&l()},a=n`
|
|
2
2
|
<div class="ds-modal-mask">
|
|
3
|
-
<div class="ds-dialog"
|
|
4
|
-
<div class="ds-dialog__icon ds-dialog__icon--${
|
|
5
|
-
<div class="ds-dialog__title"
|
|
6
|
-
<div class="ds-dialog__content"
|
|
3
|
+
<div class="ds-dialog">
|
|
4
|
+
<div class="ds-dialog__icon ds-dialog__icon--${o}">${x[o]||x.normal}</div>
|
|
5
|
+
<div class="ds-dialog__title">${i}</div>
|
|
6
|
+
<div class="ds-dialog__content">${s}</div>
|
|
7
7
|
<div class="ds-dialog__actions">
|
|
8
|
-
${
|
|
9
|
-
<button class="ds-btn ds-btn--primary" data-action="confirm"
|
|
8
|
+
${r?n`<button class="ds-btn ds-btn--ghost" data-action="cancel">${c}</button>`:""}
|
|
9
|
+
<button class="ds-btn ds-btn--primary" data-action="confirm">${e}</button>
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
|
-
`,
|
|
13
|
+
`,d=document.createDocumentFragment(),v=y(a,d);document.body.appendChild(d);const g=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;g&&g.classList.add("is-visible"),document.body.style.overflow="hidden";const m=g.querySelector('[data-action="confirm"]'),w=g.querySelector('[data-action="cancel"]');function p(){document.removeEventListener("keydown",f),document.body.style.overflow="",g&&g.classList.remove("is-visible"),setTimeout(()=>{v.destroy(),g&&g.parentNode&&g.parentNode.removeChild(g)},50)}m&&m.addEventListener("click",l),w&&w.addEventListener("click",u),g&&g.addEventListener("click",h),document.addEventListener("keydown",f)})}const p={confirm:w,alert:function(t={}){return w({...t,showCancel:!1}).then(()=>{})}};export{p as Dialog};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function l(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new a,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=l,w(l,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(l),i}function w(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?p(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function p(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==l(s,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&o.insertBefore(document.createTextNode(d),t);const y=new f(o,n[c]);i.parts.push(y);let w=t;return a&&(w=document.createTextNode(a),o.insertBefore(w,t)),o.removeChild(t),y.p=w!==t?w:null,void(a&&p(w,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const u=l(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[o]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new h(t,e.name,n[o]);i.parts.push(r)}}w(t,n,s,i)}exports.Drawer=function(t={},s=null){const{title:i="",placement:o="left",width:e="",closableOnMask:c=!0,escClose:r=!0}=t;let u=!1;function l(){u||(u=!0,p&&p.classList.add("is-visible"),m&&m.classList.add("is-visible"),document.body.style.overflow="hidden")}function f(){u&&(u=!1,p&&p.classList.remove("is-visible"),m&&m.classList.remove("is-visible"),document.body.style.overflow="")}const h=t=>{r&&"Escape"===t.key&&u&&f()};document.addEventListener("keydown",h);const d=n`
|
|
2
|
+
<div class="ds-drawer-mask" onclick="${t=>{c&&t.target===t.currentTarget&&f()}}">
|
|
3
|
+
<div class="${"right"===o?"ds-drawer ds-drawer--right":"ds-drawer"}" style="${e?`width: ${e}`:""}">
|
|
4
|
+
<div class="ds-drawer__header">
|
|
5
|
+
<span class="ds-drawer__title">${i}</span>
|
|
6
|
+
<button class="ds-drawer__close" onclick="${f}" aria-label="Close">
|
|
7
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
8
|
+
<path d="M18 6L6 18M6 6l12 12"/>
|
|
9
|
+
</svg>
|
|
10
|
+
</button>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="ds-drawer__body">${s}</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
`,a=document.createDocumentFragment(),w=y(d,a),p=a.querySelector(".ds-drawer-mask"),m=a.querySelector(".ds-drawer");return{get element(){return a},open:l,close:f,toggle:function(){u?f():l()},destroy(){document.removeEventListener("keydown",h),document.body.style.overflow="",w.destroy()}}};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,
|
|
2
|
-
<div class="ds-drawer-mask" onclick="${t=>{
|
|
3
|
-
<div class="${"right"===
|
|
1
|
+
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.l.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function l(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class f{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new a,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),l=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=l,w(l,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(l),i}function w(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?p(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function p(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==l(s,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&o.insertBefore(document.createTextNode(d),t);const y=new f(o,n[c]);i.parts.push(y);let w=t;return a&&(w=document.createTextNode(a),o.insertBefore(w,t)),o.removeChild(t),y.p=w!==t?w:null,void(a&&p(w,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const u=l(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[o]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new h(t,e.name,n[o]);i.parts.push(r)}}w(t,n,s,i)}function v(t={},s=null){const{title:i="",placement:o="left",width:e="",closableOnMask:c=!0,escClose:r=!0}=t;let u=!1;function l(){u||(u=!0,p&&p.classList.add("is-visible"),m&&m.classList.add("is-visible"),document.body.style.overflow="hidden")}function f(){u&&(u=!1,p&&p.classList.remove("is-visible"),m&&m.classList.remove("is-visible"),document.body.style.overflow="")}const h=t=>{r&&"Escape"===t.key&&u&&f()};document.addEventListener("keydown",h);const d=n`
|
|
2
|
+
<div class="ds-drawer-mask" onclick="${t=>{c&&t.target===t.currentTarget&&f()}}">
|
|
3
|
+
<div class="${"right"===o?"ds-drawer ds-drawer--right":"ds-drawer"}" style="${e?`width: ${e}`:""}">
|
|
4
4
|
<div class="ds-drawer__header">
|
|
5
|
-
<span class="ds-drawer__title"
|
|
6
|
-
<button class="ds-drawer__close" onclick="${f}" aria-label="Close"
|
|
5
|
+
<span class="ds-drawer__title">${i}</span>
|
|
6
|
+
<button class="ds-drawer__close" onclick="${f}" aria-label="Close">
|
|
7
7
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
8
8
|
<path d="M18 6L6 18M6 6l12 12"/>
|
|
9
9
|
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||o(n)},o(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function o(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.o)n.l.delete(t);t.o.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const s=[];for(let o=0;o<n.strings.length;o++)if(s.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?s.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(u).join("")):c(i)?s.push(e(i.value)):"function"!=typeof i&&s.push(e(i??""))}return s.join("")}function f(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const o=t.substring(0,s).lastIndexOf("<");if(-1===o)return{type:"text"};if(t.substring(o,s).includes(">"))return{type:"text"};const i=t.substring(o+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const e=i[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class l{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,s){const o=new a,i=function(n){const s=[];for(let o=0;o<n.strings.length;o++)if(s.push(n.strings[o]),o<n.values.length){const i=n.values[o];i instanceof t?s.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?s.push(i.map(u).join("")):"function"==typeof i||c(i)?s.push(r(o)):s.push(e(i??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);o.fragment=f,m(f,n.values,i,o);for(const t of o.parts)t.mount();return s.appendChild(f),o}function m(t,n,s,o){const i=[...t.childNodes];for(const e of i)3===e.nodeType?w(e,n,s,o,t):1===e.nodeType&&y(e,n,s,o)}function w(t,n,s,o,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==f(s,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&i.insertBefore(document.createTextNode(d),t);const p=new l(i,n[c]);o.parts.push(p);let m=t;return a&&(m=document.createTextNode(a),i.insertBefore(m,t)),i.removeChild(t),p.p=m!==t?m:null,void(a&&w(m,n,s,o,i))}}function y(t,n,s,o){const i=[...t.attributes];for(const e of i)for(let i=0;i<n.length;i++){const c=r(i);if(!e.value.includes(c))continue;const u=f(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new d(t,e.name,n[i]);o.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new h(t,e.name,n[i]);o.parts.push(r)}}m(t,n,s,o)}exports.Dropdown=function(t={}){const{items:s=[],trigger:o="click",closeOnClick:i=!0,onSelect:e=null,placeholder:c="Select..."}=t;let r=!1,u=-1;function f(){r||(r=!0,b&&b.classList.add("is-open"))}function l(){r&&(r=!1,u=-1,b&&b.classList.remove("is-open"),d())}function h(){r?l():f()}function d(){if(!b)return;b.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused"))}function a(t){if(!b)return;const n=b.querySelectorAll(".ds-dropdown__item");0!==n.length&&(d(),u=(t%n.length+n.length)%n.length,n[u].classList.add("is-focused"))}function m(t){if(t<0||t>=s.length)return;const n=s[t];e&&e({value:n.value,text:n.text,item:n}),i&&l()}const w=t=>{r&&k&&!k.contains(t.target)&&l()};document.addEventListener("click",w);const y=t=>{if(r)switch(t.key){case"ArrowDown":t.preventDefault(),a(u+1);break;case"ArrowUp":t.preventDefault(),a(u-1);break;case"Enter":t.preventDefault(),u>=0&&m(u);break;case"Escape":t.preventDefault(),l()}};document.addEventListener("keydown",y);const g=n`
|
|
2
|
+
<div class="ds-dropdown">
|
|
3
|
+
<button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===o&&h()}}">
|
|
4
|
+
<span>${c}</span>
|
|
5
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
6
|
+
<polyline points="6 9 12 15 18 9"/>
|
|
7
|
+
</svg>
|
|
8
|
+
</button>
|
|
9
|
+
<div class="ds-dropdown__menu">${s.map(t=>n`<button class="ds-dropdown__item" data-value="${t.value}">${t.text}</button>`)}</div>
|
|
10
|
+
</div>
|
|
11
|
+
`,_=document.createDocumentFragment(),v=p(g,_),k=_.querySelector(".ds-dropdown"),b=_.querySelector(".ds-dropdown__menu");if(b){b.querySelectorAll(".ds-dropdown__item").forEach((t,n)=>{var s;t.addEventListener("click",(s=n,t=>{t.stopPropagation(),m(s)}))})}return{get element(){return _},open:f,close:l,toggle:h,destroy(){document.removeEventListener("click",w),document.removeEventListener("keydown",y),v.destroy()}}};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...o){return new t(n,o)}function o(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,
|
|
1
|
+
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...o){return new t(n,o)}function o(t){const n={t:t,o:new Set,i:null,u:!1};return n.i=()=>{n.u||s(n)},s(n),()=>function(t){if(t.u)return;t.u=!0,i(t)}(n)}function s(t){i(t);try{t.t()}finally{}}function i(t){for(const n of t.o)n.l.delete(t);t.o.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const o=Object.getPrototypeOf(t);if(o){const t=Object.getOwnPropertyDescriptor(o,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?o.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?o.push(i.map(u).join("")):c(i)?o.push(e(i.value)):"function"!=typeof i&&o.push(e(i??""))}return o.join("")}function f(t,n){const o=t.indexOf(n);if(-1===o)return{type:"text"};const s=t.substring(0,o).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,o).includes(">"))return{type:"text"};const i=t.substring(s+1,o).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!i)return{type:"text"};const e=i[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class l{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class h{constructor(t,n,o){this.element=t,this.attrName=n,this.rawValue=o,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=o(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class d{constructor(t,n,o){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=o,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class a{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,o){const s=new a,i=function(n){const o=[];for(let s=0;s<n.strings.length;s++)if(o.push(n.strings[s]),s<n.values.length){const i=n.values[s];i instanceof t?o.push(u(i)):Array.isArray(i)&&i.length>0&&i[0]instanceof t?o.push(i.map(u).join("")):"function"==typeof i||c(i)?o.push(r(s)):o.push(e(i??""))}return o.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(i);s.fragment=f,m(f,n.values,i,s);for(const t of s.parts)t.mount();return o.appendChild(f),s}function m(t,n,o,s){const i=[...t.childNodes];for(const e of i)3===e.nodeType?w(e,n,o,s,t):1===e.nodeType&&y(e,n,o,s)}function w(t,n,o,s,i){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),h=e.indexOf(u);if(-1===h)continue;if("text"!==f(o,u).type)continue;const d=e.substring(0,h),a=e.substring(h+u.length);d&&i.insertBefore(document.createTextNode(d),t);const p=new l(i,n[c]);s.parts.push(p);let m=t;return a&&(m=document.createTextNode(a),i.insertBefore(m,t)),i.removeChild(t),p.p=m!==t?m:null,void(a&&w(m,n,o,s,i))}}function y(t,n,o,s){const i=[...t.attributes];for(const e of i)for(let i=0;i<n.length;i++){const c=r(i);if(!e.value.includes(c))continue;const u=f(o,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const o=new d(t,e.name,n[i]);s.parts.push(o)}else if("attr"===u.type&&u.attrName===e.name){const o=e.value.replace(c,"");o?t.setAttribute(e.name,o):t.removeAttribute(e.name);const r=new h(t,e.name,n[i]);s.parts.push(r)}}m(t,n,o,s)}function g(t={}){const{items:o=[],trigger:s="click",closeOnClick:i=!0,onSelect:e=null,placeholder:c="Select..."}=t;let r=!1,u=-1;function f(){r||(r=!0,b&&b.classList.add("is-open"))}function l(){r&&(r=!1,u=-1,b&&b.classList.remove("is-open"),d())}function h(){r?l():f()}function d(){if(!b)return;b.querySelectorAll(".ds-dropdown__item").forEach(t=>t.classList.remove("is-focused"))}function a(t){if(!b)return;const n=b.querySelectorAll(".ds-dropdown__item");0!==n.length&&(d(),u=(t%n.length+n.length)%n.length,n[u].classList.add("is-focused"))}function m(t){if(t<0||t>=o.length)return;const n=o[t];e&&e({value:n.value,text:n.text,item:n}),i&&l()}const w=t=>{r&&k&&!k.contains(t.target)&&l()};document.addEventListener("click",w);const y=t=>{if(r)switch(t.key){case"ArrowDown":t.preventDefault(),a(u+1);break;case"ArrowUp":t.preventDefault(),a(u-1);break;case"Enter":t.preventDefault(),u>=0&&m(u);break;case"Escape":t.preventDefault(),l()}};document.addEventListener("keydown",y);const g=n`
|
|
2
2
|
<div class="ds-dropdown">
|
|
3
|
-
<button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===s&&
|
|
3
|
+
<button class="ds-dropdown__trigger" onclick="${t=>{t.stopPropagation(),"click"===s&&h()}}">
|
|
4
4
|
<span>${c}</span>
|
|
5
5
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
6
6
|
<polyline points="6 9 12 15 18 9"/>
|
|
7
7
|
</svg>
|
|
8
8
|
</button>
|
|
9
|
-
<div class="ds-dropdown__menu"
|
|
9
|
+
<div class="ds-dropdown__menu">${o.map(t=>n`<button class="ds-dropdown__item" data-value="${t.value}">${t.text}</button>`)}</div>
|
|
10
10
|
</div>
|
|
11
|
-
`,_=document.createDocumentFragment(),
|
|
11
|
+
`,_=document.createDocumentFragment(),v=p(g,_),k=_.querySelector(".ds-dropdown"),b=_.querySelector(".ds-dropdown__menu");if(b){b.querySelectorAll(".ds-dropdown__item").forEach((t,n)=>{var o;t.addEventListener("click",(o=n,t=>{t.stopPropagation(),m(o)}))})}return{get element(){return _},open:f,close:l,toggle:h,destroy(){document.removeEventListener("click",w),document.removeEventListener("keydown",y),v.destroy()}}}export{g as Dropdown};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"en-US":{"modal.close":"Close","dialog.ok":"OK","dialog.cancel":"Cancel","table.empty":"No data","pagination.page":"Page","pagination.of":"of","select.placeholder":"Select...","datepicker.placeholder":"Select date","timepicker.placeholder":"Select time","fileupload.drag":"Drag files here or","fileupload.browse":"Browse","empty.text":"No data"},"zh-CN":{"modal.close":"关闭","dialog.ok":"确定","dialog.cancel":"取消","table.empty":"暂无数据","pagination.page":"页","pagination.of":"/","select.placeholder":"请选择","datepicker.placeholder":"选择日期","timepicker.placeholder":"选择时间","fileupload.drag":"拖拽文件到此处或","fileupload.browse":"浏览","empty.text":"暂无数据"}};let o="en-US";exports.addMessages=function(o,t){e[o]||(e[o]={}),Object.assign(e[o],t)},exports.getLocale=function(){return o},exports.setLocale=function(e){o=e},exports.t=function(t,a={}){let l=(e[o]||e["en-US"])[t]||t;for(const[e,o]of Object.entries(a))l=l.replace(`{${e}}`,o);return l};
|
|
@@ -1 +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"
|
|
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,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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const 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
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const 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`
|
|
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
|
-
`,
|
|
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()}}};
|
|
@@ -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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const 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`
|
|
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
|
-
`,
|
|
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};
|