# sham-ui-macro

> Babel macros for sham-ui

Latest version **3.6.0** (published 2021-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install sham-ui-macro
pnpm add sham-ui-macro
yarn add sham-ui-macro
bun add sham-ui-macro
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.6.0 |
| Published | 2021-10-27 |
| First published | 2019-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sham |
| Maintainers | shamcode |
| Keywords | babel-macros, errors, debug |

## Links

- npm: https://www.npmjs.com/package/sham-ui-macro
- Repository: https://github.com/sham-ui/sham-ui-macro
- Homepage: https://github.com/sham-ui/sham-ui-macro#readme
- Issues: https://github.com/sham-ui/sham-ui-macro/issues
- npm.io page: https://npm.io/package/sham-ui-macro

## Dependencies (3)

- [babel-types](https://npm.io/package/babel-types.md) ^6.26.0
- [babel-macros](https://npm.io/package/babel-macros.md) ^1.0.2
- [babel-generator](https://npm.io/package/babel-generator.md) ^6.26.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 3.6.0 (latest) — 2021-10-27
- 3.5.0 — 2021-07-05
- 3.4.0 — 2021-06-29
- 3.3.0 — 2021-06-03
- 3.2.0 — 2021-05-21
- 3.1.0 — 2021-05-19
- 3.0.0 — 2021-04-27
- 2.0.0 — 2021-04-15
- 1.1.0 — 2020-12-24
- 1.0.0 — 2019-10-14

## README

# sham-ui-macro

[![Build Status](https://travis-ci.com/sham-ui/sham-ui-macro.svg?branch=master)](https://travis-ci.com/sham-ui/sham-ui-macro)
[![npm version](https://badge.fury.io/js/sham-ui-macro.svg)](https://badge.fury.io/js/sham-ui-macro)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)

Babel macros for `sham-ui`.

### Install

Install from yarn:
`yarn add sham-ui-macro --dev`

And add `babel-macros` plugin to your babel config. 

### ref

Add to to `package.json` 

-   for app for `dev` envrimonent

```json
"babelMacros": {
  "ref": {
    "uniq": false,
    "enabled": true
  }
}
```

-   for app for `prod` envrimonent

```json
"babelMacros": {
  "ref": {
    "uniq": true,
    "enabled": true
  }
}
```

-   for library

```json
"babelMacros": {
  "ref": {
    "enabled": false
  }
}
```

### API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

##### Table of Contents

-   [inject](#inject)
    -   [Parameters](#parameters)
    -   [Examples](#examples)
-   [$](#)
    -   [Parameters](#parameters-1)
    -   [Examples](#examples-1)
-   [this$](#this)
    -   [Parameters](#parameters-2)
    -   [Examples](#examples-2)

#### inject

Macro for `DI.resolve`

##### Parameters

-   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Name of injected item

##### Examples

```javascript
import { inject } from 'sham-ui-macro/inject.macro';
class Service {
    @inject api;
    @inject( 'sham-ui:store' ) uiStore;
}


// ↓ ↓ ↓ ↓ ↓ ↓

class Service {
   get api() {
       return this.DI.resolve('api');
   }

   get uiStore() {
       return this.DI.resolve('sham-ui:store');
   }

}
```

#### $

Macro for get/generate uniq reference

##### Parameters

-   `name` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object))?** Name of reference  or object for processing

##### Examples

```javascript
// Config in package.json
// "babelMacros": {
//   "ref": {
//     "enabled": true,
//     "uniq": true
//   }
// }

import { $ } from 'sham-ui-macro/ref.macro';

const firstName = $();
const lastName = $.lastName;
const state = {
    [ firstName ]: 'John',
    [ lastName ]: 'Smith'
}
const fullName = state[ $( 'firstName' ) ] + state[ $.lastName ];
const user = $( { firstName: 'John', lastName: 'Smith' } );

// ↓ ↓ ↓ ↓ ↓ ↓

const firstName = 0;
const lastName = 1;
const state = {
    [ firstName ]: 'John',
    [ lastName ]: 'Smith'
}
const fullName = state[ 0 ] + state[ 1 ];
const user = { 0: 'John', 1: 'Smith' };
```

#### this$

Sugar for $ macro. Translate `this$.foo` to analog `this[ $.foo ]`

##### Parameters

-   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Name of reference

##### Examples

```javascript
// Config in package.json
// "babelMacros": {
//   "ref": {
//     "enabled": true,
//     "uniq": true
//   }
// }

import { this$ } from 'sham-ui-macro/ref.macro';

this$.handleClick = e => { };

// ↓ ↓ ↓ ↓ ↓ ↓

this[ 0 ] = e => {};
```

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