@fremtind/jokul 0.27.0 → 0.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/build-stats.html +1 -1
- package/build/cjs/components/ScreenReaderOnly.cjs.map +1 -1
- package/build/cjs/components/accordion/Accordion.cjs.map +1 -1
- package/build/cjs/components/accordion/AccordionItem.cjs.map +1 -1
- package/build/cjs/components/breadcrumb/Breadcrumb.cjs.map +1 -1
- package/build/cjs/components/breadcrumb/BreadcrumbItem.cjs.map +1 -1
- package/build/cjs/components/button/Button.cjs.map +1 -1
- package/build/cjs/components/button/index.d.cts +1 -1
- package/build/cjs/components/button/types.cjs.map +1 -1
- package/build/cjs/components/card/Card.cjs.map +1 -1
- package/build/cjs/components/card/CardImage.cjs.map +1 -1
- package/build/cjs/components/card/InfoCard.cjs.map +1 -1
- package/build/cjs/components/card/NavCard.cjs.map +1 -1
- package/build/cjs/components/card/TaskCard.cjs.map +1 -1
- package/build/cjs/components/card/documentation/examples/FakturainfoExample.d.cts +1 -1
- package/build/cjs/components/card/documentation/examples/StatuskortExample.d.cts +1 -1
- package/build/cjs/components/card/types.cjs.map +1 -1
- package/build/cjs/components/card/utils.cjs.map +1 -1
- package/build/cjs/components/checkbox/Checkbox.cjs.map +1 -1
- package/build/cjs/components/combobox/Combobox.cjs.map +1 -1
- package/build/cjs/components/combobox/index.d.cts +1 -1
- package/build/cjs/components/cookie-consent/CookieConsent.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/CookieConsentContext.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/CookieConsentModal.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/consents/CustomConsents.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/consents/DefaultConsents.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/consents/RequirementCheckbox.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/consents/RequirementCheckbox.d.cts +1 -1
- package/build/cjs/components/cookie-consent/cookieConsentUtils.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/cookieConsentUtils.d.cts +1 -1
- package/build/cjs/components/cookie-consent/index.d.cts +1 -1
- package/build/cjs/components/datepicker/DatePicker.cjs.map +1 -1
- package/build/cjs/components/datepicker/internal/Calendar.cjs.map +1 -1
- package/build/cjs/components/datepicker/internal/calendarReducer.cjs.map +1 -1
- package/build/cjs/components/datepicker/internal/useCalendar.cjs.map +1 -1
- package/build/cjs/components/datepicker/internal/utils.cjs.map +1 -1
- package/build/cjs/components/datepicker/internal/utils.d.cts +2 -2
- package/build/cjs/components/datepicker/utils.cjs.map +1 -1
- package/build/cjs/components/description-list/DescriptionList.cjs.map +1 -1
- package/build/cjs/components/expander/ExpandSection.cjs.map +1 -1
- package/build/cjs/components/expander/Expander.cjs.map +1 -1
- package/build/cjs/components/feedback/Feedback.cjs.map +1 -1
- package/build/cjs/components/feedback/FeedbackSuccess.cjs.map +1 -1
- package/build/cjs/components/feedback/FeedbackValues.cjs.map +1 -1
- package/build/cjs/components/feedback/feedbackContext.cjs.map +1 -1
- package/build/cjs/components/feedback/followup/Followup.cjs.map +1 -1
- package/build/cjs/components/feedback/followup/followupContext.cjs.map +1 -1
- package/build/cjs/components/feedback/followup/useFollowup.cjs.map +1 -1
- package/build/cjs/components/feedback/main-question/MainQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/main-question/mainQuestionContext.cjs.map +1 -1
- package/build/cjs/components/feedback/main-question/useMainQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/presets.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/AddonQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/CheckboxQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/ContactQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/RadioQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/SmileyQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/TextQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/questions/smileyUtils.cjs.map +1 -1
- package/build/cjs/components/feedback/utils.cjs.map +1 -1
- package/build/cjs/components/flex/Flex.cjs.map +1 -1
- package/build/cjs/components/icon/Icon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ArrowDownIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ArrowLeftIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ArrowNorthEastIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ArrowRightIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ArrowUpIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/CalendarIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/CheckIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ChevronDownIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ChevronLeftIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ChevronRightIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ChevronUpIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/CloseIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/CopyIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/DotsIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/DragIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/GreenCheckIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/HamburgerIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/LinkIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/MinusIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/PenIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/PlusIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/QuestionIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/RedCrossIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/SearchIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ThumbDownIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/ThumbUpIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/TrashCanIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/animated/ArrowHorizontalAnimated.cjs.map +1 -1
- package/build/cjs/components/icon/icons/animated/ArrowVerticalAnimated.cjs.map +1 -1
- package/build/cjs/components/icon/icons/animated/PlusRemoveAnimated.cjs.map +1 -1
- package/build/cjs/components/icon-button/IconButton.cjs.map +1 -1
- package/build/cjs/components/image/Image.cjs.map +1 -1
- package/build/cjs/components/image/useImageLoadingStatus.cjs.map +1 -1
- package/build/cjs/components/index.d.cts +1 -1
- package/build/cjs/components/input-group/FieldGroup.cjs.map +1 -1
- package/build/cjs/components/input-group/InputGroup.cjs.map +1 -1
- package/build/cjs/components/input-group/Label.cjs.map +1 -1
- package/build/cjs/components/input-group/SupportLabel.cjs.map +1 -1
- package/build/cjs/components/input-group/index.d.cts +2 -2
- package/build/cjs/components/link/Link.cjs.map +1 -1
- package/build/cjs/components/link/NavLink.cjs.map +1 -1
- package/build/cjs/components/link-list/LinkList.cjs.map +1 -1
- package/build/cjs/components/loader/index.d.cts +2 -2
- package/build/cjs/components/loader/skeletons/SkeletonAnimation.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonButton.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonCheckboxGroup.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonElement.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonInput.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonLabel.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonRadioButtonGroup.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonTable.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonTextArea.cjs.map +1 -1
- package/build/cjs/components/loader/useDelayedRender.cjs.map +1 -1
- package/build/cjs/components/logo/Logo.cjs.map +1 -1
- package/build/cjs/components/logo/LogoStamp.cjs.map +1 -1
- package/build/cjs/components/logo/useTextSpinner.cjs.map +1 -1
- package/build/cjs/components/menu/Menu.cjs.map +1 -1
- package/build/cjs/components/menu/MenuItem.cjs.map +1 -1
- package/build/cjs/components/menu/MenuItemCheckbox.cjs.map +1 -1
- package/build/cjs/components/menu/index.d.cts +1 -1
- package/build/cjs/components/message/DismissButton.cjs.map +1 -1
- package/build/cjs/components/message/FormErrorMessage.cjs.map +1 -1
- package/build/cjs/components/message/Message.cjs.map +1 -1
- package/build/cjs/components/message/index.d.cts +2 -2
- package/build/cjs/components/modal/Modal.cjs +1 -1
- package/build/cjs/components/modal/Modal.cjs.map +1 -1
- package/build/cjs/components/modal/index.d.cts +1 -1
- package/build/cjs/components/modal/useModal.cjs.map +1 -1
- package/build/cjs/components/pagination/Pagination.cjs.map +1 -1
- package/build/cjs/components/popover/Popover.cjs +1 -1
- package/build/cjs/components/popover/Popover.cjs.map +1 -1
- package/build/cjs/components/progress-bar/Countdown.cjs.map +1 -1
- package/build/cjs/components/radio-button/BaseRadioButton.cjs.map +1 -1
- package/build/cjs/components/radio-button/RadioButton.cjs.map +1 -1
- package/build/cjs/components/radio-button/RadioButtonGroup.cjs.map +1 -1
- package/build/cjs/components/radio-button/radioGroupContext.cjs.map +1 -1
- package/build/cjs/components/radio-panel/RadioPanel.cjs.map +1 -1
- package/build/cjs/components/select/NativeSelect.cjs.map +1 -1
- package/build/cjs/components/select/Select.cjs.map +1 -1
- package/build/cjs/components/select/select-utils.cjs.map +1 -1
- package/build/cjs/components/summary-table/SummaryTable.cjs.map +1 -1
- package/build/cjs/components/summary-table/SummaryTableRow.cjs.map +1 -1
- package/build/cjs/components/summary-table/mocks.cjs.map +1 -1
- package/build/cjs/components/system-message/SystemMessage.cjs.map +1 -1
- package/build/cjs/components/system-message/common/DismissButton.cjs.map +1 -1
- package/build/cjs/components/system-message/common/MessageIcon.cjs.map +1 -1
- package/build/cjs/components/system-message/index.d.cts +1 -1
- package/build/cjs/components/table/DataTable.cjs.map +1 -1
- package/build/cjs/components/table/ExpandableTableRow.cjs.map +1 -1
- package/build/cjs/components/table/ExpandableTableRowController.cjs.map +1 -1
- package/build/cjs/components/table/Table.cjs.map +1 -1
- package/build/cjs/components/table/TableBody.cjs.map +1 -1
- package/build/cjs/components/table/TableCaption.cjs.map +1 -1
- package/build/cjs/components/table/TableCell.cjs.map +1 -1
- package/build/cjs/components/table/TableColumn.cjs.map +1 -1
- package/build/cjs/components/table/TableColumnGroup.cjs.map +1 -1
- package/build/cjs/components/table/TableFooter.cjs.map +1 -1
- package/build/cjs/components/table/TableHead.cjs.map +1 -1
- package/build/cjs/components/table/TableHeader.cjs.map +1 -1
- package/build/cjs/components/table/TablePagination.cjs.map +1 -1
- package/build/cjs/components/table/TableRow.cjs.map +1 -1
- package/build/cjs/components/table/index.d.cts +1 -1
- package/build/cjs/components/table/tableContext.cjs.map +1 -1
- package/build/cjs/components/table/tableSectionContext.cjs.map +1 -1
- package/build/cjs/components/table/utils.cjs.map +1 -1
- package/build/cjs/components/tabs/NavTab.cjs.map +1 -1
- package/build/cjs/components/tabs/NavTabs.cjs.map +1 -1
- package/build/cjs/components/tabs/Tab.cjs.map +1 -1
- package/build/cjs/components/tabs/TabList.cjs.map +1 -1
- package/build/cjs/components/tabs/Tabs.cjs.map +1 -1
- package/build/cjs/components/tag/Tag.cjs.map +1 -1
- package/build/cjs/components/text-input/BaseTextArea.cjs.map +1 -1
- package/build/cjs/components/text-input/BaseTextInput.cjs.map +1 -1
- package/build/cjs/components/text-input/TextArea.cjs.map +1 -1
- package/build/cjs/components/text-input/TextInput.cjs.map +1 -1
- package/build/cjs/components/toast/Toast.cjs.map +1 -1
- package/build/cjs/components/toast/ToastRegion.cjs.map +1 -1
- package/build/cjs/components/toast/ToastRegion.d.cts +1 -1
- package/build/cjs/components/toast/toastContext.cjs.map +1 -1
- package/build/cjs/components/toggle-switch/ToggleSlider.cjs.map +1 -1
- package/build/cjs/components/toggle-switch/ToggleSwitch.cjs.map +1 -1
- package/build/cjs/components/toggle-switch/usePillStyles.cjs.map +1 -1
- package/build/cjs/components/tooltip/PopupTip.cjs.map +1 -1
- package/build/cjs/components/tooltip/Tooltip.cjs.map +1 -1
- package/build/cjs/components/tooltip/TooltipContent.cjs.map +1 -1
- package/build/cjs/components/tooltip/TooltipTrigger.cjs.map +1 -1
- package/build/cjs/components/tooltip/index.d.cts +1 -1
- package/build/cjs/hooks/index.d.cts +5 -5
- package/build/cjs/hooks/mediaQueryUtils.cjs.map +1 -1
- package/build/cjs/hooks/useAnimatedDetails/useAnimatedDetails.cjs.map +1 -1
- package/build/cjs/hooks/useAnimatedHeight/index.d.cts +1 -1
- package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeight.cjs.map +1 -1
- package/build/cjs/hooks/useAnimatedHeight/useAnimatedHeightBetween.cjs.map +1 -1
- package/build/cjs/hooks/useAnimatedHeight/useAutoAnimateHeight.cjs.map +1 -1
- package/build/cjs/hooks/useAriaLiveRegion/index.d.cts +1 -1
- package/build/cjs/hooks/useAriaLiveRegion/useAriaLiveRegion.cjs.map +1 -1
- package/build/cjs/hooks/useBrowserPreferences/useBrowserPreferences.cjs.map +1 -1
- package/build/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
- package/build/cjs/hooks/useElementDimensions/index.d.cts +1 -1
- package/build/cjs/hooks/useElementDimensions/useElementDimensions.cjs.map +1 -1
- package/build/cjs/hooks/useFocusOutside/useFocusOutside.cjs.map +1 -1
- package/build/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.cjs.map +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.d.cts +1 -1
- package/build/cjs/hooks/useLocalStorage/useLocalStorage.cjs.map +1 -1
- package/build/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
- package/build/cjs/hooks/useProgressiveImg/index.d.cts +1 -1
- package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.cjs.map +1 -1
- package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.d.cts +1 -1
- package/build/cjs/hooks/useScreen/state.cjs.map +1 -1
- package/build/cjs/hooks/useScreen/useScreen.cjs.map +1 -1
- package/build/cjs/hooks/useScrollIntoView/index.d.cts +1 -1
- package/build/cjs/hooks/useSwipeGesture/useSwipeGesture.cjs.map +1 -1
- package/build/cjs/utilities/formatters/avstand/formatAvstand.cjs.map +1 -1
- package/build/cjs/utilities/formatters/bytes/formatBytes.cjs.map +1 -1
- package/build/cjs/utilities/formatters/date/formatDate.cjs.map +1 -1
- package/build/cjs/utilities/formatters/fodselsnummer/formatFodselsnummer.cjs.map +1 -1
- package/build/cjs/utilities/formatters/index.d.cts +5 -5
- package/build/cjs/utilities/formatters/kontonummer/formatKontonummer.cjs.map +1 -1
- package/build/cjs/utilities/formatters/kortnummer/formatKortnummer.cjs.map +1 -1
- package/build/cjs/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.cjs.map +1 -1
- package/build/cjs/utilities/formatters/telefonnummer/formatTelefonnummer.cjs.map +1 -1
- package/build/cjs/utilities/formatters/util/formatNumber.cjs.map +1 -1
- package/build/cjs/utilities/formatters/util/parseNumber.cjs.map +1 -1
- package/build/cjs/utilities/formatters/util/registerWithMask.cjs.map +1 -1
- package/build/cjs/utilities/formatters/valuta/formatValuta.cjs.map +1 -1
- package/build/cjs/utilities/getThemeAndDensity.cjs.map +1 -1
- package/build/cjs/utilities/polymorphism/SlotComponent.cjs.map +1 -1
- package/build/cjs/utilities/polymorphism/index.d.cts +1 -1
- package/build/cjs/utilities/polymorphism/mergeProps.cjs.map +1 -1
- package/build/cjs/utilities/polymorphism/mergeRefs.cjs.map +1 -1
- package/build/cjs/utilities/tabListener.cjs.map +1 -1
- package/build/cjs/utilities/validators/hasMinimumWords/hasMinimumWords.cjs.map +1 -1
- package/build/cjs/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidChassisnummer/isValidChassisnummer.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidEpost/isValidEpost.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidKortnummer/isValidKortnummer.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidName/isValidName.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.cjs.map +1 -1
- package/build/es/components/ScreenReaderOnly.js.map +1 -1
- package/build/es/components/accordion/Accordion.js.map +1 -1
- package/build/es/components/accordion/AccordionItem.js.map +1 -1
- package/build/es/components/breadcrumb/Breadcrumb.js.map +1 -1
- package/build/es/components/breadcrumb/BreadcrumbItem.js.map +1 -1
- package/build/es/components/button/Button.js.map +1 -1
- package/build/es/components/button/index.d.ts +1 -1
- package/build/es/components/button/types.js.map +1 -1
- package/build/es/components/card/Card.js.map +1 -1
- package/build/es/components/card/CardImage.js.map +1 -1
- package/build/es/components/card/InfoCard.js.map +1 -1
- package/build/es/components/card/NavCard.js.map +1 -1
- package/build/es/components/card/TaskCard.js.map +1 -1
- package/build/es/components/card/documentation/examples/FakturainfoExample.d.ts +1 -1
- package/build/es/components/card/documentation/examples/StatuskortExample.d.ts +1 -1
- package/build/es/components/card/types.js.map +1 -1
- package/build/es/components/card/utils.js.map +1 -1
- package/build/es/components/checkbox/Checkbox.js.map +1 -1
- package/build/es/components/combobox/Combobox.js.map +1 -1
- package/build/es/components/combobox/index.d.ts +1 -1
- package/build/es/components/cookie-consent/CookieConsent.js.map +1 -1
- package/build/es/components/cookie-consent/CookieConsentContext.js.map +1 -1
- package/build/es/components/cookie-consent/CookieConsentModal.js.map +1 -1
- package/build/es/components/cookie-consent/consents/CustomConsents.js.map +1 -1
- package/build/es/components/cookie-consent/consents/DefaultConsents.js.map +1 -1
- package/build/es/components/cookie-consent/consents/RequirementCheckbox.d.ts +1 -1
- package/build/es/components/cookie-consent/consents/RequirementCheckbox.js.map +1 -1
- package/build/es/components/cookie-consent/cookieConsentUtils.d.ts +1 -1
- package/build/es/components/cookie-consent/cookieConsentUtils.js.map +1 -1
- package/build/es/components/cookie-consent/index.d.ts +1 -1
- package/build/es/components/datepicker/DatePicker.js.map +1 -1
- package/build/es/components/datepicker/internal/Calendar.js.map +1 -1
- package/build/es/components/datepicker/internal/calendarReducer.js.map +1 -1
- package/build/es/components/datepicker/internal/useCalendar.js.map +1 -1
- package/build/es/components/datepicker/internal/utils.d.ts +2 -2
- package/build/es/components/datepicker/internal/utils.js.map +1 -1
- package/build/es/components/datepicker/utils.js.map +1 -1
- package/build/es/components/description-list/DescriptionList.js.map +1 -1
- package/build/es/components/expander/ExpandSection.js.map +1 -1
- package/build/es/components/expander/Expander.js.map +1 -1
- package/build/es/components/feedback/Feedback.js.map +1 -1
- package/build/es/components/feedback/FeedbackSuccess.js.map +1 -1
- package/build/es/components/feedback/FeedbackValues.js.map +1 -1
- package/build/es/components/feedback/feedbackContext.js.map +1 -1
- package/build/es/components/feedback/followup/Followup.js.map +1 -1
- package/build/es/components/feedback/followup/followupContext.js.map +1 -1
- package/build/es/components/feedback/followup/useFollowup.js.map +1 -1
- package/build/es/components/feedback/main-question/MainQuestion.js.map +1 -1
- package/build/es/components/feedback/main-question/mainQuestionContext.js.map +1 -1
- package/build/es/components/feedback/main-question/useMainQuestion.js.map +1 -1
- package/build/es/components/feedback/presets.js.map +1 -1
- package/build/es/components/feedback/questions/AddonQuestion.js.map +1 -1
- package/build/es/components/feedback/questions/CheckboxQuestion.js.map +1 -1
- package/build/es/components/feedback/questions/ContactQuestion.js.map +1 -1
- package/build/es/components/feedback/questions/RadioQuestion.js.map +1 -1
- package/build/es/components/feedback/questions/SmileyQuestion.js.map +1 -1
- package/build/es/components/feedback/questions/TextQuestion.js.map +1 -1
- package/build/es/components/feedback/questions/smileyUtils.js.map +1 -1
- package/build/es/components/feedback/utils.js.map +1 -1
- package/build/es/components/flex/Flex.js.map +1 -1
- package/build/es/components/icon/Icon.js.map +1 -1
- package/build/es/components/icon/icons/ArrowDownIcon.js.map +1 -1
- package/build/es/components/icon/icons/ArrowLeftIcon.js.map +1 -1
- package/build/es/components/icon/icons/ArrowNorthEastIcon.js.map +1 -1
- package/build/es/components/icon/icons/ArrowRightIcon.js.map +1 -1
- package/build/es/components/icon/icons/ArrowUpIcon.js.map +1 -1
- package/build/es/components/icon/icons/CalendarIcon.js.map +1 -1
- package/build/es/components/icon/icons/CheckIcon.js.map +1 -1
- package/build/es/components/icon/icons/ChevronDownIcon.js.map +1 -1
- package/build/es/components/icon/icons/ChevronLeftIcon.js.map +1 -1
- package/build/es/components/icon/icons/ChevronRightIcon.js.map +1 -1
- package/build/es/components/icon/icons/ChevronUpIcon.js.map +1 -1
- package/build/es/components/icon/icons/CloseIcon.js.map +1 -1
- package/build/es/components/icon/icons/CopyIcon.js.map +1 -1
- package/build/es/components/icon/icons/DotsIcon.js.map +1 -1
- package/build/es/components/icon/icons/DragIcon.js.map +1 -1
- package/build/es/components/icon/icons/GreenCheckIcon.js.map +1 -1
- package/build/es/components/icon/icons/HamburgerIcon.js.map +1 -1
- package/build/es/components/icon/icons/LinkIcon.js.map +1 -1
- package/build/es/components/icon/icons/MinusIcon.js.map +1 -1
- package/build/es/components/icon/icons/PenIcon.js.map +1 -1
- package/build/es/components/icon/icons/PlusIcon.js.map +1 -1
- package/build/es/components/icon/icons/QuestionIcon.js.map +1 -1
- package/build/es/components/icon/icons/RedCrossIcon.js.map +1 -1
- package/build/es/components/icon/icons/SearchIcon.js.map +1 -1
- package/build/es/components/icon/icons/ThumbDownIcon.js.map +1 -1
- package/build/es/components/icon/icons/ThumbUpIcon.js.map +1 -1
- package/build/es/components/icon/icons/TrashCanIcon.js.map +1 -1
- package/build/es/components/icon/icons/animated/ArrowHorizontalAnimated.js.map +1 -1
- package/build/es/components/icon/icons/animated/ArrowVerticalAnimated.js.map +1 -1
- package/build/es/components/icon/icons/animated/PlusRemoveAnimated.js.map +1 -1
- package/build/es/components/icon-button/IconButton.js.map +1 -1
- package/build/es/components/image/Image.js.map +1 -1
- package/build/es/components/image/useImageLoadingStatus.js.map +1 -1
- package/build/es/components/index.d.ts +1 -1
- package/build/es/components/input-group/FieldGroup.js.map +1 -1
- package/build/es/components/input-group/InputGroup.js.map +1 -1
- package/build/es/components/input-group/Label.js.map +1 -1
- package/build/es/components/input-group/SupportLabel.js.map +1 -1
- package/build/es/components/input-group/index.d.ts +2 -2
- package/build/es/components/link/Link.js.map +1 -1
- package/build/es/components/link/NavLink.js.map +1 -1
- package/build/es/components/link-list/LinkList.js.map +1 -1
- package/build/es/components/loader/index.d.ts +2 -2
- package/build/es/components/loader/skeletons/SkeletonAnimation.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonButton.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonCheckboxGroup.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonElement.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonInput.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonLabel.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonRadioButtonGroup.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonTable.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonTextArea.js.map +1 -1
- package/build/es/components/loader/useDelayedRender.js.map +1 -1
- package/build/es/components/logo/Logo.js.map +1 -1
- package/build/es/components/logo/LogoStamp.js.map +1 -1
- package/build/es/components/logo/useTextSpinner.js.map +1 -1
- package/build/es/components/menu/Menu.js.map +1 -1
- package/build/es/components/menu/MenuItem.js.map +1 -1
- package/build/es/components/menu/MenuItemCheckbox.js.map +1 -1
- package/build/es/components/menu/index.d.ts +1 -1
- package/build/es/components/message/DismissButton.js.map +1 -1
- package/build/es/components/message/FormErrorMessage.js.map +1 -1
- package/build/es/components/message/Message.js.map +1 -1
- package/build/es/components/message/index.d.ts +2 -2
- package/build/es/components/modal/Modal.js +1 -1
- package/build/es/components/modal/Modal.js.map +1 -1
- package/build/es/components/modal/index.d.ts +1 -1
- package/build/es/components/modal/useModal.js.map +1 -1
- package/build/es/components/pagination/Pagination.js.map +1 -1
- package/build/es/components/popover/Popover.js +1 -1
- package/build/es/components/popover/Popover.js.map +1 -1
- package/build/es/components/progress-bar/Countdown.js.map +1 -1
- package/build/es/components/radio-button/BaseRadioButton.js.map +1 -1
- package/build/es/components/radio-button/RadioButton.js.map +1 -1
- package/build/es/components/radio-button/RadioButtonGroup.js.map +1 -1
- package/build/es/components/radio-button/radioGroupContext.js.map +1 -1
- package/build/es/components/radio-panel/RadioPanel.js.map +1 -1
- package/build/es/components/select/NativeSelect.js.map +1 -1
- package/build/es/components/select/Select.js.map +1 -1
- package/build/es/components/select/select-utils.js.map +1 -1
- package/build/es/components/summary-table/SummaryTable.js.map +1 -1
- package/build/es/components/summary-table/SummaryTableRow.js.map +1 -1
- package/build/es/components/summary-table/mocks.js.map +1 -1
- package/build/es/components/system-message/SystemMessage.js.map +1 -1
- package/build/es/components/system-message/common/DismissButton.js.map +1 -1
- package/build/es/components/system-message/common/MessageIcon.js.map +1 -1
- package/build/es/components/system-message/index.d.ts +1 -1
- package/build/es/components/table/DataTable.js.map +1 -1
- package/build/es/components/table/ExpandableTableRow.js.map +1 -1
- package/build/es/components/table/ExpandableTableRowController.js.map +1 -1
- package/build/es/components/table/Table.js.map +1 -1
- package/build/es/components/table/TableBody.js.map +1 -1
- package/build/es/components/table/TableCaption.js.map +1 -1
- package/build/es/components/table/TableCell.js.map +1 -1
- package/build/es/components/table/TableColumn.js.map +1 -1
- package/build/es/components/table/TableColumnGroup.js.map +1 -1
- package/build/es/components/table/TableFooter.js.map +1 -1
- package/build/es/components/table/TableHead.js.map +1 -1
- package/build/es/components/table/TableHeader.js.map +1 -1
- package/build/es/components/table/TablePagination.js.map +1 -1
- package/build/es/components/table/TableRow.js.map +1 -1
- package/build/es/components/table/index.d.ts +1 -1
- package/build/es/components/table/tableContext.js.map +1 -1
- package/build/es/components/table/tableSectionContext.js.map +1 -1
- package/build/es/components/table/utils.js.map +1 -1
- package/build/es/components/tabs/NavTab.js.map +1 -1
- package/build/es/components/tabs/NavTabs.js.map +1 -1
- package/build/es/components/tabs/Tab.js.map +1 -1
- package/build/es/components/tabs/TabList.js.map +1 -1
- package/build/es/components/tabs/Tabs.js.map +1 -1
- package/build/es/components/tag/Tag.js.map +1 -1
- package/build/es/components/text-input/BaseTextArea.js.map +1 -1
- package/build/es/components/text-input/BaseTextInput.js.map +1 -1
- package/build/es/components/text-input/TextArea.js.map +1 -1
- package/build/es/components/text-input/TextInput.js.map +1 -1
- package/build/es/components/toast/Toast.js.map +1 -1
- package/build/es/components/toast/ToastRegion.d.ts +1 -1
- package/build/es/components/toast/ToastRegion.js.map +1 -1
- package/build/es/components/toast/toastContext.js.map +1 -1
- package/build/es/components/toggle-switch/ToggleSlider.js.map +1 -1
- package/build/es/components/toggle-switch/ToggleSwitch.js.map +1 -1
- package/build/es/components/toggle-switch/usePillStyles.js.map +1 -1
- package/build/es/components/tooltip/PopupTip.js.map +1 -1
- package/build/es/components/tooltip/Tooltip.js.map +1 -1
- package/build/es/components/tooltip/TooltipContent.js.map +1 -1
- package/build/es/components/tooltip/TooltipTrigger.js.map +1 -1
- package/build/es/components/tooltip/index.d.ts +1 -1
- package/build/es/hooks/index.d.ts +5 -5
- package/build/es/hooks/mediaQueryUtils.js.map +1 -1
- package/build/es/hooks/useAnimatedDetails/useAnimatedDetails.js.map +1 -1
- package/build/es/hooks/useAnimatedHeight/index.d.ts +1 -1
- package/build/es/hooks/useAnimatedHeight/useAnimatedHeight.js.map +1 -1
- package/build/es/hooks/useAnimatedHeight/useAnimatedHeightBetween.js.map +1 -1
- package/build/es/hooks/useAnimatedHeight/useAutoAnimateHeight.js.map +1 -1
- package/build/es/hooks/useAriaLiveRegion/index.d.ts +1 -1
- package/build/es/hooks/useAriaLiveRegion/useAriaLiveRegion.js.map +1 -1
- package/build/es/hooks/useBrowserPreferences/useBrowserPreferences.js.map +1 -1
- package/build/es/hooks/useClickOutside/useClickOutside.js.map +1 -1
- package/build/es/hooks/useElementDimensions/index.d.ts +1 -1
- package/build/es/hooks/useElementDimensions/useElementDimensions.js.map +1 -1
- package/build/es/hooks/useFocusOutside/useFocusOutside.js.map +1 -1
- package/build/es/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.d.ts +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -1
- package/build/es/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
- package/build/es/hooks/useMutationObserver/useMutationObserver.js.map +1 -1
- package/build/es/hooks/useProgressiveImg/index.d.ts +1 -1
- package/build/es/hooks/useProgressiveImg/useProgressiveImg.d.ts +1 -1
- package/build/es/hooks/useProgressiveImg/useProgressiveImg.js.map +1 -1
- package/build/es/hooks/useScreen/state.js.map +1 -1
- package/build/es/hooks/useScreen/useScreen.js.map +1 -1
- package/build/es/hooks/useScrollIntoView/index.d.ts +1 -1
- package/build/es/hooks/useSwipeGesture/useSwipeGesture.js.map +1 -1
- package/build/es/utilities/formatters/avstand/formatAvstand.js.map +1 -1
- package/build/es/utilities/formatters/bytes/formatBytes.js.map +1 -1
- package/build/es/utilities/formatters/date/formatDate.js.map +1 -1
- package/build/es/utilities/formatters/fodselsnummer/formatFodselsnummer.js.map +1 -1
- package/build/es/utilities/formatters/index.d.ts +5 -5
- package/build/es/utilities/formatters/kontonummer/formatKontonummer.js.map +1 -1
- package/build/es/utilities/formatters/kortnummer/formatKortnummer.js.map +1 -1
- package/build/es/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.js.map +1 -1
- package/build/es/utilities/formatters/telefonnummer/formatTelefonnummer.js.map +1 -1
- package/build/es/utilities/formatters/util/formatNumber.js.map +1 -1
- package/build/es/utilities/formatters/util/parseNumber.js.map +1 -1
- package/build/es/utilities/formatters/util/registerWithMask.js.map +1 -1
- package/build/es/utilities/formatters/valuta/formatValuta.js.map +1 -1
- package/build/es/utilities/getThemeAndDensity.js.map +1 -1
- package/build/es/utilities/polymorphism/SlotComponent.js.map +1 -1
- package/build/es/utilities/polymorphism/index.d.ts +1 -1
- package/build/es/utilities/polymorphism/mergeProps.js.map +1 -1
- package/build/es/utilities/polymorphism/mergeRefs.js.map +1 -1
- package/build/es/utilities/tabListener.js.map +1 -1
- package/build/es/utilities/validators/hasMinimumWords/hasMinimumWords.js.map +1 -1
- package/build/es/utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js.map +1 -1
- package/build/es/utilities/validators/isValidChassisnummer/isValidChassisnummer.js.map +1 -1
- package/build/es/utilities/validators/isValidEpost/isValidEpost.js.map +1 -1
- package/build/es/utilities/validators/isValidFodselsnummer/isValidFodselsnummer.js.map +1 -1
- package/build/es/utilities/validators/isValidKortnummer/isValidKortnummer.js.map +1 -1
- package/build/es/utilities/validators/isValidName/isValidName.js.map +1 -1
- package/build/es/utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js.map +1 -1
- package/build/es/utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js.map +1 -1
- package/package.json +2 -2
- package/styles/components/button/button.css +2 -2
- package/styles/components/button/button.min.css +1 -1
- package/styles/components/checkbox/checkbox.css +4 -4
- package/styles/components/checkbox/checkbox.min.css +1 -1
- package/styles/components/feedback/feedback.css +2 -2
- package/styles/components/feedback/feedback.min.css +1 -1
- package/styles/components/input-group/input-group.css +2 -2
- package/styles/components/input-group/input-group.min.css +1 -1
- package/styles/components/loader/loader.css +6 -6
- package/styles/components/loader/loader.min.css +1 -1
- package/styles/components/loader/skeleton-loader.css +5 -5
- package/styles/components/loader/skeleton-loader.min.css +1 -1
- package/styles/components/message/message.css +2 -2
- package/styles/components/message/message.min.css +1 -1
- package/styles/components/progress-bar/progress-bar.css +2 -2
- package/styles/components/progress-bar/progress-bar.min.css +1 -1
- package/styles/components/radio-button/radio-button.css +2 -2
- package/styles/components/radio-button/radio-button.min.css +1 -1
- package/styles/components/radio-panel/radio-panel.css +6 -6
- package/styles/components/radio-panel/radio-panel.min.css +1 -1
- package/styles/components/system-message/system-message.css +2 -2
- package/styles/components/system-message/system-message.min.css +1 -1
- package/styles/components/toast/toast.css +4 -4
- package/styles/components/toast/toast.min.css +1 -1
- package/styles/styles.css +35 -35
- package/styles/styles.min.css +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsent.js","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { usePreviousValue } from \"../../hooks/usePreviousValue/usePreviousValue.js\";\nimport { useCookieConsentState } from \"./CookieConsentContext.js\";\nimport { CookieConsentModal } from \"./CookieConsentModal.js\";\nimport { setConsentCookie } from \"./cookieConsentUtils.js\";\nimport { AcceptConsentCallback, Consent } from \"./types.js\";\n\nexport interface CookieConsentProps {\n blocking?: boolean;\n onAccept?: AcceptConsentCallback;\n}\n\nexport const CookieConsent = ({
|
|
1
|
+
{"version":3,"file":"CookieConsent.js","sources":["../../../../src/components/cookie-consent/CookieConsent.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { usePreviousValue } from \"../../hooks/usePreviousValue/usePreviousValue.js\";\nimport { useCookieConsentState } from \"./CookieConsentContext.js\";\nimport { CookieConsentModal } from \"./CookieConsentModal.js\";\nimport { setConsentCookie } from \"./cookieConsentUtils.js\";\nimport { AcceptConsentCallback, Consent } from \"./types.js\";\n\nexport interface CookieConsentProps {\n blocking?: boolean;\n onAccept?: AcceptConsentCallback;\n}\n\nexport const CookieConsent = ({\n blocking,\n onAccept,\n ...rest\n}: CookieConsentProps): JSX.Element | null => {\n const { dispatch, consent, cookieName, cookieDomain } =\n useCookieConsentState();\n const prevConsent = usePreviousValue(consent);\n\n useEffect(() => {\n if (onAccept) {\n // Prevent onAccept from being triggered every time state changes\\\n if (consent !== prevConsent) {\n onAccept(consent);\n }\n }\n }, [onAccept, consent, prevConsent]);\n\n // Cookies are disabled in the browser\n if (typeof navigator !== \"undefined\" && !navigator.cookieEnabled) {\n if (onAccept) {\n onAccept({\n functional: \"denied\",\n marketing: \"denied\",\n statistics: \"denied\",\n });\n }\n\n return null;\n }\n\n const handleAccept = (newConsent: Partial<Consent>) => {\n // Filter out null values from the new consent\n const newConsentWithoutNullValues = Object.fromEntries(\n Object.entries(newConsent).filter(([, value]) => value != null),\n );\n\n // Merge the existing consent with the new consent\n const updatedConsent: Consent = {\n ...consent,\n ...newConsentWithoutNullValues,\n };\n\n dispatch({ type: \"UPDATE_CONSENT\", payload: updatedConsent });\n dispatch({ type: \"SET_SHOW_CONSENT\", payload: false });\n setConsentCookie({\n consent: updatedConsent,\n name: cookieName,\n domain: cookieDomain,\n });\n };\n\n // This returns different variants of consents based on the behavior required to get the consent\n // Blocking implies a blocking modal demanding an active action before the user can interact with the application\n if (blocking) {\n return <CookieConsentModal {...rest} onAccept={handleAccept} />;\n }\n\n return null;\n};\n"],"names":["CookieConsent","blocking","onAccept","rest","dispatch","consent","cookieName","cookieDomain","useCookieConsentState","prevConsent","usePreviousValue","useEffect","navigator","cookieEnabled","functional","marketing","statistics","jsx","CookieConsentModal","newConsent","newConsentWithoutNullValues","Object","fromEntries","entries","filter","value","updatedConsent","type","payload","setConsentCookie","name","domain"],"mappings":"wVAYO,MAAMA,EAAgB,EACzBC,SAAAA,EACAC,SAAAA,KACGC,MAEH,MAAQC,SAAAA,EAAUC,QAAAA,EAASC,WAAAA,EAAYC,aAAAA,GACnCC,IACEC,EAAcC,EAAiBL,GAYrC,GAVAM,GAAU,KACFT,GAEIG,IAAYI,GACZP,EAASG,EAAO,GAGzB,CAACH,EAAUG,EAASI,WAGZG,UAAc,MAAgBA,UAAUC,cAC/C,OAAIX,GACSA,EAAA,CACLY,WAAY,SACZC,UAAW,SACXC,WAAY,WAIb,KA0BPf,OAAAA,EACQgB,EAAAC,EAAA,IAAuBf,EAAMD,SAxBnBiB,IAElB,MAAMC,EAA8BC,OAAOC,YACvCD,OAAOE,QAAQJ,GAAYK,QAAO,GAAIC,KAAoB,MAATA,KAI/CC,EAA0B,IACzBrB,KACAe,GAGPhB,EAAS,CAAEuB,KAAM,iBAAkBC,QAASF,IAC5CtB,EAAS,CAAEuB,KAAM,mBAAoBC,SAAS,IAC7BC,EAAA,CACbxB,QAASqB,EACTI,KAAMxB,EACNyB,OAAQxB,GACX,IASE,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsentContext.js","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { WithChildren } from \"../../core/types.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"CookieConsentContext.js","sources":["../../../../src/components/cookie-consent/CookieConsentContext.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { WithChildren } from \"../../core/types.js\";\nimport {\n buildRequirementsObject,\n getConsentCookie,\n shouldShowConsentDialog,\n} from \"./cookieConsentUtils.js\";\nimport { Consent, ConsentRequirement } from \"./types.js\";\n\n// https://kentcdodds.com/blog/how-to-use-react-context-effectively\n\ninterface SetShowConsentAction {\n type: \"SET_SHOW_CONSENT\";\n payload: boolean;\n}\n\ninterface SetShowSettingsAction {\n type: \"SET_SHOW_SETTINGS\";\n payload: boolean;\n}\n\ninterface UpdateConsentAction {\n type: \"UPDATE_CONSENT\";\n payload: Consent;\n}\n\ninterface UpdateRequirementsAction {\n type: \"UPDATE_REQUIREMENTS\";\n payload: ConsentRequirement;\n}\n\ntype Action =\n | SetShowConsentAction\n | UpdateConsentAction\n | SetShowSettingsAction\n | UpdateRequirementsAction;\ntype Dispatch = (action: Action) => void;\n\ninterface State {\n isOpen: boolean;\n showSettings: boolean;\n requirement: ConsentRequirement;\n consent: Consent;\n}\n\nexport const DEFAULT_COOKIE_NAME = \"fremtind-cookie-consent\";\n\nconst CookieConsentContext = React.createContext<\n | {\n state: State;\n dispatch: Dispatch;\n cookieName: string;\n cookieDomain?: string;\n }\n | undefined\n>(undefined);\n\nconst cookieConsentReducer = (state: State, action: Action): State => {\n switch (action.type) {\n case \"SET_SHOW_CONSENT\":\n return { ...state, isOpen: action.payload };\n\n case \"SET_SHOW_SETTINGS\":\n return {\n ...state,\n showSettings: action.payload,\n };\n\n case \"UPDATE_CONSENT\":\n return {\n ...state,\n consent: {\n ...state.consent,\n ...action.payload,\n },\n };\n\n case \"UPDATE_REQUIREMENTS\":\n return {\n ...state,\n requirement: {\n ...state.requirement,\n ...action.payload,\n },\n };\n\n default: {\n // @ts-ignore Denne skal ikke oppstå, men den _kan_ oppstå\n throw new Error(`Unhandled action type: ${action.type}`);\n }\n }\n};\n\nexport interface CookieConsentProviderProps\n extends Partial<ConsentRequirement>,\n WithChildren {\n cookieAdapter?: () => Consent | undefined;\n cookieName?: string;\n cookieDomain?: string;\n}\n\nconst CookieConsentProvider: React.FC<CookieConsentProviderProps> = ({\n children,\n cookieAdapter,\n marketing,\n functional,\n statistics,\n cookieName = DEFAULT_COOKIE_NAME,\n cookieDomain,\n}) => {\n // Load existing consent at initial render\n const consentCookie = useMemo(() => {\n return (\n getConsentCookie({ adapter: cookieAdapter, name: cookieName }) ?? {\n marketing: null,\n functional: null,\n statistics: null,\n }\n );\n }, [cookieAdapter, cookieName]);\n\n const requirement = useMemo(\n () => buildRequirementsObject({ marketing, functional, statistics }),\n [marketing, functional, statistics],\n );\n\n const [state, dispatch] = React.useReducer(cookieConsentReducer, {\n isOpen: false,\n showSettings: false,\n requirement,\n consent: consentCookie,\n });\n\n useEffect(() => {\n if (shouldShowConsentDialog(requirement, consentCookie)) {\n dispatch({ type: \"SET_SHOW_CONSENT\", payload: true });\n } else if (consentCookie) {\n dispatch({ type: \"UPDATE_CONSENT\", payload: consentCookie });\n }\n }, [requirement, consentCookie]);\n\n const value = { state, dispatch, cookieName, cookieDomain };\n return (\n <CookieConsentContext.Provider value={value}>\n {children}\n </CookieConsentContext.Provider>\n );\n};\n\ninterface UseCookieConsentState extends State {\n dispatch: Dispatch;\n cookieName: string;\n cookieDomain?: string;\n}\n\n// control and state for internal use\nconst useCookieConsentState = (): UseCookieConsentState => {\n const context = React.useContext(CookieConsentContext);\n if (context === undefined) {\n throw new Error(\n \"useCookieConsentState must be used within a CookieConsentProvider\",\n );\n }\n\n return {\n dispatch: context.dispatch,\n cookieName: context.cookieName,\n cookieDomain: context.cookieDomain,\n ...context.state,\n };\n};\n\ntype UseCookieConsent = {\n openConsentModalWithSettings: () => void;\n openConsentModalWithDefaults: () => void;\n /** Se hvilke samtykker som er gitt, om du for eksempel trenger styre UI basert på samtykker. */\n consents: Consent;\n};\n\n// expose functionality to be used by consumers\nconst useCookieConsent = (): UseCookieConsent => {\n const context = React.useContext(CookieConsentContext);\n if (context === undefined) {\n throw new Error(\n \"useCookieConsent must be used within a CookieConsentProvider\",\n );\n }\n\n const openConsentModalWithSettings = () => {\n context.dispatch({ type: \"SET_SHOW_CONSENT\", payload: true });\n context.dispatch({ type: \"SET_SHOW_SETTINGS\", payload: true });\n };\n\n const openConsentModalWithDefaults = () => {\n context.dispatch({ type: \"SET_SHOW_CONSENT\", payload: true });\n context.dispatch({ type: \"SET_SHOW_SETTINGS\", payload: false });\n };\n\n const consents = context.state.consent;\n\n return {\n openConsentModalWithSettings,\n openConsentModalWithDefaults,\n consents,\n };\n};\n\nexport { CookieConsentProvider, useCookieConsent, useCookieConsentState };\n"],"names":["DEFAULT_COOKIE_NAME","CookieConsentContext","React","createContext","cookieConsentReducer","state","action","type","isOpen","payload","showSettings","consent","requirement","Error","CookieConsentProvider","children","cookieAdapter","marketing","functional","statistics","cookieName","cookieDomain","consentCookie","useMemo","getConsentCookie","adapter","name","buildRequirementsObject","dispatch","useReducer","useEffect","shouldShowConsentDialog","value","jsx","Provider","useCookieConsentState","context","useContext","useCookieConsent","openConsentModalWithSettings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AAAA,EAAUlC,EAAMmC,WAAWpC,GACjC,QAAgB,IAAZmC,EACA,MAAM,IAAIvB,MACN,qEAID,MAAA,CACHe,SAAUQ,EAAQR,SAClBR,WAAYgB,EAAQhB,WACpBC,aAAce,EAAQf,gBACnBe,EAAQ/B,MAAA,EAYbiC,EAAmB,KACfF,MAAAA,EAAUlC,EAAMmC,WAAWpC,GACjC,QAAgB,IAAZmC,EACA,MAAM,IAAIvB,MACN,gEAgBD,MAAA,CACH0B,6BAbiC,KACjCH,EAAQR,SAAS,CAAErB,KAAM,mBAAoBE,SAAS,IACtD2B,EAAQR,SAAS,CAAErB,KAAM,oBAAqBE,SAAS,GAAM,EAY7D+B,6BATiC,KACjCJ,EAAQR,SAAS,CAAErB,KAAM,mBAAoBE,SAAS,IACtD2B,EAAQR,SAAS,CAAErB,KAAM,oBAAqBE,SAAS,GAAO,EAQ9DgC,SALaL,EAAQ/B,MAAMM,QAK3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieConsentModal.js","sources":["../../../../src/components/cookie-consent/CookieConsentModal.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { ModalContainer, ModalOverlay } from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { CustomConsents } from \"./consents/CustomConsents.js\";\nimport { DefaultConsents } from \"./consents/DefaultConsents.js\";\nimport { useCookieConsentState } from \"./CookieConsentContext.js\";\nimport { convertBooleanConsentObjectToConsentObject } from \"./cookieConsentUtils.js\";\nimport { Consent, ConsentComponentBaseProps } from \"./types.js\";\n\nexport const CookieConsentModal: FC<ConsentComponentBaseProps> = ({
|
|
1
|
+
{"version":3,"file":"CookieConsentModal.js","sources":["../../../../src/components/cookie-consent/CookieConsentModal.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { ModalContainer, ModalOverlay } from \"../modal/Modal.js\";\nimport { useModal } from \"../modal/useModal.js\";\nimport { CustomConsents } from \"./consents/CustomConsents.js\";\nimport { DefaultConsents } from \"./consents/DefaultConsents.js\";\nimport { useCookieConsentState } from \"./CookieConsentContext.js\";\nimport { convertBooleanConsentObjectToConsentObject } from \"./cookieConsentUtils.js\";\nimport { Consent, ConsentComponentBaseProps } from \"./types.js\";\n\nexport const CookieConsentModal: FC<ConsentComponentBaseProps> = ({\n onAccept,\n ...rest\n}) => {\n const { isOpen, requirement, showSettings } = useCookieConsentState();\n\n const handleAccept = useCallback(\n (v: Consent | \"implicit\") => {\n if (v === \"implicit\") {\n onAccept(\n convertBooleanConsentObjectToConsentObject(requirement),\n );\n } else {\n onAccept(v);\n }\n },\n [onAccept, requirement],\n );\n\n const [instance, modalConfig] = useModal({\n id: useId(\"jkl-cookie-modal\"),\n // The optional `role` attribute of the dialog element, either `dialog`\n // (default) or `alertdialog` to make it a modal (preventing closing on\n // click outside of ESC key).\n role: \"alertdialog\",\n // The required dialog title, mandatory in the document\n // to provide context to assistive technology.\n title: \"Informasjonskapsler\",\n });\n\n useEffect(() => {\n if (!instance) {\n return;\n }\n if (isOpen) {\n instance.show();\n } else {\n instance.hide();\n }\n }, [instance, isOpen]);\n\n if (typeof document === \"undefined\") {\n return null;\n }\n\n return ReactDOM.createPortal(\n <ModalContainer\n {...rest}\n {...modalConfig.container}\n data-testautoid=\"jkl-cookie-consent-modal\"\n >\n <ModalOverlay {...modalConfig.overlay} />\n {showSettings ? (\n <CustomConsents\n modalConfig={modalConfig}\n handleAccept={handleAccept}\n />\n ) : (\n <DefaultConsents\n modalConfig={modalConfig}\n handleAccept={handleAccept}\n />\n )}\n </ModalContainer>,\n document.body,\n );\n};\n"],"names":["CookieConsentModal","onAccept","rest","isOpen","requirement","showSettings","useCookieConsentState","handleAccept","useCallback","v","convertBooleanConsentObjectToConsentObject","instance","modalConfig","useModal","id","useId","role","title","useEffect","show","hide","document","ReactDOM","createPortal","jsxs","ModalContainer","container","children","jsx","ModalOverlay","overlay","CustomConsents","DefaultConsents","body"],"mappings":"2jBAWO,MAAMA,EAAoD,EAC7DC,SAAAA,KACGC,MAEG,MAAEC,OAAAA,EAAQC,YAAAA,EAAaC,aAAAA,GAAiBC,IAExCC,EAAeC,GAChBC,IAEOR,EADM,aAANQ,EAEIC,EAA2CN,GAGtCK,EAHiD,GAMlE,CAACR,EAAUG,KAGRO,EAAUC,GAAeC,EAAS,CACrCC,GAAIC,EAAM,oBAIVC,KAAM,cAGNC,MAAO,wBAcP,OAXJC,GAAU,KACDP,IAGDR,EACAQ,EAASQ,OAETR,EAASS,OAAK,GAEnB,CAACT,EAAUR,WAEHkB,SAAa,IACb,KAGJC,EAASC,aACZC,EAACC,EAAA,IACOvB,KACAU,EAAYc,UAChB,kBAAgB,2BAEhBC,SAAA,CAACC,EAAAC,EAAA,IAAiBjB,EAAYkB,UAE1BF,EADHvB,EACI0B,EAKAC,EALA,CACGpB,YAAAA,EACAL,aAAAA,OASZc,SAASY,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomConsents.js","sources":["../../../../../src/components/cookie-consent/consents/CustomConsents.tsx"],"sourcesContent":["import React, { FC, FormEvent, useCallback } from \"react\";\nimport { PrimaryButton } from \"../../button/Button.js\";\nimport { UnorderedList } from \"../../list/List.js\";\nimport { CheckListItem } from \"../../list/ListItem.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"CustomConsents.js","sources":["../../../../../src/components/cookie-consent/consents/CustomConsents.tsx"],"sourcesContent":["import React, { FC, FormEvent, useCallback } from \"react\";\nimport { PrimaryButton } from \"../../button/Button.js\";\nimport { UnorderedList } from \"../../list/List.js\";\nimport { CheckListItem } from \"../../list/ListItem.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalHeader,\n ModalTitle,\n} from \"../../modal/Modal.js\";\nimport { ModalConfig } from \"../../modal/useModal.js\";\nimport { useCookieConsentState } from \"../CookieConsentContext.js\";\nimport { convertBooleanConsentObjectToConsentObject } from \"../cookieConsentUtils.js\";\nimport { Consent } from \"../types.js\";\nimport { RequirementCheckbox } from \"./RequirementCheckbox.js\";\n\ntype Props = {\n modalConfig: ModalConfig;\n handleAccept: (v: Consent | \"implicit\") => void;\n};\n\nexport const CustomConsents: FC<Props> = ({ modalConfig, handleAccept }) => {\n const { consent, requirement } = useCookieConsentState();\n\n const onSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n\n const formValues: Partial<Record<keyof Consent, boolean>> = {};\n const requiredFormNames = Object.entries(requirement)\n .map(([name, required]) => (required ? name : undefined))\n .filter(Boolean) as Array<keyof Consent>;\n\n const formData = new FormData(event.target as HTMLFormElement);\n requiredFormNames.forEach((name) => {\n formValues[name] = formData.get(name) === \"True\";\n });\n\n handleAccept(\n convertBooleanConsentObjectToConsentObject(formValues),\n );\n },\n [handleAccept, requirement],\n );\n\n return (\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Informasjonskapsler\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <UnorderedList className=\"jkl-cookie-consent-modal__checklist\">\n <CheckListItem>\n Nettsidene skal fungere teknisk\n </CheckListItem>\n </UnorderedList>\n <p className=\"jkl-cookie-consent-modal__info-text\">\n For at nettsidene skal fungere, må vi bruke tekniske\n informasjonskapsler. Denne kan derfor ikke slås av.\n </p>\n {requirement.functional && (\n <RequirementCheckbox\n name=\"functional\"\n label=\"Tillat funksjonelle\"\n defaultChecked={consent.functional === \"accepted\"}\n >\n Funksjonelle informasjonskapsler lagrer opplysninger om\n din bruk av nettsidene og hvilke innstillinger du har\n gjort, slik at du kan få funksjonalitet tilpasset deg.\n </RequirementCheckbox>\n )}\n\n {requirement.statistics && (\n <RequirementCheckbox\n name=\"statistics\"\n label=\"Tillat statistikk\"\n defaultChecked={consent.statistics === \"accepted\"}\n >\n Informasjonskapslene lagrer statistikk som hjelper oss\n med å forstå hvordan nettsidene blir brukt, slik at vi\n kan gjøre dem bedre og enklere å bruke.\n </RequirementCheckbox>\n )}\n\n {requirement.marketing && (\n <RequirementCheckbox\n name=\"marketing\"\n label=\"Tillat personlig markedsføring\"\n defaultChecked={consent.marketing === \"accepted\"}\n >\n Dette gjør at vi kan gi deg mer relevant og tilpasset\n markedsføring, også gjennom våre samarbeidspartnere, på\n for eksempel nettsider, annonser og i sosiale medier.\n </RequirementCheckbox>\n )}\n </ModalBody>\n <ModalActions>\n <PrimaryButton data-testid=\"jkl-cookie-consent-godta\">\n Godta\n </PrimaryButton>\n </ModalActions>\n </Modal>\n );\n};\n"],"names":["CustomConsents","modalConfig","handleAccept","consent","requirement","useCookieConsentState","onSubmit","useCallback","event","preventDefault","formValues","requiredFormNames","Object","entries","map","name","required","filter","Boolean","formData","FormData","target","forEach","get","convertBooleanConsentObjectToConsentObject","jsxs","Modal","component","modal","children","jsx","ModalHeader","ModalTitle","title","ModalBody","UnorderedList","className","CheckListItem","functional","RequirementCheckbox","label","defaultChecked","statistics","marketing","ModalActions","PrimaryButton"],"mappings":"8jBAsBO,MAAMA,EAA4B,EAAGC,YAAAA,EAAaC,aAAAA,MAC/C,MAAEC,QAAAA,EAASC,YAAAA,GAAgBC,IAE3BC,EAAWC,GACZC,IACGA,EAAMC,iBAEAC,MAAAA,EAAsD,CAAA,EACtDC,EAAoBC,OAAOC,QAAQT,GACpCU,KAAI,EAAEC,EAAMC,KAAeA,EAAWD,OAAO,IAC7CE,OAAOC,SAENC,EAAW,IAAIC,SAASZ,EAAMa,QAClBV,EAAAW,SAASP,IACvBL,EAAWK,GAA+B,SAAvBI,EAASI,IAAIR,EAAU,IAG9Cb,EACIsB,EAA2Cd,GAAU,GAG7D,CAACR,EAAcE,IAIf,OAAAqB,EAACC,EAAM,CAAAC,UAAU,UAAW1B,EAAY2B,MAAatB,SAAAA,EACjDuB,SAAA,CAAAC,EAACC,GACGF,SAACC,EAAAE,EAAA,IAAe/B,EAAYgC,MAAOJ,qCAItCK,EACG,CAAAL,SAAA,CAAAC,EAACK,GAAcC,UAAU,sCACrBP,SAACC,EAAAO,EAAA,CAAcR,+CAIlBC,EAAA,IAAA,CAAEM,UAAU,sCAAsCP,SAGnD,6GACCzB,EAAYkC,YACTR,EAACS,EAAA,CACGxB,KAAK,aACLyB,MAAM,sBACNC,eAAuC,aAAvBtC,EAAQmC,WAC3BT,SAAA,yKAOJzB,EAAYsC,YACTZ,EAACS,EAAA,CACGxB,KAAK,aACLyB,MAAM,oBACNC,eAAuC,aAAvBtC,EAAQuC,WAC3Bb,SAAA,0JAOJzB,EAAYuC,WACTb,EAACS,EAAA,CACGxB,KAAK,YACLyB,MAAM,iCACNC,eAAsC,aAAtBtC,EAAQwC,UAC3Bd,SAAA,6KAORe,EACG,CAAAf,SAAAC,EAACe,GAAc,cAAY,2BAA2BhB,uBAI9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultConsents.js","sources":["../../../../../src/components/cookie-consent/consents/DefaultConsents.tsx"],"sourcesContent":["import React, { FC, FormEvent, useCallback } from \"react\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { UnorderedList } from \"../../list/List.js\";\nimport { CheckListItem } from \"../../list/ListItem.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"DefaultConsents.js","sources":["../../../../../src/components/cookie-consent/consents/DefaultConsents.tsx"],"sourcesContent":["import React, { FC, FormEvent, useCallback } from \"react\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { UnorderedList } from \"../../list/List.js\";\nimport { CheckListItem } from \"../../list/ListItem.js\";\nimport {\n Modal,\n ModalActions,\n ModalBody,\n ModalHeader,\n ModalTitle,\n} from \"../../modal/Modal.js\";\nimport { ModalConfig } from \"../../modal/useModal.js\";\nimport { useCookieConsentState } from \"../CookieConsentContext.js\";\nimport { Consent } from \"../types.js\";\n\ntype Props = {\n modalConfig: ModalConfig;\n handleAccept: (v: Consent | \"implicit\") => void;\n};\n\nexport const DefaultConsents: FC<Props> = ({ modalConfig, handleAccept }) => {\n const { dispatch, requirement } = useCookieConsentState();\n\n const onSubmit = useCallback(\n (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n handleAccept(\"implicit\");\n },\n [handleAccept],\n );\n\n return (\n <Modal component=\"form\" {...modalConfig.modal} {...{ onSubmit }}>\n <ModalHeader>\n <ModalTitle {...modalConfig.title}>\n Vi bruker informasjonskapsler slik at:\n </ModalTitle>\n </ModalHeader>\n <ModalBody>\n <UnorderedList className=\"jkl-cookie-consent-modal__checklist\">\n <CheckListItem>\n Nettsidene skal fungere teknisk\n </CheckListItem>\n {requirement.functional && (\n <CheckListItem>\n Nettsidene skal tilpasses din bruk, dine valg og\n dine innstillinger.\n </CheckListItem>\n )}\n {requirement.statistics && (\n <CheckListItem>\n Vi kan samle statistikk på hvordan nettsidene brukes\n og dermed kunne forbedre tjenestene våre.\n </CheckListItem>\n )}\n {requirement.marketing && (\n <CheckListItem>\n Vi kan gi deg personlig tilpasset innhold og\n relevante annonser, også gjennom våre\n samarbeidspartnere, på for eksempel nettsider og i\n sosiale medier.\n </CheckListItem>\n )}\n </UnorderedList>\n </ModalBody>\n <ModalActions>\n <PrimaryButton\n data-testid=\"jkl-cookie-consent-godta\"\n {...modalConfig.closeButton}\n type={\"submit\"}\n >\n Godta\n </PrimaryButton>\n\n <TertiaryButton\n type=\"button\"\n onClick={() => {\n dispatch({ type: \"SET_SHOW_SETTINGS\", payload: true });\n }}\n >\n Innstillinger\n </TertiaryButton>\n </ModalActions>\n </Modal>\n );\n};\n"],"names":["DefaultConsents","modalConfig","handleAccept","dispatch","requirement","useCookieConsentState","onSubmit","useCallback","event","preventDefault","jsxs","Modal","component","modal","children","jsx","ModalHeader","ModalTitle","title","ModalBody","UnorderedList","className","CheckListItem","functional","statistics","marketing","ModalActions","PrimaryButton","closeButton","type","TertiaryButton","onClick","payload"],"mappings":"6bAoBO,MAAMA,EAA6B,EAAGC,YAAAA,EAAaC,aAAAA,MAChD,MAAEC,SAAAA,EAAUC,YAAAA,GAAgBC,IAE5BC,EAAWC,GACZC,IACGA,EAAMC,iBACNP,EAAa,WAAU,GAE3B,CAACA,IAID,OAAAQ,EAACC,EAAM,CAAAC,UAAU,UAAWX,EAAYY,MAAaP,SAAAA,EACjDQ,SAAA,CAAAC,EAACC,GACGF,SAACC,EAAAE,EAAA,IAAehB,EAAYiB,MAAOJ,sDAItCC,EAAAI,EAAA,CACGL,SAACJ,EAAAU,EAAA,CAAcC,UAAU,sCACrBP,SAAA,CAAAC,EAACO,GAAcR,SAEf,oCACCV,EAAYmB,YACRR,EAAAO,EAAA,CAAcR,SAGf,yEAEHV,EAAYoB,YACRT,EAAAO,EAAA,CAAcR,SAGf,mGAEHV,EAAYqB,WACRV,EAAAO,EAAA,CAAcR,SAKf,iKAIXY,EACG,CAAAZ,SAAA,CAAAC,EAACY,EAAA,CACG,cAAY,8BACR1B,EAAY2B,YAChBC,KAAM,SACTf,SAAA,UAIDC,EAACe,EAAA,CACGD,KAAK,SACLE,QAAS,KACL5B,EAAS,CAAE0B,KAAM,oBAAqBG,SAAS,GAAM,EAE5DlB,SAAA,uBAIT"}
|
|
@@ -5,5 +5,5 @@ interface RequirementCheckboxProps extends WithChildren {
|
|
|
5
5
|
name: "functional" | "marketing" | "statistics";
|
|
6
6
|
label: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const RequirementCheckbox: ({ defaultChecked, name, label, children }: RequirementCheckboxProps) => React.JSX.Element;
|
|
8
|
+
export declare const RequirementCheckbox: ({ defaultChecked, name, label, children, }: RequirementCheckboxProps) => React.JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequirementCheckbox.js","sources":["../../../../../src/components/cookie-consent/consents/RequirementCheckbox.tsx"],"sourcesContent":["import React from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { Checkbox } from \"../../checkbox/Checkbox.js\";\n\ninterface RequirementCheckboxProps extends WithChildren {\n defaultChecked: boolean;\n name: \"functional\" | \"marketing\" | \"statistics\";\n label: string;\n}\n\nexport const RequirementCheckbox = ({
|
|
1
|
+
{"version":3,"file":"RequirementCheckbox.js","sources":["../../../../../src/components/cookie-consent/consents/RequirementCheckbox.tsx"],"sourcesContent":["import React from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { Checkbox } from \"../../checkbox/Checkbox.js\";\n\ninterface RequirementCheckboxProps extends WithChildren {\n defaultChecked: boolean;\n name: \"functional\" | \"marketing\" | \"statistics\";\n label: string;\n}\n\nexport const RequirementCheckbox = ({\n defaultChecked,\n name,\n label,\n children,\n}: RequirementCheckboxProps) => {\n return (\n <>\n <Checkbox\n className=\"jkl-cookie-consent-modal__checkbox\"\n value=\"True\"\n name={name}\n defaultChecked={defaultChecked}\n >\n {label}\n </Checkbox>\n <p className=\"jkl-cookie-consent-modal__info-text\">{children}</p>\n </>\n );\n};\n"],"names":["RequirementCheckbox","defaultChecked","name","label","children","jsxs","Fragment","jsx","Checkbox","className","value"],"mappings":"sHAUO,MAAMA,EAAsB,EAC/BC,eAAAA,EACAC,KAAAA,EACAC,MAAAA,EACAC,SAAAA,KAIQC,EAAAC,EAAA,CAAAF,SAAA,CAAAG,EAACC,EAAA,CACGC,UAAU,qCACVC,MAAM,OACNR,KAAAA,EACAD,eAAAA,EAECG,SAAAD,IAEJI,EAAA,IAAA,CAAEE,UAAU,sCAAuCL,SAAAA"}
|
|
@@ -16,7 +16,7 @@ export declare const convertConsentObjectToBooleans: (consent: Partial<Record<ke
|
|
|
16
16
|
};
|
|
17
17
|
export declare const convertBooleanToConsentValue: (formValue: boolean | undefined) => ConsentState;
|
|
18
18
|
export declare const convertBooleanConsentObjectToConsentObject: (consent: Partial<Record<keyof Consent, boolean | undefined>>) => Consent;
|
|
19
|
-
export declare const buildRequirementsObject: ({ marketing, functional, statistics }: ConsentRequirement) => {
|
|
19
|
+
export declare const buildRequirementsObject: ({ marketing, functional, statistics, }: ConsentRequirement) => {
|
|
20
20
|
statistics?: true | undefined;
|
|
21
21
|
functional?: true | undefined;
|
|
22
22
|
marketing?: true | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookieConsentUtils.js","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n `SameSite=Lax`,\n !!domain && `domain=${domain}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (requirement: ConsentRequirement
|
|
1
|
+
{"version":3,"file":"cookieConsentUtils.js","sources":["../../../../src/components/cookie-consent/cookieConsentUtils.ts"],"sourcesContent":["import type { Consent, ConsentRequirement, ConsentState } from \"./types.js\";\n\nconst getCookie = (name: string) => {\n if (typeof document === \"undefined\") {\n return undefined;\n }\n\n const cookie = document.cookie\n // split a string of cookies into array of cookies\n .split(\";\")\n // split cookies into [name, value]\n .map((s) => s.trim().split(\"=\"))\n // find our golden nugget\n .find((c) => c[0] === name);\n\n if (!cookie) {\n return undefined;\n }\n\n return cookie;\n};\n\nexport const getConsentCookie = ({\n adapter,\n name,\n}: {\n adapter?: () => Consent | undefined;\n name: string;\n}): Consent | undefined => {\n const cookie = getCookie(name);\n\n if (cookie) {\n const consent = JSON.parse(cookie[1]);\n\n return consent as Consent;\n }\n\n if (adapter) {\n return adapter();\n }\n\n return undefined;\n};\n\n// 120 days\nconst DEFAULT_MAX_AGE = 10368000;\n\nexport const setConsentCookie = ({\n consent,\n maxAge = DEFAULT_MAX_AGE,\n name,\n domain,\n}: {\n consent: Consent;\n maxAge?: number;\n name: string;\n domain?: string;\n}): void => {\n document.cookie = [\n `${name}=${JSON.stringify(consent)}`,\n `max-age=${maxAge}`,\n `SameSite=Lax`,\n !!domain && `domain=${domain}`,\n ]\n .filter((f) => f)\n .join(\";\");\n};\n\nexport const shouldShowConsentDialog = (\n requirement: ConsentRequirement,\n consent: Consent | undefined,\n): boolean => {\n if (!consent) {\n // check if requirement has truthy values. should show consent if it has\n return Object.values(requirement).some(\n (requirementValue) => requirementValue,\n );\n } else {\n // convert to a map to ease accessing dynamic keys\n const consentMap = new Map(Object.entries(consent));\n\n // pls spare the CPU of converting to an entries array 3 times\n const requirementEntries = Object.entries(requirement);\n\n for (const [name, required] of requirementEntries) {\n // no need to check more if the value isn't required\n if (!required) {\n continue;\n }\n\n // cancel and show consent if a value isn't decided\n if (consentMap.get(name) === null) {\n return true;\n }\n }\n\n return false;\n }\n};\n\nexport const convertConsentValueToFormValue = (\n consent: ConsentState,\n): boolean | undefined => {\n if (!consent) {\n return undefined;\n }\n\n if (consent === \"denied\") {\n return false;\n }\n\n return true;\n};\n\nexport const convertConsentObjectToBooleans = (\n consent: Partial<Record<keyof Consent, ConsentState>>,\n): { [k: string]: boolean | undefined } => {\n const defaultConsent = {\n functional: null,\n marketing: null,\n statistics: null,\n };\n\n const consentEntries: Array<[string, boolean | undefined]> = Object.entries(\n { ...defaultConsent, ...consent },\n ).map(([consentName, value]) => [\n consentName,\n convertConsentValueToFormValue(value),\n ]);\n return Object.fromEntries(consentEntries);\n};\n\nexport const convertBooleanToConsentValue = (\n formValue: boolean | undefined,\n): ConsentState => {\n if (typeof formValue === \"undefined\") {\n return null;\n }\n\n if (formValue === false || String(formValue).toLowerCase() === \"false\") {\n return \"denied\";\n }\n\n return \"accepted\";\n};\n\nexport const convertBooleanConsentObjectToConsentObject = (\n consent: Partial<Record<keyof Consent, boolean | undefined>>,\n): Consent => {\n const defaultObject = {\n functional: undefined,\n marketing: undefined,\n statistics: undefined,\n };\n\n const consentEntries = Object.entries({ ...defaultObject, ...consent }).map(\n ([consentName, value]) => [\n consentName,\n convertBooleanToConsentValue(value),\n ],\n );\n\n return Object.fromEntries(consentEntries);\n};\n\nexport const buildRequirementsObject = ({\n marketing,\n functional,\n statistics,\n}: ConsentRequirement) => {\n return {\n ...(marketing && { marketing }),\n ...(functional && { functional }),\n ...(statistics && { statistics }),\n };\n};\n"],"names":["getConsentCookie","adapter","name","cookie","document","split","map","s","trim","find","c","getCookie","JSON","parse","setConsentCookie","consent","maxAge","domain","stringify","filter","f","join","shouldShowConsentDialog","requirement","consentMap","Map","Object","entries","requirementEntries","required","get","values","some","requirementValue","convertConsentValueToFormValue","convertConsentObjectToBooleans","consentEntries","functional","marketing","statistics","consentName","value","fromEntries","convertBooleanToConsentValue","formValue","String","toLowerCase","convertBooleanConsentObjectToConsentObject","buildRequirementsObject"],"mappings":"AAEA,MAoBaA,EAAmB,EAC5BC,QAAAA,EACAC,KAAAA,MAKMC,MAAAA,EA3BQ,CAACD,IACX,UAAOE,SAAa,IACb,OAGLD,MAAAA,EAASC,SAASD,OAEnBE,MAAM,KAENC,KAAKC,GAAMA,EAAEC,OAAOH,MAAM,OAE1BI,MAAMC,GAAMA,EAAE,KAAOR,IAErBC,OAAAA,QAAAA,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A,WAAAA,MAChBE,GAAc,CAAEA,WAAAA"}
|
|
@@ -2,4 +2,4 @@ export type { AcceptConsentCallback, Consent, ConsentState } from './types.js';
|
|
|
2
2
|
export type { CookieConsentProps } from './CookieConsent.js';
|
|
3
3
|
export { CookieConsent } from './CookieConsent.js';
|
|
4
4
|
export type { CookieConsentProviderProps } from './CookieConsentContext.js';
|
|
5
|
-
export { CookieConsentProvider, useCookieConsent } from './CookieConsentContext.js';
|
|
5
|
+
export { CookieConsentProvider, useCookieConsent, } from './CookieConsentContext.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { startOfDay } from \"date-fns\";\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 { CalendarIcon } from \"../icon/index.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport Popover from \"../popover/Popover.js\";\nimport { BaseTextInput } from \"../text-input/BaseTextInput.js\";\nimport { Calendar } from \"./internal/Calendar.js\";\nimport { DateInfo, getInitialDate } from \"./internal/utils.js\";\nimport { DatePickerProps, DateValidationError } from \"./types.js\";\nimport { formatInput, parseDateString } from \"./utils.js\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation.js\";\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\n const calendarRef = useRef<HTMLDivElement>(null);\n const datepickerRef = useRef<HTMLDivElement>(null);\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 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 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 // Make sure the popover-modal is correctly positioned before focusing a button\n // so we avoid accidentally scrolling to the top of the page\n window.requestAnimationFrame(() => button && button.focus());\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\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 return (\n <InputGroup\n id={id}\n className={clsx(\"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 <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 onChange={handleChange}\n actionButton={\n <Popover\n positionReference={inputRef}\n open={showCalendar}\n onOpenChange={() => setShowCalendar(!showCalendar)}\n offset={8}\n >\n <Popover.Trigger\n {...action}\n data-testid=\"jkl-datepicker__trigger\"\n className=\"jkl-text-input-action-button\"\n title={showCalendar ? hideCalendarLabel : showCalendarLabel}\n tabIndex={0}\n onClick={clickCalendar}\n onKeyDown={handleKeyDownAction}\n asChild\n >\n <IconButton>\n <CalendarIcon />\n </IconButton>\n </Popover.Trigger>\n <Popover.Content initialFocus={-1} padding={24}>\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 onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </Popover.Content>\n </Popover>\n }\n {...inputProps}\n />\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","useRef","datepickerRef","iconButtonRef","inputRef","unifiedInputRef","useCallback","instance","current","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","window","requestAnimationFrame","focus","onClick","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","jsx","InputGroup","clsx","ref","render","inputProps","BaseTextInput","type","actionButton","jsxs","Popover","positionReference","open","onOpenChange","offset","children","Trigger","title","tabIndex","asChild","IconButton","CalendarIcon","Content","initialFocus","padding","Calendar","onDateSelected","onTabOutside","displayName"],"mappings":"yiEAwBO,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,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,iBACFlB,IAAgB,GACFI,GAAAK,SAAWL,GAAcK,QAAQwB,OAAM,GAEzD,CAACjC,KAID,OAAA4C,EAACC,EAAA,CACG9F,GAAAA,EACAC,UAAW8F,EAAK,iBAAkB9F,EAAW,CACzC,uBAAwB+C,QAExBhB,EACJgE,IAAK5C,GACLlD,MAAAA,EACAC,WAAAA,EACAa,QAAAA,EACAH,UAAAA,EACAC,WAAAA,EACAgB,kBAAAA,EACAC,aAAAA,EACAkE,OAASC,GACLL,EAACM,EAAA,CACGH,IAAKzC,GACL,cAAY,wBACZ,kBAAiBxD,EACjBE,UAAU,wBACVW,KAAAA,EACAR,aAAAA,EACAY,QAAAA,EACAV,MAAAA,EACA8F,KAAK,OACL/E,YAAAA,EACAC,MAAAA,EACAG,QAASkC,GACTnC,OAAQwC,GACRzC,SAAU8C,GACVgC,aACIC,EAACC,EAAA,CACGC,kBAAmBlD,GACnBmD,KAAMzD,GACN0D,aAAc,IAAMzD,IAAiBD,IACrC2D,OAAQ,EAERC,SAAA,CAAAf,EAACU,EAAQM,QAAR,IACOlF,EACJ,cAAY,0BACZ1B,UAAU,+BACV6G,MAAO9D,GAAenB,EAAoBD,EAC1CmF,SAAU,EACV5B,QAASR,GACTjD,UAAWuC,GACX+C,SAAO,EAEPJ,SAACf,EAAAoB,EAAA,CACGL,SAACf,EAAAqB,EAAA,CAAa,SAGrBX,EAAQY,QAAR,CAAgBC,cAAkB,EAAAC,QAAS,GACxCT,SAAAf,EAACyB,EAAA,CACGtB,IAAK9C,GACLlC,QAAAA,EACA0B,KAAAA,GACAH,QAAAA,GACAE,QAAAA,GACAxB,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAT,YAAAA,EACA4G,eAAgBnC,GAChBoC,aAAc5B,aAK1BM,KACR,IAMhBvG,EAAW8H,YAAc"}
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sources":["../../../../src/components/datepicker/DatePicker.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { startOfDay } from \"date-fns\";\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 { CalendarIcon } from \"../icon/index.js\";\nimport { IconButton } from \"../icon-button/IconButton.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport Popover from \"../popover/Popover.js\";\nimport { BaseTextInput } from \"../text-input/BaseTextInput.js\";\nimport { Calendar } from \"./internal/Calendar.js\";\nimport { DateInfo, getInitialDate } from \"./internal/utils.js\";\nimport { DatePickerProps, DateValidationError } from \"./types.js\";\nimport { formatInput, parseDateString } from \"./utils.js\";\nimport { isWithinLowerBound, isWithinUpperBound } from \"./validation.js\";\n\nexport const DatePicker = forwardRef<HTMLInputElement, DatePickerProps>(\n (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\n ? startOfDay(disableBeforeDate)\n : undefined;\n const disableAfterDate = parseDateString(disableAfter);\n const maxDate = disableAfterDate\n ? startOfDay(disableAfterDate)\n : undefined;\n\n const [date, setDate] = useState(\n getInitialDate(value, defaultValue, minDate, maxDate),\n );\n const [error, setError] = useState<DateValidationError | null>(null);\n\n /// Calendar state\n\n const [showCalendar, setShowCalendar] = useState(defaultShow);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n const datepickerRef = useRef<HTMLDivElement>(null);\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 handleFocus = useCallback(\n (e: FocusEvent<HTMLInputElement>) => {\n if (!onFocus || !datepickerRef.current) {\n return;\n }\n\n const nextFocusIsInside = datepickerRef.current.contains(\n e.relatedTarget as Node,\n );\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 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, {\n error: nextError,\n value: e.target.value,\n });\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 =\n calendarEl &&\n (calendarEl.querySelector(\n '[aria-pressed=\"true\"]',\n ) as HTMLButtonElement);\n // Make sure the popover-modal is correctly positioned before focusing a button\n // so we avoid accidentally scrolling to the top of the page\n window.requestAnimationFrame(() => button && button.focus());\n\n if (action?.onClick) {\n action.onClick(e);\n }\n },\n [setShowCalendar, showCalendar, action, calendarRef],\n );\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(\n event as unknown as ChangeEvent<HTMLInputElement>,\n date,\n {\n error: null,\n value: node.value,\n },\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 return (\n <InputGroup\n id={id}\n className={clsx(\"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 <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 onChange={handleChange}\n actionButton={\n <Popover\n positionReference={inputRef}\n open={showCalendar}\n onOpenChange={() =>\n setShowCalendar(!showCalendar)\n }\n offset={8}\n >\n <Popover.Trigger\n {...action}\n data-testid=\"jkl-datepicker__trigger\"\n className=\"jkl-text-input-action-button\"\n title={\n showCalendar\n ? hideCalendarLabel\n : showCalendarLabel\n }\n tabIndex={0}\n onClick={clickCalendar}\n onKeyDown={handleKeyDownAction}\n asChild\n >\n <IconButton>\n <CalendarIcon />\n </IconButton>\n </Popover.Trigger>\n <Popover.Content initialFocus={-1} padding={24}>\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 onDateSelected={handleClickCalendarDay}\n onTabOutside={handleTabOutsideCalendar}\n />\n </Popover.Content>\n </Popover>\n }\n {...inputProps}\n />\n )}\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","useRef","datepickerRef","iconButtonRef","inputRef","unifiedInputRef","useCallback","instance","current","handleFocus","e","contains","relatedTarget","target","handleBlur","handleKeyDownAction","key","preventDefault","stopPropagation","handleChange","nextDate","nextError","val","isWithinLowerBound","isWithinUpperBound","clickCalendar","flushSync","calendarEl","button","querySelector","window","requestAnimationFrame","focus","onClick","handleClickCalendarDay","node","formatInput","event","document","createEvent","initEvent","dispatchEvent","handleTabOutsideCalendar","jsx","InputGroup","clsx","ref","render","inputProps","BaseTextInput","type","actionButton","jsxs","Popover","positionReference","open","onOpenChange","offset","children","Trigger","title","tabIndex","asChild","IconButton","CalendarIcon","Content","initialFocus","padding","Calendar","onDateSelected","onTabOutside","displayName"],"mappings":"yiEAwBO,MAAMA,EAAaC,GACtB,CAACC,EAAOC,KACE,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,EACAC,kBAAAA,EAAoB,gBACpBC,kBAAAA,EAAoB,gBACpBC,kBAAAA,EACAC,aAAAA,KACGC,GACHnC,EAEyB,eAAzBoC,QAAQC,IAAIC,UAA6B7B,GAASF,GAC1CgC,QAAAC,KACJ,sIAKF9B,MAAAA,EAAoB+B,EAAgB9B,GACpC+B,GAAUhC,EACViC,EAAWjC,QACX,EACAE,GAAmB6B,EAAgB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EACAY,QAAAA,EACAV,MAAAA,EACA8F,KAAK,OACL/E,YAAAA,EACAC,MAAAA,EACAG,QAASkC,GACTnC,OAAQwC,GACRzC,SAAU8C,GACVgC,aACIC,EAACC,EAAA,CACGC,kBAAmBlD,GACnBmD,KAAMzD,GACN0D,aAAc,IACVzD,IAAiBD,IAErB2D,OAAQ,EAERC,SAAA,CAAAf,EAACU,EAAQM,QAAR,IACOlF,EACJ,cAAY,0BACZ1B,UAAU,+BACV6G,MACI9D,GACMnB,EACAD,EAEVmF,SAAU,EACV5B,QAASR,GACTjD,UAAWuC,GACX+C,SAAO,EAEPJ,SAACf,EAAAoB,EAAA,CACGL,SAACf,EAAAqB,EAAA,CAAa,SAGrBX,EAAQY,QAAR,CAAgBC,cAAkB,EAAAC,QAAS,GACxCT,SAAAf,EAACyB,EAAA,CACGtB,IAAK9C,GACLlC,QAAAA,EACA0B,KAAAA,GACAH,QAAAA,GACAE,QAAAA,GACAxB,KAAAA,EACAC,OAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAT,YAAAA,EACA4G,eAAgBnC,GAChBoC,aAAc5B,aAK1BM,KACR,IAOpBvG,EAAW8H,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","sources":["../../../../../src/components/datepicker/internal/Calendar.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useReducer, useRef } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Density } from \"../../../core/types.js\";\nimport { useId } from \"../../../hooks/useId/useId.js\";\nimport { ArrowLeftIcon, ArrowRightIcon, ChevronDownIcon } from \"../../icon/index.js\";\nimport { YearsToShow } from \"../types.js\";\nimport { calendarInitializer, calendarReducer } from \"./calendarReducer.js\";\nimport { useCalendar, UseCalendarProps } from \"./useCalendar.js\";\nimport {\n addMonth,\n DateInfo,\n DEFAULT_YEARS_TO_SHOW,\n getInitialDateShown,\n getMonthSelectOptions,\n getYearSelectOptions,\n isBackDisabled,\n isForwardDisabled,\n subtractMonth,\n} from \"./utils.js\";\n\ninterface CalendarProps\n extends Omit<UseCalendarProps, \"date\" | \"onOffsetChanged\" | \"offset\" | \"firstDayOfWeek\" | \"selected\"> {\n date: Date | null;\n density?: Density;\n defaultSelected?: Date;\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 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 ref={ref} id={id} className=\"jkl-calendar\" data-testid=\"jkl-calendar\">\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","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","children","jsxs","onKeyDown","onClick","ArrowLeftIcon","variant","bold","ArrowRightIcon","onChange","map","label","ChevronDownIcon","calendar","month","weekday","weeks","week","weekIndex","index","today","dateObj","tabIndex","toLowerCase","disabled","displayName"],"mappings":"gjEAiCA,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,KAAAA,EACAC,gBAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EAAOV,EACPW,OAAAA,EAASZ,EACTa,WAAAA,EAAa,aACbC,UAAAA,EAAY,UACZC,YAAAA,EAAcC,EACdC,aAAAA,KACGC,GACHd,EAEEe,EAAKC,EAAM,kBAERC,OAAAA,EAAQC,aAAAA,EAAcC,UAAAA,GAAaC,GAAYC,EACpDC,EACAC,EAAoBrB,EAAMC,EAAiBE,EAASC,GACpDkB,GAGEC,EAAaN,EAAUO,WACvBC,EAAYR,EAAUS,cAE5BC,GAAU,KACGT,EAAA,CACLU,KAAM,oBACNC,QAASR,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AEZC,SAAA,CAACC,EAAA,UAAA,CAAQF,UAAU,cACdC,SAAA,CAAAlG,EAAO8G,EAASC,OAAO,KAAGD,EAAS5B,QAExCc,EAAC,SACGE,SAACF,EAAA,KAAA,CACIE,WAAKS,KAAKK,GACPhB,EAAC,KAAwD,CAAAE,SAAAc,GAAhD,GAAGF,EAASC,QAAQD,EAAS5B,OAAO8B,aAIxD,QAAM,CAAA,cAAY,uBACdd,SAAAY,EAASG,MAAMN,KAAI,CAACO,EAAMC,MACtB,KACI,CAAAjB,SAAAgB,EAAKP,KAAI,CAACnC,EAAU4C,KACXrD,MAAAA,EAAM,GAAG+C,EAASC,QAAQD,EAAS5B,OAAOiC,IAAYC,IACxD,GAAoB,iBAAb5C,EAEF,OAAAwB,EAAA,KAAA,CAAGC,UAAU,+CACTC,YAD6DnC,GAKpE,MAAErE,KAAAA,EAAM+E,WAAAA,EAAY4C,MAAAA,EAAO3C,UAAAA,EAAWC,UAAAA,GAAcH,EAE1D,SACK,KACG,CAAA0B,SAAAF,EAAC,SAAA,IACOnE,EAAa,CACbyF,QAAS9C,IAEblD,KAAK,SACL2E,UAAU,2BACVsB,SAAUhD,GAAgBC,GAAY,GAAI,EAC1C,aAAY,GAAG9E,EAAKmF,cAAc7E,EAC9BN,EAAKwB,YACPsG,gBACF,eAAcH,EAAQ,YAAS,EAC/B,gBAAe3C,GAAaC,EAAY,YAAS,EACjD8C,UAAWhD,EACX2B,UAAWvC,EAEXqC,WAAC,OAAK,CAAA,cAAY,OAAQA,SAAAxG,EAAKmF,eAhB9Bd,EAkBT,KA/BH,GAAG+C,EAASC,QAAQD,EAAS5B,OAAOiC,WAfhD,GAAGL,EAASC,QAAQD,EAAS5B,cAuDlD,IAIR5F,EAASoI,YAAc"}
|
|
1
|
+
{"version":3,"file":"Calendar.js","sources":["../../../../../src/components/datepicker/internal/Calendar.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useReducer,\n useRef,\n} from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { Density } from \"../../../core/types.js\";\nimport { useId } from \"../../../hooks/useId/useId.js\";\nimport {\n ArrowLeftIcon,\n ArrowRightIcon,\n ChevronDownIcon,\n} from \"../../icon/index.js\";\nimport { YearsToShow } from \"../types.js\";\nimport { calendarInitializer, calendarReducer } from \"./calendarReducer.js\";\nimport { useCalendar, UseCalendarProps } from \"./useCalendar.js\";\nimport {\n addMonth,\n DateInfo,\n DEFAULT_YEARS_TO_SHOW,\n getInitialDateShown,\n getMonthSelectOptions,\n getYearSelectOptions,\n isBackDisabled,\n isForwardDisabled,\n subtractMonth,\n} from \"./utils.js\";\n\ninterface CalendarProps\n extends Omit<\n UseCalendarProps,\n \"date\" | \"onOffsetChanged\" | \"offset\" | \"firstDayOfWeek\" | \"selected\"\n > {\n date: Date | null;\n density?: Density;\n defaultSelected?: Date;\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>(\n (props, ref) => {\n const {\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(\n date,\n defaultSelected,\n minDate,\n maxDate,\n ),\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 {\n calendars,\n getBackProps,\n getDateProps,\n getForwardProps,\n handleOffsetChanged,\n } = 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 =\n 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 (\n newNodeKey <= buttons.length - 1 &&\n newNodeKey >= 0\n ) {\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(\n offset -\n subtractMonth({\n calendars,\n offset: 1,\n minDate,\n }),\n );\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons =\n 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(\n newButtons[newButtons.length + newNodeKey],\n );\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(\n offset +\n addMonth({\n calendars,\n offset: 1,\n maxDate,\n }),\n );\n });\n if (!calendarPaddingRef.current) {\n return;\n }\n const newButtons =\n 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(\n newButtons[newNodeKey - buttons.length],\n );\n }\n }\n }\n });\n },\n [\n handleOffsetChanged,\n calendarPaddingRef,\n offset,\n calendars,\n maxDate,\n minDate,\n ],\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(\n (event) => {\n if (event.key !== \"Tab\") return;\n\n const focusableElements =\n 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 =\n focusableElements[focusableElements.length - 1];\n\n if (!event.shiftKey && document.activeElement === lastElement) {\n firstElement.focus();\n event.preventDefault();\n } else if (\n event.shiftKey &&\n document.activeElement === firstElement\n ) {\n lastElement.focus();\n event.preventDefault();\n }\n },\n [],\n );\n\n const isFocusableDate = useCallback(\n (dateInfo: DateInfo) => {\n const { date, selected, selectable, prevMonth, nextMonth } =\n 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\n .querySelectorAll<HTMLButtonElement>(\n \".jkl-calendar-navigation__arrow\",\n )[1]\n .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\n .querySelectorAll<HTMLButtonElement>(\n \".jkl-calendar-navigation__arrow\",\n )[0]\n .focus();\n }\n }, [minDate, maxDate, shownDate]);\n\n /// Extended variant events\n\n const handleYearChange = useCallback<\n React.ChangeEventHandler<HTMLSelectElement>\n >(\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(\n shownDate.getFullYear(),\n shownDate.getMonth() + offset,\n shownDate.getDate(),\n );\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<\n React.ChangeEventHandler<HTMLSelectElement>\n >(\n (event) => {\n if (!selectedDate && !date) {\n return;\n }\n\n const yearDiff =\n shownDate.getFullYear() -\n (selectedDate || new Date()).getFullYear();\n const monthDiff =\n Number.parseInt(event.target.value) -\n (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(\n shownYear,\n minDate,\n maxDate,\n yearsToShow,\n );\n const monthSelectOptions = getMonthSelectOptions(\n shownYear,\n months,\n minDate,\n maxDate,\n );\n\n return (\n <div\n ref={ref}\n id={id}\n className=\"jkl-calendar\"\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\n className=\"jkl-calendar__padding\"\n ref={calendarPaddingRef}\n onKeyDown={handleTabInside}\n >\n <fieldset className=\"jkl-calendar-navigation\">\n <div>\n <button\n {...getBackProps({\n calendars,\n onClick: handleGotoEdgeMonth,\n })}\n className=\"jkl-calendar-navigation__arrow\"\n type=\"button\"\n >\n <ArrowLeftIcon variant=\"medium\" bold />\n </button>\n <button\n {...getForwardProps({\n calendars,\n onClick: handleGotoEdgeMonth,\n })}\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(\n ({ label, value }) => (\n <option key={value} value={value}>\n {label}\n </option>\n ),\n )}\n </select>\n <ChevronDownIcon\n bold\n className=\"jkl-calendar-navigation-dropdown__chevron\"\n />\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\n bold\n className=\"jkl-calendar-navigation-dropdown__chevron\"\n />\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\n key={`${calendar.month}${calendar.year}${weekday}`}\n >\n {weekday}\n </th>\n ))}\n </tr>\n </thead>\n <tbody data-testid=\"jkl-datepicker-dates\">\n {calendar.weeks.map((week, weekIndex) => (\n <tr\n key={`${calendar.month}${calendar.year}${weekIndex}`}\n >\n {week.map((dateInfo, index) => {\n const key = `${calendar.month}${calendar.year}${weekIndex}${index}`;\n if (typeof dateInfo === \"string\") {\n return (\n <td\n className=\"jkl-calendar__date jkl-calendar__date--empty\"\n key={key}\n >\n {dateInfo}\n </td>\n );\n }\n const {\n date,\n selectable,\n today,\n prevMonth,\n nextMonth,\n } = 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={\n isFocusableDate(\n dateInfo,\n )\n ? 0\n : -1\n }\n aria-label={`${date.getDate()}. ${months[\n date.getMonth()\n ].toLowerCase()}`}\n aria-current={\n today\n ? \"date\"\n : undefined\n }\n data-adjacent={\n prevMonth ||\n nextMonth\n ? \"true\"\n : undefined\n }\n disabled={!selectable}\n onKeyDown={\n handleArrowNavigation\n }\n >\n <span aria-hidden=\"true\">\n {date.getDate()}\n </span>\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n ))}\n </div>\n </div>\n );\n },\n);\n\nCalendar.displayName = \"Calendar\";\n"],"names":["defaultMonths","defaultDays","Calendar","forwardRef","props","ref","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","children","jsxs","onKeyDown","onClick","ArrowLeftIcon","variant","bold","ArrowRightIcon","onChange","map","label","ChevronDownIcon","calendar","month","weekday","weeks","week","weekIndex","index","today","dateObj","tabIndex","toLowerCase","disabled","displayName"],"mappings":"gjEA8CA,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,GACpB,CAACC,EAAOC,KACE,MACFC,KAAAA,EACAC,gBAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,QAAAA,EACAC,KAAAA,EAAOV,EACPW,OAAAA,EAASZ,EACTa,WAAAA,EAAa,aACbC,UAAAA,EAAY,UACZC,YAAAA,EAAcC,EACdC,aAAAA,KACGC,GACHd,EAEEe,EAAKC,EAAM,kBAERC,OAAAA,EAAQC,aAAAA,EAAcC,UAAAA,GAAaC,GAAYC,EACpDC,EACAC,EAAoBrB,EAAMC,EAAiBE,EAASC,GACpDkB,GAGEC,EAAaN,EAAUO,WACvBC,EAAYR,EAAUS,cAE5BC,GAAU,KACGT,EAAA,CACLU,KAAM,oBACNC,QAASR,EACLrB,EACAC,EACAE,EACAC,IAEP,GACF,CAACJ,EAAMC,EAAiBE,EAASC,IAE9B0B,MAAAA,EAAkBC,GAAaC,IACxBd,EAAA,CACLU,KAAM,aACNI,UAAAA,GACH,GACF,KAGCC,UAAAA,EACAC,aAAAA,EACAC,aAAAA,EACAC,gBAAAA,EACAC,oBAAAA,GACAC,EAAY,CACZtC,KAAMgB,EACNuB,SAAUvB,EACVb,QAAAA,EACAC,QAAAA,EACAW,OAAAA,EACAe,gBAAAA,EACAU,eAAgB,KACb5B,IAKD6B,EAAqBC,EAAuB,MAC5CC,EAAgBZ,GACjBa,IACO,IAACH,EAAmBI,QACpB,OAGJ,MAAMC,EAAIC,SAASC,cACbC,EACFR,EAAmBI,QAAQK,iBACvB,8DAGFC,EAAgBC,MAAOC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,EACAC,UAAAA,GACAH,EAEJ,SACK,KACG,CAAA0B,SAAAF,EAAC,SAAA,IACOnE,EAAa,CACbyF,QAAS9C,IAEblD,KAAK,SACL2E,UAAU,2BACVsB,SACIhD,GACIC,GAEE,GACA,EAEV,aAAY,GAAG9E,EAAKmF,cAAc7E,EAC9BN,EAAKwB,YACPsG,gBACF,eACIH,EACM,YACA,EAEV,gBACI3C,GACAC,EACM,YACA,EAEV8C,UAAWhD,EACX2B,UACIvC,EAGJqC,WAAC,OAAK,CAAA,cAAY,OACbA,SAAAxG,EAAKmF,eAlCTd,EAqCT,KA5DH,GAAG+C,EAASC,QAAQD,EAAS5B,OAAOiC,WApBhD,GAAGL,EAASC,QAAQD,EAAS5B,cAwF9C,IAMhB5F,EAASoI,YAAc"}
|
|
@@ -1 +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
|
|
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> = (\n currentState,\n action,\n) => {\n let shownDate: Date;\n\n switch (action.type) {\n case \"SET_OFFSET\":\n shownDate = new Date(currentState.selectedDate);\n shownDate.setMonth(\n currentState.selectedDate.getMonth() + action.newOffset,\n );\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(\n currentState.selectedDate.getMonth() +\n currentState.offset +\n action.addedOffset,\n );\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,CACnEC,EACAC,KAEIC,IAAAA,EAEJ,OAAQD,EAAOE,MACX,IAAK,aACW,OAAAD,EAAA,IAAIE,KAAKJ,EAAaK,cACxBH,EAAAI,SACNN,EAAaK,aAAaE,WAAaN,EAAOO,WAG3C,IACAR,EACHS,OAAQR,EAAOO,UACfN,UAAAA,GAGR,IAAK,aACW,OAAAA,EAAA,IAAIE,KAAKJ,EAAaK,cACxBH,EAAAI,SACNN,EAAaK,aAAaE,WACtBP,EAAaS,OACbR,EAAOS,aAGR,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"}
|
|
@@ -1 +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\";\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.js\";\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
|
|
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\";\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.js\";\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(\n onDateSelected: BoundGetDateProps,\n { onClick, dateObj }: GetDateProps,\n): 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(\n offsetMonth - subtractMonth({ calendars, offset, minDate }),\n );\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(\n offsetMonth + addMonth({ calendars, offset, maxDate }),\n );\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 = (\n props: GetForwardProps,\n) => 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":"uNAoCA,SAASA,EAAmBC,GACxB,YAAsB,IAAfA,CACX,CAoBA,SAASC,EACLC,GACEC,QAAAA,EAASC,QAAAA,IAEJ,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,EACID,EAAcK,EAAc,CAAEF,UAAAA,EAAWD,OAAAA,EAAQH,QAAAA,IAAS,IAGlEL,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,EACID,EAAcU,EAAS,CAAEP,UAAAA,EAAWD,OAAAA,EAAQO,QAAAA,IAAS,IAG7Df,SAAUiB,EAAkB,CAAER,UAAAA,EAAWM,QAAAA,IACzC,aAAcL,EACdG,MAAOH,EAEf,CA8BO,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,EAjJV,SAAmBuB,EAAcC,GACtBtC,OAAAA,EAAmBqC,GAAQA,EAAOC,CAC7C,CA+IwBC,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"}
|
|
@@ -58,7 +58,7 @@ export declare function addMonth({ calendars, offset, maxDate, }: {
|
|
|
58
58
|
* @param {Date} param.minDate The earliest date available
|
|
59
59
|
* @returns {Boolean} Whether the back button should be disabled.
|
|
60
60
|
*/
|
|
61
|
-
export declare function isBackDisabled({ calendars, minDate }: {
|
|
61
|
+
export declare function isBackDisabled({ calendars, minDate, }: {
|
|
62
62
|
calendars: CalendarMonth[];
|
|
63
63
|
minDate?: Date;
|
|
64
64
|
}): boolean;
|
|
@@ -70,7 +70,7 @@ export declare function isBackDisabled({ calendars, minDate }: {
|
|
|
70
70
|
* @param {Date} param.maxDate The furthest date available
|
|
71
71
|
* @returns {Boolean} Whether the forward button should be disabled.
|
|
72
72
|
*/
|
|
73
|
-
export declare function isForwardDisabled({ calendars, maxDate }: {
|
|
73
|
+
export declare function isForwardDisabled({ calendars, maxDate, }: {
|
|
74
74
|
calendars: CalendarMonth[];
|
|
75
75
|
maxDate?: Date;
|
|
76
76
|
}): boolean;
|