In adding an item, if user has inputted either required or not required, what's the best confirmation if user clicked outside the modal or press ESC? Some scenarios could be a user accidentally press the ESC or clicked outside the modal and then let user enter again all the expected data on all the input fields.
i think you should make the user to confirm leaving ( only if he have entered data ) if he pressed out side , hit ESC or hit cancel . it will be simple ( You have unsaved data , are you sure you want to leave ? ) if he hit yes and open the dialog again , he shouldnt see his unsaved data . also consider how critical is the data entered and its size for example if its one text field , no confirmation needed