react-multi-email icon indicating copy to clipboard operation
react-multi-email copied to clipboard

Support enable flag

Open jopemachine opened this issue 5 years ago • 2 comments

Changes

  • Support enable flag

Notes

I tested this after removing node-sass due to node-sass issue.

Please let me know if node-sass should be removed from dev-dependency.

Manual Test

Test code


  enableToCreateEmail({ emailCnt }: { emailCnt: number }) {
    if (emailCnt < 2) {
      return true;
    }
    return false;
  };

  onRejectHandler() {
    alert("Reached max email count");
  }

  render() {
    const { emails } = this.state;

    return (
      <>
        <form>
          <h3>Email</h3>
          <ReactMultiEmail
            placeholder="Input your email"
            emails={emails}
            onChange={(_emails: string[]) => {
              this.setState({ emails: _emails });
            }}
            enable={this.enableToCreateEmail}
            onDisabled={this.onRejectHandler}
            getLabel={(
              email: string,
              index: number,
              removeEmail: (index: number) => void,
            ) => {
              return (
                <div data-tag key={index}>
                  <div data-tag-item>
                    {email}
                  </div>
                  <span data-tag-handle onClick={() => removeEmail(index)}>
                    ×
                  </span>
                </div>
              );
            }}
          />
          <br />
          <h4>react-multi-email value</h4>
          <p>{emails.join(', ') || 'empty'}</p>
        </form>
      </>
    );

Result

Sep-17-2020 17-12-51

When I tried to add more than two emails, the callback function I specified was executed.

jopemachine avatar Sep 17 '20 08:09 jopemachine

Merge!!!

rishav394 avatar Feb 04 '21 10:02 rishav394

Merge!!!

I'm not sure this repository is still managed.

So, I made a forked version of this repository.

https://www.npmjs.com/package/@jopemachine/react-multi-email

This version support below additional features

This version could be removed when the above PRs are merged or close.

jopemachine avatar Feb 12 '21 09:02 jopemachine