carbon-react 120.1.0 → 120.2.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.js +16 -8
- package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.js +2 -0
- package/esm/components/heading/heading.style.d.ts +1 -1
- package/esm/components/typography/typography.component.d.ts +4 -1
- package/esm/components/typography/typography.component.js +3 -1
- package/esm/components/typography/typography.style.js +4 -1
- package/lib/__spec_helper__/test-utils.js +16 -8
- package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.js +2 -0
- package/lib/components/heading/heading.style.d.ts +1 -1
- package/lib/components/typography/typography.component.d.ts +4 -1
- package/lib/components/typography/typography.component.js +3 -1
- package/lib/components/typography/typography.style.js +4 -1
- package/package.json +3 -2
|
@@ -105,10 +105,14 @@ export const getDefaultValue = value => {
|
|
|
105
105
|
};
|
|
106
106
|
const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts) => {
|
|
107
107
|
describe("default props", () => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
let wrapper;
|
|
109
|
+
let StyleElement;
|
|
110
|
+
beforeAll(() => {
|
|
111
|
+
wrapper = mount(component({
|
|
112
|
+
...defaults
|
|
113
|
+
}));
|
|
114
|
+
StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
115
|
+
});
|
|
112
116
|
it("should set the correct margins", () => {
|
|
113
117
|
let margin;
|
|
114
118
|
let marginLeft;
|
|
@@ -153,10 +157,14 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
|
|
|
153
157
|
};
|
|
154
158
|
const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts) => {
|
|
155
159
|
describe("default props", () => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
let wrapper;
|
|
161
|
+
let StyleElement;
|
|
162
|
+
beforeAll(() => {
|
|
163
|
+
wrapper = mount(component({
|
|
164
|
+
...defaults
|
|
165
|
+
}));
|
|
166
|
+
StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
167
|
+
});
|
|
160
168
|
it("should set the correct paddings", () => {
|
|
161
169
|
let padding;
|
|
162
170
|
let paddingLeft;
|
|
@@ -96,8 +96,10 @@ const ButtonToggleGroup = ({
|
|
|
96
96
|
// guard needed to avoid warnings about setting state on an unmounted component - the callback ref will
|
|
97
97
|
// get called with null when the component is about to be unmounted, and it has been unmounted by the time
|
|
98
98
|
// the setTimeout completes
|
|
99
|
+
/* istanbul ignore else */
|
|
99
100
|
if (button) {
|
|
100
101
|
const innerButtons = getInnerButtons();
|
|
102
|
+
/* istanbul ignore if */
|
|
101
103
|
if (!innerButtons) {
|
|
102
104
|
setFirstButton(undefined);
|
|
103
105
|
} else if (button === innerButtons[0]) {
|
|
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
|
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}, any, StyledHeadingTitleProps, never>;
|
|
18
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -44,9 +44,12 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
44
44
|
opacity?: string | number;
|
|
45
45
|
/** @private @ignore */
|
|
46
46
|
className?: string;
|
|
47
|
+
/** Set whether it will be visually hidden
|
|
48
|
+
* NOTE: This is for screen readers only and will make a lot of the other props redundant */
|
|
49
|
+
screenReaderOnly?: boolean;
|
|
47
50
|
}
|
|
48
51
|
export declare const Typography: {
|
|
49
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: TypographyProps): React.JSX.Element;
|
|
52
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
50
53
|
displayName: string;
|
|
51
54
|
};
|
|
52
55
|
export default Typography;
|
|
@@ -27,6 +27,7 @@ export const Typography = ({
|
|
|
27
27
|
opacity,
|
|
28
28
|
children,
|
|
29
29
|
className,
|
|
30
|
+
screenReaderOnly,
|
|
30
31
|
...rest
|
|
31
32
|
}) => {
|
|
32
33
|
return /*#__PURE__*/React.createElement(StyledTypography, _extends({
|
|
@@ -48,7 +49,8 @@ export const Typography = ({
|
|
|
48
49
|
backgroundColor: backgroundColor,
|
|
49
50
|
bg: bg,
|
|
50
51
|
opacity: opacity,
|
|
51
|
-
className: className
|
|
52
|
+
className: className,
|
|
53
|
+
screenReaderOnly: screenReaderOnly
|
|
52
54
|
}, tagComponent(dataComponent, rest), filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest)), children);
|
|
53
55
|
};
|
|
54
56
|
Typography.displayName = "Typography";
|
|
@@ -2,6 +2,7 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
import { space } from "styled-system";
|
|
3
3
|
import styledColor from "../../style/utils/color";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
|
+
import visuallyHidden from "../../style/utils/visually-hidden";
|
|
5
6
|
const getAs = variant => {
|
|
6
7
|
switch (variant) {
|
|
7
8
|
case "h1-large":
|
|
@@ -149,7 +150,8 @@ const StyledTypography = styled.span.attrs(({
|
|
|
149
150
|
whiteSpace,
|
|
150
151
|
wordWrap,
|
|
151
152
|
textOverflow,
|
|
152
|
-
truncate
|
|
153
|
+
truncate,
|
|
154
|
+
screenReaderOnly
|
|
153
155
|
}) => css`
|
|
154
156
|
font-style: normal;
|
|
155
157
|
font-size: ${size};
|
|
@@ -165,6 +167,7 @@ const StyledTypography = styled.span.attrs(({
|
|
|
165
167
|
${truncate && css`
|
|
166
168
|
overflow: hidden;
|
|
167
169
|
`};
|
|
170
|
+
${screenReaderOnly && visuallyHidden}
|
|
168
171
|
${variant === "sup" && "vertical-align: super;"};
|
|
169
172
|
${variant === "sub" && "vertical-align: sub;"};
|
|
170
173
|
${display && `display: ${display};`};
|
|
@@ -133,10 +133,14 @@ const getDefaultValue = value => {
|
|
|
133
133
|
exports.getDefaultValue = getDefaultValue;
|
|
134
134
|
const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts) => {
|
|
135
135
|
describe("default props", () => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
let wrapper;
|
|
137
|
+
let StyleElement;
|
|
138
|
+
beforeAll(() => {
|
|
139
|
+
wrapper = (0, _enzyme.mount)(component({
|
|
140
|
+
...defaults
|
|
141
|
+
}));
|
|
142
|
+
StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
143
|
+
});
|
|
140
144
|
it("should set the correct margins", () => {
|
|
141
145
|
let margin;
|
|
142
146
|
let marginLeft;
|
|
@@ -182,10 +186,14 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
|
|
|
182
186
|
exports.testStyledSystemMargin = testStyledSystemMargin;
|
|
183
187
|
const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts) => {
|
|
184
188
|
describe("default props", () => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
let wrapper;
|
|
190
|
+
let StyleElement;
|
|
191
|
+
beforeAll(() => {
|
|
192
|
+
wrapper = (0, _enzyme.mount)(component({
|
|
193
|
+
...defaults
|
|
194
|
+
}));
|
|
195
|
+
StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
196
|
+
});
|
|
189
197
|
it("should set the correct paddings", () => {
|
|
190
198
|
let padding;
|
|
191
199
|
let paddingLeft;
|
|
@@ -106,8 +106,10 @@ const ButtonToggleGroup = ({
|
|
|
106
106
|
// guard needed to avoid warnings about setting state on an unmounted component - the callback ref will
|
|
107
107
|
// get called with null when the component is about to be unmounted, and it has been unmounted by the time
|
|
108
108
|
// the setTimeout completes
|
|
109
|
+
/* istanbul ignore else */
|
|
109
110
|
if (button) {
|
|
110
111
|
const innerButtons = getInnerButtons();
|
|
112
|
+
/* istanbul ignore if */
|
|
111
113
|
if (!innerButtons) {
|
|
112
114
|
setFirstButton(undefined);
|
|
113
115
|
} else if (button === innerButtons[0]) {
|
|
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
|
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}, any, StyledHeadingTitleProps, never>;
|
|
18
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -44,9 +44,12 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
44
44
|
opacity?: string | number;
|
|
45
45
|
/** @private @ignore */
|
|
46
46
|
className?: string;
|
|
47
|
+
/** Set whether it will be visually hidden
|
|
48
|
+
* NOTE: This is for screen readers only and will make a lot of the other props redundant */
|
|
49
|
+
screenReaderOnly?: boolean;
|
|
47
50
|
}
|
|
48
51
|
export declare const Typography: {
|
|
49
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: TypographyProps): React.JSX.Element;
|
|
52
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
50
53
|
displayName: string;
|
|
51
54
|
};
|
|
52
55
|
export default Typography;
|
|
@@ -34,6 +34,7 @@ const Typography = ({
|
|
|
34
34
|
opacity,
|
|
35
35
|
children,
|
|
36
36
|
className,
|
|
37
|
+
screenReaderOnly,
|
|
37
38
|
...rest
|
|
38
39
|
}) => {
|
|
39
40
|
return /*#__PURE__*/_react.default.createElement(_typography.default, _extends({
|
|
@@ -55,7 +56,8 @@ const Typography = ({
|
|
|
55
56
|
backgroundColor: backgroundColor,
|
|
56
57
|
bg: bg,
|
|
57
58
|
opacity: opacity,
|
|
58
|
-
className: className
|
|
59
|
+
className: className,
|
|
60
|
+
screenReaderOnly: screenReaderOnly
|
|
59
61
|
}, (0, _tags.default)(dataComponent, rest), (0, _utils.filterStyledSystemMarginProps)(rest), (0, _utils.filterStyledSystemPaddingProps)(rest)), children);
|
|
60
62
|
};
|
|
61
63
|
exports.Typography = Typography;
|
|
@@ -8,6 +8,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _color = _interopRequireDefault(require("../../style/utils/color"));
|
|
10
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
|
+
var _visuallyHidden = _interopRequireDefault(require("../../style/utils/visually-hidden"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
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
14
|
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; }
|
|
@@ -158,7 +159,8 @@ const StyledTypography = _styledComponents.default.span.attrs(({
|
|
|
158
159
|
whiteSpace,
|
|
159
160
|
wordWrap,
|
|
160
161
|
textOverflow,
|
|
161
|
-
truncate
|
|
162
|
+
truncate,
|
|
163
|
+
screenReaderOnly
|
|
162
164
|
}) => (0, _styledComponents.css)`
|
|
163
165
|
font-style: normal;
|
|
164
166
|
font-size: ${size};
|
|
@@ -174,6 +176,7 @@ const StyledTypography = _styledComponents.default.span.attrs(({
|
|
|
174
176
|
${truncate && (0, _styledComponents.css)`
|
|
175
177
|
overflow: hidden;
|
|
176
178
|
`};
|
|
179
|
+
${screenReaderOnly && _visuallyHidden.default}
|
|
177
180
|
${variant === "sup" && "vertical-align: super;"};
|
|
178
181
|
${variant === "sub" && "vertical-align: sub;"};
|
|
179
182
|
${display && `display: ${display};`};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "120.
|
|
3
|
+
"version": "120.2.0",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"prepare": "husky install",
|
|
39
39
|
"test:ct": "playwright test -c playwright-ct.config.ts",
|
|
40
40
|
"test:ct:ui": "playwright test --ui -c playwright-ct.config.ts",
|
|
41
|
-
"test:ct:report": "npx playwright show-report"
|
|
41
|
+
"test:ct:report": "npx playwright show-report",
|
|
42
|
+
"clear-playwright-cache": "rimraf ./playwright/.cache"
|
|
42
43
|
},
|
|
43
44
|
"repository": {
|
|
44
45
|
"type": "git",
|