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.
@@ -3,6 +3,7 @@ import React, { useContext, useState, useEffect, useCallback, Fragment, useRef,
3
3
  import ResumableJS from 'resumablejs';
4
4
  import RSwitch from 'react-switch';
5
5
  import { Store, ReactNotifications } from 'react-notifications-component';
6
+ import { AnimatePresence, motion } from 'framer-motion';
6
7
  import 'react-notifications-component/dist/theme.css';
7
8
  import moment$1 from 'moment';
8
9
  import { extendMoment } from 'moment-range';
@@ -3338,6 +3339,75 @@ var Page = function Page(props) {
3338
3339
  }, children));
3339
3340
  };
3340
3341
 
3342
+ /**
3343
+ * Use Hash Page
3344
+ */
3345
+ function useHashPage(defaultPage) {
3346
+ if (defaultPage === void 0) {
3347
+ defaultPage = "home";
3348
+ }
3349
+ var getCurrentPageFromURL = function getCurrentPageFromURL() {
3350
+ var hash = window.location.hash.replace("#", "");
3351
+ return hash || defaultPage;
3352
+ };
3353
+ var _useState = useState(getCurrentPageFromURL()),
3354
+ page = _useState[0],
3355
+ setPage = _useState[1];
3356
+ var _useState2 = useState([]),
3357
+ history = _useState2[0],
3358
+ setHistory = _useState2[1];
3359
+ var _useState3 = useState("left"),
3360
+ setDirection = _useState3[1];
3361
+ var isFirstLoad = useRef(true);
3362
+ useEffect(function () {
3363
+ var handleHashChange = function handleHashChange() {
3364
+ var newPage = getCurrentPageFromURL();
3365
+ if (!isFirstLoad.current) {
3366
+ setHistory(function (prev) {
3367
+ return [].concat(prev, [page]);
3368
+ }); // Guarda la página anterior
3369
+ } else {
3370
+ isFirstLoad.current = false;
3371
+ }
3372
+ setPage(newPage);
3373
+ };
3374
+ window.addEventListener("hashchange", handleHashChange);
3375
+ return function () {
3376
+ return window.removeEventListener("hashchange", handleHashChange);
3377
+ };
3378
+ }, [page]);
3379
+ var _goto = function _goto(id, dir) {
3380
+ if (dir === void 0) {
3381
+ dir = "left";
3382
+ }
3383
+ if (page) {
3384
+ setHistory(function (prev) {
3385
+ return [].concat(prev, [page]);
3386
+ });
3387
+ }
3388
+ setDirection(dir);
3389
+ setPage(id);
3390
+ window.location.hash = id;
3391
+ };
3392
+ var goBack = function goBack() {
3393
+ if (history.length > 0) {
3394
+ var lastPage = history[history.length - 1];
3395
+ setHistory(function (prev) {
3396
+ return prev.slice(0, -1);
3397
+ });
3398
+ setDirection("right");
3399
+ setPage(lastPage);
3400
+ window.location.hash = lastPage;
3401
+ }
3402
+ };
3403
+ return {
3404
+ page: page,
3405
+ "goto": _goto,
3406
+ goBack: goBack,
3407
+ history: history
3408
+ };
3409
+ }
3410
+
3341
3411
  /**
3342
3412
  * Site Provider
3343
3413
  */
@@ -3378,30 +3448,10 @@ var SiteProvider = function SiteProvider(_ref) {
3378
3448
  var _useState11 = useState(),
3379
3449
  breadcrumb = _useState11[0],
3380
3450
  setBreadcrumb = _useState11[1];
3381
- var _useState12 = useState([]),
3382
- history = _useState12[0],
3383
- setHistory = _useState12[1];
3384
-
3385
- // 📌 Extraer la página actual desde la URL (por defecto "home")
3386
- var getCurrentPageFromURL = function getCurrentPageFromURL() {
3387
- var path = window.location.pathname.replace("/", "");
3388
- return path || "home";
3389
- };
3390
- var _useState13 = useState(getCurrentPageFromURL()),
3391
- page = _useState13[0],
3392
- setPage = _useState13[1];
3393
- useEffect(function () {
3394
- // 📌 Detectar cambios en la URL cuando el usuario presiona "Atrás" o "Adelante"
3395
- var handlePopState = function handlePopState(event) {
3396
- var _event$state;
3397
- var previousPage = ((_event$state = event.state) == null ? void 0 : _event$state.page) || "home";
3398
- setPage(previousPage);
3399
- };
3400
- window.addEventListener("popstate", handlePopState);
3401
- return function () {
3402
- return window.removeEventListener("popstate", handlePopState);
3403
- };
3404
- }, []);
3451
+ var _useHashPage = useHashPage(),
3452
+ page = _useHashPage.page,
3453
+ _goto = _useHashPage["goto"],
3454
+ goBack = _useHashPage.goBack;
3405
3455
  var value = {
3406
3456
  lang: lang,
3407
3457
  setLang: setLang,
@@ -3411,15 +3461,6 @@ var SiteProvider = function SiteProvider(_ref) {
3411
3461
  var _dictionary$key;
3412
3462
  return (dictionary == null ? void 0 : (_dictionary$key = dictionary[key]) == null ? void 0 : _dictionary$key[lang]) || key;
3413
3463
  }, [lang, dictionary]),
3414
- /*
3415
- translate: (key) => {
3416
- if (!key) return key
3417
- if (dictionary === undefined) return key
3418
- const term = dictionary[key]
3419
- return term ? term[lang] : key
3420
- },
3421
- */
3422
-
3423
3464
  sideNav: sideNav,
3424
3465
  setSideNav: setSideNav,
3425
3466
  showNav: showNav,
@@ -3446,27 +3487,8 @@ var SiteProvider = function SiteProvider(_ref) {
3446
3487
  breadcrumb: breadcrumb,
3447
3488
  setBreadcrumb: setBreadcrumb,
3448
3489
  page: page,
3449
- "goto": function goto(id) {
3450
- if (page) {
3451
- setHistory(function (prev) {
3452
- return [].concat(prev, [page]);
3453
- }); // 🔹 Guarda la página actual en el historial antes de cambiar
3454
- }
3455
- setPage(id);
3456
- window.history.pushState({
3457
- page: id
3458
- }, "", "/" + id); // 🔹 Actualiza la URL
3459
- },
3460
- goBack: function goBack() {
3461
- if (history.length > 0) {
3462
- var lastPage = history[history.length - 1];
3463
- setHistory(function (prev) {
3464
- return prev.slice(0, -1);
3465
- }); // 🔹 Elimina la última entrada del historial
3466
- setPage(lastPage); // 🔹 Vuelve a la página anterior
3467
- window.history.back(); // 🔹 Regresa en la navegación del navegador
3468
- }
3469
- },
3490
+ "goto": _goto,
3491
+ goBack: goBack,
3470
3492
  dialog: dialog,
3471
3493
  openDialog: function openDialog(dialog) {
3472
3494
  setDialog(dialog);
@@ -3619,7 +3641,7 @@ var SiteMenu = function SiteMenu(_ref6) {
3619
3641
  var next = sideNav === 'max' ? 'min' : 'max';
3620
3642
  setSideNav(next);
3621
3643
  }
3622
- var _goto = function _goto(id) {
3644
+ var _goto2 = function _goto2(id) {
3623
3645
  context.setShowNav(false);
3624
3646
  context["goto"](id);
3625
3647
  };
@@ -3657,7 +3679,7 @@ var SiteMenu = function SiteMenu(_ref6) {
3657
3679
  className: "site-menu-item " + styleItem,
3658
3680
  key: id,
3659
3681
  onClick: function onClick() {
3660
- return _goto(id);
3682
+ return _goto2(id);
3661
3683
  }
3662
3684
  }, /*#__PURE__*/React.createElement(Tooltip, {
3663
3685
  text: title,
@@ -3668,7 +3690,7 @@ var SiteMenu = function SiteMenu(_ref6) {
3668
3690
  icon: icon,
3669
3691
  clickable: true,
3670
3692
  action: function action() {
3671
- return _goto(id);
3693
+ return _goto2(id);
3672
3694
  }
3673
3695
  })), sideNav === 'max' ? /*#__PURE__*/React.createElement("label", null, titleTxt) : null);
3674
3696
  }), /*#__PURE__*/React.createElement("div", {
@@ -3688,7 +3710,8 @@ var SitePage = function SitePage(_ref8) {
3688
3710
  var children = _ref8.children,
3689
3711
  init = _ref8.init;
3690
3712
  var context = useContext(SiteContext);
3691
- var page = context.page;
3713
+ var page = context.page,
3714
+ direction = context.direction;
3692
3715
  useEffect(function () {
3693
3716
  if (init) {
3694
3717
  context["goto"](init);
@@ -3696,9 +3719,32 @@ var SitePage = function SitePage(_ref8) {
3696
3719
  context["goto"]("EMPTY");
3697
3720
  }
3698
3721
  }, []);
3699
- return /*#__PURE__*/React.createElement("main", null, React.Children.toArray(children).filter(function (child) {
3722
+ var currentPage = React.Children.toArray(children).filter(function (child) {
3700
3723
  return child.props ? child.props.id === page : false;
3701
- }));
3724
+ });
3725
+ var xOffset = direction === "left" ? 40 : -40;
3726
+ return /*#__PURE__*/React.createElement("main", {
3727
+ className: "site-page-container"
3728
+ }, /*#__PURE__*/React.createElement(AnimatePresence, {
3729
+ exitBeforeEnter: true
3730
+ }, currentPage && /*#__PURE__*/React.createElement(motion.div, {
3731
+ key: page,
3732
+ initial: {
3733
+ opacity: 0,
3734
+ x: xOffset
3735
+ },
3736
+ animate: {
3737
+ opacity: 1,
3738
+ x: 0
3739
+ },
3740
+ exit: {
3741
+ opacity: 0,
3742
+ x: -xOffset
3743
+ },
3744
+ transition: {
3745
+ duration: 0.3
3746
+ }
3747
+ }, currentPage)));
3702
3748
  };
3703
3749
 
3704
3750
  /**
@@ -3867,6 +3913,36 @@ var TabbedView = function TabbedView(props) {
3867
3913
  }, children));
3868
3914
  };
3869
3915
 
3916
+ /**
3917
+ * PageLink - Navegación declarativa usando el sistema de hash
3918
+ *
3919
+ * Props:
3920
+ * - page: string → ID de la página a mostrar
3921
+ * - children: ReactNode → contenido visual del enlace
3922
+ * - className: string → clases opcionales
3923
+ * - style: object → estilos en línea opcionales
3924
+ */
3925
+ var PageLink = function PageLink(_ref) {
3926
+ var page = _ref.page,
3927
+ children = _ref.children,
3928
+ _ref$className = _ref.className,
3929
+ className = _ref$className === void 0 ? '' : _ref$className,
3930
+ _ref$style = _ref.style,
3931
+ style = _ref$style === void 0 ? {} : _ref$style;
3932
+ var _useContext = useContext(SiteContext),
3933
+ _goto2 = _useContext["goto"];
3934
+ var handleClick = function handleClick(e) {
3935
+ e.preventDefault();
3936
+ _goto2(page);
3937
+ };
3938
+ return /*#__PURE__*/React.createElement("a", {
3939
+ href: "#" + page,
3940
+ onClick: handleClick,
3941
+ className: className,
3942
+ style: style
3943
+ }, children);
3944
+ };
3945
+
3870
3946
  /**
3871
3947
  * Admin Change User Password Dialog
3872
3948
  */
@@ -12765,5 +12841,5 @@ var isFunction = function isFunction(value) {
12765
12841
  return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
12766
12842
  };
12767
12843
 
12768
- export { Accordion, ActionButton, Avatar, Button, Calendar, ChangeUserPasswordAction, ChangeUserPasswordDialog, CheckBox, Chip, Chips, CircularProgress, CollectionAPI$1 as CollectionAPI, CollectionAPI as CollectionAPI2, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FileExplorerView, FileGridItem, FilesGridView, FilesSearchBox, FilesTableView, FoldersTreeView, ForgetUserPasswordAction, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, KanbanHeader, KanbanSwimlane, LOGIN_API, LOGIN_CONTEXT, LOGIN_DICTIONARY, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MonthCalendar, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Planner2, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, Switch2, TASK_STATES, TEXTFORMATS, TYPES$1 as TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UnlockUserAction, UploadArea, UploadDialog, UploadFile$1 as UploadFile, UploadForm, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction, validatePassword };
12844
+ export { Accordion, ActionButton, Avatar, Button, Calendar, ChangeUserPasswordAction, ChangeUserPasswordDialog, CheckBox, Chip, Chips, CircularProgress, CollectionAPI$1 as CollectionAPI, CollectionAPI as CollectionAPI2, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FileExplorerView, FileGridItem, FilesGridView, FilesSearchBox, FilesTableView, FoldersTreeView, ForgetUserPasswordAction, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, KanbanHeader, KanbanSwimlane, LOGIN_API, LOGIN_CONTEXT, LOGIN_DICTIONARY, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MonthCalendar, MultiSelector, Page, PageContext, PageLink, PageProvider, PasswordEditor, PasswordField, Planner, Planner2, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, Switch2, TASK_STATES, TEXTFORMATS, TYPES$1 as TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UnlockUserAction, UploadArea, UploadDialog, UploadFile$1 as UploadFile, UploadForm, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction, validatePassword };
12769
12845
  //# sourceMappingURL=index.modern.js.map