@pingux/astro 1.17.0-alpha.0 → 1.17.0-alpha.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.
@@ -56,7 +56,7 @@ var _colors = require("../../styles/colors");
56
56
 
57
57
  var _templateObject;
58
58
 
59
- var _excluded = ["className", "fallbackImage", "fallbackTimeout", "isDisabled", "src", "sx"];
59
+ var _excluded = ["className", "fallbackImage", "fallbackTimeout", "isDisabled", "src", "alt", "sx"];
60
60
 
61
61
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
62
62
 
@@ -77,6 +77,7 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
77
77
  fallbackTimeout = props.fallbackTimeout,
78
78
  isDisabled = props.isDisabled,
79
79
  src = props.src,
80
+ alt = props.alt,
80
81
  sx = props.sx,
81
82
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
82
83
 
@@ -122,6 +123,8 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
122
123
  return imgRef.current;
123
124
  });
124
125
  (0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
126
+ var ariaLabel = props['aria-label'] || alt;
127
+ (0, _hooks.useAriaLabelWarning)('Image', ariaLabel);
125
128
 
126
129
  var _useHover = (0, _interactions.useHover)(props),
127
130
  hoverProps = _useHover.hoverProps,
@@ -178,7 +181,7 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
178
181
  var themeUiImage = (0, _react2.jsx)(_themeUi.Image, (0, _extends2["default"])({
179
182
  className: classNames,
180
183
  ref: imgRef,
181
- alt: "Image",
184
+ alt: alt,
182
185
  role: "img",
183
186
  src: imgSrc,
184
187
  sx: sx
@@ -212,7 +215,15 @@ Image.propTypes = {
212
215
  fallbackImage: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]),
213
216
 
214
217
  /** Time in milliseconds that component should wait for a response from src address. */
215
- fallbackTimeout: _propTypes["default"].number
218
+ fallbackTimeout: _propTypes["default"].number,
219
+
220
+ /** Descriptive text for an image. This is *highly* recommended in most cases.
221
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt).
222
+ * */
223
+ alt: _propTypes["default"].string,
224
+
225
+ /** Defines a string value that labels the current element. */
226
+ 'aria-label': _propTypes["default"].string
216
227
  };
217
228
  Image.defaultProps = {
218
229
  isDisabled: false,
@@ -67,7 +67,9 @@ exports["default"] = _default;
67
67
 
68
68
  var Default = function Default(_ref) {
69
69
  var args = (0, _extends2["default"])({}, _ref);
70
- return (0, _react2.jsx)(_["default"], args);
70
+ return (0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, args, {
71
+ alt: "Ping identity square logo"
72
+ }));
71
73
  };
72
74
 
73
75
  exports.Default = Default;
@@ -75,7 +77,8 @@ exports.Default = Default;
75
77
  var Avatar = function Avatar() {
76
78
  return (0, _react2.jsx)(_["default"], {
77
79
  src: _imageConstants.pingImg,
78
- variant: "images.avatar"
80
+ variant: "images.avatar",
81
+ alt: "Ping identity round avatar"
79
82
  });
80
83
  };
81
84
 
@@ -89,7 +92,8 @@ var CustomSizeAndRadius = function CustomSizeAndRadius() {
89
92
  height: '70px',
90
93
  borderRadius: 8,
91
94
  bg: 'neutral.90'
92
- }
95
+ },
96
+ alt: "Terry Crews in a red suite"
93
97
  });
94
98
  };
95
99
 
@@ -98,7 +102,8 @@ exports.CustomSizeAndRadius = CustomSizeAndRadius;
98
102
  var Disabled = function Disabled() {
99
103
  return (0, _react2.jsx)(_["default"], {
100
104
  src: _imageConstants.pingImg,
101
- isDisabled: true
105
+ isDisabled: true,
106
+ alt: "Ping identity square logo"
102
107
  });
103
108
  };
104
109
 
@@ -111,7 +116,8 @@ var FallbackImage = function FallbackImage() {
111
116
  sx: {
112
117
  width: '150px',
113
118
  height: '150px'
114
- }
119
+ },
120
+ alt: "Random image"
115
121
  });
116
122
  };
117
123
 
@@ -125,7 +131,8 @@ var WithSkeletonLoadSuccess = function WithSkeletonLoadSuccess(_ref2) {
125
131
  sx: {
126
132
  width: '150px',
127
133
  height: '150px'
128
- }
134
+ },
135
+ alt: "Random image"
129
136
  });
130
137
  };
131
138
 
@@ -140,7 +147,8 @@ var WithSkeletonLoadTimeout = function WithSkeletonLoadTimeout() {
140
147
  sx: {
141
148
  width: '150px',
142
149
  height: '150px'
143
- }
150
+ },
151
+ alt: "Random image"
144
152
  });
145
153
  };
146
154
 
@@ -169,7 +177,8 @@ var UpdatingImageSrc = function UpdatingImageSrc() {
169
177
  width: '200px',
170
178
  height: '200px',
171
179
  mt: '25px'
172
- }
180
+ },
181
+ alt: image === _imageConstants.pingImg ? 'Ping identity square logo' : 'Terry Crews in a red suite'
173
182
  }));
174
183
  };
175
184
 
@@ -101,6 +101,15 @@ test('image shows disabled status', function () {
101
101
 
102
102
  expect(img).toHaveClass('is-disabled');
103
103
  });
104
+ test('image with alt text', function () {
105
+ getComponent({
106
+ alt: 'Test'
107
+ });
108
+ (0, _react2.act)(function () {
109
+ fallbackImageObj.onImageLoad();
110
+ });
111
+ expect(_testWrapper.screen.getByAltText('Test')).toBeInTheDocument();
112
+ });
104
113
  test('image source is able to be changed', function () {
105
114
  var src2 = 'second-src';
106
115
 
@@ -14,7 +14,7 @@ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectW
14
14
 
15
15
  var _templateObject;
16
16
 
17
- var _excluded = ["className", "fallbackImage", "fallbackTimeout", "isDisabled", "src", "sx"];
17
+ var _excluded = ["className", "fallbackImage", "fallbackTimeout", "isDisabled", "src", "alt", "sx"];
18
18
 
19
19
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
20
 
@@ -25,7 +25,7 @@ import PropTypes from 'prop-types';
25
25
  import { Image as ThemeUIImage } from 'theme-ui';
26
26
  import { useHover } from '@react-aria/interactions';
27
27
  import { keyframes } from '@emotion/react';
28
- import { usePropWarning, useStatusClasses, useFallbackImage } from '../../hooks';
28
+ import { usePropWarning, useStatusClasses, useFallbackImage, useAriaLabelWarning } from '../../hooks';
29
29
  import { Box } from '../../index';
30
30
  import { neutral } from '../../styles/colors';
31
31
  /**
@@ -41,6 +41,7 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
41
41
  fallbackTimeout = props.fallbackTimeout,
42
42
  isDisabled = props.isDisabled,
43
43
  src = props.src,
44
+ alt = props.alt,
44
45
  sx = props.sx,
45
46
  others = _objectWithoutProperties(props, _excluded);
46
47
 
@@ -86,6 +87,8 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
86
87
  return imgRef.current;
87
88
  });
88
89
  usePropWarning(props, 'disabled', 'isDisabled');
90
+ var ariaLabel = props['aria-label'] || alt;
91
+ useAriaLabelWarning('Image', ariaLabel);
89
92
 
90
93
  var _useHover = useHover(props),
91
94
  hoverProps = _useHover.hoverProps,
@@ -142,7 +145,7 @@ var Image = /*#__PURE__*/forwardRef(function (props, ref) {
142
145
  var themeUiImage = ___EmotionJSX(ThemeUIImage, _extends({
143
146
  className: classNames,
144
147
  ref: imgRef,
145
- alt: "Image",
148
+ alt: alt,
146
149
  role: "img",
147
150
  src: imgSrc,
148
151
  sx: sx
@@ -176,7 +179,15 @@ Image.propTypes = {
176
179
  fallbackImage: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
177
180
 
178
181
  /** Time in milliseconds that component should wait for a response from src address. */
179
- fallbackTimeout: PropTypes.number
182
+ fallbackTimeout: PropTypes.number,
183
+
184
+ /** Descriptive text for an image. This is *highly* recommended in most cases.
185
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt).
186
+ * */
187
+ alt: PropTypes.string,
188
+
189
+ /** Defines a string value that labels the current element. */
190
+ 'aria-label': PropTypes.string
180
191
  };
181
192
  Image.defaultProps = {
182
193
  isDisabled: false,
@@ -35,12 +35,15 @@ export default {
35
35
  export var Default = function Default(_ref) {
36
36
  var args = _extends({}, _ref);
37
37
 
38
- return ___EmotionJSX(Image, args);
38
+ return ___EmotionJSX(Image, _extends({}, args, {
39
+ alt: "Ping identity square logo"
40
+ }));
39
41
  };
40
42
  export var Avatar = function Avatar() {
41
43
  return ___EmotionJSX(Image, {
42
44
  src: pingImg,
43
- variant: "images.avatar"
45
+ variant: "images.avatar",
46
+ alt: "Ping identity round avatar"
44
47
  });
45
48
  };
46
49
  export var CustomSizeAndRadius = function CustomSizeAndRadius() {
@@ -51,13 +54,15 @@ export var CustomSizeAndRadius = function CustomSizeAndRadius() {
51
54
  height: '70px',
52
55
  borderRadius: 8,
53
56
  bg: 'neutral.90'
54
- }
57
+ },
58
+ alt: "Terry Crews in a red suite"
55
59
  });
56
60
  };
57
61
  export var Disabled = function Disabled() {
58
62
  return ___EmotionJSX(Image, {
59
63
  src: pingImg,
60
- isDisabled: true
64
+ isDisabled: true,
65
+ alt: "Ping identity square logo"
61
66
  });
62
67
  };
63
68
  export var FallbackImage = function FallbackImage() {
@@ -67,7 +72,8 @@ export var FallbackImage = function FallbackImage() {
67
72
  sx: {
68
73
  width: '150px',
69
74
  height: '150px'
70
- }
75
+ },
76
+ alt: "Random image"
71
77
  });
72
78
  };
73
79
  export var WithSkeletonLoadSuccess = function WithSkeletonLoadSuccess(_ref2) {
@@ -78,7 +84,8 @@ export var WithSkeletonLoadSuccess = function WithSkeletonLoadSuccess(_ref2) {
78
84
  sx: {
79
85
  width: '150px',
80
86
  height: '150px'
81
- }
87
+ },
88
+ alt: "Random image"
82
89
  });
83
90
  };
84
91
  WithSkeletonLoadSuccess.args = {
@@ -90,7 +97,8 @@ export var WithSkeletonLoadTimeout = function WithSkeletonLoadTimeout() {
90
97
  sx: {
91
98
  width: '150px',
92
99
  height: '150px'
93
- }
100
+ },
101
+ alt: "Random image"
94
102
  });
95
103
  };
96
104
  export var UpdatingImageSrc = function UpdatingImageSrc() {
@@ -116,6 +124,7 @@ export var UpdatingImageSrc = function UpdatingImageSrc() {
116
124
  width: '200px',
117
125
  height: '200px',
118
126
  mt: '25px'
119
- }
127
+ },
128
+ alt: image === pingImg ? 'Ping identity square logo' : 'Terry Crews in a red suite'
120
129
  }));
121
130
  };
@@ -76,6 +76,15 @@ test('image shows disabled status', function () {
76
76
  var img = screen.getByRole('img');
77
77
  expect(img).toHaveClass('is-disabled');
78
78
  });
79
+ test('image with alt text', function () {
80
+ getComponent({
81
+ alt: 'Test'
82
+ });
83
+ act(function () {
84
+ fallbackImageObj.onImageLoad();
85
+ });
86
+ expect(screen.getByAltText('Test')).toBeInTheDocument();
87
+ });
79
88
  test('image source is able to be changed', function () {
80
89
  var src2 = 'second-src';
81
90
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.17.0-alpha.0",
3
+ "version": "1.17.0-alpha.1",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "ux-development@pingidentity.com",
6
6
  "license": "Apache-2.0",