mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 04:16:34 +00:00
Upgrade Fuse (#6012)
This commit is contained in:
parent
7427b209a7
commit
c5ef33cc78
@ -1,13 +1,13 @@
|
||||
import * as Fuse from "fuse.js";
|
||||
import Fuse from "fuse.js";
|
||||
import { HassioAddonInfo } from "../../../src/data/hassio/addon";
|
||||
|
||||
export function filterAndSort(addons: HassioAddonInfo[], filter: string) {
|
||||
const options: Fuse.FuseOptions<HassioAddonInfo> = {
|
||||
const options: Fuse.IFuseOptions<HassioAddonInfo> = {
|
||||
keys: ["name", "description", "slug"],
|
||||
caseSensitive: false,
|
||||
isCaseSensitive: false,
|
||||
minMatchCharLength: 2,
|
||||
threshold: 0.2,
|
||||
};
|
||||
const fuse = new Fuse(addons, options);
|
||||
return fuse.search(filter);
|
||||
return fuse.search(filter).map((result) => result.item);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@
|
||||
"deep-freeze": "^0.0.1",
|
||||
"es6-object-assign": "^1.1.0",
|
||||
"fecha": "^4.2.0",
|
||||
"fuse.js": "^3.4.4",
|
||||
"fuse.js": "^6.0.0",
|
||||
"google-timezones-json": "^1.0.2",
|
||||
"hls.js": "^0.12.4",
|
||||
"home-assistant-js-websocket": "^5.1.2",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "@polymer/paper-item/paper-icon-item";
|
||||
import "@polymer/paper-item/paper-item-body";
|
||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||
import * as Fuse from "fuse.js";
|
||||
import Fuse from "fuse.js";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -52,14 +52,14 @@ class StepFlowPickHandler extends LitElement {
|
||||
});
|
||||
|
||||
if (filter) {
|
||||
const options: Fuse.FuseOptions<HandlerObj> = {
|
||||
const options: Fuse.IFuseOptions<HandlerObj> = {
|
||||
keys: ["name", "slug"],
|
||||
caseSensitive: false,
|
||||
isCaseSensitive: false,
|
||||
minMatchCharLength: 2,
|
||||
threshold: 0.2,
|
||||
};
|
||||
const fuse = new Fuse(handlers, options);
|
||||
return fuse.search(filter);
|
||||
return fuse.search(filter).map((result) => result.item);
|
||||
}
|
||||
return handlers.sort((a, b) =>
|
||||
a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import memoizeOne from "memoize-one";
|
||||
import * as Fuse from "fuse.js";
|
||||
import Fuse from "fuse.js";
|
||||
import { caseInsensitiveCompare } from "../../../common/string/compare";
|
||||
import { computeRTL } from "../../../common/util/compute_rtl";
|
||||
import { nextRender } from "../../../common/util/render-status";
|
||||
@ -149,14 +149,14 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
||||
if (!filter) {
|
||||
return [...configEntries];
|
||||
}
|
||||
const options: Fuse.FuseOptions<ConfigEntryExtended> = {
|
||||
const options: Fuse.IFuseOptions<ConfigEntryExtended> = {
|
||||
keys: ["domain", "localized_domain_name", "title"],
|
||||
caseSensitive: false,
|
||||
isCaseSensitive: false,
|
||||
minMatchCharLength: 2,
|
||||
threshold: 0.2,
|
||||
};
|
||||
const fuse = new Fuse(configEntries, options);
|
||||
return fuse.search(filter);
|
||||
return fuse.search(filter).map((result) => result.item);
|
||||
}
|
||||
);
|
||||
|
||||
@ -193,14 +193,14 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
||||
if (!filter) {
|
||||
return configEntriesInProgress;
|
||||
}
|
||||
const options: Fuse.FuseOptions<DataEntryFlowProgressExtended> = {
|
||||
const options: Fuse.IFuseOptions<DataEntryFlowProgressExtended> = {
|
||||
keys: ["handler", "localized_title"],
|
||||
caseSensitive: false,
|
||||
isCaseSensitive: false,
|
||||
minMatchCharLength: 2,
|
||||
threshold: 0.2,
|
||||
};
|
||||
const fuse = new Fuse(configEntriesInProgress, options);
|
||||
return fuse.search(filter);
|
||||
return fuse.search(filter).map((result) => result.item);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as Fuse from "fuse.js";
|
||||
import Fuse from "fuse.js";
|
||||
import {
|
||||
css,
|
||||
CSSResult,
|
||||
@ -60,14 +60,14 @@ export class HuiCardPicker extends LitElement {
|
||||
let cards = cardElements.map(
|
||||
(cardElement: CardElement) => cardElement.card
|
||||
);
|
||||
const options: Fuse.FuseOptions<Card> = {
|
||||
const options: Fuse.IFuseOptions<Card> = {
|
||||
keys: ["type", "name", "description"],
|
||||
caseSensitive: false,
|
||||
isCaseSensitive: false,
|
||||
minMatchCharLength: 2,
|
||||
threshold: 0.2,
|
||||
};
|
||||
const fuse = new Fuse(cards, options);
|
||||
cards = fuse.search(filter);
|
||||
cards = fuse.search(filter).map((result) => result.item);
|
||||
cardElements = cardElements.filter((cardElement: CardElement) =>
|
||||
cards.includes(cardElement.card)
|
||||
);
|
||||
|
@ -7907,10 +7907,10 @@ functional-red-black-tree@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
|
||||
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
|
||||
|
||||
fuse.js@^3.4.4:
|
||||
version "3.4.4"
|
||||
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-3.4.4.tgz#f98f55fcb3b595cf6a3e629c5ffaf10982103e95"
|
||||
integrity sha512-pyLQo/1oR5Ywf+a/tY8z4JygnIglmRxVUOiyFAbd11o9keUDpUJSMGRWJngcnkURj30kDHPmhoKY8ChJiz3EpQ==
|
||||
fuse.js@^6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-6.0.0.tgz#6fc16cd7555648deda392892402d4188553552b2"
|
||||
integrity sha512-e5Ap6mhF/WQ9bKqsMFTTR5/DS9qbYab4VXHtMdxCanH+VZkdUV2LqcgMO31etSQv53NXsguQF1bdqkrrPAM2HQ==
|
||||
|
||||
g-status@^2.0.2:
|
||||
version "2.0.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user