Skip to content
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

fix(type): fix tsc build type #155

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/_util/lightDom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
4 changes: 2 additions & 2 deletions src/back-top/back-top.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
4 changes: 2 additions & 2 deletions src/badge/badge.tsx
Original file line number Diff line number Diff line change
@@ -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 {}

Expand Down
6 changes: 3 additions & 3 deletions src/badge/index.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/breadcrumb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class Button extends Component<ButtonProps> {
static css = [];

static propTypes = {
children: [Function, Object, String, Number],
theme: String,
type: String,
variant: String,
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/bordered-none.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/footer-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/footer-content-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/header-bordered.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/header-footer-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/header-subtitle-footer-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/card/_example/header.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/checkbox/checkbox-group.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/dropdown/_example/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => <div>操作四</div>;
Expand Down
2 changes: 1 addition & 1 deletion src/dropdown/_example/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => <div>操作四</div>;
Expand Down
4 changes: 2 additions & 2 deletions src/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ export default class Input extends Component<InputProps> {
}

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 ? (
Expand Down
2 changes: 1 addition & 1 deletion src/message/const.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
8 changes: 4 additions & 4 deletions src/message/message.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/message/messageClose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions src/message/messageComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/message/messageIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/message/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AttachNode, StyledProps, Styles, TNode } from '../common.ts';
import { AttachNode, StyledProps, Styles, TNode } from '../common';

export interface TdMessageProps {
/**
Expand Down
6 changes: 4 additions & 2 deletions src/range-input/RangeInputInner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand Down Expand Up @@ -34,5 +35,6 @@ export default class RangeInput extends Input {
.${getClassPrefix()}-size-l .${getClassPrefix()}-input {
padding: 0 var(--td-comp-margin-s);
}
`;
`,
];
}
4 changes: 4 additions & 0 deletions src/space/space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export default class Space extends Component<SpaceProps> {
});
}

beforeRender(): void {
this.innerHTML = '';
}

render(props: OmiProps<SpaceProps>) {
return (
<div
Expand Down
6 changes: 3 additions & 3 deletions src/swiper/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import './style/index.ts';
import './style/index';

import _Swiper from './swiper.tsx';
import _Swiper from './swiper';

export type { SwiperProps } from './type.ts';
export type { SwiperProps } from './swiper';

export const Swiper = _Swiper;
export default Swiper;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tag/_example/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class Base extends Component {
return (
<t-space direction="vertical">
<t-space>
<t-tag>标签一</t-tag>
<t-tag icon="11">标签一</t-tag>
<a href="https://www.tencent.com/zh-cn" target="_blank" rel="noreferrer">
<t-tag>超链接</t-tag>
</a>
Expand Down
13 changes: 0 additions & 13 deletions src/tag/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/tag/tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class Tag extends Component<TagProps> {
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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tag/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SizeEnum, StyledProps, TElement, TNode } from '../common';
import { SizeEnum, StyledProps, TNode } from '../common';

export interface TagProps extends StyledProps {
/**
Expand All @@ -22,7 +22,7 @@ export interface TagProps extends StyledProps {
/**
* 标签中的图标,可自定义图标呈现
*/
icon?: TElement;
icon?: TNode;
/**
* 标签最大宽度,宽度超出后会出现省略号。示例:'50px' / 80
*/
Expand Down
2 changes: 1 addition & 1 deletion src/upload/_example/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/upload/_example/single-input.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import './style/index.js';

import _Upload from './upload';

export type { UploadProps } from './upload';
export * from './type';

export const Upload = _Upload;
Expand Down
Loading