chore: format
This commit is contained in:
@@ -1,70 +1,70 @@
|
||||
{
|
||||
"name": "@honeymachine/search",
|
||||
"version": "1.0.0",
|
||||
"description": "A search component for the modern web",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"module": "lib/index.js",
|
||||
"files": [
|
||||
"src",
|
||||
"lib",
|
||||
"module",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf lib module",
|
||||
"test": "exit 0",
|
||||
"build:tsc": "tsc -d",
|
||||
"watch:tsc": "tsc -d -w",
|
||||
"build:rollup": "rollup -c",
|
||||
"watch:rollup": "rollup -c -w",
|
||||
"build": "pnpm run build:tsc & pnpm run build:rollup & wait",
|
||||
"watch": "pnpm run watch:tsc & pnpm run watch:rollup",
|
||||
"serve": "serve -l 3337",
|
||||
"dev": "pnpm run watch & pnpm run serve",
|
||||
"preversion": "sed -i '' -E 's:^(lib|docs/assets/hm-\\*)$:#<removed temporarily>\\1:' .gitignore",
|
||||
"version": "pnpm run build && git add .",
|
||||
"postversion": "sed -i '' -E 's:^#<removed temporarily>(lib|docs/assets/hm-\\*)$:\\1:' .gitignore && git rm --cached -r lib docs/assets/hm-* && git add . && git commit -m 'Restore preversion .gitignore'",
|
||||
"prepack": "pnpm run clean && pnpm run build"
|
||||
},
|
||||
"author": "Sebastian Krüger <sk@honeymachine.io> (https://honeymachine.io/)",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@hydecorp/component": "^1.0.0",
|
||||
"@types/w3c-css-typed-object-model-level-1": "20180410.0.4",
|
||||
"lunr": "^2.3.9"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/honeymachine/search.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/honeymachine/search/issues"
|
||||
},
|
||||
"homepage": "https://honeymachine.github.io/search/",
|
||||
"tags": [
|
||||
"search",
|
||||
"touch-events",
|
||||
"swipe-gestures",
|
||||
"webcomponent",
|
||||
"jquery",
|
||||
"rxjs",
|
||||
"pivoine",
|
||||
"jquery-plugin",
|
||||
"vanilla-js",
|
||||
"search-layout",
|
||||
"custom-element",
|
||||
"vanilla",
|
||||
"web-components",
|
||||
"ui-component",
|
||||
"reactive",
|
||||
"menu",
|
||||
"menu-navigation"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/lunr": "^2.3.7"
|
||||
}
|
||||
"name": "@honeymachine/search",
|
||||
"version": "1.0.0",
|
||||
"description": "A search component for the modern web",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"module": "lib/index.js",
|
||||
"files": [
|
||||
"src",
|
||||
"lib",
|
||||
"module",
|
||||
"tsconfig.json"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf lib module",
|
||||
"test": "exit 0",
|
||||
"build:tsc": "tsc -d",
|
||||
"watch:tsc": "tsc -d -w",
|
||||
"build:rollup": "rollup -c",
|
||||
"watch:rollup": "rollup -c -w",
|
||||
"build": "pnpm run build:tsc & pnpm run build:rollup & wait",
|
||||
"watch": "pnpm run watch:tsc & pnpm run watch:rollup",
|
||||
"serve": "serve -l 3337",
|
||||
"dev": "pnpm run watch & pnpm run serve",
|
||||
"preversion": "sed -i '' -E 's:^(lib|docs/assets/hm-\\*)$:#<removed temporarily>\\1:' .gitignore",
|
||||
"version": "pnpm run build && git add .",
|
||||
"postversion": "sed -i '' -E 's:^#<removed temporarily>(lib|docs/assets/hm-\\*)$:\\1:' .gitignore && git rm --cached -r lib docs/assets/hm-* && git add . && git commit -m 'Restore preversion .gitignore'",
|
||||
"prepack": "pnpm run clean && pnpm run build"
|
||||
},
|
||||
"author": "Sebastian Krüger <sk@honeymachine.io> (https://honeymachine.io/)",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@hydecorp/component": "^1.0.0",
|
||||
"@types/w3c-css-typed-object-model-level-1": "20180410.0.4",
|
||||
"lunr": "^2.3.9"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/honeymachine/search.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/honeymachine/search/issues"
|
||||
},
|
||||
"homepage": "https://honeymachine.github.io/search/",
|
||||
"tags": [
|
||||
"search",
|
||||
"touch-events",
|
||||
"swipe-gestures",
|
||||
"webcomponent",
|
||||
"jquery",
|
||||
"rxjs",
|
||||
"pivoine",
|
||||
"jquery-plugin",
|
||||
"vanilla-js",
|
||||
"search-layout",
|
||||
"custom-element",
|
||||
"vanilla",
|
||||
"web-components",
|
||||
"ui-component",
|
||||
"reactive",
|
||||
"menu",
|
||||
"menu-navigation"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/lunr": "^2.3.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import terser from "@rollup/plugin-terser";
|
||||
|
||||
export default [
|
||||
{
|
||||
input: 'src/index.ts',
|
||||
output: [
|
||||
{
|
||||
file: `docs/assets/hm-search.js`,
|
||||
format: 'es',
|
||||
sourcemap: true,
|
||||
},
|
||||
{
|
||||
file: `module/index.js`,
|
||||
format: 'es',
|
||||
sourcemap: true,
|
||||
},
|
||||
],
|
||||
plugins: [typescript(), resolve(), commonjs(), terser()],
|
||||
},
|
||||
{
|
||||
input: "src/index.ts",
|
||||
output: [
|
||||
{
|
||||
file: `docs/assets/hm-search.js`,
|
||||
format: "es",
|
||||
sourcemap: true,
|
||||
},
|
||||
{
|
||||
file: `module/index.js`,
|
||||
format: "es",
|
||||
sourcemap: true,
|
||||
},
|
||||
],
|
||||
plugins: [typescript(), resolve(), commonjs(), terser()],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { applyMixins } from '@hydecorp/component';
|
||||
export { applyMixins } from "@hydecorp/component";
|
||||
|
||||
@@ -17,76 +17,80 @@
|
||||
* @license
|
||||
* @nocompile
|
||||
*/
|
||||
import { html } from 'lit';
|
||||
import { customElement, property, query, eventOptions } from 'lit/decorators.js';
|
||||
import { RxLitElement } from '@hydecorp/component';
|
||||
import lunr from 'lunr';
|
||||
import { applyMixins } from './common';
|
||||
import { styles } from './styles';
|
||||
import { Key } from 'readline';
|
||||
import { html } from "lit";
|
||||
import {
|
||||
customElement,
|
||||
property,
|
||||
query,
|
||||
eventOptions,
|
||||
} from "lit/decorators.js";
|
||||
import { RxLitElement } from "@hydecorp/component";
|
||||
import lunr from "lunr";
|
||||
import { applyMixins } from "./common";
|
||||
import { styles } from "./styles";
|
||||
import { Key } from "readline";
|
||||
|
||||
@customElement('hm-search')
|
||||
@customElement("hm-search")
|
||||
export class HmSearch extends applyMixins(RxLitElement, []) {
|
||||
static styles = styles;
|
||||
static styles = styles;
|
||||
|
||||
@query('.hm-search-input') inputEl!: HTMLInputElement;
|
||||
@query(".hm-search-input") inputEl!: HTMLInputElement;
|
||||
|
||||
@property({ type: String, reflect: true }) placeholder: string = 'Search...';
|
||||
@property({ type: Array, reflect: true }) documents: Array<any> = [];
|
||||
@property({ type: Array, reflect: true }) fields: Array<string> = [];
|
||||
@property({ type: String, reflect: true }) placeholder: string = "Search...";
|
||||
@property({ type: Array, reflect: true }) documents: Array<any> = [];
|
||||
@property({ type: Array, reflect: true }) fields: Array<string> = [];
|
||||
|
||||
idx!: lunr.Index;
|
||||
idx!: lunr.Index;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
handleKeyup(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') {
|
||||
this.clear();
|
||||
return;
|
||||
}
|
||||
const query = this.inputEl.value;
|
||||
if (!query) {
|
||||
this.fireEvent('search', { detail: [] });
|
||||
return;
|
||||
}
|
||||
this.fireEvent('search', { detail: this.idx.search(query) });
|
||||
}
|
||||
handleKeyup(e: KeyboardEvent) {
|
||||
if (e.key === "Escape") {
|
||||
this.clear();
|
||||
return;
|
||||
}
|
||||
const query = this.inputEl.value;
|
||||
if (!query) {
|
||||
this.fireEvent("search", { detail: [] });
|
||||
return;
|
||||
}
|
||||
this.fireEvent("search", { detail: this.idx.search(query) });
|
||||
}
|
||||
|
||||
updated(): void {
|
||||
const documents = this.documents;
|
||||
const fields = this.fields;
|
||||
this.idx = lunr(function () {
|
||||
fields.forEach((field) => {
|
||||
this.field(field);
|
||||
});
|
||||
|
||||
updated(): void {
|
||||
const documents = this.documents;
|
||||
const fields = this.fields;
|
||||
this.idx = lunr(function () {
|
||||
fields.forEach((field) => {
|
||||
this.field(field);
|
||||
});
|
||||
documents.forEach((doc) => {
|
||||
this.add(doc);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
documents.forEach((doc) => {
|
||||
this.add(doc);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
render() {
|
||||
return html`
|
||||
<div class="hm-search">
|
||||
<input class="hm-search-input" type="text" placeholder="${this.placeholder}" name="hm-search-input" @keyup="${this.handleKeyup}" />
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
focus() {
|
||||
this.inputEl.focus();
|
||||
}
|
||||
focus() {
|
||||
this.inputEl.focus();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.inputEl.value = '';
|
||||
this.fireEvent('search', { detail: [] });
|
||||
}
|
||||
clear() {
|
||||
this.inputEl.value = "";
|
||||
this.fireEvent("search", { detail: [] });
|
||||
}
|
||||
|
||||
get active() {
|
||||
return this.inputEl === document.activeElement;
|
||||
}
|
||||
get active() {
|
||||
return this.inputEl === document.activeElement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { css } from 'lit';
|
||||
import { css } from "lit";
|
||||
|
||||
export const styles = css`
|
||||
@media screen {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
||||
"moduleResolution": "Node",
|
||||
"module": "ES2020",
|
||||
"target": "ES2018",
|
||||
"outDir": "lib",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"strict": true,
|
||||
"importHelpers": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": ["typings/**/*.ts", "src/**/*.ts"]
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
||||
"moduleResolution": "Node",
|
||||
"module": "ES2020",
|
||||
"target": "ES2018",
|
||||
"outDir": "lib",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"strict": true,
|
||||
"importHelpers": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": ["typings/**/*.ts", "src/**/*.ts"]
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
type Constructor<T> = {
|
||||
new (...args: unknown[]): T
|
||||
new (...args: unknown[]): T;
|
||||
};
|
||||
|
||||
// From the TC39 Decorators proposal
|
||||
interface ClassDescriptor {
|
||||
kind: 'class';
|
||||
elements: ClassElement[];
|
||||
finisher?: <T>(clazz: Constructor<T>) => undefined | Constructor<T>;
|
||||
kind: "class";
|
||||
elements: ClassElement[];
|
||||
finisher?: <T>(clazz: Constructor<T>) => undefined | Constructor<T>;
|
||||
}
|
||||
|
||||
// From the TC39 Decorators proposal
|
||||
interface ClassElement {
|
||||
kind: 'field'|'method';
|
||||
key: PropertyKey;
|
||||
placement: 'static'|'prototype'|'own';
|
||||
initializer?: Function;
|
||||
extras?: ClassElement[];
|
||||
finisher?: <T>(clazz: Constructor<T>) => undefined | Constructor<T>;
|
||||
descriptor?: PropertyDescriptor;
|
||||
}
|
||||
kind: "field" | "method";
|
||||
key: PropertyKey;
|
||||
placement: "static" | "prototype" | "own";
|
||||
initializer?: Function;
|
||||
extras?: ClassElement[];
|
||||
finisher?: <T>(clazz: Constructor<T>) => undefined | Constructor<T>;
|
||||
descriptor?: PropertyDescriptor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user