From b38d09ccf9569043c77b99d82ce2d8efc9db2b34 Mon Sep 17 00:00:00 2001 From: sulmo Date: Fri, 2 Sep 2022 15:39:33 +0900 Subject: [PATCH 1/8] feat(text-input): add show/hide button when type is password feat: add add --- src/inputs/input/PTextInput.vue | 46 +++++++++++++++++++++++++-------- src/inputs/input/type.ts | 4 +++ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/inputs/input/PTextInput.vue b/src/inputs/input/PTextInput.vue index 05ad7e5e6..f9b05b7ae 100644 --- a/src/inputs/input/PTextInput.vue +++ b/src/inputs/input/PTextInput.vue @@ -18,7 +18,7 @@ {{ tag.label || tag.value }} - - - + {{ isPasswordVisible ? $t('COMPONENT.TEXT_INPUT.HIDE') : $t('COMPONENT.TEXT_INPUT.SHOW') }} + + ({ @@ -105,6 +116,7 @@ export default defineComponent({ PTag, PI, PContextMenu, + PButton, }, directives: { focus, @@ -178,9 +190,13 @@ export default defineComponent({ type: Boolean, default: false, }, + visiblePassword: { + type: Boolean, + default: false, + }, }, - setup(props, { emit, listeners }) { + setup(props, { emit, listeners, attrs }) { const { proxyVisibleMenu, targetRef, targetElement, contextMenuStyle, } = useContextMenuFixedStyle({ @@ -195,6 +211,8 @@ export default defineComponent({ menuRef: null, targetRef: null, isFocused: false, + inputType: (attrs?.type) ?? 'text' as HTMLInputTypeAttribute, + isPasswordVisible: false, proxyValue: useProxyValue('value', props, emit), proxySelectedValue: useProxyValue('selected', props, emit), deleteTarget: undefined as string | undefined, @@ -281,6 +299,11 @@ export default defineComponent({ hideMenu(); }; + const handleTogglePassword = () => { + state.isPasswordVisible = !state.isPasswordVisible; + state.inputType = state.isPasswordVisible ? 'text' : 'password'; + }; + const deleteSelectedTags = () => { if (state.proxyValue.length > 0) return; const lastIdx = state.proxySelectedValue.length - 1; @@ -362,6 +385,7 @@ export default defineComponent({ handleDeleteAllTags, handleFocusMenuItem, handleSelectMenuItem, + handleTogglePassword, }; }, }); diff --git a/src/inputs/input/type.ts b/src/inputs/input/type.ts index e29364b31..6b5fa6ebb 100644 --- a/src/inputs/input/type.ts +++ b/src/inputs/input/type.ts @@ -12,3 +12,7 @@ export interface SelectedItem { export interface TextInputHandler { (val: string, searchableItems: MenuItem[]): Promise<{results: MenuItem[]}>|{results: MenuItem[]} } + +// eslint-disable-next-line max-len +type HTMLInputTypeAttribute = null | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'; +export type { HTMLInputTypeAttribute }; From 1b0e534844f1e3a157e68c2b7f0185ad6ceceeb7 Mon Sep 17 00:00:00 2001 From: sulmo Date: Fri, 2 Sep 2022 15:39:51 +0900 Subject: [PATCH 2/8] chore(language): update lang-pack version --- src/translations/language-pack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/translations/language-pack b/src/translations/language-pack index e4ffa5172..42ed92f6e 160000 --- a/src/translations/language-pack +++ b/src/translations/language-pack @@ -1 +1 @@ -Subproject commit e4ffa517262987890665f983d0fcbcc608661f67 +Subproject commit 42ed92f6e0a1ff4dd6a7500252b99824ddc1ed70 From 0a0649fd73f10fa2a1db8a065926e200d8edb5b2 Mon Sep 17 00:00:00 2001 From: sulmo Date: Fri, 2 Sep 2022 15:41:55 +0900 Subject: [PATCH 3/8] docs(text-input): add visiblePassword, attrs type --- src/inputs/input/PTextInput.stories.mdx | 23 ++++++++++++++++ src/inputs/input/story-helper.ts | 35 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/inputs/input/PTextInput.stories.mdx b/src/inputs/input/PTextInput.stories.mdx index 6ff740656..f584ee836 100644 --- a/src/inputs/input/PTextInput.stories.mdx +++ b/src/inputs/input/PTextInput.stories.mdx @@ -27,6 +27,8 @@ export const Template = (args, { argTypes }) => ({ :disabled="disabled" :block="block" :menu="menu" :use-fixed-menu-style="useFixedMenuStyle" :loading="loading" + :visible-password="visiblePassword" + :type="type" >