init
This commit is contained in:
294
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.js
vendored
Normal file
294
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.js
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_nutuiUni_components__constants_event = require("../_constants/event.js");
|
||||
const uni_modules_nutuiUni_components__constants_prefix = require("../_constants/prefix.js");
|
||||
const uni_modules_nutuiUni_components__utils_env = require("../_utils/env.js");
|
||||
const uni_modules_nutuiUni_components__utils_pxCheck = require("../_utils/pxCheck.js");
|
||||
const uni_modules_nutuiUni_components__utils_style = require("../_utils/style.js");
|
||||
require("../../locale/locale.js");
|
||||
const uni_modules_nutuiUni_locale_useTranslate = require("../../locale/useTranslate.js");
|
||||
const form = require("../../../../form.js");
|
||||
const uni_modules_nutuiUni_components__utils_is = require("../_utils/is.js");
|
||||
const uni_modules_nutuiUni_components__utils_props = require("../_utils/props.js");
|
||||
const textareaProps = {
|
||||
...uni_modules_nutuiUni_components__utils_props.commonProps,
|
||||
/**
|
||||
* @description 输入值,支持双向绑定
|
||||
*/
|
||||
modelValue: String,
|
||||
/**
|
||||
* @description 文本位置,可选值left,center,right
|
||||
*/
|
||||
textAlign: String,
|
||||
/**
|
||||
* @description textarea是否展示输入字符。须配合max-length使用
|
||||
*/
|
||||
limitShow: Boolean,
|
||||
/**
|
||||
* @description 限制最长输入字符
|
||||
*/
|
||||
maxLength: [String, Number],
|
||||
/**
|
||||
* @description textarea的高度,优先级高于autosize属性 仅支持 H5
|
||||
*/
|
||||
rows: [String, Number],
|
||||
/**
|
||||
* @description 文本域自定义类名
|
||||
*/
|
||||
textareaClass: {
|
||||
type: [String, Object, Array],
|
||||
default: ""
|
||||
},
|
||||
/**
|
||||
* @description 文本域自定义样式
|
||||
*/
|
||||
textareaStyle: {
|
||||
type: [String, Object, Array],
|
||||
default: ""
|
||||
},
|
||||
/**
|
||||
* @description 设置占位提示文字
|
||||
*/
|
||||
placeholder: String,
|
||||
/**
|
||||
* @description 指定 placeholder 的样式
|
||||
*/
|
||||
placeholderStyle: uni_modules_nutuiUni_components__utils_props.makeStringProp(""),
|
||||
/**
|
||||
* @description 指定 placeholder 的样式类
|
||||
*/
|
||||
placeholderClass: uni_modules_nutuiUni_components__utils_props.makeStringProp("textarea-placeholder"),
|
||||
/**
|
||||
* @description 只读属性
|
||||
*/
|
||||
readonly: Boolean,
|
||||
/**
|
||||
* @description 禁用属性
|
||||
*/
|
||||
disabled: uni_modules_nutuiUni_components__utils_props.nullableBooleanProp,
|
||||
/**
|
||||
* @description 是否自适应内容高度,也可传入对象
|
||||
*/
|
||||
autosize: {
|
||||
type: [Boolean, Object],
|
||||
default: false
|
||||
},
|
||||
/**
|
||||
* @description 自动获取焦点
|
||||
*/
|
||||
autofocus: Boolean,
|
||||
/**
|
||||
* @description 指定光标与键盘的距离。取textarea距离底部的距离和cursor-spacing指定的距离的最小值作为光标与键盘的距离
|
||||
*/
|
||||
cursorSpacing: uni_modules_nutuiUni_components__utils_props.makeNumberProp(0),
|
||||
/**
|
||||
* @description 指定focus时的光标位置
|
||||
*/
|
||||
cursor: uni_modules_nutuiUni_components__utils_props.makeNumberProp(-1),
|
||||
/**
|
||||
* @description 是否显示键盘上方带有”完成“按钮那一栏
|
||||
*/
|
||||
showConfirmBar: uni_modules_nutuiUni_components__utils_props.truthProp,
|
||||
/**
|
||||
* @description 光标起始位置,自动聚集时有效,需与selection-end搭配使用
|
||||
*/
|
||||
selectionStart: uni_modules_nutuiUni_components__utils_props.makeNumberProp(-1),
|
||||
/**
|
||||
* @description 光标结束位置,自动聚集时有效,需与selection-start搭配使用
|
||||
*/
|
||||
selectionEnd: uni_modules_nutuiUni_components__utils_props.makeNumberProp(-1),
|
||||
/**
|
||||
* @description 键盘弹起时,是否自动上推页面
|
||||
*/
|
||||
adjustPosition: uni_modules_nutuiUni_components__utils_props.truthProp,
|
||||
/**
|
||||
* @description focus时,点击页面的时候不收起键盘
|
||||
*/
|
||||
holdKeyboard: Boolean,
|
||||
/**
|
||||
* @description 是否去掉 iOS 下的默认内边距
|
||||
*/
|
||||
disableDefaultPadding: Boolean,
|
||||
/**
|
||||
* @description 设置键盘右下角按钮的文字,可选值 `send` `search` `next` `go` `done` `return`
|
||||
*/
|
||||
confirmType: uni_modules_nutuiUni_components__utils_props.makeStringProp("return"),
|
||||
/**
|
||||
* @description 点击键盘右下角按钮时是否保持键盘不收起
|
||||
*/
|
||||
confirmHold: Boolean,
|
||||
/**
|
||||
* @description 键盘对齐位置,可选值 `cursor` `bottom`
|
||||
*/
|
||||
adjustKeyboardTo: uni_modules_nutuiUni_components__utils_props.makeStringProp("cursor")
|
||||
};
|
||||
const textareaEmits = {
|
||||
[uni_modules_nutuiUni_components__constants_event.BLUR_EVENT]: (evt) => evt instanceof Object,
|
||||
[uni_modules_nutuiUni_components__constants_event.FOCUS_EVENT]: (evt) => evt instanceof Object,
|
||||
[uni_modules_nutuiUni_components__constants_event.CHANGE_EVENT]: (val1, val2) => uni_modules_nutuiUni_components__utils_is.isString(val1) && (uni_modules_nutuiUni_components__utils_is.isString(val2) || val2 instanceof Object),
|
||||
[uni_modules_nutuiUni_components__constants_event.UPDATE_MODEL_EVENT]: (val1, val2) => uni_modules_nutuiUni_components__utils_is.isString(val1) && (uni_modules_nutuiUni_components__utils_is.isString(val2) || val2 instanceof Object),
|
||||
[uni_modules_nutuiUni_components__constants_event.CONFIRM_EVENT]: (evt) => evt instanceof Object,
|
||||
[uni_modules_nutuiUni_components__constants_event.INPUT_EVENT]: (val, evt) => uni_modules_nutuiUni_components__utils_is.isString(val) && evt instanceof Object
|
||||
};
|
||||
const componentName = `${uni_modules_nutuiUni_components__constants_prefix.PREFIX}-textarea`;
|
||||
const { translate } = uni_modules_nutuiUni_locale_useTranslate.useTranslate(componentName);
|
||||
const __default__ = common_vendor.defineComponent({
|
||||
name: componentName,
|
||||
inheritAttrs: false,
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
});
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: textareaProps,
|
||||
emits: textareaEmits,
|
||||
setup(__props, { emit: __emit }) {
|
||||
const props = __props;
|
||||
const emit = __emit;
|
||||
const formDisabled = form.useFormDisabled(common_vendor.toRef(props, "disabled"));
|
||||
function stringModelValue() {
|
||||
if (props.modelValue == null)
|
||||
return "";
|
||||
return String(props.modelValue);
|
||||
}
|
||||
const innerValue = common_vendor.computed(() => {
|
||||
return stringModelValue();
|
||||
});
|
||||
const classes = common_vendor.computed(() => {
|
||||
return uni_modules_nutuiUni_components__utils_style.getMainClass(props, componentName, {
|
||||
[`${componentName}--disabled`]: formDisabled.value
|
||||
});
|
||||
});
|
||||
const textareaClasses = common_vendor.computed(() => {
|
||||
return [props.textareaClass, {
|
||||
"nut-textarea__ali": uni_modules_nutuiUni_components__utils_env.isMpAlipay
|
||||
}];
|
||||
});
|
||||
const textareaStyles = common_vendor.computed(() => {
|
||||
const style = {
|
||||
textAlign: props.textAlign
|
||||
};
|
||||
if (typeof props.autosize === "object") {
|
||||
const { minHeight, maxHeight } = props.autosize;
|
||||
if (minHeight != null)
|
||||
style.minHeight = uni_modules_nutuiUni_components__utils_pxCheck.pxCheck(minHeight);
|
||||
if (maxHeight != null)
|
||||
style.maxHeight = uni_modules_nutuiUni_components__utils_pxCheck.pxCheck(maxHeight);
|
||||
}
|
||||
return [props.textareaStyle, style];
|
||||
});
|
||||
const innerMaxLength = common_vendor.computed(() => {
|
||||
if (props.maxLength == null)
|
||||
return -1;
|
||||
return Number(props.maxLength);
|
||||
});
|
||||
function updateValue(value, evt) {
|
||||
if (innerMaxLength.value > 0 && value.length > innerMaxLength.value)
|
||||
value = value.slice(0, innerMaxLength.value);
|
||||
emit(uni_modules_nutuiUni_components__constants_event.UPDATE_MODEL_EVENT, value, evt);
|
||||
emit(uni_modules_nutuiUni_components__constants_event.CHANGE_EVENT, value, evt);
|
||||
}
|
||||
function _onInput(evt) {
|
||||
updateValue(evt.detail.value, evt);
|
||||
common_vendor.nextTick$1(() => {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.INPUT_EVENT, innerValue.value, evt);
|
||||
});
|
||||
}
|
||||
function handleInput(evt) {
|
||||
if (uni_modules_nutuiUni_components__utils_env.isH5) {
|
||||
const target = evt.target;
|
||||
if (!target.composing)
|
||||
_onInput(evt);
|
||||
} else {
|
||||
_onInput(evt);
|
||||
}
|
||||
}
|
||||
function handleFocus(evt) {
|
||||
if (formDisabled.value || props.readonly)
|
||||
return;
|
||||
emit(uni_modules_nutuiUni_components__constants_event.FOCUS_EVENT, evt);
|
||||
}
|
||||
function handleBlur(evt) {
|
||||
if (formDisabled.value || props.readonly)
|
||||
return;
|
||||
updateValue(evt.detail.value, evt);
|
||||
emit(uni_modules_nutuiUni_components__constants_event.BLUR_EVENT, evt);
|
||||
}
|
||||
function handleConfirm(evt) {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.CONFIRM_EVENT, evt);
|
||||
}
|
||||
function startComposing(evt) {
|
||||
if (uni_modules_nutuiUni_components__utils_env.isH5) {
|
||||
const target = evt.target;
|
||||
target.composing = true;
|
||||
}
|
||||
}
|
||||
function endComposing(evt) {
|
||||
if (uni_modules_nutuiUni_components__utils_env.isH5) {
|
||||
const target = evt.target;
|
||||
if (target.composing) {
|
||||
target.composing = false;
|
||||
target.dispatchEvent(new Event("input"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: props.readonly
|
||||
}, props.readonly ? {
|
||||
b: common_vendor.n(textareaClasses.value),
|
||||
c: common_vendor.s(textareaStyles.value),
|
||||
d: innerValue.value,
|
||||
e: props.rows,
|
||||
f: props.placeholder || common_vendor.unref(translate)("placeholder"),
|
||||
g: props.placeholderStyle,
|
||||
h: props.placeholderClass,
|
||||
i: !!props.autosize,
|
||||
j: props.disableDefaultPadding
|
||||
} : {
|
||||
k: common_vendor.n(textareaClasses.value),
|
||||
l: common_vendor.s(textareaStyles.value),
|
||||
m: innerValue.value,
|
||||
n: props.rows,
|
||||
o: common_vendor.unref(formDisabled) || props.readonly,
|
||||
p: innerMaxLength.value,
|
||||
q: props.placeholder || common_vendor.unref(translate)("placeholder"),
|
||||
r: props.placeholderStyle,
|
||||
s: props.placeholderClass,
|
||||
t: props.autofocus,
|
||||
v: !!props.autosize,
|
||||
w: props.cursorSpacing,
|
||||
x: props.cursor,
|
||||
y: props.showConfirmBar,
|
||||
z: props.selectionStart,
|
||||
A: props.selectionEnd,
|
||||
B: props.adjustPosition,
|
||||
C: props.holdKeyboard,
|
||||
D: props.disableDefaultPadding,
|
||||
E: props.confirmType,
|
||||
F: props.confirmHold,
|
||||
G: props.adjustKeyboardTo,
|
||||
H: common_vendor.o(handleInput),
|
||||
I: common_vendor.o(handleFocus),
|
||||
J: common_vendor.o(handleBlur),
|
||||
K: common_vendor.o(endComposing),
|
||||
L: common_vendor.o(startComposing),
|
||||
M: common_vendor.o(endComposing),
|
||||
N: common_vendor.o(handleConfirm)
|
||||
}, {
|
||||
O: props.limitShow && innerMaxLength.value > 0
|
||||
}, props.limitShow && innerMaxLength.value > 0 ? {
|
||||
P: common_vendor.t(innerValue.value.length),
|
||||
Q: common_vendor.t(innerMaxLength.value)
|
||||
} : {}, {
|
||||
R: common_vendor.n(classes.value),
|
||||
S: common_vendor.s(props.customStyle)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
wx.createComponent(_sfc_main);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="{{R}}" style="{{S}}"><textarea wx:if="{{a}}" class="{{['nut-textarea__textarea', 'nut-textarea__textarea__readonly', b]}}" style="{{c}}" value="{{d}}" rows="{{e}}" disabled="{{true}}" show-count="{{false}}" placeholder="{{f}}" placeholder-style="{{g}}" placeholder-class="{{h}}" auto-height="{{i}}" disable-default-padding="{{j}}"/><block wx:else><textarea wx:if="{{r0}}" class="{{['nut-textarea__textarea', k]}}" style="{{l}}" value="{{m}}" rows="{{n}}" disabled="{{o}}" show-count="{{false}}" maxlength="{{p}}" placeholder="{{q}}" placeholder-style="{{r}}" placeholder-class="{{s}}" auto-focus="{{t}}" auto-height="{{v}}" cursor-spacing="{{w}}" cursor="{{x}}" show-confirm-bar="{{y}}" selection-start="{{z}}" selection-end="{{A}}" adjust-position="{{B}}" hold-keyboard="{{C}}" disable-default-padding="{{D}}" confirm-type="{{E}}" confirm-hold="{{F}}" adjust-keyboard-to="{{G}}" bindinput="{{H}}" bindfocus="{{I}}" bindblur="{{J}}" bindchange="{{K}}" bindcompositionstart="{{L}}" bindcompositionend="{{M}}" bindconfirm="{{N}}"/></block><view wx:if="{{O}}" class="nut-textarea__limit">{{P}}/{{Q}}</view></view>
|
||||
99
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.wxss
vendored
Normal file
99
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/textarea/textarea.wxss
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.nut-theme-dark .nut-textarea {
|
||||
background: var(--nut-dark-background, #131313);
|
||||
}
|
||||
.nut-theme-dark .nut-textarea__textarea {
|
||||
color: var(--nut-dark-color, var(--nut-white, #fff));
|
||||
}
|
||||
.nut-textarea {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding: 10px 25px;
|
||||
font-size: var(--nut-textarea-font, var(--nut-font-size-2, 14px));
|
||||
background: var(--nut-white, #fff);
|
||||
}
|
||||
.nut-textarea--disabled .nut-textarea__textarea,
|
||||
.nut-textarea--disabled .nut-textarea__limit {
|
||||
color: var(--nut-textarea-disabled-color, var(--nut-disable-color, #ccc)) !important;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.nut-textarea__limit {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
bottom: 12px;
|
||||
font-size: var(--nut-textarea-font, var(--nut-font-size-2, 14px));
|
||||
color: var(--nut-textarea-limit-color, var(--nut-text-color, #808080));
|
||||
}
|
||||
.nut-textarea__textarea {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: var(--nut-textarea-font, var(--nut-font-size-2, 14px));
|
||||
line-height: 20px;
|
||||
color: var(--nut-textarea-text-color, var(--nut-title-color, #1a1a1a));
|
||||
text-align: left;
|
||||
resize: none;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
.nut-textarea__textarea .taro-textarea {
|
||||
font-size: 14px;
|
||||
}
|
||||
.nut-textarea__ali {
|
||||
line-height: 17px;
|
||||
}
|
||||
Reference in New Issue
Block a user