@pingux/astro 2.16.1-alpha.1 → 2.17.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/ListView/ListView.js +1 -1
- package/lib/cjs/components/ListView/ListView.mdx +4 -1
- package/lib/cjs/components/ListView/ListView.stories.js +52 -98
- package/lib/cjs/components/ListView/ListViewItem.js +126 -0
- package/lib/cjs/components/ListViewItem/ListViewItem.js +81 -100
- package/lib/cjs/{experimental → components}/ListViewItem/ListViewItem.mdx +4 -4
- package/lib/cjs/{experimental → components}/ListViewItem/ListViewItem.stories.js +32 -37
- package/lib/cjs/{experimental → components}/ListViewItem/ListViewItem.test.js +3 -3
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemEditButton.js +5 -5
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemEditButton.stories.js +5 -5
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemEditButton.test.js +2 -2
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemMenu.js +8 -8
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemMenu.stories.js +5 -5
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemMenu.test.js +2 -3
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemSwitchField.js +5 -5
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemSwitchField.stories.js +5 -5
- package/lib/cjs/{experimental → components}/ListViewItem/controls/ListViewItemSwitchField.test.js +2 -2
- package/lib/cjs/experimental/PageHeader/PageHeader.js +14 -14
- package/lib/cjs/experimental/PageHeader/PageHeader.stories.js +27 -11
- package/lib/cjs/experimental/PageHeader/PageHeader.test.js +14 -5
- package/lib/cjs/experimental/PanelHeader/PanelHeader.js +1 -1
- package/lib/cjs/experimental/PanelHeader/PanelHeader.stories.js +1 -1
- package/lib/cjs/index.d.ts +4 -4
- package/lib/cjs/index.js +8 -8
- package/lib/cjs/recipes/ListAndPanel.stories.js +195 -267
- package/lib/cjs/recipes/MaskedValue.stories.js +8 -1
- package/lib/cjs/{experimental/recipes → recipes}/ScrollableListView.stories.js +2 -2
- package/lib/cjs/utils/designUtils/figmaLinks.js +3 -0
- package/lib/components/ListView/ListView.js +1 -1
- package/lib/components/ListView/ListView.mdx +4 -1
- package/lib/components/ListView/ListView.stories.js +47 -93
- package/lib/components/ListView/ListViewItem.js +113 -0
- package/lib/components/ListViewItem/ListViewItem.js +78 -99
- package/lib/{experimental → components}/ListViewItem/ListViewItem.mdx +4 -4
- package/lib/{experimental → components}/ListViewItem/ListViewItem.stories.js +7 -12
- package/lib/{experimental → components}/ListViewItem/ListViewItem.test.js +1 -1
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemEditButton.js +4 -4
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemEditButton.stories.js +3 -3
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemEditButton.test.js +1 -1
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemMenu.js +5 -5
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemMenu.stories.js +3 -3
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemMenu.test.js +1 -2
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemSwitchField.js +4 -4
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemSwitchField.stories.js +3 -3
- package/lib/{experimental → components}/ListViewItem/controls/ListViewItemSwitchField.test.js +1 -1
- package/lib/experimental/PageHeader/PageHeader.js +14 -14
- package/lib/experimental/PageHeader/PageHeader.stories.js +25 -10
- package/lib/experimental/PageHeader/PageHeader.test.js +14 -5
- package/lib/experimental/PanelHeader/PanelHeader.js +1 -1
- package/lib/experimental/PanelHeader/PanelHeader.stories.js +1 -1
- package/lib/index.js +4 -4
- package/lib/recipes/ListAndPanel.stories.js +186 -260
- package/lib/recipes/MaskedValue.stories.js +7 -0
- package/lib/{experimental/recipes → recipes}/ScrollableListView.stories.js +2 -2
- package/lib/utils/designUtils/figmaLinks.js +3 -0
- package/package.json +1 -1
- package/lib/cjs/components/ListItem/ListItem.stories.js +0 -189
- package/lib/cjs/experimental/ListView/ListView.mdx +0 -47
- package/lib/cjs/experimental/ListView/ListView.stories.js +0 -742
- package/lib/cjs/experimental/ListViewItem/ListViewItem.js +0 -108
- package/lib/cjs/experimental/recipes/ListAndPanel.stories.js +0 -359
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +0 -133
- package/lib/cjs/recipes/ScrollableListView.stories.hidden.js +0 -136
- package/lib/components/ListItem/ListItem.stories.js +0 -174
- package/lib/experimental/ListView/ListView.mdx +0 -47
- package/lib/experimental/ListView/ListView.stories.js +0 -729
- package/lib/experimental/ListViewItem/ListViewItem.js +0 -93
- package/lib/experimental/recipes/ListAndPanel.stories.js +0 -342
- package/lib/recipes/RadioButtonsWithLinks.stories.js +0 -118
- package/lib/recipes/ScrollableListView.stories.hidden.js +0 -121
- /package/lib/cjs/{experimental → components}/ListViewItem/listViewItemAttributes.js +0 -0
- /package/lib/cjs/{experimental/recipes → recipes}/items.js +0 -0
- /package/lib/{experimental → components}/ListViewItem/listViewItemAttributes.js +0 -0
- /package/lib/{experimental/recipes → recipes}/items.js +0 -0
@@ -17,13 +17,11 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
|
|
17
17
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
18
18
|
import React from 'react';
|
19
19
|
import { Item, useAsyncList } from 'react-stately';
|
20
|
-
import CreateIcon from '@pingux/mdi-react/CreateIcon';
|
21
20
|
import FormSelectIcon from '@pingux/mdi-react/FormSelectIcon';
|
22
|
-
import MoreVertIcon from '@pingux/mdi-react/MoreVertIcon';
|
23
21
|
import { action } from '@storybook/addon-actions';
|
24
22
|
import isChromatic from 'chromatic/isChromatic';
|
25
23
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
26
|
-
import { Box,
|
24
|
+
import { Box, ListView, ListViewItem, ListViewItemMenu, ListViewItemSwitchField } from '../..';
|
27
25
|
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
28
26
|
import ListViewReadme from './ListView.mdx';
|
29
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -47,19 +45,20 @@ export default {
|
|
47
45
|
options: loadingStates
|
48
46
|
}
|
49
47
|
},
|
50
|
-
disabledKeys: {
|
51
|
-
defaultValue: ['Snake']
|
52
|
-
},
|
48
|
+
disabledKeys: {},
|
53
49
|
items: {
|
54
50
|
control: {
|
55
51
|
type: 'none'
|
56
52
|
}
|
57
53
|
},
|
58
54
|
onSelectionChange: {
|
59
|
-
control: 'none'
|
60
|
-
// eslint-disable-next-line no-console
|
61
|
-
defaultValue: console.log
|
55
|
+
control: 'none'
|
62
56
|
}
|
57
|
+
},
|
58
|
+
args: {
|
59
|
+
disabledKeys: ['Snake'],
|
60
|
+
// eslint-disable-next-line no-console
|
61
|
+
onSelectionChange: console.log
|
63
62
|
}
|
64
63
|
};
|
65
64
|
var items = [{
|
@@ -533,82 +532,33 @@ var actions = {
|
|
533
532
|
onFocus: action('onFocus'),
|
534
533
|
onLoadMore: action('onLoadMore')
|
535
534
|
};
|
536
|
-
var
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
}, ___EmotionJSX(Icon, {
|
545
|
-
icon: FormSelectIcon,
|
546
|
-
mr: "sm",
|
547
|
-
color: "accent.40",
|
548
|
-
size: "md"
|
549
|
-
}), ___EmotionJSX(Text, {
|
550
|
-
variant: "itemTitle",
|
551
|
-
alignSelf: "center"
|
552
|
-
}, item.name)), ___EmotionJSX(Box, {
|
553
|
-
isRow: true,
|
554
|
-
alignSelf: "center",
|
555
|
-
gap: "sm"
|
556
|
-
}, ___EmotionJSX(IconButton, {
|
557
|
-
"aria-label": "create-icon"
|
558
|
-
}, ___EmotionJSX(Icon, {
|
559
|
-
icon: CreateIcon,
|
560
|
-
size: "sm"
|
561
|
-
})), ___EmotionJSX(IconButton, {
|
562
|
-
"aria-label": "actions-icon"
|
563
|
-
}, ___EmotionJSX(Icon, {
|
564
|
-
icon: MoreVertIcon,
|
565
|
-
size: "sm"
|
566
|
-
}))));
|
535
|
+
var Controls = function Controls() {
|
536
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(ListViewItemSwitchField, null), ___EmotionJSX(ListViewItemMenu, null, ___EmotionJSX(Item, {
|
537
|
+
key: "enable"
|
538
|
+
}, "Enable user"), ___EmotionJSX(Item, {
|
539
|
+
key: "disable"
|
540
|
+
}, "Disable user"), ___EmotionJSX(Item, {
|
541
|
+
key: "delete"
|
542
|
+
}, "Delete user")));
|
567
543
|
};
|
568
|
-
export var Default = function Default(
|
569
|
-
var args = _extends({}, (_objectDestructuringEmpty(
|
544
|
+
export var Default = function Default(_ref) {
|
545
|
+
var args = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
570
546
|
return ___EmotionJSX(ListView, _extends({}, props, args, {
|
571
547
|
items: items
|
572
548
|
}), function (item) {
|
573
549
|
return ___EmotionJSX(Item, {
|
574
|
-
key: item.name
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
mr: "auto",
|
582
|
-
alignSelf: "center"
|
583
|
-
}, ___EmotionJSX(Icon, {
|
584
|
-
icon: FormSelectIcon,
|
585
|
-
mr: "sm",
|
586
|
-
color: "accent.40",
|
587
|
-
size: "md"
|
588
|
-
}), ___EmotionJSX(Text, {
|
589
|
-
variant: "itemTitle",
|
590
|
-
alignSelf: "center"
|
591
|
-
}, item.name)), ___EmotionJSX(Box, {
|
592
|
-
isRow: true,
|
593
|
-
alignSelf: "center",
|
594
|
-
gap: "sm"
|
595
|
-
}, ___EmotionJSX(IconButton, {
|
596
|
-
"aria-label": "create-icon"
|
597
|
-
}, ___EmotionJSX(Icon, {
|
598
|
-
icon: CreateIcon,
|
599
|
-
size: "sm"
|
600
|
-
})), ___EmotionJSX(IconButton, {
|
601
|
-
"aria-label": "actions-icon",
|
602
|
-
size: "sm"
|
603
|
-
}, ___EmotionJSX(Icon, {
|
604
|
-
icon: MoreVertIcon,
|
605
|
-
size: "sm"
|
606
|
-
})))));
|
550
|
+
key: item.name
|
551
|
+
}, ___EmotionJSX(ListViewItem, {
|
552
|
+
data: {
|
553
|
+
text: item.name,
|
554
|
+
icon: FormSelectIcon
|
555
|
+
}
|
556
|
+
}, ___EmotionJSX(Controls, null)));
|
607
557
|
});
|
608
558
|
};
|
609
559
|
export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
610
560
|
var getMockData = /*#__PURE__*/function () {
|
611
|
-
var
|
561
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(signal, cursor) {
|
612
562
|
var pageNumber;
|
613
563
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
614
564
|
while (1) {
|
@@ -640,11 +590,11 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
|
640
590
|
}, _callee);
|
641
591
|
}));
|
642
592
|
return function getMockData(_x, _x2) {
|
643
|
-
return
|
593
|
+
return _ref2.apply(this, arguments);
|
644
594
|
};
|
645
595
|
}();
|
646
596
|
var fetchApiData = /*#__PURE__*/function () {
|
647
|
-
var
|
597
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(signal, cursor, filterText) {
|
648
598
|
var res, json;
|
649
599
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
650
600
|
while (1) {
|
@@ -698,18 +648,18 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
|
698
648
|
}, _callee2, null, [[2, 14]]);
|
699
649
|
}));
|
700
650
|
return function fetchApiData(_x3, _x4, _x5) {
|
701
|
-
return
|
651
|
+
return _ref3.apply(this, arguments);
|
702
652
|
};
|
703
653
|
}();
|
704
654
|
var list = useAsyncList({
|
705
|
-
load: function load(
|
655
|
+
load: function load(_ref4) {
|
706
656
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
707
657
|
var signal, cursor, filterText;
|
708
658
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
709
659
|
while (1) {
|
710
660
|
switch (_context3.prev = _context3.next) {
|
711
661
|
case 0:
|
712
|
-
signal =
|
662
|
+
signal = _ref4.signal, cursor = _ref4.cursor, filterText = _ref4.filterText;
|
713
663
|
if (cursor) {
|
714
664
|
// eslint-disable-next-line
|
715
665
|
cursor = cursor.replace(/^http:\/\//i, "https://");
|
@@ -742,11 +692,13 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
|
|
742
692
|
onLoadMore: list.loadMore
|
743
693
|
}), function (item) {
|
744
694
|
return ___EmotionJSX(Item, {
|
745
|
-
key: item.name
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
695
|
+
key: item.name
|
696
|
+
}, ___EmotionJSX(ListViewItem, {
|
697
|
+
data: {
|
698
|
+
text: item.name,
|
699
|
+
icon: FormSelectIcon
|
700
|
+
}
|
701
|
+
}, ___EmotionJSX(Controls, null)));
|
750
702
|
}));
|
751
703
|
};
|
752
704
|
InfiniteLoadingList.args = {
|
@@ -759,17 +711,19 @@ InfiniteLoadingList.parameters = {
|
|
759
711
|
}
|
760
712
|
}
|
761
713
|
};
|
762
|
-
export var MultipleSelection = function MultipleSelection(
|
763
|
-
var args = _extends({}, (_objectDestructuringEmpty(
|
714
|
+
export var MultipleSelection = function MultipleSelection(_ref5) {
|
715
|
+
var args = _extends({}, (_objectDestructuringEmpty(_ref5), _ref5));
|
764
716
|
return ___EmotionJSX(ListView, _extends({}, props, args, {
|
765
717
|
items: items,
|
766
718
|
selectionMode: "multiple"
|
767
719
|
}), function (item) {
|
768
720
|
return ___EmotionJSX(Item, {
|
769
|
-
key: item.name
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
721
|
+
key: item.name
|
722
|
+
}, ___EmotionJSX(ListViewItem, {
|
723
|
+
data: {
|
724
|
+
text: item.name,
|
725
|
+
icon: FormSelectIcon
|
726
|
+
}
|
727
|
+
}, ___EmotionJSX(Controls, null)));
|
774
728
|
});
|
775
729
|
};
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
2
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
3
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
6
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
7
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
8
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
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";
|
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 _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; }
|
14
|
+
import React, { useContext, useRef } from 'react';
|
15
|
+
import { mergeProps, useFocusRing } from 'react-aria';
|
16
|
+
import { useHover } from '@react-aria/interactions';
|
17
|
+
import { useListItem } from '@react-aria/list';
|
18
|
+
import PropTypes from 'prop-types';
|
19
|
+
import { useStatusClasses } from '../../hooks';
|
20
|
+
import Box from '../Box';
|
21
|
+
import { ListViewContext } from './ListViewContext';
|
22
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
23
|
+
var ListViewItem = function ListViewItem(props) {
|
24
|
+
var _context;
|
25
|
+
var item = props.item,
|
26
|
+
_props$item$props = props.item.props,
|
27
|
+
listItemProps = _props$item$props.listItemProps,
|
28
|
+
rowProps = _props$item$props.rowProps,
|
29
|
+
_props$item$props$has = _props$item$props.hasSeparator,
|
30
|
+
hasSeparator = _props$item$props$has === void 0 ? true : _props$item$props$has,
|
31
|
+
hasInsetSeparator = _props$item$props.hasInsetSeparator,
|
32
|
+
isHoverable = props.isHoverable,
|
33
|
+
isFocusable = props.isFocusable,
|
34
|
+
className = props.className;
|
35
|
+
var dataId = item.props['data-id'];
|
36
|
+
var _useContext = useContext(ListViewContext),
|
37
|
+
state = _useContext.state;
|
38
|
+
var isDisabled = state.disabledKeys.has(item.key);
|
39
|
+
var rowRef = useRef();
|
40
|
+
var isSelectable = state.selectionManager.selectionMode !== 'none';
|
41
|
+
var _useFocusRing = useFocusRing({
|
42
|
+
within: true
|
43
|
+
}),
|
44
|
+
isFocusVisibleWithin = _useFocusRing.isFocusVisible,
|
45
|
+
focusWithinProps = _useFocusRing.focusProps;
|
46
|
+
var _useFocusRing2 = useFocusRing(),
|
47
|
+
focusProps = _useFocusRing2.focusProps,
|
48
|
+
isFocusVisible = _useFocusRing2.isFocusVisible;
|
49
|
+
var _useHover = useHover({
|
50
|
+
onHoverStart: function onHoverStart() {
|
51
|
+
state.hover.setHoveredItem(item.key);
|
52
|
+
}
|
53
|
+
}),
|
54
|
+
hoverProps = _useHover.hoverProps,
|
55
|
+
isHovered = _useHover.isHovered;
|
56
|
+
var _useListItem = useListItem({
|
57
|
+
node: item,
|
58
|
+
isVirtualized: true,
|
59
|
+
isDisabled: isDisabled
|
60
|
+
}, state, rowRef),
|
61
|
+
raRowProps = _useListItem.rowProps,
|
62
|
+
gridCellProps = _useListItem.gridCellProps;
|
63
|
+
var isSelected = state.selectionManager.isSelected(item.key);
|
64
|
+
var mergedProps = mergeProps(raRowProps, hoverProps, isFocusable ? _objectSpread(_objectSpread({}, focusProps), focusWithinProps) : {});
|
65
|
+
var _useStatusClasses = useStatusClasses(className, {
|
66
|
+
isHovered: isSelectable && isHovered && isHoverable && item.key === state.hover.hoveredItem,
|
67
|
+
isSelected: isSelected,
|
68
|
+
isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin,
|
69
|
+
hasSeparator: hasSeparator,
|
70
|
+
hasInsetSeparator: hasInsetSeparator
|
71
|
+
}),
|
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');
|
77
|
+
return ___EmotionJSX(Box, _extends({
|
78
|
+
isDisabled: isDisabled,
|
79
|
+
isRow: true,
|
80
|
+
ref: rowRef
|
81
|
+
}, mergedProps, rowProps, {
|
82
|
+
sx: {
|
83
|
+
outline: 'none'
|
84
|
+
}
|
85
|
+
}), ___EmotionJSX(Box, _extends({
|
86
|
+
as: "div"
|
87
|
+
// Apply appropriate variant dependant on whether a legacy list item is used
|
88
|
+
,
|
89
|
+
variant: shouldOverRideLegacyStyles ? 'listViewItem.styledListItem' : 'listViewItem.container'
|
90
|
+
}, gridCellProps, {
|
91
|
+
isFocused: isDisabled ? false : isFocusVisible,
|
92
|
+
isDisabled: isDisabled,
|
93
|
+
isSelected: isSelected,
|
94
|
+
className: classNames,
|
95
|
+
"data-id": dataId
|
96
|
+
}, listItemProps), item.rendered));
|
97
|
+
};
|
98
|
+
ListViewItem.propTypes = {
|
99
|
+
item: PropTypes.shape({
|
100
|
+
key: PropTypes.string,
|
101
|
+
rendered: PropTypes.node,
|
102
|
+
props: PropTypes.shape({
|
103
|
+
'data-id': PropTypes.string,
|
104
|
+
listItemProps: PropTypes.shape({}),
|
105
|
+
rowProps: PropTypes.shape({}),
|
106
|
+
hasSeparator: PropTypes.bool,
|
107
|
+
hasInsetSeparator: PropTypes.bool
|
108
|
+
})
|
109
|
+
}),
|
110
|
+
isHoverable: PropTypes.bool,
|
111
|
+
isFocusable: PropTypes.bool
|
112
|
+
};
|
113
|
+
export default ListViewItem;
|
@@ -1,113 +1,92 @@
|
|
1
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
2
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
3
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
4
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
6
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
7
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
8
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
9
|
-
import
|
10
|
-
|
11
|
-
import
|
12
|
-
|
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; }
|
14
|
-
import React, { useContext, useRef } from 'react';
|
15
|
-
import { mergeProps, useFocusRing } from 'react-aria';
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["children", "className", "data", "isHovered", "isSelected", "linkProps", "onHoverChange", "onHoverEnd", "onHoverStart", "slots"];
|
4
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
5
|
+
import React, { forwardRef } from 'react';
|
16
6
|
import { useHover } from '@react-aria/interactions';
|
17
|
-
import {
|
18
|
-
import PropTypes from 'prop-types';
|
7
|
+
import { Box, Icon, Image, Text } from '../..';
|
19
8
|
import { useStatusClasses } from '../../hooks';
|
20
|
-
import
|
21
|
-
import { ListViewContext } from '../ListView/ListViewContext';
|
9
|
+
import { listViewItemPropTypes } from './listViewItemAttributes';
|
22
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
23
|
-
var
|
11
|
+
export var LIST_ITEM_ICON = '-list-item-icon';
|
12
|
+
var ListViewItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
24
13
|
var _context;
|
25
|
-
var
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
var
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
var
|
41
|
-
var _useFocusRing = useFocusRing({
|
42
|
-
within: true
|
43
|
-
}),
|
44
|
-
isFocusVisibleWithin = _useFocusRing.isFocusVisible,
|
45
|
-
focusWithinProps = _useFocusRing.focusProps;
|
46
|
-
var _useFocusRing2 = useFocusRing(),
|
47
|
-
focusProps = _useFocusRing2.focusProps,
|
48
|
-
isFocusVisible = _useFocusRing2.isFocusVisible;
|
14
|
+
var children = _ref.children,
|
15
|
+
className = _ref.className,
|
16
|
+
data = _ref.data,
|
17
|
+
isHovered = _ref.isHovered,
|
18
|
+
isSelected = _ref.isSelected,
|
19
|
+
linkProps = _ref.linkProps,
|
20
|
+
onHoverChange = _ref.onHoverChange,
|
21
|
+
onHoverEnd = _ref.onHoverEnd,
|
22
|
+
onHoverStart = _ref.onHoverStart,
|
23
|
+
slots = _ref.slots,
|
24
|
+
others = _objectWithoutProperties(_ref, _excluded);
|
25
|
+
var icon = data.icon,
|
26
|
+
image = data.image,
|
27
|
+
subtext = data.subtext,
|
28
|
+
text = data.text;
|
29
|
+
var shouldUseDefaultHover = isHovered === undefined;
|
49
30
|
var _useHover = useHover({
|
50
|
-
|
51
|
-
|
52
|
-
|
31
|
+
onHoverChange: onHoverChange,
|
32
|
+
onHoverEnd: onHoverEnd,
|
33
|
+
onHoverStart: onHoverStart
|
53
34
|
}),
|
54
35
|
hoverProps = _useHover.hoverProps,
|
55
|
-
|
56
|
-
var _useListItem = useListItem({
|
57
|
-
node: item,
|
58
|
-
isVirtualized: true,
|
59
|
-
isDisabled: isDisabled
|
60
|
-
}, state, rowRef),
|
61
|
-
raRowProps = _useListItem.rowProps,
|
62
|
-
gridCellProps = _useListItem.gridCellProps;
|
63
|
-
var isSelected = state.selectionManager.isSelected(item.key);
|
64
|
-
var mergedProps = mergeProps(raRowProps, hoverProps, isFocusable ? _objectSpread(_objectSpread({}, focusProps), focusWithinProps) : {});
|
36
|
+
defaultIsHovered = _useHover.isHovered;
|
65
37
|
var _useStatusClasses = useStatusClasses(className, {
|
66
|
-
isHovered:
|
67
|
-
isSelected: isSelected
|
68
|
-
isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin,
|
69
|
-
hasSeparator: hasSeparator,
|
70
|
-
hasInsetSeparator: hasInsetSeparator
|
38
|
+
isHovered: shouldUseDefaultHover ? defaultIsHovered : isHovered,
|
39
|
+
isSelected: isSelected
|
71
40
|
}),
|
72
41
|
classNames = _useStatusClasses.classNames;
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
42
|
+
var getWrapperVariant = function getWrapperVariant() {
|
43
|
+
if (slots !== null && slots !== void 0 && slots.leftOfData) return 'listViewItem.leftOfDataWrapper';
|
44
|
+
if (image && !icon) return 'listViewItem.imageWrapper';
|
45
|
+
return 'listViewItem.iconWrapper';
|
46
|
+
};
|
47
|
+
var renderIcon = icon && ___EmotionJSX(Box, {
|
48
|
+
width: "25px"
|
49
|
+
}, ___EmotionJSX(Icon, {
|
50
|
+
color: "accent.40",
|
51
|
+
icon: icon,
|
52
|
+
size: "md",
|
53
|
+
title: {
|
54
|
+
name: _concatInstanceProperty(_context = "".concat(text)).call(_context, LIST_ITEM_ICON)
|
84
55
|
}
|
85
|
-
})
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
56
|
+
}));
|
57
|
+
var renderImage = !icon && image && ___EmotionJSX(Box, {
|
58
|
+
width: "35px"
|
59
|
+
}, ___EmotionJSX(Image, {
|
60
|
+
src: image.src,
|
61
|
+
alt: image.alt,
|
62
|
+
"aria-label": image['aria-label']
|
63
|
+
}));
|
64
|
+
var renderData = ___EmotionJSX(Box, {
|
65
|
+
isRow: true,
|
66
|
+
alignItems: "center"
|
67
|
+
}, (slots === null || slots === void 0 ? void 0 : slots.leftOfData) || renderIcon || renderImage, ___EmotionJSX(Box, {
|
68
|
+
variant: getWrapperVariant()
|
69
|
+
}, text && ___EmotionJSX(Text, {
|
70
|
+
variant: "listViewItemText"
|
71
|
+
}, text), subtext && ___EmotionJSX(Text, {
|
72
|
+
variant: "listViewItemSubtext"
|
73
|
+
}, subtext)));
|
74
|
+
return ___EmotionJSX(Box, _extends({
|
94
75
|
className: classNames,
|
95
|
-
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
isFocusable: PropTypes.bool
|
112
|
-
};
|
76
|
+
ref: ref,
|
77
|
+
variant: "listViewItem.styledContainer"
|
78
|
+
}, hoverProps, others), ___EmotionJSX(Box, {
|
79
|
+
isRow: true,
|
80
|
+
variant: getWrapperVariant()
|
81
|
+
}, renderData, (slots === null || slots === void 0 ? void 0 : slots.rightOfData) && ___EmotionJSX(Box, {
|
82
|
+
isRow: true,
|
83
|
+
variant: "listViewItem.rightOfData"
|
84
|
+
}, slots.rightOfData), ___EmotionJSX(Box, {
|
85
|
+
isRow: true,
|
86
|
+
gap: "sm",
|
87
|
+
variant: "listViewItem.controls"
|
88
|
+
}, children)));
|
89
|
+
});
|
90
|
+
ListViewItem.propTypes = listViewItemPropTypes;
|
91
|
+
ListViewItem.displayName = 'ListViewItem';
|
113
92
|
export default ListViewItem;
|
@@ -7,7 +7,7 @@ import { Meta } from '@storybook/addon-docs';
|
|
7
7
|
The ListViewItem allows easy creation of list items. Styles have been included to match Ping specs. Use the data prop to pass in text, subtext and an image, mdi or svg icon.
|
8
8
|
|
9
9
|
### Recommended Use
|
10
|
-
This component is intended to be used inside a ListView component. See the [ListAndPanel](./?path=/
|
10
|
+
This component is intended to be used inside a ListView component. See the [ListAndPanel](./?path=/docs/recipes-listandpanel--docs) and [ScrollableListView](./?path=/docs/recipes-scrollablelistview--docs)
|
11
11
|
recipes for a more detailed examples.
|
12
12
|
|
13
13
|
#### Commonly Used Components
|
@@ -35,9 +35,9 @@ leftOfData slot is used, it will prevent an icon in the `data.icon` prop from re
|
|
35
35
|
#### Children
|
36
36
|
To add action controls, pass control elements as `{children}`. All elements passed in this way will be right justified and center aligned. Use one of the following
|
37
37
|
styled control components to easily match Ping specs.
|
38
|
-
- [ListViewItemEditButton](./?path=/
|
39
|
-
- [ListViewItemMenu](./?path=/
|
40
|
-
- [ListViewItemSwitchField](./?path=/
|
38
|
+
- [ListViewItemEditButton](./?path=/docs/components-listviewitem-controls-listviewitemeditbutton--docs)
|
39
|
+
- [ListViewItemMenu](./?path=/docs/components-listviewitem-controls-listviewitemmenu--docs)
|
40
|
+
- [ListViewItemSwitchField](./?path=/docs/components-listviewitem-controls-listviewitemswitchfield--docs)
|
41
41
|
|
42
42
|
### Note:
|
43
43
|
The nature of components that have been styled to match design specs is that as design specs are updated, so will the matching component. Be aware that styles
|
@@ -3,13 +3,13 @@ import { Item } from 'react-stately';
|
|
3
3
|
import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
4
4
|
import FormSelectIcon from '@pingux/mdi-react/FormSelectIcon';
|
5
5
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
6
|
-
import { Badge, Box, ListViewItem, ListViewItemEditButton, ListViewItemMenu, ListViewItemSwitchField, Separator, Text } from '
|
6
|
+
import { Badge, Box, ListViewItem, ListViewItemEditButton, ListViewItemMenu, ListViewItemSwitchField, Separator, Text } from '../..';
|
7
7
|
import { pingImg } from '../../utils/devUtils/constants/images';
|
8
8
|
import ListViewItemReadMe from './ListViewItem.mdx';
|
9
9
|
import { listViewItemArgTypes } from './listViewItemAttributes';
|
10
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
11
|
export default {
|
12
|
-
title: '
|
12
|
+
title: 'Components/ListViewItem',
|
13
13
|
component: ListViewItem,
|
14
14
|
parameters: {
|
15
15
|
docs: {
|
@@ -40,8 +40,7 @@ export var Default = function Default() {
|
|
40
40
|
data: {
|
41
41
|
icon: AccountIcon,
|
42
42
|
text: 'Fons Vernall'
|
43
|
-
}
|
44
|
-
"aria-label": "Fons Vernall"
|
43
|
+
}
|
45
44
|
}));
|
46
45
|
};
|
47
46
|
export var WithSubtext = function WithSubtext() {
|
@@ -50,8 +49,7 @@ export var WithSubtext = function WithSubtext() {
|
|
50
49
|
icon: AccountIcon,
|
51
50
|
subtext: 'rad_developer@pingidentity.com',
|
52
51
|
text: 'Fons Vernall'
|
53
|
-
}
|
54
|
-
"aria-label": "Fons Vernall"
|
52
|
+
}
|
55
53
|
}));
|
56
54
|
};
|
57
55
|
export var WithImage = function WithImage() {
|
@@ -105,8 +103,7 @@ export var WithRightOfDataSlot = function WithRightOfDataSlot() {
|
|
105
103
|
},
|
106
104
|
slots: {
|
107
105
|
rightOfData: renderRightOfData
|
108
|
-
}
|
109
|
-
"aria-label": "Fons Vernall"
|
106
|
+
}
|
110
107
|
}, ___EmotionJSX(ListViewItemMenu, null, ___EmotionJSX(Item, {
|
111
108
|
key: "enable"
|
112
109
|
}, "Enable user"), ___EmotionJSX(Item, {
|
@@ -134,8 +131,7 @@ export var WithLeftOfDataSlot = function WithLeftOfDataSlot() {
|
|
134
131
|
,
|
135
132
|
slots: {
|
136
133
|
leftOfData: renderLeftOfData
|
137
|
-
}
|
138
|
-
"aria-label": "Fons Vernall"
|
134
|
+
}
|
139
135
|
}, ___EmotionJSX(ListViewItemMenu, null, ___EmotionJSX(Item, {
|
140
136
|
key: "enable"
|
141
137
|
}, "Enable user"), ___EmotionJSX(Item, {
|
@@ -164,8 +160,7 @@ export var WithExtraLongText = function WithExtraLongText() {
|
|
164
160
|
},
|
165
161
|
slots: {
|
166
162
|
rightOfData: renderRightOfData
|
167
|
-
}
|
168
|
-
"aria-label": "Fons Vernall"
|
163
|
+
}
|
169
164
|
}, ___EmotionJSX(ListViewItemMenu, null, ___EmotionJSX(Item, {
|
170
165
|
key: "enable"
|
171
166
|
}, "Enable user"), ___EmotionJSX(Item, {
|
@@ -14,7 +14,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
14
14
|
import React from 'react';
|
15
15
|
import AccountIcon from '@pingux/mdi-react/AccountIcon';
|
16
16
|
import { act } from '@testing-library/react';
|
17
|
-
import { ListViewItem, ListViewItemSwitchField } from '
|
17
|
+
import { ListViewItem, ListViewItemSwitchField } from '../..';
|
18
18
|
import { pingImg } from '../../utils/devUtils/constants/images';
|
19
19
|
import axeTest from '../../utils/testUtils/testAxe';
|
20
20
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import CreateIcon from '@pingux/mdi-react/CreateIcon';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { Box, Icon, IconButton } from '../../..';
|
4
|
+
import { iconButtonPropTypes } from '../../IconButton/iconButtonAttributes';
|
5
5
|
|
6
6
|
/**
|
7
7
|
* ListViewItemEditButton is one of several styled control components that can be used as a child
|
8
|
-
* nested inside of the [ListViewItem](./?path=/
|
9
|
-
* Its a wrapper component around the [IconButton](./?path=/
|
8
|
+
* nested inside of the [ListViewItem](./?path=/docs/components-listviewitem--docs).
|
9
|
+
* Its a wrapper component around the [IconButton](./?path=/docs/components-iconbutton--docs),
|
10
10
|
* intended to make matching specs easy. Most props available to the IconButton are also available
|
11
11
|
* to ListItemEditButton.
|
12
12
|
*/
|