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

majra

v0.4.16

Published

<div align="center"> <img src="https://user-images.githubusercontent.com/37629053/136436193-098d6531-570c-4d67-9b6a-bb881bf063c0.png" alt="majra"> </div> <p align="center"> <img src="https://img.shields.io/badge/vue.js-2.6-green" alt="vue">

Downloads

465

Readme

About Majra

Majra is a tool for quickly creating CRUD UI & forms. Make your components reusable by majra.

  • Powerful form generator
  • Lots of ready fields
  • Simplicity in usage
  • Extendable
  • static friendly

Install Majra

npm i --save majra

in vue applications

import Vue from "vue";
import Majra from "majra";

Vue.use(Majra, {
  store, // your store instance
  configs: {},
});

in nuxt applications

import Vue from "vue";
import Majra from "majra";

export default async ({ store }) => {
  Vue.use(Majra, {
    store,
    configs: {},
  });
};

Usage

simple example

<template>
  <DynamicTemplate />
</template>

<script>
import { DynamicTemplate } from "majra";

export default {
  components: {
    DynamicTemplate,
  },

  beforeCreate() {
    this.$majra.init({
      mainRoute: "/product",
      relations: [{ route: "/get-menus-list", key: "Menu" }],
      fields: [
        {
          title: "Product name", // title of field that shows in form and table
          field: "name", // the key of data
          type: "text", // type of field (uses majra textField)
          isHeader: true, // show this field in table
        },
        {
          title: "Menu",
          field: "menu",
          sendKey: "menu_id", // you can change your key when sending the form by sendKey
          type: "select",
          rel: {
            model: "Menu", // the key of data that returns from api call
          },
          props: {
            "item-text": "title",
            "item-value": "id",
          },
          isHeader: true,
        },
      ],
    });
  },
};
</script>

You can also use the form builder

<template>
  <DynamicForm :form="form" :fields="fields" />
</template>

<script>
import { DynamicForm } from "majra";

export default {
  components: {
    DynamicForm,
  },
  data: () => ({
    fields: [
      {
        title: "Product name",
        field: "name",
        type: "text",
      },
      {
        title: "Menu",
        field: "menu",
        sendKey: "menu_id",
        type: "select",
        rel: {
          model: "Menu", // the key of data that returns from api call
        },
        props: {
          "item-text": "title",
          "item-value": "id",
        },
      },
    ],
  }),
};
</script>

How create a field

jsut extend AbstractField from majra and make your field, when you extend AbstractField then necessary data and methods will be available.

<template>
  <div>
    <input :value="value" @input="updateField($event)"/>
  <div>
</template>

<script>
  import {AbstractField} from 'majra';

  export default {
    extends: AbstractField,
  }
</script>

How use it

Just import your component and use it

import YourTextField from "./YourTextField.vue";

export default {
  beforeCreate() {
    this.$majra.init({
      mainRoute: "/product",
      fields: [
        {
          title: "Product name",
          field: "name",
          type: "text",
          component: YourTextField, // this field will replace by YourField
          isHeader: true,
        },
      ],
    });
  },
};

License

The Majra is open-sourced software licensed under the MIT license.