vue-search-input
Advanced tools
Comparing version
@@ -0,1 +1,8 @@ | ||
## [1.1.13](https://github.com/kouts/vue-search-input/compare/v1.1.12...v1.1.13) (2023-10-16) | ||
### Bug Fixes | ||
* added password as a field type ([975f540](https://github.com/kouts/vue-search-input/commit/975f540130025db13aa74caeba546b9f9b750bc7)) | ||
## [1.1.12](https://github.com/kouts/vue-search-input/compare/v1.1.11...v1.1.12) (2023-08-14) | ||
@@ -2,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
export declare const fieldType: readonly ["search", "text"]; | ||
export declare const fieldType: readonly ["search", "text", "password"]; | ||
export type FieldType = (typeof fieldType)[number]; |
@@ -5,3 +5,3 @@ import { FieldType } from './SearchInput.types'; | ||
type: { | ||
type: PropType<"search" | "text">; | ||
type: PropType<"search" | "text" | "password">; | ||
default: string; | ||
@@ -70,3 +70,3 @@ validator: (prop: FieldType) => boolean; | ||
type: { | ||
type: PropType<"search" | "text">; | ||
type: PropType<"search" | "text" | "password">; | ||
default: string; | ||
@@ -122,3 +122,3 @@ validator: (prop: FieldType) => boolean; | ||
}, { | ||
type: "search" | "text"; | ||
type: "search" | "text" | "password"; | ||
modelValue: string; | ||
@@ -125,0 +125,0 @@ wrapperClass: string; |
import { defineComponent as k, ref as I, computed as i, watch as b, onBeforeUnmount as K, openBlock as V, createElementBlock as B, normalizeProps as C, guardReactiveProps as L, renderSlot as u, createCommentVNode as y, createElementVNode as d, mergeProps as H, withKeys as M } from "vue"; | ||
const P = ["search", "text"], g = (e, t, l = !0) => { | ||
const P = ["search", "text", "password"], g = (e, t, l = !0) => { | ||
const r = {}; | ||
@@ -4,0 +4,0 @@ return Object.keys(e).forEach((o) => { |
@@ -1,1 +0,1 @@ | ||
(function(t,d){typeof exports=="object"&&typeof module<"u"?module.exports=d(require("vue")):typeof define=="function"&&define.amd?define(["vue"],d):(t=typeof globalThis<"u"?globalThis:t||self,t.VueSearchInput=d(t.Vue))})(this,function(t){"use strict";const d=["search","text"],m=(e,n,c=!0)=>{const l={};return Object.keys(e).forEach(r=>{(c?n.indexOf(r)===-1:n.indexOf(r)>=0)&&(l[r]=e[r])}),l},a=(e=!0)=>({type:Boolean,default:e}),S=t.defineComponent({inheritAttrs:!1,props:{type:{type:String,default:"search",validator:e=>d.includes(e)},modelValue:{type:String,default:""},wrapperClass:{type:String,default:"search-input-wrapper"},searchIcon:a(),shortcutIcon:a(),clearIcon:a(),hideShortcutIconOnBlur:a(),clearOnEsc:a(),blurOnEsc:a(),selectOnFocus:a(),shortcutListenerEnabled:a(),shortcutKey:{type:String,default:"/"}},emits:["update:modelValue"],setup(e,{emit:n,attrs:c}){const l=t.ref(!1),r=t.ref(null),i=t.computed(()=>m(c,["class","style"])),s=t.computed(()=>{const o=m(c,["class","style"],!1);return o.class||(o.class=e.wrapperClass),o}),$=t.computed(()=>!!(e.clearIcon&&e.modelValue.length>0)),k=t.computed(()=>!!(e.shortcutIcon&&!l.value&&!e.hideShortcutIconOnBlur||e.shortcutIcon&&!l.value&&e.modelValue.length===0)),p=()=>{n("update:modelValue","")},b=o=>{n("update:modelValue",o.target.value)},C=o=>{o.key==="Escape"&&(e.clearOnEsc&&p(),e.blurOnEsc&&r.value.blur())},y=o=>{if(o.key===e.shortcutKey&&o.target!==r.value&&window.document.activeElement!==r.value&&!(o.target instanceof HTMLInputElement)&&!(o.target instanceof HTMLSelectElement)&&!(o.target instanceof HTMLTextAreaElement)){o.preventDefault();const f=[].slice.call(document.querySelectorAll('[data-search-input="true"]:not([data-shortcut-enabled="false"])')).filter(h=>!!(h.offsetWidth||h.offsetHeight||h.getClientRects().length)),u=f.length>1?f[0]:r.value;u==null||u.focus(),e.selectOnFocus&&(u==null||u.select())}},w=()=>window.document.removeEventListener("keydown",y);return t.watch(()=>e.shortcutListenerEnabled,o=>{o?window.document.addEventListener("keydown",y):w()},{immediate:!0}),t.onBeforeUnmount(()=>{w()}),{inputRef:r,hasFocus:l,clear:p,onInput:b,onKeydown:C,attrsStyles:s,attrsWithoutStyles:i,showClearIcon:$,showShortcutIcon:k}}}),I=(e,n)=>{const c=e.__vccOpts||e;for(const[l,r]of n)c[l]=r;return c},E=t.createElementVNode("i",{class:"search-icon search"},null,-1),g=["data-shortcut-enabled","value"],V=t.createElementVNode("i",{class:"search-icon shortcut",title:'Press "/" to search'},null,-1);function O(e,n,c,l,r,i){return t.openBlock(),t.createElementBlock("div",t.normalizeProps(t.guardReactiveProps(e.attrsStyles)),[t.renderSlot(e.$slots,"prepend"),e.searchIcon?t.renderSlot(e.$slots,"search-icon",{key:0},()=>[E]):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"prepend-inner"),t.createElementVNode("input",t.mergeProps({ref:"inputRef",type:"search","data-search-input":"true","data-shortcut-enabled":e.shortcutListenerEnabled,value:e.modelValue},e.attrsWithoutStyles,{onInput:n[0]||(n[0]=(...s)=>e.onInput&&e.onInput(...s)),onFocus:n[1]||(n[1]=s=>e.hasFocus=!0),onBlur:n[2]||(n[2]=s=>e.hasFocus=!1),onKeydown:n[3]||(n[3]=(...s)=>e.onKeydown&&e.onKeydown(...s))}),null,16,g),t.renderSlot(e.$slots,"append"),e.showShortcutIcon?t.renderSlot(e.$slots,"shortcut-icon",{key:1},()=>[V]):t.createCommentVNode("",!0),e.showClearIcon?t.renderSlot(e.$slots,"clear-icon",{key:2,clear:e.clear},()=>[t.createElementVNode("button",{class:"search-icon clear","aria-label":"Clear",onMousedown:n[4]||(n[4]=(...s)=>e.clear&&e.clear(...s)),onKeydown:n[5]||(n[5]=t.withKeys((...s)=>e.clear&&e.clear(...s),["space","enter"]))},null,32)]):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"append-outer")],16)}return I(S,[["render",O]])}); | ||
(function(t,d){typeof exports=="object"&&typeof module<"u"?module.exports=d(require("vue")):typeof define=="function"&&define.amd?define(["vue"],d):(t=typeof globalThis<"u"?globalThis:t||self,t.VueSearchInput=d(t.Vue))})(this,function(t){"use strict";const d=["search","text","password"],m=(e,n,c=!0)=>{const l={};return Object.keys(e).forEach(s=>{(c?n.indexOf(s)===-1:n.indexOf(s)>=0)&&(l[s]=e[s])}),l},a=(e=!0)=>({type:Boolean,default:e}),S=t.defineComponent({inheritAttrs:!1,props:{type:{type:String,default:"search",validator:e=>d.includes(e)},modelValue:{type:String,default:""},wrapperClass:{type:String,default:"search-input-wrapper"},searchIcon:a(),shortcutIcon:a(),clearIcon:a(),hideShortcutIconOnBlur:a(),clearOnEsc:a(),blurOnEsc:a(),selectOnFocus:a(),shortcutListenerEnabled:a(),shortcutKey:{type:String,default:"/"}},emits:["update:modelValue"],setup(e,{emit:n,attrs:c}){const l=t.ref(!1),s=t.ref(null),i=t.computed(()=>m(c,["class","style"])),r=t.computed(()=>{const o=m(c,["class","style"],!1);return o.class||(o.class=e.wrapperClass),o}),$=t.computed(()=>!!(e.clearIcon&&e.modelValue.length>0)),k=t.computed(()=>!!(e.shortcutIcon&&!l.value&&!e.hideShortcutIconOnBlur||e.shortcutIcon&&!l.value&&e.modelValue.length===0)),p=()=>{n("update:modelValue","")},b=o=>{n("update:modelValue",o.target.value)},C=o=>{o.key==="Escape"&&(e.clearOnEsc&&p(),e.blurOnEsc&&s.value.blur())},y=o=>{if(o.key===e.shortcutKey&&o.target!==s.value&&window.document.activeElement!==s.value&&!(o.target instanceof HTMLInputElement)&&!(o.target instanceof HTMLSelectElement)&&!(o.target instanceof HTMLTextAreaElement)){o.preventDefault();const f=[].slice.call(document.querySelectorAll('[data-search-input="true"]:not([data-shortcut-enabled="false"])')).filter(h=>!!(h.offsetWidth||h.offsetHeight||h.getClientRects().length)),u=f.length>1?f[0]:s.value;u==null||u.focus(),e.selectOnFocus&&(u==null||u.select())}},w=()=>window.document.removeEventListener("keydown",y);return t.watch(()=>e.shortcutListenerEnabled,o=>{o?window.document.addEventListener("keydown",y):w()},{immediate:!0}),t.onBeforeUnmount(()=>{w()}),{inputRef:s,hasFocus:l,clear:p,onInput:b,onKeydown:C,attrsStyles:r,attrsWithoutStyles:i,showClearIcon:$,showShortcutIcon:k}}}),I=(e,n)=>{const c=e.__vccOpts||e;for(const[l,s]of n)c[l]=s;return c},E=t.createElementVNode("i",{class:"search-icon search"},null,-1),g=["data-shortcut-enabled","value"],V=t.createElementVNode("i",{class:"search-icon shortcut",title:'Press "/" to search'},null,-1);function O(e,n,c,l,s,i){return t.openBlock(),t.createElementBlock("div",t.normalizeProps(t.guardReactiveProps(e.attrsStyles)),[t.renderSlot(e.$slots,"prepend"),e.searchIcon?t.renderSlot(e.$slots,"search-icon",{key:0},()=>[E]):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"prepend-inner"),t.createElementVNode("input",t.mergeProps({ref:"inputRef",type:"search","data-search-input":"true","data-shortcut-enabled":e.shortcutListenerEnabled,value:e.modelValue},e.attrsWithoutStyles,{onInput:n[0]||(n[0]=(...r)=>e.onInput&&e.onInput(...r)),onFocus:n[1]||(n[1]=r=>e.hasFocus=!0),onBlur:n[2]||(n[2]=r=>e.hasFocus=!1),onKeydown:n[3]||(n[3]=(...r)=>e.onKeydown&&e.onKeydown(...r))}),null,16,g),t.renderSlot(e.$slots,"append"),e.showShortcutIcon?t.renderSlot(e.$slots,"shortcut-icon",{key:1},()=>[V]):t.createCommentVNode("",!0),e.showClearIcon?t.renderSlot(e.$slots,"clear-icon",{key:2,clear:e.clear},()=>[t.createElementVNode("button",{class:"search-icon clear","aria-label":"Clear",onMousedown:n[4]||(n[4]=(...r)=>e.clear&&e.clear(...r)),onKeydown:n[5]||(n[5]=t.withKeys((...r)=>e.clear&&e.clear(...r),["space","enter"]))},null,32)]):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"append-outer")],16)}return I(S,[["render",O]])}); |
{ | ||
"name": "vue-search-input", | ||
"description": "A Vue.js 3 search input component, inspired by the global search input of Storybook and GitHub.", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"license": "MIT", | ||
@@ -46,33 +46,33 @@ "repository": "https://github.com/kouts/vue-search-input", | ||
"devDependencies": { | ||
"@babel/core": "^7.22.10", | ||
"@babel/preset-env": "^7.22.10", | ||
"@commitlint/cli": "^17.7.1", | ||
"@commitlint/config-conventional": "^17.7.0", | ||
"@kouts/eslint-config": "^0.0.13", | ||
"@babel/core": "^7.23.2", | ||
"@babel/preset-env": "^7.23.2", | ||
"@commitlint/cli": "^17.8.0", | ||
"@commitlint/config-conventional": "^17.8.0", | ||
"@kouts/eslint-config": "^0.0.14", | ||
"@semantic-release/changelog": "^6.0.3", | ||
"@semantic-release/git": "^10.0.1", | ||
"@types/jest": "^29.5.3", | ||
"@types/node": "^20.5.0", | ||
"@vitejs/plugin-vue": "^4.2.3", | ||
"@types/jest": "^29.5.5", | ||
"@types/node": "^20.8.6", | ||
"@vitejs/plugin-vue": "^4.4.0", | ||
"@vue/compiler-sfc": "^3.3.4", | ||
"@vue/test-utils": "^2.4.1", | ||
"@vue/vue3-jest": "29.2.5", | ||
"babel-jest": "^29.6.2", | ||
"bootstrap": "^5.3.1", | ||
"eslint": "^8.47.0", | ||
"@vue/vue3-jest": "29.2.6", | ||
"babel-jest": "^29.7.0", | ||
"bootstrap": "^5.3.2", | ||
"eslint": "^8.51.0", | ||
"husky": "^8.0.3", | ||
"jest": "^29.6.2", | ||
"jest-environment-jsdom": "^29.6.2", | ||
"lint-staged": "^14.0.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"lint-staged": "^15.0.1", | ||
"make-coverage-badge": "^1.2.0", | ||
"prettier": "^2.7.1", | ||
"prettier": "^3.0.3", | ||
"rollup-plugin-delete": "^2.0.0", | ||
"sass": "^1.65.1", | ||
"sass": "^1.69.3", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.1.6", | ||
"vite": "^4.4.9", | ||
"vite-plugin-dts": "^3.5.2", | ||
"typescript": "^5.2.2", | ||
"vite": "^4.4.11", | ||
"vite-plugin-dts": "^3.6.0", | ||
"vue": "^3.3.4", | ||
"vue-tsc": "^1.8.8" | ||
"vue-tsc": "^1.8.19" | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
export const fieldType = ['search', 'text'] as const | ||
export const fieldType = ['search', 'text', 'password'] as const | ||
export type FieldType = (typeof fieldType)[number] |
95523
0.35%