@oaknational/oak-components 2.45.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/npm/cjs/index.js +7949 -0
- package/dist/{types.d.ts → npm/cjs/types.d.ts} +2 -16
- package/dist/npm/es/animation/usePrefersReducedMotion.js +16 -0
- package/dist/npm/es/components/OakGlobalStyle/OakGlobalStyle.js +14 -0
- package/dist/npm/es/components/OakThemeProvider/OakThemeProvider.js +14 -0
- package/dist/npm/es/components/buttons/OakButtonWithDropdown/OakButtonWithDropdown.js +105 -0
- package/dist/npm/es/components/buttons/OakCloseButton/OakCloseButton.js +18 -0
- package/dist/npm/es/components/buttons/OakLeftAlignedButton/OakLeftAlignedButton.js +57 -0
- package/dist/npm/es/components/buttons/OakPrimaryButton/OakPrimaryButton.js +23 -0
- package/dist/npm/es/components/buttons/OakPrimaryInvertedButton/OakPrimaryInvertedButton.js +23 -0
- package/dist/npm/es/components/buttons/OakSecondaryButton/OakSecondaryButton.js +23 -0
- package/dist/npm/es/components/buttons/OakSecondaryButtonWithDropdown/OakSecondaryButtonWithDropdown.js +20 -0
- package/dist/npm/es/components/buttons/OakSmallPrimaryButton/OakSmallPrimaryButton.js +23 -0
- package/dist/npm/es/components/buttons/OakSmallPrimaryInvertedButton/OakSmallPrimaryInvertedButton.js +23 -0
- package/dist/npm/es/components/buttons/OakSmallSecondaryButton/OakSmallSecondaryButton.js +23 -0
- package/dist/npm/es/components/buttons/OakSmallSecondaryButtonWithDropdown/OakSmallSecondaryButtonWithDropdown.js +20 -0
- package/dist/npm/es/components/buttons/OakSmallSecondaryToggleButton/OakSmallSecondaryToggleButton.js +37 -0
- package/dist/npm/es/components/buttons/OakSmallTertiaryInvertedButton/OakSmallTertiaryInvertedButton.js +23 -0
- package/dist/npm/es/components/buttons/OakTertiaryButton/OakTertiaryButton.js +14 -0
- package/dist/npm/es/components/buttons/OakTertiaryInvertedButton/OakTertiaryInvertedButton.js +14 -0
- package/dist/npm/es/components/cookies/OakCookieBanner/OakCookieBanner.js +62 -0
- package/dist/npm/es/components/cookies/OakCookieConsent/OakCookieConsent.js +17 -0
- package/dist/npm/es/components/cookies/OakCookieConsentProvider/OakCookieConsentProvider.js +103 -0
- package/dist/npm/es/components/cookies/OakCookieConsentProvider/cookieConsentReducer.js +32 -0
- package/dist/npm/es/components/cookies/OakCookieSettingsModal/OakCookieSettingsModal.js +91 -0
- package/dist/npm/es/components/form-elements/OakButtonAsRadioGroup/OakButtonAsRadioGroup.js +44 -0
- package/dist/npm/es/components/form-elements/OakCheckBox/OakCheckBox.js +71 -0
- package/dist/npm/es/components/form-elements/OakFieldError/OakFieldError.js +25 -0
- package/dist/npm/es/components/form-elements/OakFieldset/OakFieldset.js +12 -0
- package/dist/npm/es/components/form-elements/OakForm/OakForm.js +16 -0
- package/dist/npm/es/components/form-elements/OakFormInput/OakFormInput.js +26 -0
- package/dist/npm/es/components/form-elements/OakJauntyAngleLabel/OakJauntyAngleLabel.js +10 -0
- package/dist/npm/es/components/form-elements/OakLabel/OakLabel.js +15 -0
- package/dist/npm/es/components/form-elements/OakMultilineText/OakMultilineText.js +96 -0
- package/dist/npm/es/components/form-elements/OakRadioAsButton/OakRadioAsButton.js +96 -0
- package/dist/npm/es/components/form-elements/OakRadioButton/OakRadioButton.js +31 -0
- package/dist/npm/es/components/form-elements/OakRadioGroup/OakRadioGroup.js +44 -0
- package/dist/npm/es/components/form-elements/OakSearchFilterCheckBox/OakSearchFilterCheckBox.js +64 -0
- package/dist/npm/es/components/form-elements/OakSecondaryButtonAsRadio/OakSecondaryButtonAsRadio.js +25 -0
- package/dist/npm/es/components/form-elements/OakSelect/NativeLegend.js +9 -0
- package/dist/npm/es/components/form-elements/OakSelect/NativeOptGroup.js +7 -0
- package/dist/npm/es/components/form-elements/OakSelect/NativeOption.js +22 -0
- package/dist/npm/es/components/form-elements/OakSelect/NativeSelect.js +23 -0
- package/dist/npm/es/components/form-elements/OakSelect/OakOptGroup.js +12 -0
- package/dist/npm/es/components/form-elements/OakSelect/OakOption.js +12 -0
- package/dist/npm/es/components/form-elements/OakSelect/OakSelect.js +44 -0
- package/dist/npm/es/components/form-elements/OakTextArea/OakTextArea.js +23 -0
- package/dist/npm/es/components/form-elements/OakTextInput/OakTextInput.js +59 -0
- package/dist/npm/es/components/house-cat/OakCaptionCard/OakCaptionCard.js +81 -0
- package/dist/npm/es/components/house-cat/OakCaptionSearch/OakCaptionSearch.js +24 -0
- package/dist/npm/es/components/house-cat/utils.js +33 -0
- package/dist/npm/es/components/images-and-icons/OakAspectRatio/OakAspectRatio.js +39 -0
- package/dist/npm/es/components/images-and-icons/OakIcon/OakIcon.js +38 -0
- package/dist/npm/es/components/images-and-icons/OakImage/OakImage.js +51 -0
- package/dist/npm/es/components/images-and-icons/OakImage/useShowPlaceholder.js +29 -0
- package/dist/npm/es/components/images-and-icons/OakRoundIcon/OakRoundIcon.js +17 -0
- package/dist/npm/es/components/images-and-icons/OakSvg/OakSvg.js +47 -0
- package/dist/npm/es/components/internal-components/InternalAccordion/InternalAccordion.js +36 -0
- package/dist/npm/es/components/internal-components/InternalAccordion/InternalAccordionProvider.js +24 -0
- package/dist/npm/es/components/internal-components/InternalAccordion/useAccordionContext.js +12 -0
- package/dist/npm/es/components/internal-components/InternalButton/InternalButton.js +48 -0
- package/dist/npm/es/components/internal-components/InternalCard/InternalCard.js +19 -0
- package/dist/npm/es/components/internal-components/InternalCardWithBackgroundElement/InternalCardWithBackgroundElement.js +22 -0
- package/dist/npm/es/components/internal-components/InternalCheckBox/InternalCheckBox.js +82 -0
- package/dist/npm/es/components/internal-components/InternalCheckBoxLabel/InternalCheckBoxLabel.js +16 -0
- package/dist/npm/es/components/internal-components/InternalCheckBoxWrapper/InternalCheckBoxWrapper.js +24 -0
- package/dist/npm/es/components/internal-components/InternalChevronAccordion/InternalChevronAccordion.js +83 -0
- package/dist/npm/es/components/internal-components/InternalClientPortal/InternalClientPortal.js +13 -0
- package/dist/npm/es/components/internal-components/InternalDndContext/InternalDndContext.js +28 -0
- package/dist/npm/es/components/internal-components/InternalLink/InternalLink.js +54 -0
- package/dist/npm/es/components/internal-components/InternalModalTransition/InternalModalTransition.js +31 -0
- package/dist/npm/es/components/internal-components/InternalRadio/InternalRadio.js +82 -0
- package/dist/npm/es/components/internal-components/InternalRadioWrapper/InternalRadioWrapper.js +36 -0
- package/dist/npm/es/components/internal-components/InternalReviewAccordion/InternalReviewAccordion.js +38 -0
- package/dist/npm/es/components/internal-components/InternalShadowIconButton/InternalShadowIconButton.js +56 -0
- package/dist/npm/es/components/internal-components/InternalShadowRectButton/InternalShadowRectButton.js +56 -0
- package/dist/npm/es/components/internal-components/InternalShadowRoundButton/InternalShadowRoundButton.js +56 -0
- package/dist/npm/es/components/internal-components/InternalSlideInFlex/InternalSlideInFlex.js +30 -0
- package/dist/npm/es/components/internal-components/InternalStyledSvg/InternalStyledSvg.js +14 -0
- package/dist/npm/es/components/internal-components/InternalTextInput/InternalTextInput.js +50 -0
- package/dist/npm/es/components/internal-components/InternalTooltip/InternalTooltip.js +36 -0
- package/dist/npm/es/components/layout-and-structure/OakAccordion/OakAccordion.js +39 -0
- package/dist/npm/es/components/layout-and-structure/OakBasicAccordion/OakBasicAccordion.js +10 -0
- package/dist/npm/es/components/layout-and-structure/OakBox/OakBox.js +41 -0
- package/dist/npm/es/components/layout-and-structure/OakCollapsibleContent/OakCollapsibleContent.js +23 -0
- package/dist/npm/es/components/layout-and-structure/OakFlex/OakFlex.js +18 -0
- package/dist/npm/es/components/layout-and-structure/OakGrid/OakGrid.js +16 -0
- package/dist/npm/es/components/layout-and-structure/OakGridArea/OakGridArea.js +51 -0
- package/dist/npm/es/components/layout-and-structure/OakMaxWidth/OakMaxWidth.js +23 -0
- package/dist/npm/es/components/messaging-and-feedback/OakFocusIndicator/OakFocusIndicator.js +38 -0
- package/dist/npm/es/components/messaging-and-feedback/OakHandDrawnFocusUnderline/OakHandDrawnFocusUnderline.js +22 -0
- package/dist/npm/es/components/messaging-and-feedback/OakHandDrawnFocusUnderline/SubHandDrawnFocusUnderline.js +17 -0
- package/dist/npm/es/components/messaging-and-feedback/OakInformativeModal/OakInformativeModal.js +41 -0
- package/dist/npm/es/components/messaging-and-feedback/OakInformativeModal/OakInformativeModalBody.js +14 -0
- package/dist/npm/es/components/messaging-and-feedback/OakInformativeModal/OakInformativeModalFooter.js +16 -0
- package/dist/npm/es/components/messaging-and-feedback/OakInlineBanner/OakInlineBanner.js +129 -0
- package/dist/npm/es/components/messaging-and-feedback/OakKbd/OakKbd.js +12 -0
- package/dist/npm/es/components/messaging-and-feedback/OakLoadingSpinner/OakLoadingSpinner.js +34 -0
- package/dist/npm/es/components/messaging-and-feedback/OakModalCenter/OakModalCenter.js +106 -0
- package/dist/npm/es/components/messaging-and-feedback/OakModalCenter/OakModalCenterBody.js +36 -0
- package/dist/npm/es/components/messaging-and-feedback/OakScreenReader/OakScreenReader.js +15 -0
- package/dist/npm/es/components/messaging-and-feedback/OakTagFunctional/OakTagFunctional.js +18 -0
- package/dist/npm/es/components/messaging-and-feedback/OakToast/OakToast.js +96 -0
- package/dist/npm/es/components/messaging-and-feedback/OakTooltip/OakTooltip.js +122 -0
- package/dist/npm/es/components/navigation/OakAnchorTarget/OakAnchorTarget.js +20 -0
- package/dist/npm/es/components/navigation/OakBreadcrumbs/OakBreadcrumbs.js +46 -0
- package/dist/npm/es/components/navigation/OakCard/OakCard.js +64 -0
- package/dist/npm/es/components/navigation/OakHoverLink/OakHoverLink.js +23 -0
- package/dist/npm/es/components/navigation/OakLink/OakLink.js +17 -0
- package/dist/npm/es/components/navigation/OakLink/config.js +18 -0
- package/dist/npm/es/components/navigation/OakPagination/OakPagination.js +106 -0
- package/dist/npm/es/components/navigation/OakPagination/utils.js +19 -0
- package/dist/npm/es/components/navigation/OakPrimaryNav/OakPrimaryNav.js +22 -0
- package/dist/npm/es/components/navigation/OakPrimaryNavItem/OakPrimaryNavItem.js +23 -0
- package/dist/npm/es/components/navigation/OakSecondaryLink/OakSecondaryLink.js +25 -0
- package/dist/npm/es/components/navigation/OakTabs/OakTabs.js +47 -0
- package/dist/npm/es/components/owa/OakBackLink/OakBackLink.js +28 -0
- package/dist/npm/es/components/owa/OakBulletList/OakBulletList.js +17 -0
- package/dist/npm/es/components/owa/OakCardWithHandDrawnBorder/OakCardWithHandDrawnBorder.js +17 -0
- package/dist/npm/es/components/owa/OakCloudinaryImage/OakCloudinaryImage.js +35 -0
- package/dist/npm/es/components/owa/OakCloudinaryImage/cloudinary.js +17 -0
- package/dist/npm/es/components/owa/OakCodeRenderer/OakCodeRenderer.js +135 -0
- package/dist/npm/es/components/owa/OakCopyLinkButton/OakCopyLinkButton.js +42 -0
- package/dist/npm/es/components/owa/OakDownloadCard/OakDownloadCard.js +72 -0
- package/dist/npm/es/components/owa/OakDownloadsJourneyChildSubjectTierSelector/OakDownloadsJourneyChildSubjectTierSelector.js +54 -0
- package/dist/npm/es/components/owa/OakDragAndDropInstructions/OakDragAndDropInstructions.js +41 -0
- package/dist/npm/es/components/owa/OakDraggable/OakDraggable.js +30 -0
- package/dist/npm/es/components/owa/OakDraggableFeedback/OakDraggableFeedback.js +13 -0
- package/dist/npm/es/components/owa/OakDroppable/OakDroppable.js +45 -0
- package/dist/npm/es/components/owa/OakFilterDrawer/OakFilterDrawer.js +43 -0
- package/dist/npm/es/components/owa/OakFormInputWithLabels/OakFormInputWithLabels.js +18 -0
- package/dist/npm/es/components/owa/OakHandDrawnCard/OakHandDrawnCard.js +17 -0
- package/dist/npm/es/components/owa/OakHandDrawnCardWithIcon/OakHandDrawnCardWithIcon.js +15 -0
- package/dist/npm/es/components/owa/OakHandDrawnHR/HandDrawnHRSvg.js +11 -0
- package/dist/npm/es/components/owa/OakHandDrawnHR/OakHandDrawnHR.js +22 -0
- package/dist/npm/es/components/owa/OakHeaderHero/OakHeaderHero.js +45 -0
- package/dist/npm/es/components/owa/OakHomepageTabButton/OakHomepageTabButton.js +35 -0
- package/dist/npm/es/components/owa/OakInfo/OakInfo.js +22 -0
- package/dist/npm/es/components/owa/OakInfoButton/OakInfoButton.js +20 -0
- package/dist/npm/es/components/owa/OakLessonInfoCard/OakLessonInfoCard.js +33 -0
- package/dist/npm/es/components/owa/OakLinkCard/OakLinkCard.js +42 -0
- package/dist/npm/es/components/owa/OakListItem/OakListItem.js +93 -0
- package/dist/npm/es/components/owa/OakMediaClip/OakMediaClip.js +90 -0
- package/dist/npm/es/components/owa/OakMediaClipList/OakMediaClipList.js +26 -0
- package/dist/npm/es/components/owa/OakMediaClipListAccordion/OakMediaClipListAccordion.js +29 -0
- package/dist/npm/es/components/owa/OakMediaClipStackListItem/OakMediaClipStackListItem.js +41 -0
- package/dist/npm/es/components/owa/OakOutlineAccordion/OakOutlineAccordion.js +21 -0
- package/dist/npm/es/components/owa/OakPromoTag/OakPromoTag.js +22 -0
- package/dist/npm/es/components/owa/OakRadioTile/OakRadioTile.js +40 -0
- package/dist/npm/es/components/owa/OakSaveCount/OakSaveCount.js +33 -0
- package/dist/npm/es/components/owa/OakScaleImageButton/OakScaleImageButton.js +19 -0
- package/dist/npm/es/components/owa/OakSideMenuNav/OakSideMenuNav.js +24 -0
- package/dist/npm/es/components/owa/OakSideMenuNavLink/OakSideMenuNavLink.js +48 -0
- package/dist/npm/es/components/owa/OakSignLanguageButton/OakSignLanguageButton.js +23 -0
- package/dist/npm/es/components/owa/OakSubjectIcon/OakSubjectIcon.js +20 -0
- package/dist/npm/es/components/owa/OakSubjectIconButton/OakSubjectIconButton.js +44 -0
- package/dist/npm/es/components/owa/OakTimer/OakTimer.js +26 -0
- package/dist/npm/es/components/owa/OakVideoTranscript/OakVideoTranscript.js +32 -0
- package/dist/npm/es/components/owa/pupil/OakUnitListItem/OakUnitListItem.js +63 -0
- package/dist/npm/es/components/owa/pupil/OakUnitListOptionalityItem/OakUnitListOptionalityItem.js +57 -0
- package/dist/npm/es/components/owa/pupil/OakUnitListOptionalityItemCard/OakUnitListOptionalityItemCard.js +36 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyContentGuidance/OakPupilJourneyContentGuidance.js +44 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyHeader/OakPupilJourneyHeader.js +29 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyLayout/OakPupilJourneyLayout.js +62 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyList/OakPupilJourneyList.js +46 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyListCounter/OakPupilJourneyListCounter.js +12 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyListItem/OakPupilJourneyListItem.js +45 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyListItemSubheading/OakPupilJourneyListItemSubheading.js +20 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyOptionalityButton/OakPupilJourneyOptionalityButton.js +35 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyOptionalityItem/OakPupilJourneyOptionalityItem.js +23 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyProgrammeOptions/OakPupilJourneyProgrammeOptions.js +27 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyUnitsFilter/OakPupilJourneyUnitsFilter.js +42 -0
- package/dist/npm/es/components/owa/pupil/browse/OakPupilJourneyYearButton/OakPupilJourneyYearButton.js +31 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonBottomNav/OakLessonBottomNav.js +34 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonLayout/OakLessonLayout.js +153 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonNavItem/OakLessonNavItem.js +167 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonReviewIntroVideo/OakPupilLessonReviewIntroVideo.js +30 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonReviewItem/OakPupilLessonReviewItem.js +106 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonReviewQuiz/OakPupilLessonReviewQuiz.js +56 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonTopNav/OakLessonTopNav.js +58 -0
- package/dist/npm/es/components/owa/pupil/lesson/OakLessonVideoTranscript/OakLessonVideoTranscript.js +27 -0
- package/dist/npm/es/components/owa/pupil/quiz/InternalDroppableHoldingPen/InternalDroppableHoldingPen.js +60 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakHintButton/OakHintButton.js +27 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizCheckBox/OakQuizCheckBox.js +58 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizCounter/OakQuizCounter.js +33 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizFeedback/OakQuizFeedback.js +31 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizHint/OakQuizHint.js +28 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizMatch/OakQuizMatch.js +121 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizOrder/OakQuizOrder.js +88 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizPrintableHeader/OakQuizPrintableHeader.js +29 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizPrintableSubHeader/OakQuizPrintableSubHeader.js +28 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizRadioButton/OakQuizRadioButton.js +78 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizResultItem/OakQuizResultItem.js +70 -0
- package/dist/npm/es/components/owa/pupil/quiz/OakQuizTextInput/OakQuizTextInput.js +28 -0
- package/dist/npm/es/components/owa/teacher/OakDownloadsAccordion/OakDownloadsAccordion.js +56 -0
- package/dist/npm/es/components/owa/teacher/OakInlineRegistrationBanner/OakInlineRegistrationBanner.js +62 -0
- package/dist/npm/es/components/owa/teacher/OakInlineRegistrationBanner/SurfingStudentSVG.js +15 -0
- package/dist/npm/es/components/owa/teacher/OakTeacherNotesInline/OakTeacherNotesInline.js +16 -0
- package/dist/npm/es/components/owa/teacher/OakTeacherNotesModal/OakTeacherNotesModal.js +72 -0
- package/dist/npm/es/components/owa/teacher/OakTertiaryOLNav/OakTertiaryOLNav.js +34 -0
- package/dist/npm/es/components/presentational/OakCarousel/OakCarousel.js +39 -0
- package/dist/npm/es/components/presentational/OakCarousel/SubCarouselPositionControl.js +12 -0
- package/dist/npm/es/components/presentational/OakCarousel/SubCarouselPositionIndicator.js +17 -0
- package/dist/npm/es/components/presentational/OakQuote/OakQuote.js +34 -0
- package/dist/npm/es/components/typography/OakHeading/OakHeading.js +33 -0
- package/dist/npm/es/components/typography/OakLI/OakLI.js +23 -0
- package/dist/npm/es/components/typography/OakOL/OakOL.js +22 -0
- package/dist/npm/es/components/typography/OakP/OakP.js +17 -0
- package/dist/npm/es/components/typography/OakSpan/OakSpan.js +18 -0
- package/dist/npm/es/components/typography/OakTypography/OakTypography.js +16 -0
- package/dist/npm/es/components/typography/OakUL/OakUL.js +19 -0
- package/dist/npm/es/components/unstyled/UnstyledChevronAccordion/UnstyledChevronAccordion.js +55 -0
- package/dist/npm/es/hooks/useBreakpoint.js +38 -0
- package/dist/npm/es/hooks/useIsScrolled.js +30 -0
- package/dist/npm/es/hooks/useMediaQuery.js +20 -0
- package/dist/npm/es/hooks/useMounted.js +12 -0
- package/dist/npm/es/image-map.js +205 -0
- package/dist/npm/es/index.js +196 -0
- package/dist/npm/es/styles/global/oak.styles.js +17 -0
- package/dist/npm/es/styles/global/reset.styles.js +11 -0
- package/dist/npm/es/styles/helpers/getFontSize.js +9 -0
- package/dist/npm/es/styles/helpers/getInternalPadding.js +15 -0
- package/dist/npm/es/styles/helpers/parseBorder.js +13 -0
- package/dist/npm/es/styles/helpers/parseBorderRadius.js +13 -0
- package/dist/npm/es/styles/helpers/parseBorderWidth.js +15 -0
- package/dist/npm/es/styles/helpers/parseColor.js +19 -0
- package/dist/npm/es/styles/helpers/parseColorFilter.js +19 -0
- package/dist/npm/es/styles/helpers/parseDropShadow.js +15 -0
- package/dist/npm/es/styles/helpers/parseOpacity.js +12 -0
- package/dist/npm/es/styles/helpers/parseSpacing.js +29 -0
- package/dist/npm/es/styles/helpers/parseTransitions.js +12 -0
- package/dist/npm/es/styles/helpers/parseTypography.js +36 -0
- package/dist/npm/es/styles/helpers/parseZIndex.js +13 -0
- package/dist/npm/es/styles/helpers/pxToRem.js +7 -0
- package/dist/npm/es/styles/helpers/truthy.js +13 -0
- package/dist/npm/es/styles/theme/borders.js +22 -0
- package/dist/npm/es/styles/theme/color.js +207 -0
- package/dist/npm/es/styles/theme/dark.theme.js +99 -0
- package/dist/npm/es/styles/theme/default.theme.js +99 -0
- package/dist/npm/es/styles/theme/dropShadow.js +13 -0
- package/dist/npm/es/styles/theme/opacity.js +8 -0
- package/dist/npm/es/styles/theme/spacing.js +48 -0
- package/dist/npm/es/styles/theme/transitions.js +6 -0
- package/dist/npm/es/styles/theme/typography.js +73 -0
- package/dist/npm/es/styles/theme/zIndex.js +17 -0
- package/dist/npm/es/styles/utils/borderStyle.js +27 -0
- package/dist/npm/es/styles/utils/colorFilterStyle.js +9 -0
- package/dist/npm/es/styles/utils/colorStyle.js +9 -0
- package/dist/npm/es/styles/utils/displayStyle.js +8 -0
- package/dist/npm/es/styles/utils/dropShadowStyle.js +9 -0
- package/dist/npm/es/styles/utils/flexStyle.js +9 -0
- package/dist/npm/es/styles/utils/listStyle.js +8 -0
- package/dist/npm/es/styles/utils/opacityStyle.js +9 -0
- package/dist/npm/es/styles/utils/positionStyle.js +9 -0
- package/dist/npm/es/styles/utils/responsiveStyle.js +69 -0
- package/dist/npm/es/styles/utils/scrollSnapStyle.js +11 -0
- package/dist/npm/es/styles/utils/sizeStyle.js +9 -0
- package/dist/npm/es/styles/utils/spacingStyle.js +25 -0
- package/dist/npm/es/styles/utils/transformStyle.js +8 -0
- package/dist/npm/es/styles/utils/transitionStyle.js +9 -0
- package/dist/npm/es/styles/utils/typographyStyle.js +9 -0
- package/dist/npm/es/styles/utils/zIndexStyle.js +9 -0
- package/dist/npm/es/svgs/button-border-bottom.js +6 -0
- package/dist/npm/es/svgs/button-border-left.js +6 -0
- package/dist/npm/es/svgs/button-border-right.js +6 -0
- package/dist/npm/es/svgs/button-border-top.js +6 -0
- package/dist/npm/es/svgs/header-underline.js +6 -0
- package/dist/npm/es/svgs/horizontal-rule.js +6 -0
- package/dist/npm/es/svgs/icon-background.js +6 -0
- package/dist/npm/es/svgs/scribble.js +11 -0
- package/dist/npm/es/svgs/underline-3.js +6 -0
- package/dist/npm/es/svgs/underline.js +6 -0
- package/dist/npm/es/test-helpers/colorConversion.js +14 -0
- package/dist/npm/es/test-helpers/mockIntersectionObserver.js +50 -0
- package/dist/npm/es/test-helpers/mockResizeObserver.js +25 -0
- package/dist/npm/es/types.d.ts +5249 -0
- package/package.json +28 -12
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/index.js +0 -15
- package/dist/esm/index.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { __makeTemplateObject, __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { parseColor } from '../../../styles/helpers/parseColor.js';
|
|
5
|
+
import { InternalTextInput } from '../../internal-components/InternalTextInput/InternalTextInput.js';
|
|
6
|
+
import { OakIcon } from '../../images-and-icons/OakIcon/OakIcon.js';
|
|
7
|
+
import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
|
|
8
|
+
import { parseDropShadow } from '../../../styles/helpers/parseDropShadow.js';
|
|
9
|
+
|
|
10
|
+
var StyledTextInputWrapper = styled(OakFlex)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &:hover {\n cursor: text;\n }\n\n &:focus-within {\n box-shadow: ", ";\n }\n\n background: ", ";\n\n ", "\n\n ", "\n\n ", "\n"], ["\n &:hover {\n cursor: text;\n }\n\n &:focus-within {\n box-shadow: ", ";\n }\n\n background: ", ";\n\n ", "\n\n ", "\n\n ", "\n"])), function (props) {
|
|
11
|
+
return props.$focusRingDropShadows
|
|
12
|
+
.map(function (dropShadow) { return parseDropShadow(dropShadow); })
|
|
13
|
+
.join(",");
|
|
14
|
+
}, function (props) { return parseColor(props.$background); }, function (props) {
|
|
15
|
+
return !props.$readOnly && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n @media (hover: hover) {\n &:hover:not(:focus-within) {\n background: ", ";\n }\n }\n "], ["\n @media (hover: hover) {\n &:hover:not(:focus-within) {\n background: ", ";\n }\n }\n "])), parseColor(props.$hoverBackground));
|
|
16
|
+
}, function (props) {
|
|
17
|
+
return props.$readOnly && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-color: ", ";\n color: ", ";\n "], ["\n border-color: ", ";\n color: ", ";\n "])), parseColor(props.$readOnlyBorderColor), parseColor(props.$readOnlyColor));
|
|
18
|
+
}, function (props) {
|
|
19
|
+
return props.$disabled && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: ", ";\n color: ", ";\n &:hover {\n cursor: not-allowed;\n }\n "], ["\n background: ", ";\n color: ", ";\n &:hover {\n cursor: not-allowed;\n }\n "])), parseColor(props.$disabledBackgroundColor), parseColor(props.$disabledColor));
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Default input which can be extended to create specialised inputs.
|
|
23
|
+
*/
|
|
24
|
+
var OakTextInput = function (_a) {
|
|
25
|
+
var _b = _a.type, type = _b === void 0 ? "text" : _b, _c = _a.borderColor, borderColor = _c === void 0 ? "border-primary" : _c, _d = _a.readOnlyBorderColor, readOnlyBorderColor = _d === void 0 ? "border-neutral" : _d, _e = _a.focusRingDropShadows, focusRingDropShadows = _e === void 0 ? [
|
|
26
|
+
"drop-shadow-centered-lemon",
|
|
27
|
+
"drop-shadow-centered-grey",
|
|
28
|
+
] : _e, _f = _a.background, background = _f === void 0 ? "bg-primary" : _f, _g = _a.hoverBackground, hoverBackground = _g === void 0 ? "bg-neutral" : _g, _h = _a.disabledBackgroundColor, disabledBackgroundColor = _h === void 0 ? "bg-neutral" : _h, _j = _a.highlightBackgroundColor, highlightBackgroundColor = _j === void 0 ? "bg-decorative5-main" : _j, _k = _a.color, color = _k === void 0 ? "text-primary" : _k, _l = _a.disabledColor, disabledColor = _l === void 0 ? "text-disabled" : _l, _m = _a.readOnlyColor, readOnlyColor = _m === void 0 ? "text-subdued" : _m, validity = _a.validity, _o = _a.iconColor, iconColor = _o === void 0 ? "icon-primary" : _o, _p = _a.validBorderColor, validBorderColor = _p === void 0 ? "border-success" : _p, _q = _a.invalidBorderColor, invalidBorderColor = _q === void 0 ? "border-error" : _q, _r = _a.validIconColor, validIconColor = _r === void 0 ? "icon-success" : _r, _s = _a.invalidIconColor, invalidIconColor = _s === void 0 ? "border-error" : _s, iconName = _a.iconName, iconAlt = _a.iconAlt, _t = _a.isTrailingIcon, isTrailingIcon = _t === void 0 ? false : _t, _u = _a.isHighlighted, isHighlighted = _u === void 0 ? false : _u, wrapperWidth = _a.wrapperWidth, wrapperMaxWidth = _a.wrapperMaxWidth, props = __rest(_a, ["type", "borderColor", "readOnlyBorderColor", "focusRingDropShadows", "background", "hoverBackground", "disabledBackgroundColor", "highlightBackgroundColor", "color", "disabledColor", "readOnlyColor", "validity", "iconColor", "validBorderColor", "invalidBorderColor", "validIconColor", "invalidIconColor", "iconName", "iconAlt", "isTrailingIcon", "isHighlighted", "wrapperWidth", "wrapperMaxWidth"]);
|
|
29
|
+
var finalBackgroundColor = background;
|
|
30
|
+
var finalBorderColor = borderColor;
|
|
31
|
+
var finalIconColor = iconColor;
|
|
32
|
+
var finalReadOnlyBorderColor = readOnlyBorderColor;
|
|
33
|
+
switch (true) {
|
|
34
|
+
case validity === "valid":
|
|
35
|
+
finalBorderColor = validBorderColor;
|
|
36
|
+
finalIconColor = validIconColor;
|
|
37
|
+
finalReadOnlyBorderColor = validBorderColor;
|
|
38
|
+
break;
|
|
39
|
+
case validity === "invalid":
|
|
40
|
+
finalBorderColor = invalidBorderColor;
|
|
41
|
+
finalIconColor = invalidIconColor;
|
|
42
|
+
finalReadOnlyBorderColor = invalidBorderColor;
|
|
43
|
+
break;
|
|
44
|
+
case isHighlighted:
|
|
45
|
+
finalBackgroundColor = highlightBackgroundColor;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
return (React.createElement(StyledTextInputWrapper, { "$height": "fit-content", "$width": wrapperWidth, "$maxWidth": wrapperMaxWidth, "$borderRadius": "border-radius-s", "$ba": "border-solid-m", "$borderColor": finalBorderColor, "$focusRingDropShadows": focusRingDropShadows, "$background": finalBackgroundColor, "$hoverBackground": hoverBackground, "$disabledBackgroundColor": disabledBackgroundColor, "$readOnlyBorderColor": finalReadOnlyBorderColor, "$disabledColor": disabledColor, "$readOnlyColor": readOnlyColor, "$color": color, "$alignItems": "center", "$position": "relative", "$gap": "spacing-16", "$ph": "spacing-20", "$disabled": !!props.disabled, "$readOnly": !!props.readOnly, onClick: function (event) {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = event.currentTarget.querySelector("input")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
51
|
+
} },
|
|
52
|
+
!isTrailingIcon && iconName && (React.createElement(OakIcon, { iconName: iconName, "$colorFilter": finalIconColor, "$pointerEvents": "none", "$width": "spacing-32", alt: iconAlt })),
|
|
53
|
+
React.createElement(OakFlex, { "$flexGrow": 1 },
|
|
54
|
+
React.createElement(InternalTextInput, __assign({ type: type, "$width": "100%", "$pv": "spacing-20", "$height": "spacing-72" }, props))),
|
|
55
|
+
isTrailingIcon && iconName && (React.createElement(OakIcon, { iconName: iconName, "$colorFilter": finalIconColor, "$pointerEvents": "none", "$width": "spacing-32", alt: iconAlt }))));
|
|
56
|
+
};
|
|
57
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
58
|
+
|
|
59
|
+
export { OakTextInput };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { __makeTemplateObject } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { getTimeText } from '../utils.js';
|
|
5
|
+
import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
6
|
+
import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
|
|
7
|
+
import { OakIcon } from '../../images-and-icons/OakIcon/OakIcon.js';
|
|
8
|
+
import { OakSpan } from '../../typography/OakSpan/OakSpan.js';
|
|
9
|
+
import { InternalCheckBoxLabelHoverDecor } from '../../internal-components/InternalCheckBoxLabel/InternalCheckBoxLabel.js';
|
|
10
|
+
import { parseColor } from '../../../styles/helpers/parseColor.js';
|
|
11
|
+
import { parseDropShadow } from '../../../styles/helpers/parseDropShadow.js';
|
|
12
|
+
import { OakCheckBox } from '../../form-elements/OakCheckBox/OakCheckBox.js';
|
|
13
|
+
import { OakLink } from '../../navigation/OakLink/OakLink.js';
|
|
14
|
+
|
|
15
|
+
var StyledFlexBox = styled(OakFlex)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &:hover:has(input:not(:disabled)) ", " {\n text-decoration: underline;\n }\n\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n ", "\n\n ", "\n ", "\n"], ["\n &:hover:has(input:not(:disabled)) ", " {\n text-decoration: underline;\n }\n\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n ", "\n\n ", "\n ", "\n"])), InternalCheckBoxLabelHoverDecor, parseDropShadow("drop-shadow-centered-lemon"), parseDropShadow("drop-shadow-centered-grey"), function (props) {
|
|
16
|
+
return props.$disabled && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n cursor: not-allowed;\n background-color: ", ";\n color: ", ";\n "], ["\n cursor: not-allowed;\n background-color: ", ";\n color: ", ";\n "])), parseColor("bg-neutral-stronger"), parseColor("text-disabled"));
|
|
17
|
+
}, function (props) {
|
|
18
|
+
return !props.$disabled &&
|
|
19
|
+
props.$highlighted && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n border-color: ", ";\n &:hover {\n background-color: ", ";\n }\n "], ["\n background-color: ", ";\n border-color: ", ";\n &:hover {\n background-color: ", ";\n }\n "])), parseColor("bg-decorative3-very-subdued"), parseColor("bg-decorative3-main"), parseColor("bg-decorative3-subdued"));
|
|
20
|
+
}, function (props) {
|
|
21
|
+
return !props.$disabled &&
|
|
22
|
+
!props.$highlighted && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background-color: ", ";\n }\n "], ["\n &:hover {\n background-color: ", ";\n }\n "])), parseColor("bg-decorative3-subdued"));
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* A caption card with links to the associated lesson and rev edit page.
|
|
26
|
+
*
|
|
27
|
+
* ## Events
|
|
28
|
+
* The following callbacks are available for tracking checkbox events:
|
|
29
|
+
*
|
|
30
|
+
* ### onCheckChanged
|
|
31
|
+
* onCheckChanged?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
var OakCaptionCard = function (props) {
|
|
35
|
+
var checked = props.checked, onCheckChanged = props.onCheckChanged, onClick = props.onClick, captionId = props.captionId, videoTitle = props.videoTitle, lessonUid = props.lessonUid, videoType = props.videoType, lastUpdated = props.lastUpdated, lastEdited = props.lastEdited, _a = props.highlighted, highlighted = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props["data-testid"], dataTestId = _c === void 0 ? "caption-card" : _c, editHref = props.editHref, lessonHref = props.lessonHref;
|
|
36
|
+
var filterColor = disabled ? "icon-disabled" : null;
|
|
37
|
+
return (React.createElement(StyledFlexBox, { "data-testid": dataTestId, "$minHeight": "spacing-40", "$position": "relative", "$background": "bg-primary", "$borderRadius": "border-radius-s", "$pa": "spacing-16", "$gap": "spacing-12", "$flexDirection": "column", "$width": "100%", "$highlighted": !!highlighted, "$disabled": !!disabled, onClick: onClick },
|
|
38
|
+
React.createElement(OakFlex, { "$justifyContent": "flex-start", "$alignItems": "center", "$width": "100%", "$gap": "spacing-12", "$font": "heading-7" },
|
|
39
|
+
React.createElement(OakCheckBox, { checked: checked, value: "Caption ID: ".concat(captionId), displayValue: "", disabled: disabled, onChange: onCheckChanged, "aria-labelledby": captionId, "aria-label": "check caption ".concat(captionId), "data-testid": "checkbox", id: captionId }),
|
|
40
|
+
React.createElement(OakFlex, { "$font": "heading-7", "$justifyContent": "flex-start", "$gap": "spacing-8", "$flexWrap": "wrap" },
|
|
41
|
+
React.createElement(OakSpan, { "$font": "heading-7" },
|
|
42
|
+
"Caption ID: ",
|
|
43
|
+
captionId),
|
|
44
|
+
React.createElement(OakSpan, null, " \u2022 "),
|
|
45
|
+
React.createElement(OakBox, null,
|
|
46
|
+
"Video Title: ",
|
|
47
|
+
videoTitle)),
|
|
48
|
+
React.createElement(OakFlex, { "$flexGrow": 10, "$justifyContent": "flex-end" },
|
|
49
|
+
React.createElement(OakLink, { variant: "secondary", href: editHref, iconName: "external", isTrailingIcon: true, "aria-label": "edit caption ".concat(captionId, " in a new tab in rev"), target: "_blank", onClick: function (e) {
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
} }, "Edit"))),
|
|
52
|
+
React.createElement(OakFlex, { "$justifyContent": "flex-start", "$alignItems": "center", "$width": "100%", "$gap": "spacing-32", "$font": "body-2" },
|
|
53
|
+
React.createElement(OakLink, { variant: "secondary", href: lessonHref, "aria-label": "view lesson ".concat(lessonUid, " in a new tab"), "data-testid": "lesson_uid", iconName: "external", isTrailingIcon: true, target: "_blank", onClick: function (e) {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
} }, lessonUid),
|
|
56
|
+
React.createElement(OakFlex, { "$alignItems": "center", "$gap": "spacing-4" },
|
|
57
|
+
" ",
|
|
58
|
+
React.createElement(OakIcon, { alt: "", iconName: "video", iconWidth: "spacing-24", iconHeight: "spacing-24", "$colorFilter": filterColor }),
|
|
59
|
+
getVideoTypeText(videoType)),
|
|
60
|
+
lastEdited ? (React.createElement(OakFlex, { "$alignItems": "center" },
|
|
61
|
+
React.createElement(OakIcon, { alt: "", iconName: "equipment-required", iconWidth: "spacing-24", iconHeight: "spacing-24", "$colorFilter": filterColor }),
|
|
62
|
+
"Edited ",
|
|
63
|
+
getTimeText(lastEdited))) : null,
|
|
64
|
+
React.createElement(OakFlex, { "$alignItems": "center" },
|
|
65
|
+
React.createElement(OakIcon, { alt: "", iconName: "success", iconWidth: "spacing-24", iconHeight: "spacing-24", "$colorFilter": filterColor }),
|
|
66
|
+
"Updated ",
|
|
67
|
+
getTimeText(lastUpdated)))));
|
|
68
|
+
};
|
|
69
|
+
function getVideoTypeText(videoType) {
|
|
70
|
+
switch (videoType) {
|
|
71
|
+
case "lesson":
|
|
72
|
+
return "Lesson video";
|
|
73
|
+
case "media clip":
|
|
74
|
+
return "Media clip";
|
|
75
|
+
default:
|
|
76
|
+
return "Unknown";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
80
|
+
|
|
81
|
+
export { OakCaptionCard };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
|
|
3
|
+
import { OakPrimaryButton } from '../../buttons/OakPrimaryButton/OakPrimaryButton.js';
|
|
4
|
+
import { OakFormInputWithLabels } from '../../owa/OakFormInputWithLabels/OakFormInputWithLabels.js';
|
|
5
|
+
|
|
6
|
+
var OakCaptionSearch = function (_a) {
|
|
7
|
+
var onSearch = _a.onSearch, hasError = _a.hasError, errorText = _a.errorText, _b = _a.isLoading, isLoading = _b === void 0 ? false : _b, defaultValue = _a.defaultValue;
|
|
8
|
+
var handleFormSubmit = function (event) {
|
|
9
|
+
// NB. we don't handle caption ID validation here to remain decoupled from the application logic
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
// get the input value from the form
|
|
12
|
+
var form = event.target;
|
|
13
|
+
var input = form.querySelector('input[name="caption-id"]');
|
|
14
|
+
var captionIdString = input.value.trim();
|
|
15
|
+
if (onSearch) {
|
|
16
|
+
onSearch(captionIdString);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return (React.createElement(OakFlex, { as: "form", "$flexDirection": "column", "$color": "text-primary", "$background": "bg-primary", "$pa": "spacing-24", "$gap": "spacing-24", "$borderRadius": "border-radius-s", onSubmit: handleFormSubmit },
|
|
20
|
+
React.createElement(OakFormInputWithLabels, { label: "Caption ID", inputName: "caption-id", helperText: "Enter on or more IDs (separated by commas).", invalid: hasError, invalidText: errorText, disabled: isLoading, defaultValue: defaultValue, required: true }),
|
|
21
|
+
React.createElement(OakPrimaryButton, { type: "submit", iconName: "search", isTrailingIcon: true, isLoading: isLoading }, "Search")));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { OakCaptionSearch };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function getTimeText(timestamp) {
|
|
2
|
+
var date = new Date(timestamp);
|
|
3
|
+
if (isNaN(date.getTime())) {
|
|
4
|
+
return "at an unknown time";
|
|
5
|
+
}
|
|
6
|
+
var now = Date.now();
|
|
7
|
+
var diff = now - date.getTime();
|
|
8
|
+
var seconds = Math.floor(diff / 1000);
|
|
9
|
+
if (seconds < 1) {
|
|
10
|
+
return "just now";
|
|
11
|
+
}
|
|
12
|
+
if (seconds < 60) {
|
|
13
|
+
return "".concat(seconds, " secs ago");
|
|
14
|
+
}
|
|
15
|
+
if (seconds < 3600) {
|
|
16
|
+
return "".concat(Math.floor(seconds / 60), " mins ago");
|
|
17
|
+
}
|
|
18
|
+
if (seconds < 86400) {
|
|
19
|
+
return "".concat(Math.floor(seconds / 3600), " hrs ago");
|
|
20
|
+
}
|
|
21
|
+
if (seconds < 604800) {
|
|
22
|
+
return "".concat(Math.floor(seconds / 86400), " days ago");
|
|
23
|
+
}
|
|
24
|
+
if (seconds < 2592000) {
|
|
25
|
+
return "".concat(Math.floor(seconds / 604800), " weeks ago");
|
|
26
|
+
}
|
|
27
|
+
if (seconds < 31536000) {
|
|
28
|
+
return "".concat(Math.floor(seconds / 2592000), " months ago");
|
|
29
|
+
}
|
|
30
|
+
return "".concat(Math.floor(seconds / 31536000), " years ago");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { getTimeText };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __makeTemplateObject, __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { responsiveStyle } from '../../../styles/utils/responsiveStyle.js';
|
|
5
|
+
|
|
6
|
+
var oakAspectRatioPercentage = {
|
|
7
|
+
"16:9": 56.25,
|
|
8
|
+
"3:2": 66.66,
|
|
9
|
+
"1:1": 100,
|
|
10
|
+
"2:3": 150,
|
|
11
|
+
"7:8": 114,
|
|
12
|
+
};
|
|
13
|
+
var parseRatioToPercentage = function (ratio) {
|
|
14
|
+
return ratio ? "".concat(oakAspectRatioPercentage[ratio], "%") : undefined;
|
|
15
|
+
};
|
|
16
|
+
var OakAspectRatioOuter = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 0;\n position: relative;\n ", "\n"], ["\n width: 100%;\n height: 0;\n position: relative;\n ", "\n"])), responsiveStyle("padding-top", function (props) { return props.ratio; }, parseRatioToPercentage));
|
|
17
|
+
var OakAspectRatioInner = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n position: absolute;\n right: 0;\n bottom: 0;\n left: 0;\n top: 0;\n"], ["\n display: flex;\n position: absolute;\n right: 0;\n bottom: 0;\n left: 0;\n top: 0;\n"])));
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* AspectRatio provides a container of fixed aspect ratio
|
|
21
|
+
*
|
|
22
|
+
* ⚠️ To be deprecated
|
|
23
|
+
* @deprecated
|
|
24
|
+
*
|
|
25
|
+
* ## Usage
|
|
26
|
+
* Use this component when you want to ensure a box has a certain aspect ratio.
|
|
27
|
+
* Wrap with component with <code>position: relative</code> and a width or min-width
|
|
28
|
+
* The 'ratio' prop is responsive, so you can pass an array e.g. <code>["3:2", "16:9"]</code>
|
|
29
|
+
* which will result in different aspect ratios on different screen widths.
|
|
30
|
+
* For an example usage, see the <code>CardImage</code> component.
|
|
31
|
+
*/
|
|
32
|
+
var OakAspectRatio = function (props) {
|
|
33
|
+
var children = props.children, ratio = props.ratio, htmlAttrs = __rest(props, ["children", "ratio"]);
|
|
34
|
+
return (React.createElement(OakAspectRatioOuter, __assign({ ratio: ratio }, htmlAttrs),
|
|
35
|
+
React.createElement(OakAspectRatioInner, null, children)));
|
|
36
|
+
};
|
|
37
|
+
var templateObject_1, templateObject_2;
|
|
38
|
+
|
|
39
|
+
export { OakAspectRatio };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { icons } from '../../../image-map.js';
|
|
4
|
+
import { OakImage } from '../OakImage/OakImage.js';
|
|
5
|
+
|
|
6
|
+
var oakIconNames = Object.keys(icons);
|
|
7
|
+
/**
|
|
8
|
+
* returns true if the given string is a valid `OakIconName`
|
|
9
|
+
*/
|
|
10
|
+
function isValidIconName(iconName) {
|
|
11
|
+
return oakIconNames.includes(iconName);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* returns a Icon URL from Cloudinary if is a valid icon, otherwise returns undefined
|
|
15
|
+
*/
|
|
16
|
+
function generateOakIconURL(iconName) {
|
|
17
|
+
var urlPath = "https://".concat(process.env.NEXT_PUBLIC_OAK_ASSETS_HOST, "/").concat(process.env.NEXT_PUBLIC_OAK_ASSETS_PATH);
|
|
18
|
+
if (isValidIconName(iconName)) {
|
|
19
|
+
return "".concat(urlPath, "/").concat(icons[iconName]);
|
|
20
|
+
}
|
|
21
|
+
else if (iconName.includes("subject")) {
|
|
22
|
+
return "".concat(urlPath, "/").concat(icons["books"]);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return "".concat(urlPath, "/").concat(icons["question-mark"]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A wrapper around OakImage which uses the image-map.json file to map icon names to image paths.
|
|
30
|
+
*/
|
|
31
|
+
var OakIcon = function (props) {
|
|
32
|
+
var iconName = props.iconName, alt = props.alt, iconWidth = props.iconWidth, iconHeight = props.iconHeight, _a = props.$width, $width = _a === void 0 ? iconWidth !== null && iconWidth !== void 0 ? iconWidth : "spacing-32" : _a, _b = props.$height, $height = _b === void 0 ? iconHeight !== null && iconHeight !== void 0 ? iconHeight : "spacing-32" : _b, _c = props.$minHeight, $minHeight = _c === void 0 ? $height : _c, _d = props.$minWidth, $minWidth = _d === void 0 ? $width : _d; props.imageProps; var rest = __rest(props, ["iconName", "alt", "iconWidth", "iconHeight", "$width", "$height", "$minHeight", "$minWidth", "imageProps"]);
|
|
33
|
+
return (React.createElement(OakImage, __assign({ src: generateOakIconURL(iconName), alt: alt !== null && alt !== void 0 ? alt : "", "$width": $width, "$height": $height, "$minHeight": $minHeight, "$minWidth": $minWidth, placeholder: "empty",
|
|
34
|
+
// Icons should not be optimised since the SVG is already as small as it can be and should be served directly
|
|
35
|
+
unoptimized: true }, rest)));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { OakIcon, generateOakIconURL, isValidIconName, oakIconNames };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __makeTemplateObject, __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
import { useShowPlaceholder } from './useShowPlaceholder.js';
|
|
6
|
+
import { colorFilterStyle } from '../../../styles/utils/colorFilterStyle.js';
|
|
7
|
+
import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
8
|
+
import { parseColor } from '../../../styles/helpers/parseColor.js';
|
|
9
|
+
import { parseSpacing } from '../../../styles/helpers/parseSpacing.js';
|
|
10
|
+
|
|
11
|
+
var oakPlaceholder = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZmlsbD0iIzIyMiIgZD0iTTI4Ljc3OSAxOS4xNzZhMjcuMTkxIDI3LjE5MSAwIDAgMC0zLjggMS42IDE2LjcgMTYuNyAwIDAgMC03LjEgOC40YzAgLjEtLjEuMi0uMS4zLS43IDIuNC0uNiAyIDEuMyAyLjMgMS45LjMgMSAuNSAxIDEuMy0uMSA4LjggNC4xIDE1LjEgMTEuNCAxOS42YTEuNSAxLjUgMCAwIDAgMS43LjJjNS43LTIuNiA5LjMtNyAxMC4zLTEzLjJhMSAxIDAgMCAxIDEtMWwzLS4yYy44IDAgMS4zLjIgMS4yIDEuMmExNy45IDE3LjkgMCAwIDEtMy4yIDkuMiAyMy43IDIzLjcgMCAwIDEtMTAuOSA5LjEgNS40MDEgNS40MDEgMCAwIDEtNC41LS4yIDI2LjI5OCAyNi4yOTggMCAwIDEtOC41LTYuNiAyNS45IDI1LjkgMCAwIDEtNi40LTE0LjRjMC0uNi0uMi0uNy0uOC0uOC0yLjUtLjQtMi41LS4xLTIuMy0yLjlhMTkuMyAxOS4zIDAgMCAxIDEwLjgtMTYuNiAzOC45OTkgMzguOTk5IDAgMCAxIDUuNy0yLjEgMi4xIDIuMSAwIDAgMCAuOS0xLjMgMTQuMSAxNC4xIDAgMCAxIDMuNS02LjNsLjMtLjNjMS45LTIgMi42LTIgNC4zLjJsLjQuNWMxLjEgMS4xIDEgMS41LS4xIDIuNmExMS45IDExLjkgMCAwIDAtMy4yIDQuNCAxNi45IDE2LjkgMCAwIDEgNy41IDIuM2M1LjcgMy41IDkuMiA4LjMgOS45IDE1IC4wMTYuOTAxLS4wMTcgMS44MDItLjEgMi43IDAgLjgtLjYgMS0xLjIgMS4yYTE2LjEgMTYuMSAwIDAgMS0xMS0uNyAxNy45MDEgMTcuOTAxIDAgMCAxLTEwLjktMTMuNiA5Ljc5NiA5Ljc5NiAwIDAgMS0uMS0xLjlabTE4LjEgMTIuMmMuNC01LjUtNi45LTEyLjYtMTMtMTIuMS41IDYuNSA3LjYgMTIuOCAxMyAxMi4xWiIgb3BhY2l0eT0iLjEiLz48L3N2Zz4=";
|
|
12
|
+
var clickStyles = css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
13
|
+
/* onClick might be passed in the useClickableCard pattern */
|
|
14
|
+
return props.onClick && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n :hover {\n cursor: pointer;\n }\n "], ["\n :hover {\n cursor: pointer;\n }\n "])));
|
|
15
|
+
});
|
|
16
|
+
var placeholderStyles = css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
17
|
+
return props.$showOakPlaceholder && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-image: url(", ");\n background-color: ", ";\n background-size: ", ";\n background-position: center;\n background-repeat: no-repeat;\n "], ["\n background-image: url(", ");\n background-color: ", ";\n background-size: ", ";\n background-position: center;\n background-repeat: no-repeat;\n "])), oakPlaceholder, parseColor("bg-decorative2-very-subdued"), parseSpacing("spacing-64"));
|
|
18
|
+
});
|
|
19
|
+
var StyledFillImage = styled(Image)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n ", "\n"], ["\n ", "\n ", "\n ", "\n ", "\n"])), colorFilterStyle, clickStyles, placeholderStyles, function (props) { return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n object-fit: ", ";\n "], ["\n object-fit: ", ";\n "])), props.$objectFit ? props.$objectFit : "contain"); });
|
|
20
|
+
var StyledResponsiveImage = styled(Image)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n width: 100%;\n height: auto;\n"], ["\n ", "\n ", "\n ", "\n width: 100%;\n height: auto;\n"])), colorFilterStyle, clickStyles, placeholderStyles);
|
|
21
|
+
/**
|
|
22
|
+
* A wrapper for NextJs's Image component.
|
|
23
|
+
*
|
|
24
|
+
* Use this for all image types as well as icons.
|
|
25
|
+
* Can accept remote urls provided they are whitelisted in next.config.js and relative urls for local images provided they begin with a "/".
|
|
26
|
+
* Set the width and height of the image through the `$width` and `$height` props when the aspect ratio is not known. This will letterbox the image to avoid stretching.
|
|
27
|
+
* Alternatively pass `width` and `height` props when the aspect ratio is known and use $minWidth to set the rendered width, avoiding letter-boxing.
|
|
28
|
+
* NB. for letterboxed images, $background controls the color of the letterbox not the image.
|
|
29
|
+
* `positionStyle` and `spacingStyle` props are also exposed for container.
|
|
30
|
+
* sizes is exposed for further optimisation read Next docs for more info.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
var OakImage = function (_a) {
|
|
34
|
+
var props = __rest(_a, []);
|
|
35
|
+
var as = props.as, src = props.src, alt = props.alt, width = props.width, height = props.height, sizes = props.sizes, _b = props.$width, $width = _b === void 0 ? "100%" : _b, _c = props.$position, $position = _c === void 0 ? "relative" : _c, $colorFilter = props.$colorFilter, _d = props.placeholder, placeholder = _d === void 0 ? "oak" : _d, unoptimized = props.unoptimized, imageProps = props.imageProps, $objectFit = props.$objectFit, onLoad = props.onLoad, onError = props.onError, rest = __rest(props, ["as", "src", "alt", "width", "height", "sizes", "$width", "$position", "$colorFilter", "placeholder", "unoptimized", "imageProps", "$objectFit", "onLoad", "onError"]);
|
|
36
|
+
var finalPlaceholder = placeholder === "oak" ? undefined : placeholder;
|
|
37
|
+
var _e = useShowPlaceholder(), showPlaceholder = _e.showPlaceholder, handleComplete = _e.handleComplete, setImg = _e.setImg;
|
|
38
|
+
// We don't know the aspect ratio of the image, so we must use fill and letterbox it to avoid stretching
|
|
39
|
+
// Use $width and $height to set the width and height of the image container
|
|
40
|
+
if (!width || !height) {
|
|
41
|
+
return (React.createElement(OakBox, __assign({ as: "span", "$display": "block", "$position": $position, "$width": $width }, rest),
|
|
42
|
+
React.createElement(StyledFillImage, __assign({ ref: setImg, as: as !== null && as !== void 0 ? as : Image, src: src, alt: alt, sizes: sizes, fill: true, "$colorFilter": $colorFilter, placeholder: finalPlaceholder, "$showOakPlaceholder": placeholder === "oak" && showPlaceholder, unoptimized: unoptimized, onLoad: handleComplete(onLoad), onError: handleComplete(onError), "$objectFit": $objectFit }, imageProps))));
|
|
43
|
+
}
|
|
44
|
+
// When we know the aspect ratio, we can use Image's repsonsive layout
|
|
45
|
+
// Use $minWidth to set the width with auto height
|
|
46
|
+
return (React.createElement(OakBox, __assign({ as: "span", "$display": "block", "$maxWidth": "spacing-0", "$position": $position }, rest),
|
|
47
|
+
React.createElement(StyledResponsiveImage, __assign({ ref: setImg, as: as !== null && as !== void 0 ? as : Image, src: src, alt: alt, width: width, height: height, sizes: sizes, unoptimized: unoptimized, "$colorFilter": $colorFilter, placeholder: finalPlaceholder, "$showOakPlaceholder": placeholder === "oak" && showPlaceholder, onLoad: handleComplete(onLoad), onError: handleComplete(onError) }, imageProps))));
|
|
48
|
+
};
|
|
49
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
50
|
+
|
|
51
|
+
export { OakImage, oakPlaceholder, placeholderStyles };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __read } from 'tslib';
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
function useShowPlaceholder() {
|
|
5
|
+
// Default to false so that we don't show the placeholder if the image is already complete
|
|
6
|
+
var _a = __read(useState(false), 2), showPlaceholder = _a[0], setShowPlaceholder = _a[1];
|
|
7
|
+
var setImg = useCallback(function (img) {
|
|
8
|
+
// the `load` or `error` event may never be called if the image is coming from the cache
|
|
9
|
+
// so we need to check the `complete` property as well as listen to the `onLoad` and `onError` events
|
|
10
|
+
img && setShowPlaceholder(!img.complete);
|
|
11
|
+
}, []);
|
|
12
|
+
return {
|
|
13
|
+
showPlaceholder: showPlaceholder,
|
|
14
|
+
setImg: setImg,
|
|
15
|
+
/**
|
|
16
|
+
* Wraps the `onLoad` and `onError` events to set the placeholder state
|
|
17
|
+
*/
|
|
18
|
+
handleComplete: function (originalHandler) {
|
|
19
|
+
return function (event) {
|
|
20
|
+
if (originalHandler) {
|
|
21
|
+
originalHandler(event);
|
|
22
|
+
}
|
|
23
|
+
setShowPlaceholder(false);
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { useShowPlaceholder };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
4
|
+
import { OakIcon } from '../OakIcon/OakIcon.js';
|
|
5
|
+
import { OakImage } from '../OakImage/OakImage.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A wrapper around `OakIcon` which applies a rounded background.
|
|
9
|
+
* Supports either an icon name or an image src
|
|
10
|
+
*/
|
|
11
|
+
var OakRoundIcon = function (_a) {
|
|
12
|
+
var _b = _a.$background, $background = _b === void 0 ? "bg-decorative5-main" : _b, _c = _a.$borderRadius, $borderRadius = _c === void 0 ? "border-radius-circle" : _c, _d = _a.$width, $width = _d === void 0 ? "spacing-48" : _d, _e = _a.$height, $height = _e === void 0 ? "spacing-48" : _e, _f = _a.$pa, $pa = _f === void 0 ? "spacing-4" : _f, className = _a.className, rest = __rest(_a, ["$background", "$borderRadius", "$width", "$height", "$pa", "className"]);
|
|
13
|
+
var icon = rest.iconName ? (React.createElement(OakIcon, __assign({}, rest, { "$height": "100%", "$width": "100%" }))) : (React.createElement(OakImage, __assign({}, rest, { "$height": "100%", "$width": "100%" })));
|
|
14
|
+
return (React.createElement(OakBox, { className: className, "$background": $background, "$borderRadius": $borderRadius, "$width": $width, "$height": $height, "$pa": $pa }, icon));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { OakRoundIcon };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { __makeTemplateObject, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { oakBoxCss } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
5
|
+
import { Underline } from '../../../svgs/underline.js';
|
|
6
|
+
import { HorizontalRule } from '../../../svgs/horizontal-rule.js';
|
|
7
|
+
import { HeaderUnderline } from '../../../svgs/header-underline.js';
|
|
8
|
+
import { Underline3 } from '../../../svgs/underline-3.js';
|
|
9
|
+
import { ButtonBorderTop } from '../../../svgs/button-border-top.js';
|
|
10
|
+
import { ButtonBorderBottom } from '../../../svgs/button-border-bottom.js';
|
|
11
|
+
import { ButtonBorderLeft } from '../../../svgs/button-border-left.js';
|
|
12
|
+
import { ButtonBorderRight } from '../../../svgs/button-border-right.js';
|
|
13
|
+
import { IconBackground } from '../../../svgs/icon-background.js';
|
|
14
|
+
import { Scribble } from '../../../svgs/scribble.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Map of the svg names to the actual svg components
|
|
18
|
+
* Only components that are used in the OakSvg component should be added here
|
|
19
|
+
* Should be used only in cases where OakIcon can't be used and if this list grows much bigger in the future we should consider refactoring
|
|
20
|
+
*/
|
|
21
|
+
var svgMap = {
|
|
22
|
+
"header-underline": HeaderUnderline,
|
|
23
|
+
underline: Underline,
|
|
24
|
+
"horizontal-rule": HorizontalRule,
|
|
25
|
+
"underline-3": Underline3,
|
|
26
|
+
"button-border-top": ButtonBorderTop,
|
|
27
|
+
"button-border-bottom": ButtonBorderBottom,
|
|
28
|
+
"button-border-left": ButtonBorderLeft,
|
|
29
|
+
"button-border-right": ButtonBorderRight,
|
|
30
|
+
"icon-background": IconBackground,
|
|
31
|
+
scribble: Scribble,
|
|
32
|
+
};
|
|
33
|
+
var StyledSvg = styled.svg(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n transition: all 0.3s ease;\n"], ["\n ", ";\n transition: all 0.3s ease;\n"])), oakBoxCss);
|
|
34
|
+
/**
|
|
35
|
+
* This is component used for rendering SVGs that don't belong to be rendered with OakIcon component
|
|
36
|
+
* ie. UI elements that are not icons/illustratons but are part of the design system (underline, etc)
|
|
37
|
+
*/
|
|
38
|
+
var OakSvg = function (props) {
|
|
39
|
+
var getSvgByName = function (name) {
|
|
40
|
+
var SvgComponent = svgMap[name];
|
|
41
|
+
return React.createElement(SvgComponent, null);
|
|
42
|
+
};
|
|
43
|
+
return (React.createElement(StyledSvg, __assign({ "aria-hidden": true, xmlns: "http://www.w3.org/2000/svg", width: "100%", height: "100%" }, props), getSvgByName(props.name)));
|
|
44
|
+
};
|
|
45
|
+
var templateObject_1;
|
|
46
|
+
|
|
47
|
+
export { OakSvg };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __makeTemplateObject, __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import useAccordionContext from './useAccordionContext.js';
|
|
5
|
+
import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
|
|
6
|
+
import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
7
|
+
|
|
8
|
+
var FlexWithReset = styled(OakFlex)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font: inherit;\n color: inherit;\n border: none;\n background: none;\n appearance: none;\n outline: none;\n padding: 0;\n"], ["\n font: inherit;\n color: inherit;\n border: none;\n background: none;\n appearance: none;\n outline: none;\n padding: 0;\n"])));
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Content which will appear and disappear
|
|
12
|
+
*
|
|
13
|
+
* Must appear as a sibling of InternalAccordionButton
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
var InternalAccordionContent = function (_a) {
|
|
17
|
+
var children = _a.children, onScroll = _a.onScroll, ref = _a.ref, rest = __rest(_a, ["children", "onScroll", "ref"]);
|
|
18
|
+
var isOpen = useAccordionContext().isOpen;
|
|
19
|
+
return (React.createElement(OakBox, __assign({ hidden: !isOpen, role: "region" }, rest, { onScroll: onScroll, ref: ref }), children));
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* User interface to toggle visibility of InternalAccordionContent
|
|
24
|
+
*
|
|
25
|
+
* Must appear as a sibling of InternalAccordionContent
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
var AccordionButton = function (props) {
|
|
29
|
+
var children = props.children, id = props.id, rest = __rest(props, ["children", "id"]);
|
|
30
|
+
var _a = useAccordionContext(), isOpen = _a.isOpen, setOpen = _a.setOpen;
|
|
31
|
+
return (React.createElement(FlexWithReset, __assign({ as: "button", type: "button", onClick: function () { return setOpen(!isOpen); }, "$flexGrow": 1, "aria-expanded": isOpen, id: id }, rest), children));
|
|
32
|
+
};
|
|
33
|
+
var InternalAccordionButton = styled(AccordionButton)(templateObject_2 || (templateObject_2 = __makeTemplateObject([""], [""])));
|
|
34
|
+
var templateObject_1, templateObject_2;
|
|
35
|
+
|
|
36
|
+
export { InternalAccordionButton, InternalAccordionContent };
|
package/dist/npm/es/components/internal-components/InternalAccordion/InternalAccordionProvider.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __read } from 'tslib';
|
|
2
|
+
import React, { createContext, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
var accordionContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Decomposed component comprising InternalAccordionButton and InternalAccordionContent wrapped by InternalAccordionProvider
|
|
8
|
+
*
|
|
9
|
+
* - InternalAccordionButton will toggle InternalAccordionContent visibility
|
|
10
|
+
* - It is up to the user to arrange the InternalAccordionButton and InternalAccordionContent components in the desired order
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
var InternalAccordionProvider = function (_a) {
|
|
14
|
+
var children = _a.children, isInitialOpen = _a.isInitialOpen;
|
|
15
|
+
var _b = __read(useState(isInitialOpen), 2), isOpen = _b[0], setOpen = _b[1];
|
|
16
|
+
var accordionValue = {
|
|
17
|
+
isOpen: isOpen,
|
|
18
|
+
setOpen: setOpen,
|
|
19
|
+
isInitialOpen: false,
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(accordionContext.Provider, { value: accordionValue }, children));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { InternalAccordionProvider, accordionContext, InternalAccordionProvider as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { accordionContext } from './InternalAccordionProvider.js';
|
|
3
|
+
|
|
4
|
+
var useAccordionContext = function () {
|
|
5
|
+
var accordionValue = useContext(accordionContext);
|
|
6
|
+
if (!accordionValue) {
|
|
7
|
+
throw new Error("useAccordionContext() called outside of menu provider");
|
|
8
|
+
}
|
|
9
|
+
return accordionValue;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { useAccordionContext as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __makeTemplateObject, __rest, __assign } from 'tslib';
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { colorStyle } from '../../../styles/utils/colorStyle.js';
|
|
5
|
+
import { displayStyle } from '../../../styles/utils/displayStyle.js';
|
|
6
|
+
import { spacingStyle } from '../../../styles/utils/spacingStyle.js';
|
|
7
|
+
import { typographyStyle } from '../../../styles/utils/typographyStyle.js';
|
|
8
|
+
import { dropShadowStyle } from '../../../styles/utils/dropShadowStyle.js';
|
|
9
|
+
import { borderStyle } from '../../../styles/utils/borderStyle.js';
|
|
10
|
+
|
|
11
|
+
var internalButtonCss = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: none;\n color: inherit;\n border: none;\n padding: 0;\n font: inherit;\n cursor: pointer;\n text-align: left;\n font-family: unset;\n outline: none;\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n &:disabled {\n pointer-events: none;\n cursor: default;\n }\n"], ["\n background: none;\n color: inherit;\n border: none;\n padding: 0;\n font: inherit;\n cursor: pointer;\n text-align: left;\n font-family: unset;\n outline: none;\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n &:disabled {\n pointer-events: none;\n cursor: default;\n }\n"])), typographyStyle, colorStyle, spacingStyle, displayStyle, borderStyle, dropShadowStyle);
|
|
12
|
+
var UnstyledInternalButton = function (props) {
|
|
13
|
+
var onClick = props.onClick, onHovered = props.onHovered, _a = props.element, Component = _a === void 0 ? "button" : _a, rest = __rest(props, ["onClick", "onHovered", "element"]);
|
|
14
|
+
var hoverStart = useRef(Date.now());
|
|
15
|
+
var handleClick = function (event) {
|
|
16
|
+
if (onClick) {
|
|
17
|
+
onClick(event);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var handleMouseEnter = function () {
|
|
21
|
+
hoverStart.current = Date.now();
|
|
22
|
+
};
|
|
23
|
+
var handleMouseLeave = function (event) {
|
|
24
|
+
var delta = Date.now() - hoverStart.current;
|
|
25
|
+
if (onHovered) {
|
|
26
|
+
onHovered(event, delta);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return (React.createElement(Component, __assign({}, rest, { onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave })));
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* An unstyled button to be used as a basis for all UI button components.
|
|
34
|
+
* The following callbacks are available for tracking focus events:
|
|
35
|
+
*
|
|
36
|
+
* ### onClick
|
|
37
|
+
* `onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;`
|
|
38
|
+
|
|
39
|
+
* ### onHovered
|
|
40
|
+
* `onHovered?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, duration: number) => void;`<br>
|
|
41
|
+
* called after a mouseEnter and mouseLeave event has happened
|
|
42
|
+
*
|
|
43
|
+
* NB. We must export a styled component for it to be inheritable
|
|
44
|
+
*/
|
|
45
|
+
var InternalButton = styled(UnstyledInternalButton)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), internalButtonCss);
|
|
46
|
+
var templateObject_1, templateObject_2;
|
|
47
|
+
|
|
48
|
+
export { InternalButton };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __assign, __makeTemplateObject } from 'tslib';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
|
|
4
|
+
|
|
5
|
+
var internalCardDefaults = {
|
|
6
|
+
$pa: "spacing-24",
|
|
7
|
+
$flexDirection: "column",
|
|
8
|
+
$flexGrow: 1,
|
|
9
|
+
$position: "relative",
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* InternalCard extends OakFlex. It has all the props of OakFlex, but applies default styles for consistency.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
var InternalCard = styled(OakFlex).attrs(function (props) { return (__assign(__assign({}, internalCardDefaults), props)); })(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
17
|
+
var templateObject_1;
|
|
18
|
+
|
|
19
|
+
export { InternalCard, internalCardDefaults };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __makeTemplateObject, __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { InternalCard } from '../InternalCard/InternalCard.js';
|
|
5
|
+
import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The `backgroundElement` should be sized to fit the entire card
|
|
9
|
+
*/
|
|
10
|
+
var StyledBackgroundBox = styled(OakBox)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & > * {\n width: 100%;\n height: 100%;\n }\n"], ["\n & > * {\n width: 100%;\n height: 100%;\n }\n"])));
|
|
11
|
+
/**
|
|
12
|
+
* A flexed card with a presentational background element positioned behind the card contents.
|
|
13
|
+
*/
|
|
14
|
+
var InternalCardWithBackgroundElement = function (_a) {
|
|
15
|
+
var backgroundElement = _a.backgroundElement, children = _a.children, props = __rest(_a, ["backgroundElement", "children"]);
|
|
16
|
+
return (React.createElement(InternalCard, __assign({}, props),
|
|
17
|
+
React.createElement(StyledBackgroundBox, { "$position": "absolute", "$inset": "spacing-0", "aria-hidden": true }, backgroundElement),
|
|
18
|
+
React.createElement(OakBox, { "$position": "relative" }, children)));
|
|
19
|
+
};
|
|
20
|
+
var templateObject_1;
|
|
21
|
+
|
|
22
|
+
export { InternalCardWithBackgroundElement };
|