1 | import { __rest } from "tslib";
|
2 | import * as React from 'react';
|
3 | import { css } from '@patternfly/react-styles';
|
4 | import styles from '@patternfly/react-styles/css/components/ToggleGroup/toggle-group';
|
5 | import { ToggleGroupItemVariant, ToggleGroupItemElement } from './ToggleGroupItemElement';
|
6 | export const ToggleGroupItem = (_a) => {
|
7 | var { text, icon, className, isDisabled = false, isSelected = false, 'aria-label': ariaLabel = '', onChange = () => { }, buttonId = '' } = _a, props = __rest(_a, ["text", "icon", "className", "isDisabled", "isSelected", 'aria-label', "onChange", "buttonId"]);
|
8 | const handleChange = (event) => {
|
9 | onChange(!isSelected, event);
|
10 | };
|
11 | if (!ariaLabel && icon && !text) {
|
12 |
|
13 | console.warn('An accessible aria-label is required when using the toggle group item icon variant.');
|
14 | }
|
15 | return (React.createElement("div", Object.assign({ className: css(styles.toggleGroupItem, className) }, props),
|
16 | React.createElement("button", Object.assign({ type: "button", className: css(styles.toggleGroupButton, isSelected && styles.modifiers.selected), "aria-pressed": isSelected, onClick: handleChange }, (ariaLabel && { 'aria-label': ariaLabel }), (isDisabled && { disabled: true }), (buttonId && { id: buttonId })),
|
17 | icon ? React.createElement(ToggleGroupItemElement, { variant: ToggleGroupItemVariant.icon }, icon) : null,
|
18 | text ? React.createElement(ToggleGroupItemElement, { variant: ToggleGroupItemVariant.text }, text) : null)));
|
19 | };
|
20 | ToggleGroupItem.displayName = 'ToggleGroupItem';
|
21 |
|
\ | No newline at end of file |