ywana-core8 0.1.55 → 0.1.57

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.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('material-design-icons-iconfont/dist/material-design-icons.css'), require('react'), require('resumablejs'), require('react-switch'), require('react-notifications-component'), require('react-notifications-component/dist/theme.css'), require('moment'), require('moment-range'), require('moment/locale/es'), require('axios'), require('deep-equal')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'material-design-icons-iconfont/dist/material-design-icons.css', 'react', 'resumablejs', 'react-switch', 'react-notifications-component', 'react-notifications-component/dist/theme.css', 'moment', 'moment-range', 'moment/locale/es', 'axios', 'deep-equal'], factory) :
4
- (global = global || self, factory(global.ywanaCore8 = {}, null, global.react, global.resumablejs, global.reactSwitch, global.reactNotificationsComponent, null, global.moment, global.momentRange, null, global.axios, global.deepEqual));
5
- })(this, (function (exports, materialDesignIcons_css, React, ResumableJS, RSwitch, reactNotificationsComponent, theme_css, moment$1, momentRange, es, axios, equal) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('material-design-icons-iconfont/dist/material-design-icons.css'), require('react'), require('resumablejs'), require('react-switch'), require('react-notifications-component'), require('framer-motion'), require('react-notifications-component/dist/theme.css'), require('moment'), require('moment-range'), require('moment/locale/es'), require('axios'), require('deep-equal')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'material-design-icons-iconfont/dist/material-design-icons.css', 'react', 'resumablejs', 'react-switch', 'react-notifications-component', 'framer-motion', 'react-notifications-component/dist/theme.css', 'moment', 'moment-range', 'moment/locale/es', 'axios', 'deep-equal'], factory) :
4
+ (global = global || self, factory(global.ywanaCore8 = {}, null, global.react, global.resumablejs, global.reactSwitch, global.reactNotificationsComponent, global.framerMotion, null, global.moment, global.momentRange, null, global.axios, global.deepEqual));
5
+ })(this, (function (exports, materialDesignIcons_css, React, ResumableJS, RSwitch, reactNotificationsComponent, framerMotion, theme_css, moment$1, momentRange, es, axios, equal) {
6
6
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
7
 
8
8
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
@@ -3340,6 +3340,75 @@
3340
3340
  }, children));
3341
3341
  };
3342
3342
 
3343
+ /**
3344
+ * Use Hash Page
3345
+ */
3346
+ function useHashPage(defaultPage) {
3347
+ if (defaultPage === void 0) {
3348
+ defaultPage = "home";
3349
+ }
3350
+ var getCurrentPageFromURL = function getCurrentPageFromURL() {
3351
+ var hash = window.location.hash.replace("#", "");
3352
+ return hash || defaultPage;
3353
+ };
3354
+ var _useState = React.useState(getCurrentPageFromURL()),
3355
+ page = _useState[0],
3356
+ setPage = _useState[1];
3357
+ var _useState2 = React.useState([]),
3358
+ history = _useState2[0],
3359
+ setHistory = _useState2[1];
3360
+ var _useState3 = React.useState("left"),
3361
+ setDirection = _useState3[1];
3362
+ var isFirstLoad = React.useRef(true);
3363
+ React.useEffect(function () {
3364
+ var handleHashChange = function handleHashChange() {
3365
+ var newPage = getCurrentPageFromURL();
3366
+ if (!isFirstLoad.current) {
3367
+ setHistory(function (prev) {
3368
+ return [].concat(prev, [page]);
3369
+ }); // Guarda la página anterior
3370
+ } else {
3371
+ isFirstLoad.current = false;
3372
+ }
3373
+ setPage(newPage);
3374
+ };
3375
+ window.addEventListener("hashchange", handleHashChange);
3376
+ return function () {
3377
+ return window.removeEventListener("hashchange", handleHashChange);
3378
+ };
3379
+ }, [page]);
3380
+ var _goto = function _goto(id, dir) {
3381
+ if (dir === void 0) {
3382
+ dir = "left";
3383
+ }
3384
+ if (page) {
3385
+ setHistory(function (prev) {
3386
+ return [].concat(prev, [page]);
3387
+ });
3388
+ }
3389
+ setDirection(dir);
3390
+ setPage(id);
3391
+ window.location.hash = id;
3392
+ };
3393
+ var goBack = function goBack() {
3394
+ if (history.length > 0) {
3395
+ var lastPage = history[history.length - 1];
3396
+ setHistory(function (prev) {
3397
+ return prev.slice(0, -1);
3398
+ });
3399
+ setDirection("right");
3400
+ setPage(lastPage);
3401
+ window.location.hash = lastPage;
3402
+ }
3403
+ };
3404
+ return {
3405
+ page: page,
3406
+ "goto": _goto,
3407
+ goBack: goBack,
3408
+ history: history
3409
+ };
3410
+ }
3411
+
3343
3412
  /**
3344
3413
  * Site Provider
3345
3414
  */
@@ -3380,30 +3449,10 @@
3380
3449
  var _useState11 = React.useState(),
3381
3450
  breadcrumb = _useState11[0],
3382
3451
  setBreadcrumb = _useState11[1];
3383
- var _useState12 = React.useState([]),
3384
- history = _useState12[0],
3385
- setHistory = _useState12[1];
3386
-
3387
- // 📌 Extraer la página actual desde la URL (por defecto "home")
3388
- var getCurrentPageFromURL = function getCurrentPageFromURL() {
3389
- var path = window.location.pathname.replace("/", "");
3390
- return path || "home";
3391
- };
3392
- var _useState13 = React.useState(getCurrentPageFromURL()),
3393
- page = _useState13[0],
3394
- setPage = _useState13[1];
3395
- React.useEffect(function () {
3396
- // 📌 Detectar cambios en la URL cuando el usuario presiona "Atrás" o "Adelante"
3397
- var handlePopState = function handlePopState(event) {
3398
- var _event$state;
3399
- var previousPage = ((_event$state = event.state) == null ? void 0 : _event$state.page) || "home";
3400
- setPage(previousPage);
3401
- };
3402
- window.addEventListener("popstate", handlePopState);
3403
- return function () {
3404
- return window.removeEventListener("popstate", handlePopState);
3405
- };
3406
- }, []);
3452
+ var _useHashPage = useHashPage(),
3453
+ page = _useHashPage.page,
3454
+ _goto = _useHashPage["goto"],
3455
+ goBack = _useHashPage.goBack;
3407
3456
  var value = {
3408
3457
  lang: lang,
3409
3458
  setLang: setLang,
@@ -3413,15 +3462,6 @@
3413
3462
  var _dictionary$key;
3414
3463
  return (dictionary == null ? void 0 : (_dictionary$key = dictionary[key]) == null ? void 0 : _dictionary$key[lang]) || key;
3415
3464
  }, [lang, dictionary]),
3416
- /*
3417
- translate: (key) => {
3418
- if (!key) return key
3419
- if (dictionary === undefined) return key
3420
- const term = dictionary[key]
3421
- return term ? term[lang] : key
3422
- },
3423
- */
3424
-
3425
3465
  sideNav: sideNav,
3426
3466
  setSideNav: setSideNav,
3427
3467
  showNav: showNav,
@@ -3448,27 +3488,8 @@
3448
3488
  breadcrumb: breadcrumb,
3449
3489
  setBreadcrumb: setBreadcrumb,
3450
3490
  page: page,
3451
- "goto": function goto(id) {
3452
- if (page) {
3453
- setHistory(function (prev) {
3454
- return [].concat(prev, [page]);
3455
- }); // 🔹 Guarda la página actual en el historial antes de cambiar
3456
- }
3457
- setPage(id);
3458
- window.history.pushState({
3459
- page: id
3460
- }, "", "/" + id); // 🔹 Actualiza la URL
3461
- },
3462
- goBack: function goBack() {
3463
- if (history.length > 0) {
3464
- var lastPage = history[history.length - 1];
3465
- setHistory(function (prev) {
3466
- return prev.slice(0, -1);
3467
- }); // 🔹 Elimina la última entrada del historial
3468
- setPage(lastPage); // 🔹 Vuelve a la página anterior
3469
- window.history.back(); // 🔹 Regresa en la navegación del navegador
3470
- }
3471
- },
3491
+ "goto": _goto,
3492
+ goBack: goBack,
3472
3493
  dialog: dialog,
3473
3494
  openDialog: function openDialog(dialog) {
3474
3495
  setDialog(dialog);
@@ -3621,7 +3642,7 @@
3621
3642
  var next = sideNav === 'max' ? 'min' : 'max';
3622
3643
  setSideNav(next);
3623
3644
  }
3624
- var _goto = function _goto(id) {
3645
+ var _goto2 = function _goto2(id) {
3625
3646
  context.setShowNav(false);
3626
3647
  context["goto"](id);
3627
3648
  };
@@ -3659,7 +3680,7 @@
3659
3680
  className: "site-menu-item " + styleItem,
3660
3681
  key: id,
3661
3682
  onClick: function onClick() {
3662
- return _goto(id);
3683
+ return _goto2(id);
3663
3684
  }
3664
3685
  }, /*#__PURE__*/React__default["default"].createElement(Tooltip, {
3665
3686
  text: title,
@@ -3670,7 +3691,7 @@
3670
3691
  icon: icon,
3671
3692
  clickable: true,
3672
3693
  action: function action() {
3673
- return _goto(id);
3694
+ return _goto2(id);
3674
3695
  }
3675
3696
  })), sideNav === 'max' ? /*#__PURE__*/React__default["default"].createElement("label", null, titleTxt) : null);
3676
3697
  }), /*#__PURE__*/React__default["default"].createElement("div", {
@@ -3690,7 +3711,8 @@
3690
3711
  var children = _ref8.children,
3691
3712
  init = _ref8.init;
3692
3713
  var context = React.useContext(SiteContext);
3693
- var page = context.page;
3714
+ var page = context.page,
3715
+ direction = context.direction;
3694
3716
  React.useEffect(function () {
3695
3717
  if (init) {
3696
3718
  context["goto"](init);
@@ -3698,9 +3720,32 @@
3698
3720
  context["goto"]("EMPTY");
3699
3721
  }
3700
3722
  }, []);
3701
- return /*#__PURE__*/React__default["default"].createElement("main", null, React__default["default"].Children.toArray(children).filter(function (child) {
3723
+ var currentPage = React__default["default"].Children.toArray(children).filter(function (child) {
3702
3724
  return child.props ? child.props.id === page : false;
3703
- }));
3725
+ });
3726
+ var xOffset = direction === "left" ? 40 : -40;
3727
+ return /*#__PURE__*/React__default["default"].createElement("main", {
3728
+ className: "site-page-container"
3729
+ }, /*#__PURE__*/React__default["default"].createElement(framerMotion.AnimatePresence, {
3730
+ exitBeforeEnter: true
3731
+ }, currentPage && /*#__PURE__*/React__default["default"].createElement(framerMotion.motion.div, {
3732
+ key: page,
3733
+ initial: {
3734
+ opacity: 0,
3735
+ x: xOffset
3736
+ },
3737
+ animate: {
3738
+ opacity: 1,
3739
+ x: 0
3740
+ },
3741
+ exit: {
3742
+ opacity: 0,
3743
+ x: -xOffset
3744
+ },
3745
+ transition: {
3746
+ duration: 0.3
3747
+ }
3748
+ }, currentPage)));
3704
3749
  };
3705
3750
 
3706
3751
  /**
@@ -3869,6 +3914,36 @@
3869
3914
  }, children));
3870
3915
  };
3871
3916
 
3917
+ /**
3918
+ * PageLink - Navegación declarativa usando el sistema de hash
3919
+ *
3920
+ * Props:
3921
+ * - page: string → ID de la página a mostrar
3922
+ * - children: ReactNode → contenido visual del enlace
3923
+ * - className: string → clases opcionales
3924
+ * - style: object → estilos en línea opcionales
3925
+ */
3926
+ var PageLink = function PageLink(_ref) {
3927
+ var page = _ref.page,
3928
+ children = _ref.children,
3929
+ _ref$className = _ref.className,
3930
+ className = _ref$className === void 0 ? '' : _ref$className,
3931
+ _ref$style = _ref.style,
3932
+ style = _ref$style === void 0 ? {} : _ref$style;
3933
+ var _useContext = React.useContext(SiteContext),
3934
+ _goto2 = _useContext["goto"];
3935
+ var handleClick = function handleClick(e) {
3936
+ e.preventDefault();
3937
+ _goto2(page);
3938
+ };
3939
+ return /*#__PURE__*/React__default["default"].createElement("a", {
3940
+ href: "#" + page,
3941
+ onClick: handleClick,
3942
+ className: className,
3943
+ style: style
3944
+ }, children);
3945
+ };
3946
+
3872
3947
  /**
3873
3948
  * Admin Change User Password Dialog
3874
3949
  */
@@ -12835,6 +12910,7 @@
12835
12910
  exports.MultiSelector = MultiSelector;
12836
12911
  exports.Page = Page;
12837
12912
  exports.PageContext = PageContext;
12913
+ exports.PageLink = PageLink;
12838
12914
  exports.PageProvider = PageProvider;
12839
12915
  exports.PasswordEditor = PasswordEditor;
12840
12916
  exports.PasswordField = PasswordField;