@pingux/astro 1.41.0-alpha.0 → 1.41.0-alpha.2

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/Patterns/AttributeMappingDisplayViewPattern.stories.hidden.js +138 -0
  3. package/lib/Patterns/AttributeMappingEditViewPattern.stories.hidden.js +145 -0
  4. package/lib/Patterns/ListAndPanelPattern.stories.hidden.js +381 -0
  5. package/lib/Patterns/MessagesPattern.stories.hidden.js +69 -0
  6. package/lib/Patterns/SaveBarPattern.stories.hidden.js +80 -0
  7. package/lib/Patterns/UnsavedChangesPattern.stories.hidden.js +106 -0
  8. package/lib/cjs/Patterns/AttributeMappingDisplayViewPattern.stories.hidden.js +158 -0
  9. package/lib/cjs/Patterns/AttributeMappingEditViewPattern.stories.hidden.js +167 -0
  10. package/lib/cjs/Patterns/ListAndPanelPattern.stories.hidden.js +418 -0
  11. package/lib/cjs/Patterns/MessagesPattern.stories.hidden.js +99 -0
  12. package/lib/cjs/Patterns/SaveBarPattern.stories.hidden.js +109 -0
  13. package/lib/cjs/Patterns/UnsavedChangesPattern.stories.hidden.js +136 -0
  14. package/lib/cjs/components/Bracket/Bracket.stories.js +1 -3
  15. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +1 -1
  16. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +2 -18
  17. package/lib/cjs/components/Card/Card.js +117 -2
  18. package/lib/cjs/components/Card/Card.stories.js +45 -17
  19. package/lib/cjs/components/Card/Card.test.js +50 -0
  20. package/lib/cjs/components/CheckboxField/CheckboxField.js +6 -1
  21. package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +13 -1
  22. package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +75 -4
  23. package/lib/cjs/components/DataTable/DataTable.js +56 -12
  24. package/lib/cjs/components/DataTable/DataTable.stories.js +84 -17
  25. package/lib/cjs/components/DataTable/DataTable.test.js +38 -6
  26. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +1 -1
  27. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +18 -3
  28. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +19 -5
  29. package/lib/cjs/components/Image/Image.stories.js +2 -2
  30. package/lib/cjs/components/ListBox/ListBoxSection.js +8 -1
  31. package/lib/cjs/components/ListView/ListView.stories.js +6 -4
  32. package/lib/cjs/components/ListView/ListView.test.js +39 -1
  33. package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +2 -1
  34. package/lib/cjs/components/SelectField/SelectField.stories.js +13 -1
  35. package/lib/cjs/components/SelectField/SelectField.test.js +75 -0
  36. package/lib/cjs/recipes/ConditionalFilter.stories.js +0 -1
  37. package/lib/cjs/recipes/ScrollableListView.stories.js +3 -2
  38. package/lib/cjs/recipes/TrialExperienceIndustryButtons.stories.js +4 -8
  39. package/lib/cjs/styles/variants/boxes.js +6 -6
  40. package/lib/cjs/utils/devUtils/constants/text.js +11 -0
  41. package/lib/components/Bracket/Bracket.stories.js +1 -3
  42. package/lib/components/Breadcrumbs/Breadcrumbs.js +1 -1
  43. package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +0 -13
  44. package/lib/components/Card/Card.js +110 -2
  45. package/lib/components/Card/Card.stories.js +35 -10
  46. package/lib/components/Card/Card.test.js +36 -0
  47. package/lib/components/CheckboxField/CheckboxField.js +5 -1
  48. package/lib/components/ComboBoxField/ComboBoxField.stories.js +13 -1
  49. package/lib/components/ComboBoxField/ComboBoxField.test.js +70 -5
  50. package/lib/components/DataTable/DataTable.js +56 -12
  51. package/lib/components/DataTable/DataTable.stories.js +75 -17
  52. package/lib/components/DataTable/DataTable.test.js +36 -6
  53. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +1 -1
  54. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +18 -3
  55. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +16 -5
  56. package/lib/components/Image/Image.stories.js +2 -2
  57. package/lib/components/ListBox/ListBoxSection.js +7 -2
  58. package/lib/components/ListView/ListView.stories.js +6 -4
  59. package/lib/components/ListView/ListView.test.js +35 -1
  60. package/lib/components/OverlayPanel/OverlayPanel.stories.js +2 -1
  61. package/lib/components/SelectField/SelectField.stories.js +13 -1
  62. package/lib/components/SelectField/SelectField.test.js +68 -1
  63. package/lib/recipes/ConditionalFilter.stories.js +0 -1
  64. package/lib/recipes/ScrollableListView.stories.js +3 -2
  65. package/lib/recipes/TrialExperienceIndustryButtons.stories.js +4 -8
  66. package/lib/styles/variants/boxes.js +6 -6
  67. package/lib/utils/devUtils/constants/text.js +1 -0
  68. package/package.json +1 -1
@@ -26,6 +26,8 @@ var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/consta
26
26
 
27
27
  var _ListView = _interopRequireDefault(require("./ListView"));
28
28
 
29
+ var _CheckboxField = _interopRequireDefault(require("../CheckboxField"));
30
+
29
31
  var _react2 = require("@emotion/react");
30
32
 
31
33
  var items = [{
@@ -104,6 +106,31 @@ var getComponentEmpty = function getComponentEmpty() {
104
106
  }, (0, _react2.jsx)(_ListView["default"], (0, _extends2["default"])({}, defaultProps, props))));
105
107
  };
106
108
 
109
+ var getComponentWithCheckbox = function getComponentWithCheckbox() {
110
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
111
+
112
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
113
+ _ref3$renderFn = _ref3.renderFn,
114
+ renderFn = _ref3$renderFn === void 0 ? _testWrapper.render : _ref3$renderFn;
115
+
116
+ return renderFn((0, _react2.jsx)(_focus.FocusScope, {
117
+ restoreFocus: true
118
+ }, (0, _react2.jsx)(_ListView["default"], (0, _extends2["default"])({}, defaultProps, props, {
119
+ items: items
120
+ }), function (item) {
121
+ return (0, _react2.jsx)(_collections.Item, {
122
+ key: item.key,
123
+ textValue: item.name,
124
+ "data-id": item.key
125
+ }, (0, _react2.jsx)(_CheckboxField["default"], {
126
+ label: item.name,
127
+ containerProps: {
128
+ 'data-testid': 'TestID'
129
+ }
130
+ }));
131
+ })));
132
+ };
133
+
107
134
  test('renders listview component', function () {
108
135
  getComponent();
109
136
 
@@ -354,4 +381,15 @@ test('when user navigates with tab and arrows keys, onFocus is called and the is
354
381
  }
355
382
  }
356
383
  }, _callee7);
357
- })));
384
+ })));
385
+ test('list view not receive focus when click on checkbox', function () {
386
+ getComponentWithCheckbox();
387
+
388
+ var listItem = _testWrapper.screen.getAllByRole('gridcell');
389
+
390
+ var checkbox = _testWrapper.screen.getAllByTestId('TestID');
391
+
392
+ expect(listItem[0]).not.toHaveClass('is-focused');
393
+ checkbox[0].click();
394
+ expect(listItem[0]).not.toHaveClass('is-focused');
395
+ });
@@ -207,7 +207,8 @@ var InnerPanel = function InnerPanel(_ref2) {
207
207
  }, "Open Panel"), outer), messagesOpen && (0, _react2.jsx)(_index.Messages, {
208
208
  sx: {
209
209
  zIndex: 11
210
- }
210
+ },
211
+ onClose: toggleMessagesOpen
211
212
  }, (0, _react2.jsx)(_collections.Item, {
212
213
  key: "message2",
213
214
  status: "success"
@@ -122,6 +122,7 @@ var animals = [{
122
122
  }];
123
123
  var withSection = [{
124
124
  name: 'Animals',
125
+ key: 'Animals',
125
126
  children: [{
126
127
  name: 'Aardvark'
127
128
  }, {
@@ -131,6 +132,7 @@ var withSection = [{
131
132
  }]
132
133
  }, {
133
134
  name: 'People',
135
+ key: 'People',
134
136
  children: [{
135
137
  name: 'Michael'
136
138
  }, {
@@ -138,6 +140,16 @@ var withSection = [{
138
140
  }, {
139
141
  name: 'Creed'
140
142
  }]
143
+ }, {
144
+ name: null,
145
+ key: 'Fruit',
146
+ children: [{
147
+ name: 'Apple'
148
+ }, {
149
+ name: 'Strawberry'
150
+ }, {
151
+ name: 'Blueberry'
152
+ }]
141
153
  }];
142
154
  var _default = {
143
155
  title: 'Form/SelectField',
@@ -221,7 +233,7 @@ var WithSections = function WithSections(args) {
221
233
  items: withSection
222
234
  }, args), function (section) {
223
235
  return (0, _react2.jsx)(_2.Section, {
224
- key: section.name,
236
+ key: section.key,
225
237
  items: section.children,
226
238
  title: section.name
227
239
  }, function (item) {
@@ -6,6 +6,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
6
6
 
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
 
9
+ var _overlays = require("@react-aria/overlays");
10
+
11
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
12
+
9
13
  var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
10
14
 
11
15
  var _testWrapper = require("../../utils/testUtils/testWrapper");
@@ -23,6 +27,37 @@ var items = [{
23
27
  }, {
24
28
  name: 'c'
25
29
  }];
30
+ var withSection = [{
31
+ name: 'Animals',
32
+ key: 'Animals',
33
+ kids: [{
34
+ name: 'Aardvark'
35
+ }, {
36
+ name: 'Kangaroo'
37
+ }, {
38
+ name: 'Snake'
39
+ }]
40
+ }, {
41
+ name: 'People',
42
+ key: 'People',
43
+ kids: [{
44
+ name: 'Michael'
45
+ }, {
46
+ name: 'Dwight'
47
+ }, {
48
+ name: 'Creed'
49
+ }]
50
+ }, {
51
+ name: null,
52
+ key: 'Fruit',
53
+ kids: [{
54
+ name: 'Apple'
55
+ }, {
56
+ name: 'Strawberry'
57
+ }, {
58
+ name: 'Blueberry'
59
+ }]
60
+ }];
26
61
  var testId = 'test-dropdown';
27
62
  var controlTestId = "".concat(testId, "-input");
28
63
  var testValue = 'test';
@@ -48,6 +83,28 @@ var getComponent = function getComponent() {
48
83
  key: item.name
49
84
  }, item.name);
50
85
  }));
86
+ };
87
+
88
+ var getComponentWithSections = function getComponentWithSections() {
89
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90
+
91
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
92
+ _ref2$renderFn = _ref2.renderFn,
93
+ renderFn = _ref2$renderFn === void 0 ? _testWrapper.render : _ref2$renderFn;
94
+
95
+ return renderFn((0, _react2.jsx)(_overlays.OverlayProvider, null, (0, _react2.jsx)(_index.SelectField, (0, _extends2["default"])({}, defaultProps, props, {
96
+ items: withSection
97
+ }), function (section) {
98
+ return (0, _react2.jsx)(_index.Section, {
99
+ key: section.key,
100
+ items: section.kids,
101
+ title: section.name
102
+ }, function (item) {
103
+ return (0, _react2.jsx)(_index.Item, {
104
+ key: item.name
105
+ }, item.name);
106
+ });
107
+ })));
51
108
  }; // Need to be added to each test file to test accessibility using axe.
52
109
 
53
110
 
@@ -102,4 +159,22 @@ test('passing helper text should display it and correct aria attributes on input
102
159
  expect(visibleInput).toHaveAttribute('aria-invalid', 'true');
103
160
  var helperTextID = helper.getAttribute('id');
104
161
  expect(_testWrapper.screen.getByRole('button')).toHaveAttribute('aria-describedby', helperTextID);
162
+ });
163
+ test('passing sections, renders separators', function () {
164
+ getComponentWithSections();
165
+
166
+ var button = _testWrapper.screen.getByRole('button');
167
+
168
+ _userEvent["default"].click(button);
169
+
170
+ expect(_testWrapper.screen.queryAllByRole('separator')).toHaveLength(2);
171
+ });
172
+ test('a blank title does not render', function () {
173
+ getComponentWithSections();
174
+
175
+ var button = _testWrapper.screen.getByRole('button');
176
+
177
+ _userEvent["default"].click(button);
178
+
179
+ expect(_testWrapper.screen.queryByText('Fruit')).not.toBeInTheDocument();
105
180
  });
@@ -141,7 +141,6 @@ var Default = function Default() {
141
141
  isRow: true,
142
142
  key: item.key
143
143
  }, (0, _react2.jsx)(_index.Bracket, null), (0, _react2.jsx)(_index.Box, {
144
- ml: "3px",
145
144
  width: "100%"
146
145
  }, (0, _react2.jsx)(_index.Box, {
147
146
  variant: "forms.input.container",
@@ -128,14 +128,15 @@ var Default = function Default(_ref) {
128
128
  }, (0, _react2.jsx)(_index.Icon, {
129
129
  icon: _FormSelectIcon["default"],
130
130
  mr: "sm",
131
- color: "text.primary",
131
+ color: "accent.40",
132
132
  size: 25
133
133
  }), (0, _react2.jsx)(_index.Text, {
134
134
  variant: "itemTitle",
135
135
  alignSelf: "center"
136
136
  }, item.name)), (0, _react2.jsx)(_index.Box, {
137
137
  isRow: true,
138
- alignSelf: "center"
138
+ alignSelf: "center",
139
+ gap: "sm"
139
140
  }, (0, _react2.jsx)(_index.IconButton, {
140
141
  "aria-label": "create-icon"
141
142
  }, (0, _react2.jsx)(_index.Icon, {
@@ -667,14 +667,10 @@ var buttons = [{
667
667
 
668
668
  var Default = function Default() {
669
669
  var state = (0, _useModalState["default"])();
670
- return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Button, {
671
- onPress: state.open,
672
- "aria-label": "Open modal"
673
- }, "Open Modal"), state.isOpen && (0, _react2.jsx)(_index.Modal, {
674
- isOpen: state.isOpen,
670
+ return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Modal, {
671
+ isOpen: true,
675
672
  onClose: state.close,
676
- contentProps: sx.contentProps,
677
- isDismissable: true
673
+ contentProps: sx.contentProps
678
674
  }, (0, _react2.jsx)(_index.Box, {
679
675
  contentProps: true
680
676
  }, (0, _react2.jsx)(_index.IconButton, {
@@ -701,7 +697,7 @@ var Default = function Default() {
701
697
  }, (0, _react2.jsx)(_index.Icon, {
702
698
  icon: button.icon,
703
699
  sx: sx.iconStyle,
704
- size: "58"
700
+ size: 58
705
701
  }), (0, _react2.jsx)(_index.Text, {
706
702
  sx: sx.buttonLabelStyle
707
703
  }, button.name)));
@@ -36,13 +36,13 @@ var base = {
36
36
  display: 'flex'
37
37
  };
38
38
  var card = {
39
- boxShadow: 'standard',
39
+ boxShadow: '0px 1px 14px rgba(37, 55, 70, 0.15)',
40
+ borderRadius: '3px',
40
41
  p: 'lg',
41
- alignItems: 'center',
42
- justifyContent: 'center',
43
42
  flex: '1 1 0',
44
- fontWeight: 1,
45
- fontSize: 'md'
43
+ fontWeight: 0,
44
+ fontSize: 'md',
45
+ color: 'text.primary'
46
46
  }; // Used to give a border to radio elements
47
47
 
48
48
  var radioContainer = {
@@ -96,7 +96,7 @@ var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
96
96
  },
97
97
  '&.has-separator': {
98
98
  borderBottom: '1px solid',
99
- borderBottomColor: 'line.hairline'
99
+ borderBottomColor: 'neutral.80'
100
100
  },
101
101
  '&.is-focused': {
102
102
  boxShadow: '0 0 0 1px inset #D033FF'
@@ -0,0 +1,11 @@
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.DummyText = void 0;
10
+ var DummyText = "\nSed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,\ntotam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae\ndicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, \nsed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, \nqui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora\nincidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum\nexercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel\neum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem \neum fugiat quo voluptas nulla pariatur? At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis \npraesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate \nnon provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. \nEt harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi \noptio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis \ndolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et \nvoluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut \nreiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.\n";
11
+ exports.DummyText = DummyText;
@@ -41,8 +41,7 @@ export var Default = function Default() {
41
41
  ml: "sm",
42
42
  bg: "background"
43
43
  }, ___EmotionJSX(Box, {
44
- isRow: true,
45
- mb: "xs"
44
+ isRow: true
46
45
  }, ___EmotionJSX(Chip, {
47
46
  label: "Any",
48
47
  bg: "neutral.20",
@@ -57,7 +56,6 @@ export var Default = function Default() {
57
56
  isLast: index === anyConditions.length - 1
58
57
  }), ___EmotionJSX(Box, {
59
58
  mt: "md",
60
- ml: "xs",
61
59
  variant: "forms.input.container",
62
60
  bg: "white",
63
61
  isRow: true,
@@ -55,7 +55,7 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
55
55
  "aria-hidden": "true",
56
56
  icon: icon,
57
57
  mx: 5,
58
- size: 16
58
+ size: "xs"
59
59
  }, iconProps)));
60
60
  }, [children.length, filteredChildren, icon, iconProps, onAction]);
61
61
  return ___EmotionJSX("nav", {
@@ -61,17 +61,4 @@ export var Default = function Default(args) {
61
61
  "data-id": "march",
62
62
  href: "https://www.pingidentity.com"
63
63
  }, "March 2020 Assets"));
64
- };
65
- export var WithSpan = function WithSpan() {
66
- return ___EmotionJSX(Breadcrumbs, {
67
- icon: ChevronRightIcon
68
- }, ___EmotionJSX(Item, {
69
- key: "Parent",
70
- "aria-label": "parent",
71
- elementType: "span"
72
- }, "Parent"), ___EmotionJSX(Item, {
73
- key: "FonsVernall",
74
- "aria-label": "fons-vernall",
75
- elementType: "span"
76
- }, "Fons Vernall"));
77
64
  };
@@ -1,6 +1,13 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "onHoverStart", "onHoverChange", "onHoverEnd", "onPress", "onPressStart", "onPressEnd", "onPressChange", "onPressUp"];
2
4
  import React, { forwardRef } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { mergeProps } from '@react-aria/utils';
7
+ import { useHover, usePress } from '@react-aria/interactions';
8
+ import { useFocusRing } from '@react-aria/focus';
3
9
  import Box from '../Box';
10
+ import { useStatusClasses } from '../../hooks';
4
11
  /**
5
12
  * A Box component built for the common "Card" use case. Has default variant of card.
6
13
  * See Box for list of props.
@@ -8,10 +15,111 @@ import Box from '../Box';
8
15
 
9
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
10
17
  var Card = /*#__PURE__*/forwardRef(function (props, ref) {
18
+ var className = props.className,
19
+ onHoverStart = props.onHoverStart,
20
+ onHoverChange = props.onHoverChange,
21
+ onHoverEnd = props.onHoverEnd,
22
+ onPress = props.onPress,
23
+ onPressStart = props.onPressStart,
24
+ onPressEnd = props.onPressEnd,
25
+ onPressChange = props.onPressChange,
26
+ onPressUp = props.onPressUp,
27
+ others = _objectWithoutProperties(props, _excluded);
28
+
29
+ var _useHover = useHover(props),
30
+ hoverProps = _useHover.hoverProps,
31
+ isHovered = _useHover.isHovered;
32
+
33
+ var _useFocusRing = useFocusRing(),
34
+ focusProps = _useFocusRing.focusProps,
35
+ isFocusVisible = _useFocusRing.isFocusVisible;
36
+
37
+ var _usePress = usePress({
38
+ ref: ref,
39
+ onPress: onPress,
40
+ onPressStart: onPressStart,
41
+ onPressEnd: onPressEnd,
42
+ onPressChange: onPressChange,
43
+ onPressUp: onPressUp
44
+ }),
45
+ pressProps = _usePress.pressProps,
46
+ isPressed = _usePress.isPressed;
47
+
48
+ var _useFocusRing2 = useFocusRing({
49
+ within: true
50
+ }),
51
+ focusWithinProps = _useFocusRing2.focusProps,
52
+ isFocusedWithin = _useFocusRing2.isFocusVisible;
53
+
54
+ var _useStatusClasses = useStatusClasses(className, {
55
+ isHovered: isHovered,
56
+ isPressed: isPressed,
57
+ isFocused: isFocusVisible || isFocusedWithin
58
+ }),
59
+ classNames = _useStatusClasses.classNames;
60
+
61
+ var ariaLabel = props['aria-label'];
11
62
  return ___EmotionJSX(Box, _extends({
63
+ "aria-label": ariaLabel,
12
64
  variant: "boxes.card",
13
- ref: ref
14
- }, props));
65
+ className: classNames,
66
+ ref: ref,
67
+ isFocused: isFocusVisible
68
+ }, others, mergeProps(hoverProps, pressProps, focusProps, focusWithinProps)));
15
69
  });
70
+ Card.propTypes = {
71
+ /** Defines a string value that labels the current element. */
72
+ 'aria-label': PropTypes.string,
73
+
74
+ /**
75
+ * Handler that is called when a hover interaction starts.
76
+ * (e: HoverEvent) => void
77
+ */
78
+ onHoverStart: PropTypes.func,
79
+
80
+ /**
81
+ * Handler that is called when a hover interaction ends.
82
+ * (e: HoverEvent) => void
83
+ */
84
+ onHoverEnd: PropTypes.func,
85
+
86
+ /**
87
+ * Handler that is called when the hover state changes.
88
+ * (isHovering: boolean) => void
89
+ */
90
+ onHoverChange: PropTypes.func,
91
+
92
+ /**
93
+ * Handler that is called when the press is released over the target.
94
+ * (e: PressEvent) => void
95
+ */
96
+ onPress: PropTypes.func,
97
+
98
+ /**
99
+ * Handler that is called when a press interaction starts.
100
+ * (e: PressEvent) => void
101
+ */
102
+ onPressStart: PropTypes.func,
103
+
104
+ /**
105
+ * Handler that is called when a press interaction ends, either over the target or when the
106
+ * pointer leaves the target.
107
+ * (e: PressEvent) => void
108
+ */
109
+ onPressEnd: PropTypes.func,
110
+
111
+ /**
112
+ * Handler that is called when the press state changes.
113
+ * (isPressed: boolean) => void
114
+ */
115
+ onPressChange: PropTypes.func,
116
+
117
+ /**
118
+ * Handler that is called when a press is released over the target, regardless of whether it
119
+ * started on the target or not.
120
+ * (e: PressEvent) => void
121
+ */
122
+ onPressUp: PropTypes.func
123
+ };
16
124
  Card.displayName = 'Card';
17
125
  export default Card;
@@ -1,6 +1,6 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
1
2
  import React from 'react';
2
- import Card from './Card';
3
- import Box from '../Box';
3
+ import { Box, Button, Card } from '../../index';
4
4
  import { jsx as ___EmotionJSX } from "@emotion/react";
5
5
  export default {
6
6
  title: 'Components/Card',
@@ -8,7 +8,7 @@ export default {
8
8
  argTypes: {
9
9
  children: {
10
10
  description: 'Card content.',
11
- defaultValue: 'Card Children',
11
+ defaultValue: 'Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut at enim nunc. Cras congue consequat odio, ac sodales lacus imperdiet quis. In id ex eu lorem sollicitudin hendrerit feugiat ultrices elit. Curabitur imperdiet libero vitae luctus blandit. Ut ac dignissim tortor. Pellentesque convallis eu metus vitae mollis. Donec sapien felis, laoreet eu egestas eu, blandit quis tellus. Donec luctus suscipit nibh, et tincidunt nisl facilisis ut. Mauris molestie purus at lectus venenatis, ac ultrices felis ultrices.',
12
12
  table: {
13
13
  type: {}
14
14
  },
@@ -21,7 +21,7 @@ export default {
21
21
  export var Default = function Default(args) {
22
22
  return ___EmotionJSX(Card, args);
23
23
  };
24
- export var CardRow = function CardRow() {
24
+ export var CardRow = function CardRow(args) {
25
25
  var sx = {
26
26
  li: {
27
27
  display: 'inline',
@@ -40,17 +40,42 @@ export var CardRow = function CardRow() {
40
40
  }, ___EmotionJSX(Box, {
41
41
  as: "li",
42
42
  sx: sx.li
43
- }, ___EmotionJSX(Card, {
43
+ }, ___EmotionJSX(Card, _extends({
44
44
  sx: sx.card
45
- }, "First")), ___EmotionJSX(Box, {
45
+ }, args))), ___EmotionJSX(Box, {
46
46
  as: "li",
47
47
  sx: sx.li
48
- }, ___EmotionJSX(Card, {
48
+ }, ___EmotionJSX(Card, _extends({
49
49
  sx: sx.card
50
- }, "Second")), ___EmotionJSX(Box, {
50
+ }, args))), ___EmotionJSX(Box, {
51
51
  as: "li",
52
52
  sx: sx.li
53
- }, ___EmotionJSX(Card, {
53
+ }, ___EmotionJSX(Card, _extends({
54
54
  sx: sx.card
55
- }, "Third")));
55
+ }, args))));
56
+ };
57
+ export var InteractiveCard = function InteractiveCard() {
58
+ var sx = {
59
+ alignContent: 'center',
60
+ height: '221px',
61
+ justifyContent: 'center',
62
+ textAlign: 'center',
63
+ width: '233px'
64
+ };
65
+ return ___EmotionJSX(Card, {
66
+ onPress: function onPress() {
67
+ return console.log('card pressed');
68
+ },
69
+ onHoverStart: function onHoverStart() {
70
+ return console.log('card hovered');
71
+ },
72
+ tabIndex: "0",
73
+ sx: sx
74
+ }, "Interactive Card", ___EmotionJSX(Button, {
75
+ variant: "inline",
76
+ mt: "md",
77
+ onPress: function onPress() {
78
+ return console.log('button pressed');
79
+ }
80
+ }, "Explore"));
56
81
  };
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React from 'react';
3
3
  import { render, screen } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
4
5
  import Card from './Card';
5
6
  import Button from '../Button';
6
7
  import axeTest from '../../utils/testUtils/testAxe';
@@ -31,4 +32,39 @@ test('renders children within Card component', function () {
31
32
  });
32
33
  var mockedChildren = screen.getByRole('button');
33
34
  expect(mockedChildren).toBeInTheDocument();
35
+ });
36
+ test('card allows hover, focus, and press events', function () {
37
+ var children = ___EmotionJSX(Button, null);
38
+
39
+ var onPress = jest.fn();
40
+ getComponent({
41
+ children: children,
42
+ onPress: onPress,
43
+ tabIndex: 0
44
+ });
45
+ var card = screen.getByTestId(testId);
46
+ expect(card).not.toHaveClass('is-hovered');
47
+ userEvent.hover(card);
48
+ expect(card).toHaveClass('is-hovered');
49
+ userEvent.click(card);
50
+ expect(onPress).toHaveBeenCalled();
51
+ expect(card).not.toHaveClass('is-focused');
52
+ userEvent.tab();
53
+ expect(card).toHaveClass('is-focused');
54
+ });
55
+ test('allows focus within card', function () {
56
+ var children = ___EmotionJSX(Button, null);
57
+
58
+ getComponent({
59
+ children: children,
60
+ tabIndex: 0
61
+ });
62
+ var button = screen.getByRole('button');
63
+ var card = screen.getByTestId(testId);
64
+ expect(button).not.toHaveClass('is-focused');
65
+ userEvent.tab();
66
+ expect(button).not.toHaveClass('is-focused');
67
+ expect(card).toHaveClass('is-focused');
68
+ userEvent.tab();
69
+ expect(button).toHaveClass('is-focused');
34
70
  });
@@ -17,6 +17,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
17
  import React, { forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
18
18
  import { useCheckbox } from '@react-aria/checkbox';
19
19
  import { useToggleState } from '@react-stately/toggle';
20
+ import { usePress } from '@react-aria/interactions';
20
21
  import PropTypes from 'prop-types';
21
22
  import { v4 as uuid } from 'uuid';
22
23
  import { Box, Checkbox, FieldHelperText, Label } from '../../';
@@ -47,6 +48,9 @@ var CheckboxField = /*#__PURE__*/forwardRef(function (props, ref) {
47
48
  defaultSelected: isDefaultSelected || controlProps.isDefaultSelected
48
49
  }, props), controlProps);
49
50
 
51
+ var _usePress = usePress(props),
52
+ containerPressProps = _usePress.pressProps;
53
+
50
54
  var state = useToggleState(checkboxProps);
51
55
  var checkboxRef = useRef();
52
56
  usePropWarning(props, 'disabled', 'isDisabled');
@@ -66,7 +70,7 @@ var CheckboxField = /*#__PURE__*/forwardRef(function (props, ref) {
66
70
  var _useCheckbox = useCheckbox(checkboxProps, state, checkboxRef),
67
71
  inputProps = _useCheckbox.inputProps;
68
72
 
69
- var _useField = useField(_objectSpread(_objectSpread({}, props), {}, {
73
+ var _useField = useField(_objectSpread(_objectSpread(_objectSpread({}, containerPressProps), props), {}, {
70
74
  statusClasses: {
71
75
  isIndeterminate: isIndeterminate
72
76
  },
@@ -88,6 +88,7 @@ var animals = [{
88
88
  }];
89
89
  var withSection = [{
90
90
  name: 'Animals',
91
+ key: 'Animals',
91
92
  children: [{
92
93
  name: 'Raccoon'
93
94
  }, {
@@ -97,6 +98,7 @@ var withSection = [{
97
98
  }]
98
99
  }, {
99
100
  name: 'People',
101
+ key: 'People',
100
102
  children: [{
101
103
  name: 'Michael'
102
104
  }, {
@@ -104,6 +106,16 @@ var withSection = [{
104
106
  }, {
105
107
  name: 'Creed'
106
108
  }]
109
+ }, {
110
+ name: null,
111
+ key: 'fruit',
112
+ children: [{
113
+ name: 'Apple'
114
+ }, {
115
+ name: 'Orange'
116
+ }, {
117
+ name: 'Banana'
118
+ }]
107
119
  }];
108
120
  var actions = {
109
121
  onOpenChange: action('onOpenChange'),
@@ -192,7 +204,7 @@ export var WithSections = function WithSections(args) {
192
204
  items: withSection
193
205
  }, args), function (section) {
194
206
  return ___EmotionJSX(Section, {
195
- key: section.name,
207
+ key: section.key,
196
208
  items: section.children,
197
209
  title: section.name
198
210
  }, function (item) {