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

seidr-react

v1.2.15

Published

A react component library for Seidr

Downloads

24

Readme

Seidr React

A react component library for Seidr.

Publish package on NPM npm version

Usage

Seidr React provides react components and hooks to interact with Seidr's features.

Prerequisites

You have seidr running? Good. All you need is to install Seidr React and leverage its components. We highly recommend using pnpm over npm.

Development

  • Install dependencies[^install_dependencies]:
    • Run pnpm ci, if you want to install the current version without any changes.
    • Run pnpm i, if you intend to update/change dependencies or the version.
  • Run: pnpm run storybook

Configuration

Basic

To leverage Seidr React wrap your react application with SeidrProvider. SeidrProvider has several props, of which baseUrl is the most important. Set it to your Seidr backend URL. If not set, SeidrProvider will assume the baseUrl to be window.location.origin.

SeidrProvider

| prop | value | description | |---------------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| | baseUrl | string | The base URL of your Seidr application. (Example: www.domain.com/api/v1) | | theme | object: MantineThemeOverride | A theme object to style Seidr components (e.g. DataGrid) globally | | inheritMantineTheme | boolean | Determines if a MantineTheme from an outer scope should be merged with Seidr's default theme or the MantineTheme provided (see theme property) |

Components and Hooks

You now can use Seidr React's components and hooks anywhere in the application.

Hooks

useSeidrInfo

Provides the baseUrl and information from Seidr's SeidrInfo throughout your application. SeidrInfo data will automatically retrieved, once the user is authenticated.

useSeidrTheme

Provides the merged MantineTheme throughout your application.

useSeidrAuth

Provides user, error, loading, signin, signout, update, resetPassword to interact with ** Seidr's** authentication functionality. This hook will also trigger a rerender when user, error and loading change (react lifecycle).

useApi[^inside_seidr_api_provider]

Provides path, data, info, queryParams, loading, error, setQueryParams, getEntry, addEntry , updateEntry, deleteEntry to interact with Seidr's BaseModelRestApi. Setting queryParams via setQueryParams will trigger an update of data.

Components

UserMenu

Creates a dropdown according to Mantine's menu. The dropdown includes links to react-router routes with the following paths:

  • /users
  • /roles
  • /permissions
  • /viewmenus
  • /permissionviews

These paths will be appended to the provided basePath.

| prop | value | description | |----------|-----------|-------------------------------------------------------------------------------------------| | basePath | string | Determines the base path to append the routes' paths to, defaults to /security | | Target | ReactNode | A react element to render instead of the default button | | children | ReactNode | A set of mantine's Menu.Divider, Menu.Label and Menu.Item to append to the dropdown |

SeidrApiProvider

SeidrApiProvider interacts with Seidr's BaseModelRestApi. Path should be the same as resource_name used in BaseModelRestApi.

| prop | value | description | |--------------------|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | path | string | The path segment to add to the baseUrl provided to SeidrProvider. The resulting url should point to a valid Seidr base route. Will ignore baseUrl, if it is a URL. | | relation | object: Relation | A base filter to apply (currently used in the context of RelatedAPIs) | | initialQueryParams | object: QueryParams | Set initial query parameters |

DataGrid[^inside_seidr_api_provider]

A feature rich table component that leverages useApi internally. Use this, if you don't want to implement your own table.

| prop | value | description | |------------------|------------------------|-------------------------------------------------------------------------------------------------------| | hideToolbar | boolean | Hide toolbar, the toolbar is the upper section containing Settings, Add and Filter | | hideFilter | boolean | Hide filters | | hideSettings | boolean | Hide settings | | hideError | boolean | Hide error modal when a customized error modal is necessary | | hideActions | boolean | Hide Action column on every row > | | hidePagination | boolean | Hide Pagination | | hideAdd | boolean | Hide add button from toolbar | | settings | object: Settings | Style settings | | rowsPerPageProps | number | Externally control page size | | fetchOnMount | boolean | Determines if the table should trigger a data fetch on mount, defaults to true | | onSelectEntry | function | Callback to be fired on entry selection | | styles | object: DataGridStyles | Interface to style DataGrid (based on Mantine's StylesAPI) |

Quick Filter

| prop | value | description | |------|--------|--------------------------------------------------------------| | name | string | Name of the quick filter to leverage provided by the backend |

CheckBoxGroup[^mantine_checkbox_group_props]

Creates a Mantine Checkbox.Group based on a quick filter of the type multiselect that creates a new filter of the type {col: <quickfilter.column>, opr: 'in', value: } (FilterIn) if it doesn't exist, else updates it.

MultiSelect[^mantine_multiselect_props]

Creates a Mantine MultiSelect based on a quick filter of the type multiselect that creates a new filter of the type {col: <quickfilter.column>, opr: 'in', value: } (FilterIn) if it doesn't exist, else updates it.

Select[^mantine_select_props]

Creates a Mantine Select based on a quick filter of the type select that creates a new filter of the type {col: <quickfilter.column>, opr: 'eq', value: } (FilterEqual) if it doesn't exist, else updates it.

Authentication

useSeidrAuth assumes the presence of AuthApi provided by Seidr in your backend. Given this and correctly set paths, you gain the full capability of a session based authentication feature which has the same (except OIDC) functionality as Flask Appbuilder's

Styling

Seidr React provides the same StylesAPI as on Mantine.

[^install_dependencies]: pnpm i will update pnpm-lock.yaml if changes occured, while pnpm ci will wipe your node_modules folder and install dependencies only from pnpm-lock.yaml [^inside_seidr_api_provider]: Can only be used inside of SeidrApiProvider. [^mantine_checkbox_group_props]: Also supports any prop for Mantine's CheckBox.Group [^mantine_multiselect_props]: Also supports any prop for Mantine's MultiSelect [^mantine_select_props]: Also supports any prop for Mantine's Select