antd-mini-rpx
Advanced tools
Comparing version 0.0.6-beta.1 to 0.0.6-beta.2
{ | ||
"component": true, | ||
"usingComponents": { | ||
"loading": "../LoadingMini/index", | ||
"loading": "../Loading/index", | ||
"icon": "../Icon/index", | ||
@@ -6,0 +6,0 @@ "image-icon": "../ImageIcon/index" |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
/** | ||
* 注意,delay 的变更不能实时生效 | ||
*/ | ||
Component({ | ||
props: props_1.LoadingDefaultProps, | ||
data: { | ||
// 决定实际是否渲染加载中状态 | ||
_loading: false, | ||
@@ -12,0 +8,0 @@ }, |
@@ -9,25 +9,54 @@ | ||
/** | ||
* @description 是否加载中 | ||
* @description 加载时的颜色,当 type 为 'spin' 时,只支持十六进制颜色码,如'#fff' | ||
* @default '#999' | ||
*/ | ||
color?: string; | ||
/** | ||
* @description 延时显示加载状态,单位 ms, 注意,delay 的变更不能实时生效,当 type 为 'spin' 时生效 | ||
*/ | ||
delay?: number; | ||
/** | ||
* @description 加载图标高度,不传则默认与 size 大小一致,当 type 为 'mini' 时生效 | ||
* @default '200rpx' | ||
*/ | ||
height?: string; | ||
/** | ||
* @description 是否加载中,当 type 为 'spin' 时生效 | ||
* @default true | ||
*/ | ||
loading?: boolean; | ||
/** | ||
* @description 尺寸 | ||
* @description 加载图标宽度,当 type 为 'mini' 时生效 | ||
* @default '200rpx' | ||
*/ | ||
miniSize?: string; | ||
/** | ||
* @description 加载图标尺寸,当 type 为 'spin' 时生效 | ||
* @default "medium" | ||
*/ | ||
size?: 'x-large' | 'large' | 'medium' | 'small'; | ||
/** | ||
* @description 延时显示加载状态,单位 ms | ||
* @description 加载中文案,当 type 为 'spin' 时生效 | ||
*/ | ||
delay?: number; | ||
/** | ||
* @description 加载中文案 | ||
*/ | ||
text?: string; | ||
/** | ||
* @description 颜色,dark/深色, light/浅色 | ||
* @description 颜色,dark/深色, light/浅色,当 type 为 'spin' 时生效 | ||
* @default "dark" | ||
*/ | ||
theme?: 'dark' | 'light'; | ||
/** | ||
* @description 加载样式类型 | ||
* @default 'spin' | ||
*/ | ||
type?: 'spin' | 'mini'; | ||
} | ||
export declare const LoadingDefaultProps: Partial<ILoadingProps>; |
@@ -0,14 +1,16 @@ | ||
"use strict"; | ||
Component({ | ||
props: { | ||
size: '200rpx', | ||
className: '', | ||
color: '#999', | ||
height: '', | ||
}, | ||
didUpdate: function () { | ||
var color = this.props.color; | ||
this.setData({ | ||
color: color, | ||
}); | ||
}, | ||
props: { | ||
size: '200rpx', | ||
className: '', | ||
color: '#999', | ||
height: '' | ||
}, | ||
didUpdate: function didUpdate() { | ||
var color = this.props.color; | ||
this.setData({ | ||
color: color | ||
}); | ||
} | ||
}); |
@@ -19,14 +19,12 @@ "use strict"; | ||
context_1.componentValue.onUpdate(this.props.uid, (this.checkedListener = function (v) { | ||
if (v) { | ||
if (v.indexOf(_this.props.value) !== -1) { | ||
_this.setData({ | ||
_checked: true, | ||
}); | ||
} | ||
else { | ||
_this.setData({ | ||
_checked: false, | ||
}); | ||
} | ||
if (v === _this.props.value) { | ||
_this.setData({ | ||
_checked: true, | ||
}); | ||
} | ||
else { | ||
_this.setData({ | ||
_checked: false, | ||
}); | ||
} | ||
})); | ||
@@ -33,0 +31,0 @@ }, |
@@ -10,3 +10,3 @@ import { IBaseProps } from '../../_base'; | ||
*/ | ||
value?: string; | ||
value?: any; | ||
/** | ||
@@ -13,0 +13,0 @@ * @description 是否禁用 |
@@ -74,3 +74,3 @@ "use strict"; | ||
}); | ||
this.cOnChange(this.getInputValue(value)); | ||
this.cOnChange(this.getInputValue(value), this.getDataSet()); | ||
(_b = (_a = this.props).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, this.getInputValue(value)); | ||
@@ -85,3 +85,3 @@ } | ||
}); | ||
this.cOnChange(this.getInputValue(value)); | ||
this.cOnChange(this.getInputValue(value), this.getDataSet()); | ||
}, | ||
@@ -112,3 +112,3 @@ getInputValue: function (inputValue) { | ||
var minusTemp = (0, utils_1.downStep)(cValue, step, precision); | ||
this.cOnChange(Math.max(minusTemp, min), e); | ||
this.cOnChange(Math.max(minusTemp, min), this.getDataSet()); | ||
} | ||
@@ -118,7 +118,16 @@ else if (mode === 'add') { | ||
var addTemp = (0, utils_1.upStep)(cValue, step, precision); | ||
this.cOnChange(Math.min(addTemp, max), e); | ||
this.cOnChange(Math.min(addTemp, max), this.getDataSet()); | ||
} | ||
} | ||
}, | ||
getDataSet: function () { | ||
return Object.entries(this.props).reduce(function (prev, cur) { | ||
var key = cur[0], val = cur[1]; | ||
if (key.startsWith('data-')) { | ||
prev[key.replace('data-', '')] = val; | ||
} | ||
return prev; | ||
}, {}); | ||
} | ||
}, | ||
}); |
@@ -37,4 +37,16 @@ import { IBaseFormItemProps } from '../_base'; | ||
*/ | ||
inputWidth?: string; | ||
inputWidth?: string; | ||
/** | ||
* @description 输入框宽度 | ||
*/ | ||
onFocus?: ( e: number ) => void | ||
/** | ||
* @description 输入框宽度 | ||
*/ | ||
onBlur?: ( e: number ) => void | ||
/** | ||
* @description 输入框宽度 | ||
*/ | ||
onChange?: ( e: number, dataSet: Record<string, any> ) => void | ||
} | ||
export declare const StepperDefaultProps: Partial<IStepperProps>; |
@@ -5,9 +5,8 @@ "use strict"; | ||
var props_1 = require("./props"); | ||
var context_1 = require("./context"); | ||
var console_1 = require("../_util/console"); | ||
var tools_1 = require("../_util/tools"); | ||
var compareVersion_1 = require("../_util/compareVersion"); | ||
var tabsStore_1 = require("../_util/tabsStore"); | ||
var canSwipeable = my.canIUse('swiper.disable-touch'); | ||
var component2 = my.canIUse('component2'); | ||
var hasTab = false; | ||
var isShouldNotCalHeight = component2 && (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.6.4') >= 0; | ||
@@ -38,15 +37,20 @@ var isForceUpdate = (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.6.4') >= 0 && (0, compareVersion_1.compareVersion)(my.SDKVersion, '2.7.5') === -1; | ||
var _this = this; | ||
if (hasTab) { | ||
console_1.log.error('Tabs', '目前仅支持在一个页面中使用一个 Tabs 组件。'); | ||
} | ||
hasTab = true; | ||
context_1.componentContext.onUpdate(function (value) { | ||
_this.setData({ | ||
_tabs: value, | ||
}); | ||
}); | ||
context_1.componentContextFallback.update(this.props.fallback); | ||
var setGroupDataVal = function () { | ||
var group = tabsStore_1.tabsStore.getGroup(_this.props.uid); | ||
if (group) { | ||
var items = (0, tools_1.objectValues)(group.items).reduce(function (prev, cur) { | ||
if (cur) | ||
prev.push(cur.getTabsItemVal()); | ||
return prev; | ||
}, []); | ||
_this.setData({ | ||
_tabs: items | ||
}); | ||
} | ||
}; | ||
tabsStore_1.tabsStore.setGroupDataVal(this.props.uid, function () { return setTimeout(setGroupDataVal, 50); }); | ||
setGroupDataVal(); | ||
this.updateTabsItemFallbackVal(this.props.fallback); | ||
var _a = this.props, index = _a.index, animation = _a.animation; | ||
this.setData({ | ||
_tabs: (0, tools_1.objectValues)(context_1.getTabArray), | ||
currentIndex: index, | ||
@@ -100,3 +104,3 @@ }); | ||
if (prevProps.fallback !== fallback) { | ||
context_1.componentContextFallback.update(fallback); | ||
this.updateTabsItemFallbackVal(fallback); | ||
} | ||
@@ -145,6 +149,14 @@ if (prevProps.index !== index && prevData.currentIndex === this.data.currentIndex) { | ||
didUnmount: function () { | ||
hasTab = false; | ||
context_1.componentContext.clearEvent(); | ||
tabsStore_1.tabsStore.removeGroup(this.props.uid); | ||
}, | ||
methods: { | ||
updateTabsItemFallbackVal: function (v) { | ||
var group = tabsStore_1.tabsStore.getGroup(this.props.uid); | ||
if (group) { | ||
(0, tools_1.objectValues)(group.items).forEach(function (item) { | ||
// @ts-ignore | ||
item.setFallback(v); | ||
}); | ||
} | ||
}, | ||
_autoHeight: function (tabIndex) { | ||
@@ -151,0 +163,0 @@ var _this = this; |
@@ -12,2 +12,7 @@ | ||
*/ | ||
uid: string; | ||
/** | ||
* @description 类型,basis(基础),capsule(胶囊),mixin(混合) | ||
* @default "basis" | ||
*/ | ||
type?: 'basis' | 'capsule' | 'mixin'; | ||
@@ -14,0 +19,0 @@ /** |
@@ -16,4 +16,5 @@ "use strict"; | ||
touchAngle: 45, | ||
onGetRef: function onGetRef() {} | ||
onGetRef: function onGetRef() {}, | ||
uid: 'tabs' | ||
}; | ||
exports.TabsDefaultProps = TabsDefaultProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var props_1 = require("./props"); | ||
var context_1 = require("../context"); | ||
var console_1 = require("../../_util/console"); | ||
var tools_1 = require("../../_util/tools"); | ||
var compareVersion_1 = require("../../_util/compareVersion"); | ||
var n = 0; | ||
var tabsStore_1 = require("../../_util/tabsStore"); | ||
var isBaseSwiper = (0, compareVersion_1.compareVersion)('2.0.0', my.SDKVersion) < 0 ? true : false; | ||
@@ -18,17 +16,19 @@ Component({ | ||
var _this = this; | ||
this._getTabInfo('didMount'); | ||
context_1.componentContextFallback.onUpdate(function (v) { | ||
_this.setData({ | ||
fallback: v | ||
}); | ||
}); | ||
// 更新 fallback 值 | ||
console.log(this.props.tab); | ||
var setFallback = function (v) { return _this.setData({ fallback: v }); }; | ||
// 注册 item | ||
var getTabsItemVal = function () { return _this.props.tab; }; | ||
tabsStore_1.tabsStore.addItem(this.props.uid, "".concat(this.$id), { setFallback: setFallback, getTabsItemVal: getTabsItemVal }); | ||
// 更新视图 | ||
// console.log(tabsStore) | ||
this.update(); | ||
}, | ||
didUpdate: function () { | ||
this._getTabInfo(); | ||
// 更新视图 | ||
this.update(); | ||
}, | ||
didUnmount: function () { | ||
delete context_1.getTabArray[this.uid]; | ||
setTimeout(function () { | ||
context_1.componentContext.update((0, tools_1.objectValues)(context_1.getTabArray)); | ||
}, 0); | ||
tabsStore_1.tabsStore.removeItem(this.props.uid, "".concat(this.$id)); | ||
console.log(tabsStore_1.tabsStore); | ||
}, | ||
@@ -44,20 +44,9 @@ methods: { | ||
} | ||
if ((tab === null || tab === void 0 ? void 0 : tab.badge) && typeof (tab === null || tab === void 0 ? void 0 : tab.badge) !== 'number') { | ||
console_1.log.error('TabItem', "tab \u4E2D\u7684 badge \u7C7B\u578B\u4E0D\u5339\u914D\uFF0C\u5F53\u524D\u7684 badge \u503C\u4E3A ".concat(tab === null || tab === void 0 ? void 0 : tab.badge, "\uFF0C \u7C7B\u578B\u4E3A ").concat(typeof (tab === null || tab === void 0 ? void 0 : tab.badge))); | ||
} | ||
}, | ||
_getTabInfo: function (lifeCycle) { | ||
// 获取每个 tab-item 中的 tab 值 | ||
// 如果是 didMount 时对 uid 的值做累加处理 | ||
if (lifeCycle === 'didMount') { | ||
this.uid = n++; | ||
} | ||
var tab = this.props.tab; | ||
this._tabError(tab); | ||
context_1.getTabArray[this.uid] = tab; | ||
setTimeout(function () { | ||
context_1.componentContext.update((0, tools_1.objectValues)(context_1.getTabArray)); | ||
}, 0); | ||
}, | ||
update: function () { | ||
var group = tabsStore_1.tabsStore.getGroup(this.props.uid); | ||
if (group && group.setGroupDataVal) | ||
group.setGroupDataVal(); | ||
} | ||
}, | ||
}); |
@@ -8,2 +8,6 @@ import { IBaseProps } from '../../_base'; | ||
/** | ||
* @description | ||
*/ | ||
uid: string | ||
/** | ||
* @description 每一项 tab 内容 | ||
@@ -10,0 +14,0 @@ */ |
@@ -7,3 +7,5 @@ "use strict"; | ||
exports.TabItemDefaultProps = void 0; | ||
var TabItemDefaultProps = {}; | ||
var TabItemDefaultProps = { | ||
uid: "tabs" | ||
}; | ||
exports.TabItemDefaultProps = TabItemDefaultProps; |
{ | ||
"name": "antd-mini-rpx", | ||
"version": "0.0.6-beta.1", | ||
"version": "0.0.6-beta.2", | ||
"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
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
Sorry, the diff of this file is not supported yet
355316
321
6341