carbon-react 119.12.2 → 120.1.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/__internal__/input/input-presentation.style.d.ts +1 -1
- package/esm/__spec_helper__/test-utils.d.ts +3 -2
- package/esm/__spec_helper__/test-utils.js +15 -1
- package/esm/components/box/box.component.d.ts +23 -6
- package/esm/components/box/box.component.js +3570 -103
- package/esm/components/box/box.style.d.ts +3 -0
- package/esm/components/box/box.style.js +112 -0
- package/esm/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/esm/components/drawer/drawer.style.d.ts +2 -1
- package/esm/components/duelling-picklist/picklist/picklist.style.js +4 -2
- package/esm/components/flat-table/__internal__/build-position-map.d.ts +2 -0
- package/esm/components/flat-table/__internal__/build-position-map.js +14 -0
- package/esm/components/flat-table/__internal__/index.d.ts +2 -0
- package/esm/components/flat-table/__internal__/index.js +2 -0
- package/esm/components/flat-table/__internal__/use-calculate-sticky-cells.d.ts +12 -0
- package/esm/components/flat-table/__internal__/use-calculate-sticky-cells.js +28 -0
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +2 -41
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +26 -25
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +7 -2
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +3 -25
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +21 -14
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +3 -1
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +4 -0
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +21 -24
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.d.ts +2 -26
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +15 -13
- package/esm/components/flat-table/flat-table-header/flat-table-header.style.d.ts +3 -1
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +12 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.js +6 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +3 -1
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +17 -3
- package/esm/components/flat-table/flat-table-row/__internal__/sub-row-provider.d.ts +15 -0
- package/esm/components/flat-table/flat-table-row/__internal__/sub-row-provider.js +28 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +1 -15
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +85 -74
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.d.ts +4 -1
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +1 -9
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +4 -42
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +33 -20
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +7 -1
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +5 -1
- package/esm/components/flat-table/flat-table.component.js +24 -7
- package/esm/components/flat-table/flat-table.style.js +2 -2
- package/esm/components/heading/heading.style.d.ts +4 -9
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +2 -2
- package/esm/components/menu/scrollable-block/scrollable-block.style.js +2 -2
- package/esm/components/typography/typography.component.d.ts +25 -15
- package/esm/components/typography/typography.component.js +37 -184
- package/esm/components/typography/typography.style.d.ts +12 -0
- package/esm/components/typography/typography.style.js +190 -0
- package/esm/components/vertical-menu/vertical-menu.style.js +3 -3
- package/esm/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-flexbox-props.js +5 -0
- package/esm/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-grid-props.js +5 -0
- package/esm/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-layout-props.js +5 -0
- package/esm/style/utils/index.d.ts +4 -1
- package/esm/style/utils/index.js +4 -1
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
- package/lib/__spec_helper__/test-utils.d.ts +3 -2
- package/lib/__spec_helper__/test-utils.js +16 -1
- package/lib/components/box/box.component.d.ts +23 -6
- package/lib/components/box/box.component.js +3569 -105
- package/lib/components/box/box.style.d.ts +3 -0
- package/lib/components/box/box.style.js +122 -0
- package/lib/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/lib/components/drawer/drawer.style.d.ts +2 -1
- package/lib/components/duelling-picklist/picklist/picklist.style.js +2 -1
- package/lib/components/flat-table/__internal__/build-position-map.d.ts +2 -0
- package/lib/components/flat-table/__internal__/build-position-map.js +21 -0
- package/lib/components/flat-table/__internal__/index.d.ts +2 -0
- package/lib/components/flat-table/__internal__/index.js +20 -0
- package/lib/components/flat-table/__internal__/package.json +6 -0
- package/lib/components/flat-table/__internal__/use-calculate-sticky-cells.d.ts +12 -0
- package/lib/components/flat-table/__internal__/use-calculate-sticky-cells.js +36 -0
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +2 -41
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +25 -24
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +7 -2
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +3 -25
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +20 -13
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +3 -1
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +4 -0
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +23 -25
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.d.ts +2 -26
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +14 -12
- package/lib/components/flat-table/flat-table-header/flat-table-header.style.d.ts +3 -1
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +12 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.js +13 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +3 -1
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +17 -3
- package/lib/components/flat-table/flat-table-row/__internal__/sub-row-provider.d.ts +15 -0
- package/lib/components/flat-table/flat-table-row/__internal__/sub-row-provider.js +38 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +1 -15
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +84 -73
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.d.ts +4 -1
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +1 -9
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +4 -42
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +32 -19
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +7 -1
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +5 -1
- package/lib/components/flat-table/flat-table.component.js +24 -7
- package/lib/components/flat-table/flat-table.style.js +1 -1
- package/lib/components/heading/heading.style.d.ts +4 -9
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +1 -1
- package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
- package/lib/components/typography/typography.component.d.ts +25 -15
- package/lib/components/typography/typography.component.js +39 -187
- package/lib/components/typography/typography.style.d.ts +12 -0
- package/lib/components/typography/typography.style.js +200 -0
- package/lib/components/vertical-menu/vertical-menu.style.js +1 -1
- package/lib/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-flexbox-props.js +14 -0
- package/lib/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-grid-props.js +14 -0
- package/lib/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-layout-props.js +14 -0
- package/lib/style/utils/index.d.ts +4 -1
- package/lib/style/utils/index.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { space } from "styled-system";
|
|
3
|
+
import styledColor from "../../style/utils/color";
|
|
4
|
+
import baseTheme from "../../style/themes/base";
|
|
5
|
+
const getAs = variant => {
|
|
6
|
+
switch (variant) {
|
|
7
|
+
case "h1-large":
|
|
8
|
+
return "h1";
|
|
9
|
+
case "segment-header":
|
|
10
|
+
case "segment-header-small":
|
|
11
|
+
case "segment-subheader":
|
|
12
|
+
case "segment-subheader-alt":
|
|
13
|
+
return "h5";
|
|
14
|
+
case "big":
|
|
15
|
+
return "p";
|
|
16
|
+
default:
|
|
17
|
+
return variant;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const getSize = variant => {
|
|
21
|
+
switch (variant) {
|
|
22
|
+
case "h1-large":
|
|
23
|
+
return "32px";
|
|
24
|
+
case "h1":
|
|
25
|
+
return "24px";
|
|
26
|
+
case "h2":
|
|
27
|
+
return "22px";
|
|
28
|
+
case "h3":
|
|
29
|
+
case "segment-header":
|
|
30
|
+
return "20px";
|
|
31
|
+
case "h4":
|
|
32
|
+
case "segment-header-small":
|
|
33
|
+
return "18px";
|
|
34
|
+
case "h5":
|
|
35
|
+
case "segment-subheader":
|
|
36
|
+
case "big":
|
|
37
|
+
return "16px";
|
|
38
|
+
case "small":
|
|
39
|
+
case "sub":
|
|
40
|
+
case "sup":
|
|
41
|
+
return "13px";
|
|
42
|
+
case "segment-subheader-alt":
|
|
43
|
+
case "p":
|
|
44
|
+
case "b":
|
|
45
|
+
case "strong":
|
|
46
|
+
case "em":
|
|
47
|
+
default:
|
|
48
|
+
return "14px";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const getLineHeight = variant => {
|
|
52
|
+
switch (variant) {
|
|
53
|
+
case "h1-large":
|
|
54
|
+
return "40px";
|
|
55
|
+
case "h1":
|
|
56
|
+
case "segment-subheader":
|
|
57
|
+
return "31px";
|
|
58
|
+
case "h2":
|
|
59
|
+
return "29px";
|
|
60
|
+
case "h3":
|
|
61
|
+
case "segment-header":
|
|
62
|
+
return "26px";
|
|
63
|
+
case "big":
|
|
64
|
+
return "24px";
|
|
65
|
+
case "h4":
|
|
66
|
+
case "segment-header-small":
|
|
67
|
+
return "23px";
|
|
68
|
+
case "small":
|
|
69
|
+
case "sub":
|
|
70
|
+
case "sup":
|
|
71
|
+
return "20px";
|
|
72
|
+
case "h5":
|
|
73
|
+
case "segment-subheader-alt":
|
|
74
|
+
case "p":
|
|
75
|
+
case "b":
|
|
76
|
+
case "strong":
|
|
77
|
+
case "em":
|
|
78
|
+
default:
|
|
79
|
+
return "21px";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const getWeight = variant => {
|
|
83
|
+
switch (variant) {
|
|
84
|
+
case "h1-large":
|
|
85
|
+
case "h1":
|
|
86
|
+
case "segment-header":
|
|
87
|
+
case "segment-header-small":
|
|
88
|
+
return "900";
|
|
89
|
+
case "h2":
|
|
90
|
+
case "h3":
|
|
91
|
+
case "segment-subheader":
|
|
92
|
+
case "segment-subheader-alt":
|
|
93
|
+
case "b":
|
|
94
|
+
case "em":
|
|
95
|
+
case "strong":
|
|
96
|
+
return "700";
|
|
97
|
+
case "h4":
|
|
98
|
+
case "h5":
|
|
99
|
+
case "p":
|
|
100
|
+
case "small":
|
|
101
|
+
case "big":
|
|
102
|
+
case "sub":
|
|
103
|
+
case "sup":
|
|
104
|
+
default:
|
|
105
|
+
return "400";
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const getTransform = variant => {
|
|
109
|
+
if (variant === "segment-subheader-alt") {
|
|
110
|
+
return "uppercase";
|
|
111
|
+
}
|
|
112
|
+
return "none";
|
|
113
|
+
};
|
|
114
|
+
const getDecoration = variant => {
|
|
115
|
+
if (variant === "em") {
|
|
116
|
+
return "underline";
|
|
117
|
+
}
|
|
118
|
+
return "none";
|
|
119
|
+
};
|
|
120
|
+
const StyledTypography = styled.span.attrs(({
|
|
121
|
+
variant,
|
|
122
|
+
as,
|
|
123
|
+
fontSize,
|
|
124
|
+
fontWeight,
|
|
125
|
+
textTransform,
|
|
126
|
+
lineHeight,
|
|
127
|
+
textDecoration
|
|
128
|
+
}) => {
|
|
129
|
+
return {
|
|
130
|
+
as: as || getAs(variant),
|
|
131
|
+
size: fontSize || getSize(variant),
|
|
132
|
+
weight: fontWeight || getWeight(variant),
|
|
133
|
+
textTransform: textTransform || getTransform(variant),
|
|
134
|
+
textDecoration: textDecoration || getDecoration(variant),
|
|
135
|
+
lineHeight: lineHeight || getLineHeight(variant),
|
|
136
|
+
defaultMargin: variant === "p" ? "0 0 16px" : "0"
|
|
137
|
+
};
|
|
138
|
+
})`
|
|
139
|
+
${({
|
|
140
|
+
size,
|
|
141
|
+
weight,
|
|
142
|
+
textTransform,
|
|
143
|
+
lineHeight,
|
|
144
|
+
defaultMargin,
|
|
145
|
+
textDecoration,
|
|
146
|
+
display,
|
|
147
|
+
variant,
|
|
148
|
+
listStyleType,
|
|
149
|
+
whiteSpace,
|
|
150
|
+
wordWrap,
|
|
151
|
+
textOverflow,
|
|
152
|
+
truncate
|
|
153
|
+
}) => css`
|
|
154
|
+
font-style: normal;
|
|
155
|
+
font-size: ${size};
|
|
156
|
+
font-weight: ${weight};
|
|
157
|
+
text-transform: ${textTransform};
|
|
158
|
+
text-decoration: ${textDecoration};
|
|
159
|
+
line-height: ${lineHeight};
|
|
160
|
+
margin: ${defaultMargin};
|
|
161
|
+
padding: 0;
|
|
162
|
+
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
163
|
+
word-wrap: ${wordWrap};
|
|
164
|
+
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
165
|
+
${truncate && css`
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
`};
|
|
168
|
+
${variant === "sup" && "vertical-align: super;"};
|
|
169
|
+
${variant === "sub" && "vertical-align: sub;"};
|
|
170
|
+
${display && `display: ${display};`};
|
|
171
|
+
${listStyleType && `list-style-type: ${listStyleType};`}; ;
|
|
172
|
+
`}
|
|
173
|
+
${space}
|
|
174
|
+
${({
|
|
175
|
+
color,
|
|
176
|
+
bg,
|
|
177
|
+
backgroundColor,
|
|
178
|
+
...rest
|
|
179
|
+
}) => styledColor({
|
|
180
|
+
color,
|
|
181
|
+
bg,
|
|
182
|
+
backgroundColor,
|
|
183
|
+
...rest
|
|
184
|
+
})}
|
|
185
|
+
`;
|
|
186
|
+
StyledTypography.defaultProps = {
|
|
187
|
+
theme: baseTheme
|
|
188
|
+
};
|
|
189
|
+
StyledTypography.displayName = "Typography";
|
|
190
|
+
export default StyledTypography;
|
|
@@ -4,7 +4,7 @@ import addFocusStyling from "../../style/utils/add-focus-styling";
|
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
5
|
import StyledIcon from "../icon/icon.style";
|
|
6
6
|
import Icon from "../icon";
|
|
7
|
-
import
|
|
7
|
+
import StyledBox from "../box/box.style";
|
|
8
8
|
export const StyledList = styled.ul`
|
|
9
9
|
list-style: none;
|
|
10
10
|
margin: 0;
|
|
@@ -97,7 +97,7 @@ export const StyledChevronIcon = styled(Icon)`
|
|
|
97
97
|
width: 20px;
|
|
98
98
|
color: var(--colorsComponentsLeftnavWinterStandardContent);
|
|
99
99
|
`;
|
|
100
|
-
export const StyledVerticalMenu = styled(
|
|
100
|
+
export const StyledVerticalMenu = styled(StyledBox)`
|
|
101
101
|
// TODO remove hardcoded values when DS have had chance to review which token to use
|
|
102
102
|
&::-webkit-scrollbar-track {
|
|
103
103
|
background-color: #cccccc;
|
|
@@ -109,7 +109,7 @@ export const StyledVerticalMenu = styled(Box)`
|
|
|
109
109
|
width: 12px;
|
|
110
110
|
}
|
|
111
111
|
`;
|
|
112
|
-
export const StyledVerticalMenuFullScreen = styled(
|
|
112
|
+
export const StyledVerticalMenuFullScreen = styled(StyledBox)`
|
|
113
113
|
position: fixed;
|
|
114
114
|
top: 0;
|
|
115
115
|
bottom: 0;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import filterObjectProperties from "../../__internal__/filter-object-properties";
|
|
2
|
+
export const flexboxPropertyNames = ["alignItems", "alignContent", "justifyItems", "justifyContent", "flexWrap", "flexDirection", "flex", "flexGrow", "flexShrink", "flexBasis", "justifySelf", "alignSelf", "order"];
|
|
3
|
+
export default function filterStyledSystemFlexboxProps(originalObject) {
|
|
4
|
+
return filterObjectProperties(originalObject, flexboxPropertyNames);
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import filterObjectProperties from "../../__internal__/filter-object-properties";
|
|
2
|
+
export const gridPropertyNames = ["gridColumn", "gridRow", "gridArea", "gridAutoFlow", "gridAutoRows", "gridAutoColumns", "gridTemplateRows", "gridTemplateColumns", "gridTemplateAreas"];
|
|
3
|
+
export default function filterStyledSystemGridProps(originalObject) {
|
|
4
|
+
return filterObjectProperties(originalObject, gridPropertyNames);
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import filterObjectProperties from "../../__internal__/filter-object-properties";
|
|
2
|
+
export const layoutPropertyNames = ["width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "size", "display", "verticalAlign", "overflow", "overflowX", "overflowY", "position", "top", "right", "bottom", "left"];
|
|
3
|
+
export default function filterStyledSystemLayoutProps(originalObject) {
|
|
4
|
+
return filterObjectProperties(originalObject, layoutPropertyNames);
|
|
5
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import filterStyledSystemPaddingProps from "./filter-styled-system-padding-props";
|
|
2
2
|
import filterStyledSystemMarginProps from "./filter-styled-system-margin-props";
|
|
3
3
|
import filterOutStyledSystemSpacingProps from "./filter-out-styled-system-spacing-props";
|
|
4
|
-
|
|
4
|
+
import filterStyledSystemLayoutProps from "./filter-styled-system-layout-props";
|
|
5
|
+
import filterStyledSystemFlexboxProps from "./filter-styled-system-flexbox-props";
|
|
6
|
+
import filterStyledSystemGridProps from "./filter-styled-system-grid-props";
|
|
7
|
+
export { filterStyledSystemPaddingProps, filterStyledSystemMarginProps, filterOutStyledSystemSpacingProps, filterStyledSystemLayoutProps, filterStyledSystemFlexboxProps, filterStyledSystemGridProps, };
|
package/esm/style/utils/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import filterStyledSystemPaddingProps from "./filter-styled-system-padding-props";
|
|
2
2
|
import filterStyledSystemMarginProps from "./filter-styled-system-margin-props";
|
|
3
3
|
import filterOutStyledSystemSpacingProps from "./filter-out-styled-system-spacing-props";
|
|
4
|
-
|
|
4
|
+
import filterStyledSystemLayoutProps from "./filter-styled-system-layout-props";
|
|
5
|
+
import filterStyledSystemFlexboxProps from "./filter-styled-system-flexbox-props";
|
|
6
|
+
import filterStyledSystemGridProps from "./filter-styled-system-grid-props";
|
|
7
|
+
export { filterStyledSystemPaddingProps, filterStyledSystemMarginProps, filterOutStyledSystemSpacingProps, filterStyledSystemLayoutProps, filterStyledSystemFlexboxProps, filterStyledSystemGridProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonInputPresentationProps } from "./input-presentation.component";
|
|
2
2
|
import { InputContextProps } from "../input-behaviour";
|
|
3
3
|
import { CarbonProviderProps } from "../../components/carbon-provider";
|
|
4
|
-
export declare const StyledInputPresentationContainer: import("styled-components").StyledComponent<"div", any, Pick<CommonInputPresentationProps, "
|
|
4
|
+
export declare const StyledInputPresentationContainer: import("styled-components").StyledComponent<"div", any, Pick<CommonInputPresentationProps, "maxWidth" | "inputWidth">, never>;
|
|
5
5
|
declare const InputPresentationStyle: import("styled-components").StyledComponent<"div", any, Pick<InputContextProps, "hasFocus"> & Pick<CommonInputPresentationProps, "disabled" | "error" | "info" | "warning" | "prefix" | "align" | "readOnly" | "size" | "hasIcon"> & Pick<CarbonProviderProps, "validationRedesignOptIn">, never>;
|
|
6
6
|
export default InputPresentationStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ReactWrapper, ShallowWrapper } from "enzyme";
|
|
3
|
-
import { LayoutProps, FlexboxProps, BackgroundProps, PositionProps } from "styled-system";
|
|
3
|
+
import { LayoutProps, FlexboxProps, BackgroundProps, PositionProps, GridProps } from "styled-system";
|
|
4
4
|
import { ReactTestRendererJSON } from "react-test-renderer";
|
|
5
5
|
import { mockMatchMedia } from "./mock-match-media";
|
|
6
6
|
declare const toCSSCase: (str: string) => string;
|
|
@@ -46,7 +46,8 @@ declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
47
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
48
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
|
+
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
50
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
51
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
52
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
52
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
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, };
|
|
@@ -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.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.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");
|
|
@@ -112,6 +112,7 @@ const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#
|
|
|
112
112
|
const widthProps = ["width", "width", "200px"];
|
|
113
113
|
const layoutProps = [widthProps, ["height", "height", "200px"], ["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
114
|
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
|
+
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 . . ."]];
|
|
115
116
|
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"]];
|
|
116
117
|
const positionProps = [["top", "0px"], ["bottom", "0px"], ["right", "0px"], ["left", "0px"], ["position", "fixed"], ["position", "sticky"], ["position", "absolute"], ["position", "static"], ["position", "relative"]];
|
|
117
118
|
const getDefaultValue = value => {
|
|
@@ -295,6 +296,20 @@ const testStyledSystemFlexBox = (component, styleContainer) => {
|
|
|
295
296
|
});
|
|
296
297
|
};
|
|
297
298
|
exports.testStyledSystemFlexBox = testStyledSystemFlexBox;
|
|
299
|
+
const testStyledSystemGrid = (component, styleContainer) => {
|
|
300
|
+
describe.each(gridProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
301
|
+
it(`then ${propName} should have been set correctly`, () => {
|
|
302
|
+
const props = {
|
|
303
|
+
[styledSystemProp]: value
|
|
304
|
+
};
|
|
305
|
+
const wrapper = (0, _enzyme.mount)(component(props));
|
|
306
|
+
assertStyleMatch({
|
|
307
|
+
[propName]: value
|
|
308
|
+
}, styleContainer ? styleContainer(wrapper) : wrapper);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
exports.testStyledSystemGrid = testStyledSystemGrid;
|
|
298
313
|
const testStyledSystemBackground = (component, styleContainer) => {
|
|
299
314
|
describe.each(backgroundProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
300
315
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SpaceProps, LayoutProps, FlexboxProps,
|
|
2
|
+
import { SpaceProps, LayoutProps, FlexboxProps, PositionProps, GridProps } from "styled-system";
|
|
3
3
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
5
|
declare const GAP_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
5
6
|
export declare type OverflowWrap = "break-word" | "anywhere";
|
|
6
7
|
export declare type ScrollVariant = "light" | "dark";
|
|
@@ -10,16 +11,22 @@ export declare type Gap = AllowedNumericalValues | string;
|
|
|
10
11
|
declare type DesignTokensType = keyof typeof DesignTokens;
|
|
11
12
|
declare type BoxShadowsType = Extract<DesignTokensType, `boxShadow${string}`>;
|
|
12
13
|
declare type BorderRadiusType = Extract<DesignTokensType, `borderRadius${string}`>;
|
|
13
|
-
export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps,
|
|
14
|
+
export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, Omit<GridProps, "gridGap" | "gridRowGap" | "gridColumnGap">, TagProps, Omit<PositionProps, "zIndex"> {
|
|
14
15
|
as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
|
|
16
|
+
/** Set the ID attribute of the Box component */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** Content to be rendered inside the Box component */
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** Set the Role attribute of the Box component */
|
|
21
|
+
role?: string;
|
|
15
22
|
/** String to set Box content break strategy. Note "anywhere" is not supported in Safari */
|
|
16
23
|
overflowWrap?: OverflowWrap;
|
|
17
|
-
/**
|
|
24
|
+
/** Scroll styling attribute */
|
|
18
25
|
scrollVariant?: ScrollVariant;
|
|
19
|
-
/**
|
|
26
|
+
/** Set the box-sizing attribute of the Box component */
|
|
20
27
|
boxSizing?: BoxSizing;
|
|
21
28
|
/** Allows a tabindex to be specified */
|
|
22
|
-
tabIndex?: number
|
|
29
|
+
tabIndex?: number;
|
|
23
30
|
/** Gap, an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
|
|
24
31
|
gap?: Gap;
|
|
25
32
|
/** Column gap, an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
|
|
@@ -30,6 +37,16 @@ export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorPr
|
|
|
30
37
|
boxShadow?: BoxShadowsType;
|
|
31
38
|
/** Design Token for Border Radius. Note: please check that the border radius design token you are using is compatible with the Box component. **This prop will not do anything if you have the roundedCornerOptOut flag set in the CarbonProvider** */
|
|
32
39
|
borderRadius?: BorderRadiusType;
|
|
40
|
+
/** @private @ignore */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Set the color attribute of the Box component */
|
|
43
|
+
color?: string;
|
|
44
|
+
/** Set the bg attribute of the Box component */
|
|
45
|
+
bg?: string;
|
|
46
|
+
/** Set the backgroundColor attribute of the Box component */
|
|
47
|
+
backgroundColor?: string;
|
|
48
|
+
/** Set the opacity attribute of the Box component */
|
|
49
|
+
opacity?: string | number;
|
|
33
50
|
}
|
|
34
|
-
export declare const Box:
|
|
51
|
+
export declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
35
52
|
export default Box;
|