carbon-react 122.0.1 → 123.0.1
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/__internal__/utils/helpers/tags/tags-specs/index.d.ts +1 -1
- package/esm/__internal__/utils/helpers/tags/tags-specs/index.js +1 -1
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +2 -1
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +6 -3
- package/esm/components/textarea/textarea.component.d.ts +4 -1
- package/esm/components/textarea/textarea.component.js +3 -3
- package/esm/components/textbox/textbox.component.d.ts +4 -1
- package/esm/components/textbox/textbox.component.js +3 -3
- package/esm/components/textbox/textbox.style.d.ts +1 -2
- package/esm/components/textbox/textbox.style.js +2 -10
- package/esm/components/tile/__internal__/compute-content-padding.d.ts +13 -0
- package/esm/components/tile/__internal__/compute-content-padding.js +23 -0
- package/esm/components/tile/__internal__/tile-context.d.ts +8 -0
- package/esm/components/tile/__internal__/tile-context.js +4 -0
- package/esm/components/tile/index.d.ts +5 -1
- package/esm/components/tile/index.js +3 -1
- package/esm/components/tile/tile-content/index.d.ts +2 -0
- package/esm/components/tile/tile-content/index.js +1 -0
- package/esm/components/tile/tile-content/tile-content.component.d.ts +10 -0
- package/esm/components/tile/tile-content/tile-content.component.js +33 -0
- package/esm/components/tile/tile-content/tile-content.style.d.ts +9 -0
- package/esm/components/tile/tile-content/tile-content.style.js +64 -0
- package/esm/components/tile/tile-footer/tile-footer.component.d.ts +3 -2
- package/esm/components/tile/tile-footer/tile-footer.component.js +6 -7
- package/esm/components/tile/tile.component.d.ts +3 -2
- package/esm/components/tile/tile.component.js +23 -34
- package/esm/components/tile/tile.style.d.ts +1 -8
- package/esm/components/tile/tile.style.js +1 -60
- package/esm/style/utils/filter-styled-system-padding-props.d.ts +8 -1
- package/esm/style/utils/filter-styled-system-padding-props.js +10 -1
- package/lib/__internal__/utils/helpers/tags/tags-specs/index.d.ts +1 -1
- package/lib/__internal__/utils/helpers/tags/tags-specs/index.js +6 -0
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +2 -1
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +8 -4
- package/lib/components/textarea/textarea.component.d.ts +4 -1
- package/lib/components/textarea/textarea.component.js +2 -2
- package/lib/components/textbox/textbox.component.d.ts +4 -1
- package/lib/components/textbox/textbox.component.js +2 -2
- package/lib/components/textbox/textbox.style.d.ts +1 -2
- package/lib/components/textbox/textbox.style.js +2 -11
- package/lib/components/tile/__internal__/compute-content-padding.d.ts +13 -0
- package/lib/components/tile/__internal__/compute-content-padding.js +30 -0
- package/lib/components/tile/__internal__/tile-context.d.ts +8 -0
- package/lib/components/tile/__internal__/tile-context.js +11 -0
- package/lib/components/tile/index.d.ts +5 -1
- package/lib/components/tile/index.js +15 -1
- package/lib/components/tile/tile-content/index.d.ts +2 -0
- package/lib/components/tile/tile-content/index.js +13 -0
- package/lib/components/tile/tile-content/package.json +6 -0
- package/lib/components/tile/tile-content/tile-content.component.d.ts +10 -0
- package/lib/components/tile/tile-content/tile-content.component.js +43 -0
- package/lib/components/tile/tile-content/tile-content.style.d.ts +9 -0
- package/lib/components/tile/tile-content/tile-content.style.js +74 -0
- package/lib/components/tile/tile-footer/tile-footer.component.d.ts +3 -2
- package/lib/components/tile/tile-footer/tile-footer.component.js +6 -7
- package/lib/components/tile/tile.component.d.ts +3 -2
- package/lib/components/tile/tile.component.js +24 -35
- package/lib/components/tile/tile.style.d.ts +1 -8
- package/lib/components/tile/tile.style.js +4 -63
- package/lib/style/utils/filter-styled-system-padding-props.d.ts +8 -1
- package/lib/style/utils/filter-styled-system-padding-props.js +18 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export { elementsTagTest, rootTagTest } from "./tags-specs";
|
|
1
|
+
export { elementsTagTest, rootTagTest, rootTagTestRtl } from "./tags-specs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { elementsTagTest, rootTagTest } from "./tags-specs";
|
|
1
|
+
export { elementsTagTest, rootTagTest, rootTagTestRtl } from "./tags-specs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactWrapper, ShallowWrapper } from "enzyme";
|
|
2
2
|
declare const elementsTagTest: (wrapper: ReactWrapper | ShallowWrapper, elements: string[]) => void;
|
|
3
3
|
declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
|
|
4
|
-
|
|
4
|
+
declare const rootTagTestRtl: (element: HTMLElement, comp: string, elem?: string, role?: string) => void;
|
|
5
|
+
export { elementsTagTest, rootTagTest, rootTagTestRtl };
|
|
@@ -12,6 +12,9 @@ const rootTagTest = (rootNode, comp, elem, role) => {
|
|
|
12
12
|
expect(rootNode.prop("data-element")).toEqual(elem);
|
|
13
13
|
expect(rootNode.prop("data-role")).toEqual(role);
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const rootTagTestRtl = (element, comp, elem, role) => {
|
|
16
|
+
expect(element.getAttribute("data-component")).toBe(comp);
|
|
17
|
+
expect(element.getAttribute("data-element")).toBe(elem);
|
|
18
|
+
expect(element.getAttribute("data-role")).toBe(role);
|
|
19
|
+
};
|
|
20
|
+
export { elementsTagTest, rootTagTest, rootTagTestRtl };
|
|
@@ -59,7 +59,10 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
|
|
|
59
59
|
label?: string;
|
|
60
60
|
/** Inline label alignment */
|
|
61
61
|
labelAlign?: "left" | "right";
|
|
62
|
-
/** Text applied to label help tooltip
|
|
62
|
+
/** [Legacy] Text applied to label help tooltip. When opted into new design validations
|
|
63
|
+
* it will render as a hint above the input, unless an `inputHint`
|
|
64
|
+
* prop is also passed
|
|
65
|
+
*/
|
|
63
66
|
labelHelp?: React.ReactNode;
|
|
64
67
|
/** When true, label is placed in line an input */
|
|
65
68
|
labelInline?: boolean;
|
|
@@ -12,7 +12,7 @@ import StyledTextarea, { MIN_HEIGHT } from "./textarea.style";
|
|
|
12
12
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
13
13
|
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
|
|
14
14
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
15
|
-
import { ErrorBorder, StyledHintText
|
|
15
|
+
import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
|
|
16
16
|
import ValidationMessage from "../../__internal__/validation-message";
|
|
17
17
|
import Box from "../box";
|
|
18
18
|
import Logger from "../../__internal__/utils/logger";
|
|
@@ -215,10 +215,10 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
215
215
|
useValidationIcon: computeLabelPropValues(validationOnLabel),
|
|
216
216
|
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
|
|
217
217
|
validationRedesignOptIn: validationRedesignOptIn
|
|
218
|
-
}, inputHint
|
|
218
|
+
}, (inputHint || labelHelp && validationRedesignOptIn) && /*#__PURE__*/React.createElement(StyledHintText, {
|
|
219
219
|
id: inputHintId,
|
|
220
220
|
"data-element": "input-hint"
|
|
221
|
-
}, inputHint
|
|
221
|
+
}, inputHint || labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
|
|
222
222
|
position: "relative"
|
|
223
223
|
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
224
224
|
error: error,
|
|
@@ -52,7 +52,10 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
|
|
|
52
52
|
label?: string;
|
|
53
53
|
/** Inline label alignment */
|
|
54
54
|
labelAlign?: "left" | "right";
|
|
55
|
-
/**
|
|
55
|
+
/** [Legacy] Text applied to label help tooltip. When opted into new design validations
|
|
56
|
+
* it will render as a hint above the input, unless an `inputHint`
|
|
57
|
+
* prop is also passed
|
|
58
|
+
*/
|
|
56
59
|
labelHelp?: React.ReactNode;
|
|
57
60
|
/** When true label is inline */
|
|
58
61
|
labelInline?: boolean;
|
|
@@ -11,7 +11,7 @@ import StyledPrefix from "./__internal__/prefix.style";
|
|
|
11
11
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
12
12
|
import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
|
|
13
13
|
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility/useInputAccessibility";
|
|
14
|
-
import { ErrorBorder,
|
|
14
|
+
import { ErrorBorder, StyledHintText } from "./textbox.style";
|
|
15
15
|
import ValidationMessage from "../../__internal__/validation-message";
|
|
16
16
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
17
17
|
import NumeralDateContext from "../numeral-date/numeral-date-context";
|
|
@@ -193,10 +193,10 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
|
193
193
|
"data-element": dataElement,
|
|
194
194
|
validationIconId: validationRedesignOptIn ? undefined : validationId,
|
|
195
195
|
validationRedesignOptIn: validationRedesignOptIn
|
|
196
|
-
}, filterStyledSystemMarginProps(props)), inputHint
|
|
196
|
+
}, filterStyledSystemMarginProps(props)), (inputHint || labelHelp && validationRedesignOptIn) && /*#__PURE__*/React.createElement(StyledHintText, {
|
|
197
197
|
id: inputHintId,
|
|
198
198
|
"data-element": "input-hint"
|
|
199
|
-
}, inputHint
|
|
199
|
+
}, inputHint || labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
|
|
200
200
|
position: "relative"
|
|
201
201
|
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
202
202
|
error: error,
|
|
@@ -2,6 +2,5 @@ declare const ErrorBorder: import("styled-components").StyledComponent<"span", a
|
|
|
2
2
|
warning: boolean;
|
|
3
3
|
inline?: boolean | undefined;
|
|
4
4
|
}, never>;
|
|
5
|
-
declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
6
5
|
declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
-
export { StyledHintText, ErrorBorder
|
|
6
|
+
export { StyledHintText, ErrorBorder };
|
|
@@ -13,22 +13,14 @@ const ErrorBorder = styled.span`
|
|
|
13
13
|
top: 0px;
|
|
14
14
|
`}
|
|
15
15
|
`;
|
|
16
|
-
const
|
|
16
|
+
const StyledHintText = styled.div`
|
|
17
17
|
::after {
|
|
18
18
|
content: " ";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
display: block;
|
|
22
|
-
flex: 1;
|
|
23
|
-
margin-top: -3px;
|
|
24
|
-
margin-bottom: 8px;
|
|
25
|
-
color: var(--colorsUtilityYin055);
|
|
26
|
-
white-space: pre-wrap;
|
|
27
|
-
`;
|
|
28
|
-
const StyledHintText = styled.div`
|
|
29
21
|
margin-top: 0px;
|
|
30
22
|
margin-bottom: 8px;
|
|
31
23
|
color: var(--colorsUtilityYin055);
|
|
32
24
|
font-size: 14px;
|
|
33
25
|
`;
|
|
34
|
-
export { StyledHintText, ErrorBorder
|
|
26
|
+
export { StyledHintText, ErrorBorder };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
2
|
+
declare const _default: (paddingProps: PaddingProps, isHorizontal: boolean) => {
|
|
3
|
+
pr: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
|
4
|
+
pl: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
|
5
|
+
pt?: undefined;
|
|
6
|
+
pb?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
pt: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
|
9
|
+
pb: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
|
10
|
+
pr?: undefined;
|
|
11
|
+
pl?: undefined;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { paddingNames, paddingLeftPropertyNames, paddingRightPropertyNames, paddingBottomPropertyNames, paddingTopPropertyNames, paddingXPropertyNames, paddingYPropertyNames } from "../../../style/utils/filter-styled-system-padding-props";
|
|
2
|
+
const CONTENT_PADDING_LEFT_KEYS = [...paddingLeftPropertyNames, ...paddingXPropertyNames, ...paddingNames];
|
|
3
|
+
const CONTENT_PADDING_RIGHT_KEYS = [...paddingRightPropertyNames, ...paddingXPropertyNames, ...paddingNames];
|
|
4
|
+
const CONTENT_PADDING_TOP_KEYS = [...paddingTopPropertyNames, ...paddingYPropertyNames, ...paddingNames];
|
|
5
|
+
const CONTENT_PADDING_BOTTOM_KEYS = [...paddingBottomPropertyNames, ...paddingYPropertyNames, ...paddingNames];
|
|
6
|
+
export default ((paddingProps, isHorizontal) => {
|
|
7
|
+
const getPaddingProps = paddingKeys => {
|
|
8
|
+
const key = paddingKeys.find(propName => paddingProps[propName]);
|
|
9
|
+
|
|
10
|
+
/* istanbul ignore if */
|
|
11
|
+
if (!key) {
|
|
12
|
+
return key;
|
|
13
|
+
}
|
|
14
|
+
return paddingProps[key];
|
|
15
|
+
};
|
|
16
|
+
return isHorizontal ? {
|
|
17
|
+
pr: getPaddingProps(CONTENT_PADDING_LEFT_KEYS),
|
|
18
|
+
pl: getPaddingProps(CONTENT_PADDING_RIGHT_KEYS)
|
|
19
|
+
} : {
|
|
20
|
+
pt: getPaddingProps(CONTENT_PADDING_TOP_KEYS),
|
|
21
|
+
pb: getPaddingProps(CONTENT_PADDING_BOTTOM_KEYS)
|
|
22
|
+
};
|
|
23
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PaddingProps } from "styled-system";
|
|
3
|
+
interface TileContextProps {
|
|
4
|
+
isHorizontal?: boolean;
|
|
5
|
+
paddingPropsFromTile: PaddingProps;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("react").Context<TileContextProps>;
|
|
8
|
+
export default _default;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { default } from "./tile.component";
|
|
1
|
+
export { default as Tile } from "./tile.component";
|
|
2
2
|
export type { TileProps } from "./tile.component";
|
|
3
|
+
export { default as TileContent } from "./tile-content";
|
|
4
|
+
export type { TileContentProps } from "./tile-content";
|
|
5
|
+
export { default as TileFooter } from "./tile-footer";
|
|
6
|
+
export type { TileFooterProps } from "./tile-footer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./tile-content.component";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
4
|
+
export interface TileContentProps extends SpaceProps, TagProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
width?: string | number;
|
|
7
|
+
height?: string | number;
|
|
8
|
+
}
|
|
9
|
+
declare const TileContent: ({ children, width, height, ...rest }: TileContentProps) => React.JSX.Element | null;
|
|
10
|
+
export default TileContent;
|
|
@@ -0,0 +1,33 @@
|
|
|
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, { useContext } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import StyledTileContent from "./tile-content.style";
|
|
5
|
+
import TileContext from "../__internal__/tile-context";
|
|
6
|
+
import tagComponent from "../../../__internal__/utils/helpers/tags";
|
|
7
|
+
import filterStyledSystemPaddingProps from "../../../style/utils/filter-styled-system-padding-props";
|
|
8
|
+
import filterStyledSystemMarginProps from "../../../style/utils/filter-styled-system-margin-props";
|
|
9
|
+
const TileContent = ({
|
|
10
|
+
children,
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
...rest
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
isHorizontal,
|
|
17
|
+
paddingPropsFromTile
|
|
18
|
+
} = useContext(TileContext);
|
|
19
|
+
if (!children) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const spacingProps = {
|
|
23
|
+
...filterStyledSystemPaddingProps(rest),
|
|
24
|
+
...filterStyledSystemMarginProps(rest)
|
|
25
|
+
};
|
|
26
|
+
return /*#__PURE__*/React.createElement(StyledTileContent, _extends({
|
|
27
|
+
width: width,
|
|
28
|
+
height: height,
|
|
29
|
+
isHorizontal: isHorizontal,
|
|
30
|
+
isVertical: !isHorizontal
|
|
31
|
+
}, paddingPropsFromTile, spacingProps, tagComponent("tile-content", rest)), children);
|
|
32
|
+
};
|
|
33
|
+
export default TileContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TileContentProps } from "./tile-content.component";
|
|
2
|
+
interface StyledTileContentProps extends TileContentProps {
|
|
3
|
+
isHorizontal?: boolean;
|
|
4
|
+
isVertical?: boolean;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
height?: string | number;
|
|
7
|
+
}
|
|
8
|
+
declare const StyledTileContent: import("styled-components").StyledComponent<"div", any, StyledTileContentProps, never>;
|
|
9
|
+
export default StyledTileContent;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { space } from "styled-system";
|
|
3
|
+
import baseTheme from "../../../style/themes/base";
|
|
4
|
+
import computeSizing from "../../../style/utils/element-sizing";
|
|
5
|
+
const StyledTileContent = styled.div`
|
|
6
|
+
${({
|
|
7
|
+
isHorizontal,
|
|
8
|
+
isVertical,
|
|
9
|
+
width,
|
|
10
|
+
height
|
|
11
|
+
}) => css`
|
|
12
|
+
${space}
|
|
13
|
+
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
position: relative;
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
|
|
18
|
+
${isHorizontal && css`
|
|
19
|
+
display: inline;
|
|
20
|
+
|
|
21
|
+
:last-of-type {
|
|
22
|
+
padding-right: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:first-of-type {
|
|
26
|
+
padding-left: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
& + & {
|
|
30
|
+
margin-top: 0;
|
|
31
|
+
border-left: solid 1px var(--colorsUtilityMajor050);
|
|
32
|
+
}
|
|
33
|
+
`}
|
|
34
|
+
|
|
35
|
+
${isVertical && css`
|
|
36
|
+
width: auto;
|
|
37
|
+
|
|
38
|
+
:last-of-type {
|
|
39
|
+
padding-bottom: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:first-of-type {
|
|
43
|
+
padding-top: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
& + & {
|
|
47
|
+
margin-top: 0;
|
|
48
|
+
border-top: solid 1px var(--colorsUtilityMajor050);
|
|
49
|
+
}
|
|
50
|
+
`}
|
|
51
|
+
|
|
52
|
+
${(width || height) && css`
|
|
53
|
+
flex-grow: 0;
|
|
54
|
+
${computeSizing({
|
|
55
|
+
width: width || /* istanbul ignore next */undefined,
|
|
56
|
+
height: height || undefined
|
|
57
|
+
})}
|
|
58
|
+
`}
|
|
59
|
+
`}
|
|
60
|
+
`;
|
|
61
|
+
StyledTileContent.defaultProps = {
|
|
62
|
+
theme: baseTheme
|
|
63
|
+
};
|
|
64
|
+
export default StyledTileContent;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PaddingProps } from "styled-system";
|
|
3
|
-
|
|
3
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
4
|
+
export interface TileFooterProps extends PaddingProps, TagProps {
|
|
4
5
|
children?: React.ReactNode;
|
|
5
6
|
/** set which background color variant should be used */
|
|
6
7
|
variant?: "default" | "black" | "transparent";
|
|
7
8
|
}
|
|
8
|
-
export declare const TileFooter: ({ variant, children, ...
|
|
9
|
+
export declare const TileFooter: ({ variant, children, ...rest }: TileFooterProps) => React.JSX.Element;
|
|
9
10
|
export default TileFooter;
|
|
@@ -2,14 +2,13 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import StyledTileFooter from "./tile-footer.style";
|
|
5
|
+
import tagComponent from "../../../__internal__/utils/helpers/tags";
|
|
6
|
+
import filterStyledSystemPaddingProps from "../../../style/utils/filter-styled-system-padding-props";
|
|
5
7
|
export const TileFooter = ({
|
|
6
8
|
variant,
|
|
7
9
|
children,
|
|
8
|
-
...
|
|
9
|
-
}) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
variant: variant
|
|
13
|
-
}, props), children);
|
|
14
|
-
};
|
|
10
|
+
...rest
|
|
11
|
+
}) => /*#__PURE__*/React.createElement(StyledTileFooter, _extends({
|
|
12
|
+
variant: variant
|
|
13
|
+
}, filterStyledSystemPaddingProps(rest), tagComponent("tile-footer", rest)), children);
|
|
15
14
|
export default TileFooter;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
3
3
|
import { SpaceProps, WidthProps } from "styled-system";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
5
|
declare type DesignTokensType = keyof typeof DesignTokens;
|
|
5
|
-
export interface TileProps extends SpaceProps, WidthProps {
|
|
6
|
+
export interface TileProps extends SpaceProps, WidthProps, TagProps {
|
|
6
7
|
/** Sets the theme of the tile - either 'tile', 'transparent' or 'active' */
|
|
7
8
|
variant?: "tile" | "transparent" | "active";
|
|
8
9
|
/**
|
|
@@ -31,5 +32,5 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
31
32
|
*/
|
|
32
33
|
height?: string | number;
|
|
33
34
|
}
|
|
34
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...
|
|
35
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, ...rest }: TileProps) => React.JSX.Element;
|
|
35
36
|
export default Tile;
|
|
@@ -1,7 +1,12 @@
|
|
|
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
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import
|
|
4
|
+
import StyledTile from "./tile.style";
|
|
5
|
+
import TileContext from "./__internal__/tile-context";
|
|
6
|
+
import filterStyledSystemPaddingProps from "../../style/utils/filter-styled-system-padding-props";
|
|
7
|
+
import filterStyledSystemMarginProps from "../../style/utils/filter-styled-system-margin-props";
|
|
8
|
+
import computeContentPadding from "./__internal__/compute-content-padding";
|
|
9
|
+
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
5
10
|
export const Tile = ({
|
|
6
11
|
variant = "tile",
|
|
7
12
|
p = 3,
|
|
@@ -10,47 +15,31 @@ export const Tile = ({
|
|
|
10
15
|
width = "100%",
|
|
11
16
|
roundness = "default",
|
|
12
17
|
height,
|
|
13
|
-
|
|
18
|
+
borderWidth,
|
|
19
|
+
borderVariant,
|
|
20
|
+
...rest
|
|
14
21
|
}) => {
|
|
15
22
|
const isHorizontal = orientation === "horizontal";
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// istanbul ignore if
|
|
23
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
24
|
-
return child;
|
|
25
|
-
}
|
|
26
|
-
const {
|
|
27
|
-
width: contentWidth,
|
|
28
|
-
height: contentHeight,
|
|
29
|
-
...childProps
|
|
30
|
-
} = child.props;
|
|
31
|
-
const key = child.key || `tile-content-${index + 1}`;
|
|
32
|
-
return /*#__PURE__*/React.createElement(TileContent, _extends({
|
|
33
|
-
key: key,
|
|
34
|
-
width: contentWidth,
|
|
35
|
-
height: contentHeight,
|
|
36
|
-
isHorizontal: isHorizontal,
|
|
37
|
-
isVertical: isVertical
|
|
38
|
-
}, isVertical && {
|
|
39
|
-
pt: props.pt || props.py || p,
|
|
40
|
-
pb: props.pb || props.py || p
|
|
41
|
-
}, isHorizontal && {
|
|
42
|
-
pr: props.pr || props.px || p,
|
|
43
|
-
pl: props.pl || props.px || p
|
|
44
|
-
}), /*#__PURE__*/React.cloneElement(child, childProps));
|
|
23
|
+
const paddingProps = filterStyledSystemPaddingProps({
|
|
24
|
+
p,
|
|
25
|
+
...rest
|
|
45
26
|
});
|
|
27
|
+
const marginProps = filterStyledSystemMarginProps(rest);
|
|
28
|
+
const contentPaddingProps = computeContentPadding(paddingProps, isHorizontal);
|
|
46
29
|
return /*#__PURE__*/React.createElement(StyledTile, _extends({
|
|
47
30
|
variant: variant,
|
|
48
31
|
width: width,
|
|
49
32
|
height: height,
|
|
50
|
-
"data-component": "tile",
|
|
51
33
|
isHorizontal: isHorizontal,
|
|
52
34
|
p: p,
|
|
53
|
-
roundness: roundness
|
|
54
|
-
|
|
35
|
+
roundness: roundness,
|
|
36
|
+
borderWidth: borderWidth,
|
|
37
|
+
borderVariant: borderVariant
|
|
38
|
+
}, paddingProps, marginProps, tagComponent("tile", rest)), /*#__PURE__*/React.createElement(TileContext.Provider, {
|
|
39
|
+
value: {
|
|
40
|
+
isHorizontal,
|
|
41
|
+
paddingPropsFromTile: contentPaddingProps
|
|
42
|
+
}
|
|
43
|
+
}, children));
|
|
55
44
|
};
|
|
56
45
|
export default Tile;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { SpaceProps } from "styled-system";
|
|
2
2
|
import { TileProps } from "./tile.component";
|
|
3
|
-
interface TileContentProps {
|
|
4
|
-
isHorizontal?: boolean;
|
|
5
|
-
isVertical?: boolean;
|
|
6
|
-
width?: TileProps["width"];
|
|
7
|
-
height?: TileProps["height"];
|
|
8
|
-
}
|
|
9
|
-
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
10
3
|
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
11
4
|
isHorizontal?: boolean | undefined;
|
|
12
5
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
13
|
-
export
|
|
6
|
+
export default StyledTile;
|
|
@@ -18,62 +18,6 @@ const getBorderColor = borderVariant => {
|
|
|
18
18
|
return "var(--colorsUtilityMajor100)";
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
const TileContent = styled.div`
|
|
22
|
-
${({
|
|
23
|
-
isHorizontal,
|
|
24
|
-
isVertical,
|
|
25
|
-
width,
|
|
26
|
-
height
|
|
27
|
-
}) => css`
|
|
28
|
-
${space}
|
|
29
|
-
|
|
30
|
-
box-sizing: border-box;
|
|
31
|
-
position: relative;
|
|
32
|
-
flex-grow: 1;
|
|
33
|
-
|
|
34
|
-
${isHorizontal && css`
|
|
35
|
-
display: inline;
|
|
36
|
-
|
|
37
|
-
:last-of-type {
|
|
38
|
-
padding-right: 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:first-of-type {
|
|
42
|
-
padding-left: 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
& + & {
|
|
46
|
-
margin-top: 0;
|
|
47
|
-
border-left: solid 1px var(--colorsUtilityMajor050);
|
|
48
|
-
}
|
|
49
|
-
`}
|
|
50
|
-
|
|
51
|
-
${isVertical && css`
|
|
52
|
-
width: auto;
|
|
53
|
-
|
|
54
|
-
:last-of-type {
|
|
55
|
-
padding-bottom: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
:first-of-type {
|
|
59
|
-
padding-top: 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
& + & {
|
|
63
|
-
margin-top: 0;
|
|
64
|
-
border-top: solid 1px var(--colorsUtilityMajor050);
|
|
65
|
-
}
|
|
66
|
-
`}
|
|
67
|
-
|
|
68
|
-
${(width || height) && css`
|
|
69
|
-
flex-grow: 0;
|
|
70
|
-
${computeSizing({
|
|
71
|
-
width: width || /* istanbul ignore next */undefined,
|
|
72
|
-
height: height || undefined
|
|
73
|
-
})}
|
|
74
|
-
`}
|
|
75
|
-
`}
|
|
76
|
-
`;
|
|
77
21
|
const StyledTile = styled.div`
|
|
78
22
|
${({
|
|
79
23
|
borderVariant,
|
|
@@ -113,10 +57,7 @@ const StyledTile = styled.div`
|
|
|
113
57
|
})}
|
|
114
58
|
`}
|
|
115
59
|
`;
|
|
116
|
-
TileContent.defaultProps = {
|
|
117
|
-
theme: baseTheme
|
|
118
|
-
};
|
|
119
60
|
StyledTile.defaultProps = {
|
|
120
61
|
theme: baseTheme
|
|
121
62
|
};
|
|
122
|
-
export
|
|
63
|
+
export default StyledTile;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { PaddingProps } from "styled-system";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const paddingNames: (keyof PaddingProps)[];
|
|
3
|
+
export declare const paddingLeftPropertyNames: (keyof PaddingProps)[];
|
|
4
|
+
export declare const paddingRightPropertyNames: (keyof PaddingProps)[];
|
|
5
|
+
export declare const paddingXPropertyNames: (keyof PaddingProps)[];
|
|
6
|
+
export declare const paddingTopPropertyNames: (keyof PaddingProps)[];
|
|
7
|
+
export declare const paddingBottomPropertyNames: (keyof PaddingProps)[];
|
|
8
|
+
export declare const paddingYPropertyNames: (keyof PaddingProps)[];
|
|
9
|
+
export declare const paddingPropertyNames: (keyof PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>)[];
|
|
3
10
|
export default function filterStyledSystemPaddingProps(props: Record<string, unknown> | PaddingProps): PaddingProps;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import filterObjectProperties from "../../__internal__/filter-object-properties";
|
|
2
|
-
export const
|
|
2
|
+
export const paddingNames = ["p", "padding"];
|
|
3
|
+
export const paddingLeftPropertyNames = ["pl", "paddingLeft"];
|
|
4
|
+
export const paddingRightPropertyNames = ["pr", "paddingRight"];
|
|
5
|
+
export const paddingXPropertyNames = ["px", "paddingX"];
|
|
6
|
+
const paddingHorizontalPropertyNames = [...paddingLeftPropertyNames, ...paddingRightPropertyNames, ...paddingXPropertyNames];
|
|
7
|
+
export const paddingTopPropertyNames = ["pt", "paddingTop"];
|
|
8
|
+
export const paddingBottomPropertyNames = ["pb", "paddingBottom"];
|
|
9
|
+
export const paddingYPropertyNames = ["py", "paddingY"];
|
|
10
|
+
const paddingVerticalPropertyNames = [...paddingTopPropertyNames, ...paddingBottomPropertyNames, ...paddingYPropertyNames];
|
|
11
|
+
export const paddingPropertyNames = [...paddingNames, ...paddingHorizontalPropertyNames, ...paddingVerticalPropertyNames];
|
|
3
12
|
export default function filterStyledSystemPaddingProps(props) {
|
|
4
13
|
return filterObjectProperties(props, paddingPropertyNames);
|
|
5
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { elementsTagTest, rootTagTest } from "./tags-specs";
|
|
1
|
+
export { elementsTagTest, rootTagTest, rootTagTestRtl } from "./tags-specs";
|
|
@@ -15,4 +15,10 @@ Object.defineProperty(exports, "rootTagTest", {
|
|
|
15
15
|
return _tagsSpecs.rootTagTest;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "rootTagTestRtl", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _tagsSpecs.rootTagTestRtl;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
var _tagsSpecs = require("./tags-specs");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactWrapper, ShallowWrapper } from "enzyme";
|
|
2
2
|
declare const elementsTagTest: (wrapper: ReactWrapper | ShallowWrapper, elements: string[]) => void;
|
|
3
3
|
declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
|
|
4
|
-
|
|
4
|
+
declare const rootTagTestRtl: (element: HTMLElement, comp: string, elem?: string, role?: string) => void;
|
|
5
|
+
export { elementsTagTest, rootTagTest, rootTagTestRtl };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.rootTagTest = exports.elementsTagTest = void 0;
|
|
6
|
+
exports.rootTagTestRtl = exports.rootTagTest = exports.elementsTagTest = void 0;
|
|
7
7
|
const elementsTagTest = (wrapper, elements) => {
|
|
8
8
|
elements.forEach(element => {
|
|
9
9
|
it(`include 'data-element="${element}"'`, () => {
|
|
@@ -19,6 +19,10 @@ const rootTagTest = (rootNode, comp, elem, role) => {
|
|
|
19
19
|
expect(rootNode.prop("data-element")).toEqual(elem);
|
|
20
20
|
expect(rootNode.prop("data-role")).toEqual(role);
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
exports.rootTagTest = rootTagTest;
|
|
23
|
+
const rootTagTestRtl = (element, comp, elem, role) => {
|
|
24
|
+
expect(element.getAttribute("data-component")).toBe(comp);
|
|
25
|
+
expect(element.getAttribute("data-element")).toBe(elem);
|
|
26
|
+
expect(element.getAttribute("data-role")).toBe(role);
|
|
27
|
+
};
|
|
28
|
+
exports.rootTagTestRtl = rootTagTestRtl;
|