@tabworthy/components 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/customParseFormat-l09KVyWD.js +45 -0
- package/dist/cjs/tabworthy-dates.cjs.entry.js +19 -22
- package/dist/cjs/tabworthy-times.cjs.entry.js +43 -23
- package/dist/collection/components/tabworthy-dates/tabworthy-dates.js +19 -17
- package/dist/collection/components/tabworthy-times/tabworthy-times.js +27 -23
- package/dist/components/p-DkyM-7xr.js +1 -0
- package/dist/components/tabworthy-dates.js +1 -1
- package/dist/components/tabworthy-times.js +1 -1
- package/dist/esm/customParseFormat-DkyM-7xr.js +41 -0
- package/dist/esm/tabworthy-dates.entry.js +18 -21
- package/dist/esm/tabworthy-times.entry.js +43 -23
- package/dist/tabworthy-components/p-6335f1a7.entry.js +1 -0
- package/dist/tabworthy-components/p-DkyM-7xr.js +1 -0
- package/dist/tabworthy-components/p-c378a069.entry.js +1 -0
- package/dist/tabworthy-components/tabworthy-components.esm.js +1 -1
- package/package.json +2 -3
- package/dist/cjs/moment-CdViwxPQ.js +0 -5681
- package/dist/components/p-Mki5YqAR.js +0 -8
- package/dist/esm/moment-Mki5YqAR.js +0 -5679
- package/dist/tabworthy-components/p-Mki5YqAR.js +0 -8
- package/dist/tabworthy-components/p-d4a7458b.entry.js +0 -1
- package/dist/tabworthy-components/p-ea7b79b0.entry.js +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function getDefaultExportFromCjs (x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var dayjs_min$1 = {exports: {}};
|
|
8
|
+
|
|
9
|
+
var dayjs_min = dayjs_min$1.exports;
|
|
10
|
+
|
|
11
|
+
var hasRequiredDayjs_min;
|
|
12
|
+
|
|
13
|
+
function requireDayjs_min () {
|
|
14
|
+
if (hasRequiredDayjs_min) return dayjs_min$1.exports;
|
|
15
|
+
hasRequiredDayjs_min = 1;
|
|
16
|
+
(function (module, exports) {
|
|
17
|
+
!function(t,e){module.exports=e();}(dayjs_min,(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}));
|
|
18
|
+
} (dayjs_min$1));
|
|
19
|
+
return dayjs_min$1.exports;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var dayjs_minExports = requireDayjs_min();
|
|
23
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
24
|
+
|
|
25
|
+
var customParseFormat$2 = {exports: {}};
|
|
26
|
+
|
|
27
|
+
var customParseFormat$1 = customParseFormat$2.exports;
|
|
28
|
+
|
|
29
|
+
var hasRequiredCustomParseFormat;
|
|
30
|
+
|
|
31
|
+
function requireCustomParseFormat () {
|
|
32
|
+
if (hasRequiredCustomParseFormat) return customParseFormat$2.exports;
|
|
33
|
+
hasRequiredCustomParseFormat = 1;
|
|
34
|
+
(function (module, exports) {
|
|
35
|
+
!function(e,t){module.exports=t();}(customParseFormat$1,(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);};}}));
|
|
36
|
+
} (customParseFormat$2));
|
|
37
|
+
return customParseFormat$2.exports;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var customParseFormatExports = requireCustomParseFormat();
|
|
41
|
+
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);
|
|
42
|
+
|
|
43
|
+
exports.customParseFormat = customParseFormat;
|
|
44
|
+
exports.dayjs = dayjs;
|
|
45
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index$1 = require('./index-B1s0tI-Z.js');
|
|
4
|
-
var
|
|
4
|
+
var customParseFormat = require('./customParseFormat-l09KVyWD.js');
|
|
5
5
|
var utils = require('./utils-y5Vtky2t.js');
|
|
6
6
|
|
|
7
7
|
function _mergeNamespaces(n, m) {
|
|
@@ -103,10 +103,6 @@ class $319e236875307eab$var$LiveAnnouncer {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
function getDefaultExportFromCjs (x) {
|
|
107
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
106
|
var dist = {};
|
|
111
107
|
|
|
112
108
|
var en = {};
|
|
@@ -10316,7 +10312,7 @@ function requireDist () {
|
|
|
10316
10312
|
}
|
|
10317
10313
|
|
|
10318
10314
|
var distExports = requireDist();
|
|
10319
|
-
var index = /*@__PURE__*/getDefaultExportFromCjs(distExports);
|
|
10315
|
+
var index = /*@__PURE__*/customParseFormat.getDefaultExportFromCjs(distExports);
|
|
10320
10316
|
|
|
10321
10317
|
var chrono = /*#__PURE__*/_mergeNamespaces({
|
|
10322
10318
|
__proto__: null,
|
|
@@ -10472,6 +10468,7 @@ const chronoParseRange = async (dateString, options) => {
|
|
|
10472
10468
|
|
|
10473
10469
|
const tabworthyDatesCss = () => `.visually-hidden.sc-tabworthy-dates{position:absolute;overflow:hidden;width:1px;height:1px;white-space:nowrap;clip:rect(0 0 0 0);-webkit-clip-path:inset(50%);clip-path:inset(50%)}`;
|
|
10474
10470
|
|
|
10471
|
+
customParseFormat.dayjs.extend(customParseFormat.customParseFormat);
|
|
10475
10472
|
const defaultLabels = {
|
|
10476
10473
|
selected: "selected",
|
|
10477
10474
|
openCalendar: "Open calendar",
|
|
@@ -10732,7 +10729,7 @@ const TabworthyDates = class {
|
|
|
10732
10729
|
}
|
|
10733
10730
|
return {
|
|
10734
10731
|
value: parsedDate && parsedDate.value instanceof Date
|
|
10735
|
-
?
|
|
10732
|
+
? customParseFormat.dayjs(parsedDate.value).format(this.format)
|
|
10736
10733
|
: undefined,
|
|
10737
10734
|
reason: parsedDate && parsedDate.reason ? parsedDate.reason : undefined
|
|
10738
10735
|
};
|
|
@@ -10747,11 +10744,11 @@ const TabworthyDates = class {
|
|
|
10747
10744
|
updateValue(newValue) {
|
|
10748
10745
|
// Range
|
|
10749
10746
|
if (Array.isArray(newValue)) {
|
|
10750
|
-
this.internalValue = newValue.map((date) =>
|
|
10747
|
+
this.internalValue = newValue.map((date) => customParseFormat.dayjs(date).format(this.format));
|
|
10751
10748
|
}
|
|
10752
10749
|
// Single
|
|
10753
10750
|
else {
|
|
10754
|
-
this.internalValue =
|
|
10751
|
+
this.internalValue = customParseFormat.dayjs(newValue).format(this.format);
|
|
10755
10752
|
}
|
|
10756
10753
|
if (this.pickerRef) {
|
|
10757
10754
|
this.pickerRef.value = newValue;
|
|
@@ -10780,7 +10777,7 @@ const TabworthyDates = class {
|
|
|
10780
10777
|
return; // Range date is invalid, leave the text field as is
|
|
10781
10778
|
let output = "";
|
|
10782
10779
|
this.internalValue.forEach((value, index) => {
|
|
10783
|
-
const parsedDate =
|
|
10780
|
+
const parsedDate = customParseFormat.dayjs(useInputValue ? this.inputRef.value : value, this.format, true);
|
|
10784
10781
|
const dateToFormat = parsedDate.isValid()
|
|
10785
10782
|
? parsedDate.toDate()
|
|
10786
10783
|
: utils.removeTimezoneOffset(new Date(useInputValue ? this.inputRef.value : value));
|
|
@@ -10793,7 +10790,7 @@ const TabworthyDates = class {
|
|
|
10793
10790
|
this.inputRef.value = output;
|
|
10794
10791
|
}
|
|
10795
10792
|
else {
|
|
10796
|
-
const parsedDate =
|
|
10793
|
+
const parsedDate = customParseFormat.dayjs(useInputValue ? this.inputRef.value : this.internalValue, this.format, true);
|
|
10797
10794
|
const dateToFormat = parsedDate.isValid()
|
|
10798
10795
|
? parsedDate.toDate()
|
|
10799
10796
|
: utils.removeTimezoneOffset(new Date(useInputValue ? this.inputRef.value : this.internalValue));
|
|
@@ -10812,7 +10809,7 @@ const TabworthyDates = class {
|
|
|
10812
10809
|
if (newValue.length === 2)
|
|
10813
10810
|
(_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close();
|
|
10814
10811
|
// Convert ISO dates to specified format
|
|
10815
|
-
this.internalValue = newValue.map((date) =>
|
|
10812
|
+
this.internalValue = newValue.map((date) => customParseFormat.dayjs(date).format(this.format));
|
|
10816
10813
|
this.errorState = false;
|
|
10817
10814
|
if (document.activeElement !== this.inputRef) {
|
|
10818
10815
|
this.formatInput(true, false);
|
|
@@ -10823,7 +10820,7 @@ const TabworthyDates = class {
|
|
|
10823
10820
|
(_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.close();
|
|
10824
10821
|
// Convert ISO date to specified format
|
|
10825
10822
|
const formattedDate = newValue
|
|
10826
|
-
?
|
|
10823
|
+
? customParseFormat.dayjs(newValue).format(this.format)
|
|
10827
10824
|
: "";
|
|
10828
10825
|
this.inputRef.value = formattedDate;
|
|
10829
10826
|
this.internalValue = formattedDate;
|
|
@@ -10841,8 +10838,8 @@ const TabworthyDates = class {
|
|
|
10841
10838
|
return;
|
|
10842
10839
|
}
|
|
10843
10840
|
const newValueInIsoFormat = Array.isArray(newValue)
|
|
10844
|
-
? newValue.map((date) =>
|
|
10845
|
-
:
|
|
10841
|
+
? newValue.map((date) => customParseFormat.dayjs(date, this.format).toISOString())
|
|
10842
|
+
: customParseFormat.dayjs(newValue, this.format).toISOString();
|
|
10846
10843
|
let content = "";
|
|
10847
10844
|
if (Array.isArray(newValueInIsoFormat)) {
|
|
10848
10845
|
if (newValueInIsoFormat.length === 1) {
|
|
@@ -10885,7 +10882,7 @@ const TabworthyDates = class {
|
|
|
10885
10882
|
if (this.pickerRef) {
|
|
10886
10883
|
if (Array.isArray(value)) {
|
|
10887
10884
|
const dates = value.reduce((acc, v) => {
|
|
10888
|
-
const d =
|
|
10885
|
+
const d = customParseFormat.dayjs(v, this.format, true);
|
|
10889
10886
|
if (d.isValid())
|
|
10890
10887
|
acc.push(d.toDate());
|
|
10891
10888
|
return acc;
|
|
@@ -10894,7 +10891,7 @@ const TabworthyDates = class {
|
|
|
10894
10891
|
}
|
|
10895
10892
|
else {
|
|
10896
10893
|
if (value) {
|
|
10897
|
-
const parsedDate =
|
|
10894
|
+
const parsedDate = customParseFormat.dayjs(value, this.format, true);
|
|
10898
10895
|
if (parsedDate.isValid()) {
|
|
10899
10896
|
this.pickerRef.value = parsedDate.toDate();
|
|
10900
10897
|
}
|
|
@@ -10914,10 +10911,10 @@ const TabworthyDates = class {
|
|
|
10914
10911
|
}
|
|
10915
10912
|
render() {
|
|
10916
10913
|
var _a;
|
|
10917
|
-
return (index$1.h(index$1.Host, { key: '
|
|
10914
|
+
return (index$1.h(index$1.Host, { key: '7dc37ffe7603f9c65f674910f5e1de3fec6d13f7' }, index$1.h("label", { key: '240bdaf77226608e88efc0bf810ed0d08090927a', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), index$1.h("br", { key: 'd37a77330ffabc8b8565c5c058ee4c5ee32e755b' }), index$1.h("div", { key: 'db290a3f753694a073ab8dd779b90e06fabe3b25', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index$1.h("input", { key: 'd51dcd7f6abc15bd605a5d8c5b77da97eec76ed8', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
|
|
10918
10915
|
[this.getClassName("input")]: true,
|
|
10919
10916
|
[this.inputClass]: !!this.inputClass
|
|
10920
|
-
}, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (index$1.h("button", { key: '
|
|
10917
|
+
}, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (index$1.h("button", { key: '41527ddd0ae71c44a645c887cd395957dc22252c', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index$1.h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), index$1.h("tabworthy-dates-modal", { key: '9356c01fadb2450a04664dcd4c4b3a1fce278394', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
10921
10918
|
if (!this.pickerRef)
|
|
10922
10919
|
return;
|
|
10923
10920
|
this.pickerRef.modalIsOpen = true;
|
|
@@ -10925,11 +10922,11 @@ const TabworthyDates = class {
|
|
|
10925
10922
|
if (!this.pickerRef)
|
|
10926
10923
|
return;
|
|
10927
10924
|
this.pickerRef.modalIsOpen = false;
|
|
10928
|
-
}, inline: this.inline, appendTo: this.appendTo }, index$1.h("tabworthy-dates-calendar", { key: '
|
|
10925
|
+
}, inline: this.inline, appendTo: this.appendTo }, index$1.h("tabworthy-dates-calendar", { key: '371f6b079a3dc3d42d84e0ce0d301a4121747130', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), onRequestClose: () => { var _a; return (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close(); }, labels: this.datesCalendarLabels ? this.datesCalendarLabels : undefined, ref: (el) => (this.pickerRef = el), startDate: this.startDate, firstDayOfWeek: this.firstDayOfWeek, showHiddenTitle: true, disabled: this.disabledState, showMonthStepper: this.showMonthStepper, showYearStepper: this.showYearStepper, showClearButton: this.showClearButton, showCloseButton: this.showCloseButton, showKeyboardHint: this.showKeyboardHint, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline })), this.showQuickButtons &&
|
|
10929
10926
|
((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
10930
|
-
this.chronoSupportedLocale && (index$1.h("div", { key: '
|
|
10927
|
+
this.chronoSupportedLocale && (index$1.h("div", { key: 'afadda0a46a2e3224c940d27ba884edc45487bf3', class: this.getClassName("quick-group"), role: "group", "aria-label": this.datesLabels.quickSelection }, this.quickButtons.map((buttonText) => {
|
|
10931
10928
|
return (index$1.h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
|
|
10932
|
-
}))), this.errorState && (index$1.h("div", { key: '
|
|
10929
|
+
}))), this.errorState && (index$1.h("div", { key: '7caa060a5da1846323cc161cbf9cff4b5275b90f', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
10933
10930
|
}
|
|
10934
10931
|
get el() { return index$1.getElement(this); }
|
|
10935
10932
|
static get watchers() { return {
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-B1s0tI-Z.js');
|
|
4
|
-
var
|
|
4
|
+
var customParseFormat = require('./customParseFormat-l09KVyWD.js');
|
|
5
5
|
var utils = require('./utils-y5Vtky2t.js');
|
|
6
6
|
|
|
7
|
+
var localizedFormat$2 = {exports: {}};
|
|
8
|
+
|
|
9
|
+
var localizedFormat$1 = localizedFormat$2.exports;
|
|
10
|
+
|
|
11
|
+
var hasRequiredLocalizedFormat;
|
|
12
|
+
|
|
13
|
+
function requireLocalizedFormat () {
|
|
14
|
+
if (hasRequiredLocalizedFormat) return localizedFormat$2.exports;
|
|
15
|
+
hasRequiredLocalizedFormat = 1;
|
|
16
|
+
(function (module, exports) {
|
|
17
|
+
!function(e,t){module.exports=t();}(localizedFormat$1,(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"};return function(t,o,n){var r=o.prototype,i=r.format;n.en.formats=e,r.format=function(t){ void 0===t&&(t="YYYY-MM-DDTHH:mm:ssZ");var o=this.$locale().formats,n=function(t,o){return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var i=r&&r.toUpperCase();return n||o[r]||e[r]||o[i].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,o){return t||o.slice(1)}))}))}(t,void 0===o?{}:o);return i.call(this,n)};}}));
|
|
18
|
+
} (localizedFormat$2));
|
|
19
|
+
return localizedFormat$2.exports;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var localizedFormatExports = requireLocalizedFormat();
|
|
23
|
+
var localizedFormat = /*@__PURE__*/customParseFormat.getDefaultExportFromCjs(localizedFormatExports);
|
|
24
|
+
|
|
25
|
+
customParseFormat.dayjs.extend(customParseFormat.customParseFormat);
|
|
26
|
+
customParseFormat.dayjs.extend(localizedFormat);
|
|
7
27
|
const defaultLabels = {
|
|
8
28
|
selected: "selected",
|
|
9
29
|
openCalendar: "Choose time",
|
|
@@ -132,10 +152,10 @@ const InclusiveTimes = class {
|
|
|
132
152
|
this.handleInputChange = (event) => {
|
|
133
153
|
const value = event.target.value;
|
|
134
154
|
// Try to parse the input value as a datetime
|
|
135
|
-
const parsed =
|
|
155
|
+
const parsed = customParseFormat.dayjs(value);
|
|
136
156
|
if (parsed.isValid()) {
|
|
137
|
-
this.selectedHours = parsed.
|
|
138
|
-
this.selectedMinutes = parsed.
|
|
157
|
+
this.selectedHours = parsed.hour();
|
|
158
|
+
this.selectedMinutes = parsed.minute();
|
|
139
159
|
this.updateValue(parsed.toDate());
|
|
140
160
|
}
|
|
141
161
|
};
|
|
@@ -168,12 +188,12 @@ const InclusiveTimes = class {
|
|
|
168
188
|
// Parse the first datetime value to set time picker
|
|
169
189
|
const firstValue = Array.isArray(this.value) ? this.value[0] : this.value;
|
|
170
190
|
if (firstValue) {
|
|
171
|
-
const parsed =
|
|
191
|
+
const parsed = customParseFormat.dayjs(firstValue, this.format);
|
|
172
192
|
if (parsed.isValid()) {
|
|
173
193
|
this.selectedDate = parsed.toDate();
|
|
174
|
-
this.selectedHours = parsed.
|
|
175
|
-
this.selectedMinutes = parsed.
|
|
176
|
-
this.selectedSeconds = parsed.
|
|
194
|
+
this.selectedHours = parsed.hour();
|
|
195
|
+
this.selectedMinutes = parsed.minute();
|
|
196
|
+
this.selectedSeconds = parsed.second();
|
|
177
197
|
}
|
|
178
198
|
}
|
|
179
199
|
}
|
|
@@ -185,10 +205,10 @@ const InclusiveTimes = class {
|
|
|
185
205
|
if (Array.isArray(date)) {
|
|
186
206
|
// Range mode
|
|
187
207
|
const formattedDates = date.map((d) => {
|
|
188
|
-
const m =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
208
|
+
const m = customParseFormat.dayjs(d)
|
|
209
|
+
.hour(this.selectedHours)
|
|
210
|
+
.minute(this.selectedMinutes)
|
|
211
|
+
.second(this.selectedSeconds);
|
|
192
212
|
return m.format(this.format);
|
|
193
213
|
});
|
|
194
214
|
this.internalValue = formattedDates;
|
|
@@ -197,10 +217,10 @@ const InclusiveTimes = class {
|
|
|
197
217
|
}
|
|
198
218
|
else {
|
|
199
219
|
// Single date mode
|
|
200
|
-
const m =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
220
|
+
const m = customParseFormat.dayjs(date)
|
|
221
|
+
.hour(this.selectedHours)
|
|
222
|
+
.minute(this.selectedMinutes)
|
|
223
|
+
.second(this.selectedSeconds);
|
|
204
224
|
const formatted = m.format(this.format);
|
|
205
225
|
this.internalValue = formatted;
|
|
206
226
|
this.value = formatted;
|
|
@@ -218,13 +238,13 @@ const InclusiveTimes = class {
|
|
|
218
238
|
if (Array.isArray(this.internalValue)) {
|
|
219
239
|
// Format range
|
|
220
240
|
const formatted = this.internalValue
|
|
221
|
-
.map((v) =>
|
|
241
|
+
.map((v) => customParseFormat.dayjs(v, this.format).format("lll"))
|
|
222
242
|
.join(` ${this.timesLabels.to} `);
|
|
223
243
|
this.inputRef.value = formatted;
|
|
224
244
|
}
|
|
225
245
|
else {
|
|
226
246
|
// Format single datetime
|
|
227
|
-
this.inputRef.value =
|
|
247
|
+
this.inputRef.value = customParseFormat.dayjs(this.internalValue, this.format).format("lll");
|
|
228
248
|
}
|
|
229
249
|
}
|
|
230
250
|
getClassName(suffix) {
|
|
@@ -234,8 +254,8 @@ const InclusiveTimes = class {
|
|
|
234
254
|
if (!dateString)
|
|
235
255
|
return null;
|
|
236
256
|
const date = Array.isArray(dateString)
|
|
237
|
-
? dateString.map((d) =>
|
|
238
|
-
:
|
|
257
|
+
? dateString.map((d) => customParseFormat.dayjs(d, this.format).toDate())
|
|
258
|
+
: customParseFormat.dayjs(dateString, this.format).toDate();
|
|
239
259
|
return date;
|
|
240
260
|
}
|
|
241
261
|
async clearValue() {
|
|
@@ -252,10 +272,10 @@ const InclusiveTimes = class {
|
|
|
252
272
|
}
|
|
253
273
|
render() {
|
|
254
274
|
var _a;
|
|
255
|
-
return (index.h(index.Host, { key: '
|
|
275
|
+
return (index.h(index.Host, { key: '03aaff051aa6af4a7606b64056336c4f597ffaeb', class: this.elementClassName, "has-error": this.errorState, disabled: this.disabledState }, index.h("label", { key: 'd05264d3b32741ccfeca0be4473f9323b4934071', htmlFor: `${this.id}-input`, class: this.getClassName("label") }, this.label), index.h("div", { key: '7a4306a4863ffffe35a0d33c80ebfc19298c2182', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, index.h("input", { key: '03080dc8619d396347b831b307c8fa9070434b35', id: `${this.id}-input`, ref: (r) => (this.inputRef = r), type: "text", class: {
|
|
256
276
|
[this.getClassName("input")]: true,
|
|
257
277
|
[this.inputClass]: !!this.inputClass
|
|
258
|
-
}, placeholder: this.placeholder, disabled: this.disabledState || this.disableFreeformInput, value: (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.toString(), onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (index.h("button", { key: '
|
|
278
|
+
}, placeholder: this.placeholder, disabled: this.disabledState || this.disableFreeformInput, value: (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.toString(), onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (index.h("button", { key: 'cc384691007bc6eb4044098ab79ba38809375de7', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (index.h("span", { innerHTML: this.calendarButtonContent })) : (this.timesLabels.openCalendar)))), index.h("tabworthy-dates-modal", { key: '14290fe8ca21e0027c384bd56d913d2cdda55380', label: this.timesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
259
279
|
if (this.pickerRef) {
|
|
260
280
|
this.pickerRef.modalIsOpen = true;
|
|
261
281
|
}
|
|
@@ -263,7 +283,7 @@ const InclusiveTimes = class {
|
|
|
263
283
|
if (this.pickerRef) {
|
|
264
284
|
this.pickerRef.modalIsOpen = false;
|
|
265
285
|
}
|
|
266
|
-
}, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '
|
|
286
|
+
}, inline: this.inline, appendTo: this.appendTo }, index.h("div", { key: '83c1e85f688a0ff213872e54a96702429f00869b', class: this.getClassName("picker-container") }, index.h("tabworthy-dates-calendar", { key: '6afcc9ddb6fcedf07127c933ad1ed192a4c88eaf', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), onRequestClose: () => { var _a; return (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close(); }, labels: this.datesCalendarLabels, ref: (el) => (this.pickerRef = el), startDate: this.startDate, firstDayOfWeek: this.firstDayOfWeek, showHiddenTitle: true, disabled: this.disabledState, showMonthStepper: this.showMonthStepper, showYearStepper: this.showYearStepper, showClearButton: this.showClearButton, showCloseButton: this.showCloseButton, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline, value: this.value ? this.toDate(this.value) : undefined }, index.h("div", { key: '7e47f4b63a85d6431f8019a8725acbf79fb44d67', slot: "after-calendar", class: this.getClassName("time-section") }, index.h("hr", { key: '8b72711de0422f1b1848bb22a72ed363b1c63ebb', class: this.getClassName("divider") }), index.h("tabworthy-times-picker", { key: '29f47e57c4f3f94232345bbe602d0278b5f53fa4', hours: this.selectedHours, minutes: this.selectedMinutes, seconds: this.selectedSeconds, showSeconds: this.showSeconds, useTwelveHourFormat: this.useTwelveHourFormat, disabled: this.disabledState, onTimeChanged: this.handleTimeChange, labels: this.timesPickerLabels }))))), this.errorState && (index.h("div", { key: 'aa6f743bc35538f6271a45bb2564e89164e5a909', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
267
287
|
}
|
|
268
288
|
get el() { return index.getElement(this); }
|
|
269
289
|
static get watchers() { return {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import { announce } from "@react-aria/live-announcer";
|
|
3
|
-
import
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
5
|
+
dayjs.extend(customParseFormat);
|
|
4
6
|
import { getISODateString, removeTimezoneOffset } from "../../../../shared/utils/utils";
|
|
5
7
|
import { chronoParseDate, chronoParseRange } from "../../../../shared/utils/chrono-parser/chrono-parser";
|
|
6
8
|
const defaultLabels = {
|
|
@@ -259,7 +261,7 @@ export class TabworthyDates {
|
|
|
259
261
|
}
|
|
260
262
|
return {
|
|
261
263
|
value: parsedDate && parsedDate.value instanceof Date
|
|
262
|
-
?
|
|
264
|
+
? dayjs(parsedDate.value).format(this.format)
|
|
263
265
|
: undefined,
|
|
264
266
|
reason: parsedDate && parsedDate.reason ? parsedDate.reason : undefined
|
|
265
267
|
};
|
|
@@ -274,11 +276,11 @@ export class TabworthyDates {
|
|
|
274
276
|
updateValue(newValue) {
|
|
275
277
|
// Range
|
|
276
278
|
if (Array.isArray(newValue)) {
|
|
277
|
-
this.internalValue = newValue.map((date) =>
|
|
279
|
+
this.internalValue = newValue.map((date) => dayjs(date).format(this.format));
|
|
278
280
|
}
|
|
279
281
|
// Single
|
|
280
282
|
else {
|
|
281
|
-
this.internalValue =
|
|
283
|
+
this.internalValue = dayjs(newValue).format(this.format);
|
|
282
284
|
}
|
|
283
285
|
if (this.pickerRef) {
|
|
284
286
|
this.pickerRef.value = newValue;
|
|
@@ -307,7 +309,7 @@ export class TabworthyDates {
|
|
|
307
309
|
return; // Range date is invalid, leave the text field as is
|
|
308
310
|
let output = "";
|
|
309
311
|
this.internalValue.forEach((value, index) => {
|
|
310
|
-
const parsedDate =
|
|
312
|
+
const parsedDate = dayjs(useInputValue ? this.inputRef.value : value, this.format, true);
|
|
311
313
|
const dateToFormat = parsedDate.isValid()
|
|
312
314
|
? parsedDate.toDate()
|
|
313
315
|
: removeTimezoneOffset(new Date(useInputValue ? this.inputRef.value : value));
|
|
@@ -320,7 +322,7 @@ export class TabworthyDates {
|
|
|
320
322
|
this.inputRef.value = output;
|
|
321
323
|
}
|
|
322
324
|
else {
|
|
323
|
-
const parsedDate =
|
|
325
|
+
const parsedDate = dayjs(useInputValue ? this.inputRef.value : this.internalValue, this.format, true);
|
|
324
326
|
const dateToFormat = parsedDate.isValid()
|
|
325
327
|
? parsedDate.toDate()
|
|
326
328
|
: removeTimezoneOffset(new Date(useInputValue ? this.inputRef.value : this.internalValue));
|
|
@@ -339,7 +341,7 @@ export class TabworthyDates {
|
|
|
339
341
|
if (newValue.length === 2)
|
|
340
342
|
(_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close();
|
|
341
343
|
// Convert ISO dates to specified format
|
|
342
|
-
this.internalValue = newValue.map((date) =>
|
|
344
|
+
this.internalValue = newValue.map((date) => dayjs(date).format(this.format));
|
|
343
345
|
this.errorState = false;
|
|
344
346
|
if (document.activeElement !== this.inputRef) {
|
|
345
347
|
this.formatInput(true, false);
|
|
@@ -350,7 +352,7 @@ export class TabworthyDates {
|
|
|
350
352
|
(_b = this.modalRef) === null || _b === void 0 ? void 0 : _b.close();
|
|
351
353
|
// Convert ISO date to specified format
|
|
352
354
|
const formattedDate = newValue
|
|
353
|
-
?
|
|
355
|
+
? dayjs(newValue).format(this.format)
|
|
354
356
|
: "";
|
|
355
357
|
this.inputRef.value = formattedDate;
|
|
356
358
|
this.internalValue = formattedDate;
|
|
@@ -368,8 +370,8 @@ export class TabworthyDates {
|
|
|
368
370
|
return;
|
|
369
371
|
}
|
|
370
372
|
const newValueInIsoFormat = Array.isArray(newValue)
|
|
371
|
-
? newValue.map((date) =>
|
|
372
|
-
:
|
|
373
|
+
? newValue.map((date) => dayjs(date, this.format).toISOString())
|
|
374
|
+
: dayjs(newValue, this.format).toISOString();
|
|
373
375
|
let content = "";
|
|
374
376
|
if (Array.isArray(newValueInIsoFormat)) {
|
|
375
377
|
if (newValueInIsoFormat.length === 1) {
|
|
@@ -412,7 +414,7 @@ export class TabworthyDates {
|
|
|
412
414
|
if (this.pickerRef) {
|
|
413
415
|
if (Array.isArray(value)) {
|
|
414
416
|
const dates = value.reduce((acc, v) => {
|
|
415
|
-
const d =
|
|
417
|
+
const d = dayjs(v, this.format, true);
|
|
416
418
|
if (d.isValid())
|
|
417
419
|
acc.push(d.toDate());
|
|
418
420
|
return acc;
|
|
@@ -421,7 +423,7 @@ export class TabworthyDates {
|
|
|
421
423
|
}
|
|
422
424
|
else {
|
|
423
425
|
if (value) {
|
|
424
|
-
const parsedDate =
|
|
426
|
+
const parsedDate = dayjs(value, this.format, true);
|
|
425
427
|
if (parsedDate.isValid()) {
|
|
426
428
|
this.pickerRef.value = parsedDate.toDate();
|
|
427
429
|
}
|
|
@@ -441,10 +443,10 @@ export class TabworthyDates {
|
|
|
441
443
|
}
|
|
442
444
|
render() {
|
|
443
445
|
var _a;
|
|
444
|
-
return (h(Host, { key: '
|
|
446
|
+
return (h(Host, { key: '7dc37ffe7603f9c65f674910f5e1de3fec6d13f7' }, h("label", { key: '240bdaf77226608e88efc0bf810ed0d08090927a', htmlFor: this.id ? `${this.id}-input` : undefined, class: this.getClassName("label") }, this.label), h("br", { key: 'd37a77330ffabc8b8565c5c058ee4c5ee32e755b' }), h("div", { key: 'db290a3f753694a073ab8dd779b90e06fabe3b25', class: this.getClassName("input-container"), ref: (r) => (this.inputContainerRef = r) }, h("input", { key: 'd51dcd7f6abc15bd605a5d8c5b77da97eec76ed8', disabled: this.disabledState || this.disableFreeformInput, id: this.id ? `${this.id}-input` : undefined, type: "text", placeholder: this.placeholder, class: {
|
|
445
447
|
[this.getClassName("input")]: true,
|
|
446
448
|
[this.inputClass]: !!this.inputClass
|
|
447
|
-
}, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: '
|
|
449
|
+
}, ref: (r) => (this.inputRef = r), onChange: this.handleChange, onFocus: () => this.formatInput(false), onBlur: () => this.formatInput(true, false), "aria-describedby": this.errorState ? `${this.id}-error` : undefined, "aria-invalid": this.errorState }), !this.inline && (h("button", { key: '41527ddd0ae71c44a645c887cd395957dc22252c', type: "button", onClick: this.handleCalendarButtonClick, class: this.getClassName("calendar-button"), disabled: this.disabledState }, this.calendarButtonContent ? (h("span", { innerHTML: this.calendarButtonContent })) : (this.datesLabels.openCalendar)))), h("tabworthy-dates-modal", { key: '9356c01fadb2450a04664dcd4c4b3a1fce278394', label: this.datesLabels.calendar, ref: (el) => (this.modalRef = el), onOpened: () => {
|
|
448
450
|
if (!this.pickerRef)
|
|
449
451
|
return;
|
|
450
452
|
this.pickerRef.modalIsOpen = true;
|
|
@@ -452,11 +454,11 @@ export class TabworthyDates {
|
|
|
452
454
|
if (!this.pickerRef)
|
|
453
455
|
return;
|
|
454
456
|
this.pickerRef.modalIsOpen = false;
|
|
455
|
-
}, inline: this.inline, appendTo: this.appendTo }, h("tabworthy-dates-calendar", { key: '
|
|
457
|
+
}, inline: this.inline, appendTo: this.appendTo }, h("tabworthy-dates-calendar", { key: '371f6b079a3dc3d42d84e0ce0d301a4121747130', range: this.range, locale: this.locale, onSelectDate: (event) => this.handlePickerSelection(event.detail), onChangeMonth: (event) => this.handleChangedMonths(event.detail), onChangeYear: (event) => this.handleYearChange(event.detail), onRequestClose: () => { var _a; return (_a = this.modalRef) === null || _a === void 0 ? void 0 : _a.close(); }, labels: this.datesCalendarLabels ? this.datesCalendarLabels : undefined, ref: (el) => (this.pickerRef = el), startDate: this.startDate, firstDayOfWeek: this.firstDayOfWeek, showHiddenTitle: true, disabled: this.disabledState, showMonthStepper: this.showMonthStepper, showYearStepper: this.showYearStepper, showClearButton: this.showClearButton, showCloseButton: this.showCloseButton, showKeyboardHint: this.showKeyboardHint, showTodayButton: this.showTodayButton, disableDate: this.disableDate, minDate: this.minDate, maxDate: this.maxDate, inline: this.inline })), this.showQuickButtons &&
|
|
456
458
|
((_a = this.quickButtons) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
457
|
-
this.chronoSupportedLocale && (h("div", { key: '
|
|
459
|
+
this.chronoSupportedLocale && (h("div", { key: 'afadda0a46a2e3224c940d27ba884edc45487bf3', class: this.getClassName("quick-group"), role: "group", "aria-label": this.datesLabels.quickSelection }, this.quickButtons.map((buttonText) => {
|
|
458
460
|
return (h("button", { class: this.getClassName("quick-button"), onClick: this.handleQuickButtonClick, disabled: this.disabledState, type: "button" }, buttonText));
|
|
459
|
-
}))), this.errorState && (h("div", { key: '
|
|
461
|
+
}))), this.errorState && (h("div", { key: '7caa060a5da1846323cc161cbf9cff4b5275b90f', class: this.getClassName("input-error"), id: this.id ? `${this.id}-error` : undefined, role: "status" }, this.errorMessage))));
|
|
460
462
|
}
|
|
461
463
|
static get is() { return "tabworthy-dates"; }
|
|
462
464
|
static get encapsulation() { return "scoped"; }
|