@pingux/astro 1.2.0-alpha.1 → 1.2.0-alpha.13
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/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/cjs/components/Button/Button.js +14 -2
- package/lib/cjs/components/Button/Button.stories.js +69 -28
- package/lib/cjs/components/Button/Button.test.js +26 -0
- package/lib/cjs/components/CopyText/CopyButton.js +9 -2
- package/lib/cjs/components/HelpHint/HelpHint.js +24 -6
- package/lib/cjs/components/HelpHint/HelpHint.stories.js +57 -0
- package/lib/cjs/components/HelpHint/HelpHint.test.js +80 -0
- package/lib/cjs/components/Messages/Messages.reducer.js +2 -1
- package/lib/cjs/components/Messages/Messages.stories.js +10 -10
- package/lib/cjs/components/Messages/Messages.test.js +15 -1
- package/lib/cjs/components/Messages/index.js +21 -2
- package/lib/cjs/components/Modal/Modal.stories.js +1 -1
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +3 -1
- package/lib/cjs/components/NumberField/NumberField.js +3 -1
- package/lib/cjs/components/NumberField/NumberField.test.js +7 -0
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +2 -16
- package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +44 -0
- package/lib/cjs/components/SearchField/SearchField.stories.js +1 -15
- package/lib/cjs/components/TextAreaField/TextAreaField.js +1 -1
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +1 -54
- package/lib/cjs/components/TextField/TextField.stories.js +79 -2
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/layouts/ListLayout.stories.js +6 -6
- package/lib/cjs/recipes/ArrayField.stories.js +1 -1
- package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/cjs/styles/variants/buttons.js +78 -2
- package/lib/cjs/styles/variants/text.js +14 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/components/Button/Button.js +15 -3
- package/lib/components/Button/Button.stories.js +53 -15
- package/lib/components/Button/Button.test.js +20 -0
- package/lib/components/CopyText/CopyButton.js +7 -2
- package/lib/components/HelpHint/HelpHint.js +25 -5
- package/lib/components/HelpHint/HelpHint.stories.js +34 -0
- package/lib/components/HelpHint/HelpHint.test.js +58 -0
- package/lib/components/Messages/Messages.reducer.js +1 -1
- package/lib/components/Messages/Messages.stories.js +1 -1
- package/lib/components/Messages/Messages.test.js +11 -1
- package/lib/components/Messages/index.js +2 -1
- package/lib/components/Modal/Modal.stories.js +1 -1
- package/lib/components/MultivaluesField/MultivaluesField.js +3 -1
- package/lib/components/NumberField/NumberField.js +2 -1
- package/lib/components/NumberField/NumberField.test.js +7 -0
- package/lib/components/OverlayPanel/OverlayPanel.js +3 -16
- package/lib/components/OverlayPanel/OverlayPanel.test.js +38 -0
- package/lib/components/SearchField/SearchField.stories.js +0 -11
- package/lib/components/TextAreaField/TextAreaField.js +1 -1
- package/lib/components/TextAreaField/TextAreaField.stories.js +0 -43
- package/lib/components/TextField/TextField.stories.js +72 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/layouts/ListLayout.stories.js +6 -6
- package/lib/recipes/ArrayField.stories.js +1 -1
- package/lib/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/styles/variants/buttons.js +78 -2
- package/lib/styles/variants/text.js +14 -0
- package/package.json +2 -2
@@ -1,10 +1,11 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
1
3
|
import React from 'react';
|
2
4
|
import AddCircleIcon from 'mdi-react/AddCircleIcon';
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import Text from '
|
7
|
-
import { buttonVariants } from '../../utils/devUtils/constants/variants'; // removing the iconButton variants from this story.
|
5
|
+
import CreateIcon from 'mdi-react/CreateIcon';
|
6
|
+
import FilterIcon from 'mdi-react/FilterIcon';
|
7
|
+
import { buttonVariants } from '../../utils/devUtils/constants/variants';
|
8
|
+
import { Box, Button, Icon, SearchField, Text } from '../../index'; // removing the iconButton variants from this story.
|
8
9
|
|
9
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
11
|
var variants = buttonVariants;
|
@@ -36,6 +37,13 @@ export default {
|
|
36
37
|
type: 'text'
|
37
38
|
}
|
38
39
|
}
|
40
|
+
},
|
41
|
+
parameters: {
|
42
|
+
docs: {
|
43
|
+
source: {
|
44
|
+
type: 'code'
|
45
|
+
}
|
46
|
+
}
|
39
47
|
}
|
40
48
|
};
|
41
49
|
export var Default = function Default(args) {
|
@@ -59,19 +67,49 @@ export var TextIconButton = function TextIconButton() {
|
|
59
67
|
size: 20
|
60
68
|
}), "Add a Form"));
|
61
69
|
};
|
62
|
-
export var TextButton = function TextButton() {
|
63
|
-
return ___EmotionJSX(Button, {
|
64
|
-
mb: "sm",
|
65
|
-
variant: "text",
|
66
|
-
"aria-label": "Add option"
|
67
|
-
}, ___EmotionJSX(Text, {
|
68
|
-
variant: "label",
|
69
|
-
color: "active"
|
70
|
-
}, " + Add Option"));
|
71
|
-
};
|
72
70
|
export var InlineButton = function InlineButton() {
|
73
71
|
return ___EmotionJSX(Button, {
|
74
72
|
mb: "sm",
|
75
73
|
variant: "inline"
|
76
74
|
}, "Inline");
|
75
|
+
};
|
76
|
+
export var ColorBlockButton = function ColorBlockButton(args) {
|
77
|
+
// Change `isConfigured` property in storybook controls
|
78
|
+
var isConfigured = args.isConfigured,
|
79
|
+
props = _objectWithoutProperties(args, ["isConfigured"]);
|
80
|
+
|
81
|
+
return ___EmotionJSX(Button, _extends({}, props, {
|
82
|
+
variant: "colorBlock",
|
83
|
+
className: isConfigured ? 'is-configured' : ''
|
84
|
+
}), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|
85
|
+
variant: "buttonTitle"
|
86
|
+
}, "Title"), ___EmotionJSX(Text, {
|
87
|
+
variant: "buttonSubtitle"
|
88
|
+
}, "Info")), ___EmotionJSX(Icon, {
|
89
|
+
icon: CreateIcon
|
90
|
+
}));
|
91
|
+
};
|
92
|
+
ColorBlockButton.story = {
|
93
|
+
argTypes: {
|
94
|
+
isConfigured: {
|
95
|
+
control: {
|
96
|
+
type: 'boolean'
|
97
|
+
},
|
98
|
+
defaultValue: false
|
99
|
+
}
|
100
|
+
}
|
101
|
+
};
|
102
|
+
export var FilterButton = function FilterButton() {
|
103
|
+
return ___EmotionJSX(Box, {
|
104
|
+
p: "xx",
|
105
|
+
isRow: true,
|
106
|
+
gap: "md"
|
107
|
+
}, ___EmotionJSX(SearchField, {
|
108
|
+
"aria-label": "search items"
|
109
|
+
}), ___EmotionJSX(Button, {
|
110
|
+
variant: "filter",
|
111
|
+
"aria-label": "filter button"
|
112
|
+
}, ___EmotionJSX(Icon, {
|
113
|
+
icon: FilterIcon
|
114
|
+
})));
|
77
115
|
};
|
@@ -89,4 +89,24 @@ test('button renders children when not loading', function () {
|
|
89
89
|
expect(childWrapper).toBeInTheDocument();
|
90
90
|
expect(childWrapper).toBeVisible();
|
91
91
|
expect(screen.queryByRole('progressbar')).not.toBeInTheDocument();
|
92
|
+
});
|
93
|
+
test('color block button renders in default state', function () {
|
94
|
+
getComponent({
|
95
|
+
variant: 'colorBlock'
|
96
|
+
});
|
97
|
+
var button = screen.getByRole('button');
|
98
|
+
expect(button).toBeInTheDocument();
|
99
|
+
expect(button).not.toHaveClass('is-configured');
|
100
|
+
userEvent.tab();
|
101
|
+
expect(button).toHaveClass('is-focused');
|
102
|
+
expect(button).toHaveFocus();
|
103
|
+
});
|
104
|
+
test('color block button renders in configured state', function () {
|
105
|
+
getComponent({
|
106
|
+
variant: 'colorBlock',
|
107
|
+
className: 'is-configured'
|
108
|
+
});
|
109
|
+
var button = screen.getByRole('button');
|
110
|
+
expect(button).toBeInTheDocument();
|
111
|
+
expect(button).toHaveClass('is-configured');
|
92
112
|
});
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import ContentCopy from 'mdi-react/ContentCopyIcon';
|
4
|
+
import { omit } from 'lodash';
|
5
|
+
import PropTypes from 'prop-types';
|
4
6
|
import Icon from '../Icon';
|
5
7
|
import IconButton from '../IconButton';
|
6
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -9,9 +11,12 @@ var CopyButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
9
11
|
ref: ref,
|
10
12
|
"aria-label": "copy",
|
11
13
|
variant: "buttons.copy"
|
12
|
-
}, props), ___EmotionJSX(Icon, {
|
14
|
+
}, omit(props, 'iconProps')), ___EmotionJSX(Icon, _extends({
|
13
15
|
icon: ContentCopy,
|
14
16
|
size: 15
|
15
|
-
}));
|
17
|
+
}, props === null || props === void 0 ? void 0 : props.iconProps)));
|
16
18
|
});
|
19
|
+
CopyButton.propTypes = {
|
20
|
+
iconProps: PropTypes.shape({})
|
21
|
+
};
|
17
22
|
export default CopyButton;
|
@@ -1,12 +1,32 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
3
|
import React, { forwardRef } from 'react';
|
4
|
-
import HelpIcon from 'mdi-react/HelpIcon';
|
5
4
|
import PropTypes from 'prop-types';
|
6
5
|
import IconButton from '../IconButton';
|
7
6
|
import TooltipTrigger, { Tooltip } from '../TooltipTrigger';
|
8
7
|
import Icon from '../Icon';
|
9
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
|
+
|
10
|
+
var HelpIcon = function HelpIcon() {
|
11
|
+
return ___EmotionJSX("svg", {
|
12
|
+
width: "7",
|
13
|
+
height: "9",
|
14
|
+
viewBox: "0 0 7 9",
|
15
|
+
fill: "none",
|
16
|
+
xmlns: "http://www.w3.org/2000/svg"
|
17
|
+
}, ___EmotionJSX("path", {
|
18
|
+
d: "M2.56685 7.306V9H4.29385V7.306H2.56685ZM0.795848 3.676H2.41285C2.41285 3.478 2.43485 3.29467 2.47885 3.126C2.52285 2.95 2.58885 2.79967 2.67685 2.675C2.77218 2.543 2.88951 2.44033 3.02885 2.367C3.17551 2.28633 3.34785 2.246 3.54585 2.246C3.83918 2.246 4.06651 2.32667 4.22785 2.488C4.39651 2.64933 4.48085 2.89867 4.48085 3.236C4.48818 3.434 4.45151 3.599 4.37085 3.731C4.29751 3.863 4.19851 3.984 4.07385 4.094C3.94918 4.204 3.81351 4.314 3.66685 4.424C3.52018 4.534 3.38085 4.666 3.24885 4.82C3.11685 4.96667 2.99951 5.14633 2.89685 5.359C2.80151 5.57167 2.74285 5.83567 2.72085 6.151V6.646H4.20585V6.228C4.23518 6.008 4.30485 5.82467 4.41485 5.678C4.53218 5.53133 4.66418 5.403 4.81085 5.293C4.95751 5.17567 5.11151 5.062 5.27285 4.952C5.44151 4.83467 5.59185 4.69533 5.72385 4.534C5.86318 4.37267 5.97685 4.17833 6.06485 3.951C6.16018 3.72367 6.20785 3.434 6.20785 3.082C6.20785 2.86933 6.16018 2.642 6.06485 2.4C5.97685 2.15067 5.82651 1.91967 5.61385 1.707C5.40118 1.49433 5.11885 1.31833 4.76685 1.179C4.42218 1.03233 3.98951 0.959 3.46885 0.959C3.06551 0.959 2.69885 1.02867 2.36885 1.168C2.04618 1.3 1.76751 1.487 1.53285 1.729C1.30551 1.971 1.12585 2.257 0.993848 2.587C0.869181 2.917 0.803181 3.28 0.795848 3.676Z",
|
19
|
+
fill: "#3B4A58"
|
20
|
+
}));
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* A `HelpHint` is a composed component using tooltip trigger and icon button.
|
24
|
+
*
|
25
|
+
* For customization the trigger icon,
|
26
|
+
* please see the [TooltipTrigger](./?path=/docs/tooltiptrigger--default) docs.
|
27
|
+
*/
|
28
|
+
|
29
|
+
|
10
30
|
var HelpHint = /*#__PURE__*/forwardRef(function (props, ref) {
|
11
31
|
var children = props.children,
|
12
32
|
tooltipProps = props.tooltipProps,
|
@@ -14,14 +34,14 @@ var HelpHint = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
14
34
|
others = _objectWithoutProperties(props, ["children", "tooltipProps", "iconButtonProps"]);
|
15
35
|
|
16
36
|
return ___EmotionJSX(TooltipTrigger, _extends({
|
17
|
-
ref: ref
|
18
|
-
|
37
|
+
ref: ref,
|
38
|
+
direction: "top"
|
39
|
+
}, others, tooltipProps), ___EmotionJSX(IconButton, _extends({
|
19
40
|
variant: "helpHint",
|
20
41
|
"aria-label": "label help hint",
|
21
42
|
"data-testid": "help-hint__button"
|
22
43
|
}, iconButtonProps), ___EmotionJSX(Icon, {
|
23
|
-
icon: HelpIcon
|
24
|
-
size: "11px"
|
44
|
+
icon: HelpIcon
|
25
45
|
})), ___EmotionJSX(Tooltip, tooltipProps, children));
|
26
46
|
});
|
27
47
|
HelpHint.propTypes = {
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import HelpHint from '.';
|
3
|
+
import Box from '../Box';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
export default {
|
6
|
+
title: 'HelpHint',
|
7
|
+
component: HelpHint,
|
8
|
+
argTypes: {
|
9
|
+
children: {
|
10
|
+
description: 'Tooltip content',
|
11
|
+
defaultValue: 'Text of the tooltip right here...',
|
12
|
+
control: {
|
13
|
+
type: 'text'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
};
|
18
|
+
export var Default = function Default(args) {
|
19
|
+
return ___EmotionJSX(Box, {
|
20
|
+
p: 50
|
21
|
+
}, ___EmotionJSX(HelpHint, args));
|
22
|
+
};
|
23
|
+
export var WithTooltipAndIconButtonProps = function WithTooltipAndIconButtonProps() {
|
24
|
+
return ___EmotionJSX(Box, {
|
25
|
+
p: 50
|
26
|
+
}, ___EmotionJSX(HelpHint, {
|
27
|
+
tooltipProps: {
|
28
|
+
direction: 'bottom'
|
29
|
+
},
|
30
|
+
iconButtonProps: {
|
31
|
+
'aria-label': 'Help hint'
|
32
|
+
}
|
33
|
+
}, "Text of the tooltip right here..."));
|
34
|
+
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import userEvent from '@testing-library/user-event';
|
4
|
+
import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
5
|
+
import axeTest from '../../utils/testUtils/testAxe';
|
6
|
+
import HelpHint from './HelpHint';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
var testId = 'help-hint__button';
|
9
|
+
var tooltipValue = 'Some text';
|
10
|
+
var defaultProps = {
|
11
|
+
children: tooltipValue
|
12
|
+
};
|
13
|
+
|
14
|
+
var getComponent = function getComponent() {
|
15
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
16
|
+
return render(___EmotionJSX(HelpHint, _extends({}, defaultProps, props)));
|
17
|
+
}; // Need to be added to each test file to test accessibility using axe.
|
18
|
+
|
19
|
+
|
20
|
+
axeTest(getComponent);
|
21
|
+
test('renders HelpHint component', function () {
|
22
|
+
getComponent();
|
23
|
+
var helpHintButton = screen.getByTestId(testId);
|
24
|
+
expect(helpHintButton).toBeInTheDocument();
|
25
|
+
});
|
26
|
+
test('shows tooltip on hover', function () {
|
27
|
+
getComponent();
|
28
|
+
var helpHintButton = screen.getByTestId(testId);
|
29
|
+
expect(screen.queryByText(tooltipValue)).not.toBeInTheDocument();
|
30
|
+
fireEvent.mouseMove(helpHintButton);
|
31
|
+
fireEvent.mouseEnter(helpHintButton);
|
32
|
+
expect(screen.getByText(tooltipValue)).toBeInTheDocument();
|
33
|
+
});
|
34
|
+
test('shows tooltip on focus', function () {
|
35
|
+
getComponent();
|
36
|
+
var helpHintButton = screen.getByTestId(testId);
|
37
|
+
expect(screen.queryByText(tooltipValue)).not.toBeInTheDocument();
|
38
|
+
userEvent.tab();
|
39
|
+
expect(helpHintButton).toHaveFocus();
|
40
|
+
expect(screen.queryByText(tooltipValue)).toBeInTheDocument();
|
41
|
+
});
|
42
|
+
test('applies tooltipProps', function () {
|
43
|
+
getComponent({
|
44
|
+
tooltipProps: {
|
45
|
+
isOpen: true
|
46
|
+
}
|
47
|
+
});
|
48
|
+
expect(screen.getByText(tooltipValue)).toBeInTheDocument();
|
49
|
+
});
|
50
|
+
test('applies iconButtonProps', function () {
|
51
|
+
var newLabel = 'New label';
|
52
|
+
getComponent({
|
53
|
+
iconButtonProps: {
|
54
|
+
'aria-label': newLabel
|
55
|
+
}
|
56
|
+
});
|
57
|
+
expect(screen.getByLabelText(newLabel)).toBeInTheDocument();
|
58
|
+
});
|
@@ -13,7 +13,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
13
13
|
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; }
|
14
14
|
|
15
15
|
import { messagesReducer as messagesReducerCore, multiMessagesReducer as multiMessagesReducerCore } from './utils';
|
16
|
-
var messagesReducer = messagesReducerCore;
|
16
|
+
export var messagesReducer = messagesReducerCore;
|
17
17
|
export var multiMessagesReducer = multiMessagesReducerCore;
|
18
18
|
|
19
19
|
var makeShowMessage = function makeShowMessage(status, timeout) {
|
@@ -23,7 +23,7 @@ import { Item } from '@react-stately/collections';
|
|
23
23
|
import AccountIcon from 'mdi-react/AccountIcon';
|
24
24
|
import statuses from '../../utils/devUtils/constants/statuses';
|
25
25
|
import { Box, Button, Messages } from '../..';
|
26
|
-
import messagesReducer,
|
26
|
+
import { messagesReducerStory as messagesReducer, multiMessagesReducerStory as multiMessagesReducer } from './index';
|
27
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
28
28
|
export default {
|
29
29
|
title: 'Messages',
|
@@ -9,7 +9,7 @@ import { Item } from '@react-stately/collections';
|
|
9
9
|
import userEvent from '@testing-library/user-event';
|
10
10
|
import axeTest from '../../utils/testUtils/testAxe';
|
11
11
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
12
|
-
import Messages from '.';
|
12
|
+
import Messages, { messagesReducerStory, multiMessagesReducerStory } from '.';
|
13
13
|
import Button from '../Button';
|
14
14
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
15
|
jest.mock('@react-aria/live-announcer');
|
@@ -173,4 +173,14 @@ describe('announcements', function () {
|
|
173
173
|
expect(messages.childElementCount).toBe(1);
|
174
174
|
expect(announce).toHaveBeenCalledWith('New message 1', 'polite');
|
175
175
|
});
|
176
|
+
});
|
177
|
+
test('should render messages with messagesReducerStory', function () {
|
178
|
+
getComponent();
|
179
|
+
messagesReducerStory.actions.showSuccessMessage();
|
180
|
+
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
181
|
+
});
|
182
|
+
test('should render messages with multiMessagesReducerStory', function () {
|
183
|
+
getComponent();
|
184
|
+
multiMessagesReducerStory.actions.showSuccessMessage();
|
185
|
+
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
176
186
|
});
|
@@ -138,7 +138,7 @@ export var DarkVariant = function DarkVariant() {
|
|
138
138
|
onPress: state.close,
|
139
139
|
"aria-label": "Yes"
|
140
140
|
}, "Yes"), ___EmotionJSX(Button, {
|
141
|
-
variant: "
|
141
|
+
variant: "link",
|
142
142
|
onPress: state.close,
|
143
143
|
"aria-label": "Cancel"
|
144
144
|
}, "Cancel"))))
|
@@ -22,6 +22,7 @@ import { useNumberField } from '@react-aria/numberfield';
|
|
22
22
|
import { useNumberFieldState } from '@react-stately/numberfield';
|
23
23
|
import { useLocale } from '@react-aria/i18n';
|
24
24
|
import { mergeProps } from '@react-aria/utils';
|
25
|
+
import omit from 'lodash/omit';
|
25
26
|
import statuses from '../../utils/devUtils/constants/statuses';
|
26
27
|
import { Box, FieldHelperText, Icon, IconButton, Input, Label } from '../../index';
|
27
28
|
import { useField, usePropWarning } from '../../hooks';
|
@@ -94,7 +95,7 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
95
|
ref: inputRef // we don't want to merge this props, we want to
|
95
96
|
// overwrite them like defaultValue, value, ect.
|
96
97
|
|
97
|
-
}, fieldControlProps, inputProps)), ControlArrows), helperText && ___EmotionJSX(FieldHelperText, {
|
98
|
+
}, fieldControlProps, omit(inputProps, 'name'))), ControlArrows), helperText && ___EmotionJSX(FieldHelperText, {
|
98
99
|
status: status
|
99
100
|
}, helperText)));
|
100
101
|
});
|
@@ -128,4 +128,11 @@ test('increment and decrement buttons shouldn\'t be able to be focused via keybo
|
|
128
128
|
expect(screen.getByLabelText('arrow-up')).not.toHaveFocus();
|
129
129
|
userEvent.tab();
|
130
130
|
expect(screen.getByLabelText('arrow-down')).not.toHaveFocus();
|
131
|
+
});
|
132
|
+
test('number field input receiving name attribute', function () {
|
133
|
+
var testName = 'testName';
|
134
|
+
getComponent({
|
135
|
+
name: testName
|
136
|
+
});
|
137
|
+
expect(screen.getByLabelText(testLabel)).toHaveAttribute('name', testName);
|
131
138
|
});
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
4
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
5
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, { forwardRef, useRef, useImperativeHandle
|
5
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
7
6
|
import PropTypes from 'prop-types';
|
8
7
|
import { FocusScope } from '@react-aria/focus';
|
9
8
|
import Box from '../Box';
|
@@ -26,14 +25,8 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
25
|
onClose = _useOverlayPanelState.onClose;
|
27
26
|
|
28
27
|
var overlayPanelRef = useRef();
|
29
|
-
|
30
|
-
var _useState = useState(true),
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
contain = _useState2[0],
|
33
|
-
setIsContained = _useState2[1];
|
34
28
|
/* istanbul ignore next */
|
35
29
|
|
36
|
-
|
37
30
|
useImperativeHandle(ref, function () {
|
38
31
|
return overlayPanelRef.current;
|
39
32
|
});
|
@@ -47,18 +40,12 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
47
40
|
e.stopPropagation();
|
48
41
|
|
49
42
|
if (e.key === 'Escape') {
|
50
|
-
|
43
|
+
onClose(state, triggerRef, onCloseProp);
|
51
44
|
}
|
52
45
|
};
|
53
46
|
|
54
|
-
useEffect(function () {
|
55
|
-
if (!contain && onClose) {
|
56
|
-
onClose(state, triggerRef, onCloseProp);
|
57
|
-
}
|
58
|
-
}, [contain]);
|
59
47
|
return ___EmotionJSX(FocusScope, {
|
60
|
-
autoFocus: true
|
61
|
-
contain: contain
|
48
|
+
autoFocus: true
|
62
49
|
}, ___EmotionJSX(Box, _extends({
|
63
50
|
variant: "overlayPanel.overlayPanel",
|
64
51
|
ref: overlayPanelRef
|
@@ -60,6 +60,13 @@ test('onClose callback fires when provided', function () {
|
|
60
60
|
});
|
61
61
|
expect(onClose).toHaveBeenCalled();
|
62
62
|
});
|
63
|
+
test('custom classname can be passed', function () {
|
64
|
+
getComponent({
|
65
|
+
className: 'testing-class'
|
66
|
+
});
|
67
|
+
var overlayPanel = screen.getByTestId(testId);
|
68
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
69
|
+
});
|
63
70
|
test('neither callback fires when not provided', function () {
|
64
71
|
var onClose = jest.fn();
|
65
72
|
getComponent({
|
@@ -110,4 +117,35 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
110
117
|
charCode: 27
|
111
118
|
});
|
112
119
|
expect(focusFunction).toHaveBeenCalled();
|
120
|
+
});
|
121
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
122
|
+
var onClose = jest.fn();
|
123
|
+
var focusFunction = jest.fn();
|
124
|
+
var state = {
|
125
|
+
close: onClose
|
126
|
+
};
|
127
|
+
var triggerRef = {
|
128
|
+
current: {
|
129
|
+
focus: focusFunction
|
130
|
+
}
|
131
|
+
};
|
132
|
+
getComponent({
|
133
|
+
state: state,
|
134
|
+
children: ___EmotionJSX("div", null, "Test"),
|
135
|
+
triggerRef: triggerRef
|
136
|
+
});
|
137
|
+
var overlayPanel = screen.getByTestId(testId);
|
138
|
+
fireEvent.keyDown(overlayPanel, {
|
139
|
+
key: 'KeyA',
|
140
|
+
code: 'KeyA',
|
141
|
+
keyCode: 65,
|
142
|
+
charCode: 65
|
143
|
+
});
|
144
|
+
fireEvent.keyUp(overlayPanel, {
|
145
|
+
key: 'KeyA',
|
146
|
+
code: 'KeyA',
|
147
|
+
keyCode: 65,
|
148
|
+
charCode: 65
|
149
|
+
});
|
150
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
113
151
|
});
|
@@ -101,17 +101,6 @@ export var NoClearButton = function NoClearButton() {
|
|
101
101
|
|
102
102
|
});
|
103
103
|
};
|
104
|
-
export var MaxLength = function MaxLength(args) {
|
105
|
-
return ___EmotionJSX(SearchField, _extends({}, args, {
|
106
|
-
icon: SearchIcon,
|
107
|
-
"aria-label": "Search Groups",
|
108
|
-
onSubmit: function onSubmit(text) {
|
109
|
-
return alert(text);
|
110
|
-
} // eslint-disable-line no-alert
|
111
|
-
,
|
112
|
-
maxLength: 9
|
113
|
-
}));
|
114
|
-
};
|
115
104
|
export var ControlledWithDebouncedInput = function ControlledWithDebouncedInput() {
|
116
105
|
var _useState3 = useState(''),
|
117
106
|
_useState4 = _slicedToArray(_useState3, 2),
|
@@ -2,7 +2,6 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
2
2
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import TextAreaField from '.';
|
5
|
-
import Box from '../Box';
|
6
5
|
import statuses from '../../utils/devUtils/constants/statuses';
|
7
6
|
import { modes as labelModes } from '../Label/constants';
|
8
7
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -71,34 +70,6 @@ export var FloatLabel = function FloatLabel() {
|
|
71
70
|
labelMode: "float"
|
72
71
|
});
|
73
72
|
};
|
74
|
-
export var LeftLabel = function LeftLabel() {
|
75
|
-
return ___EmotionJSX(Box, {
|
76
|
-
gap: "xl",
|
77
|
-
width: "fit-content"
|
78
|
-
}, ___EmotionJSX(TextAreaField, {
|
79
|
-
label: "Example label",
|
80
|
-
labelMode: "left"
|
81
|
-
}), ___EmotionJSX(TextAreaField, {
|
82
|
-
label: "Example label that is much longer than the previous one",
|
83
|
-
labelMode: "left",
|
84
|
-
status: "error"
|
85
|
-
}), ___EmotionJSX(TextAreaField, {
|
86
|
-
label: "Example label with set width",
|
87
|
-
labelMode: "left",
|
88
|
-
containerProps: {
|
89
|
-
sx: {
|
90
|
-
gridTemplateColumns: '120px auto'
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}));
|
94
|
-
};
|
95
|
-
LeftLabel.parameters = {
|
96
|
-
docs: {
|
97
|
-
description: {
|
98
|
-
story: 'Users are able to override the default 40% column width when using left label by providing a new gridTemplatesColumn value, as shown in the example below.'
|
99
|
-
}
|
100
|
-
}
|
101
|
-
};
|
102
73
|
export var Controlled = function Controlled() {
|
103
74
|
var _useState = useState(),
|
104
75
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -152,20 +123,6 @@ export var Error = function Error() {
|
|
152
123
|
status: "error"
|
153
124
|
});
|
154
125
|
};
|
155
|
-
export var Success = function Success() {
|
156
|
-
return ___EmotionJSX(TextAreaField, {
|
157
|
-
helperText: "Here is some helpful text...",
|
158
|
-
label: "Example Label",
|
159
|
-
status: "success"
|
160
|
-
});
|
161
|
-
};
|
162
|
-
export var Warning = function Warning() {
|
163
|
-
return ___EmotionJSX(TextAreaField, {
|
164
|
-
helperText: "Here is some helpful text...",
|
165
|
-
label: "Example Label",
|
166
|
-
status: "warning"
|
167
|
-
});
|
168
|
-
};
|
169
126
|
export var WithoutStatusIndicator = function WithoutStatusIndicator() {
|
170
127
|
return ___EmotionJSX(TextAreaField, {
|
171
128
|
label: "Example Label",
|
@@ -8,6 +8,8 @@ import TextField from '.';
|
|
8
8
|
import { modes as labelModes } from '../Label/constants';
|
9
9
|
import statuses from '../../utils/devUtils/constants/statuses.js';
|
10
10
|
import Box from '../Box';
|
11
|
+
import useCopyToClipboard from '../../hooks/useCopyToClipboard';
|
12
|
+
import CopyButton from '../CopyText/CopyButton';
|
11
13
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
14
|
export default {
|
13
15
|
title: 'Form/TextField',
|
@@ -186,4 +188,74 @@ export var MaxLength = function MaxLength() {
|
|
186
188
|
label: "Example label",
|
187
189
|
maxLength: 9
|
188
190
|
});
|
191
|
+
};
|
192
|
+
export var WithSlots = function WithSlots() {
|
193
|
+
var _useState5 = useState("[{ 'type': 'work', 'streetAddress': 'San Antonio MI 47096' },{ 'type': 'home', 'streetAddress': 'Santa Rosa MN 98804' }]"),
|
194
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
195
|
+
addressesValue = _useState6[0],
|
196
|
+
setAddressesValue = _useState6[1];
|
197
|
+
|
198
|
+
var _useState7 = useState("[{ 'status': 'inactive', 'subject': 'example@pingidentity.com' },{ 'status': 'active', 'subject': 'john@pingidentity.com' }]"),
|
199
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
200
|
+
jsonValue = _useState8[0],
|
201
|
+
setJsonValue = _useState8[1];
|
202
|
+
|
203
|
+
var copyAddressesToClipboard = useCopyToClipboard(addressesValue);
|
204
|
+
var copyJsonToClipboard = useCopyToClipboard(jsonValue);
|
205
|
+
var buttonSx = {
|
206
|
+
position: 'absolute',
|
207
|
+
right: 0,
|
208
|
+
top: '5px'
|
209
|
+
};
|
210
|
+
var containerSx = {
|
211
|
+
sx: {
|
212
|
+
'& input': {
|
213
|
+
paddingRight: '40px'
|
214
|
+
}
|
215
|
+
}
|
216
|
+
};
|
217
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(TextField, {
|
218
|
+
label: "Multiple Addresses",
|
219
|
+
labelMode: "float",
|
220
|
+
onChange: function onChange(e) {
|
221
|
+
return setAddressesValue(e.target.value);
|
222
|
+
},
|
223
|
+
value: addressesValue,
|
224
|
+
containerProps: containerSx,
|
225
|
+
slots: {
|
226
|
+
inContainer: ___EmotionJSX(CopyButton, {
|
227
|
+
onPress: copyAddressesToClipboard,
|
228
|
+
sx: buttonSx,
|
229
|
+
iconProps: {
|
230
|
+
sx: {
|
231
|
+
path: {
|
232
|
+
fill: 'active'
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
})
|
237
|
+
},
|
238
|
+
mb: 30
|
239
|
+
}), ___EmotionJSX(TextField, {
|
240
|
+
label: "Example JSON",
|
241
|
+
labelMode: "float",
|
242
|
+
onChange: function onChange(e) {
|
243
|
+
return setJsonValue(e.target.value);
|
244
|
+
},
|
245
|
+
value: jsonValue,
|
246
|
+
containerProps: containerSx,
|
247
|
+
slots: {
|
248
|
+
inContainer: ___EmotionJSX(CopyButton, {
|
249
|
+
onPress: copyJsonToClipboard,
|
250
|
+
sx: buttonSx,
|
251
|
+
iconProps: {
|
252
|
+
sx: {
|
253
|
+
path: {
|
254
|
+
fill: 'active'
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
})
|
259
|
+
}
|
260
|
+
}));
|
189
261
|
};
|