1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.SimpleListItem = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const React = tslib_1.__importStar(require("react"));
|
6 | const react_styles_1 = require("@patternfly/react-styles");
|
7 | const simple_list_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/SimpleList/simple-list"));
|
8 | const SimpleList_1 = require("./SimpleList");
|
9 | class SimpleListItem extends React.Component {
|
10 | constructor() {
|
11 | super(...arguments);
|
12 | this.ref = React.createRef();
|
13 | }
|
14 | render() {
|
15 | const _a = this.props, { children, isCurrent, isActive, className, component: Component, componentClassName, componentProps, onClick, type, href,
|
16 |
|
17 | itemId } = _a, props = tslib_1.__rest(_a, ["children", "isCurrent", "isActive", "className", "component", "componentClassName", "componentProps", "onClick", "type", "href", "itemId"]);
|
18 | return (React.createElement(SimpleList_1.SimpleListContext.Consumer, null, ({ currentRef, updateCurrentRef, isControlled }) => {
|
19 | const isButton = Component === 'button';
|
20 | const isCurrentItem = this.ref && currentRef && isControlled ? currentRef.current === this.ref.current : isActive || isCurrent;
|
21 | const additionalComponentProps = isButton
|
22 | ? {
|
23 | type
|
24 | }
|
25 | : {
|
26 | tabIndex: 0,
|
27 | href
|
28 | };
|
29 | return (React.createElement("li", Object.assign({ className: react_styles_1.css(className) }, props),
|
30 | React.createElement(Component, Object.assign({ className: react_styles_1.css(simple_list_1.default.simpleListItemLink, isCurrentItem && simple_list_1.default.modifiers.current, componentClassName), onClick: (evt) => {
|
31 | onClick(evt);
|
32 | updateCurrentRef(this.ref, this.props);
|
33 | }, ref: this.ref }, componentProps, additionalComponentProps), children)));
|
34 | }));
|
35 | }
|
36 | }
|
37 | exports.SimpleListItem = SimpleListItem;
|
38 | SimpleListItem.displayName = 'SimpleListItem';
|
39 | SimpleListItem.defaultProps = {
|
40 | children: null,
|
41 | className: '',
|
42 | isActive: false,
|
43 | isCurrent: false,
|
44 | component: 'button',
|
45 | componentClassName: '',
|
46 | type: 'button',
|
47 | href: '',
|
48 | onClick: () => { }
|
49 | };
|
50 |
|
\ | No newline at end of file |