@pingux/astro 1.0.0-alpha.6 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +186 -0
- package/README.md +5 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
- package/lib/cjs/components/AccordionItem/AccordionItem.js +3 -1
- package/lib/cjs/components/Button/Button.js +5 -24
- package/lib/cjs/components/Button/Button.stories.js +5 -11
- package/lib/cjs/components/Button/Button.test.js +0 -24
- package/lib/cjs/components/Chip/Chip.js +26 -10
- package/lib/cjs/components/Chip/Chip.stories.js +44 -5
- package/lib/cjs/components/Chip/Chip.test.js +9 -0
- package/lib/cjs/components/{Panel/index.js → Chip/ChipContext.js} +8 -7
- package/lib/cjs/components/CopyText/CopyText.js +3 -73
- package/lib/cjs/components/IconButton/IconButton.js +17 -7
- package/lib/cjs/components/IconButton/IconButton.test.js +0 -1
- package/lib/cjs/components/ListItem/ListItem.stories.js +0 -2
- package/lib/cjs/components/ListView/ListView.js +4 -3
- package/lib/cjs/components/ListViewItem/ListViewItem.js +3 -6
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +1 -1
- package/lib/cjs/components/Stepper/Stepper.js +1 -0
- package/lib/cjs/components/Tab/Tab.js +15 -6
- 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/components/TextAreaField/TextAreaField.test.js +10 -0
- package/lib/cjs/components/TooltipTrigger/TooltipTrigger.stories.js +45 -2
- package/lib/cjs/{components/DropdownField → hooks/useCopyToClipboard}/index.js +2 -2
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +83 -0
- package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.test.js +79 -0
- package/lib/cjs/index.js +48 -136
- package/lib/cjs/layouts/ListLayout.stories.js +2 -1
- package/lib/cjs/layouts/SchemaFormLayout.stories.js +2 -21
- package/lib/cjs/recipes/ArrayField.stories.js +3 -3
- package/lib/cjs/recipes/CopyToClipboard.stories.js +45 -0
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +146 -0
- package/lib/cjs/styles/forms/input.js +4 -0
- package/lib/cjs/styles/theme.js +0 -3
- package/lib/cjs/styles/variants/accordion.js +7 -9
- package/lib/cjs/styles/variants/boxes.js +22 -19
- package/lib/cjs/styles/variants/buttons.js +38 -29
- package/lib/cjs/styles/variants/tabs.js +1 -0
- package/lib/cjs/styles/variants/variants.js +0 -3
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
- package/lib/components/AccordionItem/AccordionItem.js +3 -1
- package/lib/components/Button/Button.js +7 -24
- package/lib/components/Button/Button.stories.js +5 -10
- package/lib/components/Button/Button.test.js +0 -20
- package/lib/components/Chip/Chip.js +25 -10
- package/lib/components/Chip/Chip.stories.js +41 -5
- package/lib/components/Chip/Chip.test.js +9 -0
- package/lib/components/Chip/ChipContext.js +3 -0
- package/lib/components/CopyText/CopyText.js +2 -71
- package/lib/components/IconButton/IconButton.js +17 -9
- package/lib/components/IconButton/IconButton.test.js +0 -1
- package/lib/components/ListItem/ListItem.stories.js +0 -2
- package/lib/components/ListView/ListView.js +4 -3
- package/lib/components/ListViewItem/ListViewItem.js +3 -5
- package/lib/components/MultivaluesField/MultivaluesField.js +1 -1
- package/lib/components/Stepper/Stepper.js +1 -0
- package/lib/components/Tab/Tab.js +15 -6
- 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/components/TextAreaField/TextAreaField.test.js +8 -0
- package/lib/components/TooltipTrigger/TooltipTrigger.stories.js +33 -1
- 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 +0 -8
- package/lib/layouts/ListLayout.stories.js +2 -1
- package/lib/layouts/SchemaFormLayout.stories.js +2 -19
- package/lib/recipes/ArrayField.stories.js +3 -3
- package/lib/recipes/CopyToClipboard.stories.js +25 -0
- package/lib/recipes/RadioButtonsWithLinks.stories.js +120 -0
- package/lib/styles/forms/input.js +4 -0
- package/lib/styles/theme.js +0 -3
- package/lib/styles/variants/accordion.js +7 -9
- package/lib/styles/variants/boxes.js +21 -19
- package/lib/styles/variants/buttons.js +37 -29
- package/lib/styles/variants/tabs.js +1 -0
- package/lib/styles/variants/variants.js +0 -2
- package/package.json +2 -2
- package/lib/cjs/components/Dropdown/Dropdown.js +0 -112
- package/lib/cjs/components/Dropdown/Dropdown.test.js +0 -80
- package/lib/cjs/components/Dropdown/index.js +0 -18
- package/lib/cjs/components/DropdownField/DropdownField.js +0 -187
- package/lib/cjs/components/DropdownField/DropdownField.stories.js +0 -278
- package/lib/cjs/components/DropdownField/DropdownField.test.js +0 -80
- package/lib/cjs/components/Panel/Panel.js +0 -101
- package/lib/cjs/components/Panel/Panel.stories.js +0 -57
- package/lib/cjs/components/Panel/Panel.test.js +0 -72
- package/lib/cjs/components/Popover/Popover.js +0 -87
- package/lib/cjs/components/Popover/Popover.stories.js +0 -80
- package/lib/cjs/components/Popover/Popover.test.js +0 -91
- package/lib/cjs/components/Popover/index.js +0 -18
- package/lib/cjs/recipes/InputBoxWithLinkedChip.stories.js +0 -67
- package/lib/cjs/styles/variants/popover.js +0 -86
- package/lib/components/Dropdown/Dropdown.js +0 -90
- package/lib/components/Dropdown/Dropdown.test.js +0 -62
- package/lib/components/Dropdown/index.js +0 -1
- package/lib/components/DropdownField/DropdownField.js +0 -155
- package/lib/components/DropdownField/DropdownField.stories.js +0 -222
- package/lib/components/DropdownField/DropdownField.test.js +0 -60
- package/lib/components/DropdownField/index.js +0 -1
- package/lib/components/Panel/Panel.js +0 -71
- package/lib/components/Panel/Panel.stories.js +0 -35
- package/lib/components/Panel/Panel.test.js +0 -52
- package/lib/components/Panel/index.js +0 -1
- package/lib/components/Popover/Popover.js +0 -65
- package/lib/components/Popover/Popover.stories.js +0 -52
- package/lib/components/Popover/Popover.test.js +0 -75
- package/lib/components/Popover/index.js +0 -2
- package/lib/recipes/InputBoxWithLinkedChip.stories.js +0 -43
- package/lib/styles/variants/popover.js +0 -76
@@ -1,11 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
3
|
import userEvent from '@testing-library/user-event';
|
4
|
-
import AddCircleIcon from 'mdi-react/AddCircleIcon';
|
5
4
|
import axeTest from '../../utils/testUtils/testAxe';
|
6
5
|
import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
7
6
|
import Button from '.';
|
8
|
-
import Icon from '../Icon';
|
9
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
8
|
var testId = 'test-button';
|
11
9
|
var defaultProps = {
|
@@ -15,15 +13,6 @@ var defaultProps = {
|
|
15
13
|
var getComponent = function getComponent() {
|
16
14
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
17
15
|
return render(___EmotionJSX(Button, _extends({}, defaultProps, props)));
|
18
|
-
};
|
19
|
-
|
20
|
-
var getIconButton = function getIconButton() {
|
21
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
22
|
-
return render(___EmotionJSX(Button, _extends({}, defaultProps, props, {
|
23
|
-
variant: "icon"
|
24
|
-
}), ___EmotionJSX(Icon, {
|
25
|
-
icon: AddCircleIcon
|
26
|
-
})));
|
27
16
|
}; // Need to be added to each test file to test accessibility using axe.
|
28
17
|
|
29
18
|
|
@@ -99,13 +88,4 @@ test('button renders children when not loading', function () {
|
|
99
88
|
expect(childWrapper).toBeInTheDocument();
|
100
89
|
expect(childWrapper).toBeVisible();
|
101
90
|
expect(screen.queryByRole('progressbar')).not.toBeInTheDocument();
|
102
|
-
});
|
103
|
-
test('passing in an icon makes the button parent a div', function () {
|
104
|
-
getIconButton({
|
105
|
-
mode: 'icon'
|
106
|
-
});
|
107
|
-
var button = screen.getByRole('button');
|
108
|
-
expect(button).toBeInTheDocument();
|
109
|
-
expect(button).toBeVisible();
|
110
|
-
expect(button).toBeInstanceOf(HTMLDivElement);
|
111
91
|
});
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
|
+
import { ChipContext } from './ChipContext';
|
4
5
|
import Box from '../Box/Box';
|
5
6
|
import Text from '../Text/Text';
|
6
7
|
import * as colors from '../../styles/colors';
|
@@ -12,21 +13,31 @@ import * as colors from '../../styles/colors';
|
|
12
13
|
|
13
14
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
15
|
var Chip = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
15
|
-
var
|
16
|
+
var bg = props.bg,
|
17
|
+
children = props.children,
|
16
18
|
textColor = props.textColor,
|
17
19
|
textProps = props.textProps,
|
18
|
-
label = props.label
|
19
|
-
|
20
|
+
label = props.label,
|
21
|
+
isUppercase = props.isUppercase;
|
22
|
+
return ___EmotionJSX(ChipContext.Provider, {
|
23
|
+
value: {
|
24
|
+
bg: bg
|
25
|
+
}
|
26
|
+
}, ___EmotionJSX(Box, _extends({
|
20
27
|
isRow: true,
|
21
28
|
variant: "boxes.chip",
|
29
|
+
sx: isUppercase && {
|
30
|
+
paddingBottom: '3px'
|
31
|
+
},
|
22
32
|
ref: ref
|
23
33
|
}, props), ___EmotionJSX(Text, _extends({
|
24
34
|
variant: "label",
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
35
|
+
color: textColor,
|
36
|
+
sx: isUppercase && {
|
37
|
+
textTransform: 'uppercase',
|
38
|
+
fontSize: '11px'
|
39
|
+
}
|
40
|
+
}, textProps), label), children));
|
30
41
|
});
|
31
42
|
Chip.propTypes = {
|
32
43
|
/** The text color of the chip. */
|
@@ -39,10 +50,14 @@ Chip.propTypes = {
|
|
39
50
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
40
51
|
|
41
52
|
/** Props object that is spread directly into the textfield. */
|
42
|
-
textProps: PropTypes.shape({})
|
53
|
+
textProps: PropTypes.shape({}),
|
54
|
+
|
55
|
+
/** When true, display chip label as uppercase. */
|
56
|
+
isUppercase: PropTypes.bool
|
43
57
|
};
|
44
58
|
Chip.defaultProps = {
|
45
59
|
textColor: 'white',
|
46
|
-
bg: colors.neutral[10]
|
60
|
+
bg: colors.neutral[10],
|
61
|
+
isUppercase: false
|
47
62
|
};
|
48
63
|
export default Chip;
|
@@ -3,8 +3,11 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
3
3
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
4
4
|
import React from 'react';
|
5
5
|
import Clear from 'mdi-react/CloseIcon';
|
6
|
-
import
|
7
|
-
import
|
6
|
+
import ContentCopy from 'mdi-react/ContentCopyIcon';
|
7
|
+
import Earth from 'mdi-react/EarthIcon';
|
8
|
+
import Chip from '../Chip';
|
9
|
+
import Icon from '../Icon';
|
10
|
+
import IconButton from '../IconButton';
|
8
11
|
import { flatColorList } from '../../styles/colors.js';
|
9
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
13
|
export default {
|
@@ -40,6 +43,12 @@ export default {
|
|
40
43
|
control: {
|
41
44
|
type: 'text'
|
42
45
|
}
|
46
|
+
},
|
47
|
+
isUppercase: {
|
48
|
+
defaultValue: false,
|
49
|
+
control: {
|
50
|
+
type: 'boolean'
|
51
|
+
}
|
43
52
|
}
|
44
53
|
}
|
45
54
|
};
|
@@ -59,13 +68,40 @@ export var ChipWithCustomColors = function ChipWithCustomColors() {
|
|
59
68
|
});
|
60
69
|
};
|
61
70
|
export var ChipWithIcon = function ChipWithIcon() {
|
62
|
-
return ___EmotionJSX(Chip, {
|
63
|
-
label: "Chip with Icon",
|
71
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Chip, {
|
72
|
+
label: "Chip with Icon Button",
|
64
73
|
bg: "navy"
|
74
|
+
}, ___EmotionJSX(IconButton, {
|
75
|
+
"aria-label": "Clear Chip with Icon Button",
|
76
|
+
variant: "inverted"
|
65
77
|
}, ___EmotionJSX(Icon, {
|
66
78
|
icon: Clear,
|
67
79
|
ml: "xs",
|
80
|
+
size: "14px"
|
81
|
+
}))), ___EmotionJSX("div", {
|
82
|
+
style: {
|
83
|
+
padding: '5px'
|
84
|
+
}
|
85
|
+
}), ___EmotionJSX(Chip, {
|
86
|
+
label: "Chip with Icon Button"
|
87
|
+
}, ___EmotionJSX(IconButton, {
|
88
|
+
"aria-label": "Clear Chip with Icon Button",
|
89
|
+
variant: "inverted"
|
90
|
+
}, ___EmotionJSX(Icon, {
|
91
|
+
icon: Earth,
|
92
|
+
ml: "xs",
|
93
|
+
size: "14px"
|
94
|
+
}))), ___EmotionJSX("div", {
|
95
|
+
style: {
|
96
|
+
padding: '5px'
|
97
|
+
}
|
98
|
+
}), ___EmotionJSX(Chip, {
|
99
|
+
label: "Chip with Icon",
|
100
|
+
bg: "green"
|
101
|
+
}, ___EmotionJSX(Icon, {
|
102
|
+
icon: ContentCopy,
|
103
|
+
ml: "xs",
|
68
104
|
size: "14px",
|
69
105
|
color: "white"
|
70
|
-
}));
|
106
|
+
})));
|
71
107
|
};
|
@@ -31,4 +31,13 @@ test('renders children within Chip component', function () {
|
|
31
31
|
});
|
32
32
|
var mockedChildren = screen.getByRole('button');
|
33
33
|
expect(mockedChildren).toBeInTheDocument();
|
34
|
+
});
|
35
|
+
test('renders Chip component with uppercase', function () {
|
36
|
+
var label = 'uppercase';
|
37
|
+
var isUppercase = true;
|
38
|
+
getComponent({
|
39
|
+
label: label,
|
40
|
+
isUppercase: isUppercase
|
41
|
+
});
|
42
|
+
expect(screen.queryByText('uppercase')).toHaveStyleRule('text-transform', 'uppercase');
|
34
43
|
});
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
3
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
4
2
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
5
3
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
6
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
@@ -11,6 +9,7 @@ import { Pressable, useHover } from '@react-aria/interactions';
|
|
11
9
|
import { mergeProps } from '@react-aria/utils';
|
12
10
|
import { Box, Button, Tooltip, TooltipTrigger } from '../../index';
|
13
11
|
import CopyButton from './CopyButton';
|
12
|
+
import useCopyToClipboard from '../../hooks/useCopyToClipboard';
|
14
13
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
14
|
|
16
15
|
var TooltipWrapper = function TooltipWrapper(_ref) {
|
@@ -75,75 +74,7 @@ var CopyText = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
75
74
|
|
76
75
|
return undefined;
|
77
76
|
}, [isCopied]);
|
78
|
-
|
79
|
-
var copyToClipboard = /*#__PURE__*/function () {
|
80
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
81
|
-
var textArea, isSuccessful;
|
82
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
83
|
-
while (1) {
|
84
|
-
switch (_context.prev = _context.next) {
|
85
|
-
case 0:
|
86
|
-
_context.prev = 0;
|
87
|
-
|
88
|
-
if (!navigator.clipboard) {
|
89
|
-
_context.next = 7;
|
90
|
-
break;
|
91
|
-
}
|
92
|
-
|
93
|
-
_context.next = 4;
|
94
|
-
return navigator.clipboard.writeText(value);
|
95
|
-
|
96
|
-
case 4:
|
97
|
-
setIsCopied(true);
|
98
|
-
_context.next = 20;
|
99
|
-
break;
|
100
|
-
|
101
|
-
case 7:
|
102
|
-
// Workaround for copying in insecure origin
|
103
|
-
textArea = document.createElement('textarea');
|
104
|
-
textArea.value = value;
|
105
|
-
textArea.style.position = 'fixed';
|
106
|
-
document.body.appendChild(textArea);
|
107
|
-
textArea.focus();
|
108
|
-
textArea.select();
|
109
|
-
isSuccessful = document.execCommand('copy');
|
110
|
-
textArea.remove();
|
111
|
-
|
112
|
-
if (!isSuccessful) {
|
113
|
-
_context.next = 19;
|
114
|
-
break;
|
115
|
-
}
|
116
|
-
|
117
|
-
setIsCopied(isSuccessful);
|
118
|
-
_context.next = 20;
|
119
|
-
break;
|
120
|
-
|
121
|
-
case 19:
|
122
|
-
throw new Error('Unable to copy message');
|
123
|
-
|
124
|
-
case 20:
|
125
|
-
_context.next = 25;
|
126
|
-
break;
|
127
|
-
|
128
|
-
case 22:
|
129
|
-
_context.prev = 22;
|
130
|
-
_context.t0 = _context["catch"](0);
|
131
|
-
// eslint-disable-next-line no-console
|
132
|
-
console.error('Failed to copy: ', _context.t0);
|
133
|
-
|
134
|
-
case 25:
|
135
|
-
case "end":
|
136
|
-
return _context.stop();
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}, _callee, null, [[0, 22]]);
|
140
|
-
}));
|
141
|
-
|
142
|
-
return function copyToClipboard() {
|
143
|
-
return _ref2.apply(this, arguments);
|
144
|
-
};
|
145
|
-
}();
|
146
|
-
|
77
|
+
var copyToClipboard = useCopyToClipboard(value, setIsCopied);
|
147
78
|
var content = mode === 'link' ? children : ___EmotionJSX(Button, _extends({
|
148
79
|
variant: "quiet",
|
149
80
|
onPress: copyToClipboard,
|
@@ -14,13 +14,15 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
14
14
|
|
15
15
|
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; }
|
16
16
|
|
17
|
-
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
17
|
+
import React, { forwardRef, useRef, useImperativeHandle, useContext } from 'react';
|
18
18
|
import PropTypes from 'prop-types';
|
19
19
|
import { IconButton as ThemeUIIconButton } from 'theme-ui';
|
20
|
+
import { useButton } from '@react-aria/button';
|
20
21
|
import { useFocusRing } from '@react-aria/focus';
|
21
|
-
import { Pressable, useHover
|
22
|
+
import { Pressable, useHover } from '@react-aria/interactions';
|
22
23
|
import { mergeProps } from '@react-aria/utils';
|
23
24
|
import { useAriaLabelWarning, useStatusClasses } from '../../hooks';
|
25
|
+
import { ChipContext } from '../Chip/ChipContext';
|
24
26
|
import TooltipTrigger, { Tooltip } from '../TooltipTrigger';
|
25
27
|
/**
|
26
28
|
* Convenience wrapper for a Button + Icon. This component applies specific styles necessary for
|
@@ -51,11 +53,12 @@ var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
51
53
|
return buttonRef.current;
|
52
54
|
});
|
53
55
|
|
54
|
-
var
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
var _useButton = useButton(_objectSpread({}, props), buttonRef),
|
57
|
+
buttonProps = _useButton.buttonProps,
|
58
|
+
isPressed = _useButton.isPressed;
|
59
|
+
|
60
|
+
var _useContext = useContext(ChipContext),
|
61
|
+
chipBg = _useContext.bg;
|
59
62
|
|
60
63
|
var _useHover = useHover(props),
|
61
64
|
hoverProps = _useHover.hoverProps,
|
@@ -80,8 +83,13 @@ var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
80
83
|
tabIndex: 0,
|
81
84
|
ref: buttonRef,
|
82
85
|
className: classNames,
|
83
|
-
"aria-label": ariaLabel || 'Icon Button'
|
84
|
-
|
86
|
+
"aria-label": ariaLabel || 'Icon Button',
|
87
|
+
sx: chipBg && isHovered && {
|
88
|
+
'path': {
|
89
|
+
fill: chipBg
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}, mergeProps(hoverProps, focusProps, buttonProps, others)), children);
|
85
93
|
|
86
94
|
if (title) {
|
87
95
|
return ___EmotionJSX(TooltipTrigger, {
|
@@ -32,7 +32,6 @@ test('default icon button', function () {
|
|
32
32
|
var button = screen.getByRole('button');
|
33
33
|
expect(button).toHaveAttribute('data-testid', testId);
|
34
34
|
expect(button).toBeInstanceOf(HTMLButtonElement);
|
35
|
-
expect(button).toHaveAttribute('tabindex', '0');
|
36
35
|
expect(button).toBeInTheDocument();
|
37
36
|
});
|
38
37
|
test('icon button hover', function () {
|
@@ -32,7 +32,6 @@ export var Default = function Default(args) {
|
|
32
32
|
isRow: true,
|
33
33
|
alignSelf: "center"
|
34
34
|
}, ___EmotionJSX(IconButton, {
|
35
|
-
variant: "icon",
|
36
35
|
size: 26
|
37
36
|
}, ___EmotionJSX(Icon, {
|
38
37
|
icon: MoreVertIcon,
|
@@ -64,7 +63,6 @@ export var WithSubtitle = function WithSubtitle(args) {
|
|
64
63
|
isRow: true,
|
65
64
|
alignSelf: "center"
|
66
65
|
}, ___EmotionJSX(IconButton, {
|
67
|
-
variant: "icon",
|
68
66
|
size: 26
|
69
67
|
}, ___EmotionJSX(Icon, {
|
70
68
|
icon: MoreVertIcon,
|
@@ -37,18 +37,19 @@ export var collectionTypes = {
|
|
37
37
|
PLACEHOLDER: 'placeholder'
|
38
38
|
};
|
39
39
|
export function useListLayout(state) {
|
40
|
+
var ROW_HEIGHT = 81;
|
40
41
|
var collator = useCollator({
|
41
42
|
usage: 'search',
|
42
43
|
sensitivity: 'base'
|
43
44
|
});
|
44
45
|
var layout = useMemo(function () {
|
45
46
|
return new ListLayout({
|
46
|
-
estimatedRowHeight:
|
47
|
+
estimatedRowHeight: ROW_HEIGHT,
|
47
48
|
estimatedHeadingHeight: 26,
|
48
49
|
paddingRight: 4,
|
49
50
|
paddingLeft: 4,
|
50
|
-
loaderHeight:
|
51
|
-
placeholderHeight:
|
51
|
+
loaderHeight: ROW_HEIGHT,
|
52
|
+
placeholderHeight: ROW_HEIGHT,
|
52
53
|
collator: collator
|
53
54
|
});
|
54
55
|
}, [collator]);
|
@@ -8,7 +8,6 @@ import { useGridCell, useGridRow } from '@react-aria/grid';
|
|
8
8
|
import { useHover } from '@react-aria/interactions';
|
9
9
|
import { ListViewContext } from '../ListView/ListViewContext';
|
10
10
|
import Box from '../Box';
|
11
|
-
import Separator from '../Separator';
|
12
11
|
import { useStatusClasses } from '../../hooks';
|
13
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
13
|
|
@@ -65,7 +64,8 @@ var ListViewItem = function ListViewItem(props) {
|
|
65
64
|
var _useStatusClasses = useStatusClasses(className, {
|
66
65
|
isHovered: isHovered,
|
67
66
|
isSelected: isSelected,
|
68
|
-
isFocused: isDisabled ? false : isFocusVisible
|
67
|
+
isFocused: isDisabled ? false : isFocusVisible,
|
68
|
+
hasSeparator: hasSeparator
|
69
69
|
}),
|
70
70
|
classNames = _useStatusClasses.classNames;
|
71
71
|
|
@@ -86,9 +86,7 @@ var ListViewItem = function ListViewItem(props) {
|
|
86
86
|
isSelected: isSelected,
|
87
87
|
className: classNames,
|
88
88
|
"data-id": dataId
|
89
|
-
}, listItemProps), item.rendered))
|
90
|
-
m: "0px"
|
91
|
-
}));
|
89
|
+
}, listItemProps), item.rendered)));
|
92
90
|
};
|
93
91
|
|
94
92
|
ListViewItem.propTypes = {
|
@@ -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,
|
@@ -32,10 +33,11 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
32
33
|
tabLabelProps = itemProps.tabLabelProps,
|
33
34
|
tabLineProps = itemProps.tabLineProps,
|
34
35
|
content = itemProps.content,
|
35
|
-
|
36
|
+
titleAttr = itemProps.titleAttr,
|
37
|
+
otherItemProps = _objectWithoutProperties(itemProps, ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content", "titleAttr"]);
|
36
38
|
|
37
|
-
var isDisabled = tabsDisabled || tabDisabled;
|
38
39
|
var state = useContext(TabsContext);
|
40
|
+
var isDisabled = tabsDisabled || tabDisabled || state.disabledKeys.has(key);
|
39
41
|
var isSelected = state.selectedKey === key;
|
40
42
|
|
41
43
|
var _useFocusRing = useFocusRing(),
|
@@ -70,14 +72,17 @@ export var CollectionTab = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
72
|
}, state, tabRef),
|
71
73
|
tabProps = _useTab.tabProps;
|
72
74
|
|
73
|
-
var tab = ___EmotionJSX(Box,
|
75
|
+
var tab = ___EmotionJSX(Box, {
|
76
|
+
isRow: true
|
77
|
+
}, slots === null || slots === void 0 ? void 0 : slots.beforeTab, ___EmotionJSX(Box, _extends({
|
74
78
|
className: classNames,
|
75
79
|
variant: "tab"
|
76
80
|
}, mergeProps(focusProps, hoverProps, tabProps), otherItemProps, {
|
77
|
-
ref: tabRef
|
81
|
+
ref: tabRef,
|
82
|
+
title: titleAttr || undefined
|
78
83
|
}), icon, ___EmotionJSX(Text, _extends({
|
79
84
|
variant: "tabLabel"
|
80
|
-
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps));
|
85
|
+
}, tabLabelProps), rendered), isSelected && !isDisabled && ___EmotionJSX(TabLine, tabLineProps)), slots === null || slots === void 0 ? void 0 : slots.afterTab);
|
81
86
|
|
82
87
|
if (mode === 'tooltip') {
|
83
88
|
return ___EmotionJSX(React.Fragment, null, separator, ___EmotionJSX(TooltipTrigger, _extends({}, tooltipTriggerProps, {
|
@@ -100,7 +105,11 @@ CollectionTab.propTypes = {
|
|
100
105
|
}),
|
101
106
|
mode: PropTypes.oneOf(['default', 'tooltip']),
|
102
107
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
103
|
-
tooltipTriggerProps: PropTypes.shape({})
|
108
|
+
tooltipTriggerProps: PropTypes.shape({}),
|
109
|
+
slots: PropTypes.shape({
|
110
|
+
beforeTab: PropTypes.node,
|
111
|
+
afterTab: PropTypes.node
|
112
|
+
})
|
104
113
|
};
|
105
114
|
|
106
115
|
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
|
};
|