@matthesketh/utopia-router 0.7.2 → 0.7.3
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/dist/index.cjs +3 -0
- package/dist/index.d.cts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -439,6 +439,9 @@ async function preloadRoute() {
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
function createRouterView() {
|
|
442
|
+
return { render: () => createRouterViewNode() };
|
|
443
|
+
}
|
|
444
|
+
function createRouterViewNode() {
|
|
442
445
|
const container = document.createElement("div");
|
|
443
446
|
container.setAttribute("data-utopia-router-view", "");
|
|
444
447
|
let currentCleanup = null;
|
package/dist/index.d.cts
CHANGED
|
@@ -204,7 +204,8 @@ declare function destroy(): void;
|
|
|
204
204
|
*/
|
|
205
205
|
declare function preloadRoute(): Promise<void>;
|
|
206
206
|
/**
|
|
207
|
-
* Creates a
|
|
207
|
+
* Creates a UtopiaJS-compatible component that renders the current route's
|
|
208
|
+
* component. Can be used as `<RouterView />` in .utopia templates.
|
|
208
209
|
*
|
|
209
210
|
* When the route changes:
|
|
210
211
|
* 1. The new component is lazily loaded (old content stays visible)
|
|
@@ -212,15 +213,17 @@ declare function preloadRoute(): Promise<void>;
|
|
|
212
213
|
* 3. If the route has a layout, the page is wrapped in the layout
|
|
213
214
|
* 4. If loading fails and an error component exists, it is shown instead
|
|
214
215
|
*
|
|
215
|
-
* @returns A
|
|
216
|
+
* @returns A component definition compatible with UtopiaJS's component system
|
|
216
217
|
*
|
|
217
218
|
* @example
|
|
218
219
|
* ```ts
|
|
219
|
-
*
|
|
220
|
-
*
|
|
220
|
+
* import { createRouterView as RouterView } from '@matthesketh/utopia-router';
|
|
221
|
+
* // In template: <RouterView />
|
|
221
222
|
* ```
|
|
222
223
|
*/
|
|
223
|
-
declare function createRouterView():
|
|
224
|
+
declare function createRouterView(): {
|
|
225
|
+
render: () => Node;
|
|
226
|
+
};
|
|
224
227
|
/**
|
|
225
228
|
* Creates an anchor element that performs client-side navigation when clicked.
|
|
226
229
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -204,7 +204,8 @@ declare function destroy(): void;
|
|
|
204
204
|
*/
|
|
205
205
|
declare function preloadRoute(): Promise<void>;
|
|
206
206
|
/**
|
|
207
|
-
* Creates a
|
|
207
|
+
* Creates a UtopiaJS-compatible component that renders the current route's
|
|
208
|
+
* component. Can be used as `<RouterView />` in .utopia templates.
|
|
208
209
|
*
|
|
209
210
|
* When the route changes:
|
|
210
211
|
* 1. The new component is lazily loaded (old content stays visible)
|
|
@@ -212,15 +213,17 @@ declare function preloadRoute(): Promise<void>;
|
|
|
212
213
|
* 3. If the route has a layout, the page is wrapped in the layout
|
|
213
214
|
* 4. If loading fails and an error component exists, it is shown instead
|
|
214
215
|
*
|
|
215
|
-
* @returns A
|
|
216
|
+
* @returns A component definition compatible with UtopiaJS's component system
|
|
216
217
|
*
|
|
217
218
|
* @example
|
|
218
219
|
* ```ts
|
|
219
|
-
*
|
|
220
|
-
*
|
|
220
|
+
* import { createRouterView as RouterView } from '@matthesketh/utopia-router';
|
|
221
|
+
* // In template: <RouterView />
|
|
221
222
|
* ```
|
|
222
223
|
*/
|
|
223
|
-
declare function createRouterView():
|
|
224
|
+
declare function createRouterView(): {
|
|
225
|
+
render: () => Node;
|
|
226
|
+
};
|
|
224
227
|
/**
|
|
225
228
|
* Creates an anchor element that performs client-side navigation when clicked.
|
|
226
229
|
*
|
package/dist/index.js
CHANGED
|
@@ -394,6 +394,9 @@ async function preloadRoute() {
|
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
function createRouterView() {
|
|
397
|
+
return { render: () => createRouterViewNode() };
|
|
398
|
+
}
|
|
399
|
+
function createRouterViewNode() {
|
|
397
400
|
const container = document.createElement("div");
|
|
398
401
|
container.setAttribute("data-utopia-router-view", "");
|
|
399
402
|
let currentCleanup = null;
|