@pingux/astro 1.36.2 → 1.36.3-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.
@@ -324,11 +324,11 @@ exports.Controlled = Controlled;
324
324
 
325
325
  var AccordionWithInputs = function AccordionWithInputs() {
326
326
  return (0, _react2.jsx)(_AccordionGridGroup["default"], {
327
- items: data
327
+ items: data,
328
+ defaultSelectedKeys: ['Organization']
328
329
  }, function (item) {
329
330
  return (0, _react2.jsx)(_collections.Item, {
330
- key: item.key,
331
- textValue: item.name
331
+ key: item.key
332
332
  }, (0, _react2.jsx)(_index.Text, {
333
333
  sx: {
334
334
  fontWeight: 3,
@@ -42,7 +42,7 @@ var _isIterable = require("../../utils/devUtils/props/isIterable");
42
42
 
43
43
  var _react2 = require("@emotion/react");
44
44
 
45
- var _excluded = ["onExpandedChange"];
45
+ var _excluded = ["defaultExpandedKeys", "expandedKeys", "onExpandedChange"];
46
46
 
47
47
  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); }
48
48
 
@@ -59,7 +59,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
59
59
  var AccordionGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
60
60
  var _context;
61
61
 
62
- var onExpandedChange = props.onExpandedChange,
62
+ var defaultExpandedKeys = props.defaultExpandedKeys,
63
+ expandedKeys = props.expandedKeys,
64
+ onExpandedChange = props.onExpandedChange,
63
65
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
64
66
  var state = (0, _tree.useTreeState)(props);
65
67
  var accordionRef = (0, _react.useRef)();
@@ -73,6 +75,11 @@ var AccordionGroup = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
73
75
  (0, _react.useImperativeHandle)(ref, function () {
74
76
  return accordionRef.current;
75
77
  });
78
+ (0, _react.useEffect)(function () {
79
+ if (expandedKeys || defaultExpandedKeys) {
80
+ state.selectionManager.setFocused(true);
81
+ }
82
+ }, [defaultExpandedKeys, expandedKeys, state.selectionManager]);
76
83
  return (0, _react2.jsx)(_AccordionContext.AccordionContext.Provider, {
77
84
  value: state
78
85
  }, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
@@ -70,6 +70,23 @@ var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
70
70
  textValue: "Duplicate",
71
71
  "data-id": "third"
72
72
  }, (0, _react2.jsx)(_Text["default"], null, "Render me!")))));
73
+ };
74
+
75
+ var getComponentWithInput = function getComponentWithInput() {
76
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
77
+ return (0, _testWrapper.render)((0, _react2.jsx)(_AccordionGroup["default"], (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_collections.Item, {
78
+ key: "first",
79
+ textValue: "Duplicate",
80
+ "data-id": "first",
81
+ label: "Accordion item"
82
+ }, (0, _react2.jsx)(_Text["default"], null, "Render me!")), (0, _react2.jsx)(_collections.Item, {
83
+ key: "second",
84
+ textValue: "Duplicate",
85
+ "data-id": "second",
86
+ label: "Accordion item"
87
+ }, (0, _react2.jsx)("input", {
88
+ "data-testid": "testInput"
89
+ }))));
73
90
  }; // Need to be added to each test file to test accessibility using axe.
74
91
 
75
92
 
@@ -268,6 +285,19 @@ test('expanded keys expands an accordion item', function () {
268
285
  var selectedItem = buttons[0];
269
286
  expect(selectedItem).toHaveAttribute('aria-expanded', 'true');
270
287
  });
288
+ test('input recives focus in expanded accordion item when click', function () {
289
+ getComponentWithInput({
290
+ expandedKeys: ['second']
291
+ });
292
+
293
+ var input = _testWrapper.screen.getByTestId('testInput');
294
+
295
+ expect(input).not.toHaveFocus();
296
+
297
+ _userEvent["default"].click(input);
298
+
299
+ expect(input).toHaveFocus();
300
+ });
271
301
  test('able to click a textfield that is the rendered child of an accordion', function () {
272
302
  getComponent({
273
303
  expandedKeys: ['third']
@@ -95,8 +95,7 @@ var NavBar = function NavBar(props) {
95
95
  role: "navigation",
96
96
  as: "nav"
97
97
  }, items.length ? (0, _react2.jsx)(_focus.FocusScope, {
98
- restoreFocus: true,
99
- autoFocus: true
98
+ restoreFocus: true
100
99
  }, (0, _map["default"])(items).call(items, function (_ref) {
101
100
  var item = _ref.item,
102
101
  key = _ref.key;
@@ -76,7 +76,8 @@ var buttons = {
76
76
  },
77
77
  environmentBreadcrumb: {
78
78
  current: {
79
- '&:hover:not(.disabled)': _objectSpread({}, _theme["default"].buttons.environmentBreadcrumb.current)
79
+ '&:hover:not(.disabled)': _objectSpread({}, _theme["default"].buttons.environmentBreadcrumb.current),
80
+ '&:focus': _objectSpread({}, _theme["default"].buttons.environmentBreadcrumb.current)
80
81
  }
81
82
  },
82
83
  rocker: _objectSpread(_objectSpread({}, _theme["default"].buttons.rocker), {}, {
@@ -565,6 +565,9 @@ var environmentBreadcrumb = {
565
565
  borderRadius: '2px',
566
566
  boxShadow: '0 0 0 1px #4462ED'
567
567
  },
568
+ '&:focus-visible': {
569
+ outline: 'none'
570
+ },
568
571
  '&.is-pressed': {
569
572
  color: 'accent.20',
570
573
  textDecoration: 'none'
@@ -286,11 +286,11 @@ export var Controlled = function Controlled() {
286
286
 
287
287
  export var AccordionWithInputs = function AccordionWithInputs() {
288
288
  return ___EmotionJSX(AccordionGridGroup, {
289
- items: data
289
+ items: data,
290
+ defaultSelectedKeys: ['Organization']
290
291
  }, function (item) {
291
292
  return ___EmotionJSX(Item, {
292
- key: item.key,
293
- textValue: item.name
293
+ key: item.key
294
294
  }, ___EmotionJSX(Text, {
295
295
  sx: {
296
296
  fontWeight: 3,
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
3
3
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
4
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["onExpandedChange"];
6
- import React, { forwardRef, useRef, useImperativeHandle } from 'react';
5
+ var _excluded = ["defaultExpandedKeys", "expandedKeys", "onExpandedChange"];
6
+ import React, { forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
7
7
  import { useAccordion } from '@react-aria/accordion';
8
8
  import { useTreeState } from '@react-stately/tree';
9
9
  import PropTypes from 'prop-types';
@@ -24,7 +24,9 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
24
24
  var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
25
25
  var _context;
26
26
 
27
- var onExpandedChange = props.onExpandedChange,
27
+ var defaultExpandedKeys = props.defaultExpandedKeys,
28
+ expandedKeys = props.expandedKeys,
29
+ onExpandedChange = props.onExpandedChange,
28
30
  others = _objectWithoutProperties(props, _excluded);
29
31
 
30
32
  var state = useTreeState(props);
@@ -39,6 +41,11 @@ var AccordionGroup = /*#__PURE__*/forwardRef(function (props, ref) {
39
41
  useImperativeHandle(ref, function () {
40
42
  return accordionRef.current;
41
43
  });
44
+ useEffect(function () {
45
+ if (expandedKeys || defaultExpandedKeys) {
46
+ state.selectionManager.setFocused(true);
47
+ }
48
+ }, [defaultExpandedKeys, expandedKeys, state.selectionManager]);
42
49
  return ___EmotionJSX(AccordionContext.Provider, {
43
50
  value: state
44
51
  }, ___EmotionJSX(Box, _extends({
@@ -55,6 +55,23 @@ var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
55
55
  textValue: "Duplicate",
56
56
  "data-id": "third"
57
57
  }, ___EmotionJSX(Text, null, "Render me!")))));
58
+ };
59
+
60
+ var getComponentWithInput = function getComponentWithInput() {
61
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
+ return render(___EmotionJSX(AccordionGroup, _extends({}, defaultProps, props), ___EmotionJSX(Item, {
63
+ key: "first",
64
+ textValue: "Duplicate",
65
+ "data-id": "first",
66
+ label: "Accordion item"
67
+ }, ___EmotionJSX(Text, null, "Render me!")), ___EmotionJSX(Item, {
68
+ key: "second",
69
+ textValue: "Duplicate",
70
+ "data-id": "second",
71
+ label: "Accordion item"
72
+ }, ___EmotionJSX("input", {
73
+ "data-testid": "testInput"
74
+ }))));
58
75
  }; // Need to be added to each test file to test accessibility using axe.
59
76
 
60
77
 
@@ -205,6 +222,15 @@ test('expanded keys expands an accordion item', function () {
205
222
  var selectedItem = buttons[0];
206
223
  expect(selectedItem).toHaveAttribute('aria-expanded', 'true');
207
224
  });
225
+ test('input recives focus in expanded accordion item when click', function () {
226
+ getComponentWithInput({
227
+ expandedKeys: ['second']
228
+ });
229
+ var input = screen.getByTestId('testInput');
230
+ expect(input).not.toHaveFocus();
231
+ userEvent.click(input);
232
+ expect(input).toHaveFocus();
233
+ });
208
234
  test('able to click a textfield that is the rendered child of an accordion', function () {
209
235
  getComponent({
210
236
  expandedKeys: ['third']
@@ -62,8 +62,7 @@ var NavBar = function NavBar(props) {
62
62
  role: "navigation",
63
63
  as: "nav"
64
64
  }, items.length ? ___EmotionJSX(FocusScope, {
65
- restoreFocus: true,
66
- autoFocus: true
65
+ restoreFocus: true
67
66
  }, _mapInstanceProperty(items).call(items, function (_ref) {
68
67
  var item = _ref.item,
69
68
  key = _ref.key;
@@ -57,7 +57,8 @@ var buttons = {
57
57
  },
58
58
  environmentBreadcrumb: {
59
59
  current: {
60
- '&:hover:not(.disabled)': _objectSpread({}, theme.buttons.environmentBreadcrumb.current)
60
+ '&:hover:not(.disabled)': _objectSpread({}, theme.buttons.environmentBreadcrumb.current),
61
+ '&:focus': _objectSpread({}, theme.buttons.environmentBreadcrumb.current)
61
62
  }
62
63
  },
63
64
  rocker: _objectSpread(_objectSpread({}, theme.buttons.rocker), {}, {
@@ -544,6 +544,9 @@ var environmentBreadcrumb = {
544
544
  borderRadius: '2px',
545
545
  boxShadow: '0 0 0 1px #4462ED'
546
546
  },
547
+ '&:focus-visible': {
548
+ outline: 'none'
549
+ },
547
550
  '&.is-pressed': {
548
551
  color: 'accent.20',
549
552
  textDecoration: 'none'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.36.2",
3
+ "version": "1.36.3-alpha.1",
4
4
  "description": "PingUX themeable React component library",
5
5
  "repository": {
6
6
  "type": "git",