@pingux/astro 0.41.0 → 1.0.0-alpha.10
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/CHANGELOG.md +132 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +1 -1
- package/lib/cjs/components/AccordionItem/AccordionItem.js +3 -1
- package/lib/cjs/components/CopyText/CopyText.js +3 -73
- package/lib/cjs/components/FileInputField/FileInputField.js +324 -0
- package/lib/cjs/components/FileInputField/FileInputField.stories.js +250 -0
- package/lib/cjs/components/FileInputField/FileInputField.test.js +227 -0
- package/lib/cjs/components/FileInputField/FileItem.js +125 -0
- package/lib/cjs/components/FileInputField/FileSelect.js +48 -0
- package/lib/cjs/components/FileInputField/index.js +18 -0
- package/lib/cjs/components/ListView/ListView.js +2 -1
- package/lib/cjs/components/ListViewItem/ListViewItem.js +14 -6
- package/lib/cjs/components/NumberField/NumberField.js +4 -2
- package/lib/cjs/components/NumberField/NumberField.test.js +15 -0
- package/lib/cjs/components/Tab/Tab.js +11 -4
- package/lib/cjs/components/Tabs/Tabs.js +7 -1
- package/lib/cjs/components/Tabs/Tabs.stories.js +60 -6
- package/lib/cjs/components/Tabs/Tabs.test.js +78 -15
- package/lib/cjs/hooks/useCopyToClipboard/index.js +18 -0
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +83 -0
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.test.js +79 -0
- package/lib/cjs/index.js +10 -0
- package/lib/cjs/recipes/ApplicationSearchDropdown.stories.js +310 -0
- package/lib/cjs/recipes/CopyToClipboard.stories.js +45 -0
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +146 -0
- package/lib/cjs/recipes/RowLineChart.stories.js +6 -1
- package/lib/cjs/recipes/ScrollableListView.stories.js +1 -1
- package/lib/cjs/styles/forms/input.js +11 -0
- package/lib/cjs/styles/variants/accordion.js +2 -2
- package/lib/cjs/styles/variants/boxes.js +23 -0
- package/lib/cjs/styles/variants/buttons.js +56 -1
- package/lib/cjs/styles/variants/tabs.js +1 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +1 -1
- package/lib/components/AccordionItem/AccordionItem.js +3 -1
- package/lib/components/CopyText/CopyText.js +2 -71
- package/lib/components/FileInputField/FileInputField.js +280 -0
- package/lib/components/FileInputField/FileInputField.stories.js +206 -0
- package/lib/components/FileInputField/FileInputField.test.js +187 -0
- package/lib/components/FileInputField/FileItem.js +100 -0
- package/lib/components/FileInputField/FileSelect.js +31 -0
- package/lib/components/FileInputField/index.js +1 -0
- package/lib/components/ListView/ListView.js +2 -1
- package/lib/components/ListViewItem/ListViewItem.js +14 -6
- package/lib/components/NumberField/NumberField.js +4 -2
- package/lib/components/NumberField/NumberField.test.js +9 -0
- package/lib/components/Tab/Tab.js +11 -4
- package/lib/components/Tabs/Tabs.js +7 -1
- package/lib/components/Tabs/Tabs.stories.js +56 -4
- package/lib/components/Tabs/Tabs.test.js +78 -15
- package/lib/hooks/useCopyToClipboard/index.js +1 -0
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.js +69 -0
- package/lib/hooks/useCopyToClipboard/useCopyToClipboard.test.js +64 -0
- package/lib/index.js +1 -0
- package/lib/recipes/ApplicationSearchDropdown.stories.js +272 -0
- package/lib/recipes/CopyToClipboard.stories.js +25 -0
- package/lib/recipes/RadioButtonsWithLinks.stories.js +120 -0
- package/lib/recipes/RowLineChart.stories.js +6 -1
- package/lib/recipes/ScrollableListView.stories.js +1 -1
- package/lib/styles/forms/input.js +11 -0
- package/lib/styles/variants/accordion.js +2 -2
- package/lib/styles/variants/boxes.js +23 -0
- package/lib/styles/variants/buttons.js +56 -1
- package/lib/styles/variants/tabs.js +1 -0
- package/package.json +3 -2
@@ -0,0 +1,187 @@
|
|
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";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
+
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
13
|
+
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
15
|
+
|
16
|
+
import React from 'react';
|
17
|
+
import userEvent from '@testing-library/user-event';
|
18
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
19
|
+
import axeTest from '../../utils/testUtils/testAxe';
|
20
|
+
import FileInputField from './FileInputField';
|
21
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
22
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
23
|
+
var fileInputFieldTestId = 'file-input-test-id';
|
24
|
+
var testLabel = 'file-input-test-label';
|
25
|
+
var fileSelectTestIdButton = 'file-input-field__file-select';
|
26
|
+
var fileUploadedDeleteIconTestId = 'file-uploaded__delete-file-button';
|
27
|
+
var fileUploadedFileIconErrorTestId = 'file-uploaded__file-icon--is-error';
|
28
|
+
var fileUploadedDownloadTestId = 'file-uploaded__download-file-button';
|
29
|
+
var fileUploadedDownloadLinkTestId = 'file-uploaded__download-link';
|
30
|
+
var loaderTestId = 'file-input-field__loader';
|
31
|
+
var testFileURL = 'test-file-url';
|
32
|
+
var testFileId = 'test-file-id-1';
|
33
|
+
var testFileName = 'chucknorris.png';
|
34
|
+
var testFileName2 = 'chucknorris222.png';
|
35
|
+
var testFile = new File(['(⌐□_□)'], testFileName, {
|
36
|
+
type: 'image/png'
|
37
|
+
});
|
38
|
+
var testFile2 = new File(['(⌐□_□)'], testFileName2, {
|
39
|
+
type: 'image/png'
|
40
|
+
});
|
41
|
+
var testFileObject = {
|
42
|
+
id: testFileId,
|
43
|
+
name: testFileName,
|
44
|
+
downloadLink: testFileURL
|
45
|
+
};
|
46
|
+
var originalValue = global.URL.createObjectURL;
|
47
|
+
var defaultProps = {
|
48
|
+
'data-testid': fileInputFieldTestId,
|
49
|
+
label: testLabel
|
50
|
+
};
|
51
|
+
beforeAll(function () {
|
52
|
+
global.URL.createObjectURL = jest.fn(function () {
|
53
|
+
return testFileURL;
|
54
|
+
});
|
55
|
+
});
|
56
|
+
afterAll(function () {
|
57
|
+
global.URL.createObjectURL = originalValue;
|
58
|
+
});
|
59
|
+
|
60
|
+
var getComponent = function getComponent(props) {
|
61
|
+
return render(___EmotionJSX(FileInputField, _extends({}, defaultProps, props)));
|
62
|
+
};
|
63
|
+
|
64
|
+
axeTest(getComponent);
|
65
|
+
test('should render file input field component by default', function () {
|
66
|
+
getComponent();
|
67
|
+
var fileUploadField = screen.getByTestId(fileInputFieldTestId);
|
68
|
+
expect(fileUploadField).toBeInstanceOf(HTMLDivElement);
|
69
|
+
expect(fileUploadField).toBeInTheDocument();
|
70
|
+
});
|
71
|
+
test('should render files if they are passed as default', function () {
|
72
|
+
getComponent({
|
73
|
+
defaultFileList: [testFileObject]
|
74
|
+
});
|
75
|
+
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
76
|
+
});
|
77
|
+
test('should render files if they are passed as controlled prop', function () {
|
78
|
+
getComponent({
|
79
|
+
fileList: [testFileObject]
|
80
|
+
});
|
81
|
+
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
82
|
+
});
|
83
|
+
test('should be able to display uploaded file', function () {
|
84
|
+
getComponent();
|
85
|
+
var fileUploadFieldInput = screen.getByLabelText(testLabel);
|
86
|
+
userEvent.click(screen.getByTestId(fileSelectTestIdButton));
|
87
|
+
fireEvent.change(fileUploadFieldInput, {
|
88
|
+
target: {
|
89
|
+
files: [testFile]
|
90
|
+
}
|
91
|
+
});
|
92
|
+
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
93
|
+
});
|
94
|
+
test('should be able to add uploaded file if isMultiple true and file select always present', function () {
|
95
|
+
var testCustomButtonName = 'test Custom Button Name';
|
96
|
+
getComponent({
|
97
|
+
defaultFileList: [testFileObject],
|
98
|
+
defaultButtonText: testCustomButtonName,
|
99
|
+
isMultiple: true
|
100
|
+
});
|
101
|
+
var fileUploadFieldInput = screen.getByLabelText(testLabel);
|
102
|
+
userEvent.click(screen.getByTestId(fileSelectTestIdButton));
|
103
|
+
fireEvent.change(fileUploadFieldInput, {
|
104
|
+
target: {
|
105
|
+
files: [testFile2]
|
106
|
+
}
|
107
|
+
});
|
108
|
+
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
109
|
+
expect(screen.getByText(testFileName2)).toBeInTheDocument();
|
110
|
+
expect(screen.getByText(testCustomButtonName)).toBeInTheDocument();
|
111
|
+
});
|
112
|
+
test('should call onFileSelect if file uploaded', function () {
|
113
|
+
var mockOnFileSelect = jest.fn();
|
114
|
+
getComponent({
|
115
|
+
onFileSelect: mockOnFileSelect
|
116
|
+
});
|
117
|
+
var fileUploadFieldInput = screen.getByLabelText(testLabel);
|
118
|
+
userEvent.click(screen.getByTestId(fileSelectTestIdButton));
|
119
|
+
fireEvent.change(fileUploadFieldInput, {
|
120
|
+
target: {
|
121
|
+
files: [testFile]
|
122
|
+
}
|
123
|
+
});
|
124
|
+
expect(mockOnFileSelect).toHaveBeenCalledTimes(1);
|
125
|
+
});
|
126
|
+
test('file should have download link as attribute', function () {
|
127
|
+
getComponent({
|
128
|
+
defaultFileList: [testFileObject]
|
129
|
+
});
|
130
|
+
userEvent.click(screen.getByTestId(fileUploadedDownloadTestId));
|
131
|
+
expect(screen.getByTestId(fileUploadedDownloadLinkTestId)).toHaveAttribute('href', testFileURL);
|
132
|
+
});
|
133
|
+
test('should remove file if trash icon clicked', function () {
|
134
|
+
getComponent({
|
135
|
+
defaultFileList: [testFileObject]
|
136
|
+
});
|
137
|
+
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
138
|
+
userEvent.click(screen.getByTestId(fileUploadedDeleteIconTestId));
|
139
|
+
expect(screen.queryByText(testFileName)).not.toBeInTheDocument();
|
140
|
+
});
|
141
|
+
test('should call onRemove if trash icon clicked', function () {
|
142
|
+
var mockOnRemove = jest.fn();
|
143
|
+
getComponent({
|
144
|
+
defaultFileList: [{
|
145
|
+
id: testFileId,
|
146
|
+
name: 'test'
|
147
|
+
}],
|
148
|
+
onRemove: mockOnRemove
|
149
|
+
});
|
150
|
+
userEvent.click(screen.getByTestId(fileUploadedDeleteIconTestId));
|
151
|
+
expect(mockOnRemove).toHaveBeenCalledTimes(1);
|
152
|
+
expect(mockOnRemove).toHaveBeenCalledWith(expect.anything(), testFileId);
|
153
|
+
});
|
154
|
+
test('file select will have custom text if from props if provided', function () {
|
155
|
+
var mockTitle = 'test-title';
|
156
|
+
getComponent({
|
157
|
+
defaultButtonText: mockTitle
|
158
|
+
});
|
159
|
+
expect(screen.getByText(mockTitle)).toBeInTheDocument();
|
160
|
+
});
|
161
|
+
test('should render error border if appropriate state passed', function () {
|
162
|
+
getComponent({
|
163
|
+
status: statuses.ERROR
|
164
|
+
});
|
165
|
+
expect(screen.getByTestId(fileInputFieldTestId)).toHaveClass('is-error');
|
166
|
+
});
|
167
|
+
test('file uploaded should render red error icon', function () {
|
168
|
+
getComponent({
|
169
|
+
defaultFileList: [_objectSpread(_objectSpread({}, testFileObject), {}, {
|
170
|
+
status: statuses.ERROR
|
171
|
+
})]
|
172
|
+
});
|
173
|
+
expect(screen.getByTestId(fileUploadedFileIconErrorTestId)).toBeInTheDocument();
|
174
|
+
});
|
175
|
+
test('should display loader if appropriate prop is passed', function () {
|
176
|
+
getComponent({
|
177
|
+
isLoading: true
|
178
|
+
});
|
179
|
+
expect(screen.getByTestId(loaderTestId)).toBeInTheDocument();
|
180
|
+
});
|
181
|
+
test('should display helper text if passed', function () {
|
182
|
+
var testHelperText = 'testHelperText';
|
183
|
+
getComponent({
|
184
|
+
helperText: testHelperText
|
185
|
+
});
|
186
|
+
expect(screen.getByText(testHelperText)).toBeInTheDocument();
|
187
|
+
});
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
2
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
|
+
import React, { useCallback, useRef } from 'react';
|
4
|
+
import InsertDriveFileIcon from 'mdi-react/InsertDriveFileIcon';
|
5
|
+
import ErrorIcon from 'mdi-react/ErrorIcon';
|
6
|
+
import DeleteIcon from 'mdi-react/DeleteIcon';
|
7
|
+
import PropTypes from 'prop-types';
|
8
|
+
import { useVisuallyHidden } from '@react-aria/visually-hidden';
|
9
|
+
import { Box, Button, IconButton, Icon, Text } from '../../index';
|
10
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
11
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
|
+
|
13
|
+
var FileItem = function FileItem(props) {
|
14
|
+
var downloadLink = props.downloadLink,
|
15
|
+
handleFileDelete = props.handleFileDelete,
|
16
|
+
id = props.id,
|
17
|
+
isDisabled = props.isDisabled,
|
18
|
+
name = props.name,
|
19
|
+
status = props.status,
|
20
|
+
textProps = props.textProps;
|
21
|
+
var handleDeleteButtonPress = useCallback(function (e) {
|
22
|
+
return handleFileDelete(e, id);
|
23
|
+
}, [id, handleFileDelete]);
|
24
|
+
|
25
|
+
var _useVisuallyHidden = useVisuallyHidden(),
|
26
|
+
visuallyHiddenProps = _useVisuallyHidden.visuallyHiddenProps;
|
27
|
+
|
28
|
+
var downloadRef = useRef();
|
29
|
+
var getFileIconProps = useCallback(function () {
|
30
|
+
switch (status) {
|
31
|
+
case statuses.ERROR:
|
32
|
+
return {
|
33
|
+
icon: ErrorIcon,
|
34
|
+
color: 'critical.dark',
|
35
|
+
'data-testid': 'file-uploaded__file-icon--is-error'
|
36
|
+
};
|
37
|
+
|
38
|
+
default:
|
39
|
+
return {
|
40
|
+
icon: InsertDriveFileIcon
|
41
|
+
};
|
42
|
+
}
|
43
|
+
}, [status]);
|
44
|
+
|
45
|
+
var handleDownloadPress = function handleDownloadPress() {
|
46
|
+
downloadRef.current.click();
|
47
|
+
};
|
48
|
+
|
49
|
+
return ___EmotionJSX(Box, {
|
50
|
+
isRow: true,
|
51
|
+
alignItems: "center",
|
52
|
+
mx: 15,
|
53
|
+
my: 5
|
54
|
+
}, ___EmotionJSX(Icon, _extends({
|
55
|
+
size: 15,
|
56
|
+
"data-testid": "file-uploaded__file-icon"
|
57
|
+
}, getFileIconProps(), {
|
58
|
+
isDisabled: isDisabled
|
59
|
+
})), ___EmotionJSX(Button, {
|
60
|
+
variant: "fileInputField",
|
61
|
+
mx: 5,
|
62
|
+
isDisabled: isDisabled,
|
63
|
+
"aria-label": name,
|
64
|
+
"data-testid": "file-uploaded__download-file-button",
|
65
|
+
onPress: handleDownloadPress
|
66
|
+
}, ___EmotionJSX(Text, _extends({
|
67
|
+
color: "active"
|
68
|
+
}, textProps), name)), ___EmotionJSX(IconButton, {
|
69
|
+
"aria-label": "Delete ".concat(name, " file icon"),
|
70
|
+
"data-testid": "file-uploaded__delete-file-button",
|
71
|
+
isDisabled: isDisabled,
|
72
|
+
onPress: handleDeleteButtonPress,
|
73
|
+
sx: {
|
74
|
+
alignSelf: 'auto'
|
75
|
+
}
|
76
|
+
}, ___EmotionJSX(Icon, {
|
77
|
+
icon: DeleteIcon,
|
78
|
+
size: 15,
|
79
|
+
isDisabled: isDisabled
|
80
|
+
})), ___EmotionJSX("a", _extends({
|
81
|
+
href: downloadLink
|
82
|
+
}, visuallyHiddenProps, {
|
83
|
+
download: true,
|
84
|
+
ref: downloadRef,
|
85
|
+
"aria-label": "download",
|
86
|
+
"data-testid": "file-uploaded__download-link",
|
87
|
+
tabIndex: -1
|
88
|
+
})));
|
89
|
+
};
|
90
|
+
|
91
|
+
export default FileItem;
|
92
|
+
FileItem.propTypes = {
|
93
|
+
downloadLink: PropTypes.string,
|
94
|
+
handleFileDelete: PropTypes.func,
|
95
|
+
id: PropTypes.string,
|
96
|
+
isDisabled: PropTypes.bool,
|
97
|
+
name: PropTypes.string,
|
98
|
+
status: PropTypes.oneOf(_Object$values(statuses)),
|
99
|
+
textProps: PropTypes.shape({})
|
100
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import { Button, Text } from '../../index';
|
5
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
6
|
+
|
7
|
+
var FileSelect = function FileSelect(props) {
|
8
|
+
var buttonText = props.buttonText,
|
9
|
+
handleFileSelect = props.handleFileSelect,
|
10
|
+
isDisabled = props.isDisabled,
|
11
|
+
textProps = props.textProps;
|
12
|
+
return ___EmotionJSX(Button, {
|
13
|
+
"aria-label": buttonText,
|
14
|
+
"data-testid": "file-input-field__file-select",
|
15
|
+
isDisabled: isDisabled,
|
16
|
+
mx: 15,
|
17
|
+
my: 5,
|
18
|
+
onPress: handleFileSelect,
|
19
|
+
variant: "fileInputField"
|
20
|
+
}, ___EmotionJSX(Text, _extends({
|
21
|
+
color: "active"
|
22
|
+
}, textProps), buttonText));
|
23
|
+
};
|
24
|
+
|
25
|
+
export default FileSelect;
|
26
|
+
FileSelect.propTypes = {
|
27
|
+
buttonText: PropTypes.string,
|
28
|
+
handleFileSelect: PropTypes.func,
|
29
|
+
isDisabled: PropTypes.bool,
|
30
|
+
textProps: PropTypes.shape({})
|
31
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './FileInputField';
|
@@ -16,6 +16,11 @@ var ListViewItem = function ListViewItem(props) {
|
|
16
16
|
var _context;
|
17
17
|
|
18
18
|
var item = props.item,
|
19
|
+
_props$item$props = props.item.props,
|
20
|
+
listItemProps = _props$item$props.listItemProps,
|
21
|
+
rowProps = _props$item$props.rowProps,
|
22
|
+
_props$item$props$has = _props$item$props.hasSeparator,
|
23
|
+
hasSeparator = _props$item$props$has === void 0 ? true : _props$item$props$has,
|
19
24
|
className = props.className;
|
20
25
|
var dataId = item.props['data-id'];
|
21
26
|
|
@@ -45,9 +50,9 @@ var ListViewItem = function ListViewItem(props) {
|
|
45
50
|
node: item,
|
46
51
|
isVirtualized: true
|
47
52
|
}, state, rowRef),
|
48
|
-
|
53
|
+
raRowProps = _useGridRow.rowProps;
|
49
54
|
|
50
|
-
var isSelected =
|
55
|
+
var isSelected = raRowProps['aria-selected'];
|
51
56
|
|
52
57
|
var _useGridCell = useGridCell({
|
53
58
|
node: cellNode,
|
@@ -68,9 +73,9 @@ var ListViewItem = function ListViewItem(props) {
|
|
68
73
|
as: "li",
|
69
74
|
isDisabled: isDisabled,
|
70
75
|
isRow: true
|
71
|
-
},
|
76
|
+
}, raRowProps, {
|
72
77
|
ref: rowRef
|
73
|
-
}), ___EmotionJSX(Box, _extends({
|
78
|
+
}, rowProps), ___EmotionJSX(Box, _extends({
|
74
79
|
as: "div",
|
75
80
|
ref: cellRef
|
76
81
|
}, mergedProps, {
|
@@ -81,7 +86,7 @@ var ListViewItem = function ListViewItem(props) {
|
|
81
86
|
isSelected: isSelected,
|
82
87
|
className: classNames,
|
83
88
|
"data-id": dataId
|
84
|
-
}), item.rendered)), ___EmotionJSX(Separator, {
|
89
|
+
}, listItemProps), item.rendered)), hasSeparator && ___EmotionJSX(Separator, {
|
85
90
|
m: "0px"
|
86
91
|
}));
|
87
92
|
};
|
@@ -92,7 +97,10 @@ ListViewItem.propTypes = {
|
|
92
97
|
rendered: PropTypes.node,
|
93
98
|
childNodes: PropTypes.arrayOf(PropTypes.shape({})),
|
94
99
|
props: PropTypes.shape({
|
95
|
-
'data-id': PropTypes.string
|
100
|
+
'data-id': PropTypes.string,
|
101
|
+
listItemProps: PropTypes.shape({}),
|
102
|
+
rowProps: PropTypes.shape({}),
|
103
|
+
hasSeparator: PropTypes.bool
|
96
104
|
})
|
97
105
|
})
|
98
106
|
};
|
@@ -71,12 +71,14 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
71
71
|
var ControlArrows = ___EmotionJSX(Box, {
|
72
72
|
variant: "numberField.arrows"
|
73
73
|
}, ___EmotionJSX(IconButton, _extends({}, incrementButtonProps, {
|
74
|
-
ref: decRef
|
74
|
+
ref: decRef,
|
75
|
+
tabIndex: "-1"
|
75
76
|
}), ___EmotionJSX(Icon, {
|
76
77
|
icon: ArrowDropUpIcon,
|
77
78
|
size: 12
|
78
79
|
})), ___EmotionJSX(IconButton, _extends({}, decrementButtonProps, {
|
79
|
-
ref: incrRef
|
80
|
+
ref: incrRef,
|
81
|
+
tabIndex: "-1"
|
80
82
|
}), ___EmotionJSX(Icon, {
|
81
83
|
icon: ArrowDropDownIcon,
|
82
84
|
size: 12
|
@@ -119,4 +119,13 @@ test('should show hintText text if prop is passed', function () {
|
|
119
119
|
fireEvent.mouseMove(helpHintButton);
|
120
120
|
fireEvent.mouseEnter(helpHintButton);
|
121
121
|
expect(screen.getByText(hintText)).toBeInTheDocument();
|
122
|
+
});
|
123
|
+
test('increment and decrement buttons shouldn\'t be able to be focused via keyboard', function () {
|
124
|
+
getComponent();
|
125
|
+
userEvent.tab();
|
126
|
+
expect(screen.getByLabelText(testLabel)).toHaveFocus();
|
127
|
+
userEvent.tab();
|
128
|
+
expect(screen.getByLabelText('arrow-up')).not.toHaveFocus();
|
129
|
+
userEvent.tab();
|
130
|
+
expect(screen.getByLabelText('arrow-down')).not.toHaveFocus();
|
122
131
|
});
|
@@ -21,6 +21,7 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
21
21
|
tabsDisabled = props.isDisabled,
|
22
22
|
orientation = props.orientation,
|
23
23
|
mode = props.mode,
|
24
|
+
slots = props.slots,
|
24
25
|
tooltipTriggerProps = props.tooltipTriggerProps;
|
25
26
|
var key = item.key,
|
26
27
|
rendered = item.rendered,
|
@@ -34,8 +35,8 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
34
35
|
content = itemProps.content,
|
35
36
|
otherItemProps = _objectWithoutProperties(itemProps, ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content"]);
|
36
37
|
|
37
|
-
var isDisabled = tabsDisabled || tabDisabled;
|
38
38
|
var state = useContext(TabsContext);
|
39
|
+
var isDisabled = tabsDisabled || tabDisabled || state.disabledKeys.has(key);
|
39
40
|
var isSelected = state.selectedKey === key;
|
40
41
|
|
41
42
|
var _useFocusRing = useFocusRing(),
|
@@ -70,14 +71,16 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
71
|
}, state, tabRef),
|
71
72
|
tabProps = _useTab.tabProps;
|
72
73
|
|
73
|
-
var tab = ___EmotionJSX(Box,
|
74
|
+
var tab = ___EmotionJSX(Box, {
|
75
|
+
isRow: true
|
76
|
+
}, slots === null || slots === void 0 ? void 0 : slots.beforeTab, ___EmotionJSX(Box, _extends({
|
74
77
|
className: classNames,
|
75
78
|
variant: "tab"
|
76
79
|
}, mergeProps(focusProps, hoverProps, tabProps), otherItemProps, {
|
77
80
|
ref: tabRef
|
78
81
|
}), icon, ___EmotionJSX(Text, _extends({
|
79
82
|
variant: "tabLabel"
|
80
|
-
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps));
|
83
|
+
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps)), slots === null || slots === void 0 ? void 0 : slots.afterTab);
|
81
84
|
|
82
85
|
if (mode === 'tooltip') {
|
83
86
|
return ___EmotionJSX(React.Fragment, null, separator, ___EmotionJSX(TooltipTrigger, _extends({}, tooltipTriggerProps, {
|
@@ -100,7 +103,11 @@ CollectionTab.propTypes = {
|
|
100
103
|
}),
|
101
104
|
mode: PropTypes.oneOf(['default', 'tooltip']),
|
102
105
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
103
|
-
tooltipTriggerProps: PropTypes.shape({})
|
106
|
+
tooltipTriggerProps: PropTypes.shape({}),
|
107
|
+
slots: PropTypes.shape({
|
108
|
+
beforeTab: PropTypes.node,
|
109
|
+
afterTab: PropTypes.node
|
110
|
+
})
|
104
111
|
};
|
105
112
|
|
106
113
|
var TabLine = function TabLine(props) {
|
@@ -71,12 +71,15 @@ var Tabs = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
71
71
|
}, tabListProps, raTabListProps, {
|
72
72
|
ref: tabListRef
|
73
73
|
}), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
|
74
|
+
var _item$props;
|
75
|
+
|
74
76
|
return ___EmotionJSX(CollectionTab, {
|
75
77
|
key: item.key,
|
76
78
|
item: item,
|
77
79
|
isDisabled: isDisabled,
|
78
80
|
orientation: orientation,
|
79
|
-
mode: mode
|
81
|
+
mode: mode,
|
82
|
+
slots: item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.slots
|
80
83
|
});
|
81
84
|
})), ___EmotionJSX(Box, _extends({
|
82
85
|
variant: "tabPanel",
|
@@ -87,6 +90,9 @@ Tabs.propTypes = {
|
|
87
90
|
/** The default tab key to be selected. (uncontrolled) */
|
88
91
|
defaultSelectedKey: PropTypes.string,
|
89
92
|
|
93
|
+
/** Array of keys to disable within the tab list. */
|
94
|
+
disabledKeys: PropTypes.arrayOf(PropTypes.string),
|
95
|
+
|
90
96
|
/** The tab key that is currently selected. (controlled) */
|
91
97
|
selectedKey: PropTypes.string,
|
92
98
|
|
@@ -2,10 +2,12 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import Earth from 'mdi-react/GlobeModelIcon';
|
5
|
+
import LockIcon from 'mdi-react/LockIcon';
|
5
6
|
import Tabs from './Tabs';
|
6
7
|
import Tab from '../Tab';
|
7
8
|
import Icon from '../Icon';
|
8
9
|
import Text from '../Text';
|
10
|
+
import { Chip } from '../../index';
|
9
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
12
|
export default {
|
11
13
|
title: 'Tabs',
|
@@ -126,13 +128,12 @@ export var Centered = function Centered() {
|
|
126
128
|
};
|
127
129
|
export var DisabledSingleTab = function DisabledSingleTab() {
|
128
130
|
return ___EmotionJSX(Tabs, {
|
129
|
-
|
130
|
-
|
131
|
+
items: tabs,
|
132
|
+
disabledKeys: ['Tab 2']
|
131
133
|
}, function (item) {
|
132
134
|
return ___EmotionJSX(Tab, {
|
133
135
|
key: item.name,
|
134
|
-
title: item.name
|
135
|
-
isDisabled: item.name === 'Tab 1'
|
136
|
+
title: item.name
|
136
137
|
}, item.children);
|
137
138
|
});
|
138
139
|
};
|
@@ -184,4 +185,55 @@ export var TabPanelProps = function TabPanelProps() {
|
|
184
185
|
title: item.name
|
185
186
|
}, item.children);
|
186
187
|
});
|
188
|
+
};
|
189
|
+
export var ContentSlots = function ContentSlots() {
|
190
|
+
var beforeTabNode = ___EmotionJSX(Icon, {
|
191
|
+
icon: LockIcon,
|
192
|
+
sx: {
|
193
|
+
marginTop: 10,
|
194
|
+
marginRight: 5
|
195
|
+
}
|
196
|
+
});
|
197
|
+
|
198
|
+
var nodeSx = {
|
199
|
+
alignItems: 'center',
|
200
|
+
backgroundColor: 'neutral.95',
|
201
|
+
borderRadius: '50%',
|
202
|
+
color: 'neutral.30',
|
203
|
+
fontSize: 'sm',
|
204
|
+
height: 20,
|
205
|
+
justifyContent: 'center',
|
206
|
+
marginLeft: 6,
|
207
|
+
marginTop: 10,
|
208
|
+
minWidth: 20
|
209
|
+
};
|
210
|
+
|
211
|
+
var afterTabNode = ___EmotionJSX(Chip, {
|
212
|
+
sx: nodeSx
|
213
|
+
}, "14");
|
214
|
+
|
215
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Tabs, {
|
216
|
+
items: tabs,
|
217
|
+
mb: 50
|
218
|
+
}, ___EmotionJSX(Tab, {
|
219
|
+
key: "tab1",
|
220
|
+
title: "Tab 1",
|
221
|
+
slots: {
|
222
|
+
beforeTab: beforeTabNode
|
223
|
+
}
|
224
|
+
}, ___EmotionJSX(Text, null, "This is content for Tab 1")), ___EmotionJSX(Tab, {
|
225
|
+
key: "tab2",
|
226
|
+
title: "Tab 2"
|
227
|
+
}, ___EmotionJSX(Text, null, "This is content for Tab 2"))), ___EmotionJSX(Tabs, {
|
228
|
+
items: tabs
|
229
|
+
}, ___EmotionJSX(Tab, {
|
230
|
+
key: "tab1",
|
231
|
+
title: "Tab 1"
|
232
|
+
}, ___EmotionJSX(Text, null, "Compose Filter")), ___EmotionJSX(Tab, {
|
233
|
+
key: "tab2",
|
234
|
+
title: "Tab 2",
|
235
|
+
slots: {
|
236
|
+
afterTab: afterTabNode
|
237
|
+
}
|
238
|
+
}, ___EmotionJSX(Text, null, "Users Matched"))));
|
187
239
|
};
|