@pingux/astro 2.17.0-alpha.5 → 2.17.0-alpha.7
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.
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +7 -2
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumbAxe.test.js +7 -0
- package/lib/cjs/components/ListView/ListView.stories.js +38 -3
- package/lib/cjs/components/ListViewItem/ListViewItem.mdx +1 -0
- package/lib/cjs/components/ListViewItem/ListViewItem.stories.js +36 -2
- package/lib/cjs/components/ListViewItem/ListViewItem.styles.js +1 -1
- package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.js +102 -0
- package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.mdx +11 -0
- package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.stories.js +50 -0
- package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.styles.js +112 -0
- package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChart.test.js +76 -0
- package/lib/cjs/components/ListViewItem/controls/chart/ListViewItemChartAttributes.js +127 -0
- package/lib/cjs/components/ListViewItem/controls/chart/chartData.js +45 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/styles/variants/variants.js +2 -0
- package/lib/cjs/utils/testUtils/testAxe.js +4 -3
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +3 -4
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumbAxe.test.js +4 -0
- package/lib/components/ListView/ListView.stories.js +32 -2
- package/lib/components/ListViewItem/ListViewItem.mdx +1 -0
- package/lib/components/ListViewItem/ListViewItem.stories.js +30 -2
- package/lib/components/ListViewItem/ListViewItem.styles.js +1 -1
- package/lib/components/ListViewItem/controls/chart/ListViewItemChart.js +88 -0
- package/lib/components/ListViewItem/controls/chart/ListViewItemChart.mdx +11 -0
- package/lib/components/ListViewItem/controls/chart/ListViewItemChart.stories.js +35 -0
- package/lib/components/ListViewItem/controls/chart/ListViewItemChart.styles.js +104 -0
- package/lib/components/ListViewItem/controls/chart/ListViewItemChart.test.js +73 -0
- package/lib/components/ListViewItem/controls/chart/ListViewItemChartAttributes.js +118 -0
- package/lib/components/ListViewItem/controls/chart/chartData.js +37 -0
- package/lib/index.js +1 -0
- package/lib/styles/variants/variants.js +2 -0
- package/lib/utils/testUtils/testAxe.js +4 -3
- package/package.json +2 -2
@@ -0,0 +1,127 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
12
|
+
_Object$defineProperty(exports, "__esModule", {
|
13
|
+
value: true
|
14
|
+
});
|
15
|
+
exports.listViewItemChartPropTypes = exports.listViewItemChartArgTypes = void 0;
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
18
|
+
var _docArgTypes = require("../../../../utils/docUtils/docArgTypes");
|
19
|
+
var _buttonAttributes = require("../../../Button/buttonAttributes");
|
20
|
+
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; }
|
21
|
+
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) { (0, _defineProperty2["default"])(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; }
|
22
|
+
var descriptions = {
|
23
|
+
buttonProps: 'Object includes same props as `Button` component',
|
24
|
+
chartData: 'Array with objects `{ id, keyName }` for chart',
|
25
|
+
chartDataKey: 'Name of the `keyName` in `chartData`',
|
26
|
+
chartLabel: 'Label under chart',
|
27
|
+
mobileBreakPoint: 'Container width breakpoint to hide all ListViewItemChart',
|
28
|
+
tabletBreakPoint: 'Container width breakpoint to hide content (counter and counter label)',
|
29
|
+
title: 'Main title of chart',
|
30
|
+
tooltipText: 'Text inside tooltip',
|
31
|
+
contentCount: 'Number of events',
|
32
|
+
contentCountLabel: 'Label under `contentCount`',
|
33
|
+
trend: 'Text for trend'
|
34
|
+
};
|
35
|
+
var listViewItemChartArgTypes = {
|
36
|
+
buttonProps: _objectSpread(_objectSpread({}, _buttonAttributes.buttonArgTypes), {}, {
|
37
|
+
type: {
|
38
|
+
summary: _docArgTypes.docArgTypes.object
|
39
|
+
},
|
40
|
+
description: descriptions.buttonProps,
|
41
|
+
control: 'object'
|
42
|
+
}),
|
43
|
+
chartData: {
|
44
|
+
description: descriptions.chartData,
|
45
|
+
type: {
|
46
|
+
summary: _docArgTypes.docArgTypes.object
|
47
|
+
},
|
48
|
+
control: 'object'
|
49
|
+
},
|
50
|
+
chartDataKey: {
|
51
|
+
description: descriptions.chartDataKey,
|
52
|
+
type: {
|
53
|
+
summary: _docArgTypes.docArgTypes.string
|
54
|
+
},
|
55
|
+
control: 'text'
|
56
|
+
},
|
57
|
+
chartLabel: {
|
58
|
+
description: descriptions.chartLabel,
|
59
|
+
type: {
|
60
|
+
summary: _docArgTypes.docArgTypes.string
|
61
|
+
},
|
62
|
+
control: 'text'
|
63
|
+
},
|
64
|
+
mobileBreakPoint: {
|
65
|
+
description: descriptions.mobileBreakPoint,
|
66
|
+
type: {
|
67
|
+
summary: _docArgTypes.docArgTypes.number
|
68
|
+
},
|
69
|
+
control: 'number'
|
70
|
+
},
|
71
|
+
tabletBreakPoint: {
|
72
|
+
description: descriptions.tabletBreakPoint,
|
73
|
+
type: {
|
74
|
+
summary: _docArgTypes.docArgTypes.number
|
75
|
+
},
|
76
|
+
control: 'number'
|
77
|
+
},
|
78
|
+
title: {
|
79
|
+
description: descriptions.title,
|
80
|
+
type: {
|
81
|
+
summary: _docArgTypes.docArgTypes.string
|
82
|
+
},
|
83
|
+
control: 'text'
|
84
|
+
},
|
85
|
+
tooltipText: {
|
86
|
+
description: descriptions.tooltipText,
|
87
|
+
type: {
|
88
|
+
summary: _docArgTypes.docArgTypes.string
|
89
|
+
},
|
90
|
+
control: 'text'
|
91
|
+
},
|
92
|
+
contentCount: {
|
93
|
+
description: descriptions.contentCount,
|
94
|
+
type: {
|
95
|
+
summary: _docArgTypes.docArgTypes.string
|
96
|
+
},
|
97
|
+
control: 'text'
|
98
|
+
},
|
99
|
+
contentCountLabel: {
|
100
|
+
description: descriptions.contentCountLabel,
|
101
|
+
type: {
|
102
|
+
summary: _docArgTypes.docArgTypes.string
|
103
|
+
},
|
104
|
+
control: 'text'
|
105
|
+
},
|
106
|
+
trend: {
|
107
|
+
description: descriptions.trend,
|
108
|
+
type: {
|
109
|
+
summary: _docArgTypes.docArgTypes.string
|
110
|
+
},
|
111
|
+
control: 'text'
|
112
|
+
}
|
113
|
+
};
|
114
|
+
exports.listViewItemChartArgTypes = listViewItemChartArgTypes;
|
115
|
+
var listViewItemChartPropTypes = {
|
116
|
+
chartData: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
|
117
|
+
chartLabel: _propTypes["default"].string,
|
118
|
+
chartDataKey: _propTypes["default"].string,
|
119
|
+
contentCount: _propTypes["default"].string,
|
120
|
+
contentCountLabel: _propTypes["default"].string,
|
121
|
+
mobileBreakPoint: _propTypes["default"].number,
|
122
|
+
tabletBreakPoint: _propTypes["default"].number,
|
123
|
+
title: _propTypes["default"].string,
|
124
|
+
tooltipText: _propTypes["default"].string,
|
125
|
+
trend: _propTypes["default"].string
|
126
|
+
};
|
127
|
+
exports.listViewItemChartPropTypes = listViewItemChartPropTypes;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.chartData = void 0;
|
8
|
+
var chartData = [{
|
9
|
+
id: 1,
|
10
|
+
fullData: 1
|
11
|
+
}, {
|
12
|
+
id: 2,
|
13
|
+
fullData: 5
|
14
|
+
}, {
|
15
|
+
id: 3,
|
16
|
+
fullData: 3
|
17
|
+
}, {
|
18
|
+
id: 4,
|
19
|
+
fullData: 2
|
20
|
+
}, {
|
21
|
+
id: 5,
|
22
|
+
fullData: 5
|
23
|
+
}, {
|
24
|
+
id: 6,
|
25
|
+
fullData: 1
|
26
|
+
}, {
|
27
|
+
id: 7,
|
28
|
+
fullData: 5
|
29
|
+
}, {
|
30
|
+
id: 8,
|
31
|
+
fullData: 5
|
32
|
+
}, {
|
33
|
+
id: 9,
|
34
|
+
fullData: 1
|
35
|
+
}, {
|
36
|
+
id: 10,
|
37
|
+
fullData: 2
|
38
|
+
}, {
|
39
|
+
id: 11,
|
40
|
+
fullData: 4
|
41
|
+
}, {
|
42
|
+
id: 12,
|
43
|
+
fullData: 11
|
44
|
+
}];
|
45
|
+
exports.chartData = chartData;
|
package/lib/cjs/index.d.ts
CHANGED
@@ -80,6 +80,7 @@ export * from './components/ListItem';
|
|
80
80
|
export { default as ListView } from './components/ListView';
|
81
81
|
export * from './components/ListView';
|
82
82
|
export { default as ListViewItem } from './components/ListViewItem';
|
83
|
+
export { default as ListViewItemChart } from './components/ListViewItem/controls/chart/ListViewItemChart';
|
83
84
|
export { default as ListViewItemEditButton } from './components/ListViewItem/controls/ListViewItemEditButton';
|
84
85
|
export { default as ListViewItemMenu } from './components/ListViewItem/controls/ListViewItemMenu';
|
85
86
|
export { default as ListViewItemSwitchField } from './components/ListViewItem/controls/ListViewItemSwitchField';
|
package/lib/cjs/index.js
CHANGED
@@ -58,6 +58,7 @@ var _exportNames = {
|
|
58
58
|
ListItem: true,
|
59
59
|
ListView: true,
|
60
60
|
ListViewItem: true,
|
61
|
+
ListViewItemChart: true,
|
61
62
|
ListViewItemEditButton: true,
|
62
63
|
ListViewItemMenu: true,
|
63
64
|
ListViewItemSwitchField: true,
|
@@ -451,6 +452,12 @@ _Object$defineProperty(exports, "ListViewItem", {
|
|
451
452
|
return _ListViewItem["default"];
|
452
453
|
}
|
453
454
|
});
|
455
|
+
_Object$defineProperty(exports, "ListViewItemChart", {
|
456
|
+
enumerable: true,
|
457
|
+
get: function get() {
|
458
|
+
return _ListViewItemChart["default"];
|
459
|
+
}
|
460
|
+
});
|
454
461
|
_Object$defineProperty(exports, "ListViewItemEditButton", {
|
455
462
|
enumerable: true,
|
456
463
|
get: function get() {
|
@@ -1210,6 +1217,7 @@ _forEachInstanceProperty(_context36 = _Object$keys(_ListView)).call(_context36,
|
|
1210
1217
|
});
|
1211
1218
|
});
|
1212
1219
|
var _ListViewItem = _interopRequireDefault(require("./components/ListViewItem"));
|
1220
|
+
var _ListViewItemChart = _interopRequireDefault(require("./components/ListViewItem/controls/chart/ListViewItemChart"));
|
1213
1221
|
var _ListViewItemEditButton = _interopRequireDefault(require("./components/ListViewItem/controls/ListViewItemEditButton"));
|
1214
1222
|
var _ListViewItemMenu = _interopRequireDefault(require("./components/ListViewItem/controls/ListViewItemMenu"));
|
1215
1223
|
var _ListViewItemSwitchField = _interopRequireDefault(require("./components/ListViewItem/controls/ListViewItemSwitchField"));
|
@@ -33,6 +33,7 @@ var _HelpHint = _interopRequireDefault(require("../../components/HelpHint/HelpHi
|
|
33
33
|
var _imageUpload = _interopRequireDefault(require("../../components/ImageUploadField/imageUpload"));
|
34
34
|
var _ListBox = _interopRequireDefault(require("../../components/ListBox/ListBox.styles"));
|
35
35
|
var _ListItem = _interopRequireDefault(require("../../components/ListItem/ListItem.styles"));
|
36
|
+
var _ListViewItemChart = _interopRequireDefault(require("../../components/ListViewItem/controls/chart/ListViewItemChart.styles"));
|
36
37
|
var _ListViewItem = _interopRequireDefault(require("../../components/ListViewItem/ListViewItem.styles"));
|
37
38
|
var _Loader = _interopRequireDefault(require("../../components/Loader/Loader.styles"));
|
38
39
|
var _Menu = _interopRequireDefault(require("../../components/Menu/Menu.styles"));
|
@@ -74,6 +75,7 @@ var _default = _objectSpread({
|
|
74
75
|
listBox: _ListBox["default"],
|
75
76
|
listItem: _ListItem["default"],
|
76
77
|
listViewItem: _ListViewItem["default"],
|
78
|
+
lisViewItemChart: _ListViewItemChart["default"],
|
77
79
|
loader: _Loader["default"],
|
78
80
|
menu: _Menu["default"],
|
79
81
|
menuItem: _MenuItem["default"],
|
@@ -31,13 +31,14 @@ var axeTest = /*#__PURE__*/function () {
|
|
31
31
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
32
32
|
while (1) switch (_context.prev = _context.next) {
|
33
33
|
case 0:
|
34
|
+
jest.useRealTimers();
|
34
35
|
_getComponent = getComponent(), container = _getComponent.container;
|
35
|
-
_context.next =
|
36
|
+
_context.next = 4;
|
36
37
|
return (0, _jestAxe.axe)(container, rules);
|
37
|
-
case
|
38
|
+
case 4:
|
38
39
|
results = _context.sent;
|
39
40
|
expect(results).toHaveNoViolations();
|
40
|
-
case
|
41
|
+
case 6:
|
41
42
|
case "end":
|
42
43
|
return _context.stop();
|
43
44
|
}
|
@@ -25,7 +25,6 @@ import React from 'react';
|
|
25
25
|
import { Section } from 'react-stately';
|
26
26
|
import userEvent from '@testing-library/user-event';
|
27
27
|
import { EnvironmentBreadcrumb, Item, OverlayProvider } from '../..';
|
28
|
-
import axeTest from '../../utils/testUtils/testAxe';
|
29
28
|
import { render, screen, within } from '../../utils/testUtils/testWrapper';
|
30
29
|
import { breadCrumbDataIds } from './EnvironmentBreadcrumb';
|
31
30
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -84,7 +83,7 @@ var defaultWithSectionsProps = {
|
|
84
83
|
items: itemsWithSections
|
85
84
|
};
|
86
85
|
var onSelectionChange = jest.fn();
|
87
|
-
var getComponent = function getComponent(props) {
|
86
|
+
export var getComponent = function getComponent(props) {
|
88
87
|
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultProps, props), function (item) {
|
89
88
|
return ___EmotionJSX(Item, {
|
90
89
|
key: item.name,
|
@@ -92,7 +91,7 @@ var getComponent = function getComponent(props) {
|
|
92
91
|
}, item.name);
|
93
92
|
})));
|
94
93
|
};
|
95
|
-
var getSectionsComponent = function getSectionsComponent() {
|
94
|
+
export var getSectionsComponent = function getSectionsComponent() {
|
96
95
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
97
96
|
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultWithSectionsProps, props), function (section) {
|
98
97
|
return (
|
@@ -126,6 +125,7 @@ beforeAll(function () {
|
|
126
125
|
jest.spyOn(window, 'requestAnimationFrame').mockImplementation(function (cb) {
|
127
126
|
return cb();
|
128
127
|
});
|
128
|
+
jest.useFakeTimers();
|
129
129
|
});
|
130
130
|
afterEach(function () {
|
131
131
|
jest.clearAllMocks();
|
@@ -287,7 +287,6 @@ test('should show empty state in search if there are no results', function () {
|
|
287
287
|
userEvent.type(screen.getByRole('searchbox'), '111');
|
288
288
|
expect(screen.getByText(testEmptySearchText)).toBeInTheDocument();
|
289
289
|
});
|
290
|
-
axeTest(getComponent);
|
291
290
|
test('should be open when isDefaultOpen is true', function () {
|
292
291
|
getComponent({
|
293
292
|
isDefaultOpen: true
|
@@ -15,14 +15,15 @@ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
15
15
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
16
16
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
17
17
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
18
|
-
import React from 'react';
|
18
|
+
import React, { useRef } from 'react';
|
19
19
|
import { Item, useAsyncList } from 'react-stately';
|
20
20
|
import FormSelectIcon from '@pingux/mdi-react/FormSelectIcon';
|
21
21
|
import { action } from '@storybook/addon-actions';
|
22
22
|
import isChromatic from 'chromatic/isChromatic';
|
23
23
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
24
|
-
import { Box, ListView, ListViewItem, ListViewItemMenu, ListViewItemSwitchField } from '../..';
|
24
|
+
import { Box, ListView, ListViewItem, ListViewItemChart, ListViewItemMenu, ListViewItemSwitchField } from '../..';
|
25
25
|
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
26
|
+
import { chartData } from '../ListViewItem/controls/chart/chartData';
|
26
27
|
import ListViewReadme from './ListView.mdx';
|
27
28
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
28
29
|
export default {
|
@@ -720,4 +721,33 @@ export var MultipleSelection = function MultipleSelection(_ref5) {
|
|
720
721
|
}
|
721
722
|
}, ___EmotionJSX(Controls, null)));
|
722
723
|
});
|
724
|
+
};
|
725
|
+
export var WithCharts = function WithCharts(_ref6) {
|
726
|
+
var args = _extends({}, (_objectDestructuringEmpty(_ref6), _ref6));
|
727
|
+
var chartContainerRef = useRef();
|
728
|
+
return ___EmotionJSX(ListView, _extends({}, args, {
|
729
|
+
items: items,
|
730
|
+
selectionMode: "multiple"
|
731
|
+
}), function (item) {
|
732
|
+
return ___EmotionJSX(Item, {
|
733
|
+
key: item.name
|
734
|
+
}, ___EmotionJSX(ListViewItem, {
|
735
|
+
ref: chartContainerRef,
|
736
|
+
data: {
|
737
|
+
text: item.name,
|
738
|
+
subtext: item.subtext,
|
739
|
+
icon: FormSelectIcon
|
740
|
+
}
|
741
|
+
}, ___EmotionJSX(ListViewItemChart, {
|
742
|
+
containerRef: chartContainerRef,
|
743
|
+
chartData: chartData,
|
744
|
+
chartDataKey: "fullData",
|
745
|
+
title: "Avg daily sign-ons:",
|
746
|
+
contentCount: "31",
|
747
|
+
contentCountLabel: "Past 7 days",
|
748
|
+
chartLabel: "12 wk trend",
|
749
|
+
trend: "+115.0%",
|
750
|
+
tooltipText: "See Contributing Data"
|
751
|
+
}), ___EmotionJSX(Controls, null)));
|
752
|
+
});
|
723
753
|
};
|
@@ -38,6 +38,7 @@ styled control components to easily match Ping specs.
|
|
38
38
|
- [ListViewItemEditButton](./?path=/docs/components-listviewitem-controls-listviewitemeditbutton--docs)
|
39
39
|
- [ListViewItemMenu](./?path=/docs/components-listviewitem-controls-listviewitemmenu--docs)
|
40
40
|
- [ListViewItemSwitchField](./?path=/docs/components-listviewitem-controls-listviewitemswitchfield--docs)
|
41
|
+
- [ListViewItemChart](./?path=/docs/components-listviewitem-controls-listviewitemchart--docs)
|
41
42
|
|
42
43
|
### Note:
|
43
44
|
The nature of components that have been styled to match design specs is that as design specs are updated, so will the matching component. Be aware that styles
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { useRef } from 'react';
|
2
2
|
import { Item } from 'react-stately';
|
3
3
|
import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
4
4
|
import FormSelectIcon from '@pingux/mdi-react/FormSelectIcon';
|
5
5
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
6
|
-
import { Badge, Box, ListViewItem, ListViewItemEditButton, ListViewItemMenu, ListViewItemSwitchField, Separator, Text } from '../..';
|
6
|
+
import { Badge, Box, ListViewItem, ListViewItemChart, ListViewItemEditButton, ListViewItemMenu, ListViewItemSwitchField, Separator, Text } from '../..';
|
7
7
|
import { pingImg } from '../../utils/devUtils/constants/images';
|
8
|
+
import { chartData } from './controls/chart/chartData';
|
8
9
|
import ListViewItemReadMe from './ListViewItem.mdx';
|
9
10
|
import { listViewItemArgTypes } from './listViewItemAttributes';
|
10
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -140,6 +141,33 @@ export var WithLeftOfDataSlot = function WithLeftOfDataSlot() {
|
|
140
141
|
key: "delete"
|
141
142
|
}, "Delete user"))));
|
142
143
|
};
|
144
|
+
export var WithCharts = function WithCharts() {
|
145
|
+
var containerRef = useRef();
|
146
|
+
return ___EmotionJSX(Wrapper, null, ___EmotionJSX(ListViewItem, {
|
147
|
+
ref: containerRef,
|
148
|
+
data: {
|
149
|
+
text: 'Kangaroo',
|
150
|
+
subtext: 'kangaroo@example.com',
|
151
|
+
icon: FormSelectIcon
|
152
|
+
}
|
153
|
+
}, ___EmotionJSX(ListViewItemChart, {
|
154
|
+
containerRef: containerRef,
|
155
|
+
chartData: chartData,
|
156
|
+
title: "Avg daily sign-ons:",
|
157
|
+
chartDataKey: "fullData",
|
158
|
+
contentCount: "31",
|
159
|
+
contentCountLabel: "Past 7 days",
|
160
|
+
chartLabel: "12 wk trend",
|
161
|
+
trend: "+115.0%",
|
162
|
+
tooltipText: "See Contributing Data"
|
163
|
+
}), ___EmotionJSX(ListViewItemSwitchField, null), ___EmotionJSX(ListViewItemMenu, null, ___EmotionJSX(Item, {
|
164
|
+
key: "enable"
|
165
|
+
}, "Enable user"), ___EmotionJSX(Item, {
|
166
|
+
key: "disable"
|
167
|
+
}, "Disable user"), ___EmotionJSX(Item, {
|
168
|
+
key: "delete"
|
169
|
+
}, "Delete user"))));
|
170
|
+
};
|
143
171
|
export var WithExtraLongText = function WithExtraLongText() {
|
144
172
|
var renderRightOfData = ___EmotionJSX(Box, {
|
145
173
|
isRow: true,
|
@@ -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
|
+
};
|