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

instaui

v0.0.7

Published

`instaui` is a zero-code CRUD UI generator for React, designed to create a full-featured CRUD interface from any RESTful API with minimal configuration. With fabric-ui, developers can instantly render entity management views by simply passing in API clien

Downloads

365

Readme

instaui

⚠️ Notice: This package is currently under development and is in beta. Features and functionality may change. Use it at your own risk, and feel free to contribute or report issues!

instaui is a zero-code CRUD UI generator for React, allowing you to create fully functional CRUD interfaces from any REST API with minimal setup. By simply passing in an API client and configuration object, instaui dynamically renders all necessary CRUD components and actions, saving you from writing repetitive code.

Features

  • 🛠️ Instant CRUD UI: Generate CRUD interfaces by defining an API endpoint and config details.
  • 📄 Server-side Pagination: Efficiently handles large datasets using server-side pagination.
  • 🔗 Relation Management: Supports related entities, seamlessly linking them within the UI.
  • ✏️ Built-in Validation: Define custom validators for each field in the config.
  • 🚀 Ant Design Integration: Uses Ant Design's Drawer and components for a polished UI out of the box.
  • 🔄 Routing & Breadcrumbs: Integrated routing and breadcrumb support for easy navigation.

Installation

Install instaui with npm or Yarn:

npm install instaui
# or
yarn add instaui

Usage

To get started, import instaui and provide it with the required configuration props.

Basic Setup

import React from 'react';
import Instaui from 'instaui';
import axios from 'axios';

const apiClient = axios.create({
  baseURL: 'https://example.com/api',
  headers: { Authorization: 'Bearer your-token' },
});

const userConfig = {
  entity: "users",
  endpoint: "/users",
  keys: [
    {
      key: "fname",
      label: "First Name",
      type: "Text",
      validator: "name",
      creatable: true,
      editable: true,
    },
    {
      key: "lname",
      label: "Last Name",
      type: "Text",
      validator: "name",
      creatable: true,
      editable: true,
    },
    {
      key: "email",
      label: "Email",
      type: "Text",
      validator: "email",
      creatable: true,
      editable: false,
    },
    {
      key: "photo",
      label: "Photo",
      type: "File",
      validator: "image",
      creatable: true,
      editable: false,
      hideInListView: true,
    },
    {
      key: "card",
      label: "Card",
      type: "relation",
      target: "card",
      path: "/cards",
      identifier: "cardId",
    },
  ],
};

function App() {
	const validators = {
			email: (v) => /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/.test(v)
				? [true, ""]
				: [false, "Invalid email format"],
			name: (v) => v.length >= 2 ? [true, ""] : [false, "Name too short"],
		};
  return (
    <Instaui config={userConfig} client={apiClient} validators={validators}/>
  );
}

export default App;

Props

| Prop | Type | Description | |--------------|-----------------|------------------------------------------------------------------------------------------------------| | config | object | Configuration object defining the entity, fields, validation, and relation details. | | client | AxiosInstance | The axios instance for handling API calls, including authentication headers. | | validators | object | Custom validation functions for fields. Validators should return [true, ""] or [false, "Error"]. |

Example Config

The config prop defines the fields and behavior of each CRUD component. Here’s an example config:

{
  "entity": "users",
  "endpoint": "/users",
  "keys": [
    {
      "key": "fname",
      "label": "First Name",
      "type": "Text",
      "validator": "name",
      "creatable": true,
      "editable": true
    },
    {
      "key": "lname",
      "label": "Last Name",
      "type": "Text",
      "validator": "name",
      "creatable": true,
      "editable": true
    },
    {
      "key": "email",
      "label": "Email",
      "type": "Text",
      "validator": "email",
      "creatable": true,
      "editable": false
    },
    {
      "key": "photo",
      "label": "Photo",
      "type": "File",
      "validator": "image",
      "creatable": true,
      "editable": false,
      "hideInListView": true
    },
    {
      "key": "card",
      "label": "Card",
      "type": "relation",
      "target": "card",
      "path": "/cards",
      "identifier": "cardId"
    }
  ]
}

Validators

Define custom validation functions in the validators prop. Each validator should return a tuple with a boolean and an error message:

validators = {
  email: (value: string) => /^[\w-]+@([\w-]+\.)+[\w-]{2,4}$/.test(value)
    ? [true, ""]
    : [false, "Invalid email format"],
  name: (value: string) => value.length > 1
    ? [true, ""]
    : [false, "Name too short"],
}

Example with Relations

Define relations in the config to handle foreign entities. The relation type field will make requests to the specified path and populate options in a dropdown.

Components

  • Create: Handles creating a new entity.
  • Edit: Allows in-line and modal-based editing of fields.
  • Delete: Enables single-click deletion with confirmation.
  • Detail View: Displays additional details in a Drawer for fields hidden in list view.

Contributing

We welcome contributions to instaui. Please see our contribution guidelines for more information.


License

This project is licensed under the MIT License.