@novemberizing/bootstrap
Advanced tools
Comparing version 0.0.43 to 0.0.44
@@ -1,1 +0,1 @@ | ||
const t={parent:(t,e)=>{for(;t&&t.nodeName&&t.nodeName.toLowerCase()!==e;)t=t.parentNode;return t},previous:(t,e)=>{for(;t&&t.nodeName.toLowerCase()!==e;)t=t.previousElementSibling;return t},children:{remove:t=>{for(;t.firstChild;)t.lastChild.remove()}}},e={equal:(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),str:(t,e="/")=>{function s(t){return t<10?`0${t}`:t}return`${t.getFullYear()}${e}${s(t.getMonth()+1)}${e}${s(t.getDate())}`},next:(t,e=1)=>(t.setDate(t.getDate()+e),t),month:{str:t=>{return`${t.getFullYear()}/${e=t.getMonth()+1,e<10?`0${e}`:e}`;var e},begin:t=>(t.setDate(1),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t),previous:t=>(t.setMonth(t.getMonth()-1),t.setDate(1),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t),next:t=>(t.setMonth(t.getMonth()+1),t.setDate(1),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t)},week:{begin:t=>(t.setDate(t.getDate()-t.getDay()),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t)}};class s{static#t='<p class="d-inline-flex gap-1 star"></p>';static#e='<button type="button"></button>';static#s='<i class="fa-solid fa-star"></i>';static#n='<i class="fa-regular fa-star"></i>';static{const t=new DOMParser;s.#t=t.parseFromString(s.#t,"text/html").querySelector("p"),s.#e=t.parseFromString(s.#e,"text/html").querySelector("button"),s.#s=t.parseFromString(s.#s,"text/html").querySelector("i"),s.#n=t.parseFromString(s.#n,"text/html").querySelector("i")}#o=null;#i=null;#a=null;#l=null;#r=null;#d=null;#c=null;static load(t){const e=document.querySelectorAll("input[type='range'].form-control.star");for(const n of e)new s(n,"function"==typeof t?t(n):t)}static#u(){return s.#t.cloneNode(!0)}static#h(e,n){const o=s.#e.cloneNode(!0);return o.setAttribute("data-value",e+1),o.setAttribute("aria-pressed",n),n?o.appendChild(s.#s.cloneNode(!0)):o.appendChild(s.#n.cloneNode(!0)),o.addEventListener("click",(e=>{const s=t.parent(e.target,"button"),n=t.parent(s,"p"),o=t.previous(n,"input"),i=parseInt(s.getAttribute("data-value")),a=s.getAttribute("aria-pressed"),l=s.nextElementSibling;"true"===a?l&&"true"===l.getAttribute("aria-pressed")?o.setAttribute("value",i):o.setAttribute("value",i-1):o.setAttribute("value",i);const r=parseInt(o.getAttribute("value")),d=n.querySelectorAll("button");for(const t of d){const e=t.querySelector("i");r<parseInt(t.getAttribute("data-value"))?(e.classList.contains("fa-solid")&&e.classList.replace("fa-solid","fa-regular"),t.setAttribute("aria-pressed","false")):(e.classList.contains("fa-regular")&&e.classList.replace("fa-regular","fa-solid"),t.setAttribute("aria-pressed","true"))}})),o}constructor(t,e){this.#a=t,this.#l=e,"string"==typeof this.#a&&(this.#a=document.getElementById(this.#a)),this.#o=this.#a.parentNode,this.#i=this.#a.nextSibling,this.#r=parseInt(this.#a.max),this.#d=parseInt(this.#a.min),this.#c=parseInt(this.#a.defaultValue);const n=s.#u();for(let t=this.#d;t<this.#r;t++){const e=s.#h(t,t<this.#c);n.appendChild(e)}this.#a.style.display="none",this.#o.insertBefore(n,this.#i)}}class n{static#b='<div class="calendar">\n <div class="input-group">\n <input type="text" class="form-control" data-date="" disabled>\n <span class="input-group-text">\n <button type="button" class="btn btn-link"><i class="fa-regular fa-calendar"></i></button>\n </span>\n </div>\n <div class="form calendar-form-ui small hide" data-focus-date="">\n <div class="calendar-header d-flex justify-content-between mb-3">\n <button type="button" class="btn btn-light btn-sm text-start month fw-bold"></button>\n <div>\n <button type="button" class="btn btn-light btn-sm up"><i class="fa-solid fa-caret-up"></i></button>\n <button type="button" class="btn btn-light btn-sm down"><i class="fa-solid fa-caret-down"></i></button>\n </div>\n </div>\n <div class="calendar-body mb-2">\n <table class="table">\n <thead>\n <tr>\n <th scope="col">Sun</th>\n <th scope="col">Mon</th>\n <th scope="col">Tue</th>\n <th scope="col">Wed</th>\n <th scope="col">Thu</th>\n <th scope="col">Fri</th>\n <th scope="col">Sat</th>\n </tr>\n </thead>\n </table>\n <div class="calendar-date">\n <table class="table">\n <tbody>\n <tr>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n </tr>\n </tbody>\n </table>\n </div>\n </div>\n <div class="calendar-footer d-flex justify-content-between">\n <button type="button" class="btn btn-light btn-sm erase">삭제</button>\n <button type="button" class="btn btn-light btn-sm today">오늘</button>\n </div>\n </div>\n</div>';static#t=null;static#m=null;static{const t=new DOMParser;n.#b=t.parseFromString(n.#b,"text/html"),n.#t=n.#b.querySelector("div.calendar");const e=n.#t.querySelector("div.calendar-date"),s=e.querySelector("tr");n.#m=s.querySelector("td"),n.#m=n.#m.cloneNode(!0),s.remove()}static load(t){const e=document.querySelectorAll('input[type="date"].form-control');for(const s of e)new n(s,"function"==typeof t?t(s):t)}#a=null;#l=null;#o=null;#i=null;#p=null;#f=null;#g=null;#w=null;#v(){this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):this.#g.classList.add("hide"),t.children.remove(this.#w);const s=e.month.begin(new Date);this.#g.setAttribute("data-focus-date",s),e.week.begin(new Date(s)),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(s)}#y(t,s,o,i=null){let a=new Date(t);for(let t=0;t<6;t++)if(s.querySelector(`tr[data-date="${a}"]`))a=e.next(a,7);else{const t=document.createElement("tr");t.setAttribute("data-date",a);for(let s=0;s<7;s++){const s=n.#m.cloneNode(!0),o=s.querySelector("button");o.appendChild(document.createTextNode(a.getDate()));const i=new Date(a);o.addEventListener("click",(t=>{this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):this.#g.classList.add("hide");const s=e.month.begin(new Date(i));this.#g.setAttribute("data-focus-date",s),this.#f.setAttribute("value",e.str(i)),this.#f.setAttribute("data-date",i),this.#a.setAttribute("value",e.str(i,"-"))})),t.appendChild(s),a=e.next(a)}s.insertBefore(t,i)}a=new Date(t);const l=new Date(this.#f.getAttribute("data-date"));for(let t=0;t<6;t++){let t=s.querySelector(`tr[data-date="${a}"]`).querySelector("td");for(let s=0;s<7;s++){const s=t.querySelector("button");s.classList.remove("active"),s.classList.remove("fw-bold"),a.getMonth()!==o?s.classList.contains("not-current")||s.classList.add("not-current"):(s.classList.contains("not-current")&&s.classList.remove("not-current"),e.equal(a,l)&&(s.classList.add("active"),s.classList.add("fw-bold"))),a=e.next(a),t=t.nextElementSibling}}}#L(t){t.scrollIntoView({behavior:"smooth"})}#S(t){const s=new Date(this.#g.getAttribute("data-focus-date")),n=e.month.previous(new Date(s)),o=e.week.begin(new Date(n)),i=e.week.begin(e.month.begin(new Date(s))),a=this.#w.querySelector(`tr[data-date="${i}"]`);this.#y(o,this.#w,n.getMonth(),a),this.#g.setAttribute("data-focus-date",n),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(n),this.#L(this.#w.querySelector(`tr[data-date="${o}"]`))}#x(t){const s=new Date(this.#g.getAttribute("data-focus-date")),n=e.month.next(new Date(s)),o=e.week.begin(new Date(n)),i=e.next(new Date(o),42),a=this.#w.querySelector(`tr[data-date="${i}"]`);this.#y(o,this.#w,n.getMonth(),a),this.#g.setAttribute("data-focus-date",n),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(n),this.#L(this.#w.querySelector(`tr[data-date="${o}"]`))}#D(){const t=this.#f.getBoundingClientRect();this.#g.style.top=`${t.top+t.height+window.scrollY+5}px`,this.#g.style.left=`${t.left+5}px`}#A(s){const o=e.month.begin(new Date(s)),i=e.week.begin(new Date(o));this.#p=n.#t.cloneNode(!0);const a=this.#p.querySelector("div.input-group button");this.#f=this.#p.querySelector("div.input-group input"),this.#g=this.#p.querySelector("div.form"),this.#w=this.#g.querySelector("div.form div.calendar-date tbody");for(const t of this.#a.attributes)this.#f.setAttribute(t.name,t.value);this.#f.setAttribute("type","text"),this.#f.removeAttribute("id"),this.#g.querySelector("div.calendar-header button.up").addEventListener("click",(t=>this.#S(t))),this.#g.querySelector("div.calendar-header button.down").addEventListener("click",(t=>this.#x(t))),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(o),this.#g.querySelector("div.calendar-footer button.today").addEventListener("click",(t=>{const s=new Date,n=e.month.begin(new Date(s));this.#g.setAttribute("data-focus-date",n),this.#f.setAttribute("value",e.str(s)),this.#f.setAttribute("data-date",s),this.#a.setAttribute("value",e.str(s,"-")),this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):(this.#g.classList.replace("hide","show"),this.#D())})),this.#g.querySelector("div.calendar-footer button.erase").addEventListener("click",(t=>{const s=new Date,n=e.month.begin(new Date(s));this.#g.setAttribute("data-focus-date",n),this.#f.setAttribute("value",""),this.#f.setAttribute("data-date",""),this.#a.setAttribute("value",""),this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):(this.#g.classList.replace("hide","show"),this.#D())})),this.#g.setAttribute("data-focus-date",o),a.addEventListener("click",(s=>{if(this.#g.classList.contains("show")){this.#g.classList.replace("show","hide"),t.children.remove(this.#w);const s=e.month.begin(new Date);this.#g.setAttribute("data-focus-date",s),e.week.begin(new Date(s)),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(s)}else if(this.#g.classList.contains("hide")){t.children.remove(this.#w);const s=new Date(this.#g.getAttribute("data-focus-date")),n=e.week.begin(new Date(s)),o=this.#w.querySelector(`tr[data-date="${n}"]`);this.#y(n,this.#w,s.getMonth(),o),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(s),this.#g.classList.replace("hide","show"),this.#D()}})),this.#y(i,this.#w,o.getMonth()),this.#o.insertBefore(this.#p,this.#i)}constructor(t,e){this.#a=t,this.#l=e,"string"==typeof this.#a&&(this.#a=document.getElementById(this.#a)),this.#o=this.#a.parentNode,this.#i=this.#a.nextSibling;const s=this.#a.getAttribute("value")||this.#a.getAttribute("defaultValue");this.#A(s?new Date(s):new Date),this.#a.style.display="none"}}class o{static#q=new Set;static#k(){for(const t of o.#q){const e=document.getElementById(t);e.classList.contains("show")?e.classList.replace("show","hide"):e.classList.add("hide")}}static on(e,s,n){const i=document.getElementById(s);i.classList.contains("hide")?(i.classList.replace("hide","show"),o.#k(),o.#q.add(s)):(i.classList.add("show"),o.#k(),o.#q.add(s));const a=t.parent(e.target,"button").getBoundingClientRect();if(i.addEventListener("click",(t=>{o.toggle(e,s,n)}),{once:!0}),console.log(a,a.bottom,window.scrollY),n){const t=n.getBoundingClientRect();i.style.left=`${t.left+20}px`,i.style.width=t.width-40+"px"}else i.style.left=`${a.left}px`;const l=i.getBoundingClientRect();console.log(l),i.style.top=`${parseInt(a.top+window.scrollY-l.height-4)}px`}static toggle(e,s,n=void 0){const i=document.getElementById(s);if(i.classList.contains("hide")){o.#k(),i.classList.replace("hide","show"),o.#q.add(s);const a=t.parent(e.target,"button").getBoundingClientRect();if(console.log(a,a.bottom,window.scrollY),i.addEventListener("click",(t=>{o.toggle(e,s,n)}),{once:!0}),n){const t=n.getBoundingClientRect();i.style.left=`${t.left+20}px`,i.style.width=t.width-40+"px"}else i.style.left=`${a.left}px`;const l=i.getBoundingClientRect();console.log(l),i.style.top=`${parseInt(a.top+window.scrollY-l.height-4)}px`}else if(i.classList.contains("show"))o.#q.delete(s),i.classList.replace("show","hide");else{o.#k(),i.classList.add("show"),o.#q.add(s);const a=t.parent(e.target,"button").getBoundingClientRect();if(console.log(a,a.bottom,window.scrollY),i.addEventListener("click",(t=>{o.toggle(e,s,n)}),{once:!0}),n){const t=n.getBoundingClientRect();i.style.left=`${t.left+20}px`,i.style.width=t.width-40+"px"}else i.style.left=`${a.left}px`;const l=i.getBoundingClientRect();console.log(l),i.style.top=`${parseInt(a.top+window.scrollY-l.height-4)}px`}}}class i{static#$=null;static#C=null;static#M=null;static submit(){if(i.#$){const t=i.#C;i.#$._element.addEventListener("hidden.bs.modal",(e=>{console.log(t),t&&t(e)}),{once:!0}),i.#$.hide()}}static cancel(){i.#$.hide()}static hide(){i.#$.hide()}static#E(t,e,s){i.#$=t,i.#C=e,i.#M=s,i.#$._element.addEventListener("hidden.bs.modal",(t=>{i.#$=null,i.#C=null,i.#M=null}),{once:!0}),i.#$.show()}static show(t,e,s){if(i.#$)return i.#$._element.addEventListener("hidden.bs.modal",(n=>{s&&s(n),i.#E(t,e,s)}),{once:!0}),void i.#$.hide();i.#E(t,e,s)}}class a{static check(t,e=!0){if(t.validity)return t.validity.valid&&e?(t.classList.remove("is-valid"),t.classList.remove("is-invalid"),!0):(!1===e&&(t.value=""),t.classList.contains("is-valid")?t.classList.replace("is-valid","is-invalid"):t.classList.add("is-invalid"),t.focus(),!1);throw new Error}}void 0===window.novemberizing?console.error("need to ..."):void 0===window.novemberizing.bootstrap?window.novemberizing.bootstrap={Star:s,Date:n,modal:i,popover:o,validity:a}:(window.novemberizing.bootstrap.Star=s,window.novemberizing.bootstrap.Date=n,window.novemberizing.bootstrap.modal=i,window.novemberizing.bootstrap.popover=o,window.novemberizing.bootstrap.validity=a); | ||
const t={parent:(t,e)=>{for(;t&&t.nodeName&&t.nodeName.toLowerCase()!==e;)t=t.parentNode;return t},previous:(t,e)=>{for(;t&&t.nodeName.toLowerCase()!==e;)t=t.previousElementSibling;return t},children:{remove:t=>{for(;t.firstChild;)t.lastChild.remove()}}},e={equal:(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),str:(t,e="/")=>{function s(t){return t<10?`0${t}`:t}return`${t.getFullYear()}${e}${s(t.getMonth()+1)}${e}${s(t.getDate())}`},next:(t,e=1)=>(t.setDate(t.getDate()+e),t),month:{str:t=>{return`${t.getFullYear()}/${e=t.getMonth()+1,e<10?`0${e}`:e}`;var e},begin:t=>(t.setDate(1),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t),previous:t=>(t.setMonth(t.getMonth()-1),t.setDate(1),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t),next:t=>(t.setMonth(t.getMonth()+1),t.setDate(1),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t)},week:{begin:t=>(t.setDate(t.getDate()-t.getDay()),t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t)}};class s{static#t='<p class="d-inline-flex gap-1 star"></p>';static#e='<button type="button"></button>';static#s='<i class="fa-solid fa-star"></i>';static#n='<i class="fa-regular fa-star"></i>';static{const t=new DOMParser;s.#t=t.parseFromString(s.#t,"text/html").querySelector("p"),s.#e=t.parseFromString(s.#e,"text/html").querySelector("button"),s.#s=t.parseFromString(s.#s,"text/html").querySelector("i"),s.#n=t.parseFromString(s.#n,"text/html").querySelector("i")}#o=null;#i=null;#a=null;#l=null;#r=null;#d=null;#c=null;static load(t){const e=document.querySelectorAll("input[type='range'].form-control.star");for(const n of e)new s(n,"function"==typeof t?t(n):t)}static#u(){return s.#t.cloneNode(!0)}static#h(e,n){const o=s.#e.cloneNode(!0);return o.setAttribute("data-value",e+1),o.setAttribute("aria-pressed",n),n?o.appendChild(s.#s.cloneNode(!0)):o.appendChild(s.#n.cloneNode(!0)),o.addEventListener("click",(e=>{const s=t.parent(e.target,"button"),n=t.parent(s,"p"),o=t.previous(n,"input"),i=parseInt(s.getAttribute("data-value")),a=s.getAttribute("aria-pressed"),l=s.nextElementSibling;"true"===a?l&&"true"===l.getAttribute("aria-pressed")?o.setAttribute("value",i):o.setAttribute("value",i-1):o.setAttribute("value",i);const r=parseInt(o.getAttribute("value")),d=n.querySelectorAll("button");for(const t of d){const e=t.querySelector("i");r<parseInt(t.getAttribute("data-value"))?(e.classList.contains("fa-solid")&&e.classList.replace("fa-solid","fa-regular"),t.setAttribute("aria-pressed","false")):(e.classList.contains("fa-regular")&&e.classList.replace("fa-regular","fa-solid"),t.setAttribute("aria-pressed","true"))}})),o}constructor(t,e){this.#a=t,this.#l=e,"string"==typeof this.#a&&(this.#a=document.getElementById(this.#a)),this.#o=this.#a.parentNode,this.#i=this.#a.nextSibling,this.#r=parseInt(this.#a.max),this.#d=parseInt(this.#a.min),this.#c=parseInt(this.#a.defaultValue);const n=s.#u();for(let t=this.#d;t<this.#r;t++){const e=s.#h(t,t<this.#c);n.appendChild(e)}this.#a.style.display="none",this.#o.insertBefore(n,this.#i)}}class n{static#b='<div class="calendar">\n <div class="input-group">\n <input type="text" class="form-control" data-date="" disabled>\n <span class="input-group-text">\n <button type="button" class="btn btn-link"><i class="fa-regular fa-calendar"></i></button>\n </span>\n </div>\n <div class="form calendar-form-ui small hide" data-focus-date="">\n <div class="calendar-header d-flex justify-content-between mb-3">\n <button type="button" class="btn btn-light btn-sm text-start month fw-bold"></button>\n <div>\n <button type="button" class="btn btn-light btn-sm up"><i class="fa-solid fa-caret-up"></i></button>\n <button type="button" class="btn btn-light btn-sm down"><i class="fa-solid fa-caret-down"></i></button>\n </div>\n </div>\n <div class="calendar-body mb-2">\n <table class="table">\n <thead>\n <tr>\n <th scope="col">Sun</th>\n <th scope="col">Mon</th>\n <th scope="col">Tue</th>\n <th scope="col">Wed</th>\n <th scope="col">Thu</th>\n <th scope="col">Fri</th>\n <th scope="col">Sat</th>\n </tr>\n </thead>\n </table>\n <div class="calendar-date">\n <table class="table">\n <tbody>\n <tr>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n <td><button type="button" class="btn btn-link btn-sm"></button></td>\n </tr>\n </tbody>\n </table>\n </div>\n </div>\n <div class="calendar-footer d-flex justify-content-between">\n <button type="button" class="btn btn-light btn-sm erase">삭제</button>\n <button type="button" class="btn btn-light btn-sm today">오늘</button>\n </div>\n </div>\n</div>';static#t=null;static#m=null;static{const t=new DOMParser;n.#b=t.parseFromString(n.#b,"text/html"),n.#t=n.#b.querySelector("div.calendar");const e=n.#t.querySelector("div.calendar-date"),s=e.querySelector("tr");n.#m=s.querySelector("td"),n.#m=n.#m.cloneNode(!0),s.remove()}static load(t){const e=document.querySelectorAll('input[type="date"].form-control');for(const s of e)new n(s,"function"==typeof t?t(s):t)}#a=null;#l=null;#o=null;#i=null;#p=null;#f=null;#g=null;#v=null;#w(){this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):this.#g.classList.add("hide"),t.children.remove(this.#v);const s=e.month.begin(new Date);this.#g.setAttribute("data-focus-date",s),e.week.begin(new Date(s)),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(s)}#y(t,s,o,i=null){let a=new Date(t);for(let t=0;t<6;t++)if(s.querySelector(`tr[data-date="${a}"]`))a=e.next(a,7);else{const t=document.createElement("tr");t.setAttribute("data-date",a);for(let s=0;s<7;s++){const s=n.#m.cloneNode(!0),o=s.querySelector("button");o.appendChild(document.createTextNode(a.getDate()));const i=new Date(a);o.addEventListener("click",(t=>{this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):this.#g.classList.add("hide");const s=e.month.begin(new Date(i));this.#g.setAttribute("data-focus-date",s),this.#f.setAttribute("value",e.str(i)),this.#f.setAttribute("data-date",i),this.#a.setAttribute("value",e.str(i,"-"))})),t.appendChild(s),a=e.next(a)}s.insertBefore(t,i)}a=new Date(t);const l=new Date(this.#f.getAttribute("data-date"));for(let t=0;t<6;t++){let t=s.querySelector(`tr[data-date="${a}"]`).querySelector("td");for(let s=0;s<7;s++){const s=t.querySelector("button");s.classList.remove("active"),s.classList.remove("fw-bold"),a.getMonth()!==o?s.classList.contains("not-current")||s.classList.add("not-current"):(s.classList.contains("not-current")&&s.classList.remove("not-current"),e.equal(a,l)&&(s.classList.add("active"),s.classList.add("fw-bold"))),a=e.next(a),t=t.nextElementSibling}}}#L(t){t.scrollIntoView({behavior:"smooth"})}#S(t){const s=new Date(this.#g.getAttribute("data-focus-date")),n=e.month.previous(new Date(s)),o=e.week.begin(new Date(n)),i=e.week.begin(e.month.begin(new Date(s))),a=this.#v.querySelector(`tr[data-date="${i}"]`);this.#y(o,this.#v,n.getMonth(),a),this.#g.setAttribute("data-focus-date",n),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(n),this.#L(this.#v.querySelector(`tr[data-date="${o}"]`))}#x(t){const s=new Date(this.#g.getAttribute("data-focus-date")),n=e.month.next(new Date(s)),o=e.week.begin(new Date(n)),i=e.next(new Date(o),42),a=this.#v.querySelector(`tr[data-date="${i}"]`);this.#y(o,this.#v,n.getMonth(),a),this.#g.setAttribute("data-focus-date",n),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(n),this.#L(this.#v.querySelector(`tr[data-date="${o}"]`))}#D(){const t=this.#f.getBoundingClientRect();this.#g.style.top=`${t.top+t.height+window.scrollY+5}px`,this.#g.style.left=`${t.left+5}px`}#A(s){const o=e.month.begin(new Date(s)),i=e.week.begin(new Date(o));this.#p=n.#t.cloneNode(!0);const a=this.#p.querySelector("div.input-group button");this.#f=this.#p.querySelector("div.input-group input"),this.#g=this.#p.querySelector("div.form"),this.#v=this.#g.querySelector("div.form div.calendar-date tbody");for(const t of this.#a.attributes)this.#f.setAttribute(t.name,t.value);this.#f.setAttribute("type","text"),this.#f.removeAttribute("id"),this.#g.querySelector("div.calendar-header button.up").addEventListener("click",(t=>this.#S(t))),this.#g.querySelector("div.calendar-header button.down").addEventListener("click",(t=>this.#x(t))),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(o),this.#g.querySelector("div.calendar-footer button.today").addEventListener("click",(t=>{const s=new Date,n=e.month.begin(new Date(s));this.#g.setAttribute("data-focus-date",n),this.#f.setAttribute("value",e.str(s)),this.#f.setAttribute("data-date",s),this.#a.setAttribute("value",e.str(s,"-")),this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):(this.#g.classList.replace("hide","show"),this.#D())})),this.#g.querySelector("div.calendar-footer button.erase").addEventListener("click",(t=>{const s=new Date,n=e.month.begin(new Date(s));this.#g.setAttribute("data-focus-date",n),this.#f.setAttribute("value",""),this.#f.setAttribute("data-date",""),this.#a.setAttribute("value",""),this.#g.classList.contains("show")?this.#g.classList.replace("show","hide"):(this.#g.classList.replace("hide","show"),this.#D())})),this.#g.setAttribute("data-focus-date",o),a.addEventListener("click",(s=>{if(this.#g.classList.contains("show")){this.#g.classList.replace("show","hide"),t.children.remove(this.#v);const s=e.month.begin(new Date);this.#g.setAttribute("data-focus-date",s),e.week.begin(new Date(s)),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(s)}else if(this.#g.classList.contains("hide")){t.children.remove(this.#v);const s=new Date(this.#g.getAttribute("data-focus-date")),n=e.week.begin(new Date(s)),o=this.#v.querySelector(`tr[data-date="${n}"]`);this.#y(n,this.#v,s.getMonth(),o),this.#g.querySelector("div.calendar-header button.month").textContent=e.month.str(s),this.#g.classList.replace("hide","show"),this.#D()}})),this.#y(i,this.#v,o.getMonth()),this.#o.insertBefore(this.#p,this.#i)}constructor(t,e){this.#a=t,this.#l=e,"string"==typeof this.#a&&(this.#a=document.getElementById(this.#a)),this.#o=this.#a.parentNode,this.#i=this.#a.nextSibling;const s=this.#a.getAttribute("value")||this.#a.getAttribute("defaultValue");this.#A(s?new Date(s):new Date),this.#a.style.display="none"}}class o{static#q=new Set;static#k(){for(const t of o.#q){const e=document.getElementById(t);e.classList.contains("show")?e.classList.replace("show","hide"):e.classList.add("hide")}}static on(e,s,n){const i=document.getElementById(s);i.classList.contains("hide")?(i.classList.replace("hide","show"),o.#k(),o.#q.add(s)):(i.classList.add("show"),o.#k(),o.#q.add(s));const a=t.parent(e.target,"button").getBoundingClientRect();if(i.addEventListener("click",(t=>{o.toggle(e,s,n)}),{once:!0}),console.log(a,a.bottom,window.scrollY),n){const t=n.getBoundingClientRect();i.style.left=`${t.left+20}px`,i.style.width=t.width-40+"px"}else i.style.left=`${a.left}px`;const l=i.getBoundingClientRect();console.log(l),i.style.top=`${parseInt(a.top+window.scrollY-l.height-4)}px`}static toggle(e,s,n=void 0){const i=document.getElementById(s);if(i.classList.contains("hide")){o.#k(),i.classList.replace("hide","show"),o.#q.add(s);const a=t.parent(e.target,"button").getBoundingClientRect();if(console.log(a,a.bottom,window.scrollY),i.addEventListener("click",(t=>{o.toggle(e,s,n)}),{once:!0}),n){const t=n.getBoundingClientRect();i.style.left=`${t.left+20}px`,i.style.width=t.width-40+"px"}else i.style.left=`${a.left}px`;const l=i.getBoundingClientRect();console.log(l),i.style.top=`${parseInt(a.top+window.scrollY-l.height-4)}px`}else if(i.classList.contains("show"))o.#q.delete(s),i.classList.replace("show","hide");else{o.#k(),i.classList.add("show"),o.#q.add(s);const a=t.parent(e.target,"button").getBoundingClientRect();if(console.log(a,a.bottom,window.scrollY),i.addEventListener("click",(t=>{o.toggle(e,s,n)}),{once:!0}),n){const t=n.getBoundingClientRect();i.style.left=`${t.left+20}px`,i.style.width=t.width-40+"px"}else i.style.left=`${a.left}px`;const l=i.getBoundingClientRect();console.log(l),i.style.top=`${parseInt(a.top+window.scrollY-l.height-4)}px`}}}class i{static#$=null;static#C=null;static#M=null;static submit(){if(i.#$){const t=i.#C;i.#$._element.addEventListener("hidden.bs.modal",(e=>{console.log(t),t&&t(e)}),{once:!0}),i.#$.hide()}}static cancel(){i.#$.hide()}static hide(){i.#$.hide()}static#E(t,e,s){i.#$=t,i.#C=e,i.#M=s,i.#$._element.addEventListener("hidden.bs.modal",(t=>{i.#$=null,i.#C=null,i.#M=null}),{once:!0}),i.#$.show()}static show(t,e,s){if(i.#$)return i.#$._element.addEventListener("hidden.bs.modal",(n=>{s&&s(n),i.#E(t,e,s)}),{once:!0}),void i.#$.hide();i.#E(t,e,s)}}class a{static valid(t){t.classList.contains("is-invalid")?t.classList.replace("is-invalid","is-valid"):t.classList.add("is-valid")}static invalid(t){t.classList.contains("is-valid")?t.classList.replace("is-valid","is-invalid"):t.classList.add("is-invalid")}static check(t,e=!0){if(t.validity)return t.validity.valid&&e?(t.classList.remove("is-valid"),t.classList.remove("is-invalid"),!0):(!1===e&&(t.value=""),t.classList.contains("is-valid")?t.classList.replace("is-valid","is-invalid"):t.classList.add("is-invalid"),t.focus(),!1);throw new Error}}void 0===window.novemberizing?console.error("need to ..."):void 0===window.novemberizing.bootstrap?window.novemberizing.bootstrap={Star:s,Date:n,modal:i,popover:o,validity:a}:(window.novemberizing.bootstrap.Star=s,window.novemberizing.bootstrap.Date=n,window.novemberizing.bootstrap.modal=i,window.novemberizing.bootstrap.popover=o,window.novemberizing.bootstrap.validity=a); |
{ | ||
"name": "@novemberizing/bootstrap", | ||
"version": "0.0.43", | ||
"version": "0.0.44", | ||
"description": "novemberizing's bootstrap plugin", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
export default class ValidityUI { | ||
static valid(element) { | ||
if(element.classList.contains("is-invalid")) { | ||
element.classList.replace("is-invalid", "is-valid"); | ||
} else { | ||
element.classList.add('is-valid'); | ||
} | ||
} | ||
static invalid(element) { | ||
if(element.classList.contains("is-valid")) { | ||
element.classList.replace("is-valid", "is-invalid"); | ||
} else { | ||
element.classList.add('is-invalid'); | ||
} | ||
} | ||
static check(element, condition = true) { | ||
@@ -4,0 +18,0 @@ if(element.validity) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66359
838