npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bizmate-oss/sveltekit-components

v1.0.92

Published

Library for sveltekit components

Downloads

81

Readme

Sveltekit Library

Library containing Sveltekit components

Usage

npm install -D @bizmate-oss/sveltekit-components

Components

Table

Responsive table to display and filter arrays of data

Minimalistic example

<script>
import { Table } from '@bizmate-oss/sveltekit-components';
//or import Table from '@bizmate-oss/sveltekit-components/Table/Table.svelte'
let cols = [
    {
        id: 'firstName',
        label: 'First Name',
        searchable: true,
    },
    {
        id: 'params.lastName',
        label: 'Last Name'
    }
]
let rows = [
    {
        firstName: 'Jason',
        params: {
            lastName: 'Smith'
        }
    },
    {
        firstName: 'John',
        params: {
            lastName: 'White'
        }
    }
]
</script>

<Table {rows} {cols} border alternateRows isExportable/>

Configuration

  • id: string - A unique id for the table. Will be automatically generated if not provided
  • rows: Array of Objects - Array containing the data to be displayed
  • cols: Array of Objeccts - Array that describes the columns of the table. Every column object can have the following properties:
    • id: string - A unique id for identifing the column. MUST be equal to the path where the values of rows are saved, words divided by a dot. Example: to display the value of rows[n].params.data, the respective column id must be 'params.data'
    • label: string - The label that will be displayed on top of the column
    • datatype (optional): string - The datatype which will occupy such column.
      • Available values: 'string' | 'number' | 'date' | 'boolean' | 'enum' . Default: 'string'
    • searchable (optional): boolean - Specify if a column is searchable. Default: false
    • sortable (optional): boolean - Specify if a column is sortable. Default: true
    • icon (optional): boolean - Specify if the column value is represented by an icon. Default: false
    • min (optional): boolean - Specify if a column should be the smallest as possibile. Default: false
    • align (optional): string - Align contents of the column's cells.
    • hidden (optional): boolean - Hides the column
      • Available values: 'center' | 'end'. Default: undefined (normally aligned to the left)
    • format (optional): function - Function that transforms the column's respective value of rows in the desired HTML format.
      • Arguments: The column's row value and the row object
      • Return value: string
  • title: string - Table's Title that will be displayed on top
  • pageRows: string | number - The number of rows to be displayed for each page. Can be changed afterwards through GUI. Default: 10
  • isExportable: boolean - Set if the Table can be exported or not.
    • Available formats: 'csv' | 'xls' | 'pdf'
  • alternateRows: boolean - Set if rows should be coloured with slightly different colours. Default: false
  • dark: boolean - Enable dark theme for the table. Default: false
  • border: boolean - Set if the table should have borders. Default: false

Select

Select with support for HTML options and selections

Example

<script>
import { Select } from '@bizmate-oss/sveltekit-components';

let options = ["Product", "sky", "Dollar", "Minivan", "San"]

const format = (opt) => {
  if(opt.length <= 6){
    return `<div class="text-primary">${opt}</div>`
  } else {
    return `<div class="text-secondary">${opt}</div>`
  }
}
</script>

<Select {options} {format}/>

Configuration

  • options: Array of strings - The available options for selection. Can be undefined if both data and path are defined
  • data: Array of Objects - Array containing the data from where the options can be extracted
  • path: string - Path relative to data where the options can be found N.B.: If both options and data+path are defined, the options passed will be overwritten by the ones coming from data
  • placeholder: string - Placeholder if no option is selected
  • format: function - Function that trasforms the options in the desired HTML format.
    • If the Select is using the property "options" to display the data, the function will be called for each option and have as an argument just the option itself.
    • If the Select is extracting the options from the data, then the function will be called once for every object of data (with arguments the value of the current object in the specified path and the object itself), make values unique and then save them in the "options" variable.
  • multiple: boolean - Allow selections of multiple options. Default: false
  • width: number - Set the width of Select
  • selected: Array | string - The currently selected options. Will be an array if multiple is set, otherwise just a string.

Auth

A component that displays slotted content within if any role of the current user matches his scope

Example

<script>
import { Auth } from '@bizmate-oss/sveltekit-components';

let user_roles = ["user", "manager"];

</script>
<Auth allow="manager,admin" roles={user_roles}>
  <p>You can only see this if you're a manager or an admin</p>
</Auth>

Configuration

  • allow: string | Array of Strings - The roles that are granted access to the slotted resorce. If using a string, concatenate multiple roles using ,
  • roles: Array of Strings - The current user roles

Navbar

Svelte configurable navbar built on bootstrap navbar, with child component NavItem Bootstrap must be installed in the project for this component to work

Example

<script>
import { Navbar, NavItem } from '@bizmate-oss/sveltekit-components';
import { page } from '$app/stores';

</script>

<Navbar {vertical} pills>
    <NavItem href="/" active={$page.route.id == '/'}>Home</NavItem>
    <NavItem href="/settings" active={$page.route.id.startsWith('/settings')}>Settings</NavItem>
</Navbar>

Configuration

  • Navbar:
    • vertical: Boolean - Place the navbar vertically
    • pills: Boolean - Use pills style
    • tabs: Boolean - Use tabs style
    • fill: Boolean - Fill width of container
    • class: - DOM classes
    • style: inline style
  • NavItem:
    • href: String - Reference to navigation page
    • active: Boolean - If the current element is the current active element

Dropdown

Svelte configurable dropdown built on bootstrap dropdown, with child component DropdownItem Bootstrap must be installed in the project for this component to work

Example

<script>
import { Dropdown, DropdownItem } from '@bizmate-oss/sveltekit-components';
import { faker } from '@faker-js/faker';

let user = {
    email: faker.internet.email(),
    name: faker.name.firstName(),
    tenant: faker.company.name(),
    profile: '/',
}

</script>

<Dropdown custom class="me-2">
  <div slot="toggler">
    <div class="d-flex align-items-center">
      <i class="d-none d-md-inline bi-three-dots-vertical"></i>
    </div>
  </div>
  <DropdownItem header>Actions</DropdownItem>
  <DropdownItem href='/test'>Action</DropdownItem>
  <DropdownItem divider />
  <DropdownItem href="/logout">Logout</DropdownItem>
</Dropdown>

</script>

Configuration

  • custom: Boolean - Custom toggler. Places a instead of using the default toggler
  • split: Boolean - Make a split dropdown with two buttons
  • title: String - Button Title if using default toggler
  • dark: Boolean - Dropdown dark style
  • direction: String - Direction in which the dropdown will be displayed relatively to its trigger button. Possible values: up | right | left | down (default)
  • class - DOM classes
  • style - inline style

Percentage

Shows the value property as a percentage and adds increase/decrease icon, configurable font size

Example

<script>
import { Percentage } from '@bizmate-oss/sveltekit-components';

let value = 4.5
</script>

<Percentage {value} fontSize="3rem">

Configuration

  • value: Number - Current percentage value
  • fontSize: String - Text font-size. The space occupied by the component and the icon's dimensions will be calculated accordingly. Supported size units: px | pt | em | rem