9.0.10 • Published 17 days ago

@exmg/exmg-form v9.0.10

Weekly downloads
83
License
MIT
Repository
github
Last release
17 days ago

<exmg-button> Published on npm

exmg-form

The Exmg Form enhances form design by offering a more intuitive layout visualization, streamlining the user experience with several key features. These include:

  • Automated form validity checks, ensuring data integrity.
  • Dynamic submit button control, which enables or disables the button based on form completeness.
  • JSON output capability, allowing for easy data serialization and integration.
  • A loading spinner, providing a visual indicator for asynchronous form submissions.

Installation

npm install @exmg/exmg-form

Example Usage

Text

<exmg-form class="has-aside" @dialog-submit="${doFormAction}">
  <div slot="toolbar" class="toolbar"><div class="title">Create contact</div></div>
  <form>
    <div class="row">
      <md-filled-text-field name="firstname" dialogFocus label="First Name" required></md-filled-text-field>
      <md-filled-text-field name="lastname" label="Last Name" required></md-filled-text-field>
    </div>
    <div class="row">
      <md-filled-text-field name="company" label="Company"></md-filled-text-field>
      <md-filled-text-field name="amount" label="Amount" type="number" min="0" max="10"></md-filled-text-field>
    </div>
    <md-filled-text-field
      name="email"
      label="Email"
      pattern="[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,4}$"
      required
    ></md-filled-text-field>
    <md-filled-text-field name="phone" label="Phone" required></md-filled-text-field>
  </form>
  <div slot="aside">
    Ex Machina will send notices about the Data <a href="#">Processing Terms</a> and EU General Data Protection
    Regulation to your primary contact. If your organization has a data protection officer or an EU representative, add
    their contact information.
  </div>
</exmg-form>
   async function doFormAction(e: CustomEvent<unknown>) {
    const formDialog = e.target as ExmgForm;
    try {
      formDialog.submitting = true;
      // Do server call
      // Show success message
    } catch (error) {
      console.error(error instanceof Error ? error.message : 'Unknown error');
    } finally {
      formDialog.submitting = false;
    }
  }

API

Properties/Attributes

NameTypeDefaultDescription
submitBtnstringSaveSubmit button copy
cancelBtnstringCancelCancel button copy
submittingbooleanfalseIndicated form submit in progress and disables the button
hasAsideContentbooleanfalseIndicated if form has a side help section

For other options see the m3 docs:

Additional references

9.0.9

17 days ago

9.0.10

17 days ago

9.0.8

1 month ago

9.0.7

1 month ago

9.0.6

2 months ago

9.0.5

2 months ago

9.0.4

3 months ago

9.0.3

3 months ago

9.0.1

3 months ago

8.1.40

5 months ago

8.1.37

8 months ago

8.1.36

10 months ago

8.1.39

6 months ago

8.1.38

7 months ago

8.1.31

11 months ago

8.1.33

11 months ago

8.1.32

11 months ago

8.1.35

11 months ago

8.1.20

2 years ago

8.1.22

2 years ago

8.1.24

2 years ago

8.1.23

2 years ago

8.1.17

2 years ago

8.1.9

2 years ago

8.1.11

2 years ago

8.1.10

2 years ago

8.1.13

2 years ago

8.1.12

2 years ago

8.1.15

2 years ago

8.1.14

2 years ago

8.1.16

2 years ago

8.1.0

3 years ago

8.0.1

3 years ago

8.0.2

3 years ago

8.0.0

3 years ago

3.0.1

3 years ago

3.0.0

4 years ago

2.2.5

4 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.2

4 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago