From 0801476b8c380db6b39b553cd78952ed41a19272 Mon Sep 17 00:00:00 2001 From: duenyang <377153400@qq.com> Date: Fri, 11 Oct 2024 14:55:21 +0800 Subject: [PATCH 1/2] fix(type): fix tsc build type --- src/_util/lightDom.ts | 5 +++++ src/alert/alert.tsx | 6 +++--- src/back-top/back-top.tsx | 4 ++-- src/badge/badge.tsx | 4 ++-- src/badge/index.ts | 6 +++--- src/breadcrumb/index.ts | 2 +- src/button/button.tsx | 1 + src/card/_example/bordered-none.tsx | 2 +- src/card/_example/footer-actions.tsx | 2 +- src/card/_example/footer-content-actions.tsx | 2 +- src/card/_example/header-bordered.tsx | 2 +- src/card/_example/header-footer-actions.tsx | 2 +- .../_example/header-subtitle-footer-actions.tsx | 2 +- src/card/_example/header.tsx | 2 +- src/checkbox/checkbox-group.tsx | 4 ++-- src/checkbox/checkbox.tsx | 2 +- src/dropdown/_example/base.tsx | 2 +- src/dropdown/_example/button.tsx | 2 +- src/input/input.tsx | 4 ++-- src/message/const.tsx | 2 +- src/message/message.tsx | 8 ++++---- src/message/messageClose.tsx | 4 ++-- src/message/messageComponent.tsx | 4 ++-- src/message/messageIcon.tsx | 2 +- src/message/type.ts | 2 +- src/range-input/RangeInputInner.tsx | 6 ++++-- src/space/space.tsx | 4 ++++ src/swiper/index.ts | 6 +++--- src/swiper/style/{index.ts => index.js} | 0 src/tag/_example/base.tsx | 2 +- src/tag/index.html | 13 ------------- src/tag/tag.tsx | 2 +- src/tag/type.ts | 4 ++-- src/upload/_example/base.tsx | 2 +- src/upload/_example/single-input.tsx | 2 +- src/upload/index.ts | 1 - 36 files changed, 59 insertions(+), 61 deletions(-) rename src/swiper/style/{index.ts => index.js} (100%) delete mode 100644 src/tag/index.html diff --git a/src/_util/lightDom.ts b/src/_util/lightDom.ts index 61fae53..9005cec 100644 --- a/src/_util/lightDom.ts +++ b/src/_util/lightDom.ts @@ -89,6 +89,11 @@ const buildLightDomCtor = (nodeCtor: ComponentConstructor) => { */ export const convertToLightDomNode = (node: TNode) => { const tNode = parseTNode(node); + + if (!tNode) { + return tNode; + } + if (!(typeof tNode === 'object' && 'nodeName' in tNode && typeof tNode.nodeName === 'string')) { return tNode; } diff --git a/src/alert/alert.tsx b/src/alert/alert.tsx index 2b616c1..5de3e9d 100644 --- a/src/alert/alert.tsx +++ b/src/alert/alert.tsx @@ -6,10 +6,10 @@ import 'tdesign-icons-web-components/esm/components/close'; import { isObject } from 'lodash'; import { Component, createRef, signal, SignalValue, tag } from 'omi'; -import classname, { getClassPrefix } from '../_util/classname.ts'; -import parseTNode from '../_util/parseTNode.ts'; +import classname, { getClassPrefix } from '../_util/classname'; +import parseTNode from '../_util/parseTNode'; import { StyledProps } from '../common'; -import { TdAlertProps } from './type.ts'; +import { TdAlertProps } from './type'; export interface AlertProps extends TdAlertProps, StyledProps {} diff --git a/src/back-top/back-top.tsx b/src/back-top/back-top.tsx index a922e0d..97798cb 100644 --- a/src/back-top/back-top.tsx +++ b/src/back-top/back-top.tsx @@ -3,9 +3,9 @@ import 'tdesign-icons-web-components/esm/components/align-top'; import { Component, createRef, OmiProps, signal, SignalValue, tag } from 'omi'; import classname, { getClassPrefix } from '../_util/classname'; -import { scrollTo } from '../_util/dom.ts'; +import { scrollTo } from '../_util/dom'; import { AttachNode, StyledProps } from '../common'; -import { TdBackTopProps } from './type.ts'; +import { TdBackTopProps } from './type'; export interface BackTopProps extends TdBackTopProps, StyledProps {} diff --git a/src/badge/badge.tsx b/src/badge/badge.tsx index 9f3c42a..a22560c 100644 --- a/src/badge/badge.tsx +++ b/src/badge/badge.tsx @@ -1,8 +1,8 @@ import { classNames, Component, createRef, tag } from 'omi'; -import { getClassPrefix } from '../_util/classname.ts'; +import { getClassPrefix } from '../_util/classname'; import { StyledProps, Styles } from '../common'; -import { TdBadgeProps } from './type.ts'; +import { TdBadgeProps } from './type'; export interface BadgeProps extends TdBadgeProps, StyledProps {} diff --git a/src/badge/index.ts b/src/badge/index.ts index 3ee5a64..a5e323b 100644 --- a/src/badge/index.ts +++ b/src/badge/index.ts @@ -1,8 +1,8 @@ -import './style/index.js'; +import './style/index'; -import _Badge from './badge.tsx'; +import _Badge from './badge'; -export type { BadgeProps } from './badge.tsx'; +export type { BadgeProps } from './badge'; export const Badge = _Badge; export default Badge; diff --git a/src/breadcrumb/index.ts b/src/breadcrumb/index.ts index b25451d..0c4b057 100644 --- a/src/breadcrumb/index.ts +++ b/src/breadcrumb/index.ts @@ -5,7 +5,7 @@ import _BreadcrumbItem from './breadcrumb-item'; export * from './type'; -export type { TdBreadcrumbProps, TdBreadcrumbItemProps } from './type.ts'; +export type { TdBreadcrumbProps, TdBreadcrumbItemProps } from './type'; export const Breadcrumb = _Breadcrumb; export const BreadcrumbItem = _BreadcrumbItem; export default Breadcrumb; diff --git a/src/button/button.tsx b/src/button/button.tsx index f6f8042..d52ba47 100644 --- a/src/button/button.tsx +++ b/src/button/button.tsx @@ -17,6 +17,7 @@ export default class Button extends Component { static css = []; static propTypes = { + children: [Function, Object, String, Number], theme: String, type: String, variant: String, diff --git a/src/card/_example/bordered-none.tsx b/src/card/_example/bordered-none.tsx index 6e259ce..a214514 100644 --- a/src/card/_example/bordered-none.tsx +++ b/src/card/_example/bordered-none.tsx @@ -1,7 +1,7 @@ import 'tdesign-web-components/card'; import { bind, Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; export default class Button extends Component { @bind diff --git a/src/card/_example/footer-actions.tsx b/src/card/_example/footer-actions.tsx index b4b713e..05525a4 100644 --- a/src/card/_example/footer-actions.tsx +++ b/src/card/_example/footer-actions.tsx @@ -13,7 +13,7 @@ import 'tdesign-icons-web-components/esm/components/heart'; import 'tdesign-icons-web-components/esm/components/more'; import { Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; interface Option { content: string; diff --git a/src/card/_example/footer-content-actions.tsx b/src/card/_example/footer-content-actions.tsx index 35da24a..829767c 100644 --- a/src/card/_example/footer-content-actions.tsx +++ b/src/card/_example/footer-content-actions.tsx @@ -4,7 +4,7 @@ import 'tdesign-web-components/comment'; import 'tdesign-web-components/grid'; import { Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; interface Option { content: string; diff --git a/src/card/_example/header-bordered.tsx b/src/card/_example/header-bordered.tsx index 0d5ebd3..c6fea61 100644 --- a/src/card/_example/header-bordered.tsx +++ b/src/card/_example/header-bordered.tsx @@ -1,7 +1,7 @@ import 'tdesign-web-components/card'; import { bind, Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; export default class Button extends Component { @bind diff --git a/src/card/_example/header-footer-actions.tsx b/src/card/_example/header-footer-actions.tsx index 279c5dd..7cceca1 100644 --- a/src/card/_example/header-footer-actions.tsx +++ b/src/card/_example/header-footer-actions.tsx @@ -9,7 +9,7 @@ import 'tdesign-icons-web-components/esm/components/share'; import 'tdesign-icons-web-components/esm/components/more'; import { Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; interface Option { content: string; diff --git a/src/card/_example/header-subtitle-footer-actions.tsx b/src/card/_example/header-subtitle-footer-actions.tsx index 634107d..8948c9f 100644 --- a/src/card/_example/header-subtitle-footer-actions.tsx +++ b/src/card/_example/header-subtitle-footer-actions.tsx @@ -8,7 +8,7 @@ import 'tdesign-icons-web-components/esm/components/share'; import 'tdesign-icons-web-components/esm/components/more'; import { Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; interface Option { content: string; diff --git a/src/card/_example/header.tsx b/src/card/_example/header.tsx index 607bc60..b764554 100644 --- a/src/card/_example/header.tsx +++ b/src/card/_example/header.tsx @@ -1,7 +1,7 @@ import 'tdesign-web-components/card'; import { bind, Component } from 'omi'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; export default class Button extends Component { @bind diff --git a/src/checkbox/checkbox-group.tsx b/src/checkbox/checkbox-group.tsx index 48fe61d..cc05210 100644 --- a/src/checkbox/checkbox-group.tsx +++ b/src/checkbox/checkbox-group.tsx @@ -1,8 +1,8 @@ import { intersection, isObject, isString, isUndefined, toArray } from 'lodash'; import { bind, Component, signal, tag, VNode } from 'omi'; -import classname, { getClassPrefix } from '../_util/classname.ts'; -import { convertToLightDomNode } from '../_util/lightDom.ts'; +import classname, { getClassPrefix } from '../_util/classname'; +import { convertToLightDomNode } from '../_util/lightDom'; import { StyledProps, TNode } from '../common'; import { CheckboxContextKey } from './checkbox'; import { diff --git a/src/checkbox/checkbox.tsx b/src/checkbox/checkbox.tsx index 6f22963..091a82e 100644 --- a/src/checkbox/checkbox.tsx +++ b/src/checkbox/checkbox.tsx @@ -1,7 +1,7 @@ import { Component, createRef, signal, tag } from 'omi'; import clsx, { getClassPrefix } from '../_util/classname'; -import { StyledProps } from '../common.ts'; +import { StyledProps } from '../common'; import { TdCheckboxProps } from './type'; export const CheckboxContextKey = 'CheckboxContextKey'; diff --git a/src/dropdown/_example/base.tsx b/src/dropdown/_example/base.tsx index bffcd08..bd52cdb 100644 --- a/src/dropdown/_example/base.tsx +++ b/src/dropdown/_example/base.tsx @@ -3,7 +3,7 @@ import 'tdesign-icons-web-components'; import 'tdesign-web-components/dropdown'; import { DropdownProps } from 'tdesign-web-components/dropdown'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; export default function BasicDropdown() { const getContent = () =>
操作四
; diff --git a/src/dropdown/_example/button.tsx b/src/dropdown/_example/button.tsx index f3ec237..9053b79 100644 --- a/src/dropdown/_example/button.tsx +++ b/src/dropdown/_example/button.tsx @@ -2,7 +2,7 @@ import 'tdesign-icons-web-components'; import 'tdesign-web-components/dropdown'; import 'tdesign-web-components/button'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; export default function BasicDropdown() { const getContent = () =>
操作四
; diff --git a/src/input/input.tsx b/src/input/input.tsx index 334f27e..f0ba3dd 100644 --- a/src/input/input.tsx +++ b/src/input/input.tsx @@ -429,8 +429,8 @@ export default class Input extends Component { } const suffixIconContent = renderIcon('t', 'suffix', parseTNode(convertToLightDomNode(suffixIconNew))); - const labelContent = isFunction(label) ? label({}) : label; - const suffixContent = isFunction(suffix) ? suffix({}) : suffix; + const labelContent = isFunction(label) ? (label as Function)({}) : label; + const suffixContent = isFunction(suffix) ? (suffix as Function)({}) : suffix; const limitNumberNode = limitNumber() && showLimitNumber ? ( diff --git a/src/message/const.tsx b/src/message/const.tsx index 6ea7915..174bee9 100644 --- a/src/message/const.tsx +++ b/src/message/const.tsx @@ -1,4 +1,4 @@ -import { getClassPrefix } from 'tdesign-web-components/_util/classname.ts'; +import { getClassPrefix } from 'tdesign-web-components/_util/classname'; import { MessagePlacementList, MessageThemeList } from './type'; diff --git a/src/message/message.tsx b/src/message/message.tsx index 0e420b8..45b2c17 100644 --- a/src/message/message.tsx +++ b/src/message/message.tsx @@ -1,11 +1,11 @@ import { Component, render, tag } from 'omi'; -import { convertToLightDomNode } from 'tdesign-web-components/_util/lightDom.ts'; +import { convertToLightDomNode } from 'tdesign-web-components/_util/lightDom'; import classname from '../_util/classname'; import { AttachNodeReturnValue, Styles, TNode } from '../common'; -import { getMessageConfig, globalConfig, setGlobalConfig } from './config.ts'; -import { PlacementOffset, tdMessageListClass, tdMessagePlacementClassGenerator } from './const.tsx'; -import MessageComponent from './messageComponent.tsx'; +import { getMessageConfig, globalConfig, setGlobalConfig } from './config'; +import { PlacementOffset, tdMessageListClass, tdMessagePlacementClassGenerator } from './const'; +import MessageComponent from './messageComponent'; import { MessageCloseAllMethod, MessageContainerProps, diff --git a/src/message/messageClose.tsx b/src/message/messageClose.tsx index 47c2746..23176e1 100644 --- a/src/message/messageClose.tsx +++ b/src/message/messageClose.tsx @@ -6,9 +6,9 @@ import 'tdesign-icons-web-components/esm/components/close'; import Omi, { classNames, Component, tag } from 'omi'; import { StyledProps } from 'tdesign-web-components'; -import { parseContentTNode } from 'tdesign-web-components/_util/parseTNode.ts'; +import { parseContentTNode } from 'tdesign-web-components/_util/parseTNode'; -import { tdMessageClassGenerator } from './const.tsx'; +import { tdMessageClassGenerator } from './const'; import { TdMessageProps } from './type'; export interface TdMessageCloseProps extends TdMessageProps, StyledProps {} diff --git a/src/message/messageComponent.tsx b/src/message/messageComponent.tsx index b5998d3..5b54d48 100644 --- a/src/message/messageComponent.tsx +++ b/src/message/messageComponent.tsx @@ -2,10 +2,10 @@ import './messageClose'; import classNames from 'classnames'; import Omi, { Component, createRef, signal, tag } from 'omi'; -import MessageIcon from 'tdesign-web-components/message/messageIcon.tsx'; +import MessageIcon from 'tdesign-web-components/message/messageIcon'; import { StyledProps, TNode } from '../common'; -import { tdClassIsGenerator, tdMessageClassGenerator, tdMessagePrefix } from './const.tsx'; +import { tdClassIsGenerator, tdMessageClassGenerator, tdMessagePrefix } from './const'; // 依赖组件引入 import { TdMessageProps } from './type'; diff --git a/src/message/messageIcon.tsx b/src/message/messageIcon.tsx index 399aed0..e40ec42 100644 --- a/src/message/messageIcon.tsx +++ b/src/message/messageIcon.tsx @@ -4,7 +4,7 @@ import 'tdesign-icons-web-components/esm/components/error-circle-filled'; import 'tdesign-icons-web-components/esm/components/help-circle-filled'; import 'tdesign-web-components/loading'; -import { classPrefix } from './const.tsx'; +import { classPrefix } from './const'; import { TdMessageProps } from './type'; export default function MessageIcon({ theme, onCloseBtnClick }: TdMessageProps) { diff --git a/src/message/type.ts b/src/message/type.ts index d9de4bb..563b980 100644 --- a/src/message/type.ts +++ b/src/message/type.ts @@ -1,4 +1,4 @@ -import { AttachNode, StyledProps, Styles, TNode } from '../common.ts'; +import { AttachNode, StyledProps, Styles, TNode } from '../common'; export interface TdMessageProps { /** diff --git a/src/range-input/RangeInputInner.tsx b/src/range-input/RangeInputInner.tsx index 51f8789..093cc0c 100644 --- a/src/range-input/RangeInputInner.tsx +++ b/src/range-input/RangeInputInner.tsx @@ -4,7 +4,8 @@ import { Input } from 'tdesign-web-components/input'; @tag('t-range-input-inner') export default class RangeInput extends Input { - static css = ` + static css = [ + ` .${getClassPrefix()}-range-input__inner-left, .${getClassPrefix()}-range-input__inner-right { width: 100%; @@ -34,5 +35,6 @@ export default class RangeInput extends Input { .${getClassPrefix()}-size-l .${getClassPrefix()}-input { padding: 0 var(--td-comp-margin-s); } - `; + `, + ]; } diff --git a/src/space/space.tsx b/src/space/space.tsx index 70863ab..3c504f4 100644 --- a/src/space/space.tsx +++ b/src/space/space.tsx @@ -71,6 +71,10 @@ export default class Space extends Component { }); } + beforeRender(): void { + this.innerHTML = ''; + } + render(props: OmiProps) { return (
- 标签一 + 标签一 超链接 diff --git a/src/tag/index.html b/src/tag/index.html deleted file mode 100644 index d31c31c..0000000 --- a/src/tag/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/tag/tag.tsx b/src/tag/tag.tsx index 5971221..27b7329 100644 --- a/src/tag/tag.tsx +++ b/src/tag/tag.tsx @@ -83,7 +83,7 @@ export default class Tag extends Component { render(props: TagProps) { const { disabled, maxWidth, icon, children, content, closable, innerStyle, innerClass } = props; - if (icon) { + if (typeof icon === 'object' && 'attributes' in icon) { icon.attributes.style = {}; icon.attributes.style.marginRight = 4; } diff --git a/src/tag/type.ts b/src/tag/type.ts index 244fc1d..3722731 100644 --- a/src/tag/type.ts +++ b/src/tag/type.ts @@ -1,4 +1,4 @@ -import { SizeEnum, StyledProps, TElement, TNode } from '../common'; +import { SizeEnum, StyledProps, TNode } from '../common'; export interface TagProps extends StyledProps { /** @@ -22,7 +22,7 @@ export interface TagProps extends StyledProps { /** * 标签中的图标,可自定义图标呈现 */ - icon?: TElement; + icon?: TNode; /** * 标签最大宽度,宽度超出后会出现省略号。示例:'50px' / 80 */ diff --git a/src/upload/_example/base.tsx b/src/upload/_example/base.tsx index 71c215c..9ee41a5 100644 --- a/src/upload/_example/base.tsx +++ b/src/upload/_example/base.tsx @@ -2,7 +2,7 @@ import 'tdesign-icons-web-components/esm/components/close'; import { Component, computed, createRef, signal } from 'omi'; import Button from 'tdesign-web-components/button'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; import Space from 'tdesign-web-components/space'; import type { UploadFile, UploadProps } from 'tdesign-web-components/upload'; import Upload from 'tdesign-web-components/upload'; diff --git a/src/upload/_example/single-input.tsx b/src/upload/_example/single-input.tsx index 5981d03..ef064f3 100644 --- a/src/upload/_example/single-input.tsx +++ b/src/upload/_example/single-input.tsx @@ -1,6 +1,6 @@ import { Component, createRef, signal } from 'omi'; import { Button, Space, Upload } from 'tdesign-web-components'; -import { MessagePlugin } from 'tdesign-web-components/message/message.tsx'; +import { MessagePlugin } from 'tdesign-web-components/message/message'; import type { UploadProps } from 'tdesign-web-components/upload'; export default class UploadSingleInput extends Component { diff --git a/src/upload/index.ts b/src/upload/index.ts index 18f09e3..cf789a7 100644 --- a/src/upload/index.ts +++ b/src/upload/index.ts @@ -2,7 +2,6 @@ import './style/index.js'; import _Upload from './upload'; -export type { UploadProps } from './upload'; export * from './type'; export const Upload = _Upload; From 9b54e6c1f6ab93b8259952cc5fdc065f457d4b91 Mon Sep 17 00:00:00 2001 From: duenyang <377153400@qq.com> Date: Fri, 11 Oct 2024 16:05:59 +0800 Subject: [PATCH 2/2] fix(type): input-number --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index f9683c1..7033aea 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit f9683c1edee5c09f455ba8cb19cb8ce07d4490be +Subproject commit 7033aea8c26f5619c2e8ed44325a94752920a2bb