222
This commit is contained in:
+145
@@ -0,0 +1,145 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
name: "u-textarea",
|
||||
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$2],
|
||||
data() {
|
||||
return {
|
||||
// 输入框的值
|
||||
innerValue: "",
|
||||
// 是否处于获得焦点状态
|
||||
focused: false,
|
||||
// value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
|
||||
firstChange: true,
|
||||
// value绑定值的变化是由内部还是外部引起的
|
||||
changeFromInner: false,
|
||||
// 过滤处理方法
|
||||
innerFormatter: (value) => value
|
||||
};
|
||||
},
|
||||
created() {
|
||||
},
|
||||
watch: {
|
||||
modelValue: {
|
||||
immediate: true,
|
||||
handler(newVal, oldVal) {
|
||||
this.innerValue = newVal;
|
||||
this.firstChange = false;
|
||||
this.changeFromInner = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
fieldStyle() {
|
||||
let style = {};
|
||||
style["height"] = common_vendor.addUnit(this.height);
|
||||
if (this.autoHeight) {
|
||||
style["height"] = "auto";
|
||||
style["minHeight"] = common_vendor.addUnit(this.height);
|
||||
}
|
||||
return style;
|
||||
},
|
||||
// 组件的类名
|
||||
textareaClass() {
|
||||
let classes = [], { border, disabled } = this;
|
||||
border === "surround" && (classes = classes.concat(["u-border", "u-textarea--radius"]));
|
||||
border === "bottom" && (classes = classes.concat([
|
||||
"u-border-bottom",
|
||||
"u-textarea--no-radius"
|
||||
]));
|
||||
disabled && classes.push("u-textarea--disabled");
|
||||
return classes.join(" ");
|
||||
},
|
||||
// 组件的样式
|
||||
textareaStyle() {
|
||||
const style = {};
|
||||
return common_vendor.deepMerge(style, common_vendor.addStyle(this.customStyle));
|
||||
}
|
||||
},
|
||||
emits: ["update:modelValue", "linechange", "focus", "blur", "change", "confirm", "keyboardheightchange"],
|
||||
methods: {
|
||||
addStyle: common_vendor.addStyle,
|
||||
addUnit: common_vendor.addUnit,
|
||||
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
||||
setFormatter(e) {
|
||||
this.innerFormatter = e;
|
||||
},
|
||||
onFocus(e) {
|
||||
this.$emit("focus", e);
|
||||
},
|
||||
onBlur(e) {
|
||||
this.$emit("blur", e);
|
||||
common_vendor.formValidate(this, "blur");
|
||||
},
|
||||
onLinechange(e) {
|
||||
this.$emit("linechange", e);
|
||||
},
|
||||
onInput(e) {
|
||||
let { value = "" } = e.detail || {};
|
||||
const formatter = this.formatter || this.innerFormatter;
|
||||
const formatValue = formatter(value);
|
||||
this.innerValue = value;
|
||||
this.$nextTick(() => {
|
||||
this.innerValue = formatValue;
|
||||
this.valueChange();
|
||||
});
|
||||
},
|
||||
// 内容发生变化,进行处理
|
||||
valueChange() {
|
||||
const value = this.innerValue;
|
||||
this.$nextTick(() => {
|
||||
this.$emit("update:modelValue", value);
|
||||
this.changeFromInner = true;
|
||||
this.$emit("change", value);
|
||||
common_vendor.formValidate(this, "change");
|
||||
});
|
||||
},
|
||||
onConfirm(e) {
|
||||
this.$emit("confirm", e);
|
||||
},
|
||||
onKeyboardheightchange(e) {
|
||||
this.$emit("keyboardheightchange", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: $data.innerValue,
|
||||
b: common_vendor.s($options.fieldStyle),
|
||||
c: _ctx.placeholder,
|
||||
d: $options.addStyle(_ctx.placeholderStyle, typeof _ctx.placeholderStyle === "string" ? "string" : "object"),
|
||||
e: _ctx.placeholderClass,
|
||||
f: _ctx.disabled,
|
||||
g: _ctx.focus,
|
||||
h: _ctx.autoHeight,
|
||||
i: _ctx.fixed,
|
||||
j: _ctx.cursorSpacing,
|
||||
k: _ctx.cursor,
|
||||
l: _ctx.showConfirmBar,
|
||||
m: _ctx.selectionStart,
|
||||
n: _ctx.selectionEnd,
|
||||
o: _ctx.adjustPosition,
|
||||
p: _ctx.disableDefaultPadding,
|
||||
q: _ctx.holdKeyboard,
|
||||
r: _ctx.maxlength,
|
||||
s: _ctx.confirmType,
|
||||
t: _ctx.ignoreCompositionEvent,
|
||||
v: common_vendor.o((...args) => $options.onFocus && $options.onFocus(...args)),
|
||||
w: common_vendor.o((...args) => $options.onBlur && $options.onBlur(...args)),
|
||||
x: common_vendor.o((...args) => $options.onLinechange && $options.onLinechange(...args)),
|
||||
y: common_vendor.o((...args) => $options.onInput && $options.onInput(...args)),
|
||||
z: common_vendor.o((...args) => $options.onConfirm && $options.onConfirm(...args)),
|
||||
A: common_vendor.o((...args) => $options.onKeyboardheightchange && $options.onKeyboardheightchange(...args)),
|
||||
B: _ctx.count
|
||||
}, _ctx.count ? {
|
||||
C: common_vendor.t($data.innerValue.length),
|
||||
D: common_vendor.t(_ctx.maxlength),
|
||||
E: _ctx.disabled ? "transparent" : "#fff"
|
||||
} : {}, {
|
||||
F: common_vendor.n($options.textareaClass),
|
||||
G: common_vendor.s($options.textareaStyle)
|
||||
});
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-31706dd7"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/uview-plus/components/u-textarea/u-textarea.js.map
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
<view class="{{['u-textarea', 'data-v-31706dd7', F]}}" style="{{G}}"><block wx:if="{{r0}}"><textarea class="u-textarea__field data-v-31706dd7" value="{{a}}" style="{{b}}" placeholder="{{c}}" placeholder-style="{{d}}" placeholder-class="{{e}}" disabled="{{f}}" focus="{{g}}" autoHeight="{{h}}" fixed="{{i}}" cursorSpacing="{{j}}" cursor="{{k}}" showConfirmBar="{{l}}" selectionStart="{{m}}" selectionEnd="{{n}}" adjustPosition="{{o}}" disableDefaultPadding="{{p}}" holdKeyboard="{{q}}" maxlength="{{r}}" confirm-type="{{s}}" ignoreCompositionEvent="{{t}}" bindfocus="{{v}}" bindblur="{{w}}" bindlinechange="{{x}}" bindinput="{{y}}" bindconfirm="{{z}}" bindkeyboardheightchange="{{A}}"></textarea></block><text wx:if="{{B}}" class="u-textarea__count data-v-31706dd7" style="{{'background-color:' + E}}">{{C}}/{{D}}</text></view>
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.u-empty.data-v-31706dd7,
|
||||
.u-empty__wrap.data-v-31706dd7,
|
||||
.u-tabs.data-v-31706dd7,
|
||||
.u-tabs__wrapper.data-v-31706dd7,
|
||||
.u-tabs__wrapper__scroll-view-wrapper.data-v-31706dd7,
|
||||
.u-tabs__wrapper__scroll-view.data-v-31706dd7,
|
||||
.u-tabs__wrapper__nav.data-v-31706dd7,
|
||||
.u-tabs__wrapper__nav__line.data-v-31706dd7,
|
||||
.up-empty.data-v-31706dd7,
|
||||
.up-empty__wrap.data-v-31706dd7,
|
||||
.up-tabs.data-v-31706dd7,
|
||||
.up-tabs__wrapper.data-v-31706dd7,
|
||||
.up-tabs__wrapper__scroll-view-wrapper.data-v-31706dd7,
|
||||
.up-tabs__wrapper__scroll-view.data-v-31706dd7,
|
||||
.up-tabs__wrapper__nav.data-v-31706dd7,
|
||||
.up-tabs__wrapper__nav__line.data-v-31706dd7 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: auto;
|
||||
align-items: stretch;
|
||||
align-content: flex-start;
|
||||
}
|
||||
.u-textarea.data-v-31706dd7 {
|
||||
border-radius: 4px;
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
padding: 9px;
|
||||
}
|
||||
.u-textarea--radius.data-v-31706dd7 {
|
||||
border-radius: 4px;
|
||||
}
|
||||
.u-textarea--no-radius.data-v-31706dd7 {
|
||||
border-radius: 0;
|
||||
}
|
||||
.u-textarea--disabled.data-v-31706dd7 {
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
.u-textarea__field.data-v-31706dd7 {
|
||||
flex: 1;
|
||||
font-size: 15px;
|
||||
color: #606266;
|
||||
width: 100%;
|
||||
}
|
||||
.u-textarea__count.data-v-31706dd7 {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
bottom: 2px;
|
||||
font-size: 12px;
|
||||
color: #909193;
|
||||
background-color: #ffffff;
|
||||
padding: 1px 4px;
|
||||
}
|
||||
Reference in New Issue
Block a user