-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally allow the use of external DOMs #209
Conversation
darn, i was hoping i could make ReactDOM work well enough, but unfortunately, the use of unstable__transformChildren makes this difficult since ReactDOM rejects unknown props on DOM elements. given there are other packages (like ink-box) that use it, it makes it difficult to rename it. forking react-dom isn't really a valid path forward either. my ultimate goal was to make it easier to integrate key input events as well as events like focus. but, it seems like the only real way to go is to write the appropriate renderer glue in the reconciler :( |
What would you rename it to? I control |
Thank you for the huge effort you've put in this PR, but I'm not sure I would want to merge it in current form. If we were to decide to move to As for focus management, I'm a little confused here, how would Regarding mouse events, I don't think I would want to have support for it in Ink, at least in the foreseeable future. Mouse support works great in ncurses-based CLIs (see react-blessed), because of their fullscreen approach to rendering UIs. Ink's output, however, just keeps "adding rows" to the terminal and it can go way beyond the terminal height (viewport), which makes it impossible to determine where exactly user is clicking. |
react-dom allows custom DOM properties when they are all lowercase. so, any all-lowercase custom prop would be fine. i would simply propose lowercasing the whole thing to
it's not that focus management is somehow specific to jsdom, but that an existing DOM implementation already has the abstractions to manage event listeners, event bubbling, etc. and two of those events are that can all be implemented in
hm, that's interesting. i didn't realize the philosophy here. i'd really like to be thinking about my react app as living inside a viewport as i want things to change. what about something like i gave blessed and react-blessed a try, but i ran into a bunch of issues getting what i wanted working. i will re-evaluate it to understand more detail of what's not possible over there that brought me to |
i went back to playing around with |
Glad you found a tool that suits your needs! I'm going to close this PR for now, but feel free to come back with ideas, suggestions and PRs in the future ;) |
External DOMs like jsdom are more featureful than the DOM present in ink.
Features like focus and event dispatch can allow for much richer UIs with react.
These commits allow the client to create a DOM and specify its objects to the
render method via options.
Additionally, when the external DOM is available, it is assumed it supports
event dispatch and so ink uses a keyboard event dispatcher.
This enables the use of features like
react-hotkeys
and other event-basedfunctionality. For instance, this opens the door to mouse events being
delivered.