@beisen-platform/auto-complete
Advanced tools
Comparing version 0.2.28 to 1.0.0
204
lib/index.js
@@ -1,46 +0,19 @@ | ||
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _reactDom = require("react-dom"); | ||
require("./index.css"); | ||
var _classnames = _interopRequireDefault(require("classnames")); | ||
var _es6PromiseDebounce = _interopRequireDefault(require("@beisen/es6-promise-debounce")); | ||
var _loading = _interopRequireDefault(require("@beisen-platform/loading")); | ||
var _commonMount = _interopRequireDefault(require("@beisen-platform/common-mount")); | ||
var _commonInput = _interopRequireDefault(require("@beisen-platform/common-input")); | ||
var _commonLabel = _interopRequireDefault(require("@beisen-platform/common-label")); | ||
var _toolTip = _interopRequireDefault(require("@beisen-platform/tool-tip")); | ||
var _commonFunc = require("@beisen-platform/common-func"); | ||
var _Close = _interopRequireDefault(require("@beisen-platform/react-icons/lib/icons/Close.js")); | ||
import "core-js/modules/es6.object.assign"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; | ||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; | ||
import _inherits from "@babel/runtime/helpers/inherits"; | ||
import React, { Component } from 'react'; | ||
import { findDOMNode } from 'react-dom'; | ||
import './index.css'; | ||
import classnames from 'classnames'; | ||
import debounce from '@beisen/es6-promise-debounce'; | ||
import Loading from '@beisen-platform/loading'; | ||
import CommonMount from '@beisen-platform/common-mount'; | ||
import CommonInput from '@beisen-platform/common-input'; | ||
import CommonLabel from '@beisen-platform/common-label'; | ||
import ToolTip from '@beisen-platform/tool-tip'; | ||
import { clearToolTipDom } from '@beisen-platform/common-func'; | ||
import CloseIcon from '@beisen-platform/react-icons/lib/icons/Close.js'; | ||
var defaultTranslation = { | ||
@@ -54,3 +27,3 @@ emptyBgText: '这里什么都没有...' | ||
function (_Component) { | ||
(0, _inherits2.default)(AutoComplete, _Component); | ||
_inherits(AutoComplete, _Component); | ||
@@ -60,5 +33,6 @@ function AutoComplete(props) { | ||
(0, _classCallCheck2.default)(this, AutoComplete); | ||
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(AutoComplete).call(this, props)); | ||
_classCallCheck(this, AutoComplete); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(AutoComplete).call(this, props)); | ||
_this.addClass = function (event) { | ||
@@ -168,3 +142,3 @@ if (_this.props.disabled) { | ||
_this.handlerOut = function (event) { | ||
var dom = (0, _reactDom.findDOMNode)(_this.refs.mouseIconClose); | ||
var dom = findDOMNode(_this.refs.mouseIconClose); | ||
@@ -229,3 +203,3 @@ if (dom.className.indexOf('active') <= 0) { | ||
_this.onClose = function (event) { | ||
(0, _commonFunc.clearToolTipDom)(); | ||
clearToolTipDom(); | ||
var areaUl = document.getElementsByClassName('auto-result')[0]; | ||
@@ -318,5 +292,5 @@ | ||
_this.domState = false; | ||
_this.onChange = (0, _es6PromiseDebounce.default)(_this.onChange, 300); //挂载组件 zyt | ||
_this.onChange = debounce(_this.onChange, 300); //挂载组件 zyt | ||
_this.CommonMount = new _commonMount.default({ | ||
_this.CommonMount = new CommonMount({ | ||
containerId: 'AutoComplete_ul', | ||
@@ -332,3 +306,3 @@ // 容器ID | ||
(0, _createClass2.default)(AutoComplete, [{ | ||
_createClass(AutoComplete, [{ | ||
key: "componentWillReceiveProps", | ||
@@ -349,3 +323,2 @@ value: function componentWillReceiveProps(nextProps, nextContext) { | ||
<<<<<<< HEAD | ||
}, { | ||
@@ -357,70 +330,2 @@ key: "componentDidUpdate", | ||
} | ||
======= | ||
AutoComplete.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) { | ||
if (this.domState) { | ||
this.renderDom(false, offset); | ||
}; | ||
}; | ||
AutoComplete.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this.CommonMount.unmountBox(); | ||
}; | ||
// input foucs animation | ||
// input blur animation | ||
// input onchange event | ||
// input keyup callback | ||
// list click && callback | ||
AutoComplete.prototype.renderDom = function renderDom(temp) { | ||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var _props = this.props, | ||
defaultItems = _props.defaultItems, | ||
customResultClassName = _props.customResultClassName; | ||
var height = defaultItems.length > 10 ? '320px' : 'inherit'; | ||
var setHeight = defaultItems.length > 10 ? '320px' : defaultItems.length * 32 + 'px'; | ||
var _state = this.state, | ||
inputValue = _state.inputValue, | ||
isShow = _state.isShow; | ||
var overflowY = height == 'inherit' ? 'hidden' : 'scroll'; | ||
var findResultChild = defaultItems.length > 0 && inputValue.length > 0 ? defaultItems : ''; | ||
var findResult = defaultItems.length == 0 && inputValue.length > 0 ? _react2.default.createElement( | ||
'div', | ||
{ className: 'us-no-data' }, | ||
_react2.default.createElement('span', { className: 'u-icon empty-icon', 'data-bg-text': this.translation.emptyBgText }) | ||
) : findResultChild; | ||
var showAutoUl = isShow && inputValue.length != 0 ? _react2.default.createElement( | ||
'ul', | ||
{ className: "auto-result " + customResultClassName, onClick: this.itemClick }, | ||
_react2.default.createElement( | ||
'div', | ||
{ style: { "maxHeight": height, 'overflowY': overflowY, backgroundColor: "#FFF" } }, | ||
findResult | ||
) | ||
) : ''; | ||
if (this.props.isFetching) { | ||
showAutoUl = isShow ? _react2.default.createElement( | ||
'ul', | ||
{ className: 'auto-result', onClick: this.itemClick }, | ||
_react2.default.createElement( | ||
'div', | ||
{ style: { "maxHeight": height, 'overflowY': overflowY, backgroundColor: "#FFF", height: '200px' } }, | ||
_react2.default.createElement(_loading2.default, { type: 'small' }) | ||
) | ||
) : ''; | ||
//解决出现loading时跳动问题。author lsh | ||
setHeight = "200px"; | ||
>>>>>>> master | ||
} | ||
@@ -431,2 +336,9 @@ }, { | ||
this.CommonMount.unmountBox(); | ||
document.removeEventListener('mouseup', this.onClose); | ||
} | ||
}, { | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
document.removeEventListener('mouseup', this.onClose); | ||
document.addEventListener('mouseup', this.onClose); | ||
} // input foucs animation | ||
@@ -448,11 +360,12 @@ | ||
var findResultChild = defaultItems.length > 0 && inputValue.length > 0 ? defaultItems : ''; | ||
var findResult = defaultItems.length === 0 && inputValue.length > 0 ? _react.default.createElement("div", { | ||
var findResult = defaultItems.length === 0 && inputValue.length > 0 ? React.createElement("div", { | ||
className: "us-no-data" | ||
}, _react.default.createElement("span", { | ||
className: "u-icon empty-icon" | ||
}, React.createElement("span", { | ||
className: "u-icon empty-icon", | ||
"data-bg-text": this.translation.emptyBgText | ||
})) : findResultChild; | ||
var showAutoUl = isShow && inputValue.length !== 0 ? _react.default.createElement("ul", { | ||
var showAutoUl = isShow && inputValue.length !== 0 ? React.createElement("ul", { | ||
className: "auto-result " + customResultClassName, | ||
onClick: this.itemClick | ||
}, _react.default.createElement("div", { | ||
}, React.createElement("div", { | ||
style: { | ||
@@ -466,6 +379,6 @@ "maxHeight": height, | ||
if (this.props.isFetching) { | ||
showAutoUl = isShow ? _react.default.createElement("ul", { | ||
showAutoUl = isShow ? React.createElement("ul", { | ||
className: "auto-result", | ||
onClick: this.itemClick | ||
}, _react.default.createElement("div", { | ||
}, React.createElement("div", { | ||
style: { | ||
@@ -477,3 +390,3 @@ "maxHeight": height, | ||
} | ||
}, _react.default.createElement(_loading.default, { | ||
}, React.createElement(Loading, { | ||
type: "small" | ||
@@ -504,3 +417,3 @@ }))) : ''; //解决出现loading时跳动问题。author lsh | ||
if (this.props.hidden) { | ||
return _react.default.createElement("div", { | ||
return React.createElement("div", { | ||
className: "field auto-complete" | ||
@@ -526,3 +439,3 @@ }); | ||
var autoInputDivClass = (0, _classnames.default)({ | ||
var autoInputDivClass = classnames({ | ||
'auto-form-input': true, | ||
@@ -535,3 +448,3 @@ 'form-item__control': true, | ||
var closeDisabled = !showCloseBtn || !isHover || inputValue.length <= 0; | ||
var closeIcon = (0, _classnames.default)({ | ||
var closeIcon = classnames({ | ||
'u-icon': true, | ||
@@ -542,5 +455,5 @@ 'icon-close': true, | ||
}); | ||
return _react.default.createElement("div", { | ||
return React.createElement("div", { | ||
className: "form-item" | ||
}, _react.default.createElement(_commonLabel.default, this.props), readOnly || disabled ? _react.default.createElement(_commonInput.default, { | ||
}, React.createElement(CommonLabel, this.props), readOnly || disabled ? React.createElement(CommonInput, { | ||
readonly: true, | ||
@@ -550,3 +463,3 @@ errorMsg: errorMsg, | ||
defaultValue: inputValue | ||
}) : _react.default.createElement("div", { | ||
}) : React.createElement("div", { | ||
ref: "mouseIconClose", | ||
@@ -556,5 +469,5 @@ className: autoInputDivClass, | ||
onMouseOut: this.handlerOut | ||
}, _react.default.createElement(_toolTip.default, { | ||
}, React.createElement(ToolTip, { | ||
title: inputValue | ||
}, _react.default.createElement("div", { | ||
}, React.createElement("div", { | ||
className: "form-item_is-hidden-tips", | ||
@@ -565,3 +478,3 @@ style: { | ||
onClick: this.tipsClick | ||
}, inputValue)), _react.default.createElement("input", { | ||
}, inputValue)), React.createElement("input", { | ||
ref: "textInput", | ||
@@ -583,9 +496,9 @@ className: "u-input", | ||
onBlur: this.removeClass | ||
}), _react.default.createElement("span", { | ||
}), React.createElement("span", { | ||
className: "form-item__right-icon auto-complete__btn-group", | ||
onClick: this.clearInputValue | ||
}, _react.default.createElement("i", { | ||
}, React.createElement("i", { | ||
className: closeIcon, | ||
onClick: this.addClass | ||
}, _react.default.createElement(_Close.default, null))), (errorStatus || isFocus) && changeText && !readOnly ? _react.default.createElement("span", { | ||
}, React.createElement(CloseIcon, null))), (errorStatus || isFocus) && changeText && !readOnly ? React.createElement("span", { | ||
className: "form-item__explain" | ||
@@ -595,6 +508,6 @@ }, changeText) : null)); | ||
}]); | ||
return AutoComplete; | ||
}(_react.Component); | ||
}(Component); | ||
exports.default = AutoComplete; | ||
AutoComplete.defaultProps = { | ||
@@ -605,2 +518,3 @@ showCloseBtn: true, | ||
isNeedResetValOnMouseUp: true | ||
}; | ||
}; | ||
export { AutoComplete as default }; |
{ | ||
"name": "@beisen-platform/auto-complete", | ||
"version": "0.2.28", | ||
"version": "1.0.0", | ||
"description": "平台智能搜索组件", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
7
1065272
10
25440