ywana-core8 0.1.47 → 0.1.49
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 +71 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +73 -32
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +71 -30
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/site/site.js +50 -14
package/dist/index.cjs
CHANGED
@@ -2051,31 +2051,59 @@ var SiteProvider = function SiteProvider(_ref) {
|
|
2051
2051
|
consoleLines = _useState7[0],
|
2052
2052
|
setConsoleLines = _useState7[1];
|
2053
2053
|
var _useState8 = React.useState(),
|
2054
|
-
|
2055
|
-
|
2054
|
+
dialog = _useState8[0],
|
2055
|
+
setDialog = _useState8[1];
|
2056
2056
|
var _useState9 = React.useState(),
|
2057
|
-
|
2058
|
-
|
2057
|
+
promptDialog = _useState9[0],
|
2058
|
+
setPromptDialog = _useState9[1];
|
2059
2059
|
var _useState10 = React.useState(),
|
2060
|
-
|
2061
|
-
|
2060
|
+
preview = _useState10[0],
|
2061
|
+
setPreview = _useState10[1];
|
2062
2062
|
var _useState11 = React.useState(),
|
2063
|
-
|
2064
|
-
|
2065
|
-
var _useState12 = React.useState(),
|
2066
|
-
|
2067
|
-
|
2063
|
+
breadcrumb = _useState11[0],
|
2064
|
+
setBreadcrumb = _useState11[1];
|
2065
|
+
var _useState12 = React.useState([]),
|
2066
|
+
history = _useState12[0],
|
2067
|
+
setHistory = _useState12[1];
|
2068
|
+
|
2069
|
+
// 📌 Extraer la página actual desde la URL (por defecto "home")
|
2070
|
+
var getCurrentPageFromURL = function getCurrentPageFromURL() {
|
2071
|
+
var path = window.location.pathname.replace("/", "");
|
2072
|
+
return path || "home";
|
2073
|
+
};
|
2074
|
+
var _useState13 = React.useState(getCurrentPageFromURL()),
|
2075
|
+
page = _useState13[0],
|
2076
|
+
setPage = _useState13[1];
|
2077
|
+
React.useEffect(function () {
|
2078
|
+
// 📌 Detectar cambios en la URL cuando el usuario presiona "Atrás" o "Adelante"
|
2079
|
+
var handlePopState = function handlePopState(event) {
|
2080
|
+
var _event$state;
|
2081
|
+
var previousPage = ((_event$state = event.state) == null ? void 0 : _event$state.page) || "home";
|
2082
|
+
setPage(previousPage);
|
2083
|
+
};
|
2084
|
+
window.addEventListener("popstate", handlePopState);
|
2085
|
+
return function () {
|
2086
|
+
return window.removeEventListener("popstate", handlePopState);
|
2087
|
+
};
|
2088
|
+
}, []);
|
2068
2089
|
var value = {
|
2069
2090
|
lang: lang,
|
2070
2091
|
setLang: setLang,
|
2071
2092
|
dictionary: dictionary,
|
2072
2093
|
setDictionary: setDictionary,
|
2073
|
-
translate: function
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2094
|
+
translate: React.useCallback(function (key) {
|
2095
|
+
var _dictionary$key;
|
2096
|
+
return (dictionary == null ? void 0 : (_dictionary$key = dictionary[key]) == null ? void 0 : _dictionary$key[lang]) || key;
|
2097
|
+
}, [lang, dictionary]),
|
2098
|
+
/*
|
2099
|
+
translate: (key) => {
|
2100
|
+
if (!key) return key
|
2101
|
+
if (dictionary === undefined) return key
|
2102
|
+
const term = dictionary[key]
|
2103
|
+
return term ? term[lang] : key
|
2078
2104
|
},
|
2105
|
+
*/
|
2106
|
+
|
2079
2107
|
sideNav: sideNav,
|
2080
2108
|
setSideNav: setSideNav,
|
2081
2109
|
showNav: showNav,
|
@@ -2103,7 +2131,25 @@ var SiteProvider = function SiteProvider(_ref) {
|
|
2103
2131
|
setBreadcrumb: setBreadcrumb,
|
2104
2132
|
page: page,
|
2105
2133
|
"goto": function goto(id) {
|
2134
|
+
if (page) {
|
2135
|
+
setHistory(function (prev) {
|
2136
|
+
return [].concat(prev, [page]);
|
2137
|
+
}); // 🔹 Guarda la página actual en el historial antes de cambiar
|
2138
|
+
}
|
2106
2139
|
setPage(id);
|
2140
|
+
window.history.pushState({
|
2141
|
+
page: id
|
2142
|
+
}, "", "/" + id); // 🔹 Actualiza la URL
|
2143
|
+
},
|
2144
|
+
goBack: function goBack() {
|
2145
|
+
if (history.length > 0) {
|
2146
|
+
var lastPage = history[history.length - 1];
|
2147
|
+
setHistory(function (prev) {
|
2148
|
+
return prev.slice(0, -1);
|
2149
|
+
}); // 🔹 Elimina la última entrada del historial
|
2150
|
+
setPage(lastPage); // 🔹 Vuelve a la página anterior
|
2151
|
+
window.history.back(); // 🔹 Regresa en la navegación del navegador
|
2152
|
+
}
|
2107
2153
|
},
|
2108
2154
|
dialog: dialog,
|
2109
2155
|
openDialog: function openDialog(dialog) {
|
@@ -2261,20 +2307,15 @@ var SiteMenu = function SiteMenu(_ref6) {
|
|
2261
2307
|
context.setShowNav(false);
|
2262
2308
|
context["goto"](id);
|
2263
2309
|
};
|
2264
|
-
var sections =
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
icon: icon,
|
2274
|
-
title: title
|
2275
|
-
});
|
2276
|
-
return sections;
|
2277
|
-
}, {}) : {};
|
2310
|
+
var sections = React.useMemo(function () {
|
2311
|
+
return children.reduce(function (acc, child) {
|
2312
|
+
var section = child.props.section || "";
|
2313
|
+
if (!acc[section]) acc[section] = [];
|
2314
|
+
var title = child.props.title;
|
2315
|
+
if (title) acc[section].push(child.props);
|
2316
|
+
return acc;
|
2317
|
+
}, {});
|
2318
|
+
}, [children]);
|
2278
2319
|
var style = sideNav === 'max' ? 'max' : 'min';
|
2279
2320
|
var toggleIcon = sideNav === 'max' ? 'chevron_left' : 'chevron_right';
|
2280
2321
|
var menutTitle = sideNav === 'max' ? title : '';
|