1/* 2 * Copyright (c) 2024-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import React from 'react'; 17 18export const Icon = (props) => <span data-testid="mocked-icon" {...props}>Mocked Icon</span>; 19 20export const Button = ({ disabled, ...props }) => ( 21 <button disabled={disabled} {...props} /> 22); 23export const Checkbox = (props) => <input type="checkbox" {...props} />; 24export const Popover = ({ content, children, popoverClassName, interactionKind, isOpen, popoverRef, ...props }) => ( 25 <div className={popoverClassName} ref={popoverRef} {...props}> 26 {children} 27 {isOpen && <div data-testid="compile-options-content">{content}</div>} 28 </div> 29); 30export const Ratio = ({ children, ...props }) => <div data-testid="mocked-ratio" {...props}>{children}</div>; 31export const Switch = ({ checked, onChange, ...props }) => ( 32 <label data-testid="mocked-switch"> 33 <input 34 type="checkbox" 35 checked={checked} 36 onChange={onChange} 37 {...props} 38 /> 39 {checked ? 'On' : 'Off'} 40 </label> 41); 42export const Menu = ({ children, ...props }) => ( 43 <div data-testid="mocked-menu" {...props}>{children}</div> 44); 45 46export const MenuItem = ({ icon, text, onClick, labelElement, ...props }) => ( 47 <div data-testid="mocked-menu-item" onClick={onClick} {...props}> 48 {icon && <Icon icon={icon} />} 49 {text} 50 {labelElement} 51 </div> 52); 53 54export const RadioGroup = ({ label, name, selectedValue, onChange, children, inline, ...props }) => ( 55 <div data-testid="mocked-radio-group" role="radiogroup" {...props}> 56 {React.Children.map(children, (child) => { 57 return React.cloneElement(child, { 58 name, 59 checked: child.props.value === selectedValue, 60 onChange, 61 }); 62 })} 63 {selectedValue} 64 {label} 65 </div> 66); 67 68export const Radio = ({ label, value, checked, onChange, ...props }) => ( 69 <label data-testid="mocked-radio"> 70 <input 71 type="radio" 72 value={value} 73 checked={checked} 74 onChange={onChange} 75 {...props} 76 /> 77 {label} 78 </label> 79); 80 81export const Tooltip = ({ content, children, tooltipClassName, isOpen, tooltipRef, ...props }) => ( 82 <div className={tooltipClassName} ref={tooltipRef} {...props}> 83 {children} 84 {isOpen && <div data-testid="mocked-tooltip-content">{content}</div>} 85 </div> 86); 87 88export const ButtonGroup = ({ children, groupClassName, ...props }) => ( 89 <div className={groupClassName} data-testid="mocked-button-group" {...props}> 90 {children} 91 </div> 92);