@oaknational/oak-components 3.18.0 → 3.20.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.
@@ -1,39 +0,0 @@
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 };
@@ -1,43 +0,0 @@
1
- import { __rest, __assign } from 'tslib';
2
- import React, { useRef } from 'react';
3
- import { createPortal } from 'react-dom';
4
- import { InternalShadowRoundButton } from '../../internal-components/InternalShadowRoundButton/InternalShadowRoundButton.js';
5
- import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
6
- import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
7
- import { OakHeading } from '../../typography/OakHeading/OakHeading.js';
8
- import { useIsScrolled } from '../../../hooks/useIsScrolled.js';
9
- import { useMounted } from '../../../hooks/useMounted.js';
10
- import InternalModalTransition from '../../internal-components/InternalModalTransition/InternalModalTransition.js';
11
- import { OakLink } from '../../navigation/OakLink/OakLink.js';
12
-
13
- /**
14
- *
15
- * Based on the OakModal component, this component is a filter drawer that slides in from the right side of the screen.
16
- * Designed for mobile and tablet devices
17
- *
18
- * ### Callbacks
19
- * clearAllInputs: used to clear filter options
20
- *
21
- */
22
- var OakFilterDrawer = function (_a) {
23
- var isOpen = _a.isOpen, domContainer = _a.domContainer, onClose = _a.onClose, zIndex = _a.zIndex, children = _a.children, clearAllInputs = _a.clearAllInputs, footerSlot = _a.footerSlot, rest = __rest(_a, ["isOpen", "domContainer", "onClose", "zIndex", "children", "clearAllInputs", "footerSlot"]);
24
- var _b = useIsScrolled(), isScrolled = _b.isScrolled, ObserveScroll = _b.ObserveScroll;
25
- var transitionRef = useRef(null);
26
- var isMounted = useMounted();
27
- if (!isMounted) {
28
- return null;
29
- }
30
- var finalZIndex = typeof zIndex === "number" ? zIndex : "modal-dialog";
31
- return createPortal(React.createElement(InternalModalTransition, __assign({ isOpen: isOpen, transitionRef: transitionRef, onClose: onClose, finalZIndex: finalZIndex, isLeftHandSide: false }, rest),
32
- React.createElement(OakFlex, { "$ma": "spacing-24", "$justifyContent": "space-between", "$alignItems": "center" },
33
- React.createElement(OakLink, { variant: "secondary", onClick: clearAllInputs, "aria-label": "Clear", element: "button" }, "Clear"),
34
- React.createElement(OakHeading, { "$font": "heading-6", tag: "h3" }, "Filters"),
35
- React.createElement(InternalShadowRoundButton, { onClick: onClose, "aria-label": "Close", defaultIconBackground: "transparent", defaultIconColor: "icon-primary", defaultTextColor: "transparent", hoverTextColor: "transparent", disabledTextColor: "transparent", hoverIconBackground: "icon-primary", hoverIconColor: "icon-inverted", disabledIconBackground: "transparent", iconBackgroundSize: "spacing-24", iconSize: "spacing-24", iconName: "cross" })),
36
- React.createElement(OakFlex, { "$flexGrow": 1, "$flexDirection": "column", "$overflow": "auto", "$bt": "border-solid-s", "$borderColor": isScrolled ? "border-neutral-lighter" : "transparent" },
37
- React.createElement(ObserveScroll, null,
38
- React.createElement("div", { "data-autofocus-inside": true, tabIndex: -2 },
39
- React.createElement(OakBox, { "$mh": "spacing-24" }, children)))),
40
- React.createElement(OakFlex, { "$flexDirection": ["column", "row"], "$bt": "border-solid-s", "$borderColor": "border-neutral-lighter", "$pa": "spacing-12", "$gap": ["spacing-16", "spacing-24"], "$width": "100%" }, footerSlot)), domContainer !== null && domContainer !== void 0 ? domContainer : document.body);
41
- };
42
-
43
- export { OakFilterDrawer };
@@ -1,40 +0,0 @@
1
- import { __makeTemplateObject, __read } from 'tslib';
2
- import React, { useState } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { OakFlex } from '../../layout-and-structure/OakFlex/OakFlex.js';
5
- import { parseSpacing } from '../../../styles/helpers/parseSpacing.js';
6
- import { OakBox } from '../../layout-and-structure/OakBox/OakBox.js';
7
- import { OakLabel } from '../../form-elements/OakLabel/OakLabel.js';
8
- import { parseColor } from '../../../styles/helpers/parseColor.js';
9
-
10
- var isTileItem = function (u) {
11
- return (typeof u === "object" &&
12
- u !== null &&
13
- typeof u.id === "string" &&
14
- typeof u.label === "string");
15
- };
16
- var RadioTileLabel = styled(OakLabel)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n cursor: pointer;\n display: flex;\n gap: ", ";\n"], ["\n cursor: pointer;\n display: flex;\n gap: ", ";\n"])), parseSpacing("spacing-16"));
17
- var HiddenRadioButtonInput = styled.input.attrs({
18
- type: "radio",
19
- })(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n opacity: 0;\n cursor: pointer;\n"], ["\n position: absolute;\n opacity: 0;\n cursor: pointer;\n"])));
20
- var RadioTileFocus = styled(OakBox)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n box-shadow: ", ";\n width: calc(100% + 12px);\n height: calc(100% + 12px);\n top: -6px;\n left: -6px;\n"], ["\n box-shadow: ", ";\n width: calc(100% + 12px);\n height: calc(100% + 12px);\n top: -6px;\n left: -6px;\n"])), "inset 0 0 0 0.15rem ".concat(parseColor("icon-promo")));
21
- var OakRadioTileCss = css(templateObject_4 || (templateObject_4 = __makeTemplateObject([""], [""])));
22
- var UnstyledComponent = function (props) {
23
- var tileItem = props.tileItem, isChecked = props.isChecked, id = props.id, onChange = props.onChange;
24
- var _a = __read(useState(false), 2), isFocussed = _a[0], setIsFocussed = _a[1];
25
- return (React.createElement(OakBox, { "$borderColor": "border-neutral", "$ba": "border-solid-m", "$borderRadius": "border-radius-s", "$pa": "spacing-12", "$position": "relative", "$background": isFocussed || isChecked ? "bg-inverted" : "transparent", "$color": isFocussed || isChecked ? "text-inverted" : "text-primary" },
26
- isFocussed && (React.createElement(RadioTileFocus, { "$background": "transparent", "$position": "absolute", "$ba": "border-solid-l", "$borderColor": "border-neutral-stronger", "$borderRadius": "border-radius-s", "data-testid": "radio-tile-focus" })),
27
- React.createElement(RadioTileLabel, { htmlFor: id },
28
- React.createElement(HiddenRadioButtonInput, { value: tileItem.id, id: id, checked: isChecked, onChange: function () { return onChange(tileItem); }, tabIndex: 0, onFocus: function () { return setIsFocussed(true); }, onBlur: function () { return setIsFocussed(false); }, onClick: function (e) {
29
- // remove focus on mouse click events
30
- if (e.clientX || e.clientY) {
31
- setIsFocussed(false);
32
- }
33
- } }),
34
- React.createElement(OakFlex, { "$height": "spacing-24", "$width": "spacing-24", "$borderColor": "border-neutral", "$flexGrow": 0, "$flexShrink": 0, "$alignItems": "center", "$justifyContent": "center", "$background": "bg-primary", "$ba": "border-solid-m", "$borderRadius": "border-radius-circle" }, isChecked && (React.createElement(OakBox, { "$height": "spacing-16", "$width": "spacing-16", "$background": "bg-inverted", "$position": "absolute", "$borderRadius": "border-radius-circle", "data-testid": "radio-tile-checked" }))),
35
- tileItem.label)));
36
- };
37
- var OakRadioTile = styled(UnstyledComponent)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), OakRadioTileCss);
38
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
39
-
40
- export { OakRadioTile, isTileItem };