@pingux/astro 1.14.0-alpha.0 → 1.14.0-alpha.11

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.
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
3
5
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
6
 
5
7
  _Object$defineProperty(exports, "__esModule", {
@@ -8,22 +10,19 @@ _Object$defineProperty(exports, "__esModule", {
8
10
 
9
11
  exports["default"] = void 0;
10
12
 
11
- var _react = require("react");
13
+ var _useDevelopmentWarning = _interopRequireDefault(require("../useDevelopmentWarning"));
12
14
 
13
15
  /**
14
16
  * Provides a development-only console warning when a component
15
17
  * that needs an aria-label is mounted without one.
16
- *
17
- * e.g. "\`Component\` requires an aria-label."
18
18
  */
19
19
  var useAriaLabelWarning = function useAriaLabelWarning(component, ariaLabel) {
20
- var condition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
21
- (0, _react.useEffect)(function () {
22
- if (process.env.NODE_ENV === 'development' && condition && !ariaLabel) {
23
- // eslint-disable-next-line no-console
24
- console.warn("".concat(component, " requires an aria-label"), '\n', '\n', 'NOTE: This is a development-only warning and will not display in production.');
25
- }
26
- }, []);
20
+ var shouldTrigger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
21
+ var message = "".concat(component, " has an undefined aria-label. If the surrounding content sufficiently labels this component instance, you may disable this warning by setting the prop to `null`. Otherwise, please provide an appropriate aria-label. See more info here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label");
22
+ (0, _useDevelopmentWarning["default"])({
23
+ message: message,
24
+ shouldTrigger: shouldTrigger && ariaLabel === undefined
25
+ });
27
26
  };
28
27
 
29
28
  var _default = useAriaLabelWarning;
@@ -28,7 +28,7 @@ test('default useAriaLabelWarning', function () {
28
28
  expect(spy).toHaveBeenCalledTimes(1);
29
29
  });
30
30
  test('useAriaLabelWarning with string', function () {
31
- var compound = "".concat(component, " requires an aria-label");
31
+ var compound = "".concat(component, " has an undefined aria-label. If the surrounding content sufficiently labels this component instance, you may disable this warning by setting the prop to `null`. Otherwise, please provide an appropriate aria-label. See more info here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label");
32
32
  var spy = jest.spyOn(console, 'warn');
33
33
  expect(spy).not.toHaveBeenCalled();
34
34
  (0, _reactHooks.renderHook)(function () {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ _Object$defineProperty(exports, "default", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _useDevelopmentWarning["default"];
15
+ }
16
+ });
17
+
18
+ var _useDevelopmentWarning = _interopRequireDefault(require("./useDevelopmentWarning"));
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+
9
+ exports["default"] = void 0;
10
+
11
+ var _react = require("react");
12
+
13
+ /**
14
+ * Provides a development-only console warning.
15
+ */
16
+ var useDevelopmentWarning = function useDevelopmentWarning(_ref) {
17
+ var message = _ref.message,
18
+ shouldTrigger = _ref.shouldTrigger;
19
+ (0, _react.useMemo)(function () {
20
+ if (process.env.NODE_ENV === 'development' && shouldTrigger) {
21
+ // eslint-disable-next-line no-console
22
+ console.warn("".concat(message), '\n', '\n', 'NOTE: This is a development-only warning and will not display in production.');
23
+ }
24
+ }, [message, shouldTrigger]);
25
+ };
26
+
27
+ var _default = useDevelopmentWarning;
28
+ exports["default"] = _default;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _reactHooks = require("@testing-library/react-hooks");
6
+
7
+ var _useDevelopmentWarning = _interopRequireDefault(require("./useDevelopmentWarning"));
8
+
9
+ var message = 'This is test message';
10
+ beforeEach(function () {
11
+ process.env.NODE_ENV = 'development';
12
+
13
+ global.console.warn = function () {
14
+ return jest.mock();
15
+ }; // eslint-disable-line no-console
16
+
17
+ });
18
+ afterEach(function () {
19
+ process.env.NODE_ENV = 'test';
20
+ jest.restoreAllMocks();
21
+ });
22
+ test('useDevelopmentWarning with message and trigger false', function () {
23
+ var spy = jest.spyOn(console, 'warn');
24
+ expect(spy).not.toHaveBeenCalled();
25
+ (0, _reactHooks.renderHook)(function () {
26
+ return (0, _useDevelopmentWarning["default"])({
27
+ message: message,
28
+ shouldTrigger: false
29
+ });
30
+ });
31
+ expect(spy).not.toHaveBeenCalled();
32
+ });
33
+ test('useDevelopmentWarning with message and trigger true', function () {
34
+ var spy = jest.spyOn(console, 'warn');
35
+ expect(spy).not.toHaveBeenCalled();
36
+ (0, _reactHooks.renderHook)(function () {
37
+ return (0, _useDevelopmentWarning["default"])({
38
+ message: message,
39
+ shouldTrigger: true
40
+ });
41
+ });
42
+ expect(spy).toHaveBeenNthCalledWith(1, expect.stringMatching(message), expect.any(String), expect.any(String), expect.any(String));
43
+ });
@@ -1,19 +1,16 @@
1
- import { useEffect } from 'react';
1
+ import useDevelopmentWarning from '../useDevelopmentWarning';
2
2
  /**
3
3
  * Provides a development-only console warning when a component
4
4
  * that needs an aria-label is mounted without one.
5
- *
6
- * e.g. "\`Component\` requires an aria-label."
7
5
  */
8
6
 
9
7
  var useAriaLabelWarning = function useAriaLabelWarning(component, ariaLabel) {
10
- var condition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11
- useEffect(function () {
12
- if (process.env.NODE_ENV === 'development' && condition && !ariaLabel) {
13
- // eslint-disable-next-line no-console
14
- console.warn("".concat(component, " requires an aria-label"), '\n', '\n', 'NOTE: This is a development-only warning and will not display in production.');
15
- }
16
- }, []);
8
+ var shouldTrigger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
9
+ var message = "".concat(component, " has an undefined aria-label. If the surrounding content sufficiently labels this component instance, you may disable this warning by setting the prop to `null`. Otherwise, please provide an appropriate aria-label. See more info here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label");
10
+ useDevelopmentWarning({
11
+ message: message,
12
+ shouldTrigger: shouldTrigger && ariaLabel === undefined
13
+ });
17
14
  };
18
15
 
19
16
  export default useAriaLabelWarning;
@@ -22,7 +22,7 @@ test('default useAriaLabelWarning', function () {
22
22
  expect(spy).toHaveBeenCalledTimes(1);
23
23
  });
24
24
  test('useAriaLabelWarning with string', function () {
25
- var compound = "".concat(component, " requires an aria-label");
25
+ var compound = "".concat(component, " has an undefined aria-label. If the surrounding content sufficiently labels this component instance, you may disable this warning by setting the prop to `null`. Otherwise, please provide an appropriate aria-label. See more info here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label");
26
26
  var spy = jest.spyOn(console, 'warn');
27
27
  expect(spy).not.toHaveBeenCalled();
28
28
  renderHook(function () {
@@ -0,0 +1 @@
1
+ export { default } from './useDevelopmentWarning';
@@ -0,0 +1,17 @@
1
+ import { useMemo } from 'react';
2
+ /**
3
+ * Provides a development-only console warning.
4
+ */
5
+
6
+ var useDevelopmentWarning = function useDevelopmentWarning(_ref) {
7
+ var message = _ref.message,
8
+ shouldTrigger = _ref.shouldTrigger;
9
+ useMemo(function () {
10
+ if (process.env.NODE_ENV === 'development' && shouldTrigger) {
11
+ // eslint-disable-next-line no-console
12
+ console.warn("".concat(message), '\n', '\n', 'NOTE: This is a development-only warning and will not display in production.');
13
+ }
14
+ }, [message, shouldTrigger]);
15
+ };
16
+
17
+ export default useDevelopmentWarning;
@@ -0,0 +1,37 @@
1
+ import { renderHook } from '@testing-library/react-hooks';
2
+ import useDevelopmentWarning from './useDevelopmentWarning';
3
+ var message = 'This is test message';
4
+ beforeEach(function () {
5
+ process.env.NODE_ENV = 'development';
6
+
7
+ global.console.warn = function () {
8
+ return jest.mock();
9
+ }; // eslint-disable-line no-console
10
+
11
+ });
12
+ afterEach(function () {
13
+ process.env.NODE_ENV = 'test';
14
+ jest.restoreAllMocks();
15
+ });
16
+ test('useDevelopmentWarning with message and trigger false', function () {
17
+ var spy = jest.spyOn(console, 'warn');
18
+ expect(spy).not.toHaveBeenCalled();
19
+ renderHook(function () {
20
+ return useDevelopmentWarning({
21
+ message: message,
22
+ shouldTrigger: false
23
+ });
24
+ });
25
+ expect(spy).not.toHaveBeenCalled();
26
+ });
27
+ test('useDevelopmentWarning with message and trigger true', function () {
28
+ var spy = jest.spyOn(console, 'warn');
29
+ expect(spy).not.toHaveBeenCalled();
30
+ renderHook(function () {
31
+ return useDevelopmentWarning({
32
+ message: message,
33
+ shouldTrigger: true
34
+ });
35
+ });
36
+ expect(spy).toHaveBeenNthCalledWith(1, expect.stringMatching(message), expect.any(String), expect.any(String), expect.any(String));
37
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.14.0-alpha.0",
3
+ "version": "1.14.0-alpha.11",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "ux-development@pingidentity.com",
6
6
  "license": "Apache-2.0",