Skip to main content

Installation and initialization

SVAR FileManager is an open-source library distributed under the MIT license.

Installing File Manager

To install the Svelte File Manager widget, you can run the following command:

npm install wx-svelte-filemanager

//yarn
yarn add wx-svelte-filemanager

Initializing

Import the Filemanager component:

<script>
import { Filemanager } from "wx-svelte-filemanager";
</script>

Initialize the Filemanager properties.

The example below creates the File Manager with two folders and three files. The data array holds the files structure, paths to the items, creation dates and the sizes of items. It's necessary to define the data component inside the Filemanager tag.

<script>
import { Filemanager } from "wx-svelte-filemanager";

const rawdata = [
{
id: "/Code",
size: 4096,
date: new Date(2023, 11, 2, 17, 25),
type: "folder",
},
{
id: "/Music",
size: 4096,
date: new Date(2023, 11, 1, 14, 45),
type: "folder",
},

{
id: "/Info.txt",
size: 1000,
date: new Date(2023, 10, 30, 6, 13),
type: "file",
},
{
//parent: "/Code/Datepicker",
id: "/Code/Datepicker/Year.svelte",
size: 1595,
date: new Date(2023, 11, 7, 15, 23),
type: "file",
},
{
id: "/Pictures/162822515312968813.png",
size: 510885,
date: new Date(2023, 11, 1, 14, 45),
type: "file",
},
];
</script>

<Filemanager data={rawdata} />

Now you can move forward and load data. See Loading data.