@gympass/yoga 7.80.0 → 7.81.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/cjs/Checkbox/web/Checkbox.js +3 -1
- package/cjs/Icon/Icon.js +72 -20
- package/esm/Checkbox/web/Checkbox.js +3 -1
- package/esm/Checkbox/web/Checkbox.test.js +10 -2
- package/esm/Icon/Icon.js +66 -20
- package/esm/Icon/native/Icon.test.js +13 -0
- package/esm/Icon/web/Icon.test.js +13 -0
- package/package.json +2 -2
|
@@ -181,7 +181,9 @@ var Checkbox = function Checkbox(_ref8) {
|
|
|
181
181
|
ref: inputRef,
|
|
182
182
|
checked: checked,
|
|
183
183
|
disabled: disabled
|
|
184
|
-
},
|
|
184
|
+
}, value ? {
|
|
185
|
+
value: value
|
|
186
|
+
} : {}, rest)), label)), (helper || error) && /*#__PURE__*/_react["default"].createElement(HelperWrapper, null, /*#__PURE__*/_react["default"].createElement(Helper, {
|
|
185
187
|
error: error
|
|
186
188
|
}, error || helper)));
|
|
187
189
|
};
|
package/cjs/Icon/Icon.js
CHANGED
|
@@ -13,7 +13,7 @@ var _lodash = _interopRequireDefault(require("lodash.get"));
|
|
|
13
13
|
|
|
14
14
|
var _Box = _interopRequireDefault(require("../Box"));
|
|
15
15
|
|
|
16
|
-
var _excluded = ["as", "size", "width", "height", "fill", "stroke", "theme"];
|
|
16
|
+
var _excluded = ["as", "size", "width", "height", "fill", "stroke", "theme", "title", "description", "ariaLabel"];
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
|
|
@@ -31,17 +31,56 @@ var Icon = function Icon(_ref) {
|
|
|
31
31
|
fill = _ref.fill,
|
|
32
32
|
stroke = _ref.stroke,
|
|
33
33
|
theme = _ref.theme,
|
|
34
|
+
title = _ref.title,
|
|
35
|
+
description = _ref.description,
|
|
36
|
+
ariaLabel = _ref.ariaLabel,
|
|
34
37
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
35
38
|
|
|
39
|
+
var componentWithTitle = function componentWithTitle(propsTitle) {
|
|
40
|
+
var titleId = ariaLabel + "-titleId";
|
|
41
|
+
var ariaDescribedBy = titleId;
|
|
42
|
+
|
|
43
|
+
var titleElement = /*#__PURE__*/_react["default"].createElement("title", {
|
|
44
|
+
id: titleId,
|
|
45
|
+
key: titleId
|
|
46
|
+
}, title);
|
|
47
|
+
|
|
48
|
+
var svgChildren = [titleElement];
|
|
49
|
+
|
|
50
|
+
if (description) {
|
|
51
|
+
var descId = ariaLabel + "-descId";
|
|
52
|
+
|
|
53
|
+
var descElement = /*#__PURE__*/_react["default"].createElement("desc", {
|
|
54
|
+
id: descId,
|
|
55
|
+
key: descId
|
|
56
|
+
}, description);
|
|
57
|
+
|
|
58
|
+
ariaDescribedBy += " " + descId;
|
|
59
|
+
svgChildren = [].concat(svgChildren, [descElement]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var defaultProps = {
|
|
63
|
+
viewBox: '0 0 12 12',
|
|
64
|
+
role: 'img',
|
|
65
|
+
'aria-describedby': ariaDescribedBy
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var newSvg = /*#__PURE__*/_react["default"].createElement('svg', _extends({}, propsTitle, defaultProps), svgChildren, Component().props.children);
|
|
69
|
+
|
|
70
|
+
return newSvg;
|
|
71
|
+
};
|
|
72
|
+
|
|
36
73
|
return /*#__PURE__*/_react["default"].createElement(_Box["default"], _extends({
|
|
37
|
-
as: Component,
|
|
74
|
+
as: title && ariaLabel ? componentWithTitle : Component,
|
|
38
75
|
width: (0, _lodash["default"])(theme.yoga.spacing, width, width),
|
|
39
76
|
height: (0, _lodash["default"])(theme.yoga.spacing, height, height)
|
|
40
77
|
}, fill && {
|
|
41
78
|
fill: (0, _lodash["default"])(theme.yoga.colors, fill, fill)
|
|
42
79
|
}, stroke && {
|
|
43
80
|
stroke: (0, _lodash["default"])(theme.yoga.colors, stroke, stroke)
|
|
44
|
-
}, props
|
|
81
|
+
}, props, {
|
|
82
|
+
"aria-hidden": title ? undefined : true
|
|
83
|
+
}));
|
|
45
84
|
};
|
|
46
85
|
|
|
47
86
|
var commonSizes = ['xxxsmall', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', 'xxxlarge', 'huge', 'xhuge'];
|
|
@@ -57,6 +96,31 @@ Icon.propTypes = {
|
|
|
57
96
|
* tokens (vibin, neutral, stamina...) */
|
|
58
97
|
stroke: _propTypes.string,
|
|
59
98
|
|
|
99
|
+
/** Text that will be displayed in the title element, used for accessibility */
|
|
100
|
+
title: _propTypes.string,
|
|
101
|
+
|
|
102
|
+
/** Text used as element description, used for accessibility.
|
|
103
|
+
* A title must be given in order to use description corretly.
|
|
104
|
+
*/
|
|
105
|
+
description: _propTypes.string,
|
|
106
|
+
|
|
107
|
+
/** Text used as identifier for aria-describedby, title and description */
|
|
108
|
+
ariaLabel: function ariaLabel(props, propName, componentName) {
|
|
109
|
+
var _checkPropTypes;
|
|
110
|
+
|
|
111
|
+
var title = props.title,
|
|
112
|
+
ariaLabel = props.ariaLabel;
|
|
113
|
+
|
|
114
|
+
if (title && !ariaLabel) {
|
|
115
|
+
return new Error("accessible elements, such as title, must receive the " + propName + " property as an identifier.");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
(0, _propTypes.checkPropTypes)((_checkPropTypes = {}, _checkPropTypes[propName] = _propTypes.string, _checkPropTypes), {
|
|
119
|
+
ariaLabel: ariaLabel
|
|
120
|
+
}, 'prop', componentName);
|
|
121
|
+
return null;
|
|
122
|
+
},
|
|
123
|
+
|
|
60
124
|
/** Horizontal size of the SVG. Use it as one of
|
|
61
125
|
* theme.spacing tokens (xxsmall, small, medium...) */
|
|
62
126
|
width: (0, _propTypes.oneOfType)([(0, _propTypes.oneOf)(commonSizes), _propTypes.string, _propTypes.number]),
|
|
@@ -67,29 +131,17 @@ Icon.propTypes = {
|
|
|
67
131
|
|
|
68
132
|
/** Size for vertical and horizontal of the SVG.
|
|
69
133
|
* Use it as one of theme.spacing tokens (xxsmall, small, medium...) */
|
|
70
|
-
size:
|
|
71
|
-
var _checkPropTypes;
|
|
72
|
-
|
|
73
|
-
var size = props.size,
|
|
74
|
-
width = props.width,
|
|
75
|
-
height = props.height;
|
|
76
|
-
|
|
77
|
-
if (size && (width || height)) {
|
|
78
|
-
return new Error("you must use only " + propName + ", alone, or width and/or height in " + componentName);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
(0, _propTypes.checkPropTypes)((_checkPropTypes = {}, _checkPropTypes[propName] = (0, _propTypes.oneOfType)([(0, _propTypes.oneOf)(commonSizes), _propTypes.string, _propTypes.number]), _checkPropTypes), {
|
|
82
|
-
size: size
|
|
83
|
-
}, 'prop', componentName);
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
134
|
+
size: (0, _propTypes.oneOfType)([(0, _propTypes.oneOf)(commonSizes), _propTypes.string, _propTypes.number])
|
|
86
135
|
};
|
|
87
136
|
Icon.defaultProps = {
|
|
88
137
|
fill: undefined,
|
|
89
138
|
stroke: undefined,
|
|
139
|
+
title: undefined,
|
|
140
|
+
description: undefined,
|
|
141
|
+
ariaLabel: undefined,
|
|
90
142
|
width: undefined,
|
|
91
143
|
height: undefined,
|
|
92
|
-
size:
|
|
144
|
+
size: 12
|
|
93
145
|
};
|
|
94
146
|
|
|
95
147
|
var _default = (0, _styledComponents.withTheme)(Icon);
|
|
@@ -159,7 +159,9 @@ var Checkbox = function Checkbox(_ref8) {
|
|
|
159
159
|
ref: inputRef,
|
|
160
160
|
checked: checked,
|
|
161
161
|
disabled: disabled
|
|
162
|
-
},
|
|
162
|
+
}, value ? {
|
|
163
|
+
value: value
|
|
164
|
+
} : {}, rest)), label)), (helper || error) && /*#__PURE__*/React.createElement(HelperWrapper, null, /*#__PURE__*/React.createElement(Helper, {
|
|
163
165
|
error: error
|
|
164
166
|
}, error || helper)));
|
|
165
167
|
};
|
|
@@ -134,15 +134,23 @@ describe('<Checkbox />', function () {
|
|
|
134
134
|
|
|
135
135
|
expect(container).toMatchSnapshot();
|
|
136
136
|
});
|
|
137
|
+
it('should match snapshot with a given value', function () {
|
|
138
|
+
var _render15 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
139
|
+
value: "test_value"
|
|
140
|
+
})))),
|
|
141
|
+
container = _render15.container;
|
|
142
|
+
|
|
143
|
+
expect(container).toMatchSnapshot();
|
|
144
|
+
});
|
|
137
145
|
});
|
|
138
146
|
describe('Events', function () {
|
|
139
147
|
it('should call onChange function when press on Checkbox', function () {
|
|
140
148
|
var onChangeMock = jest.fn();
|
|
141
149
|
|
|
142
|
-
var
|
|
150
|
+
var _render16 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, data, {
|
|
143
151
|
onChange: onChangeMock
|
|
144
152
|
})))),
|
|
145
|
-
getByRole =
|
|
153
|
+
getByRole = _render16.getByRole;
|
|
146
154
|
|
|
147
155
|
fireEvent.click(getByRole('checkbox', {
|
|
148
156
|
hidden: true
|
package/esm/Icon/Icon.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["as", "size", "width", "height", "fill", "stroke", "theme"];
|
|
1
|
+
var _excluded = ["as", "size", "width", "height", "fill", "stroke", "theme", "title", "description", "ariaLabel"];
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
@@ -20,17 +20,50 @@ var Icon = function Icon(_ref) {
|
|
|
20
20
|
fill = _ref.fill,
|
|
21
21
|
stroke = _ref.stroke,
|
|
22
22
|
theme = _ref.theme,
|
|
23
|
+
title = _ref.title,
|
|
24
|
+
description = _ref.description,
|
|
25
|
+
ariaLabel = _ref.ariaLabel,
|
|
23
26
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
24
27
|
|
|
28
|
+
var componentWithTitle = function componentWithTitle(propsTitle) {
|
|
29
|
+
var titleId = ariaLabel + "-titleId";
|
|
30
|
+
var ariaDescribedBy = titleId;
|
|
31
|
+
var titleElement = /*#__PURE__*/React.createElement("title", {
|
|
32
|
+
id: titleId,
|
|
33
|
+
key: titleId
|
|
34
|
+
}, title);
|
|
35
|
+
var svgChildren = [titleElement];
|
|
36
|
+
|
|
37
|
+
if (description) {
|
|
38
|
+
var descId = ariaLabel + "-descId";
|
|
39
|
+
var descElement = /*#__PURE__*/React.createElement("desc", {
|
|
40
|
+
id: descId,
|
|
41
|
+
key: descId
|
|
42
|
+
}, description);
|
|
43
|
+
ariaDescribedBy += " " + descId;
|
|
44
|
+
svgChildren = [].concat(svgChildren, [descElement]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var defaultProps = {
|
|
48
|
+
viewBox: '0 0 12 12',
|
|
49
|
+
role: 'img',
|
|
50
|
+
'aria-describedby': ariaDescribedBy
|
|
51
|
+
};
|
|
52
|
+
var newSvg = /*#__PURE__*/React.createElement('svg', _extends({}, propsTitle, defaultProps), svgChildren, Component().props.children);
|
|
53
|
+
return newSvg;
|
|
54
|
+
};
|
|
55
|
+
|
|
25
56
|
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
26
|
-
as: Component,
|
|
57
|
+
as: title && ariaLabel ? componentWithTitle : Component,
|
|
27
58
|
width: get(theme.yoga.spacing, width, width),
|
|
28
59
|
height: get(theme.yoga.spacing, height, height)
|
|
29
60
|
}, fill && {
|
|
30
61
|
fill: get(theme.yoga.colors, fill, fill)
|
|
31
62
|
}, stroke && {
|
|
32
63
|
stroke: get(theme.yoga.colors, stroke, stroke)
|
|
33
|
-
}, props
|
|
64
|
+
}, props, {
|
|
65
|
+
"aria-hidden": title ? undefined : true
|
|
66
|
+
}));
|
|
34
67
|
};
|
|
35
68
|
|
|
36
69
|
var commonSizes = ['xxxsmall', 'xxsmall', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'xxlarge', 'xxxlarge', 'huge', 'xhuge'];
|
|
@@ -46,6 +79,31 @@ Icon.propTypes = {
|
|
|
46
79
|
* tokens (vibin, neutral, stamina...) */
|
|
47
80
|
stroke: string,
|
|
48
81
|
|
|
82
|
+
/** Text that will be displayed in the title element, used for accessibility */
|
|
83
|
+
title: string,
|
|
84
|
+
|
|
85
|
+
/** Text used as element description, used for accessibility.
|
|
86
|
+
* A title must be given in order to use description corretly.
|
|
87
|
+
*/
|
|
88
|
+
description: string,
|
|
89
|
+
|
|
90
|
+
/** Text used as identifier for aria-describedby, title and description */
|
|
91
|
+
ariaLabel: function ariaLabel(props, propName, componentName) {
|
|
92
|
+
var _checkPropTypes;
|
|
93
|
+
|
|
94
|
+
var title = props.title,
|
|
95
|
+
ariaLabel = props.ariaLabel;
|
|
96
|
+
|
|
97
|
+
if (title && !ariaLabel) {
|
|
98
|
+
return new Error("accessible elements, such as title, must receive the " + propName + " property as an identifier.");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
checkPropTypes((_checkPropTypes = {}, _checkPropTypes[propName] = string, _checkPropTypes), {
|
|
102
|
+
ariaLabel: ariaLabel
|
|
103
|
+
}, 'prop', componentName);
|
|
104
|
+
return null;
|
|
105
|
+
},
|
|
106
|
+
|
|
49
107
|
/** Horizontal size of the SVG. Use it as one of
|
|
50
108
|
* theme.spacing tokens (xxsmall, small, medium...) */
|
|
51
109
|
width: oneOfType([oneOf(commonSizes), string, number]),
|
|
@@ -56,28 +114,16 @@ Icon.propTypes = {
|
|
|
56
114
|
|
|
57
115
|
/** Size for vertical and horizontal of the SVG.
|
|
58
116
|
* Use it as one of theme.spacing tokens (xxsmall, small, medium...) */
|
|
59
|
-
size:
|
|
60
|
-
var _checkPropTypes;
|
|
61
|
-
|
|
62
|
-
var size = props.size,
|
|
63
|
-
width = props.width,
|
|
64
|
-
height = props.height;
|
|
65
|
-
|
|
66
|
-
if (size && (width || height)) {
|
|
67
|
-
return new Error("you must use only " + propName + ", alone, or width and/or height in " + componentName);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
checkPropTypes((_checkPropTypes = {}, _checkPropTypes[propName] = oneOfType([oneOf(commonSizes), string, number]), _checkPropTypes), {
|
|
71
|
-
size: size
|
|
72
|
-
}, 'prop', componentName);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
117
|
+
size: oneOfType([oneOf(commonSizes), string, number])
|
|
75
118
|
};
|
|
76
119
|
Icon.defaultProps = {
|
|
77
120
|
fill: undefined,
|
|
78
121
|
stroke: undefined,
|
|
122
|
+
title: undefined,
|
|
123
|
+
description: undefined,
|
|
124
|
+
ariaLabel: undefined,
|
|
79
125
|
width: undefined,
|
|
80
126
|
height: undefined,
|
|
81
|
-
size:
|
|
127
|
+
size: 12
|
|
82
128
|
};
|
|
83
129
|
export default withTheme(Icon);
|
|
@@ -44,4 +44,17 @@ describe('Snapshots', function () {
|
|
|
44
44
|
|
|
45
45
|
expect(toJSON()).toMatchSnapshot();
|
|
46
46
|
});
|
|
47
|
+
it('should match snapshot with accessible props', function () {
|
|
48
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Icon, {
|
|
49
|
+
as: Circle,
|
|
50
|
+
size: "small",
|
|
51
|
+
fill: "stamina",
|
|
52
|
+
title: "Circle icon",
|
|
53
|
+
description: "This is a circular icon",
|
|
54
|
+
ariaLabel: "circleIcon"
|
|
55
|
+
}))),
|
|
56
|
+
toJSON = _render4.toJSON;
|
|
57
|
+
|
|
58
|
+
expect(toJSON()).toMatchSnapshot();
|
|
59
|
+
});
|
|
47
60
|
});
|
|
@@ -44,4 +44,17 @@ describe('Snapshots', function () {
|
|
|
44
44
|
|
|
45
45
|
expect(container).toMatchSnapshot();
|
|
46
46
|
});
|
|
47
|
+
it('should match snapshot with acessible props', function () {
|
|
48
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Icon, {
|
|
49
|
+
as: Circle,
|
|
50
|
+
size: "small",
|
|
51
|
+
fill: "stamina",
|
|
52
|
+
title: "Circle icon",
|
|
53
|
+
description: "This is a circular icon",
|
|
54
|
+
ariaLabel: "circleIcon"
|
|
55
|
+
}))),
|
|
56
|
+
container = _render4.container;
|
|
57
|
+
|
|
58
|
+
expect(container).toMatchSnapshot();
|
|
59
|
+
});
|
|
47
60
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.81.1",
|
|
4
4
|
"description": "Gympass component library",
|
|
5
5
|
"main": "./cjs",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react-native": "0.72.3",
|
|
56
56
|
"styled-components": "^4.4.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "095b688d0538a0e54143c03e82521e1b2ef02867",
|
|
59
59
|
"module": "./esm",
|
|
60
60
|
"types": "./typings/index.d.ts",
|
|
61
61
|
"private": false,
|