1.0.80 • Published 3 days ago

@bizmate-oss/sveltekit-components v1.0.80

Weekly downloads
-
License
-
Repository
-
Last release
3 days ago

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 rowsn.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
1.0.80

3 days ago

1.0.77

10 days ago

1.0.79

10 days ago

1.0.78

10 days ago

1.0.76

29 days ago

1.0.75

29 days ago

1.0.74

30 days ago

1.0.73

5 months ago

1.0.72

5 months ago

1.0.62

6 months ago

1.0.61

6 months ago

1.0.60

6 months ago

1.0.66

6 months ago

1.0.65

6 months ago

1.0.64

6 months ago

1.0.63

6 months ago

1.0.69

6 months ago

1.0.68

6 months ago

1.0.67

6 months ago

1.0.71

6 months ago

1.0.70

6 months ago

1.0.48

10 months ago

1.0.47

10 months ago

1.0.46

10 months ago

1.0.45

10 months ago

1.0.49

10 months ago

1.0.51

10 months ago

1.0.50

10 months ago

1.0.55

8 months ago

1.0.54

8 months ago

1.0.53

8 months ago

1.0.52

10 months ago

1.0.59

6 months ago

1.0.58

6 months ago

1.0.57

6 months ago

1.0.56

8 months ago

1.0.44

11 months ago

1.0.43

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.2

1 year ago

1.0.1

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

1.0.3

1 year ago

0.0.70

1 year ago

0.0.71

1 year ago

0.0.72

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.34

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.66

1 year ago

0.0.67

1 year ago

0.0.68

1 year ago

0.0.69

1 year ago

0.0.61

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.55

1 year ago

0.0.50

1 year ago

0.0.48

2 years ago

1.0.11

2 years ago

0.0.49

2 years ago

0.0.6

1 year ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.4

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.3

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago