v1.1.5
This commit is contained in:
parent
5f7d923b9c
commit
6cc1f00d38
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,5 +1,16 @@
|
||||
## 更新日志
|
||||
|
||||
### 1.1.5
|
||||
|
||||
*2019-12-12*
|
||||
|
||||
#### Bug fixes
|
||||
|
||||
- 修复el为dom模式时, 点击页面其他位置无法关闭下拉的问题
|
||||
- 修复tree模式的虚线显示问题
|
||||
- 修复tree默认选中半选状态不完全的问题
|
||||
|
||||
|
||||
### 1.1.4
|
||||
|
||||
*2019-12-09*
|
||||
|
4
dist/static/2.js
vendored
4
dist/static/2.js
vendored
File diff suppressed because one or more lines are too long
4
dist/static/3.js
vendored
4
dist/static/3.js
vendored
File diff suppressed because one or more lines are too long
10
dist/static/docs.js
vendored
10
dist/static/docs.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/static/wx.b556b2e.jpg
vendored
Normal file
BIN
dist/static/wx.b556b2e.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
BIN
dist/static/wx.f391ad4.jpg
vendored
BIN
dist/static/wx.f391ad4.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 81 KiB |
4
dist/xm-select.js
vendored
4
dist/xm-select.js
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 101 KiB |
@ -11,12 +11,12 @@ var demo1 = xmSelect.render({
|
||||
pageSize: 2,
|
||||
autoRow: true,
|
||||
tree: {
|
||||
strict: false,
|
||||
strict: true,
|
||||
show: true,
|
||||
showFolderIcon: true,
|
||||
showLine: true,
|
||||
indent: 20,
|
||||
expandedKeys: [ -1, -2 ],
|
||||
expandedKeys: [ 14 ],
|
||||
lazy: true,
|
||||
load: function(item, cb){
|
||||
setTimeout(function(){
|
||||
@ -38,14 +38,20 @@ var demo1 = xmSelect.render({
|
||||
show: true
|
||||
},
|
||||
height: 'auto',
|
||||
initValue: [],
|
||||
on: function(a){
|
||||
console.log(this)
|
||||
}.bind('#demo1'),
|
||||
data(){
|
||||
return [
|
||||
{name: '北京市时代峰峻莱克斯顿荆防颗粒受到了开发建设的路口附近', value: -1, children: [
|
||||
{name: '朝阳区', value: 1, children: []},
|
||||
{name: '朝阳区', value: 1, children: [
|
||||
{name: '河北省', value: -12, children: [
|
||||
{name: '廊坊市', value: 14, selected: true},
|
||||
{name: '石家庄', value: 15},
|
||||
{name: '邯郸市', value: 16},
|
||||
]}
|
||||
|
||||
]},
|
||||
{name: '海淀区', value: 2},
|
||||
{name: '通州区', value: 3},
|
||||
]},
|
||||
|
@ -1,9 +1,5 @@
|
||||
## 安装
|
||||
|
||||
### 投票 ^_^
|
||||
|
||||
谢谢大家投出宝贵的一票,[2019 年度最受欢迎开源中国软件评选](https://www.oschina.net/p/xm-select)
|
||||
|
||||
### 简介
|
||||
|
||||
:::tip
|
||||
@ -24,9 +20,11 @@ maplemei, 热爱前端的Java程序猿, 如果喜欢作者的插件, 可以请
|
||||
|
||||
### 打赏
|
||||
|
||||
喜欢就支持一下吧
|
||||
|
||||
<p>
|
||||
<a href="javascript:;">
|
||||
<img src="../assets/wx.jpg" alt="打赏" width="300">
|
||||
<img src="../assets/wx.jpg" alt="打赏" width="300" style="border: 1px solid #EFEFEF">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xm-select",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"description": "始于Layui的select多选解决方案",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -90,12 +90,13 @@ class Framework extends Component{
|
||||
})
|
||||
}
|
||||
|
||||
load(data, dataObj, flatData, parent){
|
||||
load(data, dataObj, flatData, parent, level = 0){
|
||||
const { prop, tree } = this.props;
|
||||
const { children, optgroup, value, selected, disabled } = prop;
|
||||
data.forEach(item => {
|
||||
//数据提取/处理
|
||||
item.__node = { parent, loading: item.__node && item.__node.loading }
|
||||
item.__node = { parent, level, loading: item.__node && item.__node.loading },
|
||||
console.log(item);
|
||||
|
||||
dataObj[item[value]] = item;
|
||||
flatData.push(item);
|
||||
@ -104,7 +105,7 @@ class Framework extends Component{
|
||||
if(child && isArray(child)){
|
||||
let len = child.length;
|
||||
if(len > 0){
|
||||
this.load(child, dataObj, flatData, item);
|
||||
this.load(child, dataObj, flatData, item, level + 1);
|
||||
|
||||
//是否包含子节点
|
||||
item[optgroup] = true;
|
||||
@ -123,7 +124,7 @@ class Framework extends Component{
|
||||
//检查子节点的数据是否都被选中
|
||||
let slen = child.filter(i => i[selected] === true || i.__node.selected === true).length;
|
||||
item.__node.selected = slen === len;
|
||||
item.__node.half = slen > 0 && slen < len;
|
||||
item.__node.half = slen > 0 && slen < len || child.filter(i => i.__node.half === true).length > 0;
|
||||
item.__node.disabled = child.filter(i => i[disabled] === true || i.__node.disabled === true).length === len;
|
||||
}
|
||||
}
|
||||
|
@ -261,8 +261,8 @@ class Tree extends Component{
|
||||
child.length === 0 && (expand = false)
|
||||
return (
|
||||
<div class="xm-tree">
|
||||
{ tree.showFolderIcon && tree.showLine && expand && <i class='left-line left-line-group' style={ {left: indent + 3 + 'px'} }></i> }
|
||||
{ renderItem(item, indent, child.length === 0 && item.__node.loading === false ? 0 : expand) }
|
||||
{ tree.showFolderIcon && tree.showLine && expand && child.length > 1 && <i class='left-line left-line-group' style={ {left: indent + 3 + 'px'} }></i> }
|
||||
{ renderItem(item, indent, child.length === 0 && (!tree.lazy || tree.lazy && item.__node.loading === false) ? 0 : expand) }
|
||||
{ expand && <div class="xm-tree-box">{ child.map(c => renderGroup(c, indent)) }</div> }
|
||||
</div>
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { h, Component, render } from 'preact'
|
||||
import { datas, optionData, childData } from '@/index.js';
|
||||
import { selector, warn, listenerClose, isArray, deepMerge, exchangeOptionsData } from '@/common/util'
|
||||
import { warn, listenerClose, isArray, deepMerge, exchangeOptionsData } from '@/common/util'
|
||||
import Framework from '@/components/framework'
|
||||
import defaultOptions from '@/config/options'
|
||||
|
||||
@ -28,7 +28,7 @@ class xmOptions {
|
||||
this.options = deepMerge(this.options, options);
|
||||
|
||||
//如果dom不存在, 则不进行渲染事项
|
||||
let dom = selector(this.options.el);
|
||||
let { dom } = this.options;
|
||||
if(!dom){
|
||||
warn(`没有找到渲染对象: ${options.el}, 请检查`)
|
||||
return ;
|
||||
|
14
src/index.js
14
src/index.js
@ -10,10 +10,18 @@ export default {
|
||||
name,
|
||||
version,
|
||||
render(options) {
|
||||
let { el } = options;
|
||||
let { el } = options;
|
||||
options.dom = selector(el);
|
||||
|
||||
if(el.nodeType){
|
||||
let id = "DOM_RENDER_" + Date.now() + '_' + Math.random();
|
||||
el.setAttribute(name, id);
|
||||
el = `[${name}='${id}']`
|
||||
options.el = el;
|
||||
}
|
||||
optionData[el] = options;
|
||||
|
||||
let instance = new Select(options);
|
||||
|
||||
let instance = new Select(options);
|
||||
//已经渲染
|
||||
if (instance) {
|
||||
datas[el] = instance;
|
||||
|
Loading…
Reference in New Issue
Block a user