@pingux/astro 1.0.1 → 1.1.0-alpha.3
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 +49 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +7 -0
- package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +25 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +44 -0
- package/lib/cjs/components/IconButton/IconButton.stories.js +8 -17
- package/lib/cjs/components/ListView/ListView.stories.js +580 -39
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +1 -1
- package/lib/cjs/components/TooltipTrigger/TooltipTrigger.stories.js +45 -2
- package/lib/cjs/styles/variants/boxes.js +2 -1
- package/lib/cjs/styles/variants/buttons.js +46 -1
- package/lib/components/ComboBoxField/ComboBoxField.js +7 -0
- package/lib/components/ComboBoxField/ComboBoxField.stories.js +21 -0
- package/lib/components/ComboBoxField/ComboBoxField.test.js +35 -0
- package/lib/components/IconButton/IconButton.stories.js +7 -13
- package/lib/components/ListView/ListView.stories.js +577 -39
- package/lib/components/MultivaluesField/MultivaluesField.js +1 -1
- package/lib/components/TooltipTrigger/TooltipTrigger.stories.js +33 -1
- package/lib/styles/variants/boxes.js +1 -1
- package/lib/styles/variants/buttons.js +45 -1
- package/package.json +1 -1
@@ -8,16 +8,20 @@ _Object$defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
9
9
|
});
|
10
10
|
|
11
|
-
exports.Disabled = exports.isOpen = exports.withDelayProp = exports.withDirectionProp = exports.withAlignProp = exports.Default = exports["default"] = void 0;
|
11
|
+
exports.TextWithTooltip = exports.ChipWithTooltip = exports.IconWithTooltip = exports.Disabled = exports.isOpen = exports.withDelayProp = exports.withDirectionProp = exports.withAlignProp = exports.Default = exports["default"] = void 0;
|
12
12
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
14
14
|
|
15
15
|
var _EarthIcon = _interopRequireDefault(require("mdi-react/EarthIcon"));
|
16
16
|
|
17
|
+
var _PersonIcon = _interopRequireDefault(require("mdi-react/PersonIcon"));
|
18
|
+
|
17
19
|
var _index = require("../../index");
|
18
20
|
|
19
21
|
var _IconButton = _interopRequireDefault(require("../IconButton"));
|
20
22
|
|
23
|
+
var _Text = _interopRequireDefault(require("../Text"));
|
24
|
+
|
21
25
|
var _react2 = require("@emotion/react");
|
22
26
|
|
23
27
|
var _default = {
|
@@ -80,4 +84,43 @@ Disabled.parameters = {
|
|
80
84
|
story: 'The tooltip can be disabled without disabling the button press events.'
|
81
85
|
}
|
82
86
|
}
|
83
|
-
};
|
87
|
+
};
|
88
|
+
|
89
|
+
var IconWithTooltip = function IconWithTooltip() {
|
90
|
+
return (0, _react2.jsx)(_index.Box, {
|
91
|
+
pl: 50
|
92
|
+
}, (0, _react2.jsx)(_index.TooltipTrigger, null, (0, _react2.jsx)(_IconButton["default"], {
|
93
|
+
variant: "tooltipIconButton"
|
94
|
+
}, (0, _react2.jsx)(_index.Icon, {
|
95
|
+
icon: _PersonIcon["default"]
|
96
|
+
})), (0, _react2.jsx)(_index.Tooltip, null, "Useful tooltip")));
|
97
|
+
};
|
98
|
+
|
99
|
+
exports.IconWithTooltip = IconWithTooltip;
|
100
|
+
|
101
|
+
var ChipWithTooltip = function ChipWithTooltip() {
|
102
|
+
return (0, _react2.jsx)(_index.Box, {
|
103
|
+
pl: 50
|
104
|
+
}, (0, _react2.jsx)(_index.TooltipTrigger, null, (0, _react2.jsx)(_index.Button, {
|
105
|
+
variant: "tooltipChip",
|
106
|
+
bg: "neutral.10"
|
107
|
+
}, (0, _react2.jsx)(_Text["default"], {
|
108
|
+
variant: "label",
|
109
|
+
sx: {
|
110
|
+
textTransform: 'uppercase'
|
111
|
+
},
|
112
|
+
color: "white"
|
113
|
+
}, "Some text")), (0, _react2.jsx)(_index.Tooltip, null, "Useful tooltip")));
|
114
|
+
};
|
115
|
+
|
116
|
+
exports.ChipWithTooltip = ChipWithTooltip;
|
117
|
+
|
118
|
+
var TextWithTooltip = function TextWithTooltip() {
|
119
|
+
return (0, _react2.jsx)(_index.Box, {
|
120
|
+
pl: 50
|
121
|
+
}, (0, _react2.jsx)(_index.TooltipTrigger, null, (0, _react2.jsx)(_index.Button, {
|
122
|
+
variant: "tooltipInline"
|
123
|
+
}, "Some text"), (0, _react2.jsx)(_index.Tooltip, null, "Useful tooltip")));
|
124
|
+
};
|
125
|
+
|
126
|
+
exports.TextWithTooltip = TextWithTooltip;
|
@@ -8,7 +8,7 @@ _Object$defineProperty2(exports, "__esModule", {
|
|
8
8
|
value: true
|
9
9
|
});
|
10
10
|
|
11
|
-
exports["default"] = void 0;
|
11
|
+
exports["default"] = exports.chip = void 0;
|
12
12
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
14
14
|
|
@@ -131,6 +131,7 @@ var chip = {
|
|
131
131
|
}
|
132
132
|
}
|
133
133
|
};
|
134
|
+
exports.chip = chip;
|
134
135
|
var inputInContainerSlot = {
|
135
136
|
position: 'absolute',
|
136
137
|
bg: 'transparent',
|
@@ -32,6 +32,8 @@ var _text = require("./text");
|
|
32
32
|
|
33
33
|
var _colors = require("../colors");
|
34
34
|
|
35
|
+
var _boxes = require("./boxes");
|
36
|
+
|
35
37
|
function ownKeys(object, enumerableOnly) { var keys = (0, _keys["default"])(object); if (_getOwnPropertySymbols["default"]) { var symbols = (0, _getOwnPropertySymbols["default"])(object); if (enumerableOnly) symbols = (0, _filter["default"])(symbols).call(symbols, function (sym) { return (0, _getOwnPropertyDescriptor["default"])(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
36
38
|
|
37
39
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; (0, _forEach["default"])(_context = ownKeys(Object(source), true)).call(_context, function (key) { (0, _defineProperty3["default"])(target, key, source[key]); }); } else if (_getOwnPropertyDescriptors["default"]) { (0, _defineProperties["default"])(target, (0, _getOwnPropertyDescriptors["default"])(source)); } else { var _context2; (0, _forEach["default"])(_context2 = ownKeys(Object(source))).call(_context2, function (key) { (0, _defineProperty2["default"])(target, key, (0, _getOwnPropertyDescriptor["default"])(source, key)); }); } } return target; }
|
@@ -102,6 +104,10 @@ var iconButton = {
|
|
102
104
|
}
|
103
105
|
};
|
104
106
|
|
107
|
+
var square = _objectSpread(_objectSpread({}, iconButton), {}, {
|
108
|
+
borderRadius: '2px'
|
109
|
+
});
|
110
|
+
|
105
111
|
var modalCloseButton = _objectSpread(_objectSpread({}, iconButton), {}, {
|
106
112
|
position: 'absolute',
|
107
113
|
top: 14,
|
@@ -239,6 +245,10 @@ var inverted = _objectSpread(_objectSpread({}, iconButton), {}, {
|
|
239
245
|
}
|
240
246
|
});
|
241
247
|
|
248
|
+
var invertedSquare = _objectSpread(_objectSpread({}, inverted), {}, {
|
249
|
+
borderRadius: '2px'
|
250
|
+
});
|
251
|
+
|
242
252
|
var applicationPortal = _objectSpread(_objectSpread({}, iconButton), {}, {
|
243
253
|
background: 'transparent',
|
244
254
|
'&.is-focused': _objectSpread({}, defaultFocus),
|
@@ -467,6 +477,36 @@ var fileInputField = {
|
|
467
477
|
boxShadow: 'focus'
|
468
478
|
}
|
469
479
|
};
|
480
|
+
|
481
|
+
var tooltipChip = _objectSpread(_objectSpread({}, _boxes.chip), {}, {
|
482
|
+
cursor: 'default',
|
483
|
+
'&.is-hovered, &.is-pressed': {
|
484
|
+
cursor: 'default',
|
485
|
+
outline: 'none'
|
486
|
+
}
|
487
|
+
});
|
488
|
+
|
489
|
+
var tooltipIconButton = _objectSpread(_objectSpread({}, iconButton), {}, {
|
490
|
+
cursor: 'default',
|
491
|
+
'&.is-hovered, &.is-pressed': {
|
492
|
+
backgroundColor: 'inherit',
|
493
|
+
cursor: 'default',
|
494
|
+
path: {
|
495
|
+
fill: 'neutral.20'
|
496
|
+
}
|
497
|
+
}
|
498
|
+
});
|
499
|
+
|
500
|
+
var tooltipInline = _objectSpread(_objectSpread({}, text), {}, {
|
501
|
+
cursor: 'default',
|
502
|
+
alignSelf: 'flex-start',
|
503
|
+
'&.is-hovered, &.is-pressed': {
|
504
|
+
backgroundColor: 'inherit',
|
505
|
+
cursor: 'default',
|
506
|
+
textDecoration: 'inherit'
|
507
|
+
}
|
508
|
+
});
|
509
|
+
|
470
510
|
var _default = {
|
471
511
|
accordionHeader: accordionHeader,
|
472
512
|
chipDeleteButton: chipDeleteButton,
|
@@ -499,6 +539,11 @@ var _default = {
|
|
499
539
|
helpHint: helpHint,
|
500
540
|
modalCloseButton: modalCloseButton,
|
501
541
|
applicationPortalPinned: applicationPortalPinned,
|
502
|
-
applicationPortal: applicationPortal
|
542
|
+
applicationPortal: applicationPortal,
|
543
|
+
square: square,
|
544
|
+
invertedSquare: invertedSquare,
|
545
|
+
tooltipChip: tooltipChip,
|
546
|
+
tooltipIconButton: tooltipIconButton,
|
547
|
+
tooltipInline: tooltipInline
|
503
548
|
};
|
504
549
|
exports["default"] = _default;
|
@@ -116,6 +116,12 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
116
116
|
useImperativeHandle(ref, function () {
|
117
117
|
return inputRef.current;
|
118
118
|
});
|
119
|
+
/* istanbul ignore next */
|
120
|
+
|
121
|
+
var onSelectionChangeHandler = function onSelectionChangeHandler(key) {
|
122
|
+
var newVal = key || selectedKey || '';
|
123
|
+
if (onSelectionChange) onSelectionChange(newVal);
|
124
|
+
};
|
119
125
|
|
120
126
|
var _useFilter = useFilter({
|
121
127
|
sensitivity: 'base'
|
@@ -123,6 +129,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
123
129
|
contains = _useFilter.contains;
|
124
130
|
|
125
131
|
var state = useComboBoxState(_objectSpread(_objectSpread({}, comboBoxOptions), {}, {
|
132
|
+
onSelectionChange: hasCustomValue ? onSelectionChangeHandler : onSelectionChange,
|
126
133
|
defaultFilter: contains
|
127
134
|
}));
|
128
135
|
|
@@ -330,6 +330,27 @@ export var ControlledFiltering = function ControlledFiltering() {
|
|
330
330
|
}, item.name);
|
331
331
|
}));
|
332
332
|
};
|
333
|
+
export var ControlledWithCustomValue = function ControlledWithCustomValue() {
|
334
|
+
var _useState9 = useState(''),
|
335
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
336
|
+
inputValue = _useState10[0],
|
337
|
+
setInputValue = _useState10[1];
|
338
|
+
|
339
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
|
340
|
+
label: "Example label",
|
341
|
+
defaultItems: items
|
342
|
+
}, actions, {
|
343
|
+
inputValue: inputValue,
|
344
|
+
selectedKey: inputValue,
|
345
|
+
onInputChange: setInputValue,
|
346
|
+
onSelectionChange: setInputValue,
|
347
|
+
hasCustomValue: true
|
348
|
+
}), function (item) {
|
349
|
+
return ___EmotionJSX(Item, {
|
350
|
+
key: item.name
|
351
|
+
}, item.name);
|
352
|
+
}));
|
353
|
+
};
|
333
354
|
export var AllowCustomValue = function AllowCustomValue() {
|
334
355
|
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
|
335
356
|
label: "Example label",
|
@@ -639,6 +639,41 @@ test('two listbox can not be open at the same time', function () {
|
|
639
639
|
name: 'Tango'
|
640
640
|
})).toBeInTheDocument();
|
641
641
|
});
|
642
|
+
test('should handle selecting custom option', function () {
|
643
|
+
getComponent({
|
644
|
+
hasCustomValue: true
|
645
|
+
});
|
646
|
+
var input = screen.queryByRole('combobox');
|
647
|
+
expect(input).toHaveValue(''); // type something
|
648
|
+
|
649
|
+
userEvent.type(input, 'custom'); // set input value as selected
|
650
|
+
|
651
|
+
userEvent.type(input, '{enter}', {
|
652
|
+
skipClick: true
|
653
|
+
});
|
654
|
+
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
655
|
+
expect(screen.queryByRole('combobox')).toHaveValue('custom'); // blur input
|
656
|
+
|
657
|
+
userEvent.tab();
|
658
|
+
expect(input).toHaveValue('custom');
|
659
|
+
});
|
660
|
+
test('onSelectionChange works properly with custom value', function () {
|
661
|
+
var onSelectionChange = jest.fn();
|
662
|
+
getComponent({
|
663
|
+
hasCustomValue: true,
|
664
|
+
onSelectionChange: onSelectionChange,
|
665
|
+
onInputChange: onSelectionChange
|
666
|
+
});
|
667
|
+
var input = screen.queryByRole('combobox');
|
668
|
+
expect(input).toHaveValue('');
|
669
|
+
expect(onSelectionChange).not.toHaveBeenCalled(); // Should fire when input value was typed, and enter was pressed
|
670
|
+
|
671
|
+
userEvent.type(input, 'custom{enter}');
|
672
|
+
expect(onSelectionChange).toHaveBeenCalledWith('custom'); // Should fire when input is cleared
|
673
|
+
|
674
|
+
userEvent.type(input, '{selectall}{backspace}{enter}');
|
675
|
+
expect(onSelectionChange).toHaveBeenCalledWith('');
|
676
|
+
});
|
642
677
|
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
643
678
|
var _getComponent6, container, results;
|
644
679
|
|
@@ -35,29 +35,23 @@ export default {
|
|
35
35
|
isDisabled: {},
|
36
36
|
variant: {
|
37
37
|
control: {
|
38
|
-
type: '
|
39
|
-
|
38
|
+
type: 'select',
|
39
|
+
options: ['iconButton', 'inverted', 'square', 'invertedSquare']
|
40
|
+
},
|
41
|
+
defaultValue: 'iconButton'
|
40
42
|
}
|
41
43
|
}
|
42
44
|
};
|
43
45
|
export var Default = function Default(args) {
|
44
46
|
return ___EmotionJSX(IconButton, _extends({
|
45
|
-
"aria-label": "
|
47
|
+
"aria-label": "default icon button"
|
46
48
|
}, args), ___EmotionJSX(Icon, {
|
47
49
|
icon: CreateIcon
|
48
50
|
}));
|
49
51
|
};
|
50
|
-
export var Inverted = function Inverted() {
|
51
|
-
return ___EmotionJSX(IconButton, {
|
52
|
-
"aria-label": "my-label",
|
53
|
-
variant: "inverted"
|
54
|
-
}, ___EmotionJSX(Icon, {
|
55
|
-
icon: CreateIcon
|
56
|
-
}));
|
57
|
-
};
|
58
52
|
export var WithTooltip = function WithTooltip() {
|
59
53
|
return ___EmotionJSX(IconButton, {
|
60
|
-
"aria-label": "
|
54
|
+
"aria-label": "icon button with tooltip",
|
61
55
|
title: "Edit"
|
62
56
|
}, ___EmotionJSX(Icon, {
|
63
57
|
icon: CreateIcon
|
@@ -65,7 +59,7 @@ export var WithTooltip = function WithTooltip() {
|
|
65
59
|
};
|
66
60
|
export var Disabled = function Disabled() {
|
67
61
|
return ___EmotionJSX(IconButton, {
|
68
|
-
"aria-label": "
|
62
|
+
"aria-label": "disabled icon button",
|
69
63
|
isDisabled: true
|
70
64
|
}, ___EmotionJSX(Icon, {
|
71
65
|
icon: CreateIcon
|