@pingux/astro 1.27.0-alpha.14 → 1.27.0-alpha.16
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/DataTable/DataTable.js +477 -0
- package/lib/cjs/components/DataTable/DataTable.stories.js +310 -0
- package/lib/cjs/components/DataTable/DataTable.styles.js +156 -0
- package/lib/cjs/components/DataTable/DataTable.test.js +1307 -0
- package/lib/cjs/components/DataTable/DataTableChip.js +63 -0
- package/lib/cjs/components/DataTable/DataTableChip.test.js +38 -0
- package/lib/cjs/components/DataTable/DataTableMenu.js +51 -0
- package/lib/cjs/components/DataTable/DataTableMenu.test.js +20 -0
- package/lib/cjs/components/DataTable/DataTableMultiLine.js +75 -0
- package/lib/cjs/components/DataTable/DataTableMultiLine.test.js +30 -0
- package/lib/cjs/components/DataTable/DataTableVirtualizer.js +188 -0
- package/lib/cjs/components/DataTable/index.js +54 -0
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +8 -2
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +35 -0
- package/lib/cjs/components/PageHeader/PageHeader.js +7 -1
- package/lib/cjs/context/DataTableContext/index.js +31 -0
- package/lib/cjs/index.js +67 -2
- package/lib/cjs/recipes/FlippableCaretMenuButton.stories.js +38 -30
- package/lib/cjs/recipes/ListAndPanel.stories.js +102 -87
- package/lib/cjs/recipes/MaskedValue.stories.js +8 -5
- package/lib/cjs/recipes/NeutralInput.stories.js +6 -3
- package/lib/cjs/recipes/OneWayToBidirectionalArrow.stories.js +38 -33
- package/lib/cjs/recipes/PageHeader.stories.js +73 -0
- package/lib/cjs/recipes/RowLineChart.stories.js +58 -70
- package/lib/cjs/recipes/SelectedFieldOverlay.story.js +25 -21
- package/lib/cjs/recipes/TrialExperienceStatusBar.stories.js +81 -72
- package/lib/cjs/styles/variants/variants.js +4 -1
- package/lib/components/DataTable/DataTable.js +431 -0
- package/lib/components/DataTable/DataTable.stories.js +273 -0
- package/lib/components/DataTable/DataTable.styles.js +137 -0
- package/lib/components/DataTable/DataTable.test.js +1256 -0
- package/lib/components/DataTable/DataTableChip.js +33 -0
- package/lib/components/DataTable/DataTableChip.test.js +31 -0
- package/lib/components/DataTable/DataTableMenu.js +24 -0
- package/lib/components/DataTable/DataTableMenu.test.js +13 -0
- package/lib/components/DataTable/DataTableMultiLine.js +46 -0
- package/lib/components/DataTable/DataTableMultiLine.test.js +22 -0
- package/lib/components/DataTable/DataTableVirtualizer.js +157 -0
- package/lib/components/DataTable/index.js +5 -0
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +7 -2
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +25 -0
- package/lib/components/PageHeader/PageHeader.js +8 -1
- package/lib/context/DataTableContext/index.js +5 -0
- package/lib/index.js +4 -1
- package/lib/recipes/FlippableCaretMenuButton.stories.js +38 -30
- package/lib/recipes/ListAndPanel.stories.js +102 -87
- package/lib/recipes/MaskedValue.stories.js +8 -5
- package/lib/recipes/NeutralInput.stories.js +6 -3
- package/lib/recipes/OneWayToBidirectionalArrow.stories.js +38 -33
- package/lib/recipes/PageHeader.stories.js +53 -0
- package/lib/recipes/RowLineChart.stories.js +58 -70
- package/lib/recipes/SelectedFieldOverlay.story.js +25 -21
- package/lib/recipes/TrialExperienceStatusBar.stories.js +81 -72
- package/lib/styles/variants/variants.js +3 -1
- package/package.json +55 -50
@@ -0,0 +1,33 @@
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
2
|
+
import React, { forwardRef } from 'react';
|
3
|
+
import AlertIcon from 'mdi-react/AlertIcon';
|
4
|
+
import AlertCircleIcon from 'mdi-react/AlertCircleIcon';
|
5
|
+
import CheckIcon from 'mdi-react/CheckIcon';
|
6
|
+
import PropTypes from 'prop-types';
|
7
|
+
import { Chip, Icon } from '../../index';
|
8
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
|
+
var DataTableChip = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
10
|
+
var cell = _ref.cell;
|
11
|
+
var color = cell === 'Pending' ? 'line.light' : cell === 'Failed' ? 'warning.bright' : cell === 'Rejected' ? 'critical.bright' : 'success.dark';
|
12
|
+
return ___EmotionJSX(Chip, {
|
13
|
+
label: cell,
|
14
|
+
bg: "white",
|
15
|
+
ref: ref,
|
16
|
+
textColor: cell === 'Pending' || cell === 'Failed' ? 'text.primary' : color,
|
17
|
+
sx: {
|
18
|
+
border: '1px',
|
19
|
+
borderStyle: 'solid',
|
20
|
+
borderColor: color,
|
21
|
+
flexDirection: 'row-reverse !important'
|
22
|
+
}
|
23
|
+
}, cell !== 'Pending' && ___EmotionJSX(Icon, {
|
24
|
+
icon: cell === 'Approved' ? CheckIcon : cell === 'Rejected' ? AlertCircleIcon : cell === 'Failed' ? AlertIcon : null,
|
25
|
+
mr: "xs",
|
26
|
+
size: "14px",
|
27
|
+
color: color
|
28
|
+
}));
|
29
|
+
});
|
30
|
+
DataTableChip.propTypes = {
|
31
|
+
cell: PropTypes.string
|
32
|
+
};
|
33
|
+
export default DataTableChip;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import { DataTableChip } from '../../index';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
|
6
|
+
var getComponent = function getComponent() {
|
7
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
8
|
+
return render(___EmotionJSX(DataTableChip, props));
|
9
|
+
};
|
10
|
+
|
11
|
+
test('renders component with rejected label', function () {
|
12
|
+
var cell = 'Rejected';
|
13
|
+
getComponent({
|
14
|
+
cell: cell
|
15
|
+
});
|
16
|
+
expect(screen.queryByText('Rejected')).toBeInTheDocument();
|
17
|
+
});
|
18
|
+
test('renders component with pending label', function () {
|
19
|
+
var cell = 'Pending';
|
20
|
+
getComponent({
|
21
|
+
cell: cell
|
22
|
+
});
|
23
|
+
expect(screen.queryByText('Pending')).toBeInTheDocument();
|
24
|
+
});
|
25
|
+
test('renders component with failed label', function () {
|
26
|
+
var cell = 'Failed';
|
27
|
+
getComponent({
|
28
|
+
cell: cell
|
29
|
+
});
|
30
|
+
expect(screen.queryByText('Failed')).toBeInTheDocument();
|
31
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React, { forwardRef } from 'react';
|
2
|
+
import DotsVerticalIcon from 'mdi-react/DotsVerticalIcon';
|
3
|
+
import { Box, Icon, IconButton, Item, Menu, OverlayProvider, PopoverMenu, Text } from '../../index';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
var DataTableMenu = /*#__PURE__*/forwardRef(function (props, ref) {
|
6
|
+
return ___EmotionJSX(Box, {
|
7
|
+
ref: ref,
|
8
|
+
variant: "dataTable.tableMenu"
|
9
|
+
}, ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(PopoverMenu, null, ___EmotionJSX(IconButton, {
|
10
|
+
"aria-label": "row menu"
|
11
|
+
}, ___EmotionJSX(Icon, {
|
12
|
+
icon: DotsVerticalIcon
|
13
|
+
})), ___EmotionJSX(Menu, null, ___EmotionJSX(Item, {
|
14
|
+
key: "edit"
|
15
|
+
}, "Edit"), ___EmotionJSX(Item, {
|
16
|
+
key: "duplicate"
|
17
|
+
}, "Duplicate"), ___EmotionJSX(Item, {
|
18
|
+
key: "delete",
|
19
|
+
textValue: "delete"
|
20
|
+
}, ___EmotionJSX(Text, {
|
21
|
+
color: "critical.bright"
|
22
|
+
}, "Delete"))))));
|
23
|
+
});
|
24
|
+
export default DataTableMenu;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import { DataTableMenu } from '../../index';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
|
6
|
+
var getComponent = function getComponent() {
|
7
|
+
return render(___EmotionJSX(DataTableMenu, null));
|
8
|
+
};
|
9
|
+
|
10
|
+
test('renders component with menu', function () {
|
11
|
+
getComponent();
|
12
|
+
expect(screen.getByLabelText('row menu')).toBeInTheDocument();
|
13
|
+
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
3
|
+
import React, { forwardRef } from 'react';
|
4
|
+
import PropTypes from 'prop-types';
|
5
|
+
import { Box, Icon } from '../../index';
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
|
+
var DataTableMultiLine = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
8
|
+
var cell = _ref.cell;
|
9
|
+
return ___EmotionJSX(React.Fragment, null, _mapInstanceProperty(cell).call(cell, function (item) {
|
10
|
+
var _context;
|
11
|
+
|
12
|
+
return ___EmotionJSX(Box, {
|
13
|
+
key: _concatInstanceProperty(_context = "".concat(cell.key, "_")).call(_context, item.accountId),
|
14
|
+
ref: ref
|
15
|
+
}, ___EmotionJSX(Box, {
|
16
|
+
sx: {
|
17
|
+
flexDirection: 'row !important'
|
18
|
+
}
|
19
|
+
}, ___EmotionJSX(Box, {
|
20
|
+
sx: {
|
21
|
+
alignItems: 'center',
|
22
|
+
justifyContent: 'center',
|
23
|
+
mx: '18px'
|
24
|
+
}
|
25
|
+
}, ___EmotionJSX(Icon, {
|
26
|
+
icon: item.icon,
|
27
|
+
color: "accent.40",
|
28
|
+
size: "18.75"
|
29
|
+
})), ___EmotionJSX(Box, null, ___EmotionJSX(Box, {
|
30
|
+
sx: {
|
31
|
+
fontWeight: 500,
|
32
|
+
fontSize: '15px'
|
33
|
+
}
|
34
|
+
}, item.name), ___EmotionJSX(Box, {
|
35
|
+
sx: {
|
36
|
+
color: 'neutral.40',
|
37
|
+
fontWeight: 400,
|
38
|
+
fontSize: '13px'
|
39
|
+
}
|
40
|
+
}, "Account ID: ", item.accountId))));
|
41
|
+
}));
|
42
|
+
});
|
43
|
+
DataTableMultiLine.propTypes = {
|
44
|
+
cell: PropTypes.arrayOf(PropTypes.shape({}))
|
45
|
+
};
|
46
|
+
export default DataTableMultiLine;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import ApplicationIcon from 'mdi-react/ApplicationIcon';
|
4
|
+
import { DataTableMultiLine } from '../../index';
|
5
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
6
|
+
|
7
|
+
var getComponent = function getComponent() {
|
8
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
9
|
+
return render(___EmotionJSX(DataTableMultiLine, props));
|
10
|
+
};
|
11
|
+
|
12
|
+
test('renders component with account name', function () {
|
13
|
+
var cell = [{
|
14
|
+
name: 'Acme',
|
15
|
+
icon: ApplicationIcon,
|
16
|
+
accountId: 123
|
17
|
+
}];
|
18
|
+
getComponent({
|
19
|
+
cell: cell
|
20
|
+
});
|
21
|
+
expect(screen.queryByText('Acme')).toBeInTheDocument();
|
22
|
+
});
|
@@ -0,0 +1,157 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["layout", "collection", "focusedKey", "renderView", "renderWrapper", "domRef", "bodyRef", "setTableWidth", "getColumnWidth", "onVisibleRectChange"];
|
4
|
+
import PropTypes from 'prop-types';
|
5
|
+
import React, { forwardRef, useCallback, useRef } from 'react';
|
6
|
+
import { chain, mergeProps, useLayoutEffect } from '@react-aria/utils';
|
7
|
+
import { ScrollView, setScrollLeft, useVirtualizer } from '@react-aria/virtualizer';
|
8
|
+
import { useVirtualizerState } from '@react-stately/virtualizer';
|
9
|
+
import { Box } from '../../index';
|
10
|
+
/**
|
11
|
+
* Custom Virtualizer using react aria Spectrum TableView/TableVirtualizer
|
12
|
+
* Primarily utilizes [TableView](https://react-spectrum.adobe.com/react-spectrum/TableView.html)
|
13
|
+
*/
|
14
|
+
|
15
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
16
|
+
var DataTableVirtualizer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
17
|
+
var _layout$getLayoutInfo;
|
18
|
+
|
19
|
+
var layout = _ref.layout,
|
20
|
+
collection = _ref.collection,
|
21
|
+
focusedKey = _ref.focusedKey,
|
22
|
+
renderView = _ref.renderView,
|
23
|
+
renderWrapper = _ref.renderWrapper,
|
24
|
+
domRef = _ref.domRef,
|
25
|
+
bodyRef = _ref.bodyRef,
|
26
|
+
setTableWidth = _ref.setTableWidth,
|
27
|
+
getColumnWidth = _ref.getColumnWidth,
|
28
|
+
onVisibleRectChangeProp = _ref.onVisibleRectChange,
|
29
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
30
|
+
|
31
|
+
var direction = 'ltr'; // useLocale override
|
32
|
+
|
33
|
+
var headerRef = useRef(ref);
|
34
|
+
var loadingState = collection.body.props.loadingState;
|
35
|
+
var isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
|
36
|
+
var onLoadMore = collection.body.props.onLoadMore;
|
37
|
+
var state = useVirtualizerState({
|
38
|
+
layout: layout,
|
39
|
+
collection: collection,
|
40
|
+
renderView: renderView,
|
41
|
+
renderWrapper: renderWrapper,
|
42
|
+
onVisibleRectChange: function onVisibleRectChange(rect) {
|
43
|
+
// eslint-disable-next-line no-param-reassign
|
44
|
+
bodyRef.current.scrollTop = rect.y;
|
45
|
+
setScrollLeft(bodyRef.current, direction, rect.x);
|
46
|
+
},
|
47
|
+
transitionDuration: isLoading ? 160 : 220
|
48
|
+
});
|
49
|
+
|
50
|
+
var _useVirtualizer = useVirtualizer({
|
51
|
+
focusedKey: focusedKey,
|
52
|
+
scrollToItem: function scrollToItem(key) {
|
53
|
+
var item = collection.getItem(key);
|
54
|
+
state.virtualizer.scrollToItem(key, {
|
55
|
+
duration: 0,
|
56
|
+
// Prevent scrolling to the top when clicking on column headers.
|
57
|
+
shouldScrollY: (item === null || item === void 0 ? void 0 : item.type) !== 'column',
|
58
|
+
// Offset scroll position by width of selection cell
|
59
|
+
// (which is sticky and will overlap the cell we're scrolling to).
|
60
|
+
offsetX: 0
|
61
|
+
});
|
62
|
+
}
|
63
|
+
}, state, domRef),
|
64
|
+
virtualizerProps = _useVirtualizer.virtualizerProps; // If column widths change, need to relay out.
|
65
|
+
|
66
|
+
|
67
|
+
useLayoutEffect(function () {
|
68
|
+
state.virtualizer.relayoutNow({
|
69
|
+
sizeChanged: true
|
70
|
+
});
|
71
|
+
}, [state.virtualizer]);
|
72
|
+
var headerHeight = ((_layout$getLayoutInfo = layout.getLayoutInfo('header')) === null || _layout$getLayoutInfo === void 0 ? void 0 : _layout$getLayoutInfo.rect.height) || 0;
|
73
|
+
var visibleRect = state.virtualizer.visibleRect; // Sync the scroll position from the table body to the header container.
|
74
|
+
|
75
|
+
var onScroll = useCallback(function () {
|
76
|
+
headerRef.current.scrollLeft = bodyRef.current.scrollLeft;
|
77
|
+
}, [bodyRef]);
|
78
|
+
var onVisibleRectChange = useCallback(function (rect) {
|
79
|
+
setTableWidth(rect.width);
|
80
|
+
state.setVisibleRect(rect);
|
81
|
+
|
82
|
+
if (!isLoading && onLoadMore) {
|
83
|
+
var scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
|
84
|
+
|
85
|
+
if (rect.y > scrollOffset) {
|
86
|
+
onLoadMore();
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
90
|
+
[onLoadMore, isLoading, state.setVisibleRect, state.virtualizer]);
|
91
|
+
useLayoutEffect(function () {
|
92
|
+
if (!isLoading && onLoadMore && !state.isAnimating) {
|
93
|
+
if (state.contentSize.height <= state.virtualizer.visibleRect.height) {
|
94
|
+
onLoadMore();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}, [state.contentSize, state.virtualizer, state.isAnimating, onLoadMore, isLoading]);
|
98
|
+
return ___EmotionJSX(Box, _extends({}, mergeProps(otherProps, virtualizerProps), {
|
99
|
+
ref: domRef
|
100
|
+
}), ___EmotionJSX(Box, {
|
101
|
+
role: "presentation",
|
102
|
+
variant: "dataTable.tableHeadWrapper",
|
103
|
+
style: {
|
104
|
+
width: visibleRect.width,
|
105
|
+
height: headerHeight,
|
106
|
+
overflow: 'hidden',
|
107
|
+
position: 'relative',
|
108
|
+
willChange: state.isScrolling ? 'scroll-position' : '',
|
109
|
+
transition: state.isAnimating ? "none ".concat(state.virtualizer.transitionDuration, "ms") : undefined
|
110
|
+
},
|
111
|
+
ref: headerRef
|
112
|
+
}, state.visibleViews[0]), ___EmotionJSX(ScrollView, {
|
113
|
+
role: "presentation",
|
114
|
+
variant: "dataTable.tableBody",
|
115
|
+
style: {
|
116
|
+
flex: 1
|
117
|
+
},
|
118
|
+
innerStyle: {
|
119
|
+
overflow: 'visible',
|
120
|
+
transition: state.isAnimating ? "none ".concat(state.virtualizer.transitionDuration, "ms") : undefined
|
121
|
+
},
|
122
|
+
ref: bodyRef,
|
123
|
+
contentSize: state.contentSize,
|
124
|
+
onVisibleRectChange: chain(onVisibleRectChange, onVisibleRectChangeProp),
|
125
|
+
onScrollStart: state.startScrolling,
|
126
|
+
onScrollEnd: state.endScrolling,
|
127
|
+
onScroll: onScroll
|
128
|
+
}, state.visibleViews[1]));
|
129
|
+
});
|
130
|
+
DataTableVirtualizer.propTypes = {
|
131
|
+
bodyRef: PropTypes.shape({
|
132
|
+
current: PropTypes.shape({
|
133
|
+
scrollLeft: PropTypes.number,
|
134
|
+
scrollTop: PropTypes.number
|
135
|
+
})
|
136
|
+
}),
|
137
|
+
collection: PropTypes.shape({
|
138
|
+
body: PropTypes.shape({
|
139
|
+
props: PropTypes.shape({
|
140
|
+
loadingState: PropTypes.string,
|
141
|
+
onLoadMore: PropTypes.func
|
142
|
+
})
|
143
|
+
}),
|
144
|
+
getItem: PropTypes.func
|
145
|
+
}),
|
146
|
+
domRef: PropTypes.shape({}),
|
147
|
+
focusedKey: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
148
|
+
getColumnWidth: PropTypes.func,
|
149
|
+
layout: PropTypes.shape({
|
150
|
+
getLayoutInfo: PropTypes.func
|
151
|
+
}),
|
152
|
+
onVisibleRectChange: PropTypes.func,
|
153
|
+
renderView: PropTypes.func,
|
154
|
+
renderWrapper: PropTypes.func,
|
155
|
+
setTableWidth: PropTypes.func
|
156
|
+
};
|
157
|
+
export default DataTableVirtualizer;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { default } from './DataTable';
|
2
|
+
export { default as DataTableChip } from './DataTableChip';
|
3
|
+
export { default as DataTableMultiLine } from './DataTableMultiLine';
|
4
|
+
export { default as DataTableVirtualize } from './DataTableVirtualizer';
|
5
|
+
export { default as DataTableMenu } from './DataTableMenu';
|
@@ -12,7 +12,7 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
|
|
12
12
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
13
13
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
14
14
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
15
|
-
var _excluded = ["children", "disabledKeys", "emptySearchText", "isDefaultOpen", "isOpen", "items", "itemsFilter", "onOpenChange", "onNamePress", "onPopoverClose", "onPopoverOpen", "onSelectionChange", "name", "searchProps", "selectedItem"];
|
15
|
+
var _excluded = ["children", "disabledKeys", "emptySearchText", "isDefaultOpen", "isOpen", "items", "itemsFilter", "onOpenChange", "onNamePress", "onPopoverClose", "onPopoverOpen", "onSelectionChange", "name", "searchProps", "selectedItem", "popoverProps"];
|
16
16
|
|
17
17
|
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; }
|
18
18
|
|
@@ -25,6 +25,7 @@ import HomeIcon from 'mdi-react/HomeIcon';
|
|
25
25
|
import PropTypes from 'prop-types';
|
26
26
|
import { useOverlayTriggerState } from '@react-stately/overlays';
|
27
27
|
import { useOverlayPosition, useOverlayTrigger } from '@react-aria/overlays';
|
28
|
+
import { mergeProps } from '@react-aria/utils';
|
28
29
|
import ArrowDropUpIcon from 'mdi-react/ArrowDropUpIcon';
|
29
30
|
import ArrowDropDownIcon from 'mdi-react/ArrowDropDownIcon';
|
30
31
|
import { FocusScope } from '@react-aria/focus';
|
@@ -51,6 +52,7 @@ var EnvironmentBreadcrumb = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
51
52
|
name = props.name,
|
52
53
|
searchProps = props.searchProps,
|
53
54
|
selectedItem = props.selectedItem,
|
55
|
+
popoverProps = props.popoverProps,
|
54
56
|
others = _objectWithoutProperties(props, _excluded);
|
55
57
|
|
56
58
|
var _useState = useState(''),
|
@@ -215,7 +217,7 @@ var EnvironmentBreadcrumb = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
215
217
|
"aria-label": "".concat((typeof selectedItem === 'string' ? selectedItem : selectedValue) || 'Selected Item')
|
216
218
|
}), selectedItem, ___EmotionJSX(Icon, {
|
217
219
|
icon: popoverState.isOpen ? ArrowDropUpIcon : ArrowDropDownIcon
|
218
|
-
})), ___EmotionJSX(PopoverContainer, _extends({}, overlayProps, positionProps, {
|
220
|
+
})), ___EmotionJSX(PopoverContainer, _extends({}, overlayProps, positionProps, mergeProps(overlayProps, positionProps, popoverProps), {
|
219
221
|
ref: overlayRef,
|
220
222
|
isOpen: popoverState.isOpen,
|
221
223
|
scrollRef: scrollBoxRef,
|
@@ -303,6 +305,9 @@ EnvironmentBreadcrumb.propTypes = {
|
|
303
305
|
/** Callback function that fires when the dropdown is closed. */
|
304
306
|
onPopoverClose: PropTypes.func,
|
305
307
|
|
308
|
+
/** Props object that is spread directly into the popover container component. */
|
309
|
+
popoverProps: PropTypes.shape({}),
|
310
|
+
|
306
311
|
/** Props object that is spread directly into the SearchField element. */
|
307
312
|
searchProps: PropTypes.shape({}),
|
308
313
|
|
@@ -1,6 +1,20 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
1
9
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
2
10
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
11
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
3
12
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
13
|
+
|
14
|
+
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; }
|
15
|
+
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
17
|
+
|
4
18
|
import React from 'react';
|
5
19
|
import userEvent from '@testing-library/user-event';
|
6
20
|
import { Section } from '@react-stately/collections';
|
@@ -38,6 +52,10 @@ var defaultProps = {
|
|
38
52
|
},
|
39
53
|
items: items
|
40
54
|
};
|
55
|
+
var popoverProps = {
|
56
|
+
maxWidth: '100px',
|
57
|
+
'data-testid': 'popover-container'
|
58
|
+
};
|
41
59
|
var defaultWithSectionsProps = {
|
42
60
|
'data-testid': testEnvBreadcrumb,
|
43
61
|
name: testName,
|
@@ -115,6 +133,13 @@ test('should display name', function () {
|
|
115
133
|
getComponent();
|
116
134
|
expect(screen.getByText(testName)).toBeInTheDocument();
|
117
135
|
});
|
136
|
+
test('should spread props into popover container', function () {
|
137
|
+
getComponent(_objectSpread(_objectSpread({}, popoverProps), {}, {
|
138
|
+
isDefaultOpen: true
|
139
|
+
}));
|
140
|
+
userEvent.click(screen.getByText(testSelectedItem));
|
141
|
+
expect(screen.queryByTestId('popover-container')).toHaveStyle('max-width: 100px');
|
142
|
+
});
|
118
143
|
test('should display selectedItem', function () {
|
119
144
|
getComponent();
|
120
145
|
expect(screen.getByText(testSelectedItem)).toBeInTheDocument();
|
@@ -6,13 +6,20 @@ import PropTypes from 'prop-types';
|
|
6
6
|
import Text from '../Text/Text';
|
7
7
|
import Box from '../Box/Box';
|
8
8
|
import { useDeprecationWarning } from '../../hooks';
|
9
|
+
/**
|
10
|
+
* A `Page Header` is a composed component using text and icon button.
|
11
|
+
* The component is separated from the body and appears at the top.
|
12
|
+
* For customization,
|
13
|
+
* please see [Page Header](./?path=/story/recipes-page-header--default) recipe docs.
|
14
|
+
*/
|
15
|
+
|
9
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
17
|
var PageHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
11
18
|
var title = props.title,
|
12
19
|
children = props.children,
|
13
20
|
others = _objectWithoutProperties(props, _excluded);
|
14
21
|
|
15
|
-
useDeprecationWarning('The Page Header component will be deprecated in Astro-UI 2.0.0.');
|
22
|
+
useDeprecationWarning('The Page Header component will be deprecated in Astro-UI 2.0.0. Use Page Header recipe instead.');
|
16
23
|
return ___EmotionJSX(Box, _extends({
|
17
24
|
isRow: true,
|
18
25
|
justifyContent: "space-between",
|
package/lib/index.js
CHANGED
@@ -151,4 +151,7 @@ export * from './components/TooltipTrigger';
|
|
151
151
|
|
152
152
|
export { Item, Section } from '@react-stately/collections';
|
153
153
|
export { OverlayProvider, useOverlayPosition, useOverlayTrigger } from '@react-aria/overlays';
|
154
|
-
export { useOverlayTriggerState } from '@react-stately/overlays';
|
154
|
+
export { useOverlayTriggerState } from '@react-stately/overlays';
|
155
|
+
export { default as DataTable } from './components/DataTable';
|
156
|
+
export * from './components/DataTable';
|
157
|
+
export { Cell as DataTableCell, Column as DataTableColumn, Row as DataTableRow, TableBody as DataTableBody, TableHeader as DataTableHeader } from '@react-spectrum/table';
|
@@ -31,6 +31,40 @@ export default {
|
|
31
31
|
title: 'Recipes/FlippableCaretMenuButton'
|
32
32
|
};
|
33
33
|
var buttonArray = ['Web App', 'Native App', 'Single Page App', 'Non-Interactive', 'Worker', 'Advanced Configuration', 'Built-in admin console for this environment', 'Built-in Application portal'];
|
34
|
+
var sx = {
|
35
|
+
openButton: {
|
36
|
+
height: '30px',
|
37
|
+
borderRadius: 'md',
|
38
|
+
fontSize: '13px',
|
39
|
+
mb: 'sm'
|
40
|
+
},
|
41
|
+
closeIconButton: {
|
42
|
+
position: 'absolute',
|
43
|
+
top: '14px',
|
44
|
+
right: 'sm'
|
45
|
+
},
|
46
|
+
buttonsContainer: {
|
47
|
+
p: 'lg',
|
48
|
+
flexDirection: 'initial !important',
|
49
|
+
alignContent: 'space-between',
|
50
|
+
flexWrap: 'wrap'
|
51
|
+
},
|
52
|
+
selectedButton: {
|
53
|
+
mb: 'sm',
|
54
|
+
mr: '4px',
|
55
|
+
height: '30px',
|
56
|
+
borderRadius: '15px',
|
57
|
+
fontSize: '13px'
|
58
|
+
},
|
59
|
+
unSelectedButton: {
|
60
|
+
mb: 'sm',
|
61
|
+
mr: '4px',
|
62
|
+
borderColor: 'neutral.80',
|
63
|
+
height: '30px',
|
64
|
+
borderRadius: '15px',
|
65
|
+
fontSize: '13px'
|
66
|
+
}
|
67
|
+
};
|
34
68
|
export var Default = function Default() {
|
35
69
|
var buttonRef = useRef();
|
36
70
|
var popoverRef = useRef();
|
@@ -89,14 +123,9 @@ export var Default = function Default() {
|
|
89
123
|
|
90
124
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Button, {
|
91
125
|
ref: buttonRef,
|
92
|
-
mb: "sm",
|
93
126
|
variant: "inline",
|
94
127
|
onPress: onChange,
|
95
|
-
sx:
|
96
|
-
height: '30px',
|
97
|
-
borderRadius: '15px',
|
98
|
-
fontSize: '13px'
|
99
|
-
}
|
128
|
+
sx: sx.openButton
|
100
129
|
}, ___EmotionJSX(Box, {
|
101
130
|
isRow: true,
|
102
131
|
alignItems: "center"
|
@@ -119,36 +148,15 @@ export var Default = function Default() {
|
|
119
148
|
onPress: function onPress() {
|
120
149
|
return setIsOpen(false);
|
121
150
|
},
|
122
|
-
sx:
|
123
|
-
position: 'absolute',
|
124
|
-
top: 14,
|
125
|
-
right: 10
|
126
|
-
}
|
151
|
+
sx: sx.closeIconButton
|
127
152
|
}, ___EmotionJSX(Icon, {
|
128
153
|
icon: CloseIcon
|
129
154
|
})), ___EmotionJSX(Box, {
|
130
|
-
sx:
|
131
|
-
p: 'lg',
|
132
|
-
flexDirection: 'initial !important',
|
133
|
-
alignContent: 'space-between',
|
134
|
-
flexWrap: 'wrap'
|
135
|
-
}
|
155
|
+
sx: sx.buttonsContainer
|
136
156
|
}, _mapInstanceProperty(buttonArray).call(buttonArray, function (item) {
|
137
157
|
return ___EmotionJSX(Button, {
|
138
|
-
mb: "sm",
|
139
158
|
variant: "inline",
|
140
|
-
sx: _includesInstanceProperty(selectedButtons).call(selectedButtons, item) ?
|
141
|
-
mr: '4px',
|
142
|
-
height: '30px',
|
143
|
-
borderRadius: '15px',
|
144
|
-
fontSize: '13px'
|
145
|
-
} : {
|
146
|
-
mr: '4px',
|
147
|
-
borderColor: 'neutral.80',
|
148
|
-
height: '30px',
|
149
|
-
borderRadius: '15px',
|
150
|
-
fontSize: '13px'
|
151
|
-
},
|
159
|
+
sx: _includesInstanceProperty(selectedButtons).call(selectedButtons, item) ? sx.selectedButton : sx.unSelectedButton,
|
152
160
|
key: item,
|
153
161
|
onPress: function onPress() {
|
154
162
|
return toggleButton(item);
|