@pingux/astro 2.8.0-alpha.0 → 2.8.0-alpha.1
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/IconButton/IconButton.js +2 -38
- package/lib/cjs/components/IconButton/IconButton.stories.js +2 -34
- package/lib/cjs/components/IconButton/iconButtonAttributes.js +100 -0
- package/lib/cjs/components/ListItem/ListItem.js +1 -0
- package/lib/cjs/components/ListView/ListView.js +0 -9
- package/lib/cjs/components/ListView/ListView.stories.js +39 -104
- package/lib/cjs/components/ListViewItem/ListViewItem.js +14 -5
- package/lib/cjs/components/ListViewItem/ListViewItem.styles.js +6 -1
- package/lib/cjs/components/Menu/Menu.js +7 -60
- package/lib/cjs/components/Menu/Menu.stories.js +2 -56
- package/lib/cjs/components/Menu/menuAttributes.js +104 -0
- package/lib/cjs/components/SwitchField/SwitchField.js +12 -54
- package/lib/cjs/components/SwitchField/SwitchField.stories.js +2 -34
- package/lib/cjs/components/SwitchField/SwitchField.test.js +4 -5
- package/lib/cjs/components/SwitchField/switchFieldAttributes.js +191 -0
- package/lib/cjs/experimental/ListViewItem/ListViewItem.js +157 -0
- package/lib/cjs/experimental/ListViewItem/ListViewItem.stories.js +136 -0
- package/lib/cjs/experimental/ListViewItem/ListViewItem.test.js +77 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemEditButton.js +34 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemEditButton.stories.js +31 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemEditButton.test.js +25 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemMenu.js +37 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemMenu.stories.js +36 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemMenu.test.js +59 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemSwitchField.js +32 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemSwitchField.stories.js +41 -0
- package/lib/cjs/experimental/ListViewItem/controls/ListViewItemSwitchField.test.js +25 -0
- package/lib/cjs/experimental/ListViewItem/listViewItemAttributes.js +81 -0
- package/lib/cjs/experimental/recipes/ListAndPanel.stories.js +359 -0
- package/lib/cjs/experimental/recipes/ScrollableListView.stories.js +104 -0
- package/lib/cjs/experimental/recipes/items.js +77 -0
- package/lib/cjs/index.js +64 -51
- package/lib/cjs/utils/docUtils/hoverProps.js +7 -2
- package/lib/components/IconButton/IconButton.js +2 -38
- package/lib/components/IconButton/IconButton.stories.js +2 -34
- package/lib/components/IconButton/iconButtonAttributes.js +91 -0
- package/lib/components/ListItem/ListItem.js +2 -1
- package/lib/components/ListView/ListView.js +0 -9
- package/lib/components/ListView/ListView.stories.js +40 -106
- package/lib/components/ListViewItem/ListViewItem.js +12 -4
- package/lib/components/ListViewItem/ListViewItem.styles.js +6 -1
- package/lib/components/Menu/Menu.js +7 -60
- package/lib/components/Menu/Menu.stories.js +2 -57
- package/lib/components/Menu/menuAttributes.js +95 -0
- package/lib/components/SwitchField/SwitchField.js +14 -55
- package/lib/components/SwitchField/SwitchField.stories.js +2 -34
- package/lib/components/SwitchField/SwitchField.test.js +4 -5
- package/lib/components/SwitchField/switchFieldAttributes.js +182 -0
- package/lib/experimental/ListViewItem/ListViewItem.js +144 -0
- package/lib/experimental/ListViewItem/ListViewItem.stories.js +122 -0
- package/lib/experimental/ListViewItem/ListViewItem.test.js +74 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemEditButton.js +25 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemEditButton.stories.js +21 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemEditButton.test.js +22 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemMenu.js +28 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemMenu.stories.js +26 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemMenu.test.js +56 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemSwitchField.js +23 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemSwitchField.stories.js +32 -0
- package/lib/experimental/ListViewItem/controls/ListViewItemSwitchField.test.js +22 -0
- package/lib/experimental/ListViewItem/listViewItemAttributes.js +72 -0
- package/lib/experimental/recipes/ListAndPanel.stories.js +342 -0
- package/lib/experimental/recipes/ScrollableListView.stories.js +89 -0
- package/lib/experimental/recipes/items.js +68 -0
- package/lib/index.js +7 -3
- package/lib/utils/docUtils/hoverProps.js +7 -2
- package/package.json +1 -1
@@ -0,0 +1,91 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
12
|
+
import CreateIcon from '@pingux/mdi-react/CreateIcon';
|
13
|
+
import PropTypes from 'prop-types';
|
14
|
+
import { descriptions as ariaDescriptions } from '../../utils/docUtils/ariaAttributes';
|
15
|
+
import { booleanArg, funcArg } from '../../utils/docUtils/docArgTypes';
|
16
|
+
var descriptions = {
|
17
|
+
icon: 'The icon to render. List of icons at https://materialdesignicons.com/',
|
18
|
+
isDisabled: 'Whether the icon is disabled.',
|
19
|
+
onPress: 'Handler that is called when the press is released over the target. (e: PressEvent) => void',
|
20
|
+
onPressChange: 'Handler that is called when the press state changes. (isPressed: boolean) => void',
|
21
|
+
onPressEnd: 'Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. (e: PressEvent) => void',
|
22
|
+
onPressStart: 'Handler that is called when a press interaction starts. (e: PressEvent) => void',
|
23
|
+
onPressUp: 'Handler that is called when a press is released over the target, regardless of whether it started on the target or not. (e: PressEvent) => void',
|
24
|
+
title: 'Content will be displayed in a tooltip on hover or focus.',
|
25
|
+
variant: 'Styling to apply to the IconButton.'
|
26
|
+
};
|
27
|
+
export var iconButtonArgTypes = {
|
28
|
+
icon: {
|
29
|
+
control: {
|
30
|
+
type: 'none'
|
31
|
+
},
|
32
|
+
defaultValue: CreateIcon,
|
33
|
+
description: descriptions.icon
|
34
|
+
},
|
35
|
+
title: {
|
36
|
+
control: {
|
37
|
+
type: 'text'
|
38
|
+
},
|
39
|
+
description: descriptions.title
|
40
|
+
},
|
41
|
+
'aria-label': {
|
42
|
+
control: {
|
43
|
+
type: 'text'
|
44
|
+
},
|
45
|
+
description: ariaDescriptions.ariaLabel
|
46
|
+
},
|
47
|
+
isDisabled: _objectSpread({
|
48
|
+
description: descriptions.isDisabled
|
49
|
+
}, booleanArg),
|
50
|
+
variant: {
|
51
|
+
control: {
|
52
|
+
type: 'select',
|
53
|
+
options: ['base', 'inverted', 'invertedSquare', 'square']
|
54
|
+
},
|
55
|
+
defaultValue: 'base',
|
56
|
+
description: descriptions.variant
|
57
|
+
},
|
58
|
+
size: {
|
59
|
+
control: {
|
60
|
+
type: 'select',
|
61
|
+
options: ['xs', 'sm', 'md']
|
62
|
+
},
|
63
|
+
defaultValue: 'sm'
|
64
|
+
},
|
65
|
+
onPress: _objectSpread({
|
66
|
+
description: descriptions.onPress
|
67
|
+
}, funcArg),
|
68
|
+
onPressStart: _objectSpread({
|
69
|
+
description: descriptions.onPressStart
|
70
|
+
}, funcArg),
|
71
|
+
onPressEnd: _objectSpread({
|
72
|
+
description: descriptions.onPressEnd
|
73
|
+
}, funcArg),
|
74
|
+
onPressChange: _objectSpread({
|
75
|
+
description: descriptions.onPressChange
|
76
|
+
}, funcArg),
|
77
|
+
onPressUp: _objectSpread({
|
78
|
+
description: descriptions.onPressUp
|
79
|
+
}, funcArg)
|
80
|
+
};
|
81
|
+
export var iconButtonPropTypes = {
|
82
|
+
variant: PropTypes.string,
|
83
|
+
'aria-label': PropTypes.string,
|
84
|
+
title: PropTypes.string,
|
85
|
+
onPress: PropTypes.func,
|
86
|
+
onPressStart: PropTypes.func,
|
87
|
+
onPressEnd: PropTypes.func,
|
88
|
+
onPressChange: PropTypes.func,
|
89
|
+
onPressUp: PropTypes.func,
|
90
|
+
isDisabled: PropTypes.bool
|
91
|
+
};
|
@@ -15,7 +15,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
15
15
|
import React, { forwardRef } from 'react';
|
16
16
|
import { useHover } from '@react-aria/interactions';
|
17
17
|
import PropTypes from 'prop-types';
|
18
|
-
import { useStatusClasses } from '../../hooks';
|
18
|
+
import { useDeprecationWarning, useStatusClasses } from '../../hooks';
|
19
19
|
import { onHoverPropTypes } from '../../utils/docUtils/hoverProps';
|
20
20
|
import Box from '../Box/Box';
|
21
21
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -34,6 +34,7 @@ var ListItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
34
34
|
onHoverStart: onHoverStart
|
35
35
|
}),
|
36
36
|
hoverProps = _useHover.hoverProps;
|
37
|
+
useDeprecationWarning('The ListItem will be depreciated in the near future, please use ListViewItem');
|
37
38
|
var _useStatusClasses = useStatusClasses(className, {
|
38
39
|
isHovered: isHovered,
|
39
40
|
isSelected: isSelected
|
@@ -53,15 +53,6 @@ export function useListLayout(state) {
|
|
53
53
|
layout.disabledKeys = state.disabledKeys;
|
54
54
|
return layout;
|
55
55
|
}
|
56
|
-
|
57
|
-
/**
|
58
|
-
* NOTE: be careful with putting focusable elements inside ListView.
|
59
|
-
* It is using a grid (useList hook) with its own event listeners under the hood.
|
60
|
-
* [react-specttrum-github-issue](https://github.com/adobe/react-spectrum/issues/2801)
|
61
|
-
* If you decided to add a focusable element inside ListView,
|
62
|
-
* you should stop bubbling of a pointerDown event and put a focus on the element.
|
63
|
-
*/
|
64
|
-
|
65
56
|
var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
66
57
|
var disabledKeys = props.disabledKeys,
|
67
58
|
_props$isHoverable = props.isHoverable,
|
@@ -15,21 +15,18 @@ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
15
15
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
16
16
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
17
17
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
18
|
-
/* eslint-disable react/prop-types */
|
19
18
|
import React from 'react';
|
20
19
|
import { Item, useAsyncList } from 'react-stately';
|
21
|
-
import CreateIcon from '@pingux/mdi-react/CreateIcon';
|
22
20
|
import FormSelectIcon from '@pingux/mdi-react/FormSelectIcon';
|
23
|
-
import MoreVertIcon from '@pingux/mdi-react/MoreVertIcon';
|
24
21
|
import { action } from '@storybook/addon-actions';
|
25
22
|
import isChromatic from 'chromatic/isChromatic';
|
26
23
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
27
|
-
import { Box,
|
24
|
+
import { Box, ListView, ListViewItem, ListViewItemMenu, ListViewItemSwitchField } from '../../index';
|
28
25
|
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
29
26
|
import ListViewReadme from './ListView.mdx';
|
30
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
31
28
|
export default {
|
32
|
-
title: '
|
29
|
+
title: 'Experimental/ListView',
|
33
30
|
component: ListView,
|
34
31
|
parameters: {
|
35
32
|
docs: {
|
@@ -534,100 +531,33 @@ var actions = {
|
|
534
531
|
onFocus: action('onFocus'),
|
535
532
|
onLoadMore: action('onLoadMore')
|
536
533
|
};
|
537
|
-
var
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
}, ___EmotionJSX(Icon, {
|
546
|
-
icon: FormSelectIcon,
|
547
|
-
mr: "sm",
|
548
|
-
color: "accent.40",
|
549
|
-
size: "md",
|
550
|
-
title: {
|
551
|
-
name: 'Form Select Icon'
|
552
|
-
}
|
553
|
-
}), ___EmotionJSX(Text, {
|
554
|
-
variant: "itemTitle",
|
555
|
-
alignSelf: "center"
|
556
|
-
}, item.name)), ___EmotionJSX(Box, {
|
557
|
-
isRow: true,
|
558
|
-
alignSelf: "center",
|
559
|
-
gap: "sm"
|
560
|
-
}, ___EmotionJSX(IconButton, {
|
561
|
-
"aria-label": "create-icon"
|
562
|
-
}, ___EmotionJSX(Icon, {
|
563
|
-
icon: CreateIcon,
|
564
|
-
size: "sm",
|
565
|
-
title: {
|
566
|
-
name: 'Create Icon'
|
567
|
-
}
|
568
|
-
})), ___EmotionJSX(IconButton, {
|
569
|
-
"aria-label": "actions-icon"
|
570
|
-
}, ___EmotionJSX(Icon, {
|
571
|
-
icon: MoreVertIcon,
|
572
|
-
size: "sm",
|
573
|
-
title: {
|
574
|
-
name: 'More Vertical Icon'
|
575
|
-
}
|
576
|
-
}))));
|
534
|
+
var Controls = function Controls() {
|
535
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(ListViewItemSwitchField, null), ___EmotionJSX(ListViewItemMenu, null, ___EmotionJSX(Item, {
|
536
|
+
key: "enable"
|
537
|
+
}, "Enable user"), ___EmotionJSX(Item, {
|
538
|
+
key: "disable"
|
539
|
+
}, "Disable user"), ___EmotionJSX(Item, {
|
540
|
+
key: "delete"
|
541
|
+
}, "Delete user")));
|
577
542
|
};
|
578
|
-
export var Default = function Default(
|
579
|
-
var args = _extends({}, (_objectDestructuringEmpty(
|
543
|
+
export var Default = function Default(_ref) {
|
544
|
+
var args = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
580
545
|
return ___EmotionJSX(ListView, _extends({}, props, args, {
|
581
546
|
items: items
|
582
547
|
}), function (item) {
|
583
548
|
return ___EmotionJSX(Item, {
|
584
|
-
key: item.name
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
}, ___EmotionJSX(Box, {
|
590
|
-
isRow: true,
|
591
|
-
mr: "auto",
|
592
|
-
alignSelf: "center"
|
593
|
-
}, ___EmotionJSX(Icon, {
|
594
|
-
icon: FormSelectIcon,
|
595
|
-
mr: "sm",
|
596
|
-
color: "accent.40",
|
597
|
-
size: "md",
|
598
|
-
title: {
|
599
|
-
name: 'Form Select Icon'
|
600
|
-
}
|
601
|
-
}), ___EmotionJSX(Text, {
|
602
|
-
variant: "itemTitle",
|
603
|
-
alignSelf: "center"
|
604
|
-
}, item.name)), ___EmotionJSX(Box, {
|
605
|
-
isRow: true,
|
606
|
-
alignSelf: "center",
|
607
|
-
gap: "sm"
|
608
|
-
}, ___EmotionJSX(IconButton, {
|
609
|
-
"aria-label": "create-icon"
|
610
|
-
}, ___EmotionJSX(Icon, {
|
611
|
-
icon: CreateIcon,
|
612
|
-
size: "sm",
|
613
|
-
title: {
|
614
|
-
name: 'Create Icon'
|
615
|
-
}
|
616
|
-
})), ___EmotionJSX(IconButton, {
|
617
|
-
"aria-label": "actions-icon",
|
618
|
-
size: "sm"
|
619
|
-
}, ___EmotionJSX(Icon, {
|
620
|
-
icon: MoreVertIcon,
|
621
|
-
size: "sm",
|
622
|
-
title: {
|
623
|
-
name: 'More Vertical Icon'
|
549
|
+
key: item.name
|
550
|
+
}, ___EmotionJSX(ListViewItem, {
|
551
|
+
data: {
|
552
|
+
text: item.name,
|
553
|
+
icon: FormSelectIcon
|
624
554
|
}
|
625
|
-
})))
|
555
|
+
}, ___EmotionJSX(Controls, null)));
|
626
556
|
});
|
627
557
|
};
|
628
558
|
export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
629
559
|
var getMockData = /*#__PURE__*/function () {
|
630
|
-
var
|
560
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(signal, cursor) {
|
631
561
|
var pageNumber;
|
632
562
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
633
563
|
while (1) {
|
@@ -659,11 +589,11 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
|
659
589
|
}, _callee);
|
660
590
|
}));
|
661
591
|
return function getMockData(_x, _x2) {
|
662
|
-
return
|
592
|
+
return _ref2.apply(this, arguments);
|
663
593
|
};
|
664
594
|
}();
|
665
595
|
var fetchApiData = /*#__PURE__*/function () {
|
666
|
-
var
|
596
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(signal, cursor, filterText) {
|
667
597
|
var res, json;
|
668
598
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
669
599
|
while (1) {
|
@@ -717,18 +647,18 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
|
717
647
|
}, _callee2, null, [[2, 14]]);
|
718
648
|
}));
|
719
649
|
return function fetchApiData(_x3, _x4, _x5) {
|
720
|
-
return
|
650
|
+
return _ref3.apply(this, arguments);
|
721
651
|
};
|
722
652
|
}();
|
723
653
|
var list = useAsyncList({
|
724
|
-
load: function load(
|
654
|
+
load: function load(_ref4) {
|
725
655
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
726
656
|
var signal, cursor, filterText;
|
727
657
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
728
658
|
while (1) {
|
729
659
|
switch (_context3.prev = _context3.next) {
|
730
660
|
case 0:
|
731
|
-
signal =
|
661
|
+
signal = _ref4.signal, cursor = _ref4.cursor, filterText = _ref4.filterText;
|
732
662
|
if (cursor) {
|
733
663
|
// eslint-disable-next-line
|
734
664
|
cursor = cursor.replace(/^http:\/\//i, "https://");
|
@@ -761,11 +691,13 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
|
761
691
|
onLoadMore: list.loadMore
|
762
692
|
}), function (item) {
|
763
693
|
return ___EmotionJSX(Item, {
|
764
|
-
key: item.name
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
694
|
+
key: item.name
|
695
|
+
}, ___EmotionJSX(ListViewItem, {
|
696
|
+
data: {
|
697
|
+
text: item.name,
|
698
|
+
icon: FormSelectIcon
|
699
|
+
}
|
700
|
+
}, ___EmotionJSX(Controls, null)));
|
769
701
|
}));
|
770
702
|
};
|
771
703
|
InfiniteLoadingList.args = {
|
@@ -778,17 +710,19 @@ InfiniteLoadingList.parameters = {
|
|
778
710
|
}
|
779
711
|
}
|
780
712
|
};
|
781
|
-
export var MultipleSelection = function MultipleSelection(
|
782
|
-
var args = _extends({}, (_objectDestructuringEmpty(
|
713
|
+
export var MultipleSelection = function MultipleSelection(_ref5) {
|
714
|
+
var args = _extends({}, (_objectDestructuringEmpty(_ref5), _ref5));
|
783
715
|
return ___EmotionJSX(ListView, _extends({}, props, args, {
|
784
716
|
items: items,
|
785
717
|
selectionMode: "multiple"
|
786
718
|
}), function (item) {
|
787
719
|
return ___EmotionJSX(Item, {
|
788
|
-
key: item.name
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
720
|
+
key: item.name
|
721
|
+
}, ___EmotionJSX(ListViewItem, {
|
722
|
+
data: {
|
723
|
+
text: item.name,
|
724
|
+
icon: FormSelectIcon
|
725
|
+
}
|
726
|
+
}, ___EmotionJSX(Controls, null)));
|
793
727
|
});
|
794
728
|
};
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
1
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
2
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
3
|
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
@@ -8,8 +7,10 @@ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/obje
|
|
8
7
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
8
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
11
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
11
12
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
14
|
import React, { useContext, useRef } from 'react';
|
14
15
|
import { mergeProps, useFocusRing } from 'react-aria';
|
15
16
|
import { useHover } from '@react-aria/interactions';
|
@@ -20,6 +21,7 @@ import Box from '../Box';
|
|
20
21
|
import { ListViewContext } from '../ListView/ListViewContext';
|
21
22
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
22
23
|
var ListViewItem = function ListViewItem(props) {
|
24
|
+
var _context;
|
23
25
|
var item = props.item,
|
24
26
|
_props$item$props = props.item.props,
|
25
27
|
listItemProps = _props$item$props.listItemProps,
|
@@ -68,6 +70,10 @@ var ListViewItem = function ListViewItem(props) {
|
|
68
70
|
hasInsetSeparator: hasInsetSeparator
|
69
71
|
}),
|
70
72
|
classNames = _useStatusClasses.classNames;
|
73
|
+
|
74
|
+
// Whether the current component should have legacy styles removed
|
75
|
+
// TODO: [Astro 3.0.0] Remove the legacy styles and update the code here.
|
76
|
+
var shouldOverRideLegacyStyles = _includesInstanceProperty(_context = _Object$keys(item.rendered.props)).call(_context, 'data');
|
71
77
|
return ___EmotionJSX(Box, _extends({
|
72
78
|
isDisabled: isDisabled,
|
73
79
|
isRow: true,
|
@@ -77,8 +83,10 @@ var ListViewItem = function ListViewItem(props) {
|
|
77
83
|
outline: 'none'
|
78
84
|
}
|
79
85
|
}), ___EmotionJSX(Box, _extends({
|
80
|
-
as: "div"
|
81
|
-
variant
|
86
|
+
as: "div"
|
87
|
+
// Apply appropriate variant dependant on whether a legacy list item is used
|
88
|
+
,
|
89
|
+
variant: shouldOverRideLegacyStyles ? 'listViewItem.styledListItem' : 'listViewItem.container'
|
82
90
|
}, gridCellProps, {
|
83
91
|
isFocused: isDisabled ? false : isFocusVisible,
|
84
92
|
isDisabled: isDisabled,
|
@@ -35,6 +35,10 @@ var container = {
|
|
35
35
|
borderBottomColor: 'line.light'
|
36
36
|
}
|
37
37
|
};
|
38
|
+
var styledListItem = _objectSpread(_objectSpread({}, container), {}, {
|
39
|
+
padding: 0,
|
40
|
+
minHeight: 0
|
41
|
+
});
|
38
42
|
var linkedViewContainer = _objectSpread(_objectSpread({}, container), {}, {
|
39
43
|
minHeight: '75px',
|
40
44
|
height: '76px',
|
@@ -66,5 +70,6 @@ var linkedViewContainer = _objectSpread(_objectSpread({}, container), {}, {
|
|
66
70
|
});
|
67
71
|
export default {
|
68
72
|
container: container,
|
69
|
-
linkedViewContainer: linkedViewContainer
|
73
|
+
linkedViewContainer: linkedViewContainer,
|
74
|
+
styledListItem: styledListItem
|
70
75
|
};
|
@@ -9,7 +9,7 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["isDisabled", "isNotFocusedOnHover", "onAction", "onHoverChange", "onHoverEnd", "onHoverStart", "onSelectionChange"];
|
12
|
+
var _excluded = ["isDisabled", "isNotFocusedOnHover", "onAction", "onHoverChange", "onHoverEnd", "onHoverStart", "onSelectionChange", "selectionMode"];
|
13
13
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
14
14
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
15
15
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -19,23 +19,25 @@ import { mergeProps, useFocusRing, useMenu } from 'react-aria';
|
|
19
19
|
import { useTreeState } from 'react-stately';
|
20
20
|
import { useHover } from '@react-aria/interactions';
|
21
21
|
import { useSyncRef } from '@react-aria/utils';
|
22
|
-
import PropTypes from 'prop-types';
|
23
22
|
import { MenuContext } from '../../context/MenuContext';
|
24
23
|
import { usePropWarning } from '../../hooks';
|
25
24
|
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
26
|
-
import { onHoverPropTypes } from '../../utils/docUtils/hoverProps';
|
27
25
|
import Box from '../Box';
|
28
26
|
import MenuItem from '../MenuItem';
|
27
|
+
import { menuPropTypes } from './menuAttributes';
|
29
28
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
30
29
|
var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
31
30
|
var _context;
|
32
|
-
var isDisabled = props.isDisabled,
|
31
|
+
var _props$isDisabled = props.isDisabled,
|
32
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
33
33
|
isNotFocusedOnHover = props.isNotFocusedOnHover,
|
34
34
|
onAction = props.onAction,
|
35
35
|
onHoverChange = props.onHoverChange,
|
36
36
|
onHoverEnd = props.onHoverEnd,
|
37
37
|
onHoverStart = props.onHoverStart,
|
38
38
|
onSelectionChange = props.onSelectionChange,
|
39
|
+
_props$selectionMode = props.selectionMode,
|
40
|
+
selectionMode = _props$selectionMode === void 0 ? 'none' : _props$selectionMode,
|
39
41
|
others = _objectWithoutProperties(props, _excluded);
|
40
42
|
var contextProps = useContext(MenuContext);
|
41
43
|
var completeProps = _objectSpread({}, mergeProps(contextProps, props));
|
@@ -79,61 +81,6 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
79
81
|
});
|
80
82
|
}));
|
81
83
|
});
|
82
|
-
Menu.propTypes =
|
83
|
-
/** The type of selection that is allowed. */
|
84
|
-
selectionMode: PropTypes.oneOf(['none', 'single', 'multiple']),
|
85
|
-
/**
|
86
|
-
* The item keys that are disabled. These items cannot be selected, focused, or otherwise
|
87
|
-
* interacted with.
|
88
|
-
*/
|
89
|
-
disabledKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])),
|
90
|
-
/**
|
91
|
-
* The initial selected keys in the collection (uncontrolled).
|
92
|
-
*
|
93
|
-
* `defaultSelectedKeys="all"` can be used to select every key.
|
94
|
-
*/
|
95
|
-
defaultSelectedKeys: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
96
|
-
/**
|
97
|
-
* The currently selected keys in the collection (controlled).
|
98
|
-
*
|
99
|
-
* `selectedKeys="all"` can be used to select every key.
|
100
|
-
*/
|
101
|
-
selectedKeys: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
102
|
-
/** Whether the item is disabled. */
|
103
|
-
isDisabled: PropTypes.bool,
|
104
|
-
/** Whether the menu item is selected. */
|
105
|
-
isSelected: PropTypes.bool,
|
106
|
-
/**
|
107
|
-
* Whether menu item should receive focus state on hover.
|
108
|
-
*/
|
109
|
-
isNotFocusedOnHover: PropTypes.bool,
|
110
|
-
/**
|
111
|
-
* Handler that is called when an item is selected.
|
112
|
-
*
|
113
|
-
* `(key: Key) => void`
|
114
|
-
*/
|
115
|
-
onAction: PropTypes.func,
|
116
|
-
/**
|
117
|
-
* Handler that is called when the selection changes. Does not fire when `selectionMode="none"`.
|
118
|
-
*
|
119
|
-
* `(keys: Selection) => any`
|
120
|
-
*/
|
121
|
-
onSelectionChange: PropTypes.func,
|
122
|
-
/** A screen reader only label for the menu item. */
|
123
|
-
'aria-label': PropTypes.string,
|
124
|
-
/** Identifies the element (or elements) that labels the current element. */
|
125
|
-
'aria-labelledby': PropTypes.string,
|
126
|
-
/** Identifies the element (or elements) that describes the object. */
|
127
|
-
'aria-describedby': PropTypes.string,
|
128
|
-
/**
|
129
|
-
* Identifies the element (or elements) that provide a detailed,
|
130
|
-
* extended description for the object.
|
131
|
-
*/
|
132
|
-
'aria-details': PropTypes.string
|
133
|
-
}, onHoverPropTypes);
|
134
|
-
Menu.defaultProps = {
|
135
|
-
selectionMode: 'none',
|
136
|
-
isDisabled: false
|
137
|
-
};
|
84
|
+
Menu.propTypes = menuPropTypes;
|
138
85
|
Menu.displayName = 'Menu';
|
139
86
|
export default Menu;
|
@@ -1,24 +1,13 @@
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
1
|
import _objectDestructuringEmpty from "@babel/runtime-corejs3/helpers/esm/objectDestructuringEmpty";
|
10
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
3
|
import React from 'react';
|
15
4
|
import { Item } from 'react-stately';
|
16
5
|
import { withDesign } from 'storybook-addon-designs';
|
17
6
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
18
7
|
import { Menu, Text } from '../../index';
|
19
8
|
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.js';
|
20
|
-
import { onHoverArgTypes } from '../../utils/docUtils/hoverProps';
|
21
9
|
import MenuReadme from './Menu.mdx';
|
10
|
+
import { menuArgTypes } from './menuAttributes';
|
22
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
23
12
|
export default {
|
24
13
|
title: 'Components/Menu',
|
@@ -40,51 +29,7 @@ export default {
|
|
40
29
|
type: 'figma'
|
41
30
|
}
|
42
31
|
},
|
43
|
-
argTypes:
|
44
|
-
selectionMode: {},
|
45
|
-
isDisabled: {},
|
46
|
-
isNotFocusedOnHover: {},
|
47
|
-
'aria-label': {
|
48
|
-
control: {
|
49
|
-
type: 'text'
|
50
|
-
}
|
51
|
-
},
|
52
|
-
'aria-labelledby': {
|
53
|
-
control: {
|
54
|
-
type: 'text'
|
55
|
-
}
|
56
|
-
},
|
57
|
-
'aria-describedby': {
|
58
|
-
control: {
|
59
|
-
type: 'text'
|
60
|
-
}
|
61
|
-
},
|
62
|
-
'aria-details': {
|
63
|
-
control: {
|
64
|
-
type: 'text'
|
65
|
-
}
|
66
|
-
},
|
67
|
-
isSelected: {
|
68
|
-
control: {
|
69
|
-
type: 'none'
|
70
|
-
}
|
71
|
-
},
|
72
|
-
disabledKeys: {
|
73
|
-
control: {
|
74
|
-
type: 'none'
|
75
|
-
}
|
76
|
-
},
|
77
|
-
defaultSelectedKeys: {
|
78
|
-
control: {
|
79
|
-
type: 'none'
|
80
|
-
}
|
81
|
-
},
|
82
|
-
selectedKeys: {
|
83
|
-
control: {
|
84
|
-
type: 'none'
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}, onHoverArgTypes)
|
32
|
+
argTypes: menuArgTypes
|
88
33
|
};
|
89
34
|
export var Default = function Default(_ref) {
|
90
35
|
var args = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|