GeezerVison is showing github.com — feat(common-ui): add HelpTip · vanestone/lowcode-engine@ce72fc1
File treeExpand file treeCollapse file tree Open diff view settings editor-core/src/widgets/tip editor-skeleton/src/components/widget-views
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/commonUI.md +10Lines changed: 10 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,16 @@ CommonUI API 是一个专为低代码引擎设计的组件 UI 库,使用它开 | 19 | 19 | | direction | tip 的方向 | 'top' \| 'bottom' \| 'left' \| 'right' | | | 20 | 20 |
| 21 | 21 |
| | 22 | +### HelpTip | | 23 | + | | 24 | +带 help icon 的提示组件 | | 25 | + | | 26 | +| 参数 | 说明 | 类型 | 默认值 | | | 27 | +|-----------|--------|-----------------------------------|--------| | | 28 | +| help | 描述 | IPublicTypeHelpTipConfig | | | | 29 | +| direction | 方向 | IPublicTypeTipConfig['direction'] | 'top' | | | 30 | +| size | 方向 | IconProps['size'] | 'small'| | | 31 | + | 22 | 32 | ### Title | 23 | 33 |
| 24 | 34 | 标题组件 | |
Collapse file Copy file name to clipboard +40Lines changed: 40 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { IPublicTypeHelpTipConfig, IPublicTypeTipConfig } from '@alilc/lowcode-types'; | | 2 | +import { Tip } from './tip'; | | 3 | +import { Icon } from '@alifd/next'; | | 4 | +import { IconProps } from '@alifd/next/types/icon'; | | 5 | + | | 6 | +export function HelpTip({ | | 7 | + help, | | 8 | + direction = 'top', | | 9 | + size = 'small', | | 10 | +}: { | | 11 | + help: IPublicTypeHelpTipConfig; | | 12 | + direction?: IPublicTypeTipConfig['direction']; | | 13 | + size?: IconProps['size']; | | 14 | +}) { | | 15 | + if (typeof help === 'string') { | | 16 | + return ( | | 17 | + <div> | | 18 | + <Icon type="help" size={size} className="lc-help-tip" /> | | 19 | + <Tip direction={direction}>{help}</Tip> | | 20 | + </div> | | 21 | + ); | | 22 | + } | | 23 | + | | 24 | + if (typeof help === 'object' && help.url) { | | 25 | + return ( | | 26 | + <div> | | 27 | + <a href={help.url} target="_blank" rel="noopener noreferrer"> | | 28 | + <Icon type="help" size={size} className="lc-help-tip" /> | | 29 | + </a> | | 30 | + <Tip direction={direction}>{help.content}</Tip> | | 31 | + </div> | | 32 | + ); | | 33 | + } | | 34 | + return ( | | 35 | + <div> | | 36 | + <Icon type="help" size="small" className="lc-help-tip" /> | | 37 | + <Tip direction={direction}>{help.content}</Tip> | | 38 | + </div> | | 39 | + ); | | 40 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-core/src/widgets/tip/index.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,3 +2,4 @@ import './style.less'; | 2 | 2 |
| 3 | 3 | export * from './tip'; | 4 | 4 | export * from './tip-container'; | | 5 | +export * from './help-tips'; |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/components/widget-views/index.tsx +2-22Lines changed: 2 additions & 22 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Component, ReactElement } from 'react'; | 2 | | -import { Icon } from '@alifd/next'; | 3 | 2 | import classNames from 'classnames'; | 4 | | -import { Title, observer, Tip } from '@alilc/lowcode-editor-core'; | | 3 | +import { Title, observer, HelpTip } from '@alilc/lowcode-editor-core'; | 5 | 4 | import { DockProps } from '../../types'; | 6 | 5 | import { PanelDock } from '../../widget/panel-dock'; | 7 | 6 | import { composeTitle } from '../../widget/utils'; | @@ -26,25 +25,6 @@ export function DockView({ title, icon, description, size, className, onClick }: | 26 | 25 | ); | 27 | 26 | } | 28 | 27 |
| 29 | | -function HelpTip({ tip }: any) { | 30 | | - if (tip && tip.url) { | 31 | | - return ( | 32 | | - <div> | 33 | | - <a href={tip.url} target="_blank" rel="noopener noreferrer"> | 34 | | - <Icon type="help" size="small" className="lc-help-tip" /> | 35 | | - </a> | 36 | | - <Tip>{tip.content}</Tip> | 37 | | - </div> | 38 | | - ); | 39 | | - } | 40 | | - return ( | 41 | | - <div> | 42 | | - <Icon type="help" size="small" className="lc-help-tip" /> | 43 | | - <Tip>{tip.content}</Tip> | 44 | | - </div> | 45 | | - ); | 46 | | -} | 47 | | - | 48 | 28 | @observer | 49 | 29 | export class PanelDockView extends Component<DockProps & { dock: PanelDock }> { | 50 | 30 | private lastActived = false; | @@ -328,7 +308,7 @@ class PanelTitle extends Component<{ panel: Panel; className?: string }> { | 328 | 308 | data-name={panel.name} | 329 | 309 | > | 330 | 310 | <Title title={panel.title || panel.name} /> | 331 | | - {panel.help ? <HelpTip tip={panel.help} /> : null} | | 311 | + {panel.help ? <HelpTip help={panel.help} /> : null} | 332 | 312 | </div> | 333 | 313 | ); | 334 | 314 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/api/commonUI.tsx +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { IPublicApiCommonUI, IPublicModelPluginContext, IPublicTypeContextMenuAction } from '@alilc/lowcode-types'; | 2 | 2 | import { | | 3 | + HelpTip, | 3 | 4 | IEditor, | 4 | 5 | Tip as InnerTip, | 5 | 6 | Title as InnerTitle, | @@ -46,6 +47,11 @@ export class CommonUI implements IPublicApiCommonUI { | 46 | 47 | get Tip() { | 47 | 48 | return InnerTip; | 48 | 49 | } | | 50 | + | | 51 | + get HelpTip() { | | 52 | + return HelpTip; | | 53 | + } | | 54 | + | 49 | 55 | get Title() { | 50 | 56 | return InnerTitle; | 51 | 57 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/types/src/shell/api/commonUI.ts +28-8Lines changed: 28 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { ReactElement } from 'react'; | 2 | | -import { IPublicTypeContextMenuAction, IPublicTypeTitleContent } from '../type'; | | 1 | +import React, { ReactElement } from 'react'; | | 2 | +import { IPublicTypeContextMenuAction, IPublicTypeHelpTipConfig, IPublicTypeTipConfig, IPublicTypeTitleContent } from '../type'; | 3 | 3 | import { Balloon, Breadcrumb, Button, Card, Checkbox, DatePicker, Dialog, Dropdown, Form, Icon, Input, Loading, Message, Overlay, Pagination, Radio, Search, Select, SplitButton, Step, Switch, Tab, Table, Tree, TreeSelect, Upload, Divider } from '@alifd/next'; | | 4 | +import { IconProps } from '@alifd/next/types/icon'; | 4 | 5 |
| 5 | 6 | export interface IPublicApiCommonUI { | 6 | 7 | Balloon: typeof Balloon; | @@ -33,22 +34,41 @@ export interface IPublicApiCommonUI { | 33 | 34 |
| 34 | 35 | /** | 35 | 36 | * Title 组件 | 36 | | - * @experimental unstable API, pay extra caution when trying to use this | 37 | 37 | */ | 38 | | - get Tip(): React.ComponentClass<{}>; | | 38 | + get Tip(): React.ComponentClass<IPublicTypeTipConfig>; | | 39 | + | | 40 | + /** | | 41 | + * HelpTip 组件 | | 42 | + */ | | 43 | + get HelpTip(): React.VFC<{ | | 44 | + help: IPublicTypeHelpTipConfig; | | 45 | + | | 46 | + /** | | 47 | + * 方向 | | 48 | + * @default 'top' | | 49 | + */ | | 50 | + direction: IPublicTypeTipConfig['direction']; | | 51 | + | | 52 | + /** | | 53 | + * 大小 | | 54 | + * @default 'small' | | 55 | + */ | | 56 | + size: IconProps['size']; | | 57 | + }>; | 39 | 58 |
| 40 | 59 | /** | 41 | 60 | * Tip 组件 | 42 | | - * @experimental unstable API, pay extra caution when trying to use this | 43 | 61 | */ | 44 | 62 | get Title(): React.ComponentClass<{ | 45 | 63 | title: IPublicTypeTitleContent | undefined; | 46 | 64 | match?: boolean; | 47 | 65 | keywords?: string | null; | 48 | 66 | }>; | 49 | 67 |
| 50 | | - get ContextMenu(): (props: { | | 68 | + get ContextMenu(): ((props: { | 51 | 69 | menus: IPublicTypeContextMenuAction[]; | 52 | 70 | children: React.ReactElement[] | React.ReactElement; | 53 | | - }) => ReactElement; | 54 | | -} | | 71 | + }) => ReactElement) & { | | 72 | + create(menus: IPublicTypeContextMenuAction[], event: MouseEvent | React.MouseEvent): void; | | 73 | + }; | | 74 | +} |
|