Skip to content

Added double click to almost all components #1754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open
8 changes: 5 additions & 3 deletions client/packages/lowcoder/src/comps/comps/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IconControl } from "comps/controls/iconControl";
import {
clickEvent,
eventHandlerControl,
doubleClickEvent,
} from "../controls/eventHandlerControl";
import { Avatar, AvatarProps, Badge, Dropdown, Menu } from "antd";
import { LeftRightControl, dropdownControl } from "../controls/dropdownControl";
Expand All @@ -34,6 +35,8 @@ import { BadgeBasicSection, badgeChildren } from "./badgeComp/badgeConstants";
import { DropdownOptionControl } from "../controls/optionsControl";
import { ReactElement, useContext, useEffect } from "react";
import { CompNameContext, EditorContext } from "../editorState";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";


const AvatarWrapper = styled(Avatar) <AvatarProps & { $cursorPointer?: boolean, $style: AvatarStyleType }>`
background: ${(props) => props.$style.background};
Expand Down Expand Up @@ -106,7 +109,7 @@ padding: ${props=>props.$style.padding};
background: ${props=>props.$style.background};
text-decoration: ${props => props.$style.textDecoration};
`
const EventOptions = [clickEvent] as const;
const EventOptions = [clickEvent, doubleClickEvent] as const;
const sharpOptions = [
{ label: trans("avatarComp.square"), value: "square" },
{ label: trans("avatarComp.circle"), value: "circle" },
Expand Down Expand Up @@ -181,8 +184,7 @@ const AvatarView = (props: RecordConstructorToView<typeof childrenMap>) => {
shape={shape}
$style={props.avatarStyle}
src={src.value}
// $cursorPointer={eventsCount > 0}
onClick={() => props.onEvent("click")}
onClick={ComponentClickHandler({onEvent: props.onEvent})}
>
{title.value}
</AvatarWrapper>
Expand Down
7 changes: 4 additions & 3 deletions client/packages/lowcoder/src/comps/comps/avatarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
import { trans } from "i18n";
import { NumberControl, StringControl } from "comps/controls/codeControl";
import { Avatar, Tooltip } from "antd";
import { clickEvent, eventHandlerControl, refreshEvent } from "../controls/eventHandlerControl";
import { clickEvent, doubleClickEvent, eventHandlerControl, refreshEvent } from "../controls/eventHandlerControl";
import styled from "styled-components";
import { useContext, ReactElement, useEffect } from "react";
import { MultiCompBuilder, stateComp, withDefault } from "../generators";
Expand All @@ -19,6 +19,7 @@ import { optionsControl } from "../controls/optionsControl";
import { BoolControl } from "../controls/boolControl";
import { dropdownControl } from "../controls/dropdownControl";
import { JSONObject } from "util/jsonTypes";
import { ComponentClickHandler } from "../utils/componentClickHandler";

const MacaroneList = [
'#fde68a',
Expand Down Expand Up @@ -77,7 +78,7 @@ const DropdownOption = new MultiCompBuilder(
))
.build();

const EventOptions = [clickEvent, refreshEvent] as const;
const EventOptions = [clickEvent, refreshEvent, doubleClickEvent] as const;

export const alignOptions = [
{ label: <AlignLeft />, value: "flex-start" },
Expand Down Expand Up @@ -125,7 +126,7 @@ const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & {
}}
size={props.avatarSize}
onClick={() => {
props.onEvent("click")
ComponentClickHandler({onEvent: props.onEvent})();
props.dispatch(changeChildAction("currentAvatar", item as JSONObject, false));
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { AnimationStyle } from "@lowcoder-ee/comps/controls/styleControlConstant
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
import { RecordConstructorToComp } from "lowcoder-core";
import { ToViewReturn } from "@lowcoder-ee/comps/generators/multi";
import { useCompClickEventHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const FormLabel = styled(CommonBlueLabel)`
font-size: 13px;
Expand Down Expand Up @@ -181,6 +182,7 @@ const ButtonPropertyView = React.memo((props: {
const ButtonView = React.memo((props: ToViewReturn<ChildrenType>) => {
const editorState = useContext(EditorContext);
const mountedRef = useRef<boolean>(true);
const handleClickEvent = useCompClickEventHandler({onEvent: props.onEvent});

useEffect(() => {
return () => {
Expand All @@ -193,7 +195,8 @@ const ButtonView = React.memo((props: ToViewReturn<ChildrenType>) => {

try {
if (isDefault(props.type)) {
props.onEvent("click");
// ComponentClickHandler({onEvent: props.onEvent})()
handleClickEvent();
} else {
submitForm(editorState, props.form);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import styled from "styled-components";
import { ButtonEventHandlerControl } from "comps/controls/eventHandlerControl";
import { manualOptionsControl } from "comps/controls/optionsControl";
import { useContext, useEffect } from "react";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const StyledFloatButton = styled(FloatButton)<{
$animationStyle: AnimationStyleType;
Expand Down Expand Up @@ -105,7 +106,7 @@ const FloatButtonView = (props: RecordConstructorToView<typeof childrenMap>) =>
$animationStyle={props.animationStyle}
key={button?.id}
icon={button?.icon}
onClick={() => button.onEvent("click")}
onClick={ComponentClickHandler({onEvent: button.onEvent})}
tooltip={button?.label}
description={button?.description}
badge={{ count: button?.badge, color: props.badgeStyle.badgeColor, dot: props?.dot }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import {
eventHandlerControl,
deleteEvent,
mentionEvent,
} from "comps/controls/eventHandlerControl";

doubleClickEvent,
} from "comps/controls/eventHandlerControl";
import { EditorContext } from "comps/editorState";


// Introducing styles
import {
AnimationStyle,
Expand Down Expand Up @@ -66,6 +67,7 @@ import dayjs from "dayjs";
// import "dayjs/locale/zh-cn";
import { getInitialsAndColorCode } from "util/stringUtils";
import { default as CloseOutlined } from "@ant-design/icons/CloseOutlined";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

dayjs.extend(relativeTime);
// dayjs.locale("zh-cn");
Expand All @@ -80,6 +82,7 @@ dayjs.extend(relativeTime);

const EventOptions = [
clickEvent,
doubleClickEvent,
submitEvent,
deleteEvent,
mentionEvent,
Expand Down Expand Up @@ -174,7 +177,7 @@ const CommentCompBase = (
const generateCommentAvatar = (item: commentDataTYPE) => {
return (
<Avatar
onClick={() => props.onEvent("click")}
onClick={ComponentClickHandler({onEvent: props.onEvent})}
// If there is an avatar, no background colour is set, and if displayName is not null, displayName is called using getInitialsAndColorCode
style={{
backgroundColor: item?.user?.avatar
Expand Down Expand Up @@ -290,7 +293,9 @@ const CommentCompBase = (
<List.Item.Meta
avatar={generateCommentAvatar(item)}
title={
<div onClick={() => props.onEvent("click")}>
<div
onClick={ComponentClickHandler({onEvent: props.onEvent})}
>
<a>{item?.user?.name}</a>
<Tooltip
title={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { optionsControl } from "comps/controls/optionsControl";
import { dropdownControl } from "comps/controls/dropdownControl";
import { styleControl } from "comps/controls/styleControl";
import { getBackgroundStyle } from "@lowcoder-ee/util/styleUtils";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const { Meta } = Card;

Expand Down Expand Up @@ -196,7 +197,6 @@ export const ContainerBaseComp = (function () {

return new ContainerCompBuilder(childrenMap, (props) => {
props.container.showHeader = false;
// 注入容器参数
props.container.style = Object.assign(props.container.style, {
CONTAINER_BODY_PADDING: props.style.containerBodyPadding,
border: '#00000000',
Expand Down Expand Up @@ -233,7 +233,7 @@ export const ContainerBaseComp = (function () {
$cardType={props.cardType}
onMouseEnter={() => props.onEvent('focus')}
onMouseLeave={() => props.onEvent('blur')}
onClick={() => props.onEvent('click')}
onClick={ComponentClickHandler({onEvent: props.onEvent})}
>
<Card
style={{ width: width, height: '100%' }}
Expand All @@ -249,7 +249,7 @@ export const ContainerBaseComp = (function () {
props.actionOptions.filter(item => !item.hidden).map(item => {
return (
<IconWrapper
onClick={() => item.onEvent('click')}
onClick={ComponentClickHandler({onEvent: props.onEvent})}
disabled={item.disabled}
$style={props.style}
>
Expand Down
6 changes: 4 additions & 2 deletions client/packages/lowcoder/src/comps/comps/iconComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ import { AutoHeightControl } from "../controls/autoHeightControl";
import {
clickEvent,
eventHandlerControl,
doubleClickEvent,
} from "../controls/eventHandlerControl";
import { useContext } from "react";
import { EditorContext } from "comps/editorState";
import { AssetType, IconscoutControl } from "@lowcoder-ee/comps/controls/iconscoutControl";
import { dropdownControl } from "../controls/dropdownControl";
import { ComponentClickHandler } from "../utils/componentClickHandler";

const Container = styled.div<{
$sourceMode: string;
Expand Down Expand Up @@ -72,7 +74,7 @@ const Container = styled.div<{
`}
`;

const EventOptions = [clickEvent] as const;
const EventOptions = [clickEvent, doubleClickEvent] as const;

const ModeOptions = [
{ label: "Standard", value: "standard" },
Expand Down Expand Up @@ -134,7 +136,7 @@ const IconView = (props: RecordConstructorToView<typeof childrenMap>) => {
$sourceMode={props.sourceMode}
$animationStyle={props.animationStyle}
style={style}
onClick={() => props.onEvent("click")}
onClick={ComponentClickHandler({onEvent: props.onEvent})}
>
{ props.sourceMode === 'standard'
? (props.icon || '')
Expand Down
6 changes: 4 additions & 2 deletions client/packages/lowcoder/src/comps/comps/imageComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Section, sectionNames } from "lowcoder-design";
import {
clickEvent,
eventHandlerControl,
doubleClickEvent,
} from "../controls/eventHandlerControl";
import { StringStateControl } from "../controls/codeStateControl";
import { UICompBuilder, withDefault } from "../generators";
Expand Down Expand Up @@ -37,6 +38,7 @@ import { StringControl } from "../controls/codeControl";
import { PositionControl } from "comps/controls/dropdownControl";
import { dropdownControl } from "../controls/dropdownControl";
import { AssetType, IconscoutControl } from "../controls/iconscoutControl";
import { ComponentClickHandler } from "../utils/componentClickHandler";

const Container = styled.div<{
$style: ImageStyleType | undefined,
Expand Down Expand Up @@ -112,7 +114,7 @@ const getStyle = (style: ImageStyleType) => {
`;
};

const EventOptions = [clickEvent] as const;
const EventOptions = [clickEvent, doubleClickEvent] as const;
const ModeOptions = [
{ label: "URL", value: "standard" },
{ label: "Asset Library", value: "asset-library" },
Expand Down Expand Up @@ -211,7 +213,7 @@ const ContainerImg = (props: RecordConstructorToView<typeof childrenMap>) => {
draggable={false}
preview={props.supportPreview ? {src: props.previewSrc || props.src.value } : false}
fallback={DEFAULT_IMG_URL}
onClick={() => props.onEvent("click")}
onClick={ComponentClickHandler({onEvent: props.onEvent})}
/>
</div>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { useResizeDetector } from "react-resize-detector";
import { useContext } from "react";
import { Tooltip } from "antd";
import { AssetType, IconscoutControl } from "@lowcoder-ee/comps/controls/iconscoutControl";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const Container = styled.div<{ $style: any }>`
height: 100%;
Expand Down Expand Up @@ -285,7 +286,7 @@ let ButtonTmpComp = (function () {
}
onClick={() =>
isDefault(props.type)
? props.onEvent("click")
? ComponentClickHandler({onEvent: props.onEvent})()
: submitForm(editorState, props.form)
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { withDefault } from "comps/generators";
import styled from "styled-components";
import { IconControl } from "comps/controls/iconControl";
import { hasIcon } from "comps/utils";
import { clickEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
import { clickEvent, eventHandlerControl, doubleClickEvent } from "comps/controls/eventHandlerControl";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const InputNumberWrapper = styled.div`
.ant-input-number {
Expand All @@ -33,7 +34,7 @@ const NumberViewWrapper = styled.div`
gap: 4px;
`;

const NumberEventOptions = [clickEvent] as const;
const NumberEventOptions = [clickEvent, doubleClickEvent] as const;

const childrenMap = {
text: NumberControl,
Expand Down Expand Up @@ -79,9 +80,7 @@ const ColumnNumberView = React.memo((props: NumberViewProps) => {
}, [props.value, props.float, props.precision]);

const handleClick = useCallback(() => {
if (props.onEvent) {
props.onEvent("click");
}
props.onEvent && ComponentClickHandler({onEvent: props.onEvent})()
}, [props.onEvent]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { avatarGroupStyle, AvatarGroupStyleType } from "comps/controls/styleCont
import { AlignCenter, AlignLeft, AlignRight } from "lowcoder-design";
import { NumberControl } from "comps/controls/codeControl";
import { Avatar, Tooltip } from "antd";
import { clickEvent, eventHandlerControl, refreshEvent } from "comps/controls/eventHandlerControl";
import { clickEvent, eventHandlerControl, refreshEvent, doubleClickEvent } from "comps/controls/eventHandlerControl";
import React, { ReactElement, useCallback, useEffect, useRef } from "react";
import { IconControl } from "comps/controls/iconControl";
import { ColorControl } from "comps/controls/colorControl";
import { optionsControl } from "comps/controls/optionsControl";
import { BoolControl } from "comps/controls/boolControl";
import { dropdownControl } from "comps/controls/dropdownControl";
import { JSONObject } from "util/jsonTypes";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const MacaroneList = [
'#fde68a',
Expand Down Expand Up @@ -72,7 +73,7 @@ const DropdownOption = new MultiCompBuilder(
})
.build();

const EventOptions = [clickEvent, refreshEvent] as const;
const EventOptions = [clickEvent, refreshEvent, doubleClickEvent] as const;

export const alignOptions = [
{ label: <AlignLeft />, value: "flex-start" },
Expand Down Expand Up @@ -116,7 +117,7 @@ const MemoizedAvatar = React.memo(({
}

// Then trigger main component event
onEvent("click");
ComponentClickHandler({onEvent})()
}, [onEvent, onItemEvent]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { ButtonStyle } from "comps/controls/styleControlConstants";
import { Button100 } from "comps/comps/buttonComp/buttonCompConstants";
import styled from "styled-components";
import { ButtonType } from "antd/es/button";
import { clickEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
import { clickEvent, eventHandlerControl, doubleClickEvent } from "comps/controls/eventHandlerControl";
import { ComponentClickHandler } from "@lowcoder-ee/comps/utils/componentClickHandler";

const StyledButton = styled(Button100)`
display: flex;
Expand All @@ -29,7 +30,7 @@ const StyledIconWrapper = styled(IconWrapper)`
margin: 0;
`;

const DropdownEventOptions = [clickEvent] as const;
const DropdownEventOptions = [clickEvent, doubleClickEvent] as const;

const childrenMap = {
buttonType: dropdownControl(ButtonTypeOptions, "primary"),
Expand Down Expand Up @@ -59,7 +60,7 @@ const DropdownMenu = React.memo(({ items, options, onEvent }: { items: any[]; op
const itemIndex = options.findIndex(option => option.label === item?.label);
item && options[itemIndex]?.onEvent("click");
// Also trigger the dropdown's main event handler
onEvent?.("click");
onEvent && ComponentClickHandler({onEvent})();
}, [items, options, onEvent]);

const handleMouseDown = useCallback((e: React.MouseEvent) => {
Expand Down
Loading
Loading