@ripple-ts/compat-react 0.2.179 → 0.2.180
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.
- package/package.json +2 -2
- package/src/index.js +32 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ripple-ts/compat-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.180",
|
|
4
4
|
"description": "Ripple compatibility layer for React",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Dominic Gannaway",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"react": "^19.2.0",
|
|
19
19
|
"react-dom": "^19.2.0",
|
|
20
|
-
"ripple": "0.2.
|
|
20
|
+
"ripple": "0.2.180"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^19.2.2",
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
useState,
|
|
11
11
|
Component,
|
|
12
12
|
Suspense,
|
|
13
|
+
use,
|
|
13
14
|
} from 'react';
|
|
14
15
|
import { createPortal } from 'react-dom';
|
|
15
16
|
import { createRoot } from 'react-dom/client';
|
|
@@ -197,6 +198,7 @@ function get_block_from_dom(node) {
|
|
|
197
198
|
export function Ripple({ component, props }) {
|
|
198
199
|
const ref = useRef(null);
|
|
199
200
|
const tracked_props_ref = useRef(/** @type {any} */ (null));
|
|
201
|
+
const suspense_ref = useRef(/** @type {any} */ (null));
|
|
200
202
|
const portals_ref = /** @type {React.MutableRefObject<Map<any, any> | null>} */ (useRef(null));
|
|
201
203
|
const [, update] = useState(0);
|
|
202
204
|
|
|
@@ -205,6 +207,10 @@ export function Ripple({ component, props }) {
|
|
|
205
207
|
}
|
|
206
208
|
const portals = portals_ref.current;
|
|
207
209
|
|
|
210
|
+
if (suspense_ref.current !== null) {
|
|
211
|
+
use(suspense_ref.current);
|
|
212
|
+
}
|
|
213
|
+
|
|
208
214
|
useEffect(() => {
|
|
209
215
|
const span = /** @type {HTMLSpanElement | null} */ (ref.current);
|
|
210
216
|
if (span === null) {
|
|
@@ -226,9 +232,32 @@ export function Ripple({ component, props }) {
|
|
|
226
232
|
/** @type {any} */
|
|
227
233
|
const b = with_block(block, () => {
|
|
228
234
|
PortalContext.set({ portals, update });
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
const state = {
|
|
236
|
+
a() {
|
|
237
|
+
/** @type {((value?: unknown) => void) | undefined} */
|
|
238
|
+
let resolve;
|
|
239
|
+
const promise = new Promise((_resolve) => {
|
|
240
|
+
resolve = _resolve;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
suspense_ref.current = promise;
|
|
244
|
+
update((x) => x + 1);
|
|
245
|
+
|
|
246
|
+
return () => {
|
|
247
|
+
resolve?.();
|
|
248
|
+
suspense_ref.current = null;
|
|
249
|
+
};
|
|
250
|
+
},
|
|
251
|
+
c: null,
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
return branch(
|
|
255
|
+
() => {
|
|
256
|
+
component(anchor, proxied_props);
|
|
257
|
+
},
|
|
258
|
+
TRY_BLOCK,
|
|
259
|
+
state,
|
|
260
|
+
);
|
|
232
261
|
});
|
|
233
262
|
|
|
234
263
|
span.append(frag);
|