Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

antd-mini

Package Overview
Dependencies
Maintainers
2
Versions
216
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antd-mini - npm Package Compare versions

Comparing version 0.0.3-beta.14 to 0.0.3

1

es/Tabs/context.js
import { ComponentContext } from '../_util/context';
export var componentContext = new ComponentContext();
export var componentContextFallback = new ComponentContext();
export var getTabArray = {};

133

es/Tabs/index.js
/* eslint-disable @typescript-eslint/no-explicit-any */
import { TabsDefaultProps } from './props';
import { getTabArray, componentContext } from './context';
import { getTabArray, componentContext, componentContextFallback } from './context';
import { log } from '../_util/console';

@@ -13,2 +13,3 @@ import { objectValues } from '../_util/tools';

var isMoreThan275 = compareVersion(my.SDKVersion, '2.7.5') >= 0;
var isBaseSwiper = compareVersion(my.SDKVersion, '2.0.0') >= 0;
Component({

@@ -29,2 +30,3 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars

component2: component2,
isBaseSwiper: isBaseSwiper,
_forceRefreshSwiper: 0,

@@ -46,2 +48,3 @@ _isForceUpdate: isForceUpdate

});
componentContextFallback.update(this.props.fallback);
var _this$props = this.props,

@@ -64,23 +67,23 @@ index = _this$props.index,

my.createSelectorQuery().select("#amd-tabs-bar-item-" + index).boundingClientRect().exec(function (ret) {
var _tabsViewportWidth = _this.data._tabsViewportWidth;
if (!ret[0]) {
if (!ret || !ret[0]) {
// 当获取到的索引值无法匹配时显示错误提示
log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 " + index + " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002");
return;
}
var _tabsViewportWidth = _this.data._tabsViewportWidth; // 正确的索引值在初次加载时高亮展示当前 tab
// eslint-disable-next-line no-lonely-if
if (ret[0].left > _tabsViewportWidth / 2) {
_this.setData({
_scrollLeft: ret[0].left - _tabsViewportWidth / 2 + ret[0].width / 2,
_leftFade: true,
_swipeableAnimation: animation
});
} else {
// 正确的索引值在初次加载时高亮展示当前 tab
// eslint-disable-next-line no-lonely-if
if (ret[0].left > _tabsViewportWidth / 2) {
_this.setData({
_scrollLeft: ret[0].left - _tabsViewportWidth / 2 + ret[0].width / 2,
_leftFade: true,
_swipeableAnimation: animation
});
} else {
_this.setData({
_scrollLeft: 0,
_leftFade: false,
_swipeableAnimation: animation
});
}
_this.setData({
_scrollLeft: 0,
_leftFade: false,
_swipeableAnimation: animation
});
}

@@ -101,4 +104,9 @@ });

index = _this$props2.index,
animation = _this$props2.animation;
animation = _this$props2.animation,
fallback = _this$props2.fallback;
if (prevProps.fallback !== fallback) {
componentContextFallback.update(fallback);
}
if (prevProps.index !== index && prevData.currentIndex === this.data.currentIndex) {

@@ -108,2 +116,8 @@ this._getTabsWidth();

my.createSelectorQuery().select("#amd-tabs-bar-item-" + index).boundingClientRect().exec(function (ret) {
if (!ret || !ret[0]) {
// 当获取到的索引值无法匹配时显示错误提示
log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 " + index + " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002");
return;
}
var _tabsViewportWidth = _this2.data._tabsViewportWidth;

@@ -114,29 +128,23 @@ _tabsViewportWidth = Math.floor(_tabsViewportWidth);

var width = Math.floor(ret[0].width);
var width = Math.floor(ret[0].width); // 正确的索引值在初次加载时高亮展示当前 tab
if (!ret[0]) {
// 当获取到的索引值无法匹配时显示错误提示
log.error('Tabs', "\u6FC0\u6D3B\u7684\u7D22\u5F15\u503C\u9519\u8BEF\uFF0C\u8BF7\u786E\u8BA4 " + index + " \u662F\u5426\u4E3A\u6B63\u786E\u7684\u7D22\u5F15\u503C\u3002");
if (_this2.changeTap) {
left = _this2.currentLeft;
_this2.changeTap = false;
}
if (left > _tabsViewportWidth / 2) {
_this2.setData({
_scrollLeft: left - _tabsViewportWidth / 2 + width / 2,
_leftFade: true,
currentIndex: index,
_swipeableAnimation: animation
});
} else {
// 正确的索引值在初次加载时高亮展示当前 tab
if (_this2.changeTap) {
left = _this2.currentLeft;
_this2.changeTap = false;
}
if (left > _tabsViewportWidth / 2) {
_this2.setData({
_scrollLeft: left - _tabsViewportWidth / 2 + width / 2,
_leftFade: true,
currentIndex: index,
_swipeableAnimation: animation
});
} else {
_this2.setData({
_scrollLeft: 0,
_leftFade: false,
currentIndex: index,
_swipeableAnimation: animation
});
}
_this2.setData({
_scrollLeft: 0,
_leftFade: false,
currentIndex: index,
_swipeableAnimation: animation
});
}

@@ -158,3 +166,4 @@ });

if (isShouldNotCalHeight) return; // tabItem 自适应高度的处理
if (isShouldNotCalHeight) return;
if (this.props.fallback) return; // tabItem 自适应高度的处理
// 获取每个 item-pane 的高度,通过传入当前 tab 的 index 值

@@ -164,7 +173,9 @@ // 动态修改 _tabContentHeight 后在 axml 中插入修改

my.createSelectorQuery().selectAll("#amd-tabs-content-" + this.$id + " .amd-tabs-item-pane").boundingClientRect().exec(function (ret) {
var _tabIndex;
if (ret && ret[0]) {
var _tabIndex;
_this3.setData({
_tabContentHeight: (_tabIndex = ret[0][tabIndex]) == null ? void 0 : _tabIndex.height
});
_this3.setData({
_tabContentHeight: (_tabIndex = ret[0][tabIndex]) == null ? void 0 : _tabIndex.height
});
}
});

@@ -219,5 +230,7 @@ },

my.createSelectorQuery().select("#amd-tabs-bar-scroll-view-" + this.$id).boundingClientRect().exec(function (ret) {
_this4.setData({
_tabsViewportWidth: ret[0].width
});
if (ret && ret[0]) {
_this4.setData({
_tabsViewportWidth: ret[0].width
});
}
});

@@ -244,2 +257,16 @@ },

},
handleSwiperTouchStart: function handleSwiperTouchStart(e) {
var onTouchStart = this.props.onTouchStart;
if (typeof onTouchStart === "function") {
onTouchStart(e);
}
},
handleSwiperTransition: function handleSwiperTransition(e) {
var onTransition = this.props.onTransition;
if (typeof onTransition === "function") {
onTransition(e);
}
},
appearLeft: function appearLeft() {

@@ -246,0 +273,0 @@ this.setData({

import { IBaseProps } from '../_base';
/**
* @description 标签栏,内部配合 TabItem 使用。
*/
export interface ITabsProps extends IBaseProps {

@@ -17,3 +17,2 @@ /**

*/
index?: number;

@@ -23,3 +22,2 @@ /**

*/
onChange?: (index: number) => void;

@@ -30,3 +28,2 @@ /**

*/
animation?: boolean;

@@ -38,3 +35,2 @@ /**

swipeable?: boolean;
/**

@@ -45,3 +41,28 @@ * @description 是否支持吸顶

sticky?: boolean;
/**
* @description 吸顶高度
* @default 0
*/
stickyTop?: boolean;
/**
* @description 内部 swiper 组件的 onTouchStart 事件(仅在基础库 2.x 版本生效)
* @default 0
*/
onTouchStart?: (e:any) => void;
/**
* @description 内部 swiper 组件的 onTouchStart 事件(仅在基础库 2.x 版本下生效)
* @default 0
*/
onTransition?: (e:any) => void;
/**
* @description 是否自定义实现"轮播",详见 fallback demo
* @default 0
*/
fallback?: boolean;
/**
* @description 内部 swiper 组件属性 touch-angle。计算用户手势时所依赖的滑动角度。角度根据 touchstart 事件和首次 touchmove 事件的坐标计算得出。数值越小越对用户的滑动方向准确度要求越高。
* @default 45
*/
touchAngle?: number;
}
export declare const TabsDefaultProps: Partial<ITabsProps>;

@@ -7,3 +7,6 @@ export const TabsDefaultProps = {

sticky: false,
stickyTop: 0,
fallback:false,
touchAngle: 45,
onGetRef: () => {},
};
import { TabItemDefaultProps } from './props';
import { getTabArray, componentContext } from '../context';
import { getTabArray, componentContext, componentContextFallback } from '../context';
import { log } from '../../_util/console';
import { objectValues } from '../../_util/tools';
import { compareVersion } from '../../_util/compareVersion';
var n = 0;
var component2 = my.canIUse('component2');
var isBaseSwiper = compareVersion(my.SDKVersion, '2.0.0');
Component({
props: TabItemDefaultProps,
data: {
component2: component2
isBaseSwiper: isBaseSwiper,
fallback: false
},
didMount: function didMount() {
var _this = this;
this._getTabInfo('didMount');
componentContextFallback.onUpdate(function (v) {
_this.setData({
fallback: v
});
});
},

@@ -15,0 +25,0 @@ didUpdate: function didUpdate() {

{
"name": "antd-mini",
"version": "0.0.3-beta.14",
"version": "0.0.3",
"scripts": {

@@ -5,0 +5,0 @@ "dev": "minidev dev --less --typescript --no-source-map",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc