I see two issues: 1) Lack of communication, and 2) Overreaction.
First, Dad could've avoided this by simply saying, "I dropped a gift into your closet -- feel free to peek. I'm going to wrap it later". If the daugther wasn't home, he could've left a note. Over the years my girls've hidden numerous presents for me and their dad, and they've always felt special to be in on the secret.
I don't see any hint that Dad did anything wrong here in storing the gift in a closet. He just should've used better communication to avoid the problem, even if they have a history of storing gifts in this way.
Second, the daughter overreacted when she spoke to her mom. It's reasonable that an almost-adult should've put two and two together, and she should've realized it was a gift. Even if her dad had dropped the ball in not speaking to her, she should've been smart enough to realize that no good could come from giving away his secret (after all, she doesn't have any way to know that Mom had spoken to Dad about the cookie jar earlier). She should've said nothing to Mom, and then later she could've been on firm ground to say to Dad, "Hey, I wish you'd told me that you were putting an item in my closet. For all you knew, I could've been hiding something for you in there!" Dad would've then thought, "Yeah, my baby's growing up. I should've behaved differently." And I bet he would've next time left the gift in the trunk of his car.
At the same time, Mom overreacted. She knew her husband was going to buy the cookie jar. No real surprise ever existed. So why be upset enough to tell strangers about the issue? Mom had no control over what happened, but she could've said, "Oh, I suspect your dad left that in there as a surprise for me. I wish you hadn't told me! Now I'm going to have to act surprised!" And that would've been reprimand enough to let the daughter know that she'd been out of line to give away her dad's surprise, and hopefully the daughter'd realize later that she should've kept this problem between herself and Dad.