1 | import { __rest } from "tslib";
|
2 | import * as React from 'react';
|
3 | import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
4 | import { Toggle } from './Toggle';
|
5 | import styles from '@patternfly/react-styles/css/components/Dropdown/dropdown';
|
6 | import { DropdownContext } from './dropdownConstants';
|
7 | import { css } from '@patternfly/react-styles';
|
8 | import { useOUIAProps } from '../../helpers';
|
9 | export const DropdownToggle = (_a) => {
|
10 | var { id = '', children = null, className = '', isOpen = false, parentRef = null, getMenuRef = null, isDisabled = false, isPlain = false, isText = false, isPrimary = false, toggleVariant = 'default',
|
11 |
|
12 | isActive = false,
|
13 |
|
14 | onToggle = (_isOpen) => undefined, icon = null, toggleIndicator: ToggleIndicator = CaretDownIcon, splitButtonItems, splitButtonVariant = 'checkbox', 'aria-haspopup': ariaHasPopup, ouiaId, ouiaSafe,
|
15 |
|
16 | ref } = _a,
|
17 | props = __rest(_a, ["id", "children", "className", "isOpen", "parentRef", "getMenuRef", "isDisabled", "isPlain", "isText", "isPrimary", "toggleVariant", "isActive", "onToggle", "icon", "toggleIndicator", "splitButtonItems", "splitButtonVariant", 'aria-haspopup', "ouiaId", "ouiaSafe", "ref"]);
|
18 | const ouiaProps = useOUIAProps(DropdownToggle.displayName, ouiaId, ouiaSafe);
|
19 | const toggle = (React.createElement(DropdownContext.Consumer, null, ({ toggleTextClass, toggleIndicatorClass, toggleIconClass }) => (React.createElement(Toggle, Object.assign({}, props, { id: id, className: className, isOpen: isOpen, parentRef: parentRef, getMenuRef: getMenuRef, isActive: isActive, isDisabled: isDisabled, isPlain: isPlain, isText: isText, isPrimary: isPrimary, toggleVariant: toggleVariant, onToggle: onToggle, "aria-haspopup": ariaHasPopup }, ouiaProps, (splitButtonItems && { isSplitButton: true, 'aria-label': props['aria-label'] || 'Select' })),
|
20 | icon && React.createElement("span", { className: css(toggleIconClass) }, icon),
|
21 | children && React.createElement("span", { className: ToggleIndicator && css(toggleTextClass) }, children),
|
22 | ToggleIndicator && (React.createElement("span", { className: css(!splitButtonItems && toggleIndicatorClass) },
|
23 | React.createElement(ToggleIndicator, null)))))));
|
24 | if (splitButtonItems) {
|
25 | return (React.createElement("div", { className: css(styles.dropdownToggle, styles.modifiers.splitButton, splitButtonVariant === 'action' && styles.modifiers.action, (toggleVariant === 'primary' || isPrimary) && splitButtonVariant === 'action' && styles.modifiers.primary, isDisabled && styles.modifiers.disabled) },
|
26 | splitButtonItems,
|
27 | toggle));
|
28 | }
|
29 | return toggle;
|
30 | };
|
31 | DropdownToggle.displayName = 'DropdownToggle';
|
32 |
|
\ | No newline at end of file |