import * as React from "react"; import BaseControl, { ControlData, ControlProps } from "./BaseControl"; import { TooltipComponent } from "design-system"; import { boxShadowOptions } from "constants/ThemeConstants"; import CloseLineIcon from "remixicon-react/CloseLineIcon"; import { ButtonTab } from "design-system"; import { DSEventDetail, DSEventTypes, DS_EVENT, emitInteractionAnalyticsEvent, } from "utils/AppsmithUtils"; export interface BoxShadowOptionsControlProps extends ControlProps { propertyValue: string | undefined; } const options = Object.keys(boxShadowOptions).map((optionKey) => ({ icon: ( {optionKey} } key={optionKey} openOnTargetFocus={false} > {boxShadowOptions[optionKey] === "none" && ( )} ), value: boxShadowOptions[optionKey], })); const optionsValues = new Set(Object.values(boxShadowOptions)); class BoxShadowOptionsControl extends BaseControl< BoxShadowOptionsControlProps > { componentRef = React.createRef(); componentDidMount() { this.componentRef.current?.addEventListener( DS_EVENT, this.handleAdsEvent as (arg0: Event) => void, ); } componentWillUnmount() { this.componentRef.current?.removeEventListener( DS_EVENT, this.handleAdsEvent as (arg0: Event) => void, ); } handleAdsEvent = (e: CustomEvent) => { if ( e.detail.component === "ButtonTab" && e.detail.event === DSEventTypes.KEYPRESS ) { emitInteractionAnalyticsEvent(this.componentRef.current, { key: e.detail.meta.key, }); e.stopPropagation(); } }; static getControlType() { return "BOX_SHADOW_OPTIONS"; } public render() { return ( { this.updateProperty( this.props.propertyName, value, isUpdatedViaKeyboard, ); }} values={this.props.evaluatedValue ? [this.props.evaluatedValue] : []} /> ); } static canDisplayValueInUI(config: ControlData, value: any): boolean { return optionsValues.has(value); } } export default BoxShadowOptionsControl;