Skip to main content

filter-files

Description

Fires when the filter state is changed

Usage

"filter-files": ({
text: string | null
}) => boolean | void

Parameters

The callback of the filter-files action takes an object with the following parameters:

  • text- (required) the text value to filter by; if it's set to null, the filtering is not activated or the current filter is reset

Example

<script>
import { getData, getDrive } from "./common/data";
import { Filemanager } from "@wx/svelte-filemanager";

let api;

$: if (api) {
api.on("filter-files", ({ text }) => {
if (text === null) {
console.log("Filtering deactivated");
} else {
console.log(`Filter by ${text}`);
}
// block operation if filter text is 'block'
if (text === "block") {
return false;
}
});
}

</script>

<Filemanager data={getData()} drive={getDrive()} bind:api />

Related articles: How to access File Manager API