mod-arch-shared
Version:
Shared UI components and utilities for modular architecture micro-frontend projects
17 lines • 1.28 kB
JavaScript
import * as React from 'react';
import { SearchInput, TextInput } from '@patternfly/react-core';
import { useThemeContext } from 'mod-arch-kubeflow';
import FormFieldset from './FormFieldset';
const ThemeAwareSearchInput = ({ value, onChange, onClear, fieldLabel, placeholder, isDisabled, className, style, 'aria-label': ariaLabel = 'Search', 'data-testid': dataTestId, ...rest }) => {
const { isMUITheme } = useThemeContext();
if (isMUITheme) {
return (React.createElement(FormFieldset, { className: className, field: fieldLabel, component: React.createElement(TextInput, { ...rest, value: value, type: "text", placeholder: placeholder, onChange: (_event, newValue) => onChange(newValue), isDisabled: isDisabled, "aria-label": ariaLabel, "data-testid": dataTestId, style: style }) }));
}
return (React.createElement(SearchInput, { ...rest, className: className, style: style, placeholder: placeholder, value: value, isDisabled: isDisabled, "aria-label": ariaLabel, "data-testid": dataTestId, onChange: (_event, newValue) => onChange(newValue), onClear: (event) => {
event.stopPropagation();
onChange('');
onClear?.();
} }));
};
export default ThemeAwareSearchInput;
//# sourceMappingURL=ThemeAwareSearchInput.js.map