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

antd-mini

Package Overview
Dependencies
Maintainers
4
Versions
213
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 2.19.0 to 2.20.0

compiled/wechat/src/Radio/index.js

48

es/Radio/index.js

@@ -1,24 +0,30 @@

import { RadioDefaultProps } from './props';
import fmtEvent from '../_util/fmtEvent';
import mixinValue from '../mixins/value';
import { useEvent } from 'functional-mini/component';
import '../_util/assert-component2';
Component({
props: RadioDefaultProps,
mixins: [
mixinValue({
valueKey: 'checked',
defaultValueKey: 'defaultChecked',
}),
],
methods: {
onChange: function (e) {
var value = e.detail.value;
if (!this.isControlled()) {
this.update(value);
}
if (this.props.onChange) {
this.props.onChange(value, fmtEvent(this.props, e));
}
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
import { useMixState } from '../_util/hooks/useMixState';
var Radio = function (props) {
var _a = useMixState(props.defaultChecked, {
value: props.checked,
}), radioValue = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEvent = useComponentEvent(props).triggerEvent;
useEvent('onChange', function (e) {
var value = e.detail.value;
if (!isControlled) {
update(value);
}
triggerEvent('change', value, e);
});
return {
mixin: {
value: radioValue,
},
},
};
};
mountComponent(Radio, {
value: null,
defaultChecked: null,
color: '',
checked: null,
disabled: false,
});
{
"component": true,
"usingComponents": {
"list-item": "../List/ListItem/index",
"icon": "../Icon/index"
"ant-icon": "../Icon/index"
}
}
import { IBaseProps } from '../_util/base';
export interface IRadioProps extends IBaseProps {
/**
* @description 组件值,选中时 change 事件会携带的 value。
*/
value?: string;
defaultChecked?: boolean;
/**
* @description radio 的颜色,同 CSS 色值。
*/
color?: string;
checked?: boolean;

@@ -5,0 +13,0 @@ disabled?: boolean;

@@ -1,19 +0,32 @@

import { RadioGroupDefaultProps } from './props';
import fmtEvent from '../../_util/fmtEvent';
import mixinValue from '../../mixins/value';
Component({
props: RadioGroupDefaultProps,
mixins: [mixinValue()],
methods: {
onChange: function (_, e) {
var index = e.currentTarget.dataset.index;
var value = this.props.options[index].value;
if (!this.isControlled()) {
this.update(value);
}
if (this.props.onChange) {
this.props.onChange(value, fmtEvent(this.props, e));
}
import { mountComponent } from '../../_util/component';
import { useMixState } from '../../_util/hooks/useMixState';
import { useEvent } from 'functional-mini/component';
import { useComponentEvent } from '../../_util/hooks/useComponentEvent';
var RadioGroup = function (props) {
var _a = useMixState(props.defaultValue, {
value: props.value,
}), value = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEvent = useComponentEvent(props).triggerEvent;
useEvent('onChange', function (_, e) {
var index = e.currentTarget.dataset.index;
var value = props.options[index].value;
if (!isControlled) {
update(value);
}
},
triggerEvent('change', value, e);
});
return {
mixin: {
value: value,
},
};
};
mountComponent(RadioGroup, {
value: null,
defaultValue: null,
name: '',
disabled: false,
color: '',
position: 'vertical',
options: [],
});

@@ -9,3 +9,3 @@ import { IBaseProps } from '../../_util/base';

position: 'horizontal' | 'vertical';
onChange: (value: string, e: any) => void;
onChange?: (value: string, e: any) => void;
options: {

@@ -15,4 +15,5 @@ label?: string;

disabled?: boolean;
color?: string;
}[];
}
export declare const RadioGroupDefaultProps: Partial<IRadioGroupProps>;

@@ -1,138 +0,156 @@

import { __awaiter, __generator } from "tslib";
import { RateDefaultProps } from './props';
import createValue from '../mixins/value';
import { __assign, __awaiter, __generator } from "tslib";
import { useComponent, useEvent, useRef, useState, } from 'functional-mini/component';
import '../_util/assert-component2';
function getBoundingClientRect(selector) {
return new Promise(function (resolve, reject) {
my.createSelectorQuery()
.select(selector)
.boundingClientRect()
.exec(function (ret) {
if (ret && ret[0]) {
resolve(ret[0]);
return;
}
reject();
});
});
}
Component({
props: RateDefaultProps,
mixins: [
createValue({
transformValue: function (value) {
if (this.props.allowHalf) {
return {
needUpdate: true,
value: value % 0.5 !== 0 ? Math.round(value) : value,
};
}
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
import { useMixState } from '../_util/hooks/useMixState';
import { getInstanceBoundingClientRect } from '../_util/jsapi/get-instance-bounding-client-rect';
var Rate = function (props) {
var _a = useMixState(props.defaultValue, {
value: props.value,
postState: function (value) {
if (props.allowHalf) {
return {
needUpdate: true,
value: Math.ceil(value),
valid: true,
value: value % 0.5 !== 0 ? Math.round(value) : value,
};
},
}),
],
methods: {
handleStarTap: function (e) {
return __awaiter(this, void 0, void 0, function () {
var clientX, startTapRate, rate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.props.readonly) {
return [2 /*return*/];
}
return {
valid: true,
value: Math.ceil(value),
};
},
}), rateValue = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEvent = useComponentEvent(props).triggerEvent;
var _c = useState(null), displayValue = _c[0], setDisplayValue = _c[1];
var ref = useRef(false);
var instance = useComponent();
function getInstance() {
if (instance.$id) {
return my;
}
return instance;
}
function getRate(clientX) {
return __awaiter(this, void 0, void 0, function () {
var gutter, count, _a, left, width, halfRateWidth, num, halfRateCount, val, rate;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
gutter = props.gutter, count = props.count;
return [4 /*yield*/, getInstanceBoundingClientRect(getInstance(), "#ant-rate-container".concat(instance.$id ? "-".concat(instance.$id) : ''))];
case 1:
_a = _b.sent(), left = _a.left, width = _a.width;
halfRateWidth = (width - (count - 1) * gutter) / count / 2;
num = clientX - left;
halfRateCount = 0;
/* eslint-disable no-constant-condition */
while (true) {
val = halfRateWidth * halfRateCount + gutter * Math.floor(halfRateCount / 2);
if (halfRateCount >= count * 2 || num <= val) {
break;
}
clientX = e.detail.clientX;
startTapRate = this.getValue();
return [4 /*yield*/, this.updateRate(clientX)];
case 1:
rate = _a.sent();
if (startTapRate === rate && this.props.allowClear) {
rate = 0;
}
if (!this.isControlled()) {
this.update(rate);
}
if (startTapRate !== rate && this.props.onChange) {
this.props.onChange(rate);
}
return [2 /*return*/];
}
});
halfRateCount++;
}
rate = props.allowHalf
? halfRateCount * 0.5
: Math.ceil(halfRateCount * 0.5);
return [2 /*return*/, rate];
}
});
},
startMoveRate: undefined,
handleStarMove: function (e) {
return __awaiter(this, void 0, void 0, function () {
var touches, clientX, rate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.props.readonly) {
return [2 /*return*/];
}
touches = e.touches;
clientX = touches[0].clientX;
if (typeof this.startMoveRate === 'undefined') {
this.startMoveRate = this.getValue();
}
return [4 /*yield*/, this.updateRate(clientX)];
case 1:
rate = _a.sent();
this.update(rate);
return [2 /*return*/];
});
}
useEvent('handleStarTap', function (e) { return __awaiter(void 0, void 0, void 0, function () {
var _a, clientX, x, clickX, rate;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (props.readonly) {
return [2 /*return*/];
}
});
});
},
handleStarMoveEnd: function () {
if (this.props.readonly) {
return;
_a = e.detail, clientX = _a.clientX, x = _a.x;
clickX = typeof x === 'number' ? x : clientX;
return [4 /*yield*/, getRate(clickX)];
case 1:
rate = _b.sent();
if (rateValue === rate && props.allowClear) {
rate = 0;
}
if (!isControlled) {
update(rate);
}
if (rateValue !== rate) {
triggerEvent('change', rate);
}
return [2 /*return*/];
}
if (typeof this.startMoveRate === 'undefined') {
return;
});
}); });
useEvent('handleStarMove', function (e) { return __awaiter(void 0, void 0, void 0, function () {
var touches, clientX, rate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (props.readonly) {
return [2 /*return*/];
}
touches = e.touches;
clientX = touches[0].clientX;
if (!ref.current) {
ref.current = {
originalRate: rateValue,
};
}
return [4 /*yield*/, getRate(clientX)];
case 1:
rate = _a.sent();
if (ref.current) {
ref.current = __assign(__assign({}, ref.current), { currentRate: rate });
if (isControlled) {
setDisplayValue(rate);
}
else {
update(rate);
}
}
return [2 /*return*/];
}
var startMoveRate = this.startMoveRate;
this.startMoveRate = undefined;
var rate = this.getValue();
if (this.isControlled()) {
this.update(startMoveRate);
});
}); });
useEvent('handleStarMoveEnd', function () { return __awaiter(void 0, void 0, void 0, function () {
var _a, currentRate, originalRate;
return __generator(this, function (_b) {
if (props.readonly) {
return [2 /*return*/];
}
if (startMoveRate !== rate && this.props.onChange) {
this.props.onChange(rate);
if (!ref.current) {
return [2 /*return*/];
}
_a = ref.current, currentRate = _a.currentRate, originalRate = _a.originalRate;
ref.current = null;
if (isControlled) {
setDisplayValue(null);
}
if (currentRate !== originalRate) {
triggerEvent('change', currentRate);
}
return [2 /*return*/];
});
}); });
return {
mixin: {
value: displayValue !== null ? displayValue : rateValue,
},
updateRate: function (clientX) {
return __awaiter(this, void 0, void 0, function () {
var _a, gutter, count, _b, left, width, halfRateWidth, num, halfRateCount, val, rate;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = this.props, gutter = _a.gutter, count = _a.count;
return [4 /*yield*/, getBoundingClientRect("#ant-rate-container-".concat(this.$id))];
case 1:
_b = _c.sent(), left = _b.left, width = _b.width;
halfRateWidth = (width - (count - 1) * gutter) / count / 2;
num = clientX - left;
halfRateCount = 0;
/* eslint-disable no-constant-condition */
while (true) {
val = halfRateWidth * halfRateCount +
gutter * Math.floor(halfRateCount / 2);
if (halfRateCount >= count * 2 || num <= val) {
break;
}
halfRateCount++;
}
rate = this.props.allowHalf
? halfRateCount * 0.5
: Math.ceil(halfRateCount * 0.5);
return [2 /*return*/, rate];
}
});
});
},
},
};
};
mountComponent(Rate, {
value: null,
defaultValue: null,
gutter: 4,
allowHalf: false,
allowClear: true,
count: 5,
characterActiveClassName: '',
characterClassName: '',
readonly: false,
});
{
"component": true,
"usingComponents": {
"icon": "../Icon/index"
"component": true,
"usingComponents": {
"ant-icon": "../Icon/index"
}
}

@@ -42,4 +42,4 @@ import { IBaseProps } from '../_util/base';

*/
onChange: (rate: number) => void;
onChange?: (rate: number) => void;
}
export declare const RateDefaultProps: Partial<IRateProps>;
import { __spreadArray } from "tslib";
import { SelectorDefaultProps } from './props';
import mixinValue from '../mixins/value';
import fmtEvent from '../_util/fmtEvent';
import { useEvent } from 'functional-mini/component';
import '../_util/assert-component2';
Component({
mixins: [mixinValue()],
props: SelectorDefaultProps,
methods: {
onChange: function (e) {
var event = fmtEvent(this.props);
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value;
var _b = this.props, multiple = _b.multiple, options = _b.options, maxSelectedCount = _b.maxSelectedCount, minSelectedCount = _b.minSelectedCount, onSelectMax = _b.onSelectMax, onSelectMin = _b.onSelectMin, onChange = _b.onChange;
if (disabled || this.props.disabled) {
return;
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
import { useMixState } from '../_util/hooks/useMixState';
var Selector = function (props) {
var _a = useMixState(props.defaultValue, {
value: props.value,
}), selectorValue = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEventValues = useComponentEvent(props).triggerEventValues;
useEvent('onChange', function (e) {
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value;
var multiple = props.multiple, options = props.options, maxSelectedCount = props.maxSelectedCount, minSelectedCount = props.minSelectedCount;
if (disabled || props.disabled) {
return;
}
if (multiple) {
var currentValue_1 = selectorValue || [];
if (currentValue_1.indexOf(value) > -1) {
if (typeof minSelectedCount === 'number' &&
currentValue_1.length <= minSelectedCount) {
triggerEventValues('selectMin', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
currentValue_1 = currentValue_1.filter(function (v) { return v !== value; });
}
if (multiple) {
var currentValue_1 = this.getValue() || [];
if (currentValue_1.indexOf(value) > -1) {
if (!isNaN(minSelectedCount) &&
currentValue_1.length <= minSelectedCount) {
if (onSelectMin) {
onSelectMin(value, options.find(function (v) { return v.value === value; }), event);
}
return;
}
currentValue_1 = currentValue_1.filter(function (v) { return v !== value; });
else {
if (typeof maxSelectedCount === 'number' &&
currentValue_1.length >= maxSelectedCount) {
triggerEventValues('selectMax', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
else {
if (!isNaN(maxSelectedCount) &&
currentValue_1.length >= maxSelectedCount) {
if (onSelectMax) {
onSelectMax(value, options.find(function (v) { return v.value === value; }), event);
}
return;
}
currentValue_1 = __spreadArray(__spreadArray([], currentValue_1, true), [value], false);
currentValue_1 = __spreadArray(__spreadArray([], currentValue_1, true), [value], false);
}
if (!isControlled) {
update(currentValue_1);
}
triggerEventValues('change', [
currentValue_1,
options.filter(function (v) { return currentValue_1.indexOf(v.value) > -1; }),
], e);
}
else {
if (value === selectorValue) {
if (minSelectedCount === 1) {
triggerEventValues('selectMin', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
if (!this.isControlled()) {
this.update(currentValue_1);
if (!isControlled) {
update(undefined);
}
if (onChange) {
onChange(currentValue_1, options.filter(function (v) { return currentValue_1.indexOf(v.value) > -1; }), fmtEvent(this.props));
}
triggerEventValues('change', [undefined, undefined], e);
}
else {
if (value === this.getValue()) {
if (minSelectedCount === 1) {
if (onSelectMin) {
onSelectMin(value, options.find(function (v) { return v.value === value; }), event);
}
return;
}
if (!this.isControlled()) {
this.update(undefined);
}
if (onChange) {
onChange(undefined, undefined, fmtEvent(this.props));
}
if (!isControlled) {
update(value);
}
else {
if (!this.isControlled()) {
this.update(value);
}
if (onChange) {
onChange(value, options.find(function (v) { return v.value === value; }), fmtEvent(this.props));
}
}
triggerEventValues('change', [value, options.find(function (v) { return v.value === value; })], e);
}
}
});
return {
mixin: {
value: selectorValue,
},
},
};
};
mountComponent(Selector, {
value: null,
defaultValue: null,
options: null,
activeItemClassName: '',
activeItemStyle: '',
multiple: false,
minSelectedCount: null,
maxSelectedCount: null,
disabled: false,
});

@@ -59,12 +59,12 @@ import { IBaseProps } from '../_util/base';

disabled: boolean;
onChange(value: Value | Value[] | undefined, item: ISelectorItem | ISelectorItem[] | undefined, e: Record<string, any>): void;
onChange?(value: Value | Value[] | undefined, item: ISelectorItem | ISelectorItem[] | undefined, e: Record<string, any>): void;
/**
* @description 触发最大限制
*/
onSelectMax(value: Value, item: ISelectorItem, e: Record<string, any>): void;
onSelectMax?(value: Value, item: ISelectorItem, e: Record<string, any>): void;
/**
* @description 触发最小限制
*/
onSelectMin(value: Value, item: ISelectorItem, e: Record<string, any>): void;
onSelectMin?(value: Value, item: ISelectorItem, e: Record<string, any>): void;
}
export declare const SelectorDefaultProps: Partial<ISelectorProps>;

@@ -21,4 +21,4 @@ import { IBaseProps } from '../_util/base';

/**
* @description 列表
*/
* @description 列表
*/
items: {

@@ -28,2 +28,3 @@ title: string;

disabled?: boolean;
subTitle?: string;
}[];

@@ -38,3 +39,15 @@ /**

scrollMode: 'edge' | 'center';
/**
* @description tabs bar类名
*/
tabsBarClassName?: string;
/**
* @description tab类名
*/
tabClassName?: string;
/**
*@description tab active类名
*/
tabActiveClassName?: string;
}
export declare const TabsDefaultProps: Partial<ITabsProps>;

@@ -6,8 +6,14 @@ export interface Props {

name?: string;
scrollX?: any;
'a:key'?: string;
scrollLeft?: any;
onTap?: string;
checked?: boolean;
src?: string;
mode?: string;
scrollAnimationDuration?: any;
cell?: string;
scrollWithAnimation?: any;
children?: any;
scrollY?: any;
id?: string;

@@ -18,2 +24,3 @@ onScroll?: any;

onFollowLifestyle?: any;
scrollTop?: any;
catchTap?: string;

@@ -53,2 +60,3 @@ onError?: any;

fileList?: any;
isActive?: boolean;
}

@@ -1,24 +0,30 @@

import { RadioDefaultProps } from './props';
import fmtEvent from '../_util/fmtEvent';
import mixinValue from '../mixins/value';
import { useEvent } from 'functional-mini/component';
import '../_util/assert-component2';
Component({
props: RadioDefaultProps,
mixins: [
mixinValue({
valueKey: 'checked',
defaultValueKey: 'defaultChecked',
}),
],
methods: {
onChange: function (e) {
var value = e.detail.value;
if (!this.isControlled()) {
this.update(value);
}
if (this.props.onChange) {
this.props.onChange(value, fmtEvent(this.props, e));
}
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
import { useMixState } from '../_util/hooks/useMixState';
var Radio = function (props) {
var _a = useMixState(props.defaultChecked, {
value: props.checked,
}), radioValue = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEvent = useComponentEvent(props).triggerEvent;
useEvent('onChange', function (e) {
var value = e.detail.value;
if (!isControlled) {
update(value);
}
triggerEvent('change', value, e);
});
return {
mixin: {
value: radioValue,
},
},
};
};
mountComponent(Radio, {
value: null,
defaultChecked: null,
color: '',
checked: null,
disabled: false,
});
{
"component": true,
"usingComponents": {
"list-item": "../List/ListItem/index",
"icon": "../Icon/index"
"ant-icon": "../Icon/index"
}
}
import { IBaseProps } from '../_util/base';
export interface IRadioProps extends IBaseProps {
/**
* @description 组件值,选中时 change 事件会携带的 value。
*/
value?: string;
defaultChecked?: boolean;
/**
* @description radio 的颜色,同 CSS 色值。
*/
color?: string;
checked?: boolean;

@@ -5,0 +13,0 @@ disabled?: boolean;

@@ -1,19 +0,32 @@

import { RadioGroupDefaultProps } from './props';
import fmtEvent from '../../_util/fmtEvent';
import mixinValue from '../../mixins/value';
Component({
props: RadioGroupDefaultProps,
mixins: [mixinValue()],
methods: {
onChange: function (_, e) {
var index = e.currentTarget.dataset.index;
var value = this.props.options[index].value;
if (!this.isControlled()) {
this.update(value);
}
if (this.props.onChange) {
this.props.onChange(value, fmtEvent(this.props, e));
}
import { mountComponent } from '../../_util/component';
import { useMixState } from '../../_util/hooks/useMixState';
import { useEvent } from 'functional-mini/component';
import { useComponentEvent } from '../../_util/hooks/useComponentEvent';
var RadioGroup = function (props) {
var _a = useMixState(props.defaultValue, {
value: props.value,
}), value = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEvent = useComponentEvent(props).triggerEvent;
useEvent('onChange', function (_, e) {
var index = e.currentTarget.dataset.index;
var value = props.options[index].value;
if (!isControlled) {
update(value);
}
},
triggerEvent('change', value, e);
});
return {
mixin: {
value: value,
},
};
};
mountComponent(RadioGroup, {
value: null,
defaultValue: null,
name: '',
disabled: false,
color: '',
position: 'vertical',
options: [],
});

@@ -9,3 +9,3 @@ import { IBaseProps } from '../../_util/base';

position: 'horizontal' | 'vertical';
onChange: (value: string, e: any) => void;
onChange?: (value: string, e: any) => void;
options: {

@@ -15,4 +15,5 @@ label?: string;

disabled?: boolean;
color?: string;
}[];
}
export declare const RadioGroupDefaultProps: Partial<IRadioGroupProps>;

@@ -1,138 +0,156 @@

import { __awaiter, __generator } from "tslib";
import { RateDefaultProps } from './props';
import createValue from '../mixins/value';
import { __assign, __awaiter, __generator } from "tslib";
import { useComponent, useEvent, useRef, useState, } from 'functional-mini/component';
import '../_util/assert-component2';
function getBoundingClientRect(selector) {
return new Promise(function (resolve, reject) {
my.createSelectorQuery()
.select(selector)
.boundingClientRect()
.exec(function (ret) {
if (ret && ret[0]) {
resolve(ret[0]);
return;
}
reject();
});
});
}
Component({
props: RateDefaultProps,
mixins: [
createValue({
transformValue: function (value) {
if (this.props.allowHalf) {
return {
needUpdate: true,
value: value % 0.5 !== 0 ? Math.round(value) : value,
};
}
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
import { useMixState } from '../_util/hooks/useMixState';
import { getInstanceBoundingClientRect } from '../_util/jsapi/get-instance-bounding-client-rect';
var Rate = function (props) {
var _a = useMixState(props.defaultValue, {
value: props.value,
postState: function (value) {
if (props.allowHalf) {
return {
needUpdate: true,
value: Math.ceil(value),
valid: true,
value: value % 0.5 !== 0 ? Math.round(value) : value,
};
},
}),
],
methods: {
handleStarTap: function (e) {
return __awaiter(this, void 0, void 0, function () {
var clientX, startTapRate, rate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.props.readonly) {
return [2 /*return*/];
}
return {
valid: true,
value: Math.ceil(value),
};
},
}), rateValue = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEvent = useComponentEvent(props).triggerEvent;
var _c = useState(null), displayValue = _c[0], setDisplayValue = _c[1];
var ref = useRef(false);
var instance = useComponent();
function getInstance() {
if (instance.$id) {
return my;
}
return instance;
}
function getRate(clientX) {
return __awaiter(this, void 0, void 0, function () {
var gutter, count, _a, left, width, halfRateWidth, num, halfRateCount, val, rate;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
gutter = props.gutter, count = props.count;
return [4 /*yield*/, getInstanceBoundingClientRect(getInstance(), "#ant-rate-container".concat(instance.$id ? "-".concat(instance.$id) : ''))];
case 1:
_a = _b.sent(), left = _a.left, width = _a.width;
halfRateWidth = (width - (count - 1) * gutter) / count / 2;
num = clientX - left;
halfRateCount = 0;
/* eslint-disable no-constant-condition */
while (true) {
val = halfRateWidth * halfRateCount + gutter * Math.floor(halfRateCount / 2);
if (halfRateCount >= count * 2 || num <= val) {
break;
}
clientX = e.detail.clientX;
startTapRate = this.getValue();
return [4 /*yield*/, this.updateRate(clientX)];
case 1:
rate = _a.sent();
if (startTapRate === rate && this.props.allowClear) {
rate = 0;
}
if (!this.isControlled()) {
this.update(rate);
}
if (startTapRate !== rate && this.props.onChange) {
this.props.onChange(rate);
}
return [2 /*return*/];
}
});
halfRateCount++;
}
rate = props.allowHalf
? halfRateCount * 0.5
: Math.ceil(halfRateCount * 0.5);
return [2 /*return*/, rate];
}
});
},
startMoveRate: undefined,
handleStarMove: function (e) {
return __awaiter(this, void 0, void 0, function () {
var touches, clientX, rate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.props.readonly) {
return [2 /*return*/];
}
touches = e.touches;
clientX = touches[0].clientX;
if (typeof this.startMoveRate === 'undefined') {
this.startMoveRate = this.getValue();
}
return [4 /*yield*/, this.updateRate(clientX)];
case 1:
rate = _a.sent();
this.update(rate);
return [2 /*return*/];
});
}
useEvent('handleStarTap', function (e) { return __awaiter(void 0, void 0, void 0, function () {
var _a, clientX, x, clickX, rate;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (props.readonly) {
return [2 /*return*/];
}
});
});
},
handleStarMoveEnd: function () {
if (this.props.readonly) {
return;
_a = e.detail, clientX = _a.clientX, x = _a.x;
clickX = typeof x === 'number' ? x : clientX;
return [4 /*yield*/, getRate(clickX)];
case 1:
rate = _b.sent();
if (rateValue === rate && props.allowClear) {
rate = 0;
}
if (!isControlled) {
update(rate);
}
if (rateValue !== rate) {
triggerEvent('change', rate);
}
return [2 /*return*/];
}
if (typeof this.startMoveRate === 'undefined') {
return;
});
}); });
useEvent('handleStarMove', function (e) { return __awaiter(void 0, void 0, void 0, function () {
var touches, clientX, rate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (props.readonly) {
return [2 /*return*/];
}
touches = e.touches;
clientX = touches[0].clientX;
if (!ref.current) {
ref.current = {
originalRate: rateValue,
};
}
return [4 /*yield*/, getRate(clientX)];
case 1:
rate = _a.sent();
if (ref.current) {
ref.current = __assign(__assign({}, ref.current), { currentRate: rate });
if (isControlled) {
setDisplayValue(rate);
}
else {
update(rate);
}
}
return [2 /*return*/];
}
var startMoveRate = this.startMoveRate;
this.startMoveRate = undefined;
var rate = this.getValue();
if (this.isControlled()) {
this.update(startMoveRate);
});
}); });
useEvent('handleStarMoveEnd', function () { return __awaiter(void 0, void 0, void 0, function () {
var _a, currentRate, originalRate;
return __generator(this, function (_b) {
if (props.readonly) {
return [2 /*return*/];
}
if (startMoveRate !== rate && this.props.onChange) {
this.props.onChange(rate);
if (!ref.current) {
return [2 /*return*/];
}
_a = ref.current, currentRate = _a.currentRate, originalRate = _a.originalRate;
ref.current = null;
if (isControlled) {
setDisplayValue(null);
}
if (currentRate !== originalRate) {
triggerEvent('change', currentRate);
}
return [2 /*return*/];
});
}); });
return {
mixin: {
value: displayValue !== null ? displayValue : rateValue,
},
updateRate: function (clientX) {
return __awaiter(this, void 0, void 0, function () {
var _a, gutter, count, _b, left, width, halfRateWidth, num, halfRateCount, val, rate;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = this.props, gutter = _a.gutter, count = _a.count;
return [4 /*yield*/, getBoundingClientRect("#ant-rate-container-".concat(this.$id))];
case 1:
_b = _c.sent(), left = _b.left, width = _b.width;
halfRateWidth = (width - (count - 1) * gutter) / count / 2;
num = clientX - left;
halfRateCount = 0;
/* eslint-disable no-constant-condition */
while (true) {
val = halfRateWidth * halfRateCount +
gutter * Math.floor(halfRateCount / 2);
if (halfRateCount >= count * 2 || num <= val) {
break;
}
halfRateCount++;
}
rate = this.props.allowHalf
? halfRateCount * 0.5
: Math.ceil(halfRateCount * 0.5);
return [2 /*return*/, rate];
}
});
});
},
},
};
};
mountComponent(Rate, {
value: null,
defaultValue: null,
gutter: 4,
allowHalf: false,
allowClear: true,
count: 5,
characterActiveClassName: '',
characterClassName: '',
readonly: false,
});
{
"component": true,
"usingComponents": {
"icon": "../Icon/index"
"component": true,
"usingComponents": {
"ant-icon": "../Icon/index"
}
}

@@ -42,4 +42,4 @@ import { IBaseProps } from '../_util/base';

*/
onChange: (rate: number) => void;
onChange?: (rate: number) => void;
}
export declare const RateDefaultProps: Partial<IRateProps>;
import { __spreadArray } from "tslib";
import { SelectorDefaultProps } from './props';
import mixinValue from '../mixins/value';
import fmtEvent from '../_util/fmtEvent';
import { useEvent } from 'functional-mini/component';
import '../_util/assert-component2';
Component({
mixins: [mixinValue()],
props: SelectorDefaultProps,
methods: {
onChange: function (e) {
var event = fmtEvent(this.props);
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value;
var _b = this.props, multiple = _b.multiple, options = _b.options, maxSelectedCount = _b.maxSelectedCount, minSelectedCount = _b.minSelectedCount, onSelectMax = _b.onSelectMax, onSelectMin = _b.onSelectMin, onChange = _b.onChange;
if (disabled || this.props.disabled) {
return;
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
import { useMixState } from '../_util/hooks/useMixState';
var Selector = function (props) {
var _a = useMixState(props.defaultValue, {
value: props.value,
}), selectorValue = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update;
var triggerEventValues = useComponentEvent(props).triggerEventValues;
useEvent('onChange', function (e) {
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value;
var multiple = props.multiple, options = props.options, maxSelectedCount = props.maxSelectedCount, minSelectedCount = props.minSelectedCount;
if (disabled || props.disabled) {
return;
}
if (multiple) {
var currentValue_1 = selectorValue || [];
if (currentValue_1.indexOf(value) > -1) {
if (typeof minSelectedCount === 'number' &&
currentValue_1.length <= minSelectedCount) {
triggerEventValues('selectMin', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
currentValue_1 = currentValue_1.filter(function (v) { return v !== value; });
}
if (multiple) {
var currentValue_1 = this.getValue() || [];
if (currentValue_1.indexOf(value) > -1) {
if (!isNaN(minSelectedCount) &&
currentValue_1.length <= minSelectedCount) {
if (onSelectMin) {
onSelectMin(value, options.find(function (v) { return v.value === value; }), event);
}
return;
}
currentValue_1 = currentValue_1.filter(function (v) { return v !== value; });
else {
if (typeof maxSelectedCount === 'number' &&
currentValue_1.length >= maxSelectedCount) {
triggerEventValues('selectMax', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
else {
if (!isNaN(maxSelectedCount) &&
currentValue_1.length >= maxSelectedCount) {
if (onSelectMax) {
onSelectMax(value, options.find(function (v) { return v.value === value; }), event);
}
return;
}
currentValue_1 = __spreadArray(__spreadArray([], currentValue_1, true), [value], false);
currentValue_1 = __spreadArray(__spreadArray([], currentValue_1, true), [value], false);
}
if (!isControlled) {
update(currentValue_1);
}
triggerEventValues('change', [
currentValue_1,
options.filter(function (v) { return currentValue_1.indexOf(v.value) > -1; }),
], e);
}
else {
if (value === selectorValue) {
if (minSelectedCount === 1) {
triggerEventValues('selectMin', [value, options.find(function (v) { return v.value === value; })], e);
return;
}
if (!this.isControlled()) {
this.update(currentValue_1);
if (!isControlled) {
update(undefined);
}
if (onChange) {
onChange(currentValue_1, options.filter(function (v) { return currentValue_1.indexOf(v.value) > -1; }), fmtEvent(this.props));
}
triggerEventValues('change', [undefined, undefined], e);
}
else {
if (value === this.getValue()) {
if (minSelectedCount === 1) {
if (onSelectMin) {
onSelectMin(value, options.find(function (v) { return v.value === value; }), event);
}
return;
}
if (!this.isControlled()) {
this.update(undefined);
}
if (onChange) {
onChange(undefined, undefined, fmtEvent(this.props));
}
if (!isControlled) {
update(value);
}
else {
if (!this.isControlled()) {
this.update(value);
}
if (onChange) {
onChange(value, options.find(function (v) { return v.value === value; }), fmtEvent(this.props));
}
}
triggerEventValues('change', [value, options.find(function (v) { return v.value === value; })], e);
}
}
});
return {
mixin: {
value: selectorValue,
},
},
};
};
mountComponent(Selector, {
value: null,
defaultValue: null,
options: null,
activeItemClassName: '',
activeItemStyle: '',
multiple: false,
minSelectedCount: null,
maxSelectedCount: null,
disabled: false,
});

@@ -59,12 +59,12 @@ import { IBaseProps } from '../_util/base';

disabled: boolean;
onChange(value: Value | Value[] | undefined, item: ISelectorItem | ISelectorItem[] | undefined, e: Record<string, any>): void;
onChange?(value: Value | Value[] | undefined, item: ISelectorItem | ISelectorItem[] | undefined, e: Record<string, any>): void;
/**
* @description 触发最大限制
*/
onSelectMax(value: Value, item: ISelectorItem, e: Record<string, any>): void;
onSelectMax?(value: Value, item: ISelectorItem, e: Record<string, any>): void;
/**
* @description 触发最小限制
*/
onSelectMin(value: Value, item: ISelectorItem, e: Record<string, any>): void;
onSelectMin?(value: Value, item: ISelectorItem, e: Record<string, any>): void;
}
export declare const SelectorDefaultProps: Partial<ISelectorProps>;

@@ -21,4 +21,4 @@ import { IBaseProps } from '../_util/base';

/**
* @description 列表
*/
* @description 列表
*/
items: {

@@ -28,2 +28,3 @@ title: string;

disabled?: boolean;
subTitle?: string;
}[];

@@ -38,3 +39,15 @@ /**

scrollMode: 'edge' | 'center';
/**
* @description tabs bar类名
*/
tabsBarClassName?: string;
/**
* @description tab类名
*/
tabClassName?: string;
/**
*@description tab active类名
*/
tabActiveClassName?: string;
}
export declare const TabsDefaultProps: Partial<ITabsProps>;

@@ -6,8 +6,14 @@ export interface Props {

name?: string;
scrollX?: any;
'a:key'?: string;
scrollLeft?: any;
onTap?: string;
checked?: boolean;
src?: string;
mode?: string;
scrollAnimationDuration?: any;
cell?: string;
scrollWithAnimation?: any;
children?: any;
scrollY?: any;
id?: string;

@@ -18,2 +24,3 @@ onScroll?: any;

onFollowLifestyle?: any;
scrollTop?: any;
catchTap?: string;

@@ -53,2 +60,3 @@ onError?: any;

fileList?: any;
isActive?: boolean;
}
{
"name": "antd-mini",
"version": "2.19.0",
"version": "2.20.0",
"description": "antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。",

@@ -5,0 +5,0 @@ "miniprogram": "compiled/wechat/src",

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

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

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

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