Skip to content

Commit 14dae48

Browse files
authored
Merge pull request #1576 from easyops-cn/steve/jsx
fix(jsx): refine event types
2 parents c86a975 + e1f48c6 commit 14dae48

File tree

3 files changed

+72
-30
lines changed

3 files changed

+72
-30
lines changed

bricks/basic/src/jsx.ts

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ import type { Menu, MenuProps } from "./menu";
2121
import type { List, ListProps } from "./list";
2222
import type { Popover, PopoverProps } from "./popover";
2323
import type { EoContextMenu, EoContextMenuProps } from "./context-menu";
24-
import type { TagList, TagListProps } from "./tag-list";
24+
import type { TagList, TagListProps, TagListItem } from "./tag-list";
2525
import type { EoPageTitle, PageTitleProps } from "./page-title";
2626
import type { EoImage, ImageProps } from "./image";
2727
import type { EoEasyopsAvatar, EoEasyopsAvatarProps } from "./easyops-avatar";
28-
import type { EoMiniActions, EoMiniActionsProps } from "./mini-actions";
28+
import type {
29+
EoMiniActions,
30+
EoMiniActionsProps,
31+
SimpleActionType,
32+
} from "./mini-actions";
2933
import type {
3034
DropdownSelect,
3135
DropdownSelectProps,
@@ -62,6 +66,7 @@ import type { EoAppBarWrapper, AppBarWrapperProps } from "./app-bar-wrapper";
6266
import type { EoTooltip, ToolTipProps } from "./tooltip";
6367
import type { EoCounterBadge, BadgeProps } from "./counter-badge";
6468
import type { EoSidebar, EoSidebarProps } from "./sidebar";
69+
import type { ExpandedState } from "./sidebar/utils";
6570
import type { EoSidebarMenu, EoSidebarMenuProps } from "./sidebar/sidebar-menu";
6671
import type {
6772
EoSidebarMenuGroup,
@@ -75,6 +80,8 @@ import type {
7580
EoSidebarMenuItem,
7681
EoSidebarMenuItemProps,
7782
} from "./sidebar/sidebar-menu-item";
83+
import type { EoBatchAgent } from "./batch-agent";
84+
import type { EoEventAgent } from "./event-agent";
7885

7986
declare global {
8087
// eslint-disable-next-line @typescript-eslint/no-namespace
@@ -98,6 +105,12 @@ declare global {
98105
EoAvatarGroup
99106
> &
100107
EoAvatarGroupProps;
108+
"eo-batch-agent": DetailedHTMLProps<
109+
HTMLAttributes<EoBatchAgent>,
110+
EoBatchAgent
111+
> & {
112+
onTrigger?: (event: CustomEvent<{ type: string }>) => void;
113+
};
101114
"eo-breadcrumb": DetailedHTMLProps<
102115
HTMLAttributes<EoBreadcrumb>,
103116
EoBreadcrumb
@@ -134,12 +147,18 @@ declare global {
134147
HTMLAttributes<EoDropdownActions>,
135148
EoDropdownActions
136149
> &
137-
DropdownActionsProps;
150+
DropdownActionsProps & {
151+
onActionClick?: (event: CustomEvent<SimpleAction>) => void;
152+
onVisibleChange?: (event: CustomEvent<boolean>) => void;
153+
};
138154
"eo-dropdown-button": DetailedHTMLProps<
139155
HTMLAttributes<DropdownButton>,
140156
DropdownButton
141157
> &
142-
DropdownButtonProps;
158+
DropdownButtonProps & {
159+
onActionClick?: (event: CustomEvent<SimpleAction>) => void;
160+
onVisibleChange?: (event: CustomEvent<boolean>) => void;
161+
};
143162
"eo-dropdown-select": DetailedHTMLProps<
144163
HTMLAttributes<DropdownSelect>,
145164
DropdownSelect
@@ -152,6 +171,12 @@ declare global {
152171
EoEasyopsAvatar
153172
> &
154173
EoEasyopsAvatarProps;
174+
"eo-event-agent": DetailedHTMLProps<
175+
HTMLAttributes<EoEventAgent>,
176+
EoEventAgent
177+
> & {
178+
onTrigger?: (event: CustomEvent<unknown>) => void;
179+
};
155180
"eo-formatter-number": DetailedHTMLProps<
156181
HTMLAttributes<EoFormatterNumber>,
157182
EoFormatterNumber
@@ -167,7 +192,9 @@ declare global {
167192
onLoad?: (event: CustomEvent<void>) => void;
168193
};
169194
"eo-image": DetailedHTMLProps<HTMLAttributes<EoImage>, EoImage> &
170-
ImageProps;
195+
ImageProps & {
196+
onVisibleChange?: (event: CustomEvent<boolean>) => void;
197+
};
171198
"eo-link": DetailedHTMLProps<HTMLAttributes<Link>, Link> & LinkProps;
172199
"eo-list": DetailedHTMLProps<HTMLAttributes<List>, List> & ListProps;
173200
"eo-loading-container": DetailedHTMLProps<
@@ -199,7 +226,8 @@ declare global {
199226
EoMiniActions
200227
> &
201228
EoMiniActionsProps & {
202-
onActionClick?: (event: CustomEvent<SimpleAction>) => void;
229+
onActionClick?: (event: CustomEvent<SimpleActionType>) => void;
230+
onVisibleChange?: (event: CustomEvent<boolean>) => void;
203231
};
204232
"eo-page-title": DetailedHTMLProps<
205233
HTMLAttributes<EoPageTitle>,
@@ -212,7 +240,10 @@ declare global {
212240
onBeforeVisibleChange?: (event: CustomEvent<boolean>) => void;
213241
};
214242
"eo-sidebar": DetailedHTMLProps<HTMLAttributes<EoSidebar>, EoSidebar> &
215-
EoSidebarProps;
243+
EoSidebarProps & {
244+
onActualWidthChange?: (event: CustomEvent<number>) => void;
245+
onExpandedStateChange?: (event: CustomEvent<ExpandedState>) => void;
246+
};
216247
"eo-sidebar-menu": DetailedHTMLProps<
217248
HTMLAttributes<EoSidebarMenu>,
218249
EoSidebarMenu
@@ -243,15 +274,40 @@ declare global {
243274
onClose?: (event: CustomEvent<TagProps>) => void;
244275
};
245276
"eo-tag-list": DetailedHTMLProps<HTMLAttributes<TagList>, TagList> &
246-
TagListProps;
247-
"eo-text": DetailedHTMLProps<HTMLAttributes<EoText>, EoText> & TextProps;
277+
TagListProps & {
278+
onCheck?: (
279+
event: CustomEvent<{
280+
item: TagListItem | string | undefined;
281+
list: TagListItem[];
282+
}>
283+
) => void;
284+
onClose?: (
285+
event: CustomEvent<{
286+
item: TagListItem | string | undefined;
287+
list: TagListItem[];
288+
}>
289+
) => void;
290+
onTagClick?: (
291+
event: CustomEvent<TagListItem | string | undefined>
292+
) => void;
293+
};
294+
"eo-text": DetailedHTMLProps<HTMLAttributes<EoText>, EoText> &
295+
TextProps & {
296+
onChange?: (event: CustomEvent<string>) => void;
297+
onUpdate?: (event: CustomEvent<string>) => void;
298+
};
248299
"eo-toggle-link": DetailedHTMLProps<
249300
HTMLAttributes<ToggleLink>,
250301
ToggleLink
251302
> &
252-
ToggleLinkProps;
303+
ToggleLinkProps & {
304+
onToggle?: (event: CustomEvent<boolean>) => void;
305+
};
253306
"eo-tooltip": DetailedHTMLProps<HTMLAttributes<EoTooltip>, EoTooltip> &
254-
ToolTipProps;
307+
ToolTipProps & {
308+
onOpenChange?: (event: CustomEvent<boolean>) => void;
309+
onAfterOpenChange?: (event: CustomEvent<boolean>) => void;
310+
};
255311
"eo-viewport": DetailedHTMLProps<HTMLAttributes<EoViewport>, EoViewport> &
256312
ViewportProps;
257313
}

bricks/basic/src/text/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const typeElementNameMap: Record<string, "code" | "kbd" | "span"> = {
7474
};
7575

7676
export interface TextProps {
77-
type: TextType;
77+
type?: TextType;
7878
editable?: boolean | EditableConfig | undefined;
7979
color?: CSSProperties["color"];
8080
fontSize?: CSSProperties["fontSize"];

bricks/containers/src/jsx.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import type { EoPopup, EoPopupProps } from "./popup";
1616
import type { ResizableBox, ResizableBoxProps } from "./resizable-box";
1717
import type { SearchBar, SearchBarProps } from "./search-bar";
1818
import type { EoSpin, EoSpinProps } from "./spin";
19-
import type { TabGroup, TabGroupProps } from "./tab/tab-group";
20-
import type { TabItem, TabItemProps } from "./tab/tab-item";
2119
import type { TabList, TabListProps } from "./tab/tab-list";
2220

2321
declare global {
@@ -55,7 +53,9 @@ declare global {
5553
HTMLAttributes<EoMainView>,
5654
EoMainView
5755
> &
58-
MainViewProps;
56+
MainViewProps & {
57+
onDashboardExit?: (event: CustomEvent<void>) => void;
58+
};
5959
"eo-micro-view": DetailedHTMLProps<HTMLAttributes<MicroView>, MicroView>;
6060
"eo-modal": DetailedHTMLProps<HTMLAttributes<Modal>, Modal> &
6161
ModalProps & {
@@ -80,25 +80,11 @@ declare global {
8080
HTMLAttributes<ResizableBox>,
8181
ResizableBox
8282
> &
83-
ResizableBoxProps & {
84-
onResizeStart?: (event: CustomEvent<void>) => void;
85-
onResize?: (
86-
event: CustomEvent<{ width: number; height: number }>
87-
) => void;
88-
onResizeStop?: (
89-
event: CustomEvent<{ width: number; height: number }>
90-
) => void;
91-
};
83+
ResizableBoxProps;
9284
"eo-search-bar": DetailedHTMLProps<HTMLAttributes<SearchBar>, SearchBar> &
9385
SearchBarProps;
9486
"eo-spin": DetailedHTMLProps<HTMLAttributes<EoSpin>, EoSpin> &
9587
EoSpinProps;
96-
"eo-tab-group": DetailedHTMLProps<HTMLAttributes<TabGroup>, TabGroup> &
97-
TabGroupProps & {
98-
onTabSelect?: (event: CustomEvent<string>) => void;
99-
};
100-
"eo-tab-item": DetailedHTMLProps<HTMLAttributes<TabItem>, TabItem> &
101-
TabItemProps;
10288
"eo-tab-list": DetailedHTMLProps<HTMLAttributes<TabList>, TabList> &
10389
TabListProps & {
10490
onTabSelect?: (event: CustomEvent<string>) => void;

0 commit comments

Comments
 (0)