docs: add source reference and author attribution to ConfirmationDialog and useConfirmationStore

This commit is contained in:
ngc2207 2024-12-09 13:39:27 +08:00
parent bb2093d14f
commit 398c56b38b
2 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,6 @@
// This implementation is derived from the solution provided by [baydisng13] in the discussion thread:
// https://github.com/shadcn-ui/ui/discussions/3875
"use client"; "use client";
import React from "react"; import React from "react";

View File

@ -1,3 +1,6 @@
// This implementation is derived from the solution provided by [baydisng13] in the discussion thread:
// https://github.com/shadcn-ui/ui/discussions/3875
import { create } from "zustand"; import { create } from "zustand";
interface ConfirmationState { interface ConfirmationState {
@ -42,10 +45,14 @@ const useConfirmationStore = create<ConfirmationState & ConfirmationActions>(
onAction: data.onAction, onAction: data.onAction,
})), })),
closeConfirmation: () => { closeConfirmation: () => {
// Close the confirmation dialog by setting the 'open' state to false.
set((state) => ({ set((state) => ({
...state, ...state,
open: false, open: false,
})); }));
// After a short delay (100ms), reset the dialog's state to its initial values.
// This delay ensures that the dialog is fully closed before resetting,
// preventing any visual flickering or UI inconsistencies.
setTimeout(() => { setTimeout(() => {
set((state) => ({ set((state) => ({
...state, ...state,