@nullplatform/ui-plugin-sdk 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/component.js +12 -4
  2. package/package.json +1 -1
package/dist/component.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./polyfill.js";
2
2
  import "@remote-dom/react/polyfill";
3
3
  import { createRemoteComponent } from "@remote-dom/react";
4
- import { createElement } from "react";
4
+ import { createElement, useLayoutEffect, useRef } from "react";
5
5
  import { CATALOG_BY_TAG } from "./catalog.js";
6
6
  import { defineCatalogElements } from "./elements.js";
7
7
  const elements = defineCatalogElements();
@@ -17,11 +17,19 @@ export function component(tag) {
17
17
  eventProps: eventProps,
18
18
  });
19
19
  const handlerProps = Object.values(spec.events);
20
- if (handlerProps.length === 0)
21
- return Remote;
22
- // remote-dom delivers a RemoteEvent to listeners; plugin authors want the payload the host sent.
23
20
  const Wrapped = (props) => {
24
21
  const mapped = { ...props };
22
+ // remote-dom's component only sets the props a render passes, so a prop dropped between renders
23
+ // (a `<Stack direction="row">` that React reuses as a `<Stack>`) would keep its old value on the
24
+ // host. Passing it as `undefined` sends the change, and the host falls back to its default.
25
+ const passed = useRef([]);
26
+ for (const prop of passed.current)
27
+ if (!(prop in mapped))
28
+ mapped[prop] = undefined;
29
+ useLayoutEffect(() => {
30
+ passed.current = Object.keys(props).filter((prop) => prop !== "children");
31
+ });
32
+ // remote-dom delivers a RemoteEvent to listeners; plugin authors want the payload the host sent.
25
33
  for (const prop of handlerProps) {
26
34
  const handler = props[prop];
27
35
  if (typeof handler === "function") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nullplatform/ui-plugin-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "SDK for nullplatform UI plugins: catalog components, bridge client and defineUI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",