@mtes-mct/monitor-ui 2.8.0 → 2.9.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.
- package/CHANGELOG.md +14 -0
- package/README.md +2 -1
- package/index.js +112 -89
- package/index.js.map +1 -1
- package/package.json +6 -1
- package/src/ThemeProvider.d.ts +2 -2
- package/src/elements/Button.d.ts +4 -4
- package/src/elements/FieldError.d.ts +1 -1
- package/src/elements/Fieldset.d.ts +4 -4
- package/src/elements/IconBox.d.ts +2 -2
- package/src/elements/IconButton.d.ts +4 -4
- package/src/elements/Label.d.ts +3 -3
- package/src/elements/Legend.d.ts +2 -2
- package/src/elements/Tag/index.d.ts +3 -3
- package/src/fields/AutoComplete.d.ts +11 -10
- package/src/fields/Checkbox.d.ts +1 -1
- package/src/fields/DatePicker/CalendarPicker.d.ts +2 -2
- package/src/fields/DatePicker/index.d.ts +14 -14
- package/src/fields/DateRangePicker/DateInput.d.ts +3 -3
- package/src/fields/DateRangePicker/NumberInput.d.ts +5 -5
- package/src/fields/DateRangePicker/RangeCalendarPicker.d.ts +2 -2
- package/src/fields/DateRangePicker/TimeInput.d.ts +9 -9
- package/src/fields/DateRangePicker/index.d.ts +8 -8
- package/src/fields/MultiCheckbox.d.ts +5 -5
- package/src/fields/MultiRadio.d.ts +5 -5
- package/src/fields/MultiSelect.d.ts +7 -7
- package/src/fields/MultiZoneEditor/index.d.ts +6 -6
- package/src/fields/NumberInput.d.ts +4 -4
- package/src/fields/Select.d.ts +6 -6
- package/src/fields/TextInput.d.ts +4 -4
- package/src/fields/Textarea.d.ts +4 -4
- package/src/theme.d.ts +2 -2
- package/src/types.d.ts +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.8.1](https://github.com/MTES-MCT/monitor-ui/compare/v2.8.0...v2.8.1) (2023-01-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **fields:** fix string date wrong default value offset in DatePicker & DateRangePicker ([18bc2aa](https://github.com/MTES-MCT/monitor-ui/commit/18bc2aa729cbe88c8e87fac294515a2fa75abbe7))
|
|
7
|
+
|
|
8
|
+
# [2.8.0](https://github.com/MTES-MCT/monitor-ui/compare/v2.7.2...v2.8.0) (2023-01-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **fields:** handle both Date & string dates in DatePicker & DateRangePicker ([6aacf70](https://github.com/MTES-MCT/monitor-ui/commit/6aacf7007bcbc789b9de643be2d192a1808b0afc))
|
|
14
|
+
|
|
1
15
|
## [2.7.2](https://github.com/MTES-MCT/monitor-ui/compare/v2.7.1...v2.7.2) (2023-01-13)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -55,7 +55,8 @@ Please read the [contributing document](CONTRIBUTING.md) for setup and contribut
|
|
|
55
55
|
|
|
56
56
|
---
|
|
57
57
|
|
|
58
|
-
[img-github]:
|
|
58
|
+
[img-github]:
|
|
59
|
+
https://img.shields.io/github/actions/workflow/status/MTES-MCT/monitor-ui/check.yml?branch=main&style=flat-square
|
|
59
60
|
[img-license]: https://img.shields.io/github/license/MTES-MCT/monitor-ui?style=flat-square
|
|
60
61
|
[img-npm]: https://img.shields.io/npm/v/@mtes-mct/monitor-ui?style=flat-square
|
|
61
62
|
[lnk-github]: https://github.com/MTES-MCT/monitor-ui/actions?query=branch%3Amain++
|
package/index.js
CHANGED
|
@@ -2809,6 +2809,10 @@ const useClickOutside = (zoneRefOrzoneRefs, action, baseContainer) => {
|
|
|
2809
2809
|
|
|
2810
2810
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2811
2811
|
|
|
2812
|
+
function getDefaultExportFromCjs (x) {
|
|
2813
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2812
2816
|
/**
|
|
2813
2817
|
* lodash (Custom Build) <https://lodash.com/>
|
|
2814
2818
|
* Build: `lodash modularize exports="npm" -o ./`
|
|
@@ -3390,47 +3394,64 @@ const StyledCheckbox = styled(Checkbox$1) `
|
|
|
3390
3394
|
}
|
|
3391
3395
|
`;
|
|
3392
3396
|
|
|
3393
|
-
var
|
|
3397
|
+
var dayjs_minExports$1 = {};
|
|
3398
|
+
var dayjs_min = {
|
|
3399
|
+
get exports(){ return dayjs_minExports$1; },
|
|
3400
|
+
set exports(v){ dayjs_minExports$1 = v; },
|
|
3401
|
+
};
|
|
3394
3402
|
|
|
3395
3403
|
var hasRequiredDayjs_min;
|
|
3396
3404
|
|
|
3397
3405
|
function requireDayjs_min () {
|
|
3398
|
-
if (hasRequiredDayjs_min) return
|
|
3406
|
+
if (hasRequiredDayjs_min) return dayjs_minExports$1;
|
|
3399
3407
|
hasRequiredDayjs_min = 1;
|
|
3400
3408
|
(function (module, exports) {
|
|
3401
3409
|
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="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,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);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:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p=function(t){return t instanceof _},S=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},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t);}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(O.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.$x=t.x||{},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 O},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.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=!!O.u(e)||e,h=O.p(t),l=function(t,e){var i=O.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 O.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(h){case c:return r?l(1,0):l(31,11);case f: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,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),l=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){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[O.p(t)]()},m.add=function(r,h){var d,l=this;r=Number(r);var $=O.p(h),y=function(t){var e=w(l);return O.w(e.date(e.date()+Math.round(t*r)),l)};if($===f)return this.set(f,this.$M+r);if($===c)return this.set(c,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 O.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=O.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,f=n.months,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=n.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},$={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(n.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(n.weekdaysMin,this.$W,o,2),ddd:h(n.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:i};return r.replace(y,(function(t,e){return e||$[t]||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,v=this-M,g=O.m(this,M);return g=($={},$[c]=g/12,$[f]=g,$[h]=g/3,$[o]=(v-m)/6048e5,$[a]=(v-m)/864e5,$[u]=v/n,$[s]=v/e,$[i]=v/t,$)[y]||v,l?g:O.a(g)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.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}(),T=_.prototype;return w.prototype=T,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){T[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=D[g],w.Ls=D,w.p={},w}));
|
|
3402
3410
|
} (dayjs_min));
|
|
3403
|
-
return
|
|
3411
|
+
return dayjs_minExports$1;
|
|
3404
3412
|
}
|
|
3405
3413
|
|
|
3406
3414
|
var dayjs_minExports = requireDayjs_min();
|
|
3415
|
+
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
3407
3416
|
|
|
3408
|
-
var
|
|
3417
|
+
var timezoneExports = {};
|
|
3418
|
+
var timezone$1 = {
|
|
3419
|
+
get exports(){ return timezoneExports; },
|
|
3420
|
+
set exports(v){ timezoneExports = v; },
|
|
3421
|
+
};
|
|
3409
3422
|
|
|
3410
3423
|
(function (module, exports) {
|
|
3411
3424
|
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t={year:0,month:1,day:2,hour:3,minute:4,second:5},e={};return function(n,i,o){var r,a=function(t,n,i){void 0===i&&(i={});var o=new Date(t),r=function(t,n){void 0===n&&(n={});var i=n.timeZoneName||"short",o=t+"|"+i,r=e[o];return r||(r=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),e[o]=r),r}(n,i);return r.formatToParts(o)},u=function(e,n){for(var i=a(e,n),r=[],u=0;u<i.length;u+=1){var f=i[u],s=f.type,m=f.value,c=t[s];c>=0&&(r[c]=parseInt(m,10));}var d=r[3],l=24===d?0:d,v=r[0]+"-"+r[1]+"-"+r[2]+" "+l+":"+r[4]+":"+r[5]+":000",h=+e;return (o.utc(v).valueOf()-(h-=h%1e3))/6e4},f=i.prototype;f.tz=function(t,e){void 0===t&&(t=r);var n=this.utcOffset(),i=this.toDate(),a=i.toLocaleString("en-US",{timeZone:t}),u=Math.round((i-new Date(a))/1e3/60),f=o(a).$set("millisecond",this.$ms).utcOffset(15*-Math.round(i.getTimezoneOffset()/15)-u,!0);if(e){var s=f.utcOffset();f=f.add(n-s,"minute");}return f.$x.$timezone=t,f},f.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),n=a(this.valueOf(),e,{timeZoneName:t}).find((function(t){return "timezonename"===t.type.toLowerCase()}));return n&&n.value};var s=f.startOf;f.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return s.call(this,t,e);var n=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return s.call(n,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,n){var i=n&&e,a=n||e||r,f=u(+o(),a);if("string"!=typeof t)return o(t).tz(a);var s=function(t,e,n){var i=t-60*e*1e3,o=u(i,n);if(e===o)return [i,e];var r=u(i-=60*(o-e)*1e3,n);return o===r?[i,o]:[t-60*Math.min(o,r)*1e3,Math.max(o,r)]}(o.utc(t,i).valueOf(),f,a),m=s[0],c=s[1],d=o(m).utcOffset(c);return d.$x.$timezone=a,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){r=t;};}}));
|
|
3412
3425
|
} (timezone$1));
|
|
3413
3426
|
|
|
3414
|
-
var timezone =
|
|
3427
|
+
var timezone = timezoneExports;
|
|
3415
3428
|
|
|
3416
|
-
var
|
|
3429
|
+
var utcExports = {};
|
|
3430
|
+
var utc$1 = {
|
|
3431
|
+
get exports(){ return utcExports; },
|
|
3432
|
+
set exports(v){ utcExports = v; },
|
|
3433
|
+
};
|
|
3417
3434
|
|
|
3418
3435
|
(function (module, exports) {
|
|
3419
3436
|
!function(t,i){module.exports=i();}(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:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var o=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),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)};}}));
|
|
3420
3437
|
} (utc$1));
|
|
3421
3438
|
|
|
3422
|
-
var utc =
|
|
3439
|
+
var utc = utcExports;
|
|
3423
3440
|
|
|
3424
|
-
var
|
|
3441
|
+
var frExports = {};
|
|
3442
|
+
var fr = {
|
|
3443
|
+
get exports(){ return frExports; },
|
|
3444
|
+
set exports(v){ frExports = v; },
|
|
3445
|
+
};
|
|
3425
3446
|
|
|
3426
3447
|
(function (module, exports) {
|
|
3427
3448
|
!function(e,n){module.exports=n(requireDayjs_min());}(commonjsGlobal,(function(e){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(e),i={name:"fr",weekdays:"dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi".split("_"),weekdaysShort:"dim._lun._mar._mer._jeu._ven._sam.".split("_"),weekdaysMin:"di_lu_ma_me_je_ve_sa".split("_"),months:"janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre".split("_"),monthsShort:"janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.".split("_"),weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"dans %s",past:"il y a %s",s:"quelques secondes",m:"une minute",mm:"%d minutes",h:"une heure",hh:"%d heures",d:"un jour",dd:"%d jours",M:"un mois",MM:"%d mois",y:"un an",yy:"%d ans"},ordinal:function(e){return ""+e+(1===e?"er":"")}};return t.default.locale(i,null,!0),i}));
|
|
3428
3449
|
} (fr));
|
|
3429
3450
|
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3451
|
+
dayjs.extend(timezone);
|
|
3452
|
+
dayjs.extend(utc);
|
|
3453
|
+
dayjs.locale('fr');
|
|
3454
|
+
dayjs.tz.setDefault('UTC');
|
|
3434
3455
|
|
|
3435
3456
|
// TODO Use `date-fns` instead of `dayjs`.
|
|
3436
3457
|
/**
|
|
@@ -3440,14 +3461,10 @@ dayjs_minExports.tz.setDefault('UTC');
|
|
|
3440
3461
|
* `2022-01-02T03:04:05.006Z` => `2022-01-02T03:04:05.006+01:00` (or `+02:00` during DST) in Europe/Paris timezone.
|
|
3441
3462
|
*/
|
|
3442
3463
|
function getLocalizedDayjs(utcDate) {
|
|
3443
|
-
if (typeof utcDate === 'string') {
|
|
3444
|
-
return dayjs_minExports(utcDate);
|
|
3445
|
-
}
|
|
3446
|
-
const utcDateAsDate = dayjs_minExports(utcDate).toDate();
|
|
3447
3464
|
// The number of minutes returned by getTimezoneOffset() is positive if the local time zone is behind UTC,
|
|
3448
3465
|
// and negative if the local time zone is ahead of UTC. For example, for UTC+10, -600 will be returned.
|
|
3449
|
-
const timezoneOffsetInMinutes =
|
|
3450
|
-
return
|
|
3466
|
+
const timezoneOffsetInMinutes = new Date().getTimezoneOffset();
|
|
3467
|
+
return dayjs(utcDate).add(timezoneOffsetInMinutes, 'minutes');
|
|
3451
3468
|
}
|
|
3452
3469
|
|
|
3453
3470
|
// TODO Use `date-fns` instead of `dayjs`.
|
|
@@ -3462,7 +3479,7 @@ function getUtcizedDayjs(localDate) {
|
|
|
3462
3479
|
// The number of minutes returned by getTimezoneOffset() is positive if the local time zone is behind UTC,
|
|
3463
3480
|
// and negative if the local time zone is ahead of UTC. For example, for UTC+10, -600 will be returned.
|
|
3464
3481
|
const timezoneOffsetInMinutes = definedLocalDate.getTimezoneOffset();
|
|
3465
|
-
return
|
|
3482
|
+
return dayjs(definedLocalDate).subtract(timezoneOffsetInMinutes, 'minutes');
|
|
3466
3483
|
}
|
|
3467
3484
|
|
|
3468
3485
|
/**
|
|
@@ -3897,7 +3914,7 @@ function formatNumberAsDoubleDigit(numberLike) {
|
|
|
3897
3914
|
function getDateFromDateAndTimeTuple(dateTuple, timeTuple, isEnd = false) {
|
|
3898
3915
|
const [year, month, day] = dateTuple;
|
|
3899
3916
|
const [hour, minute] = timeTuple;
|
|
3900
|
-
const rawDateAsDayjs =
|
|
3917
|
+
const rawDateAsDayjs = dayjs()
|
|
3901
3918
|
.year(Number(year))
|
|
3902
3919
|
.month(Number(month) - 1)
|
|
3903
3920
|
.date(Number(day))
|
|
@@ -4261,7 +4278,7 @@ const InputGroup = styled.div `
|
|
|
4261
4278
|
`;
|
|
4262
4279
|
|
|
4263
4280
|
function getUtcDayjs() {
|
|
4264
|
-
return
|
|
4281
|
+
return dayjs().utc();
|
|
4265
4282
|
}
|
|
4266
4283
|
|
|
4267
4284
|
new Array(24).fill(undefined).map((_, index) => ({
|
|
@@ -4308,7 +4325,9 @@ function CalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
|
4308
4325
|
}, [forceUpdate]);
|
|
4309
4326
|
return (jsx(Box$5, { ref: boxRef, onClick: stopMouseEventPropagation, children: boxRef.current && (jsx(DatePicker$1, { container: boxRef.current, disabledDate: disabledDate, format: "yyyy-MM-dd", locale: RSUITE_CALENDAR_LOCALE, oneTap: true, onSelect: handleSelect, open: isOpen,
|
|
4310
4327
|
// `defaultValue` seems to be immediatly cancelled so we come down to using a controlled `value`
|
|
4311
|
-
ranges: [],
|
|
4328
|
+
ranges: [],
|
|
4329
|
+
// eslint-disable-next-line no-null/no-null
|
|
4330
|
+
value: defaultValue ?? null })) }));
|
|
4312
4331
|
}
|
|
4313
4332
|
const Box$5 = styled.div `
|
|
4314
4333
|
height: 0;
|
|
@@ -4472,20 +4491,20 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4472
4491
|
const dateInputRef = useRef();
|
|
4473
4492
|
const timeInputRef = useRef();
|
|
4474
4493
|
const isCalendarPickerOpenRef = useRef(false);
|
|
4475
|
-
const
|
|
4476
|
-
const
|
|
4477
|
-
const
|
|
4494
|
+
const selectedLocalizedDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue).toDate() : undefined);
|
|
4495
|
+
const selectedLocalizedDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedDateRef.current));
|
|
4496
|
+
const selectedLocalizedTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedDateRef.current));
|
|
4478
4497
|
const { forceUpdate } = useForceUpdate();
|
|
4479
|
-
const rangeCalendarPickerDefaultValue = useMemo(() =>
|
|
4480
|
-
? getDateFromDateAndTimeTuple(
|
|
4498
|
+
const rangeCalendarPickerDefaultValue = useMemo(() => selectedLocalizedDateTupleRef.current
|
|
4499
|
+
? getDateFromDateAndTimeTuple(selectedLocalizedDateTupleRef.current, ['00', '00'])
|
|
4481
4500
|
: undefined,
|
|
4482
4501
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4483
|
-
[
|
|
4502
|
+
[selectedLocalizedDateTupleRef.current]);
|
|
4484
4503
|
const submit = useCallback(() => {
|
|
4485
|
-
if (!onChange || !
|
|
4504
|
+
if (!onChange || !selectedLocalizedDateRef.current) {
|
|
4486
4505
|
return;
|
|
4487
4506
|
}
|
|
4488
|
-
const nextDateAsDayjs = getUtcizedDayjs(
|
|
4507
|
+
const nextDateAsDayjs = getUtcizedDayjs(selectedLocalizedDateRef.current);
|
|
4489
4508
|
if (isStringDate) {
|
|
4490
4509
|
onChange(nextDateAsDayjs.toISOString());
|
|
4491
4510
|
}
|
|
@@ -4504,13 +4523,13 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4504
4523
|
timeInputRef.current.focus();
|
|
4505
4524
|
}, [withTime]);
|
|
4506
4525
|
const handleDateInputChange = useCallback((nextDateTuple, isFilled) => {
|
|
4507
|
-
|
|
4526
|
+
selectedLocalizedDateTupleRef.current = nextDateTuple;
|
|
4508
4527
|
// If there is no time input or a time has already been selected,
|
|
4509
|
-
if (!withTime ||
|
|
4528
|
+
if (!withTime || selectedLocalizedTimeTupleRef.current) {
|
|
4510
4529
|
// we must update the selected date and call onChange()
|
|
4511
|
-
const timeTuple = (withTime ?
|
|
4530
|
+
const timeTuple = (withTime ? selectedLocalizedTimeTupleRef.current : ['00', '00']);
|
|
4512
4531
|
const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, timeTuple);
|
|
4513
|
-
|
|
4532
|
+
selectedLocalizedDateRef.current = getLocalizedDayjs(nextDate).toDate();
|
|
4514
4533
|
submit();
|
|
4515
4534
|
}
|
|
4516
4535
|
if (isFilled) {
|
|
@@ -4522,32 +4541,32 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4522
4541
|
if (!withTime) {
|
|
4523
4542
|
// we have to fix the date at the beginning of the day
|
|
4524
4543
|
const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, ['00', '00']);
|
|
4525
|
-
|
|
4544
|
+
selectedLocalizedDateRef.current = nextDate;
|
|
4526
4545
|
}
|
|
4527
4546
|
// If this is a date picker with a time input,
|
|
4528
4547
|
else {
|
|
4529
4548
|
// we include the selected time if it exists, set it at the beginning of the day if not
|
|
4530
|
-
const nextDate = getDateFromDateAndTimeTuple(nextDateTuple,
|
|
4531
|
-
|
|
4549
|
+
const nextDate = getDateFromDateAndTimeTuple(nextDateTuple, selectedLocalizedTimeTupleRef.current || ['00', '00']);
|
|
4550
|
+
selectedLocalizedDateRef.current = nextDate;
|
|
4532
4551
|
}
|
|
4533
|
-
|
|
4534
|
-
|
|
4552
|
+
selectedLocalizedDateTupleRef.current = nextDateTuple;
|
|
4553
|
+
selectedLocalizedTimeTupleRef.current = getTimeTupleFromDate(selectedLocalizedDateRef.current);
|
|
4535
4554
|
closeCalendarPicker();
|
|
4536
4555
|
forceUpdate();
|
|
4537
4556
|
submit();
|
|
4538
|
-
if (withTime && !
|
|
4557
|
+
if (withTime && !selectedLocalizedTimeTupleRef.current) {
|
|
4539
4558
|
timeInputRef.current.focus();
|
|
4540
4559
|
}
|
|
4541
4560
|
}, [closeCalendarPicker, forceUpdate, submit, withTime]);
|
|
4542
4561
|
const handleTimeInputFilled = useCallback((nextTimeTuple) => {
|
|
4543
4562
|
// If a date has already been selected
|
|
4544
|
-
if (
|
|
4563
|
+
if (selectedLocalizedDateTupleRef.current) {
|
|
4545
4564
|
// we must update the selected date accordingly and submit it
|
|
4546
|
-
const nextDate = getDateFromDateAndTimeTuple(
|
|
4547
|
-
|
|
4565
|
+
const nextDate = getDateFromDateAndTimeTuple(selectedLocalizedDateTupleRef.current, nextTimeTuple);
|
|
4566
|
+
selectedLocalizedDateRef.current = nextDate;
|
|
4548
4567
|
submit();
|
|
4549
4568
|
}
|
|
4550
|
-
|
|
4569
|
+
selectedLocalizedTimeTupleRef.current = nextTimeTuple;
|
|
4551
4570
|
submit();
|
|
4552
4571
|
}, [submit]);
|
|
4553
4572
|
const openCalendarPicker = useCallback(() => {
|
|
@@ -4555,7 +4574,7 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4555
4574
|
forceUpdate();
|
|
4556
4575
|
}, [forceUpdate]);
|
|
4557
4576
|
useClickOutside(boxRef, closeCalendarPicker, baseContainer);
|
|
4558
|
-
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue:
|
|
4577
|
+
return (jsxs(Fieldset, { disabled: disabled, ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$4, { ref: boxRef, children: [jsx(Field$1, { children: jsx(DateInput, { ref: dateInputRef, defaultValue: selectedLocalizedDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isCalendarPickerOpenRef.current, isLight: isLight, onChange: handleDateInputChange, onClick: openCalendarPicker, onNext: handleDateInputNext }) }), withTime && (jsx(Field$1, { "$isTimeField": true, children: jsx(TimeInput, { ref: timeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, minutesRange: minutesRange, onBack: () => dateInputRef.current.focus(true), onChange: handleTimeInputFilled, onFocus: closeCalendarPicker, onPrevious: () => dateInputRef.current.focus(true) }) }))] }), jsx(CalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isCalendarPickerOpenRef.current, onChange: handleCalendarPickerChange })] }));
|
|
4559
4578
|
}
|
|
4560
4579
|
const Box$4 = styled.div `
|
|
4561
4580
|
* {
|
|
@@ -4576,7 +4595,7 @@ function sortDates(dates) {
|
|
|
4576
4595
|
return dates
|
|
4577
4596
|
.map(date => date.toISOString())
|
|
4578
4597
|
.sort()
|
|
4579
|
-
.map(dateAsIsoString =>
|
|
4598
|
+
.map(dateAsIsoString => dayjs(dateAsIsoString).toDate());
|
|
4580
4599
|
}
|
|
4581
4600
|
|
|
4582
4601
|
function RangeCalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
@@ -4605,7 +4624,8 @@ function RangeCalendarPicker({ defaultValue, isHistorical, isOpen, onChange }) {
|
|
|
4605
4624
|
}, [forceUpdate]);
|
|
4606
4625
|
return (jsx(Box$3, { ref: boxRef, onClick: stopMouseEventPropagation, children: boxRef.current && (jsx(DateRangePicker$1, { container: boxRef.current, disabledDate: disabledDate, format: "yyyy-MM-dd", locale: RSUITE_CALENDAR_LOCALE, onSelect: handleSelect, open: isOpen, ranges: [],
|
|
4607
4626
|
// `defaultValue` seems to be immediatly cancelled so we come down to using a controlled `value`
|
|
4608
|
-
|
|
4627
|
+
// eslint-disable-next-line no-null/no-null
|
|
4628
|
+
value: controlledValue ?? null })) }));
|
|
4609
4629
|
}
|
|
4610
4630
|
const Box$3 = styled.div `
|
|
4611
4631
|
height: 0;
|
|
@@ -4784,34 +4804,34 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4784
4804
|
const endDateInputRef = useRef();
|
|
4785
4805
|
const endTimeInputRef = useRef();
|
|
4786
4806
|
const isRangeCalendarPickerOpenRef = useRef(false);
|
|
4787
|
-
const
|
|
4788
|
-
const
|
|
4789
|
-
const
|
|
4790
|
-
const
|
|
4791
|
-
const
|
|
4792
|
-
const
|
|
4807
|
+
const selectedLocalizedStartDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue[0]).toDate() : undefined);
|
|
4808
|
+
const selectedLocalizedEndDateRef = useRef(defaultValue ? getLocalizedDayjs(defaultValue[1]).toDate() : undefined);
|
|
4809
|
+
const selectedLocalizedStartDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedStartDateRef.current));
|
|
4810
|
+
const selectedLocalizedEndDateTupleRef = useRef(getDateTupleFromDate(selectedLocalizedEndDateRef.current));
|
|
4811
|
+
const selectedLocalizedStartTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedStartDateRef.current));
|
|
4812
|
+
const selectedLocalizedEndTimeTupleRef = useRef(getTimeTupleFromDate(selectedLocalizedEndDateRef.current));
|
|
4793
4813
|
const { forceUpdate } = useForceUpdate();
|
|
4794
|
-
const rangeCalendarPickerDefaultValue = useMemo(() =>
|
|
4814
|
+
const rangeCalendarPickerDefaultValue = useMemo(() => selectedLocalizedStartDateTupleRef.current && selectedLocalizedEndDateTupleRef.current
|
|
4795
4815
|
? [
|
|
4796
|
-
getDateFromDateAndTimeTuple(
|
|
4797
|
-
getDateFromDateAndTimeTuple(
|
|
4816
|
+
getDateFromDateAndTimeTuple(selectedLocalizedStartDateTupleRef.current, ['00', '00']),
|
|
4817
|
+
getDateFromDateAndTimeTuple(selectedLocalizedEndDateTupleRef.current, ['00', '00'], true)
|
|
4798
4818
|
]
|
|
4799
4819
|
: undefined,
|
|
4800
4820
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4801
|
-
[
|
|
4821
|
+
[selectedLocalizedEndDateTupleRef.current, selectedLocalizedStartDateTupleRef.current]);
|
|
4802
4822
|
const submit = useCallback(() => {
|
|
4803
|
-
if (!onChange || !
|
|
4823
|
+
if (!onChange || !selectedLocalizedStartDateRef.current || !selectedLocalizedEndDateRef.current) {
|
|
4804
4824
|
return;
|
|
4805
4825
|
}
|
|
4806
4826
|
if (isStringDate) {
|
|
4807
|
-
const utcizedStartDateAsString = getUtcizedDayjs(
|
|
4808
|
-
const utcizedEndDateAsString = getUtcizedDayjs(
|
|
4827
|
+
const utcizedStartDateAsString = getUtcizedDayjs(selectedLocalizedStartDateRef.current).toISOString();
|
|
4828
|
+
const utcizedEndDateAsString = getUtcizedDayjs(selectedLocalizedEndDateRef.current).toISOString();
|
|
4809
4829
|
const nextDateAsStringRange = [utcizedStartDateAsString, utcizedEndDateAsString];
|
|
4810
4830
|
onChange(nextDateAsStringRange);
|
|
4811
4831
|
}
|
|
4812
4832
|
else {
|
|
4813
|
-
const utcizedStartDate = getUtcizedDayjs(
|
|
4814
|
-
const utcizedEndDate = getUtcizedDayjs(
|
|
4833
|
+
const utcizedStartDate = getUtcizedDayjs(selectedLocalizedStartDateRef.current).toDate();
|
|
4834
|
+
const utcizedEndDate = getUtcizedDayjs(selectedLocalizedEndDateRef.current).toDate();
|
|
4815
4835
|
const nextDateRange = [utcizedStartDate, utcizedEndDate];
|
|
4816
4836
|
onChange(nextDateRange);
|
|
4817
4837
|
}
|
|
@@ -4842,13 +4862,13 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4842
4862
|
}, [withTime]);
|
|
4843
4863
|
const handleDateInputChange = useCallback((position, nextDateTuple, isFilled) => {
|
|
4844
4864
|
if (position === DateRangePosition.START) {
|
|
4845
|
-
|
|
4865
|
+
selectedLocalizedStartDateTupleRef.current = nextDateTuple;
|
|
4846
4866
|
// If there is no time input or a start time has already been selected,
|
|
4847
|
-
if (!withTime ||
|
|
4867
|
+
if (!withTime || selectedLocalizedStartTimeTupleRef.current) {
|
|
4848
4868
|
// we must update the selected start date and call onChange()
|
|
4849
|
-
const startTimeTuple = (withTime ?
|
|
4869
|
+
const startTimeTuple = (withTime ? selectedLocalizedStartTimeTupleRef.current : ['00', '00']);
|
|
4850
4870
|
const nextStartDate = getDateFromDateAndTimeTuple(nextDateTuple, startTimeTuple);
|
|
4851
|
-
|
|
4871
|
+
selectedLocalizedStartDateRef.current = nextStartDate;
|
|
4852
4872
|
submit();
|
|
4853
4873
|
}
|
|
4854
4874
|
if (isFilled) {
|
|
@@ -4856,13 +4876,13 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4856
4876
|
}
|
|
4857
4877
|
}
|
|
4858
4878
|
else {
|
|
4859
|
-
|
|
4879
|
+
selectedLocalizedEndDateTupleRef.current = nextDateTuple;
|
|
4860
4880
|
// If there is no time input or an end time has already been selected,
|
|
4861
|
-
if (!withTime ||
|
|
4881
|
+
if (!withTime || selectedLocalizedEndTimeTupleRef.current) {
|
|
4862
4882
|
// we must update the selected end date and call onChange()
|
|
4863
|
-
const endTimeTuple = (withTime ?
|
|
4883
|
+
const endTimeTuple = (withTime ? selectedLocalizedEndTimeTupleRef.current : ['23', '59']);
|
|
4864
4884
|
const nextEndDate = getDateFromDateAndTimeTuple(nextDateTuple, endTimeTuple, true);
|
|
4865
|
-
|
|
4885
|
+
selectedLocalizedEndDateRef.current = nextEndDate;
|
|
4866
4886
|
submit();
|
|
4867
4887
|
}
|
|
4868
4888
|
if (isFilled) {
|
|
@@ -4878,22 +4898,22 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4878
4898
|
const nextStartDate = getDateFromDateAndTimeTuple(nextStartDateTuple, ['00', '00']);
|
|
4879
4899
|
// and the end date at the end of the day
|
|
4880
4900
|
const nextEndDate = getDateFromDateAndTimeTuple(nextEndDateTuple, ['23', '59'], true);
|
|
4881
|
-
|
|
4882
|
-
|
|
4901
|
+
selectedLocalizedStartDateRef.current = nextStartDate;
|
|
4902
|
+
selectedLocalizedEndDateRef.current = nextEndDate;
|
|
4883
4903
|
}
|
|
4884
4904
|
// If this is a date picker with a time input,
|
|
4885
4905
|
else {
|
|
4886
4906
|
// we include the selected start time if it exists, set it at the beginning of the day if not
|
|
4887
|
-
const nextStartDate = getDateFromDateAndTimeTuple(nextStartDateTuple,
|
|
4888
|
-
|
|
4907
|
+
const nextStartDate = getDateFromDateAndTimeTuple(nextStartDateTuple, selectedLocalizedStartTimeTupleRef.current || ['00', '00']);
|
|
4908
|
+
selectedLocalizedStartDateRef.current = nextStartDate;
|
|
4889
4909
|
// we include the selected end time if it exists, set it at the end of the day if not
|
|
4890
|
-
const nextEndDate = getDateFromDateAndTimeTuple(nextEndDateTuple,
|
|
4891
|
-
|
|
4910
|
+
const nextEndDate = getDateFromDateAndTimeTuple(nextEndDateTuple, selectedLocalizedEndTimeTupleRef.current || ['23', '59'], true);
|
|
4911
|
+
selectedLocalizedEndDateRef.current = nextEndDate;
|
|
4892
4912
|
}
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4913
|
+
selectedLocalizedStartDateTupleRef.current = nextStartDateTuple;
|
|
4914
|
+
selectedLocalizedStartTimeTupleRef.current = getTimeTupleFromDate(selectedLocalizedStartDateRef.current);
|
|
4915
|
+
selectedLocalizedEndDateTupleRef.current = nextEndDateTuple;
|
|
4916
|
+
selectedLocalizedEndTimeTupleRef.current = getTimeTupleFromDate(selectedLocalizedEndDateRef.current);
|
|
4897
4917
|
closeRangeCalendarPicker();
|
|
4898
4918
|
forceUpdate();
|
|
4899
4919
|
submit();
|
|
@@ -4901,24 +4921,24 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4901
4921
|
const handleTimeInputFilled = useCallback((position, nextTimeTuple) => {
|
|
4902
4922
|
if (position === DateRangePosition.START) {
|
|
4903
4923
|
// If a start date has already been selected
|
|
4904
|
-
if (
|
|
4924
|
+
if (selectedLocalizedStartDateTupleRef.current) {
|
|
4905
4925
|
// we must update the selected start date accordingly and submit it
|
|
4906
|
-
const nextStartDate = getDateFromDateAndTimeTuple(
|
|
4907
|
-
|
|
4926
|
+
const nextStartDate = getDateFromDateAndTimeTuple(selectedLocalizedStartDateTupleRef.current, nextTimeTuple);
|
|
4927
|
+
selectedLocalizedStartDateRef.current = nextStartDate;
|
|
4908
4928
|
submit();
|
|
4909
4929
|
}
|
|
4910
|
-
|
|
4930
|
+
selectedLocalizedStartTimeTupleRef.current = nextTimeTuple;
|
|
4911
4931
|
endDateInputRef.current.focus();
|
|
4912
4932
|
}
|
|
4913
4933
|
else {
|
|
4914
4934
|
// If an end date has already been selected
|
|
4915
|
-
if (
|
|
4935
|
+
if (selectedLocalizedEndDateTupleRef.current) {
|
|
4916
4936
|
// we must update the selected end date accordingly and submit it
|
|
4917
|
-
const nextEndDate = getDateFromDateAndTimeTuple(
|
|
4918
|
-
|
|
4937
|
+
const nextEndDate = getDateFromDateAndTimeTuple(selectedLocalizedEndDateTupleRef.current, nextTimeTuple, true);
|
|
4938
|
+
selectedLocalizedEndDateRef.current = nextEndDate;
|
|
4919
4939
|
submit();
|
|
4920
4940
|
}
|
|
4921
|
-
|
|
4941
|
+
selectedLocalizedEndTimeTupleRef.current = nextTimeTuple;
|
|
4922
4942
|
}
|
|
4923
4943
|
submit();
|
|
4924
4944
|
}, [submit]);
|
|
@@ -4927,7 +4947,7 @@ disabled = false, isCompact = false, isHistorical = false, isLabelHidden = false
|
|
|
4927
4947
|
forceUpdate();
|
|
4928
4948
|
}, [forceUpdate]);
|
|
4929
4949
|
useClickOutside([endDateInputRef, startDateInputRef], closeRangeCalendarPicker, baseContainer);
|
|
4930
|
-
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue:
|
|
4950
|
+
return (jsxs(Fieldset, { ...nativeProps, children: [jsx(Legend, { isDisabled: disabled, isHidden: isLabelHidden, children: label }), jsxs(Box$2, { isDisabled: disabled, children: [jsx(Field, { children: jsx(DateInput, { ref: startDateInputRef, defaultValue: selectedLocalizedStartDateTupleRef.current, disabled: disabled, isCompact: isCompact, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, isStartDate: true, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.START, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleStartDateInputNext }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: startTimeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedStartTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isLight: isLight, isStartDate: true, minutesRange: minutesRange, onBack: () => startDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.START, nextTimeTuple), onFocus: closeRangeCalendarPicker, onNext: () => endDateInputRef.current.focus(), onPrevious: () => startDateInputRef.current.focus(true) }) })), jsx(Field, { isEndDateField: true, children: jsx(DateInput, { ref: endDateInputRef, defaultValue: selectedLocalizedEndDateTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isForcedFocused: isRangeCalendarPickerOpenRef.current, isLight: isLight, onBack: handleEndDateInputPrevious, onChange: (nextDateTuple, isFilled) => handleDateInputChange(DateRangePosition.END, nextDateTuple, isFilled), onClick: openRangeCalendarPicker, onNext: handleEndDateInputNext, onPrevious: handleEndDateInputPrevious }) }), withTime && (jsx(Field, { isTimeField: true, children: jsx(TimeInput, { ref: endTimeInputRef, baseContainer: baseContainer, defaultValue: selectedLocalizedEndTimeTupleRef.current, disabled: disabled, isCompact: isCompact, isEndDate: true, isLight: isLight, minutesRange: minutesRange, onBack: () => endDateInputRef.current.focus(true), onChange: nextTimeTuple => handleTimeInputFilled(DateRangePosition.END, nextTimeTuple), onFocus: closeRangeCalendarPicker, onPrevious: () => endDateInputRef.current.focus(true) }) }))] }), jsx(RangeCalendarPicker, { defaultValue: rangeCalendarPickerDefaultValue, isHistorical: isHistorical, isOpen: isRangeCalendarPickerOpenRef.current, onChange: handleRangeCalendarPickerChange })] }));
|
|
4931
4951
|
}
|
|
4932
4952
|
const Box$2 = styled.div `
|
|
4933
4953
|
* {
|
|
@@ -5342,6 +5362,9 @@ function FormikAutoComplete({ name, ...originalProps }) {
|
|
|
5342
5362
|
const [field, , helpers] = useField(name);
|
|
5343
5363
|
// eslint-disable-next-line react-hooks/exhaustive-deps, @typescript-eslint/naming-convention
|
|
5344
5364
|
const defaultValue = useMemo(() => field.value, []);
|
|
5365
|
+
if (!defaultValue) {
|
|
5366
|
+
return jsx(AutoComplete, { name: name, onChange: helpers.setValue, ...originalProps });
|
|
5367
|
+
}
|
|
5345
5368
|
return jsx(AutoComplete, { defaultValue: defaultValue, name: name, onChange: helpers.setValue, ...originalProps });
|
|
5346
5369
|
}
|
|
5347
5370
|
|