carbon-react 102.0.0 → 102.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/lib/components/button-toggle/button-toggle-input.component.js +4 -7
- package/lib/components/button-toggle/button-toggle.component.js +28 -1
- package/lib/components/button-toggle/button-toggle.d.ts +10 -0
- package/lib/components/button-toggle/button-toggle.style.js +5 -2
- package/lib/components/button-toggle-group/button-toggle-group.component.js +1 -1
- package/package.json +9 -4
|
@@ -19,6 +19,8 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
21
21
|
|
|
22
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
23
|
+
|
|
22
24
|
const ButtonToggleInput = /*#__PURE__*/_react.default.forwardRef((props, forwardRef) => {
|
|
23
25
|
const {
|
|
24
26
|
onFocus,
|
|
@@ -41,18 +43,13 @@ const ButtonToggleInput = /*#__PURE__*/_react.default.forwardRef((props, forward
|
|
|
41
43
|
if (onFocus) onFocus(ev);
|
|
42
44
|
};
|
|
43
45
|
|
|
44
|
-
return /*#__PURE__*/_react.default.createElement(_buttonToggle.StyledButtonToggleInput, {
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_buttonToggle.StyledButtonToggleInput, _extends({}, props, {
|
|
45
47
|
type: "radio",
|
|
46
|
-
name: props.name,
|
|
47
48
|
id: props.guid,
|
|
48
|
-
disabled: props.disabled,
|
|
49
|
-
checked: props.checked,
|
|
50
|
-
onChange: props.onChange,
|
|
51
49
|
onBlur: handleBlur,
|
|
52
50
|
onFocus: handleFocus,
|
|
53
|
-
value: props.value,
|
|
54
51
|
ref: forwardRef
|
|
55
|
-
});
|
|
52
|
+
}));
|
|
56
53
|
});
|
|
57
54
|
|
|
58
55
|
ButtonToggleInput.propTypes = {
|
|
@@ -27,10 +27,15 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
27
27
|
|
|
28
28
|
const ButtonToggle = props => {
|
|
29
29
|
const {
|
|
30
|
+
"aria-label": ariaLabel,
|
|
31
|
+
"aria-labelledby": ariaLabelledBy,
|
|
30
32
|
buttonIcon,
|
|
31
33
|
buttonIconSize,
|
|
32
34
|
checked,
|
|
33
35
|
children,
|
|
36
|
+
"data-component": dataComponent,
|
|
37
|
+
"data-element": dataElement,
|
|
38
|
+
"data-role": dataRole,
|
|
34
39
|
disabled,
|
|
35
40
|
grouped,
|
|
36
41
|
name,
|
|
@@ -50,8 +55,10 @@ const ButtonToggle = props => {
|
|
|
50
55
|
|
|
51
56
|
if (buttonIcon) {
|
|
52
57
|
icon = /*#__PURE__*/_react.default.createElement(_buttonToggleIcon.default, {
|
|
58
|
+
"aria-hidden": true,
|
|
53
59
|
buttonIcon: buttonIcon,
|
|
54
60
|
buttonIconSize: buttonIconSize,
|
|
61
|
+
hasNoContent: !children,
|
|
55
62
|
disabled: disabled
|
|
56
63
|
});
|
|
57
64
|
}
|
|
@@ -61,10 +68,15 @@ const ButtonToggle = props => {
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
return /*#__PURE__*/_react.default.createElement(_buttonToggle.StyledButtonToggle, {
|
|
64
|
-
"data-component": "button-toggle",
|
|
71
|
+
"data-component": dataComponent || "button-toggle",
|
|
72
|
+
"data-element": dataElement,
|
|
73
|
+
"data-role": dataRole,
|
|
65
74
|
grouped: grouped,
|
|
66
75
|
onClick: handleClick
|
|
67
76
|
}, /*#__PURE__*/_react.default.createElement(_buttonToggleInput.default, {
|
|
77
|
+
"aria-label": ariaLabel,
|
|
78
|
+
"aria-labelledby": ariaLabelledBy,
|
|
79
|
+
"data-element": "button-toggle-input",
|
|
68
80
|
name: name,
|
|
69
81
|
checked: checked,
|
|
70
82
|
disabled: disabled,
|
|
@@ -86,9 +98,24 @@ const ButtonToggle = props => {
|
|
|
86
98
|
};
|
|
87
99
|
|
|
88
100
|
ButtonToggle.propTypes = {
|
|
101
|
+
/** Prop to specify the aria-label of the component */
|
|
102
|
+
"aria-label": _propTypes.default.string,
|
|
103
|
+
|
|
104
|
+
/** Prop to specify the aria-labelledby property of the component */
|
|
105
|
+
"aria-labelledby": _propTypes.default.string,
|
|
106
|
+
|
|
89
107
|
/** Set the checked value of the radio button */
|
|
90
108
|
checked: _propTypes.default.bool,
|
|
91
109
|
|
|
110
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
111
|
+
"data-component": _propTypes.default.string,
|
|
112
|
+
|
|
113
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
114
|
+
"data-element": _propTypes.default.string,
|
|
115
|
+
|
|
116
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
117
|
+
"data-role": _propTypes.default.string,
|
|
118
|
+
|
|
92
119
|
/** Name used on the hidden radio button. */
|
|
93
120
|
name: _propTypes.default.string,
|
|
94
121
|
|
|
@@ -2,10 +2,20 @@ import * as React from "react";
|
|
|
2
2
|
import { ButtonToggleIconSizes } from "./button-toggle-types";
|
|
3
3
|
|
|
4
4
|
export interface ButtonToggleProps {
|
|
5
|
+
/** Prop to specify the aria-label of the component */
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
/** Prop to specify the aria-labelledby property of the component */
|
|
8
|
+
"aria-labelledby"?: string;
|
|
5
9
|
/** buttonIcon to render. */
|
|
6
10
|
buttonIcon?: string;
|
|
7
11
|
/** Sets the size of the buttonIcon (eg. large) */
|
|
8
12
|
buttonIconSize?: ButtonToggleIconSizes;
|
|
13
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
14
|
+
"data-component"?: string;
|
|
15
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
16
|
+
"data-element"?: string;
|
|
17
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
18
|
+
"data-role"?: string;
|
|
9
19
|
/** ButtonToggle size */
|
|
10
20
|
size?: "small" | "medium" | "large";
|
|
11
21
|
/** Set the checked value of the radio button */
|
|
@@ -134,8 +134,11 @@ const iconFontSizes = {
|
|
|
134
134
|
largeIcon: 32
|
|
135
135
|
};
|
|
136
136
|
const StyledButtonToggleIcon = _styledComponents.default.div`
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
${({
|
|
138
|
+
hasNoContent
|
|
139
|
+
}) => hasNoContent ? "" : (0, _styledComponents.css)`
|
|
140
|
+
margin-right: 8px;
|
|
141
|
+
`}
|
|
139
142
|
${({
|
|
140
143
|
buttonIconSize
|
|
141
144
|
}) => buttonIconSize === "large" && (0, _styledComponents.css)`
|
|
@@ -80,7 +80,7 @@ const ButtonToggleGroup = ({
|
|
|
80
80
|
"data-element": dataElement
|
|
81
81
|
}, validationProps, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_buttonToggleGroup.default, _extends({
|
|
82
82
|
"aria-label": label,
|
|
83
|
-
role: "
|
|
83
|
+
role: "radiogroup",
|
|
84
84
|
inputWidth: inputWidth
|
|
85
85
|
}, validationProps), /*#__PURE__*/_react.default.createElement(_radioButtonMapper.default, {
|
|
86
86
|
name: name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "102.0.
|
|
3
|
+
"version": "102.0.1",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
"start:debug-theme": "cross-env STORYBOOK_DEBUG_THEME=true npm run start",
|
|
18
18
|
"test": "jest --config=./jest.conf.json",
|
|
19
19
|
"test-update": "jest --config=./jest.conf.json --updateSnapshot",
|
|
20
|
-
"test
|
|
20
|
+
"test:cypress": "cypress open",
|
|
21
|
+
"cypress:react": "npx cypress open-ct",
|
|
22
|
+
"cypress:ci:react": "npx cypress run-ct --spec './src/components/**/*.test.js' --record --key --parallel --group 'ubuntu-cypress-react' --browser=chrome",
|
|
21
23
|
"debug": "node --inspect ./node_modules/jest-cli/bin/jest --watch --config=./jest.conf.json",
|
|
22
24
|
"format": "prettier --write './src'",
|
|
23
25
|
"lint": "eslint ./src",
|
|
@@ -27,7 +29,7 @@
|
|
|
27
29
|
"watch": "npm run clean-lib && npm run copy-files -- --watch & npm run babel -- --watch",
|
|
28
30
|
"build-storybook": "build-storybook -c .storybook -s .assets",
|
|
29
31
|
"start:static": "npx http-server -p 9001 ./storybook-static",
|
|
30
|
-
"babel": "cross-env NODE_ENV=production babel ./src --config-file ./babel.config.js --out-dir ./lib --ignore '**/*/__spec__.js','**/*.spec.js','**/__definition__.js' --quiet",
|
|
32
|
+
"babel": "cross-env NODE_ENV=production babel ./src --config-file ./babel.config.js --out-dir ./lib --ignore '**/*/__spec__.js','**/*.spec.js','**/__definition__.js','**/*.test.js' --quiet",
|
|
31
33
|
"clean-lib": "rimraf ./lib",
|
|
32
34
|
"copy-files": "cpy \"**/\" \"!**/(*.js|*.md|*.mdx|*.stories.*|*.snap)\" ../lib/ --cwd=src --parents",
|
|
33
35
|
"commit": "git-cz",
|
|
@@ -59,6 +61,8 @@
|
|
|
59
61
|
"@babel/preset-typescript": "7.12.7",
|
|
60
62
|
"@commitlint/cli": "^11.0.0",
|
|
61
63
|
"@commitlint/config-conventional": "^11.0.0",
|
|
64
|
+
"@cypress/react": "^5.9.2",
|
|
65
|
+
"@cypress/webpack-dev-server": "^1.4.0",
|
|
62
66
|
"@semantic-release/changelog": "^6.0.1",
|
|
63
67
|
"@semantic-release/exec": "^6.0.2",
|
|
64
68
|
"@semantic-release/git": "^10.0.1",
|
|
@@ -136,7 +140,8 @@
|
|
|
136
140
|
"semver": "^7.3.5",
|
|
137
141
|
"sprintf-js": "^1.1.2",
|
|
138
142
|
"styled-components": "^4.4.1",
|
|
139
|
-
"typescript": "^3.9.5"
|
|
143
|
+
"typescript": "^3.9.5",
|
|
144
|
+
"webpack-dev-server": "^3.11.2"
|
|
140
145
|
},
|
|
141
146
|
"dependencies": {
|
|
142
147
|
"@octokit/rest": "^18.12.0",
|