2.6.0 • Published 2 months ago

@deltablot/malle v2.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

malle

Edit in place library with no dependencies and small footprint.

validate npm version GitHub license

Description

malle allows you to listen to a particular event (e.g. click, hover) on an element (e.g. p, span) and transform that element into an input that will be processed by a function.

The event can be: click or hover.

The element can be a p, div, span, ...

The created input can be a normal input or a textarea.

The user provided function will typically POST to an endpoint to get some JSON back.

Demo

Live demo: https://deltablot.github.io/malle/

Installation

npm i @deltablot/malle
# or
yarn add @deltablot/malle

Quickstart

This is a minimal example:

import { Malle } from '@deltablot/malle';

// now create the malle
const malle = new Malle({
  // this is the function that will be called once user has finished entering text (press Enter or click outside)
  // it receives the new value, the original element, the event and the input element
  fun: (value, original, event, input) => {
    console.log(`New text: ${value}`);
    console.log(`Original element:`);
    console.log(original);
    // add here your code for POSTing the new value
    return myFunctionReturingAPromiseString();
  },
}).listen(); // directly start listening after object creation

In this example, when a user clicks on an element with data-malleable='true', the function in the fun option will be called. The element will be replaced by a form containing the input and optionally action buttons (Submit, Cancel).

Head to the Demo to see more examples.

See the API Documentation for usage and available options.

Maintenance status

malle is currently MAINTAINED and used in production environments.

Contributing

See contributing documentation.

License

This software is open source and licensed under the MIT License.

2.6.0

2 months ago

2.5.2

6 months ago

2.5.1

6 months ago

2.3.0

1 year ago

2.5.0

11 months ago

2.4.0

11 months ago

2.4.2

11 months ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.0.1

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago