# Usage

## Basic Initialization

After including the library, initialize the `Blocker` to start protecting your forms:

```javascript
import { Blocker } from "disposable-email-blocker";

// Initialize with default settings
new Blocker();
```

Alternatively, if included via a CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/disposable-email-blocker/disposable-email-blocker.min.js"></script>
<script>
  new Disposable.Blocker();
</script>
```

## Customizing Error Messages

You can customize the error messages displayed when a disposable or webmail email is detected:

```javascript
new Blocker({
  messages: {
    disposable: "Disposable email addresses are not allowed.",
    webmail: "Please use your professional email address.",
  },
});
```

## Blocking Webmail Services

By default, the blocker focuses on disposable email services. To extend protection to webmail services (e.g., Gmail, Yahoo), enable the `blockWebmail` option:

```javascript
new Blocker({
  blockWebmail: true,
});
```

## Blocker options

Blocker constructor options.

```javascript
const options = {
  apiUrl: "string",
  data: "TombaStatusResponse[]",
  disposable: {
    message: "string",
  },
  webmail: {
    message: "string",
    block: false,
  },
  emailError: {
    className: "string",
    style: `string`,
  },
};
new Disposable.Blocker(options);
```

## Custom API URL

```javascript
const options = {
  apiUrl: "string",
};
new Disposable.Blocker(options);
```

## Custom DATA

Use this to skip API calls and rely on local data only.

```javascript
const options = {
  data: [
    {
      domain: "coronafleet.com",
      webmail: true,
      disposable: false,
    },
  ],
};
new Disposable.Blocker(options);
```

## Event

Use the `on()` API method.
Available event name: `done`. It fires after input is processed.

```javascript
const blocker = new Blocker();
blocker.on("done", (e) => {
  if (e.detail.disposable) {
    alert(blocker.options.disposable.message);
  }
});
```
