This repo contains examples of importing Webix Core and Complex Widgets into a SvelteKit App.
By default, the demo shows how to initialize the Dashboard, Scheduler and Spreadsheet, but it can be replaced with any of Webix Widgets.
Complex widgets are PRO components.
In the demo Webix, Spreadsheet, and Scheduler are fetched from npm, so make sure you have signed in to our private @xbs scope.
Note: NPM always provides access to the latest versions of packages, so credentials are valid only while the license is active.
Alternatively, you can remove these dependencies, place the "codebase" of Webix/Complex widget into the demo's static folder, and include the js files through a <script> in the app.html.
To download the latest Trial package, check webix.com/download.
The demo is based on the default SvelteKit project.
If you're looking for native Svelte components, check SVAR Svelte component library. The collection includes feature-rich datagrid, Gantt chart, calendar, and other UI components for building interactive web apps with Svelte and SvelteKit. Most of them are open-source, MIT-licensed and available on SVAR's GitHub.
npm install
npm run dev
Open http://localhost:5173/ to view the demo in the browser.
Production build
To create a production version of your app, run npm run build.
You can preview the production build with npm run preview.
Webix is a client-side UI library, so when integrating it in SvelteKit, make sure that Webix elements are imported and rendered on a client side only.
Additionally, a main requirement when initing a Webix Complex widget is to have a global Webix object (it should be available before the component's sources are imported).
Since there're two complex widgets in this demo, the global assignment was moved to SvelteKit's hooks.client.js.
In other cases, especially if Webix is needed only for rare pages, you could import and make webix global in files with complex components code.
// src/hooks.client.js
import * as webix from "@xbs/webix-pro";
window.webix = webix;onMount(async () => {
await import('@xbs/scheduler');
if (disposed) return;
scheduler = webix.ui({
view: 'scheduler',
container,
date,
url
});
cleanupResizeObserver = createResizeObserver(container, () => scheduler?.adjust());
});
onDestroy(() => {
disposed = true;
cleanupResizeObserver?.();
scheduler?.destructor();
});
<div bind:this={container} style="height: 100%"></div>;- use onMount() method to init a webix.ui instance and set all related in-app handlers
- the returned function in onMount can be used to destruct the component and stop other related processes such as ResizeObserver, etc. (won't work with an async function in onMount())
- or use onDestroy method to do the same with an async or regular function in onMount()
MIT