Skip to content

Releases: github/auto-check-element

v5.0.2

13 Dec 19:46
4554e7f
Compare
Choose a tag to compare
  • #42 removes change event listener, so auto-check now only happens on input events. This means if your app was previously programmatically changing input value and firing change event to trigger an auto-check call, you'd need to update the code to fire input instead.

v5.0.1

26 Nov 15:04
6ce5cea
Compare
Choose a tag to compare
  • remove early exit when same value is entered in input (#41)

v5.0.0...v5.0.1

v5.0.0

21 Nov 15:19
3a099ac
Compare
Choose a tag to compare

A lot of changes! We've completely re-written parts of the component.


  • Make sure we emit a loading state outside the debounced function (#35)
  • Set the required property correctly when the attribute changes (#39)
  • Add hooks so that the consuming application can set validation messages (#37)
  • Set credentials as same-origin in fetch options for older browsers (#36)
  • Use AbortController to cancel inflight requests (#32)
  • Use @github/mini-throttle for debouncing (#33)
  • Replace XHR request implementation with fetch (#29)

v4.1.1...v5.0.0

v4.1.1

12 Sep 10:51
Compare
Choose a tag to compare
  • types(ts): add window declaration 895672e
  • Bump eslint-utils from 1.4.0 to 1.4.2 31d1039

v4.1.0...v4.1.1

v4.1.0

27 Aug 09:13
a16fd2a
Compare
Choose a tag to compare
  • Merge pull request #24 from github/content-type-in-payload 0d4522c
  • Merge branch 'master' into content-type-in-payload c4566cf
  • set content type in error event payload cbc4aed

v4.0.2...v4.1.0

4.1.0

27 Aug 09:13
0d4522c
Compare
Choose a tag to compare
Merge pull request #24 from github/content-type-in-payload

Set content type in error event payload

v4.0.2

19 Aug 08:03
72e84e0
Compare
Choose a tag to compare
  • Merge pull request #20 from github/add-typescript-definition-file 07ceeec
  • use a union for nullable type 4e6a779
  • Merge branch 'master' into add-typescript-definition-file 16a9019
  • Merge branch 'master' into add-typescript-definition-file 4b9f4d9
  • add typescript definition file 6d5f818

v4.0.1...v4.0.2

4.0.2

19 Aug 08:03
07ceeec
Compare
Choose a tag to compare

<auto-check> element

An input element that validates its value against a server endpoint.

Installation

$ npm install --save @github/auto-check-element

Usage

import '@github/auto-check-element'
<auto-check src="/signup_check/username" csrf="<%= authenticity_token_for("/signup_check/username") %>">
 <input>
</auto-check>

Provide a URL and a CSRF token and the autocheck component will show validation confirmations and validation errors.

The endpoint should respond to POST requests with:

  • a 200 HTTP status code if the provided value if valid.
  • a 422 HTTP status code if the provided value is invalid.
  • a optional error message in the body and a Content-Type header with a value of text/html; fragment.

Events

const check = document.querySelector('auto-check')

// Network request lifecycle events.
check.addEventListener('loadstart', function(event) {
  console.log('Network request started', event)
})
check.addEventListener('loadend', function(event) {
  console.log('Network request complete', event)
})
check.addEventListener('load', function(event) {
  console.log('Network request succeeded', event)
})
check.addEventListener('error', function(event) {
  console.log('Network request failed', event)
})

// Auto-check result events.
const input = check.querySelector('input')

input.addEventListener('auto-check-send', function(event) {
  console.log('Adding to FormData before network request is sent.')
  const {body} = event.detail
  body.append('custom_form_data', 'value')
})
input.addEventListener('auto-check-success', function(event) {
  const {message} = event.detail
  console.log('Validation passed', message)
})
input.addEventListener('auto-check-error', function(event) {
  const {message} = event.detail
  console.log('Validation failed', message)
})
input.addEventListener('auto-check-complete', function(event) {
  console.log('Validation complete', event)
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.

v4.0.1

09 Aug 08:13
7dc0a58
Compare
Choose a tag to compare
  • Merge pull request #22 from github/publish-to-gpr-as-well 6364b56
  • publish to GPR as a postpublish step 9d159bc

v4.0.0...v4.0.1

4.0.1

09 Aug 08:13
6364b56
Compare
Choose a tag to compare

<auto-check> element

An input element that validates its value against a server endpoint.

Installation

$ npm install --save @github/auto-check-element

Usage

import '@github/auto-check-element'
<auto-check src="/signup_check/username" csrf="<%= authenticity_token_for("/signup_check/username") %>">
 <input>
</auto-check>

Provide a URL and a CSRF token and the autocheck component will show validation confirmations and validation errors.

The endpoint should respond to POST requests with:

  • a 200 HTTP status code if the provided value if valid.
  • a 422 HTTP status code if the provided value is invalid.
  • a optional error message in the body and a Content-Type header with a value of text/html; fragment.

Events

const check = document.querySelector('auto-check')

// Network request lifecycle events.
check.addEventListener('loadstart', function(event) {
  console.log('Network request started', event)
})
check.addEventListener('loadend', function(event) {
  console.log('Network request complete', event)
})
check.addEventListener('load', function(event) {
  console.log('Network request succeeded', event)
})
check.addEventListener('error', function(event) {
  console.log('Network request failed', event)
})

// Auto-check result events.
const input = check.querySelector('input')

input.addEventListener('auto-check-send', function(event) {
  console.log('Adding to FormData before network request is sent.')
  const {body} = event.detail
  body.append('custom_form_data', 'value')
})
input.addEventListener('auto-check-success', function(event) {
  const {message} = event.detail
  console.log('Validation passed', message)
})
input.addEventListener('auto-check-error', function(event) {
  const {message} = event.detail
  console.log('Validation failed', message)
})
input.addEventListener('auto-check-complete', function(event) {
  console.log('Validation complete', event)
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.