first commit
This commit is contained in:
1
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/.pydio
vendored
Normal file
1
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/.pydio
vendored
Normal file
@@ -0,0 +1 @@
|
||||
d172a121-0ded-47da-8a57-6654ce0afc3d
|
||||
224
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.js
vendored
Normal file
224
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.js
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
import baseComponent from '../helpers/baseComponent'
|
||||
import classNames from '../helpers/classNames'
|
||||
import eventsMixin from '../helpers/eventsMixin'
|
||||
import styleToCssString from '../helpers/styleToCssString'
|
||||
|
||||
const defaultEvents = {
|
||||
onChange() {},
|
||||
onFocus() {},
|
||||
onBlur() {},
|
||||
onConfirm() {},
|
||||
onClear() {},
|
||||
onError() {},
|
||||
}
|
||||
|
||||
baseComponent({
|
||||
behaviors: [eventsMixin({ defaultEvents })],
|
||||
relations: {
|
||||
'../field/index': {
|
||||
type: 'ancestor',
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
prefixCls: {
|
||||
type: String,
|
||||
value: 'wux-input',
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
extra: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
defaultValue: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
value: '',
|
||||
observer(newVal) {
|
||||
if (this.data.controlled) {
|
||||
this.updated(newVal)
|
||||
}
|
||||
},
|
||||
},
|
||||
controlled: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
value: 'text',
|
||||
},
|
||||
password: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
placeholderStyle: {
|
||||
type: [String, Object],
|
||||
value: '',
|
||||
observer(newVal) {
|
||||
this.setData({
|
||||
extStyle: styleToCssString(newVal),
|
||||
})
|
||||
},
|
||||
},
|
||||
placeholderClass: {
|
||||
type: String,
|
||||
value: 'input-placeholder',
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
maxlength: {
|
||||
type: Number,
|
||||
value: 140,
|
||||
},
|
||||
cursorSpacing: {
|
||||
type: Number,
|
||||
value: 11,
|
||||
},
|
||||
focus: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
confirmType: {
|
||||
type: String,
|
||||
value: 'done',
|
||||
},
|
||||
confirmHold: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
cursor: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
},
|
||||
selectionStart: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
},
|
||||
selectionEnd: {
|
||||
type: Number,
|
||||
value: -1,
|
||||
},
|
||||
adjustPosition: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
clear: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
error: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
inputValue: '',
|
||||
inputFocus: false,
|
||||
extStyle: '',
|
||||
},
|
||||
computed: {
|
||||
classes: ['prefixCls, disabled, inputFocus, error', function(prefixCls, disabled, inputFocus, hasError) {
|
||||
const wrap = classNames(prefixCls, {
|
||||
[`${prefixCls}--focus`]: inputFocus,
|
||||
[`${prefixCls}--disabled`]: disabled,
|
||||
[`${prefixCls}--error`]: hasError,
|
||||
})
|
||||
const label = `${prefixCls}__label`
|
||||
const control = `${prefixCls}__control`
|
||||
const item = `${prefixCls}__item`
|
||||
const clear = `${prefixCls}__clear`
|
||||
const error = `${prefixCls}__error`
|
||||
const extra = `${prefixCls}__extra`
|
||||
|
||||
return {
|
||||
wrap,
|
||||
label,
|
||||
control,
|
||||
item,
|
||||
clear,
|
||||
error,
|
||||
extra,
|
||||
}
|
||||
}],
|
||||
},
|
||||
methods: {
|
||||
updated(inputValue) {
|
||||
if (this.hasFieldDecorator) return
|
||||
if (this.data.inputValue !== inputValue) {
|
||||
this.setData({ inputValue })
|
||||
}
|
||||
},
|
||||
onChange(e) {
|
||||
const { value } = e.detail
|
||||
|
||||
if (!this.data.controlled) {
|
||||
this.updated(value)
|
||||
}
|
||||
|
||||
this.triggerEvent('change', e.detail)
|
||||
},
|
||||
onFocus(e) {
|
||||
this.clearTimer()
|
||||
|
||||
this.setData({
|
||||
inputFocus: true,
|
||||
})
|
||||
|
||||
this.triggerEvent('focus', e.detail)
|
||||
},
|
||||
onBlur(e) {
|
||||
this.setTimer()
|
||||
this.triggerEvent('blur', e.detail)
|
||||
},
|
||||
onConfirm(e) {
|
||||
this.triggerEvent('confirm', e.detail)
|
||||
},
|
||||
onClear(e) {
|
||||
const params = { value: '' }
|
||||
|
||||
if (!this.data.controlled) {
|
||||
this.updated(params.value)
|
||||
}
|
||||
|
||||
this.triggerEvent('change', params)
|
||||
this.triggerEvent('clear', params)
|
||||
},
|
||||
onError() {
|
||||
const { inputValue: value } = this.data
|
||||
this.triggerEvent('error', { value })
|
||||
},
|
||||
setTimer() {
|
||||
this.clearTimer()
|
||||
|
||||
this.timeout = setTimeout(() => {
|
||||
this.setData({
|
||||
inputFocus: false,
|
||||
})
|
||||
}, 200)
|
||||
},
|
||||
clearTimer() {
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout)
|
||||
this.timeout = null
|
||||
}
|
||||
},
|
||||
},
|
||||
attached() {
|
||||
const { defaultValue, value, controlled } = this.data
|
||||
const inputValue = controlled ? value : defaultValue
|
||||
|
||||
this.updated(inputValue)
|
||||
},
|
||||
})
|
||||
3
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.json
vendored
Normal file
3
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
41
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.wxml
vendored
Normal file
41
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.wxml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<view class="wux-class {{ classes.wrap }}">
|
||||
<view class="{{ classes.label }}" wx:if="{{ label }}">{{ label }}</view>
|
||||
<block wx:else>
|
||||
<slot></slot>
|
||||
</block>
|
||||
<view class="{{ classes.control }}">
|
||||
<input
|
||||
class="{{ classes.item }}"
|
||||
value="{{ inputValue }}"
|
||||
type="{{ type }}"
|
||||
password="{{ password }}"
|
||||
placeholder="{{ placeholder }}"
|
||||
placeholder-style="{{ extStyle }}"
|
||||
placeholder-class="{{ placeholderClass }}"
|
||||
disabled="{{ disabled }}"
|
||||
maxlength="{{ maxlength }}"
|
||||
cursor-spacing="{{ cursorSpacing }}"
|
||||
focus="{{ focus }}"
|
||||
confirm-type="{{ confirmType }}"
|
||||
confirm-hold="{{ confirmHold }}"
|
||||
cursor="{{ cursor }}"
|
||||
selection-start="{{ selectionStart }}"
|
||||
selection-end="{{ selectionEnd }}"
|
||||
adjust-position="{{ adjustPosition }}"
|
||||
bindinput="onChange"
|
||||
bindfocus="onFocus"
|
||||
bindblur="onBlur"
|
||||
bindconfirm="onConfirm"
|
||||
/>
|
||||
</view>
|
||||
<view class="{{ classes.clear }}" bindtap="onClear" wx:if="{{ clear && !disabled && inputValue && inputValue.length > 0 }}">
|
||||
<icon type="clear" color="#B2B2B2" size="14" />
|
||||
</view>
|
||||
<view class="{{ classes.error }}" bindtap="onError" wx:if="{{ error }}">
|
||||
<icon type="warn" color="#ef473a" size="14" />
|
||||
</view>
|
||||
<view class="{{ classes.extra }}" wx:if="{{ extra }}">{{ extra }}</view>
|
||||
<block wx:else>
|
||||
<slot name="footer"></slot>
|
||||
</block>
|
||||
</view>
|
||||
50
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.wxss
vendored
Normal file
50
衣莎项目/源码/YiShaXiYi/extend/wux/dist/input/index.wxss
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
.wux-input {
|
||||
position: relative;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-align: center;
|
||||
align-items: center
|
||||
}
|
||||
.wux-input__label {
|
||||
margin-left: 0;
|
||||
margin-right: 10rpx;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
width: 210rpx
|
||||
}
|
||||
.wux-input__control {
|
||||
-ms-flex: 1;
|
||||
flex: 1
|
||||
}
|
||||
.wux-input__item {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
-webkit-appearance: none;
|
||||
background-color: transparent;
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
height: 1.47058824em;
|
||||
min-height: 1.47058824em;
|
||||
line-height: 1.47058824
|
||||
}
|
||||
.wux-input__extra {
|
||||
color: rgba(0,0,0,.45);
|
||||
margin-left: 10rpx
|
||||
}
|
||||
.wux-input__error {
|
||||
margin-left: 10rpx
|
||||
}
|
||||
.wux-input__clear {
|
||||
display: none
|
||||
}
|
||||
.wux-input--focus .wux-input__clear {
|
||||
display: block
|
||||
}
|
||||
.wux-input--disabled {
|
||||
opacity: .3
|
||||
}
|
||||
.wux-input--error .wux-input__control {
|
||||
color: #ef473a
|
||||
}
|
||||
Reference in New Issue
Block a user