* Adds analytics for DropdownControl * Add isUpdatedViaKeyboard to WIDGET_PROPERTY_UPDATE * fix: jest test for iconselectorcontrol * refactor: Interaction analytics event dispatching moved to a hook * refactor: event collection logic to HOC * Analytics for SwitchControl * Analytics for CodeEditor * Analytics for InputTextControl * Analytics for ColorPicker * fix issue with ColorPicker * refactor to re-use ref * rename the hook to ts * Analytics for StepControl * Analytics for ButtonTabComponent * Analytics for NumericInputControl * Analytics for IconSelector * fix: failed test * Analytics for ActionSelector * fix: failed jest test * fix: jest test for StepControl * Analytics for Option Control * Analytics for LocationSearchControl * Adds Analytics for Tab key * analytics for Property pane connections * Add analytics for widget name * Adds analytics for copy & delete button * fix issue with widget name analytics * add useCallback for tab keydown handler for button * Create separate Event handling for design system * removes unused imports * changes ADS_EVENT to DS_EVENT * Changes AdsEventTypes to DSEventTypes * Changes AdsEventDetail to DSEventDetail * changes occurences of Ads to DS * avoids creation of intermediate function * removes trace of 'analytics' from DS components * rename dispatchDSEvent to emitDSEvent * fix: Cypress selector
104 lines
2.6 KiB
TypeScript
104 lines
2.6 KiB
TypeScript
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 { ButtonTabComponent } from "components/ads";
|
|
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: (
|
|
<TooltipComponent
|
|
content={
|
|
<div>
|
|
<div>{optionKey}</div>
|
|
</div>
|
|
}
|
|
key={optionKey}
|
|
openOnTargetFocus={false}
|
|
>
|
|
<button tabIndex={-1}>
|
|
<div
|
|
className="flex items-center justify-center w-5 h-5 bg-white"
|
|
style={{ boxShadow: boxShadowOptions[optionKey] }}
|
|
>
|
|
{boxShadowOptions[optionKey] === "none" && (
|
|
<CloseLineIcon className="text-gray-700" />
|
|
)}
|
|
</div>
|
|
</button>
|
|
</TooltipComponent>
|
|
),
|
|
value: boxShadowOptions[optionKey],
|
|
}));
|
|
|
|
const optionsValues = new Set(Object.values(boxShadowOptions));
|
|
|
|
class BoxShadowOptionsControl extends BaseControl<
|
|
BoxShadowOptionsControlProps
|
|
> {
|
|
componentRef = React.createRef<HTMLDivElement>();
|
|
|
|
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<DSEventDetail>) => {
|
|
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 (
|
|
<ButtonTabComponent
|
|
options={options}
|
|
ref={this.componentRef}
|
|
selectButton={(value, isUpdatedViaKeyboard = false) => {
|
|
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;
|