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

gtrnpm

v0.1.0

Published

gtrnpm package

Downloads

1

Readme

empeek.utils.react-admin

Utilitary helpers for react-admin applications. It's private package, supported by Empeek team.

Installation

npm install empeek.utils.react-admin

#or

yarn add empeek.utils.react-admin

Documentation

MultiColumnForm

Includes a set of components for constructing a form, built using Material UI Tabs component. Unlike TabbedForm component provided by react-admin, MultiColumnForm does not include Toolbar with SaveButton by default, but has a more flexible layout and better customization options.

Basic Usage:

import React from 'react';
import { MultiColumnForm, Content } from 'empeek.utils.react-admin';
import { TextInput, NumberInput } from 'react-admin';
export default props => (
  <MultiColumnForm {...props}>
    <Content position="main">
      <NumberInput source="id" label="ID" />
      <TextInput source="name" label="Name" />
    </Content>
  </MultiColumnForm>
);

Usage with Tabs:

import React from 'react';
import { MultiColumnForm, Content, FormTab } from 'empeek.utils.react-admin';
import { TextInput, NumberInput } from 'react-admin';
export default props => (
  <MultiColumnForm {...props}>
    <Content position="main">
      <NumberInput source="id" label="ID" />
      <TextInput source="name" label="Name" />
    </Content>
    <Content position="bottom">
      <FormTab label="Notes">
        <TextInput source="notes" label="Notes" />
      </FormTab>
      <FormTab label="Contact details">
        <TextInput source="phone" label="phone" />
        <TextInput source="email" label="email" />
      </FormTab>
    </Content>
  </MultiColumnForm>
);

Tip: FormTab expects a child, which can be in most cases Input type or Field type Component, but you can pass inside your own component with unique layout, it's totally up to you.

Content component available props:

  • position : Type: String. Available values: "main", "side", "bottom".

FormTab component available props:

  • label : Type: String. Used as Tab Name.
  • icon : Type: Element. You can easily set icon from collection of Material UI icons

TableFormIterator

Component allows editing of arrays, inside in record. For example tags array inside in post record:

{
  id: 123;
  tags: [
    {
      id: 0,
      name: 'Sport',
    },
    {
      id: 1,
      name: 'Music',
    },
  ];
}

Component displays an array of fields in an table (<table>), one sub-form by table row (<tr>). It also provides controls for adding and removing a sub-record. Built using Material UI table conponents.

Usage:

import React from 'react';
import { DisabledInput, TextField, NumberField } from 'react-admin';
import { TableFormIterator } from 'empeek.utils.react-admin';

export default props => (
  <ArrayInput source="tags">
    <TableFormIterator>
      <NumberField source="id" label="ID" />
      <TextField source="name" label="Name" />
    </TableFormIterator>
  </ArrayInput>
);

Available props:

  • disableAdd : Type: Boolean. Disable ADD button. Default value false.
  • disableRemove Type: Boolean. Disable REMOVE button, bellow the table. Default value false.
  • tableRowDisable Type: Boolean. Style table row by adding red color.

Data Provider

Data Provider already includes credentials for API (Authorization header) and supports features needed for authentication refreshTokens. Data Provider it's function which receives three arguments:

  • fakeData - for testing purpose.
  • apiBaseUrl - string, which will be concat to your main entry point url.
  • apiAuthUrl - string, which will be concat to your main entry point url and used for auth requests.
  • saveTokens - func, receives data object, which contains all necessary credential info, like username and tokens. Must be same for authProvider.
  • clearTokens - func, removes credentials from local storage etc. Must be same for authProvider.

In you need to use dataProvider inside custom pages, use withDataProvider

Usage:

import React from 'react';
import { Admin, Resource } from 'react-admin';
import { dataProvider } from 'empeek.utils.react-admin';

const fakeData = {
  users: [
    id: 1,
    firstName: 'Jhon',
    lastName: 'Doe',
  ]
};

const apiBaseUrl = '/api';
const apiAuthUrl = `${apiBaseUrl}/token`;

const App = () => (
  <Admin
    title="My awesome application"
    dataProvider={dataProvider({ fakeData, apiBaseUrl, apiAuthUrl })}
  >
    <Resource name="users" />
  </Admin>
)

!Note Make sure you do not forget to specify the parameter 'proxy' in your package.json file. For example:

"proxy": "http://myawesomeapp.com",

After that dataProvider will send a request to the address http://myawesomeapp.com/api.

Auth Provider

AuthProvider supports authentication refresh tokens strategy and store user's credentials in local storage.

Issues

Sometimes you may encounter a problem when your UI on the production server is broken. The reason for this may be a collision of classnames. It may be happening because React-Admin and Material-UI using two independent counters for naming in production. You can find more info here:

https://stackoverflow.com/questions/50970625/react-admin-displays-very-messed-up

https://github.com/marmelab/react-admin/issues/1782

Modules

Roles

Pages

Login

Forgot Password

Reset Password

Change Password

Sign Up

HOC

requireAccessRights

Components

MenuItemLink