carbon-react 124.6.0 → 125.0.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/esm/components/card/__internal__/card-context/index.d.ts +3 -0
- package/esm/components/card/__internal__/card-context/index.js +3 -1
- package/esm/components/card/card-column/card-column.component.d.ts +3 -2
- package/esm/components/card/card-column/card-column.component.js +10 -5
- package/esm/components/card/card-footer/card-footer.component.d.ts +7 -3
- package/esm/components/card/card-footer/card-footer.component.js +7 -5
- package/esm/components/card/card-footer/card-footer.style.d.ts +5 -5
- package/esm/components/card/card-row/card-row.component.d.ts +4 -3
- package/esm/components/card/card-row/card-row.component.js +13 -4
- package/esm/components/card/card-row/card-row.style.d.ts +2 -6
- package/esm/components/card/card-row/card-row.style.js +12 -1
- package/esm/components/card/card.component.d.ts +22 -19
- package/esm/components/card/card.component.js +39 -44
- package/esm/components/card/card.style.d.ts +33 -4
- package/esm/components/card/card.style.js +83 -7
- package/esm/components/select/select-list/select-list.component.js +9 -2
- package/esm/locales/{pl-pl.d.ts → __internal__/pl-pl.d.ts} +1 -1
- package/esm/locales/{pl-pl.js → __internal__/pl-pl.js} +1 -1
- package/esm/locales/index.d.ts +0 -1
- package/esm/locales/index.js +1 -2
- package/lib/components/card/__internal__/card-context/index.d.ts +3 -0
- package/lib/components/card/__internal__/card-context/index.js +3 -1
- package/lib/components/card/card-column/card-column.component.d.ts +3 -2
- package/lib/components/card/card-column/card-column.component.js +10 -5
- package/lib/components/card/card-footer/card-footer.component.d.ts +7 -3
- package/lib/components/card/card-footer/card-footer.component.js +7 -5
- package/lib/components/card/card-footer/card-footer.style.d.ts +5 -5
- package/lib/components/card/card-row/card-row.component.d.ts +4 -3
- package/lib/components/card/card-row/card-row.component.js +15 -4
- package/lib/components/card/card-row/card-row.style.d.ts +2 -6
- package/lib/components/card/card-row/card-row.style.js +12 -1
- package/lib/components/card/card.component.d.ts +22 -19
- package/lib/components/card/card.component.js +39 -44
- package/lib/components/card/card.style.d.ts +33 -4
- package/lib/components/card/card.style.js +84 -9
- package/lib/components/select/select-list/select-list.component.js +9 -2
- package/lib/locales/{pl-pl.d.ts → __internal__/pl-pl.d.ts} +1 -1
- package/lib/locales/{pl-pl.js → __internal__/pl-pl.js} +1 -1
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +0 -7
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { CardSpacing } from "../../card.config";
|
|
2
3
|
export interface CardContextProps {
|
|
3
4
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
4
5
|
roundness?: "default" | "large";
|
|
6
|
+
/** Size of card for applying padding */
|
|
7
|
+
spacing: CardSpacing;
|
|
5
8
|
}
|
|
6
9
|
declare const _default: React.Context<CardContextProps>;
|
|
7
10
|
export default _default;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyledCardColumnProps } from "./card-column.style";
|
|
3
|
-
|
|
3
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags/tags";
|
|
4
|
+
export interface CardColumnProps extends Partial<StyledCardColumnProps>, Pick<TagProps, "data-element" | "data-role"> {
|
|
4
5
|
/** Child elements */
|
|
5
6
|
children: React.ReactNode;
|
|
6
7
|
}
|
|
7
8
|
declare const CardColumn: {
|
|
8
|
-
({ align, children }: CardColumnProps): React.JSX.Element;
|
|
9
|
+
({ align, children, ...rest }: CardColumnProps): React.JSX.Element;
|
|
9
10
|
displayName: string;
|
|
10
11
|
};
|
|
11
12
|
export default CardColumn;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1
2
|
import React from "react";
|
|
2
3
|
import PropTypes from "prop-types";
|
|
3
4
|
import StyledCardColumn from "./card-column.style";
|
|
5
|
+
import tagComponent from "../../../__internal__/utils/helpers/tags/tags";
|
|
4
6
|
const CardColumn = ({
|
|
5
7
|
align = "center",
|
|
6
|
-
children
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
8
|
+
children,
|
|
9
|
+
...rest
|
|
10
|
+
}) => /*#__PURE__*/React.createElement(StyledCardColumn, _extends({
|
|
11
|
+
align: align
|
|
12
|
+
}, tagComponent("card-column", {
|
|
13
|
+
"data-element": "card-column",
|
|
14
|
+
...rest
|
|
15
|
+
})), children);
|
|
11
16
|
CardColumn.displayName = "CardColumn";
|
|
12
17
|
export default CardColumn;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
import { CardContextProps } from "../__internal__/card-context";
|
|
4
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags/tags";
|
|
5
|
+
export interface CardFooterProps extends SpaceProps, Pick<CardContextProps, "roundness">, Pick<TagProps, "data-element" | "data-role"> {
|
|
4
6
|
/** Child nodes */
|
|
5
7
|
children: React.ReactNode;
|
|
8
|
+
/** Specify styling variant to render */
|
|
9
|
+
variant?: "default" | "transparent";
|
|
6
10
|
}
|
|
7
11
|
declare const CardFooter: {
|
|
8
|
-
({
|
|
12
|
+
({ children, variant, ...rest }: CardFooterProps): React.JSX.Element;
|
|
9
13
|
displayName: string;
|
|
10
14
|
};
|
|
11
15
|
export default CardFooter;
|
|
@@ -4,21 +4,23 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps } from "../../../style/utils";
|
|
5
5
|
import StyledCardFooter from "./card-footer.style";
|
|
6
6
|
import CardContext from "../__internal__/card-context";
|
|
7
|
+
import tagComponent from "../../../__internal__/utils/helpers/tags/tags";
|
|
7
8
|
const CardFooter = ({
|
|
8
|
-
spacing = "medium",
|
|
9
9
|
children,
|
|
10
10
|
variant = "default",
|
|
11
11
|
...rest
|
|
12
12
|
}) => {
|
|
13
13
|
const {
|
|
14
|
-
roundness
|
|
14
|
+
roundness,
|
|
15
|
+
spacing
|
|
15
16
|
} = useContext(CardContext);
|
|
16
17
|
return /*#__PURE__*/React.createElement(StyledCardFooter, _extends({
|
|
17
|
-
key: "card-footer",
|
|
18
|
-
"data-element": "card-footer",
|
|
19
18
|
spacing: spacing,
|
|
20
19
|
variant: variant
|
|
21
|
-
}, filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest), {
|
|
20
|
+
}, filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest), tagComponent("card-footer", {
|
|
21
|
+
"data-element": "card-footer",
|
|
22
|
+
...rest
|
|
23
|
+
}), {
|
|
22
24
|
roundness: roundness
|
|
23
25
|
}), children);
|
|
24
26
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SpaceProps } from "styled-system";
|
|
2
|
-
import { CardSpacing } from "../card.config";
|
|
3
2
|
import { CardContextProps } from "../__internal__/card-context";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
spacing: CardSpacing;
|
|
3
|
+
import { CardFooterProps } from "./card-footer.component";
|
|
4
|
+
export interface StyledCardFooterProps extends SpaceProps {
|
|
7
5
|
/** Specify styling variant to render */
|
|
8
|
-
variant: "
|
|
6
|
+
variant: Required<CardFooterProps>["variant"];
|
|
7
|
+
roundness: CardFooterProps["roundness"];
|
|
8
|
+
spacing: CardContextProps["spacing"];
|
|
9
9
|
}
|
|
10
10
|
declare const StyledCardFooter: import("styled-components").StyledComponent<"div", any, StyledCardFooterProps, never>;
|
|
11
11
|
export default StyledCardFooter;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { PaddingProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags/tags";
|
|
4
|
+
export interface CardRowProps extends PaddingProps, Pick<TagProps, "data-element" | "data-role"> {
|
|
4
5
|
/** Child nodes */
|
|
5
6
|
children: React.ReactNode;
|
|
6
7
|
}
|
|
7
8
|
declare const CardRow: {
|
|
8
|
-
({ children,
|
|
9
|
+
({ children, ...rest }: CardRowProps): React.JSX.Element;
|
|
9
10
|
displayName: string;
|
|
10
11
|
};
|
|
11
12
|
export default CardRow;
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { useContext, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { filterStyledSystemPaddingProps } from "../../../style/utils";
|
|
5
5
|
import StyledCardRow from "./card-row.style";
|
|
6
|
+
import tagComponent from "../../../__internal__/utils/helpers/tags/tags";
|
|
7
|
+
import CardContext from "../__internal__/card-context";
|
|
8
|
+
import guid from "../../../__internal__/utils/helpers/guid";
|
|
6
9
|
const CardRow = ({
|
|
7
10
|
children,
|
|
8
|
-
spacing = "medium",
|
|
9
11
|
...rest
|
|
10
12
|
}) => {
|
|
13
|
+
const {
|
|
14
|
+
spacing
|
|
15
|
+
} = useContext(CardContext);
|
|
16
|
+
const id = useRef(guid());
|
|
11
17
|
return /*#__PURE__*/React.createElement(StyledCardRow, _extends({
|
|
12
|
-
|
|
18
|
+
id: id.current,
|
|
13
19
|
spacing: spacing
|
|
14
|
-
}, filterStyledSystemPaddingProps(rest)
|
|
20
|
+
}, filterStyledSystemPaddingProps(rest), tagComponent("card-row", {
|
|
21
|
+
"data-element": "card-row",
|
|
22
|
+
...rest
|
|
23
|
+
})), children);
|
|
15
24
|
};
|
|
16
25
|
CardRow.displayName = "CardRow";
|
|
17
26
|
export default CardRow;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { PaddingProps } from "styled-system";
|
|
2
1
|
import { CardSpacing } from "../card.config";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Spacing prop is set in Card and defines the padding for the CardRow (the first CardRow has no padding by default).
|
|
6
|
-
* For more granular control of CardRow padding these can be over-ridden by Padding props from styled-system.
|
|
7
|
-
*/
|
|
2
|
+
import { CardRowProps } from "./card-row.component";
|
|
3
|
+
export interface StyledCardRowProps extends CardRowProps {
|
|
8
4
|
spacing: CardSpacing;
|
|
9
5
|
}
|
|
10
6
|
declare const StyledCardRow: import("styled-components").StyledComponent<"div", any, StyledCardRowProps, never>;
|
|
@@ -15,7 +15,18 @@ const StyledCardRow = styled.div`
|
|
|
15
15
|
padding-bottom: ${paddingSizes[spacing]};
|
|
16
16
|
`}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
&:first-of-type:not(:only-of-type) {
|
|
19
|
+
padding-top: var(--spacing000);
|
|
20
|
+
padding-bottom: var(--spacing000);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:only-of-type {
|
|
24
|
+
padding-top: var(--spacing000);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&& {
|
|
28
|
+
${padding}
|
|
29
|
+
}
|
|
19
30
|
`;
|
|
20
31
|
StyledCardRow.defaultProps = {
|
|
21
32
|
theme: baseTheme
|
|
@@ -2,40 +2,43 @@ import React from "react";
|
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
4
4
|
import { CardContextProps } from "./__internal__/card-context";
|
|
5
|
-
import {
|
|
5
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
6
6
|
declare type DesignTokensType = keyof typeof DesignTokens;
|
|
7
7
|
declare type BoxShadowsType = Extract<DesignTokensType, `boxShadow${string}`>;
|
|
8
|
-
export interface CardProps extends MarginProps,
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
12
|
-
"data-role"?: string;
|
|
13
|
-
/**
|
|
14
|
-
* [DEPRECATED - use `data-role` instead]
|
|
15
|
-
* Identifier used for testing purposes, applied to the root element of the component.
|
|
8
|
+
export interface CardProps extends MarginProps, Pick<TagProps, "data-element" | "data-role"> {
|
|
9
|
+
/** Action to be executed when card is clicked or enter pressed.
|
|
10
|
+
* Renders a button when passed and no draggable or href props set
|
|
16
11
|
* */
|
|
17
|
-
|
|
18
|
-
/** Action to be executed when card is clicked or enter pressed */
|
|
19
|
-
action?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
12
|
+
onClick?: (event: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLDivElement>) => void;
|
|
20
13
|
/** Style value for width of card */
|
|
21
|
-
|
|
14
|
+
width?: string;
|
|
22
15
|
/** Child nodes */
|
|
23
16
|
children: React.ReactNode;
|
|
24
17
|
/** Flag to indicate if card is draggable */
|
|
25
18
|
draggable?: boolean;
|
|
26
19
|
/** Height of the component (any valid CSS value) */
|
|
27
20
|
height?: string;
|
|
28
|
-
/** Flag to indicate if card is interactive */
|
|
29
|
-
interactive?: boolean;
|
|
30
|
-
/** Size of card for applying padding */
|
|
31
|
-
spacing?: CardSpacing;
|
|
32
21
|
/** Design token for custom Box Shadow. Note: please check that the box shadow design token you are using is compatible with the Card component. */
|
|
33
22
|
boxShadow?: BoxShadowsType;
|
|
34
|
-
/** Design token for custom Box Shadow on hover.
|
|
23
|
+
/** Design token for custom Box Shadow on hover. One of `onClick` or `href` props must be true. Note: please check that the box shadow design token you are using is compatible with the Card component. */
|
|
35
24
|
hoverBoxShadow?: BoxShadowsType;
|
|
25
|
+
/** Size of card for applying padding */
|
|
26
|
+
spacing?: CardContextProps["spacing"];
|
|
27
|
+
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
|
+
roundness?: CardContextProps["roundness"];
|
|
29
|
+
/** The path to navigate to. Renders an anchor element when passed and no draggable prop set */
|
|
30
|
+
href?: string;
|
|
31
|
+
/** The footer to render underneath the Card content */
|
|
32
|
+
footer?: React.ReactNode;
|
|
33
|
+
/** Target property in which link should open ie: _blank, _self, _parent, _top */
|
|
34
|
+
target?: string;
|
|
35
|
+
/** String for rel property when card has an href prop set */
|
|
36
|
+
rel?: string;
|
|
37
|
+
/** Prop to specify an aria-label for the component */
|
|
38
|
+
"aria-label"?: string;
|
|
36
39
|
}
|
|
37
40
|
declare const Card: {
|
|
38
|
-
({ "data-element": dataElement, "data-role": dataRole,
|
|
41
|
+
({ "data-element": dataElement, "data-role": dataRole, children, width, draggable, height, onClick, href, spacing, boxShadow, hoverBoxShadow, roundness, footer, rel, target, "aria-label": ariaLabel, ...rest }: CardProps): React.JSX.Element;
|
|
39
42
|
displayName: string;
|
|
40
43
|
};
|
|
41
44
|
export default Card;
|
|
@@ -1,75 +1,70 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
5
5
|
import CardContext from "./__internal__/card-context";
|
|
6
|
-
import StyledCard from "./card.style";
|
|
6
|
+
import { StyledCard, StyledCardContent } from "./card.style";
|
|
7
7
|
import Icon from "../icon";
|
|
8
|
-
import
|
|
9
|
-
import Logger from "../../__internal__/utils/logger";
|
|
10
|
-
function hasDisplayName(child, displayName) {
|
|
11
|
-
return child.type.displayName === displayName;
|
|
12
|
-
}
|
|
13
|
-
let isDeprecationWarningTriggered = false;
|
|
8
|
+
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
14
9
|
const Card = ({
|
|
15
10
|
"data-element": dataElement,
|
|
16
11
|
"data-role": dataRole,
|
|
17
|
-
dataRole: oldDataRole,
|
|
18
|
-
action,
|
|
19
12
|
children,
|
|
20
|
-
|
|
13
|
+
width = "500px",
|
|
21
14
|
draggable,
|
|
22
15
|
height,
|
|
23
|
-
|
|
16
|
+
onClick,
|
|
17
|
+
href,
|
|
24
18
|
spacing = "medium",
|
|
25
19
|
boxShadow,
|
|
26
20
|
hoverBoxShadow,
|
|
27
21
|
roundness = "default",
|
|
22
|
+
footer,
|
|
23
|
+
rel,
|
|
24
|
+
target,
|
|
25
|
+
"aria-label": ariaLabel,
|
|
28
26
|
...rest
|
|
29
27
|
}) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const [contentRef, setContentRef] = useState(null);
|
|
29
|
+
const interactive = !!(onClick || href);
|
|
30
|
+
let footerWarningFired = false;
|
|
31
|
+
if (!footerWarningFired && interactive && contentRef?.querySelector("[data-component='card-footer']")) {
|
|
32
|
+
footerWarningFired = true;
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.warn("This `Card` is interactive you should use the `footer` prop to render a `CardFooter` to avoid potential accessibility issues");
|
|
33
35
|
}
|
|
34
|
-
const renderChildren = useCallback(() => React.Children.map(children, (child, index) => {
|
|
35
|
-
if (! /*#__PURE__*/React.isValidElement(child) || /*#__PURE__*/React.isValidElement(child) && !hasDisplayName(child, CardRow.displayName) && !hasDisplayName(child, CardFooter.displayName)) return child;
|
|
36
|
-
if (index !== 0) return /*#__PURE__*/React.cloneElement(child, {
|
|
37
|
-
spacing
|
|
38
|
-
});
|
|
39
|
-
const childProps = {
|
|
40
|
-
spacing,
|
|
41
|
-
...child.props
|
|
42
|
-
};
|
|
43
|
-
if (hasDisplayName(child, CardRow.displayName)) {
|
|
44
|
-
const pad = React.Children.toArray(children).filter(row => /*#__PURE__*/React.isValidElement(row) && hasDisplayName(row, CardRow.displayName)).length === 1 ? "pt" : "py";
|
|
45
|
-
childProps[pad] = 0;
|
|
46
|
-
}
|
|
47
|
-
return /*#__PURE__*/React.cloneElement(child, childProps);
|
|
48
|
-
}), [children, spacing]);
|
|
49
36
|
return /*#__PURE__*/React.createElement(StyledCard, _extends({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"data-role": dataRole || oldDataRole,
|
|
53
|
-
cardWidth: cardWidth,
|
|
54
|
-
interactive: !!interactive,
|
|
37
|
+
cardWidth: width,
|
|
38
|
+
interactive: interactive,
|
|
55
39
|
draggable: !!draggable,
|
|
56
40
|
spacing: spacing,
|
|
57
41
|
boxShadow: boxShadow,
|
|
58
42
|
hoverBoxShadow: hoverBoxShadow,
|
|
59
|
-
|
|
60
|
-
height: height
|
|
61
|
-
}, interactive && {
|
|
62
|
-
tabIndex: 0,
|
|
63
|
-
type: "button"
|
|
64
|
-
}, {
|
|
43
|
+
height: height,
|
|
65
44
|
roundness: roundness
|
|
66
|
-
}, filterStyledSystemMarginProps(rest)
|
|
45
|
+
}, filterStyledSystemMarginProps(rest), tagComponent("card", {
|
|
46
|
+
"data-element": dataElement,
|
|
47
|
+
"data-role": dataRole
|
|
48
|
+
})), draggable && /*#__PURE__*/React.createElement(Icon, {
|
|
67
49
|
type: "drag"
|
|
68
50
|
}), /*#__PURE__*/React.createElement(CardContext.Provider, {
|
|
69
51
|
value: {
|
|
70
|
-
roundness
|
|
52
|
+
roundness,
|
|
53
|
+
spacing
|
|
71
54
|
}
|
|
72
|
-
},
|
|
55
|
+
}, /*#__PURE__*/React.createElement(StyledCardContent, {
|
|
56
|
+
"data-element": "card-content-container",
|
|
57
|
+
onClick: !draggable ? onClick : undefined,
|
|
58
|
+
href: !draggable ? href : undefined,
|
|
59
|
+
rel: !draggable && href ? rel : undefined,
|
|
60
|
+
target: !draggable && href ? target : undefined,
|
|
61
|
+
interactive: interactive,
|
|
62
|
+
spacing: spacing,
|
|
63
|
+
roundness: roundness,
|
|
64
|
+
hasFooter: !!footer,
|
|
65
|
+
ref: setContentRef,
|
|
66
|
+
"aria-label": ariaLabel
|
|
67
|
+
}, children), footer));
|
|
73
68
|
};
|
|
74
69
|
Card.displayName = "Card";
|
|
75
70
|
export default Card;
|
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
import { MarginProps } from "styled-system";
|
|
2
2
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
3
|
-
import { CardSpacing } from "./card.config";
|
|
4
3
|
import { CardContextProps } from "./__internal__/card-context";
|
|
4
|
+
import { CardProps } from "./card.component";
|
|
5
|
+
export declare const paddingSizes: {
|
|
6
|
+
small: string;
|
|
7
|
+
medium: string;
|
|
8
|
+
large: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const marginSizes: {
|
|
11
|
+
small: string;
|
|
12
|
+
medium: string;
|
|
13
|
+
large: string;
|
|
14
|
+
};
|
|
5
15
|
declare type DesignTokensType = keyof typeof DesignTokens;
|
|
6
16
|
export declare type BoxShadowsType = Extract<DesignTokensType, `boxShadow${string}`>;
|
|
7
|
-
export interface StyledCardProps extends MarginProps, CardContextProps {
|
|
17
|
+
export interface StyledCardProps extends MarginProps, Pick<CardContextProps, "roundness" | "spacing">, Pick<CardProps, "href" | "onClick"> {
|
|
8
18
|
cardWidth: string;
|
|
9
19
|
interactive: boolean;
|
|
10
20
|
draggable: boolean;
|
|
11
21
|
height?: string;
|
|
12
|
-
spacing: CardSpacing;
|
|
13
22
|
boxShadow?: BoxShadowsType;
|
|
14
23
|
hoverBoxShadow?: BoxShadowsType;
|
|
15
24
|
}
|
|
16
25
|
declare const StyledCard: import("styled-components").StyledComponent<"div", any, StyledCardProps, never>;
|
|
17
|
-
|
|
26
|
+
interface StyledCardContentProps extends Pick<CardContextProps, "roundness" | "spacing"> {
|
|
27
|
+
interactive?: boolean;
|
|
28
|
+
href?: string;
|
|
29
|
+
hasFooter: boolean;
|
|
30
|
+
target?: string;
|
|
31
|
+
rel?: string;
|
|
32
|
+
}
|
|
33
|
+
declare const StyledCardContent: import("styled-components").StyledComponent<"div", any, ({
|
|
34
|
+
as: string;
|
|
35
|
+
role?: undefined;
|
|
36
|
+
type?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
as: string;
|
|
39
|
+
role: "button";
|
|
40
|
+
type: string;
|
|
41
|
+
} | {
|
|
42
|
+
as?: undefined;
|
|
43
|
+
role?: undefined;
|
|
44
|
+
type?: undefined;
|
|
45
|
+
}) & StyledCardContentProps, "type" | "role" | "as">;
|
|
46
|
+
export { StyledCard, StyledCardContent };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { margin } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import addFocusStyling from "../../style/utils/add-focus-styling";
|
|
5
|
+
export const paddingSizes = {
|
|
6
|
+
small: "0 var(--spacing300)",
|
|
7
|
+
medium: "0 var(--spacing400)",
|
|
8
|
+
large: "0 var(--spacing600)"
|
|
9
|
+
};
|
|
10
|
+
export const marginSizes = {
|
|
11
|
+
small: "0 -24px",
|
|
12
|
+
medium: "0 -32px",
|
|
13
|
+
large: "0 -48px"
|
|
8
14
|
};
|
|
9
15
|
const StyledCard = styled.div`
|
|
10
16
|
${({
|
|
@@ -26,6 +32,7 @@ const StyledCard = styled.div`
|
|
|
26
32
|
flex-direction: column;
|
|
27
33
|
height: ${height};
|
|
28
34
|
justify-content: space-between;
|
|
35
|
+
align-items: normal;
|
|
29
36
|
margin: 25px;
|
|
30
37
|
outline: none;
|
|
31
38
|
padding: ${paddingSizes[spacing]};
|
|
@@ -35,8 +42,6 @@ const StyledCard = styled.div`
|
|
|
35
42
|
${margin}
|
|
36
43
|
|
|
37
44
|
${interactive && css`
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
|
|
40
45
|
:hover,
|
|
41
46
|
:focus {
|
|
42
47
|
box-shadow: var(--${hoverBoxShadow});
|
|
@@ -52,7 +57,78 @@ const StyledCard = styled.div`
|
|
|
52
57
|
}
|
|
53
58
|
`}
|
|
54
59
|
`;
|
|
60
|
+
const StyledCardContent = styled.div.attrs(({
|
|
61
|
+
href,
|
|
62
|
+
onClick
|
|
63
|
+
}) => {
|
|
64
|
+
if (href) {
|
|
65
|
+
return {
|
|
66
|
+
as: "a"
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (onClick) {
|
|
70
|
+
return {
|
|
71
|
+
as: "button",
|
|
72
|
+
role: "button",
|
|
73
|
+
type: "button"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {};
|
|
77
|
+
})`
|
|
78
|
+
${({
|
|
79
|
+
interactive,
|
|
80
|
+
theme
|
|
81
|
+
}) => interactive && css`
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
|
|
84
|
+
${!theme.focusRedesignOptOut && css`
|
|
85
|
+
:focus {
|
|
86
|
+
${addFocusStyling()};
|
|
87
|
+
position: relative;
|
|
88
|
+
}
|
|
89
|
+
`}
|
|
90
|
+
`}
|
|
91
|
+
|
|
92
|
+
outline: none;
|
|
93
|
+
text-decoration: none;
|
|
94
|
+
background-color: inherit;
|
|
95
|
+
border: none;
|
|
96
|
+
padding: 0;
|
|
97
|
+
|
|
98
|
+
${({
|
|
99
|
+
spacing
|
|
100
|
+
}) => `
|
|
101
|
+
padding: ${paddingSizes[spacing]};
|
|
102
|
+
margin: ${marginSizes[spacing]};
|
|
103
|
+
`}
|
|
104
|
+
|
|
105
|
+
${({
|
|
106
|
+
roundness,
|
|
107
|
+
hasFooter
|
|
108
|
+
}) => css`
|
|
109
|
+
${roundness === "default" && css`
|
|
110
|
+
border-top-left-radius: var(--borderRadius100);
|
|
111
|
+
border-top-right-radius: var(--borderRadius100);
|
|
112
|
+
${!hasFooter && css`
|
|
113
|
+
border-bottom-left-radius: var(--borderRadius100);
|
|
114
|
+
border-bottom-right-radius: var(--borderRadius100);
|
|
115
|
+
`}
|
|
116
|
+
`}
|
|
117
|
+
|
|
118
|
+
${roundness !== "default" && css`
|
|
119
|
+
border-top-left-radius: var(--borderRadius200);
|
|
120
|
+
border-top-right-radius: var(--borderRadius200);
|
|
121
|
+
${!hasFooter && css`
|
|
122
|
+
border-bottom-left-radius: var(--borderRadius200);
|
|
123
|
+
border-bottom-right-radius: var(--borderRadius200);
|
|
124
|
+
`}
|
|
125
|
+
`}
|
|
126
|
+
`}
|
|
127
|
+
`;
|
|
55
128
|
StyledCard.defaultProps = {
|
|
56
129
|
theme: baseTheme
|
|
57
130
|
};
|
|
58
|
-
|
|
131
|
+
StyledCardContent.defaultProps = {
|
|
132
|
+
theme: baseTheme
|
|
133
|
+
};
|
|
134
|
+
export { StyledCard, StyledCardContent };
|
|
@@ -324,8 +324,15 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
326
|
setCurrentOptionsListIndex(indexOfMatch);
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
}, [getIndexOfMatch, highlightedValue]);
|
|
328
|
+
|
|
329
|
+
// ensure that the currently-selected option is always visible immediately after
|
|
330
|
+
// it has been changed
|
|
331
|
+
useEffect(() => {
|
|
332
|
+
if (currentOptionsListIndex > -1) {
|
|
333
|
+
virtualizer.scrollToIndex(currentOptionsListIndex, SCROLL_OPTIONS);
|
|
334
|
+
}
|
|
335
|
+
}, [currentOptionsListIndex, virtualizer]);
|
|
329
336
|
useEffect(() => {
|
|
330
337
|
if (isLoading && currentOptionsListIndex === lastOptionIndex && lastOptionIndex > -1) {
|
|
331
338
|
virtualizer.scrollToIndex(lastOptionIndex, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Locale from "
|
|
1
|
+
import Locale from "../locale";
|
|
2
2
|
export declare const PolishPlural: (singularNominativ: string, pluralNominativ: string, pluralGenitive: string, value: number) => string;
|
|
3
3
|
declare const plPL: Locale;
|
|
4
4
|
export { PolishPlural as PolishPlurals };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pl as plDateLocale } from "
|
|
1
|
+
import { pl as plDateLocale } from "../date-fns-locales";
|
|
2
2
|
const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
|
|
3
3
|
export const PolishPlural = (singularNominativ, pluralNominativ, pluralGenitive, value) => {
|
|
4
4
|
if (value === 1) {
|
package/esm/locales/index.d.ts
CHANGED
package/esm/locales/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default as EnGb } from "./en-gb";
|
|
2
|
-
export { default as PlPl } from "./pl-pl";
|
|
1
|
+
export { default as EnGb } from "./en-gb";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { CardSpacing } from "../../card.config";
|
|
2
3
|
export interface CardContextProps {
|
|
3
4
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
4
5
|
roundness?: "default" | "large";
|
|
6
|
+
/** Size of card for applying padding */
|
|
7
|
+
spacing: CardSpacing;
|
|
5
8
|
}
|
|
6
9
|
declare const _default: React.Context<CardContextProps>;
|
|
7
10
|
export default _default;
|
|
@@ -6,4 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
var _default = exports.default = /*#__PURE__*/_react.default.createContext({
|
|
9
|
+
var _default = exports.default = /*#__PURE__*/_react.default.createContext({
|
|
10
|
+
spacing: "medium"
|
|
11
|
+
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyledCardColumnProps } from "./card-column.style";
|
|
3
|
-
|
|
3
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags/tags";
|
|
4
|
+
export interface CardColumnProps extends Partial<StyledCardColumnProps>, Pick<TagProps, "data-element" | "data-role"> {
|
|
4
5
|
/** Child elements */
|
|
5
6
|
children: React.ReactNode;
|
|
6
7
|
}
|
|
7
8
|
declare const CardColumn: {
|
|
8
|
-
({ align, children }: CardColumnProps): React.JSX.Element;
|
|
9
|
+
({ align, children, ...rest }: CardColumnProps): React.JSX.Element;
|
|
9
10
|
displayName: string;
|
|
10
11
|
};
|
|
11
12
|
export default CardColumn;
|