@helsenorge/datepicker 5.15.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 +1441 -0
- package/__mocks__/styleMock.d.ts +2 -0
- package/__mocks__/styleMock.d.ts.map +1 -0
- package/__mocks__/styleMock.js +2 -0
- package/__mocks__/styleMock.js.map +1 -0
- package/components/DatePicker/DatePicker.d.ts +40 -0
- package/components/DatePicker/DatePicker.d.ts.map +1 -0
- package/components/DatePicker/DatePickerPopup.d.ts +10 -0
- package/components/DatePicker/DatePickerPopup.d.ts.map +1 -0
- package/components/DatePicker/DateTime.d.ts +18 -0
- package/components/DatePicker/DateTime.d.ts.map +1 -0
- package/components/DatePicker/DateTimePickerWrapper.d.ts +15 -0
- package/components/DatePicker/DateTimePickerWrapper.d.ts.map +1 -0
- package/components/DatePicker/index.d.ts +7 -0
- package/components/DatePicker/index.d.ts.map +1 -0
- package/components/DatePicker/index.js +2 -0
- package/components/DatePicker/index.js.map +1 -0
- package/components/DatePicker/position-utils.d.ts +27 -0
- package/components/DatePicker/position-utils.d.ts.map +1 -0
- package/components/DatePicker/styles.module.scss +295 -0
- package/components/DatePicker/styles.module.scss.d.ts +35 -0
- package/components/DatePicker/validate-utils.d.ts +18 -0
- package/components/DatePicker/validate-utils.d.ts.map +1 -0
- package/package.json +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleMock.d.ts","sourceRoot":"","sources":["../../src/__mocks__/styleMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleMock.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DayPickerSingleProps } from 'react-day-picker';
|
|
3
|
+
export type DateFormat = 'dd.MM.yyyy';
|
|
4
|
+
export interface DatePickerProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'aria-describedby' | 'onBlur'>, Pick<DayPickerSingleProps, 'dir' | 'initialFocus'> {
|
|
5
|
+
/** Adds custom classes to the element. */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Sets aria-label on the button that opens the datepicker dialogue */
|
|
8
|
+
dateButtonAriaLabel?: string;
|
|
9
|
+
/** Sets the format of the date - only applies for desktop use. Native mobile date fields base their formats on the device */
|
|
10
|
+
dateFormat?: DateFormat;
|
|
11
|
+
/** Sets the date of the component */
|
|
12
|
+
dateValue?: Date;
|
|
13
|
+
/** Sets the current month */
|
|
14
|
+
defaultMonth?: Date;
|
|
15
|
+
/** Disables the days in the datepicker */
|
|
16
|
+
disableDays?: Date[];
|
|
17
|
+
/** Disables weekends in the datepicker */
|
|
18
|
+
disableWeekends?: boolean;
|
|
19
|
+
/** Activates Error style for the input */
|
|
20
|
+
error?: boolean;
|
|
21
|
+
/** Error text to show above the component */
|
|
22
|
+
errorText?: string;
|
|
23
|
+
/** Content to be rendered in the footer of the datepicker popup */
|
|
24
|
+
footerContent?: React.ReactNode;
|
|
25
|
+
/** Label of the input */
|
|
26
|
+
label?: React.ReactNode;
|
|
27
|
+
/** Sets the locale of the datepicker */
|
|
28
|
+
locale?: Locale;
|
|
29
|
+
/** Maximum date allowed to be selected */
|
|
30
|
+
maxDate?: Date;
|
|
31
|
+
/** Minimum date allowed to be selected */
|
|
32
|
+
minDate?: Date;
|
|
33
|
+
/** onChange callback trigges ved endring i valgt dato */
|
|
34
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<Element, MouseEvent>, date: Date | string | undefined) => void;
|
|
35
|
+
/** Sets the data-testid attribute. */
|
|
36
|
+
testId?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const DatePicker: React.ForwardRefExoticComponent<DatePickerProps & React.RefAttributes<HTMLInputElement>>;
|
|
39
|
+
export default DatePicker;
|
|
40
|
+
//# sourceMappingURL=DatePicker.d.ts.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EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACzI,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,UAAU,0FAqMrB,CAAC;AAIH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DayPickerSingleProps } from 'react-day-picker';
|
|
3
|
+
interface DatePickerPopupProps extends Pick<DayPickerSingleProps, 'dir' | 'disabled' | 'footer' | 'fromDate' | 'initialFocus' | 'locale' | 'month' | 'selected' | 'onSelect' | 'onMonthChange' | 'toDate'> {
|
|
4
|
+
datepickerWrapperRef: React.RefObject<HTMLDivElement>;
|
|
5
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
6
|
+
testId?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const DatePickerPopup: React.FC<DatePickerPopupProps>;
|
|
9
|
+
export default DatePickerPopup;
|
|
10
|
+
//# sourceMappingURL=DatePickerPopup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePickerPopup.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DatePickerPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAGhD,OAAO,EAAa,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAcnE,UAAU,oBACR,SAAQ,IAAI,CACV,oBAAoB,EACpB,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,eAAe,GAAG,QAAQ,CACxI;IACD,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACtD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqDnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type TimeUnit = 'hours' | 'minutes';
|
|
3
|
+
export interface DateTimeProps extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'aria-describedby' | 'aria-labelledby' | 'onChange' | 'disabled'> {
|
|
4
|
+
defaultValue?: number;
|
|
5
|
+
/** Activates Error style for the input */
|
|
6
|
+
error?: boolean;
|
|
7
|
+
/** Error text to show above the component */
|
|
8
|
+
errorText?: string;
|
|
9
|
+
/** Label of the input */
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
/** Sets the unit of time for the input field */
|
|
12
|
+
timeUnit: TimeUnit;
|
|
13
|
+
/** Sets the data-testid attribute. */
|
|
14
|
+
testId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const DateTime: React.ForwardRefExoticComponent<DateTimeProps & React.RefAttributes<HTMLInputElement>>;
|
|
17
|
+
export default DateTime;
|
|
18
|
+
//# sourceMappingURL=DateTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DateTime.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAQxC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3C,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,UAAU,GAAG,UAAU,CAAC;IACpI,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,gDAAgD;IAChD,QAAQ,EAAE,QAAQ,CAAC;IACnB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAWD,eAAO,MAAM,QAAQ,wFAyDnB,CAAC;AAIH,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type TimeUnits = 'hours' | 'minutes';
|
|
3
|
+
interface DateTimePickerWrapperProps {
|
|
4
|
+
/** Sets the children of the datetimepicker - the DatePicker and DateTime components go here */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Error text to show above the component */
|
|
7
|
+
errorText?: string;
|
|
8
|
+
/** text placed in the legend tag of the fieldset */
|
|
9
|
+
legend?: string;
|
|
10
|
+
/** Sets the data-testid attribute. */
|
|
11
|
+
testId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const DateTimePickerWrapper: React.ForwardRefExoticComponent<DateTimePickerWrapperProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export default DateTimePickerWrapper;
|
|
15
|
+
//# sourceMappingURL=DateTimePickerWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePickerWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DateTimePickerWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5C,UAAU,0BAA0B;IAClC,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,qBAAqB,mGA+BhC,CAAC;AAIH,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DatePicker } from './DatePicker';
|
|
2
|
+
export { DateTime } from './DateTime';
|
|
3
|
+
export { DateTimePickerWrapper } from './DateTimePickerWrapper';
|
|
4
|
+
export * from './validate-utils';
|
|
5
|
+
export * from './DatePicker';
|
|
6
|
+
export default DatePicker;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import n,{useRef as $,useState as R}from"react";import{format as A,isValid as _,parse as W,isAfter as ke,isBefore as Ie,isWithinInterval as Re,isSameDay as Ce}from"date-fns";import{nb as Be}from"date-fns/locale";import Me from"@helsenorge/designsystem-react/components/Button";import Ne from"@helsenorge/designsystem-react/components/Icons";import Ae from"@helsenorge/designsystem-react/components/Icons/Calendar";import j from"@helsenorge/designsystem-react/components/Input";import{KeyboardEventKey as ee}from"@helsenorge/designsystem-react/constants";import{useKeyboardEvent as te}from"@helsenorge/designsystem-react/hooks/useKeyboardEvent";import{useOutsideEvent as We}from"@helsenorge/designsystem-react/hooks/useOutsideEvent";import{usePseudoClasses as se}from"@helsenorge/designsystem-react/hooks/usePseudoClasses";import{isMobileUA as _e}from"@helsenorge/designsystem-react/utils/mobile";import{isMutableRefObject as ie,mergeRefs as ce}from"@helsenorge/designsystem-react/utils/refs";import S from"classnames";import{DayPicker as Ve}from"react-day-picker";import xe from"react-day-picker/dist/style.module.css?used";import{PopOverVariant as h}from"@helsenorge/designsystem-react/components/PopOver";import{useFocusTrap as Oe}from"@helsenorge/designsystem-react/hooks/useFocusTrap";import{useInterval as Fe}from"@helsenorge/designsystem-react/hooks/useInterval";import{useIsVisible as Le}from"@helsenorge/designsystem-react/hooks/useIsVisible";import{useLayoutEvent as He}from"@helsenorge/designsystem-react/hooks/useLayoutEvent";import{useSize as Te}from"@helsenorge/designsystem-react/hooks/useSize";import l from"./styles.module.scss";import Ke from"@helsenorge/designsystem-react/components/ErrorWrapper";import{isComponent as re}from"@helsenorge/designsystem-react/utils/component";const Xe=329,E=12,F=26,le=20,Z=9,oe=12,ue=(e,t)=>e.top>t.height+F?h.positionabove:h.positionbelow,Ue=e=>e.left+e.width/4,Ge=e=>document.documentElement.clientWidth-e.right+e.width/4,$e=(e,t)=>e.left+t.width,je=e=>e.left>E,Se=(e,t)=>$e(e,t)<document.documentElement.clientWidth-E,Ze=(e,t)=>Se(e,t)?je(e)?"floating":"left":"right",U=(e,t)=>e.top-F-t.height,G=e=>e.bottom+F,qe=()=>document.documentElement.clientWidth-E*2,Je=()=>document.documentElement.clientWidth>Xe+E*2,ne=e=>e.top-F-Z+5,Qe=e=>Ue(e)-le/2,Ye=e=>Ge(e)-le/2,ze=(e,t)=>{const o=Ze(e,t),r=ue(e,t);return o==="left"?r===h.positionabove?"leftabove":"leftbelow":o==="right"?r===h.positionabove?"rightabove":"rightbelow":r===h.positionabove?"floatingabove":"floatingbelow"},et=(e,t)=>{const o=ze(e,t),r=Je()?void 0:qe();return o==="leftabove"?{left:E,top:U(e,t),width:r}:o==="leftbelow"?{left:E,top:G(e),width:r}:o==="rightabove"?{right:E,top:U(e,t),width:r}:o==="rightbelow"?{right:E,top:G(e),width:r}:o==="floatingbelow"?{left:e.left,top:G(e),width:r}:{left:e.left,top:U(e,t),width:r}},tt=(e,t,o)=>{const r=Qe(t),a=Ye(t),s=e.left+oe,c=e.right+oe;return e.right?o===h.positionabove?{right:a>c?a:c,top:ne(t)}:{right:a>c?a:c,top:t.bottom+Z}:o===h.positionabove?{left:r>s?r:s,top:ne(t)}:{left:r>s?r:s,top:t.bottom+Z}},rt=e=>{const{datepickerWrapperRef:t,footer:o,inputRef:r,testId:a,...s}=e,c=$(null),[u,C]=R(),b=Te(t),P=Le(r,0);Oe(t,!0);const p=()=>{var d;C((d=r.current)==null?void 0:d.getBoundingClientRect())};n.useEffect(()=>{p()},[]),Fe(p,500),He(p,["scroll","resize"],10);const B=S(l["datepicker-popup-container"],{[l["datepicker-popup-container--visible"]]:P}),f=u&&b&&ue(u,b),M=S(l["datepicker-popup-arrow"],{[l["datepicker-popup-arrow--visible"]]:P,[l["datepicker-popup-arrow--over"]]:f===h.positionbelow,[l["datepicker-popup-arrow--under"]]:f===h.positionabove}),m=u&&b&&et(u,b),v=m&&u&&f&&tt(m,u,f),y={...xe,...l};return n.createElement(n.Fragment,null,n.createElement("div",{className:B,"data-testid":a,ref:t,style:m},n.createElement(Ve,{captionLayout:"dropdown-buttons",classNames:y,mode:"single",modifiersClassNames:{today:l["day--today"],selected:l.day_selected,disabled:l["day--disabled"]},footer:n.createElement("span",{className:l["footer-wrapper"]},o),fixedWeeks:!0,...s})),n.createElement("div",{ref:c,className:M,style:v}))},ot=rt,de=n.forwardRef((e,t)=>{const{className:o,dateButtonAriaLabel:r,dateFormat:a="dd.MM.yyyy",dateValue:s,defaultMonth:c,dir:u,disableDays:C=[],disableWeekends:b,error:P,errorText:p,footerContent:B,label:f,locale:M=Be,maxDate:m,minDate:v,onBlur:y,onChange:d,testId:w,...V}=e,[L,x]=R(s),[q,H]=R(L?A(L,a):""),[me,T]=R(c),[K,D]=R(!1),[X,J]=R(!1),ge={dayOfWeek:[0,6]},he=b?[...C,ge]:C,N=$(null),O=$(null),{refObject:g}=se(ie(t)?t:null),Q=ce([t,g]);We(O,i=>{var I;const k=i.target;(I=N==null?void 0:N.current)!=null&&I.contains(k)||D(!1)}),n.useEffect(()=>{H(s?A(s,a):""),_(s)&&(x(s),T(s))},[s]),n.useEffect(()=>{X&&g.current&&g.current.focus()},[X]);const Y=()=>{g!=null&&g.current&&g.current.focus(),D(!1)};te(O,Y,[ee.Escape]),te(N,Y,[ee.Escape]);const z=(i,k)=>{H(i.currentTarget.value);const I=W(i.currentTarget.value,k,new Date);_(I)?(x(I),T(I)):x(void 0),d&&d(i,i.currentTarget.value)},be=()=>{X?J(!1):D(!0)},ye=(i,k,I,De)=>{if(J(!0),!i){D(!1);return}x(i),g.current&&(H(A(i,a)),D(!1)),d&&d(De,i)},we=i=>{var k;(k=O.current)!=null&&k.contains(i.relatedTarget)||D(!1),y&&y(i)},Ee=i=>{i==null||i.stopPropagation(),D(!K)},Pe=n.createElement(j,{error:P,errorText:p,label:f,max:m?A(m,"yyyy-MM-dd"):"",min:v?A(v,"yyyy-MM-dd"):"",type:"date",ref:Q,value:q,width:14,...V,onBlur:i=>{y&&y(i)},onChange:i=>z(i,"yyyy-MM-dd")}),ve=n.createElement(n.Fragment,null,n.createElement("div",{className:l["date-input-wrapper"]},n.createElement(j,{error:P,errorText:p,inputWrapperRef:N,label:f,onFocus:be,type:"text",ref:Q,value:q,width:12,...V,onBlur:we,onChange:i=>z(i,a),rightOfInput:n.createElement(Me,{ariaLabel:r??"Velg dato",onClick:Ee,tabIndex:K?-1:0,variant:"borderless",wrapperClassName:l["date-button"]},n.createElement(Ne,{color:"black",svgIcon:Ae}))})),K&&n.createElement(ot,{dir:u,disabled:he,datepickerWrapperRef:O,footer:B,fromDate:v,toDate:m,inputRef:g,locale:M,month:me,selected:L,onSelect:ye,onMonthChange:T}));return n.createElement("div",{className:o,"data-testid":w},_e()?Pe:ve)});de.displayName="DatePicker";const ae=e=>{const t=String(e);return t.length===1?"0"+t:t},nt=e=>!e||/^\d+$/.test(e)&&e.length<=2,pe=n.forwardRef((e,t)=>{const{defaultValue:o,error:r,errorText:a,label:s,onChange:c,timeUnit:u,testId:C,...b}=e,[P,p]=R(typeof o<"u"?ae(o):""),{refObject:B}=se(ie(t)?t:null),f=ce([t,B]),M=d=>{const w=d.target.value;nt(w)&&(p(w),c&&c(d))},m=d=>{const w=ae(d.target.value);p(w),c&&c(d)},v=d=>{const w=/[0-9]/,V=["Backspace"," ","Enter","Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"];!w.test(d.key)&&!V.includes(d.key)&&d.preventDefault()},y=()=>u==="hours"&&n.createElement("span",{className:l["time-separator"]},":");return n.createElement("div",{"data-testid":C},n.createElement(j,{error:r,errorText:a,label:s,max:u==="hours"?23:59,min:0,type:"number",ref:f,value:P,width:5,...b,onChange:M,onBlur:m,rightOfInput:y(),onKeyDown:v}))});pe.displayName="DateTime";const at=n.forwardRef((e,t)=>{const{children:o,errorText:r,legend:a,testId:s}=e,c=u=>re(u,de)?n.cloneElement(u,{className:S(l["date-time-picker-wrapper__date-picker"]),error:!!r}):re(u,pe)?n.cloneElement(u,{error:!!r}):u;return n.createElement("div",{ref:t,tabIndex:-1},n.createElement(Ke,{errorText:r},e.legend?n.createElement("fieldset",{className:l["date-time-picker-wrapper"],"data-testid":s},e.legend&&n.createElement("legend",{className:l["date-time-picker-wrapper__legend"]},a),n.Children.map(o,c)):n.createElement("div",{className:l["date-time-picker-wrapper"]},n.Children.map(o,c))))});at.displayName="DateTimePickerWrapper";const fe=e=>{const t=["yyyy-MM-dd","dd.MM.yyyy"];for(const o of t){const r=W(e,o,new Date);if(_(r))return r}return null},At=e=>{const t=new Date(e);return t instanceof Date&&!isNaN(t.getTime())},Wt=(e,t,o,r)=>{const a=fe(e),s=typeof o<"u",c=typeof r<"u";return!a||s&&!_(o)||c&&!_(r)?"Invalid date format":s&&!c&&ke(a,o)||c&&!s&&Ie(a,r)||s&&c&&Re(a,{start:o,end:r})?!0:t},_t=(e,t,o)=>{const r=fe(e);return r?t.some(a=>Ce(a,r))?o:!0:"Invalid date format"},Vt=(e,t,o,r)=>{const a=W((e.hour+":"+e.minute).toString(),"HH:mm",new Date),s=W(((o==null?void 0:o.hour)+":"+(o==null?void 0:o.minute)).toString(),"HH:mm",new Date),c=W(((r==null?void 0:r.hour)+":"+(r==null?void 0:r.minute)).toString(),"HH:mm",new Date);return(typeof o>"u"||a>=s)&&(typeof r>"u"||a<=c)?!0:t};export{de as DatePicker,pe as DateTime,at as DateTimePickerWrapper,de as default,At as isValidDate,fe as parseInputDate,_t as validateDisabledDates,Wt as validateMinMaxDate,Vt as validateMinTimeMaxTime};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/DatePicker/position-utils.ts","../../../src/components/DatePicker/DatePickerPopup.tsx","../../../src/components/DatePicker/DatePicker.tsx","../../../src/components/DatePicker/DateTime.tsx","../../../src/components/DatePicker/DateTimePickerWrapper.tsx","../../../src/components/DatePicker/validate-utils.ts"],"sourcesContent":["import { CSSProperties } from 'react';\n\nimport { PopOverVariant } from '@helsenorge/designsystem-react/components/PopOver';\n\ntype HorizontalPosition = 'left' | 'right' | 'floating';\ntype BubblePosition = 'leftabove' | 'leftbelow' | 'rightabove' | 'rightbelow' | 'floatingabove' | 'floatingbelow';\n\n/** Bredde på hjelpeboble */\nconst BUBBLE_WIDTH_PX = 329;\n/** Hjelpeboblen skal holde avstand til venstre/høyre kant på vinduet */\nconst WINDOW_MARGIN_PX = 12;\n/** Vertikal avstand fra hjelpeboble til kontroller */\nconst BUBBLE_VERTICAL_OFFSET_PX = 26;\n/** Høyde/bredde på pil */\nconst ARROW_WIDTH_PX = 20;\n/** Avstand fra pil til hjelpeboble */\nconst ARROW_VERTICAL_OFFSET_PX = 9;\n/** Pilen skal holde avstand til venstre/høyre kant av hjelpeboblen */\nconst ARROW_HORIZONTAL_MARGIN_PX = 12;\n\n/**\n * Beregn om hjelpeboblen skal vises over eller under kontrolleren\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @param variant Ønsket plassering av hjelpeboblen (over/under/automatisk)\n * @returns Om hjelpeboblen skal vises over eller under\n */\nexport const getVerticalPosition = (controllerSize: DOMRect, bubbleSize: DOMRect): keyof typeof PopOverVariant => {\n if (controllerSize.top > bubbleSize.height + BUBBLE_VERTICAL_OFFSET_PX) {\n return PopOverVariant.positionabove;\n } else {\n return PopOverVariant.positionbelow;\n }\n};\n\n/**\n * Finn horisontalt midtpunkt på kontrolleren i forhold til venstre kant av vinduet\n * @param controllerSize DOMRect for controlleren\n * @returns Horisontalt senter av controlleren i px\n */\nconst getControllerLeftEdgePx = (controllerSize: DOMRect): number => controllerSize.left + controllerSize.width / 4;\n\n/**\n * Finn horisontalt midtpunkt på kontrolleren i forhold til høyre kant av vinduet\n * @param controllerSize DOMRect for controlleren\n * @returns Horisontalt senter av controlleren i px\n */\nconst getControllerRightEdgePx = (controllerSize: DOMRect): number =>\n document.documentElement.clientWidth - controllerSize.right + controllerSize.width / 4;\n\n/**\n * Finn venstre kant av hjelpeboblen i forhold til kontrolleren\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns Venstre kant av hjelpeboblen i px\n */\n\n/**\n * Finn høyre kant av hjelpeboblen i forhold til kontrolleren\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns Høyre kant av hjelpeboblen i px\n */\nconst getBubbleRightPx = (controllerSize: DOMRect, bubbleSize: DOMRect): number => {\n return controllerSize.left + bubbleSize.width;\n};\n\n/**\n * Sjekk om venstre kant av hjelpeboblen er innenfor vinduet\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns true dersom venstre kant er innenfor vinduet\n */\nconst getBubbleLeftVisible = (controllerSize: DOMRect): boolean => {\n return controllerSize.left > WINDOW_MARGIN_PX;\n};\n\n/**\n * Sjekk om høyre kant av hjelpeboblen er innenfor vinduet\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns true dersom høyre kant er innenfor vinduet\n */\nconst getBubbleRightIsVisible = (controllerSize: DOMRect, bubbleSize: DOMRect): boolean => {\n const bubbleRightPx = getBubbleRightPx(controllerSize, bubbleSize);\n\n return bubbleRightPx < document.documentElement.clientWidth - WINDOW_MARGIN_PX;\n};\n\n/**\n * Finn riktig horisontal plassering til hjelpeboblen\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns left, right eller floating\n */\nconst getHorizontalPosition = (controllerSize: DOMRect, bubbleSize: DOMRect): HorizontalPosition => {\n if (!getBubbleRightIsVisible(controllerSize, bubbleSize)) {\n return 'right';\n }\n if (!getBubbleLeftVisible(controllerSize)) {\n return 'left';\n }\n\n return 'floating';\n};\n\n/**\n * Finn vertikal plassering av hjelpeboblen når den skal vises over\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns \"Top\" for hjelpeboblen i px\n */\nconst getBubbleAbovePx = (controllerSize: DOMRect, bubbleSize: DOMRect): number =>\n controllerSize.top - BUBBLE_VERTICAL_OFFSET_PX - bubbleSize.height;\n\n/**\n * Finn vertikal plassering av hjelpeboblen når den skal vises under\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @returns \"Top\" for hjelpeboblen i px\n */\nconst getBubbleBelowPx = (controllerSize: DOMRect): number => controllerSize.bottom + BUBBLE_VERTICAL_OFFSET_PX;\n\n/**\n * Finn maks bredde på hjelpeboblen i forhold til vinduet\n * @returns Bredde på hjelpeboblen i px\n */\nconst getBubbleWidth = (): number => document.documentElement.clientWidth - WINDOW_MARGIN_PX * 2;\n\n/**\n * Sjekk om hjelpeboblen har plass i vinduet\n * @returns true dersom det er plass til hjelpeboblen i vinduet\n */\nconst getBubbleFitsInWindow = (): boolean => {\n return document.documentElement.clientWidth > BUBBLE_WIDTH_PX + WINDOW_MARGIN_PX * 2;\n};\n\n/**\n * Finn vertikal plassering av pilen når den skal vises over\n * @param controllerSize DOMRect for controlleren\n * @returns \"Top\" for pilen i px\n */\nconst getArrowTopxPx = (controllerSize: DOMRect): number => controllerSize.top - BUBBLE_VERTICAL_OFFSET_PX - ARROW_VERTICAL_OFFSET_PX + 5;\n\n/**\n * Finn horisontal plassering av pilen i forhold til venstre kant av vinduet\n * @param controllerSize DOMRect for controlleren\n * @returns Venstre kant av pilen i px\n */\nconst getArrowLeftPx = (controllerSize: DOMRect): number => getControllerLeftEdgePx(controllerSize) - ARROW_WIDTH_PX / 2;\n\n/**\n * Finn horisontal plassering av pilen\n * @param controllerSize DOMRect for controlleren\n * @returns Venstre kant av pilen i px\n */\nconst getArrowRightPx = (controllerSize: DOMRect): number => getControllerRightEdgePx(controllerSize) - ARROW_WIDTH_PX / 2;\n\n/**\n * Finn riktig plassering av hjelpeboblen\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @param variant Ønsket plassering av hjelpeboblen (over/under)\n * @returns Beste mulige plassering av hjelpeboblen\n */\nconst getBubblePosition = (controllerSize: DOMRect, bubbleSize: DOMRect): BubblePosition => {\n const horizontalPosition = getHorizontalPosition(controllerSize, bubbleSize);\n const verticalPosition = getVerticalPosition(controllerSize, bubbleSize);\n\n if (horizontalPosition === 'left') {\n if (verticalPosition === PopOverVariant.positionabove) {\n return 'leftabove';\n }\n return 'leftbelow';\n }\n\n if (horizontalPosition === 'right') {\n if (verticalPosition === PopOverVariant.positionabove) {\n return 'rightabove';\n }\n return 'rightbelow';\n }\n\n if (verticalPosition === PopOverVariant.positionabove) {\n return 'floatingabove';\n }\n\n return 'floatingbelow';\n};\n\n/**\n * Finn riktig plassering av hjelpeboblen\n * @param controllerSize DOMRect for controlleren\n * @param bubbleSize DOMRect for hjelpeboblen\n * @param variant Ønsket plassering av hjelpeboblen (over/under)\n * @returns CSSProperties som plasserer hjelpeboblen riktig\n */\nexport const getBubbleStyle = (controllerSize: DOMRect, bubbleSize: DOMRect): CSSProperties => {\n const bubblePosition = getBubblePosition(controllerSize, bubbleSize);\n const bubbleWidth = !getBubbleFitsInWindow() ? getBubbleWidth() : undefined;\n\n if (bubblePosition === 'leftabove') {\n return {\n left: WINDOW_MARGIN_PX,\n top: getBubbleAbovePx(controllerSize, bubbleSize),\n width: bubbleWidth,\n };\n }\n if (bubblePosition === 'leftbelow') {\n return { left: WINDOW_MARGIN_PX, top: getBubbleBelowPx(controllerSize), width: bubbleWidth };\n }\n if (bubblePosition === 'rightabove') {\n return { right: WINDOW_MARGIN_PX, top: getBubbleAbovePx(controllerSize, bubbleSize), width: bubbleWidth };\n }\n if (bubblePosition === 'rightbelow') {\n return { right: WINDOW_MARGIN_PX, top: getBubbleBelowPx(controllerSize), width: bubbleWidth };\n }\n\n if (bubblePosition === 'floatingbelow') {\n return { left: controllerSize.left, top: getBubbleBelowPx(controllerSize), width: bubbleWidth };\n }\n\n return { left: controllerSize.left, top: getBubbleAbovePx(controllerSize, bubbleSize), width: bubbleWidth };\n};\n\n/**\n * Finn riktig plassering av pilen\n * @param bubbleStyle CSSProperties for hjelpeboblen\n * @param controllerSize DOMRect for kontrolleren\n * @param verticalPosition Ønsket plassering av hjelpeboblen (over/under)\n * @returns CSSProperties som plasserer pilen riktig\n */\nexport const getArrowStyle = (\n bubbleStyle: CSSProperties,\n controllerSize: DOMRect,\n verticalPosition: keyof typeof PopOverVariant\n): CSSProperties => {\n const leftPx = getArrowLeftPx(controllerSize);\n const rightPx = getArrowRightPx(controllerSize);\n const minLeftPx = (bubbleStyle.left as number) + ARROW_HORIZONTAL_MARGIN_PX;\n const minRightPx = (bubbleStyle.right as number) + ARROW_HORIZONTAL_MARGIN_PX;\n\n if (bubbleStyle.right) {\n if (verticalPosition === PopOverVariant.positionabove) {\n return {\n right: rightPx > minRightPx ? rightPx : minRightPx,\n top: getArrowTopxPx(controllerSize),\n };\n }\n\n return {\n right: rightPx > minRightPx ? rightPx : minRightPx,\n top: controllerSize.bottom + ARROW_VERTICAL_OFFSET_PX,\n };\n }\n\n if (verticalPosition === PopOverVariant.positionabove) {\n return {\n left: leftPx > minLeftPx ? leftPx : minLeftPx,\n top: getArrowTopxPx(controllerSize),\n };\n }\n\n return {\n left: leftPx > minLeftPx ? leftPx : minLeftPx,\n top: controllerSize.bottom + ARROW_VERTICAL_OFFSET_PX,\n };\n};\n","import React, { useState, useRef } from 'react';\n\nimport classNames from 'classnames';\nimport { DayPicker, DayPickerSingleProps } from 'react-day-picker';\nimport reactdaypickerstyles from 'react-day-picker/dist/style.module.css';\n\nimport { PopOverVariant } from '@helsenorge/designsystem-react/components/PopOver';\nimport { useFocusTrap } from '@helsenorge/designsystem-react/hooks/useFocusTrap';\nimport { useInterval } from '@helsenorge/designsystem-react/hooks/useInterval';\nimport { useIsVisible } from '@helsenorge/designsystem-react/hooks/useIsVisible';\nimport { useLayoutEvent } from '@helsenorge/designsystem-react/hooks/useLayoutEvent';\nimport { useSize } from '@helsenorge/designsystem-react/hooks/useSize';\n\nimport { getArrowStyle, getBubbleStyle, getVerticalPosition } from './position-utils';\n\nimport styles from './styles.module.scss';\n\ninterface DatePickerPopupProps\n extends Pick<\n DayPickerSingleProps,\n 'dir' | 'disabled' | 'footer' | 'fromDate' | 'initialFocus' | 'locale' | 'month' | 'selected' | 'onSelect' | 'onMonthChange' | 'toDate'\n > {\n datepickerWrapperRef: React.RefObject<HTMLDivElement>;\n inputRef: React.RefObject<HTMLInputElement>;\n testId?: string;\n}\n\nconst DatePickerPopup: React.FC<DatePickerPopupProps> = props => {\n const { datepickerWrapperRef, footer, inputRef, testId, ...rest } = props;\n const arrowRef = useRef<HTMLDivElement>(null);\n const [controllerSize, setControllerSize] = useState<DOMRect>();\n const bubbleSize = useSize(datepickerWrapperRef);\n const controllerisVisible = useIsVisible(inputRef, 0);\n useFocusTrap(datepickerWrapperRef, true);\n\n const updateControllerSize = (): void => {\n setControllerSize(inputRef.current?.getBoundingClientRect());\n };\n\n React.useEffect(() => {\n updateControllerSize();\n }, []);\n\n useInterval(updateControllerSize, 500);\n useLayoutEvent(updateControllerSize, ['scroll', 'resize'], 10);\n\n const datepickerPopupContainerClasses = classNames(styles['datepicker-popup-container'], {\n [styles['datepicker-popup-container--visible']]: controllerisVisible,\n });\n const verticalPosition = controllerSize && bubbleSize && getVerticalPosition(controllerSize, bubbleSize);\n const popupArrowClasses = classNames(styles['datepicker-popup-arrow'], {\n [styles['datepicker-popup-arrow--visible']]: controllerisVisible,\n [styles['datepicker-popup-arrow--over']]: verticalPosition === PopOverVariant.positionbelow,\n [styles['datepicker-popup-arrow--under']]: verticalPosition === PopOverVariant.positionabove,\n });\n\n const bubbleStyle = controllerSize && bubbleSize && getBubbleStyle(controllerSize, bubbleSize);\n const arrowStyle = bubbleStyle && controllerSize && verticalPosition && getArrowStyle(bubbleStyle, controllerSize, verticalPosition);\n\n const datePickerClassNames = {\n ...reactdaypickerstyles,\n ...styles,\n };\n\n return (\n <>\n <div className={datepickerPopupContainerClasses} data-testid={testId} ref={datepickerWrapperRef} style={bubbleStyle}>\n <DayPicker\n captionLayout=\"dropdown-buttons\"\n classNames={datePickerClassNames}\n mode={'single'}\n modifiersClassNames={{ today: styles['day--today'], selected: styles['day_selected'], disabled: styles['day--disabled'] }}\n footer={<span className={styles['footer-wrapper']}>{footer}</span>}\n fixedWeeks\n {...rest}\n />\n </div>\n <div ref={arrowRef} className={popupArrowClasses} style={arrowStyle} />\n </>\n );\n};\n\nexport default DatePickerPopup;\n","import React, { useState, useRef } from 'react';\n\nimport { format, isValid, parse } from 'date-fns';\nimport { nb } from 'date-fns/locale';\nimport { ActiveModifiers, DayOfWeek, DayPickerSingleProps, SelectSingleEventHandler } from 'react-day-picker';\n\nimport Button from '@helsenorge/designsystem-react/components/Button';\nimport Icon from '@helsenorge/designsystem-react/components/Icons';\nimport Calendar from '@helsenorge/designsystem-react/components/Icons/Calendar';\nimport Input from '@helsenorge/designsystem-react/components/Input';\nimport { KeyboardEventKey } from '@helsenorge/designsystem-react/constants';\nimport { useKeyboardEvent } from '@helsenorge/designsystem-react/hooks/useKeyboardEvent';\nimport { useOutsideEvent } from '@helsenorge/designsystem-react/hooks/useOutsideEvent';\nimport { usePseudoClasses } from '@helsenorge/designsystem-react/hooks/usePseudoClasses';\nimport { isMobileUA } from '@helsenorge/designsystem-react/utils/mobile';\nimport { isMutableRefObject, mergeRefs } from '@helsenorge/designsystem-react/utils/refs';\n\nimport DatePickerPopup from './DatePickerPopup';\n\nimport styles from './styles.module.scss';\n\nexport type DateFormat = 'dd.MM.yyyy';\n\nexport interface DatePickerProps\n extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'aria-describedby' | 'onBlur'>,\n Pick<DayPickerSingleProps, 'dir' | 'initialFocus'> {\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets aria-label on the button that opens the datepicker dialogue */\n dateButtonAriaLabel?: string;\n /** Sets the format of the date - only applies for desktop use. Native mobile date fields base their formats on the device */\n dateFormat?: DateFormat;\n /** Sets the date of the component */\n dateValue?: Date;\n /** Sets the current month */\n defaultMonth?: Date;\n /** Disables the days in the datepicker */\n disableDays?: Date[];\n /** Disables weekends in the datepicker */\n disableWeekends?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Content to be rendered in the footer of the datepicker popup */\n footerContent?: React.ReactNode;\n /** Label of the input */\n label?: React.ReactNode;\n /** Sets the locale of the datepicker */\n locale?: Locale;\n /** Maximum date allowed to be selected */\n maxDate?: Date;\n /** Minimum date allowed to be selected */\n minDate?: Date;\n /** onChange callback trigges ved endring i valgt dato */\n onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<Element, MouseEvent>, date: Date | string | undefined) => void;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const DatePicker = React.forwardRef((props: DatePickerProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n dateButtonAriaLabel,\n dateFormat = 'dd.MM.yyyy',\n dateValue,\n defaultMonth,\n dir,\n disableDays = [],\n disableWeekends,\n error,\n errorText,\n footerContent,\n label,\n locale = nb,\n maxDate,\n minDate,\n onBlur,\n onChange,\n testId,\n ...rest\n } = props;\n\n const [dateState, setDateState] = useState<Date | undefined>(dateValue);\n const [inputValue, setInputValue] = useState<string>(dateState ? format(dateState, dateFormat) : '');\n const [month, setMonth] = useState<Date | undefined>(defaultMonth);\n const [datePickerOpen, setDatePickerOpen] = useState<boolean>(false);\n const [returnInputFocus, setReturnInputFocus] = useState<boolean>(false);\n const weekendMatcher: DayOfWeek = {\n dayOfWeek: [0, 6],\n };\n const disabledDays: (Date | DayOfWeek)[] = disableWeekends ? [...disableDays, weekendMatcher] : disableDays;\n const inputWrapperRef = useRef<HTMLDivElement>(null);\n const datepickerWrapperRef = useRef<HTMLDivElement>(null);\n const { refObject } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n useOutsideEvent(datepickerWrapperRef, e => {\n const targetAsNode = e.target as Node;\n if (!inputWrapperRef?.current?.contains(targetAsNode)) {\n setDatePickerOpen(false);\n }\n });\n\n React.useEffect(() => {\n setInputValue(dateValue ? format(dateValue, dateFormat) : '');\n\n if (isValid(dateValue)) {\n setDateState(dateValue);\n setMonth(dateValue);\n }\n }, [dateValue]);\n\n React.useEffect(() => {\n if (returnInputFocus && refObject.current) {\n refObject.current.focus();\n }\n }, [returnInputFocus]);\n\n const handleEscapeKeyDown = (): void => {\n refObject?.current && refObject.current.focus();\n setDatePickerOpen(false);\n };\n\n useKeyboardEvent(datepickerWrapperRef, handleEscapeKeyDown, [KeyboardEventKey.Escape]);\n useKeyboardEvent(inputWrapperRef, handleEscapeKeyDown, [KeyboardEventKey.Escape]);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>, inputFormat: string): void => {\n setInputValue(event.currentTarget.value);\n const newDate = parse(event.currentTarget.value, inputFormat, new Date());\n\n if (isValid(newDate)) {\n setDateState(newDate);\n setMonth(newDate);\n } else {\n setDateState(undefined);\n }\n\n onChange && onChange(event, event.currentTarget.value);\n };\n\n const handleInputFocus = (): void => {\n if (!returnInputFocus) {\n setDatePickerOpen(true);\n } else {\n setReturnInputFocus(false);\n }\n };\n\n const handleSingleDatePickerSelect: SelectSingleEventHandler = (\n date: Date | undefined,\n selectedDay: Date,\n activeModifiers: ActiveModifiers,\n e: React.MouseEvent<Element, MouseEvent>\n ): void => {\n setReturnInputFocus(true);\n\n if (!date) {\n setDatePickerOpen(false);\n return;\n }\n\n setDateState(date);\n\n if (refObject.current) {\n setInputValue(format(date, dateFormat));\n setDatePickerOpen(false);\n }\n\n onChange && onChange(e, date);\n };\n\n const handleInputBlur = (e: React.FocusEvent<HTMLInputElement, Element>) => {\n if (!datepickerWrapperRef.current?.contains(e.relatedTarget as Node)) {\n setDatePickerOpen(false);\n }\n onBlur && onBlur(e);\n };\n\n const handleButtonClick = (\n e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null | undefined\n ): void => {\n e?.stopPropagation();\n setDatePickerOpen(!datePickerOpen);\n };\n\n const renderMobile = (\n <Input\n error={error}\n errorText={errorText}\n label={label}\n max={maxDate ? format(maxDate, 'yyyy-MM-dd') : ''}\n min={minDate ? format(minDate, 'yyyy-MM-dd') : ''}\n type=\"date\"\n ref={mergedRefs}\n value={inputValue}\n width={14}\n {...rest}\n onBlur={e => {\n onBlur && onBlur(e);\n }}\n onChange={e => handleInputChange(e, 'yyyy-MM-dd')}\n />\n );\n\n const renderDesktop = (\n <>\n <div className={styles['date-input-wrapper']}>\n <Input\n error={error}\n errorText={errorText}\n inputWrapperRef={inputWrapperRef}\n label={label}\n onFocus={handleInputFocus}\n type=\"text\"\n ref={mergedRefs}\n value={inputValue}\n width={12}\n {...rest}\n onBlur={handleInputBlur}\n onChange={e => handleInputChange(e, dateFormat)}\n rightOfInput={\n <Button\n ariaLabel={dateButtonAriaLabel ?? 'Velg dato'}\n onClick={handleButtonClick}\n tabIndex={datePickerOpen ? -1 : 0}\n variant={'borderless'}\n wrapperClassName={styles['date-button']}\n >\n {<Icon color={'black'} svgIcon={Calendar} />}\n </Button>\n }\n />\n </div>\n {datePickerOpen && (\n <DatePickerPopup\n dir={dir}\n disabled={disabledDays}\n datepickerWrapperRef={datepickerWrapperRef}\n footer={footerContent}\n fromDate={minDate}\n toDate={maxDate}\n inputRef={refObject}\n locale={locale}\n month={month}\n selected={dateState}\n onSelect={handleSingleDatePickerSelect}\n onMonthChange={setMonth}\n />\n )}\n </>\n );\n\n return (\n <div className={className} data-testid={testId}>\n {isMobileUA() ? renderMobile : renderDesktop}\n </div>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n\nexport default DatePicker;\n","import React, { useState } from 'react';\n\nimport Input from '@helsenorge/designsystem-react/components/Input';\nimport { usePseudoClasses } from '@helsenorge/designsystem-react/hooks/usePseudoClasses';\nimport { isMutableRefObject, mergeRefs } from '@helsenorge/designsystem-react/utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport type TimeUnit = 'hours' | 'minutes';\n\nexport interface DateTimeProps\n extends Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'aria-describedby' | 'aria-labelledby' | 'onChange' | 'disabled'> {\n defaultValue?: number;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Label of the input */\n label?: React.ReactNode;\n /** Sets the unit of time for the input field */\n timeUnit: TimeUnit;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst formatAsTwoDigits = (value: string | number): string => {\n const stringValue = String(value);\n return stringValue.length === 1 ? '0' + stringValue : stringValue;\n};\n\nconst isNumericString = (str: string): boolean => {\n return !str || (/^\\d+$/.test(str) && str.length <= 2);\n};\n\nexport const DateTime = React.forwardRef((props: DateTimeProps, ref: React.Ref<HTMLInputElement>) => {\n const { defaultValue, error, errorText, label, onChange, timeUnit, testId, ...rest } = props;\n\n const [inputValue, setInputValue] = useState<number | string | undefined>(\n typeof defaultValue !== 'undefined' ? formatAsTwoDigits(defaultValue) : ''\n );\n const { refObject } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n const value = event.target.value;\n\n if (isNumericString(value)) {\n setInputValue(value);\n onChange && onChange(event);\n }\n };\n\n const handleInputBlur = (event: React.ChangeEvent<HTMLInputElement>): void => {\n const formattedValue = formatAsTwoDigits(event.target.value);\n setInputValue(formattedValue);\n onChange && onChange(event);\n };\n\n /** Firefox stopper ikke vanlige characters fra å skrives til input type number - derfor håndterer vi det selv her */\n const handleInputOnKeyDown = (event: React.KeyboardEvent) => {\n const validChars = /[0-9]/;\n const allowedKeys = ['Backspace', ' ', 'Enter', 'Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\n if (!validChars.test(event.key) && !allowedKeys.includes(event.key)) {\n event.preventDefault();\n }\n };\n\n const renderTimeSeparator = (): React.ReactNode => {\n return timeUnit === 'hours' && <span className={styles['time-separator']}>{':'}</span>;\n };\n\n return (\n <div data-testid={testId}>\n <Input\n error={error}\n errorText={errorText}\n label={label}\n max={timeUnit === 'hours' ? 23 : 59}\n min={0}\n type=\"number\"\n ref={mergedRefs}\n value={inputValue}\n width={5}\n {...rest}\n onChange={handleInputChange}\n onBlur={handleInputBlur}\n rightOfInput={renderTimeSeparator()}\n onKeyDown={handleInputOnKeyDown}\n />\n </div>\n );\n});\n\nDateTime.displayName = 'DateTime';\n\nexport default DateTime;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport ErrorWrapper from '@helsenorge/designsystem-react/components/ErrorWrapper';\nimport { isComponent } from '@helsenorge/designsystem-react/utils/component';\n\nimport DatePicker, { DatePickerProps } from './DatePicker';\nimport DateTime, { DateTimeProps } from './DateTime';\n\nimport styles from './styles.module.scss';\n\nexport type TimeUnits = 'hours' | 'minutes';\n\ninterface DateTimePickerWrapperProps {\n /** Sets the children of the datetimepicker - the DatePicker and DateTime components go here */\n children?: React.ReactNode;\n /** Error text to show above the component */\n errorText?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const DateTimePickerWrapper = React.forwardRef((props: DateTimePickerWrapperProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const { children, errorText, legend, testId } = props;\n\n const mapDateComponents = (child: React.ReactNode): React.ReactNode => {\n if (isComponent<DatePickerProps>(child, DatePicker)) {\n return React.cloneElement(child as React.ReactElement<DatePickerProps>, {\n className: classNames(styles['date-time-picker-wrapper__date-picker']),\n error: !!errorText,\n });\n } else if (isComponent<DateTimeProps>(child, DateTime)) {\n return React.cloneElement(child, {\n error: !!errorText,\n });\n }\n return child;\n };\n\n return (\n <div ref={ref} tabIndex={-1}>\n <ErrorWrapper errorText={errorText}>\n {props.legend ? (\n <fieldset className={styles['date-time-picker-wrapper']} data-testid={testId}>\n {props.legend && <legend className={styles['date-time-picker-wrapper__legend']}>{legend}</legend>}\n {React.Children.map(children, mapDateComponents)}\n </fieldset>\n ) : (\n <div className={styles['date-time-picker-wrapper']}>{React.Children.map(children, mapDateComponents)}</div>\n )}\n </ErrorWrapper>\n </div>\n );\n});\n\nDateTimePickerWrapper.displayName = 'DateTimePickerWrapper';\n\nexport default DateTimePickerWrapper;\n","import { isWithinInterval, isAfter, isBefore, isSameDay, parse, isValid } from 'date-fns';\n\nexport const parseInputDate = (dateString: string): Date | null => {\n const possibleFormats = ['yyyy-MM-dd', 'dd.MM.yyyy'];\n\n for (const format of possibleFormats) {\n const parsedDate = parse(dateString, format, new Date());\n if (isValid(parsedDate)) {\n return parsedDate;\n }\n }\n\n return null;\n};\n\nexport const isValidDate = (dateString: string): boolean => {\n const date = new Date(dateString);\n return date instanceof Date && !isNaN(date.getTime());\n};\n\n/** react-hook-form fromDate and toDate validation */\nexport const validateMinMaxDate = (date: string, errorMessage: string, minDate?: Date, maxDate?: Date): string | true => {\n const formattedDate = parseInputDate(date);\n const hasMinDate = typeof minDate !== 'undefined';\n const hasMaxDate = typeof maxDate !== 'undefined';\n if (!formattedDate || (hasMinDate && !isValid(minDate)) || (hasMaxDate && !isValid(maxDate))) {\n return 'Invalid date format';\n }\n\n if (hasMinDate && !hasMaxDate && isAfter(formattedDate, minDate)) return true;\n else if (hasMaxDate && !hasMinDate && isBefore(formattedDate, maxDate)) return true;\n else if (hasMinDate && hasMaxDate && isWithinInterval(formattedDate, { start: minDate, end: maxDate })) {\n return true;\n }\n\n return errorMessage;\n};\n\n/** react-hook-form fromDate and toDate validation */\nexport const validateDisabledDates = (date: string, disabledDates: Date[], errorMessage: string): string | true => {\n const formattedDate = parseInputDate(date);\n if (!formattedDate) {\n return 'Invalid date format';\n }\n if (!disabledDates.some(d => isSameDay(d, formattedDate))) {\n return true;\n }\n\n return errorMessage;\n};\n\n/** react-hook-form fromTime and toTime validation */\nexport const validateMinTimeMaxTime = (\n time: { hour: number; minute: number },\n errorMessage: string,\n minTime?: { hour: number; minute: number },\n maxTime?: { hour: number; minute: number }\n): string | true => {\n const timeParsed = parse((time.hour + ':' + time.minute).toString(), 'HH:mm', new Date());\n const minTimeParsed = parse((minTime?.hour + ':' + minTime?.minute).toString(), 'HH:mm', new Date());\n const maxTimeParsed = parse((maxTime?.hour + ':' + maxTime?.minute).toString(), 'HH:mm', new Date());\n\n if ((typeof minTime === 'undefined' || timeParsed >= minTimeParsed) && (typeof maxTime === 'undefined' || timeParsed <= maxTimeParsed)) {\n return true;\n }\n\n return errorMessage;\n};\n"],"names":["BUBBLE_WIDTH_PX","WINDOW_MARGIN_PX","BUBBLE_VERTICAL_OFFSET_PX","ARROW_WIDTH_PX","ARROW_VERTICAL_OFFSET_PX","ARROW_HORIZONTAL_MARGIN_PX","getVerticalPosition","controllerSize","bubbleSize","PopOverVariant","getControllerLeftEdgePx","getControllerRightEdgePx","getBubbleRightPx","getBubbleLeftVisible","getBubbleRightIsVisible","getHorizontalPosition","getBubbleAbovePx","getBubbleBelowPx","getBubbleWidth","getBubbleFitsInWindow","getArrowTopxPx","getArrowLeftPx","getArrowRightPx","getBubblePosition","horizontalPosition","verticalPosition","getBubbleStyle","bubblePosition","bubbleWidth","getArrowStyle","bubbleStyle","leftPx","rightPx","minLeftPx","minRightPx","DatePickerPopup","props","datepickerWrapperRef","footer","inputRef","testId","rest","arrowRef","useRef","setControllerSize","useState","useSize","controllerisVisible","useIsVisible","useFocusTrap","updateControllerSize","_a","React","useInterval","useLayoutEvent","datepickerPopupContainerClasses","classNames","styles","popupArrowClasses","arrowStyle","datePickerClassNames","reactdaypickerstyles","DayPicker","DatePickerPopup$1","DatePicker","ref","className","dateButtonAriaLabel","dateFormat","dateValue","defaultMonth","dir","disableDays","disableWeekends","error","errorText","footerContent","label","locale","nb","maxDate","minDate","onBlur","onChange","dateState","setDateState","inputValue","setInputValue","format","month","setMonth","datePickerOpen","setDatePickerOpen","returnInputFocus","setReturnInputFocus","weekendMatcher","disabledDays","inputWrapperRef","refObject","usePseudoClasses","isMutableRefObject","mergedRefs","mergeRefs","useOutsideEvent","e","targetAsNode","isValid","handleEscapeKeyDown","useKeyboardEvent","KeyboardEventKey","handleInputChange","event","inputFormat","newDate","parse","handleInputFocus","handleSingleDatePickerSelect","date","selectedDay","activeModifiers","handleInputBlur","handleButtonClick","renderMobile","Input","renderDesktop","Button","Icon","Calendar","isMobileUA","formatAsTwoDigits","value","stringValue","isNumericString","str","DateTime","defaultValue","timeUnit","formattedValue","handleInputOnKeyDown","validChars","allowedKeys","renderTimeSeparator","DateTimePickerWrapper","children","legend","mapDateComponents","child","isComponent","ErrorWrapper","parseInputDate","dateString","possibleFormats","parsedDate","isValidDate","validateMinMaxDate","errorMessage","formattedDate","hasMinDate","hasMaxDate","isAfter","isBefore","isWithinInterval","validateDisabledDates","disabledDates","d","isSameDay","validateMinTimeMaxTime","time","minTime","maxTime","timeParsed","minTimeParsed","maxTimeParsed"],"mappings":"kwDAQA,MAAMA,GAAkB,IAElBC,EAAmB,GAEnBC,EAA4B,GAE5BC,GAAiB,GAEjBC,EAA2B,EAE3BC,GAA6B,GAStBC,GAAsB,CAACC,EAAyBC,IACvDD,EAAe,IAAMC,EAAW,OAASN,EACpCO,EAAe,cAEfA,EAAe,cASpBC,GAA2BH,GAAoCA,EAAe,KAAOA,EAAe,MAAQ,EAO5GI,GAA4BJ,GAChC,SAAS,gBAAgB,YAAcA,EAAe,MAAQA,EAAe,MAAQ,EAejFK,GAAmB,CAACL,EAAyBC,IAC1CD,EAAe,KAAOC,EAAW,MASpCK,GAAwBN,GACrBA,EAAe,KAAON,EASzBa,GAA0B,CAACP,EAAyBC,IAClCI,GAAiBL,EAAgBC,CAAU,EAE1C,SAAS,gBAAgB,YAAcP,EAS1Dc,GAAwB,CAACR,EAAyBC,IACjDM,GAAwBP,EAAgBC,CAAU,EAGlDK,GAAqBN,CAAc,EAIjC,WAHE,OAHA,QAeLS,EAAmB,CAACT,EAAyBC,IACjDD,EAAe,IAAML,EAA4BM,EAAW,OAQxDS,EAAoBV,GAAoCA,EAAe,OAASL,EAMhFgB,GAAiB,IAAc,SAAS,gBAAgB,YAAcjB,EAAmB,EAMzFkB,GAAwB,IACrB,SAAS,gBAAgB,YAAcnB,GAAkBC,EAAmB,EAQ/EmB,GAAkBb,GAAoCA,EAAe,IAAML,EAA4BE,EAA2B,EAOlIiB,GAAkBd,GAAoCG,GAAwBH,CAAc,EAAIJ,GAAiB,EAOjHmB,GAAmBf,GAAoCI,GAAyBJ,CAAc,EAAIJ,GAAiB,EASnHoB,GAAoB,CAAChB,EAAyBC,IAAwC,CACpF,MAAAgB,EAAqBT,GAAsBR,EAAgBC,CAAU,EACrEiB,EAAmBnB,GAAoBC,EAAg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,EAAGR,CAAa,CAAC,EAIjDD,EAHE,GAHA,qBAOX,EAGaW,GAAyB,CACpCC,EACAZ,EACAa,EACAC,IACkB,CAClB,MAAMC,EAAaxD,GAAOqD,EAAK,KAAO,IAAMA,EAAK,QAAQ,SAAY,EAAA,QAAa,IAAA,IAAM,EAClFI,EAAgBzD,IAAOsD,GAAA,YAAAA,EAAS,MAAO,KAAMA,GAAA,YAAAA,EAAS,SAAQ,SAAY,EAAA,QAAa,IAAA,IAAM,EAC7FI,EAAgB1D,IAAOuD,GAAA,YAAAA,EAAS,MAAO,KAAMA,GAAA,YAAAA,EAAS,SAAQ,SAAY,EAAA,QAAa,IAAA,IAAM,EAE9F,OAAA,OAAOD,EAAY,KAAeE,GAAcC,KAAmB,OAAOF,EAAY,KAAeC,GAAcE,GAC/G,GAGFjB,CACT"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { PopOverVariant } from '@helsenorge/designsystem-react/components/PopOver';
|
|
3
|
+
/**
|
|
4
|
+
* Beregn om hjelpeboblen skal vises over eller under kontrolleren
|
|
5
|
+
* @param controllerSize DOMRect for controlleren
|
|
6
|
+
* @param bubbleSize DOMRect for hjelpeboblen
|
|
7
|
+
* @param variant Ønsket plassering av hjelpeboblen (over/under/automatisk)
|
|
8
|
+
* @returns Om hjelpeboblen skal vises over eller under
|
|
9
|
+
*/
|
|
10
|
+
export declare const getVerticalPosition: (controllerSize: DOMRect, bubbleSize: DOMRect) => keyof typeof PopOverVariant;
|
|
11
|
+
/**
|
|
12
|
+
* Finn riktig plassering av hjelpeboblen
|
|
13
|
+
* @param controllerSize DOMRect for controlleren
|
|
14
|
+
* @param bubbleSize DOMRect for hjelpeboblen
|
|
15
|
+
* @param variant Ønsket plassering av hjelpeboblen (over/under)
|
|
16
|
+
* @returns CSSProperties som plasserer hjelpeboblen riktig
|
|
17
|
+
*/
|
|
18
|
+
export declare const getBubbleStyle: (controllerSize: DOMRect, bubbleSize: DOMRect) => CSSProperties;
|
|
19
|
+
/**
|
|
20
|
+
* Finn riktig plassering av pilen
|
|
21
|
+
* @param bubbleStyle CSSProperties for hjelpeboblen
|
|
22
|
+
* @param controllerSize DOMRect for kontrolleren
|
|
23
|
+
* @param verticalPosition Ønsket plassering av hjelpeboblen (over/under)
|
|
24
|
+
* @returns CSSProperties som plasserer pilen riktig
|
|
25
|
+
*/
|
|
26
|
+
export declare const getArrowStyle: (bubbleStyle: CSSProperties, controllerSize: DOMRect, verticalPosition: keyof typeof PopOverVariant) => CSSProperties;
|
|
27
|
+
//# sourceMappingURL=position-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position-utils.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/position-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAkBnF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,mBAAoB,OAAO,cAAc,OAAO,KAAG,MAAM,qBAMxF,CAAC;AA6JF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mBAAoB,OAAO,cAAc,OAAO,KAAG,aA0B7E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,gBACX,aAAa,kBACV,OAAO,oBACL,MAAM,qBAAqB,KAC5C,aA+BF,CAAC"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@import '@helsenorge/designsystem-react/scss/spacers';
|
|
3
|
+
@import '@helsenorge/designsystem-react/scss/breakpoints';
|
|
4
|
+
@import '@helsenorge/designsystem-react/scss/palette';
|
|
5
|
+
@import '@helsenorge/designsystem-react/scss/font-settings';
|
|
6
|
+
@import '@helsenorge/designsystem-react/scss/title';
|
|
7
|
+
|
|
8
|
+
.date-time-picker-wrapper {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: flex-end;
|
|
11
|
+
flex-flow: row wrap;
|
|
12
|
+
border: none;
|
|
13
|
+
padding: 0;
|
|
14
|
+
margin: 0;
|
|
15
|
+
|
|
16
|
+
@media (min-width: map.get($grid-breakpoints, sm)) {
|
|
17
|
+
flex-flow: row nowrap;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__date-picker {
|
|
21
|
+
flex: 100%;
|
|
22
|
+
margin-right: getSpacer(l);
|
|
23
|
+
|
|
24
|
+
@media (min-width: map.get($grid-breakpoints, sm)) {
|
|
25
|
+
flex: unset;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__legend {
|
|
30
|
+
@include legend;
|
|
31
|
+
|
|
32
|
+
margin-bottom: getSpacer(m);
|
|
33
|
+
margin-top: 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.time-separator {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
padding: 0 getSpacer(2xs);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.datepicker-popup-container {
|
|
44
|
+
position: fixed;
|
|
45
|
+
visibility: hidden;
|
|
46
|
+
z-index: 10;
|
|
47
|
+
|
|
48
|
+
&--visible {
|
|
49
|
+
visibility: visible;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.datepicker-popup-arrow {
|
|
54
|
+
--drop-shadow-color: #{$blueberry500};
|
|
55
|
+
|
|
56
|
+
width: 0;
|
|
57
|
+
height: 0;
|
|
58
|
+
position: fixed;
|
|
59
|
+
visibility: hidden;
|
|
60
|
+
border-style: solid;
|
|
61
|
+
border-color: transparent;
|
|
62
|
+
z-index: 10;
|
|
63
|
+
|
|
64
|
+
&--visible {
|
|
65
|
+
visibility: visible;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&--over {
|
|
69
|
+
border-width: 0.625rem;
|
|
70
|
+
border-bottom-color: $white;
|
|
71
|
+
filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
|
|
72
|
+
filter: drop-shadow(0 -0.185rem 0 var(--drop-shadow-color));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&--under {
|
|
76
|
+
border-width: 0.625rem;
|
|
77
|
+
border-top-color: $white;
|
|
78
|
+
filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
|
|
79
|
+
filter: drop-shadow(0 0.2rem 0 var(--drop-shadow-color));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.date-button {
|
|
84
|
+
position: absolute;
|
|
85
|
+
z-index: 10;
|
|
86
|
+
right: 0.1rem;
|
|
87
|
+
top: 0.1rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.footer-wrapper {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: flex-end;
|
|
93
|
+
justify-content: flex-end;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Overstyrer klasser til datedaypicker pakken https://github.com/gpbl/react-day-picker/blob/main/src/style.css
|
|
97
|
+
/* stylelint-disable */
|
|
98
|
+
.root {
|
|
99
|
+
--rdp-cell-size: getSpacer(l);
|
|
100
|
+
--rdp-background-color: #e7edff;
|
|
101
|
+
|
|
102
|
+
background-color: $white;
|
|
103
|
+
padding: getSpacer(s) getSpacer(s) getSpacer(xs);
|
|
104
|
+
border: 2px solid $blueberry500;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.month {
|
|
108
|
+
width: 100%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.table {
|
|
112
|
+
width: 100%;
|
|
113
|
+
margin: 0 getSpacer(3xs) * -1 getSpacer(4xs) * -1;
|
|
114
|
+
border-spacing: getSpacer(3xs) getSpacer(4xs);
|
|
115
|
+
border-collapse: separate;
|
|
116
|
+
|
|
117
|
+
@media (min-width: map.get($grid-breakpoints, sm)) {
|
|
118
|
+
margin: 0 getSpacer(xs) * -1 getSpacer(3xs) * -1;
|
|
119
|
+
border-spacing: getSpacer(xs) getSpacer(3xs);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.head_cell {
|
|
124
|
+
color: $neutral700;
|
|
125
|
+
font-family: 'Source Sans Pro', sans-serif;
|
|
126
|
+
font-size: $font-size-sm;
|
|
127
|
+
font-weight: 400;
|
|
128
|
+
text-transform: capitalize;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.day {
|
|
132
|
+
font-size: $font-size-sm;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
font-family: 'Source Sans Pro', sans-serif;
|
|
135
|
+
color: $blueberry600;
|
|
136
|
+
display: flex;
|
|
137
|
+
overflow: hidden;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
box-sizing: border-box;
|
|
141
|
+
width: getSpacer(l);
|
|
142
|
+
max-width: getSpacer(l);
|
|
143
|
+
height: getSpacer(l);
|
|
144
|
+
margin: 0;
|
|
145
|
+
border: 2px solid transparent;
|
|
146
|
+
border-radius: 0;
|
|
147
|
+
|
|
148
|
+
&:focus-visible:not([disabled]),
|
|
149
|
+
&:focus:not([disabled]) {
|
|
150
|
+
background-color: $neutral100;
|
|
151
|
+
color: $blueberry600;
|
|
152
|
+
text-decoration: underline 2px $blueberry600;
|
|
153
|
+
outline: none;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&:hover:not([disabled]):not(._day_selected) {
|
|
157
|
+
background-color: $neutral100;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&--today {
|
|
161
|
+
background-color: $blueberry100;
|
|
162
|
+
color: $blueberry600;
|
|
163
|
+
|
|
164
|
+
&:hover:not([disabled]):not(._day_selected) {
|
|
165
|
+
background-color: $blueberry200;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&:focus-visible:not([disabled]),
|
|
169
|
+
&:focus:not([disabled]) {
|
|
170
|
+
background-color: $blueberry200;
|
|
171
|
+
text-decoration: underline 2px $blueberry600;
|
|
172
|
+
outline: none;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&--disabled:not(.day_selected) {
|
|
177
|
+
opacity: 1 !important;
|
|
178
|
+
color: $neutral400;
|
|
179
|
+
|
|
180
|
+
&:hover {
|
|
181
|
+
background-color: $white;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.day_selected {
|
|
187
|
+
background-color: $blueberry500;
|
|
188
|
+
color: $white;
|
|
189
|
+
|
|
190
|
+
&:hover:not([disabled]):not(._day_selected) {
|
|
191
|
+
background-color: $blueberry700;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
&:focus-visible:not([disabled]),
|
|
195
|
+
&:focus:not([disabled]) {
|
|
196
|
+
background-color: $blueberry700;
|
|
197
|
+
color: $white;
|
|
198
|
+
text-decoration: underline 2px $white;
|
|
199
|
+
outline: none;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.day:hover {
|
|
204
|
+
background-color: $neutral100;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.dropdown {
|
|
208
|
+
appearance: none;
|
|
209
|
+
position: absolute;
|
|
210
|
+
z-index: 2;
|
|
211
|
+
top: 0;
|
|
212
|
+
bottom: 0;
|
|
213
|
+
left: 0;
|
|
214
|
+
width: 100%;
|
|
215
|
+
margin: 0;
|
|
216
|
+
padding: 0;
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
opacity: 0;
|
|
219
|
+
border: none;
|
|
220
|
+
background-color: transparent;
|
|
221
|
+
font-size: $font-size-sm;
|
|
222
|
+
line-height: inherit;
|
|
223
|
+
text-transform: capitalize;
|
|
224
|
+
|
|
225
|
+
&:disabled {
|
|
226
|
+
opacity: unset;
|
|
227
|
+
color: unset;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
&:focus-visible:not([disabled]) + .caption_label,
|
|
231
|
+
&:focus:not([disabled]) + .caption_label {
|
|
232
|
+
box-shadow: 0 0 0 4px $neutral900;
|
|
233
|
+
border-radius: 0;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.caption_label {
|
|
238
|
+
position: relative;
|
|
239
|
+
z-index: 1;
|
|
240
|
+
display: inline-flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
margin: 0;
|
|
243
|
+
white-space: nowrap;
|
|
244
|
+
color: currentColor;
|
|
245
|
+
border: 2px solid transparent;
|
|
246
|
+
font-size: $font-size-sm;
|
|
247
|
+
font-family: 'Source Sans Pro', sans-serif;
|
|
248
|
+
font-weight: 600;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.dropdown_month,
|
|
252
|
+
.dropdown_year {
|
|
253
|
+
color: $blueberry600;
|
|
254
|
+
position: relative;
|
|
255
|
+
display: inline-flex;
|
|
256
|
+
align-items: center;
|
|
257
|
+
text-transform: capitalize;
|
|
258
|
+
font-size: $font-size-md;
|
|
259
|
+
font-weight: 600;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.dropdown_month {
|
|
263
|
+
margin-right: getSpacer(2xs);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.nav_button {
|
|
267
|
+
display: inline-flex;
|
|
268
|
+
align-items: center;
|
|
269
|
+
justify-content: center;
|
|
270
|
+
width: 2.375rem;
|
|
271
|
+
height: 2.375rem;
|
|
272
|
+
padding: 0.25em;
|
|
273
|
+
border-radius: 0;
|
|
274
|
+
|
|
275
|
+
&[disabled] {
|
|
276
|
+
margin-left: getSpacer(xs);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
&:focus-visible:not([disabled]),
|
|
280
|
+
&:focus:not([disabled]) {
|
|
281
|
+
box-shadow: 0 0 0 4px $neutral900;
|
|
282
|
+
background-color: $neutral100;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
&:hover:not([disabled]):not(.day_selected) {
|
|
286
|
+
background-color: $neutral100;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.nav_button_next,
|
|
291
|
+
.nav_button_next[disabled],
|
|
292
|
+
.nav_button_next[disabled]:not(.day_selected) {
|
|
293
|
+
margin-left: getSpacer(2xs);
|
|
294
|
+
}
|
|
295
|
+
/* stylelint-enable */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type Styles = {
|
|
2
|
+
_day_selected: string;
|
|
3
|
+
caption_label: string;
|
|
4
|
+
'date-button': string;
|
|
5
|
+
'date-time-picker-wrapper': string;
|
|
6
|
+
'date-time-picker-wrapper__date-picker': string;
|
|
7
|
+
'date-time-picker-wrapper__legend': string;
|
|
8
|
+
'datepicker-popup-arrow': string;
|
|
9
|
+
'datepicker-popup-arrow--over': string;
|
|
10
|
+
'datepicker-popup-arrow--under': string;
|
|
11
|
+
'datepicker-popup-arrow--visible': string;
|
|
12
|
+
'datepicker-popup-container': string;
|
|
13
|
+
'datepicker-popup-container--visible': string;
|
|
14
|
+
day: string;
|
|
15
|
+
day_selected: string;
|
|
16
|
+
'day--disabled': string;
|
|
17
|
+
'day--today': string;
|
|
18
|
+
dropdown: string;
|
|
19
|
+
dropdown_month: string;
|
|
20
|
+
dropdown_year: string;
|
|
21
|
+
'footer-wrapper': string;
|
|
22
|
+
head_cell: string;
|
|
23
|
+
month: string;
|
|
24
|
+
nav_button: string;
|
|
25
|
+
nav_button_next: string;
|
|
26
|
+
root: string;
|
|
27
|
+
table: string;
|
|
28
|
+
'time-separator': string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ClassNames = keyof Styles;
|
|
32
|
+
|
|
33
|
+
declare const styles: Styles;
|
|
34
|
+
|
|
35
|
+
export default styles;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const parseInputDate: (dateString: string) => Date | null;
|
|
2
|
+
export declare const isValidDate: (dateString: string) => boolean;
|
|
3
|
+
/** react-hook-form fromDate and toDate validation */
|
|
4
|
+
export declare const validateMinMaxDate: (date: string, errorMessage: string, minDate?: Date, maxDate?: Date) => string | true;
|
|
5
|
+
/** react-hook-form fromDate and toDate validation */
|
|
6
|
+
export declare const validateDisabledDates: (date: string, disabledDates: Date[], errorMessage: string) => string | true;
|
|
7
|
+
/** react-hook-form fromTime and toTime validation */
|
|
8
|
+
export declare const validateMinTimeMaxTime: (time: {
|
|
9
|
+
hour: number;
|
|
10
|
+
minute: number;
|
|
11
|
+
}, errorMessage: string, minTime?: {
|
|
12
|
+
hour: number;
|
|
13
|
+
minute: number;
|
|
14
|
+
}, maxTime?: {
|
|
15
|
+
hour: number;
|
|
16
|
+
minute: number;
|
|
17
|
+
}) => string | true;
|
|
18
|
+
//# sourceMappingURL=validate-utils.d.ts.map
|