@github/auto-complete-element
Advanced tools
Comparing version 3.5.1 to 3.6.0
@@ -29,3 +29,10 @@ import Combobox from '@github/combobox-nav'; | ||
} | ||
this.results.hidden = true; | ||
if (this.results.popover) { | ||
if (this.results.matches(':popover-open')) { | ||
this.results.hidePopover(); | ||
} | ||
} | ||
else { | ||
this.results.hidden = true; | ||
} | ||
if (!this.results.getAttribute('aria-label')) { | ||
@@ -179,13 +186,25 @@ this.results.setAttribute('aria-label', 'results'); | ||
open() { | ||
if (!this.results.hidden) | ||
return; | ||
this.combobox.start(); | ||
this.results.hidden = false; | ||
const isHidden = this.results.popover ? !this.results.matches(':popover-open') : this.results.hidden; | ||
if (isHidden) { | ||
this.combobox.start(); | ||
if (this.results.popover) { | ||
this.results.showPopover(); | ||
} | ||
else { | ||
this.results.hidden = false; | ||
} | ||
} | ||
} | ||
close() { | ||
if (this.results.hidden) | ||
return; | ||
this.combobox.stop(); | ||
this.results.hidden = true; | ||
const isVisible = this.results.popover ? this.results.matches(':popover-open') : !this.results.hidden; | ||
if (isVisible) { | ||
this.combobox.stop(); | ||
if (this.results.popover) { | ||
this.results.hidePopover(); | ||
} | ||
else { | ||
this.results.hidden = true; | ||
} | ||
} | ||
} | ||
} |
@@ -6,3 +6,3 @@ var __defProp = Object.defineProperty; | ||
var Combobox = class { | ||
constructor(input, list, { tabInsertsSuggestions, defaultFirstOption } = {}) { | ||
constructor(input, list, { tabInsertsSuggestions, defaultFirstOption, scrollIntoViewOptions } = {}) { | ||
this.input = input; | ||
@@ -12,2 +12,3 @@ this.list = list; | ||
this.defaultFirstOption = defaultFirstOption !== null && defaultFirstOption !== void 0 ? defaultFirstOption : false; | ||
this.scrollIntoViewOptions = scrollIntoViewOptions; | ||
this.isComposing = false; | ||
@@ -83,3 +84,4 @@ if (!list.id) { | ||
target.setAttribute("aria-selected", "true"); | ||
scrollTo(this.list, target); | ||
fireSelectEvent(target); | ||
target.scrollIntoView(this.scrollIntoViewOptions); | ||
} else { | ||
@@ -172,2 +174,6 @@ el.removeAttribute("aria-selected"); | ||
__name(fireCommitEvent, "fireCommitEvent"); | ||
function fireSelectEvent(target) { | ||
target.dispatchEvent(new Event("combobox-select", { bubbles: true })); | ||
} | ||
__name(fireSelectEvent, "fireSelectEvent"); | ||
function visible(el) { | ||
@@ -185,16 +191,2 @@ return !el.hidden && !(el instanceof HTMLInputElement && el.type === "hidden") && (el.offsetWidth > 0 || el.offsetHeight > 0); | ||
__name(trackComposition, "trackComposition"); | ||
function scrollTo(container, target) { | ||
if (!inViewport(container, target)) { | ||
container.scrollTop = target.offsetTop; | ||
} | ||
} | ||
__name(scrollTo, "scrollTo"); | ||
function inViewport(container, element) { | ||
const scrollTop = container.scrollTop; | ||
const containerBottom = scrollTop + container.clientHeight; | ||
const top = element.offsetTop; | ||
const bottom = top + element.clientHeight; | ||
return top >= scrollTop && bottom <= containerBottom; | ||
} | ||
__name(inViewport, "inViewport"); | ||
@@ -241,3 +233,9 @@ // dist/debounce.js | ||
} | ||
this.results.hidden = true; | ||
if (this.results.popover) { | ||
if (this.results.matches(":popover-open")) { | ||
this.results.hidePopover(); | ||
} | ||
} else { | ||
this.results.hidden = true; | ||
} | ||
if (!this.results.getAttribute("aria-label")) { | ||
@@ -385,12 +383,22 @@ this.results.setAttribute("aria-label", "results"); | ||
open() { | ||
if (!this.results.hidden) | ||
return; | ||
this.combobox.start(); | ||
this.results.hidden = false; | ||
const isHidden = this.results.popover ? !this.results.matches(":popover-open") : this.results.hidden; | ||
if (isHidden) { | ||
this.combobox.start(); | ||
if (this.results.popover) { | ||
this.results.showPopover(); | ||
} else { | ||
this.results.hidden = false; | ||
} | ||
} | ||
} | ||
close() { | ||
if (this.results.hidden) | ||
return; | ||
this.combobox.stop(); | ||
this.results.hidden = true; | ||
const isVisible = this.results.popover ? this.results.matches(":popover-open") : !this.results.hidden; | ||
if (isVisible) { | ||
this.combobox.stop(); | ||
if (this.results.popover) { | ||
this.results.hidePopover(); | ||
} else { | ||
this.results.hidden = true; | ||
} | ||
} | ||
} | ||
@@ -397,0 +405,0 @@ }; |
{ | ||
"name": "@github/auto-complete-element", | ||
"version": "3.5.1", | ||
"version": "3.6.0", | ||
"description": "Auto-complete input values from server results", | ||
@@ -18,3 +18,3 @@ "repository": "github/auto-complete-element", | ||
"prepublishOnly": "npm run build", | ||
"pretest": "npm run build", | ||
"pretest": "npm run build; npx playwright install", | ||
"test": "web-test-runner", | ||
@@ -37,3 +37,3 @@ "postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'", | ||
"devDependencies": { | ||
"@custom-elements-manifest/analyzer": "^0.8.0", | ||
"@custom-elements-manifest/analyzer": "^0.9.0", | ||
"@github/prettier-config": "^0.0.6", | ||
@@ -53,5 +53,5 @@ "@open-wc/testing": "^3.1.8", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"typescript": "^5.0.4" | ||
"typescript": "^5.2.2" | ||
}, | ||
"customElements": "custom-elements.json" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57032
1194