Skip to content

Commit 95996c6

Browse files
chore(release): set package.json to 1.0.0 [skip ci]
# 1.0.0 (2022-01-16) ### Features * added files ([1c2dd93](1c2dd93))
1 parent 1c2dd93 commit 95996c6

File tree

5 files changed

+191
-0
lines changed

5 files changed

+191
-0
lines changed

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 1.0.0 (2022-01-16)
2+
3+
4+
### Features
5+
6+
* added files ([1c2dd93](https://github.com/kouts/vue-search-input/commit/1c2dd93b57c7e46e675a7af93351ea201ec461fc))

Diff for: coverage/badge.svg

+1
Loading

Diff for: coverage/coverage-summary.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"total": {"lines":{"total":39,"covered":23,"skipped":0,"pct":58.97},"statements":{"total":40,"covered":24,"skipped":0,"pct":60},"functions":{"total":11,"covered":4,"skipped":0,"pct":36.36},"branches":{"total":26,"covered":2,"skipped":0,"pct":7.69},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
2+
,"/home/runner/work/vue-search-input/vue-search-input/src/SearchInput.types.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
3+
,"/home/runner/work/vue-search-input/vue-search-input/src/SearchInput.vue": {"lines":{"total":38,"covered":22,"skipped":0,"pct":57.89},"functions":{"total":11,"covered":4,"skipped":0,"pct":36.36},"statements":{"total":39,"covered":23,"skipped":0,"pct":58.97},"branches":{"total":26,"covered":2,"skipped":0,"pct":7.69}}
4+
}

Diff for: dist/vue-search-input.es.js

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
var __defProp = Object.defineProperty;
2+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3+
var __hasOwnProp = Object.prototype.hasOwnProperty;
4+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
5+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6+
var __spreadValues = (a, b) => {
7+
for (var prop in b || (b = {}))
8+
if (__hasOwnProp.call(b, prop))
9+
__defNormalProp(a, prop, b[prop]);
10+
if (__getOwnPropSymbols)
11+
for (var prop of __getOwnPropSymbols(b)) {
12+
if (__propIsEnum.call(b, prop))
13+
__defNormalProp(a, prop, b[prop]);
14+
}
15+
return a;
16+
};
17+
import { defineComponent, ref, computed, onBeforeUnmount, openBlock, createElementBlock, normalizeProps, guardReactiveProps, renderSlot, createElementVNode, mergeProps, createCommentVNode } from "vue";
18+
const fieldType = ["search", "text"];
19+
var _export_sfc = (sfc, props) => {
20+
const target = sfc.__vccOpts || sfc;
21+
for (const [key, val] of props) {
22+
target[key] = val;
23+
}
24+
return target;
25+
};
26+
const _sfc_main = defineComponent({
27+
inheritAttrs: false,
28+
props: {
29+
type: {
30+
type: String,
31+
default: "search",
32+
validator: (prop) => fieldType.includes(prop)
33+
},
34+
modelValue: {
35+
type: String,
36+
default: ""
37+
}
38+
},
39+
emits: ["update:modelValue"],
40+
setup(props, { emit, attrs }) {
41+
const hasFocus = ref(false);
42+
const inputRef = ref(null);
43+
const attrsWithoutStyles = computed(() => {
44+
const toOmit = ["class", "style"];
45+
const res = {};
46+
Object.keys(attrs).forEach((attr) => {
47+
if (toOmit.indexOf(attr) === -1) {
48+
res[attr] = attrs[attr];
49+
}
50+
});
51+
return res;
52+
});
53+
const attrsStyles = computed(() => {
54+
const style = attrs.style;
55+
return __spreadValues(__spreadValues({}, attrs.class ? { class: attrs.class } : {}), style ? { style } : {});
56+
});
57+
const clear = () => {
58+
emit("update:modelValue", "");
59+
};
60+
const onInput = (e) => {
61+
emit("update:modelValue", e.target.value);
62+
};
63+
const onKeydown = (e) => {
64+
if (e.key === "Escape") {
65+
clear();
66+
const el = inputRef.value;
67+
el.blur();
68+
}
69+
};
70+
const onDocumentKeydown = (e) => {
71+
if (e.key === "/" && e.target !== inputRef.value && window.document.activeElement !== inputRef.value && e.target instanceof HTMLInputElement === false && e.target instanceof HTMLSelectElement === false && e.target instanceof HTMLTextAreaElement === false) {
72+
e.preventDefault();
73+
const allVisibleSearchInputs = [].slice.call(document.querySelectorAll("[data-search-bar-input]")).filter((el) => {
74+
return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
75+
});
76+
const elToFocus = allVisibleSearchInputs.length > 1 ? allVisibleSearchInputs[0] : inputRef.value;
77+
elToFocus == null ? void 0 : elToFocus.focus();
78+
elToFocus == null ? void 0 : elToFocus.select();
79+
}
80+
};
81+
window.document.addEventListener("keydown", onDocumentKeydown);
82+
onBeforeUnmount(() => {
83+
window.document.removeEventListener("keydown", onDocumentKeydown);
84+
});
85+
return {
86+
inputRef,
87+
hasFocus,
88+
clear,
89+
onInput,
90+
onKeydown,
91+
attrsStyles,
92+
attrsWithoutStyles
93+
};
94+
}
95+
});
96+
const _hoisted_1 = /* @__PURE__ */ createElementVNode("div", { class: "search-icon search" }, [
97+
/* @__PURE__ */ createElementVNode("svg", {
98+
width: "20",
99+
height: "20",
100+
viewBox: "0 0 24 24",
101+
fill: "none",
102+
xmlns: "http://www.w3.org/2000/svg"
103+
}, [
104+
/* @__PURE__ */ createElementVNode("path", {
105+
"fill-rule": "evenodd",
106+
"clip-rule": "evenodd",
107+
d: "M18.319 14.4326C20.7628 11.2941 20.542 6.75347 17.6569 3.86829C14.5327 0.744098 9.46734 0.744098 6.34315 3.86829C3.21895 6.99249 3.21895 12.0578 6.34315 15.182C9.22833 18.0672 13.769 18.2879 16.9075 15.8442C16.921 15.8595 16.9351 15.8745 16.9497 15.8891L21.1924 20.1317C21.5829 20.5223 22.2161 20.5223 22.6066 20.1317C22.9971 19.7412 22.9971 19.1081 22.6066 18.7175L18.364 14.4749C18.3493 14.4603 18.3343 14.4462 18.319 14.4326ZM16.2426 5.28251C18.5858 7.62565 18.5858 11.4246 16.2426 13.7678C13.8995 16.1109 10.1005 16.1109 7.75736 13.7678C5.41421 11.4246 5.41421 7.62565 7.75736 5.28251C10.1005 2.93936 13.8995 2.93936 16.2426 5.28251Z",
108+
fill: "currentColor"
109+
})
110+
])
111+
], -1);
112+
const _hoisted_2 = ["value"];
113+
const _hoisted_3 = /* @__PURE__ */ createElementVNode("div", {
114+
class: "search-icon shortcut",
115+
title: 'Press "/" to search'
116+
}, [
117+
/* @__PURE__ */ createElementVNode("svg", {
118+
width: "16",
119+
height: "20",
120+
viewBox: "4 4 14 14",
121+
fill: "none",
122+
xmlns: "http://www.w3.org/2000/svg"
123+
}, [
124+
/* @__PURE__ */ createElementVNode("path", {
125+
"fill-rule": "evenodd",
126+
"clip-rule": "evenodd",
127+
d: "M14.526 6.10576C15.0265 6.33917 15.2667 6.88343 15.0625 7.3214L9.88541 18.4237C9.68118 18.8616 9.10985 19.0275 8.60931 18.7941C8.10877 18.5607 7.86857 18.0164 8.0728 17.5784L13.2499 6.47616C13.4541 6.03819 14.0254 5.87235 14.526 6.10576Z",
128+
fill: "currentColor"
129+
})
130+
])
131+
], -1);
132+
const _hoisted_4 = /* @__PURE__ */ createElementVNode("svg", {
133+
width: "18",
134+
height: "18",
135+
viewBox: "0 0 24 24",
136+
fill: "none",
137+
xmlns: "http://www.w3.org/2000/svg"
138+
}, [
139+
/* @__PURE__ */ createElementVNode("path", {
140+
d: "M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z",
141+
fill: "currentColor"
142+
})
143+
], -1);
144+
const _hoisted_5 = [
145+
_hoisted_4
146+
];
147+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
148+
return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(_ctx.attrsStyles)), [
149+
renderSlot(_ctx.$slots, "search-icon", {}, () => [
150+
_hoisted_1
151+
]),
152+
createElementVNode("input", mergeProps({
153+
ref: "inputRef",
154+
type: "search",
155+
class: "search-input",
156+
"data-search-input": "true",
157+
value: _ctx.modelValue
158+
}, _ctx.attrsWithoutStyles, {
159+
onInput: _cache[0] || (_cache[0] = (...args) => _ctx.onInput && _ctx.onInput(...args)),
160+
onFocus: _cache[1] || (_cache[1] = ($event) => _ctx.hasFocus = true),
161+
onBlur: _cache[2] || (_cache[2] = ($event) => _ctx.hasFocus = false),
162+
onKeydown: _cache[3] || (_cache[3] = (...args) => _ctx.onKeydown && _ctx.onKeydown(...args))
163+
}), null, 16, _hoisted_2),
164+
!_ctx.hasFocus && _ctx.modelValue.length === 0 ? renderSlot(_ctx.$slots, "shortcut-icon", { key: 0 }, () => [
165+
_hoisted_3
166+
]) : createCommentVNode("", true),
167+
_ctx.modelValue.length > 0 ? renderSlot(_ctx.$slots, "clear-icon", {
168+
key: 1,
169+
clear: _ctx.clear
170+
}, () => [
171+
createElementVNode("div", {
172+
class: "search-icon clear",
173+
onMousedown: _cache[4] || (_cache[4] = (...args) => _ctx.clear && _ctx.clear(...args))
174+
}, _hoisted_5, 32)
175+
]) : createCommentVNode("", true)
176+
], 16);
177+
}
178+
var SearchInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
179+
export { SearchInput as default };

Diff for: dist/vue-search-input.umd.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)