From 4f8d4edce175df40ebda23aaa72e9660016f22fc Mon Sep 17 00:00:00 2001 From: Eunsun Mota Date: Tue, 17 Dec 2024 14:12:39 -0500 Subject: [PATCH] feat: support loading state in combobox and menu --- components/combobox/apiExamples/loading.html | 6 + components/combobox/apiExamples/loading.js | 34 + components/combobox/demo/api.html | 1 + components/combobox/demo/api.js | 2 + components/combobox/demo/api.md | 70 + components/combobox/demo/api.min.js | 1862 +++++++++--------- components/combobox/demo/index.min.js | 1822 ++++++++--------- components/combobox/docs/partials/api.md | 18 + components/combobox/src/auro-combobox.js | 30 +- components/menu/demo/api.min.js | 1770 ++++++++--------- components/menu/demo/index.min.js | 1770 ++++++++--------- components/menu/src/auro-menu.js | 2 - components/menu/src/styles/style-menu.scss | 8 +- components/select/apiExamples/loading.js | 9 +- components/select/demo/api.md | 9 +- components/select/demo/api.min.js | 9 +- 16 files changed, 3659 insertions(+), 3763 deletions(-) create mode 100644 components/combobox/apiExamples/loading.html create mode 100644 components/combobox/apiExamples/loading.js 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 @@ +