@pingux/astro 2.25.0-alpha.1 → 2.25.0-alpha.3
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/Button/Buttons.styles.js +8 -0
- package/lib/cjs/components/DataTable/DataTable.js +151 -82
- package/lib/cjs/components/DataTable/DataTable.stories.js +262 -113
- package/lib/cjs/components/DataTable/DataTable.styles.js +36 -22
- package/lib/cjs/components/DataTable/DataTable.test.js +21 -14
- package/lib/cjs/components/DataTable/DataTableMenu.js +1 -0
- package/lib/cjs/components/DataTable/DataTableVirtualizer.js +7 -10
- package/lib/cjs/components/DataTable/index.js +1 -1
- package/lib/cjs/components/Text/Text.styles.d.ts +11 -0
- package/lib/cjs/components/Text/Text.styles.js +6 -0
- package/lib/cjs/recipes/DataVisualization.stories.js +416 -0
- package/lib/cjs/recipes/ListAndPanel.stories.js +7 -0
- package/lib/cjs/utils/designUtils/figmaLinks.js +3 -0
- package/lib/cjs/utils/devUtils/constants/images.js +3 -1
- package/lib/components/Button/Buttons.styles.js +8 -0
- package/lib/components/DataTable/DataTable.js +145 -76
- package/lib/components/DataTable/DataTable.stories.js +257 -112
- package/lib/components/DataTable/DataTable.styles.js +36 -22
- package/lib/components/DataTable/DataTable.test.js +21 -14
- package/lib/components/DataTable/DataTableMenu.js +1 -0
- package/lib/components/DataTable/DataTableVirtualizer.js +7 -10
- package/lib/components/DataTable/index.js +1 -1
- package/lib/components/Text/Text.styles.js +6 -0
- package/lib/recipes/DataVisualization.stories.js +403 -0
- package/lib/recipes/ListAndPanel.stories.js +7 -0
- package/lib/utils/designUtils/figmaLinks.js +3 -0
- package/lib/utils/devUtils/constants/images.js +1 -0
- package/package.json +7 -6
@@ -29,6 +29,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/
|
|
29
29
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
30
30
|
var _react = _interopRequireDefault(require("react"));
|
31
31
|
var _reactStately = require("react-stately");
|
32
|
+
var _i18n = require("@react-aria/i18n");
|
32
33
|
var _react2 = require("@testing-library/react");
|
33
34
|
var _reactHooks = require("@testing-library/react-hooks");
|
34
35
|
var _index = require("../../index");
|
@@ -310,7 +311,7 @@ describe('Async DataTable', function () {
|
|
310
311
|
(0, _react2.act)(function () {
|
311
312
|
jest.runAllTimers();
|
312
313
|
});
|
313
|
-
expect(onLoadMore).toHaveBeenCalledTimes(
|
314
|
+
expect(onLoadMore).toHaveBeenCalledTimes(6);
|
314
315
|
});
|
315
316
|
test('renders a spinner at the bottom when loading more', function () {
|
316
317
|
var testId = 'loadingMoreTable';
|
@@ -814,10 +815,16 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
814
815
|
})));
|
815
816
|
};
|
816
817
|
test('click on column header should sort column A => Z', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
817
|
-
var _renderHook5, result, sortableTable, headers;
|
818
|
+
var utils, collator, _renderHook5, result, sortableTable, headers;
|
818
819
|
return _regeneratorRuntime().wrap(function _callee24$(_context28) {
|
819
820
|
while (1) switch (_context28.prev = _context28.next) {
|
820
821
|
case 0:
|
822
|
+
utils = (0, _reactHooks.renderHook)(function () {
|
823
|
+
return (0, _i18n.useCollator)({
|
824
|
+
numeric: true
|
825
|
+
});
|
826
|
+
});
|
827
|
+
collator = utils.result.current;
|
821
828
|
_renderHook5 = (0, _reactHooks.renderHook)(function () {
|
822
829
|
return (0, _reactStately.useAsyncList)({
|
823
830
|
load: function load() {
|
@@ -847,7 +854,7 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
847
854
|
var first = a[sortDescriptor.column];
|
848
855
|
var second = b[sortDescriptor.column];
|
849
856
|
// eslint-disable-next-line radix
|
850
|
-
var cmp = (
|
857
|
+
var cmp = collator.compare(first, second);
|
851
858
|
if (sortDescriptor.direction === 'descending') {
|
852
859
|
cmp *= -1;
|
853
860
|
}
|
@@ -867,7 +874,7 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
867
874
|
}
|
868
875
|
});
|
869
876
|
}), result = _renderHook5.result;
|
870
|
-
_context28.next =
|
877
|
+
_context28.next = 5;
|
871
878
|
return (0, _reactHooks.act)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
872
879
|
return _regeneratorRuntime().wrap(function _callee19$(_context23) {
|
873
880
|
while (1) switch (_context23.prev = _context23.next) {
|
@@ -879,11 +886,11 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
879
886
|
}
|
880
887
|
}, _callee19);
|
881
888
|
})));
|
882
|
-
case
|
889
|
+
case 5:
|
883
890
|
sortableDataTable({
|
884
891
|
result: result
|
885
892
|
});
|
886
|
-
_context28.next =
|
893
|
+
_context28.next = 8;
|
887
894
|
return (0, _reactHooks.act)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
888
895
|
return _regeneratorRuntime().wrap(function _callee20$(_context24) {
|
889
896
|
while (1) switch (_context24.prev = _context24.next) {
|
@@ -895,7 +902,7 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
895
902
|
}
|
896
903
|
}, _callee20);
|
897
904
|
})));
|
898
|
-
case
|
905
|
+
case 8:
|
899
906
|
sortableTable = _react2.screen.getByTestId(testId);
|
900
907
|
expect(sortableTable).toBeInTheDocument();
|
901
908
|
expect(sortableTable).toBeVisible();
|
@@ -919,7 +926,7 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
919
926
|
expect(result.current.items[1].continent).toBe('North America');
|
920
927
|
expect(result.current.items[2].continent).toBe('Asia');
|
921
928
|
expect(result.current.items[3].continent).toBe('Europe');
|
922
|
-
_context28.next =
|
929
|
+
_context28.next = 33;
|
923
930
|
return (0, _reactHooks.act)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
924
931
|
return _regeneratorRuntime().wrap(function _callee21$(_context25) {
|
925
932
|
while (1) switch (_context25.prev = _context25.next) {
|
@@ -931,12 +938,12 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
931
938
|
}
|
932
939
|
}, _callee21);
|
933
940
|
})));
|
934
|
-
case
|
941
|
+
case 33:
|
935
942
|
expect(result.current.items[0].country).toBe('Canada');
|
936
943
|
expect(result.current.items[1].country).toBe('China');
|
937
944
|
expect(result.current.items[2].country).toBe('France');
|
938
945
|
expect(result.current.items[3].country).toBe('USA');
|
939
|
-
_context28.next =
|
946
|
+
_context28.next = 39;
|
940
947
|
return (0, _reactHooks.act)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
941
948
|
return _regeneratorRuntime().wrap(function _callee22$(_context26) {
|
942
949
|
while (1) switch (_context26.prev = _context26.next) {
|
@@ -948,12 +955,12 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
948
955
|
}
|
949
956
|
}, _callee22);
|
950
957
|
})));
|
951
|
-
case
|
958
|
+
case 39:
|
952
959
|
expect(result.current.items[0].population).toBe(37000000);
|
953
960
|
expect(result.current.items[1].population).toBe(67000000);
|
954
961
|
expect(result.current.items[2].population).toBe(320000000);
|
955
962
|
expect(result.current.items[3].population).toBe(1398000000);
|
956
|
-
_context28.next =
|
963
|
+
_context28.next = 45;
|
957
964
|
return (0, _reactHooks.act)( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
958
965
|
return _regeneratorRuntime().wrap(function _callee23$(_context27) {
|
959
966
|
while (1) switch (_context27.prev = _context27.next) {
|
@@ -965,12 +972,12 @@ describe('Sortable DataTable with useAsyncList', function () {
|
|
965
972
|
}
|
966
973
|
}, _callee23);
|
967
974
|
})));
|
968
|
-
case
|
975
|
+
case 45:
|
969
976
|
expect(result.current.items[0].continent).toBe('Asia');
|
970
977
|
expect(result.current.items[1].continent).toBe('Europe');
|
971
978
|
expect(result.current.items[2].continent).toBe('North America');
|
972
979
|
expect(result.current.items[3].continent).toBe('North America');
|
973
|
-
case
|
980
|
+
case 49:
|
974
981
|
case "end":
|
975
982
|
return _context28.stop();
|
976
983
|
}
|
@@ -22,6 +22,7 @@ var DataTableMenu = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
22
22
|
}, (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.PopoverMenu, null, (0, _react2.jsx)(_index.IconButton, {
|
23
23
|
"aria-label": "row menu"
|
24
24
|
}, (0, _react2.jsx)(_index.Icon, {
|
25
|
+
size: 25,
|
25
26
|
icon: _DotsVerticalIcon["default"],
|
26
27
|
title: {
|
27
28
|
name: 'Dots Vertical Icon'
|
@@ -18,7 +18,7 @@ var _virtualizer2 = require("@react-stately/virtualizer");
|
|
18
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
19
19
|
var _index = require("../../index");
|
20
20
|
var _react2 = require("@emotion/react");
|
21
|
-
var _excluded = ["layout", "collection", "
|
21
|
+
var _excluded = ["layout", "collection", "renderView", "renderWrapper", "domRef", "bodyRef", "setTableWidth", "getColumnWidth", "onVisibleRectChange"];
|
22
22
|
/**
|
23
23
|
* Custom Virtualizer using react aria Spectrum TableView/TableVirtualizer
|
24
24
|
* Primarily utilizes [TableView](https://react-spectrum.adobe.com/react-spectrum/TableView.html)
|
@@ -29,7 +29,6 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
29
29
|
var _layout$getLayoutInfo;
|
30
30
|
var layout = _ref.layout,
|
31
31
|
collection = _ref.collection,
|
32
|
-
focusedKey = _ref.focusedKey,
|
33
32
|
renderView = _ref.renderView,
|
34
33
|
renderWrapper = _ref.renderWrapper,
|
35
34
|
domRef = _ref.domRef,
|
@@ -43,6 +42,7 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
43
42
|
var loadingState = collection.body.props.loadingState;
|
44
43
|
var isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
|
45
44
|
var onLoadMore = collection.body.props.onLoadMore;
|
45
|
+
/* istanbul ignore next */
|
46
46
|
var state = (0, _virtualizer2.useVirtualizerState)({
|
47
47
|
layout: layout,
|
48
48
|
collection: collection,
|
@@ -56,7 +56,6 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
56
56
|
transitionDuration: isLoading ? 160 : 220
|
57
57
|
});
|
58
58
|
var _useVirtualizer = (0, _virtualizer.useVirtualizer)({
|
59
|
-
focusedKey: focusedKey,
|
60
59
|
scrollToItem: function scrollToItem(key) {
|
61
60
|
var item = collection.getItem(key);
|
62
61
|
state.virtualizer.scrollToItem(key, {
|
@@ -71,7 +70,7 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
71
70
|
}, state, domRef),
|
72
71
|
virtualizerProps = _useVirtualizer.virtualizerProps;
|
73
72
|
|
74
|
-
// If column widths change, need to relay out
|
73
|
+
// If column widths change, need to relay out
|
75
74
|
(0, _utils.useLayoutEffect)(function () {
|
76
75
|
state.virtualizer.relayoutNow({
|
77
76
|
sizeChanged: true
|
@@ -85,7 +84,6 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
85
84
|
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
86
85
|
}, [bodyRef]);
|
87
86
|
var onVisibleRectChange = (0, _react.useCallback)(function (rect) {
|
88
|
-
setTableWidth(rect.width);
|
89
87
|
state.setVisibleRect(rect);
|
90
88
|
if (!isLoading && onLoadMore) {
|
91
89
|
var scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
|
@@ -93,9 +91,8 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
93
91
|
onLoadMore();
|
94
92
|
}
|
95
93
|
}
|
96
|
-
|
97
|
-
|
98
|
-
[onLoadMore, isLoading, state.setVisibleRect, state.virtualizer]);
|
94
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
95
|
+
}, [onLoadMore, isLoading, state.setVisibleRect, state.virtualizer]);
|
99
96
|
(0, _utils.useLayoutEffect)(function () {
|
100
97
|
if (!isLoading && onLoadMore && !state.isAnimating) {
|
101
98
|
if (state.contentSize.height <= state.virtualizer.visibleRect.height) {
|
@@ -132,7 +129,8 @@ var DataTableVirtualizer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
132
129
|
onVisibleRectChange: (0, _utils.chain)(onVisibleRectChange, onVisibleRectChangeProp),
|
133
130
|
onScrollStart: state.startScrolling,
|
134
131
|
onScrollEnd: state.endScrolling,
|
135
|
-
onScroll: onScroll
|
132
|
+
onScroll: onScroll,
|
133
|
+
tabIndex: 0
|
136
134
|
}, state.visibleViews[1]));
|
137
135
|
});
|
138
136
|
DataTableVirtualizer.propTypes = {
|
@@ -152,7 +150,6 @@ DataTableVirtualizer.propTypes = {
|
|
152
150
|
getItem: _propTypes["default"].func
|
153
151
|
}),
|
154
152
|
domRef: _propTypes["default"].shape({}),
|
155
|
-
focusedKey: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
|
156
153
|
getColumnWidth: _propTypes["default"].func,
|
157
154
|
layout: _propTypes["default"].shape({
|
158
155
|
getLayoutInfo: _propTypes["default"].func
|
@@ -23,7 +23,7 @@ _Object$defineProperty(exports, "DataTableMultiLine", {
|
|
23
23
|
return _DataTableMultiLine["default"];
|
24
24
|
}
|
25
25
|
});
|
26
|
-
_Object$defineProperty(exports, "
|
26
|
+
_Object$defineProperty(exports, "DataTableVirtualizer", {
|
27
27
|
enumerable: true,
|
28
28
|
get: function get() {
|
29
29
|
return _DataTableVirtualizer["default"];
|
@@ -312,6 +312,17 @@ export declare const text: {
|
|
312
312
|
wordBreak: string;
|
313
313
|
fontFamily: string;
|
314
314
|
};
|
315
|
+
tableHeader: {
|
316
|
+
fontSize: string;
|
317
|
+
fontWeight: number;
|
318
|
+
color: string;
|
319
|
+
fontFamily: string;
|
320
|
+
display: string;
|
321
|
+
overflowWrap: string;
|
322
|
+
maxWidth: string;
|
323
|
+
wordWrap: string;
|
324
|
+
wordBreak: string;
|
325
|
+
};
|
315
326
|
tableData: {
|
316
327
|
fontSize: string;
|
317
328
|
fontWeight: number;
|
@@ -191,6 +191,12 @@ var text = {
|
|
191
191
|
sectionTitle: sectionTitle,
|
192
192
|
subtitle: subtitle,
|
193
193
|
tabLabel: tabLabel,
|
194
|
+
tableHeader: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
195
|
+
fontSize: 'sm',
|
196
|
+
fontWeight: 3,
|
197
|
+
color: 'text.primary',
|
198
|
+
fontFamily: 'standard'
|
199
|
+
}),
|
194
200
|
tableData: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
195
201
|
fontSize: 'sm',
|
196
202
|
fontWeight: 1,
|