Skip to content

Commit

Permalink
fix(types): remove invalid use for my (#13)
Browse files Browse the repository at this point in the history
* fix(types): remove invalid use for my

* fix(types): remove invalid use for my

* chore: update mini-types version
  • Loading branch information
bytemain authored Mar 2, 2022
1 parent dda4d80 commit 4bfb1e7
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"@mini-types/alipay": "^1.0.2",
"@mini-types/alipay": "^1.0.8",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"alipay-style": "^0.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/Collapse/props.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { IBaseProps } from '../_base';

/**
* @description 手风琴,内部由多个 CollapseItem 组成。
*/

export interface ICollapseProps extends IBaseProps {
uid?: string;
/**
* @description 当前激活的索引
* @default []
Expand Down
5 changes: 3 additions & 2 deletions src/NoticeBar/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NoticeBarDefaultProps } from './props';
import { log } from '../_util/console';
import { IBoundingClientRect } from "../_base"

// eslint-disable-next-line @typescript-eslint/no-empty-function
const noop = () => { };
Expand Down Expand Up @@ -129,8 +130,8 @@ Component({
.boundingClientRect()
.exec((ret) => {
// eslint-disable-next-line max-len
const _overflowWidth = (ret && ret[0] && ret[1] && ((<my.IBoundingClientRect>ret[0]).width - (<my.IBoundingClientRect>ret[1]).width)) || 0;
const _viewWidth = (<my.IBoundingClientRect>ret[1])?.width || 0;
const _overflowWidth = (ret && ret[0] && ret[1] && ((<IBoundingClientRect>ret[0]).width - (<IBoundingClientRect>ret[1]).width)) || 0;
const _viewWidth = (<IBoundingClientRect>ret[1])?.width || 0;
let marqueeScrollWidth = _overflowWidth;
if (loop) {
marqueeScrollWidth = _overflowWidth + _viewWidth;
Expand Down
5 changes: 3 additions & 2 deletions src/SwipeAction/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SwipeActionDefaultProps } from './props';
import { ComponentContext } from '../_util/context';
import { IBoundingClientRect } from "../_base"

const swipeIdContext = new ComponentContext();

Expand Down Expand Up @@ -31,13 +32,13 @@ Component({
.select(`.amd-swipe-action-right-${this.$id}`)
.boundingClientRect()
.exec((ret) => {
this.rightBtnWidth = (ret && ret[0] && (<my.IBoundingClientRect>ret[0]).width) || 0;
this.rightBtnWidth = (ret && ret[0] && (<IBoundingClientRect>ret[0]).width) || 0;
});
my.createSelectorQuery()
.select(`.amd-swipe-action-left-${this.$id}`)
.boundingClientRect()
.exec((ret) => {
this.leftBtnWidth = (ret && ret[0] && (<my.IBoundingClientRect>ret[0]).width) || 0;
this.leftBtnWidth = (ret && ret[0] && (<IBoundingClientRect>ret[0]).width) || 0;
});
},
onSwipeTap() {
Expand Down
19 changes: 10 additions & 9 deletions src/Tabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getTabArray, componentContext } from './context';
import { log } from '../_util/console';
import { objectValues } from '../_util/tools';
import { compareVersion } from '../_util/compareVersion';
import { IBoundingClientRect } from "../_base"

const canSwipeable = my.canIUse('swiper.disable-touch');
const component2 = my.canIUse('component2');
Expand Down Expand Up @@ -59,18 +60,18 @@ Component({
.boundingClientRect()
.exec((ret) => {
const { _tabsViewportWidth } = this.data;
if (!(<my.IBoundingClientRect>ret[0])) {
if (!(<IBoundingClientRect>ret[0])) {
// 当获取到的索引值无法匹配时显示错误提示
log.error('Tabs', `激活的索引值错误,请确认 ${index} 是否为正确的索引值。`);
} else {
// 正确的索引值在初次加载时高亮展示当前 tab
// eslint-disable-next-line no-lonely-if
if ((<my.IBoundingClientRect>ret[0]).left > _tabsViewportWidth / 2) {
if ((<IBoundingClientRect>ret[0]).left > _tabsViewportWidth / 2) {
this.setData({
_scrollLeft:
(<my.IBoundingClientRect>ret[0]).left -
(<IBoundingClientRect>ret[0]).left -
_tabsViewportWidth / 2 +
(<my.IBoundingClientRect>ret[0]).width / 2,
(<IBoundingClientRect>ret[0]).width / 2,
_leftFade: true,
_swipeableAnimation: animation,
});
Expand Down Expand Up @@ -102,10 +103,10 @@ Component({
.exec((ret) => {
let { _tabsViewportWidth } = this.data;
_tabsViewportWidth = Math.floor(_tabsViewportWidth);
let left = Math.floor((<my.IBoundingClientRect>ret[0]).left) + this.data._scrollLeft;
const width = Math.floor((<my.IBoundingClientRect>ret[0]).width);
let left = Math.floor((<IBoundingClientRect>ret[0]).left) + this.data._scrollLeft;
const width = Math.floor((<IBoundingClientRect>ret[0]).width);

if (!(<my.IBoundingClientRect>ret[0])) {
if (!(<IBoundingClientRect>ret[0])) {
// 当获取到的索引值无法匹配时显示错误提示
log.error('Tabs', `激活的索引值错误,请确认 ${index} 是否为正确的索引值。`);
} else {
Expand Down Expand Up @@ -150,7 +151,7 @@ Component({
.boundingClientRect()
.exec((ret) => {
this.setData({
_tabContentHeight: (<my.IBoundingClientRect>ret[0])[tabIndex]?.height,
_tabContentHeight: (<IBoundingClientRect>ret[0])[tabIndex]?.height,
});
});
},
Expand Down Expand Up @@ -194,7 +195,7 @@ Component({
.boundingClientRect()
.exec((ret) => {
this.setData({
_tabsViewportWidth: (<my.IBoundingClientRect>ret[0]).width,
_tabsViewportWidth: (<IBoundingClientRect>ret[0]).width,
});
});
},
Expand Down
7 changes: 4 additions & 3 deletions src/VTabs/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { VTabsDefaultProps } from './props';
import { getTabArray, componentContext } from './context';
import { objectValues } from '../_util/tools';
import { IBoundingClientRect, IScrollOffset } from "../_base"

Component({
props: VTabsDefaultProps,
Expand Down Expand Up @@ -63,7 +64,7 @@ Component({
.select(`#amd-vtabs-content-slides-${this.$id}`)
.boundingClientRect()
.exec((ret) => {
resolve((<my.IBoundingClientRect>ret[0]).height);
resolve((<IBoundingClientRect>ret[0]).height);
});
});

Expand All @@ -72,7 +73,7 @@ Component({
.select(`#amd-vtabs-content-slides-${this.$id}`)
.scrollOffset()
.exec((ret) => {
resolve((<my.ScrollOffset>ret[0]).scrollTop);
resolve((<IScrollOffset>ret[0]).scrollTop);
});
});

Expand All @@ -95,7 +96,7 @@ Component({
if (i === 0) {
this.indexTop[0] = 0;
} else {
this.indexTop[i] = this.indexTop[i - 1] + (<my.IBoundingClientRect>rects[i - 1])?.height;
this.indexTop[i] = this.indexTop[i - 1] + (<IBoundingClientRect>rects[i - 1])?.height;
}

prevHeight += height;
Expand Down
31 changes: 31 additions & 0 deletions src/_base/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,34 @@ export interface IBaseFormItemProps<V = any> extends IBaseFormItemPropsWithOutFo
onBlur?: (v: V) => void;
}
export declare type IconType = string;

export interface IBoundingClientRect {
/**
* @summary 上边界
*/
top: number;
/**
* @summary 右边界
*/
right: number;
/**
* @summary 下边界
*/
bottom: number;
/**
* @summary 左边界
*/
left: number;
/**
* @summary 宽度
*/
width: number;
/**
* @summary 高度
*/
height: number;
}

export interface IScrollOffset {
scrollTop: number
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"types": ["@mini-types/alipay"]
},
"lib": ["ES2015"],
"include": ["**/*"],
"include": ["src/**/*"],
"exclude": ["node_modules","src/**/*.js"]
}

0 comments on commit 4bfb1e7

Please sign in to comment.