@oaknational/oak-components 0.6.2 → 0.8.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/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as styled_components from 'styled-components';
2
2
  import { CSSProperties as CSSProperties$1 } from 'styled-components';
3
3
  import * as React$1 from 'react';
4
- import React__default, { CSSProperties, MouseEventHandler, ElementType, ComponentPropsWithoutRef, FC, ReactNode, ComponentPropsWithRef, FocusEvent, DetailedHTMLProps, InputHTMLAttributes, ChangeEventHandler, ReactElement, ComponentProps } from 'react';
4
+ import React__default, { CSSProperties, MouseEventHandler, ElementType, ComponentPropsWithoutRef, FC, ReactNode, ComponentPropsWithRef, FocusEvent, DetailedHTMLProps, InputHTMLAttributes, ChangeEventHandler, ReactElement, ComponentProps, HTMLAttributes } from 'react';
5
5
  import * as csstype from 'csstype';
6
6
  import * as Image from 'next/image';
7
7
  import Image__default, { ImageProps as ImageProps$1 } from 'next/image';
@@ -57,7 +57,7 @@ declare const oakColorTokens: {
57
57
  transparent: string;
58
58
  };
59
59
  type OakColorToken = keyof typeof oakColorTokens;
60
- declare const oakUiRoleTokens: readonly ["text-primary", "text-subdued", "text-error", "text-disabled", "text-link-active", "text-link-hover", "text-link-visited", "text-link-pressed", "text-inverted", "text-success", "text-warning", "bg-primary", "bg-neutral", "bg-neutral-stronger", "bg-btn-primary", "bg-btn-primary-hover", "bg-btn-primary-disabled", "bg-btn-secondary", "bg-btn-secondary-hover", "bg-btn-secondary-disabled", "bg-icon", "bg-icon-hover", "bg-decorative1-main", "bg-decorative1-subdued", "bg-decorative1-very-subdued", "bg-decorative2-main", "bg-decorative2-subdued", "bg-decorative2-very-subdued", "bg-decorative3-main", "bg-decorative3-subdued", "bg-decorative3-very-subdued", "bg-decorative4-main", "bg-decorative4-subdued", "bg-decorative4-very-subdued", "bg-decorative5-main", "bg-decorative5-subdued", "bg-decorative5-very-subdued", "bg-correct", "bg-incorrect", "icon-main", "icon-inverted", "icon-disabled", "icon-brand", "icon-success", "icon-error", "icon-warning", "border-primary", "border-inverted", "border-neutral", "border-brand", "border-success", "border-error", "border-warning", "border-decorative1", "border-decorative1-stronger", "border-decorative2", "border-decorative2-stronger", "border-decorative3", "border-decorative3-stronger", "border-decorative4", "border-decorative4-stronger", "border-decorative5", "border-decorative5-stronger", "border-decorative6", "border-decorative6-stronger", "transparent"];
60
+ declare const oakUiRoleTokens: readonly ["text-primary", "text-subdued", "text-error", "text-disabled", "text-link-active", "text-link-hover", "text-link-visited", "text-link-pressed", "text-inverted", "text-success", "text-warning", "bg-primary", "bg-neutral", "bg-neutral-stronger", "bg-btn-primary", "bg-btn-primary-hover", "bg-btn-primary-disabled", "bg-btn-secondary", "bg-btn-secondary-hover", "bg-btn-secondary-disabled", "bg-icon", "bg-icon-hover", "bg-decorative1-main", "bg-decorative1-subdued", "bg-decorative1-very-subdued", "bg-decorative2-main", "bg-decorative2-subdued", "bg-decorative2-very-subdued", "bg-decorative3-main", "bg-decorative3-subdued", "bg-decorative3-very-subdued", "bg-decorative4-main", "bg-decorative4-subdued", "bg-decorative4-very-subdued", "bg-decorative5-main", "bg-decorative5-subdued", "bg-decorative5-very-subdued", "bg-correct", "bg-incorrect", "icon-main", "icon-inverted", "icon-disabled", "icon-brand", "icon-success", "icon-error", "icon-warning", "border-primary", "border-inverted", "border-neutral", "border-neutral-lighter", "border-brand", "border-success", "border-error", "border-warning", "border-decorative1", "border-decorative1-stronger", "border-decorative2", "border-decorative2-stronger", "border-decorative3", "border-decorative3-stronger", "border-decorative4", "border-decorative4-stronger", "border-decorative5", "border-decorative5-stronger", "border-decorative6", "border-decorative6-stronger", "transparent"];
61
61
  type OakUiRoleToken = (typeof oakUiRoleTokens)[number];
62
62
  type UiRoleMap = Record<OakUiRoleToken, OakColorToken | null | undefined>;
63
63
  type OakCombinedColorToken = OakColorToken | OakUiRoleToken;
@@ -1653,7 +1653,14 @@ type BaseCheckBoxProps = {
1653
1653
  id: string;
1654
1654
  disabled?: boolean;
1655
1655
  value: string;
1656
+ /**
1657
+ * Uncontrolled checked state
1658
+ */
1656
1659
  defaultChecked?: boolean;
1660
+ /**
1661
+ * Controlled checked state
1662
+ */
1663
+ checked?: boolean;
1657
1664
  onHovered?: (value: string, id: string, duration: number) => void;
1658
1665
  onChange?: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
1659
1666
  onFocus?: (event: React__default.FocusEvent<HTMLInputElement>) => void;
@@ -2012,6 +2019,84 @@ type OakDraggableFeedbackProps = ComponentPropsWithoutRef<typeof OakDraggable> &
2012
2019
  */
2013
2020
  declare const OakDraggableFeedback: ({ feedback, ...props }: OakDraggableFeedbackProps) => React__default.JSX.Element;
2014
2021
 
2022
+ type OakAccordionProps = {
2023
+ /**
2024
+ * The header of the accordion
2025
+ */
2026
+ header: ReactNode;
2027
+ /**
2028
+ * Slot to place content after the header and outside the button
2029
+ */
2030
+ headerAfterSlot?: ReactNode;
2031
+ /**
2032
+ * Whether the accordion should be open initially
2033
+ */
2034
+ initialOpen?: boolean;
2035
+ /**
2036
+ * The content of the accordion
2037
+ */
2038
+ children: ReactNode;
2039
+ /**
2040
+ * The id of the accordion
2041
+ */
2042
+ id: string;
2043
+ };
2044
+ /**
2045
+ * An accordion component that can be used to show/hide content
2046
+ */
2047
+ declare const OakAccordion: ({ header, headerAfterSlot, children, initialOpen, id, }: OakAccordionProps) => React__default.JSX.Element;
2048
+
2049
+ type OakModalProps = {
2050
+ /**
2051
+ * The content of the modal.
2052
+ * Use with `<OakModalBody>` for best results.
2053
+ */
2054
+ children: ReactNode;
2055
+ /**
2056
+ * Slot for the footer of the modal.
2057
+ * Use with `<OakModalFooter>` for best results.
2058
+ */
2059
+ footerSlot?: ReactNode;
2060
+ /**
2061
+ * Indicates whether the modal is open or closed
2062
+ */
2063
+ isOpen: boolean;
2064
+ /**
2065
+ * Called when the modal is closed
2066
+ */
2067
+ onClose: () => void;
2068
+ /**
2069
+ * The DOM container to render the modal portal into.
2070
+ *
2071
+ * @default document.body
2072
+ */
2073
+ domContainer?: Element;
2074
+ } & Pick<HTMLAttributes<Element>, "aria-label" | "aria-description" | "aria-labelledby" | "aria-describedby">;
2075
+ /**
2076
+ * Modal dialog with trapped focus and a close button.
2077
+ */
2078
+ declare const OakModal: ({ children, footerSlot, domContainer, isOpen, onClose, ...rest }: OakModalProps) => React__default.ReactPortal;
2079
+
2080
+ type OakModalBodyProps = {
2081
+ children: ReactNode;
2082
+ };
2083
+ /**
2084
+ * Intended to be used in the `children` slot of `OakModal`
2085
+ * it applies some padding and margin to ensure that the contents
2086
+ * line up with the modal's header and footer
2087
+ */
2088
+ declare const OakModalBody: (props: OakModalBodyProps) => React__default.JSX.Element;
2089
+
2090
+ type OakModalFooterProps = {
2091
+ children: ReactNode;
2092
+ };
2093
+ /**
2094
+ * Intended to be used in the `footer` slot of `OakModal`
2095
+ * it is ideal as a container for one or more buttons.
2096
+ * It switches from a horizontal to vertical layout on smaller screens
2097
+ */
2098
+ declare const OakModalFooter: (props: OakModalFooterProps) => React__default.JSX.Element;
2099
+
2015
2100
  type OakQuizCheckBoxProps = Omit<BaseCheckBoxProps, "defaultChecked"> & {
2016
2101
  feedback?: "correct" | "incorrect" | null;
2017
2102
  image?: React__default.JSX.Element;
@@ -2351,4 +2436,4 @@ type OakPrimaryNavProps = {
2351
2436
  */
2352
2437
  declare const OakPrimaryNav: ({ ariaLabel, navItems }: OakPrimaryNavProps) => React__default.JSX.Element;
2353
2438
 
2354
- export { HeadingTagComponent, type OakAllSpacingToken, OakBackLink, type OakBackLinkProps, type OakBorderRadiusToken, type OakBorderWidthToken, OakBox, type OakBoxProps, OakBulletList, type OakBulletListProps, OakCardHeader, type OakCardHeaderprops, OakCheckBox, type OakCheckBoxProps, OakCloudinaryConfigProvider, OakCloudinaryImage, type OakCloudinaryImageProps, OakCollapsibleContent, type OakCollapsibleContentProps, type OakColorToken, type OakCombinedColorToken, type OakCombinedSpacingToken, OakDragAndDropInstructions, OakDraggable, OakDraggableFeedback, type OakDropShadowToken, OakDroppable, type OakDroppableProps, OakFieldError, type OakFieldErrorProps, OakFlex, type OakFlexProps, type OakFontSizeToken, type OakFontToken, OakForm, type OakFormProps, OakGlobalStyle, OakGrid, OakGridArea, type OakGridAreaProps, type OakGridProps, type OakHandDrawnBoxWithIconProps, OakHandDrawnCard, type OakHandDrawnCardProps, OakHandDrawnCardWithIcon, OakHeading, type OakHeadingProps, type OakHeadingTag, OakHintButton, type OakHintButtonProps, OakIcon, type OakIconName, type OakIconProps, OakImage, type OakImageProps, type OakInfoCardProps, type OakInnerPaddingToken, OakKbd, type OakKbdProps, OakLI, type OakLIProps, OakLabel, type OakLabelProps, OakLessonBottomNav, type OakLessonBottomNavProps, OakLessonInfoCard, OakLessonLayout, type OakLessonLayoutProps, OakLessonNavItem, type OakLessonNavItemProps, OakLessonReviewItem, type OakLessonReviewItemProps, OakLessonTopNav, type OakLessonTopNavProps, OakLessonVideoTranscript, OakLink, type OakLinkProps, OakLoadingSpinner, type OakLoadingSpinnerProps, OakMaxWidth, OakOL, type OakOLProps, type OakOpacityToken, OakP, type OakPProps, OakPrimaryButton, type OakPrimaryButtonProps, OakPrimaryInvertedButton, type OakPrimaryInvertedButtonProps, OakPrimaryNav, OakPrimaryNavItem, type OakPrimaryNavItemProps, type OakPrimaryNavProps, OakPromoTag, OakQuizCheckBox, type OakQuizCheckBoxProps, OakQuizCounter, type OakQuizCounterProps, OakQuizFeedback, type OakQuizFeedbackProps, OakQuizHint, type OakQuizHintProps, OakQuizMatch, type OakQuizMatchProps, OakQuizOrder, type OakQuizOrderProps, OakQuizRadioButton, type OakQuizRadioButtonProps, OakQuizTextInput, OakRadioButton, OakRadioGroup, OakRoundIcon, type OakRoundIconProps, OakSecondaryButton, type OakSecondaryButtonProps, type OakSpaceBetweenToken, OakSpan, type OakSpanProps, OakStaticMessageCard, OakSubjectIcon, type OakSubjectIconProps, OakTertiaryButton, OakTextInput, type OakTextInputProps, type OakTheme, OakThemeProvider, type OakThemeProviderProps, OakTooltip, type OakTooltipProps, type OakTransitionToken, OakTypography, type OakTypographyProps, OakUL, type OakULProps, type OakUiRoleToken, isValidIconName, oakAllSpacingTokens, oakBorderRadiusTokens, oakBorderWidthTokens, oakBoxCss, oakColorTokens, oakDefaultTheme, oakDropShadowTokens, oakFontSizeTokens, oakFontTokens, oakHeadingTags, oakIconNames, oakInnerPaddingTokens, oakOpacityTokens, oakSpaceBetweenTokens, oakTransitionTokens, oakUiRoleTokens };
2439
+ export { HeadingTagComponent, OakAccordion, type OakAccordionProps, type OakAllSpacingToken, OakBackLink, type OakBackLinkProps, type OakBorderRadiusToken, type OakBorderWidthToken, OakBox, type OakBoxProps, OakBulletList, type OakBulletListProps, OakCardHeader, type OakCardHeaderprops, OakCheckBox, type OakCheckBoxProps, OakCloudinaryConfigProvider, OakCloudinaryImage, type OakCloudinaryImageProps, OakCollapsibleContent, type OakCollapsibleContentProps, type OakColorToken, type OakCombinedColorToken, type OakCombinedSpacingToken, OakDragAndDropInstructions, OakDraggable, OakDraggableFeedback, type OakDropShadowToken, OakDroppable, type OakDroppableProps, OakFieldError, type OakFieldErrorProps, OakFlex, type OakFlexProps, type OakFontSizeToken, type OakFontToken, OakForm, type OakFormProps, OakGlobalStyle, OakGrid, OakGridArea, type OakGridAreaProps, type OakGridProps, type OakHandDrawnBoxWithIconProps, OakHandDrawnCard, type OakHandDrawnCardProps, OakHandDrawnCardWithIcon, OakHeading, type OakHeadingProps, type OakHeadingTag, OakHintButton, type OakHintButtonProps, OakIcon, type OakIconName, type OakIconProps, OakImage, type OakImageProps, type OakInfoCardProps, type OakInnerPaddingToken, OakKbd, type OakKbdProps, OakLI, type OakLIProps, OakLabel, type OakLabelProps, OakLessonBottomNav, type OakLessonBottomNavProps, OakLessonInfoCard, OakLessonLayout, type OakLessonLayoutProps, OakLessonNavItem, type OakLessonNavItemProps, OakLessonReviewItem, type OakLessonReviewItemProps, OakLessonTopNav, type OakLessonTopNavProps, OakLessonVideoTranscript, OakLink, type OakLinkProps, OakLoadingSpinner, type OakLoadingSpinnerProps, OakMaxWidth, OakModal, OakModalBody, type OakModalBodyProps, OakModalFooter, type OakModalFooterProps, type OakModalProps, OakOL, type OakOLProps, type OakOpacityToken, OakP, type OakPProps, OakPrimaryButton, type OakPrimaryButtonProps, OakPrimaryInvertedButton, type OakPrimaryInvertedButtonProps, OakPrimaryNav, OakPrimaryNavItem, type OakPrimaryNavItemProps, type OakPrimaryNavProps, OakPromoTag, OakQuizCheckBox, type OakQuizCheckBoxProps, OakQuizCounter, type OakQuizCounterProps, OakQuizFeedback, type OakQuizFeedbackProps, OakQuizHint, type OakQuizHintProps, OakQuizMatch, type OakQuizMatchProps, OakQuizOrder, type OakQuizOrderProps, OakQuizRadioButton, type OakQuizRadioButtonProps, OakQuizTextInput, OakRadioButton, OakRadioGroup, OakRoundIcon, type OakRoundIconProps, OakSecondaryButton, type OakSecondaryButtonProps, type OakSpaceBetweenToken, OakSpan, type OakSpanProps, OakStaticMessageCard, OakSubjectIcon, type OakSubjectIconProps, OakTertiaryButton, OakTextInput, type OakTextInputProps, type OakTheme, OakThemeProvider, type OakThemeProviderProps, OakTooltip, type OakTooltipProps, type OakTransitionToken, OakTypography, type OakTypographyProps, OakUL, type OakULProps, type OakUiRoleToken, isValidIconName, oakAllSpacingTokens, oakBorderRadiusTokens, oakBorderWidthTokens, oakBoxCss, oakColorTokens, oakDefaultTheme, oakDropShadowTokens, oakFontSizeTokens, oakFontTokens, oakHeadingTags, oakIconNames, oakInnerPaddingTokens, oakOpacityTokens, oakSpaceBetweenTokens, oakTransitionTokens, oakUiRoleTokens };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oaknational/oak-components",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
4
4
  "licence": "MIT",
5
5
  "description": "Shared components for Oak applications",
6
6
  "main": "dist/cjs/index.js",
@@ -53,6 +53,7 @@
53
53
  "@storybook/addon-onboarding": "^1.0.10",
54
54
  "@storybook/blocks": "^7.6.7",
55
55
  "@storybook/nextjs": "^7.6.7",
56
+ "@storybook/preview-api": "^8.0.4",
56
57
  "@storybook/react": "^7.6.7",
57
58
  "@storybook/testing-library": "^0.2.2",
58
59
  "@testing-library/jest-dom": "^6.2.0",
@@ -61,6 +62,7 @@
61
62
  "@types/jest": "^29.5.11",
62
63
  "@types/react": "^18.2.47",
63
64
  "@types/react-test-renderer": "^18.0.7",
65
+ "@types/react-transition-group": "^4.4.10",
64
66
  "@types/styled-components": "^5.1.34",
65
67
  "@typescript-eslint/eslint-plugin": "^6.18.1",
66
68
  "@typescript-eslint/parser": "^6.18.1",
@@ -80,7 +82,9 @@
80
82
  "prettier": "^3.1.1",
81
83
  "react": "^18.2.0",
82
84
  "react-dom": "^18.2.0",
85
+ "react-focus-on": "^3.9.2",
83
86
  "react-test-renderer": "^18.2.0",
87
+ "react-transition-group": "^4.4.5",
84
88
  "rollup": "^4.9.4",
85
89
  "rollup-plugin-dts": "^6.1.0",
86
90
  "rollup-plugin-peer-deps-external": "^2.2.4",