Skip to content

Commit

Permalink
Merge pull request #180 from duenyang/develop
Browse files Browse the repository at this point in the history
feat(omi): 优化非omi环境下使用
  • Loading branch information
duenyang authored Jan 2, 2025
2 parents 67c7e83 + ae1f140 commit 20e6da6
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 139 deletions.
204 changes: 102 additions & 102 deletions CHANGELOG.md

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"site:intranet": "cd site && vite build --mode intranet",
"site:preview": "cd site && vite build --mode preview && cd ../_site && cp index.html 404.html",
"prebuild": "rimraf es/* lib/* dist/* esm/*",
"build": "npm run generate:entry && cross-env NODE_ENV=production rollup -c script/rollup.config.js",
"build": "npm run generate:entry && cross-env NODE_ENV=production rollup -c script/rollup.config.js && npm run build:tsc",
"build:tsc": "run-p build:tsc-*",
"build:tsc-lib": "tsc --emitDeclarationOnly -d -p ./tsconfig.build.json --outDir lib/",
"build:tsc-esm": "tsc --emitDeclarationOnly -d -p ./tsconfig.build.json --outDir esm/",
Expand Down Expand Up @@ -60,9 +60,6 @@
"path": "@commitlint/cz-commitlint"
}
},
"peerDependencies": {
"omi": ">=7.7.1"
},
"dependencies": {
"@babel/runtime": "^7.24.7",
"@popperjs/core": "^2.11.8",
Expand All @@ -71,6 +68,7 @@
"copy-to-clipboard": "^3.3.3",
"htm": "^3.1.1",
"lodash": "~4.17.15",
"omi": "^7.7.4",
"omi-transition": "^0.1.11",
"tailwind-merge": "^2.2.1",
"tdesign-icons-web-components": "^0.2.0"
Expand Down
7 changes: 4 additions & 3 deletions src/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default class Button extends Component<ButtonProps> {
loading,
shape,
ignoreAttributes,
children,
suffix,
innerClass,
innerStyle,
Expand Down Expand Up @@ -129,8 +128,10 @@ export default class Button extends Component<ButtonProps> {
style={innerStyle}
{...rest}
>
{iconNode ? iconNode : null}
<span className={`${classPrefix}-button__text`}>{children}</span>
<slot name="icon">{iconNode ? iconNode : null}</slot>
<span className={`${classPrefix}-button__text`}>
<slot></slot>
</span>
{suffix && <span className={`${classPrefix}-button__suffix`}>{parseTNode(suffix)}</span>}
</Tag>
);
Expand Down
18 changes: 10 additions & 8 deletions src/popup/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export interface PopupProps extends TdPopupProps, StyledProps {
updateScrollTop?: (content: HTMLElement) => void;
}

export const defaultProps = {
attach: 'body',
destroyOnClose: false,
hideEmptyPopup: false,
placement: 'top',
showArrow: true,
trigger: 'hover' as TdPopupProps['trigger'],
};

export const PopupTypes = {
attach: [String, Function],
content: [String, Number, Object, Function],
Expand Down Expand Up @@ -59,14 +68,7 @@ export default class Popup extends Component<PopupProps> {

static propTypes = PopupTypes;

static defaultProps = {
attach: 'body',
destroyOnClose: false,
hideEmptyPopup: false,
placement: 'top',
showArrow: true,
trigger: 'hover',
};
static defaultProps = defaultProps;

triggerRef = createRef();

Expand Down
30 changes: 16 additions & 14 deletions src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import '../popup';

import { Component, createRef, OmiProps, tag } from 'omi';
import { Component, createElement, createRef, OmiProps, tag } from 'omi';

import classname, { getClassPrefix } from '../_util/classname';
import { StyledProps } from '../common';
import { type PopupVisibleChangeContext } from '../popup';
import { defaultProps as popupDefaultProps } from '../popup/popup';
import { PopupTypes } from '../popup/popup';
import { TdTooltipProps } from './type';

export interface TooltipProps extends TdTooltipProps, StyledProps {}

export const tooltipDefaultProps: TooltipProps = {
...popupDefaultProps,
destroyOnClose: true,
placement: 'top',
showArrow: true,
Expand Down Expand Up @@ -100,19 +102,19 @@ export default class Tooltip extends Component<TooltipProps> {
});
}

return (
<t-popup
visible={this.popupVisible}
destroyOnClose={destroyOnClose}
showArrow={showArrow}
overlayClassName={toolTipClass}
onVisibleChange={this.handleVisibleChange}
placement={placement}
{...restProps}
ref={this.popupRef}
>
{children}
</t-popup>
return createElement(
't-popup',
{
visible: this.popupVisible,
destroyOnClose,
showArrow,
overlayClassName: toolTipClass,
onVisibleChange: this.handleVisibleChange,
placement,
...restProps,
ref: this.popupRef,
},
children,
);
}
}

0 comments on commit 20e6da6

Please sign in to comment.