提交 047e4aca 编写于 作者: W wangjinxin613 提交者: DCloud-WZF

feat(uni-app): input、textarea 组件暴露 $triggerInput 方法

上级 3bb5f11d
...@@ -35,7 +35,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -35,7 +35,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
class: UniInputElement, class: UniInputElement,
}, },
//#endif //#endif
setup(props, { emit }) { setup(props, { emit, expose }) {
const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password', 'tel'] const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password', 'tel']
const AUTOCOMPLETES = ['off', 'one-time-code'] const AUTOCOMPLETES = ['off', 'one-time-code']
const type = computed(() => { const type = computed(() => {
...@@ -171,6 +171,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -171,6 +171,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({
!props.confirmHold && input.blur() !props.confirmHold && input.blur()
} }
expose({
$triggerInput: (detail: { value: string }) => {
emit('update:modelValue', detail.value)
emit('update:value', detail.value)
state.value = detail.value
},
})
//#if _X_ && !_NODE_JS_ //#if _X_ && !_NODE_JS_
onMounted(() => { onMounted(() => {
const rootElement = rootRef.value as UniInputElement const rootElement = rootRef.value as UniInputElement
......
...@@ -56,7 +56,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -56,7 +56,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
class: UniTextareaElement, class: UniTextareaElement,
}, },
//#endif //#endif
setup(props, { emit }) { setup(props, { emit, expose }) {
const rootRef: Ref<HTMLElement | null> = ref(null) const rootRef: Ref<HTMLElement | null> = ref(null)
const wrapperRef: Ref<HTMLElement | null> = ref(null) const wrapperRef: Ref<HTMLElement | null> = ref(null)
const { fieldRef, state, scopedAttrsState, fixDisabledColor, trigger } = const { fieldRef, state, scopedAttrsState, fixDisabledColor, trigger } =
...@@ -124,6 +124,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({ ...@@ -124,6 +124,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({
setFixMargin() setFixMargin()
} }
expose({
$triggerInput: (detail: { value: string }) => {
emit('update:modelValue', detail.value)
emit('update:value', detail.value)
state.value = detail.value
},
})
//#if _X_ && !_NODE_JS_ //#if _X_ && !_NODE_JS_
onMounted(() => { onMounted(() => {
const rootElement = rootRef.value as UniTextareaElement const rootElement = rootRef.value as UniTextareaElement
......
...@@ -3561,7 +3561,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -3561,7 +3561,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
props: props$j, props: props$j,
emits: ["confirm", ...emit], emits: ["confirm", ...emit],
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"]; const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"]; const AUTOCOMPLETES = ["off", "one-time-code"];
...@@ -3664,6 +3665,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -3664,6 +3665,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
}); });
!props2.confirmHold && input.blur(); !props2.confirmHold && input.blur();
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => { return () => {
let inputNode = props2.disabled && fixDisabledColor ? vue.createVNode("input", { let inputNode = props2.disabled && fixDisabledColor ? vue.createVNode("input", {
"key": "disabled-input", "key": "disabled-input",
...@@ -7361,7 +7369,8 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -7361,7 +7369,8 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
props: props$a, props: props$a,
emits: ["confirm", "linechange", ...emit], emits: ["confirm", "linechange", ...emit],
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const rootRef = vue.ref(null); const rootRef = vue.ref(null);
const wrapperRef = vue.ref(null); const wrapperRef = vue.ref(null);
...@@ -7423,6 +7432,13 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -7423,6 +7432,13 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
!props2.confirmHold && textarea.blur(); !props2.confirmHold && textarea.blur();
} }
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => { return () => {
let textareaNode = props2.disabled && fixDisabledColor ? vue.createVNode("textarea", { let textareaNode = props2.disabled && fixDisabledColor ? vue.createVNode("textarea", {
"key": "disabled-textarea", "key": "disabled-textarea",
......
...@@ -9754,7 +9754,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -9754,7 +9754,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
class: UniInputElement class: UniInputElement
}, },
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"]; const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"]; const AUTOCOMPLETES = ["off", "one-time-code"];
...@@ -9857,6 +9858,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -9857,6 +9858,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
}); });
!props2.confirmHold && input.blur(); !props2.confirmHold && input.blur();
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
onMounted(() => { onMounted(() => {
const rootElement = rootRef.value; const rootElement = rootRef.value;
Object.defineProperty(rootElement, "value", { Object.defineProperty(rootElement, "value", {
...@@ -15238,7 +15246,8 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -15238,7 +15246,8 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({
class: UniTextareaElement class: UniTextareaElement
}, },
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const rootRef = ref(null); const rootRef = ref(null);
const wrapperRef = ref(null); const wrapperRef = ref(null);
...@@ -15303,6 +15312,13 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -15303,6 +15312,13 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({
{ {
setFixMargin(); setFixMargin();
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
onMounted(() => { onMounted(() => {
const rootElement = rootRef.value; const rootElement = rootRef.value;
Object.defineProperty(rootElement, "value", { Object.defineProperty(rootElement, "value", {
......
...@@ -3504,7 +3504,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -3504,7 +3504,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
props: props$j, props: props$j,
emits: ["confirm", ...emit], emits: ["confirm", ...emit],
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"]; const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"]; const AUTOCOMPLETES = ["off", "one-time-code"];
...@@ -3607,6 +3608,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -3607,6 +3608,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
}); });
!props2.confirmHold && input.blur(); !props2.confirmHold && input.blur();
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => { return () => {
let inputNode = props2.disabled && fixDisabledColor ? vue.createVNode("input", { let inputNode = props2.disabled && fixDisabledColor ? vue.createVNode("input", {
"key": "disabled-input", "key": "disabled-input",
...@@ -7288,7 +7296,8 @@ const index$g = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -7288,7 +7296,8 @@ const index$g = /* @__PURE__ */ defineBuiltInComponent({
props: props$a, props: props$a,
emits: ["confirm", "linechange", ...emit], emits: ["confirm", "linechange", ...emit],
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const rootRef = vue.ref(null); const rootRef = vue.ref(null);
const wrapperRef = vue.ref(null); const wrapperRef = vue.ref(null);
...@@ -7350,6 +7359,13 @@ const index$g = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -7350,6 +7359,13 @@ const index$g = /* @__PURE__ */ defineBuiltInComponent({
!props2.confirmHold && textarea.blur(); !props2.confirmHold && textarea.blur();
} }
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state.value = detail.value;
}
});
return () => { return () => {
let textareaNode = props2.disabled && fixDisabledColor ? vue.createVNode("textarea", { let textareaNode = props2.disabled && fixDisabledColor ? vue.createVNode("textarea", {
"key": "disabled-textarea", "key": "disabled-textarea",
......
...@@ -9681,7 +9681,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -9681,7 +9681,8 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
props: props$q, props: props$q,
emits: ["confirm", ...emit], emits: ["confirm", ...emit],
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"]; const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
const AUTOCOMPLETES = ["off", "one-time-code"]; const AUTOCOMPLETES = ["off", "one-time-code"];
...@@ -9784,6 +9785,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -9784,6 +9785,13 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
}); });
!props2.confirmHold && input.blur(); !props2.confirmHold && input.blur();
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
return () => { return () => {
let inputNode = props2.disabled && fixDisabledColor ? createVNode("input", { let inputNode = props2.disabled && fixDisabledColor ? createVNode("input", {
"key": "disabled-input", "key": "disabled-input",
...@@ -14883,7 +14891,8 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -14883,7 +14891,8 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
props: props$h, props: props$h,
emits: ["confirm", "linechange", ...emit], emits: ["confirm", "linechange", ...emit],
setup(props2, { setup(props2, {
emit: emit2 emit: emit2,
expose
}) { }) {
const rootRef = ref(null); const rootRef = ref(null);
const wrapperRef = ref(null); const wrapperRef = ref(null);
...@@ -14948,6 +14957,13 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({ ...@@ -14948,6 +14957,13 @@ const index$h = /* @__PURE__ */ defineBuiltInComponent({
{ {
setFixMargin(); setFixMargin();
} }
expose({
$triggerInput: (detail) => {
emit2("update:modelValue", detail.value);
emit2("update:value", detail.value);
state2.value = detail.value;
}
});
return () => { return () => {
let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", { let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
"key": "disabled-textarea", "key": "disabled-textarea",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册