next-recomponents 2.0.76 → 2.0.77
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.js +25 -0
- package/dist/index.mjs +26 -1
- package/package.json +1 -1
- package/src/container/index.tsx +36 -0
package/dist/index.js
CHANGED
|
@@ -3660,6 +3660,7 @@ function ArrowDownIcon() {
|
|
|
3660
3660
|
|
|
3661
3661
|
// src/container/index.tsx
|
|
3662
3662
|
var import_link = __toESM(require_link2());
|
|
3663
|
+
var import_server = require("react-dom/server");
|
|
3663
3664
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3664
3665
|
function Container({
|
|
3665
3666
|
children,
|
|
@@ -3673,6 +3674,30 @@ function Container({
|
|
|
3673
3674
|
}) {
|
|
3674
3675
|
const [isSidebarOpen, setIsSidebarOpen] = (0, import_react2.useState)(false);
|
|
3675
3676
|
const [isFooterOpen, setIsFooterOpen] = (0, import_react2.useState)(expandedFooter);
|
|
3677
|
+
(0, import_react2.useEffect)(() => {
|
|
3678
|
+
if (typeof document != "undefined") {
|
|
3679
|
+
const last = navItems == null ? void 0 : navItems[navItems.length - 1];
|
|
3680
|
+
if (!last) return;
|
|
3681
|
+
const pageTitle = typeof last.name === "string" ? last.name : typeof appName === "string" ? appName : "No definido";
|
|
3682
|
+
document.title = pageTitle;
|
|
3683
|
+
if (last.icon) {
|
|
3684
|
+
try {
|
|
3685
|
+
const svgString = (0, import_server.renderToStaticMarkup)(last.icon);
|
|
3686
|
+
if (svgString.startsWith("<svg")) {
|
|
3687
|
+
const dataUri = `data:image/svg+xml,${encodeURIComponent(svgString)}`;
|
|
3688
|
+
let link = document.querySelector("link[rel='icon']");
|
|
3689
|
+
if (!link) {
|
|
3690
|
+
link = document.createElement("link");
|
|
3691
|
+
link.rel = "icon";
|
|
3692
|
+
document.head.appendChild(link);
|
|
3693
|
+
}
|
|
3694
|
+
link.href = dataUri;
|
|
3695
|
+
}
|
|
3696
|
+
} catch {
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
}, [navItems, appName]);
|
|
3676
3701
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col h-screen", children: [
|
|
3677
3702
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("header", { className: "", children: [
|
|
3678
3703
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "bg-blue-600 text-white p-4 flex justify-between items-center shadow-md", children: [
|
package/dist/index.mjs
CHANGED
|
@@ -3561,7 +3561,7 @@ function Button({
|
|
|
3561
3561
|
}
|
|
3562
3562
|
|
|
3563
3563
|
// src/container/index.tsx
|
|
3564
|
-
import { useState as useState2 } from "react";
|
|
3564
|
+
import { useEffect, useState as useState2 } from "react";
|
|
3565
3565
|
|
|
3566
3566
|
// src/container/icons.tsx
|
|
3567
3567
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -3632,6 +3632,7 @@ function ArrowDownIcon() {
|
|
|
3632
3632
|
|
|
3633
3633
|
// src/container/index.tsx
|
|
3634
3634
|
var import_link = __toESM(require_link2());
|
|
3635
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3635
3636
|
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
3636
3637
|
function Container({
|
|
3637
3638
|
children,
|
|
@@ -3645,6 +3646,30 @@ function Container({
|
|
|
3645
3646
|
}) {
|
|
3646
3647
|
const [isSidebarOpen, setIsSidebarOpen] = useState2(false);
|
|
3647
3648
|
const [isFooterOpen, setIsFooterOpen] = useState2(expandedFooter);
|
|
3649
|
+
useEffect(() => {
|
|
3650
|
+
if (typeof document != "undefined") {
|
|
3651
|
+
const last = navItems == null ? void 0 : navItems[navItems.length - 1];
|
|
3652
|
+
if (!last) return;
|
|
3653
|
+
const pageTitle = typeof last.name === "string" ? last.name : typeof appName === "string" ? appName : "No definido";
|
|
3654
|
+
document.title = pageTitle;
|
|
3655
|
+
if (last.icon) {
|
|
3656
|
+
try {
|
|
3657
|
+
const svgString = renderToStaticMarkup(last.icon);
|
|
3658
|
+
if (svgString.startsWith("<svg")) {
|
|
3659
|
+
const dataUri = `data:image/svg+xml,${encodeURIComponent(svgString)}`;
|
|
3660
|
+
let link = document.querySelector("link[rel='icon']");
|
|
3661
|
+
if (!link) {
|
|
3662
|
+
link = document.createElement("link");
|
|
3663
|
+
link.rel = "icon";
|
|
3664
|
+
document.head.appendChild(link);
|
|
3665
|
+
}
|
|
3666
|
+
link.href = dataUri;
|
|
3667
|
+
}
|
|
3668
|
+
} catch {
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
}, [navItems, appName]);
|
|
3648
3673
|
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col h-screen", children: [
|
|
3649
3674
|
/* @__PURE__ */ jsxs2("header", { className: "", children: [
|
|
3650
3675
|
/* @__PURE__ */ jsxs2("div", { className: "bg-blue-600 text-white p-4 flex justify-between items-center shadow-md", children: [
|
package/package.json
CHANGED
package/src/container/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React, { cloneElement, ReactNode, useEffect, useState } from "react";
|
|
3
3
|
import MenuIcon, { ArrowDownIcon, ArrowUpIcon, HomeIcon } from "./icons";
|
|
4
4
|
import Link from "next/link";
|
|
5
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
5
6
|
type LocationItem = {
|
|
6
7
|
location: string;
|
|
7
8
|
name: JSX.Element | string | ReactNode;
|
|
@@ -39,6 +40,41 @@ export default function Container({
|
|
|
39
40
|
// }
|
|
40
41
|
// }
|
|
41
42
|
// }, []);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (typeof document != "undefined") {
|
|
46
|
+
const last = navItems?.[navItems.length - 1];
|
|
47
|
+
if (!last) return;
|
|
48
|
+
|
|
49
|
+
const pageTitle =
|
|
50
|
+
typeof last.name === "string"
|
|
51
|
+
? last.name
|
|
52
|
+
: typeof appName === "string"
|
|
53
|
+
? appName
|
|
54
|
+
: "No definido";
|
|
55
|
+
|
|
56
|
+
document.title = pageTitle;
|
|
57
|
+
|
|
58
|
+
if (last.icon) {
|
|
59
|
+
try {
|
|
60
|
+
const svgString = renderToStaticMarkup(last.icon as any);
|
|
61
|
+
if (svgString.startsWith("<svg")) {
|
|
62
|
+
const dataUri = `data:image/svg+xml,${encodeURIComponent(svgString)}`;
|
|
63
|
+
let link =
|
|
64
|
+
document.querySelector<HTMLLinkElement>("link[rel='icon']");
|
|
65
|
+
if (!link) {
|
|
66
|
+
link = document.createElement("link");
|
|
67
|
+
link.rel = "icon";
|
|
68
|
+
document.head.appendChild(link);
|
|
69
|
+
}
|
|
70
|
+
link.href = dataUri;
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
// last.icon no es un SVG renderizable de forma estática; no tocar el favicon
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, [navItems, appName]);
|
|
42
78
|
return (
|
|
43
79
|
<div className="flex flex-col h-screen">
|
|
44
80
|
{/* Header */}
|