@pingux/astro 2.17.0 → 2.18.0-alpha.0

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 (129) hide show
  1. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +13 -15
  2. package/lib/cjs/components/ArrayField/ArrayField.stories.js +1 -3
  3. package/lib/cjs/components/Calendar/Calendar.test.js +13 -15
  4. package/lib/cjs/components/CodeView/CodeView.test.js +45 -53
  5. package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +35 -37
  6. package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +122 -132
  7. package/lib/cjs/components/CopyText/CopyText.test.js +191 -223
  8. package/lib/cjs/components/DataTable/DataTable.stories.js +75 -79
  9. package/lib/cjs/components/DataTable/DataTable.test.js +569 -629
  10. package/lib/cjs/components/DatePicker/DateField.js +1 -1
  11. package/lib/cjs/components/DatePicker/DatePicker.test.js +81 -87
  12. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +2 -2
  13. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +19 -16
  14. package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumbAxe.test.js +7 -0
  15. package/lib/cjs/components/HelpHint/HelpHint.js +5 -2
  16. package/lib/cjs/components/HelpHint/HelpHint.stories.js +3 -2
  17. package/lib/cjs/components/HelpHint/HelpHint.styles.js +5 -1
  18. package/lib/cjs/components/HelpHint/HelpHint.test.js +145 -146
  19. package/lib/cjs/components/ImageUploadField/ImageUploadField.stories.js +73 -77
  20. package/lib/cjs/components/ImageUploadField/ImageUploadField.test.js +150 -162
  21. package/lib/cjs/components/LinkSelectField/LinkSelectField.stories.js +26 -28
  22. package/lib/cjs/components/LinkSelectField/LinkSelectField.test.js +13 -15
  23. package/lib/cjs/components/ListBox/ListBox.js +1 -1
  24. package/lib/cjs/components/ListBox/ListBox.test.js +13 -15
  25. package/lib/cjs/components/ListBox/Option.js +1 -1
  26. package/lib/cjs/components/ListView/ListView.stories.js +124 -95
  27. package/lib/cjs/components/ListView/ListView.test.js +119 -133
  28. package/lib/cjs/components/ListViewItem/ListViewItem.mdx +1 -0
  29. package/lib/cjs/components/ListViewItem/ListViewItem.stories.js +36 -2
  30. package/lib/cjs/components/ListViewItem/ListViewItem.styles.js +1 -1
  31. package/lib/cjs/components/ListViewItem/controls/ListViewItemMenu.test.js +23 -25
  32. package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.js +102 -0
  33. package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.mdx +11 -0
  34. package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.stories.js +50 -0
  35. package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.styles.js +112 -0
  36. package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.test.js +76 -0
  37. package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChartAttributes.js +127 -0
  38. package/lib/cjs/components/ListViewItem/controls/chart/chartData.js +45 -0
  39. package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +61 -72
  40. package/lib/cjs/components/PasswordField/PasswordField.test.js +44 -50
  41. package/lib/cjs/components/RadioGroupField/RadioGroupField.test.js +24 -26
  42. package/lib/cjs/components/ScrollBox/ScrollBox.js +2 -2
  43. package/lib/cjs/components/SelectField/SelectField.stories.js +26 -28
  44. package/lib/cjs/components/SelectFieldBase/SelectFieldBase.test.js +13 -15
  45. package/lib/cjs/components/Stepper/Stepper.test.js +53 -55
  46. package/lib/cjs/components/Tabs/Tabs.js +1 -1
  47. package/lib/cjs/components/Tabs/Tabs.test.js +37 -41
  48. package/lib/cjs/components/TextArea/TextArea.styles.js +7 -1
  49. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.test.js +45 -29
  50. package/lib/cjs/experimental/PanelHeader/controls/PanelHeaderMenu.test.js +23 -25
  51. package/lib/cjs/hooks/useComponentToggle/useComponentToggle.test.js +22 -26
  52. package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +42 -44
  53. package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.test.js +12 -14
  54. package/lib/cjs/hooks/useField/useField.js +1 -1
  55. package/lib/cjs/hooks/useImageUploadState/useImageUploadState.js +5 -5
  56. package/lib/cjs/hooks/useLabelHeight/useLabelHeight.js +2 -2
  57. package/lib/cjs/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.test.js +98 -112
  58. package/lib/cjs/index.d.ts +1 -0
  59. package/lib/cjs/index.js +8 -0
  60. package/lib/cjs/styles/variants/variants.js +2 -0
  61. package/lib/cjs/types/index.d.ts +1 -0
  62. package/lib/cjs/types/index.js +17 -6
  63. package/lib/cjs/types/item.d.ts +29 -0
  64. package/lib/cjs/types/item.js +6 -0
  65. package/lib/cjs/utils/testUtils/testAxe.js +25 -28
  66. package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +13 -15
  67. package/lib/components/ArrayField/ArrayField.stories.js +1 -3
  68. package/lib/components/Box/Box.js +6 -6
  69. package/lib/components/Calendar/Calendar.test.js +13 -15
  70. package/lib/components/CodeView/CodeView.test.js +45 -53
  71. package/lib/components/ComboBoxField/ComboBoxField.stories.js +35 -37
  72. package/lib/components/ComboBoxField/ComboBoxField.test.js +122 -132
  73. package/lib/components/CopyText/CopyText.test.js +191 -223
  74. package/lib/components/DataTable/DataTable.stories.js +75 -79
  75. package/lib/components/DataTable/DataTable.test.js +569 -629
  76. package/lib/components/DatePicker/DateField.js +1 -1
  77. package/lib/components/DatePicker/DatePicker.test.js +81 -87
  78. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +2 -2
  79. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +15 -18
  80. package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumbAxe.test.js +4 -0
  81. package/lib/components/HelpHint/HelpHint.js +5 -2
  82. package/lib/components/HelpHint/HelpHint.stories.js +3 -2
  83. package/lib/components/HelpHint/HelpHint.styles.js +5 -1
  84. package/lib/components/HelpHint/HelpHint.test.js +145 -146
  85. package/lib/components/ImageUploadField/ImageUploadField.stories.js +73 -77
  86. package/lib/components/ImageUploadField/ImageUploadField.test.js +150 -162
  87. package/lib/components/LinkSelectField/LinkSelectField.stories.js +26 -28
  88. package/lib/components/LinkSelectField/LinkSelectField.test.js +13 -15
  89. package/lib/components/ListBox/ListBox.js +1 -1
  90. package/lib/components/ListBox/ListBox.test.js +13 -15
  91. package/lib/components/ListBox/Option.js +1 -1
  92. package/lib/components/ListView/ListView.stories.js +118 -94
  93. package/lib/components/ListView/ListView.test.js +119 -133
  94. package/lib/components/ListViewItem/ListViewItem.mdx +1 -0
  95. package/lib/components/ListViewItem/ListViewItem.stories.js +30 -2
  96. package/lib/components/ListViewItem/ListViewItem.styles.js +1 -1
  97. package/lib/components/ListViewItem/controls/ListViewItemMenu.test.js +23 -25
  98. package/lib/components/ListViewItem/controls/chart/ListViewItemChart.js +88 -0
  99. package/lib/components/ListViewItem/controls/chart/ListViewItemChart.mdx +11 -0
  100. package/lib/components/ListViewItem/controls/chart/ListViewItemChart.stories.js +35 -0
  101. package/lib/components/ListViewItem/controls/chart/ListViewItemChart.styles.js +104 -0
  102. package/lib/components/ListViewItem/controls/chart/ListViewItemChart.test.js +73 -0
  103. package/lib/components/ListViewItem/controls/chart/ListViewItemChartAttributes.js +118 -0
  104. package/lib/components/ListViewItem/controls/chart/chartData.js +37 -0
  105. package/lib/components/MultivaluesField/MultivaluesField.test.js +61 -72
  106. package/lib/components/PasswordField/PasswordField.test.js +44 -50
  107. package/lib/components/RadioGroupField/RadioGroupField.test.js +24 -26
  108. package/lib/components/ScrollBox/ScrollBox.js +2 -2
  109. package/lib/components/SelectField/SelectField.stories.js +26 -28
  110. package/lib/components/SelectFieldBase/SelectFieldBase.test.js +13 -15
  111. package/lib/components/Stepper/Stepper.test.js +53 -55
  112. package/lib/components/Tabs/Tabs.js +1 -1
  113. package/lib/components/Tabs/Tabs.test.js +37 -41
  114. package/lib/components/TextArea/TextArea.styles.js +7 -1
  115. package/lib/components/TooltipTrigger/TooltipTrigger.test.js +45 -29
  116. package/lib/experimental/PanelHeader/controls/PanelHeaderMenu.test.js +23 -25
  117. package/lib/hooks/useComponentToggle/useComponentToggle.test.js +22 -26
  118. package/lib/hooks/useCopyToClipboard/useCopyToClipboard.js +42 -44
  119. package/lib/hooks/useCopyToClipboard/useCopyToClipboard.test.js +12 -14
  120. package/lib/hooks/useField/useField.js +1 -1
  121. package/lib/hooks/useImageUploadState/useImageUploadState.js +5 -5
  122. package/lib/hooks/useLabelHeight/useLabelHeight.js +2 -2
  123. package/lib/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.test.js +98 -112
  124. package/lib/index.js +1 -0
  125. package/lib/styles/variants/variants.js +2 -0
  126. package/lib/types/index.js +1 -0
  127. package/lib/types/item.js +1 -0
  128. package/lib/utils/testUtils/testAxe.js +25 -28
  129. package/package.json +5 -4
@@ -0,0 +1,88 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React, { useCallback, useMemo } from 'react';
3
+ import { useVisuallyHidden } from 'react-aria';
4
+ import { Line, LineChart, ResponsiveContainer } from 'recharts';
5
+ import useResizeObserver from 'use-resize-observer';
6
+ import { Box, Button, Text, Tooltip, TooltipTrigger } from '../../../../index';
7
+ import { neutral } from '../../../../styles/colors';
8
+ import { listViewItemChartPropTypes } from './ListViewItemChartAttributes';
9
+ import { jsx as ___EmotionJSX } from "@emotion/react";
10
+ var ListViewItemChart = function ListViewItemChart(props) {
11
+ var buttonProps = props.buttonProps,
12
+ chartData = props.chartData,
13
+ chartLabel = props.chartLabel,
14
+ containerRef = props.containerRef,
15
+ title = props.title,
16
+ tooltipText = props.tooltipText,
17
+ contentCount = props.contentCount,
18
+ contentCountLabel = props.contentCountLabel,
19
+ trend = props.trend,
20
+ chartDataKey = props.chartDataKey,
21
+ _props$tabletBreakPoi = props.tabletBreakPoint,
22
+ tabletBreakPoint = _props$tabletBreakPoi === void 0 ? 605 : _props$tabletBreakPoi,
23
+ _props$mobileBreakPoi = props.mobileBreakPoint,
24
+ mobileBreakPoint = _props$mobileBreakPoi === void 0 ? 350 : _props$mobileBreakPoi;
25
+ var _useResizeObserver = useResizeObserver({
26
+ ref: containerRef
27
+ }),
28
+ width = _useResizeObserver.width;
29
+ var _useVisuallyHidden = useVisuallyHidden(),
30
+ visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
31
+ var isTablet = useMemo(function () {
32
+ return width <= tabletBreakPoint;
33
+ }, [tabletBreakPoint, width]);
34
+ var isMobile = useMemo(function () {
35
+ return width <= mobileBreakPoint;
36
+ }, [mobileBreakPoint, width]);
37
+ var hideIfTablet = useCallback(function () {
38
+ return isTablet && visuallyHiddenProps;
39
+ }, [isTablet, visuallyHiddenProps]);
40
+ var hideIfMobile = useCallback(function () {
41
+ return isMobile && visuallyHiddenProps;
42
+ }, [isMobile, visuallyHiddenProps]);
43
+ return ___EmotionJSX(Box, {
44
+ isRow: true,
45
+ alignItems: "center",
46
+ height: 0,
47
+ mr: "md"
48
+ }, ___EmotionJSX(Box, _extends({
49
+ variant: "lisViewItemChart.titleContainer"
50
+ }, hideIfMobile()), ___EmotionJSX(Text, {
51
+ variant: "variants.lisViewItemChart.title"
52
+ }, title)), ___EmotionJSX(Box, _extends({
53
+ variant: "lisViewItemChart.content"
54
+ }, hideIfTablet()), ___EmotionJSX(Text, {
55
+ variant: "variants.lisViewItemChart.count"
56
+ }, contentCount), ___EmotionJSX(Text, {
57
+ variant: "variants.lisViewItemChart.countLabel"
58
+ }, contentCountLabel)), ___EmotionJSX(TooltipTrigger, null, ___EmotionJSX(Button, _extends({
59
+ variant: "variants.lisViewItemChart.chartButton",
60
+ "aria-label": "line-chart button"
61
+ }, buttonProps, hideIfMobile()), ___EmotionJSX(Box, {
62
+ variant: "lisViewItemChart.divider"
63
+ }), ___EmotionJSX(Box, {
64
+ ml: "md"
65
+ }, ___EmotionJSX(Box, {
66
+ variant: "lisViewItemChart.chartContainer"
67
+ }, ___EmotionJSX(ResponsiveContainer, {
68
+ variant: "lisViewItemChart.responsiveContainer"
69
+ }, ___EmotionJSX(LineChart, {
70
+ data: chartData,
71
+ variant: "lisViewItemChart.chart"
72
+ }, ___EmotionJSX(Line, {
73
+ type: "monotone",
74
+ dataKey: chartDataKey,
75
+ dot: false,
76
+ stroke: neutral[20]
77
+ })))), ___EmotionJSX(Text, {
78
+ variant: "variants.lisViewItemChart.chartLabel"
79
+ }, chartLabel)), ___EmotionJSX(Box, {
80
+ size: "sm",
81
+ variant: "lisViewItemChart.trendContainer"
82
+ }, ___EmotionJSX(Text, {
83
+ variant: "variants.lisViewItemChart.trend"
84
+ }, trend))), ___EmotionJSX(Tooltip, null, tooltipText)));
85
+ };
86
+ ListViewItemChart.propTypes = listViewItemChartPropTypes;
87
+ ListViewItemChart.displayName = 'ListViewItemChart';
88
+ export default ListViewItemChart;
@@ -0,0 +1,11 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta title="Experimental/controls/ListViewItemChart" />
4
+
5
+ # ListViewItemChart
6
+
7
+ The ListViewItemChart allows easy creation of chart inside ListViewItem. Styles have been included to match Ping specs.
8
+
9
+ ### Recommended Use
10
+ This component is intended to be used inside a ListViewItem component. See the [ListViewItem](./?path=/docs/experimental-listviewitem--docs)
11
+ docs for a more detailed examples.
@@ -0,0 +1,35 @@
1
+ import React, { useRef } from 'react';
2
+ import DocsLayout from '../../../../../.storybook/storybookDocsLayout';
3
+ import { Box, ListViewItemChart } from '../../../../index';
4
+ import { chartData } from './chartData';
5
+ import ListViewItemChartReadMe from './ListViewItemChart.mdx';
6
+ import { listViewItemChartArgTypes } from './ListViewItemChartAttributes';
7
+ import { jsx as ___EmotionJSX } from "@emotion/react";
8
+ export default {
9
+ title: 'Components/ListViewItem/Controls/ListViewItemChart',
10
+ component: ListViewItemChart,
11
+ parameters: {
12
+ docs: {
13
+ page: function page() {
14
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(ListViewItemChartReadMe, null), ___EmotionJSX(DocsLayout, null));
15
+ }
16
+ }
17
+ },
18
+ argTypes: listViewItemChartArgTypes
19
+ };
20
+ export var Default = function Default() {
21
+ var ref = useRef();
22
+ return ___EmotionJSX(Box, {
23
+ ref: ref
24
+ }, ___EmotionJSX(ListViewItemChart, {
25
+ containerRef: ref,
26
+ chartData: chartData,
27
+ chartDataKey: "fullData",
28
+ title: "Avg daily sign-ons:",
29
+ contentCount: "31",
30
+ contentCountLabel: "Past 7 days",
31
+ chartLabel: "12 wk trend",
32
+ trend: "+115.0%",
33
+ tooltipText: "See Contributing Data"
34
+ }));
35
+ };
@@ -0,0 +1,104 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
+ 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; }
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ var expandableRowSharedStyle = {
13
+ textOverflow: 'ellipsis',
14
+ overflow: 'hidden',
15
+ whiteSpace: 'nowrap'
16
+ };
17
+ var alignCellRightWrapper = {
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ alignItems: 'flex-end'
21
+ };
22
+ var responsiveContainer = {
23
+ width: '100%',
24
+ height: '100%'
25
+ };
26
+ var chart = {
27
+ width: '50',
28
+ height: '18'
29
+ };
30
+ var chartContainer = {
31
+ width: '50px',
32
+ height: '18px'
33
+ };
34
+ var divider = {
35
+ backgroundColor: 'neutral.50',
36
+ height: '41px',
37
+ width: '1px'
38
+ };
39
+ var chartLabel = {
40
+ fontSize: 'sm',
41
+ color: 'neutral.40'
42
+ };
43
+ var trendContainer = {
44
+ ml: 'md',
45
+ width: '50px'
46
+ };
47
+ var trend = {
48
+ color: 'neutral.40',
49
+ fontSize: 'md',
50
+ fontWeight: 3,
51
+ whiteSpace: 'nowrap'
52
+ };
53
+ var chartButton = {
54
+ display: 'flex',
55
+ flexDirection: 'row',
56
+ alignItems: 'center',
57
+ color: 'black',
58
+ background: 'none',
59
+ cursor: 'pointer',
60
+ height: '44px',
61
+ padding: 0,
62
+ ml: 'md',
63
+ pr: 'md',
64
+ border: 'none',
65
+ '&:hover': {
66
+ backgroundColor: '#4462ED1A'
67
+ }
68
+ };
69
+ var titleContainer = _objectSpread(_objectSpread({}, alignCellRightWrapper), {}, {
70
+ mr: 'md'
71
+ });
72
+ var title = _objectSpread({
73
+ fontSize: 'sm',
74
+ color: 'neutral.40',
75
+ maxWidth: '100%'
76
+ }, expandableRowSharedStyle);
77
+ var content = _objectSpread(_objectSpread({}, alignCellRightWrapper), {}, {
78
+ height: '44px',
79
+ justifyContent: 'center'
80
+ });
81
+ var count = {
82
+ color: 'neutral.40',
83
+ fontSize: 'xx',
84
+ fontWeight: 3
85
+ };
86
+ var countLabel = {
87
+ fontSize: 'sm',
88
+ color: 'neutral.40'
89
+ };
90
+ export default {
91
+ chart: chart,
92
+ responsiveContainer: responsiveContainer,
93
+ chartContainer: chartContainer,
94
+ divider: divider,
95
+ chartLabel: chartLabel,
96
+ trendContainer: trendContainer,
97
+ trend: trend,
98
+ chartButton: chartButton,
99
+ titleContainer: titleContainer,
100
+ title: title,
101
+ content: content,
102
+ count: count,
103
+ countLabel: countLabel
104
+ };
@@ -0,0 +1,73 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import useResizeObserver from 'use-resize-observer';
4
+ import axeTest from '../../../../utils/testUtils/testAxe';
5
+ import { render, screen } from '../../../../utils/testUtils/testWrapper';
6
+ import Box from '../../../Box/Box';
7
+ import { chartData } from './chartData';
8
+ import ListViewItemChart from './ListViewItemChart';
9
+ import { jsx as ___EmotionJSX } from "@emotion/react";
10
+ jest.mock('use-resize-observer');
11
+ var Chart = function Chart(props) {
12
+ var ref = React.useRef();
13
+ return ___EmotionJSX(Box, {
14
+ ref: ref
15
+ }, ___EmotionJSX(ListViewItemChart, _extends({
16
+ containerRef: ref,
17
+ chartData: chartData,
18
+ chartDataKey: "fullData",
19
+ title: "Avg daily sign-ons:",
20
+ contentCount: "1,234,234",
21
+ contentCountLabel: "Past 7 days",
22
+ chartLabel: "12 wk trend",
23
+ trend: "+ 8.6%",
24
+ tooltipText: "See Contributing Data"
25
+ }, props)));
26
+ };
27
+ var getComponent = function getComponent() {
28
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
29
+ return render(___EmotionJSX(Chart, props));
30
+ };
31
+ var _window = window,
32
+ ResizeObserver = _window.ResizeObserver;
33
+ beforeEach(function () {
34
+ useResizeObserver.mockReturnValue({
35
+ width: 800
36
+ });
37
+ jest.spyOn(HTMLElement.prototype, 'clientHeight', 'get').mockReturnValue(400);
38
+ jest.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(800);
39
+ delete window.ResizeObserver;
40
+ window.ResizeObserver = jest.fn().mockImplementation(function () {
41
+ return {
42
+ observe: jest.fn(),
43
+ unobserve: jest.fn(),
44
+ disconnect: jest.fn()
45
+ };
46
+ });
47
+ });
48
+ afterEach(function () {
49
+ window.ResizeObserver = ResizeObserver;
50
+ jest.restoreAllMocks();
51
+ });
52
+
53
+ // Need to be added to each test file to test accessibility using axe.
54
+ axeTest(getComponent);
55
+ test('renders ListViewItemChart component', function () {
56
+ getComponent();
57
+ var chart = screen.getByRole('region');
58
+ var content = screen.getByText('Past 7 days');
59
+ expect(chart).toBeInTheDocument();
60
+ expect(content).toBeInTheDocument();
61
+ expect(!!content.parentNode.getAttribute('style')).toBeFalsy();
62
+ });
63
+ test('renders ListViewItemChart component for tablet', function () {
64
+ useResizeObserver.mockReturnValue({
65
+ width: 500
66
+ });
67
+ getComponent();
68
+ var chart = screen.getByRole('region');
69
+ var content = screen.getByText('Past 7 days');
70
+ expect(chart).toBeInTheDocument();
71
+ expect(content).toBeInTheDocument();
72
+ expect(!!content.parentNode.getAttribute('style')).toBeTruthy();
73
+ });
@@ -0,0 +1,118 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
+ 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; }
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ import PropTypes from 'prop-types';
13
+ import { docArgTypes } from '../../../../utils/docUtils/docArgTypes';
14
+ import { buttonArgTypes } from '../../../Button/buttonAttributes';
15
+ var descriptions = {
16
+ buttonProps: 'Object includes same props as `Button` component',
17
+ chartData: 'Array with objects `{ id, keyName }` for chart',
18
+ chartDataKey: 'Name of the `keyName` in `chartData`',
19
+ chartLabel: 'Label under chart',
20
+ mobileBreakPoint: 'Container width breakpoint to hide all ListViewItemChart',
21
+ tabletBreakPoint: 'Container width breakpoint to hide content (counter and counter label)',
22
+ title: 'Main title of chart',
23
+ tooltipText: 'Text inside tooltip',
24
+ contentCount: 'Number of events',
25
+ contentCountLabel: 'Label under `contentCount`',
26
+ trend: 'Text for trend'
27
+ };
28
+ export var listViewItemChartArgTypes = {
29
+ buttonProps: _objectSpread(_objectSpread({}, buttonArgTypes), {}, {
30
+ type: {
31
+ summary: docArgTypes.object
32
+ },
33
+ description: descriptions.buttonProps,
34
+ control: 'object'
35
+ }),
36
+ chartData: {
37
+ description: descriptions.chartData,
38
+ type: {
39
+ summary: docArgTypes.object
40
+ },
41
+ control: 'object'
42
+ },
43
+ chartDataKey: {
44
+ description: descriptions.chartDataKey,
45
+ type: {
46
+ summary: docArgTypes.string
47
+ },
48
+ control: 'text'
49
+ },
50
+ chartLabel: {
51
+ description: descriptions.chartLabel,
52
+ type: {
53
+ summary: docArgTypes.string
54
+ },
55
+ control: 'text'
56
+ },
57
+ mobileBreakPoint: {
58
+ description: descriptions.mobileBreakPoint,
59
+ type: {
60
+ summary: docArgTypes.number
61
+ },
62
+ control: 'number'
63
+ },
64
+ tabletBreakPoint: {
65
+ description: descriptions.tabletBreakPoint,
66
+ type: {
67
+ summary: docArgTypes.number
68
+ },
69
+ control: 'number'
70
+ },
71
+ title: {
72
+ description: descriptions.title,
73
+ type: {
74
+ summary: docArgTypes.string
75
+ },
76
+ control: 'text'
77
+ },
78
+ tooltipText: {
79
+ description: descriptions.tooltipText,
80
+ type: {
81
+ summary: docArgTypes.string
82
+ },
83
+ control: 'text'
84
+ },
85
+ contentCount: {
86
+ description: descriptions.contentCount,
87
+ type: {
88
+ summary: docArgTypes.string
89
+ },
90
+ control: 'text'
91
+ },
92
+ contentCountLabel: {
93
+ description: descriptions.contentCountLabel,
94
+ type: {
95
+ summary: docArgTypes.string
96
+ },
97
+ control: 'text'
98
+ },
99
+ trend: {
100
+ description: descriptions.trend,
101
+ type: {
102
+ summary: docArgTypes.string
103
+ },
104
+ control: 'text'
105
+ }
106
+ };
107
+ export var listViewItemChartPropTypes = {
108
+ chartData: PropTypes.arrayOf(PropTypes.shape({})),
109
+ chartLabel: PropTypes.string,
110
+ chartDataKey: PropTypes.string,
111
+ contentCount: PropTypes.string,
112
+ contentCountLabel: PropTypes.string,
113
+ mobileBreakPoint: PropTypes.number,
114
+ tabletBreakPoint: PropTypes.number,
115
+ title: PropTypes.string,
116
+ tooltipText: PropTypes.string,
117
+ trend: PropTypes.string
118
+ };
@@ -0,0 +1,37 @@
1
+ export var chartData = [{
2
+ id: 1,
3
+ fullData: 1
4
+ }, {
5
+ id: 2,
6
+ fullData: 5
7
+ }, {
8
+ id: 3,
9
+ fullData: 3
10
+ }, {
11
+ id: 4,
12
+ fullData: 2
13
+ }, {
14
+ id: 5,
15
+ fullData: 5
16
+ }, {
17
+ id: 6,
18
+ fullData: 1
19
+ }, {
20
+ id: 7,
21
+ fullData: 5
22
+ }, {
23
+ id: 8,
24
+ fullData: 5
25
+ }, {
26
+ id: 9,
27
+ fullData: 1
28
+ }, {
29
+ id: 10,
30
+ fullData: 2
31
+ }, {
32
+ id: 11,
33
+ fullData: 4
34
+ }, {
35
+ id: 12,
36
+ fullData: 11
37
+ }];