# akutil-common

> Utilities shared by AtlasKit components

Latest version **5.0.1** (published 2016-11-09) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install akutil-common
pnpm add akutil-common
yarn add akutil-common
bun add akutil-common
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2016-11-09 |
| First published | 2016-06-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Atlassian Pty Ltd |
| Maintainers | atlassian-aui |
| Keywords | atlaskit, ui |

## Links

- npm: https://www.npmjs.com/package/akutil-common
- Repository: https://bitbucket.org/atlassian/atlaskit
- Homepage: https://bitbucket.org/atlassian/atlaskit#readme
- npm.io page: https://npm.io/package/akutil-common

## Dependencies (3)

- [keycode](https://npm.io/package/keycode.md) ^2.1.2
- [create-error](https://npm.io/package/create-error.md) ^0.3.1
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.11.6

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 5.0.1 (latest) — 2016-11-09
- 5.0.0 — 2016-11-09
- 4.0.2 — 2016-11-08
- 4.0.1 — 2016-11-08
- 4.0.0 — 2016-11-07
- 3.0.0 — 2016-11-07
- 2.8.0 — 2016-10-19
- 2.7.1 — 2016-10-17
- 2.7.0 — 2016-10-13
- 2.6.3 — 2016-10-04
- 2.6.2 — 2016-09-29
- 2.6.0 — 2016-09-21
- 2.5.0 — 2016-09-17
- 2.4.4 — 2016-09-17
- 2.4.3 — 2016-09-08
- … 17 more at https://npm.io/package/akutil-common/versions

## README

[![AtlasKit component registry](https://img.shields.io/badge/AtlasKit-components-FF5230.svg)](http://aui-cdn.atlassian.com/atlaskit/registry/)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://Commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/GitHub-semantic_release-ffab00.svg)](https://github.com/semantic-release/semantic-release)
[![Report an issue](https://img.shields.io/badge/Report-an_issue-6554C0.svg)](https://ecosystem.atlassian.net/browse/AK)
[![Ask in our forum](https://img.shields.io/badge/Ask-in_our_forum-6554C0.svg)](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,akutil-common,akutil-common@5.0.1)

# AtlasKit common utilities

A set of common utilities for all AtlasKit components

## Classes

<dl>
<dt><a href="#KeyPressHandler">KeyPressHandler</a></dt>
<dd><p>A general class to deal with key activations</p>
</dd>
</dl>

## Functions

<dl>
<dt><a href="#computeBooleanValue">computeBooleanValue()</a></dt>
<dd><p>Like el.hasAttribute(attr) but designed for use within a skate attribute
change handler where you only have access to change.oldValue.</p>
</dd>
<dt><a href="#enumeration">enumeration()</a></dt>
<dd><p>This property extension can be used with skate.
  Usage:</p>
<pre><code>  props: {
      respondsTo: props.enum({values: [&#39;toggle&#39;, &#39;hover&#39;],
      missingDefault: &#39;toggle&#39;,
      invalidDefault: &#39;toggle&#39;})({

      })
  }
</code></pre></dd>
</dl>

<a name="KeyPressHandler"></a>

## KeyPressHandler
A general class to deal with key activations

**Kind**: global class  
* Methods

    *  [keyPressHandler.add(key, callback)](#KeyPressHandler+add)
    *  [keyPressHandler.destroy([key])](#KeyPressHandler+destroy)

<a name="new_KeyPressHandler_new"></a>

### new KeyPressHandler(key, callback, [elem])
Adds a new keypress handler


| Param | Type | Description |
| --- | --- | --- |
| key | <code>String</code> | A named key. Case insensitive. |
| callback | <code>function</code> | A callback function to invoke if the given key was activated.                            The callback is passed the event object. |
| [elem] | <code>Node</code> | The element to listen for the key activation.                       Defaults to document if none given. |

<a name="KeyPressHandler+add"></a>

### keyPressHandler.add(key, callback)
Adds or replaces a key that is listened for.

**Kind**: instance method of <code>[KeyPressHandler](#KeyPressHandler)</code>  

| Param | Type | Description |
| --- | --- | --- |
| key | <code>String</code> | A named key. Case insensitive. Replaces any previous listened key. |
| callback | <code>function</code> | The callback function to invoke. |

<a name="KeyPressHandler+destroy"></a>

### keyPressHandler.destroy([key])
Removes a key from the list of listened keys.
Or removes the whole listener if no key given.

**Kind**: instance method of <code>[KeyPressHandler](#KeyPressHandler)</code>  

| Param | Type | Description |
| --- | --- | --- |
| [key] | <code>String</code> | A named key. Case insensitive. If none given, event listener is removed. |

<a name="computeBooleanValue"></a>

## computeBooleanValue()
Like el.hasAttribute(attr) but designed for use within a skate attribute
change handler where you only have access to change.oldValue.

**Kind**: global function  
<a name="enumeration"></a>

## enumeration()
This property extension can be used with skate.
  Usage:
  ```
  props: {
      respondsTo: props.enum({values: ['toggle', 'hover'],
      missingDefault: 'toggle',
      invalidDefault: 'toggle'})({

      })
  }
  ```

**Kind**: global function  

## Support and feedback

### We're here to help!

Let us know what you think of our components and docs, your feedback is really important for us.

### Community support

Ask a question in our [forum](https://answers.atlassian.com/questions/ask?title=AtlasKit%3A%20&topics=atlaskit,akutil-common,akutil-common@5.0.1).

Check [if someone has already asked the same question before](https://answers.atlassian.com/questions/topics/42926171/atlaskit).


### Create a support ticket

Are you in trouble? [Let us know](https://ecosystem.atlassian.net/browse/AK)!

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