carbon-react 120.4.0 → 120.5.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/__spec_helper__/test-utils.d.ts +4 -1
- package/esm/__spec_helper__/test-utils.js +18 -2
- package/esm/components/multi-action-button/multi-action-button.style.js +2 -2
- package/esm/components/sidebar/sidebar.style.js +2 -2
- package/esm/components/tile/tile.component.d.ts +5 -1
- package/esm/components/tile/tile.component.js +5 -1
- package/esm/components/tile/tile.style.d.ts +3 -2
- package/esm/components/tile/tile.style.js +12 -12
- package/esm/style/utils/element-sizing.d.ts +6 -0
- package/esm/style/utils/{width.js → element-sizing.js} +5 -4
- package/lib/__spec_helper__/test-utils.d.ts +4 -1
- package/lib/__spec_helper__/test-utils.js +19 -2
- package/lib/components/multi-action-button/multi-action-button.style.js +2 -2
- package/lib/components/sidebar/sidebar.style.js +2 -2
- package/lib/components/tile/tile.component.d.ts +5 -1
- package/lib/components/tile/tile.component.js +5 -1
- package/lib/components/tile/tile.style.d.ts +3 -2
- package/lib/components/tile/tile.style.js +12 -12
- package/lib/style/utils/element-sizing.d.ts +6 -0
- package/lib/style/utils/{width.js → element-sizing.js} +5 -4
- package/package.json +1 -1
- package/esm/style/utils/width.d.ts +0 -3
- package/lib/style/utils/width.d.ts +0 -3
|
@@ -44,10 +44,13 @@ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.
|
|
|
44
44
|
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
45
45
|
width: string;
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
|
+
declare const testStyledSystemHeight: (component: (heightProperties?: {
|
|
48
|
+
height: string;
|
|
49
|
+
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
50
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
51
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
52
|
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
53
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
54
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
52
55
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
53
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
56
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -83,7 +83,8 @@ const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"
|
|
|
83
83
|
const paddingProps = [["p", "padding"], ["pl", "paddingLeft"], ["pr", "paddingRight"], ["pt", "paddingTop"], ["pb", "paddingBottom"], ["px", "paddingLeft"], ["px", "paddingRight"], ["py", "paddingTop"], ["py", "paddingBottom"]];
|
|
84
84
|
const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#FFFFFF"], ["opacity", "opacity", "0.5"]];
|
|
85
85
|
const widthProps = ["width", "width", "200px"];
|
|
86
|
-
const
|
|
86
|
+
const heightProps = ["height", "height", "200px"];
|
|
87
|
+
const layoutProps = [widthProps, heightProps, ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
87
88
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
88
89
|
const gridProps = [["gridColumn", "gridColumn", "1 / span 2"], ["gridRow", "gridRow", "1 / span 2"], ["gridArea", "gridArea", "myArea"], ["gridAutoFlow", "gridAutoFlow", "column"], ["gridAutoRows", "gridAutoRows", "150px"], ["gridAutoColumns", "gridAutoColumns", "50px"], ["gridTemplateRows", "gridTemplateRows", "100px 300px"], ["gridTemplateColumns", "gridTemplateColumns", "auto auto auto auto"], ["gridTemplateAreas", "gridTemplateAreas", "myArea myArea . . ."]];
|
|
89
90
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
@@ -241,6 +242,21 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
241
242
|
});
|
|
242
243
|
});
|
|
243
244
|
};
|
|
245
|
+
const testStyledSystemHeight = (component, styleContainer) => {
|
|
246
|
+
describe("when a height prop is specified using styled system props", () => {
|
|
247
|
+
it("then height should have been set correctly", () => {
|
|
248
|
+
const [styledSystemProp, propName, value] = heightProps;
|
|
249
|
+
const props = {
|
|
250
|
+
[styledSystemProp]: value
|
|
251
|
+
};
|
|
252
|
+
const wrapper = mount(component({
|
|
253
|
+
...props
|
|
254
|
+
}));
|
|
255
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
256
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
};
|
|
244
260
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
245
261
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
246
262
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -339,4 +355,4 @@ const expectConsoleOutput = (message, type = "error") => {
|
|
|
339
355
|
global.console[type] = consoleType;
|
|
340
356
|
};
|
|
341
357
|
};
|
|
342
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput };
|
|
358
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput };
|
|
@@ -3,7 +3,7 @@ import { margin } from "styled-system";
|
|
|
3
3
|
import StyledButton from "../button/button.style";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
5
|
import StyledIcon from "../icon/icon.style";
|
|
6
|
-
import
|
|
6
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
7
7
|
import { borderRadiusStyling } from "../split-button/split-button-children.style";
|
|
8
8
|
const StyledMultiActionButton = styled.div`
|
|
9
9
|
${margin}
|
|
@@ -14,7 +14,7 @@ const StyledMultiActionButton = styled.div`
|
|
|
14
14
|
${({
|
|
15
15
|
width
|
|
16
16
|
}) => width && css`
|
|
17
|
-
${
|
|
17
|
+
${computeSizing({
|
|
18
18
|
width
|
|
19
19
|
})}
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import
|
|
2
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
4
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
5
5
|
import { calculateFormSpacingValues, calculateWidthValue } from "../../style/utils/form-style-utils";
|
|
@@ -39,7 +39,7 @@ const StyledSidebar = styled.div`
|
|
|
39
39
|
${!width && size && css`
|
|
40
40
|
width: ${SIDEBAR_SIZES_CSS[size]};
|
|
41
41
|
`}
|
|
42
|
-
${width &&
|
|
42
|
+
${width && computeSizing({
|
|
43
43
|
width
|
|
44
44
|
})}
|
|
45
45
|
|
|
@@ -26,6 +26,10 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
26
26
|
borderVariant?: "default" | "selected" | "positive" | "negative" | "caution" | "info";
|
|
27
27
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
28
|
roundness?: "default" | "large";
|
|
29
|
+
/**
|
|
30
|
+
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
height?: string | number;
|
|
29
33
|
}
|
|
30
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, ...props }: TileProps) => React.JSX.Element;
|
|
34
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...props }: TileProps) => React.JSX.Element;
|
|
31
35
|
export default Tile;
|
|
@@ -7,8 +7,9 @@ export const Tile = ({
|
|
|
7
7
|
p = 3,
|
|
8
8
|
children,
|
|
9
9
|
orientation = "horizontal",
|
|
10
|
-
width,
|
|
10
|
+
width = "100%",
|
|
11
11
|
roundness = "default",
|
|
12
|
+
height,
|
|
12
13
|
...props
|
|
13
14
|
}) => {
|
|
14
15
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -24,12 +25,14 @@ export const Tile = ({
|
|
|
24
25
|
}
|
|
25
26
|
const {
|
|
26
27
|
width: contentWidth,
|
|
28
|
+
height: contentHeight,
|
|
27
29
|
...childProps
|
|
28
30
|
} = child.props;
|
|
29
31
|
const key = child.key || `tile-content-${index + 1}`;
|
|
30
32
|
return /*#__PURE__*/React.createElement(TileContent, _extends({
|
|
31
33
|
key: key,
|
|
32
34
|
width: contentWidth,
|
|
35
|
+
height: contentHeight,
|
|
33
36
|
isHorizontal: isHorizontal,
|
|
34
37
|
isVertical: isVertical
|
|
35
38
|
}, isVertical && {
|
|
@@ -43,6 +46,7 @@ export const Tile = ({
|
|
|
43
46
|
return /*#__PURE__*/React.createElement(StyledTile, _extends({
|
|
44
47
|
variant: variant,
|
|
45
48
|
width: width,
|
|
49
|
+
height: height,
|
|
46
50
|
"data-component": "tile",
|
|
47
51
|
isHorizontal: isHorizontal,
|
|
48
52
|
p: p,
|
|
@@ -3,10 +3,11 @@ import { TileProps } from "./tile.component";
|
|
|
3
3
|
interface TileContentProps {
|
|
4
4
|
isHorizontal?: boolean;
|
|
5
5
|
isVertical?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: TileProps["width"];
|
|
7
|
+
height?: TileProps["height"];
|
|
7
8
|
}
|
|
8
9
|
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
9
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
11
|
isHorizontal?: boolean | undefined;
|
|
11
12
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
12
13
|
export { StyledTile, TileContent };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { space } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
|
-
import
|
|
4
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
5
5
|
const getBorderColor = borderVariant => {
|
|
6
6
|
switch (borderVariant) {
|
|
7
7
|
case "selected":
|
|
@@ -22,7 +22,8 @@ const TileContent = styled.div`
|
|
|
22
22
|
${({
|
|
23
23
|
isHorizontal,
|
|
24
24
|
isVertical,
|
|
25
|
-
width
|
|
25
|
+
width,
|
|
26
|
+
height
|
|
26
27
|
}) => css`
|
|
27
28
|
${space}
|
|
28
29
|
|
|
@@ -64,10 +65,11 @@ const TileContent = styled.div`
|
|
|
64
65
|
}
|
|
65
66
|
`}
|
|
66
67
|
|
|
67
|
-
${width && css`
|
|
68
|
+
${(width || height) && css`
|
|
68
69
|
flex-grow: 0;
|
|
69
|
-
${
|
|
70
|
-
width
|
|
70
|
+
${computeSizing({
|
|
71
|
+
width: width || /* istanbul ignore next */undefined,
|
|
72
|
+
height: height || undefined
|
|
71
73
|
})}
|
|
72
74
|
`}
|
|
73
75
|
`}
|
|
@@ -79,7 +81,8 @@ const StyledTile = styled.div`
|
|
|
79
81
|
isHorizontal,
|
|
80
82
|
variant,
|
|
81
83
|
width,
|
|
82
|
-
roundness
|
|
84
|
+
roundness,
|
|
85
|
+
height
|
|
83
86
|
}) => css`
|
|
84
87
|
${space}
|
|
85
88
|
|
|
@@ -104,13 +107,10 @@ const StyledTile = styled.div`
|
|
|
104
107
|
display: flex;
|
|
105
108
|
flex-direction: ${isHorizontal ? "row" : "column"};
|
|
106
109
|
position: relative;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
${computeWidth({
|
|
111
|
-
width
|
|
110
|
+
${computeSizing({
|
|
111
|
+
width: width || /* istanbul ignore next */undefined,
|
|
112
|
+
height: height || undefined
|
|
112
113
|
})}
|
|
113
|
-
`}
|
|
114
114
|
`}
|
|
115
115
|
`;
|
|
116
116
|
TileContent.defaultProps = {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// eslint-disable-next-line no-restricted-imports
|
|
2
1
|
import { layout } from "styled-system";
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
* styled-system/layout allows users to use a width, height, minWidth, maxWidth, minHeight, maxHeight,
|
|
6
5
|
* size, display, verticalAlign, overflow, overflowX and overflowY props most of which are usually not needed.
|
|
7
|
-
* That's why the purpose of this function is to pass only the`width`
|
|
6
|
+
* That's why the purpose of this function is to pass only the `width` and `height` props to the `layout` function.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
export default (({
|
|
11
|
-
width
|
|
10
|
+
width,
|
|
11
|
+
height
|
|
12
12
|
}) => layout({
|
|
13
|
-
width
|
|
13
|
+
width,
|
|
14
|
+
height
|
|
14
15
|
}));
|
|
@@ -44,10 +44,13 @@ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.
|
|
|
44
44
|
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
45
45
|
width: string;
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
|
+
declare const testStyledSystemHeight: (component: (heightProperties?: {
|
|
48
|
+
height: string;
|
|
49
|
+
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
50
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
51
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
52
|
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
53
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
54
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
52
55
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
53
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
56
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "mockMatchMedia", {
|
|
|
10
10
|
return _mockMatchMedia.mockMatchMedia;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.toCSSCase = exports.testStyledSystemWidth = exports.testStyledSystemSpacing = exports.testStyledSystemPosition = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemLayout = exports.testStyledSystemGrid = exports.testStyledSystemFlexBox = exports.testStyledSystemColor = exports.testStyledSystemBackground = exports.simulate = exports.selectedItemOf = void 0;
|
|
13
|
+
exports.toCSSCase = exports.testStyledSystemWidth = exports.testStyledSystemSpacing = exports.testStyledSystemPosition = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemLayout = exports.testStyledSystemHeight = exports.testStyledSystemGrid = exports.testStyledSystemFlexBox = exports.testStyledSystemColor = exports.testStyledSystemBackground = exports.simulate = exports.selectedItemOf = void 0;
|
|
14
14
|
var _enzyme = require("enzyme");
|
|
15
15
|
var _sprintfJs = require("sprintf-js");
|
|
16
16
|
var _baseTheme = require("../style/themes/base/base-theme.config");
|
|
@@ -110,7 +110,8 @@ const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"
|
|
|
110
110
|
const paddingProps = [["p", "padding"], ["pl", "paddingLeft"], ["pr", "paddingRight"], ["pt", "paddingTop"], ["pb", "paddingBottom"], ["px", "paddingLeft"], ["px", "paddingRight"], ["py", "paddingTop"], ["py", "paddingBottom"]];
|
|
111
111
|
const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#FFFFFF"], ["opacity", "opacity", "0.5"]];
|
|
112
112
|
const widthProps = ["width", "width", "200px"];
|
|
113
|
-
const
|
|
113
|
+
const heightProps = ["height", "height", "200px"];
|
|
114
|
+
const layoutProps = [widthProps, heightProps, ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
114
115
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
115
116
|
const gridProps = [["gridColumn", "gridColumn", "1 / span 2"], ["gridRow", "gridRow", "1 / span 2"], ["gridArea", "gridArea", "myArea"], ["gridAutoFlow", "gridAutoFlow", "column"], ["gridAutoRows", "gridAutoRows", "150px"], ["gridAutoColumns", "gridAutoColumns", "50px"], ["gridTemplateRows", "gridTemplateRows", "100px 300px"], ["gridTemplateColumns", "gridTemplateColumns", "auto auto auto auto"], ["gridTemplateAreas", "gridTemplateAreas", "myArea myArea . . ."]];
|
|
116
117
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
@@ -274,6 +275,22 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
274
275
|
});
|
|
275
276
|
};
|
|
276
277
|
exports.testStyledSystemWidth = testStyledSystemWidth;
|
|
278
|
+
const testStyledSystemHeight = (component, styleContainer) => {
|
|
279
|
+
describe("when a height prop is specified using styled system props", () => {
|
|
280
|
+
it("then height should have been set correctly", () => {
|
|
281
|
+
const [styledSystemProp, propName, value] = heightProps;
|
|
282
|
+
const props = {
|
|
283
|
+
[styledSystemProp]: value
|
|
284
|
+
};
|
|
285
|
+
const wrapper = (0, _enzyme.mount)(component({
|
|
286
|
+
...props
|
|
287
|
+
}));
|
|
288
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
289
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
exports.testStyledSystemHeight = testStyledSystemHeight;
|
|
277
294
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
278
295
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
279
296
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -9,7 +9,7 @@ var _styledSystem = require("styled-system");
|
|
|
9
9
|
var _button = _interopRequireDefault(require("../button/button.style"));
|
|
10
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
11
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
12
|
-
var
|
|
12
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
13
13
|
var _splitButtonChildren = require("../split-button/split-button-children.style");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -23,7 +23,7 @@ const StyledMultiActionButton = _styledComponents.default.div`
|
|
|
23
23
|
${({
|
|
24
24
|
width
|
|
25
25
|
}) => width && (0, _styledComponents.css)`
|
|
26
|
-
${(0,
|
|
26
|
+
${(0, _elementSizing.default)({
|
|
27
27
|
width
|
|
28
28
|
})}
|
|
29
29
|
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var
|
|
8
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
10
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
11
11
|
var _formStyleUtils = require("../../style/utils/form-style-utils");
|
|
@@ -48,7 +48,7 @@ const StyledSidebar = _styledComponents.default.div`
|
|
|
48
48
|
${!width && size && (0, _styledComponents.css)`
|
|
49
49
|
width: ${_sidebar.SIDEBAR_SIZES_CSS[size]};
|
|
50
50
|
`}
|
|
51
|
-
${width && (0,
|
|
51
|
+
${width && (0, _elementSizing.default)({
|
|
52
52
|
width
|
|
53
53
|
})}
|
|
54
54
|
|
|
@@ -26,6 +26,10 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
26
26
|
borderVariant?: "default" | "selected" | "positive" | "negative" | "caution" | "info";
|
|
27
27
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
28
|
roundness?: "default" | "large";
|
|
29
|
+
/**
|
|
30
|
+
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
height?: string | number;
|
|
29
33
|
}
|
|
30
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, ...props }: TileProps) => React.JSX.Element;
|
|
34
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...props }: TileProps) => React.JSX.Element;
|
|
31
35
|
export default Tile;
|
|
@@ -14,8 +14,9 @@ const Tile = ({
|
|
|
14
14
|
p = 3,
|
|
15
15
|
children,
|
|
16
16
|
orientation = "horizontal",
|
|
17
|
-
width,
|
|
17
|
+
width = "100%",
|
|
18
18
|
roundness = "default",
|
|
19
|
+
height,
|
|
19
20
|
...props
|
|
20
21
|
}) => {
|
|
21
22
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -31,12 +32,14 @@ const Tile = ({
|
|
|
31
32
|
}
|
|
32
33
|
const {
|
|
33
34
|
width: contentWidth,
|
|
35
|
+
height: contentHeight,
|
|
34
36
|
...childProps
|
|
35
37
|
} = child.props;
|
|
36
38
|
const key = child.key || `tile-content-${index + 1}`;
|
|
37
39
|
return /*#__PURE__*/_react.default.createElement(_tile.TileContent, _extends({
|
|
38
40
|
key: key,
|
|
39
41
|
width: contentWidth,
|
|
42
|
+
height: contentHeight,
|
|
40
43
|
isHorizontal: isHorizontal,
|
|
41
44
|
isVertical: isVertical
|
|
42
45
|
}, isVertical && {
|
|
@@ -50,6 +53,7 @@ const Tile = ({
|
|
|
50
53
|
return /*#__PURE__*/_react.default.createElement(_tile.StyledTile, _extends({
|
|
51
54
|
variant: variant,
|
|
52
55
|
width: width,
|
|
56
|
+
height: height,
|
|
53
57
|
"data-component": "tile",
|
|
54
58
|
isHorizontal: isHorizontal,
|
|
55
59
|
p: p,
|
|
@@ -3,10 +3,11 @@ import { TileProps } from "./tile.component";
|
|
|
3
3
|
interface TileContentProps {
|
|
4
4
|
isHorizontal?: boolean;
|
|
5
5
|
isVertical?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: TileProps["width"];
|
|
7
|
+
height?: TileProps["height"];
|
|
7
8
|
}
|
|
8
9
|
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
9
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
11
|
isHorizontal?: boolean | undefined;
|
|
11
12
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
12
13
|
export { StyledTile, TileContent };
|
|
@@ -7,7 +7,7 @@ exports.TileContent = exports.StyledTile = void 0;
|
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
|
-
var
|
|
10
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -31,7 +31,8 @@ const TileContent = _styledComponents.default.div`
|
|
|
31
31
|
${({
|
|
32
32
|
isHorizontal,
|
|
33
33
|
isVertical,
|
|
34
|
-
width
|
|
34
|
+
width,
|
|
35
|
+
height
|
|
35
36
|
}) => (0, _styledComponents.css)`
|
|
36
37
|
${_styledSystem.space}
|
|
37
38
|
|
|
@@ -73,10 +74,11 @@ const TileContent = _styledComponents.default.div`
|
|
|
73
74
|
}
|
|
74
75
|
`}
|
|
75
76
|
|
|
76
|
-
${width && (0, _styledComponents.css)`
|
|
77
|
+
${(width || height) && (0, _styledComponents.css)`
|
|
77
78
|
flex-grow: 0;
|
|
78
|
-
${(0,
|
|
79
|
-
width
|
|
79
|
+
${(0, _elementSizing.default)({
|
|
80
|
+
width: width || /* istanbul ignore next */undefined,
|
|
81
|
+
height: height || undefined
|
|
80
82
|
})}
|
|
81
83
|
`}
|
|
82
84
|
`}
|
|
@@ -89,7 +91,8 @@ const StyledTile = _styledComponents.default.div`
|
|
|
89
91
|
isHorizontal,
|
|
90
92
|
variant,
|
|
91
93
|
width,
|
|
92
|
-
roundness
|
|
94
|
+
roundness,
|
|
95
|
+
height
|
|
93
96
|
}) => (0, _styledComponents.css)`
|
|
94
97
|
${_styledSystem.space}
|
|
95
98
|
|
|
@@ -114,13 +117,10 @@ const StyledTile = _styledComponents.default.div`
|
|
|
114
117
|
display: flex;
|
|
115
118
|
flex-direction: ${isHorizontal ? "row" : "column"};
|
|
116
119
|
position: relative;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
${(0, _width.default)({
|
|
121
|
-
width
|
|
120
|
+
${(0, _elementSizing.default)({
|
|
121
|
+
width: width || /* istanbul ignore next */undefined,
|
|
122
|
+
height: height || undefined
|
|
122
123
|
})}
|
|
123
|
-
`}
|
|
124
124
|
`}
|
|
125
125
|
`;
|
|
126
126
|
exports.StyledTile = StyledTile;
|
|
@@ -5,15 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledSystem = require("styled-system");
|
|
8
|
-
// eslint-disable-next-line no-restricted-imports
|
|
9
8
|
/*
|
|
10
9
|
* styled-system/layout allows users to use a width, height, minWidth, maxWidth, minHeight, maxHeight,
|
|
11
10
|
* size, display, verticalAlign, overflow, overflowX and overflowY props most of which are usually not needed.
|
|
12
|
-
* That's why the purpose of this function is to pass only the`width`
|
|
11
|
+
* That's why the purpose of this function is to pass only the `width` and `height` props to the `layout` function.
|
|
13
12
|
*/
|
|
14
13
|
var _default = ({
|
|
15
|
-
width
|
|
14
|
+
width,
|
|
15
|
+
height
|
|
16
16
|
}) => (0, _styledSystem.layout)({
|
|
17
|
-
width
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
18
19
|
});
|
|
19
20
|
exports.default = _default;
|
package/package.json
CHANGED