# majra

Latest version **0.4.20** (published 2025-02-28) · 0 weekly downloads

## Install

```sh
npm install majra
pnpm add majra
yarn add majra
bun add majra
```

## Health

**Score 20/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.20 |
| Published | 2025-02-28 |
| First published | 2021-09-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 182.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | hosseinjarrahi |

## Links

- npm: https://www.npmjs.com/package/majra
- npm.io page: https://npm.io/package/majra

## Dependencies (6)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [leaflet](https://npm.io/package/leaflet.md) ^1.7.1
- [vue-json-csv](https://npm.io/package/vue-json-csv.md) ^1.2.12
- [vuedraggable](https://npm.io/package/vuedraggable.md) ^2.24.3
- [vue-avatar-cropper](https://npm.io/package/vue-avatar-cropper.md) ^2.0.0
- [vue-persian-datetime-picker](https://npm.io/package/vue-persian-datetime-picker.md) ^2.10.0

## Recent versions

- 0.4.20 (latest) — 2025-02-28
- 0.4.19 — 2025-02-22
- 0.4.18 — 2025-02-22
- 0.4.16 — 2024-09-15
- 0.4.15 — 2024-09-11
- 0.4.14 — 2024-09-01
- 0.4.13 — 2024-08-05
- 0.4.12 — 2024-07-22
- 0.4.11 — 2024-07-22
- 0.4.10 — 2024-07-22
- 0.4.9 — 2024-07-10
- 0.4.8 — 2024-07-06
- 0.4.7 — 2024-06-24
- 0.4.5 — 2024-06-24
- 0.4.4 — 2024-06-15
- … 123 more at https://npm.io/package/majra/versions

## README

<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">
    <img src="https://img.shields.io/badge/vuetify-2.5-blue" alt="vue">
</p>

<h2 align="center">
 Don't waste time for configuration 🎯 Just focus on your logic
</p>

## 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

```shell
npm i --save majra
```

in vue applications

```js
import Vue from "vue";
import Majra from "majra";

Vue.use(Majra, {
  store, // your store instance
  configs: {},
});
```

in nuxt applications

```js
import Vue from "vue";
import Majra from "majra";

export default async ({ store }) => {
  Vue.use(Majra, {
    store,
    configs: {},
  });
};
```

## Usage

simple example

```vue
<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>
```

<div align="center">
    <img width="600" src="https://user-images.githubusercontent.com/37629053/136450704-61316d64-5185-437e-92dc-df5309804d8d.png" />
</div>

You can also use the form builder

```vue
<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.

```vue
<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

```js
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](https://opensource.org/licenses/MIT).

---
_Source: https://npm.io/package/majra · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
