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
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.7-alpha.5 to 0.0.7-alpha.6

48

es/Selector/index.js

@@ -5,17 +5,19 @@ "use strict";

var props_1 = require("./props");
var mixin_1 = tslib_1.__importDefault(require("../Form/mixin"));
var controlled_1 = tslib_1.__importDefault(require("../mixins/controlled"));
var form_1 = tslib_1.__importDefault(require("../mixins/form"));
var getFixedValue = function (value, multiple) {
var fixedValue;
if (multiple) {
fixedValue = value || [];
var fixedValue = [];
if (value === null) {
fixedValue = [];
}
else {
fixedValue = (value || []).slice(0, 1);
else if (multiple && Array.isArray(value)) {
fixedValue = value;
}
else if (!Array.isArray(value)) {
fixedValue = [value];
}
return fixedValue;
};
Component({
mixins: [(0, mixin_1.default)({
defaultPropsValue: []
})],
mixins: [(0, controlled_1.default)(), (0, form_1.default)()],
props: props_1.SelectorDefaultProps,

@@ -25,11 +27,12 @@ data: {},

onChange: function (e) {
var _a = e.currentTarget.dataset, disabled = _a.disabled, value = _a.value;
var _b = this.props, multiple = _b.multiple, items = _b.items;
var _a;
var _b = e.currentTarget.dataset, disabled = _b.disabled, value = _b.value;
var _c = this.props, multiple = _c.multiple, items = _c.items;
if (!disabled && !this.props.disabled) {
var nextValue_1;
var fixedValue = getFixedValue(this.data.cValue, multiple);
if (multiple) {
var nextValue = void 0;
// 之前已经选中,删除它
if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.indexOf(value)) !== -1) {
nextValue = fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.filter(function (item) {
nextValue_1 = fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue.filter(function (item) {
return item !== value;

@@ -40,15 +43,13 @@ });

// 之前未选中,增加
nextValue = tslib_1.__spreadArray(tslib_1.__spreadArray([], fixedValue, true), [value], false);
nextValue_1 = tslib_1.__spreadArray(tslib_1.__spreadArray([], fixedValue, true), [value], false);
}
// 将 value 重新按 options 排序
var sortValue = function (v) {
return items
.map(function (item) { return item.value; })
.filter(function (item) { return v.indexOf(item) !== -1; });
return items.map(function (item) { return item.value; }).filter(function (item) { return v.indexOf(item) !== -1; });
};
nextValue = sortValue(nextValue);
this.triggerChange(nextValue);
nextValue_1 = sortValue(nextValue_1);
var selectedItems = nextValue_1.map(function (v) { var _a; return (_a = items.filter(function (item) { return item.value === v; })) === null || _a === void 0 ? void 0 : _a[0]; });
this.triggerChange(nextValue_1, selectedItems);
}
else {
var nextValue = '';
// 单选

@@ -58,9 +59,10 @@ // 取消选中

if ((fixedValue === null || fixedValue === void 0 ? void 0 : fixedValue[0]) === value) {
nextValue = '';
nextValue_1 = '';
}
else {
// 选中
nextValue = value;
nextValue_1 = value;
}
this.triggerChange(nextValue);
var selectedItem = ((_a = items.filter(function (item) { return item.value === nextValue_1; })) === null || _a === void 0 ? void 0 : _a[0]) || null;
this.triggerChange(nextValue_1, selectedItem);
}

@@ -67,0 +69,0 @@ }

{
"component": true,
"usingComponents": {}
"usingComponents": {
"tap-modal":"../TapModal/index"
}
}
{
"name": "antd-mini",
"version": "0.0.7-alpha.5",
"version": "0.0.7-alpha.6",
"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

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