@oaknational/oak-components 3.14.4 → 3.16.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 +28 -13
- package/dist/npm/cjs/types.d.ts +15 -1
- package/dist/npm/es/components/navigation/OakCard/OakCard.js +18 -2
- package/dist/npm/es/components/owa/OakResourceCard/OakResourceCard.js +14 -8
- package/dist/npm/es/components/owa/teacher/OakResourcesAccordion/OakResourcesAccordion.js +3 -3
- package/dist/npm/es/types.d.ts +15 -1
- package/package.json +1 -1
package/dist/npm/cjs/index.js
CHANGED
|
@@ -4626,6 +4626,11 @@ var StyledOakFlex$2 = styled__default.default(OakFlex)(templateObject_6$5 || (te
|
|
|
4626
4626
|
var $cardOrientation = _a.$cardOrientation;
|
|
4627
4627
|
return getResponsiveCardOrientationStyles($cardOrientation);
|
|
4628
4628
|
});
|
|
4629
|
+
function boolAsDisplay(input) {
|
|
4630
|
+
if (input === undefined)
|
|
4631
|
+
return;
|
|
4632
|
+
return input ? "block" : "none";
|
|
4633
|
+
}
|
|
4629
4634
|
/**
|
|
4630
4635
|
* A highly customisable card component that displays a heading and takes a href at minimum.
|
|
4631
4636
|
*
|
|
@@ -4635,10 +4640,14 @@ var StyledOakFlex$2 = styled__default.default(OakFlex)(templateObject_6$5 || (te
|
|
|
4635
4640
|
* The image aspect ratio can be set to either 1:1 or 4:3.
|
|
4636
4641
|
*/
|
|
4637
4642
|
var OakCard = function (_a) {
|
|
4638
|
-
var _b = _a.as, as = _b === void 0 ? "div" : _b, heading = _a.heading, _c = _a.headingLevel, headingLevel = _c === void 0 ? "h3" : _c, href = _a.href, _d = _a.cardOrientation, cardOrientation = _d === void 0 ? "column" : _d, cardWidth = _a.cardWidth, imageSrc = _a.imageSrc, imageAlt = _a.imageAlt, _e = _a.aspectRatio, aspectRatio = _e === void 0 ? "1/1" : _e, subCopy = _a.subCopy, _f = _a.subCopyColor, subCopyColor = _f === void 0 ? "text-primary" : _f, tagName = _a.tagName, _g = _a.tagBackground, tagBackground = _g === void 0 ? "bg-decorative3-very-subdued" : _g, linkText = _a.linkText, _h = _a.linkIconName, linkIconName = _h === void 0 ? "arrow-right" : _h, _j = _a.hoverBackground, hoverBackground = _j === void 0 ? "bg-btn-secondary-hover" : _j, _k = _a.imageBackgroundColor, imageBackgroundColor = _k === void 0 ? "bg-neutral" : _k;
|
|
4643
|
+
var _b = _a.as, as = _b === void 0 ? "div" : _b, heading = _a.heading, _c = _a.headingLevel, headingLevel = _c === void 0 ? "h3" : _c, href = _a.href, _d = _a.cardOrientation, cardOrientation = _d === void 0 ? "column" : _d, cardWidth = _a.cardWidth, imageSrc = _a.imageSrc, imageAlt = _a.imageAlt, _e = _a.aspectRatio, aspectRatio = _e === void 0 ? "1/1" : _e, subCopy = _a.subCopy, _f = _a.subCopyColor, subCopyColor = _f === void 0 ? "text-primary" : _f, tagName = _a.tagName, _g = _a.tagBackground, tagBackground = _g === void 0 ? "bg-decorative3-very-subdued" : _g, linkText = _a.linkText, _h = _a.linkIconName, linkIconName = _h === void 0 ? "arrow-right" : _h, _j = _a.hoverBackground, hoverBackground = _j === void 0 ? "bg-btn-secondary-hover" : _j, _k = _a.imageBackgroundColor, imageBackgroundColor = _k === void 0 ? "bg-neutral" : _k, showImage = _a.showImage;
|
|
4644
|
+
var displayImage = Array.isArray(showImage)
|
|
4645
|
+
? showImage.map(function (value) { return boolAsDisplay(value); })
|
|
4646
|
+
: boolAsDisplay(showImage);
|
|
4639
4647
|
return (React__default.default.createElement(OakFocusIndicator, { as: as, "$background": "bg-primary", hoverBackground: hoverBackground, "$height": "100%", "$width": cardWidth, "$borderRadius": "border-radius-m2" },
|
|
4640
4648
|
React__default.default.createElement(StyledOakFlex$2, { as: "a", href: href, "$cardOrientation": cardOrientation, "$height": "100%", "$pa": "spacing-16", "$gap": "spacing-16" },
|
|
4641
|
-
imageSrc && (React__default.default.createElement(
|
|
4649
|
+
imageSrc && (React__default.default.createElement(OakBox, { "$display": displayImage },
|
|
4650
|
+
React__default.default.createElement(StyledOakImage, { src: imageSrc || "", alt: imageAlt || "", "$width": "auto", "$aspectRatio": aspectRatio, "$background": imageBackgroundColor, "$borderRadius": "border-radius-m2" }))),
|
|
4642
4651
|
React__default.default.createElement(CardContent, { "$flexDirection": "column", "$justifyContent": "space-between", "$gap": "spacing-16" },
|
|
4643
4652
|
React__default.default.createElement(OakFlex, { "$flexDirection": "column", "$gap": "spacing-16" },
|
|
4644
4653
|
React__default.default.createElement(OakHeading, { tag: headingLevel, "$font": "heading-6" }, heading),
|
|
@@ -4679,13 +4688,13 @@ var StyledAccordionButton$2 = styled__default.default(InternalAccordionButton)(t
|
|
|
4679
4688
|
* Internal accordion component that handles the accordion logic
|
|
4680
4689
|
*/
|
|
4681
4690
|
var Accordion$2 = function (_a) {
|
|
4682
|
-
var children = _a.children, id = _a.id, selectAllChecked = _a.selectAllChecked, subheading = _a.subheading, handleToggleSelectAll = _a.handleToggleSelectAll, styleProps = tslib.__rest(_a, ["children", "id", "selectAllChecked", "subheading", "handleToggleSelectAll"]);
|
|
4691
|
+
var children = _a.children, id = _a.id, selectAllChecked = _a.selectAllChecked, subheading = _a.subheading, _b = _a.showCheckbox, showCheckbox = _b === void 0 ? true : _b, handleToggleSelectAll = _a.handleToggleSelectAll, styleProps = tslib.__rest(_a, ["children", "id", "selectAllChecked", "subheading", "showCheckbox", "handleToggleSelectAll"]);
|
|
4683
4692
|
var isOpen = useAccordionContext().isOpen;
|
|
4684
4693
|
return (React__default.default.createElement(OakFlex, tslib.__assign({ "$bt": "border-solid-s", "$bb": isOpen ? "border-solid-none" : "border-solid-s", "$borderColor": "border-neutral-lighter", "$pv": "spacing-12", "$flexDirection": "column", "$width": "100%" }, styleProps),
|
|
4685
4694
|
React__default.default.createElement(OakFlex, { "$alignItems": "center", "$width": "100%" },
|
|
4686
4695
|
React__default.default.createElement(OakFlex, { "$alignItems": "center", "$width": "100%", "$gap": "spacing-16" },
|
|
4687
|
-
React__default.default.createElement(OakBox, { id: "select-all-wrapper", "$pa": "spacing-8", onClick: handleToggleSelectAll },
|
|
4688
|
-
React__default.default.createElement(OakCheckBox, { onChange: function () { return undefined; }, checked: selectAllChecked, id: "select-all", name: "select-all", value: "", "aria-labelledby": "resources-accordion-heading" })),
|
|
4696
|
+
showCheckbox ? (React__default.default.createElement(OakBox, { id: "select-all-wrapper", "$pa": "spacing-8", onClick: handleToggleSelectAll },
|
|
4697
|
+
React__default.default.createElement(OakCheckBox, { onChange: function () { return undefined; }, checked: selectAllChecked, id: "select-all", name: "select-all", value: "", "aria-labelledby": "resources-accordion-heading" }))) : null,
|
|
4689
4698
|
React__default.default.createElement(StyledAccordionButton$2, { "$justifyContent": "space-between", "$flexGrow": 1, id: id, "$alignItems": "center", "$mr": "spacing-12" },
|
|
4690
4699
|
React__default.default.createElement(OakFlex, { "$justifyContent": "center", "$alignItems": "center", "$gap": "spacing-12" },
|
|
4691
4700
|
React__default.default.createElement(OakFlex, { "$flexDirection": "column", "$justifyContent": "center", "$alignItems": "start" },
|
|
@@ -6859,9 +6868,15 @@ var MultipleIcons = function (_a) {
|
|
|
6859
6868
|
return (React__default.default.createElement(OakFlex, { "$background": "bg-decorative5-main", "$pa": "spacing-12", "$alignItems": "center", "$flexDirection": "column", "$gap": "spacing-16", "$justifyContent": "center" }, iconName.map(function (name, index) { return (React__default.default.createElement(OakFlex, { key: "".concat(name, "-").concat(index), "$position": "relative", "$alignContent": "center", "$alignItems": "center", "$justifyContent": "center" },
|
|
6860
6869
|
React__default.default.createElement(OakIcon, { iconName: name, "$width": "spacing-40", "$height": "spacing-40", "$mr": index < iconName.length - 1 ? "spacing-8" : "spacing-0" }))); })));
|
|
6861
6870
|
};
|
|
6862
|
-
var LabelContainer = styled__default.default("label")(templateObject_1$j || (templateObject_1$j = tslib.__makeTemplateObject(["\n flex: 1;\n cursor:
|
|
6863
|
-
var Container = styled__default.default(OakFlex)(templateObject_2$8 || (templateObject_2$8 = tslib.__makeTemplateObject(["\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n @media (hover: hover) {\n &:hover:not(:has(input:disabled), :active) {\n background: ", ";\n #resource-card-title {\n text-decoration:
|
|
6864
|
-
return props.$
|
|
6871
|
+
var LabelContainer = styled__default.default("label")(templateObject_1$j || (templateObject_1$j = tslib.__makeTemplateObject(["\n flex: 1;\n cursor: ", ";\n display: flex;\n\n &:has(input:disabled) {\n cursor: default;\n #resource-card-title {\n text-decoration: none;\n }\n }\n"], ["\n flex: 1;\n cursor: ", ";\n display: flex;\n\n &:has(input:disabled) {\n cursor: default;\n #resource-card-title {\n text-decoration: none;\n }\n }\n"])), function (props) { return (props.$showSelectionControl ? "pointer" : "default"); });
|
|
6872
|
+
var Container = styled__default.default(OakFlex)(templateObject_2$8 || (templateObject_2$8 = tslib.__makeTemplateObject(["\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n @media (hover: hover) {\n &:hover:not(:has(input:disabled), :active) {\n background: ", ";\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n\n &:hover:active:not(:has(input:disabled)) {\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n }\n"], ["\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n @media (hover: hover) {\n &:hover:not(:has(input:disabled), :active) {\n background: ", ";\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n\n &:hover:active:not(:has(input:disabled)) {\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n }\n"])), parseDropShadow("drop-shadow-centered-lemon"), parseDropShadow("drop-shadow-centered-grey"), function (props) {
|
|
6873
|
+
return props.$showSelectionControl
|
|
6874
|
+
? parseColor("bg-btn-secondary-hover")
|
|
6875
|
+
: parseColor("bg-primary");
|
|
6876
|
+
}, function (props) {
|
|
6877
|
+
return props.$showSelectionControl ? "underline" : "none";
|
|
6878
|
+
}, function (props) {
|
|
6879
|
+
return props.$showSelectionControl ? "underline" : "none";
|
|
6865
6880
|
});
|
|
6866
6881
|
/**
|
|
6867
6882
|
* Resource cards present a downloadable/shareable resource with metadata and a selectable control.
|
|
@@ -6875,7 +6890,7 @@ var Container = styled__default.default(OakFlex)(templateObject_2$8 || (template
|
|
|
6875
6890
|
var OakResourceCard = function (props) {
|
|
6876
6891
|
var _a;
|
|
6877
6892
|
var radioContext = React.useContext(RadioContext);
|
|
6878
|
-
var title = props.title, fileSize = props.fileSize, description = props.description, iconName = props.iconName, value = props.value, _b = props.disabled, disabled = _b === void 0 ? false : _b, defaultChecked = props.defaultChecked, checked = props.checked, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onHovered = props.onHovered, _c = props.isRadio, isRadio =
|
|
6893
|
+
var title = props.title, fileSize = props.fileSize, description = props.description, iconName = props.iconName, value = props.value, _b = props.disabled, disabled = _b === void 0 ? false : _b, defaultChecked = props.defaultChecked, checked = props.checked, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onHovered = props.onHovered, _c = props.showSelectionControl, showSelectionControl = _c === void 0 ? true : _c, _d = props.isRadio, isRadio = _d === void 0 ? false : _d, dataTestId = props["data-testid"], _e = props.isEditable, isEditable = _e === void 0 ? false : _e, rest = tslib.__rest(props, ["title", "fileSize", "description", "iconName", "value", "disabled", "defaultChecked", "checked", "onChange", "onFocus", "onBlur", "onHovered", "showSelectionControl", "isRadio", "data-testid", "isEditable"]);
|
|
6879
6894
|
var checkboxSize = "spacing-24";
|
|
6880
6895
|
var checkedBorderColor = "border-primary";
|
|
6881
6896
|
var disabledColor = "text-disabled";
|
|
@@ -6894,8 +6909,8 @@ var OakResourceCard = function (props) {
|
|
|
6894
6909
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
6895
6910
|
};
|
|
6896
6911
|
var isMultipleIcon = Array.isArray(iconName);
|
|
6897
|
-
return (React__default.default.createElement(Container, { "data-testid": dataTestId, "$background": "bg-primary", "$ba": "border-solid-m", "$borderRadius": "border-radius-s", "$overflow": "hidden", "$
|
|
6898
|
-
React__default.default.createElement(LabelContainer,
|
|
6912
|
+
return (React__default.default.createElement(Container, { "data-testid": dataTestId, "$background": "bg-primary", "$ba": "border-solid-m", "$borderRadius": "border-radius-s", "$overflow": "hidden", "$showSelectionControl": showSelectionControl, "$color": "text-primary", "$width": "100%" },
|
|
6913
|
+
React__default.default.createElement(LabelContainer, { "$showSelectionControl": showSelectionControl },
|
|
6899
6914
|
React__default.default.createElement(OakFlex, { "$alignItems": "stretch", "$flexGrow": 1 },
|
|
6900
6915
|
isMultipleIcon ? (React__default.default.createElement(MultipleIcons, { iconName: iconName })) : (React__default.default.createElement(SingleIcon, { iconName: iconName })),
|
|
6901
6916
|
React__default.default.createElement(OakFlex, { "$flexGrow": 1, "$flexDirection": "column", "$justifyContent": "center", "$gap": "spacing-4", "$pv": "spacing-12", "$ph": "spacing-16" },
|
|
@@ -6906,8 +6921,8 @@ var OakResourceCard = function (props) {
|
|
|
6906
6921
|
isEditable && (React__default.default.createElement(OakTagFunctional, { "$alignSelf": "flex-end", "$font": "heading-light-7", label: "Editable", "$background": "bg-decorative2-main" }))))),
|
|
6907
6922
|
React__default.default.createElement(OakFlex, null,
|
|
6908
6923
|
React__default.default.createElement(OakFlex, { "$alignItems": "center", "$pr": "spacing-16" },
|
|
6909
|
-
isRadio && (React__default.default.createElement(InternalRadioWrapper, { checked: isChecked, size: checkboxSize, disabled: anyDisabled, radioBorderColor: checkedBorderColor, internalRadio: React__default.default.createElement(InternalRadio, tslib.__assign({}, rest, { id: props.id, name: (_a = props.name) !== null && _a !== void 0 ? _a : radioContext.name, value: value, disabled: anyDisabled, onHovered: onHovered, onChange: handleRadioChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: radioChecked })) })),
|
|
6910
|
-
!isRadio && (React__default.default.createElement(InternalCheckBoxWrapper, { size: checkboxSize, internalCheckbox: React__default.default.createElement(InternalCheckBoxHoverFocus, tslib.__assign({ name: radioContext.name, value: value, "$width": checkboxSize, "$height": checkboxSize, "$ba": "border-solid-m", "$borderRadius": "border-radius-xs", "$borderColor": "text-primary", "$checkedBackground": currentCheckedBackgroundFill, "$checkedBorderColor": currentCheckedBorderColor, "$uncheckedBorderColor": "border-neutral", "$hoverBorderRadius": "border-radius-xs", onHovered: onHovered, onChange: onChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: checked, disabled: anyDisabled }, rest)), iconPadding: "spacing-0" })))))));
|
|
6924
|
+
showSelectionControl && isRadio && (React__default.default.createElement(InternalRadioWrapper, { checked: isChecked, size: checkboxSize, disabled: anyDisabled, radioBorderColor: checkedBorderColor, internalRadio: React__default.default.createElement(InternalRadio, tslib.__assign({}, rest, { id: props.id, name: (_a = props.name) !== null && _a !== void 0 ? _a : radioContext.name, value: value, disabled: anyDisabled, onHovered: onHovered, onChange: handleRadioChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: radioChecked })) })),
|
|
6925
|
+
showSelectionControl && !isRadio && (React__default.default.createElement(InternalCheckBoxWrapper, { size: checkboxSize, internalCheckbox: React__default.default.createElement(InternalCheckBoxHoverFocus, tslib.__assign({ name: radioContext.name, value: value, "$width": checkboxSize, "$height": checkboxSize, "$ba": "border-solid-m", "$borderRadius": "border-radius-xs", "$borderColor": "text-primary", "$checkedBackground": currentCheckedBackgroundFill, "$checkedBorderColor": currentCheckedBorderColor, "$uncheckedBorderColor": "border-neutral", "$hoverBorderRadius": "border-radius-xs", onHovered: onHovered, onChange: onChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: checked, disabled: anyDisabled }, rest)), iconPadding: "spacing-0" })))))));
|
|
6911
6926
|
};
|
|
6912
6927
|
var templateObject_1$j, templateObject_2$8;
|
|
6913
6928
|
|
package/dist/npm/cjs/types.d.ts
CHANGED
|
@@ -3567,6 +3567,10 @@ type OakCardProps = {
|
|
|
3567
3567
|
* The background colour of the card on hover.
|
|
3568
3568
|
*/
|
|
3569
3569
|
hoverBackground?: OakUiRoleToken;
|
|
3570
|
+
/**
|
|
3571
|
+
* Whether to show the image or not
|
|
3572
|
+
*/
|
|
3573
|
+
showImage?: ResponsiveValues<boolean>;
|
|
3570
3574
|
};
|
|
3571
3575
|
/**
|
|
3572
3576
|
* A highly customisable card component that displays a heading and takes a href at minimum.
|
|
@@ -3576,7 +3580,7 @@ type OakCardProps = {
|
|
|
3576
3580
|
* The card can be oriented in a row or column layout and its width can be adjusted using spacing tokens.
|
|
3577
3581
|
* The image aspect ratio can be set to either 1:1 or 4:3.
|
|
3578
3582
|
*/
|
|
3579
|
-
declare const OakCard: ({ as, heading, headingLevel, href, cardOrientation, cardWidth, imageSrc, imageAlt, aspectRatio, subCopy, subCopyColor, tagName, tagBackground, linkText, linkIconName, hoverBackground, imageBackgroundColor, }: OakCardProps) => React$1.JSX.Element;
|
|
3583
|
+
declare const OakCard: ({ as, heading, headingLevel, href, cardOrientation, cardWidth, imageSrc, imageAlt, aspectRatio, subCopy, subCopyColor, tagName, tagBackground, linkText, linkIconName, hoverBackground, imageBackgroundColor, showImage, }: OakCardProps) => React$1.JSX.Element;
|
|
3580
3584
|
|
|
3581
3585
|
type OakBreadcrumb = {
|
|
3582
3586
|
text: string;
|
|
@@ -3621,6 +3625,10 @@ type OakResourcesAccordionProps = {
|
|
|
3621
3625
|
* Whether the accordion starts in the open state, defaults to false
|
|
3622
3626
|
*/
|
|
3623
3627
|
initialOpen?: boolean;
|
|
3628
|
+
/**
|
|
3629
|
+
* Whether to show the select all checkbox
|
|
3630
|
+
*/
|
|
3631
|
+
showCheckbox?: boolean;
|
|
3624
3632
|
} & FlexStyleProps & OakBoxProps & ColorStyleProps;
|
|
3625
3633
|
/**
|
|
3626
3634
|
* OakResourcesAccordion renamed from OakDownloadsAccordion.
|
|
@@ -4453,6 +4461,12 @@ type OakResourceCardProps = BaseCheckBoxProps & {
|
|
|
4453
4461
|
* The icon used to represent the resource type.
|
|
4454
4462
|
*/
|
|
4455
4463
|
iconName: IconName | IconName[];
|
|
4464
|
+
/**
|
|
4465
|
+
* Whether to show the selection control (checkbox or radio button).
|
|
4466
|
+
*
|
|
4467
|
+
* @default true
|
|
4468
|
+
*/
|
|
4469
|
+
showSelectionControl?: boolean;
|
|
4456
4470
|
/**
|
|
4457
4471
|
* If true, renders the selection control as a radio button instead of a checkbox.
|
|
4458
4472
|
*
|
|
@@ -17,6 +17,13 @@ import { sizeStyle } from '../../../styles/utils/sizeStyle.js';
|
|
|
17
17
|
import { flexStyle } from '../../../styles/utils/flexStyle.js';
|
|
18
18
|
import { colorStyle } from '../../../styles/utils/colorStyle.js';
|
|
19
19
|
import { borderStyle } from '../../../styles/utils/borderStyle.js';
|
|
20
|
+
import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
|
|
21
|
+
import '../../layout-and-structure/OakGrid/OakGrid.js';
|
|
22
|
+
import '../../layout-and-structure/OakGridArea/OakGridArea.js';
|
|
23
|
+
import '../../layout-and-structure/OakMaxWidth/OakMaxWidth.js';
|
|
24
|
+
import '../../layout-and-structure/OakAccordion/OakAccordion.js';
|
|
25
|
+
import '../../internal-components/InternalChevronAccordion/InternalChevronAccordion.js';
|
|
26
|
+
import '../../layout-and-structure/OakCollapsibleContent/OakCollapsibleContent.js';
|
|
20
27
|
|
|
21
28
|
var CardContent = styled(OakFlex)(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
22
29
|
var StyledOakImage = styled(OakImage)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n\n img {\n border-radius: inherit;\n object-fit: cover;\n }\n"], ["\n ", "\n ", "\n ", "\n\n img {\n border-radius: inherit;\n object-fit: cover;\n }\n"])), sizeStyle, colorStyle, borderStyle);
|
|
@@ -36,6 +43,11 @@ var StyledOakFlex = styled(OakFlex)(templateObject_6 || (templateObject_6 = __ma
|
|
|
36
43
|
var $cardOrientation = _a.$cardOrientation;
|
|
37
44
|
return getResponsiveCardOrientationStyles($cardOrientation);
|
|
38
45
|
});
|
|
46
|
+
function boolAsDisplay(input) {
|
|
47
|
+
if (input === undefined)
|
|
48
|
+
return;
|
|
49
|
+
return input ? "block" : "none";
|
|
50
|
+
}
|
|
39
51
|
/**
|
|
40
52
|
* A highly customisable card component that displays a heading and takes a href at minimum.
|
|
41
53
|
*
|
|
@@ -45,10 +57,14 @@ var StyledOakFlex = styled(OakFlex)(templateObject_6 || (templateObject_6 = __ma
|
|
|
45
57
|
* The image aspect ratio can be set to either 1:1 or 4:3.
|
|
46
58
|
*/
|
|
47
59
|
var OakCard = function (_a) {
|
|
48
|
-
var _b = _a.as, as = _b === void 0 ? "div" : _b, heading = _a.heading, _c = _a.headingLevel, headingLevel = _c === void 0 ? "h3" : _c, href = _a.href, _d = _a.cardOrientation, cardOrientation = _d === void 0 ? "column" : _d, cardWidth = _a.cardWidth, imageSrc = _a.imageSrc, imageAlt = _a.imageAlt, _e = _a.aspectRatio, aspectRatio = _e === void 0 ? "1/1" : _e, subCopy = _a.subCopy, _f = _a.subCopyColor, subCopyColor = _f === void 0 ? "text-primary" : _f, tagName = _a.tagName, _g = _a.tagBackground, tagBackground = _g === void 0 ? "bg-decorative3-very-subdued" : _g, linkText = _a.linkText, _h = _a.linkIconName, linkIconName = _h === void 0 ? "arrow-right" : _h, _j = _a.hoverBackground, hoverBackground = _j === void 0 ? "bg-btn-secondary-hover" : _j, _k = _a.imageBackgroundColor, imageBackgroundColor = _k === void 0 ? "bg-neutral" : _k;
|
|
60
|
+
var _b = _a.as, as = _b === void 0 ? "div" : _b, heading = _a.heading, _c = _a.headingLevel, headingLevel = _c === void 0 ? "h3" : _c, href = _a.href, _d = _a.cardOrientation, cardOrientation = _d === void 0 ? "column" : _d, cardWidth = _a.cardWidth, imageSrc = _a.imageSrc, imageAlt = _a.imageAlt, _e = _a.aspectRatio, aspectRatio = _e === void 0 ? "1/1" : _e, subCopy = _a.subCopy, _f = _a.subCopyColor, subCopyColor = _f === void 0 ? "text-primary" : _f, tagName = _a.tagName, _g = _a.tagBackground, tagBackground = _g === void 0 ? "bg-decorative3-very-subdued" : _g, linkText = _a.linkText, _h = _a.linkIconName, linkIconName = _h === void 0 ? "arrow-right" : _h, _j = _a.hoverBackground, hoverBackground = _j === void 0 ? "bg-btn-secondary-hover" : _j, _k = _a.imageBackgroundColor, imageBackgroundColor = _k === void 0 ? "bg-neutral" : _k, showImage = _a.showImage;
|
|
61
|
+
var displayImage = Array.isArray(showImage)
|
|
62
|
+
? showImage.map(function (value) { return boolAsDisplay(value); })
|
|
63
|
+
: boolAsDisplay(showImage);
|
|
49
64
|
return (React.createElement(OakFocusIndicator, { as: as, "$background": "bg-primary", hoverBackground: hoverBackground, "$height": "100%", "$width": cardWidth, "$borderRadius": "border-radius-m2" },
|
|
50
65
|
React.createElement(StyledOakFlex, { as: "a", href: href, "$cardOrientation": cardOrientation, "$height": "100%", "$pa": "spacing-16", "$gap": "spacing-16" },
|
|
51
|
-
imageSrc && (React.createElement(
|
|
66
|
+
imageSrc && (React.createElement(OakBox, { "$display": displayImage },
|
|
67
|
+
React.createElement(StyledOakImage, { src: imageSrc || "", alt: imageAlt || "", "$width": "auto", "$aspectRatio": aspectRatio, "$background": imageBackgroundColor, "$borderRadius": "border-radius-m2" }))),
|
|
52
68
|
React.createElement(CardContent, { "$flexDirection": "column", "$justifyContent": "space-between", "$gap": "spacing-16" },
|
|
53
69
|
React.createElement(OakFlex, { "$flexDirection": "column", "$gap": "spacing-16" },
|
|
54
70
|
React.createElement(OakHeading, { tag: headingLevel, "$font": "heading-6" }, heading),
|
|
@@ -33,9 +33,15 @@ var MultipleIcons = function (_a) {
|
|
|
33
33
|
return (React.createElement(OakFlex, { "$background": "bg-decorative5-main", "$pa": "spacing-12", "$alignItems": "center", "$flexDirection": "column", "$gap": "spacing-16", "$justifyContent": "center" }, iconName.map(function (name, index) { return (React.createElement(OakFlex, { key: "".concat(name, "-").concat(index), "$position": "relative", "$alignContent": "center", "$alignItems": "center", "$justifyContent": "center" },
|
|
34
34
|
React.createElement(OakIcon, { iconName: name, "$width": "spacing-40", "$height": "spacing-40", "$mr": index < iconName.length - 1 ? "spacing-8" : "spacing-0" }))); })));
|
|
35
35
|
};
|
|
36
|
-
var LabelContainer = styled("label")(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex: 1;\n cursor:
|
|
37
|
-
var Container = styled(OakFlex)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n @media (hover: hover) {\n &:hover:not(:has(input:disabled), :active) {\n background: ", ";\n #resource-card-title {\n text-decoration:
|
|
38
|
-
return props.$
|
|
36
|
+
var LabelContainer = styled("label")(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex: 1;\n cursor: ", ";\n display: flex;\n\n &:has(input:disabled) {\n cursor: default;\n #resource-card-title {\n text-decoration: none;\n }\n }\n"], ["\n flex: 1;\n cursor: ", ";\n display: flex;\n\n &:has(input:disabled) {\n cursor: default;\n #resource-card-title {\n text-decoration: none;\n }\n }\n"])), function (props) { return (props.$showSelectionControl ? "pointer" : "default"); });
|
|
37
|
+
var Container = styled(OakFlex)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n @media (hover: hover) {\n &:hover:not(:has(input:disabled), :active) {\n background: ", ";\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n\n &:hover:active:not(:has(input:disabled)) {\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n }\n"], ["\n &:has(input:focus-visible) {\n box-shadow:\n ", ",\n ", ";\n }\n\n @media (hover: hover) {\n &:hover:not(:has(input:disabled), :active) {\n background: ", ";\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n\n &:hover:active:not(:has(input:disabled)) {\n #resource-card-title {\n text-decoration: ", ";\n }\n }\n }\n"])), parseDropShadow("drop-shadow-centered-lemon"), parseDropShadow("drop-shadow-centered-grey"), function (props) {
|
|
38
|
+
return props.$showSelectionControl
|
|
39
|
+
? parseColor("bg-btn-secondary-hover")
|
|
40
|
+
: parseColor("bg-primary");
|
|
41
|
+
}, function (props) {
|
|
42
|
+
return props.$showSelectionControl ? "underline" : "none";
|
|
43
|
+
}, function (props) {
|
|
44
|
+
return props.$showSelectionControl ? "underline" : "none";
|
|
39
45
|
});
|
|
40
46
|
/**
|
|
41
47
|
* Resource cards present a downloadable/shareable resource with metadata and a selectable control.
|
|
@@ -49,7 +55,7 @@ var Container = styled(OakFlex)(templateObject_2 || (templateObject_2 = __makeTe
|
|
|
49
55
|
var OakResourceCard = function (props) {
|
|
50
56
|
var _a;
|
|
51
57
|
var radioContext = useContext(RadioContext);
|
|
52
|
-
var title = props.title, fileSize = props.fileSize, description = props.description, iconName = props.iconName, value = props.value, _b = props.disabled, disabled = _b === void 0 ? false : _b, defaultChecked = props.defaultChecked, checked = props.checked, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onHovered = props.onHovered, _c = props.isRadio, isRadio =
|
|
58
|
+
var title = props.title, fileSize = props.fileSize, description = props.description, iconName = props.iconName, value = props.value, _b = props.disabled, disabled = _b === void 0 ? false : _b, defaultChecked = props.defaultChecked, checked = props.checked, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, onHovered = props.onHovered, _c = props.showSelectionControl, showSelectionControl = _c === void 0 ? true : _c, _d = props.isRadio, isRadio = _d === void 0 ? false : _d, dataTestId = props["data-testid"], _e = props.isEditable, isEditable = _e === void 0 ? false : _e, rest = __rest(props, ["title", "fileSize", "description", "iconName", "value", "disabled", "defaultChecked", "checked", "onChange", "onFocus", "onBlur", "onHovered", "showSelectionControl", "isRadio", "data-testid", "isEditable"]);
|
|
53
59
|
var checkboxSize = "spacing-24";
|
|
54
60
|
var checkedBorderColor = "border-primary";
|
|
55
61
|
var disabledColor = "text-disabled";
|
|
@@ -68,8 +74,8 @@ var OakResourceCard = function (props) {
|
|
|
68
74
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
69
75
|
};
|
|
70
76
|
var isMultipleIcon = Array.isArray(iconName);
|
|
71
|
-
return (React.createElement(Container, { "data-testid": dataTestId, "$background": "bg-primary", "$ba": "border-solid-m", "$borderRadius": "border-radius-s", "$overflow": "hidden", "$
|
|
72
|
-
React.createElement(LabelContainer,
|
|
77
|
+
return (React.createElement(Container, { "data-testid": dataTestId, "$background": "bg-primary", "$ba": "border-solid-m", "$borderRadius": "border-radius-s", "$overflow": "hidden", "$showSelectionControl": showSelectionControl, "$color": "text-primary", "$width": "100%" },
|
|
78
|
+
React.createElement(LabelContainer, { "$showSelectionControl": showSelectionControl },
|
|
73
79
|
React.createElement(OakFlex, { "$alignItems": "stretch", "$flexGrow": 1 },
|
|
74
80
|
isMultipleIcon ? (React.createElement(MultipleIcons, { iconName: iconName })) : (React.createElement(SingleIcon, { iconName: iconName })),
|
|
75
81
|
React.createElement(OakFlex, { "$flexGrow": 1, "$flexDirection": "column", "$justifyContent": "center", "$gap": "spacing-4", "$pv": "spacing-12", "$ph": "spacing-16" },
|
|
@@ -80,8 +86,8 @@ var OakResourceCard = function (props) {
|
|
|
80
86
|
isEditable && (React.createElement(OakTagFunctional, { "$alignSelf": "flex-end", "$font": "heading-light-7", label: "Editable", "$background": "bg-decorative2-main" }))))),
|
|
81
87
|
React.createElement(OakFlex, null,
|
|
82
88
|
React.createElement(OakFlex, { "$alignItems": "center", "$pr": "spacing-16" },
|
|
83
|
-
isRadio && (React.createElement(InternalRadioWrapper, { checked: isChecked, size: checkboxSize, disabled: anyDisabled, radioBorderColor: checkedBorderColor, internalRadio: React.createElement(InternalRadio, __assign({}, rest, { id: props.id, name: (_a = props.name) !== null && _a !== void 0 ? _a : radioContext.name, value: value, disabled: anyDisabled, onHovered: onHovered, onChange: handleRadioChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: radioChecked })) })),
|
|
84
|
-
!isRadio && (React.createElement(InternalCheckBoxWrapper, { size: checkboxSize, internalCheckbox: React.createElement(InternalCheckBoxHoverFocus, __assign({ name: radioContext.name, value: value, "$width": checkboxSize, "$height": checkboxSize, "$ba": "border-solid-m", "$borderRadius": "border-radius-xs", "$borderColor": "text-primary", "$checkedBackground": currentCheckedBackgroundFill, "$checkedBorderColor": currentCheckedBorderColor, "$uncheckedBorderColor": "border-neutral", "$hoverBorderRadius": "border-radius-xs", onHovered: onHovered, onChange: onChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: checked, disabled: anyDisabled }, rest)), iconPadding: "spacing-0" })))))));
|
|
89
|
+
showSelectionControl && isRadio && (React.createElement(InternalRadioWrapper, { checked: isChecked, size: checkboxSize, disabled: anyDisabled, radioBorderColor: checkedBorderColor, internalRadio: React.createElement(InternalRadio, __assign({}, rest, { id: props.id, name: (_a = props.name) !== null && _a !== void 0 ? _a : radioContext.name, value: value, disabled: anyDisabled, onHovered: onHovered, onChange: handleRadioChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: radioChecked })) })),
|
|
90
|
+
showSelectionControl && !isRadio && (React.createElement(InternalCheckBoxWrapper, { size: checkboxSize, internalCheckbox: React.createElement(InternalCheckBoxHoverFocus, __assign({ name: radioContext.name, value: value, "$width": checkboxSize, "$height": checkboxSize, "$ba": "border-solid-m", "$borderRadius": "border-radius-xs", "$borderColor": "text-primary", "$checkedBackground": currentCheckedBackgroundFill, "$checkedBorderColor": currentCheckedBorderColor, "$uncheckedBorderColor": "border-neutral", "$hoverBorderRadius": "border-radius-xs", onHovered: onHovered, onChange: onChange, onFocus: onFocus, onBlur: onBlur, defaultChecked: defaultChecked, checked: checked, disabled: anyDisabled }, rest)), iconPadding: "spacing-0" })))))));
|
|
85
91
|
};
|
|
86
92
|
var templateObject_1, templateObject_2;
|
|
87
93
|
|
|
@@ -19,13 +19,13 @@ var StyledAccordionButton = styled(InternalAccordionButton)(templateObject_1 ||
|
|
|
19
19
|
* Internal accordion component that handles the accordion logic
|
|
20
20
|
*/
|
|
21
21
|
var Accordion = function (_a) {
|
|
22
|
-
var children = _a.children, id = _a.id, selectAllChecked = _a.selectAllChecked, subheading = _a.subheading, handleToggleSelectAll = _a.handleToggleSelectAll, styleProps = __rest(_a, ["children", "id", "selectAllChecked", "subheading", "handleToggleSelectAll"]);
|
|
22
|
+
var children = _a.children, id = _a.id, selectAllChecked = _a.selectAllChecked, subheading = _a.subheading, _b = _a.showCheckbox, showCheckbox = _b === void 0 ? true : _b, handleToggleSelectAll = _a.handleToggleSelectAll, styleProps = __rest(_a, ["children", "id", "selectAllChecked", "subheading", "showCheckbox", "handleToggleSelectAll"]);
|
|
23
23
|
var isOpen = useAccordionContext().isOpen;
|
|
24
24
|
return (React.createElement(OakFlex, __assign({ "$bt": "border-solid-s", "$bb": isOpen ? "border-solid-none" : "border-solid-s", "$borderColor": "border-neutral-lighter", "$pv": "spacing-12", "$flexDirection": "column", "$width": "100%" }, styleProps),
|
|
25
25
|
React.createElement(OakFlex, { "$alignItems": "center", "$width": "100%" },
|
|
26
26
|
React.createElement(OakFlex, { "$alignItems": "center", "$width": "100%", "$gap": "spacing-16" },
|
|
27
|
-
React.createElement(OakBox, { id: "select-all-wrapper", "$pa": "spacing-8", onClick: handleToggleSelectAll },
|
|
28
|
-
React.createElement(OakCheckBox, { onChange: function () { return undefined; }, checked: selectAllChecked, id: "select-all", name: "select-all", value: "", "aria-labelledby": "resources-accordion-heading" })),
|
|
27
|
+
showCheckbox ? (React.createElement(OakBox, { id: "select-all-wrapper", "$pa": "spacing-8", onClick: handleToggleSelectAll },
|
|
28
|
+
React.createElement(OakCheckBox, { onChange: function () { return undefined; }, checked: selectAllChecked, id: "select-all", name: "select-all", value: "", "aria-labelledby": "resources-accordion-heading" }))) : null,
|
|
29
29
|
React.createElement(StyledAccordionButton, { "$justifyContent": "space-between", "$flexGrow": 1, id: id, "$alignItems": "center", "$mr": "spacing-12" },
|
|
30
30
|
React.createElement(OakFlex, { "$justifyContent": "center", "$alignItems": "center", "$gap": "spacing-12" },
|
|
31
31
|
React.createElement(OakFlex, { "$flexDirection": "column", "$justifyContent": "center", "$alignItems": "start" },
|
package/dist/npm/es/types.d.ts
CHANGED
|
@@ -3567,6 +3567,10 @@ type OakCardProps = {
|
|
|
3567
3567
|
* The background colour of the card on hover.
|
|
3568
3568
|
*/
|
|
3569
3569
|
hoverBackground?: OakUiRoleToken;
|
|
3570
|
+
/**
|
|
3571
|
+
* Whether to show the image or not
|
|
3572
|
+
*/
|
|
3573
|
+
showImage?: ResponsiveValues<boolean>;
|
|
3570
3574
|
};
|
|
3571
3575
|
/**
|
|
3572
3576
|
* A highly customisable card component that displays a heading and takes a href at minimum.
|
|
@@ -3576,7 +3580,7 @@ type OakCardProps = {
|
|
|
3576
3580
|
* The card can be oriented in a row or column layout and its width can be adjusted using spacing tokens.
|
|
3577
3581
|
* The image aspect ratio can be set to either 1:1 or 4:3.
|
|
3578
3582
|
*/
|
|
3579
|
-
declare const OakCard: ({ as, heading, headingLevel, href, cardOrientation, cardWidth, imageSrc, imageAlt, aspectRatio, subCopy, subCopyColor, tagName, tagBackground, linkText, linkIconName, hoverBackground, imageBackgroundColor, }: OakCardProps) => React$1.JSX.Element;
|
|
3583
|
+
declare const OakCard: ({ as, heading, headingLevel, href, cardOrientation, cardWidth, imageSrc, imageAlt, aspectRatio, subCopy, subCopyColor, tagName, tagBackground, linkText, linkIconName, hoverBackground, imageBackgroundColor, showImage, }: OakCardProps) => React$1.JSX.Element;
|
|
3580
3584
|
|
|
3581
3585
|
type OakBreadcrumb = {
|
|
3582
3586
|
text: string;
|
|
@@ -3621,6 +3625,10 @@ type OakResourcesAccordionProps = {
|
|
|
3621
3625
|
* Whether the accordion starts in the open state, defaults to false
|
|
3622
3626
|
*/
|
|
3623
3627
|
initialOpen?: boolean;
|
|
3628
|
+
/**
|
|
3629
|
+
* Whether to show the select all checkbox
|
|
3630
|
+
*/
|
|
3631
|
+
showCheckbox?: boolean;
|
|
3624
3632
|
} & FlexStyleProps & OakBoxProps & ColorStyleProps;
|
|
3625
3633
|
/**
|
|
3626
3634
|
* OakResourcesAccordion renamed from OakDownloadsAccordion.
|
|
@@ -4453,6 +4461,12 @@ type OakResourceCardProps = BaseCheckBoxProps & {
|
|
|
4453
4461
|
* The icon used to represent the resource type.
|
|
4454
4462
|
*/
|
|
4455
4463
|
iconName: IconName | IconName[];
|
|
4464
|
+
/**
|
|
4465
|
+
* Whether to show the selection control (checkbox or radio button).
|
|
4466
|
+
*
|
|
4467
|
+
* @default true
|
|
4468
|
+
*/
|
|
4469
|
+
showSelectionControl?: boolean;
|
|
4456
4470
|
/**
|
|
4457
4471
|
* If true, renders the selection control as a radio button instead of a checkbox.
|
|
4458
4472
|
*
|