This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化表单组件;修复readOnly

old
宇天 2020-07-22 19:56:46 +08:00
parent f573fa5a61
commit b5cf3b8bb6
33 changed files with 267 additions and 115 deletions

View File

@ -132,7 +132,7 @@ function mkWCFile({ style, html, js }) {
return `/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date ${BUILD_DATE}
* @version v${VERSION}
*

View File

@ -143,7 +143,7 @@ function mkWCFile({ style, html, js }) {
return `/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date ${BUILD_DATE}
* @version v${VERSION}
*

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2018-08-04 18:47:35
*/
@ -133,15 +133,44 @@ function CodeMirror(place, givenOptions) {
updateInput = false
})()
var history = new History()
connect(scroller, 'mousedown', operation(onMouseDown))
connect(scroller, 'dblclick', operation(onDoubleClick))
connect(lineSpace, 'selectstart', e_preventDefault)
if (!gecko) connect(scroller, 'contextmenu', onContextMenu)
connect(scroller, 'scroll', onScrollMain)
connect(scrollbar, 'scroll', onScrollBar)
connect(scrollbar, 'mousedown', function() {
if (focused) setTimeout(focusInput, 0)
})
connect(
scroller,
'mousedown',
operation(onMouseDown)
)
connect(
scroller,
'dblclick',
operation(onDoubleClick)
)
connect(
lineSpace,
'selectstart',
e_preventDefault
)
if (!gecko)
connect(
scroller,
'contextmenu',
onContextMenu
)
connect(
scroller,
'scroll',
onScrollMain
)
connect(
scrollbar,
'scroll',
onScrollBar
)
connect(
scrollbar,
'mousedown',
function() {
if (focused) setTimeout(focusInput, 0)
}
)
var resizeHandler = connect(
window,
'resize',
@ -151,31 +180,79 @@ function CodeMirror(place, givenOptions) {
},
true
)
connect(input, 'keyup', operation(onKeyUp))
connect(input, 'input', fastPoll)
connect(input, 'keydown', operation(onKeyDown))
connect(input, 'keypress', operation(onKeyPress))
connect(input, 'focus', onFocus)
connect(input, 'blur', onBlur)
connect(
input,
'keyup',
operation(onKeyUp)
)
connect(
input,
'input',
fastPoll
)
connect(
input,
'keydown',
operation(onKeyDown)
)
connect(
input,
'keypress',
operation(onKeyPress)
)
connect(
input,
'focus',
onFocus
)
connect(
input,
'blur',
onBlur
)
function drag_(e) {
if (options.onDragEvent && options.onDragEvent(instance, addStop(e))) return
e_stop(e)
}
if (options.dragDrop) {
connect(scroller, 'dragstart', onDragStart)
connect(scroller, 'dragenter', drag_)
connect(scroller, 'dragover', drag_)
connect(scroller, 'drop', operation(onDrop))
connect(
scroller,
'dragstart',
onDragStart
)
connect(
scroller,
'dragenter',
drag_
)
connect(
scroller,
'dragover',
drag_
)
connect(
scroller,
'drop',
operation(onDrop)
)
}
connect(scroller, 'paste', function() {
focusInput()
fastPoll()
})
connect(input, 'paste', function() {
pasteIncoming = true
fastPoll()
})
connect(
scroller,
'paste',
function() {
focusInput()
fastPoll()
}
)
connect(
input,
'paste',
function() {
pasteIncoming = true
fastPoll()
}
)
connect(
input,
'cut',
@ -184,10 +261,14 @@ function CodeMirror(place, givenOptions) {
})
)
if (khtml)
connect(sizer, 'mouseup', function() {
if (document.activeElement == input) input.blur()
focusInput()
})
connect(
sizer,
'mouseup',
function() {
if (document.activeElement == input) input.blur()
focusInput()
}
)
var hasFocus
try {
hasFocus = document.activeElement == input
@ -698,8 +779,18 @@ function CodeMirror(place, givenOptions) {
type == 'single'
) {
if (webkit) scroller.draggable = true
var up = connect(document, 'mouseup', operation(dragEnd), true)
var drop = connect(scroller, 'drop', operation(dragEnd), true)
var up = connect(
document,
'mouseup',
operation(dragEnd),
true
)
var drop = connect(
scroller,
'drop',
operation(dragEnd),
true
)
draggingText = true
if (scroller.dragDrop) scroller.dragDrop()
return
@ -775,7 +866,12 @@ function CodeMirror(place, givenOptions) {
}),
true
)
var up = connect(document, 'mouseup', operation(done), true)
var up = connect(
document,
'mouseup',
operation(done),
true
)
}
function onDoubleClick(e) {
@ -2032,12 +2128,12 @@ function CodeMirror(place, givenOptions) {
var check = isWordChar(startChar)
? isWordChar
: /\s/.test(startChar)
? function(ch) {
return /\s/.test(ch)
}
: function(ch) {
return !/\s/.test(ch) && isWordChar(ch)
}
? function(ch) {
return /\s/.test(ch)
}
: function(ch) {
return !/\s/.test(ch) && isWordChar(ch)
}
while (start > 0 && check(line.charAt(start - 1))) --start
while (end < line.length && check(line.charAt(end))) ++end
}
@ -3358,7 +3454,12 @@ CodeMirror.fromTextArea = function(textarea, options) {
textarea.value = instance.getValue()
}
if (textarea.form) {
var rmSubmit = connect(textarea.form, 'submit', save, true)
var rmSubmit = connect(
textarea.form,
'submit',
save,
true
)
var realSubmit = textarea.form.submit
textarea.form.submit = function wrappedSubmit() {
save()
@ -3764,7 +3865,7 @@ Line.prototype = {
if (!m) break
pos += skipped + 1
if (m[0] == '\t') {
var tabWidth = tabSize - col % tabSize
var tabWidth = tabSize - (col % tabSize)
content.appendChild(elt('span', spaceStr(tabWidth), 'cm-tab'))
col += tabWidth
} else {
@ -4287,7 +4388,7 @@ function countColumn(string, end, tabSize) {
if (end == -1) end = string.length
}
for (var i = 0, n = 0; i < end; ++i) {
if (string.charAt(i) == '\t') n += tabSize - n % tabSize
if (string.charAt(i) == '\t') n += tabSize - (n % tabSize)
else ++n
}
return n

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2018-08-04 18:47:35
*/
@ -117,8 +117,8 @@ CodeMirror.defineMode(
state.token == html
? htmlMode
: state.token == javascript
? jsMode
: cssMode
? jsMode
: cssMode
return {
state: state.localState || state.htmlState,
mode: mode

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2016-08-19 10:38:25
*
*/

View File

@ -1,7 +1,7 @@
@charset "UTF-8";
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-17 16:43:22
*
*/

View File

@ -0,0 +1 @@
.do-meditor-attach{width:630px;height:300px;cursor:default;color:#526273}.do-meditor-attach ::-webkit-scrollbar{width:5px;height:5px;background:#f2f5fc}.do-meditor-attach ::-webkit-scrollbar:hover{background:#e8ebf4}.do-meditor-attach ::-webkit-scrollbar-button{display:none}.do-meditor-attach ::-webkit-scrollbar-thumb{background:#bdbdbd}.do-meditor-attach ::-webkit-scrollbar-thumb:hover{background:#9e9e9e}.do-meditor-attach .tab-box{float:left;width:130px;height:300px;padding:10px 5px;text-align:center;background:#f2f5fc;border-radius:5px}.do-meditor-attach .tab-box .item{display:block;width:100%;height:40px;line-height:40px;border-radius:3px;cursor:pointer}.do-meditor-attach .tab-box .item.active{background:#fff}.do-meditor-attach .cont-box{position:relative;float:right;width:480px;height:auto;min-height:200px}.do-meditor-attach .cont-box .remote,.do-meditor-attach .cont-box .local{position:relative;width:92%;height:auto;margin:0 auto}.do-meditor-attach .cont-box .remote{padding:30px 0}.do-meditor-attach .cont-box .hide{display:none}.do-meditor-attach .cont-box .section{display:block;width:100%;height:auto;margin:15px 0;line-height:35px}.do-meditor-attach .cont-box .section .submit{float:right;width:30%;height:45px;line-height:45px}.do-meditor-attach .cont-box .select-file{width:100%;height:35px;line-height:35px}.do-meditor-attach .cont-box .select-file .file{float:left;width:100px;height:35px;border-radius:3px;background:#e8ebf4;text-align:center;cursor:pointer}.do-meditor-attach .cont-box .select-file .file:hover{background:#f2f5fc}.do-meditor-attach .cont-box .select-file .file:active{background:#dae1e9}.do-meditor-attach .cont-box .select-file .tips{display:inline-block;padding:0 10px}.do-meditor-attach .cont-box .upload-box{width:100%;height:auto;min-height:255px;padding-top:10px}.do-meditor-attach .cont-box .upload-box .thead{width:100%;height:35px;line-height:35px;background:#f2f5fc}.do-meditor-attach .cont-box .upload-box .col{overflow:hidden;float:left;height:30px;padding:0 5px;text-align:center}.do-meditor-attach .cont-box .upload-box .col:nth-child(1){width:50%}.do-meditor-attach .cont-box .upload-box .col:nth-child(2){width:35%}.do-meditor-attach .cont-box .upload-box .col:nth-child(3){width:15%}.do-meditor-attach .cont-box .upload-box .tbody{overflow:hidden;overflow-y:auto;width:100%;height:220px}.do-meditor-attach .cont-box .upload-box .tbody p{display:block;width:100%;height:30px;line-height:30px}.do-meditor-attach .cont-box .upload-box .insert{display:inline-block;padding:3px 5px;line-height:13px;background:#f2f5fc;color:#526273;cursor:pointer}.do-meditor-attach .cont-box .upload-box .red{color:#f30}.do-meditor-attach .cont-box .manager{overflow:hidden;overflow-y:auto;width:100%;height:300px}.do-meditor-attach .cont-box .manager .list-box{width:100%;-webkit-column-count:4;column-count:4;-webkit-column-gap:5;column-gap:5}.do-meditor-attach .cont-box .manager .item{margin:0 0 10px;padding:5px;text-align:center;background:#f2f5fc;-webkit-column-break-inside:avoid;break-inside:avoid;transition:background .2s ease-in-out}.do-meditor-attach .cont-box .manager .item:hover{background:#dae1e9}.do-meditor-attach .cont-box .manager .item .thumb{display:block;width:100%}.do-meditor-attach .cont-box .manager .item .name{overflow:hidden;height:30px;line-height:30px;text-align:center}.do-meditor-attach .cont-box .manager .item img{width:100%;height:auto}.do-meditor-attach .cont-box .manager .item em{line-height:1;font-size:50px}

View File

@ -1,7 +1,7 @@
@charset "UTF-8";
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-20 19:13:24
*
*/

View File

@ -1,7 +1,7 @@
@charset "UTF-8";
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2014-10-10 00:45:09
*
* douiCSS

1
src/css/tree.css Normal file
View File

@ -0,0 +1 @@
.do-tree{overflow:hidden;overflow-y:auto;position:relative;display:block;width:100%;height:100%;line-height:30px;font-size:15px;color:#526273}.do-tree__item{overflow:hidden;min-height:30px}.do-tree__item .sub-tree{display:none;width:100%;padding-left:20px}.do-tree__item em,.do-tree__item span{display:block;cursor:pointer}.do-tree__item em{float:left;padding:0 5px;font-size:20px;color:#62778d}.do-tree__item span:hover{color:#62778d}.do-tree__item span.active{color:#425064;font-weight:bold}.do-tree__item span.checkbox{float:left;position:relative;width:18px;height:18px;margin:6px 5px 6px 0;line-height:16px;border:1px solid #526273;border-radius:3px;font-size:16px;text-align:center}.do-tree__item span.label{white-space:nowrap;text-overflow:ellipsis}.do-tree__item.open>.sub-tree{display:block}

View File

@ -1,7 +1,7 @@
@charset "UTF-8";
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-14 21:18:53
*
*/

View File

@ -1,6 +1,6 @@
/**
* 拖拽插件的核心部分
* @author yutent<yutent@doui.cc>
* @author yutent<yutent.io@gmail.com>
* @date 2019/08/23 19:41:21
*/

View File

@ -1,6 +1,6 @@
/**
* 拖拽指令 :drag
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-03-29 18:39:35
*
*/

View File

@ -165,7 +165,6 @@ export default class Checkbox {
}
set value(val) {
log(val, this, this.props.label)
if (Array.isArray(val)) {
this.props.value = val
this.checked = this.props.value.includes(this.props.label)
@ -261,7 +260,11 @@ export default class Checkbox {
case 'checked':
case 'readonly':
case 'disabled':
this[name] = true
var k = name
if (k === 'readonly') {
k = 'readOnly'
}
this[k] = true
break
}
}

View File

@ -25,6 +25,7 @@ li {
-moz-user-select: none;
color: nth($cd, 2);
border-radius: 2px;
cursor: text;
}
.label {
@ -40,7 +41,7 @@ li {
border-radius: inherit;
background: #fff;
color: inherit;
cursor: text;
cursor: inherit;
input,
textarea {
@ -52,8 +53,7 @@ li {
border: 0;
border-radius: inherit;
color: inherit;
font-size: inherit;
font-family: inherit;
font: inherit;
background: none;
outline: none;
box-shadow: none;
@ -154,10 +154,16 @@ li {
:host([auto-border]) .label {
border-color: transparent;
}
:host([disabled]) .label {
background: nth($cp, 1);
:host([disabled]) {
cursor: not-allowed;
opacity: 0.6;
.label {
background: nth($cp, 1);
opacity: 0.6;
}
}
:host([readonly]) {
cursor: default;
}
:host(:focus-within) {
@include focus1;
@ -549,7 +555,11 @@ export default class Input {
case 'readonly':
case 'disabled':
this[name] = true
var k = name
if (k === 'readonly') {
k = 'readOnly'
}
this[k] = true
break
}
}

View File

@ -373,7 +373,11 @@ export default class Number {
case 'readonly':
case 'disabled':
this[name] = true
var k = name
if (k === 'readonly') {
k = 'readOnly'
}
this[k] = true
break
}
}

View File

@ -26,16 +26,14 @@
color: nth($cgr, 3);
&.checked .dot::after {
display: block;
width: 12px;
height: 12px;
border-radius: 50%;
background: nth($cgr, 1);
content: '';
}
}
.dot {
display: flex;
justify-content: center;
align-items: center;
width: 18px;
height: 18px;
padding: 2px;
@ -43,6 +41,14 @@
border: 1px solid nth($cgr, 1);
border-radius: 50%;
background: #fff;
&::after {
display: block;
width: 12px;
height: 12px;
border-radius: 50%;
background: nth($cgr, 1);
}
}
}
@ -57,33 +63,46 @@
:host([size='large']) {
label {
width: 58px;
min-width: 58px;
height: 32px;
}
.dot {
width: 26px;
height: 26px;
&::after {
width: 18px;
height: 18px;
}
}
}
:host([size='medium']) {
label {
width: 50px;
min-width: 50px;
height: 28px;
}
.dot {
width: 22px;
height: 22px;
&::after {
width: 14px;
height: 14px;
}
}
}
:host([size='mini']) {
label {
width: 22px;
height: 14px;
padding: 2px;
}
.dot {
width: 10px;
height: 10px;
width: 14px;
height: 14px;
&::after {
width: 8px;
height: 8px;
}
}
}
@ -230,11 +249,13 @@ export default class Radio {
}
mounted() {
this._handleClick = $.bind(this, 'click', ev => {
if (!this.disabled && !this.readOnly && !this.checked) {
this.checked = true
this.dispatchEvent(new CustomEvent('input'))
this._handleClick = $.catch(this, 'click', ev => {
if (this.disabled || this.readOnly || this.checked) {
return
}
this.checked = true
this.dispatchEvent(new CustomEvent('input'))
})
}
@ -251,7 +272,11 @@ export default class Radio {
case 'checked':
case 'readonly':
case 'disabled':
this[name] = true
var k = name
if (k === 'readonly') {
k = 'readOnly'
}
this[k] = true
break
}
}

View File

@ -521,7 +521,11 @@ export default class Select {
case 'readonly':
case 'disabled':
this[name] = true
var k = name
if (k === 'readonly') {
k = 'readOnly'
}
this[k] = true
break
}
}

View File

@ -15,15 +15,17 @@
display: flex;
justify-content: center;
align-items: center;
// vertical-align: middle;
line-height: 0;
white-space: nowrap;
}
label {
display: flex;
width: 38px;
height: 22px;
align-items: center;
width: 32px;
height: 18px;
padding: 3px;
margin: 5px;
line-height: 0;
border-radius: 21px;
background: nth($cp, 3);
cursor: inherit;
@ -34,8 +36,8 @@
}
}
.dot {
width: 16px;
height: 16px;
width: 12px;
height: 12px;
border-radius: 50%;
background: #fff;
}
@ -48,22 +50,24 @@
:host([size='large']) {
label {
width: 58px;
height: 32px;
width: 46px;
height: 26px;
padding: 3px 5px;
}
.dot {
width: 26px;
height: 26px;
width: 18px;
height: 18px;
}
}
:host([size='medium']) {
label {
width: 50px;
height: 28px;
width: 38px;
height: 22px;
padding: 3px 4px;
}
.dot {
width: 22px;
height: 22px;
width: 16px;
height: 16px;
}
}
:host([size='mini']) {

View File

@ -1,6 +1,6 @@
/**
* {icon svg}
* @author yutent<yutent@doui.cc>
* @author yutent<yutent.io@gmail.com>
* @date 2019/07/17 15:12:14
*/

View File

@ -1,6 +1,6 @@
/**
* markdown解析器
* @author yutent<yutent@doui.cc>
* @author yutent<yutent.io@gmail.com>
* @date 2020/02/07 17:14:19
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-19 21:17:26
*
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-19 21:17:26
*
*/
@ -108,7 +108,7 @@ class Uploader {
'progress',
evt => {
if (evt.lengthComputable && this.progress) {
let res = Math.round(evt.loaded * 100 / evt.total)
let res = Math.round((evt.loaded * 100) / evt.total)
this.progress(res)
}
},

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-17 21:41:48
*
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-17 16:37:12
*
*/
@ -471,7 +471,7 @@ Anot.component('meditor', {
let sh = ev.target.scrollHeight
let ch = ev.target.clientHeight
let psh = preview.scrollHeight
let syncTop = st / (sh - ch) * (psh - ch)
let syncTop = (st / (sh - ch)) * (psh - ch)
preview.scrollTop = syncTop
})
//编辑器成功加载的回调

View File

@ -1,6 +1,6 @@
/**
* icon字典
* @author yutent<yutent@doui.cc>
* @author yutent<yutent.io@gmail.com>
* @date 2019/07/08 17:39:11
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2018-03-25 23:59:13
* @version $Id$
*/
@ -441,7 +441,6 @@ if (!window.request) {
this.__INIT__ = param
}
}
Anot.ui.request = request.version
}
export default request

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2016-11-26 16:35:45
*
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-14 21:04:50
*
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2018-06-25 21:39:42
* @version $Id$
*/

View File

@ -1,6 +1,6 @@
/**
*
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2017-04-14 21:04:50
*
*/

View File

@ -1,7 +1,7 @@
/**
* Uploader 无刷新上传文件(next版)
* 只支持chrome/firefox/IE10+/opera12+
* @authors yutent (yutent@doui.cc)
* @authors yutent (yutent.io@gmail.com)
* @date 2016-09-05 19:33:23
*
*/
@ -74,7 +74,7 @@ define(function() {
function(evt) {
if (evt.lengthComputable && _this.progress) {
var now = Date.now()
var upSize = evt.loaded * 1000 / 1024
var upSize = (evt.loaded * 1000) / 1024
var res = { loaded: evt.loaded, time: now - startTime }
res.speed = upSize / res.time
@ -84,7 +84,7 @@ define(function() {
res.speed = res.speed.toFixed(2) + ' KB/s'
}
res.progress = Math.round(evt.loaded * 100 / evt.total)
res.progress = Math.round((evt.loaded * 100) / evt.total)
_this.progress(res)
}
},

View File

@ -1,6 +1,6 @@
/**
* 公共方法库
* @author yutent<yutent@doui.cc>
* @author yutent<yutent.io@gmail.com>
* @date 2019/08/08 10:47:55
*/