@pingux/astro 1.2.0-alpha.1 → 1.2.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/lib/cjs/components/Button/Button.js +5 -2
- package/lib/cjs/components/Button/Button.stories.js +71 -17
- 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/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/TextField/TextField.stories.js +79 -2
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/styles/variants/buttons.js +78 -2
- package/lib/cjs/styles/variants/text.js +14 -0
- package/lib/components/Button/Button.js +6 -3
- package/lib/components/Button/Button.stories.js +53 -5
- 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/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/TextField/TextField.stories.js +72 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/styles/variants/buttons.js +78 -2
- package/lib/styles/variants/text.js +14 -0
- package/package.json +2 -2
@@ -18,8 +18,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
18
18
|
|
19
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
20
20
|
|
21
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
22
|
-
|
23
21
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
24
22
|
|
25
23
|
var _react = _interopRequireWildcard(require("react"));
|
@@ -52,14 +50,8 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
52
50
|
onClose = _useOverlayPanelState.onClose;
|
53
51
|
|
54
52
|
var overlayPanelRef = (0, _react.useRef)();
|
55
|
-
|
56
|
-
var _useState = (0, _react.useState)(true),
|
57
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
58
|
-
contain = _useState2[0],
|
59
|
-
setIsContained = _useState2[1];
|
60
53
|
/* istanbul ignore next */
|
61
54
|
|
62
|
-
|
63
55
|
(0, _react.useImperativeHandle)(ref, function () {
|
64
56
|
return overlayPanelRef.current;
|
65
57
|
});
|
@@ -73,18 +65,12 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
73
65
|
e.stopPropagation();
|
74
66
|
|
75
67
|
if (e.key === 'Escape') {
|
76
|
-
|
68
|
+
onClose(state, triggerRef, onCloseProp);
|
77
69
|
}
|
78
70
|
};
|
79
71
|
|
80
|
-
(0, _react.useEffect)(function () {
|
81
|
-
if (!contain && onClose) {
|
82
|
-
onClose(state, triggerRef, onCloseProp);
|
83
|
-
}
|
84
|
-
}, [contain]);
|
85
72
|
return (0, _react2.jsx)(_focus.FocusScope, {
|
86
|
-
autoFocus: true
|
87
|
-
contain: contain
|
73
|
+
autoFocus: true
|
88
74
|
}, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
89
75
|
variant: "overlayPanel.overlayPanel",
|
90
76
|
ref: overlayPanelRef
|
@@ -79,6 +79,15 @@ test('onClose callback fires when provided', function () {
|
|
79
79
|
|
80
80
|
expect(onClose).toHaveBeenCalled();
|
81
81
|
});
|
82
|
+
test('custom classname can be passed', function () {
|
83
|
+
getComponent({
|
84
|
+
className: 'testing-class'
|
85
|
+
});
|
86
|
+
|
87
|
+
var overlayPanel = _testWrapper.screen.getByTestId(testId);
|
88
|
+
|
89
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
90
|
+
});
|
82
91
|
test('neither callback fires when not provided', function () {
|
83
92
|
var onClose = jest.fn();
|
84
93
|
getComponent({
|
@@ -137,4 +146,39 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
137
146
|
});
|
138
147
|
|
139
148
|
expect(focusFunction).toHaveBeenCalled();
|
149
|
+
});
|
150
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
151
|
+
var onClose = jest.fn();
|
152
|
+
var focusFunction = jest.fn();
|
153
|
+
var state = {
|
154
|
+
close: onClose
|
155
|
+
};
|
156
|
+
var triggerRef = {
|
157
|
+
current: {
|
158
|
+
focus: focusFunction
|
159
|
+
}
|
160
|
+
};
|
161
|
+
getComponent({
|
162
|
+
state: state,
|
163
|
+
children: (0, _react2.jsx)("div", null, "Test"),
|
164
|
+
triggerRef: triggerRef
|
165
|
+
});
|
166
|
+
|
167
|
+
var overlayPanel = _testWrapper.screen.getByTestId(testId);
|
168
|
+
|
169
|
+
_testWrapper.fireEvent.keyDown(overlayPanel, {
|
170
|
+
key: 'KeyA',
|
171
|
+
code: 'KeyA',
|
172
|
+
keyCode: 65,
|
173
|
+
charCode: 65
|
174
|
+
});
|
175
|
+
|
176
|
+
_testWrapper.fireEvent.keyUp(overlayPanel, {
|
177
|
+
key: 'KeyA',
|
178
|
+
code: 'KeyA',
|
179
|
+
keyCode: 65,
|
180
|
+
charCode: 65
|
181
|
+
});
|
182
|
+
|
183
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
140
184
|
});
|
@@ -10,7 +10,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
10
10
|
value: true
|
11
11
|
});
|
12
12
|
|
13
|
-
exports.MaxLength = exports.WithoutStatusIndicator = exports.WithHelpHint = exports.Warning = exports.Success = exports.Error = exports.DynamicRequired = exports.Required = exports.ReadOnly = exports.Disabled = exports.Password = exports.Controlled = exports.LeftLabel = exports.FloatLabel = exports.SmallVariant = exports.Default = exports["default"] = void 0;
|
13
|
+
exports.WithSlots = exports.MaxLength = exports.WithoutStatusIndicator = exports.WithHelpHint = exports.Warning = exports.Success = exports.Error = exports.DynamicRequired = exports.Required = exports.ReadOnly = exports.Disabled = exports.Password = exports.Controlled = exports.LeftLabel = exports.FloatLabel = exports.SmallVariant = exports.Default = exports["default"] = void 0;
|
14
14
|
|
15
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
16
16
|
|
@@ -32,6 +32,10 @@ var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/s
|
|
32
32
|
|
33
33
|
var _Box = _interopRequireDefault(require("../Box"));
|
34
34
|
|
35
|
+
var _useCopyToClipboard = _interopRequireDefault(require("../../hooks/useCopyToClipboard"));
|
36
|
+
|
37
|
+
var _CopyButton = _interopRequireDefault(require("../CopyText/CopyButton"));
|
38
|
+
|
35
39
|
var _react2 = require("@emotion/react");
|
36
40
|
|
37
41
|
var _default = {
|
@@ -259,4 +263,77 @@ var MaxLength = function MaxLength() {
|
|
259
263
|
});
|
260
264
|
};
|
261
265
|
|
262
|
-
exports.MaxLength = MaxLength;
|
266
|
+
exports.MaxLength = MaxLength;
|
267
|
+
|
268
|
+
var WithSlots = function WithSlots() {
|
269
|
+
var _useState5 = (0, _react.useState)("[{ 'type': 'work', 'streetAddress': 'San Antonio MI 47096' },{ 'type': 'home', 'streetAddress': 'Santa Rosa MN 98804' }]"),
|
270
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
271
|
+
addressesValue = _useState6[0],
|
272
|
+
setAddressesValue = _useState6[1];
|
273
|
+
|
274
|
+
var _useState7 = (0, _react.useState)("[{ 'status': 'inactive', 'subject': 'example@pingidentity.com' },{ 'status': 'active', 'subject': 'john@pingidentity.com' }]"),
|
275
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
276
|
+
jsonValue = _useState8[0],
|
277
|
+
setJsonValue = _useState8[1];
|
278
|
+
|
279
|
+
var copyAddressesToClipboard = (0, _useCopyToClipboard["default"])(addressesValue);
|
280
|
+
var copyJsonToClipboard = (0, _useCopyToClipboard["default"])(jsonValue);
|
281
|
+
var buttonSx = {
|
282
|
+
position: 'absolute',
|
283
|
+
right: 0,
|
284
|
+
top: '5px'
|
285
|
+
};
|
286
|
+
var containerSx = {
|
287
|
+
sx: {
|
288
|
+
'& input': {
|
289
|
+
paddingRight: '40px'
|
290
|
+
}
|
291
|
+
}
|
292
|
+
};
|
293
|
+
return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_["default"], {
|
294
|
+
label: "Multiple Addresses",
|
295
|
+
labelMode: "float",
|
296
|
+
onChange: function onChange(e) {
|
297
|
+
return setAddressesValue(e.target.value);
|
298
|
+
},
|
299
|
+
value: addressesValue,
|
300
|
+
containerProps: containerSx,
|
301
|
+
slots: {
|
302
|
+
inContainer: (0, _react2.jsx)(_CopyButton["default"], {
|
303
|
+
onPress: copyAddressesToClipboard,
|
304
|
+
sx: buttonSx,
|
305
|
+
iconProps: {
|
306
|
+
sx: {
|
307
|
+
path: {
|
308
|
+
fill: 'active'
|
309
|
+
}
|
310
|
+
}
|
311
|
+
}
|
312
|
+
})
|
313
|
+
},
|
314
|
+
mb: 30
|
315
|
+
}), (0, _react2.jsx)(_["default"], {
|
316
|
+
label: "Example JSON",
|
317
|
+
labelMode: "float",
|
318
|
+
onChange: function onChange(e) {
|
319
|
+
return setJsonValue(e.target.value);
|
320
|
+
},
|
321
|
+
value: jsonValue,
|
322
|
+
containerProps: containerSx,
|
323
|
+
slots: {
|
324
|
+
inContainer: (0, _react2.jsx)(_CopyButton["default"], {
|
325
|
+
onPress: copyJsonToClipboard,
|
326
|
+
sx: buttonSx,
|
327
|
+
iconProps: {
|
328
|
+
sx: {
|
329
|
+
path: {
|
330
|
+
fill: 'active'
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
})
|
335
|
+
}
|
336
|
+
}));
|
337
|
+
};
|
338
|
+
|
339
|
+
exports.WithSlots = WithSlots;
|
@@ -17,8 +17,9 @@ var _react = require("react");
|
|
17
17
|
* e.g. "\`Component\` requires an aria-label."
|
18
18
|
*/
|
19
19
|
var useAriaLabelWarning = function useAriaLabelWarning(component, ariaLabel) {
|
20
|
+
var condition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
20
21
|
(0, _react.useEffect)(function () {
|
21
|
-
if (process.env.NODE_ENV === 'development' && !ariaLabel) {
|
22
|
+
if (process.env.NODE_ENV === 'development' && condition && !ariaLabel) {
|
22
23
|
// eslint-disable-next-line no-console
|
23
24
|
console.warn("".concat(component, " requires an aria-label"), '\n', '\n', 'NOTE: This is a development-only warning and will not display in production.');
|
24
25
|
}
|
@@ -317,6 +317,11 @@ var helpHint = _objectSpread(_objectSpread({}, iconButton), {}, {
|
|
317
317
|
ml: '5px',
|
318
318
|
maxWidth: '13px',
|
319
319
|
maxHeight: '14px',
|
320
|
+
borderRadius: '5.5px',
|
321
|
+
'svg': {
|
322
|
+
'height': '100%',
|
323
|
+
mb: 0.75
|
324
|
+
},
|
320
325
|
'path': {
|
321
326
|
fill: 'neutral.20'
|
322
327
|
},
|
@@ -376,7 +381,7 @@ var chipDeleteButton = {
|
|
376
381
|
borderRadius: '50%',
|
377
382
|
cursor: 'pointer',
|
378
383
|
height: 14,
|
379
|
-
|
384
|
+
mx: '3px !important',
|
380
385
|
p: 0,
|
381
386
|
width: 14,
|
382
387
|
'&.is-focused, &.is-hovered': {
|
@@ -556,6 +561,75 @@ var tooltipInline = _objectSpread(_objectSpread({}, text), {}, {
|
|
556
561
|
}
|
557
562
|
});
|
558
563
|
|
564
|
+
var defaultVariant = _objectSpread(_objectSpread({}, base), {}, {
|
565
|
+
bg: 'white',
|
566
|
+
border: '1px solid',
|
567
|
+
borderColor: 'active',
|
568
|
+
'&.is-hovered': _objectSpread({}, defaultHover),
|
569
|
+
'&.is-pressed': _objectSpread({}, defaultActive),
|
570
|
+
'&.is-focused': _objectSpread({}, defaultFocus)
|
571
|
+
});
|
572
|
+
|
573
|
+
var filter = _objectSpread(_objectSpread({}, defaultVariant), {}, {
|
574
|
+
px: 'sm',
|
575
|
+
borderColor: 'neutral.80',
|
576
|
+
height: 40,
|
577
|
+
color: 'active',
|
578
|
+
display: 'flex'
|
579
|
+
});
|
580
|
+
|
581
|
+
var colorBlock = {
|
582
|
+
bg: 'neutral.95',
|
583
|
+
border: '1px solid',
|
584
|
+
borderColor: 'neutral.90',
|
585
|
+
borderRadius: 10,
|
586
|
+
outline: 'none',
|
587
|
+
cursor: 'pointer',
|
588
|
+
width: 150,
|
589
|
+
minHeight: 40,
|
590
|
+
p: '5px 15px',
|
591
|
+
display: 'flex',
|
592
|
+
justifyContent: 'space-between',
|
593
|
+
alignItems: 'center',
|
594
|
+
'&.is-hovered': {
|
595
|
+
bg: 'neutral.80'
|
596
|
+
},
|
597
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
598
|
+
'&.is-pressed': {
|
599
|
+
bg: 'neutral.60',
|
600
|
+
borderColor: 'neutral.60'
|
601
|
+
},
|
602
|
+
'& span': {
|
603
|
+
color: 'text.primary',
|
604
|
+
textAlign: 'left'
|
605
|
+
},
|
606
|
+
'&>div': {
|
607
|
+
alignItems: 'baseline'
|
608
|
+
},
|
609
|
+
'&>svg': {
|
610
|
+
color: 'text.secondary',
|
611
|
+
fill: 'text.secondary'
|
612
|
+
},
|
613
|
+
'&.is-configured': {
|
614
|
+
bg: 'active',
|
615
|
+
borderColor: 'active',
|
616
|
+
'& span': {
|
617
|
+
color: 'white'
|
618
|
+
},
|
619
|
+
'&>svg': {
|
620
|
+
color: 'white',
|
621
|
+
fill: 'white'
|
622
|
+
}
|
623
|
+
},
|
624
|
+
'&.is-configured.is-hovered': {
|
625
|
+
bg: 'accent.40',
|
626
|
+
borderColor: 'accent.40'
|
627
|
+
},
|
628
|
+
'&.is-configured.is-pressed': {
|
629
|
+
bg: 'accent.20',
|
630
|
+
borderColor: 'accent.20'
|
631
|
+
}
|
632
|
+
};
|
559
633
|
var _default = {
|
560
634
|
accordionHeader: accordionHeader,
|
561
635
|
chipDeleteButton: chipDeleteButton,
|
@@ -576,6 +650,7 @@ var _default = {
|
|
576
650
|
environmentBreadcrumb: environmentBreadcrumb,
|
577
651
|
expandableRow: expandableRow,
|
578
652
|
fileInputField: fileInputField,
|
653
|
+
filter: filter,
|
579
654
|
iconButton: iconButton,
|
580
655
|
imageUpload: imageUpload,
|
581
656
|
inline: inline,
|
@@ -595,6 +670,7 @@ var _default = {
|
|
595
670
|
invertedSquare: invertedSquare,
|
596
671
|
tooltipChip: tooltipChip,
|
597
672
|
tooltipIconButton: tooltipIconButton,
|
598
|
-
tooltipInline: tooltipInline
|
673
|
+
tooltipInline: tooltipInline,
|
674
|
+
colorBlock: colorBlock
|
599
675
|
};
|
600
676
|
exports["default"] = _default;
|
@@ -178,6 +178,20 @@ var text = {
|
|
178
178
|
color: 'accent.30',
|
179
179
|
fontFamily: 'standard'
|
180
180
|
}),
|
181
|
+
buttonTitle: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
182
|
+
fontSize: 'xs',
|
183
|
+
fontWeight: 0,
|
184
|
+
color: 'text.primary',
|
185
|
+
fontFamily: 'standard',
|
186
|
+
lineHeight: '13px'
|
187
|
+
}),
|
188
|
+
buttonSubtitle: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
189
|
+
fontSize: 'sm',
|
190
|
+
fontWeight: 3,
|
191
|
+
color: 'text.primary',
|
192
|
+
fontFamily: 'standard',
|
193
|
+
lineHeight: '16px'
|
194
|
+
}),
|
181
195
|
capsLabel: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
182
196
|
color: 'text.secondary',
|
183
197
|
textTransform: 'uppercase',
|
@@ -21,7 +21,7 @@ import { useButton } from '@react-aria/button';
|
|
21
21
|
import { useHover } from '@react-aria/interactions';
|
22
22
|
import { useFocusRing } from '@react-aria/focus';
|
23
23
|
import { mergeProps } from '@react-aria/utils';
|
24
|
-
import { useStatusClasses, usePropWarning } from '../../hooks';
|
24
|
+
import { useStatusClasses, usePropWarning, useAriaLabelWarning } from '../../hooks';
|
25
25
|
import Loader from '../Loader';
|
26
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
27
|
var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -37,7 +37,8 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
37
37
|
onPressChange = props.onPressChange,
|
38
38
|
onPressUp = props.onPressUp,
|
39
39
|
children = props.children,
|
40
|
-
|
40
|
+
variant = props.variant,
|
41
|
+
others = _objectWithoutProperties(props, ["className", "isDisabled", "isLoading", "onHoverStart", "onHoverChange", "onHoverEnd", "onPress", "onPressStart", "onPressEnd", "onPressChange", "onPressUp", "children", "variant"]);
|
41
42
|
|
42
43
|
var buttonRef = useRef();
|
43
44
|
usePropWarning(props, 'disabled', 'isDisabled');
|
@@ -70,6 +71,7 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
71
|
classNames = _useStatusClasses.classNames;
|
71
72
|
|
72
73
|
var ariaLabel = props['aria-label'];
|
74
|
+
useAriaLabelWarning('Button', ariaLabel, variant === 'filter');
|
73
75
|
return ___EmotionJSX(ThemeUIButton, _extends({
|
74
76
|
"aria-label": ariaLabel,
|
75
77
|
ref: buttonRef,
|
@@ -80,7 +82,8 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
80
82
|
display: 'flex',
|
81
83
|
justifyContent: 'center',
|
82
84
|
alignItems: 'center'
|
83
|
-
}
|
85
|
+
},
|
86
|
+
variant: variant
|
84
87
|
}, others, mergeProps(hoverProps, focusProps, buttonProps)), isLoading ? ___EmotionJSX("span", {
|
85
88
|
style: {
|
86
89
|
visibility: 'hidden'
|
@@ -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) {
|
@@ -74,4 +82,44 @@ export var InlineButton = function InlineButton() {
|
|
74
82
|
mb: "sm",
|
75
83
|
variant: "inline"
|
76
84
|
}, "Inline");
|
85
|
+
};
|
86
|
+
export var ColorBlockButton = function ColorBlockButton(args) {
|
87
|
+
// Change `isConfigured` property in storybook controls
|
88
|
+
var isConfigured = args.isConfigured,
|
89
|
+
props = _objectWithoutProperties(args, ["isConfigured"]);
|
90
|
+
|
91
|
+
return ___EmotionJSX(Button, _extends({}, props, {
|
92
|
+
variant: "colorBlock",
|
93
|
+
className: isConfigured ? 'is-configured' : ''
|
94
|
+
}), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|
95
|
+
variant: "buttonTitle"
|
96
|
+
}, "Title"), ___EmotionJSX(Text, {
|
97
|
+
variant: "buttonSubtitle"
|
98
|
+
}, "Info")), ___EmotionJSX(Icon, {
|
99
|
+
icon: CreateIcon
|
100
|
+
}));
|
101
|
+
};
|
102
|
+
ColorBlockButton.story = {
|
103
|
+
argTypes: {
|
104
|
+
isConfigured: {
|
105
|
+
control: {
|
106
|
+
type: 'boolean'
|
107
|
+
},
|
108
|
+
defaultValue: false
|
109
|
+
}
|
110
|
+
}
|
111
|
+
};
|
112
|
+
export var FilterButton = function FilterButton() {
|
113
|
+
return ___EmotionJSX(Box, {
|
114
|
+
p: "xx",
|
115
|
+
isRow: true,
|
116
|
+
gap: "md"
|
117
|
+
}, ___EmotionJSX(SearchField, {
|
118
|
+
"aria-label": "search items"
|
119
|
+
}), ___EmotionJSX(Button, {
|
120
|
+
variant: "filter",
|
121
|
+
"aria-label": "filter button"
|
122
|
+
}, ___EmotionJSX(Icon, {
|
123
|
+
icon: FilterIcon
|
124
|
+
})));
|
77
125
|
};
|
@@ -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',
|