@nova-design-system/nova-react 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cjs/{constants-98e2dcc2-C0SBCapP.js → constants-b97e736d-BzFAKCkR.js} +11 -0
  2. package/dist/cjs/{index-Byv3Vmev.js → index-B2jv2KXv.js} +2856 -1620
  3. package/dist/cjs/index.js +2 -1
  4. package/dist/cjs/{nv-alert.entry-BXY4KXbF.js → nv-alert.entry-pxBJfmIm.js} +11 -11
  5. package/dist/cjs/{nv-avatar.entry-BnPSKkJJ.js → nv-avatar.entry-CHtVctSK.js} +7 -7
  6. package/dist/cjs/nv-badge_2.entry-BO88KO1O.js +204 -0
  7. package/dist/cjs/{nv-breadcrumb.entry-D5vGHLOG.js → nv-breadcrumb.entry-7azRtyl5.js} +1 -1
  8. package/dist/cjs/{nv-breadcrumbs.entry-CsaqAsnb.js → nv-breadcrumbs.entry-DfZVMKpY.js} +1 -1
  9. package/dist/cjs/{nv-button.entry-DzZfGZGy.js → nv-button.entry-DW9SblsY.js} +7 -7
  10. package/dist/cjs/nv-calendar.entry-BeayRRor.js +1043 -0
  11. package/dist/cjs/{nv-col.entry-Cng8NaTW.js → nv-col.entry-C6oEkSbI.js} +1 -1
  12. package/dist/cjs/{nv-datagrid.entry-BbAOzpiO.js → nv-datagrid.entry-xhQP6JJP.js} +423 -94
  13. package/dist/cjs/{nv-datagridcolumn.entry-CRogHbVM.js → nv-datagridcolumn.entry-CjYmo4fM.js} +2 -2
  14. package/dist/cjs/{nv-dialog.entry-BSIZGYGF.js → nv-dialog.entry-mxETaZbc.js} +19 -13
  15. package/dist/cjs/{nv-dialogfooter_2.entry-Q4_li_QU.js → nv-dialogfooter_2.entry-DnLg2DHy.js} +3 -3
  16. package/dist/cjs/{nv-fieldcheckbox.entry-DmgzfmRd.js → nv-fieldcheckbox.entry-Be9__i15.js} +1 -1
  17. package/dist/cjs/{nv-fielddate.entry-qAvLX_Ru.js → nv-fielddate.entry-BlNily-X.js} +9 -18
  18. package/dist/cjs/nv-fielddaterange.entry-CycpKoJd.js +408 -0
  19. package/dist/cjs/{nv-fielddropdown.entry-DKXmoXeW.js → nv-fielddropdown.entry-BPwviyCp.js} +88 -57
  20. package/dist/cjs/{nv-fielddropdownitem.entry-BVLVXi0e.js → nv-fielddropdownitem.entry-BGuUR9KP.js} +2 -2
  21. package/dist/cjs/{nv-fieldmultiselect.entry-DrTbd3Dj.js → nv-fieldmultiselect.entry-Lrxr1gsi.js} +122 -104
  22. package/dist/cjs/nv-fieldnumber.entry-B1VySoWj.js +130 -0
  23. package/dist/cjs/nv-fieldpassword.entry-D7Qlx7Bh.js +121 -0
  24. package/dist/cjs/{nv-fieldradio.entry-CVEY4v6F.js → nv-fieldradio.entry-CDu8xs0p.js} +4 -4
  25. package/dist/cjs/{nv-fieldselect.entry-BrCUuRWa.js → nv-fieldselect.entry-NEdv8bQK.js} +11 -7
  26. package/dist/cjs/nv-fieldslider.entry-51gF9XPz.js +660 -0
  27. package/dist/cjs/nv-fieldtext.entry-Bug9zMgo.js +123 -0
  28. package/dist/cjs/{nv-fieldtextarea.entry-B4qiLmX1.js → nv-fieldtextarea.entry-D44HbsVQ.js} +9 -5
  29. package/dist/cjs/{nv-fieldtime.entry-Bp2IWjhN.js → nv-fieldtime.entry-MbaWbVtc.js} +71 -68
  30. package/dist/cjs/nv-icon.entry-BSSHr-ud.js +79 -0
  31. package/dist/cjs/{nv-iconbutton_2.entry-BRPAGl2S.js → nv-iconbutton_2.entry-DMaO-JWz.js} +3 -3
  32. package/dist/cjs/{nv-menu.entry-BiWiIZAm.js → nv-menu.entry-D5_lj9XB.js} +4 -2
  33. package/dist/cjs/{nv-menuitem.entry-CFkXoZ_r.js → nv-menuitem.entry-fhnYI91K.js} +2 -2
  34. package/dist/cjs/{nv-popover.entry-KT1iQUJk.js → nv-popover.entry-CYqBaVbr.js} +2 -2
  35. package/dist/cjs/{nv-row.entry-Cs2GDrcu.js → nv-row.entry-BUheLufV.js} +2 -2
  36. package/dist/cjs/{nv-stack.entry-Ci7pxGSo.js → nv-stack.entry-DNPce51E.js} +2 -2
  37. package/dist/cjs/{nv-table.entry-N4MV8Y6E.js → nv-table.entry-DXQM8l3t.js} +3 -3
  38. package/dist/cjs/{nv-tablecolumn.entry-CTz4jsZl.js → nv-tablecolumn.entry-DROQK_0c.js} +1 -1
  39. package/dist/cjs/{nv-toggle.entry-m10-ncYR.js → nv-toggle.entry-fMzTrdte.js} +3 -3
  40. package/dist/cjs/{nv-tooltip.entry-B6aRDto3.js → nv-tooltip.entry-yB2Ek1Cz.js} +3 -3
  41. package/dist/generated/components.js +12 -1
  42. package/dist/types/generated/components.d.ts +19 -7
  43. package/package.json +1 -1
  44. package/dist/cjs/nv-badge_2.entry-BsI3B8Rr.js +0 -195
  45. package/dist/cjs/nv-calendar.entry-CGKv_-gO.js +0 -1065
  46. package/dist/cjs/nv-fielddaterange.entry-DVB8Rwxk.js +0 -355
  47. package/dist/cjs/nv-fieldnumber.entry-DegbEHRL.js +0 -126
  48. package/dist/cjs/nv-fieldpassword.entry-gqjlEl7a.js +0 -117
  49. package/dist/cjs/nv-fieldtext.entry-q9NnqL5c.js +0 -119
  50. package/dist/cjs/nv-icon.entry-B1ax9cJS.js +0 -79
@@ -0,0 +1,1043 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-B2jv2KXv.js');
4
+ var constantsB97e736d = require('./constants-b97e736d-BzFAKCkR.js');
5
+ var _commonjsHelpers1789f0cf = require('./_commonjsHelpers-1789f0cf-BJu3ubxk.js');
6
+ require('react');
7
+
8
+ var dayjs_min = {exports: {}};
9
+
10
+ (function (module, exports) {
11
+ !function(t,e){module.exports=e();}(_commonjsHelpers1789f0cf.commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,true),this.parse(t),this.$x=this.$x||t.x||{},this[p]=true;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,false)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case "YY":return String(e.$y).slice(-2);case "YYYY":return b.s(e.$y,4,"0");case "M":return a+1;case "MM":return b.s(a+1,2,"0");case "MMM":return h(n.monthsShort,a,c,3);case "MMMM":return h(c,a);case "D":return e.$D;case "DD":return b.s(e.$D,2,"0");case "d":return String(e.$W);case "dd":return h(n.weekdaysMin,e.$W,o,2);case "ddd":return h(n.weekdaysShort,e.$W,o,3);case "dddd":return o[e.$W];case "H":return String(s);case "HH":return b.s(s,2,"0");case "h":return d(1);case "hh":return d(2);case "a":return $(s,u,true);case "A":return $(s,u,false);case "m":return String(u);case "mm":return b.s(u,2,"0");case "s":return String(e.$s);case "ss":return b.s(e.$s,2,"0");case "SSS":return b.s(e.$ms,3,"0");case "Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,true);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=true),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
12
+ }(dayjs_min));
13
+
14
+ const dayjs = dayjs_min.exports;
15
+
16
+ var customParseFormat$1 = {exports: {}};
17
+
18
+ (function (module, exports) {
19
+ !function(e,t){module.exports=t();}(_commonjsHelpers1789f0cf.commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d/,r=/\d\d/,i=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,s={},a=function(e){return (e=+e)+(e>68?1900:2e3)};var f=function(e){return function(t){this[e]=+t;}},h=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],u=function(e){var t=s[e];return t&&(t.indexOf?t:t.s.concat(t.f))},d=function(e,t){var n,r=s.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},c={A:[o,function(e){this.afternoon=d(e,false);}],a:[o,function(e){this.afternoon=d(e,true);}],Q:[n,function(e){this.month=3*(e-1)+1;}],S:[n,function(e){this.milliseconds=100*+e;}],SS:[r,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[i,f("seconds")],ss:[i,f("seconds")],m:[i,f("minutes")],mm:[i,f("minutes")],H:[i,f("hours")],h:[i,f("hours")],HH:[i,f("hours")],hh:[i,f("hours")],D:[i,f("day")],DD:[r,f("day")],Do:[o,function(e){var t=s.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],w:[i,f("week")],ww:[r,f("week")],M:[i,f("month")],MM:[r,f("month")],MMM:[o,function(e){var t=u("months"),n=(u("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[o,function(e){var t=u("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,f("year")],YY:[r,function(e){this.year=a(e);}],YYYY:[/\d{4}/,f("year")],Z:h,ZZ:h};function l(n){var r,i;r=n,i=s&&s.formats;for(var o=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=o.length,f=0;f<a;f+=1){var h=o[f],u=c[h],d=u&&u[0],l=u&&u[1];o[f]=l?{regex:d,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=o[n];if("string"==typeof i)r+=i.length;else {var s=i.regex,f=i.parser,h=e.slice(r),u=s.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=true,e&&e.parseTwoDigitYear&&(a=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,o=e.args;this.$u=r;var a=o[1];if("string"==typeof a){var f=true===o[2],h=true===o[3],u=f||h,d=o[2];h&&(d=o[2]),s=this.$locale(),!f&&d&&(s=n.Ls[d]),this.$d=function(e,t,n,r){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var i=l(t)(e),o=i.year,s=i.month,a=i.day,f=i.hours,h=i.minutes,u=i.seconds,d=i.milliseconds,c=i.zone,m=i.week,M=new Date,Y=a||(o||s?1:M.getDate()),p=o||M.getFullYear(),v=0;o&&!s||(v=s>0?s-1:M.getMonth());var D,w=f||0,g=h||0,y=u||0,L=d||0;return c?new Date(Date.UTC(p,v,Y,w,g,y,L+60*c.offset*1e3)):n?new Date(Date.UTC(p,v,Y,w,g,y,L)):(D=new Date(p,v,Y,w,g,y,L),m&&(D=r(D).week(m).toDate()),D)}catch(e){return new Date("")}}(t,a,r,n),this.init(),d&&true!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),s={};}else if(a instanceof Array)for(var c=a.length,m=1;m<=c;m+=1){o[1]=a[m-1];var M=n.apply(this,o);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===c&&(this.$d=new Date(""));}else i.call(this,e);};}}));
20
+ }(customParseFormat$1));
21
+
22
+ const customParseFormat = customParseFormat$1.exports;
23
+
24
+ var utc$1 = {exports: {}};
25
+
26
+ (function (module, exports) {
27
+ !function(t,i){module.exports=i();}(_commonjsHelpers1789f0cf.commonjsGlobal,(function(){var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:true,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:true});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:false})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=true),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t);};var r=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds();}else r.call(this);};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){ void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s,o=this;if(f)return o.$offset=u,o.$u=0===s,o;if(0!==s){var r=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(u+r,t)).$offset=u,o.$x.$localOffset=r;}else o=this.utc();return o};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return !!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return "s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)};}}));
28
+ }(utc$1));
29
+
30
+ const utc = utc$1.exports;
31
+
32
+ var weekOfYear$1 = {exports: {}};
33
+
34
+ (function (module, exports) {
35
+ !function(e,t){module.exports=t();}(_commonjsHelpers1789f0cf.commonjsGlobal,(function(){var e="week",t="year";return function(i,n,r){var f=n.prototype;f.week=function(i){if(void 0===i&&(i=null),null!==i)return this.add(7*(i-this.week()),"day");var n=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var f=r(this).startOf(t).add(1,t).date(n),s=r(this).endOf(e);if(f.isBefore(s))return 1}var a=r(this).startOf(t).date(n).startOf(e).subtract(1,"millisecond"),o=this.diff(a,e,true);return o<0?r(this).startOf("week").week():Math.ceil(o)},f.weeks=function(e){return void 0===e&&(e=null),this.week(e)};}}));
36
+ }(weekOfYear$1));
37
+
38
+ const weekOfYear = weekOfYear$1.exports;
39
+
40
+ dayjs.extend(customParseFormat);
41
+ dayjs.extend(utc);
42
+ dayjs.extend(weekOfYear);
43
+ /**
44
+ * Formats a date to a string according to the format
45
+ * @param {Date} date - Date to format
46
+ * @returns {string} Formatted date
47
+ * @param {Object} options - Additional options
48
+ * @param {string} options.dateFormat - Date format (ex: 'YYYY-MM-DD', 'DD-MM-YYYY', etc.)
49
+ */
50
+ function formatDate(date, options) {
51
+ if (!date)
52
+ return '';
53
+ const isUTCMode = options.dateFormat.includes('Z');
54
+ const isISO8601Format = options.dateFormat === 'YYYY-MM-DD[T]HH:mm:ss[Z]';
55
+ // Special case for ISO 8601
56
+ if (isISO8601Format) {
57
+ // For the ISO 8601 format, use directly toISOString() which is standard
58
+ return date.toISOString();
59
+ }
60
+ // If the format is "Ticks", convert the time to C# ticks
61
+ if (options.dateFormat === 'Ticks') {
62
+ const ticks = date.getTime() * 10000 + 621355968000000000;
63
+ return ticks.toString();
64
+ }
65
+ // If the format is "X" (Unix Seconds)
66
+ if (options.dateFormat === 'X') {
67
+ return dayjs(date).unix().toString();
68
+ }
69
+ // If the format is "x" (Unix Milliseconds)
70
+ if (options.dateFormat === 'x') {
71
+ return date.getTime().toString();
72
+ }
73
+ // Otherwise, format according to the mode (UTC or local)
74
+ return isUTCMode
75
+ ? dayjs(date).utc().format(options.dateFormat)
76
+ : dayjs(date).format(options.dateFormat);
77
+ }
78
+ /**
79
+ * Checks if two dates are identical
80
+ * @param {Date | null} date - First date
81
+ * @param {Date | null} compareDate - Second date
82
+ * @param {Object} options - Additional options
83
+ * @param {boolean} options.isUTCMode - Whether the dates are in UTC mode
84
+ * @returns {boolean} true if the dates are identical
85
+ */
86
+ function isSameDate(date, compareDate, options) {
87
+ if (!date || !compareDate)
88
+ return false;
89
+ if (options.isUTCMode) {
90
+ return (date.getUTCFullYear() === compareDate.getUTCFullYear() &&
91
+ date.getUTCMonth() === compareDate.getUTCMonth() &&
92
+ date.getUTCDate() === compareDate.getUTCDate());
93
+ }
94
+ else {
95
+ return (date.getFullYear() === compareDate.getFullYear() &&
96
+ date.getMonth() === compareDate.getMonth() &&
97
+ date.getDate() === compareDate.getDate());
98
+ }
99
+ }
100
+ /**
101
+ * Checks if a date is identical or before another date
102
+ * @param {Date} date - Date to check
103
+ * @param {Date} compareDate - Reference date
104
+ * @param {Object} options - Additional options
105
+ * @param {boolean} options.isUTCMode - Whether the dates are in UTC mode
106
+ * @returns {boolean} true if `date` <= `compareDate`
107
+ */
108
+ function isSameOrBefore(date, compareDate, options) {
109
+ if (!date || !compareDate)
110
+ return false;
111
+ if (options.isUTCMode) {
112
+ return (date.getUTCFullYear() < compareDate.getUTCFullYear() ||
113
+ (date.getUTCFullYear() === compareDate.getUTCFullYear() &&
114
+ date.getUTCMonth() < compareDate.getUTCMonth()) ||
115
+ (date.getUTCFullYear() === compareDate.getUTCFullYear() &&
116
+ date.getUTCMonth() === compareDate.getUTCMonth() &&
117
+ date.getUTCDate() <= compareDate.getUTCDate()));
118
+ }
119
+ else {
120
+ return (date.getFullYear() < compareDate.getFullYear() ||
121
+ (date.getFullYear() === compareDate.getFullYear() &&
122
+ date.getMonth() < compareDate.getMonth()) ||
123
+ (date.getFullYear() === compareDate.getFullYear() &&
124
+ date.getMonth() === compareDate.getMonth() &&
125
+ date.getDate() <= compareDate.getDate()));
126
+ }
127
+ }
128
+ /**
129
+ * Checks if a date is identical or after another date
130
+ * @param {Date} date - Date to check
131
+ * @param {Date} compareDate - Reference date
132
+ * @param {Object} options - Additional options
133
+ * @param {boolean} options.isUTCMode - Whether the dates are in UTC mode
134
+ * @returns {boolean} true if `date` >= `compareDate`
135
+ */
136
+ function isSameOrAfter(date, compareDate, options) {
137
+ if (!date || !compareDate)
138
+ return false;
139
+ if (options.isUTCMode) {
140
+ return (date.getUTCFullYear() > compareDate.getUTCFullYear() ||
141
+ (date.getUTCFullYear() === compareDate.getUTCFullYear() &&
142
+ date.getUTCMonth() > compareDate.getUTCMonth()) ||
143
+ (date.getUTCFullYear() === compareDate.getUTCFullYear() &&
144
+ date.getUTCMonth() === compareDate.getUTCMonth() &&
145
+ date.getUTCDate() >= compareDate.getUTCDate()));
146
+ }
147
+ else {
148
+ return (date.getFullYear() > compareDate.getFullYear() ||
149
+ (date.getFullYear() === compareDate.getFullYear() &&
150
+ date.getMonth() > compareDate.getMonth()) ||
151
+ (date.getFullYear() === compareDate.getFullYear() &&
152
+ date.getMonth() === compareDate.getMonth() &&
153
+ date.getDate() >= compareDate.getDate()));
154
+ }
155
+ }
156
+ /**
157
+ * Calculates the ISO week number
158
+ * @param {Date} date - Date to calculate
159
+ * @returns {number} Week number
160
+ */
161
+ function getWeekNumber(date) {
162
+ const startOfYear = new Date(date.getFullYear(), 0, 1);
163
+ const pastDaysOfYear = (date.getTime() - startOfYear.getTime()) / 86400000;
164
+ return Math.ceil((pastDaysOfYear + startOfYear.getDay() + 1) / 7);
165
+ }
166
+ /**
167
+ * Convert a date string/Date to a Date without timezone offset
168
+ * @param {string | Date} dateInput - Date under string or Date object form
169
+ * @param {string} dateFormat - Date format (ex: 'YYYY-MM-DD', 'DD-MM-YYYY', etc.)
170
+ * @returns {Date} Date in Date form without timezone offset
171
+ */
172
+ function parseDate(dateInput, dateFormat) {
173
+ if (dateInput instanceof Date)
174
+ return dateInput;
175
+ const isUTCMode = dateFormat.includes('Z');
176
+ // Attempt to automatically detect ISO 8601 format (generated by toISOString())
177
+ // The regex checks the standard ISO format: YYYY-MM-DDTHH:mm:ss.sssZ
178
+ if (typeof dateInput === 'string' &&
179
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(dateInput)) {
180
+ try {
181
+ const parsedDate = new Date(dateInput);
182
+ if (!isNaN(parsedDate.getTime())) {
183
+ return parsedDate;
184
+ }
185
+ }
186
+ catch (error) {
187
+ // If it fails, continue with other methods
188
+ console.error('Error parsing ISO date:', error);
189
+ }
190
+ }
191
+ // Handling Unix Seconds ("X") formats
192
+ if (dateFormat === 'X') {
193
+ const unixSeconds = Number(dateInput);
194
+ if (isNaN(unixSeconds))
195
+ return null;
196
+ return isUTCMode
197
+ ? dayjs.unix(unixSeconds).utc().toDate()
198
+ : dayjs.unix(unixSeconds).toDate();
199
+ }
200
+ // Handling Unix Milliseconds ("x") formats
201
+ if (dateFormat === 'x') {
202
+ const unixMilliseconds = Number(dateInput);
203
+ if (isNaN(unixMilliseconds))
204
+ return null;
205
+ return isUTCMode
206
+ ? dayjs(unixMilliseconds).utc().toDate()
207
+ : dayjs(unixMilliseconds).toDate();
208
+ }
209
+ // Handling C# Ticks format
210
+ if (dateFormat === 'Ticks') {
211
+ const ticks = Number(dateInput);
212
+ if (isNaN(ticks))
213
+ return null;
214
+ // Conversion of .NET ticks to milliseconds since Unix epoch
215
+ const unixMilliseconds = (ticks - 621355968000000000) / 10000;
216
+ return isUTCMode
217
+ ? dayjs(unixMilliseconds).utc().toDate()
218
+ : dayjs(unixMilliseconds).toDate();
219
+ }
220
+ // For all other formats, use customParseFormat in strict mode
221
+ let parsed;
222
+ if (isUTCMode) {
223
+ parsed = dayjs.utc(dateInput, dateFormat, true);
224
+ }
225
+ else {
226
+ parsed = dayjs(dateInput, dateFormat, true);
227
+ }
228
+ if (!parsed.isValid()) {
229
+ console.error(`Parsing error:`, {
230
+ dateInput,
231
+ dateFormat: dateFormat,
232
+ });
233
+ return null;
234
+ }
235
+ return parsed.toDate();
236
+ }
237
+
238
+ const nvCalendarCss = "nv-calendar{display:block}.datepicker-root{display:flex;justify-content:center;align-items:flex-start;width:auto}.datepicker-container{font-family:system-ui, sans-serif;display:flex;flex-direction:column;align-items:stretch;background:var(--components-calendar-background);border-radius:var(--calendar-radius);padding:var(--calendar-padding);box-shadow:0px var(--shadow-y-axis-md-1) var(--shadow-blur-md-1) var(--shadow-spread-md, 0) var(--shadow-color-opacity-0), 0px var(--shadow-y-axis-md-2) var(--shadow-blur-md-2) var(--shadow-spread-md, 0) var(--shadow-color-opacity-2);border:1px solid var(--components-calendar-border);width:auto;max-width:100%}.datepicker-container-single{max-width:300px}.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-left),.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-container-single:has(.shortcuts-placement-left),.datepicker-container-single:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-wrapper{display:flex;justify-content:center;align-items:flex-start;gap:var(--calendar-gap-x);width:auto;overflow-x:hidden}.datepicker-wrapper::-webkit-scrollbar{width:6px;height:6px}.datepicker-wrapper::-webkit-scrollbar-track{background-color:var(--color-level-10-background);border-radius:9999px}.datepicker-wrapper::-webkit-scrollbar-thumb{background-color:var(--color-gray-200);border-radius:9999px}.datepicker-wrapper.single{justify-content:center}.calendar-container{display:flex;flex-direction:column;align-items:center;padding:var(--calendar-padding);width:auto;position:relative}.calendar-separator{width:1px;background:var(--components-calendar-border);height:auto;min-height:100%;margin:0 10px}.header{display:flex;justify-content:start;align-items:center;margin-bottom:var(--calendar-header-margin-bottom);width:100%}.header nv-iconbutton{width:var(--calendar-header-button-size);height:var(--calendar-header-button-size)}.nav-buttons{display:flex;gap:var(--spacing-0);margin-left:auto}.nav-left{order:-1}.date-controls{display:flex;gap:var(--spacing-1);align-items:center;min-height:34px;justify-content:center}.datepicker-container-single .date-controls{justify-content:flex-start}.datepicker-container:not(.datepicker-container-single) .date-controls{justify-content:start;flex-grow:1}.date-controls .month-select,.date-controls .year-input{background:transparent !important}.calendar-wrapper:nth-child(n+2) .datepicker-container{margin-left:42px}.calendar-grid{display:grid;grid-template-columns:auto 1fr;column-gap:var(--calendar-weeks-calendar-gap-x);position:relative}.calendar-grid.slide-left{animation:slideLeft 0.3s ease-out}.calendar-grid.slide-right{animation:slideRight 0.3s ease-out}.week-numbers{display:grid;grid-template-rows:var(--calendar-cell-size) repeat(6, var(--calendar-cell-size));background:var(--components-calendar-weeks-background);color:var(--components-calendar-weeks-text);border-radius:var(--calendar-weeks-radius);width:var(--calendar-weeks-size);row-gap:var(--calendar-grid-gap-y)}.week-numbers .clickable{cursor:pointer}.week-numbers .clickable:hover{background-color:var(--components-calendar-weeks-background-hover);color:var(--components-calendar-weeks-text-hover);border-radius:var(--calendar-radius)}.week-header,.week-number{display:grid;place-items:center;font-size:var(--calendar-cell-font-size)}.week-header{font-weight:700;color:var(--components-calendar-weeks-text)}.week-number{color:var(--components-calendar-cell-text)}.days-container{display:grid;grid-template-rows:auto 1fr;row-gap:var(--calendar-grid-gap-y)}.days-header{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));height:var(--calendar-cell-size)}.day-header{display:grid;place-items:center;font-size:var(--calendar-cell-font-size);color:var(--components-calendar-cell-text)}.days-grid{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));grid-template-rows:repeat(6, var(--calendar-cell-size));animation:fadeIn 0.2s ease-in;row-gap:var(--calendar-grid-gap-y);z-index:0}.day{display:grid;place-items:center;width:var(--calendar-cell-size);height:var(--calendar-cell-size);font-size:var(--calendar-cell-font-size);border-radius:var(--calendar-cell-radius);cursor:pointer;border:none;background:transparent;transition:all 0.2s ease;text-align:center;animation:scaleIn 0.2s ease-out}.day:hover:not(.disabled,.empty,.selected){background:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}.day.selected,.day.selected:hover .day.is-today.selected,.day.is-today.selected:hover{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected) !important}.day.disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.day.outside-month{color:var(--components-calendar-cell-text);opacity:var(--opacity-disabled)}.day.outside-month.selected{opacity:1 !important;color:var(--components-calendar-cell-text-selected)}.day.outside-month.in-range{opacity:0.5 !important;background-color:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range)}.day.outside-month.in-range:hover{opacity:0.7 !important;background-color:var(--components-calendar-cell-background-in-range)}.day.in-range{background:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range);border-radius:0;position:relative}.day.range-start,.day.range-start:focus,.day.range-start:hover,.day.range-end,.day.range-end:focus,.day.range-end:hover{background-color:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected) !important}.day.range-start,.day.range-end,.day.range-start.is-today,.day.range-end.is-today{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected);position:relative;border-radius:var(--radius-rounded-full)}.day.range-start:hover,.day.range-end:hover,.day.range-start.is-today:hover,.day.range-end.is-today:hover{color:var(--components-calendar-cell-text-today)}.day.range-start:before,.day.range-end:before,.day.range-start.is-today:before,.day.range-end.is-today:before{content:\"\";position:absolute;bottom:0;left:0;right:0;top:0;z-index:-1;background-color:var(--components-calendar-cell-background-in-range);border-radius:var(--radius-rounded-full);width:auto;height:auto}.day.range-start:has(~.range-end):before,.day.range-start:has(+.in-range):before{border-top-right-radius:0;border-bottom-right-radius:0}.day.range-end:before{border-top-left-radius:0 !important;border-bottom-left-radius:0 !important}.day.outside-month.range-start,.day.outside-month.range-end{opacity:1 !important;background:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected)}.day.is-today{font-weight:700;position:relative;color:var(--components-calendar-cell-text-today)}.day.is-today.range-start,.day.is-today.range-end{color:var(--components-calendar-cell-text-selected)}.day.is-today.range-start:hover,.day.is-today.range-end:hover{color:var(--components-calendar-cell-text-today)}.day.is-today::after{content:\"\";position:absolute;bottom:var(--spacing-1);left:50%;transform:translateX(-50%);width:var(--calendar-cell-dot-size);height:var(--calendar-cell-dot-size);background-color:currentColor;border-radius:50%}.day.is-today.selected::after{color:var(--components-calendar-cell-text-selected)}.day.is-today.selected::after::after{background-color:var(--components-calendar-cell-dot-selected)}.calendar-footer{display:flex;gap:var(--spacing-1);justify-content:flex-start;width:100%;flex-wrap:wrap}.footer-placement-left{justify-content:flex-start}.footer-placement-right{justify-content:flex-end}.footer-placement-center{justify-content:center}.datepicker-controls{display:flex;flex-direction:column;border-top:1px solid var(--components-calendar-border);padding:var(--calendar-controls-padding-top) var(--calendar-padding) var(--calendar-padding);gap:var(--calendar-grid-gap-y);margin-top:var(--calendar-controls-margin-top)}.datepicker-actions{display:flex;justify-content:flex-end;gap:var(--spacing-1);width:100%}.datepicker-actions slot-fb{display:contents !important}.calendar-footer+.datepicker-actions{margin-top:0}.shortcuts-placement-left,.shortcuts-placement-right{display:flex;flex-direction:column;gap:var(--spacing-1);margin-top:var(--spacing-4)}.shortcuts-placement-left{align-items:flex-end}.shortcuts-placement-right{align-items:flex-start}@keyframes slideLeft{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}@keyframes slideRight{from{opacity:0;transform:translateX(-20px)}to{opacity:1;transform:translateX(0)}}@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes scaleIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}";
239
+ const NvCalendarStyle0 = nvCalendarCss;
240
+
241
+ const NvCalendar = class {
242
+ constructor(hostRef) {
243
+ index.registerInstance(this, hostRef);
244
+ this.singleDateChange = index.createEvent(this, "singleDateChange");
245
+ this.rangeDateChange = index.createEvent(this, "rangeDateChange");
246
+ /****************************************************************************/
247
+ //#region PROPERTIES
248
+ /**
249
+ * First day of the week (0 = Sunday, 1 = Monday, etc.)
250
+ * @default 0
251
+ */
252
+ this.firstDayOfWeek = 0;
253
+ /**
254
+ * Number of calendars to display
255
+ * @default 1
256
+ */
257
+ this.numberOfCalendars = 1;
258
+ /**
259
+ * Locale for date formatting
260
+ * @default 'en-BE'
261
+ */
262
+ this.locale = 'en-BE';
263
+ /**
264
+ * Date format (ex: 'YYYY-MM-DD', 'DD-MM-YYYY', etc.)
265
+ * @default 'YYYY-MM-DD'
266
+ * @note If the date format is in UTC mode, the date will be displayed in UTC time.
267
+ * @note If the date format is not in UTC mode, the date will be displayed in the local time.
268
+ */
269
+ this.dateFormat = 'YYYY-MM-DD';
270
+ /**
271
+ * Footer placement
272
+ * @default 'bottom'
273
+ */
274
+ this.shortcutsPlacement = 'bottom';
275
+ /**
276
+ * Selection type (single date or date range)
277
+ * @default 'single'
278
+ */
279
+ this.selectionType = 'single';
280
+ /**
281
+ * Show action buttons
282
+ */
283
+ this.showActions = false;
284
+ /** Cache for parsed disabled dates */
285
+ this.parsedDisabledDates = [];
286
+ //#endregion PROPERTIES
287
+ /****************************************************************************/
288
+ //#region STATE
289
+ this.currentDate = null;
290
+ this.selectedDate = null;
291
+ this.startDate = null;
292
+ this.endDate = null;
293
+ /** List of formatted months for the selector */
294
+ this.months = [];
295
+ /**
296
+ * Change the displayed month
297
+ * @param {number} offset - Month offset (-1 for previous, 1 for next)
298
+ */
299
+ this.changeMonth = (offset) => {
300
+ const newDate = new Date(this.currentDate);
301
+ // Ensure we only move by one month at a time
302
+ newDate.setUTCMonth(newDate.getUTCMonth() + offset);
303
+ // Add the appropriate animation class
304
+ const containers = this.el.querySelectorAll('.calendar-grid');
305
+ containers.forEach(container => {
306
+ // Remove existing animation classes
307
+ container.classList.remove('slide-left', 'slide-right');
308
+ // Add the new animation class
309
+ const animationClass = offset > 0 ? 'slide-left' : 'slide-right';
310
+ container.classList.add(animationClass);
311
+ // Remove the class after the animation
312
+ setTimeout(() => {
313
+ container.classList.remove(animationClass);
314
+ }, 300); // 300ms corresponds to $slide-duration in the SCSS
315
+ });
316
+ this.currentDate = newDate;
317
+ };
318
+ /**
319
+ * Handles date selection based on the mode
320
+ * @param {Date} date - Selected date
321
+ */
322
+ this.handleDateSelection = (date) => {
323
+ if (this.isDateDisabled(date)) {
324
+ return;
325
+ }
326
+ if (this.selectionType === 'single') {
327
+ this.handleSingleSelection(date);
328
+ }
329
+ else {
330
+ this.handleRangeSelection(date);
331
+ }
332
+ };
333
+ /**
334
+ * Handles single date selection
335
+ * @param {Date} date - Selected date
336
+ */
337
+ this.handleSingleSelection = (date) => {
338
+ if (!date)
339
+ return;
340
+ const formattedDate = formatDate(date, { dateFormat: this.dateFormat });
341
+ this.selectedDate = date;
342
+ this.singleDateChange.emit(formattedDate);
343
+ };
344
+ /**
345
+ * Handles range date selection
346
+ * @param {Date} date - Selected date
347
+ */
348
+ this.handleRangeSelection = (date) => {
349
+ if (!this.startDate || (this.startDate && this.endDate)) {
350
+ this.startDate = date;
351
+ this.endDate = null;
352
+ }
353
+ else {
354
+ this.endDate = date;
355
+ if (this.startDate > this.endDate) {
356
+ [this.startDate, this.endDate] = [this.endDate, this.startDate];
357
+ }
358
+ this.rangeDateChange.emit({
359
+ start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
360
+ end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
361
+ });
362
+ }
363
+ };
364
+ /**
365
+ * Checks if a date is disabled.
366
+ * Disabled if:
367
+ * - The date is before min (if defined)
368
+ * - The date is after max (if defined)
369
+ * - The date is in the disabledDates array
370
+ * @param {Date} date - Date to check
371
+ * @returns {boolean} true if the date is disabled
372
+ */
373
+ this.isDateDisabled = (date) => {
374
+ if (!date)
375
+ return true;
376
+ // Minimum bound check
377
+ if (this.min) {
378
+ const minDate = parseDate(this.min, this.dateFormat);
379
+ if (minDate && date < minDate) {
380
+ return true;
381
+ }
382
+ }
383
+ // Maximum bound check
384
+ if (this.max) {
385
+ const maxDate = parseDate(this.max, this.dateFormat);
386
+ if (maxDate && date > maxDate) {
387
+ return true;
388
+ }
389
+ }
390
+ // Check disabled dates
391
+ return this.parsedDisabledDates.some(disabledDate => isSameDate(date, disabledDate, { isUTCMode: this.isUTCMode }));
392
+ };
393
+ /**
394
+ * Checks if a date is in the selected range
395
+ * @param {Date} date - Date to check
396
+ * @returns {boolean} true if the date is in the range
397
+ */
398
+ this.isDateInRange = (date) => {
399
+ if (!date || !this.startDate || !this.endDate)
400
+ return false;
401
+ const checkDate = parseDate(date, this.dateFormat);
402
+ const startDate = parseDate(this.startDate, this.dateFormat);
403
+ const endDate = parseDate(this.endDate, this.dateFormat);
404
+ // Verify if startDate and endDate are valid
405
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
406
+ return false;
407
+ }
408
+ // Verify that startDate is before endDate (additional security)
409
+ if (startDate > endDate)
410
+ return false;
411
+ // Comparison based only on the date (year, month, day)
412
+ return (isSameOrAfter(checkDate, startDate, { isUTCMode: this.isUTCMode }) &&
413
+ isSameOrBefore(checkDate, endDate, { isUTCMode: this.isUTCMode }));
414
+ };
415
+ /**
416
+ * Retrieves the localized day names
417
+ * @returns {string[]} Array of short day names
418
+ */
419
+ this.getDayNames = () => {
420
+ // If we have custom day names for this locale
421
+ if (constantsB97e736d.CUSTOM_DAY_NAMES[this.locale]) {
422
+ const days = [...constantsB97e736d.CUSTOM_DAY_NAMES[this.locale]];
423
+ // Reorganize the days based on the first day of the week
424
+ const firstDays = days.slice(0, this.firstDayOfWeek);
425
+ const remainingDays = days.slice(this.firstDayOfWeek);
426
+ return [...remainingDays, ...firstDays];
427
+ }
428
+ // Otherwise, use the default behavior
429
+ const formatter = new Intl.DateTimeFormat(this.locale, {
430
+ weekday: 'short',
431
+ });
432
+ const days = [...Array(7)].map((_, i) => formatter.format(new Date(2023, 0, i + 1)).toUpperCase());
433
+ // Reorganize the days based on the first day of the week
434
+ const firstDays = days.slice(0, this.firstDayOfWeek);
435
+ const remainingDays = days.slice(this.firstDayOfWeek);
436
+ return [...remainingDays, ...firstDays];
437
+ };
438
+ /**
439
+ * Generates the days of the current month
440
+ * @param {number} offset - Month offset (0 by default)
441
+ * @param {number} totalCalendars - Number of calendars to display (1 by default)
442
+ * @returns {Array<{ dayOfMonth: number | null, date: Date | null, isSelected: boolean, isDisabled: boolean }>} Array of formatted days
443
+ */
444
+ this.getDaysInMonth = (offset = 0, totalCalendars = 1) => {
445
+ const year = this.currentDate.getUTCFullYear();
446
+ const month = this.currentDate.getUTCMonth() + offset;
447
+ const firstDay = new Date(Date.UTC(year, month, 1));
448
+ const lastDay = new Date(Date.UTC(year, month + 1, 0));
449
+ const days = [];
450
+ // Correct calculation of offset for previous month days
451
+ // Use getUTCDay to stay consistent with UTC timezone
452
+ const dayOfWeekIndex = firstDay.getUTCDay(); // 0 = Sunday, 1 = Monday, etc.
453
+ // Adjust based on firstDayOfWeek (if week starts on Monday, offset is different)
454
+ const offsetDays = (dayOfWeekIndex - this.firstDayOfWeek + 7) % 7;
455
+ // Add the days of the previous month for the first calendar
456
+ if (offset === 0 && offsetDays > 0) {
457
+ const prevMonthLastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
458
+ for (let i = offsetDays; i > 0; i--) {
459
+ const date = new Date(Date.UTC(year, month - 1, prevMonthLastDay - i + 1));
460
+ days.push({
461
+ dayOfMonth: date.getUTCDate(),
462
+ date,
463
+ isCurrentMonth: false,
464
+ isDisabled: this.isDateDisabled(date),
465
+ });
466
+ }
467
+ }
468
+ // Add the days of the current month
469
+ for (let i = 1; i <= lastDay.getUTCDate(); i++) {
470
+ const date = new Date(Date.UTC(year, month, i));
471
+ days.push({
472
+ dayOfMonth: i,
473
+ date,
474
+ isCurrentMonth: true,
475
+ isDisabled: this.isDateDisabled(date),
476
+ });
477
+ }
478
+ // Add the days of the next month only for the last calendar
479
+ if (offset === totalCalendars - 1) {
480
+ const nextMonthDaysNeeded = 7 - (days.length % 7 || 7);
481
+ for (let i = 1; i <= nextMonthDaysNeeded; i++) {
482
+ const date = new Date(Date.UTC(year, month + 1, i));
483
+ days.push({
484
+ dayOfMonth: i,
485
+ date,
486
+ isCurrentMonth: false,
487
+ isDisabled: this.isDateDisabled(date),
488
+ });
489
+ }
490
+ }
491
+ return days;
492
+ };
493
+ /** Initializes the list of formatted months according to the locale */
494
+ this.initializeMonths = () => {
495
+ // If we have custom month names for this locale
496
+ if (constantsB97e736d.CUSTOM_MONTH_NAMES[this.locale]) {
497
+ this.months = constantsB97e736d.CUSTOM_MONTH_NAMES[this.locale].map((label, value) => ({
498
+ value,
499
+ label,
500
+ }));
501
+ return;
502
+ }
503
+ // Otherwise, use the default behavior
504
+ const formatter = new Intl.DateTimeFormat(this.locale, { month: 'short' });
505
+ this.months = Array.from({ length: 12 }, (_, i) => ({
506
+ value: i,
507
+ label: formatter.format(new Date(2000, i, 1)).toUpperCase(),
508
+ }));
509
+ };
510
+ /**
511
+ * Retrieves the localized abbreviation for "week"
512
+ * @returns {string} Localized abbreviation for "week"
513
+ */
514
+ this.getLocalizedWeekText = () => {
515
+ return constantsB97e736d.WEEK_ABBREVIATIONS[this.locale] || 'W';
516
+ };
517
+ /**
518
+ * Handles month change in the selector
519
+ * @param {Event} event - Month change event
520
+ * @param {number} calendarOffset - Calendar offset (0 by default)
521
+ */
522
+ this.handleMonthChange = (event, calendarOffset = 0) => {
523
+ const select = event.target;
524
+ const selectedMonth = parseInt(select.value, 10);
525
+ const currentMonth = this.currentDate.getUTCMonth();
526
+ // Calculate the difference considering the calendar offset
527
+ const monthDiff = selectedMonth - ((currentMonth + calendarOffset) % 12);
528
+ const newDate = new Date(this.currentDate);
529
+ newDate.setUTCMonth(newDate.getUTCMonth() + monthDiff);
530
+ this.currentDate = newDate;
531
+ };
532
+ /**
533
+ * Handles year change in the numeric entry
534
+ * @param {Event} event - Year change event
535
+ * @param {number} calendarOffset - Calendar offset (0 by default)
536
+ */
537
+ this.handleYearChange = (event, calendarOffset = 0) => {
538
+ const input = event.target;
539
+ const year = parseInt(input.value, 10);
540
+ if (!isNaN(year) && year >= 1900 && year <= 2100) {
541
+ const newDate = new Date(this.currentDate);
542
+ newDate.setUTCFullYear(year);
543
+ newDate.setUTCMonth(newDate.getUTCMonth() + calendarOffset);
544
+ this.currentDate = newDate;
545
+ }
546
+ };
547
+ /**
548
+ * Handles week selection
549
+ * @param {Date[]} weekDays - Selected week days
550
+ * @param {number} calendarIndex - Calendar index from which the selection is made
551
+ */
552
+ this.handleWeekSelection = (weekDays, calendarIndex) => {
553
+ if (this.selectionType !== 'range')
554
+ return;
555
+ const allDays = this.getDaysInMonth(calendarIndex, this.numberOfCalendars);
556
+ const weekStart = weekDays[0];
557
+ const weekEnd = weekDays[weekDays.length - 1];
558
+ if (!weekStart || !weekEnd)
559
+ return;
560
+ const selectedWeekDays = allDays.filter(day => day.date && day.date >= weekStart && day.date <= weekEnd);
561
+ const validDays = selectedWeekDays.filter(day => !this.isDateDisabled(day.date));
562
+ if (validDays.length > 0) {
563
+ this.startDate = validDays[0].date;
564
+ this.endDate = validDays[validDays.length - 1].date;
565
+ this.rangeDateChange.emit({
566
+ start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
567
+ end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
568
+ });
569
+ }
570
+ };
571
+ /**
572
+ * Checks if a date corresponds to today
573
+ * @param {Date} date - Date to check
574
+ * @returns {boolean} true if the date is today
575
+ */
576
+ this.isToday = (date) => {
577
+ const today = new Date();
578
+ return (date.getDate() === today.getDate() &&
579
+ date.getMonth() === today.getMonth() &&
580
+ date.getFullYear() === today.getFullYear());
581
+ };
582
+ /**
583
+ * Parse and cache the disabled dates
584
+ * @description Parse and cache the disabled dates
585
+ */
586
+ this.parseDisabledDates = () => {
587
+ if (!this.disabledDates) {
588
+ this.parsedDisabledDates = [];
589
+ return;
590
+ }
591
+ try {
592
+ this.parsedDisabledDates = this.disabledDates
593
+ .map(date => parseDate(date, this.dateFormat))
594
+ .filter(date => date !== null);
595
+ }
596
+ catch (error) {
597
+ console.error('Error parsing disabled dates:', error);
598
+ this.parsedDisabledDates = [];
599
+ }
600
+ };
601
+ /**
602
+ * Applies a shortcut selection
603
+ * @param {Object} shortcut - Shortcut to apply
604
+ * @param {string | Date} shortcut.singleValue - Selected date value
605
+ * @param {Object} shortcut.rangeValue - Start and end date values
606
+ * @param {string | Date} shortcut.rangeValue.start - Start date value
607
+ * @param {string | Date} shortcut.rangeValue.end - End date value
608
+ * @param {string} shortcut.label - Label
609
+ */
610
+ this.applyShortcut = (shortcut) => {
611
+ this.selectedDate = null;
612
+ this.startDate = null;
613
+ this.endDate = null;
614
+ if (shortcut.singleValue) {
615
+ const newDate = parseDate(shortcut.singleValue, this.dateFormat);
616
+ this.selectedDate = newDate;
617
+ this.singleDateChange.emit(formatDate(newDate, { dateFormat: this.dateFormat }));
618
+ this.singleValue = formatDate(newDate, { dateFormat: this.dateFormat });
619
+ if (!this.showActions) {
620
+ const event = new CustomEvent('closePopover', {
621
+ bubbles: true,
622
+ composed: true,
623
+ });
624
+ this.el.dispatchEvent(event);
625
+ }
626
+ this.forceCalendarUpdate(newDate);
627
+ }
628
+ else {
629
+ const start = parseDate(shortcut.rangeValue.start, this.dateFormat);
630
+ const end = parseDate(shortcut.rangeValue.end, this.dateFormat);
631
+ this.startDate = start;
632
+ this.endDate = end;
633
+ this.rangeDateChange.emit({
634
+ start: formatDate(start, { dateFormat: this.dateFormat }),
635
+ end: formatDate(end, { dateFormat: this.dateFormat }),
636
+ });
637
+ this.rangeValue = {
638
+ start: formatDate(start, { dateFormat: this.dateFormat }),
639
+ end: formatDate(end, { dateFormat: this.dateFormat }),
640
+ };
641
+ if (!this.showActions) {
642
+ const event = new CustomEvent('closePopover', {
643
+ bubbles: true,
644
+ composed: true,
645
+ });
646
+ this.el.dispatchEvent(event);
647
+ }
648
+ this.currentDate = start;
649
+ }
650
+ };
651
+ /**
652
+ * Method to force the complete calendar update
653
+ * @param {Date} newDate - Date to force
654
+ */
655
+ this.forceCalendarUpdate = newDate => {
656
+ this.currentDate = new Date(newDate);
657
+ };
658
+ /**
659
+ * Handles month change with an offset
660
+ * @param {number} direction - Direction (-1 for previous, 1 for next)
661
+ * @returns {Function} Change month handler
662
+ */
663
+ this.getChangeMonthHandler = (direction) => {
664
+ return () => this.changeMonth(direction);
665
+ };
666
+ /**
667
+ * Handles month change from an event (ex: dropdown)
668
+ * @param {number} offset - Month offset (0 by default)
669
+ * @returns {Function} Change month handler
670
+ */
671
+ this.getHandleMonthChange = (offset) => {
672
+ return (event) => this.handleMonthChange(event, offset);
673
+ };
674
+ /**
675
+ * Handles year change from an event (ex: dropdown)
676
+ * @param {number} offset - Year offset (0 by default)
677
+ * @returns {Function} Change year handler
678
+ */
679
+ this.getHandleYearChange = (offset) => {
680
+ return (event) => this.handleYearChange(event, offset);
681
+ };
682
+ /**
683
+ * Handles day click
684
+ * @param {Date} date - Date to handle
685
+ * @param {boolean} isDisabled - Whether the date is disabled
686
+ * @returns {Function} Day click handler
687
+ */
688
+ this.getDayClickHandler = (date, isDisabled) => {
689
+ return isDisabled ? undefined : () => this.handleDateSelection(date);
690
+ };
691
+ /**
692
+ * Handles shortcut selection
693
+ * @param {Object} shortcut - Shortcut to handle
694
+ * @param {string | Date} shortcut.singleValue - Selected date value
695
+ * @param {Object} shortcut.rangeValue - Start and end date values
696
+ * @param {string | Date} shortcut.rangeValue.start - Start date value
697
+ * @param {string | Date} shortcut.rangeValue.end - End date value
698
+ * @param {string} shortcut.label - Label
699
+ * @returns {Function} Shortcut selection handler
700
+ */
701
+ this.getShortcutHandler = (shortcut) => {
702
+ return () => this.applyShortcut(shortcut);
703
+ };
704
+ /**
705
+ * Handles week selection
706
+ * @param {Date[]} dates - Dates to handle
707
+ * @param {number} index - Calendar index
708
+ * @returns {Function} Week selection handler
709
+ */
710
+ this.getWeekSelectionHandler = (dates, index) => {
711
+ return () => {
712
+ if (this.selectionType === 'range') {
713
+ this.handleWeekSelection(dates, index);
714
+ }
715
+ };
716
+ };
717
+ /**
718
+ * Resets the current selection
719
+ */
720
+ this.resetSelection = () => {
721
+ if (this.selectionType === 'single') {
722
+ this.selectedDate = null;
723
+ this.singleValue = null;
724
+ this.singleDateChange.emit('');
725
+ }
726
+ else {
727
+ this.startDate = null;
728
+ this.endDate = null;
729
+ this.rangeValue = null;
730
+ this.rangeDateChange.emit({ start: '', end: '' });
731
+ }
732
+ };
733
+ /**
734
+ * Confirms the current selection
735
+ */
736
+ this.confirmSelection = () => {
737
+ if (this.selectionType === 'single' && this.selectedDate) {
738
+ const dateStr = formatDate(this.selectedDate, {
739
+ dateFormat: this.dateFormat,
740
+ });
741
+ this.singleDateChange.emit(dateStr);
742
+ this.singleValue = dateStr;
743
+ const event = new CustomEvent('closePopover', {
744
+ bubbles: true,
745
+ composed: true,
746
+ });
747
+ this.el.dispatchEvent(event);
748
+ }
749
+ else if (this.selectionType === 'range' &&
750
+ this.startDate &&
751
+ this.endDate) {
752
+ this.rangeDateChange.emit({
753
+ start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
754
+ end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
755
+ });
756
+ this.rangeValue = {
757
+ start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
758
+ end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
759
+ };
760
+ const event = new CustomEvent('closePopover', {
761
+ bubbles: true,
762
+ composed: true,
763
+ });
764
+ this.el.dispatchEvent(event);
765
+ }
766
+ };
767
+ //#endregion METHODS
768
+ /****************************************************************************/
769
+ //#region RENDER
770
+ /**
771
+ * Renders the header
772
+ * @param {number} offset - Month offset
773
+ * @param {number} index - Calendar index
774
+ * @returns {JSX.Element} Header
775
+ * @description Renders the header of the calendar
776
+ */
777
+ this.renderHeader = (offset, index$1) => {
778
+ return (index.h("div", { class: "header" }, this.numberOfCalendars > 1 && index$1 === 0 && (index.h("nv-iconbutton", { class: "nav-left", emphasis: "lower", name: "chevron-left", onClick: this.getChangeMonthHandler(-1) })), index.h("div", { class: "date-controls" }, index.h("select", { class: "month-select mr-4", onChange: this.getHandleMonthChange(offset) }, this.months.map(month => (index.h("option", { key: month.value, value: month.value, selected: month.value === (this.currentDate.getUTCMonth() + offset) % 12 }, month.label)))), index.h("input", { type: "number", class: "year-input", min: "1950", max: "2100", value: this.currentDate.getUTCFullYear() +
779
+ Math.floor((this.currentDate.getUTCMonth() + offset) / 12), onChange: this.getHandleYearChange(offset) })), this.numberOfCalendars === 1 && (index.h("div", { class: "nav-buttons" }, index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-left", onClick: this.getChangeMonthHandler(-1) }), index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-right", onClick: this.getChangeMonthHandler(1) }))), this.numberOfCalendars > 1 && index$1 === this.numberOfCalendars - 1 && (index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-right", onClick: this.getChangeMonthHandler(1), class: "nav-right" }))));
780
+ };
781
+ /**
782
+ * Renders the week numbers
783
+ * @param {Array<{date: Date}>} weeks - Weeks to render
784
+ * @param {number} index - Calendar index
785
+ * @returns {JSX.Element} Week numbers
786
+ * @description Renders the week numbers of the calendar
787
+ */
788
+ this.renderWeekNumbers = (
789
+ /** Weeks to render */
790
+ weeks,
791
+ /** Calendar index */
792
+ index$1) => {
793
+ return (index.h("div", { class: "week-numbers" }, index.h("div", { class: "week-header" }, this.getLocalizedWeekText()), weeks.map((week, weekIndex) => {
794
+ var _a;
795
+ const dates = week.map(d => d.date);
796
+ return (index.h("div", { class: `week-number ${this.selectionType === 'range' ? 'clickable' : ''}`, onClick: this.getWeekSelectionHandler(dates, index$1), key: `week-${weekIndex}` }, getWeekNumber(((_a = week.find(d => d.date)) === null || _a === void 0 ? void 0 : _a.date) || new Date())));
797
+ })));
798
+ };
799
+ this.renderDaysGrid = (
800
+ /** Days to render */
801
+ days) => {
802
+ return (index.h("div", { class: "days-grid" }, days.map(day => {
803
+ const date = day.date;
804
+ if (!date)
805
+ return null;
806
+ const isSelected = this.selectionType === 'single' &&
807
+ isSameDate(date, this.selectedDate, { isUTCMode: this.isUTCMode });
808
+ const isInRange = this.isDateInRange(date);
809
+ const isStart = isSameDate(date, this.startDate, {
810
+ isUTCMode: this.isUTCMode,
811
+ });
812
+ const isEnd = isSameDate(date, this.endDate, {
813
+ isUTCMode: this.isUTCMode,
814
+ });
815
+ const isToday = this.isToday(date);
816
+ const isOutsideMonth = !day.isCurrentMonth;
817
+ const dayClasses = [
818
+ 'day',
819
+ isSelected ? 'selected' : '',
820
+ isStart ? 'range-start' : '',
821
+ isEnd ? 'range-end' : '',
822
+ isInRange ? 'in-range' : '',
823
+ day.isDisabled ? 'disabled' : '',
824
+ isOutsideMonth ? 'outside-month' : '',
825
+ isToday ? 'is-today' : '',
826
+ ];
827
+ return (index.h("div", { class: dayClasses.filter(Boolean).join(' '), onClick: this.getDayClickHandler(date, day.isDisabled), "aria-disabled": day.isDisabled, key: `day-${date.toISOString()}` }, day.dayOfMonth));
828
+ })));
829
+ };
830
+ /**
831
+ * Renders the calendar
832
+ * @param {number} index - Calendar index
833
+ * @param {number} offset - Month offset
834
+ * @returns {JSX.Element} Calendar
835
+ * @description Renders the calendar of the calendar
836
+ */
837
+ this.renderCalendar = (
838
+ /** Calendar index */
839
+ index$1,
840
+ /** Month offset */
841
+ offset) => {
842
+ const days = this.getDaysInMonth(offset, this.numberOfCalendars);
843
+ const weeks = [];
844
+ for (let i = 0; i < days.length; i += 7) {
845
+ weeks.push(days.slice(i, i + 7));
846
+ }
847
+ return (index.h("div", { class: "calendar-wrapper" }, index.h("div", { class: "calendar-container", key: `calendar-${index$1}` }, this.renderHeader(offset, index$1), index.h("div", { class: "calendar-grid" }, this.showWeekNumbers && this.renderWeekNumbers(weeks, index$1), index.h("div", { class: "days-container" }, index.h("div", { class: "days-header" }, this.getDayNames().map(day => (index.h("div", { class: "day-header" }, day)))), this.renderDaysGrid(days)))), index$1 < this.numberOfCalendars - 1 && (index.h("div", { class: "calendar-separator" }))));
848
+ };
849
+ /**
850
+ * Renders the shortcuts
851
+ * @returns {JSX.Element} Shortcuts
852
+ * @description Renders the shortcuts of the calendar
853
+ */
854
+ this.renderShortcuts = () => {
855
+ if (!this.hasShortcuts) {
856
+ return null;
857
+ }
858
+ return (index.h("div", { class: `shortcuts-container shortcuts-placement-${this.shortcutsPlacement}` }, this.shortcuts.map(shortcut => (index.h("nv-button", { emphasis: "lower", size: "xs", "aria-label": shortcut.label, onClick: this.getShortcutHandler(shortcut) }, shortcut.label)))));
859
+ };
860
+ /**
861
+ * Renders the actions
862
+ * @returns {JSX.Element} Actions
863
+ * @description Renders the actions of the calendar
864
+ * @slot actions - Child content of the component.
865
+ */
866
+ this.renderActions = () => {
867
+ return (index.h("div", { class: "datepicker-actions" }, index.h("slot", { name: "actions" }, index.h("nv-button", { emphasis: "low", size: "xs", onClick: this.resetSelection }, "Cancel"), index.h("nv-button", { size: "xs", onClick: this.confirmSelection }, "OK"))));
868
+ };
869
+ }
870
+ //#endregion EVENTS
871
+ /****************************************************************************/
872
+ //#region WATCHERS
873
+ /**
874
+ * Watches the changes of the number of calendars
875
+ * @param {number} newValue - New number of calendars
876
+ */
877
+ validateNumberOfCalendars(newValue) {
878
+ if (newValue < 1 || newValue > 4) {
879
+ console.warn('numberOfCalendars must be between 1 and 4. Defaulting to 1.');
880
+ this.numberOfCalendars = 1;
881
+ }
882
+ }
883
+ /**
884
+ * Watches the changes of the selected date range
885
+ * @param {Object} newValue - New rangeValue value
886
+ * @param {string} newValue.start - Start date
887
+ * @param {string} newValue.end - End date
888
+ */
889
+ onRangeValueChange(newValue) {
890
+ if (newValue && newValue.start && newValue.end) {
891
+ try {
892
+ const { startDate, endDate } = this.validateDateRange(newValue.start, newValue.end);
893
+ this.startDate = startDate;
894
+ this.endDate = endDate;
895
+ // Do not navigate to the start date if data-prevent-navigation attribute is present
896
+ const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
897
+ if (!preventNavigation) {
898
+ this.currentDate = startDate;
899
+ }
900
+ }
901
+ catch (error) {
902
+ console.error('Invalid rangeValue:', error);
903
+ }
904
+ }
905
+ }
906
+ /**
907
+ * Watches the changes of the disabled dates
908
+ * @description Watches the changes of the disabled dates
909
+ */
910
+ handleDisabledDatesChange() {
911
+ this.parseDisabledDates();
912
+ }
913
+ /**
914
+ * Watches the changes of the single value
915
+ * @param {string} newValue - New single value
916
+ * @param {string} oldValue - Old single value
917
+ */
918
+ onSingleValueChange(newValue, oldValue) {
919
+ if (this.selectionType === 'single' && newValue !== oldValue && newValue) {
920
+ const parsedDate = parseDate(newValue, this.dateFormat);
921
+ if (parsedDate) {
922
+ this.selectedDate = parsedDate;
923
+ // Do not navigate to the selected date if data-prevent-navigation attribute is present
924
+ const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
925
+ if (!preventNavigation) {
926
+ this.currentDate = parsedDate;
927
+ }
928
+ }
929
+ }
930
+ }
931
+ //#endregion WATCHERS
932
+ /****************************************************************************/
933
+ //#region LIFECYCLE
934
+ componentWillLoad() {
935
+ this.parseDisabledDates();
936
+ if (this.selectionType === 'single' && this.singleValue) {
937
+ this.selectedDate = parseDate(this.singleValue, this.dateFormat);
938
+ this.currentDate = this.selectedDate;
939
+ }
940
+ else if (this.selectionType === 'range' && this.rangeValue) {
941
+ try {
942
+ if (this.rangeValue.start && this.rangeValue.end) {
943
+ const { startDate, endDate, swapped } = this.validateDateRange(this.rangeValue.start, this.rangeValue.end);
944
+ this.startDate = startDate;
945
+ this.endDate = endDate;
946
+ this.currentDate = startDate;
947
+ if (swapped) {
948
+ // If dates were swapped, update the rangeValue property
949
+ this.rangeValue = {
950
+ start: formatDate(startDate, { dateFormat: this.dateFormat }),
951
+ end: formatDate(endDate, { dateFormat: this.dateFormat }),
952
+ };
953
+ }
954
+ }
955
+ }
956
+ catch (error) {
957
+ console.error('Invalid rangeValue:', error);
958
+ }
959
+ }
960
+ else {
961
+ this.currentDate = new Date();
962
+ }
963
+ this.initializeMonths();
964
+ }
965
+ //#endregion LIFECYCLE
966
+ /****************************************************************************/
967
+ //#region METHODS
968
+ /**
969
+ * Checks if shortcuts are visible
970
+ * @returns {boolean} true if shortcuts are visible
971
+ */
972
+ get hasShortcuts() {
973
+ return Boolean(this.shortcutsPlacement && this.shortcuts);
974
+ }
975
+ /**
976
+ * Checks if actions are visible
977
+ * @returns {boolean} true if actions are visible
978
+ */
979
+ get hasActions() {
980
+ return this.showActions;
981
+ }
982
+ /**
983
+ * Checks if the date format is in UTC mode
984
+ * @returns {boolean} true if the date format is in UTC mode
985
+ */
986
+ get isUTCMode() {
987
+ return this.dateFormat.includes('Z');
988
+ }
989
+ /**
990
+ * Validates and processes a date range, warning if start is after end
991
+ * @param {string} startDateStr - Start date in ISO string format
992
+ * @param {string} endDateStr - End date in ISO string format
993
+ * @returns {object} Object containing the validated start and end dates
994
+ */
995
+ validateDateRange(startDateStr, endDateStr) {
996
+ try {
997
+ const startDate = parseDate(startDateStr, this.dateFormat);
998
+ const endDate = parseDate(endDateStr, this.dateFormat);
999
+ if (startDate && endDate && startDate > endDate) {
1000
+ console.warn(`Warning: startDate (${formatDate(startDate, {
1001
+ dateFormat: this.dateFormat,
1002
+ })}) is after endDate (${formatDate(endDate, {
1003
+ dateFormat: this.dateFormat,
1004
+ })})`);
1005
+ // Return dates in correct order, with swapped flag
1006
+ return {
1007
+ startDate: endDate,
1008
+ endDate: startDate,
1009
+ swapped: true,
1010
+ };
1011
+ }
1012
+ return {
1013
+ startDate,
1014
+ endDate,
1015
+ swapped: false,
1016
+ };
1017
+ }
1018
+ catch (error) {
1019
+ console.error('Invalid date range:', error);
1020
+ throw error; // Re-throw to let the caller handle it
1021
+ }
1022
+ }
1023
+ /**
1024
+ * Renders the datepicker
1025
+ * @returns {JSX.Element} Datepicker
1026
+ * @description Renders the datepicker of the calendar
1027
+ * @slot default - Child content of the component.
1028
+ */
1029
+ render() {
1030
+ return (index.h(index.Host, { key: '9804c486acf32e12f2d88f932a54ca6260365887' }, index.h("div", { key: '8503f585401191b904f2de248ed0c24b1fed1505', class: "datepicker-root" }, index.h("div", { key: '9da71618bd2031b44f5a3fd889d40b2580fcca58', class: `datepicker-container ${this.numberOfCalendars === 1 ? 'datepicker-container-single' : ''}` }, index.h("div", { key: 'fbf71a34b520ca48f1440d8caeec442773b1e57a', class: `datepicker-wrapper ${this.numberOfCalendars === 1 ? 'single' : ''}` }, this.shortcutsPlacement === 'left' && this.renderShortcuts(), Array.from({ length: this.numberOfCalendars }, (_, index) => this.renderCalendar(index, index)), this.shortcutsPlacement === 'right' && this.renderShortcuts()), ((this.hasShortcuts && this.shortcutsPlacement === 'bottom') ||
1031
+ this.hasActions) && (index.h("div", { key: '4431e3f1221e9d47807d58af380dcaa91bf05c48', class: "datepicker-controls" }, this.shortcutsPlacement === 'bottom' && this.renderShortcuts(), this.hasActions && this.renderActions())))), index.h("slot", { key: '30386356bda72f4f12a28351084ab498ec95f5b9' })));
1032
+ }
1033
+ get el() { return index.getElement(this); }
1034
+ static get watchers() { return {
1035
+ "numberOfCalendars": ["validateNumberOfCalendars"],
1036
+ "rangeValue": ["onRangeValueChange"],
1037
+ "disabledDates": ["handleDisabledDatesChange"],
1038
+ "singleValue": ["onSingleValueChange"]
1039
+ }; }
1040
+ };
1041
+ NvCalendar.style = NvCalendarStyle0;
1042
+
1043
+ exports.nv_calendar = NvCalendar;