From e1e05af0bafd1e5d1b91f374562ed8d389fb0cae Mon Sep 17 00:00:00 2001 From: Mohammad Amin Mokhtari <41728922+aminmokhtari94@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:13:15 +0330 Subject: [PATCH] feat(Toggle): add `loading` prop (#1546) Co-authored-by: Benjamin Canac --- docs/content/2.components/toggle.md | 13 +++++++++ src/runtime/components/forms/Toggle.vue | 35 ++++++++++++++++++++++--- src/runtime/ui.config/forms/toggle.ts | 6 +++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/docs/content/2.components/toggle.md b/docs/content/2.components/toggle.md index a43aeb89..f303df33 100644 --- a/docs/content/2.components/toggle.md +++ b/docs/content/2.components/toggle.md @@ -52,6 +52,19 @@ excludedProps: --- :: +### Loading :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"} + +Use the `loading` prop to show a loading icon and disable the Toggle. + +Use the `loading-icon` prop to set a different icon or change it globally in `ui.toggle.default.loadingIcon`. Defaults to `i-heroicons-arrow-path-20-solid`. + +::component-card +--- +props: + loading: true +--- +:: + ### Disabled Use the `disabled` prop to disable the Toggle. diff --git a/src/runtime/components/forms/Toggle.vue b/src/runtime/components/forms/Toggle.vue index e825daf3..9f61ceff 100644 --- a/src/runtime/components/forms/Toggle.vue +++ b/src/runtime/components/forms/Toggle.vue @@ -3,15 +3,26 @@ :id="inputId" v-model="active" :name="name" - :disabled="disabled" + :disabled="disabled || loading" :class="switchClass" v-bind="attrs" > -