@pingux/astro 2.46.0-alpha.4 → 2.46.0-alpha.5

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.
@@ -10,6 +10,7 @@ Accordions should be used:
10
10
  - To organize related information.
11
11
  - To shorten pages and reduce scrolling when it’s not crucial that users review the content.
12
12
  - When white space is at a minimum and content cannot be displayed all at once.
13
+ - With Slots props to insert extra UI elements next to headings.
13
14
 
14
15
  Accordions should not have focusable items as children.
15
16
 
@@ -35,9 +36,14 @@ These keys provide additional functionality to the component.
35
36
  | Tab | Moves focus to the next focusable component. All focusable components in the accordion are included in the page tab sequence.|
36
37
  | Shift + Tab | Moves focus to the previous focusable component. All focusable components in the accordion are included in the page tab sequence. |
37
38
 
39
+ #### Slots
40
+
41
+ The slots prop has been provided for added flexibility. Use the **`postHeading`** slot to add helpHint or icon elements next to the heading
42
+ section. Keep in mind that this component is best suited for specific designs necessitates its use.
43
+
38
44
  #### Screen readers
39
45
 
40
46
  This component uses the following attributes to assist screen readers:
41
47
  - The accordion header button uses the **`aria-expanded`** attribute to indicate when the content expands and collapses.
42
48
  - When expanded, the **`aria-controls`** attribute is added to the button pointing to the content. The button uses **`aria-label`** to provide an accessible name.
43
- - The **`aria-labelledby`** attribute is added to the entire accordion component, which is supplied with the button ID.
49
+ - The **`aria-labelledby`** attribute is added to the entire accordion component, which is supplied with the button ID.
@@ -50,3 +50,4 @@ export declare const CustomPresentation: {
50
50
  };
51
51
  };
52
52
  export declare const LabelWithBadge: (args: any) => React.JSX.Element;
53
+ export declare const AccordionWithSlot: (args: any) => React.JSX.Element;
@@ -8,7 +8,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
8
8
  _Object$defineProperty(exports, "__esModule", {
9
9
  value: true
10
10
  });
11
- exports["default"] = exports.UncontrolledExpanded = exports.Multiple = exports.LabelWithBadge = exports.DisabledState = exports.DifferentLevels = exports.Default = exports.CustomPresentation = exports.ControlledExpanded = void 0;
11
+ exports["default"] = exports.UncontrolledExpanded = exports.Multiple = exports.LabelWithBadge = exports.DisabledState = exports.DifferentLevels = exports.Default = exports.CustomPresentation = exports.ControlledExpanded = exports.AccordionWithSlot = void 0;
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
13
13
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
14
  var _react = _interopRequireWildcard(require("react"));
@@ -318,4 +318,18 @@ var LabelWithBadge = function LabelWithBadge(args) {
318
318
  "data-id": "accordionItem"
319
319
  }, (0, _react2.jsx)(_index.Text, null, "Render me!")));
320
320
  };
321
- exports.LabelWithBadge = LabelWithBadge;
321
+ exports.LabelWithBadge = LabelWithBadge;
322
+ var AccordionWithSlot = function AccordionWithSlot(args) {
323
+ return (0, _react2.jsx)(_index.AccordionGroup, (0, _extends2["default"])({
324
+ labelHeadingTag: "h3"
325
+ }, args), (0, _react2.jsx)(_reactStately.Item, {
326
+ key: "accordionKey",
327
+ textValue: "accordionKey",
328
+ label: "Accordion Label",
329
+ "data-id": "accordionItem",
330
+ slots: {
331
+ postHeading: (0, _react2.jsx)(_index.HelpHint, null, " Text of the popover right here...")
332
+ }
333
+ }, (0, _react2.jsx)(_index.Text, null, "Render me!")));
334
+ };
335
+ exports.AccordionWithSlot = AccordionWithSlot;
@@ -41,17 +41,20 @@ var getComponent = function getComponent() {
41
41
  key: "first",
42
42
  textValue: "Duplicate",
43
43
  "data-id": "first",
44
- label: "Accordion item"
44
+ label: "Accordion item",
45
+ "data-testid": "first"
45
46
  }, (0, _react2.jsx)(_Text["default"], null, "Render me!")), (0, _react2.jsx)(_reactStately.Item, {
46
47
  key: "second",
47
48
  textValue: "Duplicate",
48
49
  "data-id": "second",
49
- label: "Accordion item"
50
+ label: "Accordion item",
51
+ "data-testid": "second"
50
52
  }, (0, _react2.jsx)(_Text["default"], null, "Render me!")), (0, _react2.jsx)(_reactStately.Item, {
51
53
  key: "third",
52
54
  textValue: "Duplicate",
53
55
  "data-id": "third",
54
- label: "Accordion item"
56
+ label: "Accordion item",
57
+ "data-testid": "third"
55
58
  }, (0, _react2.jsx)(_index.TextField, {
56
59
  role: "form",
57
60
  label: "Example Label",
@@ -161,6 +164,15 @@ var getComponentWithMultipleAccordion = function getComponentWithMultipleAccordi
161
164
  "data-id": "connection-configuration-custom-form"
162
165
  }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_Text["default"], null, "other text1"), (0, _react2.jsx)(_Text["default"], null, "another text1")))))));
163
166
  };
167
+ var getComponentWithSlot = function getComponentWithSlot(props) {
168
+ return (0, _testWrapper.render)((0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, defaultProps, props), (0, _react2.jsx)(_reactStately.Item, {
169
+ key: "first",
170
+ textValue: "Duplicate",
171
+ "data-id": "first",
172
+ label: "Accordion item",
173
+ slots: props.slots
174
+ }, (0, _react2.jsx)(_Text["default"], null, "Render me!"))));
175
+ };
164
176
  test('button press uses callback', function () {
165
177
  var onPress = jest.fn();
166
178
  getComponent({
@@ -274,10 +286,8 @@ test('disabled keys prop disables an accordion item', function () {
274
286
  getComponent({
275
287
  disabledKeys: ['first']
276
288
  });
277
- var buttons = _testWrapper.screen.getAllByRole('button');
278
- var selectedItem = buttons[0];
279
- var parentElement = selectedItem.parentElement;
280
- expect(parentElement).toHaveClass('is-disabled');
289
+ var button = _testWrapper.screen.getByTestId('first');
290
+ expect(button).toHaveClass('is-disabled');
281
291
  });
282
292
  test('default expanded keys expands an accordion item', function () {
283
293
  getComponent({
@@ -316,10 +326,10 @@ test('able to click a textfield that is the rendered child of an accordion', fun
316
326
  });
317
327
  test('Item accepts a data-id and the data-id can be found in the DOM', function () {
318
328
  getComponent();
319
- var buttons = _testWrapper.screen.getAllByRole('button');
329
+ var buttons = _testWrapper.screen.getAllByText('Accordion item');
320
330
  var selectedItem = buttons[0];
321
331
  var parentElement = selectedItem.parentElement;
322
- expect(parentElement).toHaveAttribute('data-id', 'first');
332
+ expect(parentElement).toHaveAttribute('data-key', 'first');
323
333
  });
324
334
  test('items do not automatically expand if wrapped in an open OverlayPanel', function () {
325
335
  getComponentInOverlayPanel();
@@ -404,4 +414,14 @@ test('when labelHeadingTag is uppercase, the label is rendered', function () {
404
414
  _testWrapper.screen.getAllByRole('heading', {
405
415
  level: getLabelHeadingLevel(h4Tag)
406
416
  });
417
+ });
418
+ test('renders Accordion component with slot', function () {
419
+ getComponentWithSlot({
420
+ slots: {
421
+ postHeading: (0, _react2.jsx)(_index.HelpHint, {
422
+ "data-testid": "helpHint"
423
+ }, "Text of the popover right here...")
424
+ }
425
+ });
426
+ expect(_testWrapper.screen.getByTestId('helpHint')).toBeInTheDocument();
407
427
  });
@@ -9,6 +9,9 @@ interface AccordionItemProps<T> {
9
9
  'data-id'?: string;
10
10
  children: React.ReactNode;
11
11
  buttonProps?: object;
12
+ slots?: {
13
+ postHeading: React.ReactNode;
14
+ };
12
15
  }
13
16
  declare const AccordionItem: {
14
17
  (props: AccordionItemProps<object>): React.JSX.Element;
@@ -31,6 +31,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
31
31
  var validHeadingTags = ['h1', 'h2', 'h3', 'h4'];
32
32
  exports.validHeadingTags = validHeadingTags;
33
33
  var AccordionItem = function AccordionItem(props) {
34
+ var _item$props$slots, _item$props$slots2;
34
35
  var className = props.className,
35
36
  item = props.item,
36
37
  labelHeadingTag = props.labelHeadingTag;
@@ -81,7 +82,9 @@ var AccordionItem = function AccordionItem(props) {
81
82
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
82
83
  variant: "accordion.accordion",
83
84
  className: itemClasses
84
- }, others, containerProps), (0, _react2.jsx)(_themeUi.Button, (0, _extends2["default"])({
85
+ }, others, containerProps), (0, _react2.jsx)(_index.Box, {
86
+ isRow: true
87
+ }, (0, _react2.jsx)(_themeUi.Button, (0, _extends2["default"])({
85
88
  "aria-label": ariaLabel,
86
89
  ref: buttonRef,
87
90
  sx: {
@@ -104,7 +107,7 @@ var AccordionItem = function AccordionItem(props) {
104
107
  title: {
105
108
  name: isOpen ? 'Menu Up Icon' : 'Menu Down Icon'
106
109
  }
107
- }))), isOpen && (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
110
+ }))), ((_item$props$slots = item.props.slots) === null || _item$props$slots === void 0 ? void 0 : _item$props$slots.postHeading) && ((_item$props$slots2 = item.props.slots) === null || _item$props$slots2 === void 0 ? void 0 : _item$props$slots2.postHeading)), isOpen && (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
108
111
  variant: "accordion.body"
109
112
  }, accordionRegionProps, regionProps, {
110
113
  className: itemClasses
@@ -28,6 +28,9 @@ declare module '@react-types/shared' {
28
28
  sx?: StyleProps;
29
29
  /** Key for the item. */
30
30
  key?: Key;
31
+ slots?: {
32
+ postHeading: React.ReactNode;
33
+ };
31
34
  }
32
35
  }
33
36
  export default ItemProps;
@@ -10,6 +10,7 @@ Accordions should be used:
10
10
  - To organize related information.
11
11
  - To shorten pages and reduce scrolling when it’s not crucial that users review the content.
12
12
  - When white space is at a minimum and content cannot be displayed all at once.
13
+ - With Slots props to insert extra UI elements next to headings.
13
14
 
14
15
  Accordions should not have focusable items as children.
15
16
 
@@ -35,9 +36,14 @@ These keys provide additional functionality to the component.
35
36
  | Tab | Moves focus to the next focusable component. All focusable components in the accordion are included in the page tab sequence.|
36
37
  | Shift + Tab | Moves focus to the previous focusable component. All focusable components in the accordion are included in the page tab sequence. |
37
38
 
39
+ #### Slots
40
+
41
+ The slots prop has been provided for added flexibility. Use the **`postHeading`** slot to add helpHint or icon elements next to the heading
42
+ section. Keep in mind that this component is best suited for specific designs necessitates its use.
43
+
38
44
  #### Screen readers
39
45
 
40
46
  This component uses the following attributes to assist screen readers:
41
47
  - The accordion header button uses the **`aria-expanded`** attribute to indicate when the content expands and collapses.
42
48
  - When expanded, the **`aria-controls`** attribute is added to the button pointing to the content. The button uses **`aria-label`** to provide an accessible name.
43
- - The **`aria-labelledby`** attribute is added to the entire accordion component, which is supplied with the button ID.
49
+ - The **`aria-labelledby`** attribute is added to the entire accordion component, which is supplied with the button ID.
@@ -4,7 +4,7 @@ import React, { useState } from 'react';
4
4
  import { Item } from 'react-stately';
5
5
  import { withDesign } from 'storybook-addon-designs';
6
6
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
7
- import { AccordionGroup, Badge, Box, Button, Text, TextField } from '../../index';
7
+ import { AccordionGroup, Badge, Box, Button, HelpHint, Text, TextField } from '../../index';
8
8
  import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
9
9
  import { validHeadingTags } from '../AccordionItem/AccordionItem';
10
10
  import AccordionReadme from './AccordionGroup';
@@ -296,4 +296,17 @@ export var LabelWithBadge = function LabelWithBadge(args) {
296
296
  }))),
297
297
  "data-id": "accordionItem"
298
298
  }, ___EmotionJSX(Text, null, "Render me!")));
299
+ };
300
+ export var AccordionWithSlot = function AccordionWithSlot(args) {
301
+ return ___EmotionJSX(AccordionGroup, _extends({
302
+ labelHeadingTag: "h3"
303
+ }, args), ___EmotionJSX(Item, {
304
+ key: "accordionKey",
305
+ textValue: "accordionKey",
306
+ label: "Accordion Label",
307
+ "data-id": "accordionItem",
308
+ slots: {
309
+ postHeading: ___EmotionJSX(HelpHint, null, " Text of the popover right here...")
310
+ }
311
+ }, ___EmotionJSX(Text, null, "Render me!")));
299
312
  };
@@ -4,7 +4,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
4
4
  import React from 'react';
5
5
  import { Item } from 'react-stately';
6
6
  import userEvent from '@testing-library/user-event';
7
- import { Box, Button, Menu, OverlayPanel, PopoverMenu, TextField } from '../../index';
7
+ import { Box, Button, HelpHint, Menu, OverlayPanel, PopoverMenu, TextField } from '../../index';
8
8
  import { act, fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
9
9
  import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
10
10
  import { validHeadingTags } from '../AccordionItem/AccordionItem';
@@ -38,17 +38,20 @@ var getComponent = function getComponent() {
38
38
  key: "first",
39
39
  textValue: "Duplicate",
40
40
  "data-id": "first",
41
- label: "Accordion item"
41
+ label: "Accordion item",
42
+ "data-testid": "first"
42
43
  }, ___EmotionJSX(Text, null, "Render me!")), ___EmotionJSX(Item, {
43
44
  key: "second",
44
45
  textValue: "Duplicate",
45
46
  "data-id": "second",
46
- label: "Accordion item"
47
+ label: "Accordion item",
48
+ "data-testid": "second"
47
49
  }, ___EmotionJSX(Text, null, "Render me!")), ___EmotionJSX(Item, {
48
50
  key: "third",
49
51
  textValue: "Duplicate",
50
52
  "data-id": "third",
51
- label: "Accordion item"
53
+ label: "Accordion item",
54
+ "data-testid": "third"
52
55
  }, ___EmotionJSX(TextField, {
53
56
  role: "form",
54
57
  label: "Example Label",
@@ -158,6 +161,15 @@ var getComponentWithMultipleAccordion = function getComponentWithMultipleAccordi
158
161
  "data-id": "connection-configuration-custom-form"
159
162
  }, ___EmotionJSX(Box, null, ___EmotionJSX(Text, null, "other text1"), ___EmotionJSX(Text, null, "another text1")))))));
160
163
  };
164
+ var getComponentWithSlot = function getComponentWithSlot(props) {
165
+ return render(___EmotionJSX(AccordionGroup, _extends({}, defaultProps, props), ___EmotionJSX(Item, {
166
+ key: "first",
167
+ textValue: "Duplicate",
168
+ "data-id": "first",
169
+ label: "Accordion item",
170
+ slots: props.slots
171
+ }, ___EmotionJSX(Text, null, "Render me!"))));
172
+ };
161
173
  test('button press uses callback', function () {
162
174
  var onPress = jest.fn();
163
175
  getComponent({
@@ -271,10 +283,8 @@ test('disabled keys prop disables an accordion item', function () {
271
283
  getComponent({
272
284
  disabledKeys: ['first']
273
285
  });
274
- var buttons = screen.getAllByRole('button');
275
- var selectedItem = buttons[0];
276
- var parentElement = selectedItem.parentElement;
277
- expect(parentElement).toHaveClass('is-disabled');
286
+ var button = screen.getByTestId('first');
287
+ expect(button).toHaveClass('is-disabled');
278
288
  });
279
289
  test('default expanded keys expands an accordion item', function () {
280
290
  getComponent({
@@ -313,10 +323,10 @@ test('able to click a textfield that is the rendered child of an accordion', fun
313
323
  });
314
324
  test('Item accepts a data-id and the data-id can be found in the DOM', function () {
315
325
  getComponent();
316
- var buttons = screen.getAllByRole('button');
326
+ var buttons = screen.getAllByText('Accordion item');
317
327
  var selectedItem = buttons[0];
318
328
  var parentElement = selectedItem.parentElement;
319
- expect(parentElement).toHaveAttribute('data-id', 'first');
329
+ expect(parentElement).toHaveAttribute('data-key', 'first');
320
330
  });
321
331
  test('items do not automatically expand if wrapped in an open OverlayPanel', function () {
322
332
  getComponentInOverlayPanel();
@@ -401,4 +411,14 @@ test('when labelHeadingTag is uppercase, the label is rendered', function () {
401
411
  screen.getAllByRole('heading', {
402
412
  level: getLabelHeadingLevel(h4Tag)
403
413
  });
414
+ });
415
+ test('renders Accordion component with slot', function () {
416
+ getComponentWithSlot({
417
+ slots: {
418
+ postHeading: ___EmotionJSX(HelpHint, {
419
+ "data-testid": "helpHint"
420
+ }, "Text of the popover right here...")
421
+ }
422
+ });
423
+ expect(screen.getByTestId('helpHint')).toBeInTheDocument();
404
424
  });
@@ -20,6 +20,7 @@ import { hoveredState } from '../AccordionGroup/Accordion.styles';
20
20
  import { jsx as ___EmotionJSX } from "@emotion/react";
21
21
  export var validHeadingTags = ['h1', 'h2', 'h3', 'h4'];
22
22
  var AccordionItem = function AccordionItem(props) {
23
+ var _item$props$slots, _item$props$slots2;
23
24
  var className = props.className,
24
25
  item = props.item,
25
26
  labelHeadingTag = props.labelHeadingTag;
@@ -70,7 +71,9 @@ var AccordionItem = function AccordionItem(props) {
70
71
  return ___EmotionJSX(Box, _extends({
71
72
  variant: "accordion.accordion",
72
73
  className: itemClasses
73
- }, others, containerProps), ___EmotionJSX(ThemeUIButton, _extends({
74
+ }, others, containerProps), ___EmotionJSX(Box, {
75
+ isRow: true
76
+ }, ___EmotionJSX(ThemeUIButton, _extends({
74
77
  "aria-label": ariaLabel,
75
78
  ref: buttonRef,
76
79
  sx: {
@@ -93,7 +96,7 @@ var AccordionItem = function AccordionItem(props) {
93
96
  title: {
94
97
  name: isOpen ? 'Menu Up Icon' : 'Menu Down Icon'
95
98
  }
96
- }))), isOpen && ___EmotionJSX(Box, _extends({
99
+ }))), ((_item$props$slots = item.props.slots) === null || _item$props$slots === void 0 ? void 0 : _item$props$slots.postHeading) && ((_item$props$slots2 = item.props.slots) === null || _item$props$slots2 === void 0 ? void 0 : _item$props$slots2.postHeading)), isOpen && ___EmotionJSX(Box, _extends({
97
100
  variant: "accordion.body"
98
101
  }, accordionRegionProps, regionProps, {
99
102
  className: itemClasses
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.46.0-alpha.4",
3
+ "version": "2.46.0-alpha.5",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",