1.2.15 • Published 4 months ago

seidr-react v1.2.15

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

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

propvaluedescription
baseUrlstringThe base URL of your Seidr application. (Example: www.domain.com/api/v1)
themeobject: MantineThemeOverrideA theme object to style Seidr components (e.g. DataGrid) globally
inheritMantineThemebooleanDetermines 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.

propvaluedescription
basePathstringDetermines the base path to append the routes' paths to, defaults to /security
TargetReactNodeA react element to render instead of the default button
childrenReactNodeA 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.

propvaluedescription
pathstringThe 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.
relationobject: RelationA base filter to apply (currently used in the context of RelatedAPIs)
initialQueryParamsobject: QueryParamsSet 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.

propvaluedescription
hideToolbarbooleanHide toolbar, the toolbar is the upper section containing Settings, Add and Filter
hideFilterbooleanHide filters
hideSettingsbooleanHide settings
hideErrorbooleanHide error modal when a customized error modal is necessary
hideActionsbooleanHide Action column on every row >
hidePaginationbooleanHide Pagination
hideAddbooleanHide add button from toolbar
settingsobject: SettingsStyle settings
rowsPerPagePropsnumberExternally control page size
fetchOnMountbooleanDetermines if the table should trigger a data fetch on mount, defaults to true
onSelectEntryfunctionCallback to be fired on entry selection
stylesobject: DataGridStylesInterface to style DataGrid (based on Mantine's StylesAPI)
Quick Filter
propvaluedescription
namestringName 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

1.2.15

4 months ago

1.2.12

5 months ago

1.2.13

5 months ago

1.2.14

5 months ago

1.2.11

5 months ago

1.2.0

5 months ago

1.2.8

5 months ago

1.2.7

5 months ago

1.2.6

5 months ago

1.2.5

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.2.9

5 months ago

0.15.17

6 months ago

0.15.15

7 months ago

0.15.16

6 months ago

0.15.13

8 months ago

0.15.14

7 months ago

0.15.11

8 months ago

0.15.12

8 months ago

0.15.5

8 months ago

0.15.6

8 months ago

0.15.7

8 months ago

0.15.8

8 months ago

0.15.9

8 months ago

0.15.3

8 months ago

0.15.2

8 months ago

0.15.1

8 months ago

0.15.0

8 months ago

0.14.2

9 months ago

0.14.1

9 months ago

0.14.0

10 months ago

0.12.0

10 months ago

0.11.0

11 months ago

0.10.9

11 months ago

0.10.8

11 months ago

0.10.7

11 months ago