aotc-component-lib
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,1 +0,1 @@ | ||
{"aotc-components.css":"./dist/aotc-components-8640abf1b6c95823d093fc0eba0db7a8.css","aotc-components.js":"./dist/aotc-components-6ded94b0bbcb5dc627b2efbbca8aec87.js"} | ||
{"aotc-components.css":"./dist/aotc-components-ddf8d9d20607856d9ef484ec8f6422c3.css","aotc-components.js":"./dist/aotc-components-7a74b4b75323ab8c782a80741eace98f.js"} |
@@ -35,2 +35,3 @@ /* global HTMLElement, customElements, DOMParser, FormData, fetch, window, XMLSerializer, CustomEvent */ | ||
this.input.addEventListener('focusout', this.deactivate.bind(this)) | ||
this.input.addEventListener('focus', this.activate.bind(this)) | ||
this.submit.addEventListener('click', this.triggerSearch.bind(this)) | ||
@@ -89,8 +90,13 @@ } | ||
const results = await response.text() | ||
try { | ||
const results = await response.text() | ||
const dataReceivedEvent = new CustomEvent('async-form-data-received', { bubbles: true }) | ||
this.dispatchEvent(dataReceivedEvent) | ||
const dataReceivedEvent = new CustomEvent('async-form-data-received', { bubbles: true }) | ||
this.dispatchEvent(dataReceivedEvent) | ||
this.render(results) | ||
this.render(results) | ||
} catch (e) { | ||
console.log(e) | ||
this.renderError(e) | ||
} | ||
}) | ||
@@ -108,2 +114,8 @@ } | ||
renderError (error) { | ||
if (this.target) { | ||
this.target.innerHTML = error.message | ||
} | ||
} | ||
searchUrl (form) { | ||
@@ -110,0 +122,0 @@ const queryParams = new FormData(form) |
@@ -10,2 +10,8 @@ /* global customElements, HTMLElement */ | ||
this.changeHandler = e => { | ||
const { target } = e | ||
const inputFieldId = target.getAttribute('id') | ||
if (inputFieldId) { | ||
// add input id hash to action, to maintain scroll height after filtering | ||
this.form.action = urlWithHash(this.form.action, inputFieldId) | ||
} | ||
this.form.submit() | ||
@@ -23,1 +29,14 @@ } | ||
customElements.define('reactive-filter-search', ReactiveFilterSearch) | ||
function urlWithHash (url, hash) { | ||
let relativeURL, absoluteURL | ||
try { | ||
absoluteURL = new URL(url) | ||
} catch (e) { | ||
relativeURL = url | ||
} | ||
const a = document.createElement('a') | ||
a.href = absoluteURL || relativeURL | ||
a.hash = hash | ||
return absoluteURL ? a.href : `${a.pathname}${a.hash}` | ||
} |
export { CombinedSearchForm } from './components/combined-search-form.js' | ||
export { ReactiveFilterSearch } from './components/reactive-filter-search.js' | ||
export { DateSelect } from './components/date-select.js' |
{ | ||
"name": "aotc-component-lib", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/manifest.json", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
31724
15
793
3