@fremtind/jokul 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/build/NativeSelect-DSmX3GZo.cjs +2 -0
  2. package/build/{NativeSelect-gBndJVSb.cjs.map → NativeSelect-DSmX3GZo.cjs.map} +1 -1
  3. package/build/NativeSelect-EidDABsT.js +2 -0
  4. package/build/{NativeSelect-DOSP8-ZQ.js.map → NativeSelect-EidDABsT.js.map} +1 -1
  5. package/build/build-stats.html +1 -1
  6. package/build/cjs/components/datepicker/DatePicker.js +2 -0
  7. package/build/cjs/components/datepicker/DatePicker.js.map +1 -0
  8. package/build/cjs/components/datepicker/index.js +2 -0
  9. package/build/cjs/components/datepicker/index.js.map +1 -0
  10. package/build/cjs/components/datepicker/internal/Calendar.js +2 -0
  11. package/build/cjs/components/datepicker/internal/Calendar.js.map +1 -0
  12. package/build/cjs/components/datepicker/internal/calendarReducer.js +2 -0
  13. package/build/cjs/components/datepicker/internal/calendarReducer.js.map +1 -0
  14. package/build/cjs/components/datepicker/internal/useCalendar.js +2 -0
  15. package/build/cjs/components/datepicker/internal/useCalendar.js.map +1 -0
  16. package/build/cjs/components/datepicker/internal/utils.js +2 -0
  17. package/build/cjs/components/datepicker/internal/utils.js.map +1 -0
  18. package/build/cjs/components/datepicker/types.js +2 -0
  19. package/build/cjs/components/datepicker/types.js.map +1 -0
  20. package/build/cjs/components/datepicker/utils.js +2 -0
  21. package/build/cjs/components/datepicker/utils.js.map +1 -0
  22. package/build/cjs/components/datepicker/validation.js +2 -0
  23. package/build/cjs/components/datepicker/validation.js.map +1 -0
  24. package/build/cjs/components/index.js +1 -1
  25. package/build/cjs/components/select/NativeSelect.js +1 -1
  26. package/build/cjs/components/select/Select.js +1 -1
  27. package/build/cjs/components/select/index.js +1 -1
  28. package/build/cjs/components/text-input/BaseTextArea.js +2 -0
  29. package/build/cjs/components/text-input/BaseTextArea.js.map +1 -0
  30. package/build/cjs/components/text-input/BaseTextInput.js +2 -0
  31. package/build/cjs/components/text-input/BaseTextInput.js.map +1 -0
  32. package/build/cjs/components/text-input/TextArea.js +2 -0
  33. package/build/cjs/components/text-input/TextArea.js.map +1 -0
  34. package/build/cjs/components/text-input/TextInput.js +2 -0
  35. package/build/cjs/components/text-input/TextInput.js.map +1 -0
  36. package/build/cjs/components/text-input/index.js +2 -0
  37. package/build/cjs/components/text-input/index.js.map +1 -0
  38. package/build/cjs/index.js +1 -1
  39. package/build/components/datepicker/DatePicker.d.ts +3 -0
  40. package/build/components/datepicker/index.d.ts +4 -0
  41. package/build/components/datepicker/internal/Calendar.d.ts +18 -0
  42. package/build/components/datepicker/internal/calendarReducer.d.ts +18 -0
  43. package/build/components/datepicker/internal/useCalendar.d.ts +59 -0
  44. package/build/components/datepicker/internal/utils.d.ts +167 -0
  45. package/build/components/datepicker/types.d.ts +269 -0
  46. package/build/components/datepicker/utils.d.ts +23 -0
  47. package/build/components/datepicker/validation.d.ts +11 -0
  48. package/build/components/index.d.ts +2 -0
  49. package/build/components/text-input/BaseTextArea.d.ts +27 -0
  50. package/build/components/text-input/BaseTextInput.d.ts +34 -0
  51. package/build/components/text-input/TextArea.d.ts +6 -0
  52. package/build/components/text-input/TextInput.d.ts +9 -0
  53. package/build/components/text-input/index.d.ts +4 -0
  54. package/build/es/components/datepicker/DatePicker.js +2 -0
  55. package/build/es/components/datepicker/DatePicker.js.map +1 -0
  56. package/build/es/components/datepicker/index.js +2 -0
  57. package/build/es/components/datepicker/index.js.map +1 -0
  58. package/build/es/components/datepicker/internal/Calendar.js +2 -0
  59. package/build/es/components/datepicker/internal/Calendar.js.map +1 -0
  60. package/build/es/components/datepicker/internal/calendarReducer.js +2 -0
  61. package/build/es/components/datepicker/internal/calendarReducer.js.map +1 -0
  62. package/build/es/components/datepicker/internal/useCalendar.js +2 -0
  63. package/build/es/components/datepicker/internal/useCalendar.js.map +1 -0
  64. package/build/es/components/datepicker/internal/utils.js +2 -0
  65. package/build/es/components/datepicker/internal/utils.js.map +1 -0
  66. package/build/es/components/datepicker/types.js +2 -0
  67. package/build/es/components/datepicker/types.js.map +1 -0
  68. package/build/es/components/datepicker/utils.js +2 -0
  69. package/build/es/components/datepicker/utils.js.map +1 -0
  70. package/build/es/components/datepicker/validation.js +2 -0
  71. package/build/es/components/datepicker/validation.js.map +1 -0
  72. package/build/es/components/index.js +1 -1
  73. package/build/es/components/select/NativeSelect.js +1 -1
  74. package/build/es/components/select/Select.js +1 -1
  75. package/build/es/components/select/index.js +1 -1
  76. package/build/es/components/text-input/BaseTextArea.js +2 -0
  77. package/build/es/components/text-input/BaseTextArea.js.map +1 -0
  78. package/build/es/components/text-input/BaseTextInput.js +2 -0
  79. package/build/es/components/text-input/BaseTextInput.js.map +1 -0
  80. package/build/es/components/text-input/TextArea.js +2 -0
  81. package/build/es/components/text-input/TextArea.js.map +1 -0
  82. package/build/es/components/text-input/TextInput.js +2 -0
  83. package/build/es/components/text-input/TextInput.js.map +1 -0
  84. package/build/es/components/text-input/index.js +2 -0
  85. package/build/es/components/text-input/index.js.map +1 -0
  86. package/build/es/index.js +1 -1
  87. package/package.json +7 -2
  88. package/src/components/button/styles/button.css +4 -4
  89. package/src/components/button/styles/button.min.css +1 -1
  90. package/src/components/checkbox/styles/checkbox.css +4 -4
  91. package/src/components/checkbox/styles/checkbox.min.css +1 -1
  92. package/src/components/datepicker/styles/_calendar-date-button.scss +100 -0
  93. package/src/components/datepicker/styles/_calendar-navigation-dropdown.scss +53 -0
  94. package/src/components/datepicker/styles/_calendar-navigation.scss +54 -0
  95. package/src/components/datepicker/styles/_calendar-table.scss +27 -0
  96. package/src/components/datepicker/styles/_calendar.scss +68 -0
  97. package/src/components/datepicker/styles/_index.scss +1 -0
  98. package/src/components/datepicker/styles/datepicker.css +453 -0
  99. package/src/components/datepicker/styles/datepicker.min.css +1 -0
  100. package/src/components/datepicker/styles/datepicker.scss +63 -0
  101. package/src/components/loader/styles/loader.css +6 -6
  102. package/src/components/loader/styles/loader.min.css +1 -1
  103. package/src/components/loader/styles/skeleton-loader.css +5 -5
  104. package/src/components/loader/styles/skeleton-loader.min.css +1 -1
  105. package/src/components/radio-button/styles/radio-button.css +2 -2
  106. package/src/components/radio-button/styles/radio-button.min.css +1 -1
  107. package/src/components/text-input/styles/_index.scss +1 -0
  108. package/src/components/text-input/styles/text-input.css +513 -0
  109. package/src/components/text-input/styles/text-input.min.css +1 -0
  110. package/src/components/text-input/styles/text-input.scss +389 -0
  111. package/build/NativeSelect-DOSP8-ZQ.js +0 -2
  112. package/build/NativeSelect-gBndJVSb.cjs +0 -2
@@ -0,0 +1,11 @@
1
+ export declare function isCorrectFormat(value: string | undefined): boolean;
2
+ type ComparisonOptions = {
3
+ /**
4
+ * Kontroller om testen skal godkjennes om verdien er lik
5
+ * @default false
6
+ */
7
+ inclusive: boolean;
8
+ };
9
+ export declare function isWithinLowerBound(value: Date | string | undefined, minDate: Date, options?: ComparisonOptions): boolean;
10
+ export declare function isWithinUpperBound(value: Date | string | undefined, maxDate: Date, options?: ComparisonOptions): boolean;
11
+ export {};
@@ -5,6 +5,7 @@ export * from './card';
5
5
  export * from './checkbox';
6
6
  export * from './combobox';
7
7
  export * from './cookie-consent';
8
+ export * from './datepicker';
8
9
  export * from './icon';
9
10
  export * from './icon-button';
10
11
  export * from './input-group';
@@ -16,5 +17,6 @@ export * from './modal';
16
17
  export * from './radio-button';
17
18
  export * from './select';
18
19
  export * from './tag';
20
+ export * from './text-input';
19
21
  export * from './tooltip';
20
22
  export { ScreenReaderOnly, type ScreenReaderOnlyProps } from './ScreenReaderOnly';
@@ -0,0 +1,27 @@
1
+ import { default as React, TextareaHTMLAttributes } from 'react';
2
+ type Counter = {
3
+ /** Antall tegn før telleren når maksimum og vi viser en feilmelding */
4
+ maxLength: number;
5
+ /**
6
+ * Med teller vises en progress-bar i bunnen av tekstfeltet som krymper
7
+ * ned fra 100% (null tegn skrevet) til 0% (maks antall tegn skrevet).
8
+ * Om du vil skjule den, sett denne propen til true.
9
+ *
10
+ * @default false
11
+ */
12
+ hideProgress?: boolean;
13
+ };
14
+ export interface BaseTextAreaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "children"> {
15
+ /**
16
+ * Viser en teller i tekstfeltet når det har fokus.
17
+ */
18
+ counter?: Counter;
19
+ /** Sett antall rader skjemafeltet ekspanderes til ved focus. Innholdet scroller om feltet fylles med mer innhold enn det er plass til. */
20
+ rows?: number;
21
+ inline?: boolean;
22
+ startOpen?: boolean;
23
+ /** Gjør så skjemafeltet ekspanderer seg til å vise alt innhold i stedet for å scrolle */
24
+ autoExpand?: boolean;
25
+ }
26
+ export declare const BaseTextArea: React.ForwardRefExoticComponent<BaseTextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
27
+ export {};
@@ -0,0 +1,34 @@
1
+ import { default as React, MouseEventHandler, ReactNode, InputHTMLAttributes, HTMLProps } from 'react';
2
+ import { Density } from '../../core';
3
+ import { IconProps } from '../icon';
4
+ interface ActionBaseProps extends Exclude<HTMLProps<HTMLButtonElement>, "disabled"> {
5
+ icon: React.ReactElement<IconProps>;
6
+ label: string;
7
+ buttonRef?: React.Ref<HTMLButtonElement>;
8
+ }
9
+ export interface ActionButton extends ActionBaseProps {
10
+ type?: "button" | "reset";
11
+ onClick: MouseEventHandler<HTMLButtonElement>;
12
+ }
13
+ export interface ActionSubmit extends ActionBaseProps {
14
+ type: "submit";
15
+ onClick?: MouseEventHandler<HTMLButtonElement>;
16
+ }
17
+ export type Action = ActionButton | ActionSubmit;
18
+ export interface BaseTextInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "children"> {
19
+ /**
20
+ * Brukes til inputfelter hvor det brukes maskering, for formatering av store tall. Brukes typisk bare til valuta.
21
+ * @default "left"
22
+ */
23
+ align?: "left" | "right";
24
+ action?: Action;
25
+ density?: Density;
26
+ /**
27
+ * Benevnelse for feltet. Unngå å bruke både benevnelse og handling samtidig
28
+ * @example "kr"
29
+ * */
30
+ unit?: ReactNode;
31
+ width?: string;
32
+ }
33
+ export declare const BaseTextInput: React.ForwardRefExoticComponent<BaseTextInputProps & React.RefAttributes<HTMLInputElement>>;
34
+ export {};
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ import { InputGroupProps } from '../input-group';
3
+ import { BaseTextAreaProps } from './BaseTextArea';
4
+ export interface TextAreaProps extends Omit<InputGroupProps, "children">, BaseTextAreaProps {
5
+ }
6
+ export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { InputGroupProps } from '../input-group';
3
+ import { BaseTextInputProps } from './BaseTextInput';
4
+ export interface TextInputProps extends Omit<InputGroupProps, "children">, BaseTextInputProps {
5
+ "data-testautoid"?: string;
6
+ inline?: boolean;
7
+ inputClassName?: string;
8
+ }
9
+ export declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,4 @@
1
+ export { BaseTextArea, type BaseTextAreaProps } from './BaseTextArea';
2
+ export { BaseTextInput, type BaseTextInputProps } from './BaseTextInput';
3
+ export { TextArea, type TextAreaProps } from './TextArea';
4
+ export { TextInput, type TextInputProps } from './TextInput';
@@ -0,0 +1,2 @@
1
+ import{jsx as o,jsxs as e}from"react/jsx-runtime";import t from"classnames";import n from"date-fns/startOfDay";import{forwardRef as r,useState as i,useRef as s,useCallback as a}from"react";import{flushSync as c}from"react-dom";import{useAnimatedHeight as l}from"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../hooks/useScreen/useScreen.js";import{useClickOutside as p}from"../../hooks/useClickOutside/useClickOutside.js";import{useFocusOutside as u}from"../../hooks/useFocusOutside/useFocusOutside.js";import"../../hooks/useId/useId.js";import{useKeyListener as m}from"../../hooks/useKeyListener/useKeyListener.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import{CalendarIcon as d}from"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import{InputGroup as j}from"../input-group/InputGroup.js";import"../text-input/BaseTextArea.js";import{BaseTextInput as f}from"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import{Calendar as h}from"./internal/Calendar.js";import{getInitialDate as I}from"./internal/utils.js";import{parseDateString as k,formatInput as v}from"./utils.js";import{isWithinLowerBound as y,isWithinUpperBound as D}from"./validation.js";const b=r(((r,b)=>{const{"data-testautoid":g,id:w,className:C="",label:L="Velg dato",labelProps:T,defaultValue:A,defaultShow:x=!1,value:O,disableBeforeDate:P,disableAfterDate:_,yearsToShow:E,name:S,helpLabel:N,errorLabel:R,invalid:B,density:U,days:K,months:H,monthLabel:V,yearLabel:F,placeholder:W="dd.mm.åååå",width:G="11.25rem",onChange:M,onBlur:q,onFocus:z,onKeyDown:Q,action:J,showCalendarLabel:X="Åpne kalender",hideCalendarLabel:Y="Lukk kalender",supportLabelProps:Z,tooltipProps:$,...oo}=r;"production"!==process.env.NODE_ENV&&O&&A&&console.warn("DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.");const eo=k(P),to=eo?n(eo):void 0,no=k(_),ro=no?n(no):void 0,[io,so]=i(I(O,A,to,ro)),[ao,co]=i(null),[lo,po]=i(x),[uo]=l(lo),mo=s(null),jo=s(null),fo=a((o=>{jo.current=o,b&&("function"==typeof b?b(o):b.current=o)}),[jo,b]),ho=s(null),Io=a((o=>{z&&ho.current&&(ho.current.contains(o.relatedTarget)||z(o,io,{error:ao,value:o.target.value}))}),[z,io,ao]),ko=a((o=>{q&&q(o,io,{error:ao,value:o.target.value})}),[q,io,ao]),vo=a((o=>{"Escape"===o.key&&(po(!1),o.preventDefault(),o.stopPropagation()),null!=J&&J.onKeyDown&&J.onKeyDown(o)}),[po,J]),yo=a((o=>{if("Escape"===o.key&&(po(!1),o.preventDefault(),o.stopPropagation()),Q){let e=o.currentTarget.value;/[\d.]/.test(o.key)&&(e+=o.key),Q(o,io,{error:ao,value:e})}}),[Q,po,io,ao]),Do=a((o=>{let e=null,t=null;if(o.target.value){const n=k(o.target.value);n?to&&!y(n,to)?t="OUTSIDE_LOWER_BOUND":ro&&!D(n,ro)?t="OUTSIDE_UPPER_BOUND":po(!1):t="WRONG_FORMAT",e=n||null}co(t),so(e),M&&M(o,e,{error:t,value:o.target.value})}),[M,co,so,po,to,ro]),bo=a((o=>{c((()=>{po(!lo)}));const e=uo.current,t=e&&e.querySelector('[aria-pressed="true"]');t&&t.focus(),null!=J&&J.onClick&&J.onClick(o)}),[po,lo,J,uo]),go=a((()=>{po(!lo)}),[po,lo]),wo=a((()=>{po(!1)}),[po]),Co=a((({date:o})=>{if(po(!1),so(o),jo.current){const e=jo.current;e.value=v(o);const t=document.createEvent("HTMLEvents");t.initEvent("input",!0,!1),e.dispatchEvent(t),e.focus(),M&&M(t,o,{error:null,value:e.value})}}),[po,so,M]),Lo=a((o=>{o.preventDefault(),po(!1),mo.current&&mo.current.focus()}),[po]);return p(ho,wo),u(ho,wo),m(uo,["Escape"],(()=>{po(!1),jo.current&&jo.current.focus()})),o(j,{id:w,className:t("jkl-datepicker",C,{"jkl-datepicker--open":lo}),...oo,ref:ho,label:L,labelProps:T,density:U,helpLabel:N,errorLabel:R,supportLabelProps:Z,tooltipProps:$,render:t=>e("div",{"data-testid":"jkl-datepicker__input-wrapper",className:"jkl-datepicker__input-wrapper","data-density":U,tabIndex:-1,onKeyDown:yo,children:[o(f,{ref:fo,"data-testid":"jkl-datepicker__input","data-testautoid":g,className:"jkl-datepicker__input",name:S,defaultValue:A,density:U,value:O,type:"text",placeholder:W,width:G,onFocus:Io,onBlur:ko,onClick:go,onChange:Do,...t,action:{buttonRef:mo,icon:o(d,{}),label:lo?Y:X,...J,onClick:bo,onKeyDown:vo}}),o("div",{className:"jkl-datepicker__calendar-wrapper",children:o(h,{ref:uo,density:U,date:io,minDate:to,maxDate:ro,days:K,months:H,monthLabel:V,yearLabel:F,yearsToShow:E,hidden:!lo,onDateSelected:Co,onTabOutside:Lo})})]})})}));b.displayName="DatePicker";export{b as DatePicker};
2
+ //# sourceMappingURL=DatePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatePicker.js","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport startOfDay from \"date-fns/startOfDay\";\nimport React, {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n forwardRef,\n useCallback,\n useRef,\n useState,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useAnimatedHeight, useClickOutside, useFocusOutside, useKeyListener } from \"../../hooks\";\nimport { CalendarIcon } from \"../icon\";\nimport { InputGroup } from \"../input-group\";\nimport { BaseTextInput } from \"../text-input\";\nimport { Calendar } from \"./internal/Calendar\";\nimport { getInitialDate, DateInfo } from \"./internal/utils\";\nimport { DatePickerProps, DateValidationError } from \"./types\";\nimport { formatInput, parseDateString } from \"./utils\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation\";\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>((props, forwardedInputRef) => {\n const {\n \"data-testautoid\": testAutoId,\n id,\n className = \"\",\n label = \"Velg dato\",\n labelProps,\n defaultValue,\n defaultShow = false,\n value,\n disableBeforeDate: disableBefore,\n disableAfterDate: disableAfter,\n yearsToShow,\n name,\n helpLabel,\n errorLabel,\n invalid,\n density,\n days,\n months,\n monthLabel,\n yearLabel,\n placeholder = \"dd.mm.åååå\",\n width = \"11.25rem\",\n onChange,\n onBlur,\n onFocus,\n onKeyDown,\n action,\n showCalendarLabel = \"Åpne kalender\",\n hideCalendarLabel = \"Lukk kalender\",\n supportLabelProps,\n tooltipProps,\n ...rest\n } = props;\n\n if (process.env.NODE_ENV !== \"production\" && value && defaultValue) {\n console.warn(\n \"DatePicker må enten være controlled eller uncontrolled. Hvis du bruker defaultValue og value sammen vil defaultValue bli ignorert.\",\n );\n }\n /// Input state\n\n const disableBeforeDate = parseDateString(disableBefore);\n const minDate = disableBeforeDate ? startOfDay(disableBeforeDate) : undefined;\n const disableAfterDate = parseDateString(disableAfter);\n const maxDate = disableAfterDate ? startOfDay(disableAfterDate) : undefined;\n\n const [date, setDate] = useState(getInitialDate(value, defaultValue, minDate, maxDate));\n const [error, setError] = useState<DateValidationError | null>(null);\n\n /// Calendar state\n\n const [showCalendar, setShowCalendar] = useState(defaultShow);\n const [calendarRef] = useAnimatedHeight<HTMLDivElement>(showCalendar);\n\n /// Input events\n\n const iconButtonRef = useRef<HTMLButtonElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n // Hjelper for å gjøre det enklere å både forwarde refen men også bruke den selv internt\n const unifiedInputRef = useCallback(\n (instance: HTMLInputElement | null) => {\n inputRef.current = instance;\n if (forwardedInputRef) {\n if (typeof forwardedInputRef === \"function\") {\n forwardedInputRef(instance);\n } else {\n forwardedInputRef.current = instance;\n }\n }\n },\n [inputRef, forwardedInputRef],\n );\n\n const datepickerRef = useRef<HTMLDivElement>(null);\n const handleFocus = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (!onFocus || !datepickerRef.current) {\n return;\n }\n\n const nextFocusIsInside = datepickerRef.current.contains(e.relatedTarget as Node);\n if (!nextFocusIsInside) {\n onFocus(e, date, { error, value: e.target.value });\n }\n },\n [onFocus, date, error],\n );\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e, date, { error, value: e.target.value });\n }\n },\n [onBlur, date, error],\n );\n\n const handleKeyDownAction = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (action?.onKeyDown) {\n action.onKeyDown(e);\n }\n },\n [setShowCalendar, action],\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"Escape\") {\n setShowCalendar(false);\n e.preventDefault();\n e.stopPropagation();\n }\n\n if (onKeyDown) {\n let nextValue = e.currentTarget.value;\n if (/[\\d.]/.test(e.key)) {\n nextValue += e.key;\n }\n onKeyDown(e, date, { error, value: nextValue });\n }\n },\n [onKeyDown, setShowCalendar, date, error],\n );\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n let nextDate: Date | null = null;\n let nextError: DateValidationError | null = null;\n\n if (e.target.value) {\n const val = parseDateString(e.target.value);\n if (!val) {\n nextError = \"WRONG_FORMAT\";\n } else if (minDate && !isWithinLowerBound(val, minDate)) {\n nextError = \"OUTSIDE_LOWER_BOUND\";\n } else if (maxDate && !isWithinUpperBound(val, maxDate)) {\n nextError = \"OUTSIDE_UPPER_BOUND\";\n } else {\n setShowCalendar(false);\n }\n nextDate = val || null;\n }\n\n setError(nextError);\n setDate(nextDate);\n\n if (onChange) {\n onChange(e, nextDate, { error: nextError, value: e.target.value });\n }\n },\n [onChange, setError, setDate, setShowCalendar, minDate, maxDate],\n );\n\n /// Calendar events\n\n const clickCalendar = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n flushSync(() => {\n setShowCalendar(!showCalendar);\n });\n\n const calendarEl = calendarRef.current;\n const button = calendarEl && (calendarEl.querySelector('[aria-pressed=\"true\"]') as HTMLButtonElement);\n button && button.focus();\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\n\n const clickInput = useCallback(() => {\n setShowCalendar(!showCalendar);\n }, [setShowCalendar, showCalendar]);\n\n const hideCalendar = useCallback(() => {\n setShowCalendar(false);\n }, [setShowCalendar]);\n\n const handleClickCalendarDay = useCallback(\n ({ date }: DateInfo) => {\n setShowCalendar(false);\n setDate(date);\n\n if (inputRef.current) {\n const node = inputRef.current;\n\n node.value = formatInput(date);\n\n // Simulér et change-event så APIet blir så likt som mulig en endring av inputfeltet\n const event = document.createEvent(\"HTMLEvents\");\n event.initEvent(\"input\", true, false);\n node.dispatchEvent(event);\n\n node.focus();\n\n if (onChange) {\n // Det er ikke helt sant at dette er et React.SyntheticEvent, men it's fine – probably?\n // Den har tingene man kan forvente, men hvis du gjør serdeles fancy ting med events\n // så kan det hende du må utvide denne for å dekke behovet ditt.\n onChange(event as unknown as ChangeEvent<HTMLInputElement>, date, {\n error: null,\n value: node.value,\n });\n }\n }\n },\n [setShowCalendar, setDate, onChange],\n );\n\n const handleTabOutsideCalendar = useCallback(\n (e: KeyboardEvent) => {\n e.preventDefault();\n setShowCalendar(false);\n iconButtonRef.current && iconButtonRef.current.focus();\n },\n [setShowCalendar],\n );\n\n useClickOutside(datepickerRef, hideCalendar);\n useFocusOutside(datepickerRef, hideCalendar);\n useKeyListener(calendarRef, [\"Escape\"], () => {\n setShowCalendar(false);\n inputRef.current && inputRef.current.focus();\n });\n\n return (\n <InputGroup\n id={id}\n className={cn(\"jkl-datepicker\", className, {\n \"jkl-datepicker--open\": showCalendar,\n })}\n {...rest}\n ref={datepickerRef}\n label={label}\n labelProps={labelProps}\n density={density}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n supportLabelProps={supportLabelProps}\n tooltipProps={tooltipProps}\n render={(inputProps) => (\n // The <div> element handles keyboard events that bubble up from <button> elements inside\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n data-testid=\"jkl-datepicker__input-wrapper\"\n className=\"jkl-datepicker__input-wrapper\"\n data-density={density}\n tabIndex={-1} // Må være her for Safari onBlur quirk! https://bugs.webkit.org/show_bug.cgi?id=22261\n onKeyDown={handleKeyDown}\n >\n <BaseTextInput\n ref={unifiedInputRef}\n data-testid=\"jkl-datepicker__input\"\n data-testautoid={testAutoId}\n className=\"jkl-datepicker__input\"\n name={name}\n defaultValue={defaultValue}\n density={density}\n value={value}\n type=\"text\"\n placeholder={placeholder}\n width={width}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={clickInput}\n onChange={handleChange}\n {...inputProps}\n action={{\n buttonRef: iconButtonRef,\n icon: <CalendarIcon />,\n label: showCalendar ? hideCalendarLabel : showCalendarLabel,\n ...action,\n onClick: clickCalendar,\n onKeyDown: handleKeyDownAction,\n }}\n />\n <div className=\"jkl-datepicker__calendar-wrapper\">\n <Calendar\n ref={calendarRef}\n density={density}\n date={date}\n minDate={minDate}\n maxDate={maxDate}\n days={days}\n months={months}\n monthLabel={monthLabel}\n yearLabel={yearLabel}\n yearsToShow={yearsToShow}\n hidden={!showCalendar}\n onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </div>\n </div>\n )}\n />\n );\n});\n\nDatePicker.displayName = \"DatePicker\";\n"],"names":["DatePicker","forwardRef","props","forwardedInputRef","testAutoId","id","className","label","labelProps","defaultValue","defaultShow","value","disableBeforeDate","disableBefore","disableAfterDate","disableAfter","yearsToShow","name","helpLabel","errorLabel","invalid","density","days","months","monthLabel","yearLabel","placeholder","width","onChange","onBlur","onFocus","onKeyDown","action","showCalendarLabel","hideCalendarLabel","supportLabelProps","tooltipProps","rest","process","env","NODE_ENV","console","warn","parseDateString","minDate","startOfDay","maxDate","date","setDate","useState","getInitialDate","error","setError","showCalendar","setShowCalendar","calendarRef","useAnimatedHeight","iconButtonRef","useRef","inputRef","unifiedInputRef","useCallback","instance","current","datepickerRef","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleKeyDown","nextValue","currentTarget","test","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","focus","onClick","clickInput","hideCalendar","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","useClickOutside","useFocusOutside","useKeyListener","jsx","InputGroup","cn","ref","render","inputProps","jsxs","tabIndex","children","BaseTextInput","type","buttonRef","icon","CalendarIcon","Calendar","hidden","onDateSelected","onTabOutside","displayName"],"mappings":"ghFAuBO,MAAMA,EAAaC,GAA8C,CAACC,EAAOC,KACtE,MACF,kBAAmBC,EACnBC,GAAAA,EACAC,UAAAA,EAAY,GACZC,MAAAA,EAAQ,YACRC,WAAAA,EACAC,aAAAA,EACAC,YAAAA,GAAc,EACdC,MAAAA,EACAC,kBAAmBC,EACnBC,iBAAkBC,EAClBC,YAAAA,EACAC,KAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAC,YAAAA,EAAc,aACdC,MAAAA,EAAQ,WACRC,SAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,OAAAA,E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AAR,EAACc,EAAA,CACGX,IAAKtD,GACLlC,QAAAA,EACA0B,KAAAA,GACAH,QAAAA,GACAE,QAAAA,GACAxB,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAT,YAAAA,EACAyG,QAASpE,GACTqE,eAAgB5B,GAChB6B,aAAcrB,WAG1B,IAMhBtG,EAAW4H,YAAc"}
@@ -0,0 +1,2 @@
1
+ import{isCorrectFormat as a,isWithinLowerBound as r,isWithinUpperBound as s}from"./validation.js";import{dayMonthYearRegex as t,formatInput as i,isBlurTargetOutside as e,parseDateString as o}from"./utils.js";import{DatePicker as n}from"./DatePicker.js";export{n as DatePicker,t as dayMonthYearRegex,i as formatInput,e as isBlurTargetOutside,a as isCorrectFormat,r as isWithinLowerBound,s as isWithinUpperBound,o as parseDateString};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import n from"classnames";import{forwardRef as a,useReducer as o,useEffect as r,useCallback as c,useRef as i}from"react";import{flushSync as s}from"react-dom";import"../../../hooks/useScreen/useScreen.js";import{useId as l}from"../../../hooks/useId/useId.js";import"../../icon/Icon.js";import"../../icon/icons/animated/ArrowVerticalAnimated.js";import"../../icon/icons/animated/ArrowHorizontalAnimated.js";import"../../icon/icons/animated/PlusRemoveAnimated.js";import"../../icon/icons/ArrowDownIcon.js";import{ArrowLeftIcon as d}from"../../icon/icons/ArrowLeftIcon.js";import"../../icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as u}from"../../icon/icons/ArrowRightIcon.js";import"../../icon/icons/ArrowUpIcon.js";import"../../icon/icons/CalendarIcon.js";import"../../icon/icons/CheckIcon.js";import{ChevronDownIcon as m}from"../../icon/icons/ChevronDownIcon.js";import"../../icon/icons/ChevronLeftIcon.js";import"../../icon/icons/ChevronRightIcon.js";import"../../icon/icons/ChevronUpIcon.js";import"../../icon/icons/CloseIcon.js";import"../../icon/icons/CopyIcon.js";import"../../icon/icons/DotsIcon.js";import"../../icon/icons/DragIcon.js";import"../../icon/icons/ErrorIcon.js";import"../../icon/icons/GreenCheckIcon.js";import"../../icon/icons/HamburgerIcon.js";import"../../icon/icons/InfoIcon.js";import"../../icon/icons/LinkIcon.js";import"../../icon/icons/PlusIcon.js";import"../../icon/icons/QuestionIcon.js";import"../../icon/icons/RedCrossIcon.js";import"../../icon/icons/SearchIcon.js";import"../../icon/icons/SuccessIcon.js";import"../../icon/icons/WarningIcon.js";import"../../icon/icons/MinusIcon.js";import"../../icon/icons/ThumbDownIcon.js";import"../../icon/icons/ThumbUpIcon.js";import"../../icon/icons/TrashCanIcon.js";import"../../icon/icons/PenIcon.js";import{calendarReducer as h,calendarInitializer as p}from"./calendarReducer.js";import{useCalendar as g}from"./useCalendar.js";import{getInitialDateShown as f,isBackDisabled as j,subtractMonth as b,isForwardDisabled as v,addMonth as k,getYearSelectOptions as w,getMonthSelectOptions as D,DEFAULT_YEARS_TO_SHOW as I}from"./utils.js";const y=["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],A=["man","tir","ons","tor","fre","lør","søn"],S=a(((a,S)=>{const{hidden:_,date:M,defaultSelected:C,density:F,minDate:N,maxDate:E,days:Y=A,months:x=y,monthLabel:O="Velg måned",yearLabel:T="Velg år",yearsToShow:$=I,onTabOutside:R,...L}=a,q=l("jkl-calendar"),[{offset:P,selectedDate:U,shownDate:K},H]=o(h,f(M,C,N,E),p),J=K.getMonth(),V=K.getFullYear();r((()=>{H({type:"SET_SELECTED_DATE",newDate:f(M,C,N,E)})}),[M,C,N,E]);const W=c((e=>{H({type:"SET_OFFSET",newOffset:e})}),[]),{calendars:z,getBackProps:B,getDateProps:G,getForwardProps:Q,handleOffsetChanged:X}=g({date:U,selected:U,minDate:N,maxDate:E,offset:P,onOffsetChanged:W,firstDayOfWeek:1,...L}),Z=i(null),ee=c((e=>{if(!Z.current)return;const t=document.activeElement,n=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]'),a=async e=>{null==t||t.setAttribute("tabindex","-1"),e.setAttribute("tabindex","0"),e.focus()};n.forEach(((o,r)=>{const c=r+e;if(o==t)if(c<=n.length-1&&c>=0)a(n[c]);else if(e<0){if(j({calendars:z,minDate:N})||(s((()=>{X(P-b({calendars:z,offset:1,minDate:N}))})),!Z.current))return;const e=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[e.length+c]&&(e[0].setAttribute("tabindex","-1"),a(e[e.length+c]))}else{if(v({calendars:z,maxDate:E})||(s((()=>{X(P+k({calendars:z,offset:1,maxDate:E}))})),!Z.current))return;const e=Z.current.querySelectorAll('button.jkl-calendar-date-button:not([data-adjacent="true"]');e[c-n.length]&&(e[0].setAttribute("tabindex","-1"),a(e[c-n.length]))}}))}),[X,Z,P,z,E,N]),te=c((e=>{switch(e.key){case"ArrowUp":ee(-7),e.preventDefault();break;case"ArrowRight":ee(1),e.preventDefault();break;case"ArrowDown":ee(7),e.preventDefault();break;case"ArrowLeft":ee(-1),e.preventDefault()}}),[ee]),ne=c((e=>{var t;if("Tab"!==e.key)return;const n=null==(t=Z.current)?void 0:t.querySelectorAll('button:not([disabled]):not([tabindex="-1"]), select');if(!n)return;const a=n[0],o=n[n.length-1];e.shiftKey||document.activeElement!==o?e.shiftKey&&document.activeElement===a&&(o.focus(),e.preventDefault()):(a.focus(),e.preventDefault())}),[]),ae=c((e=>{const{date:t,selected:n,selectable:a,prevMonth:o,nextMonth:r}=e;return!!a&&!(!n&&t.toString()!==(null==N?void 0:N.toString())&&(o||r||K.getFullYear()!==t.getFullYear()||U.getMonth()===t.getMonth()||1!==t.getDate()))}),[K,N,U]),oe=c((()=>{N&&K.getFullYear()-N.getFullYear()==0&&K.getMonth()-N.getMonth()==1?document.querySelectorAll(".jkl-calendar-navigation__arrow")[1].focus():E&&E.getFullYear()-K.getFullYear()==0&&E.getMonth()-K.getMonth()==1&&document.querySelectorAll(".jkl-calendar-navigation__arrow")[0].focus()}),[N,E,K]),re=c((e=>{if(4!==e.target.value.length)return;const t=Number.parseInt(e.target.value);if(Number.isNaN(t))return;let n=12*(t-K.getFullYear());const a=new Date(K.getFullYear(),K.getMonth()+n,K.getDate());E&&E.getFullYear()===a.getFullYear()&&E.getMonth()<a.getMonth()?n-=a.getMonth()-E.getMonth():N&&N.getFullYear()===a.getFullYear()&&N.getMonth()>a.getMonth()&&(n+=N.getMonth()-a.getMonth()),H({type:"ADD_OFFSET",addedOffset:n})}),[K,N,E]),ce=c((e=>{if(!U&&!M)return;const t=K.getFullYear()-(U||new Date).getFullYear(),n=Number.parseInt(e.target.value)-(U||new Date).getMonth();H({type:"SET_OFFSET",newOffset:12*t+n})}),[U,M,K]),ie=w(V,N,E,$),se=D(V,x,N,E);return e("div",{ref:S,id:q,className:n("jkl-calendar",{"jkl-calendar--hidden":_}),"data-testid":"jkl-calendar",children:t("div",{className:"jkl-calendar__padding",ref:Z,onKeyDown:ne,children:[t("fieldset",{className:"jkl-calendar-navigation",children:[t("div",{children:[e("button",{...B({calendars:z,onClick:oe}),className:"jkl-calendar-navigation__arrow",type:"button",children:e(d,{variant:"medium",bold:!0})}),e("button",{...Q({calendars:z,onClick:oe}),className:"jkl-calendar-navigation__arrow",type:"button",children:e(u,{variant:"medium",bold:!0})})]}),t("div",{children:[t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:ce,className:"jkl-calendar-navigation-dropdown__select","aria-label":O,value:J.toString(),children:se.map((({label:t,value:n})=>e("option",{value:n,children:t},n)))}),e(m,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]}),t("div",{className:"jkl-calendar-navigation-dropdown",children:[e("select",{onChange:re,className:"jkl-calendar-navigation-dropdown__select","aria-label":T,value:V.toString(),children:ie.map((t=>e("option",{value:t,children:t},t)))}),e(m,{bold:!0,className:"jkl-calendar-navigation-dropdown__chevron"})]})]})]}),z.map((n=>t("table",{className:"jkl-calendar-table","data-testid":"jkl-datepicker-calendar",children:[t("caption",{className:"jkl-sr-only",children:[x[n.month],", ",n.year]}),e("thead",{children:e("tr",{children:Y.map((t=>e("th",{children:t},`${n.month}${n.year}${t}`)))})}),e("tbody",{"data-testid":"jkl-datepicker-dates",children:n.weeks.map(((t,a)=>e("tr",{children:t.map(((t,o)=>{const r=`${n.month}${n.year}${a}${o}`;if("string"==typeof t)return e("td",{className:"jkl-calendar__date jkl-calendar__date--empty",children:t},r);const{date:c,selectable:i,today:s,prevMonth:l,nextMonth:d}=t;return e("td",{children:e("button",{...G({dateObj:t}),type:"button",className:"jkl-calendar-date-button",tabIndex:ae(t)?0:-1,"aria-label":`${c.getDate()}. ${x[c.getMonth()].toLowerCase()}`,"aria-current":s?"date":void 0,"data-adjacent":l||d?"true":void 0,disabled:!i,onKeyDown:te,children:e("span",{"aria-hidden":"true",children:c.getDate()})})},r)}))},`${n.month}${n.year}${a}`)))})]},`${n.month}${n.year}`)))]})})}));S.displayName="Calendar";export{S as Calendar};
2
+ //# sourceMappingURL=Calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Calendar.js","sources":["../../../../../src/components/datepicker/internal/Calendar.tsx"],"sourcesContent":["import cn from \"classnames\";\nimport React, { forwardRef, useCallback, useEffect, useReducer, useRef } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Density } from \"../../../core\";\nimport { useId } from \"../../../hooks\";\nimport { ArrowLeftIcon, ArrowRightIcon, ChevronDownIcon } from \"../../icon\";\nimport type { YearsToShow } from \"../types\";\nimport { calendarInitializer, calendarReducer } from \"./calendarReducer\";\nimport { useCalendar, UseCalendarProps } from \"./useCalendar\";\nimport {\n addMonth,\n subtractMonth,\n isBackDisabled,\n isForwardDisabled,\n getYearSelectOptions,\n getMonthSelectOptions,\n DateInfo,\n getInitialDateShown,\n DEFAULT_YEARS_TO_SHOW,\n} from \"./utils\";\n\ninterface CalendarProps\n extends Omit<UseCalendarProps, \"date\" | \"onOffsetChanged\" | \"offset\" | \"firstDayOfWeek\" | \"selected\"> {\n date: Date | null;\n density?: Density;\n defaultSelected?: Date;\n hidden?: boolean;\n days?: string[];\n months?: string[];\n monthLabel?: string;\n yearLabel?: string;\n yearsToShow?: YearsToShow;\n onTabOutside: React.KeyboardEventHandler;\n}\n\nconst defaultMonths = [\n \"Januar\",\n \"Februar\",\n \"Mars\",\n \"April\",\n \"Mai\",\n \"Juni\",\n \"Juli\",\n \"August\",\n \"September\",\n \"Oktober\",\n \"November\",\n \"Desember\",\n];\n\nconst defaultDays = [\"man\", \"tir\", \"ons\", \"tor\", \"fre\", \"lør\", \"søn\"];\n\nexport const Calendar = forwardRef<HTMLDivElement, CalendarProps>((props, ref) => {\n const {\n hidden,\n date,\n defaultSelected,\n density,\n minDate,\n maxDate,\n days = defaultDays,\n months = defaultMonths,\n monthLabel = \"Velg måned\",\n yearLabel = \"Velg år\",\n yearsToShow = DEFAULT_YEARS_TO_SHOW,\n onTabOutside,\n ...rest\n } = props;\n\n const id = useId(\"jkl-calendar\");\n\n const [{ offset, selectedDate, shownDate }, dispatch] = useReducer(\n calendarReducer,\n getInitialDateShown(date, defaultSelected, minDate, maxDate),\n calendarInitializer,\n );\n\n const shownMonth = shownDate.getMonth();\n const shownYear = shownDate.getFullYear();\n\n useEffect(() => {\n dispatch({\n type: \"SET_SELECTED_DATE\",\n newDate: getInitialDateShown(date, defaultSelected, minDate, maxDate),\n });\n }, [date, defaultSelected, minDate, maxDate]);\n\n const onOffsetChanged = useCallback((newOffset: number) => {\n dispatch({\n type: \"SET_OFFSET\",\n newOffset,\n });\n }, []);\n\n const { calendars, getBackProps, getDateProps, getForwardProps, handleOffsetChanged } = useCalendar({\n date: selectedDate,\n selected: selectedDate,\n minDate,\n maxDate,\n offset,\n onOffsetChanged,\n firstDayOfWeek: 1,\n ...rest,\n });\n\n /// Calendar keyboard navigation\n\n const calendarPaddingRef = useRef<HTMLDivElement>(null);\n const doFocusChange = useCallback(\n (offsetDiff: number) => {\n if (!calendarPaddingRef.current) {\n return;\n }\n\n const e = document.activeElement;\n const buttons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n\n const changeFocusTo = async (nextButton: HTMLButtonElement) => {\n e?.setAttribute(\"tabindex\", \"-1\");\n nextButton.setAttribute(\"tabindex\", \"0\");\n nextButton.focus();\n };\n\n buttons.forEach((el, i) => {\n const newNodeKey = i + offsetDiff;\n\n if (el == e) {\n if (newNodeKey <= buttons.length - 1 && newNodeKey >= 0) {\n changeFocusTo(buttons[newNodeKey]);\n } else if (offsetDiff < 0) {\n if (isBackDisabled({ calendars, minDate })) {\n return;\n }\n\n // Hvis newNodeKey er utenfor samlingen med knapper så har vi prøvd å gå til\n // en dag utenfor måneden. Er offsetDiff negativ så har vi gått tilbake en\n // måned.\n flushSync(() => {\n handleOffsetChanged(offset - subtractMonth({ calendars, offset: 1, minDate }));\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n // + - = -\n if (newButtons[newButtons.length + newNodeKey]) {\n // Sørg for at ikke både 1. i måneden og valgt dag er fokuserbare\n newButtons[0].setAttribute(\"tabindex\", \"-1\");\n changeFocusTo(newButtons[newButtons.length + newNodeKey]);\n }\n } else {\n if (isForwardDisabled({ calendars, maxDate })) {\n return;\n }\n\n // Hvis newNodeKey er utenfor samlingen med knapper så har vi prøvd å gå til\n // en dag utenfor måneden. Er offsetDiff positiv så har vi gått frem en\n // måned.\n flushSync(() => {\n handleOffsetChanged(offset + addMonth({ calendars, offset: 1, maxDate }));\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons = calendarPaddingRef.current.querySelectorAll<HTMLButtonElement>(\n 'button.jkl-calendar-date-button:not([data-adjacent=\"true\"]',\n );\n // NewNodeKey er basert på forrige måneds liste med knapper. For at verdien skal bli\n // riktig i vår nye måned må vi trekke fra anntal dager fra forrige måned.\n if (newButtons[newNodeKey - buttons.length]) {\n // Sørg for at ikke både 1. i måneden og valgt dag er fokuserbare\n newButtons[0].setAttribute(\"tabindex\", \"-1\");\n changeFocusTo(newButtons[newNodeKey - buttons.length]);\n }\n }\n }\n });\n },\n [handleOffsetChanged, calendarPaddingRef, offset, calendars, maxDate, minDate],\n );\n\n const handleArrowNavigation = useCallback(\n (event: React.KeyboardEvent) => {\n switch (event.key) {\n case \"ArrowUp\":\n doFocusChange(-7);\n event.preventDefault();\n break;\n case \"ArrowRight\":\n doFocusChange(1);\n event.preventDefault();\n break;\n case \"ArrowDown\":\n doFocusChange(7);\n event.preventDefault();\n break;\n case \"ArrowLeft\":\n doFocusChange(-1);\n event.preventDefault();\n break;\n default:\n break;\n }\n },\n [doFocusChange],\n );\n\n const handleTabInside: React.KeyboardEventHandler = useCallback((event) => {\n if (event.key !== \"Tab\") return;\n\n const focusableElements = calendarPaddingRef.current?.querySelectorAll<HTMLElement>(\n 'button:not([disabled]):not([tabindex=\"-1\"]), select',\n );\n\n if (!focusableElements) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n if (!event.shiftKey && document.activeElement === lastElement) {\n firstElement.focus();\n event.preventDefault();\n } else if (event.shiftKey && document.activeElement === firstElement) {\n lastElement.focus();\n event.preventDefault();\n }\n }, []);\n\n const isFocusableDate = useCallback(\n (dateInfo: DateInfo) => {\n const { date, selected, selectable, prevMonth, nextMonth } = dateInfo;\n\n // Datoen kan ikke velges\n if (!selectable) {\n return false;\n }\n // Datoen er valgt dato\n if (selected) {\n return true;\n }\n // Datoen er første valgbare dato\n if (date.toString() === minDate?.toString()) {\n return true;\n }\n\n // Datoen er første i måneden som vises\n if (\n !prevMonth &&\n !nextMonth &&\n shownDate.getFullYear() === date.getFullYear() &&\n selectedDate.getMonth() !== date.getMonth() &&\n date.getDate() === 1\n ) {\n return true;\n }\n\n return false;\n },\n [shownDate, minDate, selectedDate],\n );\n\n const handleGotoEdgeMonth = useCallback(() => {\n if (\n // Vi er i ferd med å gå til første måned\n minDate &&\n shownDate.getFullYear() - minDate.getFullYear() === 0 &&\n shownDate.getMonth() - minDate.getMonth() === 1\n ) {\n // Fokuser på \"neste månded\"-knappen\n document.querySelectorAll<HTMLButtonElement>(\".jkl-calendar-navigation__arrow\")[1].focus();\n } else if (\n // Vi er i ferd med å gå til siste måned\n maxDate &&\n maxDate.getFullYear() - shownDate.getFullYear() === 0 &&\n maxDate.getMonth() - shownDate.getMonth() === 1\n ) {\n // Fokuser på \"forrige månded\"-knappen\n document.querySelectorAll<HTMLButtonElement>(\".jkl-calendar-navigation__arrow\")[0].focus();\n }\n }, [minDate, maxDate, shownDate]);\n\n /// Extended variant events\n\n const handleYearChange = useCallback<React.ChangeEventHandler<HTMLSelectElement>>(\n (event) => {\n if (event.target.value.length !== 4) {\n return;\n }\n\n const year: number = Number.parseInt(event.target.value);\n if (Number.isNaN(year)) {\n return;\n }\n\n let offset = (year - shownDate.getFullYear()) * 12;\n const expectedDate = new Date(shownDate.getFullYear(), shownDate.getMonth() + offset, shownDate.getDate());\n\n // Pass på at vi ikke hopper forbi maks. eller min. dato\n if (\n maxDate &&\n maxDate.getFullYear() === expectedDate.getFullYear() &&\n maxDate.getMonth() < expectedDate.getMonth()\n ) {\n offset -= expectedDate.getMonth() - maxDate.getMonth();\n } else if (\n minDate &&\n minDate.getFullYear() === expectedDate.getFullYear() &&\n minDate.getMonth() > expectedDate.getMonth()\n ) {\n offset += minDate.getMonth() - expectedDate.getMonth();\n }\n\n dispatch({\n type: \"ADD_OFFSET\",\n addedOffset: offset,\n });\n\n return;\n },\n [shownDate, minDate, maxDate],\n );\n\n const handleMonthChange = useCallback<React.ChangeEventHandler<HTMLSelectElement>>(\n (event) => {\n if (!selectedDate && !date) {\n return;\n }\n\n const yearDiff = shownDate.getFullYear() - (selectedDate || new Date()).getFullYear();\n const monthDiff = Number.parseInt(event.target.value) - (selectedDate || new Date()).getMonth();\n\n dispatch({\n type: \"SET_OFFSET\",\n newOffset: yearDiff * 12 + monthDiff,\n });\n\n return;\n },\n [selectedDate, date, shownDate],\n );\n\n const yearSelectOptions = getYearSelectOptions(shownYear, minDate, maxDate, yearsToShow);\n const monthSelectOptions = getMonthSelectOptions(shownYear, months, minDate, maxDate);\n\n return (\n <div\n ref={ref}\n id={id}\n className={cn(\"jkl-calendar\", {\n \"jkl-calendar--hidden\": hidden,\n })}\n data-testid=\"jkl-calendar\"\n >\n {/* Vi lytter på på trykk på Tab inne i kalenderen for å håndtere fokus */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div className=\"jkl-calendar__padding\" ref={calendarPaddingRef} onKeyDown={handleTabInside}>\n <fieldset className=\"jkl-calendar-navigation\">\n <div>\n <button\n {...getBackProps({ calendars, onClick: handleGotoEdgeMonth })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowLeftIcon variant=\"medium\" bold />\n </button>\n <button\n {...getForwardProps({ calendars, onClick: handleGotoEdgeMonth })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowRightIcon variant=\"medium\" bold />\n </button>\n </div>\n <div>\n <div className=\"jkl-calendar-navigation-dropdown\">\n <select\n onChange={handleMonthChange}\n className=\"jkl-calendar-navigation-dropdown__select\"\n aria-label={monthLabel}\n value={shownMonth.toString()}\n >\n {monthSelectOptions.map(({ label, value }) => (\n <option key={value} value={value}>\n {label}\n </option>\n ))}\n </select>\n <ChevronDownIcon bold className=\"jkl-calendar-navigation-dropdown__chevron\" />\n </div>\n <div className=\"jkl-calendar-navigation-dropdown\">\n <select\n onChange={handleYearChange}\n className=\"jkl-calendar-navigation-dropdown__select\"\n aria-label={yearLabel}\n value={shownYear.toString()}\n >\n {yearSelectOptions.map((year) => (\n <option key={year} value={year}>\n {year}\n </option>\n ))}\n </select>\n <ChevronDownIcon bold className=\"jkl-calendar-navigation-dropdown__chevron\" />\n </div>\n </div>\n </fieldset>\n {calendars.map((calendar) => (\n <table\n className=\"jkl-calendar-table\"\n key={`${calendar.month}${calendar.year}`}\n data-testid=\"jkl-datepicker-calendar\"\n >\n <caption className=\"jkl-sr-only\">\n {months[calendar.month]}, {calendar.year}\n </caption>\n <thead>\n <tr>\n {days.map((weekday) => (\n <th key={`${calendar.month}${calendar.year}${weekday}`}>{weekday}</th>\n ))}\n </tr>\n </thead>\n <tbody data-testid=\"jkl-datepicker-dates\">\n {calendar.weeks.map((week, weekIndex) => (\n <tr key={`${calendar.month}${calendar.year}${weekIndex}`}>\n {week.map((dateInfo, index) => {\n const key = `${calendar.month}${calendar.year}${weekIndex}${index}`;\n if (typeof dateInfo === \"string\") {\n return (\n <td className=\"jkl-calendar__date jkl-calendar__date--empty\" key={key}>\n {dateInfo}\n </td>\n );\n }\n const { date, selectable, today, prevMonth, nextMonth } = dateInfo;\n\n return (\n <td key={key}>\n <button\n {...getDateProps({\n dateObj: dateInfo,\n })}\n type=\"button\"\n className=\"jkl-calendar-date-button\"\n tabIndex={isFocusableDate(dateInfo) ? 0 : -1}\n aria-label={`${date.getDate()}. ${months[\n date.getMonth()\n ].toLowerCase()}`}\n aria-current={today ? \"date\" : undefined}\n data-adjacent={prevMonth || nextMonth ? \"true\" : undefined}\n disabled={!selectable}\n onKeyDown={handleArrowNavigation}\n >\n <span aria-hidden=\"true\">{date.getDate()}</span>\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n ))}\n </div>\n </div>\n );\n});\n\nCalendar.displayName = \"Calendar\";\n"],"names":["defaultMonths","defaultDays","Calendar","forwardRef","props","ref","hidden","date","defaultSelected","density","minDate","maxDate","days","months","monthLabel","yearLabel","yearsToShow","DEFAULT_YEARS_TO_SHOW","onTabOutside","rest","id","useId","offset","selectedDate","shownDate","dispatch","useReducer","calendarReducer","getInitialDateShown","calendarInitializer","shownMonth","getMonth","shownYear","getFullYear","useEffect","type","newDate","onOffsetChanged","useCallback","newOffset","calendars","getBackProps","getDateProps","getForwardProps","handleOffsetChanged","useCalendar","selected","firstDayOfWeek","calendarPaddingRef","useRef","doFocusChange","offsetDiff","current","e","document","activeElement","buttons","querySelectorAll","changeFocusTo","async","nextButton","setAttribute","focus","forEach","el","i","newNodeKey","length","isBackDisabled","flushSync","subtractMonth","newButtons","isForwardDisabled","addMonth","handleArrowNavigation","event","key","preventDefault","handleTabInside","focusableElements","_a","firstElement","lastElement","shiftKey","isFocusableDate","dateInfo","selectable","prevMonth","nextMonth","toString","getDate","handleGotoEdgeMonth","handleYearChange","target","value","year","Number","parseInt","isNaN","expectedDate","Date","addedOffset","handleMonthChange","yearDiff","monthDiff","yearSelectOptions","getYearSelectOptions","monthSelectOptions","getMonthSelectOptions","jsx","className","cn","children","onKeyDown","jsxs","onClick","ArrowLeftIcon","variant","bold","ArrowRightIcon","onChange","map","label","ChevronDownIcon","calendar","month","weekday","weeks","week","weekIndex","index","today","dateObj","tabIndex","toLowerCase","disabled","displayName"],"mappings":"wnEAmCA,MAAMA,EAAgB,CAClB,SACA,UACA,OACA,QACA,MACA,OACA,OACA,SACA,YACA,UACA,WACA,YAGEC,EAAc,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,OAElDC,EAAWC,GAA0C,CAACC,EAAOC,KAChE,MACFC,OAAAA,EACAC,KAAAA,EACAC,gBAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EAAOX,EACPY,OAAAA,EAASb,EACTc,WAAAA,EAAa,aACbC,UAAAA,EAAY,UACZC,YAAAA,EAAcC,EACdC,aAAAA,KACGC,GACHf,EAEEgB,EAAKC,EAAM,kBAERC,OAAAA,EAAQC,aAAAA,EAAcC,UAAAA,GAAaC,GAAYC,EACpDC,EACAC,EAAoBrB,EAAMC,EAAiBE,EAASC,GACpDkB,GAGEC,EAAaN,EAAUO,WACvBC,EAAYR,EAAUS,cAE5BC,GAA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e.selectedDate),a.setMonth(e.selectedDate.getMonth()+s.newOffset),{...e,offset:s.newOffset,shownDate:a};case"ADD_OFFSET":return a=new Date(e.selectedDate),a.setMonth(e.selectedDate.getMonth()+e.offset+s.addedOffset),{...e,offset:e.offset+s.addedOffset,shownDate:a};case"SET_SELECTED_DATE":return t(s.newDate);default:return e}},t=e=>({selectedDate:e,offset:0,shownDate:e});export{t as calendarInitializer,e as calendarReducer};
2
+ //# sourceMappingURL=calendarReducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarReducer.js","sources":["../../../../../src/components/datepicker/internal/calendarReducer.ts"],"sourcesContent":["import { type Reducer } from \"react\";\n\nexport type CalendarAction =\n | {\n type: \"SET_SELECTED_DATE\";\n newDate: Date;\n }\n | {\n type: \"SET_OFFSET\";\n newOffset: number;\n }\n | {\n type: \"ADD_OFFSET\";\n addedOffset: number;\n };\n\nexport type CalendarState = {\n selectedDate: Date;\n offset: number;\n shownDate: Date;\n};\n\nexport const calendarReducer: Reducer<CalendarState, CalendarAction> = (currentState, action) => {\n let shownDate: Date;\n\n switch (action.type) {\n case \"SET_OFFSET\":\n shownDate = new Date(currentState.selectedDate);\n shownDate.setMonth(currentState.selectedDate.getMonth() + action.newOffset);\n\n return {\n ...currentState,\n offset: action.newOffset,\n shownDate,\n };\n\n case \"ADD_OFFSET\":\n shownDate = new Date(currentState.selectedDate);\n shownDate.setMonth(currentState.selectedDate.getMonth() + currentState.offset + action.addedOffset);\n\n return {\n ...currentState,\n offset: currentState.offset + action.addedOffset,\n shownDate,\n };\n\n case \"SET_SELECTED_DATE\":\n return calendarInitializer(action.newDate);\n\n default:\n return currentState;\n }\n};\n\nexport const calendarInitializer = (initialDate: Date): CalendarState => ({\n selectedDate: initialDate,\n offset: 0,\n shownDate: initialDate,\n});\n"],"names":["calendarReducer","currentState","action","shownDate","type","Date","selectedDate","setMonth","getMonth","newOffset","offset","addedOffset","calendarInitializer","newDate","initialDate"],"mappings":"AAsBa,MAAAA,EAA0D,CAACC,EAAcC,KAC9EC,IAAAA,EAEJ,OAAQD,EAAOE,MACX,IAAK,aACW,OAAAD,EAAA,IAAIE,KAAKJ,EAAaK,cAClCH,EAAUI,SAASN,EAAaK,aAAaE,WAAaN,EAAOO,WAE1D,IACAR,EACHS,OAAQR,EAAOO,UACfN,UAAAA,GAGR,IAAK,aACW,OAAAA,EAAA,IAAIE,KAAKJ,EAAaK,cACxBH,EAAAI,SAASN,EAAaK,aAAaE,WAAaP,EAAaS,OAASR,EAAOS,aAEhF,IACAV,EACHS,OAAQT,EAAaS,OAASR,EAAOS,YACrCR,UAAAA,GAGR,IAAK,oBACMS,OAAAA,EAAoBV,EAAOW,SAEtC,QACWZ,OAAAA,EACf,EAGSW,EAAuBE,IAAsC,CACtER,aAAcQ,EACdJ,OAAQ,EACRP,UAAWW"}
@@ -0,0 +1,2 @@
1
+ import e from"date-fns/startOfDay";import{useState as a}from"react";import{getCalendars as t,composeEventHandlers as n,subtractMonth as s,isBackDisabled as o,addMonth as d,isForwardDisabled as f}from"./utils.js";function l(e){return void 0!==e}function r(e,{onClick:a,dateObj:t}){return{onClick:n(a,(a=>{e(t,a)})),disabled:!t.selectable,"aria-pressed":t.selected,role:"button"}}function i({minDate:e,offsetMonth:a,handleOffsetChanged:t},{onClick:d,offset:f=1,calendars:l}){const r=`Gå tilbake ${f} måned${1===f?"":"er"}`;return{onClick:n(d,(()=>{t(a-s({calendars:l,offset:f,minDate:e}))})),disabled:o({calendars:l,minDate:e}),"aria-label":r,title:r}}function c({maxDate:e,offsetMonth:a,handleOffsetChanged:t},{onClick:s,offset:o=1,calendars:l}){const r=`Gå frem ${o} måned${1===o?"":"er"}`;return{onClick:n(s,(()=>{t(a+d({calendars:l,offset:o,maxDate:e}))})),disabled:f({calendars:l,maxDate:e}),"aria-label":r,title:r}}function m({date:n=e(new Date),maxDate:s,minDate:o,monthsToDisplay:d=1,firstDayOfWeek:f=0,showOutsideDays:m=!0,offset:D,onDateSelected:u,onOffsetChanged:h,selected:b}){const[C,O]=a(0),k=function(e,a){return l(e)?e:a}(D,C);function p(e){l(D)||O(e),h(e)}return{calendars:t({date:n,selected:b,monthsToDisplay:d,minDate:o,maxDate:s,offset:k,firstDayOfWeek:f,showOutsideDays:m}),getDateProps:r.bind(null,u),getBackProps:i.bind(null,{minDate:o,offsetMonth:k,handleOffsetChanged:p}),getForwardProps:c.bind(null,{maxDate:s,offsetMonth:k,handleOffsetChanged:p}),handleOffsetChanged:p}}export{m as useCalendar};
2
+ //# sourceMappingURL=useCalendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCalendar.js","sources":["../../../../../src/components/datepicker/internal/useCalendar.ts"],"sourcesContent":["/***\n * MIT License\n *\n * Copyright (c) 2017 Deseret Digital Media. 2022 Fremtind Forsikring AS.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nimport startOfDay from \"date-fns/startOfDay\";\nimport React, { useState } from \"react\";\nimport {\n composeEventHandlers,\n subtractMonth,\n addMonth,\n isBackDisabled,\n isForwardDisabled,\n getCalendars,\n DateInfo,\n CalendarMonth,\n} from \"./utils\";\n\nfunction isOffsetControlled(propOffset: number | undefined): boolean {\n return propOffset !== undefined;\n}\n\nfunction getOffset(prop: number, state: number): number {\n return isOffsetControlled(prop) ? prop : state;\n}\n\ntype BoundGetDateProps = (dateInfo: DateInfo, event: React.MouseEvent) => void;\n\ntype GetDateProps = {\n onClick?: React.MouseEventHandler;\n dateObj: DateInfo;\n};\n\ntype GetDatePropsResult = {\n onClick: React.MouseEventHandler;\n disabled: boolean;\n \"aria-pressed\": boolean;\n role: \"button\";\n};\n\nfunction getDateProps(onDateSelected: BoundGetDateProps, { onClick, dateObj }: GetDateProps): GetDatePropsResult {\n return {\n onClick: composeEventHandlers(onClick, (event) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n \"aria-pressed\": dateObj.selected,\n role: \"button\",\n };\n}\n\ntype BoundGetBackProps = {\n handleOffsetChanged: (newOffset: number) => void;\n offsetMonth: number;\n minDate?: Date;\n};\n\ntype GetBackProps = {\n onClick?: React.MouseEventHandler;\n offset?: number;\n calendars: CalendarMonth[];\n};\n\ntype GetBackPropsResult = {\n onClick: React.MouseEventHandler;\n disabled: boolean;\n \"aria-label\": string;\n title: string;\n};\n\nfunction getBackProps(\n { minDate, offsetMonth, handleOffsetChanged }: BoundGetBackProps,\n { onClick, offset = 1, calendars }: GetBackProps,\n): GetBackPropsResult {\n const label = `Gå tilbake ${offset} måned${offset === 1 ? \"\" : \"er\"}`;\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(offsetMonth - subtractMonth({ calendars, offset, minDate }));\n }),\n disabled: isBackDisabled({ calendars, minDate }),\n \"aria-label\": label,\n title: label,\n };\n}\n\ntype BoundGetForwardProps = {\n handleOffsetChanged: (newOffset: number) => void;\n offsetMonth: number;\n maxDate?: Date;\n};\n\ntype GetForwardProps = {\n onClick?: React.MouseEventHandler;\n offset?: number;\n calendars: CalendarMonth[];\n};\n\ntype GetForwardPropsResult = {\n onClick: React.MouseEventHandler;\n disabled: boolean;\n \"aria-label\": string;\n title: string;\n};\n\nfunction getForwardProps(\n { maxDate, offsetMonth, handleOffsetChanged }: BoundGetForwardProps,\n { onClick, offset = 1, calendars }: GetForwardProps,\n): GetForwardPropsResult {\n const label = `Gå frem ${offset} måned${offset === 1 ? \"\" : \"er\"}`;\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(offsetMonth + addMonth({ calendars, offset, maxDate }));\n }),\n disabled: isForwardDisabled({ calendars, maxDate }),\n \"aria-label\": label,\n title: label,\n };\n}\n\nexport interface UseCalendarProps {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n showOutsideDays?: boolean;\n offset: number;\n onDateSelected: (dateObj: DateInfo, event: React.MouseEvent) => void;\n onOffsetChanged: (newOffset: number) => void;\n selected?: Date | Date[];\n}\n\nexport type GetDatePropsFunc = (props: GetDateProps) => GetDatePropsResult;\nexport type GetBackPropsFunc = (props: GetBackProps) => GetBackPropsResult;\nexport type GetForwardPropsFunc = (props: GetForwardProps) => GetForwardPropsResult;\nexport type HandleOffsetFunc = (newOffset: number) => void;\n\nexport type UseCalendarResult = {\n calendars: CalendarMonth[];\n getDateProps: GetDatePropsFunc;\n getBackProps: GetBackPropsFunc;\n getForwardProps: GetForwardPropsFunc;\n handleOffsetChanged: HandleOffsetFunc;\n};\n\nexport function useCalendar({\n date = startOfDay(new Date()),\n maxDate,\n minDate,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n showOutsideDays = true,\n offset,\n onDateSelected,\n onOffsetChanged,\n selected,\n}: UseCalendarProps): UseCalendarResult {\n const [stateOffset, setStateOffset] = useState(0);\n const offsetMonth = getOffset(offset, stateOffset);\n\n function handleOffsetChanged(newOffset: number) {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n }\n\n const calendars = getCalendars({\n date,\n selected,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n showOutsideDays,\n });\n return {\n calendars,\n getDateProps: getDateProps.bind(null, onDateSelected),\n getBackProps: getBackProps.bind(null, {\n minDate,\n offsetMonth,\n handleOffsetChanged,\n }),\n getForwardProps: getForwardProps.bind(null, {\n maxDate,\n offsetMonth,\n handleOffsetChanged,\n }),\n handleOffsetChanged,\n };\n}\n"],"names":["isOffsetControlled","propOffset","getDateProps","onDateSelected","onClick","dateObj","composeEventHandlers","event","disabled","selectable","selected","role","getBackProps","minDate","offsetMonth","handleOffsetChanged","offset","calendars","label","subtractMonth","isBackDisabled","title","getForwardProps","maxDate","addMonth","isForwardDisabled","useCalendar","date","startOfDay","Date","monthsToDisplay","firstDayOfWeek","showOutsideDays","onOffsetChanged","stateOffset","setStateOffset","useState","prop","state","getOffset","newOffset","getCalendars","bind"],"mappings":"oNAoCA,SAASA,EAAmBC,GACxB,YAAsB,IAAfA,CACX,CAoBA,SAASC,EAAaC,GAAqCC,QAAAA,EAASC,QAAAA,IACzD,MAAA,CACHD,QAASE,EAAqBF,GAAUG,IACpCJ,EAAeE,EAASE,EAAK,IAEjCC,UAAWH,EAAQI,WACnB,eAAgBJ,EAAQK,SACxBC,KAAM,SAEd,CAqBA,SAASC,GACHC,QAAAA,EAASC,YAAAA,EAAaC,oBAAAA,IACtBX,QAAAA,EAASY,OAAAA,EAAS,EAAGC,UAAAA,IAEvB,MAAMC,EAAQ,cAAcF,UAA0B,IAAXA,EAAe,GAAK,OACxD,MAAA,CACHZ,QAASE,EAAqBF,GAAS,KACnCW,EAAoBD,EAAcK,EAAc,CAAEF,UAAAA,EAAWD,OAAAA,EAAQH,QAAAA,IAAU,IAEnFL,SAAUY,EAAe,CAAEH,UAAAA,EAAWJ,QAAAA,IACtC,aAAcK,EACdG,MAAOH,EAEf,CAqBA,SAASI,GACHC,QAAAA,EAAST,YAAAA,EAAaC,oBAAAA,IACtBX,QAAAA,EAASY,OAAAA,EAAS,EAAGC,UAAAA,IAEvB,MAAMC,EAAQ,WAAWF,UAA0B,IAAXA,EAAe,GAAK,OACrD,MAAA,CACHZ,QAASE,EAAqBF,GAAS,KACnCW,EAAoBD,EAAcU,EAAS,CAAEP,UAAAA,EAAWD,OAAAA,EAAQO,QAAAA,IAAU,IAE9Ef,SAAUiB,EAAkB,CAAER,UAAAA,EAAWM,QAAAA,IACzC,aAAcL,EACdG,MAAOH,EAEf,CA4BO,SAASQ,GACZC,KAAAA,EAAOC,EAAe,IAAAC,MACtBN,QAAAA,EACAV,QAAAA,EACAiB,gBAAAA,EAAkB,EAClBC,eAAAA,EAAiB,EACjBC,gBAAAA,GAAkB,EAClBhB,OAAAA,EACAb,eAAAA,EACA8B,gBAAAA,EACAvB,SAAAA,IAEM,MAACwB,EAAaC,GAAkBC,EAAS,GACzCtB,EAxIV,SAAmBuB,EAAcC,GACtBtC,OAAAA,EAAmBqC,GAAQA,EAAOC,CAC7C,CAsIwBC,CAAUvB,EAAQkB,GAEtC,SAASnB,EAAoByB,GACpBxC,EAAmBgB,IACpBmB,EAAeK,GAEnBP,EAAgBO,EACpB,CAYO,MAAA,CACHvB,UAXcwB,EAAa,CAC3Bd,KAAAA,EACAjB,SAAAA,EACAoB,gBAAAA,EACAjB,QAAAA,EACAU,QAAAA,EACAP,OAAQF,EACRiB,eAAAA,EACAC,gBAAAA,IAIA9B,aAAcA,EAAawC,KAAK,KAAMvC,GACtCS,aAAcA,EAAa8B,KAAK,KAAM,CAClC7B,QAAAA,EACAC,YAAAA,EACAC,oBAAAA,IAEJO,gBAAiBA,EAAgBoB,KAAK,KAAM,CACxCnB,QAAAA,EACAT,YAAAA,EACAC,oBAAAA,IAEJA,oBAAAA,EAER"}
@@ -0,0 +1,2 @@
1
+ import t from"date-fns/addDays";import e from"date-fns/differenceInCalendarMonths";import n from"date-fns/isBefore";import a from"date-fns/isToday";import s from"date-fns/startOfDay";import{parseDateString as o}from"../utils.js";function r(...t){return e=>t.some((t=>(t&&t(e),e.defaultPrevented)))}function l({calendars:t,offset:n,minDate:a}){if(n>1&&a){const{firstDayOfMonth:s}=t[0],o=e(s,a);o<n&&(n=o)}return n}const i=3;function f(t,e,n,a){if(e&&e.getFullYear()>t)return[e.getFullYear().toString()];if(n&&n.getFullYear()<t)return[n.getFullYear().toString()];let s,o,r=!1;"all"===a?(r=!0,s=3,o=3):(s="number"==typeof a?a:a.previous,o="number"==typeof a?a:a.coming);let l=t-s;if(e){const t=r?e.getFullYear():l;l=Math.max(e.getFullYear(),t)}let i=t+o;if(n){const t=r?n.getFullYear():i;i=Math.min(n.getFullYear(),t)}const f=Math.max(i-l+1,1);return[...Array(f).keys()].map((t=>t+l)).map((t=>t.toString()))}function u(t,e,n,a){const s=(null==n?void 0:n.getFullYear())||t,o=void 0===(null==n?void 0:n.getMonth())?0:n.getMonth(),r=(null==a?void 0:a.getFullYear())||t,l=void 0===(null==a?void 0:a.getMonth())?11:a.getMonth();let i=0,f=11;return s===t&&(i=o),r===t&&(f=l),e.map(((t,e)=>({value:e.toString(),label:t}))).filter((({value:t})=>parseInt(t)>=i&&parseInt(t)<=f))}function c({calendars:t,offset:n,maxDate:a}){if(n>1&&a){const{lastDayOfMonth:s}=t[t.length-1],o=e(a,s);o<n&&(n=o)}return n}function D({calendars:e,minDate:a}){if(!a)return!1;const{firstDayOfMonth:s}=e[0],o=t(s,-1);return!!n(o,a)}function h({calendars:e,maxDate:a}){if(!a)return!1;const{lastDayOfMonth:s}=e[e.length-1],o=t(s,1);return!!n(a,o)}function d({date:t,selected:e,monthsToDisplay:a,offset:o,minDate:r,maxDate:l,firstDayOfWeek:i,showOutsideDays:f}){const u=[],c=function(t,e,a){let o=s(t);if(e){const t=s(e);n(o,t)&&(o=t)}if(a){const t=s(a);n(t,o)&&(o=t)}return o}(t,r,l);for(let t=0;t<a;t++){const n=m({month:c.getMonth()+t+o,year:c.getFullYear(),selectedDates:e,minDate:r,maxDate:l,firstDayOfWeek:i,showOutsideDays:f});u.push(n)}return u}function m({month:e,year:n,selectedDates:s,minDate:o,maxDate:r,firstDayOfWeek:l,showOutsideDays:i}){const f=function(t,e){const n=new Date(e,t,1);return t=n.getMonth(),e=n.getFullYear(),{daysInMonth:32-new Date(e,t,32).getDate(),month:t,year:e}}(e,n),u=f.daysInMonth;e=f.month,n=f.year;const c=[];for(let t=1;t<=u;t++){const l=new Date(n,e,t),i={date:l,selected:g(s,l),selectable:y(o,r,l),today:a(l),prevMonth:!1,nextMonth:!1};c.push(i)}const D=new Date(n,e,1),h=new Date(n,e,u),d=function({firstDayOfMonth:e,minDate:n,maxDate:a,selectedDates:s,firstDayOfWeek:o,showOutsideDays:r}){const l=[];let i=(e.getDay()+7-o)%7;if(r){const o=t(e,-1),r=o.getDate(),f=o.getMonth(),u=o.getFullYear();let c=0;for(;c<i;){const t=new Date(u,f,r-c),e={date:t,selected:g(s,t),selectable:y(n,a,t),today:!1,prevMonth:!0,nextMonth:!1};l.unshift(e),c++}}else for(;i>0;)l.unshift(""),i--;return l}({firstDayOfMonth:D,minDate:o,maxDate:r,selectedDates:s,firstDayOfWeek:l,showOutsideDays:i}),m=function({lastDayOfMonth:e,minDate:n,maxDate:a,selectedDates:s,firstDayOfWeek:o,showOutsideDays:r}){const l=[];let i=(e.getDay()+7-o)%7;if(r){const o=t(e,1),r=o.getMonth(),f=o.getFullYear();let u=0;for(;u<6-i;){const t=new Date(f,r,1+u),e={date:t,selected:g(s,t),selectable:y(n,a,t),today:!1,prevMonth:!1,nextMonth:!0};l.push(e),u++}}else for(;i<6;)l.push(""),i++;return l}({lastDayOfMonth:h,minDate:o,maxDate:r,selectedDates:s,firstDayOfWeek:l,showOutsideDays:i});c.unshift(...d),c.push(...m);const M=function(t){const e=Math.ceil(t.length/7),n=[];for(let a=0;a<e;a++){n[a]=[];for(let e=0;e<7;e++)n[a].push(t[7*a+e])}return n}(c);return{firstDayOfMonth:D,lastDayOfMonth:h,month:e,year:n,weeks:M}}function g(t,e){return!!t&&(t=Array.isArray(t)?t:[t]).some((t=>t instanceof Date&&s(t).getTime()===s(e).getTime()))}function y(t,e,a){return!(t&&n(a,t)||e&&n(e,a))}function M(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function O(t,e){return!t||!M(t,e)}function p(t,e,n){return!!(n&&t>n||e&&t<e)}function w(t,e,n,a){const s=o(t),r=o(e);return s?p(s,n,a)?null:s:r?p(r,n,a)?null:r:null}function F(t,e,n,a){let s=t||e||new Date;return n&&(s=n>s?n:s),a&&(s=a<s?a:s),s}export{i as DEFAULT_YEARS_TO_SHOW,c as addMonth,r as composeEventHandlers,O as dateHasChanged,p as dateIsOutsideRange,d as getCalendars,w as getInitialDate,F as getInitialDateShown,u as getMonthSelectOptions,f as getYearSelectOptions,D as isBackDisabled,h as isForwardDisabled,M as isSameDay,l as subtractMonth};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/datepicker/internal/utils.ts"],"sourcesContent":["/***\n * MIT License\n *\n * Copyright (c) 2017 Deseret Digital Media. 2022 Fremtind Forsikring AS.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport addDays from \"date-fns/addDays\";\nimport differenceInCalendarMonths from \"date-fns/differenceInCalendarMonths\";\nimport isBefore from \"date-fns/isBefore\";\nimport isToday from \"date-fns/isToday\";\nimport startOfDay from \"date-fns/startOfDay\";\nimport React from \"react\";\nimport type { ValuePair } from \"../../../utilities\";\nimport type { YearsToShow } from \"../types\";\nimport { parseDateString } from \"../utils\";\n\nexport function composeEventHandlers(...fns: Array<React.MouseEventHandler | undefined>) {\n return (event: React.MouseEvent) =>\n fns.some((fn) => {\n fn && fn(event);\n return event.defaultPrevented;\n });\n}\n\n/**\n * Takes a calendars array and figures out the number of months to subtract\n * based on the current offset and the minDate allowed.\n * @param {Object} param The param object\n * @param {Array} param.calendars The calendars array created by the getCalendars function\n * @param {Number} param.offset The num of months to be subtracted\n * @param {Date} param.minDate The earliest date we are allow to subtract back to\n * @returns {Number} The number of months to subtract\n */\nexport function subtractMonth({\n calendars,\n offset,\n minDate,\n}: {\n calendars: CalendarMonth[];\n offset: number;\n minDate?: Date;\n}): number {\n if (offset > 1 && minDate) {\n const { firstDayOfMonth } = calendars[0];\n const diffInMonths = differenceInCalendarMonths(firstDayOfMonth, minDate);\n if (diffInMonths < offset) {\n offset = diffInMonths;\n }\n }\n return offset;\n}\n\nexport const DEFAULT_YEARS_TO_SHOW = 3;\n\n/**\n * Generates an array of year strings for a year selector component, with min and max dates taken into account.\n *\n * @param {number} currentYear - The current year to center the list around\n * @param {Date | undefined} [minDate] - The minimum date to include in the list of years\n * @param {Date | undefined} [maxDate] - The maximum date to include in the list of years\n *\n * @returns {string[]} - An array of year strings, starting from the earliest year specified by minDate or currentYear - 3, and ending at the latest year specified by maxDate or currentYear + 3\n */\nexport function getYearSelectOptions(\n currentYear: number,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n yearsToShow: YearsToShow,\n): string[] {\n if (minDate && minDate.getFullYear() > currentYear) {\n return [minDate.getFullYear().toString()];\n }\n\n if (maxDate && maxDate.getFullYear() < currentYear) {\n return [maxDate.getFullYear().toString()];\n }\n\n let showAllYears = false;\n let previousYearsToShow: number;\n let comingYearsToShow: number;\n\n if (yearsToShow === \"all\") {\n showAllYears = true;\n previousYearsToShow = DEFAULT_YEARS_TO_SHOW;\n comingYearsToShow = DEFAULT_YEARS_TO_SHOW;\n } else {\n previousYearsToShow = typeof yearsToShow === \"number\" ? yearsToShow : yearsToShow.previous;\n comingYearsToShow = typeof yearsToShow === \"number\" ? yearsToShow : yearsToShow.coming;\n }\n\n let startYear = currentYear - previousYearsToShow;\n if (minDate) {\n const earliestStartYear = showAllYears ? minDate.getFullYear() : startYear;\n startYear = Math.max(minDate.getFullYear(), earliestStartYear);\n }\n\n let endYear = currentYear + comingYearsToShow;\n if (maxDate) {\n const latestEndYear = showAllYears ? maxDate.getFullYear() : endYear;\n endYear = Math.min(maxDate.getFullYear(), latestEndYear);\n }\n\n // Sørg for å alltid vise minst ett år\n const numYears = Math.max(endYear - startYear + 1, 1);\n\n const range = [...Array(numYears).keys()].map((x) => x + startYear);\n const stringRange = range.map((item) => item.toString());\n\n return stringRange;\n}\n\n/**\n * Returns an array of months that are allowed for selection in the current year based on the minimum and maximum dates.\n * @param {number} currentYear The current year\n * @param {string[]} monthNames An array of strings representing the month names\n * @param {Date | undefined} minDate The minimum date that is allowed for selection\n * @param {Date | undefined} maxDate The maximum date that is allowed for selection\n * @returns {ValuePair[]} An array of ValuePairs representing the months that are allowed for selection in the current year\n */\nexport function getMonthSelectOptions(\n currentYear: number,\n monthNames: string[],\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): ValuePair[] {\n const minDateYear = minDate?.getFullYear() || currentYear;\n const minDateMonth = minDate?.getMonth() === undefined ? 0 : minDate.getMonth();\n const maxDateYear = maxDate?.getFullYear() || currentYear;\n const maxDateMonth = maxDate?.getMonth() === undefined ? 11 : maxDate.getMonth();\n\n let startMonth = 0;\n let endMonth = 11;\n\n if (minDateYear === currentYear) {\n startMonth = minDateMonth;\n }\n if (maxDateYear === currentYear) {\n endMonth = maxDateMonth;\n }\n\n const filteredMonths = monthNames\n .map((month, index) => ({\n value: index.toString(),\n label: month,\n }))\n .filter(({ value }) => parseInt(value) >= startMonth && parseInt(value) <= endMonth);\n\n return filteredMonths;\n}\n\n/**s\n * Takes a calendars array and figures out the number of months to add\n * based on the current offset and the maxDate allowed.\n * @param {Object} param The param object\n * @param {Array} param.calendars The calendars array created by the getCalendars function\n * @param {Number} param.offset The num of months to be added\n * @param {Date} param.maxDate The furthest date we are allow to add forward to\n * @returns {Number} The number of months to add\n */\nexport function addMonth({\n calendars,\n offset,\n maxDate,\n}: {\n calendars: CalendarMonth[];\n offset: number;\n maxDate?: Date;\n}): number {\n if (offset > 1 && maxDate) {\n const { lastDayOfMonth } = calendars[calendars.length - 1];\n const diffInMonths = differenceInCalendarMonths(maxDate, lastDayOfMonth);\n if (diffInMonths < offset) {\n offset = diffInMonths;\n }\n }\n return offset;\n}\n\n/**\n * Takes a calendars array and figures out if the back button should be\n * disabled based on the minDate allowed.\n * @param {Object} param The param object\n * @param {Array} param.calendars The calendars array created by the getCalendars function\n * @param {Date} param.minDate The earliest date available\n * @returns {Boolean} Whether the back button should be disabled.\n */\nexport function isBackDisabled({ calendars, minDate }: { calendars: CalendarMonth[]; minDate?: Date }): boolean {\n if (!minDate) {\n return false;\n }\n const { firstDayOfMonth } = calendars[0];\n const firstDayOfMonthMinusOne = addDays(firstDayOfMonth, -1);\n if (isBefore(firstDayOfMonthMinusOne, minDate)) {\n return true;\n }\n return false;\n}\n\n/**\n * Takes a calendars array and figures out if the forward button should be\n * disabled based on the maxDate allowed.\n * @param {Object} param The param object\n * @param {Array} param.calendars The calendars array created by the getCalendars function\n * @param {Date} param.maxDate The furthest date available\n * @returns {Boolean} Whether the forward button should be disabled.\n */\nexport function isForwardDisabled({ calendars, maxDate }: { calendars: CalendarMonth[]; maxDate?: Date }): boolean {\n if (!maxDate) {\n return false;\n }\n const { lastDayOfMonth } = calendars[calendars.length - 1];\n const lastDayOfMonthPlusOne = addDays(lastDayOfMonth, 1);\n if (isBefore(maxDate, lastDayOfMonthPlusOne)) {\n return true;\n }\n return false;\n}\n\ntype GetCalendarProps = {\n /** The date to start the calendar at */\n date: Date;\n /** Date or dates currently selected. */\n selected?: Date | Date[];\n /** The earliest date available */\n minDate?: Date;\n /** The earliest date available */\n maxDate?: Date;\n /** The number of months to return in the calendar view */\n monthsToDisplay: number;\n /** The number of months to offset based off the param.date given */\n offset: number;\n /** First day of week, 0-6 (Sunday to Saturday) */\n firstDayOfWeek: number;\n /** Flag to fill front and back weeks with dates from adjacent months */\n showOutsideDays: boolean;\n};\n\n/**\n * Figures out the months data needed based off the number of monthsToDisplay\n * and other options provided.\n * @param {Object} param The param object\n * @param {Date} param.date The date to start the calendar at\n * @param {Array.<Date>} param.selected An array of dates currently selected\n * @param {Number} param.monthsToDisplay The number of months to return in the calendar view\n * @param {Number} param.offset The number of months to offset based off the param.date given\n * @param {Date} param.minDate The earliest date available\n * @param {Date} param.maxDate The furthest date available\n * @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)\n * @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months\n * @returns {Array.<Object>} An array of objects with month data\n */\nexport function getCalendars({\n date,\n selected,\n monthsToDisplay,\n offset,\n minDate,\n maxDate,\n firstDayOfWeek,\n showOutsideDays,\n}: GetCalendarProps): CalendarMonth[] {\n const months: CalendarMonth[] = [];\n const startDate = getStartDate(date, minDate, maxDate);\n for (let i = 0; i < monthsToDisplay; i++) {\n const calendarDates = getMonths({\n month: startDate.getMonth() + i + offset,\n year: startDate.getFullYear(),\n selectedDates: selected,\n minDate,\n maxDate,\n firstDayOfWeek,\n showOutsideDays,\n });\n months.push(calendarDates);\n }\n return months;\n}\n\n/**\n * Figures out the actual start date based on\n * the min and max dates available.\n * @param {Date} date The we want to start the calendar at\n * @param {Date} minDate The earliest date available to start at\n * @param {Date} maxDate The latest date available to start at\n * @returns {Date} The actual start date\n */\nfunction getStartDate(date: Date, minDate?: Date, maxDate?: Date): Date {\n let startDate = startOfDay(date);\n if (minDate) {\n const minDateNormalized = startOfDay(minDate);\n if (isBefore(startDate, minDateNormalized)) {\n startDate = minDateNormalized;\n }\n }\n if (maxDate) {\n const maxDateNormalized = startOfDay(maxDate);\n if (isBefore(maxDateNormalized, startDate)) {\n startDate = maxDateNormalized;\n }\n }\n return startDate;\n}\n\ntype GetMonthsProps = {\n /** The month to grab data for */\n month: number;\n /** The year to grab data for */\n year: number;\n /** Date or dates currently selected. */\n selectedDates?: Date | Date[];\n /** The earliest date available */\n minDate?: Date;\n /** The earliest date available */\n maxDate?: Date;\n /** First day of week, 0-6 (Sunday to Saturday) */\n firstDayOfWeek: number;\n /** Flag to fill front and back weeks with dates from adjacent months */\n showOutsideDays: boolean;\n};\n\nexport type CalendarMonth = {\n firstDayOfMonth: Date;\n lastDayOfMonth: Date;\n month: number;\n year: number;\n weeks: CalendarWeek[];\n};\n\nexport type CalendarWeek = CalendarDay[];\n\nexport type CalendarDay = DateInfo | string;\n\n/**\n * Figures what week/day data to return for the given month\n * and year. Adds flags to day data if found in the given selectedDates,\n * if is selectable inside the given min and max dates, or is today.\n * @param {Object} param The param object\n * @param {Number} param.month The month to grab data for\n * @param {Number} param.year The year to grab data for\n * @param {Array.<Date>} sparam.electedDates An array of dates currently selected\n * @param {Date} param.minDate The earliest date available\n * @param {Date} param.maxDate The furthest date available\n * @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)\n * @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months\n * @returns {Object} The data for the selected month/year\n */\nfunction getMonths({\n month,\n year,\n selectedDates,\n minDate,\n maxDate,\n firstDayOfWeek,\n showOutsideDays,\n}: GetMonthsProps): CalendarMonth {\n // Get the normalized month and year, along with days in the month.\n const daysMonthYear = getNumDaysMonthYear(month, year);\n const daysInMonth = daysMonthYear.daysInMonth;\n month = daysMonthYear.month;\n year = daysMonthYear.year;\n\n // Fill out the dates for the month.\n const dates = [];\n for (let day = 1; day <= daysInMonth; day++) {\n const date = new Date(year, month, day);\n const dateObj = {\n date,\n selected: isSelected(selectedDates, date),\n selectable: isSelectable(minDate, maxDate, date),\n today: isToday(date),\n prevMonth: false,\n nextMonth: false,\n };\n dates.push(dateObj);\n }\n\n const firstDayOfMonth = new Date(year, month, 1);\n const lastDayOfMonth = new Date(year, month, daysInMonth);\n\n const frontWeekBuffer = fillFrontWeek({\n firstDayOfMonth,\n minDate,\n maxDate,\n selectedDates,\n firstDayOfWeek,\n showOutsideDays,\n });\n\n const backWeekBuffer = fillBackWeek({\n lastDayOfMonth,\n minDate,\n maxDate,\n selectedDates,\n firstDayOfWeek,\n showOutsideDays,\n });\n\n dates.unshift(...frontWeekBuffer);\n dates.push(...backWeekBuffer);\n\n // Get the filled out weeks for the\n // given dates.\n const weeks = getWeeks(dates);\n // return the calendar data.\n return {\n firstDayOfMonth,\n lastDayOfMonth,\n month,\n year,\n weeks,\n };\n}\n\ntype FillFrontWeekProps = {\n firstDayOfMonth: Date;\n /** Date or dates currently selected. */\n selectedDates?: Date | Date[];\n /** The earliest date available */\n minDate?: Date;\n /** The earliest date available */\n maxDate?: Date;\n /** First day of week, 0-6 (Sunday to Saturday) */\n firstDayOfWeek: number;\n /** Flag to fill front and back weeks with dates from adjacent months */\n showOutsideDays: boolean;\n};\n\n/**\n * Fill front week with either empty buffer or dates from previous month,\n * depending on showOutsideDays flag\n * @param {Object} param The param object\n * @param {Array.<Date>} param.selectedDates An array of dates currently selected\n * @param {Date} param.minDate The earliest date available\n * @param {Date} param.maxDate The furthest date available\n * @param {Date} param.firstDayOfMonth First day of the month\n * @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)\n * @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months\n * @returns {Array.<Date>} Buffer to fill front week\n */\nfunction fillFrontWeek({\n firstDayOfMonth,\n minDate,\n maxDate,\n selectedDates,\n firstDayOfWeek,\n showOutsideDays,\n}: FillFrontWeekProps): CalendarWeek {\n const dates: CalendarWeek = [];\n let firstDay = (firstDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;\n\n if (showOutsideDays) {\n const lastDayOfPrevMonth = addDays(firstDayOfMonth, -1);\n const prevDate = lastDayOfPrevMonth.getDate();\n const prevDateMonth = lastDayOfPrevMonth.getMonth();\n const prevDateYear = lastDayOfPrevMonth.getFullYear();\n\n // Fill out front week for days from\n // preceding month with dates from previous month.\n let counter = 0;\n while (counter < firstDay) {\n const date = new Date(prevDateYear, prevDateMonth, prevDate - counter);\n const dateObj: DateInfo = {\n date,\n selected: isSelected(selectedDates, date),\n selectable: isSelectable(minDate, maxDate, date),\n today: false,\n prevMonth: true,\n nextMonth: false,\n };\n dates.unshift(dateObj);\n counter++;\n }\n } else {\n // Fill out front week for days from\n // preceding month with buffer.\n while (firstDay > 0) {\n dates.unshift(\"\");\n firstDay--;\n }\n }\n\n return dates;\n}\n\nexport type DateInfo = {\n date: Date;\n selected: boolean;\n selectable: boolean;\n today: boolean;\n prevMonth: boolean;\n nextMonth: boolean;\n};\n\ntype FillBackWeekProps = {\n lastDayOfMonth: Date;\n /** Date or dates currently selected. */\n selectedDates?: Date | Date[];\n /** The earliest date available */\n minDate?: Date;\n /** The earliest date available */\n maxDate?: Date;\n /** First day of week, 0-6 (Sunday to Saturday) */\n firstDayOfWeek: number;\n /** Flag to fill front and back weeks with dates from adjacent months */\n showOutsideDays: boolean;\n};\n\n/**\n * Fill back weeks with either empty buffer or dates from next month,\n * depending on showOutsideDays flag\n * @param {Object} param The param object\n * @param {Array.<Date>} param.selectedDates An array of dates currently selected\n * @param {Date} param.minDate The earliest date available\n * @param {Date} param.maxDate The furthest date available\n * @param {Date} param.lastDayOfMonth Last day of the month\n * @param {Number} param.firstDayOfWeek First day of week, 0-6 (Sunday to Saturday)\n * @param {Bool} param.showOutsideDays Flag to fill front and back weeks with dates from adjacent months\n * @returns {Array.<Date>} Buffer to fill back week\n */\nfunction fillBackWeek({\n lastDayOfMonth,\n minDate,\n maxDate,\n selectedDates,\n firstDayOfWeek,\n showOutsideDays,\n}: FillBackWeekProps): CalendarWeek {\n const dates: CalendarWeek = [];\n let lastDay = (lastDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;\n\n if (showOutsideDays) {\n const firstDayOfNextMonth = addDays(lastDayOfMonth, 1);\n const nextDateMonth = firstDayOfNextMonth.getMonth();\n const nextDateYear = firstDayOfNextMonth.getFullYear();\n\n // Fill out back week for days from\n // following month with dates from next month.\n let counter = 0;\n while (counter < 6 - lastDay) {\n const date = new Date(nextDateYear, nextDateMonth, 1 + counter);\n const dateObj: DateInfo = {\n date,\n selected: isSelected(selectedDates, date),\n selectable: isSelectable(minDate, maxDate, date),\n today: false,\n prevMonth: false,\n nextMonth: true,\n };\n dates.push(dateObj);\n counter++;\n }\n } else {\n // Fill out back week for days from\n // following month with buffer.\n while (lastDay < 6) {\n dates.push(\"\");\n lastDay++;\n }\n }\n\n return dates;\n}\n\n/**\n * Normalizes month (could be overflow) and year pairs and returns the\n * normalized month and year along with the number of days in the month.\n * @param {Number} month The month to normalize\n * @param {Number} year The year to normalize\n * @returns {Object} The normalized month and year along with the number of days in the month\n */\nfunction getNumDaysMonthYear(month: number, year: number): { daysInMonth: number; month: number; year: number } {\n // If a parameter you specify is outside of the expected range for Month or Day,\n // JS Date attempts to update the date information in the Date object accordingly!\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate\n\n // Let Date handle the overflow of the month,\n // which should return the normalized month and year.\n const normalizedMonthYear = new Date(year, month, 1);\n month = normalizedMonthYear.getMonth();\n year = normalizedMonthYear.getFullYear();\n // Overflow the date to the next month, then subtract the difference\n // to get the number of days in the previous month.\n // This will also account for leap years!\n const daysInMonth = 32 - new Date(year, month, 32).getDate();\n return { daysInMonth, month, year };\n}\n\n/**\n * Takes an array of dates, and turns them into a multi dimensional\n * array with 7 entries for each week.\n * @param {Array.<Object>} dates An array of dates\n * @returns {Array} The weeks as a multi dimensional array\n */\nfunction getWeeks(dates: CalendarWeek): Array<CalendarWeek> {\n const weeksLength = Math.ceil(dates.length / 7);\n const weeks: Array<CalendarWeek> = [];\n for (let i = 0; i < weeksLength; i++) {\n weeks[i] = [];\n for (let x = 0; x < 7; x++) {\n weeks[i].push(dates[i * 7 + x]);\n }\n }\n return weeks;\n}\n\n/**\n * Normalizes dates to the beginning of the day,\n * then checks to see if the day given is found\n * in the selectedDates.\n * @param {Array.<Date>} selectedDates An array of dates currently selected\n * @param {Date} date The date to search with against selectedDates\n * @returns {Boolean} Whether day is found in selectedDates\n */\nfunction isSelected(selectedDates: Date | Date[] | undefined, date: Date): boolean {\n if (!selectedDates) {\n return false;\n }\n selectedDates = Array.isArray(selectedDates) ? selectedDates : [selectedDates];\n return selectedDates.some((selectedDate) => {\n if (selectedDate instanceof Date && startOfDay(selectedDate).getTime() === startOfDay(date).getTime()) {\n return true;\n }\n return false;\n });\n}\n\n/**\n * Checks to see if the date given is\n * between the min and max dates.\n * @param {Date} minDate The earliest date available\n * @param {Date} maxDate The furthest date available\n * @param {Date} date The date to compare with\n * @returns {Boolean} Whether the date is between min and max date\n */\nfunction isSelectable(minDate: Date | undefined, maxDate: Date | undefined, date: Date): boolean {\n if ((minDate && isBefore(date, minDate)) || (maxDate && isBefore(maxDate, date))) {\n return false;\n }\n return true;\n}\n\n/**\n * Check if two Date objects represent the same day\n *\n * @param date1 first Date to compare\n * @param date2 second Date to compare\n */\nexport function isSameDay(date1: Date, date2: Date): boolean {\n return (\n date1.getDate() === date2.getDate() &&\n date1.getMonth() === date2.getMonth() &&\n date1.getFullYear() === date2.getFullYear()\n );\n}\n\n/**\n * Check if the date has changed from the previous date\n *\n * @param date First date to compare\n * @param newDate Second date to compare\n */\nexport function dateHasChanged(date: Date | undefined, newDate: Date): boolean {\n return !date || !isSameDay(date, newDate);\n}\n\n/**\n * Check if a given date is outside a given range\n *\n * @param date Input date\n * @param rangeStart Dates before this date should be disabled\n * @param rangeEnd Dates after this date should be disabled\n */\nexport function dateIsOutsideRange(date: Date, rangeStart: Date | undefined, rangeEnd: Date | undefined): boolean {\n return Boolean((rangeEnd && date > rangeEnd) || (rangeStart && date < rangeStart));\n}\n\n/**\n * Get the correct initial date for initiating the datepicker reducer store\n *\n * @param value Value from props\n * @param initialDate Initial date from porps\n * @param disableDate Function for checking whether the date should be disabled\n */\nexport function getInitialDate(\n value: string | undefined,\n defaultValue: string | undefined,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): Date | null {\n const valueAsDate = parseDateString(value);\n const defaultValueAsDate = parseDateString(defaultValue);\n if (valueAsDate) {\n return !dateIsOutsideRange(valueAsDate, minDate, maxDate) ? valueAsDate : null;\n }\n if (defaultValueAsDate) {\n return !dateIsOutsideRange(defaultValueAsDate, minDate, maxDate) ? defaultValueAsDate : null;\n }\n return null;\n}\n\n/**\n * Get the initial date to show in the calendar\n *\n * @param date The date set in the DatePicker (from props)\n * @param defaultSelected The defaultSelected prop from DatePicker\n * @param minDate The earliest selectable date, from props\n * @param maxDate The latest selectable date, from props\n * @returns The date to show in the calendar\n */\nexport function getInitialDateShown(\n date: Date | null,\n defaultSelected: Date | undefined,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): Date {\n let initialDate = date || defaultSelected || new Date();\n\n if (minDate) {\n initialDate = minDate > initialDate ? minDate : initialDate;\n }\n\n if (maxDate) {\n initialDate = maxDate < initialDate ? maxDate : initialDate;\n }\n\n return initialDate;\n}\n"],"names":["composeEventHandlers","fns","event","some","fn","defaultPrevented","subtractMonth","calendars","offset","minDate","firstDayOfMonth","diffInMonths","differenceInCalendarMonths","DEFAULT_YEARS_TO_SHOW","getYearSelectOptions","currentYear","maxDate","yearsToShow","getFullYear","toString","showAllYears","previousYearsToShow","comingYearsToShow","previous","coming","startYear","earliestStartYear","Math","max","endYear","latestEndYear","min","numYears","Array","keys","map","x","item","getMonthSelectOptions","monthNames","minDateYear","minDateMonth","getMonth","maxDateYear","maxDateMonth","startMonth","endMonth","month","index","value","label","filter","parseInt","addMonth","lastDayOfMonth","length","isBackDisabled","firstDayOfMonthMinusOne","addDays","isBefore","isForwardDisabled","lastDayOfMonthPlusOne","getCalendars","date","selected","monthsToDisplay","firstDayOfWeek","showOutsideDays","months","startDate","startOfDay","minDateNormalized","maxDateNormalized","getStartDate","i","calendarDates","getMonths","year","selectedDates","push","daysMonthYear","normalizedMonthYear","Date","daysInMonth","getDate","getNumDaysMonthYear","dates","day","dateObj","isSelected","selectable","isSelectable","today","isToday","prevMonth","nextMonth","frontWeekBuffer","firstDay","getDay","lastDayOfPrevMonth","prevDate","prevDateMonth","prevDateYear","counter","unshift","fillFrontWeek","backWeekBuffer","lastDay","firstDayOfNextMonth","nextDateMonth","nextDateYear","fillBackWeek","weeks","weeksLength","ceil","getWeeks","isArray","selectedDate","getTime","isSameDay","date1","date2","dateHasChanged","newDate","dateIsOutsideRange","rangeStart","rangeEnd","getInitialDate","defaultValue","valueAsDate","parseDateString","defaultValueAsDate","getInitialDateShown","defaultSelected","initialDate"],"mappings":"qOAkCO,SAASA,KAAwBC,GAC7B,OAACC,GACJD,EAAIE,MAAMC,IACNA,GAAMA,EAAGF,GACFA,EAAMG,mBAEzB,CAWO,SAASC,GACZC,UAAAA,EACAC,OAAAA,EACAC,QAAAA,IAMID,GAAAA,EAAS,GAAKC,EAAS,CACjB,MAAEC,gBAAAA,GAAoBH,EAAU,GAChCI,EAAeC,EAA2BF,EAAiBD,GAC7DE,EAAeH,IACNA,EAAAG,EAEjB,CACOH,OAAAA,CACX,CAEO,MAAMK,EAAwB,EAW9B,SAASC,EACZC,EACAN,EACAO,EACAC,GAEIR,GAAAA,GAAWA,EAAQS,cAAgBH,EACn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AqBD,EAAgBF,GAC3C,OAAIC,EACQL,EAAmBK,EAAaxH,EAASO,GAAyB,KAAdiH,EAE5DE,EACQP,EAAmBO,EAAoB1H,EAASO,GAAgC,KAArBmH,EAEhE,IACX,CAWO,SAASC,EACZrE,EACAsE,EACA5H,EACAO,GAEA,IAAIsH,EAAcvE,GAAQsE,GAAmB,IAAInD,KAE7CzE,OAAAA,IACc6H,EAAA7H,EAAU6H,EAAc7H,EAAU6H,GAGhDtH,IACcsH,EAAAtH,EAAUsH,EAActH,EAAUsH,GAG7CA,CACX"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ const e=/^(\d\d?)[\W](\d\d?)[\W](\d{4}|\d{2})$/,t=/^(\d{4}|\d{2})[\W](\d\d?)[\W](\d\d?)$/;function r(e){return`${`${e.getDate()}`.padStart(2,"0")}.${`${e.getMonth()+1}`.padStart(2,"0")}.${e.getFullYear()}`}function n(r){if(!r)return;const n=(r=>{const n=e.exec(r);if(n)return n.slice(1,4);const a=t.exec(r);if(!a)return;const s=a.slice(1,4);return s.reverse(),s})(r);if(!n)return;const a=parseInt((new Date).toLocaleString("no-NB",{year:"2-digit"})),s=parseInt(n[0],10),d=parseInt(n[1],10)-1,i=parseInt(n[2],10),o=i>99?i:(u=i)>a?u+1900:u+2e3,c=new Date(o,d,s,0,0,0);var u;return c.getMonth()===d&&c.getFullYear()===o?c:void 0}function a(e){if(!e.relatedTarget)return!0;const t=e.target.closest(".jkl-datepicker__input-wrapper");return e.relatedTarget.closest(".jkl-datepicker__input-wrapper")!==t}export{e as dayMonthYearRegex,r as formatInput,a as isBlurTargetOutside,n as parseDateString};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/components/datepicker/utils.ts"],"sourcesContent":["import React from \"react\";\n\nexport const dayMonthYearRegex = /^(\\d\\d?)[\\W](\\d\\d?)[\\W](\\d{4}|\\d{2})$/;\nconst yearMonthDayRegex = /^(\\d{4}|\\d{2})[\\W](\\d\\d?)[\\W](\\d\\d?)$/;\n\n/**\n * Format a Date object as a string in the format DatePicker expects.\n *\n * @param date the Date object to format\n * @return returns a date string with \"dd.mm.yyyy\"-format\n */\nexport function formatInput(date: Date): string {\n const day = `${date.getDate()}`.padStart(2, \"0\");\n const month = `${date.getMonth() + 1}`.padStart(2, \"0\");\n return `${day}.${month}.${date.getFullYear()}`;\n}\n\n/**\n * Get the date segments from a string of unknown format\n *\n * @param input date as a string with unknown format\n * @returns an array of string elements [day, month, year]\n */\nconst getDateSegmentsFromString = (input: string): string[] | undefined => {\n const dayMonthYear = dayMonthYearRegex.exec(input);\n\n if (dayMonthYear) {\n return dayMonthYear.slice(1, 4);\n }\n\n const yearMonthDay = yearMonthDayRegex.exec(input);\n\n if (!yearMonthDay) {\n return undefined;\n }\n\n // reverse to get the correct ordering\n const slicedDateSegments = yearMonthDay.slice(1, 4);\n slicedDateSegments.reverse();\n\n return slicedDateSegments;\n};\n\n/**\n * Convert a date string to a Date object\n *\n * @param dateString date as string with format dd.mm.yyyy\n * @return a Date object representing the given date\n */\nexport function parseDateString(dateString?: string): Date | undefined {\n if (!dateString) {\n return undefined;\n }\n\n const inputDateSegments = getDateSegmentsFromString(dateString);\n\n if (!inputDateSegments) {\n return undefined;\n }\n\n const currentTwoDigitYear = parseInt(new Date().toLocaleString(\"no-NB\", { year: \"2-digit\" }));\n const parseTwoDigitYear = (year: number) => (year > currentTwoDigitYear ? year + 1900 : year + 2000);\n\n const day = parseInt(inputDateSegments[0], 10);\n const month = parseInt(inputDateSegments[1], 10) - 1;\n const yearIn = parseInt(inputDateSegments[2], 10);\n const year = yearIn > 99 ? yearIn : parseTwoDigitYear(yearIn);\n\n const generatedDate = new Date(year, month, day, 0, 0, 0);\n // Days can \"overflow\" to next month/year in Date(). Return undefined if it does:\n return generatedDate.getMonth() === month && generatedDate.getFullYear() === year ? generatedDate : undefined;\n}\n\n/**\n * Hjelpefunksjon for å se om en onBlur går utenfor DatePicker,\n * eller om den går til et interaktivt element inni DatePickeren.\n * @param {React.FocusEvent<HTMLButtonElement | HTMLInputElement>} e - Eventet fra onBlur og action.onBlur\n * @returns {boolean} true hvis e.relatedTarget er utenfor DatePicker\n */\nexport function isBlurTargetOutside(e: React.FocusEvent<HTMLButtonElement | HTMLInputElement>): boolean {\n if (!e.relatedTarget) {\n return true;\n }\n\n const targetRoot = e.target.closest(\".jkl-datepicker__input-wrapper\");\n const relatedTargetRoot = e.relatedTarget.closest(\".jkl-datepicker__input-wrapper\");\n\n return relatedTargetRoot !== targetRoot;\n}\n"],"names":["dayMonthYearRegex","yearMonthDayRegex","formatInput","date","getDate","padStart","getMonth","getFullYear","parseDateString","dateString","inputDateSegments","input","dayMonthYear","exec","slice","yearMonthDay","slicedDateSegments","reverse","getDateSegmentsFromString","currentTwoDigitYear","parseInt","Date","toLocaleString","year","day","month","yearIn","generatedDate","isBlurTargetOutside","e","relatedTarget","targetRoot","target","closest"],"mappings":"AAEO,MAAMA,EAAoB,wCAC3BC,EAAoB,wCAQnB,SAASC,EAAYC,GAGxB,MAAO,GAFK,GAAGA,EAAKC,YAAYC,SAAS,EAAG,QAC9B,GAAGF,EAAKG,WAAa,IAAID,SAAS,EAAG,QACzBF,EAAKI,eACnC,CAkCO,SAASC,EAAgBC,GAC5B,IAAKA,EACM,OAGLC,MAAAA,EA/BwB,CAACC,IACzBC,MAAAA,EAAeZ,EAAkBa,KAAKF,GAExCC,GAAAA,EACOA,OAAAA,EAAaE,MAAM,EAAG,GAG3BC,MAAAA,EAAed,EAAkBY,KAAKF,GAE5C,IAAKI,EACM,OAIX,MAAMC,EAAqBD,EAAaD,MAAM,EAAG,GACjDE,OAAAA,EAAmBC,UAEZD,CAAAA,EAcmBE,CAA0BT,GAEpD,IAAKC,EACM,OAGLS,MAAAA,EAAsBC,UAAS,IAAIC,MAAOC,eAAe,QAAS,CAAEC,KAAM,aAG1EC,EAAMJ,SAASV,EAAkB,GAAI,IACrCe,EAAQL,SAASV,EAAkB,GAAI,IAAM,EAC7CgB,EAASN,SAASV,EAAkB,GAAI,IACxCa,EAAOG,EAAS,GAAKA,GALAH,EAK2BG,GALFP,EAAsBI,EAAO,KAAOA,EAAO,IAOzFI,EAAgB,IAAIN,KAAKE,EAAME,EAAOD,EAAK,EAAG,EAAG,GAP7B,IAACD,EASpBI,OAAAA,EAAcrB,aAAemB,GAASE,EAAcpB,gBAAkBgB,EAAOI,OAAgB,CACxG,CAQO,SAASC,EAAoBC,GAC5B,IAACA,EAAEC,cACI,OAAA,EAGX,MAAMC,EAAaF,EAAEG,OAAOC,QAAQ,kCAGpC,OAF0BJ,EAAEC,cAAcG,QAAQ,oCAErBF,CACjC"}
@@ -0,0 +1,2 @@
1
+ import{parseDateString as i}from"./utils.js";function n(n){return!!n&&!!i(n)}function t(n,t,r={inclusive:!1}){const s="string"==typeof n?i(n):n;return!!s&&(r.inclusive?s>=t:s>t)}function r(n,t,r={inclusive:!1}){const s="string"==typeof n?i(n):n;return!!s&&(r.inclusive?s<=t:s<t)}export{n as isCorrectFormat,t as isWithinLowerBound,r as isWithinUpperBound};
2
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sources":["../../../../src/components/datepicker/validation.ts"],"sourcesContent":["import { parseDateString } from \"./utils\";\n\nexport function isCorrectFormat(value: string | undefined): boolean {\n if (!value) {\n return false;\n }\n const val = parseDateString(value);\n return Boolean(val);\n}\n\ntype ComparisonOptions = {\n /**\n * Kontroller om testen skal godkjennes om verdien er lik\n * @default false\n */\n inclusive: boolean;\n};\n\nexport function isWithinLowerBound(\n value: Date | string | undefined,\n minDate: Date,\n options: ComparisonOptions = { inclusive: false },\n): boolean {\n const val = typeof value === \"string\" ? parseDateString(value) : value;\n\n if (!val) {\n return false;\n }\n\n if (options.inclusive) {\n return val >= minDate;\n }\n\n return val > minDate;\n}\n\nexport function isWithinUpperBound(\n value: Date | string | undefined,\n maxDate: Date,\n options: ComparisonOptions = { inclusive: false },\n): boolean {\n const val = typeof value === \"string\" ? parseDateString(value) : value;\n\n if (!val) {\n return false;\n }\n\n if (options.inclusive) {\n return val <= maxDate;\n }\n\n return val < maxDate;\n}\n"],"names":["isCorrectFormat","value","parseDateString","isWithinLowerBound","minDate","options","inclusive","val","isWithinUpperBound","maxDate"],"mappings":"6CAEO,SAASA,EAAgBC,GAC5B,QAAKA,KAGOC,EAAgBD,EAEhC,CAUO,SAASE,EACZF,EACAG,EACAC,EAA6B,CAAEC,WAAW,IAE1C,MAAMC,EAAuB,iBAAVN,EAAqBC,EAAgBD,GAASA,EAEjE,QAAKM,IAIDF,EAAQC,UACDC,GAAOH,EAGXG,EAAMH,EACjB,CAEO,SAASI,EACZP,EACAQ,EACAJ,EAA6B,CAAEC,WAAW,IAE1C,MAAMC,EAAuB,iBAAVN,EAAqBC,EAAgBD,GAASA,EAEjE,QAAKM,IAIDF,EAAQC,UACDC,GAAOE,EAGXF,EAAME,EACjB"}
@@ -1,2 +1,2 @@
1
- import{AccordionItem as o}from"./accordion/AccordionItem.js";import{Accordion as s}from"./accordion/Accordion.js";import{Breadcrumb as a}from"./breadcrumb/Breadcrumb.js";import{BreadcrumbItem as n}from"./breadcrumb/BreadcrumbItem.js";import{Button as r,PrimaryButton as t,SecondaryButton as e,TertiaryButton as i}from"./button/Button.js";import{Card as c}from"./card/Card.js";import{CardImage as m}from"./card/CardImage.js";import{InfoBlock as p,NavCard as l}from"./card/NavCard.js";import{TaskCard as I}from"./card/TaskCard.js";import{InfoCard as d}from"./card/InfoCard.js";import{Checkbox as u}from"./checkbox/Checkbox.js";import{Combobox as f,getComboboxValuePair as C}from"./combobox/Combobox.js";import{CookieConsent as k}from"./cookie-consent/CookieConsent.js";import{CookieConsentProvider as j,useCookieConsent as b}from"./cookie-consent/CookieConsentContext.js";import{Icon as T}from"./icon/Icon.js";import{ArrowVerticalAnimated as h}from"./icon/icons/animated/ArrowVerticalAnimated.js";import{ArrowHorizontalAnimated as S}from"./icon/icons/animated/ArrowHorizontalAnimated.js";import{PlusRemoveAnimated as g}from"./icon/icons/animated/PlusRemoveAnimated.js";import{ArrowDownIcon as A}from"./icon/icons/ArrowDownIcon.js";import{ArrowLeftIcon as L}from"./icon/icons/ArrowLeftIcon.js";import{ArrowNorthEastIcon as B}from"./icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as w}from"./icon/icons/ArrowRightIcon.js";import{ArrowUpIcon as R}from"./icon/icons/ArrowUpIcon.js";import{CalendarIcon as v}from"./icon/icons/CalendarIcon.js";import{CheckIcon as M}from"./icon/icons/CheckIcon.js";import{ChevronDownIcon as x}from"./icon/icons/ChevronDownIcon.js";import{ChevronLeftIcon as G}from"./icon/icons/ChevronLeftIcon.js";import{ChevronRightIcon as P}from"./icon/icons/ChevronRightIcon.js";import{ChevronUpIcon as y}from"./icon/icons/ChevronUpIcon.js";import{CloseIcon as D}from"./icon/icons/CloseIcon.js";import{CopyIcon as N}from"./icon/icons/CopyIcon.js";import{DotsIcon as E}from"./icon/icons/DotsIcon.js";import{DragIcon as U}from"./icon/icons/DragIcon.js";import{ErrorIcon as H}from"./icon/icons/ErrorIcon.js";import{GreenCheckIcon as O}from"./icon/icons/GreenCheckIcon.js";import{HamburgerIcon as V}from"./icon/icons/HamburgerIcon.js";import{InfoIcon as W}from"./icon/icons/InfoIcon.js";import{LinkIcon as z}from"./icon/icons/LinkIcon.js";import{PlusIcon as F}from"./icon/icons/PlusIcon.js";import{QuestionIcon as Q}from"./icon/icons/QuestionIcon.js";import{RedCrossIcon as q}from"./icon/icons/RedCrossIcon.js";import{SearchIcon as J}from"./icon/icons/SearchIcon.js";import{SuccessIcon as K}from"./icon/icons/SuccessIcon.js";import{WarningIcon as X}from"./icon/icons/WarningIcon.js";import{MinusIcon as Y}from"./icon/icons/MinusIcon.js";import{ThumbDownIcon as Z}from"./icon/icons/ThumbDownIcon.js";import{ThumbUpIcon as $}from"./icon/icons/ThumbUpIcon.js";import{TrashCanIcon as _}from"./icon/icons/TrashCanIcon.js";import{PenIcon as oo}from"./icon/icons/PenIcon.js";import{IconButton as so}from"./icon-button/IconButton.js";import{FieldGroup as ao}from"./input-group/FieldGroup.js";import{InputGroup as no}from"./input-group/InputGroup.js";import{Label as ro}from"./input-group/Label.js";import{SupportLabel as to}from"./input-group/SupportLabel.js";import{Link as eo}from"./link/Link.js";import{NavLink as io}from"./link/NavLink.js";import{LinkList as co}from"./link-list/LinkList.js";import{List as mo,OrderedList as po,UnorderedList as lo}from"./list/List.js";import{CheckListItem as Io,CrossListItem as uo,ListItem as fo}from"./list/ListItem.js";import{Loader as Co}from"./loader/Loader.js";import{SkeletonAnimation as ko}from"./loader/skeletons/SkeletonAnimation.js";import{SkeletonButton as jo}from"./loader/skeletons/SkeletonButton.js";import{SkeletonCheckboxGroup as bo}from"./loader/skeletons/SkeletonCheckboxGroup.js";import{SkeletonElement as To}from"./loader/skeletons/SkeletonElement.js";import{SkeletonInput as ho}from"./loader/skeletons/SkeletonInput.js";import{SkeletonRadioButtonGroup as So}from"./loader/skeletons/SkeletonRadioButtonGroup.js";import{SkeletonTable as go,SkeletonTableHeader as Ao,SkeletonTableRow as Lo}from"./loader/skeletons/SkeletonTable.js";import{SkeletonTextArea as Bo}from"./loader/skeletons/SkeletonTextArea.js";import{Modal as wo,ModalActions as Ro,ModalBody as vo,ModalCloseButton as Mo,ModalContainer as xo,ModalHeader as Go,ModalOverlay as Po,ModalTitle as yo}from"./modal/Modal.js";import{useModal as Do}from"./modal/useModal.js";import{RadioButton as No}from"./radio-button/RadioButton.js";import{RadioButtonGroup as Eo}from"./radio-button/RadioButtonGroup.js";import{BaseRadioButton as Uo}from"./radio-button/BaseRadioButton.js";import{N as Ho,S as Oo}from"../../NativeSelect-DOSP8-ZQ.js";import{ErrorTag as Vo,InfoTag as Wo,SuccessTag as zo,Tag as Fo,WarningTag as Qo}from"./tag/Tag.js";import{Tooltip as qo}from"./tooltip/Tooltip.js";import{TooltipContent as Jo}from"./tooltip/TooltipContent.js";import{TooltipTrigger as Ko}from"./tooltip/TooltipTrigger.js";import{PopupTip as Xo}from"./tooltip/PopupTip.js";import{ScreenReaderOnly as Yo}from"./ScreenReaderOnly.js";export{s as Accordion,o as AccordionItem,A as ArrowDownIcon,S as ArrowHorizontalAnimated,L as ArrowLeftIcon,B as ArrowNorthEastIcon,w as ArrowRightIcon,R as ArrowUpIcon,h as ArrowVerticalAnimated,Uo as BaseRadioButton,a as Breadcrumb,n as BreadcrumbItem,r as Button,v as CalendarIcon,c as Card,m as CardImage,M as CheckIcon,Io as CheckListItem,u as Checkbox,x as ChevronDownIcon,G as ChevronLeftIcon,P as ChevronRightIcon,y as ChevronUpIcon,D as CloseIcon,f as Combobox,k as CookieConsent,j as CookieConsentProvider,N as CopyIcon,uo as CrossListItem,E as DotsIcon,U as DragIcon,H as ErrorIcon,Vo as ErrorTag,ao as FieldGroup,O as GreenCheckIcon,V as HamburgerIcon,T as Icon,so as IconButton,p as InfoBlock,d as InfoCard,W as InfoIcon,Wo as InfoTag,no as InputGroup,ro as Label,eo as Link,z as LinkIcon,co as LinkList,mo as List,fo as ListItem,Co as Loader,Y as MinusIcon,wo as Modal,Ro as ModalActions,vo as ModalBody,Mo as ModalCloseButton,xo as ModalContainer,Go as ModalHeader,Po as ModalOverlay,yo as ModalTitle,Ho as NativeSelect,l as NavCard,io as NavLink,po as OrderedList,oo as PenIcon,F as PlusIcon,g as PlusRemoveAnimated,Xo as PopupTip,t as PrimaryButton,Q as QuestionIcon,No as RadioButton,Eo as RadioButtonGroup,q as RedCrossIcon,Yo as ScreenReaderOnly,J as SearchIcon,e as SecondaryButton,Oo as Select,ko as SkeletonAnimation,jo as SkeletonButton,bo as SkeletonCheckboxGroup,To as SkeletonElement,ho as SkeletonInput,So as SkeletonRadioButtonGroup,go as SkeletonTable,Ao as SkeletonTableHeader,Lo as SkeletonTableRow,Bo as SkeletonTextArea,K as SuccessIcon,zo as SuccessTag,to as SupportLabel,Fo as Tag,I as TaskCard,i as TertiaryButton,Z as ThumbDownIcon,$ as ThumbUpIcon,qo as Tooltip,Jo as TooltipContent,Ko as TooltipTrigger,_ as TrashCanIcon,lo as UnorderedList,X as WarningIcon,Qo as WarningTag,C as getComboboxValuePair,b as useCookieConsent,Do as useModal};
1
+ import{AccordionItem as o}from"./accordion/AccordionItem.js";import{Accordion as s}from"./accordion/Accordion.js";import{Breadcrumb as a}from"./breadcrumb/Breadcrumb.js";import{BreadcrumbItem as r}from"./breadcrumb/BreadcrumbItem.js";import{Button as n,PrimaryButton as t,SecondaryButton as e,TertiaryButton as i}from"./button/Button.js";import{Card as c}from"./card/Card.js";import{CardImage as m}from"./card/CardImage.js";import{InfoBlock as p,NavCard as l}from"./card/NavCard.js";import{TaskCard as d}from"./card/TaskCard.js";import{InfoCard as I}from"./card/InfoCard.js";import{Checkbox as u}from"./checkbox/Checkbox.js";import{Combobox as f,getComboboxValuePair as C}from"./combobox/Combobox.js";import{CookieConsent as j}from"./cookie-consent/CookieConsent.js";import{CookieConsentProvider as k,useCookieConsent as T}from"./cookie-consent/CookieConsentContext.js";import{isCorrectFormat as b,isWithinLowerBound as h,isWithinUpperBound as B}from"./datepicker/validation.js";import{dayMonthYearRegex as g,formatInput as A,isBlurTargetOutside as S,parseDateString as L}from"./datepicker/utils.js";import{DatePicker as x}from"./datepicker/DatePicker.js";import{Icon as w}from"./icon/Icon.js";import{ArrowVerticalAnimated as R}from"./icon/icons/animated/ArrowVerticalAnimated.js";import{ArrowHorizontalAnimated as v}from"./icon/icons/animated/ArrowHorizontalAnimated.js";import{PlusRemoveAnimated as M}from"./icon/icons/animated/PlusRemoveAnimated.js";import{ArrowDownIcon as P}from"./icon/icons/ArrowDownIcon.js";import{ArrowLeftIcon as D}from"./icon/icons/ArrowLeftIcon.js";import{ArrowNorthEastIcon as y}from"./icon/icons/ArrowNorthEastIcon.js";import{ArrowRightIcon as G}from"./icon/icons/ArrowRightIcon.js";import{ArrowUpIcon as U}from"./icon/icons/ArrowUpIcon.js";import{CalendarIcon as N}from"./icon/icons/CalendarIcon.js";import{CheckIcon as E}from"./icon/icons/CheckIcon.js";import{ChevronDownIcon as H}from"./icon/icons/ChevronDownIcon.js";import{ChevronLeftIcon as O}from"./icon/icons/ChevronLeftIcon.js";import{ChevronRightIcon as W}from"./icon/icons/ChevronRightIcon.js";import{ChevronUpIcon as F}from"./icon/icons/ChevronUpIcon.js";import{CloseIcon as V}from"./icon/icons/CloseIcon.js";import{CopyIcon as z}from"./icon/icons/CopyIcon.js";import{DotsIcon as Q}from"./icon/icons/DotsIcon.js";import{DragIcon as Y}from"./icon/icons/DragIcon.js";import{ErrorIcon as q}from"./icon/icons/ErrorIcon.js";import{GreenCheckIcon as J}from"./icon/icons/GreenCheckIcon.js";import{HamburgerIcon as K}from"./icon/icons/HamburgerIcon.js";import{InfoIcon as X}from"./icon/icons/InfoIcon.js";import{LinkIcon as Z}from"./icon/icons/LinkIcon.js";import{PlusIcon as $}from"./icon/icons/PlusIcon.js";import{QuestionIcon as _}from"./icon/icons/QuestionIcon.js";import{RedCrossIcon as oo}from"./icon/icons/RedCrossIcon.js";import{SearchIcon as so}from"./icon/icons/SearchIcon.js";import{SuccessIcon as ao}from"./icon/icons/SuccessIcon.js";import{WarningIcon as ro}from"./icon/icons/WarningIcon.js";import{MinusIcon as no}from"./icon/icons/MinusIcon.js";import{ThumbDownIcon as to}from"./icon/icons/ThumbDownIcon.js";import{ThumbUpIcon as eo}from"./icon/icons/ThumbUpIcon.js";import{TrashCanIcon as io}from"./icon/icons/TrashCanIcon.js";import{PenIcon as co}from"./icon/icons/PenIcon.js";import{IconButton as mo}from"./icon-button/IconButton.js";import{FieldGroup as po}from"./input-group/FieldGroup.js";import{InputGroup as lo}from"./input-group/InputGroup.js";import{Label as Io}from"./input-group/Label.js";import{SupportLabel as uo}from"./input-group/SupportLabel.js";import{Link as fo}from"./link/Link.js";import{NavLink as Co}from"./link/NavLink.js";import{LinkList as jo}from"./link-list/LinkList.js";import{List as ko,OrderedList as To,UnorderedList as bo}from"./list/List.js";import{CheckListItem as ho,CrossListItem as Bo,ListItem as go}from"./list/ListItem.js";import{Loader as Ao}from"./loader/Loader.js";import{SkeletonAnimation as So}from"./loader/skeletons/SkeletonAnimation.js";import{SkeletonButton as Lo}from"./loader/skeletons/SkeletonButton.js";import{SkeletonCheckboxGroup as xo}from"./loader/skeletons/SkeletonCheckboxGroup.js";import{SkeletonElement as wo}from"./loader/skeletons/SkeletonElement.js";import{SkeletonInput as Ro}from"./loader/skeletons/SkeletonInput.js";import{SkeletonRadioButtonGroup as vo}from"./loader/skeletons/SkeletonRadioButtonGroup.js";import{SkeletonTable as Mo,SkeletonTableHeader as Po,SkeletonTableRow as Do}from"./loader/skeletons/SkeletonTable.js";import{SkeletonTextArea as yo}from"./loader/skeletons/SkeletonTextArea.js";import{Modal as Go,ModalActions as Uo,ModalBody as No,ModalCloseButton as Eo,ModalContainer as Ho,ModalHeader as Oo,ModalOverlay as Wo,ModalTitle as Fo}from"./modal/Modal.js";import{useModal as Vo}from"./modal/useModal.js";import{RadioButton as zo}from"./radio-button/RadioButton.js";import{RadioButtonGroup as Qo}from"./radio-button/RadioButtonGroup.js";import{BaseRadioButton as Yo}from"./radio-button/BaseRadioButton.js";import{N as qo,S as Jo}from"../../NativeSelect-EidDABsT.js";import{ErrorTag as Ko,InfoTag as Xo,SuccessTag as Zo,Tag as $o,WarningTag as _o}from"./tag/Tag.js";import{BaseTextArea as os}from"./text-input/BaseTextArea.js";import{BaseTextInput as ss}from"./text-input/BaseTextInput.js";import{TextArea as as}from"./text-input/TextArea.js";import{TextInput as rs}from"./text-input/TextInput.js";import{Tooltip as ns}from"./tooltip/Tooltip.js";import{TooltipContent as ts}from"./tooltip/TooltipContent.js";import{TooltipTrigger as es}from"./tooltip/TooltipTrigger.js";import{PopupTip as is}from"./tooltip/PopupTip.js";import{ScreenReaderOnly as cs}from"./ScreenReaderOnly.js";export{s as Accordion,o as AccordionItem,P as ArrowDownIcon,v as ArrowHorizontalAnimated,D as ArrowLeftIcon,y as ArrowNorthEastIcon,G as ArrowRightIcon,U as ArrowUpIcon,R as ArrowVerticalAnimated,Yo as BaseRadioButton,os as BaseTextArea,ss as BaseTextInput,a as Breadcrumb,r as BreadcrumbItem,n as Button,N as CalendarIcon,c as Card,m as CardImage,E as CheckIcon,ho as CheckListItem,u as Checkbox,H as ChevronDownIcon,O as ChevronLeftIcon,W as ChevronRightIcon,F as ChevronUpIcon,V as CloseIcon,f as Combobox,j as CookieConsent,k as CookieConsentProvider,z as CopyIcon,Bo as CrossListItem,x as DatePicker,Q as DotsIcon,Y as DragIcon,q as ErrorIcon,Ko as ErrorTag,po as FieldGroup,J as GreenCheckIcon,K as HamburgerIcon,w as Icon,mo as IconButton,p as InfoBlock,I as InfoCard,X as InfoIcon,Xo as InfoTag,lo as InputGroup,Io as Label,fo as Link,Z as LinkIcon,jo as LinkList,ko as List,go as ListItem,Ao as Loader,no as MinusIcon,Go as Modal,Uo as ModalActions,No as ModalBody,Eo as ModalCloseButton,Ho as ModalContainer,Oo as ModalHeader,Wo as ModalOverlay,Fo as ModalTitle,qo as NativeSelect,l as NavCard,Co as NavLink,To as OrderedList,co as PenIcon,$ as PlusIcon,M as PlusRemoveAnimated,is as PopupTip,t as PrimaryButton,_ as QuestionIcon,zo as RadioButton,Qo as RadioButtonGroup,oo as RedCrossIcon,cs as ScreenReaderOnly,so as SearchIcon,e as SecondaryButton,Jo as Select,So as SkeletonAnimation,Lo as SkeletonButton,xo as SkeletonCheckboxGroup,wo as SkeletonElement,Ro as SkeletonInput,vo as SkeletonRadioButtonGroup,Mo as SkeletonTable,Po as SkeletonTableHeader,Do as SkeletonTableRow,yo as SkeletonTextArea,ao as SuccessIcon,Zo as SuccessTag,uo as SupportLabel,$o as Tag,d as TaskCard,i as TertiaryButton,as as TextArea,rs as TextInput,to as ThumbDownIcon,eo as ThumbUpIcon,ns as Tooltip,ts as TooltipContent,es as TooltipTrigger,io as TrashCanIcon,bo as UnorderedList,ro as WarningIcon,_o as WarningTag,g as dayMonthYearRegex,A as formatInput,C as getComboboxValuePair,S as isBlurTargetOutside,b as isCorrectFormat,h as isWithinLowerBound,B as isWithinUpperBound,L as parseDateString,T as useCookieConsent,Vo as useModal};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"react/jsx-runtime";import"../../../clsx-BeLtu-UY.js";import"react";import"../../hooks/useScreen/useScreen.js";import"../../hooks/useId/useId.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import"../button/Button.js";import"../card/Card.js";import"../card/CardImage.js";import"../card/NavCard.js";import"../checkbox/Checkbox.js";import"../combobox/Combobox.js";import"../cookie-consent/CookieConsentContext.js";import"react-dom";import"../modal/Modal.js";import"react-a11y-dialog";import"../list/List.js";import"../list/ListItem.js";import"../icon-button/IconButton.js";import"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import"../input-group/InputGroup.js";import"../link/Link.js";import"../link/NavLink.js";import"../link-list/LinkList.js";import"../radio-button/RadioButton.js";import"../radio-button/radioGroupContext.js";import"../radio-button/BaseRadioButton.js";import{N as o}from"../../../NativeSelect-DOSP8-ZQ.js";import"../tag/Tag.js";import"../../utilities/polymorphism/SlotComponent.js";import"../../utilities/valuePair.js";export{o as NativeSelect};
1
+ import"react/jsx-runtime";import"../../../clsx-BeLtu-UY.js";import"react";import"../../hooks/useScreen/useScreen.js";import"../../hooks/useId/useId.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import"../button/Button.js";import"../card/Card.js";import"../card/CardImage.js";import"../card/NavCard.js";import"../checkbox/Checkbox.js";import"../combobox/Combobox.js";import"../cookie-consent/CookieConsentContext.js";import"react-dom";import"../modal/Modal.js";import"react-a11y-dialog";import"../list/List.js";import"../list/ListItem.js";import"../datepicker/DatePicker.js";import"../icon-button/IconButton.js";import"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import"../input-group/InputGroup.js";import"../link/Link.js";import"../link/NavLink.js";import"../link-list/LinkList.js";import"../radio-button/RadioButton.js";import"../radio-button/radioGroupContext.js";import"../radio-button/BaseRadioButton.js";import{N as o}from"../../../NativeSelect-EidDABsT.js";import"../tag/Tag.js";import"../text-input/BaseTextArea.js";import"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import"../../utilities/polymorphism/SlotComponent.js";import"../../utilities/valuePair.js";export{o as NativeSelect};
2
2
  //# sourceMappingURL=NativeSelect.js.map
@@ -1,2 +1,2 @@
1
- import"react/jsx-runtime";import"../../../clsx-BeLtu-UY.js";import"react";import"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../hooks/usePreviousValue/usePreviousValue.js";import"../../hooks/useScreen/useScreen.js";import"../../hooks/useId/useId.js";import"../../hooks/useListNavigation/useListNavigation.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import"../button/Button.js";import"../card/Card.js";import"../card/CardImage.js";import"../card/NavCard.js";import"../checkbox/Checkbox.js";import"../combobox/Combobox.js";import"../cookie-consent/CookieConsentContext.js";import"react-dom";import"../modal/Modal.js";import"react-a11y-dialog";import"../list/List.js";import"../list/ListItem.js";import"../icon-button/IconButton.js";import"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import"../input-group/InputGroup.js";import"../link/Link.js";import"../link/NavLink.js";import"../link-list/LinkList.js";import"../radio-button/RadioButton.js";import"../radio-button/radioGroupContext.js";import"../radio-button/BaseRadioButton.js";import{S as o}from"../../../NativeSelect-DOSP8-ZQ.js";import"../tag/Tag.js";import"../../utilities/polymorphism/SlotComponent.js";import"../../utilities/valuePair.js";import"./select-utils.js";export{o as Select};
1
+ import"react/jsx-runtime";import"../../../clsx-BeLtu-UY.js";import"react";import"../../hooks/useAnimatedHeight/useAnimatedHeight.js";import"../../hooks/usePreviousValue/usePreviousValue.js";import"../../hooks/useScreen/useScreen.js";import"../../hooks/useId/useId.js";import"../../hooks/useListNavigation/useListNavigation.js";import"../icon/Icon.js";import"../icon/icons/animated/ArrowVerticalAnimated.js";import"../icon/icons/animated/ArrowHorizontalAnimated.js";import"../icon/icons/animated/PlusRemoveAnimated.js";import"../icon/icons/ArrowDownIcon.js";import"../icon/icons/ArrowLeftIcon.js";import"../icon/icons/ArrowNorthEastIcon.js";import"../icon/icons/ArrowRightIcon.js";import"../icon/icons/ArrowUpIcon.js";import"../icon/icons/CalendarIcon.js";import"../icon/icons/CheckIcon.js";import"../icon/icons/ChevronDownIcon.js";import"../icon/icons/ChevronLeftIcon.js";import"../icon/icons/ChevronRightIcon.js";import"../icon/icons/ChevronUpIcon.js";import"../icon/icons/CloseIcon.js";import"../icon/icons/CopyIcon.js";import"../icon/icons/DotsIcon.js";import"../icon/icons/DragIcon.js";import"../icon/icons/ErrorIcon.js";import"../icon/icons/GreenCheckIcon.js";import"../icon/icons/HamburgerIcon.js";import"../icon/icons/InfoIcon.js";import"../icon/icons/LinkIcon.js";import"../icon/icons/PlusIcon.js";import"../icon/icons/QuestionIcon.js";import"../icon/icons/RedCrossIcon.js";import"../icon/icons/SearchIcon.js";import"../icon/icons/SuccessIcon.js";import"../icon/icons/WarningIcon.js";import"../icon/icons/MinusIcon.js";import"../icon/icons/ThumbDownIcon.js";import"../icon/icons/ThumbUpIcon.js";import"../icon/icons/TrashCanIcon.js";import"../icon/icons/PenIcon.js";import"../button/Button.js";import"../card/Card.js";import"../card/CardImage.js";import"../card/NavCard.js";import"../checkbox/Checkbox.js";import"../combobox/Combobox.js";import"../cookie-consent/CookieConsentContext.js";import"react-dom";import"../modal/Modal.js";import"react-a11y-dialog";import"../list/List.js";import"../list/ListItem.js";import"../datepicker/DatePicker.js";import"../icon-button/IconButton.js";import"../tooltip/Tooltip.js";import"../tooltip/TooltipContent.js";import"../tooltip/TooltipTrigger.js";import"../input-group/InputGroup.js";import"../link/Link.js";import"../link/NavLink.js";import"../link-list/LinkList.js";import"../radio-button/RadioButton.js";import"../radio-button/radioGroupContext.js";import"../radio-button/BaseRadioButton.js";import{S as o}from"../../../NativeSelect-EidDABsT.js";import"../tag/Tag.js";import"../text-input/BaseTextArea.js";import"../text-input/BaseTextInput.js";import"../text-input/TextArea.js";import"../text-input/TextInput.js";import"../../utilities/polymorphism/SlotComponent.js";import"../../utilities/valuePair.js";import"./select-utils.js";export{o as Select};
2
2
  //# sourceMappingURL=Select.js.map