fix(4710): Introduce safe access OTPInputContext slot array with custom hook
Description
This PR resolves an issue where the TypeScript compiler fails to build the InputOTP component due to unsafe access of the OTPInputContext's slot array.
To address this, the array access logic has been refactored into a custom hook that includes proper type guarding and error handling. This ensures safer access and improves overall code quality.
Fixes https://github.com/shadcn-ui/ui/issues/4710
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] Changed both
defaultandnew-yorkstyles - [x] Passed
checkscript - [x] Passed tests
- [x] Rebuilt the registry
@timges is attempting to deploy a commit to the shadcn-pro Team on Vercel.
A member of the Team first needs to authorize it.
Hey @shadcn would be great if you could take a small look on this, once you have some spare time. I think it's a pretty quick and easy fix for an annoying issue 🙂
Fixes: #3585 too