-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add footer argument to chat_ui()
#224
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
Changes from all commits
6064e9c
f56c0da
298db16
637084b
3e8df2a
4f06137
24ebde5
68d0d37
3f18940
0c28caa
b3f0beb
e96771f
23d81ae
53db7d2
0a8462a
895146c
f97591b
8e34e94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { useContext, useEffect, useRef } from "react" | ||
| import { ShinyLifecycleContext } from "./context" | ||
|
|
||
| // Complement to RawHTML: both use a ref div to opt out of React's DOM | ||
| // management and both manage Shiny bindings via ShinyLifecycleContext. | ||
| // RawHTML reconstructs DOM from an HTML string; RawDOM adopts existing | ||
| // DOM nodes by moving them from a source element. This preserves event | ||
| // listeners, widget state, and any other DOM state that a | ||
| // serialization round-trip through innerHTML would destroy. | ||
| // | ||
| // On setup: unbinds the source, moves children into the React-managed | ||
| // div, then rebinds in the new location. On cleanup: unbinds, moves | ||
| // children back to the source so they survive React unmount and can be | ||
| // re-adopted on remount (e.g. when the custom element is moved in the | ||
| // DOM, triggering disconnectedCallback → connectedCallback). | ||
| // | ||
| // Safety: the effect deps [source, shiny] are both referentially stable | ||
| // for the lifetime of the component — source is a DOM element stored as | ||
| // a private field on the custom element instance, and shiny is a | ||
| // window-global singleton provided via context — so the effect runs | ||
| // exactly once per mount. | ||
| export function RawDOM({ | ||
| source, | ||
| className, | ||
| }: { | ||
| source: Element | ||
| className?: string | ||
| }) { | ||
| const ref = useRef<HTMLDivElement>(null) | ||
| const shiny = useContext(ShinyLifecycleContext) | ||
|
|
||
| useEffect(() => { | ||
| const el = ref.current | ||
| if (!el) return | ||
|
|
||
| if (shiny) shiny.unbindAll(source as HTMLElement) | ||
| while (source.firstChild) { | ||
| el.appendChild(source.firstChild) | ||
| } | ||
| if (shiny) shiny.bindAll(el) | ||
|
|
||
| return () => { | ||
| if (shiny) shiny.unbindAll(el) | ||
| while (el.firstChild) { | ||
| source.appendChild(el.firstChild) | ||
| } | ||
| } | ||
| }, [source, shiny]) | ||
|
|
||
| return <div ref={ref} className={className} /> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ae728f2114d14fc321b5b3addabdb1823d06965c | ||
| f97591b21e3af83d259dce77a8a7e6c63a0fcd59 |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ae728f2114d14fc321b5b3addabdb1823d06965c | ||
| 895146c48c267da928857b0c76b35d8719bc464b |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.