diff --git a/components/combobox/apiExamples/loading.html b/components/combobox/apiExamples/loading.html new file mode 100644 index 00000000..9d0c43a2 --- /dev/null +++ b/components/combobox/apiExamples/loading.html @@ -0,0 +1,6 @@ + + Please select a preference + + Loading... + + diff --git a/components/combobox/apiExamples/loading.js b/components/combobox/apiExamples/loading.js new file mode 100644 index 00000000..d45f3f76 --- /dev/null +++ b/components/combobox/apiExamples/loading.js @@ -0,0 +1,34 @@ +export function auroMenuLoadingExample() { + const combobox = document.querySelector("#loadingExample"); + const menu = document.querySelector("#loadingExampleComboboxMenu"); + const emptyMenu = () => { + const menuoptions = menu.querySelectorAll('auro-menuoption'); + menuoptions.forEach(mo => menu.removeChild(mo)); + } + const fillMenu = () => { + menu.innerHTML += ` + Apples + Oranges + Peaches + Grapes + Cherries + No matching option + `; + } + + const load = () => { + clearTimeout(load.id); + emptyMenu(); + menu.setAttribute('loading', 'loading'); + load.id = setTimeout(() => { + menu.removeAttribute('loading'); + fillMenu(); + }, 1000); + + } + combobox.addEventListener("input", (e) => { + if (e.target.value) { + load(); + } + }); +} diff --git a/components/combobox/demo/api.html b/components/combobox/demo/api.html index 428d497e..050d4a57 100644 --- a/components/combobox/demo/api.html +++ b/components/combobox/demo/api.html @@ -45,6 +45,7 @@ +