From 29a306da8e85360f739a3a945f7a23f257b69b6c Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Tue, 31 Aug 2021 22:16:14 +0800 Subject: [PATCH 1/6] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20input=20?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sites/components/input/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/components/input/index.md b/sites/components/input/index.md index 627d994f..3379170d 100644 --- a/sites/components/input/index.md +++ b/sites/components/input/index.md @@ -96,4 +96,4 @@ export default defineComponent({ | disabled | `boolean` | false | 可选,文本框是否被禁用 | [基本用法](#基本用法) || | error | `boolean` | false | 可选,文本框是否出现输入错误 | [基本用法](#基本用法) || | size | `'sm'\|''\|'lg'` | '' | 可选,文本框尺寸,有三种选择`'lg'`,`''`,`'sm'` | [基本用法](#尺寸) || - +| cssClass | `string` | '' | 可选,支持传入类名到输入框上 | || -- Gitee From 479c1d31afa238626ec7c6d094e29592d1ac77ca Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Sun, 5 Sep 2021 16:42:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?chore:=20=E5=B0=86vitepress-theme-demoblock?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=94=BE=E5=85=A5devDependencies=E4=B8=AD?= =?UTF-8?q?=E5=B9=B6=E9=94=81=E6=AD=BB1.0.7=E7=89=88=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E9=98=B2node=E5=B0=8F=E4=BA=8E14=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BD=BF=E7=94=A8=E9=AB=98=E7=89=88=E6=9C=AC=E4=BA=A7?= =?UTF-8?q?=E7=94=9F=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e1c54ce8..07f9c716 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "@devui-design/icons": "^1.3.0", "@types/lodash-es": "^4.17.4", "lodash-es": "^4.17.20", - "vitepress-theme-demoblock": "^1.0.7", "vue": "^3.1.1", "vue-router": "^4.0.3" }, @@ -87,6 +86,7 @@ "vite": "^2.4.4", "vite-plugin-md": "^0.6.0", "vitepress": "^0.15.6", + "vitepress-theme-demoblock": "1.0.7", "vue-tsc": "^0.2.2", "yarn": "^1.22.11" }, diff --git a/yarn.lock b/yarn.lock index 241d93cf..2622c2ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6993,7 +6993,7 @@ vite@^2.3.7, vite@^2.4.4: optionalDependencies: fsevents "~2.3.2" -vitepress-theme-demoblock@^1.0.7: +vitepress-theme-demoblock@1.0.7: version "1.0.7" resolved "https://registry.nlark.com/vitepress-theme-demoblock/download/vitepress-theme-demoblock-1.0.7.tgz#03010923025a8dd6e591cb5828af15693b37d63f" integrity sha1-AwEJIwJajdblkctYKK8VaTs31j8= -- Gitee From 1410bbe6266e5c4a44f9daf1af86b3146699c039 Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Sun, 5 Sep 2021 16:43:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20input=E7=BB=84=E4=BB=B6=E6=96=B0?= =?UTF-8?q?=E5=A2=9Eapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devui/input/src/input.tsx | 18 +++++++++++++++--- devui/input/src/use-input.tsx | 4 ++++ sites/components/input/index.md | 31 ++++++++++++++----------------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/devui/input/src/input.tsx b/devui/input/src/input.tsx index a2720754..19f810be 100644 --- a/devui/input/src/input.tsx +++ b/devui/input/src/input.tsx @@ -1,12 +1,22 @@ -import { defineComponent, computed, ref, watch, toRef } from 'vue'; +import { defineComponent, computed, ref, watch, nextTick, onMounted, toRefs } from 'vue'; import { inputProps, InputType } from './use-input'; import './input.scss' export default defineComponent({ name: 'DInput', + directives: { + focus: { + mounted: function (el, binding) { + if (binding.value) { + el.focus() + } + } + } + }, props: inputProps, emits: ['update:value', 'focus', 'blur', 'change', 'keydown'], setup(props, ctx) { + const iptDom = ref(null) const sizeCls = computed(() => `devui-input-${props.size}`); const showPwdIcon = ref(false) const inputType = ref('text') @@ -23,7 +33,7 @@ export default defineComponent({ }, { immediate: true }) watch(() => props.value, value => { - value && value.length > 0 ? showPwdIcon.value = true : showPwdIcon.value = false + (value && value.length > 0 && showPreviewIcon.value) ? showPwdIcon.value = true : showPwdIcon.value = false }) const onInput = ($event: Event) => { @@ -44,8 +54,8 @@ export default defineComponent({ onChangeInputType = () => { inputType.value = inputType.value === 'password' ? 'text' : 'password' } - return { + iptDom, inputCls, inputType, showPreviewIcon, @@ -66,6 +76,7 @@ export default defineComponent({ inputCls, inputType, maxLength, + autoFocus, placeholder, disabled, onInput, @@ -78,6 +89,7 @@ export default defineComponent({ return (

Default

- +

Disabled

@@ -23,7 +23,6 @@

Error

-