@fremtind/jokul 0.43.0 → 0.43.1
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/README.md +4 -16
- package/build/build-stats.html +1 -1
- package/build/cjs/components/accordion/AccordionItem.cjs.map +1 -1
- package/build/cjs/components/autosuggest/Autosuggest.cjs +1 -1
- package/build/cjs/components/autosuggest/Autosuggest.cjs.map +1 -1
- package/build/cjs/components/autosuggest/BaseAutosuggest.cjs +2 -2
- package/build/cjs/components/autosuggest/BaseAutosuggest.cjs.map +1 -1
- package/build/cjs/components/autosuggest/ControllerButton.cjs.map +1 -1
- package/build/cjs/components/autosuggest/utils.cjs.map +1 -1
- package/build/cjs/components/breadcrumb/Breadcrumb.cjs.map +1 -1
- package/build/cjs/components/button/Button.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/NavCard.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/cookie-consent/CookieConsent.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/CookieConsentContext.cjs.map +1 -1
- package/build/cjs/components/cookie-consent/cookieConsentUtils.cjs.map +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/expander/ExpandablePanel.cjs.map +1 -1
- package/build/cjs/components/expander/ExpandablePanelContent.cjs.map +1 -1
- package/build/cjs/components/expander/Expander.cjs.map +1 -1
- package/build/cjs/components/expander/deprecated/ExpandSection.cjs.map +1 -1
- package/build/cjs/components/expander/deprecated/Expander.cjs.map +1 -1
- package/build/cjs/components/feedback/Feedback.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/useFollowup.cjs.map +1 -1
- package/build/cjs/components/feedback/main-question/MainQuestion.cjs.map +1 -1
- package/build/cjs/components/feedback/main-question/useMainQuestion.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/file-input/File.cjs.map +1 -1
- package/build/cjs/components/file-input/FileInput.cjs.map +1 -1
- package/build/cjs/components/file-input/internal/Dropzone.cjs.map +1 -1
- package/build/cjs/components/file-input/internal/Input.cjs.map +1 -1
- package/build/cjs/components/file-input/internal/fileInputContext.cjs.map +1 -1
- package/build/cjs/components/file-input/internal/validateFile.cjs.map +1 -1
- package/build/cjs/components/flex/Flex.cjs.map +1 -1
- package/build/cjs/components/icon/icons/GreenCheckIcon.cjs.map +1 -1
- package/build/cjs/components/icon/icons/RedCrossIcon.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/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-panel/RadioPanel.cjs.map +1 -1
- package/build/cjs/components/input-panel/RadioPanelGroup.cjs.map +1 -1
- package/build/cjs/components/link-list/LinkList.cjs.map +1 -1
- package/build/cjs/components/list/List.cjs.map +1 -1
- package/build/cjs/components/loader/Loader.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonAnimation.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonLabel.cjs.map +1 -1
- package/build/cjs/components/loader/skeletons/SkeletonTextArea.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/useMenuWideEvents.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/modal/Modal.cjs.map +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.map +1 -1
- package/build/cjs/components/progress-bar/Countdown.cjs.map +1 -1
- package/build/cjs/components/progress-bar/ProgressBar.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/select/NativeSelect.cjs.map +1 -1
- package/build/cjs/components/select/Select.cjs.map +1 -1
- package/build/cjs/components/system-message/SystemMessage.cjs.map +1 -1
- package/build/cjs/components/system-message/common/MessageIcon.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/TableCell.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/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/TabPanel.cjs.map +1 -1
- package/build/cjs/components/tabs/Tabs.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/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/core/index.cjs +1 -1
- package/build/cjs/core/tailwind/tailwindPreset.cjs +1 -1
- package/build/cjs/core/tailwind/tailwindPreset.cjs.map +1 -1
- package/build/cjs/hooks/useAnimatedDetails/useAnimatedDetails.cjs.map +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/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/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/useKeyListener/useKeyListener.cjs.map +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.cjs.map +1 -1
- package/build/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
- package/build/cjs/hooks/useProgressiveImg/useProgressiveImg.cjs.map +1 -1
- package/build/cjs/hooks/useScreen/state.cjs.map +1 -1
- package/build/cjs/hooks/useScreen/useScreen.cjs +1 -1
- package/build/cjs/hooks/useScreen/useScreen.cjs.map +1 -1
- package/build/cjs/index.cjs +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/fodselsnummer/formatFodselsnummer.cjs.map +1 -1
- 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/registerWithMask.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/mergeProps.cjs.map +1 -1
- package/build/cjs/utilities/tabListener.cjs.map +1 -1
- package/build/cjs/utilities/validators/isValidKortnummer/isValidKortnummer.cjs.map +1 -1
- package/build/es/components/accordion/AccordionItem.js.map +1 -1
- package/build/es/components/autosuggest/Autosuggest.js +1 -1
- package/build/es/components/autosuggest/Autosuggest.js.map +1 -1
- package/build/es/components/autosuggest/BaseAutosuggest.js +2 -2
- package/build/es/components/autosuggest/BaseAutosuggest.js.map +1 -1
- package/build/es/components/autosuggest/utils.js.map +1 -1
- package/build/es/components/breadcrumb/Breadcrumb.js.map +1 -1
- package/build/es/components/button/Button.js.map +1 -1
- package/build/es/components/card/NavCard.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/cookie-consent/CookieConsent.js.map +1 -1
- package/build/es/components/cookie-consent/CookieConsentContext.js.map +1 -1
- package/build/es/components/cookie-consent/cookieConsentUtils.js.map +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.js.map +1 -1
- package/build/es/components/expander/ExpandablePanelContent.js.map +1 -1
- package/build/es/components/expander/Expander.js.map +1 -1
- package/build/es/components/expander/deprecated/ExpandSection.js.map +1 -1
- package/build/es/components/expander/deprecated/Expander.js.map +1 -1
- package/build/es/components/feedback/Feedback.js.map +1 -1
- package/build/es/components/feedback/followup/useFollowup.js.map +1 -1
- package/build/es/components/feedback/main-question/useMainQuestion.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/file-input/File.js.map +1 -1
- package/build/es/components/file-input/FileInput.js.map +1 -1
- package/build/es/components/file-input/internal/Dropzone.js.map +1 -1
- package/build/es/components/file-input/internal/Input.js.map +1 -1
- package/build/es/components/flex/Flex.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/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-panel/RadioPanel.js.map +1 -1
- package/build/es/components/loader/Loader.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonAnimation.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonLabel.js.map +1 -1
- package/build/es/components/loader/skeletons/SkeletonTextArea.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/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/useMenuWideEvents.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/pagination/Pagination.js.map +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/progress-bar/ProgressBar.js.map +1 -1
- package/build/es/components/radio-button/BaseRadioButton.js.map +1 -1
- package/build/es/components/radio-button/RadioButtonGroup.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/system-message/SystemMessage.js.map +1 -1
- package/build/es/components/system-message/common/MessageIcon.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/TableCell.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/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/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/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/Tooltip.js.map +1 -1
- package/build/es/components/tooltip/TooltipTrigger.js.map +1 -1
- package/build/es/core/index.js +1 -1
- package/build/es/core/tailwind/tailwindPreset.js +1 -1
- package/build/es/core/tailwind/tailwindPreset.js.map +1 -1
- package/build/es/hooks/useAnimatedDetails/useAnimatedDetails.js.map +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/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/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/useKeyListener/useKeyListener.js.map +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -1
- package/build/es/hooks/useMutationObserver/useMutationObserver.js.map +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 +1 -1
- package/build/es/hooks/useScreen/useScreen.js.map +1 -1
- package/build/es/index.js +1 -1
- package/build/es/utilities/formatters/util/registerWithMask.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/mergeProps.js.map +1 -1
- package/build/es/utilities/tabListener.js.map +1 -1
- package/build/es/utilities/validators/isValidKortnummer/isValidKortnummer.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/input-panel/checkbox-panel.css +2 -2
- package/styles/components/input-panel/checkbox-panel.min.css +1 -1
- package/styles/components/input-panel/radio-panel.css +2 -2
- package/styles/components/input-panel/radio-panel.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/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 +37 -37
- package/styles/styles.min.css +1 -1
- package/build/cjs/core/tailwind/plugins/typographyPlugin.cjs +0 -2
- package/build/cjs/core/tailwind/plugins/typographyPlugin.cjs.map +0 -1
- package/build/cjs/core/tailwind/plugins/typographyPlugin.d.cts +0 -2
- package/build/es/core/tailwind/plugins/typographyPlugin.d.ts +0 -2
- package/build/es/core/tailwind/plugins/typographyPlugin.js +0 -2
- package/build/es/core/tailwind/plugins/typographyPlugin.js.map +0 -1
- package/build/tailwindPreset-CSQrgZ57.cjs +0 -2
- package/build/tailwindPreset-CSQrgZ57.cjs.map +0 -1
- package/build/tailwindPreset-D4TYL0kz.js +0 -2
- package/build/tailwindPreset-D4TYL0kz.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedbackContext.cjs","sources":["../../../../src/components/feedback/feedbackContext.tsx"],"sourcesContent":["import React, { createContext, FC, useContext } from \"react\";\nimport { WithChildren } from \"../../core/types.js\";\nimport { BaseTextAreaProps } from \"../text-input/BaseTextArea.js\";\n\ntype FeedbackContext = {\n feedbackSubmitted: boolean;\n followupStarted: boolean;\n followupSubmitted: boolean;\n contactSubmitted: boolean;\n landmarkLabel?: string;\n setFeedbackSubmitted: (state: boolean) => void;\n setFollowupStarted: (state: boolean) => void;\n setFollowupSubmitted: (state: boolean) => void;\n setContactSubmitted: (state: boolean) => void;\n} & Pick<BaseTextAreaProps, \"counter\">;\n\nconst initialState: FeedbackContext = {\n feedbackSubmitted: false,\n followupStarted: false,\n followupSubmitted: false,\n contactSubmitted: false,\n setFeedbackSubmitted: () => null,\n setFollowupStarted: () => null,\n setFollowupSubmitted: () => null,\n setContactSubmitted: () => null,\n};\n\nconst feedbackContext = createContext(initialState);\n\nexport const useFeedbackContext = (): FeedbackContext =>\n useContext(feedbackContext);\n\ninterface FeedbackContextProviderProps extends WithChildren {\n value: FeedbackContext;\n}\n\nexport const FeedbackContextProvider: FC<FeedbackContextProviderProps> = ({\n value,\n children,\n}) => (\n <feedbackContext.Provider value={value}>\n {children}\n </feedbackContext.Provider>\n);\n"],"names":["feedbackContext","createContext","feedbackSubmitted","followupStarted","followupSubmitted","contactSubmitted","setFeedbackSubmitted","setFollowupStarted","setFollowupSubmitted","setContactSubmitted","value","children","jsx","Provider","useContext"],"mappings":"wIA2BMA,EAAkBC,
|
|
1
|
+
{"version":3,"file":"feedbackContext.cjs","sources":["../../../../src/components/feedback/feedbackContext.tsx"],"sourcesContent":["import React, { createContext, FC, useContext } from \"react\";\nimport { WithChildren } from \"../../core/types.js\";\nimport { BaseTextAreaProps } from \"../text-input/BaseTextArea.js\";\n\ntype FeedbackContext = {\n feedbackSubmitted: boolean;\n followupStarted: boolean;\n followupSubmitted: boolean;\n contactSubmitted: boolean;\n landmarkLabel?: string;\n setFeedbackSubmitted: (state: boolean) => void;\n setFollowupStarted: (state: boolean) => void;\n setFollowupSubmitted: (state: boolean) => void;\n setContactSubmitted: (state: boolean) => void;\n} & Pick<BaseTextAreaProps, \"counter\">;\n\nconst initialState: FeedbackContext = {\n feedbackSubmitted: false,\n followupStarted: false,\n followupSubmitted: false,\n contactSubmitted: false,\n setFeedbackSubmitted: () => null,\n setFollowupStarted: () => null,\n setFollowupSubmitted: () => null,\n setContactSubmitted: () => null,\n};\n\nconst feedbackContext = createContext(initialState);\n\nexport const useFeedbackContext = (): FeedbackContext =>\n useContext(feedbackContext);\n\ninterface FeedbackContextProviderProps extends WithChildren {\n value: FeedbackContext;\n}\n\nexport const FeedbackContextProvider: FC<FeedbackContextProviderProps> = ({\n value,\n children,\n}) => (\n <feedbackContext.Provider value={value}>\n {children}\n </feedbackContext.Provider>\n);\n"],"names":["feedbackContext","createContext","feedbackSubmitted","followupStarted","followupSubmitted","contactSubmitted","setFeedbackSubmitted","setFollowupStarted","setFollowupSubmitted","setContactSubmitted","value","children","jsx","Provider","useContext"],"mappings":"wIA2BMA,EAAkBC,EAAAA,cAXc,CAClCC,mBAAmB,EACnBC,iBAAiB,EACjBC,mBAAmB,EACnBC,kBAAkB,EAClBC,qBAAsB,IAAM,KAC5BC,mBAAoB,IAAM,KAC1BC,qBAAsB,IAAM,KAC5BC,oBAAqB,IAAM,uCAY0C,EACrEC,MAAAA,EACAC,SAAAA,KAECC,EAAAA,IAAAZ,EAAgBa,SAAhB,CAAyBH,MAAAA,EACrBC,SAAAA,+BAZyB,IAC9BG,EAAAA,WAAWd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Followup.cjs","sources":["../../../../../src/components/feedback/followup/Followup.tsx"],"sourcesContent":["import React, { FC, useEffect, useRef, useState } from \"react\";\nimport {\n PrimaryButton,\n SecondaryButton,\n TertiaryButton,\n} from \"../../button/Button.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { FollowupProps } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { FollowUpProvider } from \"./followupContext.js\";\nimport { useFollowup } from \"./useFollowup.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk, igjen!\",\n children:\n \"Vi setter pris på at du tok deg tid til å svare på flere spørsmål. Det hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const Followup: FC<FollowupProps> = ({\n questions,\n successMessage = defaultSuccessMessage,\n onSubmit,\n}) => {\n const [noThanks, setNoThanks] = useState(false);\n const focusRef = useRef<HTMLParagraphElement>(null);\n const followupState = useFollowup(questions, onSubmit);\n const { handleAbort, handleNext, step, submitted } = followupState;\n const {\n followupStarted,\n setFollowupStarted,\n setFollowupSubmitted,\n contactSubmitted,\n landmarkLabel,\n } = useFeedbackContext();\n\n useEffect(() => {\n if (step.number === 0) {\n return;\n }\n focusRef.current && focusRef.current.focus();\n }, [step]);\n\n useEffect(() => {\n setFollowupSubmitted(submitted);\n }, [submitted, setFollowupSubmitted]);\n\n const QuestionComponent = getQuestionFromType(questions[step.number].type);\n const Button = step.isLast ? PrimaryButton : SecondaryButton;\n\n if (noThanks) {\n return null;\n }\n\n return (\n <div aria-live=\"polite\">\n <FollowUpProvider state={followupState}>\n {!followupStarted && (\n <div className=\"jkl-feedback__fade-in\">\n <p className=\"jkl-heading-4 jkl-spacing-xl--top jkl-spacing-xs--bottom\">\n Har du tid til å svare på noen flere spørsmål?\n </p>\n <p className=\"jkl-body jkl-spacing-xl--bottom\">\n Det tar kun et minutt, og hjelper oss å lage bedre\n løsninger for deg.\n </p>\n <PrimaryButton\n onClick={() => setFollowupStarted(true)}\n className=\"jkl-spacing-xl--right\"\n >\n Jeg har tid!\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n )}\n {!submitted && followupStarted && (\n <form\n onSubmit={handleNext}\n className=\"jkl-feedback__fade-in\"\n aria-label={landmarkLabel}\n >\n <p\n className=\"jkl-feedback__step-counter\"\n ref={focusRef}\n >\n Steg {step.number + 1} av {questions.length}\n </p>\n <QuestionComponent\n {...questions[step.number]}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n key={step.number}\n />\n <div className=\"jkl-spacing-xl--top\" aria-live=\"off\">\n <Button type=\"submit\">\n {step.isLast ? \"Send inn\" : \"Neste\"}\n </Button>\n <TertiaryButton\n onClick={handleAbort}\n className=\"jkl-spacing-xl--left\"\n >\n Avbryt\n </TertiaryButton>\n </div>\n </form>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </FollowUpProvider>\n </div>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","questions","successMessage","onSubmit","noThanks","setNoThanks","useState","focusRef","useRef","followupState","useFollowup","handleAbort","handleNext","step","submitted","followupStarted","setFollowupStarted","setFollowupSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","useEffect","number","current","focus","QuestionComponent","getQuestionFromType","type","Button","isLast","PrimaryButton","SecondaryButton","jsxs","FollowUpProvider","state","className","jsx","onClick","TertiaryButton","ref","length","createElement","autoFocus","key","FeedbackSuccess"],"mappings":"iVAaMA,EAAwB,CAC1BC,MAAO,eACPC,SACI,0KAGmC,EACvCC,UAAAA,EACAC,eAAAA,EAAiBJ,EACjBK,SAAAA,MAEA,MAAOC,EAAUC,GAAeC,
|
|
1
|
+
{"version":3,"file":"Followup.cjs","sources":["../../../../../src/components/feedback/followup/Followup.tsx"],"sourcesContent":["import React, { FC, useEffect, useRef, useState } from \"react\";\nimport {\n PrimaryButton,\n SecondaryButton,\n TertiaryButton,\n} from \"../../button/Button.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { FollowupProps } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { FollowUpProvider } from \"./followupContext.js\";\nimport { useFollowup } from \"./useFollowup.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk, igjen!\",\n children:\n \"Vi setter pris på at du tok deg tid til å svare på flere spørsmål. Det hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const Followup: FC<FollowupProps> = ({\n questions,\n successMessage = defaultSuccessMessage,\n onSubmit,\n}) => {\n const [noThanks, setNoThanks] = useState(false);\n const focusRef = useRef<HTMLParagraphElement>(null);\n const followupState = useFollowup(questions, onSubmit);\n const { handleAbort, handleNext, step, submitted } = followupState;\n const {\n followupStarted,\n setFollowupStarted,\n setFollowupSubmitted,\n contactSubmitted,\n landmarkLabel,\n } = useFeedbackContext();\n\n useEffect(() => {\n if (step.number === 0) {\n return;\n }\n focusRef.current && focusRef.current.focus();\n }, [step]);\n\n useEffect(() => {\n setFollowupSubmitted(submitted);\n }, [submitted, setFollowupSubmitted]);\n\n const QuestionComponent = getQuestionFromType(questions[step.number].type);\n const Button = step.isLast ? PrimaryButton : SecondaryButton;\n\n if (noThanks) {\n return null;\n }\n\n return (\n <div aria-live=\"polite\">\n <FollowUpProvider state={followupState}>\n {!followupStarted && (\n <div className=\"jkl-feedback__fade-in\">\n <p className=\"jkl-heading-4 jkl-spacing-xl--top jkl-spacing-xs--bottom\">\n Har du tid til å svare på noen flere spørsmål?\n </p>\n <p className=\"jkl-body jkl-spacing-xl--bottom\">\n Det tar kun et minutt, og hjelper oss å lage bedre\n løsninger for deg.\n </p>\n <PrimaryButton\n onClick={() => setFollowupStarted(true)}\n className=\"jkl-spacing-xl--right\"\n >\n Jeg har tid!\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n )}\n {!submitted && followupStarted && (\n <form\n onSubmit={handleNext}\n className=\"jkl-feedback__fade-in\"\n aria-label={landmarkLabel}\n >\n <p\n className=\"jkl-feedback__step-counter\"\n ref={focusRef}\n >\n Steg {step.number + 1} av {questions.length}\n </p>\n <QuestionComponent\n {...questions[step.number]}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n key={step.number}\n />\n <div className=\"jkl-spacing-xl--top\" aria-live=\"off\">\n <Button type=\"submit\">\n {step.isLast ? \"Send inn\" : \"Neste\"}\n </Button>\n <TertiaryButton\n onClick={handleAbort}\n className=\"jkl-spacing-xl--left\"\n >\n Avbryt\n </TertiaryButton>\n </div>\n </form>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </FollowUpProvider>\n </div>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","questions","successMessage","onSubmit","noThanks","setNoThanks","useState","focusRef","useRef","followupState","useFollowup","handleAbort","handleNext","step","submitted","followupStarted","setFollowupStarted","setFollowupSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","useEffect","number","current","focus","QuestionComponent","getQuestionFromType","type","Button","isLast","PrimaryButton","SecondaryButton","jsxs","FollowUpProvider","state","className","jsx","onClick","TertiaryButton","ref","length","createElement","autoFocus","key","FeedbackSuccess"],"mappings":"iVAaMA,EAAwB,CAC1BC,MAAO,eACPC,SACI,0KAGmC,EACvCC,UAAAA,EACAC,eAAAA,EAAiBJ,EACjBK,SAAAA,MAEA,MAAOC,EAAUC,GAAeC,YAAS,GACnCC,EAAWC,SAA6B,MACxCC,EAAgBC,EAAAA,YAAYT,EAAWE,IACrCQ,YAAAA,EAAaC,WAAAA,EAAYC,KAAAA,EAAMC,UAAAA,GAAcL,GAEjDM,gBAAAA,EACAC,mBAAAA,EACAC,qBAAAA,EACAC,iBAAAA,EACAC,cAAAA,GACAC,EAAmBA,qBAEvBC,EAAAA,WAAU,KACc,IAAhBR,EAAKS,QAGAf,EAAAgB,SAAWhB,EAASgB,QAAQC,OAAM,GAC5C,CAACX,IAEJQ,EAAAA,WAAU,KACNJ,EAAqBH,EAAS,GAC/B,CAACA,EAAWG,IAEf,MAAMQ,EAAoBC,EAAAA,oBAAoBzB,EAAUY,EAAKS,QAAQK,MAC/DC,EAASf,EAAKgB,OAASC,EAAAA,cAAgBC,EAAAA,gBAE7C,OAAI3B,EACO,WAIN,MAAI,CAAA,YAAU,SACXJ,SAACgC,EAAAA,KAAAC,mBAAA,CAAiBC,MAAOzB,EACpBT,SAAA,EAACe,GACEiB,EAAAA,KAAC,MAAI,CAAAG,UAAU,wBACXnC,SAAA,CAACoC,EAAAA,IAAA,IAAA,CAAED,UAAU,2DAA2DnC,SAExE,mDACCoC,EAAAA,IAAA,IAAA,CAAED,UAAU,kCAAkCnC,SAG/C,0EACAoC,EAAAA,IAACN,EAAAA,cAAA,CACGO,QAAS,IAAMrB,GAAmB,GAClCmB,UAAU,wBACbnC,SAAA,uBAGAsC,EAAAA,eAAe,CAAAD,QAAS,IAAMhC,GAAY,GAAOL,SAElD,iBAGNc,GAAaC,GACXiB,EAAAA,KAAC,OAAA,CACG7B,SAAUS,EACVuB,UAAU,wBACV,aAAYhB,EAEZnB,SAAA,CAAAgC,EAAAA,KAAC,IAAA,CACGG,UAAU,6BACVI,IAAKhC,EACRP,SAAA,CAAA,QACSa,EAAKS,OAAS,EAAE,OAAKrB,EAAUuC,UAEzCC,EAAAA,cAAChB,EAAA,IACOxB,EAAUY,EAAKS,QAEnBoB,WAAS,EACTC,IAAK9B,EAAKS,SAEbU,EAAAA,KAAA,MAAA,CAAIG,UAAU,sBAAsB,YAAU,MAC3CnC,SAAA,CAAAoC,MAACR,GAAOD,KAAK,SACR3B,SAAKa,EAAAgB,OAAS,WAAa,UAEhCO,EAAAA,IAACE,EAAAA,eAAA,CACGD,QAAS1B,EACTwB,UAAU,uBACbnC,SAAA,iBAMZc,IAAcI,GACVkB,EAAAA,IAAAQ,EAAAA,gBAAA,IAAoB1C,QAGjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFollowup.cjs","sources":["../../../../../src/components/feedback/followup/useFollowup.ts"],"sourcesContent":["import {\n Dispatch,\n FormEvent,\n SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { FeedbackAnswer, FeedbackOption, FollowupQuestion } from \"../types.js\";\n\ntype CurrentValue =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype Followup = {\n questions: FollowupQuestion[];\n values: FeedbackAnswer[] | undefined;\n step: {\n number: number;\n question: FollowupQuestion;\n isLast: boolean;\n };\n currentValue: CurrentValue;\n setCurrentValue: Dispatch<SetStateAction<CurrentValue>>;\n submitted: boolean;\n handleNext: () => void;\n handleAbort: () => void;\n};\n\nexport const useFollowup = (\n questions: FollowupQuestion[],\n onSubmit: (a: FeedbackAnswer[]) => void,\n): Followup => {\n const [values, setValues] = useState<FeedbackAnswer[]>();\n const [step, setStep] = useState({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n const [shouldSubmit, setShouldSubmit] = useState(false);\n const [submitted, setSubmitted] = useState(false);\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n\n // Store info in a ref to facilitate autosubmit on component unmount,\n // or when leaving page\n const followupRef = useRef({\n values,\n submitted,\n onSubmit,\n });\n\n // Keep values in ref updated\n useEffect(() => {\n followupRef.current = {\n ...followupRef.current,\n values,\n submitted,\n };\n }, [values, submitted]);\n\n // General method for submitting info\n const _handleSubmit = useCallback(() => {\n if (\n !followupRef.current.submitted &&\n followupRef.current.values !== undefined\n ) {\n followupRef.current.onSubmit(followupRef.current.values);\n }\n }, []);\n\n // Function for handling going to the next step in the form wizard\n function handleNext(e?: FormEvent<HTMLFormElement>) {\n e?.preventDefault();\n\n const value = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value.toString())\n : currentValue?.value;\n\n const newValue = {\n ...step.question,\n name: step.question.name || step.question.label,\n value,\n };\n\n setValues((oldValues) => {\n const filteredValues =\n oldValues?.filter(\n (oldValue) => oldValue.name !== newValue.name,\n ) || [];\n return [...filteredValues, newValue as FeedbackAnswer];\n });\n setCurrentValue(undefined);\n\n if (step.isLast) {\n setShouldSubmit(true);\n } else {\n setStep((currentStep) => {\n const newStepNum = currentStep.number + 1;\n return {\n number: newStepNum,\n question: questions[newStepNum],\n isLast: newStepNum + 1 >= questions.length,\n };\n });\n }\n }\n\n // Let the user abort without submitting answers\n function handleAbort() {\n setValues(undefined);\n setCurrentValue(undefined);\n setStep({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n setSubmitted(true);\n }\n\n // Submit info after user submits last question\n useEffect(() => {\n if (shouldSubmit) {\n _handleSubmit();\n setSubmitted(true);\n }\n }, [shouldSubmit, _handleSubmit]);\n\n // Submit info if component unmounts or page unloads\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", _handleSubmit);\n }\n return () => {\n _handleSubmit();\n window.removeEventListener(\"beforeunload\", _handleSubmit);\n };\n }, [_handleSubmit]);\n\n return {\n questions,\n values,\n step,\n currentValue,\n setCurrentValue,\n submitted,\n handleNext,\n handleAbort,\n };\n};\n"],"names":["questions","onSubmit","values","setValues","useState","step","setStep","number","question","isLast","length","shouldSubmit","setShouldSubmit","submitted","setSubmitted","currentValue","setCurrentValue","followupRef","useRef","useEffect","current","_handleSubmit","useCallback","window","addEventListener","removeEventListener","handleNext","e","preventDefault","value","Array","isArray","map","option","toString","newValue","name","label","oldValues","filter","oldValue","currentStep","newStepNum","handleAbort"],"mappings":"6HA+B2B,CACvBA,EACAC,KAEA,MAAOC,EAAQC,GAAaC,
|
|
1
|
+
{"version":3,"file":"useFollowup.cjs","sources":["../../../../../src/components/feedback/followup/useFollowup.ts"],"sourcesContent":["import {\n Dispatch,\n FormEvent,\n SetStateAction,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { FeedbackAnswer, FeedbackOption, FollowupQuestion } from \"../types.js\";\n\ntype CurrentValue =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype Followup = {\n questions: FollowupQuestion[];\n values: FeedbackAnswer[] | undefined;\n step: {\n number: number;\n question: FollowupQuestion;\n isLast: boolean;\n };\n currentValue: CurrentValue;\n setCurrentValue: Dispatch<SetStateAction<CurrentValue>>;\n submitted: boolean;\n handleNext: () => void;\n handleAbort: () => void;\n};\n\nexport const useFollowup = (\n questions: FollowupQuestion[],\n onSubmit: (a: FeedbackAnswer[]) => void,\n): Followup => {\n const [values, setValues] = useState<FeedbackAnswer[]>();\n const [step, setStep] = useState({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n const [shouldSubmit, setShouldSubmit] = useState(false);\n const [submitted, setSubmitted] = useState(false);\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n\n // Store info in a ref to facilitate autosubmit on component unmount,\n // or when leaving page\n const followupRef = useRef({\n values,\n submitted,\n onSubmit,\n });\n\n // Keep values in ref updated\n useEffect(() => {\n followupRef.current = {\n ...followupRef.current,\n values,\n submitted,\n };\n }, [values, submitted]);\n\n // General method for submitting info\n const _handleSubmit = useCallback(() => {\n if (\n !followupRef.current.submitted &&\n followupRef.current.values !== undefined\n ) {\n followupRef.current.onSubmit(followupRef.current.values);\n }\n }, []);\n\n // Function for handling going to the next step in the form wizard\n function handleNext(e?: FormEvent<HTMLFormElement>) {\n e?.preventDefault();\n\n const value = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value.toString())\n : currentValue?.value;\n\n const newValue = {\n ...step.question,\n name: step.question.name || step.question.label,\n value,\n };\n\n setValues((oldValues) => {\n const filteredValues =\n oldValues?.filter(\n (oldValue) => oldValue.name !== newValue.name,\n ) || [];\n return [...filteredValues, newValue as FeedbackAnswer];\n });\n setCurrentValue(undefined);\n\n if (step.isLast) {\n setShouldSubmit(true);\n } else {\n setStep((currentStep) => {\n const newStepNum = currentStep.number + 1;\n return {\n number: newStepNum,\n question: questions[newStepNum],\n isLast: newStepNum + 1 >= questions.length,\n };\n });\n }\n }\n\n // Let the user abort without submitting answers\n function handleAbort() {\n setValues(undefined);\n setCurrentValue(undefined);\n setStep({\n number: 0,\n question: questions[0],\n isLast: questions.length === 1,\n });\n setSubmitted(true);\n }\n\n // Submit info after user submits last question\n useEffect(() => {\n if (shouldSubmit) {\n _handleSubmit();\n setSubmitted(true);\n }\n }, [shouldSubmit, _handleSubmit]);\n\n // Submit info if component unmounts or page unloads\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", _handleSubmit);\n }\n return () => {\n _handleSubmit();\n window.removeEventListener(\"beforeunload\", _handleSubmit);\n };\n }, [_handleSubmit]);\n\n return {\n questions,\n values,\n step,\n currentValue,\n setCurrentValue,\n submitted,\n handleNext,\n handleAbort,\n };\n};\n"],"names":["questions","onSubmit","values","setValues","useState","step","setStep","number","question","isLast","length","shouldSubmit","setShouldSubmit","submitted","setSubmitted","currentValue","setCurrentValue","followupRef","useRef","useEffect","current","_handleSubmit","useCallback","window","addEventListener","removeEventListener","handleNext","e","preventDefault","value","Array","isArray","map","option","toString","newValue","name","label","oldValues","filter","oldValue","currentStep","newStepNum","handleAbort"],"mappings":"6HA+B2B,CACvBA,EACAC,KAEA,MAAOC,EAAQC,GAAaC,EAA2BA,YAChDC,EAAMC,GAAWF,WAAS,CAC7BG,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,UAEfC,EAAcC,GAAmBR,YAAS,IAC1CS,EAAWC,GAAgBV,YAAS,IACpCW,EAAcC,GAAmBZ,EAEtCA,WAIIa,EAAcC,EAAAA,OAAO,CACvBhB,OAAAA,EACAW,UAAAA,EACAZ,SAAAA,IAIJkB,EAAAA,WAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACflB,OAAAA,EACAW,UAAAA,EAAA,GAEL,CAACX,EAAQW,IAGN,MAAAQ,EAAgBC,EAAAA,aAAY,MAEzBL,EAAYG,QAAQP,gBACU,IAA/BI,EAAYG,QAAQlB,QAEpBe,EAAYG,QAAQnB,SAASgB,EAAYG,QAAQlB,OAAM,GAE5D,IAoDHiB,OAAAA,EAAAA,WAAU,KACFR,IACcU,IACdP,GAAa,GACjB,GACD,CAACH,EAAcU,IAGlBF,EAAAA,WAAU,YACKI,OAAW,KACXA,OAAAC,iBAAiB,eAAgBH,GAErC,KACWA,IACPE,OAAAE,oBAAoB,eAAgBJ,EAAa,IAE7D,CAACA,IAEG,CACHrB,UAAAA,EACAE,OAAAA,EACAG,KAAAA,EACAU,aAAAA,EACAC,gBAAAA,EACAH,UAAAA,EACAa,WA1EJ,SAAoBC,GAChB,MAAAA,GAAAA,EAAGC,iBAEH,MAAMC,EAAQC,MAAMC,QAAQhB,GACtBA,EAAaiB,KAAKC,GAAWA,EAAOJ,MAAMK,aAC1C,MAAAnB,OAAA,EAAAA,EAAcc,MAEdM,EAAW,IACV9B,EAAKG,SACR4B,KAAM/B,EAAKG,SAAS4B,MAAQ/B,EAAKG,SAAS6B,MAC1CR,MAAAA,GAGJ1B,GAAWmC,GAKA,KAHH,MAAAA,OAAAA,EAAAA,EAAWC,QACNC,GAAaA,EAASJ,OAASD,EAASC,SACxC,GACkBD,KAE/BnB,OAAgB,GAEZX,EAAKI,OACLG,GAAgB,GAEhBN,GAASmC,IACC,MAAAC,EAAaD,EAAYlC,OAAS,EACjC,MAAA,CACHA,OAAQmC,EACRlC,SAAUR,EAAU0C,GACpBjC,OAAQiC,EAAa,GAAK1C,EAAUU,OAAA,GAIpD,EAyCIiC,YAtCJ,WACIxC,OAAU,GACVa,OAAgB,GACRV,EAAA,CACJC,OAAQ,EACRC,SAAUR,EAAU,GACpBS,OAA6B,IAArBT,EAAUU,SAEtBI,GAAa,EACjB,EA6BI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/MainQuestion.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { ComponentProps, FC, ReactNode, useEffect } from \"react\";\nimport { useAnimatedHeight } from \"../../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { Feedback } from \"../Feedback.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { AddonQuestion } from \"../questions/AddonQuestion.js\";\nimport { FeedbackOption, FeedbackType } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { MainQuestionContextProvider } from \"./mainQuestionContext.js\";\nimport { useMainQuestion } from \"./useMainQuestion.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk for tilbakemeldingen!\",\n children:\n \"Husk at vi ikke kan besvare meldinger fra dette skjemaet. Kontakt gjerne din forsikringsrådgiver om du har flere spørsmål.\",\n};\n\ntype Props = Pick<ComponentProps<typeof Feedback>, \"addOnQuestion\"> & {\n type: \"radio\" | \"smiley\";\n label: string;\n helpLabel?: string;\n options: FeedbackOption[];\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n onSubmit: (value: FeedbackType) => void;\n};\n\nexport const MainQuestion: FC<Props> = ({\n label,\n options,\n type,\n addOnQuestion,\n successMessage = defaultSuccessMessage,\n helpLabel,\n onSubmit,\n}) => {\n const mainQuestionState = useMainQuestion(onSubmit);\n\n const { setFeedbackSubmitted, contactSubmitted, landmarkLabel } =\n useFeedbackContext();\n const { handleSubmit, currentValue, setCurrentValue, submitted } =\n mainQuestionState;\n const [submitWrapperRef] = useAnimatedHeight<HTMLDivElement>(\n currentValue !== undefined,\n );\n\n useEffect(() => {\n setFeedbackSubmitted(submitted);\n }, [submitted, setFeedbackSubmitted]);\n\n const MainQuestionComp = getQuestionFromType(type);\n\n return (\n <>\n {!submitted && (\n <MainQuestionContextProvider state={mainQuestionState}>\n <form onSubmit={handleSubmit} aria-label={landmarkLabel}>\n <MainQuestionComp\n label={label}\n options={options}\n helpLabel={helpLabel}\n />\n <div\n ref={submitWrapperRef}\n className={clsx({\n \"jkl-feedback__submit-wrapper\": true,\n \"jkl-feedback__submit-wrapper--hidden\":\n currentValue === undefined,\n })}\n >\n {addOnQuestion && (\n <AddonQuestion\n helpLabel={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.helpLabel\n : undefined\n }\n label={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.label\n : undefined\n }\n />\n )}\n <div className=\"jkl-feedback__buttons jkl-spacing-xl--top\">\n <PrimaryButton className=\"jkl-spacing-xl--right\">\n Send\n </PrimaryButton>\n <TertiaryButton\n type=\"button\"\n onClick={() => setCurrentValue(undefined)}\n >\n Avbryt\n </TertiaryButton>\n </div>\n </div>\n </form>\n </MainQuestionContextProvider>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","label","options","type","addOnQuestion","successMessage","helpLabel","onSubmit","mainQuestionState","useMainQuestion","setFeedbackSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","handleSubmit","currentValue","setCurrentValue","submitted","submitWrapperRef","useAnimatedHeight","useEffect","MainQuestionComp","getQuestionFromType","jsxs","Fragment","jsx","MainQuestionContextProvider","state","ref","className","clsx","AddonQuestion","PrimaryButton","TertiaryButton","onClick","FeedbackSuccess"],"mappings":"ofAaMA,EAAwB,CAC1BC,MAAO,6BACPC,SACI,mJAe+B,EACnCC,MAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,cAAAA,EACAC,eAAAA,EAAiBP,EACjBQ,UAAAA,EACAC,SAAAA,MAEM,MAAAC,EAAoBC,kBAAgBF,IAElCG,qBAAAA,EAAsBC,iBAAAA,EAAkBC,cAAAA,GAC5CC,
|
|
1
|
+
{"version":3,"file":"MainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/MainQuestion.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { ComponentProps, FC, ReactNode, useEffect } from \"react\";\nimport { useAnimatedHeight } from \"../../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { Feedback } from \"../Feedback.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { AddonQuestion } from \"../questions/AddonQuestion.js\";\nimport { FeedbackOption, FeedbackType } from \"../types.js\";\nimport { getQuestionFromType } from \"../utils.js\";\nimport { MainQuestionContextProvider } from \"./mainQuestionContext.js\";\nimport { useMainQuestion } from \"./useMainQuestion.js\";\n\nconst defaultSuccessMessage = {\n title: \"Takk for tilbakemeldingen!\",\n children:\n \"Husk at vi ikke kan besvare meldinger fra dette skjemaet. Kontakt gjerne din forsikringsrådgiver om du har flere spørsmål.\",\n};\n\ntype Props = Pick<ComponentProps<typeof Feedback>, \"addOnQuestion\"> & {\n type: \"radio\" | \"smiley\";\n label: string;\n helpLabel?: string;\n options: FeedbackOption[];\n successMessage?: {\n title: string;\n children: ReactNode;\n };\n onSubmit: (value: FeedbackType) => void;\n};\n\nexport const MainQuestion: FC<Props> = ({\n label,\n options,\n type,\n addOnQuestion,\n successMessage = defaultSuccessMessage,\n helpLabel,\n onSubmit,\n}) => {\n const mainQuestionState = useMainQuestion(onSubmit);\n\n const { setFeedbackSubmitted, contactSubmitted, landmarkLabel } =\n useFeedbackContext();\n const { handleSubmit, currentValue, setCurrentValue, submitted } =\n mainQuestionState;\n const [submitWrapperRef] = useAnimatedHeight<HTMLDivElement>(\n currentValue !== undefined,\n );\n\n useEffect(() => {\n setFeedbackSubmitted(submitted);\n }, [submitted, setFeedbackSubmitted]);\n\n const MainQuestionComp = getQuestionFromType(type);\n\n return (\n <>\n {!submitted && (\n <MainQuestionContextProvider state={mainQuestionState}>\n <form onSubmit={handleSubmit} aria-label={landmarkLabel}>\n <MainQuestionComp\n label={label}\n options={options}\n helpLabel={helpLabel}\n />\n <div\n ref={submitWrapperRef}\n className={clsx({\n \"jkl-feedback__submit-wrapper\": true,\n \"jkl-feedback__submit-wrapper--hidden\":\n currentValue === undefined,\n })}\n >\n {addOnQuestion && (\n <AddonQuestion\n helpLabel={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.helpLabel\n : undefined\n }\n label={\n typeof addOnQuestion === \"object\"\n ? addOnQuestion.label\n : undefined\n }\n />\n )}\n <div className=\"jkl-feedback__buttons jkl-spacing-xl--top\">\n <PrimaryButton className=\"jkl-spacing-xl--right\">\n Send\n </PrimaryButton>\n <TertiaryButton\n type=\"button\"\n onClick={() => setCurrentValue(undefined)}\n >\n Avbryt\n </TertiaryButton>\n </div>\n </div>\n </form>\n </MainQuestionContextProvider>\n )}\n {submitted && !contactSubmitted && (\n <FeedbackSuccess {...successMessage} />\n )}\n </>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","label","options","type","addOnQuestion","successMessage","helpLabel","onSubmit","mainQuestionState","useMainQuestion","setFeedbackSubmitted","contactSubmitted","landmarkLabel","useFeedbackContext","handleSubmit","currentValue","setCurrentValue","submitted","submitWrapperRef","useAnimatedHeight","useEffect","MainQuestionComp","getQuestionFromType","jsxs","Fragment","jsx","MainQuestionContextProvider","state","ref","className","clsx","AddonQuestion","PrimaryButton","TertiaryButton","onClick","FeedbackSuccess"],"mappings":"ofAaMA,EAAwB,CAC1BC,MAAO,6BACPC,SACI,mJAe+B,EACnCC,MAAAA,EACAC,QAAAA,EACAC,KAAAA,EACAC,cAAAA,EACAC,eAAAA,EAAiBP,EACjBQ,UAAAA,EACAC,SAAAA,MAEM,MAAAC,EAAoBC,kBAAgBF,IAElCG,qBAAAA,EAAsBC,iBAAAA,EAAkBC,cAAAA,GAC5CC,EAAmBA,sBACfC,aAAAA,EAAcC,aAAAA,EAAcC,gBAAAA,EAAiBC,UAAAA,GACjDT,GACGU,GAAoBC,EAAAA,uBACN,IAAjBJ,GAGJK,EAAAA,WAAU,KACNV,EAAqBO,EAAS,GAC/B,CAACA,EAAWP,IAET,MAAAW,EAAmBC,sBAAoBnB,GAE7C,OAESoB,EAAAA,KAAAC,WAAA,CAAAxB,SAAA,EAACiB,GACGQ,EAAAA,IAAAC,EAAAA,4BAAA,CAA4BC,MAAOnB,EAChCR,gBAAC,OAAK,CAAAO,SAAUO,EAAc,aAAYF,EACtCZ,SAAA,CAAAyB,EAAAA,IAACJ,EAAA,CACGpB,MAAAA,EACAC,QAAAA,EACAI,UAAAA,IAEJiB,EAAAA,KAAC,MAAA,CACGK,IAAKV,EACLW,UAAWC,EAAAA,KAAK,CACZ,gCAAgC,EAChC,4CACqB,IAAjBf,IAGPf,SAAA,CACGI,GAAAqB,EAAAA,IAACM,EAAAA,cAAA,CACGzB,UAC6B,iBAAlBF,EACDA,EAAcE,eACd,EAEVL,MAC6B,iBAAlBG,EACDA,EAAcH,WACd,IAIlBsB,EAAAA,KAAC,MAAI,CAAAM,UAAU,4CACX7B,SAAA,CAACyB,EAAAA,IAAAO,EAAAA,cAAA,CAAcH,UAAU,wBAAwB7B,SAEjD,SACAyB,EAAAA,IAACQ,EAAAA,eAAA,CACG9B,KAAK,SACL+B,QAAS,IAAMlB,OAAgB,GAClChB,SAAA,sBAQpBiB,IAAcN,GACVc,EAAAA,IAAAU,EAAAA,gBAAA,IAAoB9B,MAE7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import {\n useState,\n useRef,\n useCallback,\n useEffect,\n SetStateAction,\n Dispatch,\n FormEventHandler,\n} from \"react\";\nimport { FeedbackType, FeedbackOption } from \"../types.js\";\n\ntype Value =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype MainQuestion = {\n currentValue: Value;\n setCurrentValue: Dispatch<SetStateAction<Value>>;\n message: string | undefined;\n setMessage: Dispatch<SetStateAction<string | undefined>>;\n submitted: boolean;\n handleSubmit: FormEventHandler<HTMLFormElement>;\n};\n\nexport const useMainQuestion = (\n onSubmit: (f: FeedbackType) => void,\n): MainQuestion => {\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n const [message, setMessage] = useState<string>();\n const [submitted, setSubmitted] = useState(false);\n\n const feedbackRef = useRef({\n onSubmit,\n currentValue,\n message,\n submitted,\n });\n\n useEffect(() => {\n feedbackRef.current = {\n ...feedbackRef.current,\n onSubmit,\n currentValue,\n message,\n submitted,\n };\n }, [onSubmit, currentValue, message, submitted]);\n\n const submitHandler = useCallback((intentionalSubmit = true) => {\n const { message, currentValue, submitted, onSubmit } =\n feedbackRef.current;\n\n if (!submitted && currentValue !== undefined) {\n const feedbackValue = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value)\n : currentValue?.value;\n onSubmit({\n feedbackValue,\n intentionalSubmit,\n ...(intentionalSubmit && message ? { message } : {}),\n });\n }\n }, []);\n\n const autoSubmit = useCallback(() => submitHandler(false), [submitHandler]);\n\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", autoSubmit);\n }\n return () => {\n autoSubmit();\n window.removeEventListener(\"beforeunload\", autoSubmit);\n };\n }, [autoSubmit]);\n\n const handleSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n submitHandler();\n setSubmitted(true);\n };\n\n return {\n currentValue,\n setCurrentValue,\n message,\n setMessage,\n submitted,\n handleSubmit,\n };\n};\n"],"names":["onSubmit","currentValue","setCurrentValue","useState","message","setMessage","submitted","setSubmitted","feedbackRef","useRef","useEffect","current","submitHandler","useCallback","intentionalSubmit","feedbackValue","Array","isArray","map","option","value","autoSubmit","window","addEventListener","removeEventListener","handleSubmit","e","preventDefault"],"mappings":"iIA0BIA,IAEA,MAAOC,EAAcC,GAAmBC,
|
|
1
|
+
{"version":3,"file":"useMainQuestion.cjs","sources":["../../../../../src/components/feedback/main-question/useMainQuestion.ts"],"sourcesContent":["import {\n useState,\n useRef,\n useCallback,\n useEffect,\n SetStateAction,\n Dispatch,\n FormEventHandler,\n} from \"react\";\nimport { FeedbackType, FeedbackOption } from \"../types.js\";\n\ntype Value =\n | FeedbackOption<string | number>\n | FeedbackOption<string | number>[]\n | undefined;\n\ntype MainQuestion = {\n currentValue: Value;\n setCurrentValue: Dispatch<SetStateAction<Value>>;\n message: string | undefined;\n setMessage: Dispatch<SetStateAction<string | undefined>>;\n submitted: boolean;\n handleSubmit: FormEventHandler<HTMLFormElement>;\n};\n\nexport const useMainQuestion = (\n onSubmit: (f: FeedbackType) => void,\n): MainQuestion => {\n const [currentValue, setCurrentValue] = useState<\n FeedbackOption | FeedbackOption[]\n >();\n const [message, setMessage] = useState<string>();\n const [submitted, setSubmitted] = useState(false);\n\n const feedbackRef = useRef({\n onSubmit,\n currentValue,\n message,\n submitted,\n });\n\n useEffect(() => {\n feedbackRef.current = {\n ...feedbackRef.current,\n onSubmit,\n currentValue,\n message,\n submitted,\n };\n }, [onSubmit, currentValue, message, submitted]);\n\n const submitHandler = useCallback((intentionalSubmit = true) => {\n const { message, currentValue, submitted, onSubmit } =\n feedbackRef.current;\n\n if (!submitted && currentValue !== undefined) {\n const feedbackValue = Array.isArray(currentValue)\n ? currentValue.map((option) => option.value)\n : currentValue?.value;\n onSubmit({\n feedbackValue,\n intentionalSubmit,\n ...(intentionalSubmit && message ? { message } : {}),\n });\n }\n }, []);\n\n const autoSubmit = useCallback(() => submitHandler(false), [submitHandler]);\n\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeunload\", autoSubmit);\n }\n return () => {\n autoSubmit();\n window.removeEventListener(\"beforeunload\", autoSubmit);\n };\n }, [autoSubmit]);\n\n const handleSubmit: FormEventHandler<HTMLFormElement> = (e) => {\n e.preventDefault();\n submitHandler();\n setSubmitted(true);\n };\n\n return {\n currentValue,\n setCurrentValue,\n message,\n setMessage,\n submitted,\n handleSubmit,\n };\n};\n"],"names":["onSubmit","currentValue","setCurrentValue","useState","message","setMessage","submitted","setSubmitted","feedbackRef","useRef","useEffect","current","submitHandler","useCallback","intentionalSubmit","feedbackValue","Array","isArray","map","option","value","autoSubmit","window","addEventListener","removeEventListener","handleSubmit","e","preventDefault"],"mappings":"iIA0BIA,IAEA,MAAOC,EAAcC,GAAmBC,EAEtCA,YACKC,EAASC,GAAcF,EAAiBA,YACxCG,EAAWC,GAAgBJ,YAAS,GAErCK,EAAcC,EAAAA,OAAO,CACvBT,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,IAGJI,EAAAA,WAAU,KACNF,EAAYG,QAAU,IACfH,EAAYG,QACfX,SAAAA,EACAC,aAAAA,EACAG,QAAAA,EACAE,UAAAA,EAAA,GAEL,CAACN,EAAUC,EAAcG,EAASE,IAErC,MAAMM,EAAgBC,EAAAA,aAAY,CAACC,GAAoB,KAC7C,MAAEV,QAAAA,EAASH,aAAAA,EAAcK,UAAAA,EAAWN,SAAAA,GACtCQ,EAAYG,QAEZ,IAACL,QAA8B,IAAjBL,EAA4B,CAI1CD,EAAS,CACLe,cAJkBC,MAAMC,QAAQhB,GAC9BA,EAAaiB,KAAKC,GAAWA,EAAOC,QACpCnB,MAAAA,OAAAA,EAAAA,EAAcmB,MAGhBN,kBAAAA,KACIA,GAAqBV,EAAU,CAAEA,QAAAA,GAAY,CAAC,GAE1D,IACD,IAEGiB,EAAaR,EAAAA,aAAY,IAAMD,GAAc,IAAQ,CAACA,IAE5DF,OAAAA,EAAAA,WAAU,YACKY,OAAW,KACXA,OAAAC,iBAAiB,eAAgBF,GAErC,KACQA,IACJC,OAAAE,oBAAoB,eAAgBH,EAAU,IAE1D,CAACA,IAQG,CACHpB,aAAAA,EACAC,gBAAAA,EACAE,QAAAA,EACAC,WAAAA,EACAC,UAAAA,EACAmB,aAZqDC,IACrDA,EAAEC,iBACYf,IACdL,GAAa,EAAI,EASjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddonQuestion.cjs","sources":["../../../../../src/components/feedback/questions/AddonQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useState } from \"react\";\nimport { TextArea } from \"../../text-input/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\n\ninterface Props {\n label?: string;\n helpLabel?: string;\n}\n\nexport const AddonQuestion: React.FC<Props> = ({\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n label,\n}) => {\n const { counter } = useFeedbackContext();\n const context = useMainQuestionContext();\n const [dynamicLabel, setDynamicLabel] = useState<string>();\n\n useEffect(() => {\n const labelFromValue = Array.isArray(context?.currentValue)\n ? context?.currentValue[0].textAreaLabel?.toString()\n : context?.currentValue?.textAreaLabel?.toString();\n setDynamicLabel(labelFromValue || label);\n }, [context?.currentValue, label]);\n\n if (!context) {\n console.error(\n \"Addon question must be used inside a MainQuestion context provider\",\n );\n return null;\n }\n\n const { message, setMessage } = context;\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setMessage(e.target.value);\n\n return (\n <>\n {context.currentValue !== undefined && (\n <div className=\"jkl-sr-only\" aria-live=\"polite\">\n {dynamicLabel} {helpLabel}\n </div>\n )}\n <TextArea\n startOpen\n rows={4}\n data-testid=\"jkl-feedback__open-question\"\n className=\"jkl-spacing-xl--bottom jkl-spacing-xl--top\"\n label={dynamicLabel}\n labelProps={{ srOnly: true }}\n placeholder={dynamicLabel}\n helpLabel={helpLabel}\n value={message || \"\"}\n onChange={handleChange}\n counter={counter}\n />\n </>\n );\n};\n"],"names":["helpLabel","label","counter","useFeedbackContext","context","useMainQuestionContext","dynamicLabel","setDynamicLabel","useState","useEffect","labelFromValue","Array","isArray","currentValue","_a","textAreaLabel","toString","_c","_b","error","message","setMessage","jsxs","Fragment","children","className","jsx","TextArea","startOpen","rows","labelProps","srOnly","placeholder","value","onChange","e","target"],"mappings":"mSAU8C,EAC1CA,UAAAA,EAAY,uJACZC,MAAAA,MAEM,MAAEC,QAAAA,GAAYC,
|
|
1
|
+
{"version":3,"file":"AddonQuestion.cjs","sources":["../../../../../src/components/feedback/questions/AddonQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useState } from \"react\";\nimport { TextArea } from \"../../text-input/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\n\ninterface Props {\n label?: string;\n helpLabel?: string;\n}\n\nexport const AddonQuestion: React.FC<Props> = ({\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n label,\n}) => {\n const { counter } = useFeedbackContext();\n const context = useMainQuestionContext();\n const [dynamicLabel, setDynamicLabel] = useState<string>();\n\n useEffect(() => {\n const labelFromValue = Array.isArray(context?.currentValue)\n ? context?.currentValue[0].textAreaLabel?.toString()\n : context?.currentValue?.textAreaLabel?.toString();\n setDynamicLabel(labelFromValue || label);\n }, [context?.currentValue, label]);\n\n if (!context) {\n console.error(\n \"Addon question must be used inside a MainQuestion context provider\",\n );\n return null;\n }\n\n const { message, setMessage } = context;\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) =>\n setMessage(e.target.value);\n\n return (\n <>\n {context.currentValue !== undefined && (\n <div className=\"jkl-sr-only\" aria-live=\"polite\">\n {dynamicLabel} {helpLabel}\n </div>\n )}\n <TextArea\n startOpen\n rows={4}\n data-testid=\"jkl-feedback__open-question\"\n className=\"jkl-spacing-xl--bottom jkl-spacing-xl--top\"\n label={dynamicLabel}\n labelProps={{ srOnly: true }}\n placeholder={dynamicLabel}\n helpLabel={helpLabel}\n value={message || \"\"}\n onChange={handleChange}\n counter={counter}\n />\n </>\n );\n};\n"],"names":["helpLabel","label","counter","useFeedbackContext","context","useMainQuestionContext","dynamicLabel","setDynamicLabel","useState","useEffect","labelFromValue","Array","isArray","currentValue","_a","textAreaLabel","toString","_c","_b","error","message","setMessage","jsxs","Fragment","children","className","jsx","TextArea","startOpen","rows","labelProps","srOnly","placeholder","value","onChange","e","target"],"mappings":"mSAU8C,EAC1CA,UAAAA,EAAY,uJACZC,MAAAA,MAEM,MAAEC,QAAAA,GAAYC,EAAAA,qBACdC,EAAUC,EAAAA,0BACTC,EAAcC,GAAmBC,EAAiBA,WASzD,GAPAC,EAAAA,WAAU,eACN,MAAMC,EAAiBC,MAAMC,QAAQ,MAAAR,SAAAA,EAASS,cACxC,OAAAC,EAAA,MAAAV,SAAAA,EAASS,aAAa,GAAGE,oBAAzBD,EAAAA,EAAwCE,WACxC,OAAAC,EAAA,OAAAC,EAAA,MAAAd,OAAAA,EAAAA,EAASS,mBAATK,EAAAA,EAAuBH,oBAAvB,EAAAE,EAAsCD,WAC5CT,EAAgBG,GAAkBT,EAAK,GACxC,CAAC,MAAAG,OAAAA,EAAAA,EAASS,aAAcZ,KAEtBG,EACO,eAAAe,MACJ,sEAEG,KAGL,MAAEC,QAAAA,EAASC,WAAAA,GAAejB,EAIhC,OAESkB,EAAAA,KAAAC,WAAA,CAAAC,SAAA,MAAyB,IAAzBpB,EAAQS,cACLS,OAAC,OAAIG,UAAU,cAAc,YAAU,SAClCD,SAAA,CAAAlB,EAAa,IAAEN,KAGxB0B,EAAAA,IAACC,EAAAA,SAAA,CACGC,WAAS,EACTC,KAAM,EACN,cAAY,8BACZJ,UAAU,6CACVxB,MAAOK,EACPwB,WAAY,CAAEC,QAAQ,GACtBC,YAAa1B,EACbN,UAAAA,EACAiC,MAAOb,GAAW,GAClBc,SApBmDC,GAC3Dd,EAAWc,EAAEC,OAAOH,OAoBZ/B,QAAAA,MAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxQuestion.cjs","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useRef } from \"react\";\nimport { Checkbox } from \"../../checkbox/Checkbox.js\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\n\nexport const CheckboxQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n const matchingOption = options?.find(\n (option) => option.value.toString() === value,\n );\n if (!matchingOption) return;\n\n if (!context?.currentValue) {\n context?.setCurrentValue([matchingOption]);\n return;\n }\n\n if (Array.isArray(context?.currentValue)) {\n const found = context.currentValue.find(\n (option) => option === matchingOption,\n );\n if (found) {\n context.setCurrentValue((oldValues) =>\n (oldValues as FeedbackOption[]).filter(\n (option) => option !== found,\n ),\n );\n } else {\n context.setCurrentValue((oldValues) => [\n ...(oldValues as FeedbackOption[]),\n matchingOption,\n ]);\n }\n }\n };\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <Checkbox\n key={`${label}-${option.value}`}\n name={name || label}\n value={option.value.toString()}\n onChange={handleChange}\n ref={i === 0 ? ref : undefined}\n >\n {option.label}\n </Checkbox>\n ))}\n </FieldGroup>\n );\n};\n"],"names":["label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","event","value","target","matchingOption","find","option","toString","currentValue","setCurrentValue","Array","isArray","found","oldValues","filter","jsx","FieldGroup","labelProps","variant","legend","children","map","i","Checkbox","onChange","console","error"],"mappings":"2VAOyD,EACrDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,SAAyB,MAErCC,EAAAA,WAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,
|
|
1
|
+
{"version":3,"file":"CheckboxQuestion.cjs","sources":["../../../../../src/components/feedback/questions/CheckboxQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useRef } from \"react\";\nimport { Checkbox } from \"../../checkbox/Checkbox.js\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\n\nexport const CheckboxQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n const matchingOption = options?.find(\n (option) => option.value.toString() === value,\n );\n if (!matchingOption) return;\n\n if (!context?.currentValue) {\n context?.setCurrentValue([matchingOption]);\n return;\n }\n\n if (Array.isArray(context?.currentValue)) {\n const found = context.currentValue.find(\n (option) => option === matchingOption,\n );\n if (found) {\n context.setCurrentValue((oldValues) =>\n (oldValues as FeedbackOption[]).filter(\n (option) => option !== found,\n ),\n );\n } else {\n context.setCurrentValue((oldValues) => [\n ...(oldValues as FeedbackOption[]),\n matchingOption,\n ]);\n }\n }\n };\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <Checkbox\n key={`${label}-${option.value}`}\n name={name || label}\n value={option.value.toString()}\n onChange={handleChange}\n ref={i === 0 ? ref : undefined}\n >\n {option.label}\n </Checkbox>\n ))}\n </FieldGroup>\n );\n};\n"],"names":["label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","handleChange","event","value","target","matchingOption","find","option","toString","currentValue","setCurrentValue","Array","isArray","found","oldValues","filter","jsx","FieldGroup","labelProps","variant","legend","children","map","i","Checkbox","onChange","console","error"],"mappings":"2VAOyD,EACrDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,SAAyB,MAErCC,EAAAA,WAAU,KACFR,GAAaM,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACV,EAAWM,IAET,MAAAK,EAAsDC,IAClD,MAAEC,MAAAA,GAAUD,EAAME,OAClBC,EAAiB,MAAAjB,OAAAA,EAAAA,EAASkB,MAC3BC,GAAWA,EAAOJ,MAAMK,aAAeL,IAE5C,GAAKE,EAED,CAAA,GAAC,MAAAV,IAAAA,EAASc,aAEV,YADS,MAAAd,GAAAA,EAAAe,gBAAgB,CAACL,KAI9B,GAAIM,MAAMC,QAAQ,MAAAjB,SAAAA,EAASc,cAAe,CAChC,MAAAI,EAAQlB,EAAQc,aAAaH,MAC9BC,GAAWA,IAAWF,IAEvBQ,EACQlB,EAAAe,iBAAiBI,GACpBA,EAA+BC,QAC3BR,GAAWA,IAAWM,MAIvBlB,EAAAe,iBAAiBI,GAAc,IAC/BA,EACJT,IAGZ,CAAA,GAGJ,OAAKV,EAQDqB,EAAAA,IAACC,EAAAA,WAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQlC,EACRG,UAAAA,EAECgC,SAAS,MAAAjC,OAAAA,EAAAA,EAAAkC,KAAI,CAACf,EAAQgB,IACnBP,EAAAA,IAACQ,EAAAA,SAAA,CAEGrC,KAAMA,GAAQD,EACdiB,MAAOI,EAAOJ,MAAMK,WACpBiB,SAAUxB,EACVL,IAAW,IAAN2B,EAAU3B,OAAM,EAEpByB,SAAOd,EAAArB,OANH,GAAGA,KAASqB,EAAOJ,cAd5BuB,QAAAC,MACJ,yEAEG,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactQuestion.cjs","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, useEffect, useRef, useState } from \"react\";\nimport { isValidEpost } from \"../../../utilities/validators/isValidEpost/isValidEpost.js\";\nimport { isValidTelefonnummer } from \"../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { TextInput } from \"../../text-input/TextInput.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { ContactQuestionProps } from \"../types.js\";\n\nconst validateEmail = (email?: string) => {\n if (!email || email === \"\") {\n return \"Du må oppgi e-postadresse for at vi kan kontakte deg\";\n }\n if (!isValidEpost(email)) {\n return \"Skriv inn en gyldig e-postadresse\";\n }\n return;\n};\n\nconst validatePhone = (phone?: string) => {\n if (!phone || phone === \"\") {\n return \"Du må oppgi telefonnummer for at vi kan kontakte deg\";\n }\n if (!isValidTelefonnummer(phone)) {\n return \"Skriv inn et gyldig telefonnummer\";\n }\n return;\n};\n\nconst defaultSuccessMessage = {\n title: \"Takk for tiden din!\",\n children:\n \"Neste gang vi gjennomfører intervjuer og tester kan det hende vi tar kontakt med deg. Dine innspill hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const ContactQuestion: FC<ContactQuestionProps> = ({\n label = \"Kan vi kontakte deg for flere innspill?\",\n sendButtonLabel = \"Sett meg på lista!\",\n withPhone = false,\n onSubmit,\n successMessage = defaultSuccessMessage,\n children,\n}) => {\n const [email, setEmail] = useState(\"\");\n const [phone, setPhone] = useState(\"\");\n const [errors, setErrors] = useState<{ email?: string; phone?: string }>(\n {},\n );\n const emailRef = useRef<HTMLInputElement>(null);\n const phoneRef = useRef<HTMLInputElement>(null);\n const [shouldValidate, setShouldValidate] = useState(false);\n\n const [noThanks, setNoThanks] = useState(false);\n const { contactSubmitted, setContactSubmitted, landmarkLabel } =\n useFeedbackContext();\n\n const ChildrenWrapper = typeof children === \"string\" ? \"p\" : \"div\";\n\n const validate = (email: string, phone: string) => {\n const emailError = validateEmail(email);\n const phoneError = validatePhone(phone);\n setErrors({ email: emailError, phone: phoneError });\n return { emailError, phoneError };\n };\n\n useEffect(() => {\n if (shouldValidate) {\n const { emailError, phoneError } = validate(email, phone);\n\n if (!emailError && (!withPhone || !phoneError)) {\n setShouldValidate(false);\n }\n }\n }, [email, phone, shouldValidate, withPhone]);\n\n const handleChange =\n (consumer: (value: string) => void) =>\n (e: ChangeEvent<HTMLInputElement>) =>\n consumer(e.target.value);\n\n const handleSubmit: React.FormEventHandler = (e) => {\n e.preventDefault();\n\n const { emailError, phoneError } = validate(email, phone);\n if (emailError) {\n setShouldValidate(true);\n emailRef.current?.focus();\n return;\n }\n if (withPhone && phoneError) {\n setShouldValidate(true);\n phoneRef.current?.focus();\n return;\n }\n\n onSubmit({ email, phone: withPhone ? phone : undefined });\n setContactSubmitted(true);\n };\n\n if (noThanks) {\n return null;\n }\n\n if (contactSubmitted) {\n return <FeedbackSuccess {...successMessage} />;\n }\n\n return (\n <form\n className=\"jkl-spacing-xl--top\"\n onSubmit={handleSubmit}\n aria-label={landmarkLabel}\n >\n <p className=\"jkl-heading-4 jkl-spacing-xs--bottom\">{label}</p>\n {children && (\n <ChildrenWrapper className=\"jkl-body\">\n {children}\n </ChildrenWrapper>\n )}\n\n <TextInput\n ref={emailRef}\n className=\"jkl-spacing-l--top\"\n label=\"E-post\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"email\"\n name=\"email\"\n value={email}\n onChange={handleChange(setEmail)}\n errorLabel={errors.email}\n />\n {withPhone && (\n <TextInput\n ref={phoneRef}\n className=\"jkl-spacing-l--top\"\n label=\"Telefonnummer\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"tel\"\n name=\"phone\"\n value={phone}\n onChange={handleChange(setPhone)}\n errorLabel={errors.phone}\n />\n )}\n\n <div className=\"jkl-spacing-xl--top\">\n <PrimaryButton type=\"submit\" className=\"jkl-spacing-xl--right\">\n {sendButtonLabel}\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n </form>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","label","sendButtonLabel","withPhone","onSubmit","successMessage","email","setEmail","useState","phone","setPhone","errors","setErrors","emailRef","useRef","phoneRef","shouldValidate","setShouldValidate","noThanks","setNoThanks","contactSubmitted","setContactSubmitted","landmarkLabel","useFeedbackContext","ChildrenWrapper","validate","emailError","isValidEpost","validateEmail","phoneError","isValidTelefonnummer","validatePhone","useEffect","handleChange","consumer","e","target","value","jsx","FeedbackSuccess","jsxs","className","preventDefault","_a","current","focus","_b","TextInput","ref","labelProps","variant","autoComplete","name","onChange","errorLabel","PrimaryButton","type","TertiaryButton","onClick"],"mappings":"mcA6BMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,8MAGiD,EACrDC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBP,EACjBE,SAAAA,MAEA,MAAOM,EAAOC,GAAYC,
|
|
1
|
+
{"version":3,"file":"ContactQuestion.cjs","sources":["../../../../../src/components/feedback/questions/ContactQuestion.tsx"],"sourcesContent":["import React, { ChangeEvent, FC, useEffect, useRef, useState } from \"react\";\nimport { isValidEpost } from \"../../../utilities/validators/isValidEpost/isValidEpost.js\";\nimport { isValidTelefonnummer } from \"../../../utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js\";\nimport { PrimaryButton, TertiaryButton } from \"../../button/Button.js\";\nimport { TextInput } from \"../../text-input/TextInput.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { FeedbackSuccess } from \"../FeedbackSuccess.js\";\nimport { ContactQuestionProps } from \"../types.js\";\n\nconst validateEmail = (email?: string) => {\n if (!email || email === \"\") {\n return \"Du må oppgi e-postadresse for at vi kan kontakte deg\";\n }\n if (!isValidEpost(email)) {\n return \"Skriv inn en gyldig e-postadresse\";\n }\n return;\n};\n\nconst validatePhone = (phone?: string) => {\n if (!phone || phone === \"\") {\n return \"Du må oppgi telefonnummer for at vi kan kontakte deg\";\n }\n if (!isValidTelefonnummer(phone)) {\n return \"Skriv inn et gyldig telefonnummer\";\n }\n return;\n};\n\nconst defaultSuccessMessage = {\n title: \"Takk for tiden din!\",\n children:\n \"Neste gang vi gjennomfører intervjuer og tester kan det hende vi tar kontakt med deg. Dine innspill hjelper oss med å gjøre nettsidene bedre for deg og alle andre som bruker dem.\",\n};\n\nexport const ContactQuestion: FC<ContactQuestionProps> = ({\n label = \"Kan vi kontakte deg for flere innspill?\",\n sendButtonLabel = \"Sett meg på lista!\",\n withPhone = false,\n onSubmit,\n successMessage = defaultSuccessMessage,\n children,\n}) => {\n const [email, setEmail] = useState(\"\");\n const [phone, setPhone] = useState(\"\");\n const [errors, setErrors] = useState<{ email?: string; phone?: string }>(\n {},\n );\n const emailRef = useRef<HTMLInputElement>(null);\n const phoneRef = useRef<HTMLInputElement>(null);\n const [shouldValidate, setShouldValidate] = useState(false);\n\n const [noThanks, setNoThanks] = useState(false);\n const { contactSubmitted, setContactSubmitted, landmarkLabel } =\n useFeedbackContext();\n\n const ChildrenWrapper = typeof children === \"string\" ? \"p\" : \"div\";\n\n const validate = (email: string, phone: string) => {\n const emailError = validateEmail(email);\n const phoneError = validatePhone(phone);\n setErrors({ email: emailError, phone: phoneError });\n return { emailError, phoneError };\n };\n\n useEffect(() => {\n if (shouldValidate) {\n const { emailError, phoneError } = validate(email, phone);\n\n if (!emailError && (!withPhone || !phoneError)) {\n setShouldValidate(false);\n }\n }\n }, [email, phone, shouldValidate, withPhone]);\n\n const handleChange =\n (consumer: (value: string) => void) =>\n (e: ChangeEvent<HTMLInputElement>) =>\n consumer(e.target.value);\n\n const handleSubmit: React.FormEventHandler = (e) => {\n e.preventDefault();\n\n const { emailError, phoneError } = validate(email, phone);\n if (emailError) {\n setShouldValidate(true);\n emailRef.current?.focus();\n return;\n }\n if (withPhone && phoneError) {\n setShouldValidate(true);\n phoneRef.current?.focus();\n return;\n }\n\n onSubmit({ email, phone: withPhone ? phone : undefined });\n setContactSubmitted(true);\n };\n\n if (noThanks) {\n return null;\n }\n\n if (contactSubmitted) {\n return <FeedbackSuccess {...successMessage} />;\n }\n\n return (\n <form\n className=\"jkl-spacing-xl--top\"\n onSubmit={handleSubmit}\n aria-label={landmarkLabel}\n >\n <p className=\"jkl-heading-4 jkl-spacing-xs--bottom\">{label}</p>\n {children && (\n <ChildrenWrapper className=\"jkl-body\">\n {children}\n </ChildrenWrapper>\n )}\n\n <TextInput\n ref={emailRef}\n className=\"jkl-spacing-l--top\"\n label=\"E-post\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"email\"\n name=\"email\"\n value={email}\n onChange={handleChange(setEmail)}\n errorLabel={errors.email}\n />\n {withPhone && (\n <TextInput\n ref={phoneRef}\n className=\"jkl-spacing-l--top\"\n label=\"Telefonnummer\"\n labelProps={{ variant: \"small\" }}\n autoComplete=\"tel\"\n name=\"phone\"\n value={phone}\n onChange={handleChange(setPhone)}\n errorLabel={errors.phone}\n />\n )}\n\n <div className=\"jkl-spacing-xl--top\">\n <PrimaryButton type=\"submit\" className=\"jkl-spacing-xl--right\">\n {sendButtonLabel}\n </PrimaryButton>\n <TertiaryButton onClick={() => setNoThanks(true)}>\n Nei takk\n </TertiaryButton>\n </div>\n </form>\n );\n};\n"],"names":["defaultSuccessMessage","title","children","label","sendButtonLabel","withPhone","onSubmit","successMessage","email","setEmail","useState","phone","setPhone","errors","setErrors","emailRef","useRef","phoneRef","shouldValidate","setShouldValidate","noThanks","setNoThanks","contactSubmitted","setContactSubmitted","landmarkLabel","useFeedbackContext","ChildrenWrapper","validate","emailError","isValidEpost","validateEmail","phoneError","isValidTelefonnummer","validatePhone","useEffect","handleChange","consumer","e","target","value","jsx","FeedbackSuccess","jsxs","className","preventDefault","_a","current","focus","_b","TextInput","ref","labelProps","variant","autoComplete","name","onChange","errorLabel","PrimaryButton","type","TertiaryButton","onClick"],"mappings":"mcA6BMA,EAAwB,CAC1BC,MAAO,sBACPC,SACI,8MAGiD,EACrDC,MAAAA,EAAQ,0CACRC,gBAAAA,EAAkB,qBAClBC,UAAAA,GAAY,EACZC,SAAAA,EACAC,eAAAA,EAAiBP,EACjBE,SAAAA,MAEA,MAAOM,EAAOC,GAAYC,WAAS,KAC5BC,EAAOC,GAAYF,WAAS,KAC5BG,EAAQC,GAAaJ,EAAAA,SACxB,CAAC,GAECK,EAAWC,SAAyB,MACpCC,EAAWD,SAAyB,OACnCE,EAAgBC,GAAqBT,YAAS,IAE9CU,EAAUC,GAAeX,YAAS,IACjCY,iBAAAA,EAAkBC,oBAAAA,EAAqBC,cAAAA,GAC3CC,EAAmBA,qBAEjBC,EAAsC,iBAAbxB,EAAwB,IAAM,MAEvDyB,EAAW,CAACnB,EAAeG,KACvB,MAAAiB,EAlDSpB,IACdA,GAAmB,KAAVA,EAGTqB,EAAAA,aAAarB,QAAd,EACO,oCAHA,uDAgDYsB,CAActB,GAC3BuB,EAzCSpB,IACdA,GAAmB,KAAVA,EAGTqB,EAAAA,qBAAqBrB,QAAtB,EACO,oCAHA,uDAuCYsB,CAActB,GACjC,OAAAG,EAAU,CAAEN,MAAOoB,EAAYjB,MAAOoB,IAC/B,CAAEH,WAAAA,EAAYG,WAAAA,IAGzBG,EAAAA,WAAU,KACN,GAAIhB,EAAgB,CAChB,MAAQU,WAAAA,EAAYG,WAAAA,GAAeJ,EAASnB,EAAOG,IAE9CiB,KAAgBvB,IAAc0B,IAC/BZ,GAAkB,EAE1B,IACD,CAACX,EAAOG,EAAOO,EAAgBb,IAE5B,MAAA8B,EACDC,GACAC,GACGD,EAASC,EAAEC,OAAOC,OAqB1B,OAAInB,EACO,KAGPE,EACOkB,EAAAA,IAACC,EAAiBA,gBAAA,IAAGlC,IAI5BmC,EAAAA,KAAC,OAAA,CACGC,UAAU,sBACVrC,SA9BsC+B,YAC1CA,EAAEO,iBAEF,MAAQhB,WAAAA,EAAYG,WAAAA,GAAeJ,EAASnB,EAAOG,GACnD,OAAIiB,GACAT,GAAkB,QAClB,OAAA0B,EAAA9B,EAAS+B,UAATD,EAAkBE,UAGlB1C,GAAa0B,GACbZ,GAAkB,QAClB,OAAA6B,EAAA/B,EAAS6B,UAATE,EAAkBD,WAItBzC,EAAS,CAAEE,MAAAA,EAAOG,MAAON,EAAYM,OAAQ,SAC7CY,GAAoB,GAAI,EAepB,aAAYC,EAEZtB,SAAA,CAACsC,EAAAA,IAAA,IAAA,CAAEG,UAAU,uCAAwCzC,SAAMC,IAC1DD,GACGsC,EAAAA,IAACd,EAAgB,CAAAiB,UAAU,WACtBzC,SAAAA,IAITsC,EAAAA,IAACS,EAAAA,UAAA,CACGC,IAAKnC,EACL4B,UAAU,qBACVxC,MAAM,SACNgD,WAAY,CAAEC,QAAS,SACvBC,aAAa,QACbC,KAAK,QACLf,MAAO/B,EACP+C,SAAUpB,EAAa1B,GACvB+C,WAAY3C,EAAOL,QAEtBH,GACGmC,EAAAA,IAACS,EAAAA,UAAA,CACGC,IAAKjC,EACL0B,UAAU,qBACVxC,MAAM,gBACNgD,WAAY,CAAEC,QAAS,SACvBC,aAAa,MACbC,KAAK,QACLf,MAAO5B,EACP4C,SAAUpB,EAAavB,GACvB4C,WAAY3C,EAAOF,QAI3B+B,EAAAA,KAAC,MAAI,CAAAC,UAAU,sBACXzC,SAAA,CAAAsC,MAACiB,EAAAA,cAAc,CAAAC,KAAK,SAASf,UAAU,wBAClCzC,SACLE,UACCuD,EAAAA,eAAe,CAAAC,QAAS,IAAMvC,GAAY,GAAOnB,SAElD,kBACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioQuestion.cjs","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n useEffect,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport { RadioButton } from \"../../radio-button/RadioButton.js\";\nimport { RadioButtonGroup } from \"../../radio-button/RadioButtonGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { QuestionProps } from \"../types.js\";\n\nexport const RadioQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const numOptions = options?.length || 0;\n\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <RadioButtonGroup\n legend={label}\n labelProps={{ variant: \"large\" }}\n name={`${id}-${name || label}`}\n inline={numOptions < 3}\n value={selectedValue || \"\"}\n onChange={handleChange}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <RadioButton\n ref={i === 0 ? ref : undefined}\n key={`${id}-${name || label}-${option.value}`}\n label={option.label}\n value={String(option.value)}\n />\n ))}\n </RadioButtonGroup>\n );\n};\n"],"names":["label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","selectedValue","useMemo","Array","isArray","currentValue","value","toString","_a","jsx","RadioButtonGroup","legend","labelProps","variant","inline","onChange","e","option","find","target","setCurrentValue","children","map","i","RadioButton","String","console","error"],"mappings":"sWAasD,EAClDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,EAAAA,QAELC,GAAa,MAAAV,OAAA,EAAAA,EAASW,SAAU,EAEhCC,EAAMC,SAAyB,MACrCC,EAAAA,WAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,
|
|
1
|
+
{"version":3,"file":"RadioQuestion.cjs","sources":["../../../../../src/components/feedback/questions/RadioQuestion.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n useEffect,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport { RadioButton } from \"../../radio-button/RadioButton.js\";\nimport { RadioButtonGroup } from \"../../radio-button/RadioButtonGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { QuestionProps } from \"../types.js\";\n\nexport const RadioQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n options,\n helpLabel,\n autoFocus = false,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const numOptions = options?.length || 0;\n\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <RadioButtonGroup\n legend={label}\n labelProps={{ variant: \"large\" }}\n name={`${id}-${name || label}`}\n inline={numOptions < 3}\n value={selectedValue || \"\"}\n onChange={handleChange}\n helpLabel={helpLabel}\n >\n {options?.map((option, i) => (\n <RadioButton\n ref={i === 0 ? ref : undefined}\n key={`${id}-${name || label}-${option.value}`}\n label={option.label}\n value={String(option.value)}\n />\n ))}\n </RadioButtonGroup>\n );\n};\n"],"names":["label","name","options","helpLabel","autoFocus","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","numOptions","length","ref","useRef","useEffect","current","focus","selectedValue","useMemo","Array","isArray","currentValue","value","toString","_a","jsx","RadioButtonGroup","legend","labelProps","variant","inline","onChange","e","option","find","target","setCurrentValue","children","map","i","RadioButton","String","console","error"],"mappings":"sWAasD,EAClDA,MAAAA,EACAC,KAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,GAAY,MAEZ,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,EAAAA,QAELC,GAAa,MAAAV,OAAA,EAAAA,EAASW,SAAU,EAEhCC,EAAMC,SAAyB,MACrCC,EAAAA,WAAU,KACFZ,GAAaU,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACd,EAAWU,IAET,MAOAK,EAAgBC,EAAAA,SAClB,WACI,OAAAC,MAAMC,QAAQ,MAAAb,OAAAA,EAAAA,EAASc,cACjB,MAAAd,OAAAA,EAAAA,EAASc,aAAa,GAAGC,MAAMC,WAC/B,OAAAC,EAAA,MAAAjB,OAAAA,EAAAA,EAASc,mBAAT,EAAAG,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAhB,OAAAA,EAAAA,EAASc,eAGd,OAAKd,EAQDkB,EAAAA,IAACC,EAAAA,iBAAA,CACGC,OAAQ7B,EACR8B,WAAY,CAAEC,QAAS,SACvB9B,KAAM,GAAGS,KAAMT,GAAQD,IACvBgC,OAAQpB,EAAa,EACrBY,MAAOL,GAAiB,GACxBc,SA7BoDC,IACxD,MAAMC,EAAS,MAAAjC,SAAAA,EAASkC,MACnBD,GAAWA,EAAOX,MAAMC,aAAeS,EAAEG,OAAOb,QAErD,MAAAf,GAAAA,EAAS6B,gBAAgBH,IA0BrBhC,UAAAA,EAECoC,SAAS,MAAArC,OAAA,EAAAA,EAAAsC,KAAI,CAACL,EAAQM,IACnBd,EAAAA,IAACe,EAAAA,YAAA,CACG5B,IAAW,IAAN2B,EAAU3B,OAAM,EAErBd,MAAOmC,EAAOnC,MACdwB,MAAOmB,OAAOR,EAAOX,QAFhB,GAAGd,KAAMT,GAAQD,KAASmC,EAAOX,cAnB1CoB,QAAAC,MACJ,yEAEG,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmileyQuestion.cjs","sources":["../../../../../src/components/feedback/questions/SmileyQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, Fragment, useId, useMemo } from \"react\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\nimport { defaultOptions, getSmiley } from \"./smileyUtils.js\";\n\nconst isNotInScale = (option: FeedbackOption) =>\n typeof option.value !== \"number\" || ![1, 2, 3, 4, 5].includes(option.value);\n\nexport const SmileyQuestion: React.FC<QuestionProps> = ({\n label,\n name = \"smiley\",\n helpLabel,\n options = defaultOptions,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n console.log(e.target.value);\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value\n : context?.currentValue?.value,\n [context?.currentValue],\n );\n\n if (options.some(isNotInScale)) {\n console.error(\n \"SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine\",\n );\n return null;\n }\n\n if (!context || !options) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n <div className=\"jkl-feedback-smileys\">\n {options.map((option) => (\n <Fragment key={option.value}>\n <input\n className=\"jkl-sr-only\"\n id={`${id}-${name}-${option.value}`}\n name={`${id}-${name}`}\n type=\"radio\"\n value={option.value}\n onChange={handleChange}\n checked={selectedValue === option.value}\n />\n <label\n className=\"jkl-feedback-smiley-option\"\n htmlFor={`${id}-${name}-${option.value}`}\n >\n <span className=\"jkl-sr-only\">{option.label}</span>\n {getSmiley(Number(option.value))}\n </label>\n </Fragment>\n ))}\n </div>\n </FieldGroup>\n );\n};\n"],"names":["isNotInScale","option","value","includes","label","name","helpLabel","options","defaultOptions","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","handleChange","e","console","log","target","find","toString","setCurrentValue","selectedValue","useMemo","isArray","currentValue","_a","some","error","jsx","FieldGroup","labelProps","variant","legend","children","className","map","jsxs","Fragment","type","onChange","checked","htmlFor","getSmiley","Number"],"mappings":"wTAOMA,EAAgBC,GACM,iBAAjBA,EAAOC,QAAuB,CAAC,EAAG,EAAG,EAAG,EAAG,GAAGC,SAASF,EAAOC,8BAElB,EACnDE,MAAAA,EACAC,KAAAA,EAAO,SACPC,UAAAA,EACAC,QAAAA,EAAUC,EAAAA,mBAEV,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,EAAAA,QAELC,EAAsDC,IAChDC,QAAAC,IAAIF,EAAEG,OAAOlB,OACrB,MAAMD,EAAS,MAAAM,OAAAA,EAAAA,EAASc,MACnBpB,GAAWA,EAAOC,MAAMoB,aAAeL,EAAEG,OAAOlB,QAErD,MAAAW,GAAAA,EAASU,gBAAgBtB,IAGvBuB,EAAgBC,EAAAA,SAClB,WACI,aAAMC,QAAQ,MAAAb,OAAAA,EAAAA,EAASc,cACjB,MAAAd,OAAA,EAAAA,EAASc,aAAa,GAAGzB,MACzB,OAAA0B,EAAA,MAAAf,OAAA,EAAAA,EAASc,qBAATC,EAAuB1B,QACjC,CAAC,MAAAW,OAAAA,EAAAA,EAASc,eAGV,OAAApB,EAAQsB,KAAK7B,IACLkB,QAAAY,MACJ,2EAEG,MAGNjB,GAAYN,EAQbwB,EAAAA,IAACC,EAAAA,WAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQ/B,EACRE,UAAAA,EAEA8B,SAAAL,EAAAA,IAAC,OAAIM,UAAU,uBACVD,WAAQE,KAAKrC,GACVsC,EAAAA,KAACC,EACGA,SAAA,CAAAJ,SAAA,CAAAL,EAAAA,IAAC,QAAA,CACGM,UAAU,cACVvB,GAAI,GAAGA,KAAMT,KAAQJ,EAAOC,QAC5BG,KAAM,GAAGS,KAAMT,IACfoC,KAAK,QACLvC,MAAOD,EAAOC,MACdwC,SAAU1B,EACV2B,QAASnB,IAAkBvB,EAAOC,QAEtCqC,EAAAA,KAAC,QAAA,CACGF,UAAU,6BACVO,QAAS,GAAG9B,KAAMT,KAAQJ,EAAOC,QAEjCkC,SAAA,CAAAL,EAAAA,IAAC,OAAK,CAAAM,UAAU,cAAeD,SAAAnC,EAAOG,QACrCyC,
|
|
1
|
+
{"version":3,"file":"SmileyQuestion.cjs","sources":["../../../../../src/components/feedback/questions/SmileyQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, Fragment, useId, useMemo } from \"react\";\nimport { FieldGroup } from \"../../input-group/FieldGroup.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackOption, QuestionProps } from \"../types.js\";\nimport { defaultOptions, getSmiley } from \"./smileyUtils.js\";\n\nconst isNotInScale = (option: FeedbackOption) =>\n typeof option.value !== \"number\" || ![1, 2, 3, 4, 5].includes(option.value);\n\nexport const SmileyQuestion: React.FC<QuestionProps> = ({\n label,\n name = \"smiley\",\n helpLabel,\n options = defaultOptions,\n}) => {\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const id = useId();\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {\n console.log(e.target.value);\n const option = options?.find(\n (option) => option.value.toString() === e.target.value,\n );\n context?.setCurrentValue(option);\n };\n\n const selectedValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value\n : context?.currentValue?.value,\n [context?.currentValue],\n );\n\n if (options.some(isNotInScale)) {\n console.error(\n \"SmileyQuestion må ha tallene 1 til 5 som verdier for alternativene sine\",\n );\n return null;\n }\n\n if (!context || !options) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <FieldGroup\n labelProps={{ variant: \"large\" }}\n legend={label}\n helpLabel={helpLabel}\n >\n <div className=\"jkl-feedback-smileys\">\n {options.map((option) => (\n <Fragment key={option.value}>\n <input\n className=\"jkl-sr-only\"\n id={`${id}-${name}-${option.value}`}\n name={`${id}-${name}`}\n type=\"radio\"\n value={option.value}\n onChange={handleChange}\n checked={selectedValue === option.value}\n />\n <label\n className=\"jkl-feedback-smiley-option\"\n htmlFor={`${id}-${name}-${option.value}`}\n >\n <span className=\"jkl-sr-only\">{option.label}</span>\n {getSmiley(Number(option.value))}\n </label>\n </Fragment>\n ))}\n </div>\n </FieldGroup>\n );\n};\n"],"names":["isNotInScale","option","value","includes","label","name","helpLabel","options","defaultOptions","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","id","useId","handleChange","e","console","log","target","find","toString","setCurrentValue","selectedValue","useMemo","isArray","currentValue","_a","some","error","jsx","FieldGroup","labelProps","variant","legend","children","className","map","jsxs","Fragment","type","onChange","checked","htmlFor","getSmiley","Number"],"mappings":"wTAOMA,EAAgBC,GACM,iBAAjBA,EAAOC,QAAuB,CAAC,EAAG,EAAG,EAAG,EAAG,GAAGC,SAASF,EAAOC,8BAElB,EACnDE,MAAAA,EACAC,KAAAA,EAAO,SACPC,UAAAA,EACAC,QAAAA,EAAUC,EAAAA,mBAEV,MAAMC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAKC,EAAAA,QAELC,EAAsDC,IAChDC,QAAAC,IAAIF,EAAEG,OAAOlB,OACrB,MAAMD,EAAS,MAAAM,OAAAA,EAAAA,EAASc,MACnBpB,GAAWA,EAAOC,MAAMoB,aAAeL,EAAEG,OAAOlB,QAErD,MAAAW,GAAAA,EAASU,gBAAgBtB,IAGvBuB,EAAgBC,EAAAA,SAClB,WACI,aAAMC,QAAQ,MAAAb,OAAAA,EAAAA,EAASc,cACjB,MAAAd,OAAA,EAAAA,EAASc,aAAa,GAAGzB,MACzB,OAAA0B,EAAA,MAAAf,OAAA,EAAAA,EAASc,qBAATC,EAAuB1B,QACjC,CAAC,MAAAW,OAAAA,EAAAA,EAASc,eAGV,OAAApB,EAAQsB,KAAK7B,IACLkB,QAAAY,MACJ,2EAEG,MAGNjB,GAAYN,EAQbwB,EAAAA,IAACC,EAAAA,WAAA,CACGC,WAAY,CAAEC,QAAS,SACvBC,OAAQ/B,EACRE,UAAAA,EAEA8B,SAAAL,EAAAA,IAAC,OAAIM,UAAU,uBACVD,WAAQE,KAAKrC,GACVsC,EAAAA,KAACC,EACGA,SAAA,CAAAJ,SAAA,CAAAL,EAAAA,IAAC,QAAA,CACGM,UAAU,cACVvB,GAAI,GAAGA,KAAMT,KAAQJ,EAAOC,QAC5BG,KAAM,GAAGS,KAAMT,IACfoC,KAAK,QACLvC,MAAOD,EAAOC,MACdwC,SAAU1B,EACV2B,QAASnB,IAAkBvB,EAAOC,QAEtCqC,EAAAA,KAAC,QAAA,CACGF,UAAU,6BACVO,QAAS,GAAG9B,KAAMT,KAAQJ,EAAOC,QAEjCkC,SAAA,CAAAL,EAAAA,IAAC,OAAK,CAAAM,UAAU,cAAeD,SAAAnC,EAAOG,QACrCyC,EAAAA,UAAUC,OAAO7C,EAAOC,aAflBD,EAAOC,cAd1BgB,QAAAY,MACJ,yEAEG,KA8BH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextQuestion.cjs","sources":["../../../../../src/components/feedback/questions/TextQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useMemo, useRef } from \"react\";\nimport { TextArea } from \"../../text-input/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackAnswer, QuestionProps } from \"../types.js\";\n\nexport const TextQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n autoFocus = false,\n}) => {\n const { counter } = useFeedbackContext();\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n const value: FeedbackAnswer = {\n label,\n name: name || label,\n type: \"text\",\n value: e.target.value,\n };\n context?.setCurrentValue(value);\n };\n\n const currentValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <TextArea\n ref={ref}\n label={label}\n labelProps={{ variant: \"large\" }}\n name={name || label}\n startOpen\n rows={5}\n value={currentValue}\n onChange={handleChange}\n helpLabel={helpLabel}\n counter={counter}\n />\n );\n};\n"],"names":["label","name","helpLabel","autoFocus","counter","useFeedbackContext","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","currentValue","useMemo","Array","isArray","value","toString","_a","jsx","TextArea","labelProps","variant","startOpen","rows","onChange","e","type","target","setCurrentValue","console","error"],"mappings":"+UAOqD,EACjDA,MAAAA,EACAC,KAAAA,EACAC,UAAAA,EAAY,uJACZC,UAAAA,GAAY,MAEN,MAAEC,QAAAA,GAAYC,
|
|
1
|
+
{"version":3,"file":"TextQuestion.cjs","sources":["../../../../../src/components/feedback/questions/TextQuestion.tsx"],"sourcesContent":["import React, { ChangeEventHandler, useEffect, useMemo, useRef } from \"react\";\nimport { TextArea } from \"../../text-input/TextArea.js\";\nimport { useFeedbackContext } from \"../feedbackContext.js\";\nimport { useFollowUpContext } from \"../followup/followupContext.js\";\nimport { useMainQuestionContext } from \"../main-question/mainQuestionContext.js\";\nimport { FeedbackAnswer, QuestionProps } from \"../types.js\";\n\nexport const TextQuestion: React.FC<QuestionProps> = ({\n label,\n name,\n helpLabel = \"Ikke skriv personlige opplysninger. Tilbakemeldinger som kommer inn her blir ikke besvart, men brukt i videre arbeid med å forbedre tjenestene våre.\",\n autoFocus = false,\n}) => {\n const { counter } = useFeedbackContext();\n const followupContext = useFollowUpContext();\n const feedbackContext = useMainQuestionContext();\n const context = followupContext || feedbackContext;\n const ref = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => {\n if (autoFocus && ref.current) {\n ref.current.focus();\n }\n }, [autoFocus, ref]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n const value: FeedbackAnswer = {\n label,\n name: name || label,\n type: \"text\",\n value: e.target.value,\n };\n context?.setCurrentValue(value);\n };\n\n const currentValue = useMemo(\n () =>\n Array.isArray(context?.currentValue)\n ? context?.currentValue[0].value.toString()\n : context?.currentValue?.value.toString(),\n [context?.currentValue],\n );\n\n if (!context) {\n console.error(\n \"Questions must be used inside a Followup or Feedback context provider\",\n );\n return null;\n }\n\n return (\n <TextArea\n ref={ref}\n label={label}\n labelProps={{ variant: \"large\" }}\n name={name || label}\n startOpen\n rows={5}\n value={currentValue}\n onChange={handleChange}\n helpLabel={helpLabel}\n counter={counter}\n />\n );\n};\n"],"names":["label","name","helpLabel","autoFocus","counter","useFeedbackContext","followupContext","useFollowUpContext","feedbackContext","useMainQuestionContext","context","ref","useRef","useEffect","current","focus","currentValue","useMemo","Array","isArray","value","toString","_a","jsx","TextArea","labelProps","variant","startOpen","rows","onChange","e","type","target","setCurrentValue","console","error"],"mappings":"+UAOqD,EACjDA,MAAAA,EACAC,KAAAA,EACAC,UAAAA,EAAY,uJACZC,UAAAA,GAAY,MAEN,MAAEC,QAAAA,GAAYC,EAAAA,qBACdC,EAAkBC,EAAAA,qBAClBC,EAAkBC,EAAAA,yBAClBC,EAAUJ,GAAmBE,EAC7BG,EAAMC,SAA4B,MAExCC,EAAAA,WAAU,KACFV,GAAaQ,EAAIG,SACjBH,EAAIG,QAAQC,UAEjB,CAACZ,EAAWQ,IAET,MAUAK,EAAeC,EAAAA,SACjB,WACI,OAAAC,MAAMC,QAAQ,MAAAT,OAAA,EAAAA,EAASM,cACjB,MAAAN,OAAAA,EAAAA,EAASM,aAAa,GAAGI,MAAMC,WAC/B,OAAAC,EAAA,MAAAZ,SAAAA,EAASM,mBAATM,EAAAA,EAAuBF,MAAMC,UAAA,GACvC,CAAC,MAAAX,OAAA,EAAAA,EAASM,eAGd,OAAKN,EAQDa,EAAAA,IAACC,EAAAA,SAAA,CACGb,IAAAA,EACAX,MAAAA,EACAyB,WAAY,CAAEC,QAAS,SACvBzB,KAAMA,GAAQD,EACd2B,WAAS,EACTC,KAAM,EACNR,MAAOJ,EACPa,SAlCuDC,IAC3D,MAAMV,EAAwB,CAC1BpB,MAAAA,EACAC,KAAMA,GAAQD,EACd+B,KAAM,OACNX,MAAOU,EAAEE,OAAOZ,OAEpB,MAAAV,GAAAA,EAASuB,gBAAgBb,EAAAA,EA4BrBlB,UAAAA,EACAE,QAAAA,KAjBI8B,QAAAC,MACJ,yEAEG,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smileyUtils.cjs","sources":["../../../../../src/components/feedback/questions/smileyUtils.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FeedbackOption } from \"../types.js\";\n\nexport const defaultOptions: FeedbackOption<number>[] = [\n {\n label: \"Veldig misfornøyd\",\n value: 1,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Litt misfornøyd\",\n value: 2,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Midt på treet\",\n value: 3,\n textAreaLabel:\n \"Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Ganske fornøyd\",\n value: 4,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Veldig fornøyd\",\n value: 5,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n];\n\nconst Smiley: FC<WithChildren> = ({ children }) => (\n <svg\n className=\"jkl-feedback-smiley-option__icon\"\n aria-hidden\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"20\" cy=\"20\" r=\"19\" stroke=\"currentColor\" strokeWidth=\"2\" />\n {children}\n </svg>\n);\n\nconst VeldigSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 30C10 24.4772 14.4772 20 20 20C25.5228 20 30 24.4772 30 30\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M10 13.9865H16.6667\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <path\n d=\"M23.3333 13.9865H29.9999\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n </Smiley>\n);\n\nconst LittSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 28.75C10 28.75 13.75 23.3334 20 23.3334C26.25 23.3334 30 28.75 30 28.75\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst NoytralSmiley = () => (\n <Smiley>\n <path\n d=\"M9.15283 25.6986H30.8477\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst LittGladSmiley = () => (\n <Smiley>\n <path\n d=\"M10 23.3334C10 23.3334 12.9167 30 20 30C27.0833 30 30 23.3334 30 23.3334\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst VeldigGladSmiley = () => (\n <Smiley>\n <path\n d=\"M30 21C30 26.5228 25.5228 31 20 31C14.4772 31 10 26.5228 10 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M24 14.5H29\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nexport const getSmiley = (value: number) => {\n switch (value) {\n case 1:\n return <VeldigSurSmiley />;\n case 2:\n return <LittSurSmiley />;\n case 3:\n return <NoytralSmiley />;\n case 4:\n return <LittGladSmiley />;\n case 5:\n return <VeldigGladSmiley />;\n\n default:\n return <NoytralSmiley />;\n }\n};\n"],"names":["Smiley","children","jsxs","className","viewBox","fill","xmlns","jsx","cx","cy","r","stroke","strokeWidth","VeldigSurSmiley","d","LittSurSmiley","NoytralSmiley","LittGladSmiley","VeldigGladSmiley","label","value","textAreaLabel"],"mappings":"qHAqCMA,EAA2B,EAAGC,SAAAA,KAChCC,EAAAA,KAAC,MAAA,CACGC,UAAU,mCACV,eAAW,EACXC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BAENL,SAAA,CAACM,EAAAA,IAAA,SAAA,CAAOC,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,OAAO,eAAeC,YAAY,MAChEX,KAIHY,EAAkB,IACpBX,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,YAEf,OAAK,CAAAE,EAAE,sBAAsBH,OAAO,eAAeC,YAAY,MAChEL,EAAAA,IAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,SAKlBG,EAAgB,IAClBb,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,8EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CW,EAAgB,IAClBd,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,MAEhBL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CY,EAAiB,IACnBf,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,2EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3Ca,EAAmB,IACrBhB,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,YAEf,OAAK,CAAAE,EAAE,cAAcH,OAAO,eAAeC,YAAY,MACxDL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,2CA1GO,CACpD,CACIc,MAAO,oBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,kBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,gBACPC,MAAO,EACPC,cACI,wEAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,+DAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,kFAiFcD,IACtB,OAAQA,GACJ,OACI,aAAQP,EAAgB,
|
|
1
|
+
{"version":3,"file":"smileyUtils.cjs","sources":["../../../../../src/components/feedback/questions/smileyUtils.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FeedbackOption } from \"../types.js\";\n\nexport const defaultOptions: FeedbackOption<number>[] = [\n {\n label: \"Veldig misfornøyd\",\n value: 1,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Litt misfornøyd\",\n value: 2,\n textAreaLabel:\n \"Det var leit! Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Midt på treet\",\n value: 3,\n textAreaLabel:\n \"Fortell oss gjerne hva du savner, så kan vi gjøre sidene våre bedre.\",\n },\n {\n label: \"Ganske fornøyd\",\n value: 4,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n {\n label: \"Veldig fornøyd\",\n value: 5,\n textAreaLabel:\n \"Så bra! Har du noen tilbakemeldinger kan du skrive dem her.\",\n },\n];\n\nconst Smiley: FC<WithChildren> = ({ children }) => (\n <svg\n className=\"jkl-feedback-smiley-option__icon\"\n aria-hidden\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <circle cx=\"20\" cy=\"20\" r=\"19\" stroke=\"currentColor\" strokeWidth=\"2\" />\n {children}\n </svg>\n);\n\nconst VeldigSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 30C10 24.4772 14.4772 20 20 20C25.5228 20 30 24.4772 30 30\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M10 13.9865H16.6667\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <path\n d=\"M23.3333 13.9865H29.9999\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n </Smiley>\n);\n\nconst LittSurSmiley = () => (\n <Smiley>\n <path\n d=\"M10 28.75C10 28.75 13.75 23.3334 20 23.3334C26.25 23.3334 30 28.75 30 28.75\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst NoytralSmiley = () => (\n <Smiley>\n <path\n d=\"M9.15283 25.6986H30.8477\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst LittGladSmiley = () => (\n <Smiley>\n <path\n d=\"M10 23.3334C10 23.3334 12.9167 30 20 30C27.0833 30 30 23.3334 30 23.3334\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n <circle cx=\"27.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nconst VeldigGladSmiley = () => (\n <Smiley>\n <path\n d=\"M30 21C30 26.5228 25.5228 31 20 31C14.4772 31 10 26.5228 10 21\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n />\n <path d=\"M24 14.5H29\" stroke=\"currentColor\" strokeWidth=\"2\" />\n <circle cx=\"12.5\" cy=\"14.5\" r=\"1.5\" fill=\"currentColor\" />\n </Smiley>\n);\n\nexport const getSmiley = (value: number) => {\n switch (value) {\n case 1:\n return <VeldigSurSmiley />;\n case 2:\n return <LittSurSmiley />;\n case 3:\n return <NoytralSmiley />;\n case 4:\n return <LittGladSmiley />;\n case 5:\n return <VeldigGladSmiley />;\n\n default:\n return <NoytralSmiley />;\n }\n};\n"],"names":["Smiley","children","jsxs","className","viewBox","fill","xmlns","jsx","cx","cy","r","stroke","strokeWidth","VeldigSurSmiley","d","LittSurSmiley","NoytralSmiley","LittGladSmiley","VeldigGladSmiley","label","value","textAreaLabel"],"mappings":"qHAqCMA,EAA2B,EAAGC,SAAAA,KAChCC,EAAAA,KAAC,MAAA,CACGC,UAAU,mCACV,eAAW,EACXC,QAAQ,YACRC,KAAK,OACLC,MAAM,6BAENL,SAAA,CAACM,EAAAA,IAAA,SAAA,CAAOC,GAAG,KAAKC,GAAG,KAAKC,EAAE,KAAKC,OAAO,eAAeC,YAAY,MAChEX,KAIHY,EAAkB,IACpBX,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,YAEf,OAAK,CAAAE,EAAE,sBAAsBH,OAAO,eAAeC,YAAY,MAChEL,EAAAA,IAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,SAKlBG,EAAgB,IAClBb,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,8EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CW,EAAgB,IAClBd,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,2BACFH,OAAO,eACPC,YAAY,MAEhBL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3CY,EAAiB,IACnBf,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,2EACFH,OAAO,eACPC,YAAY,MAEhBL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,iBACzCE,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,oBAI3Ca,EAAmB,IACrBhB,EAAAA,KAACF,EACG,CAAAC,SAAA,CAAAM,EAAAA,IAAC,OAAA,CACGO,EAAE,iEACFH,OAAO,eACPC,YAAY,YAEf,OAAK,CAAAE,EAAE,cAAcH,OAAO,eAAeC,YAAY,MACxDL,EAAAA,IAAC,UAAOC,GAAG,OAAOC,GAAG,OAAOC,EAAE,MAAML,KAAK,2CA1GO,CACpD,CACIc,MAAO,oBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,kBACPC,MAAO,EACPC,cACI,sFAER,CACIF,MAAO,gBACPC,MAAO,EACPC,cACI,wEAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,+DAER,CACIF,MAAO,iBACPC,MAAO,EACPC,cACI,kFAiFcD,IACtB,OAAQA,GACJ,OACI,aAAQP,EAAgB,CAAA,GAC5B,KAAK,EACD,aAAQE,EAAc,CAAA,GAC1B,KACI,EAMJ,QACI,aAAQC,EAAc,CAAA,GAN1B,KACI,EAAA,aAAQC,EAAe,CAAA,GAC3B,OACI,aAAQC,EAAiB,CAAA,GAIjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../../../src/components/feedback/utils.ts"],"sourcesContent":["import React, { JSXElementConstructor, FC } from \"react\";\nimport {\n CheckboxQuestion,\n RadioQuestion,\n TextQuestion,\n SmileyQuestion,\n} from \"./questions/index.js\";\nimport { QuestionProps, QuestionType } from \"./types.js\";\n\nexport function getChildrenOfType<P>(\n ...allowedTypes: Array<string | JSXElementConstructor<P>>\n) {\n return (\n children: React.ReactNode,\n ):\n | React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[]\n | null\n | undefined =>\n React.Children.map(children, (child) => {\n if (\n React.isValidElement<P>(child) &&\n allowedTypes.includes(child.type)\n ) {\n return child;\n }\n return undefined;\n });\n}\n\nexport const getQuestionFromType = (type: QuestionType): FC<QuestionProps> => {\n switch (type) {\n case \"radio\":\n return RadioQuestion;\n case \"checkbox\":\n return CheckboxQuestion;\n case \"text\":\n return TextQuestion;\n case \"smiley\":\n return SmileyQuestion;\n\n default:\n return RadioQuestion;\n }\n};\n"],"names":["allowedTypes","children","React","Children","map","child","isValidElement","includes","type","RadioQuestion","CheckboxQuestion","TextQuestion","SmileyQuestion"],"mappings":"kjBASO,YACAA,GAEH,OACIC,GAKAC,EAAMC,SAASC,IAAIH,GAAWI,IAEtB,GAAAH,EAAMI,eAAkBD,IACxBL,EAAaO,SAASF,EAAMG,MAErB,OAAAH,IAIvB,8BAEoCG,IAChC,OAAQA,GACJ,IAAK,QASL,QACW,OAAAC,
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../../../src/components/feedback/utils.ts"],"sourcesContent":["import React, { JSXElementConstructor, FC } from \"react\";\nimport {\n CheckboxQuestion,\n RadioQuestion,\n TextQuestion,\n SmileyQuestion,\n} from \"./questions/index.js\";\nimport { QuestionProps, QuestionType } from \"./types.js\";\n\nexport function getChildrenOfType<P>(\n ...allowedTypes: Array<string | JSXElementConstructor<P>>\n) {\n return (\n children: React.ReactNode,\n ):\n | React.ReactElement<P, string | React.JSXElementConstructor<unknown>>[]\n | null\n | undefined =>\n React.Children.map(children, (child) => {\n if (\n React.isValidElement<P>(child) &&\n allowedTypes.includes(child.type)\n ) {\n return child;\n }\n return undefined;\n });\n}\n\nexport const getQuestionFromType = (type: QuestionType): FC<QuestionProps> => {\n switch (type) {\n case \"radio\":\n return RadioQuestion;\n case \"checkbox\":\n return CheckboxQuestion;\n case \"text\":\n return TextQuestion;\n case \"smiley\":\n return SmileyQuestion;\n\n default:\n return RadioQuestion;\n }\n};\n"],"names":["allowedTypes","children","React","Children","map","child","isValidElement","includes","type","RadioQuestion","CheckboxQuestion","TextQuestion","SmileyQuestion"],"mappings":"kjBASO,YACAA,GAEH,OACIC,GAKAC,EAAMC,SAASC,IAAIH,GAAWI,IAEtB,GAAAH,EAAMI,eAAkBD,IACxBL,EAAaO,SAASF,EAAMG,MAErB,OAAAH,IAIvB,8BAEoCG,IAChC,OAAQA,GACJ,IAAK,QASL,QACW,OAAAC,gBARX,IAAK,WACM,OAAAC,mBACX,IAAK,OACM,OAAAC,eACX,IAAK,SACM,OAAAC,iBAIf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.cjs","sources":["../../../../src/components/file-input/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC, MouseEvent } from \"react\";\nimport { TrashCanIcon, SuccessIcon } from \"../../components/icon/index.js\";\nimport { IconButton } from \"../../components/icon-button/IconButton.js\";\nimport { SupportLabel } from \"../../components/input-group/SupportLabel.js\";\nimport { type WithOptionalChildren } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { formatBytes } from \"../../utilities/formatters/bytes/formatBytes.js\";\nimport { useFileInputContext } from \"./internal/fileInputContext.js\";\nimport { Thumbnail } from \"./internal/Thumbnail.js\";\nimport { FileInputFileState } from \"./types.js\";\n\nexport interface FileProps extends WithOptionalChildren {\n fileName: string;\n fileType: string;\n fileSize: number;\n path?: string;\n file?: File;\n supportLabel?: string;\n supportLabelType?: \"help\" | \"error\" | \"warning\" | \"success\";\n state?: FileInputFileState;\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const File: FC<FileProps> = (props) => {\n const {\n children,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n supportLabel,\n supportLabelType,\n state,\n onRemove,\n } = props;\n\n const id = useId(\"jkl-file-preview\");\n const supportId = id + \"-support\";\n\n const context = useFileInputContext();\n\n const Component = path ? \"a\" : \"div\";\n\n const hasErrorOrWarning =\n supportLabelType === \"error\" || supportLabelType === \"warning\";\n const hasSuccess = supportLabelType === \"success\";\n\n const renderFeedbackElement = () => {\n if (!hasErrorOrWarning && !hasSuccess) {\n return (\n <SupportLabel\n className=\"jkl-file__support-label jkl-body\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n );\n }\n\n if (hasSuccess)\n return (\n <SuccessIcon\n variant=\"small\"\n aria-label=\"Filen ble lastet opp uten feil\"\n />\n );\n\n return null;\n };\n\n const fileComponent = (\n <div id={id} className=\"jkl-file\">\n <Component\n className={clsx(\"jkl-file__content\", {\n \"jkl-file__content--error\": supportLabelType === \"error\",\n \"jkl-file__content--warning\":\n supportLabelType === \"warning\",\n })}\n href={path}\n target={path ? \"_blank\" : undefined}\n >\n <Thumbnail\n fileName={fileName}\n fileType={fileType}\n file={file}\n path={path}\n state={state}\n >\n {children}\n </Thumbnail>\n <div>\n <p className=\"jkl-file__name\">{fileName}</p>\n <p className=\"jkl-file__description\">\n <span>{formatBytes(fileSize)}</span>\n {renderFeedbackElement()}\n </p>\n {supportLabel && hasErrorOrWarning && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n )}\n </div>\n </Component>\n {onRemove && (\n <IconButton\n className=\"jkl-file__delete\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n >\n <TrashCanIcon />\n </IconButton>\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["props","children","fileName","fileType","fileSize","path","file","supportLabel","supportLabelType","state","onRemove","id","useId","supportId","context","useFileInputContext","Component","hasErrorOrWarning","hasSuccess","fileComponent","jsxs","className","clsx","href","target","jsx","Thumbnail","formatBytes","SuccessIcon","variant","SupportLabel","label","labelType","IconButton","onClick","title","TrashCanIcon"],"mappings":"48DAwBoCA,IAC1B,MACFC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,aAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,SAAAA,GACAV,EAEEW,EAAKC,QAAM,oBACXC,EAAYF,EAAK,WAEjBG,EAAUC,EAAAA,sBAEVC,EAAYX,EAAO,IAAM,MAEzBY,EACmB,UAArBT,GAAqD,YAArBA,EAC9BU,EAAkC,YAArBV,EAyBbW,EACFC,EAAAA,KAAC,MAAI,CAAAT,GAAAA,EAAQU,UAAU,WACnBpB,SAAA,CAAAmB,EAAAA,KAACJ,EAAA,CACGK,UAAWC,OAAK,oBAAqB,CACjC,2BAAiD,UAArBd,EAC5B,6BACyB,YAArBA,IAERe,KAAMlB,EACNmB,OAAQnB,EAAO,cAAW,EAE1BJ,SAAA,CAAAwB,EAAAA,IAACC,EAAAA,UAAA,CACGxB,SAAAA,EACAC,SAAAA,EACAG,KAAAA,EACAD,KAAAA,EACAI,MAAAA,EAECR,SAAAA,WAEJ,MACG,CAAAA,SAAA,CAACwB,EAAAA,IAAA,IAAA,CAAEJ,UAAU,iBAAkBpB,SAASC,IACxCkB,EAAAA,KAAC,IAAE,CAAAC,UAAU,wBACTpB,SAAA,CAACwB,EAAAA,IAAA,OAAA,CAAMxB,SAAY0B,EAAAA,YAAAvB,KA7C9Ba,GAAsBC,EAWvBA,EAEIO,EAAAA,IAACG,EAAAA,YAAA,CACGC,QAAQ,QACR,aAAW,mCAIhB,KAjBCJ,EAAAA,IAACK,EAAAA,aAAA,CACGT,UAAU,mCACVV,GAAIE,EACJkB,MAAOxB,EACPyB,UAAWxB,OA0CVD,GAAgBU,GACbQ,EAAAA,IAACK,EAAAA,aAAA,CACGT,UAAU,0BACVV,GAAIE,EACJkB,MAAOxB,EACPyB,UAAWxB,UAK1BE,GACGe,EAAAA,IAACQ,EAAAA,WAAA,CACGZ,UAAU,mBACVa,QAASxB,EACTyB,MAAO,SAASjC,IAEhBD,eAACmC,
|
|
1
|
+
{"version":3,"file":"File.cjs","sources":["../../../../src/components/file-input/File.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { FC, MouseEvent } from \"react\";\nimport { TrashCanIcon, SuccessIcon } from \"../../components/icon/index.js\";\nimport { IconButton } from \"../../components/icon-button/IconButton.js\";\nimport { SupportLabel } from \"../../components/input-group/SupportLabel.js\";\nimport { type WithOptionalChildren } from \"../../core/types.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { formatBytes } from \"../../utilities/formatters/bytes/formatBytes.js\";\nimport { useFileInputContext } from \"./internal/fileInputContext.js\";\nimport { Thumbnail } from \"./internal/Thumbnail.js\";\nimport { FileInputFileState } from \"./types.js\";\n\nexport interface FileProps extends WithOptionalChildren {\n fileName: string;\n fileType: string;\n fileSize: number;\n path?: string;\n file?: File;\n supportLabel?: string;\n supportLabelType?: \"help\" | \"error\" | \"warning\" | \"success\";\n state?: FileInputFileState;\n onRemove?: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nexport const File: FC<FileProps> = (props) => {\n const {\n children,\n fileName,\n fileType,\n fileSize,\n path,\n file,\n supportLabel,\n supportLabelType,\n state,\n onRemove,\n } = props;\n\n const id = useId(\"jkl-file-preview\");\n const supportId = id + \"-support\";\n\n const context = useFileInputContext();\n\n const Component = path ? \"a\" : \"div\";\n\n const hasErrorOrWarning =\n supportLabelType === \"error\" || supportLabelType === \"warning\";\n const hasSuccess = supportLabelType === \"success\";\n\n const renderFeedbackElement = () => {\n if (!hasErrorOrWarning && !hasSuccess) {\n return (\n <SupportLabel\n className=\"jkl-file__support-label jkl-body\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n );\n }\n\n if (hasSuccess)\n return (\n <SuccessIcon\n variant=\"small\"\n aria-label=\"Filen ble lastet opp uten feil\"\n />\n );\n\n return null;\n };\n\n const fileComponent = (\n <div id={id} className=\"jkl-file\">\n <Component\n className={clsx(\"jkl-file__content\", {\n \"jkl-file__content--error\": supportLabelType === \"error\",\n \"jkl-file__content--warning\":\n supportLabelType === \"warning\",\n })}\n href={path}\n target={path ? \"_blank\" : undefined}\n >\n <Thumbnail\n fileName={fileName}\n fileType={fileType}\n file={file}\n path={path}\n state={state}\n >\n {children}\n </Thumbnail>\n <div>\n <p className=\"jkl-file__name\">{fileName}</p>\n <p className=\"jkl-file__description\">\n <span>{formatBytes(fileSize)}</span>\n {renderFeedbackElement()}\n </p>\n {supportLabel && hasErrorOrWarning && (\n <SupportLabel\n className=\"jkl-file__support-label\"\n id={supportId}\n label={supportLabel}\n labelType={supportLabelType}\n />\n )}\n </div>\n </Component>\n {onRemove && (\n <IconButton\n className=\"jkl-file__delete\"\n onClick={onRemove}\n title={`Fjern ${fileName}`}\n >\n <TrashCanIcon />\n </IconButton>\n )}\n </div>\n );\n\n return context ? <li>{fileComponent}</li> : fileComponent;\n};\n"],"names":["props","children","fileName","fileType","fileSize","path","file","supportLabel","supportLabelType","state","onRemove","id","useId","supportId","context","useFileInputContext","Component","hasErrorOrWarning","hasSuccess","fileComponent","jsxs","className","clsx","href","target","jsx","Thumbnail","formatBytes","SuccessIcon","variant","SupportLabel","label","labelType","IconButton","onClick","title","TrashCanIcon"],"mappings":"48DAwBoCA,IAC1B,MACFC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,SAAAA,EACAC,KAAAA,EACAC,KAAAA,EACAC,aAAAA,EACAC,iBAAAA,EACAC,MAAAA,EACAC,SAAAA,GACAV,EAEEW,EAAKC,QAAM,oBACXC,EAAYF,EAAK,WAEjBG,EAAUC,EAAAA,sBAEVC,EAAYX,EAAO,IAAM,MAEzBY,EACmB,UAArBT,GAAqD,YAArBA,EAC9BU,EAAkC,YAArBV,EAyBbW,EACFC,EAAAA,KAAC,MAAI,CAAAT,GAAAA,EAAQU,UAAU,WACnBpB,SAAA,CAAAmB,EAAAA,KAACJ,EAAA,CACGK,UAAWC,OAAK,oBAAqB,CACjC,2BAAiD,UAArBd,EAC5B,6BACyB,YAArBA,IAERe,KAAMlB,EACNmB,OAAQnB,EAAO,cAAW,EAE1BJ,SAAA,CAAAwB,EAAAA,IAACC,EAAAA,UAAA,CACGxB,SAAAA,EACAC,SAAAA,EACAG,KAAAA,EACAD,KAAAA,EACAI,MAAAA,EAECR,SAAAA,WAEJ,MACG,CAAAA,SAAA,CAACwB,EAAAA,IAAA,IAAA,CAAEJ,UAAU,iBAAkBpB,SAASC,IACxCkB,EAAAA,KAAC,IAAE,CAAAC,UAAU,wBACTpB,SAAA,CAACwB,EAAAA,IAAA,OAAA,CAAMxB,SAAY0B,EAAAA,YAAAvB,KA7C9Ba,GAAsBC,EAWvBA,EAEIO,EAAAA,IAACG,EAAAA,YAAA,CACGC,QAAQ,QACR,aAAW,mCAIhB,KAjBCJ,EAAAA,IAACK,EAAAA,aAAA,CACGT,UAAU,mCACVV,GAAIE,EACJkB,MAAOxB,EACPyB,UAAWxB,OA0CVD,GAAgBU,GACbQ,EAAAA,IAACK,EAAAA,aAAA,CACGT,UAAU,0BACVV,GAAIE,EACJkB,MAAOxB,EACPyB,UAAWxB,UAK1BE,GACGe,EAAAA,IAACQ,EAAAA,WAAA,CACGZ,UAAU,mBACVa,QAASxB,EACTyB,MAAO,SAASjC,IAEhBD,eAACmC,EAAaA,aAAA,SAM9B,OAAOtB,EAAUW,EAAAA,IAAC,KAAI,CAAAxB,SAAAkB,IAAsBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.cjs","sources":["../../../../src/components/file-input/FileInput.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useId } from \"react\";\nimport {\n FieldGroup,\n type FieldGroupProps,\n} from \"../../components/input-group/FieldGroup.js\";\nimport { type Density } from \"../../core/types.js\";\nimport { Dropzone } from \"./internal/Dropzone.js\";\nimport { FileInputContextProvider } from \"./internal/fileInputContext.js\";\nimport { Input } from \"./internal/Input.js\";\nimport { MaxSize } from \"./internal/MaxSize.js\";\nimport { FileInputFile } from \"./types.js\";\n\nexport interface FileInputProps extends Omit<FieldGroupProps, \"onChange\"> {\n className?: string;\n id?: string;\n density?: Density;\n /**\n * En string som begrenser hvilke filtyper som kan velges.\n *\n * Flere filtyper kan defineres som en kommaseparert liste.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept\n */\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n /**\n * @default true\n */\n multiple?: boolean;\n value: FileInputFile[];\n variant?: \"flexible\" | \"small\";\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n}\n\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const {\n accept,\n className,\n children,\n id,\n value,\n density,\n multiple = true,\n maxSizeBytes,\n onChange,\n variant,\n ...rest\n } = props;\n\n const hasFiles = value.length > 0;\n\n const maxSizeDescriptionId = useId();\n\n if (variant === \"small\") {\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\n \"jkl-file-input\",\n \"jkl-file-input--small\",\n className,\n {\n \"jkl-file-input--has-files\": hasFiles,\n },\n )}\n data-layout-density={density ? density : \"compact\"}\n {...rest}\n >\n <Dropzone>\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label=\"Legg til fil\"\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n </div>\n </Dropzone>\n <MaxSize id={maxSizeDescriptionId} />\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n </FieldGroup>\n </FileInputContextProvider>\n );\n }\n\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\"jkl-file-input\", className, {\n \"jkl-file-input--has-files\": hasFiles,\n })}\n data-layout-density={density}\n {...rest}\n >\n <Dropzone>\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label={\n multiple && hasFiles\n ? \"Legg til flere filer\"\n : \"Legg til fil\"\n }\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n <MaxSize id={maxSizeDescriptionId} />\n </div>\n </Dropzone>\n </FieldGroup>\n </FileInputContextProvider>\n );\n },\n);\n\nFileInput.displayName = \"FileInput\";\n"],"names":["FileInput","forwardRef","props","ref","accept","className","children","id","value","density","multiple","maxSizeBytes","onChange","variant","rest","hasFiles","length","maxSizeDescriptionId","useId","jsx","FileInputContextProvider","context","files","jsxs","FieldGroup","clsx","Dropzone","Input","label","MaxSize","displayName"],"mappings":"mXAwCaA,EAAYC,EAAAA,YACrB,CAACC,EAAOC,KACE,MACFC,OAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,GAAAA,EACAC,MAAAA,EACAC,QAAAA,EACAC,SAAAA,GAAW,EACXC,aAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,GACHZ,EAEEa,EAAWP,EAAMQ,OAAS,EAE1BC,EAAuBC,EAAAA,QAE7B,MAAgB,UAAZL,EAEIM,EAAAA,IAACC,EAAAA,yBAAA,CACGC,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAiB,EAAAA,KAACC,EAAAA,WAAA,CACGnB,UAAWoB,EAAAA,KACP,iBACA,wBACApB,EACA,CACI,4BAA6BU,IAGrC,sBAAqBN,GAAoB,aACrCK,EAEJR,SAAA,CAAAa,MAACO,EAAAA,SACG,CAAApB,SAAAa,EAAAA,IAAC,MAAI,CAAAd,UAAU,iCACXC,SAAAa,EAAAA,IAACQ,EAAAA,MAAA,CACGpB,GAAAA,EACAqB,MAAM,eACNlB,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,QAI9BE,EAAAA,IAACU,EAAQA,QAAA,CAAAtB,GAAIU,IACZT,EAAMQ,OAAS,SACX,KAAG,CAAAX,UAAU,wBACTC,SAAAA,SASrBa,EAAAA,IAACC,EAAAA,yBAAA,CACGC,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAa,EAAAA,IAACK,EAAAA,WAAA,CACGnB,UAAWoB,EAAAA,KAAK,iBAAkBpB,EAAW,CACzC,4BAA6BU,IAEjC,sBAAqBN,KACjBK,EAEJR,gBAACoB,WACI,CAAApB,SAAA,CAAAE,EAAMQ,OAAS,GACZG,EAAAA,IAAC,KAAG,CAAAd,UAAU,wBACTC,SAAAA,IAGTiB,EAAAA,KAAC,MAAI,CAAAlB,UAAU,iCACXC,SAAA,CAAAa,EAAAA,IAACQ,EAAAA,MAAA,CACGpB,GAAAA,EACAqB,MACIlB,GAAYK,EACN,uBACA,eAEVL,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,IAEtBE,EAAAA,IAACU,EAAQA,QAAA,CAAAtB,GAAIU,
|
|
1
|
+
{"version":3,"file":"FileInput.cjs","sources":["../../../../src/components/file-input/FileInput.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useId } from \"react\";\nimport {\n FieldGroup,\n type FieldGroupProps,\n} from \"../../components/input-group/FieldGroup.js\";\nimport { type Density } from \"../../core/types.js\";\nimport { Dropzone } from \"./internal/Dropzone.js\";\nimport { FileInputContextProvider } from \"./internal/fileInputContext.js\";\nimport { Input } from \"./internal/Input.js\";\nimport { MaxSize } from \"./internal/MaxSize.js\";\nimport { FileInputFile } from \"./types.js\";\n\nexport interface FileInputProps extends Omit<FieldGroupProps, \"onChange\"> {\n className?: string;\n id?: string;\n density?: Density;\n /**\n * En string som begrenser hvilke filtyper som kan velges.\n *\n * Flere filtyper kan defineres som en kommaseparert liste.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept\n */\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n /**\n * @default true\n */\n multiple?: boolean;\n value: FileInputFile[];\n variant?: \"flexible\" | \"small\";\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n}\n\nexport const FileInput = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const {\n accept,\n className,\n children,\n id,\n value,\n density,\n multiple = true,\n maxSizeBytes,\n onChange,\n variant,\n ...rest\n } = props;\n\n const hasFiles = value.length > 0;\n\n const maxSizeDescriptionId = useId();\n\n if (variant === \"small\") {\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\n \"jkl-file-input\",\n \"jkl-file-input--small\",\n className,\n {\n \"jkl-file-input--has-files\": hasFiles,\n },\n )}\n data-layout-density={density ? density : \"compact\"}\n {...rest}\n >\n <Dropzone>\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label=\"Legg til fil\"\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n </div>\n </Dropzone>\n <MaxSize id={maxSizeDescriptionId} />\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n </FieldGroup>\n </FileInputContextProvider>\n );\n }\n\n return (\n <FileInputContextProvider\n context={{ accept, onChange, maxSizeBytes, files: value }}\n >\n <FieldGroup\n className={clsx(\"jkl-file-input\", className, {\n \"jkl-file-input--has-files\": hasFiles,\n })}\n data-layout-density={density}\n {...rest}\n >\n <Dropzone>\n {value.length > 0 && (\n <ul className=\"jkl-file-input__files\">\n {children}\n </ul>\n )}\n <div className=\"jkl-file-input__call-to-action\">\n <Input\n id={id}\n label={\n multiple && hasFiles\n ? \"Legg til flere filer\"\n : \"Legg til fil\"\n }\n multiple={multiple}\n ref={ref}\n aria-describedby={maxSizeDescriptionId}\n />\n <MaxSize id={maxSizeDescriptionId} />\n </div>\n </Dropzone>\n </FieldGroup>\n </FileInputContextProvider>\n );\n },\n);\n\nFileInput.displayName = \"FileInput\";\n"],"names":["FileInput","forwardRef","props","ref","accept","className","children","id","value","density","multiple","maxSizeBytes","onChange","variant","rest","hasFiles","length","maxSizeDescriptionId","useId","jsx","FileInputContextProvider","context","files","jsxs","FieldGroup","clsx","Dropzone","Input","label","MaxSize","displayName"],"mappings":"mXAwCaA,EAAYC,EAAAA,YACrB,CAACC,EAAOC,KACE,MACFC,OAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,GAAAA,EACAC,MAAAA,EACAC,QAAAA,EACAC,SAAAA,GAAW,EACXC,aAAAA,EACAC,SAAAA,EACAC,QAAAA,KACGC,GACHZ,EAEEa,EAAWP,EAAMQ,OAAS,EAE1BC,EAAuBC,EAAAA,QAE7B,MAAgB,UAAZL,EAEIM,EAAAA,IAACC,EAAAA,yBAAA,CACGC,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAiB,EAAAA,KAACC,EAAAA,WAAA,CACGnB,UAAWoB,EAAAA,KACP,iBACA,wBACApB,EACA,CACI,4BAA6BU,IAGrC,sBAAqBN,GAAoB,aACrCK,EAEJR,SAAA,CAAAa,MAACO,EAAAA,SACG,CAAApB,SAAAa,EAAAA,IAAC,MAAI,CAAAd,UAAU,iCACXC,SAAAa,EAAAA,IAACQ,EAAAA,MAAA,CACGpB,GAAAA,EACAqB,MAAM,eACNlB,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,QAI9BE,EAAAA,IAACU,EAAQA,QAAA,CAAAtB,GAAIU,IACZT,EAAMQ,OAAS,SACX,KAAG,CAAAX,UAAU,wBACTC,SAAAA,SASrBa,EAAAA,IAACC,EAAAA,yBAAA,CACGC,QAAS,CAAEjB,OAAAA,EAAQQ,SAAAA,EAAUD,aAAAA,EAAcW,MAAOd,GAElDF,SAAAa,EAAAA,IAACK,EAAAA,WAAA,CACGnB,UAAWoB,EAAAA,KAAK,iBAAkBpB,EAAW,CACzC,4BAA6BU,IAEjC,sBAAqBN,KACjBK,EAEJR,gBAACoB,WACI,CAAApB,SAAA,CAAAE,EAAMQ,OAAS,GACZG,EAAAA,IAAC,KAAG,CAAAd,UAAU,wBACTC,SAAAA,IAGTiB,EAAAA,KAAC,MAAI,CAAAlB,UAAU,iCACXC,SAAA,CAAAa,EAAAA,IAACQ,EAAAA,MAAA,CACGpB,GAAAA,EACAqB,MACIlB,GAAYK,EACN,uBACA,eAEVL,SAAAA,EACAP,IAAAA,EACA,mBAAkBc,IAEtBE,EAAAA,IAACU,EAAQA,QAAA,CAAAtB,GAAIU,aAGzB,IAMhBjB,EAAU8B,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.cjs","sources":["../../../../../src/components/file-input/internal/Dropzone.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useState } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface DropzoneProps extends WithChildren {}\n\nexport const Dropzone = forwardRef<HTMLDivElement, DropzoneProps>(\n (props, ref) => {\n const { children, ...rest } = props;\n const [onDragClassName, setOnDragClassName] = useState<string>(\"\");\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>\n Dropzone must be placed inside a FileInputContextProvider.\n </p>\n );\n }\n const { maxSizeBytes, accept, onChange } = context;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={clsx(\"jkl-file-input__dropzone\", onDragClassName)}\n onDragEnter={(e) => {\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDragOver={(e) => {\n /* Prevent browser from opening file in a new tab */\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDrop={(e) => {\n e.preventDefault();\n setOnDragClassName(\"\");\n\n if (e.dataTransfer.files) {\n onChange(\n e,\n [...e.dataTransfer.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n onDragLeave={(e) => {\n setOnDragClassName(\"\");\n e.preventDefault();\n }}\n >\n {children}\n </div>\n );\n },\n);\n\nDropzone.displayName = \"Dropzone\";\n"],"names":["Dropzone","forwardRef","props","ref","children","rest","onDragClassName","setOnDragClassName","useState","context","useFileInputContext","jsx","maxSizeBytes","accept","onChange","className","clsx","onDragEnter","e","preventDefault","onDragOver","onDrop","dataTransfer","files","map","file","state","validation","validateFile","uploadProgress","onDragLeave","displayName"],"mappings":"uPASaA,EAAWC,EAAAA,YACpB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,KAAaC,GAASH,GACvBI,EAAiBC,GAAsBC,
|
|
1
|
+
{"version":3,"file":"Dropzone.cjs","sources":["../../../../../src/components/file-input/internal/Dropzone.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef, useState } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface DropzoneProps extends WithChildren {}\n\nexport const Dropzone = forwardRef<HTMLDivElement, DropzoneProps>(\n (props, ref) => {\n const { children, ...rest } = props;\n const [onDragClassName, setOnDragClassName] = useState<string>(\"\");\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>\n Dropzone must be placed inside a FileInputContextProvider.\n </p>\n );\n }\n const { maxSizeBytes, accept, onChange } = context;\n\n return (\n <div\n {...rest}\n ref={ref}\n className={clsx(\"jkl-file-input__dropzone\", onDragClassName)}\n onDragEnter={(e) => {\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDragOver={(e) => {\n /* Prevent browser from opening file in a new tab */\n setOnDragClassName(\"jkl-file-input__dropzone--enter\");\n e.preventDefault();\n }}\n onDrop={(e) => {\n e.preventDefault();\n setOnDragClassName(\"\");\n\n if (e.dataTransfer.files) {\n onChange(\n e,\n [...e.dataTransfer.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n onDragLeave={(e) => {\n setOnDragClassName(\"\");\n e.preventDefault();\n }}\n >\n {children}\n </div>\n );\n },\n);\n\nDropzone.displayName = \"Dropzone\";\n"],"names":["Dropzone","forwardRef","props","ref","children","rest","onDragClassName","setOnDragClassName","useState","context","useFileInputContext","jsx","maxSizeBytes","accept","onChange","className","clsx","onDragEnter","e","preventDefault","onDragOver","onDrop","dataTransfer","files","map","file","state","validation","validateFile","uploadProgress","onDragLeave","displayName"],"mappings":"uPASaA,EAAWC,EAAAA,YACpB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,KAAaC,GAASH,GACvBI,EAAiBC,GAAsBC,WAAiB,IAEzDC,EAAUC,EAAAA,sBAChB,IAAKD,EAEG,OAAAE,EAAAA,IAAC,KAAEP,SAEH,+DAGR,MAAQQ,aAAAA,EAAcC,OAAAA,EAAQC,SAAAA,GAAaL,EAGvC,OAAAE,EAAAA,IAAC,MAAA,IACON,EACJF,IAAAA,EACAY,UAAWC,EAAAA,KAAK,2BAA4BV,GAC5CW,YAAcC,IACVX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBC,WAAaF,IAETX,EAAmB,mCACnBW,EAAEC,gBAAe,EAErBE,OAASH,IACLA,EAAEC,iBACFZ,EAAmB,IAEfW,EAAEI,aAAaC,OACfT,EACII,EACA,IAAIA,EAAEI,aAAaC,OAAOC,KACrBC,IAAAA,CACGA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EAAAA,aACRH,EACAZ,EACAD,GAEJiB,eAAgB,MAExB,EAIZC,YAAcZ,IACVX,EAAmB,IACnBW,EAAEC,gBAAe,EAGpBf,SAAAA,GAAA,IAMjBJ,EAAS+B,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.cjs","sources":["../../../../../src/components/file-input/internal/Input.tsx"],"sourcesContent":["import React, { forwardRef, useId } from \"react\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface FileInputProps {\n id?: string;\n label: string;\n multiple: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const { multiple, id, label, ...rest } = props;\n\n const defaultId = useId();\n\n const maxSizeDescriptionId = id + \"-description\";\n const descriptor = multiple ? \"filer\" : \"fil\";\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>Input must be placed inside a FileInputContextProvider.</p>\n );\n }\n const { accept, maxSizeBytes, onChange } = context;\n\n const elementId = id || defaultId;\n\n return (\n <>\n <label\n className=\"jkl-button jkl-button--secondary\"\n htmlFor={elementId}\n id={`${elementId}__add-btn`}\n >\n {label}\n </label>\n <input\n {...rest}\n ref={ref}\n id={elementId}\n accept={accept}\n aria-describedby={\n maxSizeBytes ? maxSizeDescriptionId : undefined\n }\n className=\"jkl-sr-only\"\n type=\"file\"\n multiple={multiple}\n value=\"\"\n onChange={(e) => {\n if (e.target.files) {\n onChange(\n e,\n [...e.target.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n />\n <p className=\"jkl-file-input__dropzone-hint\">\n eller slipp {descriptor} her\n </p>{\" \"}\n </>\n );\n },\n);\n\nInput.displayName = \"Input\";\n"],"names":["Input","forwardRef","props","ref","multiple","id","label","rest","defaultId","useId","maxSizeDescriptionId","descriptor","context","useFileInputContext","jsx","children","accept","maxSizeBytes","onChange","elementId","jsxs","Fragment","className","htmlFor","type","value","e","target","files","map","file","state","validation","validateFile","uploadProgress","displayName"],"mappings":"4MAWaA,EAAQC,EAAAA,YACjB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,EAAUC,GAAAA,EAAIC,MAAAA,KAAUC,GAASL,EAEnCM,EAAYC,EAAAA,QAEZC,EAAuBL,EAAK,eAC5BM,EAAaP,EAAW,QAAU,MAElCQ,EAAUC,EAAAA,sBAChB,IAAKD,EAEG,OAAAE,EAAAA,IAAC,KAAEC,SAAuD,4DAGlE,MAAQC,OAAAA,EAAQC,aAAAA,EAAcC,SAAAA,GAAaN,EAErCO,EAAYd,GAAMG,EAExB,OAEQY,EAAAA,KAAAC,WAAA,CAAAN,SAAA,CAAAD,EAAAA,IAAC,QAAA,CACGQ,UAAU,mCACVC,QAASJ,EACTd,GAAI,GAAGc,aAENJ,SAAAT,IAELQ,EAAAA,IAAC,QAAA,IACOP,EACJJ,IAAAA,EACAE,GAAIc,EACJH,OAAAA,EACA,mBACIC,EAAeP,OAAuB,EAE1CY,UAAU,cACVE,KAAK,OACLpB,SAAAA,EACAqB,MAAM,GACNP,SAAWQ,IACHA,EAAEC,OAAOC,OACTV,EACIQ,EACA,IAAIA,EAAEC,OAAOC,OAAOC,KACfC,KACGA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EAAAA,aACRH,EACAd,EACAC,GAEJiB,eAAgB,
|
|
1
|
+
{"version":3,"file":"Input.cjs","sources":["../../../../../src/components/file-input/internal/Input.tsx"],"sourcesContent":["import React, { forwardRef, useId } from \"react\";\nimport { FileInputFile } from \"../types.js\";\nimport { useFileInputContext } from \"./fileInputContext.js\";\nimport { validateFile } from \"./validateFile.js\";\n\ninterface FileInputProps {\n id?: string;\n label: string;\n multiple: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, FileInputProps>(\n (props, ref) => {\n const { multiple, id, label, ...rest } = props;\n\n const defaultId = useId();\n\n const maxSizeDescriptionId = id + \"-description\";\n const descriptor = multiple ? \"filer\" : \"fil\";\n\n const context = useFileInputContext();\n if (!context) {\n return (\n <p>Input must be placed inside a FileInputContextProvider.</p>\n );\n }\n const { accept, maxSizeBytes, onChange } = context;\n\n const elementId = id || defaultId;\n\n return (\n <>\n <label\n className=\"jkl-button jkl-button--secondary\"\n htmlFor={elementId}\n id={`${elementId}__add-btn`}\n >\n {label}\n </label>\n <input\n {...rest}\n ref={ref}\n id={elementId}\n accept={accept}\n aria-describedby={\n maxSizeBytes ? maxSizeDescriptionId : undefined\n }\n className=\"jkl-sr-only\"\n type=\"file\"\n multiple={multiple}\n value=\"\"\n onChange={(e) => {\n if (e.target.files) {\n onChange(\n e,\n [...e.target.files].map<FileInputFile>(\n (file) => ({\n file,\n state: \"SELECTED\",\n validation: validateFile(\n file,\n accept,\n maxSizeBytes,\n ),\n uploadProgress: 0,\n }),\n ),\n );\n }\n }}\n />\n <p className=\"jkl-file-input__dropzone-hint\">\n eller slipp {descriptor} her\n </p>{\" \"}\n </>\n );\n },\n);\n\nInput.displayName = \"Input\";\n"],"names":["Input","forwardRef","props","ref","multiple","id","label","rest","defaultId","useId","maxSizeDescriptionId","descriptor","context","useFileInputContext","jsx","children","accept","maxSizeBytes","onChange","elementId","jsxs","Fragment","className","htmlFor","type","value","e","target","files","map","file","state","validation","validateFile","uploadProgress","displayName"],"mappings":"4MAWaA,EAAQC,EAAAA,YACjB,CAACC,EAAOC,KACJ,MAAQC,SAAAA,EAAUC,GAAAA,EAAIC,MAAAA,KAAUC,GAASL,EAEnCM,EAAYC,EAAAA,QAEZC,EAAuBL,EAAK,eAC5BM,EAAaP,EAAW,QAAU,MAElCQ,EAAUC,EAAAA,sBAChB,IAAKD,EAEG,OAAAE,EAAAA,IAAC,KAAEC,SAAuD,4DAGlE,MAAQC,OAAAA,EAAQC,aAAAA,EAAcC,SAAAA,GAAaN,EAErCO,EAAYd,GAAMG,EAExB,OAEQY,EAAAA,KAAAC,WAAA,CAAAN,SAAA,CAAAD,EAAAA,IAAC,QAAA,CACGQ,UAAU,mCACVC,QAASJ,EACTd,GAAI,GAAGc,aAENJ,SAAAT,IAELQ,EAAAA,IAAC,QAAA,IACOP,EACJJ,IAAAA,EACAE,GAAIc,EACJH,OAAAA,EACA,mBACIC,EAAeP,OAAuB,EAE1CY,UAAU,cACVE,KAAK,OACLpB,SAAAA,EACAqB,MAAM,GACNP,SAAWQ,IACHA,EAAEC,OAAOC,OACTV,EACIQ,EACA,IAAIA,EAAEC,OAAOC,OAAOC,KACfC,KACGA,KAAAA,EACAC,MAAO,WACPC,WAAYC,EAAAA,aACRH,EACAd,EACAC,GAEJiB,eAAgB,MAExB,IAKhBd,EAAAA,KAAC,IAAE,CAAAE,UAAU,gCAAgCP,SAAA,CAAA,eAC5BJ,EAAW,UACvB,MACT,IAKZX,EAAMmC,YAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileInputContext.cjs","sources":["../../../../../src/components/file-input/internal/fileInputContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\n\ntype FileInputContext = {\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n files: FileInputFile[];\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n};\n\nconst fileInputContext = createContext<FileInputContext | null>(null);\n\nexport const useFileInputContext = (): FileInputContext | null =>\n useContext(fileInputContext);\n\nexport interface FileInputContextProviderProps extends WithChildren {\n context: FileInputContext;\n}\n\nexport const FileInputContextProvider: React.FC<\n FileInputContextProviderProps\n> = ({ context, children }) => (\n <fileInputContext.Provider value={context}>\n {children}\n </fileInputContext.Provider>\n);\n"],"names":["fileInputContext","createContext","context","children","jsx","Provider","value","useContext"],"mappings":"wIAgBMA,EAAmBC,
|
|
1
|
+
{"version":3,"file":"fileInputContext.cjs","sources":["../../../../../src/components/file-input/internal/fileInputContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport { WithChildren } from \"../../../core/types.js\";\nimport { FileInputFile } from \"../types.js\";\n\ntype FileInputContext = {\n accept?: \"image/*\" | \".pdf\" | \"image/*,.pdf\" | HTMLInputElement[\"accept\"];\n maxSizeBytes?: number;\n files: FileInputFile[];\n onChange: (\n e:\n | React.ChangeEvent<HTMLInputElement>\n | React.DragEvent<HTMLDivElement>,\n files: FileInputFile[],\n ) => void;\n};\n\nconst fileInputContext = createContext<FileInputContext | null>(null);\n\nexport const useFileInputContext = (): FileInputContext | null =>\n useContext(fileInputContext);\n\nexport interface FileInputContextProviderProps extends WithChildren {\n context: FileInputContext;\n}\n\nexport const FileInputContextProvider: React.FC<\n FileInputContextProviderProps\n> = ({ context, children }) => (\n <fileInputContext.Provider value={context}>\n {children}\n </fileInputContext.Provider>\n);\n"],"names":["fileInputContext","createContext","context","children","jsx","Provider","value","useContext"],"mappings":"wIAgBMA,EAAmBC,EAAAA,cAAuC,uCAW5D,EAAGC,QAAAA,EAASC,SAAAA,KACXC,EAAAA,IAAAJ,EAAiBK,SAAjB,CAA0BC,MAAOJ,EAC7BC,SAAAA,gCAX0B,IAC/BI,EAAAA,WAAWP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateFile.cjs","sources":["../../../../../src/components/file-input/internal/validateFile.ts"],"sourcesContent":["import { formatBytes } from \"../../../utilities/formatters/bytes/formatBytes.js\";\nimport type { FileInputFileValidation } from \"../types.js\";\n\nexport function validateFile(\n file: File,\n accept = \"\",\n maxSizeBytes?: number,\n): FileInputFileValidation | undefined {\n const acceptStrings = accept\n .split(\",\")\n .map((s) => s.toLowerCase())\n .map((s) => s.replaceAll(\"*\", \"\"))\n .map((s) => s.trim());\n\n let isValidFormat = acceptStrings.length === 0;\n\n isValidFormat = acceptStrings.some(\n (acceptString) =>\n file.type.toLowerCase().includes(acceptString) ||\n file.name.toLowerCase().endsWith(acceptString),\n );\n\n if (!isValidFormat) {\n return {\n type: \"WRONG_TYPE\",\n message: `Filtypen ${file.name?.split(\".\")[1] || \"\"} støttes ikke`,\n };\n }\n\n if (typeof maxSizeBytes != \"undefined\" && file.size > maxSizeBytes) {\n return {\n type: \"TOO_LARGE\",\n message: `Filen er ${formatBytes(\n file.size,\n )}, men kan maksimalt være ${formatBytes(maxSizeBytes)}`,\n };\n }\n\n return undefined;\n}\n"],"names":["file","accept","maxSizeBytes","acceptStrings","split","map","s","toLowerCase","replaceAll","trim","isValidFormat","length","some","acceptString","type","includes","name","endsWith","size","message","formatBytes","_a"],"mappings":"4KAGO,SACHA,EACAC,EAAS,GACTC,SAEM,MAAAC,EAAgBF,EACjBG,MAAM,KACNC,KAAKC,GAAMA,EAAEC,gBACbF,KAAKC,GAAMA,EAAEE,WAAW,IAAK,MAC7BH,KAAKC,GAAMA,EAAEG,SAEd,IAAAC,EAAyC,IAAzBP,EAAcQ,OAQlC,OANAD,EAAgBP,EAAcS,MACzBC,GACGb,EAAKc,KAAKP,cAAcQ,SAASF,IACjCb,EAAKgB,KAAKT,cAAcU,SAASJ,KAGpCH,SAOMR,EAAgB,KAAeF,EAAKkB,KAAOhB,EAC3C,CACHY,KAAM,YACNK,QAAS,YAAYC,EAAAA,YACjBpB,EAAKkB,iCACoBE,
|
|
1
|
+
{"version":3,"file":"validateFile.cjs","sources":["../../../../../src/components/file-input/internal/validateFile.ts"],"sourcesContent":["import { formatBytes } from \"../../../utilities/formatters/bytes/formatBytes.js\";\nimport type { FileInputFileValidation } from \"../types.js\";\n\nexport function validateFile(\n file: File,\n accept = \"\",\n maxSizeBytes?: number,\n): FileInputFileValidation | undefined {\n const acceptStrings = accept\n .split(\",\")\n .map((s) => s.toLowerCase())\n .map((s) => s.replaceAll(\"*\", \"\"))\n .map((s) => s.trim());\n\n let isValidFormat = acceptStrings.length === 0;\n\n isValidFormat = acceptStrings.some(\n (acceptString) =>\n file.type.toLowerCase().includes(acceptString) ||\n file.name.toLowerCase().endsWith(acceptString),\n );\n\n if (!isValidFormat) {\n return {\n type: \"WRONG_TYPE\",\n message: `Filtypen ${file.name?.split(\".\")[1] || \"\"} støttes ikke`,\n };\n }\n\n if (typeof maxSizeBytes != \"undefined\" && file.size > maxSizeBytes) {\n return {\n type: \"TOO_LARGE\",\n message: `Filen er ${formatBytes(\n file.size,\n )}, men kan maksimalt være ${formatBytes(maxSizeBytes)}`,\n };\n }\n\n return undefined;\n}\n"],"names":["file","accept","maxSizeBytes","acceptStrings","split","map","s","toLowerCase","replaceAll","trim","isValidFormat","length","some","acceptString","type","includes","name","endsWith","size","message","formatBytes","_a"],"mappings":"4KAGO,SACHA,EACAC,EAAS,GACTC,SAEM,MAAAC,EAAgBF,EACjBG,MAAM,KACNC,KAAKC,GAAMA,EAAEC,gBACbF,KAAKC,GAAMA,EAAEE,WAAW,IAAK,MAC7BH,KAAKC,GAAMA,EAAEG,SAEd,IAAAC,EAAyC,IAAzBP,EAAcQ,OAQlC,OANAD,EAAgBP,EAAcS,MACzBC,GACGb,EAAKc,KAAKP,cAAcQ,SAASF,IACjCb,EAAKgB,KAAKT,cAAcU,SAASJ,KAGpCH,SAOMR,EAAgB,KAAeF,EAAKkB,KAAOhB,EAC3C,CACHY,KAAM,YACNK,QAAS,YAAYC,EAAAA,YACjBpB,EAAKkB,iCACoBE,EAAAA,YAAYlB,WALjD,EANW,CACHY,KAAM,aACNK,QAAS,aAAY,OAAAE,EAAArB,EAAKgB,WAALK,EAAAA,EAAWjB,MAAM,KAAK,KAAM,kBAc7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flex.cjs","sources":["../../../../src/components/flex/Flex.tsx"],"sourcesContent":["import React, { type CSSProperties } from \"react\";\nimport tokens from \"../../core/tokens.js\";\nimport { AsChildProps } from \"../../utilities/polymorphism/as-child.js\";\nimport {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport { SlotComponent } from \"../../utilities/polymorphism/SlotComponent.js\";\n\nexport type FlexDirection = \"row\" | \"row-reverse\" | \"column\" | \"column-reverse\";\nexport type GapValue = Exclude<keyof (typeof tokens)[\"spacing\"], 0>;\n\nexport type FlexProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n direction?: FlexDirection;\n wrap?: boolean;\n gap?: GapValue;\n colGap?: GapValue;\n rowGap?: GapValue;\n } & Pick<\n CSSProperties,\n \"alignContent\" | \"alignItems\" | \"justifyContent\" | \"justifyItems\"\n >\n >;\n\nexport type FlexComponent = <ElementType extends React.ElementType = \"div\">(\n props: FlexProps<ElementType> & AsChildProps,\n) => React.ReactElement | null;\n\nexport const Flex = React.forwardRef(function Flex<\n ElementType extends React.ElementType = \"div\",\n>(props: FlexProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n asChild,\n as = \"div\",\n alignContent,\n alignItems,\n children,\n colGap,\n direction,\n gap,\n justifyContent,\n justifyItems,\n rowGap,\n wrap = false,\n ...rest\n } = props;\n const Component = asChild ? SlotComponent : as;\n\n const flexStyle: CSSProperties = {\n display: \"flex\",\n flexDirection: direction,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n ...(wrap ? { flexWrap: \"wrap\" } : {}),\n ...(gap ? { gap: tokens.spacing[gap] } : {}),\n ...(colGap ? { columnGap: tokens.spacing[colGap] } : {}),\n ...(rowGap ? { rowGap: tokens.spacing[rowGap] } : {}),\n };\n\n return (\n <Component ref={ref} {...rest} style={{ ...flexStyle, ...rest.style }}>\n {children}\n </Component>\n );\n}) as FlexComponent;\n"],"names":["Flex","React","forwardRef","props","ref","asChild","as","alignContent","alignItems","children","colGap","direction","gap","justifyContent","justifyItems","rowGap","wrap","rest","Component","SlotComponent","flexStyle","display","flexDirection","flexWrap","tokens","spacing","columnGap","jsx","style"],"mappings":"uOA+BaA,EAAOC,EAAMC,YAAW,SAEnCC,EAA+BC,GACvB,MACFC,QAAAA,EACAC,GAAAA,EAAK,MACLC,aAAAA,EACAC,WAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,IAAAA,EACAC,eAAAA,EACAC,aAAAA,EACAC,OAAAA,EACAC,KAAAA,GAAO,KACJC,GACHd,EACEe,EAAYb,EAAUc,
|
|
1
|
+
{"version":3,"file":"Flex.cjs","sources":["../../../../src/components/flex/Flex.tsx"],"sourcesContent":["import React, { type CSSProperties } from \"react\";\nimport tokens from \"../../core/tokens.js\";\nimport { AsChildProps } from \"../../utilities/polymorphism/as-child.js\";\nimport {\n PolymorphicPropsWithRef,\n PolymorphicRef,\n} from \"../../utilities/polymorphism/polymorphism.js\";\nimport { SlotComponent } from \"../../utilities/polymorphism/SlotComponent.js\";\n\nexport type FlexDirection = \"row\" | \"row-reverse\" | \"column\" | \"column-reverse\";\nexport type GapValue = Exclude<keyof (typeof tokens)[\"spacing\"], 0>;\n\nexport type FlexProps<ElementType extends React.ElementType> =\n PolymorphicPropsWithRef<\n ElementType,\n {\n direction?: FlexDirection;\n wrap?: boolean;\n gap?: GapValue;\n colGap?: GapValue;\n rowGap?: GapValue;\n } & Pick<\n CSSProperties,\n \"alignContent\" | \"alignItems\" | \"justifyContent\" | \"justifyItems\"\n >\n >;\n\nexport type FlexComponent = <ElementType extends React.ElementType = \"div\">(\n props: FlexProps<ElementType> & AsChildProps,\n) => React.ReactElement | null;\n\nexport const Flex = React.forwardRef(function Flex<\n ElementType extends React.ElementType = \"div\",\n>(props: FlexProps<ElementType>, ref?: PolymorphicRef<ElementType>) {\n const {\n asChild,\n as = \"div\",\n alignContent,\n alignItems,\n children,\n colGap,\n direction,\n gap,\n justifyContent,\n justifyItems,\n rowGap,\n wrap = false,\n ...rest\n } = props;\n const Component = asChild ? SlotComponent : as;\n\n const flexStyle: CSSProperties = {\n display: \"flex\",\n flexDirection: direction,\n alignContent,\n alignItems,\n justifyContent,\n justifyItems,\n ...(wrap ? { flexWrap: \"wrap\" } : {}),\n ...(gap ? { gap: tokens.spacing[gap] } : {}),\n ...(colGap ? { columnGap: tokens.spacing[colGap] } : {}),\n ...(rowGap ? { rowGap: tokens.spacing[rowGap] } : {}),\n };\n\n return (\n <Component ref={ref} {...rest} style={{ ...flexStyle, ...rest.style }}>\n {children}\n </Component>\n );\n}) as FlexComponent;\n"],"names":["Flex","React","forwardRef","props","ref","asChild","as","alignContent","alignItems","children","colGap","direction","gap","justifyContent","justifyItems","rowGap","wrap","rest","Component","SlotComponent","flexStyle","display","flexDirection","flexWrap","tokens","spacing","columnGap","jsx","style"],"mappings":"uOA+BaA,EAAOC,EAAMC,YAAW,SAEnCC,EAA+BC,GACvB,MACFC,QAAAA,EACAC,GAAAA,EAAK,MACLC,aAAAA,EACAC,WAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,IAAAA,EACAC,eAAAA,EACAC,aAAAA,EACAC,OAAAA,EACAC,KAAAA,GAAO,KACJC,GACHd,EACEe,EAAYb,EAAUc,EAAgBA,cAAAb,EAEtCc,EAA2B,CAC7BC,QAAS,OACTC,cAAeX,EACfJ,aAAAA,EACAC,WAAAA,EACAK,eAAAA,EACAC,aAAAA,KACIE,EAAO,CAAEO,SAAU,QAAW,CAAC,KAC/BX,EAAM,CAAEA,IAAKY,EAAOC,QAAQb,IAAS,CAAC,KACtCF,EAAS,CAAEgB,UAAWF,EAAOC,QAAQf,IAAY,CAAC,KAClDK,EAAS,CAAEA,OAAQS,EAAOC,QAAQV,IAAY,CAAC,GAGvD,OACKY,EAAAA,IAAAT,EAAA,CAAUd,IAAAA,KAAca,EAAMW,MAAO,IAAKR,KAAcH,EAAKW,OACzDnB,SAAAA,GAGb"}
|