diff --git a/examples/shiny-react-upstream/5-shadcn/components.json b/examples/shiny-react-upstream/5-shadcn/components.json index 285033d3..67ea69c1 100644 --- a/examples/shiny-react-upstream/5-shadcn/components.json +++ b/examples/shiny-react-upstream/5-shadcn/components.json @@ -5,7 +5,7 @@ "tsx": true, "tailwind": { "config": "", - "css": "src/styles/globals.css", + "css": "srcts/globals.css", "baseColor": "neutral", "cssVariables": true, "prefix": "" diff --git a/examples/shiny-react-upstream/5-shadcn/package.json b/examples/shiny-react-upstream/5-shadcn/package.json index c6c0841f..1df48b4f 100644 --- a/examples/shiny-react-upstream/5-shadcn/package.json +++ b/examples/shiny-react-upstream/5-shadcn/package.json @@ -1,5 +1,6 @@ { - "name": "shiny-react-dashboard", + "name": "shiny-react-shadcn", + "private": true, "version": "1.0.0", "type": "module", "description": "Interactive dashboard example using shiny-react and shadcn/ui", diff --git a/examples/shiny-react-upstream/7-chat/py/app.py b/examples/shiny-react-upstream/7-chat/py/app.py index 699c6cee..04aecd72 100644 --- a/examples/shiny-react-upstream/7-chat/py/app.py +++ b/examples/shiny-react-upstream/7-chat/py/app.py @@ -9,7 +9,6 @@ # Load .env file in this directory for OPENAI_API_KEY app_dir = Path(__file__).parent env_file = app_dir / ".env" -print(env_file) dotenv.load_dotenv(env_file) # Initialize chat with OpenAI GPT-4o-mini by default diff --git a/examples/shiny-react-upstream/8-modules/py/app.py b/examples/shiny-react-upstream/8-modules/py/app.py index 977c12a3..18687b67 100644 --- a/examples/shiny-react-upstream/8-modules/py/app.py +++ b/examples/shiny-react-upstream/8-modules/py/app.py @@ -14,11 +14,11 @@ def _(): return 0 @reactive.effect - def _(): + async def _(): """Send notification message every 5 counts""" count = input.count() if count is not None and count > 0 and count % 5 == 0: - shinyreact.post_message( + await shinyreact.post_message( session, "notification", {"message": f"Milestone reached: {count}"}, diff --git a/examples/shiny-react-upstream/8-modules/srcts-standard/main.tsx b/examples/shiny-react-upstream/8-modules/srcts-standard/main.tsx index b3c0287a..96205345 100644 --- a/examples/shiny-react-upstream/8-modules/srcts-standard/main.tsx +++ b/examples/shiny-react-upstream/8-modules/srcts-standard/main.tsx @@ -7,5 +7,5 @@ class CounterWidgetElement extends ShinyReactComponentElement { } if (!customElements.get("counter-widget")) { - customElements.define("counter-widget", CounterWidgetElement); + customElements.define("counter-widget", CounterWidgetElement); } diff --git a/js/src/shiny-react/ImageOutput.tsx b/js/src/shiny-react/ImageOutput.tsx index 9a01cf56..9dfb4d2c 100644 --- a/js/src/shiny-react/ImageOutput.tsx +++ b/js/src/shiny-react/ImageOutput.tsx @@ -72,6 +72,10 @@ export type ImageData = { * dimension change detection (default: 400ms). Controls how long to wait * after a resize event before sending updated dimensions to Shiny. Higher * values reduce server load but may delay updates. + * @param props.namespace - Optional namespace override for Shiny module + * support. If provided, overrides the namespace from ShinyModuleProvider + * context. Pass `null` to explicitly disable namespacing even when inside + * a provider. * @param props.onRecalculating - Optional callback function that gets called * whenever the recalculation status changes. Receives a boolean indicating * whether the image is currently recalculating. diff --git a/js/src/shiny-react/ShinyModuleContext.tsx b/js/src/shiny-react/ShinyModuleContext.tsx index 62ddb383..c21c48a3 100644 --- a/js/src/shiny-react/ShinyModuleContext.tsx +++ b/js/src/shiny-react/ShinyModuleContext.tsx @@ -14,8 +14,9 @@ export interface ShinyModuleProviderProps { * useShinyMessageHandler will automatically have their IDs prefixed * with the provided namespace. * - * Note: This provider does NOT support nesting. If you need nested modules, - * pass the full namespace string (e.g., "outer-inner") directly. + * Note: Nesting providers is supported — an inner provider overrides the + * outer one (it does not concatenate namespaces). If you need a combined + * namespace, pass the full string (e.g., "outer-inner") directly. * * @param namespace The complete namespace string to apply to child hooks. * @param children React children that will receive the namespace context. @@ -48,8 +49,8 @@ export function useShinyModuleNamespace(): string | null { /** * Utility function to apply namespace to an ID. - * If namespace is provided, returns `${namespace}-${id}`. - * Otherwise returns the original id. + * If namespace is a non-empty string, returns `${namespace}-${id}`. + * If namespace is null, undefined, or empty string, returns the original id. */ export function applyNamespace( id: string,