diff --git a/console/packages/components/src/components/switch/Switch.vue b/console/packages/components/src/components/switch/Switch.vue index 443659a6c..01fced8e9 100644 --- a/console/packages/components/src/components/switch/Switch.vue +++ b/console/packages/components/src/components/switch/Switch.vue @@ -2,9 +2,11 @@ const props = withDefaults( defineProps<{ modelValue?: boolean; + disabled?: boolean; }>(), { modelValue: false, + disabled: false, } ); @@ -14,6 +16,8 @@ const emit = defineEmits<{ }>(); const handleChange = () => { + if (props.disabled) return; + emit("update:modelValue", !props.modelValue); emit("change", !props.modelValue); }; @@ -24,11 +28,13 @@ const handleChange = () => { :class="{ 'bg-gray-200': !modelValue, '!bg-primary': modelValue, + 'switch-disabled': disabled, }" aria-checked="false" class="switch-inner" role="switch" type="button" + :disabled="disabled" @click="handleChange" > { ease-in-out duration-200; + &.switch-disabled { + @apply opacity-60 + cursor-not-allowed; + } + .switch-indicator { @apply pointer-events-none inline-block